mirror of
https://github.com/Next-Flip/Momentum-Firmware.git
synced 2026-05-23 05:24:46 -07:00
adapt plugins to furi stream, fix printf formats
This commit is contained in:
@@ -1,15 +1,13 @@
|
||||
#include "wifi_marauder_app_i.h"
|
||||
#include "wifi_marauder_uart.h"
|
||||
|
||||
#include <stream_buffer.h>
|
||||
|
||||
#define UART_CH (FuriHalUartIdUSART1)
|
||||
#define BAUDRATE (115200)
|
||||
|
||||
struct WifiMarauderUart {
|
||||
WifiMarauderApp* app;
|
||||
FuriThread* rx_thread;
|
||||
StreamBufferHandle_t rx_stream;
|
||||
FuriStreamBuffer* rx_stream;
|
||||
uint8_t rx_buf[RX_BUF_SIZE + 1];
|
||||
void (*handle_rx_data_cb)(uint8_t* buf, size_t len, void* context);
|
||||
};
|
||||
@@ -30,19 +28,17 @@ void wifi_marauder_uart_set_handle_rx_data_cb(
|
||||
|
||||
void wifi_marauder_uart_on_irq_cb(UartIrqEvent ev, uint8_t data, void* context) {
|
||||
WifiMarauderUart* uart = (WifiMarauderUart*)context;
|
||||
BaseType_t xHigherPriorityTaskWoken = pdFALSE;
|
||||
|
||||
if(ev == UartIrqEventRXNE) {
|
||||
xStreamBufferSendFromISR(uart->rx_stream, &data, 1, &xHigherPriorityTaskWoken);
|
||||
furi_stream_buffer_send(uart->rx_stream, &data, 1, 0);
|
||||
furi_thread_flags_set(furi_thread_get_id(uart->rx_thread), WorkerEvtRxDone);
|
||||
portYIELD_FROM_ISR(xHigherPriorityTaskWoken);
|
||||
}
|
||||
}
|
||||
|
||||
static int32_t uart_worker(void* context) {
|
||||
WifiMarauderUart* uart = (void*)context;
|
||||
|
||||
uart->rx_stream = xStreamBufferCreate(RX_BUF_SIZE, 1);
|
||||
uart->rx_stream = furi_stream_buffer_alloc(RX_BUF_SIZE, 1);
|
||||
|
||||
while(1) {
|
||||
uint32_t events =
|
||||
@@ -50,14 +46,14 @@ static int32_t uart_worker(void* context) {
|
||||
furi_check((events & FuriFlagError) == 0);
|
||||
if(events & WorkerEvtStop) break;
|
||||
if(events & WorkerEvtRxDone) {
|
||||
size_t len = xStreamBufferReceive(uart->rx_stream, uart->rx_buf, RX_BUF_SIZE, 0);
|
||||
size_t len = furi_stream_buffer_receive(uart->rx_stream, uart->rx_buf, RX_BUF_SIZE, 0);
|
||||
if(len > 0) {
|
||||
if(uart->handle_rx_data_cb) uart->handle_rx_data_cb(uart->rx_buf, len, uart->app);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
vStreamBufferDelete(uart->rx_stream);
|
||||
furi_stream_buffer_free(uart->rx_stream);
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user