Go to the documentation of this file.
9 #ifndef __SERIAL_MANAGER_H__
10 #define __SERIAL_MANAGER_H__
21 #ifdef DEBUG_CONSOLE_TRANSFER_NON_BLOCKING
22 #ifndef SERIAL_MANAGER_NON_BLOCKING_MODE
23 #define SERIAL_MANAGER_NON_BLOCKING_MODE (1U)
26 #ifndef SERIAL_MANAGER_NON_BLOCKING_MODE
27 #define SERIAL_MANAGER_NON_BLOCKING_MODE (0U)
32 #ifndef SERIAL_PORT_TYPE_UART
33 #define SERIAL_PORT_TYPE_UART (0U)
37 #ifndef SERIAL_PORT_TYPE_USBCDC
38 #define SERIAL_PORT_TYPE_USBCDC (0U)
42 #ifndef SERIAL_PORT_TYPE_SWO
43 #define SERIAL_PORT_TYPE_SWO (0U)
47 #ifndef SERIAL_PORT_TYPE_USBCDC_VIRTUAL
48 #define SERIAL_PORT_TYPE_USBCDC_VIRTUAL (0U)
52 #if (defined(SERIAL_MANAGER_NON_BLOCKING_MODE) && (SERIAL_MANAGER_NON_BLOCKING_MODE > 0U))
53 #define SERIAL_MANAGER_WRITE_HANDLE_SIZE (44U)
54 #define SERIAL_MANAGER_READ_HANDLE_SIZE (44U)
56 #define SERIAL_MANAGER_WRITE_HANDLE_SIZE (4U)
57 #define SERIAL_MANAGER_READ_HANDLE_SIZE (4U)
60 #if (defined(SERIAL_PORT_TYPE_UART) && (SERIAL_PORT_TYPE_UART > 0U))
64 #if (defined(SERIAL_PORT_TYPE_USBCDC) && (SERIAL_PORT_TYPE_USBCDC > 0U))
66 #if !(defined(SERIAL_MANAGER_NON_BLOCKING_MODE) && (SERIAL_MANAGER_NON_BLOCKING_MODE > 0U))
67 #error The serial manager blocking mode cannot be supported for USB CDC.
70 #include "serial_port_usb.h"
73 #if (defined(SERIAL_PORT_TYPE_SWO) && (SERIAL_PORT_TYPE_SWO > 0U))
74 #include "serial_port_swo.h"
77 #if (defined(SERIAL_PORT_TYPE_USBCDC_VIRTUAL) && (SERIAL_PORT_TYPE_USBCDC_VIRTUAL > 0U))
79 #if !(defined(SERIAL_MANAGER_NON_BLOCKING_MODE) && (SERIAL_MANAGER_NON_BLOCKING_MODE > 0U))
80 #error The serial manager blocking mode cannot be supported for USB CDC.
83 #include "serial_port_usb_virtual.h"
86 #define SERIAL_MANAGER_HANDLE_SIZE_TEMP 0U
87 #if (defined(SERIAL_PORT_TYPE_UART) && (SERIAL_PORT_TYPE_UART > 0U))
89 #if (SERIAL_PORT_UART_HANDLE_SIZE > SERIAL_MANAGER_HANDLE_SIZE_TEMP)
90 #undef SERIAL_MANAGER_HANDLE_SIZE_TEMP
91 #define SERIAL_MANAGER_HANDLE_SIZE_TEMP SERIAL_PORT_UART_HANDLE_SIZE
96 #if (defined(SERIAL_PORT_TYPE_USBCDC) && (SERIAL_PORT_TYPE_USBCDC > 0U))
98 #if (SERIAL_PORT_USB_CDC_HANDLE_SIZE > SERIAL_MANAGER_HANDLE_SIZE_TEMP)
99 #undef SERIAL_MANAGER_HANDLE_SIZE_TEMP
100 #define SERIAL_MANAGER_HANDLE_SIZE_TEMP SERIAL_PORT_USB_CDC_HANDLE_SIZE
105 #if (defined(SERIAL_PORT_TYPE_SWO) && (SERIAL_PORT_TYPE_SWO > 0U))
107 #if (SERIAL_PORT_SWO_HANDLE_SIZE > SERIAL_MANAGER_HANDLE_SIZE_TEMP)
108 #undef SERIAL_MANAGER_HANDLE_SIZE_TEMP
109 #define SERIAL_MANAGER_HANDLE_SIZE_TEMP SERIAL_PORT_SWO_HANDLE_SIZE
114 #if (defined(SERIAL_PORT_TYPE_USBCDC_VIRTUAL) && (SERIAL_PORT_TYPE_USBCDC_VIRTUAL > 0U))
116 #if (SERIAL_PORT_USB_VIRTUAL_HANDLE_SIZE > SERIAL_MANAGER_HANDLE_SIZE_TEMP)
117 #undef SERIAL_MANAGER_HANDLE_SIZE_TEMP
118 #define SERIAL_MANAGER_HANDLE_SIZE_TEMP SERIAL_PORT_USB_VIRTUAL_HANDLE_SIZE
124 #if ((defined(SERIAL_MANAGER_HANDLE_SIZE_TEMP) && (SERIAL_MANAGER_HANDLE_SIZE_TEMP > 0U)))
126 #error SERIAL_PORT_TYPE_UART, SERIAL_PORT_TYPE_USBCDC, SERIAL_PORT_TYPE_SWO and SERIAL_PORT_TYPE_USBCDC_VIRTUAL should not be cleared at same time.
130 #if (defined(SERIAL_MANAGER_NON_BLOCKING_MODE) && (SERIAL_MANAGER_NON_BLOCKING_MODE > 0U))
131 #define SERIAL_MANAGER_HANDLE_SIZE (SERIAL_MANAGER_HANDLE_SIZE_TEMP + 120U)
133 #define SERIAL_MANAGER_HANDLE_SIZE (SERIAL_MANAGER_HANDLE_SIZE_TEMP + 12U)
151 #define SERIAL_MANAGER_HANDLE_DEFINE(name) \
152 uint32_t name[((SERIAL_MANAGER_HANDLE_SIZE + sizeof(uint32_t) - 1U) / sizeof(uint32_t))]
169 #define SERIAL_MANAGER_WRITE_HANDLE_DEFINE(name) \
170 uint32_t name[((SERIAL_MANAGER_WRITE_HANDLE_SIZE + sizeof(uint32_t) - 1U) / sizeof(uint32_t))]
187 #define SERIAL_MANAGER_READ_HANDLE_DEFINE(name) \
188 uint32_t name[((SERIAL_MANAGER_READ_HANDLE_SIZE + sizeof(uint32_t) - 1U) / sizeof(uint32_t))]
191 #ifndef SERIAL_MANAGER_USE_COMMON_TASK
192 #define SERIAL_MANAGER_USE_COMMON_TASK (1U)
196 #ifndef SERIAL_MANAGER_TASK_PRIORITY
197 #define SERIAL_MANAGER_TASK_PRIORITY (2U)
201 #ifndef SERIAL_MANAGER_TASK_STACK_SIZE
202 #define SERIAL_MANAGER_TASK_STACK_SIZE (1000U)
226 #if defined(DEBUG_CONSOLE_TRANSFER_NON_BLOCKING)
230 uint32_t ringBufferSize;
267 #if defined(__cplusplus)
491 #if (defined(SERIAL_MANAGER_NON_BLOCKING_MODE) && (SERIAL_MANAGER_NON_BLOCKING_MODE > 0U))
557 uint32_t *receivedLength);
604 void *callbackParam);
620 void *callbackParam);
644 #if defined(__cplusplus)
struct _serial_manager_callback_message serial_manager_callback_message_t
Callback message structure.
serial_manager_status_t SerialManager_Init(serial_handle_t serialHandle, serial_manager_config_t *config)
Initializes a serial manager module with the serial manager handle and the user configuration structu...
enum _serial_manager_status serial_manager_status_t
serial manager error code
@ kStatus_SerialManager_HandleConflict
enum _serial_port_type serial_port_type_t
serial port type
@ kSerialPort_UsbCdcVirtual
@ kStatus_SerialManager_NotConnected
serial manager config structure
@ kStatus_SerialManager_Canceled
void * serial_handle_t
The handle of the serial manager module.
@ kStatus_SerialManager_Error
@ kStatus_SerialManager_RingBufferOverflow
@ kStatus_SerialManager_Notify
serial_manager_status_t SerialManager_CloseWriteHandle(serial_write_handle_t writeHandle)
Closes a writing handle for the serial manager module.
#define MAKE_STATUS(group, code)
Construct a status code value from a group and code number.
@ kStatus_SerialManager_Success
void * serial_read_handle_t
The read handle of the serial manager module.
Callback message structure.
serial_manager_status_t SerialManager_ReadBlocking(serial_read_handle_t readHandle, uint8_t *buffer, uint32_t length)
Reads data with the blocking mode.
serial_manager_status_t SerialManager_OpenWriteHandle(serial_handle_t serialHandle, serial_write_handle_t writeHandle)
Opens a writing handle for the serial manager module.
@ kStatusGroup_SERIALMANAGER
_serial_port_type
serial port type
serial_manager_status_t SerialManager_EnterLowpower(serial_handle_t serialHandle)
Prepares to enter low power consumption.
serial_manager_status_t SerialManager_OpenReadHandle(serial_handle_t serialHandle, serial_read_handle_t readHandle)
Opens a reading handle for the serial manager module.
@ kStatus_SerialManager_Busy
void * serial_write_handle_t
The write handle of the serial manager module.
void(* serial_manager_callback_t)(void *callbackParam, serial_manager_callback_message_t *message, serial_manager_status_t status)
callback function
_serial_manager_status
serial manager error code
serial_manager_status_t SerialManager_Deinit(serial_handle_t serialHandle)
De-initializes the serial manager module instance.
serial_manager_status_t SerialManager_WriteBlocking(serial_write_handle_t writeHandle, uint8_t *buffer, uint32_t length)
Transmits data with the blocking mode.
serial_manager_status_t SerialManager_CloseReadHandle(serial_read_handle_t readHandle)
Closes a reading for the serial manager module.
static sai_transceiver_t config
struct _serial_manager_config serial_manager_config_t
serial manager config structure
serial_manager_status_t SerialManager_ExitLowpower(serial_handle_t serialHandle)
Restores from low power consumption.