Пример #1
0
ICACHE_FLASH_ATTR
void CMD_ProtoWrite(uint8_t data)
{
	switch(data){
	case SLIP_START:
	case SLIP_END:
	case SLIP_REPL:
		uart0_write(SLIP_REPL);
		uart0_write(SLIP_ESC(data));
		break;
	default:
		uart0_write(data);
	}
}
Пример #2
0
void
collect_common_recv(const rimeaddr_t *originator, uint8_t seqno, uint8_t hops,
                    uint8_t *payload, uint16_t payload_len)//originator 发起人; seqno 序号,序列号,成交回报的广播序号; hops 跳数; payload 有效载荷;
{
  int i;
  uint8_t fcs = 0;
  uint8_t data_len = 0;
  
  // output data to UART
  //0xA5+LEN(0,1)+SenderADDR(1,2)+TEMP(3,1)+VOLTAGE(4,1)+parentAddr(5,2) + FCS(7,1)
  mt_packet[0]=0xA5;
  mt_packet[1]=6; // 去掉 0xA5,LEN,FCS这几个字段长度
  data_len = mt_packet[1] + 3;
  mt_packet[2]=originator->u8[0]; //数据发送节点的地址
  mt_packet[3]=originator->u8[1];
  mt_packet[4]= *(payload+28); //msg->sensors[TEMP_SENSOR]
  mt_packet[5]= *(payload+24); //msg->sensors[BATTERY_VOLTAGE_SENSOR]
  mt_packet[6]= *(payload+14); // parent addr, Low byte
  mt_packet[7]= *(payload+15); // parent addr, high byte
  
  for(i=1;i<(data_len-1); i++) {
  fcs = fcs ^ mt_packet[i];
  }
  mt_packet[8]= fcs; 
    
  // put HEX data to uart0
  uart0_write(&mt_packet[0],data_len);  
}
Пример #3
0
ICACHE_FLASH_ATTR
uint16_t CMD_ResponseEnd(uint16_t crc)
{
	CMD_ProtoWriteBuf((uint8_t*)&crc, 2);
	uart0_write(SLIP_END);
	return 0;
}
Пример #4
0
int __sys_write(int iFileHandle, char *pcBuffer, int iLength) {
	if (iFileHandle == 1) {
		// stderr totally doesn't work
		uart0_write((const uint8_t*) pcBuffer, iLength);
		logging_log_persistent(pcBuffer, iLength);
	}
	return 0;
}
Пример #5
0
void data_abort (void)
{
    register volatile char *r_14 asm ("r14");
    long prev_pc = (long) r_14 - 8;
    uart0_write ("data abort!\r\n");
    uart0_write_hex (prev_pc);
    // XXX: register dump

    panic_blink(3);
}
Пример #6
0
void prefetch_abort (void)
{
    register volatile char *r_14 asm ("r14");
    long prev_pc = (long) r_14 - 4;
    uart0_write ("prefetch abort!\r\n");
    uart0_write_hex (prev_pc);
    // XXX: register dump

    panic_blink(2);
}
Пример #7
0
void data_abort (long r_0, long r_1, long r_2, long r_3,
		 long spsr,
		 long r_4, long r_5, long r_6, long r_7,
		 long r_8, long r_9, long r_10, long r_11,
		 long r_12, long prev_pc)
{
    uart0_write ("data abort!\r\n");
    DUMP_REGS()

    panic_blink(1500);
}
Пример #8
0
void prefetch_abort (long r_0, long r_1, long r_2, long r_3,
		     long spsr,
		     long r_4, long r_5, long r_6, long r_7,
		     long r_8, long r_9, long r_10, long r_11,
		     long r_12, long prev_pc)
{
    uart0_write ("prefetch abort!\r\n");
    DUMP_REGS()

    panic_blink(1000);
}
Пример #9
0
ICACHE_FLASH_ATTR
uint16_t CMD_ResponseStart(uint16_t cmd, uint32_t callback, uint32_t _return, uint16_t argc)
{
  uint16_t crc = 0;
  uart0_write(SLIP_START);
  CMD_ProtoWriteBuf((uint8_t*)&cmd, 2);
  crc = crc16_data((uint8_t*)&cmd, 2, crc);
  CMD_ProtoWriteBuf((uint8_t*)&callback, 4);
  crc = crc16_data((uint8_t*)&callback, 4, crc);
  CMD_ProtoWriteBuf((uint8_t*)&_return, 4);
  crc = crc16_data((uint8_t*)&_return, 4, crc);
  CMD_ProtoWriteBuf((uint8_t*)&argc, 2);
  crc = crc16_data((uint8_t*)&argc, 2, crc);
  return crc;
}
Пример #10
0
void send_version()
{
	const char version[] = PROTOCOL_VERSION;
	const uint8_t size = 0x0D;
	uint8_t checksum = IdVersionMessage + size + sequence;

	cli();
	uart0_write(IdVersionMessage);
	uart0_write(size);
	uart0_write(sequence++);

	for (uint8_t i = 0; i < 8; ++i)
	{
		uart0_write(version[i]);
		checksum += version[i];
	}

	uart0_write((uint8_t) TARGET);
	checksum += (uint8_t) TARGET;

	uart0_write(0xFF - checksum);
	sei();
}
Пример #11
0
void swi (void)
{
    uart0_write ("swi!\r\n");
    // XXX: tell us something
    exit (-1);
}
Пример #12
0
void uart0_write_byte(uint8_t Byte)
{
	uart0_write(&Byte, 1);
}
Пример #13
0
void uart0_write_string(const char* str) {
	uart0_write((const uint8_t*) str, strlen(str));
}