17 #include "em_device.h"
26 #include "rtcdriver.h"
160 const char connect[] = { 0x02, 0x06, 0x06, 0x00, 0xBB, 0x04, 0x20, 0xDA, 0x18, 0x00, 0x5F };
161 for (
int i=0 ; i <
sizeof(connect) ; i++ )
163 USART_Tx(USART1, connect[i]);
198 const char disconnect[] = { 0x02, 0x07, 0x00, 0x00, 0x05 };
199 for (
int i=0 ; i <
sizeof(disconnect) ; i++ )
201 USART_Tx(USART1, disconnect[i]);
218 uint8_t
data[9] = {0x02, 0x04, 0x04, 0x00 };
223 data[4+d] = data_in[d];
229 uint8_t checksum = 0x00;
230 for (
int j=0;j<(
sizeof(
data)/
sizeof(uint8_t));j++)
232 checksum = checksum^
data[j];
239 for (
int i = 0; i < 9; i++)
241 USART_Tx(USART1,
data[i]);
263 int ble_packet_length = length + 5;
269 ble_data[2] = length;
274 ble_data[4+d] =
data[d];
278 ble_data[ble_packet_length-2] = batt[0];
281 uint8_t checksum = 0x00;
282 for (
int j=0;j<(ble_packet_length-1);j++)
284 checksum = checksum^ble_data[j];
287 ble_data[ble_packet_length-1] = checksum;
340 char data[23] = { 0x02, 0x04, 0x06, 0x00 };
345 data[4+d] = gyroData[d];
351 data[10+d] = accelData[d];
357 data[16+d] = magnData[d];
362 char checksum = 0x00;
363 for (
int j=0;j<(
sizeof(
data)/
sizeof(
char));j++)
365 checksum = checksum^
data[j];
372 for (
int i = 0; i < 23; i++)
374 USART_Tx(USART1,
data[i]);
395 uint8_t bytes[
sizeof(float)];
400 for(
int i=0; i<
sizeof(float); i++)
402 out[i] = thing.bytes[i];
454 uint8_t checksum = 0x00;
455 for (
int j=0;j<(7-1);j++)
457 checksum = checksum^
data[j];
460 data[len-1] = checksum;