-
Notifications
You must be signed in to change notification settings - Fork 2
/
uart_worker.h
47 lines (33 loc) · 1.18 KB
/
uart_worker.h
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
#pragma once
#include <furi.h>
#include "nfc_relay.h"
#include "packet.h"
typedef enum {
UartWorkerStateReady,
UartWorkerStateRx,
UartWorkerStateStop,
} UartWorkerState;
typedef enum {
UartWorkerStateRxSubReadTyp,
UartWorkerStateRxSubReadLen,
UartWorkerStateRxSubReadData,
UartWorkerStateRxSubReadFinish,
} UartWorkerStateRxSub;
typedef struct UartWorker {
FuriThread* thread;
UartWorkerState state;
UartWorkerStateRxSub rxSubState;
FuriStreamBuffer* rx_stream;
NfcRelayPacket* packet;
FuriHalSerialHandle* serial;
NfcRelayConfigUart config;
} UartWorker;
UartWorker* uart_worker_alloc(NfcRelayConfigUart config);
//void uart_worker_change_state(UartWorker* uart_worker, UartWorkerState state);
void uart_worker_free(UartWorker* uart_worker);
void uart_worker_stop(UartWorker* uart_worker);
void uart_worker_start(UartWorker* uart_worker);
int32_t uart_worker_task(void* context);
void uart_worker_tx(UartWorker* uart_worker, uint8_t* data, size_t len);
void uart_worker_tx_packet(UartWorker* uart_worker, NfcRelayPacket* packet);
NfcRelayPacket* uart_worker_pop_packet(UartWorker* uart_worker);