1 /*
2  * Copyright 2019-2020, 2023 NXP
3  * All rights reserved.
4  *
5  *
6  * SPDX-License-Identifier: BSD-3-Clause
7  */
8 
9 #ifndef __SERIAL_PORT_INTERNAL_H__
10 #define __SERIAL_PORT_INTERNAL_H__
11 
12 /*******************************************************************************
13  * Definitions
14  ******************************************************************************/
15 
16 /*******************************************************************************
17  * API
18  ******************************************************************************/
19 
20 #if defined(__cplusplus)
21 extern "C" {
22 #endif /* _cplusplus */
23 
24 #if (defined(SERIAL_PORT_TYPE_UART) && (SERIAL_PORT_TYPE_UART > 0U))
25 serial_manager_status_t Serial_UartInit(serial_handle_t serialHandle, void *serialConfig);
26 serial_manager_status_t Serial_UartDeinit(serial_handle_t serialHandle);
27 serial_manager_status_t Serial_UartWrite(serial_handle_t serialHandle, uint8_t *buffer, uint32_t length);
28 serial_manager_status_t Serial_UartRead(serial_handle_t serialHandle, uint8_t *buffer, uint32_t length);
29 #if (defined(SERIAL_MANAGER_NON_BLOCKING_MODE) && (SERIAL_MANAGER_NON_BLOCKING_MODE > 0U))
30 serial_manager_status_t Serial_UartCancelWrite(serial_handle_t serialHandle);
31 serial_manager_status_t Serial_UartInstallTxCallback(serial_handle_t serialHandle,
32                                                      serial_manager_callback_t callback,
33                                                      void *callbackParam);
34 serial_manager_status_t Serial_UartInstallRxCallback(serial_handle_t serialHandle,
35                                                      serial_manager_callback_t callback,
36                                                      void *callbackParam);
37 void Serial_UartIsrFunction(serial_handle_t serialHandle);
38 #endif
39 serial_manager_status_t Serial_UartEnterLowpower(serial_handle_t serialHandle);
40 serial_manager_status_t Serial_UartExitLowpower(serial_handle_t serialHandle);
41 #endif
42 #if (defined(SERIAL_PORT_TYPE_UART_DMA) && (SERIAL_PORT_TYPE_UART_DMA > 0U))
43 serial_manager_status_t Serial_UartDmaInit(serial_handle_t serialHandle, void *serialConfig);
44 serial_manager_status_t Serial_UartDmaDeinit(serial_handle_t serialHandle);
45 serial_manager_status_t Serial_UartDmaWrite(serial_handle_t serialHandle, uint8_t *buffer, uint32_t length);
46 
47 #if (defined(SERIAL_MANAGER_NON_BLOCKING_MODE) && (SERIAL_MANAGER_NON_BLOCKING_MODE > 0U))
48 serial_manager_status_t Serial_UartDmaCancelWrite(serial_handle_t serialHandle);
49 serial_manager_status_t Serial_UartDmaInstallTxCallback(serial_handle_t serialHandle,
50                                                         serial_manager_callback_t callback,
51                                                         void *callbackParam);
52 serial_manager_status_t Serial_UartDmaInstallRxCallback(serial_handle_t serialHandle,
53                                                         serial_manager_callback_t callback,
54                                                         void *callbackParam);
55 void Serial_UartDmaIsrFunction(serial_handle_t serialHandle);
56 #endif
57 serial_manager_status_t Serial_UartDmaEnterLowpower(serial_handle_t serialHandle);
58 serial_manager_status_t Serial_UartDmaExitLowpower(serial_handle_t serialHandle);
59 #endif
60 
61 #if (defined(SERIAL_PORT_TYPE_RPMSG) && (SERIAL_PORT_TYPE_RPMSG > 0U))
62 serial_manager_status_t Serial_RpmsgInit(serial_handle_t serialHandle, void *serialConfig);
63 serial_manager_status_t Serial_RpmsgDeinit(serial_handle_t serialHandle);
64 serial_manager_status_t Serial_RpmsgWrite(serial_handle_t serialHandle, uint8_t *buffer, uint32_t length);
65 serial_manager_status_t Serial_RpmsgWriteBlocking(serial_handle_t serialHandle, uint8_t *buffer, uint32_t length);
66 #if !(defined(SERIAL_MANAGER_NON_BLOCKING_MODE) && (SERIAL_MANAGER_NON_BLOCKING_MODE > 0U))
67 serial_manager_status_t Serial_RpmsgRead(serial_handle_t serialHandle, uint8_t *buffer, uint32_t length);
68 #endif
69 
70 #if (defined(SERIAL_MANAGER_NON_BLOCKING_MODE) && (SERIAL_MANAGER_NON_BLOCKING_MODE > 0U))
71 serial_manager_status_t Serial_RpmsgCancelWrite(serial_handle_t serialHandle);
72 serial_manager_status_t Serial_RpmsgInstallTxCallback(serial_handle_t serialHandle,
73                                                       serial_manager_callback_t callback,
74                                                       void *callbackParam);
75 serial_manager_status_t Serial_RpmsgInstallRxCallback(serial_handle_t serialHandle,
76                                                       serial_manager_callback_t callback,
77                                                       void *callbackParam);
78 #endif
79 serial_manager_status_t Serial_RpmsgEnterLowpower(serial_handle_t serialHandle);
80 serial_manager_status_t Serial_RpmsgExitLowpower(serial_handle_t serialHandle);
81 #endif
82 
83 #if (defined(SERIAL_PORT_TYPE_USBCDC) && (SERIAL_PORT_TYPE_USBCDC > 0U))
84 serial_manager_status_t Serial_UsbCdcInit(serial_handle_t serialHandle, void *config);
85 serial_manager_status_t Serial_UsbCdcDeinit(serial_handle_t serialHandle);
86 serial_manager_status_t Serial_UsbCdcWrite(serial_handle_t serialHandle, uint8_t *buffer, uint32_t length);
87 serial_manager_status_t Serial_UsbCdcRead(serial_handle_t serialHandle, uint8_t *buffer, uint32_t length);
88 serial_manager_status_t Serial_UsbCdcCancelWrite(serial_handle_t serialHandle);
89 serial_manager_status_t Serial_UsbCdcInstallTxCallback(serial_handle_t serialHandle,
90                                                        serial_manager_callback_t callback,
91                                                        void *callbackParam);
92 serial_manager_status_t Serial_UsbCdcInstallRxCallback(serial_handle_t serialHandle,
93                                                        serial_manager_callback_t callback,
94                                                        void *callbackParam);
95 void Serial_UsbCdcIsrFunction(serial_handle_t serialHandle);
96 #endif
97 
98 #if (defined(SERIAL_PORT_TYPE_SWO) && (SERIAL_PORT_TYPE_SWO > 0U))
99 serial_manager_status_t Serial_SwoInit(serial_handle_t serialHandle, void *config);
100 serial_manager_status_t Serial_SwoDeinit(serial_handle_t serialHandle);
101 serial_manager_status_t Serial_SwoWrite(serial_handle_t serialHandle, uint8_t *buffer, uint32_t length);
102 #if !(defined(SERIAL_MANAGER_NON_BLOCKING_MODE) && (SERIAL_MANAGER_NON_BLOCKING_MODE > 0U))
103 serial_manager_status_t Serial_SwoRead(serial_handle_t serialHandle, uint8_t *buffer, uint32_t length);
104 #endif
105 #if (defined(SERIAL_MANAGER_NON_BLOCKING_MODE) && (SERIAL_MANAGER_NON_BLOCKING_MODE > 0U))
106 serial_manager_status_t Serial_SwoCancelWrite(serial_handle_t serialHandle);
107 serial_manager_status_t Serial_SwoInstallTxCallback(serial_handle_t serialHandle,
108                                                     serial_manager_callback_t callback,
109                                                     void *callbackParam);
110 serial_manager_status_t Serial_SwoInstallRxCallback(serial_handle_t serialHandle,
111                                                     serial_manager_callback_t callback,
112                                                     void *callbackParam);
113 void Serial_SwoIsrFunction(serial_handle_t serialHandle);
114 #endif
115 #endif
116 
117 #if (defined(SERIAL_PORT_TYPE_VIRTUAL) && (SERIAL_PORT_TYPE_VIRTUAL > 0U))
118 serial_manager_status_t Serial_PortVirtualInit(serial_handle_t serialHandle, void *config);
119 serial_manager_status_t Serial_PortVirtualDeinit(serial_handle_t serialHandle);
120 serial_manager_status_t Serial_PortVirtualWrite(serial_handle_t serialHandle, uint8_t *buffer, uint32_t length);
121 serial_manager_status_t Serial_PortVirtualRead(serial_handle_t serialHandle, uint8_t *buffer, uint32_t length);
122 serial_manager_status_t Serial_PortVirtualCancelWrite(serial_handle_t serialHandle);
123 serial_manager_status_t Serial_PortVirtualInstallTxCallback(serial_handle_t serialHandle,
124                                                             serial_manager_callback_t callback,
125                                                             void *callbackParam);
126 serial_manager_status_t Serial_PortVirtualInstallRxCallback(serial_handle_t serialHandle,
127                                                             serial_manager_callback_t callback,
128                                                             void *callbackParam);
129 void Serial_PortVirtualIsrFunction(serial_handle_t serialHandle);
130 #endif
131 #if (defined(SERIAL_PORT_TYPE_SPI_MASTER) && SERIAL_PORT_TYPE_SPI_MASTER > 0U)
132 serial_manager_status_t Serial_SpiMasterInit(serial_handle_t serialHandle, void *serialConfig);
133 serial_manager_status_t Serial_SpiMasterDeinit(serial_handle_t serialHandle);
134 void Serial_SpiMasterTxCallback(hal_spi_master_handle_t handle, hal_spi_status_t status, void *callbackParam);
135 void Serial_SpiMasterRxCallback(hal_spi_master_handle_t handle, hal_spi_status_t status, void *callbackParam);
136 serial_manager_status_t Serial_SpiMasterWrite(serial_handle_t serialHandle, uint8_t *buffer, uint32_t length);
137 serial_manager_status_t Serial_SpiMasterRead(serial_handle_t serialHandle, uint8_t *buffer, uint32_t length);
138 #if (defined(SERIAL_MANAGER_NON_BLOCKING_MODE) && (SERIAL_MANAGER_NON_BLOCKING_MODE > 0U))
139 serial_manager_status_t Serial_SpiMasterInstallTxCallback(serial_handle_t serialHandle,
140                                                           serial_manager_callback_t callback,
141                                                           void *callbackParam);
142 serial_manager_status_t Serial_SpiMasterInstallRxCallback(serial_handle_t serialHandle,
143                                                           serial_manager_callback_t callback,
144                                                           void *callbackParam);
145 serial_manager_status_t Serial_SpiMasterCancelWrite(serial_handle_t serialHandle);
146 
147 #endif
148 #endif
149 
150 #if (defined(SERIAL_PORT_TYPE_SPI_SLAVE) && (SERIAL_PORT_TYPE_SPI_SLAVE > 0U))
151 serial_manager_status_t Serial_SpiSlaveInit(serial_handle_t serialHandle, void *serialConfig);
152 serial_manager_status_t Serial_SpiSlaveDeinit(serial_handle_t serialHandle);
153 void Serial_SpiSlaveTxCallback(hal_spi_slave_handle_t handle, hal_spi_status_t status, void *callbackParam);
154 void Serial_SpiSlaveRxCallback(hal_spi_slave_handle_t handle, hal_spi_status_t status, void *callbackParam);
155 serial_manager_status_t Serial_SpiSlaveWrite(serial_handle_t serialHandle, uint8_t *buffer, uint32_t length);
156 serial_manager_status_t Serial_SpiSlaveRead(serial_handle_t serialHandle, uint8_t *buffer, uint32_t length);
157 
158 #if (defined(SERIAL_MANAGER_NON_BLOCKING_MODE) && (SERIAL_MANAGER_NON_BLOCKING_MODE > 0U))
159 serial_manager_status_t Serial_SpiSlaveInstallTxCallback(serial_handle_t serialHandle,
160                                                          serial_manager_callback_t callback,
161                                                          void *callbackParam);
162 serial_manager_status_t Serial_SpiSlaveInstallRxCallback(serial_handle_t serialHandle,
163                                                          serial_manager_callback_t callback,
164                                                          void *callbackParam);
165 serial_manager_status_t Serial_SpiSlaveCancelWrite(serial_handle_t serialHandle);
166 
167 #endif
168 #endif
169 
170 #if (defined(SERIAL_PORT_TYPE_BLE_WU) && (SERIAL_PORT_TYPE_BLE_WU > 0U))
171 serial_manager_status_t Serial_PortBleWuInit(serial_handle_t serialHandle, void *config);
172 serial_manager_status_t Serial_PortBleWuDeinit(serial_handle_t serialHandle);
173 serial_manager_status_t Serial_PortBleWuWrite(serial_handle_t serialHandle, uint8_t *buffer, uint32_t length);
174 serial_manager_status_t Serial_PortBleWuRead(serial_handle_t serialHandle, uint8_t *buffer, uint32_t length);
175 serial_manager_status_t Serial_PortBleWuCancelWrite(serial_handle_t serialHandle);
176 serial_manager_status_t Serial_PortBleWuInstallTxCallback(serial_handle_t serialHandle,
177                                                           serial_manager_callback_t callback,
178                                                           void *callbackParam);
179 serial_manager_status_t Serial_PortBleWuInstallRxCallback(serial_handle_t serialHandle,
180                                                           serial_manager_callback_t callback,
181                                                           void *callbackParam);
182 void Serial_PortBleWuIsrFunction(serial_handle_t serialHandle);
183 #endif
184 
185 #if defined(__cplusplus)
186 }
187 #endif
188 
189 #endif /* __SERIAL_PORT_INTERNAL_H__ */
190