diff --git a/df_datalink_sp/src/include/error.h b/df_datalink_sp/src/include/error.h index f3acc6a..0b878d5 100644 --- a/df_datalink_sp/src/include/error.h +++ b/df_datalink_sp/src/include/error.h @@ -25,7 +25,7 @@ /******************************************************************************/ /** - * @name ERRORNO) + * @name ERRORNO * @{ */ diff --git a/df_datalink_sp/src/systembus/systembus.c b/df_datalink_sp/src/systembus/systembus.c index efb32aa..524cd66 100644 --- a/df_datalink_sp/src/systembus/systembus.c +++ b/df_datalink_sp/src/systembus/systembus.c @@ -26,9 +26,13 @@ #include "common.h" #include "error.h" #include "circ_queue.h" - #include "../system_monitor.h" +/** + * @addtogroup SystemBus_Protocol_Routine + * @{ + */ + /************************** Constant Definitions *****************************/ /** * @name SystemBus_MSG_Constants @@ -498,64 +502,6 @@ static int32_t SystemBus_GenRemoteTestRsp(SYSBUS *instPtr, uint8_t *msg) return SUCCESS; } -/*****************************************************************************/ -/** - * @brief Initialize System Bus instance. - * - * @param InstPtr A double pointer to System Bus instance. - * @param config A pointer to System Bus configurations. - * - * @return None. - * - ******************************************************************************/ -int32_t SystemBus_Init(SYSBUS **instPtr, SYSBUS_CONFIG *config) -{ - ASSERT(instPtr != NULL); - ASSERT(config != NULL); - SYSBUS_UART_CONFIG uartConfig; - int32_t Status; - (*instPtr) = malloc(sizeof(SYSBUS)); - if ((*instPtr) == NULL) - { - return FAILURE; - } - (*instPtr)->rxQueue = NULL; - (*instPtr)->txQueue = NULL; - (*instPtr)->uartInst = NULL; - memcpy(&((*instPtr)->config), config, sizeof(SYSBUS_CONFIG)); - memset(&((*instPtr)->sysbusLog), 0x00, sizeof(SYSBUSLOG)); - memset(&((*instPtr)->linkLog), 0x00, sizeof(LINKLOG)); - memset(&((*instPtr)->phyLog), 0x00, sizeof(PHYLOG)); - memset(&((*instPtr)->hwState), 0x00, sizeof(HWSTATE)); - uartConfig.baseAddr = config->baseAddr; - Status = SysbusUart_Init(&((*instPtr)->uartInst), &uartConfig); - if (Status != SUCCESS) - { - Status = ENOMEM; - goto sysbus_init_error; - } - if (CircQueueCreate(&((*instPtr)->txQueue), (*instPtr)->config.txQueueMax) == false) - { - Status = ENOMEM; - goto sysbus_init_error; - } - if (CircQueueCreate(&((*instPtr)->rxQueue), (*instPtr)->config.rxQueueMax) == false) - { - Status = ENOMEM; - goto sysbus_init_error; - } - (*instPtr)->isRxDone = false; // nothing received. - (*instPtr)->isTxDone = true; // nothing to be sent. - return SUCCESS; - -sysbus_init_error: - free((*instPtr)->uartInst); - free((*instPtr)->txQueue); - free((*instPtr)->rxQueue); - free(*instPtr); - return Status; -} - /*****************************************************************************/ /** * @brief A handler function. This handler evaluate the message from system @@ -702,6 +648,66 @@ int32_t SystemBus_MakeResp(SYSBUS *instPtr) return Status; } +/** @} */ + +/*****************************************************************************/ +/** + * @brief Initialize System Bus instance. + * + * @param InstPtr A double pointer to System Bus instance. + * @param config A pointer to System Bus configurations. + * + * @return None. + * + ******************************************************************************/ +int32_t SystemBus_Init(SYSBUS **instPtr, SYSBUS_CONFIG *config) +{ + ASSERT(instPtr != NULL); + ASSERT(config != NULL); + SYSBUS_UART_CONFIG uartConfig; + int32_t Status; + (*instPtr) = malloc(sizeof(SYSBUS)); + if ((*instPtr) == NULL) + { + return FAILURE; + } + (*instPtr)->rxQueue = NULL; + (*instPtr)->txQueue = NULL; + (*instPtr)->uartInst = NULL; + memcpy(&((*instPtr)->config), config, sizeof(SYSBUS_CONFIG)); + memset(&((*instPtr)->sysbusLog), 0x00, sizeof(SYSBUSLOG)); + memset(&((*instPtr)->linkLog), 0x00, sizeof(LINKLOG)); + memset(&((*instPtr)->phyLog), 0x00, sizeof(PHYLOG)); + memset(&((*instPtr)->hwState), 0x00, sizeof(HWSTATE)); + uartConfig.baseAddr = config->baseAddr; + Status = SysbusUart_Init(&((*instPtr)->uartInst), &uartConfig); + if (Status != SUCCESS) + { + Status = ENOMEM; + goto sysbus_init_error; + } + if (CircQueueCreate(&((*instPtr)->txQueue), (*instPtr)->config.txQueueMax) == false) + { + Status = ENOMEM; + goto sysbus_init_error; + } + if (CircQueueCreate(&((*instPtr)->rxQueue), (*instPtr)->config.rxQueueMax) == false) + { + Status = ENOMEM; + goto sysbus_init_error; + } + (*instPtr)->isRxDone = false; // nothing received. + (*instPtr)->isTxDone = true; // nothing to be sent. + return SUCCESS; + +sysbus_init_error: + free((*instPtr)->uartInst); + free((*instPtr)->txQueue); + free((*instPtr)->rxQueue); + free(*instPtr); + return Status; +} + /*****************************************************************************/ /** * @brief This function handles the systembus tx irq events. diff --git a/df_datalink_sp/src/systembus/systembus.h b/df_datalink_sp/src/systembus/systembus.h index 76c0b81..d5eafdc 100644 --- a/df_datalink_sp/src/systembus/systembus.h +++ b/df_datalink_sp/src/systembus/systembus.h @@ -61,8 +61,13 @@ typedef struct int32_t SystemBus_Init(SYSBUS **instPtr, SYSBUS_CONFIG *config); +/** + * @defgroup SystemBus_Protocol_Routine + * @{ + */ int32_t SystemBus_HandleCmd(SYSBUS *instPtr); int32_t SystemBus_MakeResp(SYSBUS *instPtr); +/** @} */ int32_t SystemBus_TxIntrHandler(SYSBUS *instPtr); int32_t SystemBus_RxIntrHandler(SYSBUS *instPtr);