Files
df_datalink/src/systembus/systembus.h
T
josh c468bd9ca1 feat: 完成上位机控制逻辑修改
仅在业务阶段传输上位机数据, 上位机下发数据入队, 待发送时隙进行发送, 收到数据自动上传
2025-06-13 17:22:11 +08:00

86 lines
2.4 KiB
C

/*****************************************************************************/
/**
* @file systembus.h
* @author FanHao ([email protected])
* @brief System bus protocol header file.
* @version 0.1
* @date 2023-05-06
*
* @copyright Copyright(c) 2024 Beijing Institute of Technology.\n
* Lab of Communication and Network
*
******************************************************************************/
/**
* @defgroup SystemBus
* @{
*/
#ifndef __SYSTEMBUS_H_
#define __SYSTEMBUS_H_
/***************************** Include Files *********************************/
#include <stdint.h>
#include <stdbool.h>
#include "systembus_uart.h" // SystemBus UART driver
#include "circ_queue.h"
#include "../system_monitor.h"
/************************** Constant Definitions *****************************/
/************************** Data Type Definitions ****************************/
/**
* @struct SYSBUS_CONFIG
* @brief SystemBus Config struct holds SystemBus initialization parameters
*/
typedef struct
{
uintptr_t baseAddr; ///< base address in memory
uint32_t txQueueMax; ///< maximum tx queue length
uint32_t rxQueueMax; ///< maximum rx queue length
} SYSBUS_CONFIG;
/**
* @struct SYSBUS
* @brief SystemBus Instance struct
*/
typedef struct
{
SYSBUS_CONFIG config; ///< SystemBus initialization parameters
SYSBUSLOG sysbusLog; ///< SystemBus log
LINKLOG linkLog; ///< Link layer log
PHYLOG phyLog; ///< Physical layer log
HWSTATE hwState; ///< Hardware status
SYSBUS_UART *uartInst; ///< physical uart controller instance
CIRC_QUEUE *txQueue; ///< tx queue
CIRC_QUEUE *rxQueue; ///< rx queue
bool isTxDone; ///< tx done indicator
bool isRxDone; ///< rx done indicator
} SYSBUS;
/************************** Function Prototypes ******************************/
int32_t SystemBus_GenRecvRsp(SYSBUS *instPtr, SYSMON_SVC_PAYLOAD *payload);
int32_t SystemBus_Init(SYSBUS **instPtr, SYSBUS_CONFIG *config);
void SystemBus_Destroy(SYSBUS *instPtr);
/**
* @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);
bool SystemBus_IsReqPending(SYSBUS *instPtr);
bool SystemBus_IsRespPending(SYSBUS *instPtr);
bool SystemBus_IsTxBusy(SYSBUS *instPtr);
bool SystemBus_IsRxBusy(SYSBUS *instPtr);
#endif //__SYSTEMBUS_H_
/** @} SystemBus*/