|
|
@@ -99,6 +99,7 @@ static void process_request()
|
|
|
// spracovanie broadcast komunikacie
|
|
|
if ((request_type == BROADCAST_SPECIFIC_SENSORS || request_type == BROADCAST_GLOBAL))
|
|
|
{
|
|
|
+ nBus.hw_platform->led_on();
|
|
|
nbus_slave_broadcast(&nBus, request_type);
|
|
|
return;
|
|
|
}
|
|
|
@@ -162,17 +163,7 @@ static void nbus_blink_LED(uint8_t delay)
|
|
|
/* ----------------------- CALLBACKS----------------------- */
|
|
|
/* -------------------------------------------------------- */
|
|
|
|
|
|
-/**
|
|
|
- * @brief UART receive complete.
|
|
|
- * This callback have to called from application, when RX data is ready.
|
|
|
- * @param int size Size of received packet
|
|
|
- * Received packet is located in uBus.rx_buffer
|
|
|
- */
|
|
|
-void nbus_cb_UART_RX(int size)
|
|
|
-{
|
|
|
- nBus.rx_length = size;
|
|
|
- nBus.uart_state = UART_RX_RECEIVED;
|
|
|
-}
|
|
|
+
|
|
|
|
|
|
/* -------------------------------------------------------- */
|
|
|
/* ------------------ PUBLIC FUNCTIONS-------------------- */
|
|
|
@@ -195,8 +186,6 @@ void nbus_init(nBusAppInterface_t *interface, nBusPlatformInterface_t *hw)
|
|
|
nBus.data_timebase = 0;
|
|
|
nBus.measure_active = MEASURE_STOPPED;
|
|
|
|
|
|
- nBus.uart_state = UART_RX_WAIT;
|
|
|
-
|
|
|
nBus.interface = interface;
|
|
|
|
|
|
receivePacket();
|
|
|
@@ -272,19 +261,19 @@ void nbus_init_memory_driver(nBus_MemoryDriver *memDriver)
|
|
|
*/
|
|
|
void nbus_stack(void)
|
|
|
{
|
|
|
+ uint8_t packet_len = 0;
|
|
|
|
|
|
#if USE_ARDUINO_FRAMWORK == 0
|
|
|
nbus_blink_LED(50);
|
|
|
while (1)
|
|
|
#endif
|
|
|
{
|
|
|
- if (nBus.uart_state == UART_RX_RECEIVED)
|
|
|
+ while(nBus.hw_platform->read_rx_packet(nBus.rx_buffer, &packet_len))
|
|
|
{
|
|
|
-
|
|
|
+ nBus.rx_length = packet_len;
|
|
|
process_request();
|
|
|
- nBus.hw_platform->led_off();
|
|
|
- nBus.uart_state = UART_RX_WAIT;
|
|
|
send_response();
|
|
|
+ nBus.hw_platform->led_off();
|
|
|
}
|
|
|
|
|
|
if (nBus.hw_platform->loop_callback != NULL)
|
|
|
@@ -292,7 +281,7 @@ void nbus_stack(void)
|
|
|
|
|
|
if (nBus.hw_platform->loop_callback(CallbackType_SENSOR) == 1)
|
|
|
{
|
|
|
- nBus.interface->read();
|
|
|
+ nBus.interface->read();
|
|
|
}
|
|
|
|
|
|
nBus.hw_platform->loop_callback(CallbackType_UART);
|