Skip to content

Commit

Permalink
Add document for uart component. fix doxy file
Browse files Browse the repository at this point in the history
  • Loading branch information
QuangHaiNguyen committed Mar 22, 2024
1 parent 09ec0f2 commit 445c492
Show file tree
Hide file tree
Showing 7 changed files with 535 additions and 194 deletions.
2 changes: 1 addition & 1 deletion Doxyfile
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
3 changes: 1 addition & 2 deletions easy_embedded/service/driver/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -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)
Expand All @@ -21,7 +21,6 @@ set(FRAMEWORK_ROOT_DIR ${CMAKE_SOURCE_DIR}/easy_embedded)
# Source files ---------------------------------------------------------------
target_sources(ez_driver_lib
PRIVATE
ez_driver.c
$<$<BOOL:${ENABLE_EZ_UART}>:uart/ez_uart.c>
)

Expand Down
69 changes: 0 additions & 69 deletions easy_embedded/service/driver/ez_driver.c

This file was deleted.

88 changes: 0 additions & 88 deletions easy_embedded/service/driver/ez_driver.h

This file was deleted.

105 changes: 103 additions & 2 deletions easy_embedded/service/driver/ez_driver_def.h
Original file line number Diff line number Diff line change
Expand Up @@ -40,6 +40,9 @@
/*****************************************************************************
* Component Typedefs
*****************************************************************************/

/** @brief Return status of the Driver API
*/
typedef enum
{
STATUS_OK, /**< OK, working as expected */
Expand All @@ -52,19 +55,32 @@ 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 */
void *driver; /**< Pointer to the HAL driver, depending on the implmentation */
};


/** @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 */
Expand All @@ -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;
Expand All @@ -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)
Expand All @@ -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)
{
Expand All @@ -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)
Expand Down
27 changes: 25 additions & 2 deletions easy_embedded/service/driver/uart/ez_uart.c
Original file line number Diff line number Diff line change
Expand Up @@ -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
*/

/*****************************************************************************
Expand Down Expand Up @@ -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)
Expand Down
Loading

0 comments on commit 445c492

Please sign in to comment.