|
|
@@ -2,9 +2,9 @@
|
|
|
|
|
|
#include "nbus_app_interface_esp32.h"
|
|
|
|
|
|
-
|
|
|
static NbusLoopEsp32 *_loop_driver;
|
|
|
static bool _in_transmission = false;
|
|
|
+static uint32_t _rx_size = 0;
|
|
|
|
|
|
nBusPlatformInterface_t* nbus_platform_init(NbusLoopEsp32 *loop_driver)
|
|
|
{
|
|
|
@@ -61,6 +61,11 @@ static inline void led_toggle()
|
|
|
#endif // NBUS_USE_LED
|
|
|
}
|
|
|
|
|
|
+static inline uint32_t get_time()
|
|
|
+{
|
|
|
+ return millis();
|
|
|
+}
|
|
|
+
|
|
|
static inline void app_delay(uint8_t ms)
|
|
|
{
|
|
|
delay(ms);
|
|
|
@@ -81,9 +86,17 @@ static inline uint8_t loop_callback(nBusStateCallbackType_t state_check)
|
|
|
return 0;
|
|
|
}
|
|
|
|
|
|
+uint8_t read_rx_packet(uint8_t *data, uint8_t *length)
|
|
|
+{
|
|
|
+ // data buffers are already interconnected
|
|
|
+ *length = _rx_size;
|
|
|
+ _rx_size = 0;
|
|
|
+ return *length > 0;
|
|
|
+}
|
|
|
+
|
|
|
void nbus_platform_loop()
|
|
|
{
|
|
|
- int16_t size = _loop_driver->receiveData();
|
|
|
+ _rx_size = _loop_driver->receiveData();
|
|
|
|
|
|
if (_in_transmission == false && _loop_driver->isReceiving() == true)
|
|
|
{
|
|
|
@@ -96,11 +109,6 @@ void nbus_platform_loop()
|
|
|
led_off();
|
|
|
_in_transmission = false;
|
|
|
}
|
|
|
-
|
|
|
- if (size > 0)
|
|
|
- {
|
|
|
- nbus_cb_UART_RX(size);
|
|
|
- }
|
|
|
}
|
|
|
|
|
|
nBusPlatformInterface_t nbus_hw_platform = {
|
|
|
@@ -110,7 +118,9 @@ nBusPlatformInterface_t nbus_hw_platform = {
|
|
|
led_off,
|
|
|
led_toggle,
|
|
|
app_delay,
|
|
|
+ get_time,
|
|
|
loop_callback,
|
|
|
+ read_rx_packet
|
|
|
};
|
|
|
|
|
|
#endif // NBUS_NODE_TYPE
|