forked from gatsby/df_datalink
feat: 移除sysmon文件, 合并至sysbus
This commit is contained in:
+1
-1
@@ -25,10 +25,10 @@
|
||||
#include "common.h"
|
||||
#include "error.h"
|
||||
#include "delay.h"
|
||||
#include "system_monitor.h"
|
||||
#include "hwconfig.h"
|
||||
#include "config/app_config.h"
|
||||
#include "dev_profile/dev_profile.h"
|
||||
#include "systembus/systembus.h"
|
||||
#ifdef RFSOC
|
||||
#include "xrfdc.h"
|
||||
#endif
|
||||
|
||||
@@ -28,7 +28,6 @@
|
||||
#include "error.h"
|
||||
#include "timer.h"
|
||||
#include "hwconfig.h"
|
||||
#include "system_monitor.h"
|
||||
#include "config/app_config.h"
|
||||
#include "dev_profile/dev_profile.h"
|
||||
#include "systembus/systembus.h"
|
||||
|
||||
@@ -27,7 +27,7 @@
|
||||
#include "msg_def.h"
|
||||
#include "circ_queue.h"
|
||||
#include "../phy_layer/phy_layer.h"
|
||||
#include "../../system_monitor.h"
|
||||
#include "../../systembus/systembus.h"
|
||||
/************************** Constant Definitions *****************************/
|
||||
/***************** Macros (Inline Functions) Definitions *********************/
|
||||
#define AssertL2Event(instPtr, event) (Linklayer_EventHandler((instPtr), (event)))
|
||||
|
||||
@@ -250,7 +250,7 @@ int32_t L2_Scan_PktHandler(L2_INST *instPtr, uint8_t *msg)
|
||||
DBG_ERROR("Payload length" PRIu16 " out of range.\n", message->dataLen);
|
||||
return EIGNORE;
|
||||
}
|
||||
SYSMON_SVC_PAYLOAD *recvPayload = calloc(1, NORMALIZE_SIZE(sizeof(SYSMON_SVC_PAYLOAD)));
|
||||
SYSBUS_SVC_PLD *recvPayload = calloc(1, sizeof(SYSBUS_SVC_PLD));
|
||||
recvPayload->dataId = message->dataId;
|
||||
recvPayload->nodeId = message->common.src;
|
||||
recvPayload->dataLen = message->dataLen;
|
||||
@@ -326,7 +326,7 @@ int32_t L2_Scan_PktHandler(L2_INST *instPtr, uint8_t *msg)
|
||||
}
|
||||
|
||||
// Get data payload & upload
|
||||
SYSMON_SVC_PAYLOAD recvPayload;
|
||||
SYSBUS_SVC_PLD recvPayload;
|
||||
recvPayload.dataId = message->dataId;
|
||||
recvPayload.nodeId = message->common.src;
|
||||
recvPayload.dataLen = message->dataLen;
|
||||
|
||||
@@ -200,7 +200,7 @@ static int32_t Service_Packing128K(L2_INST *instPtr, L2_FRAME_TYPE type, uint8_t
|
||||
if (type == L2_FRAME_SVC)
|
||||
{
|
||||
// Packing extra payload
|
||||
SYSMON_SVC_PAYLOAD *sendPayload;
|
||||
SYSBUS_SVC_PLD *sendPayload;
|
||||
SysMonitor_GetSendPayload(&sendPayload);
|
||||
if(sendPayload == NULL)
|
||||
{
|
||||
@@ -278,7 +278,7 @@ static int32_t Service_Packing512K(L2_INST *instPtr, L2_FRAME_TYPE type, uint8_t
|
||||
message->srcSpeedZ = instPtr->sysInfo.vZ;
|
||||
|
||||
// Pack extra payload
|
||||
SYSMON_SVC_PAYLOAD *sendPayload;
|
||||
SYSBUS_SVC_PLD *sendPayload;
|
||||
SysMonitor_GetSendPayload(&sendPayload);
|
||||
if(sendPayload == NULL)
|
||||
{
|
||||
@@ -348,7 +348,7 @@ static int32_t Service_Packing2M(L2_INST *instPtr, L2_FRAME_TYPE type, uint8_t d
|
||||
message->srcSpeedZ = instPtr->sysInfo.vZ;
|
||||
|
||||
// Packing extra payload
|
||||
SYSMON_SVC_PAYLOAD *sendPayload;
|
||||
SYSBUS_SVC_PLD *sendPayload;
|
||||
SysMonitor_GetSendPayload(&sendPayload);
|
||||
if(sendPayload == NULL)
|
||||
{
|
||||
@@ -535,7 +535,7 @@ static int32_t Service_PktHandler128K(L2_INST *instPtr, uint8_t *msg)
|
||||
DBG_ERROR("Payload length" PRIu16 " out of range.\n", message->dataLen);
|
||||
return EIGNORE;
|
||||
}
|
||||
SYSMON_SVC_PAYLOAD *recvPayload = calloc(1, NORMALIZE_SIZE(sizeof(SYSMON_SVC_PAYLOAD)));
|
||||
SYSBUS_SVC_PLD *recvPayload = calloc(1, sizeof(SYSBUS_SVC_PLD));
|
||||
recvPayload->dataId = message->dataId;
|
||||
recvPayload->nodeId = message->common.src;
|
||||
recvPayload->dataLen = message->dataLen;
|
||||
@@ -623,7 +623,7 @@ static int32_t Service_PktHandler512K(L2_INST *instPtr, uint8_t *msg)
|
||||
DBG_ERROR("Payload length" PRIu16 " out of range.\n", message->dataLen);
|
||||
return EIGNORE;
|
||||
}
|
||||
SYSMON_SVC_PAYLOAD *recvPayload = calloc(1, NORMALIZE_SIZE(sizeof(SYSMON_SVC_PAYLOAD)));
|
||||
SYSBUS_SVC_PLD *recvPayload = calloc(1, sizeof(SYSBUS_SVC_PLD));
|
||||
recvPayload->dataId = message->dataId;
|
||||
recvPayload->nodeId = message->common.src;
|
||||
recvPayload->dataLen = message->dataLen;
|
||||
@@ -711,7 +711,7 @@ static int32_t Service_PktHandler2M(L2_INST *instPtr, uint8_t *msg)
|
||||
DBG_ERROR("Payload length" PRIu16 " out of range.\n", message->dataLen);
|
||||
return EIGNORE;
|
||||
}
|
||||
SYSMON_SVC_PAYLOAD *recvPayload = calloc(1, NORMALIZE_SIZE(sizeof(SYSMON_SVC_PAYLOAD)));
|
||||
SYSBUS_SVC_PLD *recvPayload = calloc(1, sizeof(SYSBUS_SVC_PLD));
|
||||
recvPayload->dataId = message->dataId;
|
||||
recvPayload->nodeId = message->common.src;
|
||||
recvPayload->dataLen = message->dataLen;
|
||||
|
||||
@@ -31,7 +31,7 @@
|
||||
#include "xadcps.h"
|
||||
#endif
|
||||
#endif
|
||||
#include "../../system_monitor.h"
|
||||
#include "../../systembus/systembus.h"
|
||||
#include "../../time_ctrl/time_ctrl.h"
|
||||
/************************** Constant Definitions *****************************/
|
||||
/**
|
||||
|
||||
@@ -1,383 +0,0 @@
|
||||
/**
|
||||
* @addtogroup SystemMonitor
|
||||
* @{
|
||||
*/
|
||||
|
||||
/***************************** Include Files *********************************/
|
||||
#include <string.h>
|
||||
#include <stdlib.h>
|
||||
#include <stdint.h>
|
||||
#include "common.h"
|
||||
#include "circ_queue.h"
|
||||
#include "system_monitor.h"
|
||||
#include "systembus/systembus.h"
|
||||
/************************** Constant Definitions *****************************/
|
||||
/**
|
||||
* @name SystemMonitor_Private_Constants
|
||||
* @{
|
||||
*/
|
||||
#define BUFF_A 0x00
|
||||
#define BUFF_B 0x01
|
||||
#define BUFF_NONE 0xFF
|
||||
|
||||
#define SYSINFO_PACK_LEN 54 // bytes
|
||||
#define PAYLOAD_PACK_LEN 46 // bytes
|
||||
#define SLOTLOG_PACK_LEN 88 // bytes
|
||||
#define PRTCLLOG_PACK_ELN 24 // bytes
|
||||
#define HWSTATE_PACK_ELN 12 // bytes
|
||||
/** @} SystemMonitor_Private_Constants*/
|
||||
/************************** Data Type Definitions ****************************/
|
||||
/**
|
||||
* @struct PINGPONG
|
||||
* @brief PingPing Control
|
||||
*/
|
||||
typedef struct
|
||||
{
|
||||
uint8_t latest; ///< latest available index
|
||||
uint8_t rBusy; ///< current read busy index
|
||||
uint8_t wBusy; ///< current write busy index
|
||||
} PINGPONG;
|
||||
|
||||
/**
|
||||
* @struct SYSMONITOR
|
||||
* @brief System Monitor struct holds all the system log info
|
||||
*/
|
||||
typedef struct
|
||||
{
|
||||
SYSMON_CONFIG config; ///< system monitor initialization parameters
|
||||
CIRC_QUEUE *sendQueue; ///< send queue
|
||||
CIRC_QUEUE *recvQueue; ///< receive queue
|
||||
PINGPONG sysInfoCtrl;
|
||||
SYSINFO sysInfo[2];
|
||||
PINGPONG linkLogCtrl;
|
||||
LINKLOG linkLog[2];
|
||||
PINGPONG phyLogCtrl;
|
||||
PHYLOG phyLog[2];
|
||||
PINGPONG hwStateCtrl;
|
||||
HWSTATE hwState[2];
|
||||
} SYSMONITOR;
|
||||
|
||||
/************************** Function Prototypes ******************************/
|
||||
static uint8_t GetWritable(PINGPONG ctrllor);
|
||||
static uint8_t GetReadable(PINGPONG ctrllor);
|
||||
/************************** Variable Definitions *****************************/
|
||||
static SYSMONITOR *sysMonitorInst;
|
||||
extern SYSBUS *sysbusDescPtr;
|
||||
|
||||
/*********************** Function Implementations ***************************/
|
||||
inline static uint8_t GetWritable(PINGPONG ctrllor)
|
||||
{
|
||||
// Allow only one write.
|
||||
ASSERT(ctrllor.wBusy == BUFF_NONE);
|
||||
if (ctrllor.rBusy == BUFF_NONE)
|
||||
return ((ctrllor.latest == BUFF_B) ? BUFF_A : BUFF_B);
|
||||
else
|
||||
return ((ctrllor.rBusy == BUFF_B) ? BUFF_A : BUFF_B);
|
||||
}
|
||||
|
||||
inline static uint8_t GetReadable(PINGPONG ctrllor)
|
||||
{
|
||||
if (ctrllor.wBusy == BUFF_NONE || ctrllor.wBusy != ctrllor.latest)
|
||||
return ((ctrllor.latest == BUFF_NONE) ? BUFF_A : BUFF_B);
|
||||
else
|
||||
return ((ctrllor.wBusy == BUFF_B) ? BUFF_A : BUFF_B);
|
||||
}
|
||||
|
||||
/**
|
||||
* @brief Initialize System monitor
|
||||
*
|
||||
* @return SUCCESS
|
||||
*/
|
||||
int32_t SysMonitor_Init(SYSMON_CONFIG *config)
|
||||
{
|
||||
ASSERT(config != NULL);
|
||||
|
||||
sysMonitorInst = calloc(1, sizeof(SYSMONITOR));
|
||||
if (sysMonitorInst == NULL)
|
||||
{
|
||||
return ENOMEM;
|
||||
}
|
||||
|
||||
memcpy(&(sysMonitorInst->config), config, sizeof(SYSMON_CONFIG));
|
||||
sysMonitorInst->sendQueue = NULL;
|
||||
sysMonitorInst->recvQueue = NULL;
|
||||
memset(&(sysMonitorInst->sysInfoCtrl), BUFF_NONE, sizeof(PINGPONG));
|
||||
memset(&(sysMonitorInst->linkLogCtrl), BUFF_NONE, sizeof(PINGPONG));
|
||||
memset(&(sysMonitorInst->phyLogCtrl), BUFF_NONE, sizeof(PINGPONG));
|
||||
memset(&(sysMonitorInst->hwStateCtrl), BUFF_NONE, sizeof(PINGPONG));
|
||||
|
||||
if (CircQueueCreate(&(sysMonitorInst->sendQueue),
|
||||
sysMonitorInst->config.sendQueueMax) == false)
|
||||
{
|
||||
SysMonitor_Destroy();
|
||||
return ENOMEM;
|
||||
}
|
||||
if (CircQueueCreate(&(sysMonitorInst->recvQueue),
|
||||
sysMonitorInst->config.recvQueueMax) == false)
|
||||
{
|
||||
SysMonitor_Destroy();
|
||||
return ENOMEM;
|
||||
}
|
||||
|
||||
return SUCCESS;
|
||||
}
|
||||
|
||||
/**
|
||||
* @brief Destroy system monitor release all allocated memory
|
||||
*/
|
||||
void SysMonitor_Destroy(void)
|
||||
{
|
||||
free(sysMonitorInst);
|
||||
}
|
||||
|
||||
/**
|
||||
* @name SystemInfo_API
|
||||
* @{
|
||||
*/
|
||||
|
||||
/**
|
||||
* @brief Update system info.
|
||||
*
|
||||
* @param info
|
||||
*/
|
||||
void SysMonitor_UpdateSysinfo(const SYSINFO *info)
|
||||
{
|
||||
ASSERT(info != NULL);
|
||||
uint8_t buffIndx;
|
||||
buffIndx = GetWritable(sysMonitorInst->sysInfoCtrl);
|
||||
sysMonitorInst->sysInfoCtrl.wBusy = buffIndx;
|
||||
memcpy(&(sysMonitorInst->sysInfo[buffIndx]), info, sizeof(SYSINFO));
|
||||
sysMonitorInst->sysInfoCtrl.latest = buffIndx;
|
||||
sysMonitorInst->sysInfoCtrl.wBusy = BUFF_NONE;
|
||||
}
|
||||
|
||||
/**
|
||||
* @brief Get system info.
|
||||
*
|
||||
* @param info
|
||||
*/
|
||||
void SysMonitor_GetSysinfo(SYSINFO *info)
|
||||
{
|
||||
ASSERT(sysMonitorInst != NULL);
|
||||
ASSERT(info != NULL);
|
||||
uint8_t buffIndx, buffIndex_old;
|
||||
buffIndex_old = sysMonitorInst->sysInfoCtrl.rBusy;
|
||||
if (buffIndex_old != BUFF_NONE)
|
||||
buffIndx = buffIndex_old; // Keep it busy
|
||||
else
|
||||
buffIndx = GetReadable(sysMonitorInst->sysInfoCtrl);
|
||||
sysMonitorInst->sysInfoCtrl.rBusy = buffIndx;
|
||||
memcpy(info, &(sysMonitorInst->sysInfo[buffIndx]), sizeof(SYSINFO));
|
||||
sysMonitorInst->sysInfoCtrl.rBusy = buffIndex_old;
|
||||
}
|
||||
/** @} SystemInfo_API*/
|
||||
|
||||
/**
|
||||
* @name ServicePayload_API
|
||||
* @{
|
||||
*/
|
||||
|
||||
/**
|
||||
* @brief Update send payload by
|
||||
*
|
||||
* @param payload
|
||||
*/
|
||||
int32_t SysMonitor_UpdateSendPayload(SYSMON_SVC_PAYLOAD *payload)
|
||||
{
|
||||
ASSERT(sysMonitorInst != NULL);
|
||||
ASSERT(payload != NULL);
|
||||
|
||||
// validity check
|
||||
if (payload->dataLen > PAYLOAD_LEN_MAX)
|
||||
{
|
||||
DBG_ERROR("Payload length %d exceeds valid range.", payload->dataLen);
|
||||
return EPARAM;
|
||||
}
|
||||
|
||||
// push message into send queue
|
||||
SYSMON_SVC_PAYLOAD *payloadCopy = malloc(sizeof(SYSMON_SVC_PAYLOAD));
|
||||
if (payloadCopy == NULL)
|
||||
{
|
||||
DBG_ERROR("Allocate memory for send payload failed.\n");
|
||||
return ENOMEM;
|
||||
}
|
||||
memcpy(payloadCopy, payload, sizeof(SYSMON_SVC_PAYLOAD));
|
||||
if (CircQueuePush(sysMonitorInst->sendQueue, (void *)payloadCopy) == false)
|
||||
{
|
||||
DBG_WARNING("SystemMonitor::SEND Queue overflowed!\n");
|
||||
free(payloadCopy);
|
||||
return EQUEUE;
|
||||
}
|
||||
|
||||
return SUCCESS;
|
||||
}
|
||||
|
||||
/**
|
||||
* @brief Get the latest send payload.
|
||||
*
|
||||
* @param payload
|
||||
*/
|
||||
void SysMonitor_GetSendPayload(SYSMON_SVC_PAYLOAD **payload)
|
||||
{
|
||||
ASSERT(sysMonitorInst != NULL);
|
||||
ASSERT(payload != NULL);
|
||||
|
||||
if (CircQueuePop(sysMonitorInst->sendQueue, (void **)payload) == false)
|
||||
{
|
||||
*payload = NULL;
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* @brief Update receive payload.
|
||||
*
|
||||
* @param payload
|
||||
*/
|
||||
int32_t SysMonitor_GenRecvRsp(SYSMON_SVC_PAYLOAD *payload)
|
||||
{
|
||||
ASSERT(sysMonitorInst != NULL);
|
||||
ASSERT(sysbusDescPtr != NULL);
|
||||
int32_t Status;
|
||||
|
||||
if (payload->dataId == DATA_ID_NONE || payload->dataLen > PAYLOAD_LEN_MAX)
|
||||
{
|
||||
return EIGNORE;
|
||||
}
|
||||
|
||||
Status = SystemBus_GenRecvRsp(sysbusDescPtr, payload);
|
||||
|
||||
return Status;
|
||||
}
|
||||
/** @} ServicePayload_API*/
|
||||
|
||||
/**
|
||||
* @name Linklayer_Log_API
|
||||
* @{
|
||||
*/
|
||||
|
||||
/**
|
||||
* @brief Update link layer log
|
||||
*
|
||||
* @param log
|
||||
*/
|
||||
void SysMonitor_UpdateLinklayerLog(const LINKLOG *log)
|
||||
{
|
||||
ASSERT(sysMonitorInst != NULL);
|
||||
ASSERT(log != NULL);
|
||||
uint8_t buffIndx;
|
||||
buffIndx = GetWritable(sysMonitorInst->linkLogCtrl);
|
||||
sysMonitorInst->linkLogCtrl.wBusy = buffIndx;
|
||||
memcpy(&(sysMonitorInst->linkLog[buffIndx]), log, sizeof(LINKLOG));
|
||||
sysMonitorInst->linkLogCtrl.latest = buffIndx;
|
||||
sysMonitorInst->linkLogCtrl.wBusy = BUFF_NONE;
|
||||
}
|
||||
|
||||
/**
|
||||
* @brief Get the latest link layer log
|
||||
*
|
||||
* @param log
|
||||
*/
|
||||
void SysMonitor_GetLinklayerLog(LINKLOG *log)
|
||||
{
|
||||
ASSERT(sysMonitorInst != NULL);
|
||||
ASSERT(log != NULL);
|
||||
uint8_t buffIndx, buffIndex_old;
|
||||
buffIndex_old = sysMonitorInst->linkLogCtrl.rBusy;
|
||||
if (buffIndex_old != BUFF_NONE)
|
||||
buffIndx = buffIndex_old; // Keep it busy
|
||||
else
|
||||
buffIndx = GetReadable(sysMonitorInst->linkLogCtrl);
|
||||
sysMonitorInst->linkLogCtrl.rBusy = buffIndx;
|
||||
memcpy(log, &(sysMonitorInst->linkLog[buffIndx]), sizeof(LINKLOG));
|
||||
sysMonitorInst->linkLogCtrl.rBusy = buffIndex_old;
|
||||
}
|
||||
/** @} Linklayer_Log_API*/
|
||||
|
||||
/**
|
||||
* @name PhysicalLayer_Log_API
|
||||
* @{
|
||||
*/
|
||||
|
||||
/**
|
||||
* @brief Update physical layer log
|
||||
*
|
||||
* @param log
|
||||
*/
|
||||
void SysMonitor_UpdatePhysicalLayerLog(const PHYLOG *log)
|
||||
{
|
||||
ASSERT(sysMonitorInst != NULL);
|
||||
ASSERT(log != NULL);
|
||||
uint8_t buffIndx;
|
||||
buffIndx = GetWritable(sysMonitorInst->phyLogCtrl);
|
||||
sysMonitorInst->phyLogCtrl.wBusy = buffIndx;
|
||||
memcpy(&(sysMonitorInst->phyLog[buffIndx]), log, sizeof(PHYLOG));
|
||||
sysMonitorInst->phyLogCtrl.latest = buffIndx;
|
||||
sysMonitorInst->phyLogCtrl.wBusy = BUFF_NONE;
|
||||
}
|
||||
|
||||
/**
|
||||
* @brief Get the latest physical layer log
|
||||
*
|
||||
* @param log
|
||||
*/
|
||||
void SysMonitor_GetPhysicalLayerLog(PHYLOG *log)
|
||||
{
|
||||
ASSERT(sysMonitorInst != NULL);
|
||||
ASSERT(log != NULL);
|
||||
uint8_t buffIndx, buffIndex_old;
|
||||
buffIndex_old = sysMonitorInst->phyLogCtrl.rBusy;
|
||||
if (buffIndex_old != BUFF_NONE)
|
||||
buffIndx = buffIndex_old; // Keep it busy
|
||||
else
|
||||
buffIndx = GetReadable(sysMonitorInst->phyLogCtrl);
|
||||
sysMonitorInst->phyLogCtrl.rBusy = buffIndx;
|
||||
memcpy(log, &(sysMonitorInst->phyLog[buffIndx]), sizeof(PHYLOG));
|
||||
sysMonitorInst->phyLogCtrl.rBusy = buffIndex_old;
|
||||
}
|
||||
/** @} */
|
||||
|
||||
/**
|
||||
* @name HardwareState_Log_API
|
||||
* @{
|
||||
*/
|
||||
|
||||
/**
|
||||
* @brief Log hardware running status.
|
||||
*
|
||||
* @param state
|
||||
*/
|
||||
void SysMonitor_UpdateHardwareStatus(const HWSTATE *state)
|
||||
{
|
||||
ASSERT(sysMonitorInst != NULL);
|
||||
ASSERT(state != NULL);
|
||||
uint8_t buffIndx;
|
||||
buffIndx = GetWritable(sysMonitorInst->hwStateCtrl);
|
||||
sysMonitorInst->hwStateCtrl.wBusy = buffIndx;
|
||||
memcpy(&(sysMonitorInst->hwState[buffIndx]), state, sizeof(HWSTATE));
|
||||
sysMonitorInst->hwStateCtrl.latest = buffIndx;
|
||||
sysMonitorInst->hwStateCtrl.wBusy = BUFF_NONE;
|
||||
}
|
||||
|
||||
/**
|
||||
* @brief Get the latest hardware running status.
|
||||
*
|
||||
* @param state
|
||||
*/
|
||||
void SysMonitor_GetHardwareStatus(HWSTATE *state)
|
||||
{
|
||||
ASSERT(sysMonitorInst != NULL);
|
||||
ASSERT(state != NULL);
|
||||
uint8_t buffIndx, buffIndex_old;
|
||||
buffIndex_old = sysMonitorInst->hwStateCtrl.rBusy;
|
||||
if (buffIndex_old != BUFF_NONE)
|
||||
buffIndx = buffIndex_old; // Keep it busy
|
||||
else
|
||||
buffIndx = GetReadable(sysMonitorInst->hwStateCtrl);
|
||||
sysMonitorInst->hwStateCtrl.rBusy = buffIndx;
|
||||
memcpy(state, &(sysMonitorInst->hwState[buffIndx]), sizeof(HWSTATE));
|
||||
sysMonitorInst->hwStateCtrl.rBusy = buffIndex_old;
|
||||
}
|
||||
|
||||
/** @} HardwareState_Log_API */
|
||||
|
||||
/** @} SystemMonitor*/
|
||||
@@ -1,258 +0,0 @@
|
||||
/**
|
||||
* @defgroup SystemMonitor
|
||||
* @{
|
||||
*/
|
||||
|
||||
#ifndef __SYSTEM_MONITOR_H_
|
||||
#define __SYSTEM_MONITOR_H_
|
||||
|
||||
/***************************** Include Files *********************************/
|
||||
#include <stdint.h>
|
||||
#include <stdbool.h>
|
||||
#include "util.h"
|
||||
|
||||
/************************* Constant Definitions ******************************/
|
||||
/**
|
||||
* @name SystemMonitor_Constants
|
||||
* @{
|
||||
*/
|
||||
#define PAYLOAD_LEN_MAX 1000
|
||||
|
||||
#define DATA_ID_NONE UINT32_MAX
|
||||
#define DATA_ID_TEST 0x02030203
|
||||
|
||||
#define VOLTAGE_LSB 0.01 // volt
|
||||
#define VOLTAGE_MAX 2.55 // volt
|
||||
|
||||
#define VOLT_PS_STD 1.0
|
||||
#define VOLT_PSAUX_STD 1.8
|
||||
#define VOLT_DDR_STD 1.5
|
||||
#define VOLT_PL_STD 1.0
|
||||
#define VOLT_PLAUX_STD 1.8
|
||||
#define VOLT_BRAM_STD 1.0
|
||||
|
||||
#define VOLT_PS_OK BIT(0)
|
||||
#define VOLT_PSAUX_OK BIT(1)
|
||||
#define VOLT_DDR_OK BIT(2)
|
||||
#define VOLT_PL_OK BIT(3)
|
||||
#define VOLT_PLAUX_OK BIT(4)
|
||||
#define VOLT_BRAM_OK BIT(5)
|
||||
|
||||
#define VOLT_ANT_PROC_OK BIT(0)
|
||||
#define VOLT_ANT_RF_OK BIT(2)
|
||||
#define VOLT_ANT_NIL_OK BIT(4)
|
||||
#define ANT_STATE_OK BIT(6)
|
||||
|
||||
// Xilinx Recommended
|
||||
// #define IS_PS_VALID(x) (x <= 1.05 && x >= 0.95)
|
||||
// #define IS_PSAUX_VALID(x) (x <= 1.89 && x >= 1.71)
|
||||
// #define IS_DDR_VALID(x) (x <= 1.89 && x >= 1.14)
|
||||
// #define IS_PL_VALID(x) (x <= 1.03 && x >= 0.97)
|
||||
// #define IS_PLAUX_VALID(x) (x <= 1.89 && x >= 1.71)
|
||||
// #define IS_BRAM_VALID(x) (x <= 1.03 && x >= 0.97)
|
||||
#define IS_PS_VALID(x) ((x) <= 1.1 && (x) >= 0.9)
|
||||
#define IS_PSAUX_VALID(x) ((x) <= 2.0 && (x) >= 1.6)
|
||||
#define IS_DDR_VALID(x) ((x) <= 1.7 && (x) >= 1.3)
|
||||
#define IS_PL_VALID(x) (x <= 1.1 && (x) >= 0.9)
|
||||
#define IS_PLAUX_VALID(x) ((x) <= 2.0 && (x) >= 1.6)
|
||||
#define IS_BRAM_VALID(x) ((x) <= 1.1 && (x) >= 0.9)
|
||||
|
||||
#define CLK_SP_PLL1_LOCK BIT(0)
|
||||
#define CLK_SP_PLL2_LOCK BIT(2)
|
||||
|
||||
#define CLK_AD0_BBPLL_LOCK BIT(0)
|
||||
#define CLK_AD0_RFPLL_LOCK BIT(2)
|
||||
#define CLK_AD1_BBPLL_LOCK BIT(4)
|
||||
#define CLK_AD1_RFPLL_LOCK BIT(6)
|
||||
|
||||
#define CLK_ANT_BBPLL_LOCK BIT(0)
|
||||
#define CLK_ANT_RFPLL1_LOCK BIT(2)
|
||||
#define CLK_ANT_RFPLL2_LOCK BIT(4)
|
||||
|
||||
#define TEMPERATURE_LSB 1.0 // Celsius degree
|
||||
#define TEMPERATURE_MAX 127.0 // Celsius degree
|
||||
#define TEMPERATURE_MIN -128.0 // Celsius degree
|
||||
/** @} SystemMonitor_Constants */
|
||||
|
||||
/************************* Data Type Definitions ****************************/
|
||||
|
||||
/**
|
||||
* @struct SYSINFO
|
||||
* @brief System Infomation log
|
||||
*/
|
||||
typedef struct __attribute__((packed))
|
||||
{
|
||||
uint32_t psBDS; ///< -- unit: ms, 0~604799999
|
||||
uint16_t pBDS; ///< -- unit: week, 0~0~8191
|
||||
uint32_t psGPS; ///< -- unit: ms, 0~604799999
|
||||
uint16_t pGPS; ///< -- unit: week, 0~0~8191
|
||||
uint8_t tmInd; ///< Time validation indicator \n
|
||||
// -- [0] GPS\n
|
||||
// -- [1] reserve.\n
|
||||
// -- [2] UTC\n
|
||||
// -- [3] BDS\n
|
||||
float tmFly; ///< Time of flying uint: s
|
||||
uint8_t stFly; ///< Status of flying \n
|
||||
// [7:6] departure status 11 - departed/00 - not departed \n
|
||||
// [5:4] ready status 11 - ready/00 - not ready \n
|
||||
// [3:2] attitude status 11 - attitude ok/00 - attitude not ok \n
|
||||
// [1:0] attitude adjust status 11 - adjusted/00 - not adjusted
|
||||
float posX; ///< coord X Position in launch coordinate system
|
||||
float posY; ///< coord Y Position in launch coordinate system
|
||||
float posZ; ///< coord Z Position in launch coordinate system
|
||||
float vX; ///< Speed X in launch coordinate system
|
||||
float vY; ///< Speed Y in launch coordinate system
|
||||
float vZ; ///< Speed Z in launch coordinate system
|
||||
float pitch; ///< Pitch Attitude in launch inertia coordinate system
|
||||
float yaw; ///< Yaw Attitude in launch inertia coordinate system
|
||||
float roll; ///< Roll Attitude in launch inertia coordinate system
|
||||
} SYSINFO;
|
||||
|
||||
/**
|
||||
* @struct SYSBUSLOG
|
||||
* @brief System Info holds the system bus log
|
||||
*/
|
||||
typedef struct __attribute__((packed))
|
||||
{
|
||||
// SystemBus log
|
||||
|
||||
uint8_t lastConfig[4]; ///< Last valid config \n
|
||||
// byte 0: Enable control, 0xAA - enable, 0x55 - disable \n
|
||||
// byte 1: Node ID \n
|
||||
// byte 2: Service rate \n
|
||||
// byte 3: routing table number
|
||||
uint32_t recvCnt; ///< number of received data packet
|
||||
uint32_t sendCnt; ///< number of send data packet
|
||||
uint32_t remoteCnt; ///< number of remote check commands
|
||||
} SYSBUSLOG;
|
||||
|
||||
/**
|
||||
* @struct LINKLOG
|
||||
* @brief Linklayer Log struct holds the Linklayer log
|
||||
*/
|
||||
typedef struct __attribute__((packed))
|
||||
{
|
||||
// Network log
|
||||
uint32_t tuNum; ///< current time unite number
|
||||
uint8_t slotNum; ///< current slot number
|
||||
uint8_t nodeType; ///< current node type
|
||||
uint8_t cxnStatus; ///< current connection status
|
||||
uint8_t linkStage; ///< current linklayer working stage
|
||||
uint32_t recxnCnt; ///< reconnect trial count
|
||||
uint8_t antIndex; ///< current working antenna index
|
||||
uint32_t advTxCnt; ///< adv frame send count
|
||||
uint32_t advRecvCnt; ///< adv frame received count
|
||||
uint32_t advCorrectCnt; ///< adv frame received correctly count
|
||||
uint32_t ackTxCnt; ///< ack frame send count
|
||||
uint32_t ackRecvCnt; ///< ack frame received count
|
||||
uint32_t ackCorrectCnt; ///< ack frame received correctly count
|
||||
uint32_t disTxCnt; ///< dist frame send count
|
||||
uint32_t disRecvCnt; ///< dist frame received count
|
||||
uint32_t disCorrectCnt;///< dist frame received correctly count
|
||||
uint32_t mngTxCnt; ///< mng frame send count
|
||||
uint32_t mngRecvCnt; ///< mng frame received count
|
||||
uint32_t mngCorrectCnt; ///< mng frame received correctly count
|
||||
uint32_t rttTxCnt; ///< rtt frame send count
|
||||
uint32_t rttRecvCnt; ///< rtt frame received count
|
||||
uint32_t rttCorrectCnt; ///< rtt frame received correctly count
|
||||
uint32_t svcTxCnt; ///< svc frame send count
|
||||
uint32_t svcRecvCnt; ///< svc frame received count
|
||||
uint32_t svcCorrectCnt; ///< svc frame received correctly count
|
||||
int32_t timeDev; ///< last time deviation result
|
||||
uint32_t sendId; ///< last send data id
|
||||
uint32_t recvId; ///< last received data id
|
||||
uint8_t reserve[3]; ///< reserved data
|
||||
} LINKLOG;
|
||||
|
||||
/**
|
||||
* @struct PHYLOG
|
||||
* @brief Physical Layer Log struct holds the Linklayer log
|
||||
*/
|
||||
typedef struct __attribute__((packed))
|
||||
{
|
||||
uint32_t acqCnt; ///< acquisition count
|
||||
uint32_t fsyncCnt; ///< frame sync count
|
||||
uint32_t decodeCnt; ///< decode count
|
||||
uint32_t crcCnt; ///< crc valid count
|
||||
double doppler; ///< last doppler estimation result
|
||||
uint64_t recvStamp; ///< last frame arrival time
|
||||
double acqPAPR; ///< last acquisition peak-average ration
|
||||
uint8_t acqPhase; ///< last acquisition phase estimation
|
||||
uint8_t acqFreqCh; ///< last acquisition frequency deviation estimation
|
||||
double fsyncPAPR; ///< last frame sync peak-average ration
|
||||
uint8_t fsyncFreqCh; ///< last frame sync frequency estimation
|
||||
uint16_t deintlvAmpEst; ///< de-interleave amplitude estimation
|
||||
uint8_t antControl; ///< current antenna rf mode
|
||||
uint8_t reserve[2]; ///< reserved data
|
||||
} PHYLOG;
|
||||
|
||||
/**
|
||||
* @struct HWSTATE
|
||||
* @brief Hardware Status Log struct holds all hardware status
|
||||
*/
|
||||
typedef struct __attribute__((packed))
|
||||
{
|
||||
bool isSpOk; ///< signal processor state
|
||||
bool isAntOk; ///< antenna state
|
||||
// -- Signal processor status
|
||||
uint8_t spFpgaVolt; ///< Signal processor voltage state indicator
|
||||
uint8_t spClkState; ///< Signal processor clock state indicator
|
||||
uint8_t spAdLockState; ///< Signal processor adc lock state indicator
|
||||
int8_t spAdTemp_0; ///< Signal processor adc0 temperature
|
||||
int8_t spAdTemp_1; ///< Signal processor adc1 temperature
|
||||
int8_t spFpgaTemp; ///< Signal processor FPGA temperature
|
||||
// -- Antenna status
|
||||
uint16_t ant1Freq; ///< Antenna 1 frequency
|
||||
uint16_t ant2Freq; ///< Antenna 2 frequency
|
||||
uint16_t ant3Freq; ///< Antenna 3 frequency
|
||||
uint8_t antPll; ///< Antenna pll lock state indicator
|
||||
uint8_t antMode; ///< Antenna mode indicator
|
||||
int8_t antTemp; ///< Antenna rf temperature
|
||||
uint8_t antRsvd; ///< Antenna reserved status register
|
||||
uint8_t phyId;
|
||||
uint8_t reserve[3];
|
||||
} HWSTATE;
|
||||
|
||||
/**
|
||||
* @struct SYSMON_CONFIG
|
||||
* @brief System monitor config struct holds system monitor initialization parameters
|
||||
*/
|
||||
typedef struct
|
||||
{
|
||||
uint32_t sendQueueMax; ///< maximum send queue length
|
||||
uint32_t recvQueueMax; ///< maximum receive queue length
|
||||
} SYSMON_CONFIG;
|
||||
|
||||
/**
|
||||
* @struct SYSMON_SVC_PAYLOAD
|
||||
* @brief Payload struct that holds the service payload
|
||||
*/
|
||||
typedef struct
|
||||
{
|
||||
uint32_t dataId; ///< data identifier
|
||||
uint8_t nodeId; ///< destination ID for tx, source ID for rx
|
||||
uint16_t dataLen; ///< data length
|
||||
uint8_t data[1000];
|
||||
} SYSMON_SVC_PAYLOAD;
|
||||
|
||||
/************************** Function Prototypes ******************************/
|
||||
int32_t SysMonitor_Init(SYSMON_CONFIG *config);
|
||||
void SysMonitor_Destroy(void);
|
||||
|
||||
void SysMonitor_UpdateSysinfo(const SYSINFO *info);
|
||||
void SysMonitor_GetSysinfo(SYSINFO *info);
|
||||
|
||||
int32_t SysMonitor_UpdateSendPayload(SYSMON_SVC_PAYLOAD *payload);
|
||||
void SysMonitor_GetSendPayload(SYSMON_SVC_PAYLOAD **payload);
|
||||
int32_t SysMonitor_GenRecvRsp(SYSMON_SVC_PAYLOAD *payload);
|
||||
|
||||
void SysMonitor_UpdateLinklayerLog(const LINKLOG *log);
|
||||
void SysMonitor_UpdatePhysicalLayerLog(const PHYLOG *log);
|
||||
void SysMonitor_UpdateHardwareStatus(const HWSTATE *state);
|
||||
void SysMonitor_GetLinklayerLog(LINKLOG *log);
|
||||
void SysMonitor_GetPhysicalLayerLog(PHYLOG *log);
|
||||
void SysMonitor_GetHardwareStatus(HWSTATE *state);
|
||||
|
||||
#endif //__SYSTEM_MONITOR_H_
|
||||
|
||||
/** @} */
|
||||
+364
-5
@@ -27,7 +27,6 @@
|
||||
#include "common.h"
|
||||
#include "error.h"
|
||||
#include "circ_queue.h"
|
||||
#include "../system_monitor.h"
|
||||
|
||||
/**
|
||||
* @addtogroup SystemBus_Protocol_Routine
|
||||
@@ -148,7 +147,48 @@
|
||||
// My Production Type
|
||||
#define MY_PRD_ID PRD_DL_C
|
||||
/** @} SystemBus_MSG_Constants*/
|
||||
#define BUFF_A 0x00
|
||||
#define BUFF_B 0x01
|
||||
#define BUFF_NONE 0xFF
|
||||
|
||||
#define SYSINFO_PACK_LEN 54 // bytes
|
||||
#define PAYLOAD_PACK_LEN 46 // bytes
|
||||
#define SLOTLOG_PACK_LEN 88 // bytes
|
||||
#define PRTCLLOG_PACK_ELN 24 // bytes
|
||||
#define HWSTATE_PACK_ELN 12 // bytes
|
||||
/************************** Data Type Definitions ****************************/
|
||||
/**
|
||||
* @struct PINGPONG
|
||||
* @brief PingPing Control
|
||||
*/
|
||||
typedef struct
|
||||
{
|
||||
uint8_t latest; ///< latest available index
|
||||
uint8_t rBusy; ///< current read busy index
|
||||
uint8_t wBusy; ///< current write busy index
|
||||
} PINGPONG;
|
||||
|
||||
/**
|
||||
* @struct SYSMONITOR
|
||||
* @brief System Monitor struct holds all the system log info
|
||||
*/
|
||||
typedef struct
|
||||
{
|
||||
SYSMON_CONFIG config; ///< system monitor initialization parameters
|
||||
CIRC_QUEUE *sendQueue; ///< send queue
|
||||
CIRC_QUEUE *recvQueue; ///< receive queue
|
||||
PINGPONG sysInfoCtrl;
|
||||
SYSINFO sysInfo[2];
|
||||
PINGPONG linkLogCtrl;
|
||||
LINKLOG linkLog[2];
|
||||
PINGPONG phyLogCtrl;
|
||||
PHYLOG phyLog[2];
|
||||
PINGPONG hwStateCtrl;
|
||||
HWSTATE hwState[2];
|
||||
} SYSMONITOR;
|
||||
/************************** Function Prototypes ******************************/
|
||||
static uint8_t GetWritable(PINGPONG ctrllor);
|
||||
static uint8_t GetReadable(PINGPONG ctrllor);
|
||||
static int32_t SystemBus_GenSelfTestRsp(SYSBUS *instPtr);
|
||||
static int32_t SystemBus_SystemConfig(SYSBUS *instPtr, uint8_t *msg);
|
||||
static int32_t SystemBus_Echo(SYSBUS *instPtr, SYSBUS_UART_FRAME *frame);
|
||||
@@ -160,6 +200,26 @@ static int32_t SystemBus_GenRemoteTestRsp(SYSBUS *instPtr, uint8_t *msg);
|
||||
#include "../networking/phy_layer/phy_layer.h"
|
||||
extern L2_INST *linkInstPtr;
|
||||
extern L2_CONFIG linkConfig;
|
||||
extern SYSBUS *sysbusDescPtr;
|
||||
static SYSMONITOR *sysMonitorInst;
|
||||
|
||||
inline static uint8_t GetWritable(PINGPONG ctrllor)
|
||||
{
|
||||
// Allow only one write.
|
||||
ASSERT(ctrllor.wBusy == BUFF_NONE);
|
||||
if (ctrllor.rBusy == BUFF_NONE)
|
||||
return ((ctrllor.latest == BUFF_B) ? BUFF_A : BUFF_B);
|
||||
else
|
||||
return ((ctrllor.rBusy == BUFF_B) ? BUFF_A : BUFF_B);
|
||||
}
|
||||
|
||||
inline static uint8_t GetReadable(PINGPONG ctrllor)
|
||||
{
|
||||
if (ctrllor.wBusy == BUFF_NONE || ctrllor.wBusy != ctrllor.latest)
|
||||
return ((ctrllor.latest == BUFF_NONE) ? BUFF_A : BUFF_B);
|
||||
else
|
||||
return ((ctrllor.wBusy == BUFF_B) ? BUFF_A : BUFF_B);
|
||||
}
|
||||
|
||||
inline bool SystemBus_IsReqPending(SYSBUS *instPtr)
|
||||
{
|
||||
@@ -178,6 +238,7 @@ inline bool SystemBus_IsTxBusy(SYSBUS *instPtr)
|
||||
ASSERT(instPtr != NULL);
|
||||
return (!instPtr->isTxDone);
|
||||
}
|
||||
|
||||
inline bool SystemBus_IsRxBusy(SYSBUS *instPtr)
|
||||
{
|
||||
ASSERT(instPtr != NULL);
|
||||
@@ -394,12 +455,12 @@ static int32_t SystemBus_Echo(SYSBUS *instPtr, SYSBUS_UART_FRAME *frame)
|
||||
/**
|
||||
* @brief Generate System Bus receive call command response
|
||||
*/
|
||||
int32_t SystemBus_GenRecvRsp(SYSBUS *instPtr, SYSMON_SVC_PAYLOAD *payload)
|
||||
int32_t SystemBus_GenRecvRsp(SYSBUS *instPtr, SYSBUS_SVC_PLD *payload)
|
||||
{
|
||||
ASSERT(instPtr != NULL);
|
||||
ASSERT(payload != NULL);
|
||||
|
||||
SYSBUS_UART_FRAME *sysbusRsp = malloc(NORMALIZE_SIZE(sizeof(SYSBUS_UART_FRAME)));
|
||||
SYSBUS_UART_FRAME *sysbusRsp = malloc(sizeof(SYSBUS_UART_FRAME));
|
||||
if (sysbusRsp == NULL)
|
||||
{
|
||||
DBG_ERROR("Failed to allocate memory for Receive Response!\n");
|
||||
@@ -410,7 +471,7 @@ int32_t SystemBus_GenRecvRsp(SYSBUS *instPtr, SYSMON_SVC_PAYLOAD *payload)
|
||||
|
||||
sysbusRsp->data[WD_CMD] = CMD_RECV_DATA;
|
||||
sysbusRsp->data[WD_PRD] = MY_PRD_ID;
|
||||
memcpy(sysbusRsp->data + RECV_DATA_ID_OFFSET, payload, sizeof(SYSMON_SVC_PAYLOAD));
|
||||
memcpy(sysbusRsp->data + RECV_DATA_ID_OFFSET, payload, sizeof(SYSBUS_SVC_PLD));
|
||||
|
||||
if (CircQueuePush(instPtr->txQueue, (void *)sysbusRsp) == false)
|
||||
{
|
||||
@@ -527,7 +588,7 @@ int32_t SystemBus_HandleCmd(SYSBUS *instPtr)
|
||||
}
|
||||
case CMD_SEND_DATA:
|
||||
{
|
||||
Status = SysMonitor_UpdateSendPayload((SYSMON_SVC_PAYLOAD *)(msg + SEND_DATA_ID_OFFSET));
|
||||
Status = SysMonitor_UpdateSendPayload((SYSBUS_SVC_PLD *)(msg + SEND_DATA_ID_OFFSET));
|
||||
if (Status == SUCCESS)
|
||||
{
|
||||
instPtr->sysbusLog.sendCnt++;
|
||||
@@ -703,4 +764,302 @@ int32_t SystemBus_RxIntrHandler(SYSBUS *instPtr)
|
||||
return SUCCESS;
|
||||
}
|
||||
|
||||
/**
|
||||
* @brief Initialize System monitor
|
||||
*
|
||||
* @return SUCCESS
|
||||
*/
|
||||
int32_t SysMonitor_Init(SYSMON_CONFIG *config)
|
||||
{
|
||||
ASSERT(config != NULL);
|
||||
|
||||
sysMonitorInst = calloc(1, sizeof(SYSMONITOR));
|
||||
if (sysMonitorInst == NULL)
|
||||
{
|
||||
return ENOMEM;
|
||||
}
|
||||
|
||||
memcpy(&(sysMonitorInst->config), config, sizeof(SYSMON_CONFIG));
|
||||
sysMonitorInst->sendQueue = NULL;
|
||||
sysMonitorInst->recvQueue = NULL;
|
||||
memset(&(sysMonitorInst->sysInfoCtrl), BUFF_NONE, sizeof(PINGPONG));
|
||||
memset(&(sysMonitorInst->linkLogCtrl), BUFF_NONE, sizeof(PINGPONG));
|
||||
memset(&(sysMonitorInst->phyLogCtrl), BUFF_NONE, sizeof(PINGPONG));
|
||||
memset(&(sysMonitorInst->hwStateCtrl), BUFF_NONE, sizeof(PINGPONG));
|
||||
|
||||
if (CircQueueCreate(&(sysMonitorInst->sendQueue),
|
||||
sysMonitorInst->config.sendQueueMax) == false)
|
||||
{
|
||||
SysMonitor_Destroy();
|
||||
return ENOMEM;
|
||||
}
|
||||
if (CircQueueCreate(&(sysMonitorInst->recvQueue),
|
||||
sysMonitorInst->config.recvQueueMax) == false)
|
||||
{
|
||||
SysMonitor_Destroy();
|
||||
return ENOMEM;
|
||||
}
|
||||
|
||||
return SUCCESS;
|
||||
}
|
||||
|
||||
/**
|
||||
* @brief Destroy system monitor release all allocated memory
|
||||
*/
|
||||
void SysMonitor_Destroy(void)
|
||||
{
|
||||
free(sysMonitorInst);
|
||||
}
|
||||
|
||||
/**
|
||||
* @name SystemInfo_API
|
||||
* @{
|
||||
*/
|
||||
|
||||
/**
|
||||
* @brief Update system info.
|
||||
*
|
||||
* @param info
|
||||
*/
|
||||
void SysMonitor_UpdateSysinfo(const SYSINFO *info)
|
||||
{
|
||||
ASSERT(info != NULL);
|
||||
uint8_t buffIndx;
|
||||
buffIndx = GetWritable(sysMonitorInst->sysInfoCtrl);
|
||||
sysMonitorInst->sysInfoCtrl.wBusy = buffIndx;
|
||||
memcpy(&(sysMonitorInst->sysInfo[buffIndx]), info, sizeof(SYSINFO));
|
||||
sysMonitorInst->sysInfoCtrl.latest = buffIndx;
|
||||
sysMonitorInst->sysInfoCtrl.wBusy = BUFF_NONE;
|
||||
}
|
||||
|
||||
/**
|
||||
* @brief Get system info.
|
||||
*
|
||||
* @param info
|
||||
*/
|
||||
void SysMonitor_GetSysinfo(SYSINFO *info)
|
||||
{
|
||||
ASSERT(sysMonitorInst != NULL);
|
||||
ASSERT(info != NULL);
|
||||
uint8_t buffIndx, buffIndex_old;
|
||||
buffIndex_old = sysMonitorInst->sysInfoCtrl.rBusy;
|
||||
if (buffIndex_old != BUFF_NONE)
|
||||
buffIndx = buffIndex_old; // Keep it busy
|
||||
else
|
||||
buffIndx = GetReadable(sysMonitorInst->sysInfoCtrl);
|
||||
sysMonitorInst->sysInfoCtrl.rBusy = buffIndx;
|
||||
memcpy(info, &(sysMonitorInst->sysInfo[buffIndx]), sizeof(SYSINFO));
|
||||
sysMonitorInst->sysInfoCtrl.rBusy = buffIndex_old;
|
||||
}
|
||||
/** @} SystemInfo_API*/
|
||||
|
||||
/**
|
||||
* @name ServicePayload_API
|
||||
* @{
|
||||
*/
|
||||
|
||||
/**
|
||||
* @brief Update send payload by
|
||||
*
|
||||
* @param payload
|
||||
*/
|
||||
int32_t SysMonitor_UpdateSendPayload(SYSBUS_SVC_PLD *payload)
|
||||
{
|
||||
ASSERT(sysMonitorInst != NULL);
|
||||
ASSERT(payload != NULL);
|
||||
|
||||
// validity check
|
||||
if (payload->dataLen > SYSBUS_PLD_MAX)
|
||||
{
|
||||
DBG_ERROR("Payload length %d exceeds valid range.", payload->dataLen);
|
||||
return EPARAM;
|
||||
}
|
||||
|
||||
// push message into send queue
|
||||
SYSBUS_SVC_PLD *payloadCopy = malloc(sizeof(SYSBUS_SVC_PLD));
|
||||
if (payloadCopy == NULL)
|
||||
{
|
||||
DBG_ERROR("Allocate memory for send payload failed.\n");
|
||||
return ENOMEM;
|
||||
}
|
||||
memcpy(payloadCopy, payload, sizeof(SYSBUS_SVC_PLD));
|
||||
if (CircQueuePush(sysMonitorInst->sendQueue, (void *)payloadCopy) == false)
|
||||
{
|
||||
DBG_WARNING("SystemMonitor::SEND Queue overflowed!\n");
|
||||
free(payloadCopy);
|
||||
return EQUEUE;
|
||||
}
|
||||
|
||||
return SUCCESS;
|
||||
}
|
||||
|
||||
/**
|
||||
* @brief Get the latest send payload.
|
||||
*
|
||||
* @param payload
|
||||
*/
|
||||
void SysMonitor_GetSendPayload(SYSBUS_SVC_PLD **payload)
|
||||
{
|
||||
ASSERT(sysMonitorInst != NULL);
|
||||
ASSERT(payload != NULL);
|
||||
|
||||
if (CircQueuePop(sysMonitorInst->sendQueue, (void **)payload) == false)
|
||||
{
|
||||
*payload = NULL;
|
||||
DBG_INFO("SystemMonitor::Empty sendQueue, nothing need sent.\n");
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* @brief Update receive payload.
|
||||
*
|
||||
* @param payload
|
||||
*/
|
||||
int32_t SysMonitor_GenRecvRsp(SYSBUS_SVC_PLD *payload)
|
||||
{
|
||||
ASSERT(sysMonitorInst != NULL);
|
||||
ASSERT(sysbusDescPtr != NULL);
|
||||
int32_t Status;
|
||||
|
||||
if (payload->dataId == DATA_ID_NONE || payload->dataLen > SYSBUS_PLD_MAX)
|
||||
{
|
||||
DBG_INFO("SystemMonitor::Drop invalid message.\n");
|
||||
return EIGNORE;
|
||||
}
|
||||
|
||||
Status = SystemBus_GenRecvRsp(sysbusDescPtr, payload);
|
||||
|
||||
return Status;
|
||||
}
|
||||
/** @} ServicePayload_API*/
|
||||
|
||||
/**
|
||||
* @name Linklayer_Log_API
|
||||
* @{
|
||||
*/
|
||||
|
||||
/**
|
||||
* @brief Update link layer log
|
||||
*
|
||||
* @param log
|
||||
*/
|
||||
void SysMonitor_UpdateLinklayerLog(const LINKLOG *log)
|
||||
{
|
||||
ASSERT(sysMonitorInst != NULL);
|
||||
ASSERT(log != NULL);
|
||||
uint8_t buffIndx;
|
||||
buffIndx = GetWritable(sysMonitorInst->linkLogCtrl);
|
||||
sysMonitorInst->linkLogCtrl.wBusy = buffIndx;
|
||||
memcpy(&(sysMonitorInst->linkLog[buffIndx]), log, sizeof(LINKLOG));
|
||||
sysMonitorInst->linkLogCtrl.latest = buffIndx;
|
||||
sysMonitorInst->linkLogCtrl.wBusy = BUFF_NONE;
|
||||
}
|
||||
|
||||
/**
|
||||
* @brief Get the latest link layer log
|
||||
*
|
||||
* @param log
|
||||
*/
|
||||
void SysMonitor_GetLinklayerLog(LINKLOG *log)
|
||||
{
|
||||
ASSERT(sysMonitorInst != NULL);
|
||||
ASSERT(log != NULL);
|
||||
uint8_t buffIndx, buffIndex_old;
|
||||
buffIndex_old = sysMonitorInst->linkLogCtrl.rBusy;
|
||||
if (buffIndex_old != BUFF_NONE)
|
||||
buffIndx = buffIndex_old; // Keep it busy
|
||||
else
|
||||
buffIndx = GetReadable(sysMonitorInst->linkLogCtrl);
|
||||
sysMonitorInst->linkLogCtrl.rBusy = buffIndx;
|
||||
memcpy(log, &(sysMonitorInst->linkLog[buffIndx]), sizeof(LINKLOG));
|
||||
sysMonitorInst->linkLogCtrl.rBusy = buffIndex_old;
|
||||
}
|
||||
/** @} Linklayer_Log_API*/
|
||||
|
||||
/**
|
||||
* @name PhysicalLayer_Log_API
|
||||
* @{
|
||||
*/
|
||||
|
||||
/**
|
||||
* @brief Update physical layer log
|
||||
*
|
||||
* @param log
|
||||
*/
|
||||
void SysMonitor_UpdatePhysicalLayerLog(const PHYLOG *log)
|
||||
{
|
||||
ASSERT(sysMonitorInst != NULL);
|
||||
ASSERT(log != NULL);
|
||||
uint8_t buffIndx;
|
||||
buffIndx = GetWritable(sysMonitorInst->phyLogCtrl);
|
||||
sysMonitorInst->phyLogCtrl.wBusy = buffIndx;
|
||||
memcpy(&(sysMonitorInst->phyLog[buffIndx]), log, sizeof(PHYLOG));
|
||||
sysMonitorInst->phyLogCtrl.latest = buffIndx;
|
||||
sysMonitorInst->phyLogCtrl.wBusy = BUFF_NONE;
|
||||
}
|
||||
|
||||
/**
|
||||
* @brief Get the latest physical layer log
|
||||
*
|
||||
* @param log
|
||||
*/
|
||||
void SysMonitor_GetPhysicalLayerLog(PHYLOG *log)
|
||||
{
|
||||
ASSERT(sysMonitorInst != NULL);
|
||||
ASSERT(log != NULL);
|
||||
uint8_t buffIndx, buffIndex_old;
|
||||
buffIndex_old = sysMonitorInst->phyLogCtrl.rBusy;
|
||||
if (buffIndex_old != BUFF_NONE)
|
||||
buffIndx = buffIndex_old; // Keep it busy
|
||||
else
|
||||
buffIndx = GetReadable(sysMonitorInst->phyLogCtrl);
|
||||
sysMonitorInst->phyLogCtrl.rBusy = buffIndx;
|
||||
memcpy(log, &(sysMonitorInst->phyLog[buffIndx]), sizeof(PHYLOG));
|
||||
sysMonitorInst->phyLogCtrl.rBusy = buffIndex_old;
|
||||
}
|
||||
/** @} */
|
||||
|
||||
/**
|
||||
* @name HardwareState_Log_API
|
||||
* @{
|
||||
*/
|
||||
|
||||
/**
|
||||
* @brief Log hardware running status.
|
||||
*
|
||||
* @param state
|
||||
*/
|
||||
void SysMonitor_UpdateHardwareStatus(const HWSTATE *state)
|
||||
{
|
||||
ASSERT(sysMonitorInst != NULL);
|
||||
ASSERT(state != NULL);
|
||||
uint8_t buffIndx;
|
||||
buffIndx = GetWritable(sysMonitorInst->hwStateCtrl);
|
||||
sysMonitorInst->hwStateCtrl.wBusy = buffIndx;
|
||||
memcpy(&(sysMonitorInst->hwState[buffIndx]), state, sizeof(HWSTATE));
|
||||
sysMonitorInst->hwStateCtrl.latest = buffIndx;
|
||||
sysMonitorInst->hwStateCtrl.wBusy = BUFF_NONE;
|
||||
}
|
||||
|
||||
/**
|
||||
* @brief Get the latest hardware running status.
|
||||
*
|
||||
* @param state
|
||||
*/
|
||||
void SysMonitor_GetHardwareStatus(HWSTATE *state)
|
||||
{
|
||||
ASSERT(sysMonitorInst != NULL);
|
||||
ASSERT(state != NULL);
|
||||
uint8_t buffIndx, buffIndex_old;
|
||||
buffIndex_old = sysMonitorInst->hwStateCtrl.rBusy;
|
||||
if (buffIndex_old != BUFF_NONE)
|
||||
buffIndx = buffIndex_old; // Keep it busy
|
||||
else
|
||||
buffIndx = GetReadable(sysMonitorInst->hwStateCtrl);
|
||||
sysMonitorInst->hwStateCtrl.rBusy = buffIndx;
|
||||
memcpy(state, &(sysMonitorInst->hwState[buffIndx]), sizeof(HWSTATE));
|
||||
sysMonitorInst->hwStateCtrl.rBusy = buffIndex_old;
|
||||
}
|
||||
|
||||
|
||||
/** @} SystemBus*/
|
||||
|
||||
+245
-2
@@ -23,9 +23,74 @@
|
||||
#include <stdbool.h>
|
||||
#include "systembus_uart.h" // SystemBus UART driver
|
||||
#include "circ_queue.h"
|
||||
#include "../system_monitor.h"
|
||||
|
||||
/************************** Constant Definitions *****************************/
|
||||
/**
|
||||
* @name SystemMonitor_Constants
|
||||
* @{
|
||||
*/
|
||||
#define SYSBUS_FRM_MAX UART_FRM_MAX
|
||||
#define SYSBUS_DAT_MAX UART_DAT_MAX
|
||||
#define SYSBUS_PRE_LEN 2 // length of preamble of data chunk (command + node type)
|
||||
#define SYSBUS_PLD_MAX SYSBUS_DAT_MAX-SYSBUS_PRE_LEN // max length of payload chunk (part of data chunk)
|
||||
#define SYSBUS_SVC_PRE_LEN 7 // length of service premable
|
||||
#define SYSBUS_SVC_PLD_MAX SYSBUS_PLD_MAX-SYSBUS_SVC_PRE_LEN // max length of service payload
|
||||
|
||||
#define DATA_ID_NONE UINT32_MAX
|
||||
#define DATA_ID_TEST 0x02030203
|
||||
|
||||
#define VOLTAGE_LSB 0.01 // volt
|
||||
#define VOLTAGE_MAX 2.55 // volt
|
||||
|
||||
#define VOLT_PS_STD 1.0
|
||||
#define VOLT_PSAUX_STD 1.8
|
||||
#define VOLT_DDR_STD 1.5
|
||||
#define VOLT_PL_STD 1.0
|
||||
#define VOLT_PLAUX_STD 1.8
|
||||
#define VOLT_BRAM_STD 1.0
|
||||
|
||||
#define VOLT_PS_OK BIT(0)
|
||||
#define VOLT_PSAUX_OK BIT(1)
|
||||
#define VOLT_DDR_OK BIT(2)
|
||||
#define VOLT_PL_OK BIT(3)
|
||||
#define VOLT_PLAUX_OK BIT(4)
|
||||
#define VOLT_BRAM_OK BIT(5)
|
||||
|
||||
#define VOLT_ANT_PROC_OK BIT(0)
|
||||
#define VOLT_ANT_RF_OK BIT(2)
|
||||
#define VOLT_ANT_NIL_OK BIT(4)
|
||||
#define ANT_STATE_OK BIT(6)
|
||||
|
||||
// Xilinx Recommended
|
||||
// #define IS_PS_VALID(x) (x <= 1.05 && x >= 0.95)
|
||||
// #define IS_PSAUX_VALID(x) (x <= 1.89 && x >= 1.71)
|
||||
// #define IS_DDR_VALID(x) (x <= 1.89 && x >= 1.14)
|
||||
// #define IS_PL_VALID(x) (x <= 1.03 && x >= 0.97)
|
||||
// #define IS_PLAUX_VALID(x) (x <= 1.89 && x >= 1.71)
|
||||
// #define IS_BRAM_VALID(x) (x <= 1.03 && x >= 0.97)
|
||||
#define IS_PS_VALID(x) ((x) <= 1.1 && (x) >= 0.9)
|
||||
#define IS_PSAUX_VALID(x) ((x) <= 2.0 && (x) >= 1.6)
|
||||
#define IS_DDR_VALID(x) ((x) <= 1.7 && (x) >= 1.3)
|
||||
#define IS_PL_VALID(x) (x <= 1.1 && (x) >= 0.9)
|
||||
#define IS_PLAUX_VALID(x) ((x) <= 2.0 && (x) >= 1.6)
|
||||
#define IS_BRAM_VALID(x) ((x) <= 1.1 && (x) >= 0.9)
|
||||
|
||||
#define CLK_SP_PLL1_LOCK BIT(0)
|
||||
#define CLK_SP_PLL2_LOCK BIT(2)
|
||||
|
||||
#define CLK_AD0_BBPLL_LOCK BIT(0)
|
||||
#define CLK_AD0_RFPLL_LOCK BIT(2)
|
||||
#define CLK_AD1_BBPLL_LOCK BIT(4)
|
||||
#define CLK_AD1_RFPLL_LOCK BIT(6)
|
||||
|
||||
#define CLK_ANT_BBPLL_LOCK BIT(0)
|
||||
#define CLK_ANT_RFPLL1_LOCK BIT(2)
|
||||
#define CLK_ANT_RFPLL2_LOCK BIT(4)
|
||||
|
||||
#define TEMPERATURE_LSB 1.0 // Celsius degree
|
||||
#define TEMPERATURE_MAX 127.0 // Celsius degree
|
||||
#define TEMPERATURE_MIN -128.0 // Celsius degree
|
||||
/** @} SystemMonitor_Constants */
|
||||
/************************** Data Type Definitions ****************************/
|
||||
|
||||
/**
|
||||
@@ -39,6 +104,156 @@ typedef struct
|
||||
uint32_t rxQueueMax; ///< maximum rx queue length
|
||||
} SYSBUS_CONFIG;
|
||||
|
||||
|
||||
/**
|
||||
* @struct SYSBUS_SVC_PLD
|
||||
* @brief Payload struct that holds the service payload
|
||||
*/
|
||||
typedef struct
|
||||
{
|
||||
uint32_t dataId; ///< data identifier
|
||||
uint8_t nodeId; ///< destination ID for tx, source ID for rx
|
||||
uint16_t dataLen; ///< data length
|
||||
uint8_t data[SYSBUS_SVC_PLD_MAX];
|
||||
} SYSBUS_SVC_PLD;
|
||||
|
||||
/**
|
||||
* @struct SYSINFO
|
||||
* @brief System Infomation log
|
||||
*/
|
||||
typedef struct __attribute__((packed))
|
||||
{
|
||||
uint32_t psBDS; ///< -- unit: ms, 0~604799999
|
||||
uint16_t pBDS; ///< -- unit: week, 0~0~8191
|
||||
uint32_t psGPS; ///< -- unit: ms, 0~604799999
|
||||
uint16_t pGPS; ///< -- unit: week, 0~0~8191
|
||||
uint8_t tmInd; ///< Time validation indicator \n
|
||||
// -- [0] GPS\n
|
||||
// -- [1] reserve.\n
|
||||
// -- [2] UTC\n
|
||||
// -- [3] BDS\n
|
||||
float tmFly; ///< Time of flying uint: s
|
||||
uint8_t stFly; ///< Status of flying \n
|
||||
// [7:6] departure status 11 - departed/00 - not departed \n
|
||||
// [5:4] ready status 11 - ready/00 - not ready \n
|
||||
// [3:2] attitude status 11 - attitude ok/00 - attitude not ok \n
|
||||
// [1:0] attitude adjust status 11 - adjusted/00 - not adjusted
|
||||
float posX; ///< coord X Position in launch coordinate system
|
||||
float posY; ///< coord Y Position in launch coordinate system
|
||||
float posZ; ///< coord Z Position in launch coordinate system
|
||||
float vX; ///< Speed X in launch coordinate system
|
||||
float vY; ///< Speed Y in launch coordinate system
|
||||
float vZ; ///< Speed Z in launch coordinate system
|
||||
float pitch; ///< Pitch Attitude in launch inertia coordinate system
|
||||
float yaw; ///< Yaw Attitude in launch inertia coordinate system
|
||||
float roll; ///< Roll Attitude in launch inertia coordinate system
|
||||
} SYSINFO;
|
||||
|
||||
/**
|
||||
* @struct SYSBUSLOG
|
||||
* @brief System Info holds the system bus log
|
||||
*/
|
||||
typedef struct __attribute__((packed))
|
||||
{
|
||||
// SystemBus log
|
||||
|
||||
uint8_t lastConfig[4]; ///< Last valid config \n
|
||||
// byte 0: Enable control, 0xAA - enable, 0x55 - disable \n
|
||||
// byte 1: Node ID \n
|
||||
// byte 2: Service rate \n
|
||||
// byte 3: routing table number
|
||||
uint32_t recvCnt; ///< number of received data packet
|
||||
uint32_t sendCnt; ///< number of send data packet
|
||||
uint32_t remoteCnt; ///< number of remote check commands
|
||||
} SYSBUSLOG;
|
||||
|
||||
/**
|
||||
* @struct LINKLOG
|
||||
* @brief Linklayer Log struct holds the Linklayer log
|
||||
*/
|
||||
typedef struct __attribute__((packed))
|
||||
{
|
||||
// Network log
|
||||
uint32_t tuNum; ///< current time unite number
|
||||
uint8_t slotNum; ///< current slot number
|
||||
uint8_t nodeType; ///< current node type
|
||||
uint8_t cxnStatus; ///< current connection status
|
||||
uint8_t linkStage; ///< current linklayer working stage
|
||||
uint32_t recxnCnt; ///< reconnect trial count
|
||||
uint8_t antIndex; ///< current working antenna index
|
||||
uint32_t advTxCnt; ///< adv frame send count
|
||||
uint32_t advRecvCnt; ///< adv frame received count
|
||||
uint32_t advCorrectCnt; ///< adv frame received correctly count
|
||||
uint32_t ackTxCnt; ///< ack frame send count
|
||||
uint32_t ackRecvCnt; ///< ack frame received count
|
||||
uint32_t ackCorrectCnt; ///< ack frame received correctly count
|
||||
uint32_t disTxCnt; ///< dist frame send count
|
||||
uint32_t disRecvCnt; ///< dist frame received count
|
||||
uint32_t disCorrectCnt;///< dist frame received correctly count
|
||||
uint32_t mngTxCnt; ///< mng frame send count
|
||||
uint32_t mngRecvCnt; ///< mng frame received count
|
||||
uint32_t mngCorrectCnt; ///< mng frame received correctly count
|
||||
uint32_t rttTxCnt; ///< rtt frame send count
|
||||
uint32_t rttRecvCnt; ///< rtt frame received count
|
||||
uint32_t rttCorrectCnt; ///< rtt frame received correctly count
|
||||
uint32_t svcTxCnt; ///< svc frame send count
|
||||
uint32_t svcRecvCnt; ///< svc frame received count
|
||||
uint32_t svcCorrectCnt; ///< svc frame received correctly count
|
||||
int32_t timeDev; ///< last time deviation result
|
||||
uint32_t sendId; ///< last send data id
|
||||
uint32_t recvId; ///< last received data id
|
||||
uint8_t reserve[3]; ///< reserved data
|
||||
} LINKLOG;
|
||||
|
||||
/**
|
||||
* @struct PHYLOG
|
||||
* @brief Physical Layer Log struct holds the Linklayer log
|
||||
*/
|
||||
typedef struct __attribute__((packed))
|
||||
{
|
||||
uint32_t acqCnt; ///< acquisition count
|
||||
uint32_t fsyncCnt; ///< frame sync count
|
||||
uint32_t decodeCnt; ///< decode count
|
||||
uint32_t crcCnt; ///< crc valid count
|
||||
double doppler; ///< last doppler estimation result
|
||||
uint64_t recvStamp; ///< last frame arrival time
|
||||
double acqPAPR; ///< last acquisition peak-average ration
|
||||
uint8_t acqPhase; ///< last acquisition phase estimation
|
||||
uint8_t acqFreqCh; ///< last acquisition frequency deviation estimation
|
||||
double fsyncPAPR; ///< last frame sync peak-average ration
|
||||
uint8_t fsyncFreqCh; ///< last frame sync frequency estimation
|
||||
uint16_t deintlvAmpEst; ///< de-interleave amplitude estimation
|
||||
uint8_t antControl; ///< current antenna rf mode
|
||||
uint8_t reserve[2]; ///< reserved data
|
||||
} PHYLOG;
|
||||
|
||||
/**
|
||||
* @struct HWSTATE
|
||||
* @brief Hardware Status Log struct holds all hardware status
|
||||
*/
|
||||
typedef struct __attribute__((packed))
|
||||
{
|
||||
bool isSpOk; ///< signal processor state
|
||||
bool isAntOk; ///< antenna state
|
||||
// -- Signal processor status
|
||||
uint8_t spFpgaVolt; ///< Signal processor voltage state indicator
|
||||
uint8_t spClkState; ///< Signal processor clock state indicator
|
||||
uint8_t spAdLockState; ///< Signal processor adc lock state indicator
|
||||
int8_t spAdTemp_0; ///< Signal processor adc0 temperature
|
||||
int8_t spAdTemp_1; ///< Signal processor adc1 temperature
|
||||
int8_t spFpgaTemp; ///< Signal processor FPGA temperature
|
||||
// -- Antenna status
|
||||
uint16_t ant1Freq; ///< Antenna 1 frequency
|
||||
uint16_t ant2Freq; ///< Antenna 2 frequency
|
||||
uint16_t ant3Freq; ///< Antenna 3 frequency
|
||||
uint8_t antPll; ///< Antenna pll lock state indicator
|
||||
uint8_t antMode; ///< Antenna mode indicator
|
||||
int8_t antTemp; ///< Antenna rf temperature
|
||||
uint8_t antRsvd; ///< Antenna reserved status register
|
||||
uint8_t phyId;
|
||||
uint8_t reserve[3];
|
||||
} HWSTATE;
|
||||
|
||||
/**
|
||||
* @struct SYSBUS
|
||||
* @brief SystemBus Instance struct
|
||||
@@ -57,9 +272,19 @@ typedef struct
|
||||
bool isRxDone; ///< rx done indicator
|
||||
} SYSBUS;
|
||||
|
||||
/**
|
||||
* @struct SYSMON_CONFIG
|
||||
* @brief System monitor config struct holds system monitor initialization parameters
|
||||
*/
|
||||
typedef struct
|
||||
{
|
||||
uint32_t sendQueueMax; ///< maximum send queue length
|
||||
uint32_t recvQueueMax; ///< maximum receive queue length
|
||||
} SYSMON_CONFIG;
|
||||
|
||||
/************************** Function Prototypes ******************************/
|
||||
|
||||
int32_t SystemBus_GenRecvRsp(SYSBUS *instPtr, SYSMON_SVC_PAYLOAD *payload);
|
||||
int32_t SystemBus_GenRecvRsp(SYSBUS *instPtr, SYSBUS_SVC_PLD *payload);
|
||||
int32_t SystemBus_Init(SYSBUS **instPtr, SYSBUS_CONFIG *config);
|
||||
void SystemBus_Destroy(SYSBUS *instPtr);
|
||||
|
||||
@@ -80,6 +305,24 @@ bool SystemBus_IsRespPending(SYSBUS *instPtr);
|
||||
bool SystemBus_IsTxBusy(SYSBUS *instPtr);
|
||||
bool SystemBus_IsRxBusy(SYSBUS *instPtr);
|
||||
|
||||
|
||||
int32_t SysMonitor_Init(SYSMON_CONFIG *config);
|
||||
void SysMonitor_Destroy(void);
|
||||
|
||||
void SysMonitor_UpdateSysinfo(const SYSINFO *info);
|
||||
void SysMonitor_GetSysinfo(SYSINFO *info);
|
||||
|
||||
int32_t SysMonitor_UpdateSendPayload(SYSBUS_SVC_PLD *payload);
|
||||
void SysMonitor_GetSendPayload(SYSBUS_SVC_PLD **payload);
|
||||
int32_t SysMonitor_GenRecvRsp(SYSBUS_SVC_PLD *payload);
|
||||
|
||||
void SysMonitor_UpdateLinklayerLog(const LINKLOG *log);
|
||||
void SysMonitor_UpdatePhysicalLayerLog(const PHYLOG *log);
|
||||
void SysMonitor_UpdateHardwareStatus(const HWSTATE *state);
|
||||
void SysMonitor_GetLinklayerLog(LINKLOG *log);
|
||||
void SysMonitor_GetPhysicalLayerLog(PHYLOG *log);
|
||||
void SysMonitor_GetHardwareStatus(HWSTATE *state);
|
||||
|
||||
#endif //__SYSTEMBUS_H_
|
||||
|
||||
/** @} SystemBus*/
|
||||
|
||||
@@ -21,7 +21,6 @@
|
||||
* @{
|
||||
*/
|
||||
|
||||
|
||||
#include <stdlib.h>
|
||||
#include <string.h>
|
||||
#include <stdint.h>
|
||||
@@ -34,10 +33,10 @@
|
||||
* @{
|
||||
*/
|
||||
// Control and status register
|
||||
#define MODULE_VERSION 0
|
||||
#define UART_STATUS 4
|
||||
#define UART_SEND_CMD 8
|
||||
#define UART_RECV_CNT 12
|
||||
#define MODULE_VERSION 0x00000000U
|
||||
#define UART_STATUS 0x0000004U
|
||||
#define UART_SEND_CMD 0x00000008U
|
||||
#define UART_RECV_CNT 0x0000000CU
|
||||
|
||||
// Status code
|
||||
#define UART_STATUS_TX_BUSY 0x00010000
|
||||
@@ -48,6 +47,10 @@
|
||||
#define UART_RXBUFF_OFFSET 2048
|
||||
#define UART_RXBUFF_MAX 1024
|
||||
|
||||
#if (UART_TXBUFF_MAX < UART_FRM_MAX || UART_RXBUFF_MAX < UART_FRM_MAX)
|
||||
#error "UART_FRM_MAX exceeds the maximum value."
|
||||
#endif
|
||||
|
||||
// Frame Data offsets
|
||||
#define FRAME_HEAD_LOW 0x5A
|
||||
#define FRAME_HEAD_HIGH 0x54
|
||||
@@ -62,16 +65,6 @@
|
||||
#define FRAME_OVERHEAD_LEN 7 // CheckSum, Dummy and DataLen
|
||||
/** @} SystemBus_UART_Driver_Constants*/
|
||||
|
||||
/*****************************************************************************/
|
||||
/**
|
||||
* @brief Instance initial
|
||||
*
|
||||
* @param instPtr A pointer to frame uart instance structure.
|
||||
* @param config Base address of frame uart, refer to "xparameters.h"
|
||||
*
|
||||
* @return None.
|
||||
*
|
||||
******************************************************************************/
|
||||
int SysbusUart_Init(SYSBUS_UART **instPtr, SYSBUS_UART_CONFIG *config)
|
||||
{
|
||||
ASSERT(instPtr != NULL);
|
||||
@@ -85,17 +78,6 @@ int SysbusUart_Init(SYSBUS_UART **instPtr, SYSBUS_UART_CONFIG *config)
|
||||
return SUCCESS;
|
||||
}
|
||||
|
||||
/*****************************************************************************/
|
||||
/**
|
||||
* @brief Send a system bus frame.
|
||||
*
|
||||
* @param instPtr A pointer to SYSBUS_UART instance structure.
|
||||
* @param buff A pointer to send data buffer
|
||||
* @param dLen A integer indicate the send data buffer length in byte.
|
||||
*
|
||||
* @return
|
||||
*
|
||||
******************************************************************************/
|
||||
int SysbusUart_Send(SYSBUS_UART *instPtr, SYSBUS_UART_FRAME *frame)
|
||||
{
|
||||
ASSERT(instPtr != NULL);
|
||||
@@ -154,16 +136,6 @@ int SysbusUart_Send(SYSBUS_UART *instPtr, SYSBUS_UART_FRAME *frame)
|
||||
return SUCCESS;
|
||||
}
|
||||
|
||||
/*****************************************************************************/
|
||||
/**
|
||||
* @brief Get last system bus frame.
|
||||
*
|
||||
* @param instPtr A pointer to SYSBUS_UART instance structure.
|
||||
* @param buff A pointer to receive data buffer.
|
||||
*
|
||||
* @return
|
||||
*
|
||||
******************************************************************************/
|
||||
int SysbusUart_Recv(SYSBUS_UART *instPtr, SYSBUS_UART_FRAME *frame)
|
||||
{
|
||||
ASSERT(instPtr != NULL);
|
||||
@@ -212,16 +184,6 @@ int SysbusUart_Recv(SYSBUS_UART *instPtr, SYSBUS_UART_FRAME *frame)
|
||||
return SUCCESS;
|
||||
}
|
||||
|
||||
/*****************************************************************************/
|
||||
/**
|
||||
* @brief Get rx channel status.
|
||||
*
|
||||
* @param instPtr A pointer to SYSBUS_UART instance structure.
|
||||
*
|
||||
* @return true - SYSBUS_UART rx channel is busy.
|
||||
* false - SYSBUS_UART rx channel is idle.
|
||||
*
|
||||
******************************************************************************/
|
||||
bool SysbusUart_IsRxBusy(SYSBUS_UART *instPtr)
|
||||
{
|
||||
ASSERT(instPtr != NULL);
|
||||
@@ -238,16 +200,6 @@ bool SysbusUart_IsRxBusy(SYSBUS_UART *instPtr)
|
||||
}
|
||||
}
|
||||
|
||||
/*****************************************************************************/
|
||||
/**
|
||||
* @brief Get tx channel status.
|
||||
*
|
||||
* @param instPtr A pointer to SYSBUS_UART instance structure.
|
||||
*
|
||||
* @return true - SYSBUS_UART tx channel is busy.
|
||||
* false - SYSBUS_UART tx channel is idle.
|
||||
*
|
||||
******************************************************************************/
|
||||
bool SysbusUart_IsTxBusy(SYSBUS_UART *instPtr)
|
||||
{
|
||||
ASSERT(instPtr != NULL);
|
||||
|
||||
@@ -27,6 +27,9 @@
|
||||
#include <stdint.h>
|
||||
#include <stdbool.h>
|
||||
#include "util.h"
|
||||
/************************** Constant Definitions *****************************/
|
||||
#define UART_FRM_MAX 1024 // max length of uart frame
|
||||
#define UART_DAT_MAX 1000 // max length of data chunk (part of uart frame)
|
||||
/**************************** Type Definitions *****************************/
|
||||
/**
|
||||
*
|
||||
@@ -96,23 +99,71 @@ typedef struct
|
||||
uint16_t len;
|
||||
uint8_t checkSum;
|
||||
uint8_t isValid;
|
||||
uint8_t data[1024];
|
||||
uint8_t data[UART_FRM_MAX];
|
||||
} SYSBUS_UART_FRAME;
|
||||
|
||||
/************************** Function Prototypes ******************************/
|
||||
// Instance initial
|
||||
|
||||
/*****************************************************************************/
|
||||
/**
|
||||
* @brief Instance initial
|
||||
*
|
||||
* @param instPtr A pointer to frame uart instance structure.
|
||||
* @param config Base address of frame uart, refer to "xparameters.h"
|
||||
*
|
||||
* @return None.
|
||||
*
|
||||
******************************************************************************/
|
||||
int SysbusUart_Init(SYSBUS_UART **instPtr, SYSBUS_UART_CONFIG *config);
|
||||
|
||||
// Send a system bus frame.
|
||||
|
||||
/*****************************************************************************/
|
||||
/**
|
||||
* @brief Send a system bus frame.
|
||||
*
|
||||
* @param instPtr A pointer to SYSBUS_UART instance structure.
|
||||
* @param buff A pointer to send data buffer
|
||||
* @param dLen A integer indicate the send data buffer length in byte.
|
||||
*
|
||||
* @return
|
||||
*
|
||||
******************************************************************************/
|
||||
int SysbusUart_Send(SYSBUS_UART *instPtr, SYSBUS_UART_FRAME *frame);
|
||||
|
||||
// Get last system bus frame.
|
||||
/*****************************************************************************/
|
||||
/**
|
||||
* @brief Get last system bus frame.
|
||||
*
|
||||
* @param instPtr A pointer to SYSBUS_UART instance structure.
|
||||
* @param buff A pointer to receive data buffer.
|
||||
*
|
||||
* @return
|
||||
*
|
||||
******************************************************************************/
|
||||
int SysbusUart_Recv(SYSBUS_UART *instPtr, SYSBUS_UART_FRAME *frame);
|
||||
|
||||
// Get system bus rx channel status.
|
||||
/*****************************************************************************/
|
||||
/**
|
||||
* @brief Get rx channel status.
|
||||
*
|
||||
* @param instPtr A pointer to SYSBUS_UART instance structure.
|
||||
*
|
||||
* @return true - SYSBUS_UART rx channel is busy.
|
||||
* false - SYSBUS_UART rx channel is idle.
|
||||
*
|
||||
******************************************************************************/
|
||||
bool SysbusUart_IsRxBusy(SYSBUS_UART *instPtr);
|
||||
|
||||
// Get system bus tx channel status.
|
||||
/*****************************************************************************/
|
||||
/**
|
||||
* @brief Get tx channel status.
|
||||
*
|
||||
* @param instPtr A pointer to SYSBUS_UART instance structure.
|
||||
*
|
||||
* @return true - SYSBUS_UART tx channel is busy.
|
||||
* false - SYSBUS_UART tx channel is idle.
|
||||
*
|
||||
******************************************************************************/
|
||||
bool SysbusUart_IsTxBusy(SYSBUS_UART *instPtr);
|
||||
|
||||
#endif // SYSTEMBUS_UART_H
|
||||
|
||||
Reference in New Issue
Block a user