| 
									
										
										
										
											2021-03-29 19:34:45 +02:00
										 |  |  | /*
 | 
					
						
							|  |  |  |  * SPDX-FileCopyrightText: 2021-2022 Espressif Systems (Shanghai) CO LTD | 
					
						
							| 
									
										
										
										
											2022-10-11 16:31:57 +02:00
										 |  |  |  * | 
					
						
							| 
									
										
										
										
											2021-03-29 19:34:45 +02:00
										 |  |  |  * SPDX-License-Identifier: Apache-2.0 | 
					
						
							|  |  |  |  */ | 
					
						
							| 
									
										
										
										
											2021-03-08 15:10:15 +01:00
										 |  |  | 
 | 
					
						
							| 
									
										
										
										
											2021-05-26 15:57:25 +02:00
										 |  |  | #pragma once
 | 
					
						
							|  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2021-03-08 15:10:15 +01:00
										 |  |  | #include "driver/uart.h"
 | 
					
						
							| 
									
										
										
										
											2021-03-28 13:38:20 +02:00
										 |  |  | #include "esp_modem_dce_config.h"
 | 
					
						
							| 
									
										
										
										
											2021-03-08 15:10:15 +01:00
										 |  |  | 
 | 
					
						
							| 
									
										
										
										
											2021-05-26 16:41:19 +08:00
										 |  |  | #ifdef __cplusplus
 | 
					
						
							|  |  |  | extern "C" { | 
					
						
							|  |  |  | #endif
 | 
					
						
							|  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2021-04-14 17:57:42 +02:00
										 |  |  | /**
 | 
					
						
							|  |  |  |  * @defgroup ESP_MODEM_CONFIG | 
					
						
							|  |  |  |  * @brief Configuration structures for DTE and DCE | 
					
						
							|  |  |  |  */ | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  | /** @addtogroup ESP_MODEM_CONFIG
 | 
					
						
							|  |  |  |  * @{ | 
					
						
							|  |  |  |  */ | 
					
						
							|  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2021-03-08 15:10:15 +01:00
										 |  |  | /**
 | 
					
						
							|  |  |  |  * @brief Modem flow control type | 
					
						
							|  |  |  |  * | 
					
						
							|  |  |  |  */ | 
					
						
							|  |  |  | typedef enum { | 
					
						
							|  |  |  |     ESP_MODEM_FLOW_CONTROL_NONE = 0, | 
					
						
							|  |  |  |     ESP_MODEM_FLOW_CONTROL_SW, | 
					
						
							|  |  |  |     ESP_MODEM_FLOW_CONTROL_HW | 
					
						
							|  |  |  | } esp_modem_flow_ctrl_t; | 
					
						
							|  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2021-04-14 17:57:42 +02:00
										 |  |  | /**
 | 
					
						
							| 
									
										
										
										
											2021-05-17 18:24:35 +02:00
										 |  |  |  * @brief UART configuration structure | 
					
						
							| 
									
										
										
										
											2021-04-14 17:57:42 +02:00
										 |  |  |  * | 
					
						
							|  |  |  |  */ | 
					
						
							| 
									
										
										
										
											2021-04-18 19:14:22 +02:00
										 |  |  | struct esp_modem_uart_term_config { | 
					
						
							| 
									
										
										
										
											2021-03-08 15:10:15 +01:00
										 |  |  |     uart_port_t port_num;           /*!< UART port number */ | 
					
						
							|  |  |  |     uart_word_length_t data_bits;   /*!< Data bits of UART */ | 
					
						
							|  |  |  |     uart_stop_bits_t stop_bits;     /*!< Stop bits of UART */ | 
					
						
							|  |  |  |     uart_parity_t parity;           /*!< Parity type */ | 
					
						
							|  |  |  |     esp_modem_flow_ctrl_t flow_control; /*!< Flow control type */ | 
					
						
							| 
									
										
										
										
											2022-06-22 15:37:06 +02:00
										 |  |  |     uart_sclk_t source_clk;         /*!< UART source clock selection */ | 
					
						
							|  |  |  |     int baud_rate;                  /*!< Communication baud rate */ | 
					
						
							| 
									
										
										
										
											2021-03-08 15:10:15 +01:00
										 |  |  |     int tx_io_num;                  /*!< TXD Pin Number */ | 
					
						
							|  |  |  |     int rx_io_num;                  /*!< RXD Pin Number */ | 
					
						
							|  |  |  |     int rts_io_num;                 /*!< RTS Pin Number */ | 
					
						
							|  |  |  |     int cts_io_num;                 /*!< CTS Pin Number */ | 
					
						
							|  |  |  |     int rx_buffer_size;             /*!< UART RX Buffer Size */ | 
					
						
							|  |  |  |     int tx_buffer_size;             /*!< UART TX Buffer Size */ | 
					
						
							| 
									
										
										
										
											2021-05-17 14:59:03 +02:00
										 |  |  |     int event_queue_size;           /*!< UART Event Queue Size, set to 0 if no event queue needed */ | 
					
						
							| 
									
										
										
										
											2021-03-08 15:10:15 +01:00
										 |  |  | }; | 
					
						
							|  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2021-05-26 16:41:19 +08:00
										 |  |  | // Forward declare the resource struct
 | 
					
						
							|  |  |  | struct esp_modem_vfs_resource; | 
					
						
							|  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2021-05-17 18:24:35 +02:00
										 |  |  | /**
 | 
					
						
							|  |  |  |  * @brief VFS configuration structure | 
					
						
							|  |  |  |  * | 
					
						
							|  |  |  |  */ | 
					
						
							| 
									
										
										
										
											2021-05-06 18:57:07 +02:00
										 |  |  | struct esp_modem_vfs_term_config { | 
					
						
							| 
									
										
										
										
											2021-05-23 20:43:50 +02:00
										 |  |  |     int fd;                                     /*!< Already created file descriptor */ | 
					
						
							|  |  |  |     void (*deleter)(int, struct esp_modem_vfs_resource *);            /*!< Custom close function for the fd */ | 
					
						
							|  |  |  |     struct esp_modem_vfs_resource *resource;    /*!< Resource attached to the VFS (need for clenaup) */ | 
					
						
							| 
									
										
										
										
											2021-05-06 18:57:07 +02:00
										 |  |  | }; | 
					
						
							|  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2021-05-17 18:24:35 +02:00
										 |  |  | /**
 | 
					
						
							|  |  |  |  * @brief Complete DTE configuration structure | 
					
						
							|  |  |  |  * | 
					
						
							|  |  |  |  * Note that the generic part is common for DTE and its SW resources | 
					
						
							|  |  |  |  * The following portions for config is dedicated to the chosen HW resource | 
					
						
							|  |  |  |  * used as a communication terminal for this DTE | 
					
						
							|  |  |  |  */ | 
					
						
							| 
									
										
										
										
											2021-04-18 19:14:22 +02:00
										 |  |  | struct esp_modem_dte_config { | 
					
						
							| 
									
										
										
										
											2021-05-17 14:59:03 +02:00
										 |  |  |     size_t dte_buffer_size;                             /*!< DTE buffer size */ | 
					
						
							|  |  |  |     uint32_t task_stack_size;                           /*!< Terminal task stack size */ | 
					
						
							| 
									
										
										
										
											2022-03-17 12:13:10 +01:00
										 |  |  |     unsigned task_priority;                             /*!< Terminal task priority */ | 
					
						
							| 
									
										
										
										
											2021-05-23 20:43:50 +02:00
										 |  |  |     union { | 
					
						
							|  |  |  |         struct esp_modem_uart_term_config uart_config;      /*!< Configuration for UART Terminal */ | 
					
						
							|  |  |  |         struct esp_modem_vfs_term_config vfs_config;        /*!< Configuration for VFS Terminal */ | 
					
						
							| 
									
										
										
										
											2022-03-17 12:13:10 +01:00
										 |  |  |         void *extension_config;                             /*!< Configuration for app specific Terminal */ | 
					
						
							| 
									
										
										
										
											2021-05-23 20:43:50 +02:00
										 |  |  |     }; | 
					
						
							| 
									
										
										
										
											2021-04-18 19:14:22 +02:00
										 |  |  | }; | 
					
						
							|  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2023-03-08 11:47:28 +01:00
										 |  |  | #if ESP_IDF_VERSION_MAJOR >= 5
 | 
					
						
							|  |  |  | #define ESP_MODEM_DEFAULT_UART_CLK      UART_SCLK_DEFAULT
 | 
					
						
							|  |  |  | #else
 | 
					
						
							|  |  |  | #define ESP_MODEM_DEFAULT_UART_CLK      UART_SCLK_APB
 | 
					
						
							|  |  |  | #endif
 | 
					
						
							| 
									
										
										
										
											2021-04-18 19:14:22 +02:00
										 |  |  | 
 | 
					
						
							| 
									
										
										
										
											2021-03-08 15:10:15 +01:00
										 |  |  | /**
 | 
					
						
							|  |  |  |  * @brief ESP Modem DTE Default Configuration | 
					
						
							|  |  |  |  * | 
					
						
							|  |  |  |  */ | 
					
						
							| 
									
										
										
										
											2021-04-18 19:14:22 +02:00
										 |  |  | #define ESP_MODEM_DTE_DEFAULT_CONFIG() \
 | 
					
						
							|  |  |  |     {                                  \ | 
					
						
							|  |  |  |         .dte_buffer_size = 512,        \ | 
					
						
							| 
									
										
										
										
											2023-03-08 11:47:28 +01:00
										 |  |  |         .task_stack_size = 4096,       \ | 
					
						
							|  |  |  |         .task_priority = 5,            \ | 
					
						
							| 
									
										
										
										
											2021-05-17 14:59:03 +02:00
										 |  |  |         .uart_config = {               \ | 
					
						
							| 
									
										
										
										
											2021-04-18 19:14:22 +02:00
										 |  |  |             .port_num = UART_NUM_1,                 \ | 
					
						
							|  |  |  |             .data_bits = UART_DATA_8_BITS,          \ | 
					
						
							|  |  |  |             .stop_bits = UART_STOP_BITS_1,          \ | 
					
						
							|  |  |  |             .parity = UART_PARITY_DISABLE,          \ | 
					
						
							|  |  |  |             .flow_control = ESP_MODEM_FLOW_CONTROL_NONE,\ | 
					
						
							| 
									
										
										
										
											2023-03-08 11:47:28 +01:00
										 |  |  |             .source_clk = ESP_MODEM_DEFAULT_UART_CLK,   \ | 
					
						
							| 
									
										
										
										
											2021-04-18 19:14:22 +02:00
										 |  |  |             .baud_rate = 115200,                    \ | 
					
						
							|  |  |  |             .tx_io_num = 25,                        \ | 
					
						
							|  |  |  |             .rx_io_num = 26,                        \ | 
					
						
							|  |  |  |             .rts_io_num = 27,                       \ | 
					
						
							|  |  |  |             .cts_io_num = 23,                       \ | 
					
						
							| 
									
										
										
										
											2021-05-15 22:09:08 +02:00
										 |  |  |             .rx_buffer_size = 4096,                 \ | 
					
						
							| 
									
										
										
										
											2021-04-18 19:14:22 +02:00
										 |  |  |             .tx_buffer_size = 512,                  \ | 
					
						
							|  |  |  |             .event_queue_size = 30,                 \ | 
					
						
							| 
									
										
										
										
											2021-05-17 14:59:03 +02:00
										 |  |  |        },                                           \ | 
					
						
							| 
									
										
										
										
											2021-03-08 15:10:15 +01:00
										 |  |  |     } | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  | typedef struct esp_modem_dte_config esp_modem_dte_config_t; | 
					
						
							|  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2021-04-14 17:57:42 +02:00
										 |  |  | /**
 | 
					
						
							|  |  |  |  * @} | 
					
						
							|  |  |  |  */ | 
					
						
							|  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2021-05-26 16:41:19 +08:00
										 |  |  | #ifdef __cplusplus
 | 
					
						
							|  |  |  | } | 
					
						
							|  |  |  | #endif
 |