LP Long Distance IR Vision Robot
Dependencies: max77650_charger_sample BufferedSerial SX1276GenericLib Adafruit-MotorShield NEO-6m-GPS MAX17055_EZconfig Adafruit_GFX USBDeviceHT Adafruit-PWM-Servo-Driver
Diff: global_buffers.h
- Revision:
- 24:e8d03912f303
- Parent:
- 23:f74a50977593
- Child:
- 25:1a031add188a
--- a/global_buffers.h Wed Jul 18 18:52:30 2018 +0000 +++ b/global_buffers.h Wed Jul 18 21:25:17 2018 +0000 @@ -22,15 +22,73 @@ #define __GLOBAL_BUFFERS_H__ /*************************************************************************** - * Grid Eye Sensor Information + * Indexes for which byte specific data begins at in the payload buffer **************************************************************************/ + +/* size of data in bytes that is acquired by the master device */ +const uint8_t size_of_ble = 2; +/* size of data in bytes that is acquired by the slave device */ +const uint8_t size_of_grid_eye = 128; +const uint8_t size_of_gps = 20; +const uint8_t size_of_MAX17055 = 5; +const uint8_t size_of_MAX77650 = 5; + +const uint16_t PAYLOAD_BUFFER_SIZE_MASTER_TO_SLAVE = size_of_ble; +const uint16_t PAYLOAD_BUFFER_SIZE_SLAVE_TO_MASTER = size_of_grid_eye + size_of_gps + size_of_MAX17055 + size_of_MAX77650; + #if defined(TARGET_MAX32630FTHR) // Master Device: BLE-to-LoRa Gateway - char curr_raw_frame_data_from_slave[128]; - char prev_raw_frame_data_from_slave[128]; - int16_t conv_frame_data_from_slave[64]; + /* These are indexs used to create the payload buffer to send to Slave */ + const uint8_t tx_idx_ble = 0; // 1st buf in tx payload (begins at byte 0) + + /* These are indexs used to deconstruct received payload buffer sent by the Slave */ + const uint8_t rx_idx_grid_eye = 0; // 1st buf in rx payload (begins at byte 0) + const uint8_t rx_idx_gps = rx_idx_grid_eye + size_of_grid_eye; // 2nd buf in rx payload + const uint8_t rx_idx_MAX17055 = rx_idx_gps + size_of_gps; // 3rd buf in rx payload + const uint8_t rx_idx_MAX77650 = rx_idx_MAX17055 + size_of_MAX17055; // 4th buf in rx payload + #elif defined(TARGET_MAX32620FTHR) // Client Device: LoRa Controlled Robot - char curr_raw_frame_data_to_master[128]; + + /* These are indexs used to create the payload buffer to send to Master */ + const uint8_t tx_idx_grid_eye = 0; // 1st buf in tx payload (begins at byte 0) + const uint8_t tx_idx_gps = tx_idx_grid_eye + size_of_grid_eye; // 2nd buf in tx payload + const uint8_t tx_idx_MAX17055 = tx_idx_gps + size_of_gps; // 3rd buf in tx payload + const uint8_t tx_idx_MAX77650 = tx_idx_MAX17055 + size_of_MAX17055; // 4th buf in tx payload + + /* These are indexs used to deconstruct received payload buffer sent by the Master */ + const uint8_t rx_idx_ble = 0; // 1st buf in rx payload (begins at byte 0) #endif +/*************************************************************************** + * Grid Eye Sensor Data Buffers + **************************************************************************/ +#if defined(TARGET_MAX32630FTHR) // Master Device: BLE-to-LoRa Gateway + static char curr_raw_frame_data_from_slave[payload_grid_eye_size]; + static char prev_raw_frame_data_from_slave[payload_grid_eye_size]; + static int16_t conv_frame_data_from_slave[64]; +#elif defined(TARGET_MAX32620FTHR) // Client Device: LoRa Controlled Robot + static char curr_raw_frame_data_to_master[128]; +#endif + +/*************************************************************************** + * BLE Data Buffers + **************************************************************************/ +#if defined(TARGET_MAX32630FTHR) // Master Device: BLE-to-LoRa Gateway + static char curr_ble_data_to_slave[2]; +#elif defined(TARGET_MAX32620FTHR) // Slave Device: LoRa Controlled Robot + static char curr_ble_data_from_master[2]; + static char prev_ble_data_from_master[2]; +#endif + + +/** + * @brief This function constructs a payload buffer that is used in transmitting data in a LoRa Message + */ +int fillPayloadWithGlobalBufs(); + +/** + * @brief This function deconstructs a payload buffer that contains data from a received LoRa Message + */ +int fillGlobalBufsWithPayload(); + #endif // __GLOBAL_BUFFERS_H__ \ No newline at end of file