@@ -27,77 +27,7 @@ extern "C" {
2727#include <stdlib.h>
2828#include "freertos/FreeRTOS.h"
2929#include "freertos/queue.h"
30-
31- #ifdef __cplusplus
32- enum SerialConfig {
33- SERIAL_5N1 = 0x8000010 ,
34- SERIAL_6N1 = 0x8000014 ,
35- SERIAL_7N1 = 0x8000018 ,
36- SERIAL_8N1 = 0x800001c ,
37- SERIAL_5N2 = 0x8000030 ,
38- SERIAL_6N2 = 0x8000034 ,
39- SERIAL_7N2 = 0x8000038 ,
40- SERIAL_8N2 = 0x800003c ,
41- SERIAL_5E1 = 0x8000012 ,
42- SERIAL_6E1 = 0x8000016 ,
43- SERIAL_7E1 = 0x800001a ,
44- SERIAL_8E1 = 0x800001e ,
45- SERIAL_5E2 = 0x8000032 ,
46- SERIAL_6E2 = 0x8000036 ,
47- SERIAL_7E2 = 0x800003a ,
48- SERIAL_8E2 = 0x800003e ,
49- SERIAL_5O1 = 0x8000013 ,
50- SERIAL_6O1 = 0x8000017 ,
51- SERIAL_7O1 = 0x800001b ,
52- SERIAL_8O1 = 0x800001f ,
53- SERIAL_5O2 = 0x8000033 ,
54- SERIAL_6O2 = 0x8000037 ,
55- SERIAL_7O2 = 0x800003b ,
56- SERIAL_8O2 = 0x800003f
57- };
58- #else
59- #define SERIAL_5N1 0x8000010
60- #define SERIAL_6N1 0x8000014
61- #define SERIAL_7N1 0x8000018
62- #define SERIAL_8N1 0x800001c
63- #define SERIAL_5N2 0x8000030
64- #define SERIAL_6N2 0x8000034
65- #define SERIAL_7N2 0x8000038
66- #define SERIAL_8N2 0x800003c
67- #define SERIAL_5E1 0x8000012
68- #define SERIAL_6E1 0x8000016
69- #define SERIAL_7E1 0x800001a
70- #define SERIAL_8E1 0x800001e
71- #define SERIAL_5E2 0x8000032
72- #define SERIAL_6E2 0x8000036
73- #define SERIAL_7E2 0x800003a
74- #define SERIAL_8E2 0x800003e
75- #define SERIAL_5O1 0x8000013
76- #define SERIAL_6O1 0x8000017
77- #define SERIAL_7O1 0x800001b
78- #define SERIAL_8O1 0x800001f
79- #define SERIAL_5O2 0x8000033
80- #define SERIAL_6O2 0x8000037
81- #define SERIAL_7O2 0x800003b
82- #define SERIAL_8O2 0x800003f
83- #endif // __cplusplus
84-
85- // These are Hardware Flow Contol possible usage
86- // equivalent to UDF enum uart_hw_flowcontrol_t from
87- // https://github.com/espressif/esp-idf/blob/master/components/hal/include/hal/uart_types.h#L75-L81
88- #define HW_FLOWCTRL_DISABLE 0x0 // disable HW Flow Control
89- #define HW_FLOWCTRL_RTS 0x1 // use only RTS PIN for HW Flow Control
90- #define HW_FLOWCTRL_CTS 0x2 // use only CTS PIN for HW Flow Control
91- #define HW_FLOWCTRL_CTS_RTS 0x3 // use both CTS and RTS PIN for HW Flow Control
92-
93- // These are Hardware Uart Modes possible usage
94- // equivalent to UDF enum uart_mode_t from
95- // https://github.com/espressif/esp-idf/blob/master/components/hal/include/hal/uart_types.h#L34-L40
96- #define MODE_UART 0x00 // mode: regular UART mode
97- #define MODE_RS485_HALF_DUPLEX 0x01 // mode: half duplex RS485 UART mode control by RTS pin
98- #define MODE_IRDA 0x02 // mode: IRDA UART mode
99- #define MODE_RS485_COLLISION_DETECT 0x03 // mode: RS485 collision detection UART mode (used for test purposes)
100- #define MODE_RS485_APP_CTRL 0x04
30+ #include "hal/uart_types.h"
10131
10232struct uart_struct_t ;
10333typedef struct uart_struct_t uart_t ;
@@ -145,11 +75,20 @@ void uart_init_PeriMan(void);
14575
14676
14777// Enables or disables HW Flow Control function -- needs also to set CTS and/or RTS pins
148- bool uartSetHwFlowCtrlMode (uart_t * uart , uint8_t mode , uint8_t threshold );
78+ // UART_HW_FLOWCTRL_DISABLE = 0x0 disable hardware flow control
79+ // UART_HW_FLOWCTRL_RTS = 0x1 enable RX hardware flow control (rts)
80+ // UART_HW_FLOWCTRL_CTS = 0x2 enable TX hardware flow control (cts)
81+ // UART_HW_FLOWCTRL_CTS_RTS = 0x3 enable hardware flow control
82+ bool uartSetHwFlowCtrlMode (uart_t * uart , uart_hw_flowcontrol_t mode , uint8_t threshold );
14983
15084// Used to set RS485 function -- needs to disable HW Flow Control and set RTS pin to use
15185// RTS pin becomes RS485 half duplex RE/DE
152- bool uartSetMode (uart_t * uart , uint8_t mode );
86+ // UART_MODE_UART = 0x00 mode: regular UART mode
87+ // UART_MODE_RS485_HALF_DUPLEX = 0x01 mode: half duplex RS485 UART mode control by RTS pin
88+ // UART_MODE_IRDA = 0x02 mode: IRDA UART mode
89+ // UART_MODE_RS485_COLLISION_DETECT = 0x03 mode: RS485 collision detection UART mode (used for test purposes)
90+ // UART_MODE_RS485_APP_CTRL = 0x04 mode: application control RS485 UART mode (used for test purposes)
91+ bool uartSetMode (uart_t * uart , uart_mode_t mode );
15392
15493void uartStartDetectBaudrate (uart_t * uart );
15594unsigned long uartDetectBaudrate (uart_t * uart );
0 commit comments