blob: 9a2c6dd3bf3129734828d930db70d102470aaf9d (
plain)
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
|
#ifndef __UART_H__
#define __UART_H__
#include <rthw.h>
#include <rtthread.h>
#include "cy_device_headers.h"
#include "board.h"
#include "cy_pdl.h"
#define UART_RX_BUFFER_SIZE 128u
#define UART_TX_BUFFER_SIZE 128u
#define UART_ENABLE_IRQ(n) NVIC_EnableIRQ((n))
#define UART_DISABLE_IRQ(n) NVIC_DisableIRQ((n))
struct uart_int_rx
{
rt_uint8_t rx_buffer[UART_RX_BUFFER_SIZE];
rt_uint32_t read_index, save_index;
};
struct uart_int_tx
{
rt_uint8_t tx_buffer[UART_TX_BUFFER_SIZE];
rt_uint32_t write_index, save_index;
};
struct uart_device
{
CySCB_Type* scb_device;
/* uart config */
cy_stc_scb_uart_config_t const *uart_config;
/* uart context */
cy_stc_scb_uart_context_t *uart_context;
/* uart interrupt */
const cy_stc_sysint_t *uart_int;
/* irq number */
IRQn_Type rx_irq;
IRQn_Type tx_irq;
/* rx structure */
struct uart_int_rx* int_rx;
/* tx structure */
struct uart_int_tx* int_tx;
};
void rt_hw_uart_init(void);
#endif
|