|
@@ -4,16 +4,15 @@
|
|
|
#include <FreeRTOS.h>
|
|
#include <FreeRTOS.h>
|
|
|
#include <stream_buffer.h>
|
|
#include <stream_buffer.h>
|
|
|
|
|
|
|
|
-#define UART_CH (FuriHalUartIdUSART1)
|
|
|
|
|
#define BAUDRATE (115200)
|
|
#define BAUDRATE (115200)
|
|
|
|
|
|
|
|
struct WifideautherUart {
|
|
struct WifideautherUart {
|
|
|
WifideautherApp* app;
|
|
WifideautherApp* app;
|
|
|
- FuriHalUartId channel;
|
|
|
|
|
FuriThread* rx_thread;
|
|
FuriThread* rx_thread;
|
|
|
FuriStreamBuffer* rx_stream;
|
|
FuriStreamBuffer* rx_stream;
|
|
|
uint8_t rx_buf[RX_BUF_SIZE + 1];
|
|
uint8_t rx_buf[RX_BUF_SIZE + 1];
|
|
|
void (*handle_rx_data_cb)(uint8_t* buf, size_t len, void* context);
|
|
void (*handle_rx_data_cb)(uint8_t* buf, size_t len, void* context);
|
|
|
|
|
+ FuriHalSerialHandle* serial_handle;
|
|
|
};
|
|
};
|
|
|
|
|
|
|
|
typedef enum {
|
|
typedef enum {
|
|
@@ -30,10 +29,14 @@ void wifi_deauther_uart_set_handle_rx_data_cb(
|
|
|
|
|
|
|
|
#define WORKER_ALL_RX_EVENTS (WorkerEvtStop | WorkerEvtRxDone)
|
|
#define WORKER_ALL_RX_EVENTS (WorkerEvtStop | WorkerEvtRxDone)
|
|
|
|
|
|
|
|
-void wifi_deauther_uart_on_irq_cb(UartIrqEvent ev, uint8_t data, void* context) {
|
|
|
|
|
|
|
+void wifi_deauther_uart_on_irq_cb(
|
|
|
|
|
+ FuriHalSerialHandle* handle,
|
|
|
|
|
+ FuriHalSerialRxEvent event,
|
|
|
|
|
+ void* context) {
|
|
|
WifideautherUart* uart = (WifideautherUart*)context;
|
|
WifideautherUart* uart = (WifideautherUart*)context;
|
|
|
|
|
|
|
|
- if(ev == UartIrqEventRXNE) {
|
|
|
|
|
|
|
+ if(event == FuriHalSerialRxEventData) {
|
|
|
|
|
+ uint8_t data = furi_hal_serial_async_rx(handle);
|
|
|
furi_stream_buffer_send(uart->rx_stream, &data, 1, 0);
|
|
furi_stream_buffer_send(uart->rx_stream, &data, 1, 0);
|
|
|
furi_thread_flags_set(furi_thread_get_id(uart->rx_thread), WorkerEvtRxDone);
|
|
furi_thread_flags_set(furi_thread_get_id(uart->rx_thread), WorkerEvtRxDone);
|
|
|
}
|
|
}
|
|
@@ -60,8 +63,8 @@ static int32_t uart_worker(void* context) {
|
|
|
return 0;
|
|
return 0;
|
|
|
}
|
|
}
|
|
|
|
|
|
|
|
-void wifi_deauther_uart_tx(uint8_t* data, size_t len) {
|
|
|
|
|
- furi_hal_uart_tx(UART_CH, data, len);
|
|
|
|
|
|
|
+void wifi_deauther_uart_tx(WifideautherUart* uart, uint8_t* data, size_t len) {
|
|
|
|
|
+ furi_hal_serial_tx(uart->serial_handle, data, len);
|
|
|
}
|
|
}
|
|
|
|
|
|
|
|
WifideautherUart* wifi_deauther_uart_init(WifideautherApp* app) {
|
|
WifideautherUart* wifi_deauther_uart_init(WifideautherApp* app) {
|
|
@@ -77,9 +80,10 @@ WifideautherUart* wifi_deauther_uart_init(WifideautherApp* app) {
|
|
|
|
|
|
|
|
furi_thread_start(uart->rx_thread);
|
|
furi_thread_start(uart->rx_thread);
|
|
|
|
|
|
|
|
- furi_hal_console_disable();
|
|
|
|
|
- furi_hal_uart_set_br(UART_CH, BAUDRATE);
|
|
|
|
|
- furi_hal_uart_set_irq_cb(UART_CH, wifi_deauther_uart_on_irq_cb, uart);
|
|
|
|
|
|
|
+ uart->serial_handle = furi_hal_serial_control_acquire(UART_CH);
|
|
|
|
|
+ furi_check(uart->serial_handle);
|
|
|
|
|
+ furi_hal_serial_init(uart->serial_handle, BAUDRATE);
|
|
|
|
|
+ furi_hal_serial_async_rx_start(uart->serial_handle, wifi_deauther_uart_on_irq_cb, uart, false);
|
|
|
|
|
|
|
|
return uart;
|
|
return uart;
|
|
|
}
|
|
}
|
|
@@ -91,8 +95,8 @@ void wifi_deauther_uart_free(WifideautherUart* uart) {
|
|
|
furi_thread_join(uart->rx_thread);
|
|
furi_thread_join(uart->rx_thread);
|
|
|
furi_thread_free(uart->rx_thread);
|
|
furi_thread_free(uart->rx_thread);
|
|
|
|
|
|
|
|
- furi_hal_uart_set_irq_cb(UART_CH, NULL, NULL);
|
|
|
|
|
- furi_hal_console_enable();
|
|
|
|
|
|
|
+ furi_hal_serial_deinit(uart->serial_handle);
|
|
|
|
|
+ furi_hal_serial_control_release(uart->serial_handle);
|
|
|
|
|
|
|
|
free(uart);
|
|
free(uart);
|
|
|
}
|
|
}
|