all: Unify header guard usage.
The code conventions suggest using header guards, but do not define how
those should look like and instead point to existing files. However, not
all existing files follow the same scheme, sometimes omitting header guards
altogether, sometimes using non-standard names, making it easy to
accidentally pick a "wrong" example.
This commit ensures that all header files of the MicroPython project (that
were not simply copied from somewhere else) follow the same pattern, that
was already present in the majority of files, especially in the py folder.
The rules are as follows.
Naming convention:
* start with the words MICROPY_INCLUDED
* contain the full path to the file
* replace special characters with _
In addition, there are no empty lines before #ifndef, between #ifndef and
one empty line before #endif. #endif is followed by a comment containing
the name of the guard macro.
py/grammar.h cannot use header guards by design, since it has to be
included multiple times in a single C file. Several other files also do not
need header guards as they are only used internally and guaranteed to be
included only once:
* MICROPY_MPHALPORT_H
* mpconfigboard.h
* mpconfigport.h
* mpthreadport.h
* pin_defs_*.h
* qstrdefs*.h
2017-06-29 17:14:58 -04:00
|
|
|
#ifndef MICROPY_INCLUDED_ESP8266_UART_H
|
|
|
|
#define MICROPY_INCLUDED_ESP8266_UART_H
|
2014-11-27 15:30:33 -05:00
|
|
|
|
2016-07-26 11:56:13 -04:00
|
|
|
#include <eagle_soc.h>
|
|
|
|
|
2014-11-27 15:30:33 -05:00
|
|
|
#define UART0 (0)
|
|
|
|
#define UART1 (1)
|
|
|
|
|
2018-12-05 07:31:24 -05:00
|
|
|
#define UART0_STATIC_RXBUF_LEN (16)
|
|
|
|
|
2014-11-27 15:30:33 -05:00
|
|
|
typedef enum {
|
|
|
|
UART_FIVE_BITS = 0x0,
|
|
|
|
UART_SIX_BITS = 0x1,
|
|
|
|
UART_SEVEN_BITS = 0x2,
|
|
|
|
UART_EIGHT_BITS = 0x3
|
|
|
|
} UartBitsNum4Char;
|
|
|
|
|
|
|
|
typedef enum {
|
2017-08-16 06:23:27 -04:00
|
|
|
UART_ONE_STOP_BIT = 0x1,
|
|
|
|
UART_ONE_HALF_STOP_BIT = 0x2,
|
|
|
|
UART_TWO_STOP_BIT = 0x3
|
2014-11-27 15:30:33 -05:00
|
|
|
} UartStopBitsNum;
|
|
|
|
|
|
|
|
typedef enum {
|
2016-07-26 11:56:13 -04:00
|
|
|
UART_NONE_BITS = 0,
|
|
|
|
UART_ODD_BITS = BIT0,
|
|
|
|
UART_EVEN_BITS = 0
|
2014-11-27 15:30:33 -05:00
|
|
|
} UartParityMode;
|
|
|
|
|
|
|
|
typedef enum {
|
|
|
|
UART_STICK_PARITY_DIS = 0,
|
2016-07-26 11:56:13 -04:00
|
|
|
UART_STICK_PARITY_EN = BIT1
|
2014-11-27 15:30:33 -05:00
|
|
|
} UartExistParity;
|
|
|
|
|
|
|
|
typedef enum {
|
|
|
|
UART_BIT_RATE_9600 = 9600,
|
|
|
|
UART_BIT_RATE_19200 = 19200,
|
|
|
|
UART_BIT_RATE_38400 = 38400,
|
|
|
|
UART_BIT_RATE_57600 = 57600,
|
|
|
|
UART_BIT_RATE_74880 = 74880,
|
|
|
|
UART_BIT_RATE_115200 = 115200,
|
|
|
|
UART_BIT_RATE_230400 = 230400,
|
|
|
|
UART_BIT_RATE_256000 = 256000,
|
|
|
|
UART_BIT_RATE_460800 = 460800,
|
|
|
|
UART_BIT_RATE_921600 = 921600
|
|
|
|
} UartBautRate;
|
|
|
|
|
|
|
|
typedef enum {
|
|
|
|
UART_NONE_CTRL,
|
|
|
|
UART_HARDWARE_CTRL,
|
|
|
|
UART_XON_XOFF_CTRL
|
|
|
|
} UartFlowCtrl;
|
|
|
|
|
|
|
|
typedef enum {
|
|
|
|
UART_EMPTY,
|
|
|
|
UART_UNDER_WRITE,
|
|
|
|
UART_WRITE_OVER
|
|
|
|
} RcvMsgBuffState;
|
|
|
|
|
|
|
|
typedef struct {
|
|
|
|
uint32 RcvBuffSize;
|
|
|
|
uint8 *pRcvMsgBuff;
|
|
|
|
uint8 *pWritePos;
|
|
|
|
uint8 *pReadPos;
|
|
|
|
uint8 TrigLvl; // JLU: may need to pad
|
|
|
|
RcvMsgBuffState BuffState;
|
|
|
|
} RcvMsgBuff;
|
|
|
|
|
|
|
|
typedef struct {
|
|
|
|
uint32 TrxBuffSize;
|
|
|
|
uint8 *pTrxBuff;
|
|
|
|
} TrxMsgBuff;
|
|
|
|
|
|
|
|
typedef enum {
|
|
|
|
UART_BAUD_RATE_DET,
|
|
|
|
UART_WAIT_SYNC_FRM,
|
|
|
|
UART_SRCH_MSG_HEAD,
|
|
|
|
UART_RCV_MSG_BODY,
|
|
|
|
UART_RCV_ESC_CHAR,
|
|
|
|
} RcvMsgState;
|
|
|
|
|
|
|
|
typedef struct {
|
|
|
|
UartBautRate baut_rate;
|
|
|
|
UartBitsNum4Char data_bits;
|
|
|
|
UartExistParity exist_parity;
|
|
|
|
UartParityMode parity; // chip size in byte
|
|
|
|
UartStopBitsNum stop_bits;
|
|
|
|
UartFlowCtrl flow_ctrl;
|
|
|
|
RcvMsgBuff rcv_buff;
|
|
|
|
TrxMsgBuff trx_buff;
|
|
|
|
RcvMsgState rcv_state;
|
|
|
|
int received;
|
|
|
|
int buff_uart_no; // indicate which uart use tx/rx buffer
|
|
|
|
} UartDevice;
|
|
|
|
|
2018-12-05 07:31:24 -05:00
|
|
|
extern uint8 uart_ringbuf_array[UART0_STATIC_RXBUF_LEN];
|
|
|
|
|
2014-11-27 15:30:33 -05:00
|
|
|
void uart_init(UartBautRate uart0_br, UartBautRate uart1_br);
|
|
|
|
int uart0_rx(void);
|
2016-04-21 10:19:00 -04:00
|
|
|
bool uart_rx_wait(uint32_t timeout_us);
|
|
|
|
int uart_rx_char(void);
|
2014-11-27 15:30:33 -05:00
|
|
|
void uart_tx_one_char(uint8 uart, uint8 TxChar);
|
2016-01-03 00:33:42 -05:00
|
|
|
void uart_flush(uint8 uart);
|
2022-08-26 10:42:10 -04:00
|
|
|
int uart_txdone(uint8 uart);
|
2016-04-05 17:12:58 -04:00
|
|
|
void uart_os_config(int uart);
|
2016-06-29 08:18:48 -04:00
|
|
|
void uart_setup(uint8 uart);
|
2018-12-05 07:31:24 -05:00
|
|
|
int uart0_get_rxbuf_len(void);
|
|
|
|
void uart0_set_rxbuf(uint8 *buf, int len);
|
2017-01-29 21:48:55 -05:00
|
|
|
// check status of rx/tx
|
|
|
|
int uart_rx_any(uint8 uart);
|
|
|
|
int uart_tx_any_room(uint8 uart);
|
2014-11-27 15:30:33 -05:00
|
|
|
|
all: Unify header guard usage.
The code conventions suggest using header guards, but do not define how
those should look like and instead point to existing files. However, not
all existing files follow the same scheme, sometimes omitting header guards
altogether, sometimes using non-standard names, making it easy to
accidentally pick a "wrong" example.
This commit ensures that all header files of the MicroPython project (that
were not simply copied from somewhere else) follow the same pattern, that
was already present in the majority of files, especially in the py folder.
The rules are as follows.
Naming convention:
* start with the words MICROPY_INCLUDED
* contain the full path to the file
* replace special characters with _
In addition, there are no empty lines before #ifndef, between #ifndef and
one empty line before #endif. #endif is followed by a comment containing
the name of the guard macro.
py/grammar.h cannot use header guards by design, since it has to be
included multiple times in a single C file. Several other files also do not
need header guards as they are only used internally and guaranteed to be
included only once:
* MICROPY_MPHALPORT_H
* mpconfigboard.h
* mpconfigport.h
* mpthreadport.h
* pin_defs_*.h
* qstrdefs*.h
2017-06-29 17:14:58 -04:00
|
|
|
#endif // MICROPY_INCLUDED_ESP8266_UART_H
|