| 
									
										
										
										
											2016-10-06 14:21:30 +03:00
										 |  |  | // Copyright 2015-2016 Espressif Systems (Shanghai) PTE LTD
 | 
					
						
							|  |  |  | //
 | 
					
						
							|  |  |  | // Licensed under the Apache License, Version 2.0 (the "License");
 | 
					
						
							|  |  |  | // you may not use this file except in compliance with the License.
 | 
					
						
							|  |  |  | // You may obtain a copy of the License at
 | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  | //     http://www.apache.org/licenses/LICENSE-2.0
 | 
					
						
							|  |  |  | //
 | 
					
						
							|  |  |  | // Unless required by applicable law or agreed to in writing, software
 | 
					
						
							|  |  |  | // distributed under the License is distributed on an "AS IS" BASIS,
 | 
					
						
							|  |  |  | // WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
 | 
					
						
							|  |  |  | // See the License for the specific language governing permissions and
 | 
					
						
							|  |  |  | // limitations under the License.
 | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  | #ifndef MAIN_ESP32_HAL_UART_H_
 | 
					
						
							|  |  |  | #define MAIN_ESP32_HAL_UART_H_
 | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  | #ifdef __cplusplus
 | 
					
						
							|  |  |  | extern "C" { | 
					
						
							|  |  |  | #endif
 | 
					
						
							|  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2016-10-14 03:02:40 +03:00
										 |  |  | #include <stdint.h>
 | 
					
						
							|  |  |  | #include <stdbool.h>
 | 
					
						
							|  |  |  | #include <stdlib.h>
 | 
					
						
							| 
									
										
										
										
											2016-10-06 14:21:30 +03:00
										 |  |  | 
 | 
					
						
							|  |  |  | #define SERIAL_5N1 0x8000010
 | 
					
						
							|  |  |  | #define SERIAL_6N1 0x8000014
 | 
					
						
							|  |  |  | #define SERIAL_7N1 0x8000018
 | 
					
						
							|  |  |  | #define SERIAL_8N1 0x800001c
 | 
					
						
							|  |  |  | #define SERIAL_5N2 0x8000030
 | 
					
						
							|  |  |  | #define SERIAL_6N2 0x8000034
 | 
					
						
							|  |  |  | #define SERIAL_7N2 0x8000038
 | 
					
						
							|  |  |  | #define SERIAL_8N2 0x800003c
 | 
					
						
							|  |  |  | #define SERIAL_5E1 0x8000012
 | 
					
						
							|  |  |  | #define SERIAL_6E1 0x8000016
 | 
					
						
							|  |  |  | #define SERIAL_7E1 0x800001a
 | 
					
						
							|  |  |  | #define SERIAL_8E1 0x800001e
 | 
					
						
							|  |  |  | #define SERIAL_5E2 0x8000032
 | 
					
						
							|  |  |  | #define SERIAL_6E2 0x8000036
 | 
					
						
							|  |  |  | #define SERIAL_7E2 0x800003a
 | 
					
						
							|  |  |  | #define SERIAL_8E2 0x800003e
 | 
					
						
							|  |  |  | #define SERIAL_5O1 0x8000013
 | 
					
						
							|  |  |  | #define SERIAL_6O1 0x8000017
 | 
					
						
							|  |  |  | #define SERIAL_7O1 0x800001b
 | 
					
						
							|  |  |  | #define SERIAL_8O1 0x800001f
 | 
					
						
							|  |  |  | #define SERIAL_5O2 0x8000033
 | 
					
						
							|  |  |  | #define SERIAL_6O2 0x8000037
 | 
					
						
							|  |  |  | #define SERIAL_7O2 0x800003b
 | 
					
						
							|  |  |  | #define SERIAL_8O2 0x800003f
 | 
					
						
							|  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2016-10-14 03:02:40 +03:00
										 |  |  | struct uart_struct_t; | 
					
						
							|  |  |  | typedef struct uart_struct_t uart_t; | 
					
						
							| 
									
										
										
										
											2016-10-06 14:21:30 +03:00
										 |  |  | 
 | 
					
						
							|  |  |  | uart_t* uartBegin(uint8_t uart_nr, uint32_t baudrate, uint32_t config, int8_t rxPin, int8_t txPin, uint16_t queueLen, bool inverted); | 
					
						
							| 
									
										
										
										
											2020-09-30 06:04:18 -06:00
										 |  |  | void uartEnd(uart_t* uart, uint8_t rxPin, uint8_t txPin); | 
					
						
							| 
									
										
										
										
											2016-10-06 14:21:30 +03:00
										 |  |  | 
 | 
					
						
							|  |  |  | uint32_t uartAvailable(uart_t* uart); | 
					
						
							| 
									
										
										
										
											2018-04-06 18:07:46 +02:00
										 |  |  | uint32_t uartAvailableForWrite(uart_t* uart); | 
					
						
							| 
									
										
										
										
											2016-10-06 14:21:30 +03:00
										 |  |  | uint8_t uartRead(uart_t* uart); | 
					
						
							|  |  |  | uint8_t uartPeek(uart_t* uart); | 
					
						
							| 
									
										
										
										
											2016-10-14 03:02:40 +03:00
										 |  |  | 
 | 
					
						
							| 
									
										
										
										
											2016-10-06 14:21:30 +03:00
										 |  |  | void uartWrite(uart_t* uart, uint8_t c); | 
					
						
							|  |  |  | void uartWriteBuf(uart_t* uart, const uint8_t * data, size_t len); | 
					
						
							| 
									
										
										
										
											2016-10-14 03:02:40 +03:00
										 |  |  | 
 | 
					
						
							| 
									
										
										
										
											2016-10-06 14:21:30 +03:00
										 |  |  | void uartFlush(uart_t* uart); | 
					
						
							| 
									
										
										
										
											2019-11-11 07:37:35 -07:00
										 |  |  | void uartFlushTxOnly(uart_t* uart, bool txOnly ); | 
					
						
							| 
									
										
										
										
											2016-10-06 14:21:30 +03:00
										 |  |  | 
 | 
					
						
							|  |  |  | void uartSetBaudRate(uart_t* uart, uint32_t baud_rate); | 
					
						
							|  |  |  | uint32_t uartGetBaudRate(uart_t* uart); | 
					
						
							|  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2018-09-17 12:16:18 -07:00
										 |  |  | size_t uartResizeRxBuffer(uart_t* uart, size_t new_size); | 
					
						
							|  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2020-10-01 06:58:48 -04:00
										 |  |  | void uartSetRxInvert(uart_t* uart, bool invert); | 
					
						
							|  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2016-10-06 14:21:30 +03:00
										 |  |  | void uartSetDebug(uart_t* uart); | 
					
						
							|  |  |  | int uartGetDebug(); | 
					
						
							|  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2019-09-08 23:59:32 +02:00
										 |  |  | void uartStartDetectBaudrate(uart_t *uart); | 
					
						
							| 
									
										
										
										
											2018-11-19 16:51:55 +01:00
										 |  |  | unsigned long uartDetectBaudrate(uart_t *uart); | 
					
						
							|  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2019-03-03 06:47:24 -08:00
										 |  |  | bool uartRxActive(uart_t* uart); | 
					
						
							|  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2016-10-06 14:21:30 +03:00
										 |  |  | #ifdef __cplusplus
 | 
					
						
							|  |  |  | } | 
					
						
							|  |  |  | #endif
 | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  | #endif /* MAIN_ESP32_HAL_UART_H_ */
 |