Added ping sensor data to the system
This commit is contained in:
parent
3c10f7b4de
commit
dce78c05f5
@ -37,12 +37,24 @@ typedef struct gps_data_t {
|
||||
uint8_t crc;
|
||||
} gps_data_t;
|
||||
|
||||
/***********************************************************************
|
||||
* BRIEF: RX packet structure from arduino com *
|
||||
* INFORMATION: Contains the whole ping sensor data message *
|
||||
***********************************************************************/
|
||||
typedef struct ping_data_t {
|
||||
uint8_t header;
|
||||
uint16_t distance_mm;
|
||||
uint8_t crc;
|
||||
}ping_data_t;
|
||||
|
||||
/* An instance of the GPS data read from Arduino Com */
|
||||
gps_data_t gps_data;
|
||||
|
||||
/* An instance of the compass data read from Arduino Com */
|
||||
compass_data_t compass_data;
|
||||
|
||||
/* An instance of the ping data read from Arduino Com */
|
||||
ping_data_t ping_data;
|
||||
|
||||
/***********************************************************************
|
||||
* BRIEF: Initializes the UART for Arduino com *
|
||||
|
@ -13,6 +13,7 @@
|
||||
|
||||
#define COMPASS_PACKET_SIZE 8
|
||||
#define GPS_PACKET_SIZE 10
|
||||
#define PING_PACKET_SIZE 4
|
||||
#define ARDUINO_SENSOR_SIZE 6
|
||||
|
||||
typedef struct arduino_sensor_t {
|
||||
@ -56,6 +57,7 @@ dma_usart_return raw_dma_data_t;
|
||||
enum packet_ids {
|
||||
COMPASS_PACKET_ID = 0xA1,
|
||||
GPS_PACKET_ID = 0xB1,
|
||||
PING_PACKET_ID = 0xC1,
|
||||
};
|
||||
|
||||
// Structure used to hold the data for "data_arr"
|
||||
@ -68,6 +70,7 @@ typedef struct arduino_data_t {
|
||||
enum arduino_data_e {
|
||||
COMPASS_DATA_ID,
|
||||
GPS_DATA_ID,
|
||||
PING_DATA_ID,
|
||||
ARDUINO_DATA_COUNT,
|
||||
};
|
||||
|
||||
@ -81,6 +84,10 @@ arduino_data_t data_arr[ARDUINO_DATA_COUNT] = {
|
||||
.size = GPS_PACKET_SIZE,
|
||||
.dataPtr = &gps_data,
|
||||
},
|
||||
[PING_DATA_ID] = {
|
||||
.size = PING_PACKET_SIZE,
|
||||
.dataPtr = &ping_data,
|
||||
},
|
||||
};
|
||||
|
||||
|
||||
@ -144,6 +151,9 @@ arduino_data_t find_packet_from_header(uint8_t header)
|
||||
case GPS_PACKET_ID:
|
||||
arduino_data = data_arr[GPS_DATA_ID];
|
||||
break;
|
||||
case PING_PACKET_ID:
|
||||
arduino_data = data_arr[PING_DATA_ID];
|
||||
break;
|
||||
default:
|
||||
break;
|
||||
}
|
||||
|
Reference in New Issue
Block a user