37 static inline unsigned short calculateCRC(
unsigned char data[],
unsigned int length)
40 unsigned short crc = 0;
41 for (i = 0; i < length; i++) {
42 crc = (
unsigned char)(crc >> 8) | (crc << 8);
44 crc ^= (
unsigned char)(crc & 0xff) >> 4;
46 crc ^= (crc & 0x00ff) << 5;
58 unsigned short rec_crc = (
unsigned short)(data[length] << 8 | data[length + 1]);
61 if (calc_crc == rec_crc) {
uint8_t uart_getch(struct uart_periph *p)
uint16_t uart_char_available(struct uart_periph *p)
Check UART for available chars in receive buffer.
void vn200_parse(struct VNPacket *vnp, uint8_t c)
Packet Collection & state machine.
void vn200_event(struct VNPacket *vnp)
static void vn200_read_buffer(struct VNPacket *vnp)
Vectornav VN-200 INS subsystem.
static unsigned short calculateCRC(unsigned char data[], unsigned int length)
Calculates the 16-bit CRC for the given ASCII or binary message.
static bool verify_chk(unsigned char data[], unsigned int length, uint16_t *calc_chk, uint16_t *rec_chk)
Verify checksum.
uint8_t msg_buf[VN_BUFFER_SIZE]