diff --git a/Doxyfile b/Doxyfile index fda2fa5..d385368 100644 --- a/Doxyfile +++ b/Doxyfile @@ -2276,7 +2276,7 @@ PERLMOD_MAKEVAR_PREFIX = # C-preprocessor directives found in the sources and include files. # The default value is: YES. -ENABLE_PREPROCESSING = YES +ENABLE_PREPROCESSING = NO # If the MACRO_EXPANSION tag is set to YES, doxygen will expand all macro names # in the source code. If set to NO, only conditional compilation will be diff --git a/easy_embedded/service/driver/CMakeLists.txt b/easy_embedded/service/driver/CMakeLists.txt index 6c97cba..5e2dc49 100644 --- a/easy_embedded/service/driver/CMakeLists.txt +++ b/easy_embedded/service/driver/CMakeLists.txt @@ -2,7 +2,7 @@ # Author: Hai Nguyen # Name: ez_driver_lib # License: This file is published under the license described in LICENSE.md -# Description: Cmake file for uart component +# Description: Cmake file for driver component # ---------------------------------------------------------------------------- add_library(ez_driver_lib STATIC) @@ -21,7 +21,6 @@ set(FRAMEWORK_ROOT_DIR ${CMAKE_SOURCE_DIR}/easy_embedded) # Source files --------------------------------------------------------------- target_sources(ez_driver_lib PRIVATE - ez_driver.c $<$:uart/ez_uart.c> ) diff --git a/easy_embedded/service/driver/ez_driver.c b/easy_embedded/service/driver/ez_driver.c deleted file mode 100644 index 353fdd6..0000000 --- a/easy_embedded/service/driver/ez_driver.c +++ /dev/null @@ -1,69 +0,0 @@ -/***************************************************************************** -* Filename: ez_driver.c -* Author: Hai Nguyen -* Original Date: 15.03.2024 -* -* ---------------------------------------------------------------------------- -* Contact: Hai Nguyen -* hainguyen.eeit@gmail.com -* -* ---------------------------------------------------------------------------- -* License: This file is published under the license described in LICENSE.md -* -*****************************************************************************/ - -/** @file ez_driver.c - * @author Hai Nguyen - * @date 15.03.2024 - * @brief One line description of the component - * - * @details Detail description of the component - */ - -/***************************************************************************** -* Includes -*****************************************************************************/ -#include "ez_driver.h" - -#if (EZ_DRIVER_ENABLE == 1) - -#define DEBUG_LVL LVL_TRACE /**< logging level */ -#define MOD_NAME "ez_driver" /**< module name */ -#include "ez_logging.h" - -/*the rest of include go here*/ - -/***************************************************************************** -* Component Preprocessor Macros -*****************************************************************************/ -#define A_MACRO 1 /**< a macro*/ - -/***************************************************************************** -* Component Typedefs -*****************************************************************************/ -/* None */ - -/***************************************************************************** -* Component Variable Definitions -*****************************************************************************/ -/* None */ - -/***************************************************************************** -* Function Definitions -*****************************************************************************/ -/* None */ - -/***************************************************************************** -* Public functions -*****************************************************************************/ -int sum(int a, int b) -{ - return a + b; -} - -/***************************************************************************** -* Local functions -*****************************************************************************/ - -#endif /* EZ_DRIVER_ENABLE == 1 */ -/* End of file*/ diff --git a/easy_embedded/service/driver/ez_driver.h b/easy_embedded/service/driver/ez_driver.h deleted file mode 100644 index 23af4f9..0000000 --- a/easy_embedded/service/driver/ez_driver.h +++ /dev/null @@ -1,88 +0,0 @@ -/***************************************************************************** -* Filename: ez_driver.h -* Author: Hai Nguyen -* Original Date: 15.03.2024 -* -* ---------------------------------------------------------------------------- -* Contact: Hai Nguyen -* hainguyen.eeit@gmail.com -* -* ---------------------------------------------------------------------------- -* License: This file is published under the license described in LICENSE.md -* -*****************************************************************************/ - -/** @file ez_driver.h - * @author Hai Nguyen - * @date 15.03.2024 - * @brief One line description of the component - * - * @details Detail description of the component - */ - -#ifndef _EZ_DRIVER_H -#define _EZ_DRIVER_H - -/***************************************************************************** -* Includes -*****************************************************************************/ -#if (EZ_DRIVER_ENABLE == 1) -#include "ez_driver_def.h" - -/***************************************************************************** -* Component Preprocessor Macros -*****************************************************************************/ -#define A_MACRO 1 /**< a macro*/ - -/***************************************************************************** -* Component Typedefs -*****************************************************************************/ - -/** @brief definition of a new type - * - */ -typedef struct -{ - int a; /**< an integer */ - int b; /**< an integer */ -}aType; - - -/***************************************************************************** -* Component Variable Definitions -*****************************************************************************/ -/* None */ - -/***************************************************************************** -* Function Prototypes -*****************************************************************************/ - -/***************************************************************************** -* Function: sum -*//** -* @brief one line description -* -* @details Detail description -* -* @param a: (IN)pointer to the ring buffer -* @param b: (IN)size of the ring buffer -* @return None -* -* @pre None -* @post None -* -* \b Example -* @code -* sum(a, b); -* @endcode -* -* @see sum -* -*****************************************************************************/ -int sum(int a, int b); - -#endif /* EZ_DRIVER_ENABLE == 1 */ -#endif /* _EZ_DRIVER_H */ - - -/* End of file */ diff --git a/easy_embedded/service/driver/ez_driver_def.h b/easy_embedded/service/driver/ez_driver_def.h index 2bf3e87..ad47f0a 100644 --- a/easy_embedded/service/driver/ez_driver_def.h +++ b/easy_embedded/service/driver/ez_driver_def.h @@ -40,6 +40,9 @@ /***************************************************************************** * Component Typedefs *****************************************************************************/ + +/** @brief Return status of the Driver API + */ typedef enum { STATUS_OK, /**< OK, working as expected */ @@ -52,9 +55,18 @@ typedef enum }EZ_DRV_STATUS; +/** @brief Callback to receive event from the HW implementation + * + * @param[out] event_code: index of the HW Uart instance + * @param[out] param1: point to the first parameter. Depending on event_code + * @param[out] param2: point to the second parameter. Depending on event_code + * @return None + */ typedef void (*ezDrvCallback)(uint8_t event_code, void *param1, void *param2); +/** @brief Define a driver instance. + */ struct ezDrvInstance { ezDrvCallback calback; /**< Callback funtion to handle the event from the HW driver */ @@ -62,9 +74,13 @@ struct ezDrvInstance }; +/** @brief Define a driver instance type. + */ typedef struct ezDrvInstance ezDrvInstance_t; +/** @brief Define structure holding common data of a driver + */ struct ezDriverCommon { const char* name; /* Name of the driver instance */ @@ -82,6 +98,28 @@ struct ezDriverCommon /***************************************************************************** * Function Prototypes *****************************************************************************/ + +/***************************************************************************** +* Function: ezDriver_GetDriverFromInstance +*//** +* @brief Return the driver which the instance is registered to. +* +* @details Helper function used by other components. THe user are not +* supposed to used this function +* +* @param[in] inst: Instance to be register. @see ezUartDrvInstance_t +* @return Pointer driver if success, else NULL +* +* @pre None +* @post None +* +* \b Example +* @code +* @endcode +* +* @see +* +*****************************************************************************/ static inline void *ezDriver_GetDriverFromInstance(ezDrvInstance_t *inst) { void *drv = NULL; @@ -94,7 +132,31 @@ static inline void *ezDriver_GetDriverFromInstance(ezDrvInstance_t *inst) } -static inline bool ezDriver_IsDriverAvailable(ezDrvInstance_t *inst, struct ezDriverCommon *drv_common) +/***************************************************************************** +* Function: ezDriver_IsDriverAvailable +*//** +* @brief Check if the driver is availabe and ready to be used +* +* @details Helper function used by other components. THe user are not +* supposed to used this function +* +* @param[in] inst: Driver instance +* @param[in] drv_common: Pointer to the common structure of the driver. +* @see ezDriverCommon +* @return true is the driver is available, else false +* +* @pre None +* @post None +* +* \b Example +* @code +* @endcode +* +* @see +* +*****************************************************************************/ +static inline bool ezDriver_IsDriverAvailable(ezDrvInstance_t *inst, + struct ezDriverCommon *drv_common) { bool ret = false; if(inst != NULL && drv_common != NULL) @@ -105,7 +167,27 @@ static inline bool ezDriver_IsDriverAvailable(ezDrvInstance_t *inst, struct ezDr } -static inline void ezDriver_LockDriver(ezDrvInstance_t *inst, struct ezDriverCommon *drv_common) +/***************************************************************************** +* Function: ezDriver_LockDriver +*//** +* @brief Lock the driver. Prevent other instances use it +* +* @param[in] inst: Driver instance +* @param[in] drv_common: Pointer to the common structure of the driver. +* @return None +* +* @pre None +* @post None +* +* \b Example +* @code +* @endcode +* +* @see +* +*****************************************************************************/ +static inline void ezDriver_LockDriver(ezDrvInstance_t *inst, + struct ezDriverCommon *drv_common) { if(inst != NULL && drv_common != NULL) { @@ -114,6 +196,25 @@ static inline void ezDriver_LockDriver(ezDrvInstance_t *inst, struct ezDriverCom } +/***************************************************************************** +* Function: ezDriver_UnlockDriver +*//** +* @brief Unlock the driver. +* +* @param[in] inst: Driver instance +* @param[in] drv_common: Pointer to the common structure of the driver. +* @return None +* +* @pre None +* @post None +* +* \b Example +* @code +* @endcode +* +* @see +* +*****************************************************************************/ static inline void ezDriver_UnlockDriver(struct ezDriverCommon *drv_common) { if(drv_common != NULL) diff --git a/easy_embedded/service/driver/uart/ez_uart.c b/easy_embedded/service/driver/uart/ez_uart.c index 4cb7910..bcbc064 100644 --- a/easy_embedded/service/driver/uart/ez_uart.c +++ b/easy_embedded/service/driver/uart/ez_uart.c @@ -15,9 +15,9 @@ /** @file ez_uart.c * @author Hai Nguyen * @date 15.03.2024 - * @brief One line description of the component + * @brief Implementation of the UART component * - * @details Detail description of the component + * @details */ /***************************************************************************** @@ -397,6 +397,29 @@ EZ_DRV_STATUS ezUart_UpdateConfig(ezUartDrvInstance_t *inst) /***************************************************************************** * Local functions *****************************************************************************/ + + +/***************************************************************************** +* Function: ezUart_PrintStatus +*//** +* @brief Print the EZ_DRV_STATUS +* +* @details This function is activated only when DEBUG_LVL >= LVL_DEBUG +* +* @param[in] status: status to be printed +* @return None +* +* @pre DEBUG_LVL >= LVL_DEBUG +* @post None +* +* \b Example +* @code +* ezUart_PrintStatus(STATUS_ERR_ARG); +* @endcode +* +* @see +* +*****************************************************************************/ static void ezUart_PrintStatus(EZ_DRV_STATUS status) { #if (DEBUG_LVL >= LVL_DEBUG) diff --git a/easy_embedded/service/driver/uart/ez_uart.h b/easy_embedded/service/driver/uart/ez_uart.h index ef6d3be..05a26c7 100644 --- a/easy_embedded/service/driver/uart/ez_uart.h +++ b/easy_embedded/service/driver/uart/ez_uart.h @@ -15,9 +15,11 @@ /** @file ez_uart.h * @author Hai Nguyen * @date 15.03.2024 - * @brief One line description of the component + * @brief Public API of the UART component * - * @details Detail description of the component + * @details This component provides the interfaces to interact with HW uart. + * It also provides the interface, which every HW UART implementation + * must follow. */ #ifndef _EZ_UART_H @@ -42,16 +44,16 @@ /***************************************************************************** * Component Typedefs *****************************************************************************/ -/** @brief Uart event +/** @brief UART event definitions */ typedef enum { - UART_EVENT_TX_CMPLT, - UART_EVENT_TX_ERR, - UART_EVENT_RX_CMPLT, - UART_EVENT_RX_ERR, - UART_EVENT_TIMEOUT, - UART_NUM_EVENTS, + UART_EVENT_TX_CMPLT, /**< Transmit operation is completed */ + UART_EVENT_TX_ERR, /**< Transmit operation failed */ + UART_EVENT_RX_CMPLT, /**< Receive operation is completed */ + UART_EVENT_RX_ERR, /**< Receive operation failed */ + UART_EVENT_TIMEOUT, /**< Operation is timeout */ + UART_NUM_EVENTS, /**< Number of events */ }EZ_UART_EVENT; @@ -94,53 +96,90 @@ struct ezUartConfiguration typedef struct ezDrvInstance ezUartDrvInstance_t; -/** @brief +/****************************************************************************/ +/* List of API implemented by the HW driver. Users are not supposed to use + * these API. + */ + +/** @brief Initialize the Hw Uart + * + * @param[in] index: index of the HW Uart instance + * @return STATUS_OK if success, otherwise STATUS_XXX. @see EZ_DRV_STATUS */ typedef EZ_DRV_STATUS(*ezHwUart_Initialize)(uint8_t index); -/** @brief +/** @brief Deinitialize the Hw Uart + * + * @param[in] index: index of the HW Uart instance + * @return STATUS_OK if success, otherwise STATUS_XXX. @see EZ_DRV_STATUS */ typedef EZ_DRV_STATUS(*ezHwUart_Deinitialize)(uint8_t index); -/** @brief +/** @brief Transmit data asynchornously + * + * @param[in] index: index of the HW Uart instance + * @param[in] tx_buff: point to transmited buffer + * @param[in] buff_size: size of the buffer + * @return STATUS_OK if success, otherwise STATUS_XXX. @see EZ_DRV_STATUS */ typedef EZ_DRV_STATUS(*ezHwUart_AsyncTransmit)(uint8_t index, const uint8_t *tx_buff, uint16_t buff_size); -/** @brief +/** @brief Receive data asynchornously + * + * @param[in] index: index of the HW Uart instance + * @param[in] rx_buff: point to received buffer + * @param[in] buff_size: size of the buffer + * @return STATUS_OK if success, otherwise STATUS_XXX. @see EZ_DRV_STATUS */ typedef EZ_DRV_STATUS(*ezHwUart_AsyncReceive)(uint8_t index, uint8_t *rx_buff, uint16_t buff_size); -/** @brief +/** @brief Transmit data synchronously + * + * @param[in] index: index of the HW Uart instance + * @param[in] tx_buff: point to transmited buffer + * @param[in] buff_size: size of the buffer + * @param[in] timeout_millis: timeout in millisecond + * @return STATUS_OK if success, otherwise STATUS_XXX. @see EZ_DRV_STATUS */ typedef EZ_DRV_STATUS(*ezHwUart_SyncTransmit)(uint8_t index, const uint8_t *tx_buff, uint16_t buff_size, uint32_t timeout_millis); -/** @brief +/** @brief Receive data synchronously + * + * @param[in] index: index of the HW Uart instance + * @param[in] rx_buff: point to received buffer + * @param[in] buff_size: size of the buffer + * @param[in] timeout_millis: timeout in millisecond + * @return STATUS_OK if success, otherwise STATUS_XXX. @see EZ_DRV_STATUS */ typedef EZ_DRV_STATUS(*ezHwUart_SyncReceive)(uint8_t index, uint8_t *rx_buff, uint16_t buff_size, uint32_t timeout_millis); -/** @brief +/** @brief Update the configuration + * + * @param[in] index: index of the HW Uart instance + * @return STATUS_OK if success, otherwise STATUS_ERR_XXX. @see EZ_DRV_STATUS */ typedef EZ_DRV_STATUS(*ezHwUart_UpdateConfig)(uint8_t index); -/** @brief Number of stop bit +/** @brief List of API must be supported by the Hw implementation */ struct ezHwUartInterface { uint8_t index; /**< Index of the driver instance */ - ezHwUart_Initialize initialize; /**< */ - ezHwUart_Deinitialize deinitialize; /**< */ - ezHwUart_AsyncTransmit async_transmit; /**< */ - ezHwUart_AsyncReceive async_receive; /**< */ - ezHwUart_SyncTransmit sync_transmit; /**< */ - ezHwUart_SyncReceive sync_receive; /**< */ - ezHwUart_UpdateConfig update_conf; /**< */ + ezHwUart_Initialize initialize; /**< Initialize function */ + ezHwUart_Deinitialize deinitialize; /**< Deinitialize function */ + ezHwUart_AsyncTransmit async_transmit; /**< Transmit data asynchorously. Events are reported via callback in ezDriverCommon -> ezDrvInstance_t -> calback*/ + ezHwUart_AsyncReceive async_receive; /**< Receive data asynchorously. Events are reported via callback in ezDriverCommon -> ezDrvInstance_t -> calback*/ + ezHwUart_SyncTransmit sync_transmit; /**< Transmit data synchorously */ + ezHwUart_SyncReceive sync_receive; /**< Receive data synchorously */ + ezHwUart_UpdateConfig update_conf; /**< Update configuration function */ + /* Add more API if required */ }; @@ -164,19 +203,355 @@ struct ezUartDriver /***************************************************************************** * Function Prototypes *****************************************************************************/ + +/***************************************************************************** +* Function: ezUart_SystemRegisterHwDriver +*//** +* @brief Register a HW uart implementation to the HAL +* +* @details The implementation must follow the interfaces defined by ezUartDriver +* +* @param[in] hw_uart_driver: (IN)pointer to the HW implementation +* @return STATUS_OK: Success +* STATUS_ERR_ARG: hw_uart_driver is NULL +* +* @pre None +* @post None +* +* \b Example +* @code +* EZ_DRV_STATUS status = ezUart_SystemRegisterHwDriver(&stm32_uart_driver); +* @endcode +* +* +*****************************************************************************/ EZ_DRV_STATUS ezUart_SystemRegisterHwDriver(struct ezUartDriver *hw_uart_driver); + + +/***************************************************************************** +* Function: ezUart_SystemUnregisterHwDriver +*//** +* @brief Unregister a HW driver implementation +* +* @details +* +* @param[in] hw_uart_driver: (IN)pointer to the HW implementation +* @return STATUS_OK: Success +* STATUS_ERR_ARG: hw_uart_driver is NULL +* +* @pre None +* @post None +* +* \b Example +* @code +* EZ_DRV_STATUS status = ezUart_SystemUnregisterHwDriver(&stm32_uart_driver); +* @endcode +* +* @see sum +* +*****************************************************************************/ EZ_DRV_STATUS ezUart_SystemUnregisterHwDriver(struct ezUartDriver *hw_uart_driver); -EZ_DRV_STATUS ezUart_RegisterInstance(ezUartDrvInstance_t *inst, const char *driver_name, ezDrvCallback callback); + +/***************************************************************************** +* Function: ezUart_RegisterInstance +*//** +* @brief Register a driver instance to use the driver +* +* @details +* +* @param[in] inst: Instance to be register. @see ezUartDrvInstance_t +* @param[in] driver_name: Name of the driver we want to use. +* @param[in] callback: callback function to receive event from the HW driver +* @return STATUS_OK: Success +* STATUS_XXX: Error code defined in EZ_DRV_STATUS +* +* @pre HW driver must be registered by using ezUart_SystemRegisterHwDriver +* @post None +* +* \b Example +* @code +* ezUartDrvInstance_t inst; +* EZ_DRV_STATUS status = ezUart_RegisterInstance(&inst, "stm32 uart", callback); +* @endcode +* +* @see ezUart_SystemRegisterHwDriver +* +*****************************************************************************/ +EZ_DRV_STATUS ezUart_RegisterInstance(ezUartDrvInstance_t *inst, + const char *driver_name, + ezDrvCallback callback); + + +/***************************************************************************** +* Function: ezUart_UnregisterInstance +*//** +* @brief Unregister a driver instance +* +* @details +* +* @param[in] inst: Driver instance +* @return STATUS_OK: Success +* STATUS_XXX: Error code defined in EZ_DRV_STATUS +* +* @pre None +* @post None +* +* \b Example +* @code +* EZ_DRV_STATUS status = ezUart_RegisterInstance(&inst); +* @endcode +* +* @see ezUart_RegisterInstance +* +*****************************************************************************/ EZ_DRV_STATUS ezUart_UnregisterInstance(ezUartDrvInstance_t *inst); + +/***************************************************************************** +* Function: ezUart_Initialize +*//** +* @brief Initialize the UART driver +* +* @details Normall, user do not need to call this function. The HW uart +* implementation take care of the initialization. +* +* @param[in] iinst: Driver instance +* @return STATUS_OK: Success +* STATUS_XXX: Error code defined in EZ_DRV_STATUS +* +* @pre inst must be register using ezUart_RegisterInstance +* @post None +* +* \b Example +* @code +* EZ_DRV_STATUS status = ezUart_Initialize(&inst); +* @endcode +* +* @see ezUart_RegisterInstance +* +*****************************************************************************/ EZ_DRV_STATUS ezUart_Initialize(ezUartDrvInstance_t *inst); + + +/***************************************************************************** +* Function: ezUart_Deinitialize +*//** +* @brief Deintialize the UART driver +* +* @details +* +* @param[in] inst: Driver instance +* @return STATUS_OK: Success +* STATUS_XXX: Error code defined in EZ_DRV_STATUS +* +* @pre inst must be register using ezUart_RegisterInstance +* @post None +* +* \b Example +* @code +* EZ_DRV_STATUS status = ezUart_Deinitialize(&inst); +* @endcode +* +* @see ezUart_RegisterInstance +* +*****************************************************************************/ EZ_DRV_STATUS ezUart_Deinitialize(ezUartDrvInstance_t *inst); -EZ_DRV_STATUS ezUart_AsyncTransmit(ezUartDrvInstance_t *inst, const uint8_t *tx_buff, uint16_t buff_size); -EZ_DRV_STATUS ezUart_AsyncReceive(ezUartDrvInstance_t *inst, uint8_t *rx_buff, uint16_t buff_size); -EZ_DRV_STATUS ezUart_SyncTransmit(ezUartDrvInstance_t *inst, const uint8_t *tx_buff, uint16_t buff_size, uint32_t timeout_millis); -EZ_DRV_STATUS ezUart_SyncReceive(ezUartDrvInstance_t *inst, uint8_t *rx_buff, uint16_t buff_size, uint32_t timeout_millis); -EZ_DRV_STATUS ezUart_GetConfig(ezUartDrvInstance_t *inst, struct ezUartConfiguration **config); + + +/***************************************************************************** +* Function: ezUart_AsyncTransmit +*//** +* @brief Transmit data asynchronously. +* +* @details The events or error code is reported via callback defined by +* ezUart_RegisterInstance. Since it is an asynchrous function, the user +* must ensure that the buffer for transmiting data must not be used by +* other processes. +* +* @param[in] inst: Driver instance +* @param[in] tx_buff: pointer to transmit buffer +* @param[in] buff_size: size of the buffer +* @return STATUS_OK: Success +* STATUS_XXX: Error code defined in EZ_DRV_STATUS +* +* @pre inst must be register using ezUart_RegisterInstance +* @post None +* +* \b Example +* @code +* EZ_DRV_STATUS status; +* uint8_t buff[3] = {1, 2, 3}; +* status = ezUart_AsyncTransmit(&inst, buff, 3); +* @endcode +* +* @see ezUart_RegisterInstance +* +*****************************************************************************/ +EZ_DRV_STATUS ezUart_AsyncTransmit(ezUartDrvInstance_t *inst, + const uint8_t *tx_buff, + uint16_t buff_size); + + +/***************************************************************************** +* Function: ezUart_AsyncReceive +*//** +* @brief Receive data asynchronously. +* +* @details The events or error code is reported via callback defined by +* ezUart_RegisterInstance. Since it is an asynchrous function, the users +* must ensure that the buffer for receiving data must not be used by +* other processes. +* +* @param[in] inst: Driver instance +* @param[in] rx_buff: pointer to receive buffer +* @param[in] buff_size: size of the buffer +* @return STATUS_OK: Success +* STATUS_XXX: Error code defined in EZ_DRV_STATUS +* +* @pre inst must be register using ezUart_RegisterInstance +* @post None +* +* \b Example +* @code +* EZ_DRV_STATUS status; +* uint8_t buff[3]; +* status = ezUart_AsyncReceive(&inst, buff, 3); +* @endcode +* +* @see ezUart_RegisterInstance +* +*****************************************************************************/ +EZ_DRV_STATUS ezUart_AsyncReceive(ezUartDrvInstance_t *inst, + uint8_t *rx_buff, + uint16_t buff_size); + + +/***************************************************************************** +* Function: ezUart_SyncTransmit +*//** +* @brief Transmit data synchronously. +* +* @details Since it is a synchrous function, the process is blocked for an +* interval of millisecond defined by timeout_millis argument +* +* @param[in] inst: Driver instance +* @param[in] tx_buff: pointer to transmit buffer +* @param[in] buff_size: size of the buffer +* @param[in] timeout_millis: timeout in millisecond +* @return STATUS_OK: Success +* STATUS_XXX: Error code defined in EZ_DRV_STATUS +* +* @pre inst must be register using ezUart_RegisterInstance +* @post None +* +* \b Example +* @code +* EZ_DRV_STATUS status; +* uint8_t buff[3] = {1, 2, 3}; +* status = ezUart_SyncTransmit(&inst, buff, 3, 1000); +* @endcode +* +* @see ezUart_RegisterInstance +* +*****************************************************************************/ +EZ_DRV_STATUS ezUart_SyncTransmit(ezUartDrvInstance_t *inst, + const uint8_t *tx_buff, + uint16_t buff_size, + uint32_t timeout_millis); + + +/***************************************************************************** +* Function: ezUart_SyncReceive +*//** +* @brief Receive data synchronously. +* +* @details Since it is a synchrous function, the process is blocked for an +* interval of millisecond defined by timeout_millis argument +* +* @param[in] inst: Driver instance +* @param[in] rx_buff: pointer to receive buffer +* @param[in] buff_size: size of the buffer +* @param[in] timeout_millis: timeout in millisecond +* @return STATUS_OK: Success +* STATUS_XXX: Error code defined in EZ_DRV_STATUS +* +* @pre inst must be register using ezUart_RegisterInstance +* @post None +* +* \b Example +* @code +* EZ_DRV_STATUS status; +* uint8_t buff[3] = {1, 2, 3}; +* status = ezUart_SyncReceive(&inst, buff, 3, 1000); +* @endcode +* +* @see ezUart_RegisterInstance +* +*****************************************************************************/ +EZ_DRV_STATUS ezUart_SyncReceive(ezUartDrvInstance_t *inst, + uint8_t *rx_buff, + uint16_t buff_size, + uint32_t timeout_millis); + + +/***************************************************************************** +* Function: ezUart_GetConfig +*//** +* @brief Get the configuration of the Hw Uart implementation +* +* @details +* +* @param[in] inst: Driver instance +* @param[in] config: pointer to the configutation +* @return STATUS_OK: Success +* STATUS_XXX: Error code defined in EZ_DRV_STATUS +* +* @pre inst must be register using ezUart_RegisterInstance +* @post None +* +* \b Example +* @code +* EZ_DRV_STATUS status; +* ezUartConfiguration *config = NULL; +* status = ezUart_GetConfig(&inst, &config); +* @endcode +* +* @see ezUart_RegisterInstance +* +*****************************************************************************/ +EZ_DRV_STATUS ezUart_GetConfig(ezUartDrvInstance_t *inst, + struct ezUartConfiguration **config); + + +/***************************************************************************** +* Function: ezUart_UpdateConfig +*//** +* @brief Update the configuration +* +* @details Configuration is obtained by calling the function ezUart_GetConfig. +* When this function is call, the HW implementation will internally +* update its configuration and call the intialization function +* +* @param[in] inst: Driver instance +* @return STATUS_OK: Success +* STATUS_XXX: Error code defined in EZ_DRV_STATUS +* +* @pre Configuration is obtained by ezUart_GetConfig. +* @post None +* +* \b Example +* @code +* EZ_DRV_STATUS status; +* ezUartConfiguration *config = NULL; +* status = ezUart_GetConfig(&inst, &config); +* config->baudrate = 115200; +* status = ezUart_UpdateConfig(&inst); +* @endcode +* +* @see ezUart_GetConfig +* +*****************************************************************************/ EZ_DRV_STATUS ezUart_UpdateConfig(ezUartDrvInstance_t *inst); #endif /* EZ_UART_ENABLE == 1 */