]> git.sur5r.net Git - freertos/blobdiff - FreeRTOS/Demo/CORTEX_MPU_M33F_NXP_LPC55S69_MCUXpresso/NXP_Code/component/serial_manager/serial_manager.h
Add ARMv8M demo project for NXP LPC55S69.
[freertos] / FreeRTOS / Demo / CORTEX_MPU_M33F_NXP_LPC55S69_MCUXpresso / NXP_Code / component / serial_manager / serial_manager.h
diff --git a/FreeRTOS/Demo/CORTEX_MPU_M33F_NXP_LPC55S69_MCUXpresso/NXP_Code/component/serial_manager/serial_manager.h b/FreeRTOS/Demo/CORTEX_MPU_M33F_NXP_LPC55S69_MCUXpresso/NXP_Code/component/serial_manager/serial_manager.h
new file mode 100644 (file)
index 0000000..539864d
--- /dev/null
@@ -0,0 +1,513 @@
+/*\r
+ * Copyright 2018 NXP\r
+ * All rights reserved.\r
+ *\r
+ *\r
+ * SPDX-License-Identifier: BSD-3-Clause\r
+ */\r
+\r
+#ifndef __SERIAL_MANAGER_H__\r
+#define __SERIAL_MANAGER_H__\r
+\r
+/*******************************************************************************\r
+ * Definitions\r
+ ******************************************************************************/\r
+#ifdef DEBUG_CONSOLE_TRANSFER_NON_BLOCKING\r
+#define SERIAL_MANAGER_NON_BLOCKING_MODE \\r
+    (1U) /* Enable or disable serial manager non-blocking mode (1 - enable, 0 - disable) */\r
+#else\r
+#ifndef SERIAL_MANAGER_NON_BLOCKING_MODE\r
+#define SERIAL_MANAGER_NON_BLOCKING_MODE \\r
+    (0U) /* Enable or disable serial manager non-blocking mode (1 - enable, 0 - disable) */\r
+#endif\r
+#endif\r
+\r
+#ifndef SERIAL_PORT_TYPE_UART\r
+#define SERIAL_PORT_TYPE_UART (1U) /* Enable or disable uart port (1 - enable, 0 - disable) */\r
+#endif\r
+\r
+#ifndef SERIAL_PORT_TYPE_USBCDC\r
+#define SERIAL_PORT_TYPE_USBCDC (0U) /* Enable or disable USB CDC port (1 - enable, 0 - disable) */\r
+#endif\r
+\r
+#ifndef SERIAL_PORT_TYPE_SWO\r
+#define SERIAL_PORT_TYPE_SWO (0U) /* Enable or disable SWO port (1 - enable, 0 - disable) */\r
+#endif\r
+\r
+#if (defined(SERIAL_MANAGER_NON_BLOCKING_MODE) && (SERIAL_MANAGER_NON_BLOCKING_MODE > 0U))\r
+#define SERIAL_MANAGER_WRITE_HANDLE_SIZE (44U)\r
+#define SERIAL_MANAGER_READ_HANDLE_SIZE (44U)\r
+#else\r
+#define SERIAL_MANAGER_WRITE_HANDLE_SIZE (4U)\r
+#define SERIAL_MANAGER_READ_HANDLE_SIZE (4U)\r
+#endif\r
+\r
+#if (defined(SERIAL_PORT_TYPE_UART) && (SERIAL_PORT_TYPE_UART > 0U))\r
+#include "serial_port_uart.h"\r
+#endif\r
+\r
+#if (defined(SERIAL_PORT_TYPE_USBCDC) && (SERIAL_PORT_TYPE_USBCDC > 0U))\r
+\r
+#if !(defined(SERIAL_MANAGER_NON_BLOCKING_MODE) && (SERIAL_MANAGER_NON_BLOCKING_MODE > 0U))\r
+#error The serial manager blocking mode cannot be supported for USB CDC.\r
+#endif\r
+\r
+#include "serial_port_usb.h"\r
+#endif\r
+\r
+#if (defined(SERIAL_PORT_TYPE_SWO) && (SERIAL_PORT_TYPE_SWO > 0U))\r
+#include "serial_port_swo.h"\r
+#endif\r
+\r
+#define SERIAL_MANAGER_HANDLE_SIZE_TEMP 0U\r
+#if (defined(SERIAL_PORT_TYPE_UART) && (SERIAL_PORT_TYPE_UART > 0U))\r
+\r
+#if (SERIAL_PORT_UART_HANDLE_SIZE > SERIAL_MANAGER_HANDLE_SIZE_TEMP)\r
+#undef SERIAL_MANAGER_HANDLE_SIZE_TEMP\r
+#define SERIAL_MANAGER_HANDLE_SIZE_TEMP SERIAL_PORT_UART_HANDLE_SIZE\r
+#endif\r
+\r
+#endif\r
+\r
+#if (defined(SERIAL_PORT_TYPE_USBCDC) && (SERIAL_PORT_TYPE_USBCDC > 0U))\r
+\r
+#if (SERIAL_PORT_USB_CDC_HANDLE_SIZE > SERIAL_MANAGER_HANDLE_SIZE_TEMP)\r
+#undef SERIAL_MANAGER_HANDLE_SIZE_TEMP\r
+#define SERIAL_MANAGER_HANDLE_SIZE_TEMP SERIAL_PORT_USB_CDC_HANDLE_SIZE\r
+#endif\r
+\r
+#endif\r
+\r
+#if (defined(SERIAL_PORT_TYPE_SWO) && (SERIAL_PORT_TYPE_SWO > 0U))\r
+\r
+#if (SERIAL_PORT_SWO_HANDLE_SIZE > SERIAL_MANAGER_HANDLE_SIZE_TEMP)\r
+#undef SERIAL_MANAGER_HANDLE_SIZE_TEMP\r
+#define SERIAL_MANAGER_HANDLE_SIZE_TEMP SERIAL_PORT_SWO_HANDLE_SIZE\r
+#endif\r
+\r
+#endif\r
+\r
+/* SERIAL_PORT_UART_HANDLE_SIZE/SERIAL_PORT_USB_CDC_HANDLE_SIZE + serial manager dedicated size */\r
+#if ((defined(SERIAL_MANAGER_HANDLE_SIZE_TEMP) && (SERIAL_MANAGER_HANDLE_SIZE_TEMP > 0U)))\r
+#else\r
+#error SERIAL_PORT_TYPE_UART, SERIAL_PORT_TYPE_USBCDC and SERIAL_PORT_TYPE_SWO should not be cleared at same time.\r
+#endif\r
+\r
+#if (defined(SERIAL_MANAGER_NON_BLOCKING_MODE) && (SERIAL_MANAGER_NON_BLOCKING_MODE > 0U))\r
+#define SERIAL_MANAGER_HANDLE_SIZE (SERIAL_MANAGER_HANDLE_SIZE_TEMP + 120U)\r
+#else\r
+#define SERIAL_MANAGER_HANDLE_SIZE (SERIAL_MANAGER_HANDLE_SIZE_TEMP + 12U)\r
+#endif\r
+\r
+#define SERIAL_MANAGER_USE_COMMON_TASK (1U)\r
+#define SERIAL_MANAGER_TASK_PRIORITY (2U)\r
+#define SERIAL_MANAGER_TASK_STACK_SIZE (1000U)\r
+\r
+typedef void *serial_handle_t;\r
+typedef void *serial_write_handle_t;\r
+typedef void *serial_read_handle_t;\r
+\r
+typedef enum _serial_port_type\r
+{\r
+    kSerialPort_Uart = 1U, /*!< Serial port UART */\r
+    kSerialPort_UsbCdc,    /*!< Serial port USB CDC */\r
+    kSerialPort_Swo,       /*!< Serial port SWO */\r
+} serial_port_type_t;\r
+\r
+typedef struct _serial_manager_config\r
+{\r
+    uint8_t *ringBuffer;     /*!< Ring buffer address, it is used to buffer data received by the hardware.\r
+                                  Besides, the memory space cannot be free during the lifetime of the serial\r
+                                  manager module. */\r
+    uint32_t ringBufferSize; /*!< The size of the ring buffer */\r
+    serial_port_type_t type; /*!< Serial port type */\r
+    void *portConfig;        /*!< Serial port configuration */\r
+} serial_manager_config_t;\r
+\r
+typedef enum _serial_manager_status\r
+{\r
+    kStatus_SerialManager_Success = kStatus_Success,                           /*!< Success */\r
+    kStatus_SerialManager_Error = MAKE_STATUS(kStatusGroup_SERIALMANAGER, 1),  /*!< Failed */\r
+    kStatus_SerialManager_Busy = MAKE_STATUS(kStatusGroup_SERIALMANAGER, 2),   /*!< Busy */\r
+    kStatus_SerialManager_Notify = MAKE_STATUS(kStatusGroup_SERIALMANAGER, 3), /*!< Ring buffer is not empty */\r
+    kStatus_SerialManager_Canceled =\r
+        MAKE_STATUS(kStatusGroup_SERIALMANAGER, 4), /*!< the non-blocking request is canceled */\r
+    kStatus_SerialManager_HandleConflict = MAKE_STATUS(kStatusGroup_SERIALMANAGER, 5), /*!< The handle is opened */\r
+    kStatus_SerialManager_RingBufferOverflow =\r
+        MAKE_STATUS(kStatusGroup_SERIALMANAGER, 6), /*!< The ring buffer is overflowed */\r
+} serial_manager_status_t;\r
+\r
+/*! @brief Callback message structure */\r
+typedef struct _serial_manager_callback_message\r
+{\r
+    uint8_t *buffer; /*!< Transferred buffer */\r
+    uint32_t length; /*!< Transferred data length */\r
+} serial_manager_callback_message_t;\r
+\r
+/*! @brief callback function */\r
+typedef void (*serial_manager_callback_t)(void *callbackParam,\r
+                                          serial_manager_callback_message_t *message,\r
+                                          serial_manager_status_t status);\r
+\r
+/*******************************************************************************\r
+ * API\r
+ ******************************************************************************/\r
+\r
+#if defined(__cplusplus)\r
+extern "C" {\r
+#endif /* _cplusplus */\r
+\r
+/*!\r
+ * @brief Initializes a serial manager module with the serial manager handle and the user configuration structure.\r
+ *\r
+ * This function configures the serial manager module with user-defined settings. The user can configure the\r
+ * configuration\r
+ * structure. The parameter serialHandle is a pointer to point to a memory space of size #SERIAL_MANAGER_HANDLE_SIZE\r
+ * allocated by the caller.\r
+ * The serial manager module supports two types serial port, uart (includes UART, USART, LPSCI, LPUART, etc) and USB\r
+ * CDC.\r
+ * Please refer to #serial_port_type_t for serial port setting. These two types can be set by using\r
+ * #serial_manager_config_t.\r
+ *\r
+ * Example below shows how to use this API to configure the serial manager.\r
+ * For UART,\r
+ *  @code\r
+ *   #define SERIAL_MANAGER_RING_BUFFER_SIZE          (256U)\r
+ *   static uint8_t s_serialHandleBuffer[SERIAL_MANAGER_HANDLE_SIZE];\r
+ *   static serial_handle_t s_serialHandle = &s_serialHandleBuffer[0];\r
+ *   static uint8_t s_ringBuffer[SERIAL_MANAGER_RING_BUFFER_SIZE];\r
+ *\r
+ *   serial_manager_config_t config;\r
+ *   serial_port_uart_config_t uartConfig;\r
+ *   config.type = kSerialPort_Uart;\r
+ *   config.ringBuffer = &s_ringBuffer[0];\r
+ *   config.ringBufferSize = SERIAL_MANAGER_RING_BUFFER_SIZE;\r
+ *   uartConfig.instance = 0;\r
+ *   uartConfig.clockRate = 24000000;\r
+ *   uartConfig.baudRate = 115200;\r
+ *   uartConfig.parityMode = kSerialManager_UartParityDisabled;\r
+ *   uartConfig.stopBitCount = kSerialManager_UartOneStopBit;\r
+ *   uartConfig.enableRx = 1;\r
+ *   uartConfig.enableTx = 1;\r
+ *   config.portConfig = &uartConfig;\r
+ *   SerialManager_Init(s_serialHandle, &config);\r
+ *  @endcode\r
+ * For USB CDC,\r
+ *  @code\r
+ *   #define SERIAL_MANAGER_RING_BUFFER_SIZE          (256U)\r
+ *   static uint8_t s_serialHandleBuffer[SERIAL_MANAGER_HANDLE_SIZE];\r
+ *   static serial_handle_t s_serialHandle = &s_serialHandleBuffer[0];\r
+ *   static uint8_t s_ringBuffer[SERIAL_MANAGER_RING_BUFFER_SIZE];\r
+ *\r
+ *   serial_manager_config_t config;\r
+ *   serial_port_usb_cdc_config_t usbCdcConfig;\r
+ *   config.type = kSerialPort_UsbCdc;\r
+ *   config.ringBuffer = &s_ringBuffer[0];\r
+ *   config.ringBufferSize = SERIAL_MANAGER_RING_BUFFER_SIZE;\r
+ *   usbCdcConfig.controllerIndex = kSerialManager_UsbControllerKhci0;\r
+ *   config.portConfig = &usbCdcConfig;\r
+ *   SerialManager_Init(s_serialHandle, &config);\r
+ *  @endcode\r
+ *\r
+ * @param serialHandle Pointer to point to a memory space of size #SERIAL_MANAGER_HANDLE_SIZE allocated by the caller.\r
+ * @param config Pointer to user-defined configuration structure.\r
+ * @retval kStatus_SerialManager_Error An error occurred.\r
+ * @retval kStatus_SerialManager_Success The serial manager module initialization succeed.\r
+ */\r
+serial_manager_status_t SerialManager_Init(serial_handle_t serialHandle, serial_manager_config_t *config);\r
+\r
+/*!\r
+ * @brief De-initializes the serial manager module instance.\r
+ *\r
+ * This function de-initializes the serial manager module instance. If the opened writing or\r
+ * reading handle is not closed, the function will return kStatus_SerialManager_Busy.\r
+ *\r
+ * @param serialHandle The serial manager module handle pointer.\r
+ * @retval kStatus_SerialManager_Success The serial manager de-initialization succeed.\r
+ * @retval kStatus_SerialManager_Busy Opened reading or writing handle is not closed.\r
+ */\r
+serial_manager_status_t SerialManager_Deinit(serial_handle_t serialHandle);\r
+\r
+/*!\r
+ * @brief Opens a writing handle for the serial manager module.\r
+ *\r
+ * This function Opens a writing handle for the serial manager module. If the serial manager needs to\r
+ * be used in different tasks, the task should open a dedicated write handle for itself by calling\r
+ * #SerialManager_OpenWriteHandle. Since there can only one buffer for transmission for the writing\r
+ * handle at the same time, multiple writing handles need to be opened when the multiple transmission\r
+ * is needed for a task.\r
+ *\r
+ * @param serialHandle The serial manager module handle pointer.\r
+ * @param writeHandle The serial manager module writing handle pointer.\r
+ * @retval kStatus_SerialManager_Error An error occurred.\r
+ * @retval kStatus_SerialManager_HandleConflict The writing handle was opened.\r
+ * @retval kStatus_SerialManager_Success The writing handle is opened.\r
+ *\r
+ * Example below shows how to use this API to write data.\r
+ * For task 1,\r
+ *  @code\r
+ *   static uint8_t s_serialWriteHandleBuffer1[SERIAL_MANAGER_WRITE_HANDLE_SIZE];\r
+ *   static serial_write_handle_t s_serialWriteHandle1 = &s_serialWriteHandleBuffer1[0];\r
+ *   static uint8_t s_nonBlockingWelcome1[] = "This is non-blocking writing log for task1!\r\n";\r
+ *   SerialManager_OpenWriteHandle(serialHandle, s_serialWriteHandle1);\r
+ *   SerialManager_InstallTxCallback(s_serialWriteHandle1, Task1_SerialManagerTxCallback, s_serialWriteHandle1);\r
+ *   SerialManager_WriteNonBlocking(s_serialWriteHandle1, s_nonBlockingWelcome1, sizeof(s_nonBlockingWelcome1) - 1);\r
+ *  @endcode\r
+ * For task 2,\r
+ *  @code\r
+ *   static uint8_t s_serialWriteHandleBuffer2[SERIAL_MANAGER_WRITE_HANDLE_SIZE];\r
+ *   static serial_write_handle_t s_serialWriteHandle2 = &s_serialWriteHandleBuffer2[0];\r
+ *   static uint8_t s_nonBlockingWelcome2[] = "This is non-blocking writing log for task2!\r\n";\r
+ *   SerialManager_OpenWriteHandle(serialHandle, s_serialWriteHandle2);\r
+ *   SerialManager_InstallTxCallback(s_serialWriteHandle2, Task2_SerialManagerTxCallback, s_serialWriteHandle2);\r
+ *   SerialManager_WriteNonBlocking(s_serialWriteHandle2, s_nonBlockingWelcome2, sizeof(s_nonBlockingWelcome2) - 1);\r
+ *  @endcode\r
+ */\r
+serial_manager_status_t SerialManager_OpenWriteHandle(serial_handle_t serialHandle, serial_write_handle_t writeHandle);\r
+\r
+/*!\r
+ * @brief Closes a writing handle for the serial manager module.\r
+ *\r
+ * This function Closes a writing handle for the serial manager module.\r
+ *\r
+ * @param writeHandle The serial manager module writing handle pointer.\r
+ * @retval kStatus_SerialManager_Success The writing handle is closed.\r
+ */\r
+serial_manager_status_t SerialManager_CloseWriteHandle(serial_write_handle_t writeHandle);\r
+\r
+/*!\r
+ * @brief Opens a reading handle for the serial manager module.\r
+ *\r
+ * This function Opens a reading handle for the serial manager module. The reading handle can not be\r
+ * opened multiple at the same time. The error code kStatus_SerialManager_Busy would be returned when\r
+ * the previous reading handle is not closed. And There can only one buffer for receiving for the\r
+ * reading handle at the same time.\r
+ *\r
+ * @param serialHandle The serial manager module handle pointer.\r
+ * @param readHandle The serial manager module reading handle pointer.\r
+ * @retval kStatus_SerialManager_Error An error occurred.\r
+ * @retval kStatus_SerialManager_Success The reading handle is opened.\r
+ * @retval kStatus_SerialManager_Busy Previous reading handle is not closed.\r
+ *\r
+ * Example below shows how to use this API to read data.\r
+ *  @code\r
+ *   static uint8_t s_serialReadHandleBuffer[SERIAL_MANAGER_READ_HANDLE_SIZE];\r
+ *   static serial_read_handle_t s_serialReadHandle = &s_serialReadHandleBuffer[0];\r
+ *   SerialManager_OpenReadHandle(serialHandle, s_serialReadHandle);\r
+ *   static uint8_t s_nonBlockingBuffer[64];\r
+ *   SerialManager_InstallRxCallback(s_serialReadHandle, APP_SerialManagerRxCallback, s_serialReadHandle);\r
+ *   SerialManager_ReadNonBlocking(s_serialReadHandle, s_nonBlockingBuffer, sizeof(s_nonBlockingBuffer));\r
+ *  @endcode\r
+ */\r
+serial_manager_status_t SerialManager_OpenReadHandle(serial_handle_t serialHandle, serial_read_handle_t readHandle);\r
+\r
+/*!\r
+ * @brief Closes a reading for the serial manager module.\r
+ *\r
+ * This function Closes a reading for the serial manager module.\r
+ *\r
+ * @param readHandle The serial manager module reading handle pointer.\r
+ * @retval kStatus_SerialManager_Success The reading handle is closed.\r
+ */\r
+serial_manager_status_t SerialManager_CloseReadHandle(serial_read_handle_t readHandle);\r
+\r
+/*!\r
+ * @brief Transmits data with the blocking mode.\r
+ *\r
+ * This is a blocking function, which polls the sending queue, waits for the sending queue to be empty.\r
+ * This function sends data using an interrupt method. The interrupt of the hardware could not be disabled.\r
+ * And There can only one buffer for transmission for the writing handle at the same time.\r
+ *\r
+ * @note The function #SerialManager_WriteBlocking and the function #SerialManager_WriteNonBlocking\r
+ * cannot be used at the same time.\r
+ * And, the function #SerialManager_CancelWriting cannot be used to abort the transmission of this function.\r
+ *\r
+ * @param writeHandle The serial manager module handle pointer.\r
+ * @param buffer Start address of the data to write.\r
+ * @param length Length of the data to write.\r
+ * @retval kStatus_SerialManager_Success Successfully sent all data.\r
+ * @retval kStatus_SerialManager_Busy Previous transmission still not finished; data not all sent yet.\r
+ * @retval kStatus_SerialManager_Error An error occurred.\r
+ */\r
+serial_manager_status_t SerialManager_WriteBlocking(serial_write_handle_t writeHandle,\r
+                                                    uint8_t *buffer,\r
+                                                    uint32_t length);\r
+\r
+/*!\r
+ * @brief Reads data with the blocking mode.\r
+ *\r
+ * This is a blocking function, which polls the receiving buffer, waits for the receiving buffer to be full.\r
+ * This function receives data using an interrupt method. The interrupt of the hardware could not be disabled.\r
+ * And There can only one buffer for receiving for the reading handle at the same time.\r
+ *\r
+ * @note The function #SerialManager_ReadBlocking and the function #SerialManager_ReadNonBlocking\r
+ * cannot be used at the same time.\r
+ * And, the function #SerialManager_CancelReading cannot be used to abort the transmission of this function.\r
+ *\r
+ * @param readHandle The serial manager module handle pointer.\r
+ * @param buffer Start address of the data to store the received data.\r
+ * @param length The length of the data to be received.\r
+ * @retval kStatus_SerialManager_Success Successfully received all data.\r
+ * @retval kStatus_SerialManager_Busy Previous transmission still not finished; data not all received yet.\r
+ * @retval kStatus_SerialManager_Error An error occurred.\r
+ */\r
+serial_manager_status_t SerialManager_ReadBlocking(serial_read_handle_t readHandle, uint8_t *buffer, uint32_t length);\r
+\r
+#if (defined(SERIAL_MANAGER_NON_BLOCKING_MODE) && (SERIAL_MANAGER_NON_BLOCKING_MODE > 0U))\r
+/*!\r
+ * @brief Transmits data with the non-blocking mode.\r
+ *\r
+ * This is a non-blocking function, which returns directly without waiting for all data to be sent.\r
+ * When all data is sent, the module notifies the upper layer through a TX callback function and passes\r
+ * the status parameter @ref kStatus_SerialManager_Success.\r
+ * This function sends data using an interrupt method. The interrupt of the hardware could not be disabled.\r
+ * And There can only one buffer for transmission for the writing handle at the same time.\r
+ *\r
+ * @note The function #SerialManager_WriteBlocking and the function #SerialManager_WriteNonBlocking\r
+ * cannot be used at the same time. And, the TX callback is mandatory before the function could be used.\r
+ *\r
+ * @param writeHandle The serial manager module handle pointer.\r
+ * @param buffer Start address of the data to write.\r
+ * @param length Length of the data to write.\r
+ * @retval kStatus_SerialManager_Success Successfully sent all data.\r
+ * @retval kStatus_SerialManager_Busy Previous transmission still not finished; data not all sent yet.\r
+ * @retval kStatus_SerialManager_Error An error occurred.\r
+ */\r
+serial_manager_status_t SerialManager_WriteNonBlocking(serial_write_handle_t writeHandle,\r
+                                                       uint8_t *buffer,\r
+                                                       uint32_t length);\r
+\r
+/*!\r
+ * @brief Reads data with the non-blocking mode.\r
+ *\r
+ * This is a non-blocking function, which returns directly without waiting for all data to be received.\r
+ * When all data is received, the module driver notifies the upper layer\r
+ * through a RX callback function and passes the status parameter @ref kStatus_SerialManager_Success.\r
+ * This function receives data using an interrupt method. The interrupt of the hardware could not be disabled.\r
+ * And There can only one buffer for receiving for the reading handle at the same time.\r
+ *\r
+ * @note The function #SerialManager_ReadBlocking and the function #SerialManager_ReadNonBlocking\r
+ * cannot be used at the same time. And, the RX callback is mandatory before the function could be used.\r
+ *\r
+ * @param readHandle The serial manager module handle pointer.\r
+ * @param buffer Start address of the data to store the received data.\r
+ * @param length The length of the data to be received.\r
+ * @retval kStatus_SerialManager_Success Successfully received all data.\r
+ * @retval kStatus_SerialManager_Busy Previous transmission still not finished; data not all received yet.\r
+ * @retval kStatus_SerialManager_Error An error occurred.\r
+ */\r
+serial_manager_status_t SerialManager_ReadNonBlocking(serial_read_handle_t readHandle,\r
+                                                      uint8_t *buffer,\r
+                                                      uint32_t length);\r
+\r
+/*!\r
+ * @brief Tries to read data.\r
+ *\r
+ * The function tries to read data from internal ring buffer. If the ring buffer is not empty, the data will be\r
+ * copied from ring buffer to up layer buffer. The copied length is the minimum of the ring buffer and up layer length.\r
+ * After the data is copied, the actual data length is passed by the parameter length.\r
+ * And There can only one buffer for receiving for the reading handle at the same time.\r
+ *\r
+ * @param readHandle The serial manager module handle pointer.\r
+ * @param buffer Start address of the data to store the received data.\r
+ * @param length The length of the data to be received.\r
+ * @param receivedLength Length received from the ring buffer directly.\r
+ * @retval kStatus_SerialManager_Success Successfully received all data.\r
+ * @retval kStatus_SerialManager_Busy Previous transmission still not finished; data not all received yet.\r
+ * @retval kStatus_SerialManager_Error An error occurred.\r
+ */\r
+serial_manager_status_t SerialManager_TryRead(serial_read_handle_t readHandle,\r
+                                              uint8_t *buffer,\r
+                                              uint32_t length,\r
+                                              uint32_t *receivedLength);\r
+\r
+/*!\r
+ * @brief Cancels unfinished send transmission.\r
+ *\r
+ * The function cancels unfinished send transmission. When the transfer is canceled, the module notifies the upper layer\r
+ * through a TX callback function and passes the status parameter @ref kStatus_SerialManager_Canceled.\r
+ *\r
+ * @note The function #SerialManager_CancelWriting cannot be used to abort the transmission of\r
+ * the function #SerialManager_WriteBlocking.\r
+ *\r
+ * @param writeHandle The serial manager module handle pointer.\r
+ * @retval kStatus_SerialManager_Success Get successfully abort the sending.\r
+ * @retval kStatus_SerialManager_Error An error occurred.\r
+ */\r
+serial_manager_status_t SerialManager_CancelWriting(serial_write_handle_t writeHandle);\r
+\r
+/*!\r
+ * @brief Cancels unfinished receive transmission.\r
+ *\r
+ * The function cancels unfinished receive transmission. When the transfer is canceled, the module notifies the upper\r
+ * layer\r
+ * through a RX callback function and passes the status parameter @ref kStatus_SerialManager_Canceled.\r
+ *\r
+ * @note The function #SerialManager_CancelReading cannot be used to abort the transmission of\r
+ * the function #SerialManager_ReadBlocking.\r
+ *\r
+ * @param readHandle The serial manager module handle pointer.\r
+ * @retval kStatus_SerialManager_Success Get successfully abort the receiving.\r
+ * @retval kStatus_SerialManager_Error An error occurred.\r
+ */\r
+serial_manager_status_t SerialManager_CancelReading(serial_read_handle_t readHandle);\r
+\r
+/*!\r
+ * @brief Installs a TX callback and callback parameter.\r
+ *\r
+ * This function is used to install the TX callback and callback parameter for the serial manager module.\r
+ * When any status of TX transmission changed, the driver will notify the upper layer by the installed callback\r
+ * function. And the status is also passed as status parameter when the callback is called.\r
+ *\r
+ * @param writeHandle The serial manager module handle pointer.\r
+ * @param callback The callback function.\r
+ * @param callbackParam The parameter of the callback function.\r
+ * @retval kStatus_SerialManager_Success Successfully install the callback.\r
+ */\r
+serial_manager_status_t SerialManager_InstallTxCallback(serial_write_handle_t writeHandle,\r
+                                                        serial_manager_callback_t callback,\r
+                                                        void *callbackParam);\r
+\r
+/*!\r
+ * @brief Installs a RX callback and callback parameter.\r
+ *\r
+ * This function is used to install the RX callback and callback parameter for the serial manager module.\r
+ * When any status of RX transmission changed, the driver will notify the upper layer by the installed callback\r
+ * function. And the status is also passed as status parameter when the callback is called.\r
+ *\r
+ * @param readHandle The serial manager module handle pointer.\r
+ * @param callback The callback function.\r
+ * @param callbackParam The parameter of the callback function.\r
+ * @retval kStatus_SerialManager_Success Successfully install the callback.\r
+ */\r
+serial_manager_status_t SerialManager_InstallRxCallback(serial_read_handle_t readHandle,\r
+                                                        serial_manager_callback_t callback,\r
+                                                        void *callbackParam);\r
+\r
+#endif\r
+\r
+/*!\r
+ * @brief Prepares to enter low power consumption.\r
+ *\r
+ * This function is used to prepare to enter low power consumption.\r
+ *\r
+ * @param serialHandle The serial manager module handle pointer.\r
+ * @retval kStatus_SerialManager_Success Successful operation.\r
+ */\r
+serial_manager_status_t SerialManager_EnterLowpower(serial_handle_t serialHandle);\r
+\r
+/*!\r
+ * @brief Restores from low power consumption.\r
+ *\r
+ * This function is used to restore from low power consumption.\r
+ *\r
+ * @param serialHandle The serial manager module handle pointer.\r
+ * @retval kStatus_SerialManager_Success Successful operation.\r
+ */\r
+serial_manager_status_t SerialManager_ExitLowpower(serial_handle_t serialHandle);\r
+\r
+#if defined(__cplusplus)\r
+}\r
+#endif\r
+\r
+#endif /* __SERIAL_MANAGER_H__ */\r