13 #if (defined(SERIAL_PORT_TYPE_UART) && (SERIAL_PORT_TYPE_UART > 0U))
22 #if (defined(DEBUG_CONSOLE_ASSERT_DISABLE) && (DEBUG_CONSOLE_ASSERT_DISABLE > 0U))
28 #if (defined(SERIAL_MANAGER_NON_BLOCKING_MODE) && (SERIAL_MANAGER_NON_BLOCKING_MODE > 0U))
29 #define SERIAL_PORT_UART_RECEIVE_DATA_LENGTH 1U
31 typedef struct _serial_uart_send_state
37 volatile uint8_t busy;
38 } serial_uart_send_state_t;
40 typedef struct _serial_uart_recv_state
44 volatile uint8_t busy;
45 uint8_t readBuffer[SERIAL_PORT_UART_RECEIVE_DATA_LENGTH];
46 } serial_uart_recv_state_t;
49 typedef struct _serial_uart_state
51 #if (defined(SERIAL_MANAGER_NON_BLOCKING_MODE) && (SERIAL_MANAGER_NON_BLOCKING_MODE > 0U))
52 serial_uart_send_state_t tx;
53 serial_uart_recv_state_t rx;
56 } serial_uart_state_t;
66 #if (defined(SERIAL_MANAGER_NON_BLOCKING_MODE) && (SERIAL_MANAGER_NON_BLOCKING_MODE > 0U))
70 serial_uart_state_t *serialUartHandle;
72 #if (defined(HAL_UART_TRANSFER_MODE) && (HAL_UART_TRANSFER_MODE > 0U))
81 serialUartHandle = (serial_uart_state_t *)userData;
85 if ((
NULL != serialUartHandle->rx.callback))
87 msg.
buffer = &serialUartHandle->rx.readBuffer[0];
88 msg.
length =
sizeof(serialUartHandle->rx.readBuffer);
91 #if (defined(HAL_UART_TRANSFER_MODE) && (HAL_UART_TRANSFER_MODE > 0U))
92 transfer.
data = &serialUartHandle->rx.readBuffer[0];
93 transfer.
dataSize =
sizeof(serialUartHandle->rx.readBuffer);
95 HAL_UartTransferReceiveNonBlocking(((
hal_uart_handle_t)&serialUartHandle->usartHandleBuffer[0]), &transfer))
98 HAL_UartReceiveNonBlocking(((
hal_uart_handle_t)&serialUartHandle->usartHandleBuffer[0]),
99 &serialUartHandle->rx.readBuffer[0],
sizeof(serialUartHandle->rx.readBuffer)))
102 serialUartHandle->rx.busy = 1U;
106 serialUartHandle->rx.busy = 0U;
111 if (0U != serialUartHandle->tx.busy)
113 serialUartHandle->tx.busy = 0U;
114 if ((
NULL != serialUartHandle->tx.callback))
116 msg.
buffer = serialUartHandle->tx.buffer;
117 msg.
length = serialUartHandle->tx.length;
130 serial_uart_state_t *serialUartHandle;
133 #if (defined(SERIAL_MANAGER_NON_BLOCKING_MODE) && (SERIAL_MANAGER_NON_BLOCKING_MODE > 0U))
134 #if (defined(HAL_UART_TRANSFER_MODE) && (HAL_UART_TRANSFER_MODE > 0U))
139 assert(serialConfig);
140 assert(serialHandle);
144 serialUartHandle = (serial_uart_state_t *)serialHandle;
159 #if (defined(SERIAL_MANAGER_NON_BLOCKING_MODE) && (SERIAL_MANAGER_NON_BLOCKING_MODE > 0U))
161 #if (defined(HAL_UART_TRANSFER_MODE) && (HAL_UART_TRANSFER_MODE > 0U))
163 HAL_UartTransferInstallCallback(((
hal_uart_handle_t)&serialUartHandle->usartHandleBuffer[0]),
164 Serial_UartCallback, serialUartHandle))
167 Serial_UartCallback, serialUartHandle))
175 serialUartHandle->rx.busy = 1U;
176 #if (defined(HAL_UART_TRANSFER_MODE) && (HAL_UART_TRANSFER_MODE > 0U))
177 transfer.
data = &serialUartHandle->rx.readBuffer[0];
178 transfer.
dataSize =
sizeof(serialUartHandle->rx.readBuffer);
180 HAL_UartTransferReceiveNonBlocking(((
hal_uart_handle_t)&serialUartHandle->usartHandleBuffer[0]), &transfer))
183 HAL_UartReceiveNonBlocking(((
hal_uart_handle_t)&serialUartHandle->usartHandleBuffer[0]),
184 &serialUartHandle->rx.readBuffer[0],
sizeof(serialUartHandle->rx.readBuffer)))
187 serialUartHandle->rx.busy = 0U;
198 serial_uart_state_t *serialUartHandle;
200 assert(serialHandle);
202 serialUartHandle = (serial_uart_state_t *)serialHandle;
204 #if (defined(SERIAL_MANAGER_NON_BLOCKING_MODE) && (SERIAL_MANAGER_NON_BLOCKING_MODE > 0U))
205 #if (defined(HAL_UART_TRANSFER_MODE) && (HAL_UART_TRANSFER_MODE > 0U))
206 (void)HAL_UartTransferAbortReceive(((
hal_uart_handle_t)&serialUartHandle->usartHandleBuffer[0]));
208 (void)HAL_UartAbortReceive(((
hal_uart_handle_t)&serialUartHandle->usartHandleBuffer[0]));
213 #if (defined(SERIAL_MANAGER_NON_BLOCKING_MODE) && (SERIAL_MANAGER_NON_BLOCKING_MODE > 0U))
214 serialUartHandle->tx.busy = 0U;
215 serialUartHandle->rx.busy = 0U;
221 #if (defined(SERIAL_MANAGER_NON_BLOCKING_MODE) && (SERIAL_MANAGER_NON_BLOCKING_MODE > 0U))
225 serial_uart_state_t *serialUartHandle;
226 #if (defined(HAL_UART_TRANSFER_MODE) && (HAL_UART_TRANSFER_MODE > 0U))
230 assert(serialHandle);
234 serialUartHandle = (serial_uart_state_t *)serialHandle;
236 if (0U != serialUartHandle->tx.busy)
240 serialUartHandle->tx.busy = 1U;
242 serialUartHandle->tx.buffer = buffer;
243 serialUartHandle->tx.length = length;
245 #if (defined(HAL_UART_TRANSFER_MODE) && (HAL_UART_TRANSFER_MODE > 0U))
246 transfer.
data = buffer;
249 HAL_UartTransferSendNonBlocking(((
hal_uart_handle_t)&serialUartHandle->usartHandleBuffer[0]), &transfer))
252 HAL_UartSendNonBlocking(((
hal_uart_handle_t)&serialUartHandle->usartHandleBuffer[0]), buffer, length))
255 serialUartHandle->tx.busy = 0U;
265 serial_uart_state_t *serialUartHandle;
267 assert(serialHandle);
271 serialUartHandle = (serial_uart_state_t *)serialHandle;
279 serial_uart_state_t *serialUartHandle;
281 assert(serialHandle);
285 serialUartHandle = (serial_uart_state_t *)serialHandle;
293 #if (defined(SERIAL_MANAGER_NON_BLOCKING_MODE) && (SERIAL_MANAGER_NON_BLOCKING_MODE > 0U))
296 serial_uart_state_t *serialUartHandle;
301 assert(serialHandle);
303 serialUartHandle = (serial_uart_state_t *)serialHandle;
306 isBusy = serialUartHandle->tx.busy;
307 serialUartHandle->tx.busy = 0U;
310 #if (defined(HAL_UART_TRANSFER_MODE) && (HAL_UART_TRANSFER_MODE > 0U))
311 (void)HAL_UartTransferAbortSend(((
hal_uart_handle_t)&serialUartHandle->usartHandleBuffer[0]));
313 (void)HAL_UartAbortSend(((
hal_uart_handle_t)&serialUartHandle->usartHandleBuffer[0]));
317 if ((
NULL != serialUartHandle->tx.callback))
319 msg.
buffer = serialUartHandle->tx.buffer;
320 msg.
length = serialUartHandle->tx.length;
331 serial_uart_state_t *serialUartHandle;
333 assert(serialHandle);
335 serialUartHandle = (serial_uart_state_t *)serialHandle;
337 serialUartHandle->tx.callback = callback;
338 serialUartHandle->tx.callbackParam = callbackParam;
347 serial_uart_state_t *serialUartHandle;
349 assert(serialHandle);
351 serialUartHandle = (serial_uart_state_t *)serialHandle;
353 serialUartHandle->rx.callback = callback;
354 serialUartHandle->rx.callbackParam = callbackParam;
361 serial_uart_state_t *serialUartHandle;
363 assert(serialHandle);
365 serialUartHandle = (serial_uart_state_t *)serialHandle;
367 HAL_UartIsrFunction(((
hal_uart_handle_t)&serialUartHandle->usartHandleBuffer[0]));
373 serial_uart_state_t *serialUartHandle;
375 assert(serialHandle);
377 serialUartHandle = (serial_uart_state_t *)serialHandle;
389 serial_uart_state_t *serialUartHandle;
391 assert(serialHandle);
393 serialUartHandle = (serial_uart_state_t *)serialHandle;