mirror of
https://github.com/bettse/seader.git
synced 2026-06-07 19:42:25 +00:00
50 lines
965 B
C
50 lines
965 B
C
#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 (300)
|
|
|
|
typedef struct {
|
|
uint8_t uart_ch;
|
|
uint8_t flow_pins;
|
|
uint8_t baudrate_mode;
|
|
uint32_t baudrate;
|
|
} SeaderUartConfig;
|
|
|
|
typedef struct {
|
|
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;
|
|
uint8_t IFSC;
|
|
};
|
|
|
|
typedef struct SeaderUartBridge SeaderUartBridge;
|