-
Notifications
You must be signed in to change notification settings - Fork 4
/
Copy pathseader_bridge.h
50 lines (37 loc) · 989 Bytes
/
seader_bridge.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
48
49
50
#pragma once
#include <stdlib.h> // malloc
#include <stdint.h> // uint32_t
#include <stdarg.h> // __VA_ARGS__
#include <string.h>
#include <stdio.h>
#include <furi.h>
#include <furi_hal.h>
// https://ww1.microchip.com/downloads/en/DeviceDoc/00001561C.pdf
#define SEADER_UART_RX_BUF_SIZE (261)
typedef struct {
uint8_t uart_ch;
uint8_t flow_pins;
uint8_t baudrate_mode;
uint32_t baudrate;
} SeaderUartConfig;
typedef struct {
uint32_t rx_cnt;
uint32_t tx_cnt;
uint8_t protocol;
} SeaderUartState;
struct SeaderUartBridge {
SeaderUartConfig cfg;
SeaderUartConfig cfg_new;
FuriThread* thread;
FuriThread* tx_thread;
FuriStreamBuffer* rx_stream;
FuriHalSerialHandle* serial_handle;
FuriSemaphore* tx_sem;
SeaderUartState st;
uint8_t rx_buf[SEADER_UART_RX_BUF_SIZE];
uint8_t tx_buf[SEADER_UART_RX_BUF_SIZE];
size_t tx_len;
// T=0 or T=1
uint8_t T;
};
typedef struct SeaderUartBridge SeaderUartBridge;