![](/media/cache/group/default_image.jpg.50x50_q85.jpg)
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
global_buffers.h@24:e8d03912f303, 2018-07-18 (annotated)
- Committer:
- dev_alexander
- Date:
- Wed Jul 18 21:25:17 2018 +0000
- Revision:
- 24:e8d03912f303
- Parent:
- 23:f74a50977593
- Child:
- 25:1a031add188a
Modified how buffers are handled in various functions in GenericPingPong.cpp to accommodate for how the buffer sizes for TX and RX are different depending on slave or master status. Still need to finish global_buffers.cpp.
Who changed what in which revision?
User | Revision | Line number | New contents of line |
---|---|---|---|
dev_alexander | 23:f74a50977593 | 1 | /** Description: |
dev_alexander | 23:f74a50977593 | 2 | * This File is responsible for defining the buffers that will be used in |
dev_alexander | 23:f74a50977593 | 3 | * various areas of the program. The buffers that are defined here will be |
dev_alexander | 23:f74a50977593 | 4 | * refferenced in the main.cpp and will be filled with data in one of two ways: |
dev_alexander | 23:f74a50977593 | 5 | * |
dev_alexander | 23:f74a50977593 | 6 | * 1. The buffers will be filled with data upon receiving a successful payload |
dev_alexander | 23:f74a50977593 | 7 | * transmission over LoRa. In GenericPingPong.cpp, the function OnRxDone() |
dev_alexander | 23:f74a50977593 | 8 | * will call the function fillGlobalBufsWithPayload() that is responsible for |
dev_alexander | 23:f74a50977593 | 9 | * filling the appropriate buffers with the payload data that was received |
dev_alexander | 23:f74a50977593 | 10 | * by either the master or slave device by the other device that sent it. |
dev_alexander | 23:f74a50977593 | 11 | * |
dev_alexander | 23:f74a50977593 | 12 | * 2. The buffers will be used to fill up a payload buffer that will be sent |
dev_alexander | 23:f74a50977593 | 13 | * over LoRa by either the master or slave device to the receiving device. |
dev_alexander | 23:f74a50977593 | 14 | * The function fillPayloadWithGlobalBufs() will use the global buffers that |
dev_alexander | 23:f74a50977593 | 15 | * are filled with data for various sensors in the main.cpp to construct a |
dev_alexander | 23:f74a50977593 | 16 | * payload to deliver to the other device when SX1276PingPong() is called |
dev_alexander | 23:f74a50977593 | 17 | * in file GenericPingPong.cpp. |
dev_alexander | 23:f74a50977593 | 18 | * |
dev_alexander | 23:f74a50977593 | 19 | */ |
dev_alexander | 23:f74a50977593 | 20 | |
dev_alexander | 23:f74a50977593 | 21 | #ifndef __GLOBAL_BUFFERS_H__ |
dev_alexander | 23:f74a50977593 | 22 | #define __GLOBAL_BUFFERS_H__ |
dev_alexander | 23:f74a50977593 | 23 | |
dev_alexander | 23:f74a50977593 | 24 | /*************************************************************************** |
dev_alexander | 24:e8d03912f303 | 25 | * Indexes for which byte specific data begins at in the payload buffer |
dev_alexander | 23:f74a50977593 | 26 | **************************************************************************/ |
dev_alexander | 24:e8d03912f303 | 27 | |
dev_alexander | 24:e8d03912f303 | 28 | /* size of data in bytes that is acquired by the master device */ |
dev_alexander | 24:e8d03912f303 | 29 | const uint8_t size_of_ble = 2; |
dev_alexander | 24:e8d03912f303 | 30 | /* size of data in bytes that is acquired by the slave device */ |
dev_alexander | 24:e8d03912f303 | 31 | const uint8_t size_of_grid_eye = 128; |
dev_alexander | 24:e8d03912f303 | 32 | const uint8_t size_of_gps = 20; |
dev_alexander | 24:e8d03912f303 | 33 | const uint8_t size_of_MAX17055 = 5; |
dev_alexander | 24:e8d03912f303 | 34 | const uint8_t size_of_MAX77650 = 5; |
dev_alexander | 24:e8d03912f303 | 35 | |
dev_alexander | 24:e8d03912f303 | 36 | const uint16_t PAYLOAD_BUFFER_SIZE_MASTER_TO_SLAVE = size_of_ble; |
dev_alexander | 24:e8d03912f303 | 37 | const uint16_t PAYLOAD_BUFFER_SIZE_SLAVE_TO_MASTER = size_of_grid_eye + size_of_gps + size_of_MAX17055 + size_of_MAX77650; |
dev_alexander | 24:e8d03912f303 | 38 | |
dev_alexander | 23:f74a50977593 | 39 | #if defined(TARGET_MAX32630FTHR) // Master Device: BLE-to-LoRa Gateway |
dev_alexander | 24:e8d03912f303 | 40 | /* These are indexs used to create the payload buffer to send to Slave */ |
dev_alexander | 24:e8d03912f303 | 41 | const uint8_t tx_idx_ble = 0; // 1st buf in tx payload (begins at byte 0) |
dev_alexander | 24:e8d03912f303 | 42 | |
dev_alexander | 24:e8d03912f303 | 43 | /* These are indexs used to deconstruct received payload buffer sent by the Slave */ |
dev_alexander | 24:e8d03912f303 | 44 | const uint8_t rx_idx_grid_eye = 0; // 1st buf in rx payload (begins at byte 0) |
dev_alexander | 24:e8d03912f303 | 45 | const uint8_t rx_idx_gps = rx_idx_grid_eye + size_of_grid_eye; // 2nd buf in rx payload |
dev_alexander | 24:e8d03912f303 | 46 | const uint8_t rx_idx_MAX17055 = rx_idx_gps + size_of_gps; // 3rd buf in rx payload |
dev_alexander | 24:e8d03912f303 | 47 | const uint8_t rx_idx_MAX77650 = rx_idx_MAX17055 + size_of_MAX17055; // 4th buf in rx payload |
dev_alexander | 24:e8d03912f303 | 48 | |
dev_alexander | 23:f74a50977593 | 49 | #elif defined(TARGET_MAX32620FTHR) // Client Device: LoRa Controlled Robot |
dev_alexander | 24:e8d03912f303 | 50 | |
dev_alexander | 24:e8d03912f303 | 51 | /* These are indexs used to create the payload buffer to send to Master */ |
dev_alexander | 24:e8d03912f303 | 52 | const uint8_t tx_idx_grid_eye = 0; // 1st buf in tx payload (begins at byte 0) |
dev_alexander | 24:e8d03912f303 | 53 | const uint8_t tx_idx_gps = tx_idx_grid_eye + size_of_grid_eye; // 2nd buf in tx payload |
dev_alexander | 24:e8d03912f303 | 54 | const uint8_t tx_idx_MAX17055 = tx_idx_gps + size_of_gps; // 3rd buf in tx payload |
dev_alexander | 24:e8d03912f303 | 55 | const uint8_t tx_idx_MAX77650 = tx_idx_MAX17055 + size_of_MAX17055; // 4th buf in tx payload |
dev_alexander | 24:e8d03912f303 | 56 | |
dev_alexander | 24:e8d03912f303 | 57 | /* These are indexs used to deconstruct received payload buffer sent by the Master */ |
dev_alexander | 24:e8d03912f303 | 58 | const uint8_t rx_idx_ble = 0; // 1st buf in rx payload (begins at byte 0) |
dev_alexander | 23:f74a50977593 | 59 | #endif |
dev_alexander | 23:f74a50977593 | 60 | |
dev_alexander | 23:f74a50977593 | 61 | |
dev_alexander | 24:e8d03912f303 | 62 | /*************************************************************************** |
dev_alexander | 24:e8d03912f303 | 63 | * Grid Eye Sensor Data Buffers |
dev_alexander | 24:e8d03912f303 | 64 | **************************************************************************/ |
dev_alexander | 24:e8d03912f303 | 65 | #if defined(TARGET_MAX32630FTHR) // Master Device: BLE-to-LoRa Gateway |
dev_alexander | 24:e8d03912f303 | 66 | static char curr_raw_frame_data_from_slave[payload_grid_eye_size]; |
dev_alexander | 24:e8d03912f303 | 67 | static char prev_raw_frame_data_from_slave[payload_grid_eye_size]; |
dev_alexander | 24:e8d03912f303 | 68 | static int16_t conv_frame_data_from_slave[64]; |
dev_alexander | 24:e8d03912f303 | 69 | #elif defined(TARGET_MAX32620FTHR) // Client Device: LoRa Controlled Robot |
dev_alexander | 24:e8d03912f303 | 70 | static char curr_raw_frame_data_to_master[128]; |
dev_alexander | 24:e8d03912f303 | 71 | #endif |
dev_alexander | 24:e8d03912f303 | 72 | |
dev_alexander | 24:e8d03912f303 | 73 | /*************************************************************************** |
dev_alexander | 24:e8d03912f303 | 74 | * BLE Data Buffers |
dev_alexander | 24:e8d03912f303 | 75 | **************************************************************************/ |
dev_alexander | 24:e8d03912f303 | 76 | #if defined(TARGET_MAX32630FTHR) // Master Device: BLE-to-LoRa Gateway |
dev_alexander | 24:e8d03912f303 | 77 | static char curr_ble_data_to_slave[2]; |
dev_alexander | 24:e8d03912f303 | 78 | #elif defined(TARGET_MAX32620FTHR) // Slave Device: LoRa Controlled Robot |
dev_alexander | 24:e8d03912f303 | 79 | static char curr_ble_data_from_master[2]; |
dev_alexander | 24:e8d03912f303 | 80 | static char prev_ble_data_from_master[2]; |
dev_alexander | 24:e8d03912f303 | 81 | #endif |
dev_alexander | 24:e8d03912f303 | 82 | |
dev_alexander | 24:e8d03912f303 | 83 | |
dev_alexander | 24:e8d03912f303 | 84 | /** |
dev_alexander | 24:e8d03912f303 | 85 | * @brief This function constructs a payload buffer that is used in transmitting data in a LoRa Message |
dev_alexander | 24:e8d03912f303 | 86 | */ |
dev_alexander | 24:e8d03912f303 | 87 | int fillPayloadWithGlobalBufs(); |
dev_alexander | 24:e8d03912f303 | 88 | |
dev_alexander | 24:e8d03912f303 | 89 | /** |
dev_alexander | 24:e8d03912f303 | 90 | * @brief This function deconstructs a payload buffer that contains data from a received LoRa Message |
dev_alexander | 24:e8d03912f303 | 91 | */ |
dev_alexander | 24:e8d03912f303 | 92 | int fillGlobalBufsWithPayload(); |
dev_alexander | 24:e8d03912f303 | 93 | |
dev_alexander | 23:f74a50977593 | 94 | #endif // __GLOBAL_BUFFERS_H__ |