-
Notifications
You must be signed in to change notification settings - Fork 28
/
uart.h
63 lines (54 loc) · 1.75 KB
/
uart.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
51
52
53
54
55
56
57
58
59
60
61
62
63
#ifndef uart_h
#define uart_h
#include "util.h"
#include "queue.h"
#include "sdk.h"
#include <stdint.h>
#include <stdbool.h>
typedef enum attr_packed
{
parity_none,
parity_even,
parity_odd,
parity_error
} uart_parity_t;
typedef enum
{
uart_dir_none,
uart_dir_tx,
uart_dir_rx,
} uart_direction_t;
assert_size(uart_parity_t, 1);
typedef struct attr_packed
{
uint8_t data_bits;
uart_parity_t parity;
uint8_t stop_bits;
uint32_t baud_rate;
} uart_parameters_t;
assert_size(uart_parameters_t, 7);
void uart_task(struct ETSEventTag *event);
void uart_parity_to_string(string_t *dst, uart_parity_t);
char uart_parity_to_char(uart_parity_t);
uart_parity_t uart_string_to_parity(const string_t *src);
void uart_parameters_to_string(string_t *dst, const uart_parameters_t *);
void uart_init(void);
void uart_baudrate(unsigned int uart, unsigned int baudrate);
void uart_data_bits(unsigned int uart, unsigned int data_bits);
void uart_stop_bits(unsigned int uart, unsigned int stop_bits);
void uart_parity(unsigned int uart, uart_parity_t parity);
void uart_loopback(unsigned int, bool);
bool uart_invert(unsigned int, uart_direction_t, bool enable);
void uart_autofill(unsigned int uart, bool enable, unsigned int character);
void uart_is_autofill(unsigned int uart, bool *enable, unsigned int *character);
bool uart_full(unsigned int uart);
void uart_send(unsigned int, unsigned int);
void uart_send_string(unsigned int, const string_t *);
void uart_flush(unsigned int);
bool uart_empty(void);
unsigned int uart_receive(void);
void uart_clear_receive_queue(unsigned int);
void uart_set_initial(unsigned int uart);
void uart_task_handler_fetch_fifo(unsigned int uart);
void uart_task_handler_fill_fifo(unsigned int uart);
#endif