205 lines
4.8 KiB
C
205 lines
4.8 KiB
C
#ifndef __SYSTEM_MONITOR_H_
|
|
#define __SYSTEM_MONITOR_H_
|
|
|
|
#include <stdint.h>
|
|
#include <stdbool.h>
|
|
#include "util.h"
|
|
|
|
#define PAYLOAD_LEN_MAX 256
|
|
#define PAYLOAD_LEN_FLJ_RX 168
|
|
#define PAYLOAD_LEN_FLJ_TX 66
|
|
#define PAYLOAD_LEN_LJ_RX 66
|
|
#define PAYLOAD_LEN_LJ_TX 168
|
|
|
|
#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)
|
|
|
|
#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 CLK_SP_PLL0_LOCK BIT(0)
|
|
#define CLK_SP_PLL1_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_RFPLL0_LOCK BIT(2)
|
|
#define CLK_ANT_RFPLL1_LOCK BIT(4)
|
|
|
|
#define TEMPERATURE_LSB 1.0 // Celsius degree
|
|
#define TEMPERATURE_MAX 127.0 // Celsius degree
|
|
#define TEMPERATURE_MIN -128.0 // Celsius degree
|
|
|
|
typedef struct __attribute__((packed))
|
|
{
|
|
// -- unit: ms, 0~604799999
|
|
uint32_t psBDS;
|
|
// -- unit: week, 0~0~8191
|
|
uint16_t pBDS;
|
|
// -- unit: ms, 0~604799999
|
|
uint32_t psGPS;
|
|
// -- unit: week, 0~0~8191
|
|
uint16_t pGPS;
|
|
// Time validation indicator
|
|
// -- [0] GPS
|
|
// -- [1] reserve.
|
|
// -- [2] UTC
|
|
// -- [3] BDS
|
|
uint8_t tmInd;
|
|
// Time of flying
|
|
// uint: s
|
|
float tmFly;
|
|
// Status of flying
|
|
// [7:6] departure status 11 - departed/00 - not departed
|
|
// [5:4] ready status 11 - ready/00 - not ready
|
|
// [3:2] attitude status 11 - attitude ok/00 - attitude not ok
|
|
// [1:0] attitude adjust status 11 - adjusted/00 - not adjusted
|
|
uint8_t stFly;
|
|
// Position in launch coordinate system
|
|
float posX;
|
|
float posY;
|
|
float posZ;
|
|
// Speed in launch coordinate system
|
|
float vX;
|
|
float vY;
|
|
float vZ;
|
|
// Attitude in launch inertia coordinate system
|
|
float pitch;
|
|
float yaw;
|
|
float roll;
|
|
} SYSINFO;
|
|
|
|
typedef struct __attribute__((packed))
|
|
{
|
|
// SystemBus log
|
|
// -- last valid config
|
|
// byte 0: 0x11 FLJ, 0x00 LJ
|
|
// byte 1: 0x66 Full Power, 0x88 Low Power
|
|
uint8_t lastConfig[2];
|
|
uint32_t pollCnt;
|
|
uint32_t svcCnt;
|
|
uint32_t remoteCnt;
|
|
} SYSBUSLOG;
|
|
|
|
typedef struct __attribute__((packed))
|
|
{
|
|
// Network log
|
|
uint32_t tuNum;
|
|
uint8_t slotNum;
|
|
uint8_t nodeType;
|
|
uint8_t cxnStatus;
|
|
uint8_t linkStage;
|
|
uint32_t recxnCnt;
|
|
uint8_t beamNo;
|
|
uint8_t beamWidth;
|
|
uint16_t beamAz;
|
|
uint16_t beamEl;
|
|
uint16_t advTxCnt;
|
|
uint16_t advRecvCnt;
|
|
uint16_t advCorrectCnt;
|
|
uint32_t cfmTxCnt;
|
|
uint32_t cfmRecvCnt;
|
|
uint32_t cfmCorrectCnt;
|
|
uint32_t svcTxCnt;
|
|
uint32_t svcRecvCnt;
|
|
uint32_t svcCorrectCnt;
|
|
int32_t timeDev;
|
|
uint32_t sendId;
|
|
uint32_t recvId;
|
|
uint8_t reserve[4];
|
|
} LINKLOG;
|
|
|
|
typedef struct __attribute__((packed))
|
|
{
|
|
uint32_t acqCnt;
|
|
uint32_t fsyncCnt;
|
|
uint32_t decodeCnt;
|
|
uint32_t crcCnt;
|
|
double doppler;
|
|
uint64_t recvStamp;
|
|
double acqPAPR;
|
|
uint8_t acqPhase;
|
|
uint8_t acqFreqCh;
|
|
double fsyncPAPR;
|
|
uint8_t fsyncFreqCh;
|
|
uint16_t deintlvAmpEst;
|
|
uint8_t antMode;
|
|
uint8_t reserve[3];
|
|
} PHYLOG;
|
|
|
|
typedef struct __attribute__((packed))
|
|
{
|
|
// Hardware status
|
|
bool isSpOk;
|
|
bool isAntOk;
|
|
// -- Signal processor status
|
|
uint8_t spFpgaVolt;
|
|
uint8_t spClkState;
|
|
uint8_t spAdLockState;
|
|
uint8_t spAdTemp_0;
|
|
uint8_t spAdTemp_1;
|
|
uint8_t spFpgaTemp;
|
|
// -- Antenna status
|
|
uint8_t antVolt;
|
|
uint8_t antTemp;
|
|
uint8_t antPll;
|
|
uint8_t antMgc0;
|
|
uint8_t antMgc1;
|
|
uint8_t reserve[2];
|
|
} HWSTATE;
|
|
|
|
typedef struct
|
|
{
|
|
uint32_t dataId;
|
|
uint8_t data[PAYLOAD_LEN_MAX];
|
|
} PAYLOAD;
|
|
|
|
int32_t SysMonitor_Init(void);
|
|
void SysMonitor_Destroy(void);
|
|
|
|
void SysMonitor_UpdateSysinfo(const SYSINFO *info);
|
|
void SysMonitor_GetSysinfo(SYSINFO *info);
|
|
|
|
void SysMonitor_UpdateSendPayload(const uint8_t *buff, size_t len);
|
|
void SysMonitor_UpdateRecvPayload(const uint8_t *buff, size_t len);
|
|
void SysMonitor_GetSendPayload(uint8_t *buff, uint32_t *id, size_t len);
|
|
void SysMonitor_GetRecvPayload(uint8_t *buff, uint32_t *id, size_t len);
|
|
|
|
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_
|