ql_uart_internal.h 4.2 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159
  1. /*============================================================================
  2. Copyright (c) 2020 Quectel Wireless Solution, Co., Ltd. All Rights Reserved.
  3. Quectel Wireless Solution Proprietary and Confidential.
  4. =============================================================================*/
  5. /*===========================================================================
  6. EDIT HISTORY FOR MODULE
  7. This section contains comments describing changes made to the module.
  8. Notice that changes are listed in reverse chronological order.
  9. WHEN WHO WHAT, WHERE, WHY
  10. ---------- ------------ ----------------------------------------------------
  11. =============================================================================*/
  12. #ifndef QL_UART_INTERNAL_H
  13. #define QL_UART_INTERNAL_H
  14. #include <stdint.h>
  15. #include <stdbool.h>
  16. #include "quec_common.h"
  17. #include "quec_sio_adapter.h"
  18. #include "ql_uart.h"
  19. #include "ql_api_osi.h"
  20. #include "quec_dispatch.h"
  21. #include "atr_config.h"
  22. #ifdef __cplusplus
  23. extern "C" {
  24. #endif
  25. #define QUEC_TX_MAX_CONTENT_SIZE 20*1024
  26. #define QUEC_TX_MAX_HEADER_SIZE 1024
  27. #define QL_UART_TX_FIFO_SIZE (QUEC_TX_MAX_CONTENT_SIZE+QUEC_TX_MAX_HEADER_SIZE)
  28. #ifdef CONFIG_AT_USB_REDUCE_MEMORY
  29. #define USERIAL_RX_BUF_SIZE (128 * 1024)
  30. #define USERIAL_TX_BUF_SIZE (64 * 1024)
  31. #define USERIAL_RX_DMA_SIZE (2048)
  32. #define USERIAL_TX_DMA_SIZE (2048)
  33. #else
  34. #define USERIAL_RX_BUF_SIZE (256 * 1024)
  35. #define USERIAL_TX_BUF_SIZE (128 * 1024)
  36. #define USERIAL_RX_DMA_SIZE (2048)
  37. #define USERIAL_TX_DMA_SIZE (2048)
  38. #endif
  39. /*========================================================================
  40. * Enumeration Definition
  41. *========================================================================*/
  42. typedef enum
  43. {
  44. DEV_NONE = -1,
  45. DEV_UART1 = QL_UART_PORT_1,
  46. DEV_UART2 = QL_UART_PORT_2,
  47. DEV_UART3 = QL_UART_PORT_3,
  48. DEV_UART4 = QL_UART_PORT_4,
  49. DEV_UART5 = QL_UART_PORT_5,
  50. DEV_UART6 = QL_UART_PORT_6,
  51. DEV_USB_AT = QL_USB_PORT_AT,
  52. DEV_USB_MODEM = QL_USB_PORT_MODEM,
  53. DEV_USB_NMEA = QL_USB_PORT_NMEA,
  54. #ifdef CONFIG_QUEC_PROJECT_FEATURE_CMUX
  55. DEV_CMUX1,
  56. DEV_CMUX2,
  57. DEV_CMUX3,
  58. DEV_CMUX4,
  59. #endif
  60. DEV_USB_DIAG,
  61. DEV_MAX,
  62. } quec_dev_e;
  63. typedef enum
  64. {
  65. QL_UART_CLOSE,
  66. QL_UART_AT_OPEN,
  67. QL_UART_APP_OPEN,
  68. }ql_uart_open_staus_e;
  69. typedef enum
  70. {
  71. DCD_OFF,
  72. DCD_ON,
  73. }quec_dcd_e;
  74. typedef struct
  75. {
  76. atDevice_t *device;
  77. ql_dispatch_t *dispatch;
  78. ql_uart_open_staus_e status;
  79. ql_mutex_t lock;
  80. ql_uart_callback uart_cb;
  81. uint8_t nSim; //for DS-DS
  82. } ql_dev_info_t;
  83. typedef struct
  84. {
  85. char * port_name;
  86. uint32_t drv_name;
  87. } ql_dev_name_info_s;
  88. extern const uint32_t baud_list[];
  89. extern const uint32_t cbaud_list[];
  90. extern const uint32_t autobaud_list[];
  91. extern unsigned baud_list_size;
  92. extern unsigned cbaud_list_size;
  93. extern unsigned autobaud_list_size;
  94. /*========================================================================
  95. * function Definition
  96. *========================================================================*/
  97. ql_dispatch_t *quec_get_dispatch_by_dev(uint32_t dev);
  98. quec_dev_e quec_get_dev_by_dispatch(ql_dispatch_t *dispatch);
  99. bool quec_uart_at_device_create(ql_uart_port_number_e port);
  100. uint8_t quec_get_uart_status(uint32_t dev);
  101. bool quec_uart_is_allow_create(uint32_t drv_name);
  102. void quec_at_device_create_success(uint32_t drv_name, atDevice_t *device, ql_dispatch_t *dispatch);
  103. bool quec_uart_pin_init(ql_uart_port_number_e port);
  104. void quec_write_to_at_dev(quec_dev_e dev,unsigned char * data_buff,unsigned int len);
  105. int quec_at_dispatch_reset(ql_dispatch_t *th);
  106. int quec_at_dispatch_read(ql_dispatch_t *th, uint8 *data, uint len);
  107. ql_dispatch_t *quec_dispatch_create(atDevice_t *device, uint32 name, void *cmux_engine, uint8 dlci);
  108. int quec_at_dispatch_read_avail(ql_dispatch_t *th);
  109. int quec_at_dispatch_write_avail(ql_dispatch_t *th);
  110. atDevice_t *quec_dispatch_get_device(ql_dispatch_t *th);
  111. bool quec_dispatch_bind_sim(ql_dispatch_t* dispatch, uint8_t nSim);
  112. uint8_t quec_get_sim_by_dispatch(ql_dispatch_t *dispatch);
  113. bool quec_at_userial_create(uint32 name, uint rx_size, uint tx_size);
  114. void quec_set_dcd_level(uint8_t dev, quec_dcd_e state);
  115. #ifdef __cplusplus
  116. }/*"C" */
  117. #endif
  118. #endif /*QL_UART_INTERNAL_H*/