3 * All rights reserved.
\r
6 * SPDX-License-Identifier: BSD-3-Clause
\r
9 #ifndef __SERIAL_MANAGER_H__
\r
10 #define __SERIAL_MANAGER_H__
\r
12 /*******************************************************************************
\r
14 ******************************************************************************/
\r
15 #ifdef DEBUG_CONSOLE_TRANSFER_NON_BLOCKING
\r
16 #define SERIAL_MANAGER_NON_BLOCKING_MODE \
\r
17 (1U) /* Enable or disable serial manager non-blocking mode (1 - enable, 0 - disable) */
\r
19 #ifndef SERIAL_MANAGER_NON_BLOCKING_MODE
\r
20 #define SERIAL_MANAGER_NON_BLOCKING_MODE \
\r
21 (0U) /* Enable or disable serial manager non-blocking mode (1 - enable, 0 - disable) */
\r
25 #ifndef SERIAL_PORT_TYPE_UART
\r
26 #define SERIAL_PORT_TYPE_UART (1U) /* Enable or disable uart port (1 - enable, 0 - disable) */
\r
29 #ifndef SERIAL_PORT_TYPE_USBCDC
\r
30 #define SERIAL_PORT_TYPE_USBCDC (0U) /* Enable or disable USB CDC port (1 - enable, 0 - disable) */
\r
33 #ifndef SERIAL_PORT_TYPE_SWO
\r
34 #define SERIAL_PORT_TYPE_SWO (0U) /* Enable or disable SWO port (1 - enable, 0 - disable) */
\r
37 #if (defined(SERIAL_MANAGER_NON_BLOCKING_MODE) && (SERIAL_MANAGER_NON_BLOCKING_MODE > 0U))
\r
38 #define SERIAL_MANAGER_WRITE_HANDLE_SIZE (44U)
\r
39 #define SERIAL_MANAGER_READ_HANDLE_SIZE (44U)
\r
41 #define SERIAL_MANAGER_WRITE_HANDLE_SIZE (4U)
\r
42 #define SERIAL_MANAGER_READ_HANDLE_SIZE (4U)
\r
45 #if (defined(SERIAL_PORT_TYPE_UART) && (SERIAL_PORT_TYPE_UART > 0U))
\r
46 #include "serial_port_uart.h"
\r
49 #if (defined(SERIAL_PORT_TYPE_USBCDC) && (SERIAL_PORT_TYPE_USBCDC > 0U))
\r
51 #if !(defined(SERIAL_MANAGER_NON_BLOCKING_MODE) && (SERIAL_MANAGER_NON_BLOCKING_MODE > 0U))
\r
52 #error The serial manager blocking mode cannot be supported for USB CDC.
\r
55 #include "serial_port_usb.h"
\r
58 #if (defined(SERIAL_PORT_TYPE_SWO) && (SERIAL_PORT_TYPE_SWO > 0U))
\r
59 #include "serial_port_swo.h"
\r
62 #define SERIAL_MANAGER_HANDLE_SIZE_TEMP 0U
\r
63 #if (defined(SERIAL_PORT_TYPE_UART) && (SERIAL_PORT_TYPE_UART > 0U))
\r
65 #if (SERIAL_PORT_UART_HANDLE_SIZE > SERIAL_MANAGER_HANDLE_SIZE_TEMP)
\r
66 #undef SERIAL_MANAGER_HANDLE_SIZE_TEMP
\r
67 #define SERIAL_MANAGER_HANDLE_SIZE_TEMP SERIAL_PORT_UART_HANDLE_SIZE
\r
72 #if (defined(SERIAL_PORT_TYPE_USBCDC) && (SERIAL_PORT_TYPE_USBCDC > 0U))
\r
74 #if (SERIAL_PORT_USB_CDC_HANDLE_SIZE > SERIAL_MANAGER_HANDLE_SIZE_TEMP)
\r
75 #undef SERIAL_MANAGER_HANDLE_SIZE_TEMP
\r
76 #define SERIAL_MANAGER_HANDLE_SIZE_TEMP SERIAL_PORT_USB_CDC_HANDLE_SIZE
\r
81 #if (defined(SERIAL_PORT_TYPE_SWO) && (SERIAL_PORT_TYPE_SWO > 0U))
\r
83 #if (SERIAL_PORT_SWO_HANDLE_SIZE > SERIAL_MANAGER_HANDLE_SIZE_TEMP)
\r
84 #undef SERIAL_MANAGER_HANDLE_SIZE_TEMP
\r
85 #define SERIAL_MANAGER_HANDLE_SIZE_TEMP SERIAL_PORT_SWO_HANDLE_SIZE
\r
90 /* SERIAL_PORT_UART_HANDLE_SIZE/SERIAL_PORT_USB_CDC_HANDLE_SIZE + serial manager dedicated size */
\r
91 #if ((defined(SERIAL_MANAGER_HANDLE_SIZE_TEMP) && (SERIAL_MANAGER_HANDLE_SIZE_TEMP > 0U)))
\r
93 #error SERIAL_PORT_TYPE_UART, SERIAL_PORT_TYPE_USBCDC and SERIAL_PORT_TYPE_SWO should not be cleared at same time.
\r
96 #if (defined(SERIAL_MANAGER_NON_BLOCKING_MODE) && (SERIAL_MANAGER_NON_BLOCKING_MODE > 0U))
\r
97 #define SERIAL_MANAGER_HANDLE_SIZE (SERIAL_MANAGER_HANDLE_SIZE_TEMP + 120U)
\r
99 #define SERIAL_MANAGER_HANDLE_SIZE (SERIAL_MANAGER_HANDLE_SIZE_TEMP + 12U)
\r
102 #define SERIAL_MANAGER_USE_COMMON_TASK (1U)
\r
103 #define SERIAL_MANAGER_TASK_PRIORITY (2U)
\r
104 #define SERIAL_MANAGER_TASK_STACK_SIZE (1000U)
\r
106 typedef void *serial_handle_t;
\r
107 typedef void *serial_write_handle_t;
\r
108 typedef void *serial_read_handle_t;
\r
110 typedef enum _serial_port_type
\r
112 kSerialPort_Uart = 1U, /*!< Serial port UART */
\r
113 kSerialPort_UsbCdc, /*!< Serial port USB CDC */
\r
114 kSerialPort_Swo, /*!< Serial port SWO */
\r
115 } serial_port_type_t;
\r
117 typedef struct _serial_manager_config
\r
119 uint8_t *ringBuffer; /*!< Ring buffer address, it is used to buffer data received by the hardware.
\r
120 Besides, the memory space cannot be free during the lifetime of the serial
\r
122 uint32_t ringBufferSize; /*!< The size of the ring buffer */
\r
123 serial_port_type_t type; /*!< Serial port type */
\r
124 void *portConfig; /*!< Serial port configuration */
\r
125 } serial_manager_config_t;
\r
127 typedef enum _serial_manager_status
\r
129 kStatus_SerialManager_Success = kStatus_Success, /*!< Success */
\r
130 kStatus_SerialManager_Error = MAKE_STATUS(kStatusGroup_SERIALMANAGER, 1), /*!< Failed */
\r
131 kStatus_SerialManager_Busy = MAKE_STATUS(kStatusGroup_SERIALMANAGER, 2), /*!< Busy */
\r
132 kStatus_SerialManager_Notify = MAKE_STATUS(kStatusGroup_SERIALMANAGER, 3), /*!< Ring buffer is not empty */
\r
133 kStatus_SerialManager_Canceled =
\r
134 MAKE_STATUS(kStatusGroup_SERIALMANAGER, 4), /*!< the non-blocking request is canceled */
\r
135 kStatus_SerialManager_HandleConflict = MAKE_STATUS(kStatusGroup_SERIALMANAGER, 5), /*!< The handle is opened */
\r
136 kStatus_SerialManager_RingBufferOverflow =
\r
137 MAKE_STATUS(kStatusGroup_SERIALMANAGER, 6), /*!< The ring buffer is overflowed */
\r
138 } serial_manager_status_t;
\r
140 /*! @brief Callback message structure */
\r
141 typedef struct _serial_manager_callback_message
\r
143 uint8_t *buffer; /*!< Transferred buffer */
\r
144 uint32_t length; /*!< Transferred data length */
\r
145 } serial_manager_callback_message_t;
\r
147 /*! @brief callback function */
\r
148 typedef void (*serial_manager_callback_t)(void *callbackParam,
\r
149 serial_manager_callback_message_t *message,
\r
150 serial_manager_status_t status);
\r
152 /*******************************************************************************
\r
154 ******************************************************************************/
\r
156 #if defined(__cplusplus)
\r
158 #endif /* _cplusplus */
\r
161 * @brief Initializes a serial manager module with the serial manager handle and the user configuration structure.
\r
163 * This function configures the serial manager module with user-defined settings. The user can configure the
\r
165 * structure. The parameter serialHandle is a pointer to point to a memory space of size #SERIAL_MANAGER_HANDLE_SIZE
\r
166 * allocated by the caller.
\r
167 * The serial manager module supports two types serial port, uart (includes UART, USART, LPSCI, LPUART, etc) and USB
\r
169 * Please refer to #serial_port_type_t for serial port setting. These two types can be set by using
\r
170 * #serial_manager_config_t.
\r
172 * Example below shows how to use this API to configure the serial manager.
\r
175 * #define SERIAL_MANAGER_RING_BUFFER_SIZE (256U)
\r
176 * static uint8_t s_serialHandleBuffer[SERIAL_MANAGER_HANDLE_SIZE];
\r
177 * static serial_handle_t s_serialHandle = &s_serialHandleBuffer[0];
\r
178 * static uint8_t s_ringBuffer[SERIAL_MANAGER_RING_BUFFER_SIZE];
\r
180 * serial_manager_config_t config;
\r
181 * serial_port_uart_config_t uartConfig;
\r
182 * config.type = kSerialPort_Uart;
\r
183 * config.ringBuffer = &s_ringBuffer[0];
\r
184 * config.ringBufferSize = SERIAL_MANAGER_RING_BUFFER_SIZE;
\r
185 * uartConfig.instance = 0;
\r
186 * uartConfig.clockRate = 24000000;
\r
187 * uartConfig.baudRate = 115200;
\r
188 * uartConfig.parityMode = kSerialManager_UartParityDisabled;
\r
189 * uartConfig.stopBitCount = kSerialManager_UartOneStopBit;
\r
190 * uartConfig.enableRx = 1;
\r
191 * uartConfig.enableTx = 1;
\r
192 * config.portConfig = &uartConfig;
\r
193 * SerialManager_Init(s_serialHandle, &config);
\r
197 * #define SERIAL_MANAGER_RING_BUFFER_SIZE (256U)
\r
198 * static uint8_t s_serialHandleBuffer[SERIAL_MANAGER_HANDLE_SIZE];
\r
199 * static serial_handle_t s_serialHandle = &s_serialHandleBuffer[0];
\r
200 * static uint8_t s_ringBuffer[SERIAL_MANAGER_RING_BUFFER_SIZE];
\r
202 * serial_manager_config_t config;
\r
203 * serial_port_usb_cdc_config_t usbCdcConfig;
\r
204 * config.type = kSerialPort_UsbCdc;
\r
205 * config.ringBuffer = &s_ringBuffer[0];
\r
206 * config.ringBufferSize = SERIAL_MANAGER_RING_BUFFER_SIZE;
\r
207 * usbCdcConfig.controllerIndex = kSerialManager_UsbControllerKhci0;
\r
208 * config.portConfig = &usbCdcConfig;
\r
209 * SerialManager_Init(s_serialHandle, &config);
\r
212 * @param serialHandle Pointer to point to a memory space of size #SERIAL_MANAGER_HANDLE_SIZE allocated by the caller.
\r
213 * @param config Pointer to user-defined configuration structure.
\r
214 * @retval kStatus_SerialManager_Error An error occurred.
\r
215 * @retval kStatus_SerialManager_Success The serial manager module initialization succeed.
\r
217 serial_manager_status_t SerialManager_Init(serial_handle_t serialHandle, serial_manager_config_t *config);
\r
220 * @brief De-initializes the serial manager module instance.
\r
222 * This function de-initializes the serial manager module instance. If the opened writing or
\r
223 * reading handle is not closed, the function will return kStatus_SerialManager_Busy.
\r
225 * @param serialHandle The serial manager module handle pointer.
\r
226 * @retval kStatus_SerialManager_Success The serial manager de-initialization succeed.
\r
227 * @retval kStatus_SerialManager_Busy Opened reading or writing handle is not closed.
\r
229 serial_manager_status_t SerialManager_Deinit(serial_handle_t serialHandle);
\r
232 * @brief Opens a writing handle for the serial manager module.
\r
234 * This function Opens a writing handle for the serial manager module. If the serial manager needs to
\r
235 * be used in different tasks, the task should open a dedicated write handle for itself by calling
\r
236 * #SerialManager_OpenWriteHandle. Since there can only one buffer for transmission for the writing
\r
237 * handle at the same time, multiple writing handles need to be opened when the multiple transmission
\r
238 * is needed for a task.
\r
240 * @param serialHandle The serial manager module handle pointer.
\r
241 * @param writeHandle The serial manager module writing handle pointer.
\r
242 * @retval kStatus_SerialManager_Error An error occurred.
\r
243 * @retval kStatus_SerialManager_HandleConflict The writing handle was opened.
\r
244 * @retval kStatus_SerialManager_Success The writing handle is opened.
\r
246 * Example below shows how to use this API to write data.
\r
249 * static uint8_t s_serialWriteHandleBuffer1[SERIAL_MANAGER_WRITE_HANDLE_SIZE];
\r
250 * static serial_write_handle_t s_serialWriteHandle1 = &s_serialWriteHandleBuffer1[0];
\r
251 * static uint8_t s_nonBlockingWelcome1[] = "This is non-blocking writing log for task1!\r\n";
\r
252 * SerialManager_OpenWriteHandle(serialHandle, s_serialWriteHandle1);
\r
253 * SerialManager_InstallTxCallback(s_serialWriteHandle1, Task1_SerialManagerTxCallback, s_serialWriteHandle1);
\r
254 * SerialManager_WriteNonBlocking(s_serialWriteHandle1, s_nonBlockingWelcome1, sizeof(s_nonBlockingWelcome1) - 1);
\r
258 * static uint8_t s_serialWriteHandleBuffer2[SERIAL_MANAGER_WRITE_HANDLE_SIZE];
\r
259 * static serial_write_handle_t s_serialWriteHandle2 = &s_serialWriteHandleBuffer2[0];
\r
260 * static uint8_t s_nonBlockingWelcome2[] = "This is non-blocking writing log for task2!\r\n";
\r
261 * SerialManager_OpenWriteHandle(serialHandle, s_serialWriteHandle2);
\r
262 * SerialManager_InstallTxCallback(s_serialWriteHandle2, Task2_SerialManagerTxCallback, s_serialWriteHandle2);
\r
263 * SerialManager_WriteNonBlocking(s_serialWriteHandle2, s_nonBlockingWelcome2, sizeof(s_nonBlockingWelcome2) - 1);
\r
266 serial_manager_status_t SerialManager_OpenWriteHandle(serial_handle_t serialHandle, serial_write_handle_t writeHandle);
\r
269 * @brief Closes a writing handle for the serial manager module.
\r
271 * This function Closes a writing handle for the serial manager module.
\r
273 * @param writeHandle The serial manager module writing handle pointer.
\r
274 * @retval kStatus_SerialManager_Success The writing handle is closed.
\r
276 serial_manager_status_t SerialManager_CloseWriteHandle(serial_write_handle_t writeHandle);
\r
279 * @brief Opens a reading handle for the serial manager module.
\r
281 * This function Opens a reading handle for the serial manager module. The reading handle can not be
\r
282 * opened multiple at the same time. The error code kStatus_SerialManager_Busy would be returned when
\r
283 * the previous reading handle is not closed. And There can only one buffer for receiving for the
\r
284 * reading handle at the same time.
\r
286 * @param serialHandle The serial manager module handle pointer.
\r
287 * @param readHandle The serial manager module reading handle pointer.
\r
288 * @retval kStatus_SerialManager_Error An error occurred.
\r
289 * @retval kStatus_SerialManager_Success The reading handle is opened.
\r
290 * @retval kStatus_SerialManager_Busy Previous reading handle is not closed.
\r
292 * Example below shows how to use this API to read data.
\r
294 * static uint8_t s_serialReadHandleBuffer[SERIAL_MANAGER_READ_HANDLE_SIZE];
\r
295 * static serial_read_handle_t s_serialReadHandle = &s_serialReadHandleBuffer[0];
\r
296 * SerialManager_OpenReadHandle(serialHandle, s_serialReadHandle);
\r
297 * static uint8_t s_nonBlockingBuffer[64];
\r
298 * SerialManager_InstallRxCallback(s_serialReadHandle, APP_SerialManagerRxCallback, s_serialReadHandle);
\r
299 * SerialManager_ReadNonBlocking(s_serialReadHandle, s_nonBlockingBuffer, sizeof(s_nonBlockingBuffer));
\r
302 serial_manager_status_t SerialManager_OpenReadHandle(serial_handle_t serialHandle, serial_read_handle_t readHandle);
\r
305 * @brief Closes a reading for the serial manager module.
\r
307 * This function Closes a reading for the serial manager module.
\r
309 * @param readHandle The serial manager module reading handle pointer.
\r
310 * @retval kStatus_SerialManager_Success The reading handle is closed.
\r
312 serial_manager_status_t SerialManager_CloseReadHandle(serial_read_handle_t readHandle);
\r
315 * @brief Transmits data with the blocking mode.
\r
317 * This is a blocking function, which polls the sending queue, waits for the sending queue to be empty.
\r
318 * This function sends data using an interrupt method. The interrupt of the hardware could not be disabled.
\r
319 * And There can only one buffer for transmission for the writing handle at the same time.
\r
321 * @note The function #SerialManager_WriteBlocking and the function #SerialManager_WriteNonBlocking
\r
322 * cannot be used at the same time.
\r
323 * And, the function #SerialManager_CancelWriting cannot be used to abort the transmission of this function.
\r
325 * @param writeHandle The serial manager module handle pointer.
\r
326 * @param buffer Start address of the data to write.
\r
327 * @param length Length of the data to write.
\r
328 * @retval kStatus_SerialManager_Success Successfully sent all data.
\r
329 * @retval kStatus_SerialManager_Busy Previous transmission still not finished; data not all sent yet.
\r
330 * @retval kStatus_SerialManager_Error An error occurred.
\r
332 serial_manager_status_t SerialManager_WriteBlocking(serial_write_handle_t writeHandle,
\r
337 * @brief Reads data with the blocking mode.
\r
339 * This is a blocking function, which polls the receiving buffer, waits for the receiving buffer to be full.
\r
340 * This function receives data using an interrupt method. The interrupt of the hardware could not be disabled.
\r
341 * And There can only one buffer for receiving for the reading handle at the same time.
\r
343 * @note The function #SerialManager_ReadBlocking and the function #SerialManager_ReadNonBlocking
\r
344 * cannot be used at the same time.
\r
345 * And, the function #SerialManager_CancelReading cannot be used to abort the transmission of this function.
\r
347 * @param readHandle The serial manager module handle pointer.
\r
348 * @param buffer Start address of the data to store the received data.
\r
349 * @param length The length of the data to be received.
\r
350 * @retval kStatus_SerialManager_Success Successfully received all data.
\r
351 * @retval kStatus_SerialManager_Busy Previous transmission still not finished; data not all received yet.
\r
352 * @retval kStatus_SerialManager_Error An error occurred.
\r
354 serial_manager_status_t SerialManager_ReadBlocking(serial_read_handle_t readHandle, uint8_t *buffer, uint32_t length);
\r
356 #if (defined(SERIAL_MANAGER_NON_BLOCKING_MODE) && (SERIAL_MANAGER_NON_BLOCKING_MODE > 0U))
\r
358 * @brief Transmits data with the non-blocking mode.
\r
360 * This is a non-blocking function, which returns directly without waiting for all data to be sent.
\r
361 * When all data is sent, the module notifies the upper layer through a TX callback function and passes
\r
362 * the status parameter @ref kStatus_SerialManager_Success.
\r
363 * This function sends data using an interrupt method. The interrupt of the hardware could not be disabled.
\r
364 * And There can only one buffer for transmission for the writing handle at the same time.
\r
366 * @note The function #SerialManager_WriteBlocking and the function #SerialManager_WriteNonBlocking
\r
367 * cannot be used at the same time. And, the TX callback is mandatory before the function could be used.
\r
369 * @param writeHandle The serial manager module handle pointer.
\r
370 * @param buffer Start address of the data to write.
\r
371 * @param length Length of the data to write.
\r
372 * @retval kStatus_SerialManager_Success Successfully sent all data.
\r
373 * @retval kStatus_SerialManager_Busy Previous transmission still not finished; data not all sent yet.
\r
374 * @retval kStatus_SerialManager_Error An error occurred.
\r
376 serial_manager_status_t SerialManager_WriteNonBlocking(serial_write_handle_t writeHandle,
\r
381 * @brief Reads data with the non-blocking mode.
\r
383 * This is a non-blocking function, which returns directly without waiting for all data to be received.
\r
384 * When all data is received, the module driver notifies the upper layer
\r
385 * through a RX callback function and passes the status parameter @ref kStatus_SerialManager_Success.
\r
386 * This function receives data using an interrupt method. The interrupt of the hardware could not be disabled.
\r
387 * And There can only one buffer for receiving for the reading handle at the same time.
\r
389 * @note The function #SerialManager_ReadBlocking and the function #SerialManager_ReadNonBlocking
\r
390 * cannot be used at the same time. And, the RX callback is mandatory before the function could be used.
\r
392 * @param readHandle The serial manager module handle pointer.
\r
393 * @param buffer Start address of the data to store the received data.
\r
394 * @param length The length of the data to be received.
\r
395 * @retval kStatus_SerialManager_Success Successfully received all data.
\r
396 * @retval kStatus_SerialManager_Busy Previous transmission still not finished; data not all received yet.
\r
397 * @retval kStatus_SerialManager_Error An error occurred.
\r
399 serial_manager_status_t SerialManager_ReadNonBlocking(serial_read_handle_t readHandle,
\r
404 * @brief Tries to read data.
\r
406 * The function tries to read data from internal ring buffer. If the ring buffer is not empty, the data will be
\r
407 * copied from ring buffer to up layer buffer. The copied length is the minimum of the ring buffer and up layer length.
\r
408 * After the data is copied, the actual data length is passed by the parameter length.
\r
409 * And There can only one buffer for receiving for the reading handle at the same time.
\r
411 * @param readHandle The serial manager module handle pointer.
\r
412 * @param buffer Start address of the data to store the received data.
\r
413 * @param length The length of the data to be received.
\r
414 * @param receivedLength Length received from the ring buffer directly.
\r
415 * @retval kStatus_SerialManager_Success Successfully received all data.
\r
416 * @retval kStatus_SerialManager_Busy Previous transmission still not finished; data not all received yet.
\r
417 * @retval kStatus_SerialManager_Error An error occurred.
\r
419 serial_manager_status_t SerialManager_TryRead(serial_read_handle_t readHandle,
\r
422 uint32_t *receivedLength);
\r
425 * @brief Cancels unfinished send transmission.
\r
427 * The function cancels unfinished send transmission. When the transfer is canceled, the module notifies the upper layer
\r
428 * through a TX callback function and passes the status parameter @ref kStatus_SerialManager_Canceled.
\r
430 * @note The function #SerialManager_CancelWriting cannot be used to abort the transmission of
\r
431 * the function #SerialManager_WriteBlocking.
\r
433 * @param writeHandle The serial manager module handle pointer.
\r
434 * @retval kStatus_SerialManager_Success Get successfully abort the sending.
\r
435 * @retval kStatus_SerialManager_Error An error occurred.
\r
437 serial_manager_status_t SerialManager_CancelWriting(serial_write_handle_t writeHandle);
\r
440 * @brief Cancels unfinished receive transmission.
\r
442 * The function cancels unfinished receive transmission. When the transfer is canceled, the module notifies the upper
\r
444 * through a RX callback function and passes the status parameter @ref kStatus_SerialManager_Canceled.
\r
446 * @note The function #SerialManager_CancelReading cannot be used to abort the transmission of
\r
447 * the function #SerialManager_ReadBlocking.
\r
449 * @param readHandle The serial manager module handle pointer.
\r
450 * @retval kStatus_SerialManager_Success Get successfully abort the receiving.
\r
451 * @retval kStatus_SerialManager_Error An error occurred.
\r
453 serial_manager_status_t SerialManager_CancelReading(serial_read_handle_t readHandle);
\r
456 * @brief Installs a TX callback and callback parameter.
\r
458 * This function is used to install the TX callback and callback parameter for the serial manager module.
\r
459 * When any status of TX transmission changed, the driver will notify the upper layer by the installed callback
\r
460 * function. And the status is also passed as status parameter when the callback is called.
\r
462 * @param writeHandle The serial manager module handle pointer.
\r
463 * @param callback The callback function.
\r
464 * @param callbackParam The parameter of the callback function.
\r
465 * @retval kStatus_SerialManager_Success Successfully install the callback.
\r
467 serial_manager_status_t SerialManager_InstallTxCallback(serial_write_handle_t writeHandle,
\r
468 serial_manager_callback_t callback,
\r
469 void *callbackParam);
\r
472 * @brief Installs a RX callback and callback parameter.
\r
474 * This function is used to install the RX callback and callback parameter for the serial manager module.
\r
475 * When any status of RX transmission changed, the driver will notify the upper layer by the installed callback
\r
476 * function. And the status is also passed as status parameter when the callback is called.
\r
478 * @param readHandle The serial manager module handle pointer.
\r
479 * @param callback The callback function.
\r
480 * @param callbackParam The parameter of the callback function.
\r
481 * @retval kStatus_SerialManager_Success Successfully install the callback.
\r
483 serial_manager_status_t SerialManager_InstallRxCallback(serial_read_handle_t readHandle,
\r
484 serial_manager_callback_t callback,
\r
485 void *callbackParam);
\r
490 * @brief Prepares to enter low power consumption.
\r
492 * This function is used to prepare to enter low power consumption.
\r
494 * @param serialHandle The serial manager module handle pointer.
\r
495 * @retval kStatus_SerialManager_Success Successful operation.
\r
497 serial_manager_status_t SerialManager_EnterLowpower(serial_handle_t serialHandle);
\r
500 * @brief Restores from low power consumption.
\r
502 * This function is used to restore from low power consumption.
\r
504 * @param serialHandle The serial manager module handle pointer.
\r
505 * @retval kStatus_SerialManager_Success Successful operation.
\r
507 serial_manager_status_t SerialManager_ExitLowpower(serial_handle_t serialHandle);
\r
509 #if defined(__cplusplus)
\r
513 #endif /* __SERIAL_MANAGER_H__ */
\r