5 #define PACKET_ESCAPE (uint8_t) 0xff 8 void try_dispatch_received_packet();
9 void USART_SendByte(uint8_t u8Data);
10 void ub_init_infrastructure();
17 uint8_t crc8(uint8_t* data, uint8_t length)
24 v = (data[i] ^ crc) & 0xff;
58 ub_init_infrastructure();
78 void ub_out_rec_byte(
struct uartbus* bus, uint16_t data)
80 if(data < 0 || data > 255)
91 if(received_ep >= MAX_PACKET_SIZE)
100 if(b == (uint8_t)~PACKET_ESCAPE)
107 received_data[received_ep++] = b;
113 if(b == (uint8_t)PACKET_ESCAPE)
119 received_data[received_ep++] = b;
124 void try_send_packet()
128 for(uint8_t i=0;i<send_size;++i)
130 uint8_t val = send_data[i];
131 if(PACKET_ESCAPE == val)
133 USART_SendByte((uint8_t)PACKET_ESCAPE);
137 USART_SendByte((uint8_t)PACKET_ESCAPE);
138 USART_SendByte((uint8_t)~PACKET_ESCAPE);
145 void ubh_manage_bus()
148 try_dispatch_received_packet();