32 #include "kernel/errata.h"
34 #include "modules/wltune.h"
49 static int _armResetImg = -1;
55 #define MON_FLAGS_AHRS_VALID 0x1 // AHRS data is valid
56 #define MON_TSLICE_DUR 0x2 // Contains timeslice duration
71 static MonData _monData;
73 static uint32_t _tdcFull;
74 static uint32_t _aesFull;
75 static uint32_t _flushCount;
78 static volatile bool _ofListen =
false;
81 static uint32_t _ofTdcEnabledCh;
83 static uint32_t _ofStmEnabledCh;
88 if (!_ofListen)
return;
95 logWarn(
"State-machine overflow, TDC=%08x, AES=%08x", tdcFifo, aesFifo);
96 uint32_t stmFlush = 0;
97 uint32_t ipmFlush = 0;
104 ipmFlush |= IPM_CH_0;
115 ipmFlush |= IPM_CH_1;
132 if (!_ofListen)
return;
163 _monData.flags = ins.ahrs_valid ? MON_FLAGS_AHRS_VALID : 0;
164 _monData.flags|= MON_TSLICE_DUR;
166 _monData.humid = ins.humid;
167 _monData.temp = ins.temp;
168 _monData.tdcFull = _tdcFull;
169 _monData.aesFull = _aesFull;
170 _monData.flushCount = _flushCount;
171 _monData.tSliceDur = sys.time_slice_dur;
182 void _subsSysExecEvent (
ClbEvent event)
203 volatile WrxInfo * info =
wrxInfo();
206 WRX_STATUS_MAC_ADDRESS_VALID,
207 WRX_STATUS_MAC_ADDRESS_VALID, 2000))
return;
211 ( info->macAddr[2] << 24 ) |
212 ( info->macAddr[3] << 16 ) |
213 ( info->macAddr[4] << 8 ) |
214 ( info->macAddr[5] );
216 errataInit(sys.dom_id);
218 if (errataActive(ERRATA_TEST)) {
219 logInfo(
"Test Errata active!");
224 sys.dom_id = 0xDEADBEEF;
231 sys.stmach_pktsize = STMACH_PL_SIZE_MAX;
232 sys.time_slice_dur = 100000;
235 sys.sys_run_ena = SYS_SYS_RUN_ENA_ACS | SYS_SYS_RUN_ENA_MON | SYS_SYS_RUN_ENA_TDC;
238 if (!
stmachInit(sys.dom_id, &_monData,
sizeof(_monData)))
return;
243 if (!etIsDisabled(SYS_SYS_DISABLE_PWR_MEAS)) {
251 if (!
stmachConfig(sys.stmach_pktsize, sys.time_slice_dur))
return;
259 logInfo(
"Starting run %d", sys.run_number);
266 if (sys.sys_run_ena & SYS_SYS_RUN_ENA_TDC) ena |=
STMACH_CH_TDC;
268 if (sys.sys_run_ena & SYS_SYS_RUN_ENA_ACS) ena |=
STMACH_CH_AES;
269 if (sys.sys_run_ena & SYS_SYS_RUN_ENA_MON) ena |=
STMACH_CH_MCH;
277 #ifdef FLUSH_ON_PAUSE
296 #define TCONV(X) (X*503975/4096-273150)/10
298 bool _subsSysUpdate(
ClbState state, uint32_t time)
302 switch (_armResetType) {
308 if (_armResetImg == -1 || _armResetImg >= FLASH_MAX_IMAGES ) _armResetImg =
MBOOT_GOLDEN;
320 if (!etIsDisabled(SYS_SYS_DISABLE_PWR_MEAS)) {
324 etCheckFailure(SYS_SYS_FAIL_PWR_MEAS);
325 memset(sys.pwr_meas, 0,
sizeof(sys.pwr_meas));
330 memset(sys.pwr_meas, 0,
sizeof(sys.pwr_meas));
335 sys.fpga_temp = TCONV(xadcGetMeas(xadcChanTemp, xadcTypeCur));
336 sys.power_temp = sys.pwr_meas[SYS_PWR_MEAS_TEMP_LVL] / 10;
337 sys.sys_temp_hum[SYS_SYS_TEMP_HUM_FPGA] = sys.fpga_temp;
338 sys.sys_temp_hum[SYS_SYS_TEMP_HUM_CLB] = ins.temp;
339 sys.sys_temp_hum[SYS_SYS_TEMP_HUM_CLB_HUM] = ins.humid;
340 sys.sys_temp_hum[SYS_SYS_TEMP_HUM_PWR] = sys.power_temp;
342 volatile WrxInfo * info =
wrxInfo();
346 sys.sys_temp_hum[SYS_SYS_TEMP_HUM_WR] = info->brdTemp * 100 + info->brdTempFrac;
347 sys.sys_temp_hum[SYS_SYS_TEMP_HUM_SFP] = info->sfpTemp * 100
348 + (info->sfpTempFrac * 100) / 256;
350 sys.sys_temp_hum[SYS_SYS_TEMP_HUM_WR] = 0;
351 sys.sys_temp_hum[SYS_SYS_TEMP_HUM_SFP] = 0;
372 _armResetType = rTyp;
373 _armResetImg = imgNo;
uint32_t stmachEnabled()
Returns which state-machine channels are enabled.
bool stmachInit(uint32_t domId, void *monbuf, size_t monlen)
Initializes the state-machine with the DOM ID and the monitoring channel CPU data pointer...
bool stmachEnable(uint32_t enable)
Enables one or more STMACH channels.
#define MBOOT_GOLDEN
The golden image index position.
This module provides access to the peripherals on the power board.
This driver is to read and configure the AHRS I2C sensor.
Instrumentation subsystem.
ClbEvent
All state change events.
void mbootLoad(int imgNo)
Boots a specific image.
uint32_t sysHwDateRev()
Returns the Hardware date revision.
void acouOn()
Turns the hydrophone on.
static void _clbStateModErr(int idx)
Invoked by subsystem to indicate an error happened.
#define STMACH_CH_AES
Bit of state machine AES channel, relative.
void _stmachOverflowEnd(uint32_t tdcFifo, uint32_t aesFifo)
Invoked when an AES or TDC fifo should be enabled again.
Low level routines for LM32, including interrupt handling.
White Rabbit simple timer 'Ticks' driver.
ClbState clbState(int idx)
Returns the current clbSubState for the specified subsystem.
void stmachFlush(uint32_t flush, uint8_t op)
Flushes one or more state-machine channels.
System start up and management.
void sysReboot()
Reboot the system.
uint32_t tdcChannels()
Returns which TDC channels are enabled/disabled.
void stmachMUCfg(uint32_t intervalMs)
Configure Monitor Update.
Simple task scheduler for tasks.
#define STMACH_CH_TDC
Bit of machine TDC channel, relative.
void ipMuxFlush(uint32_t channelMask, uint8_t ipmFlushOp)
Flushes the IPMUX's FIFO's.
bool wrxInit()
Initializes the whiteRabbit eXchange.
Multiboot Driver, exposes one function, mbootLoad.
CompassData insCompassData
Provides the AHRS data.
void _stmachUpdateMonitor()
Stub function invoked when it is time to update the monitor channel.
uint8_t clbSys2Idx[6]
Mapping from subsystem ID to index.
#define logWarn(MSG,...)
Format a log message with warning level.
bool pwrMeasureAll(uint16_t *results)
Initiates a conversion for the given channel.
Structure defines data from a compass/tilt/gyro sensor.
static void stmachSetRunNo(uint32_t runNo)
Sets the run-number.
static bool timeOutWaitFor(uint32_t *flags, uint32_t mask, uint32_t result, uint32_t msec)
Function to wait for a specific flag to be set or cleared.
Soft reset (Software only)
void acouOff()
Truns the hydrohpone off.
void sysArmReset(ResetType rTyp, int imgNo)
Resets the CLB.
Undefined => Idle, for internal use only.
void errPrint(bool clear)
Prints the last error.
bool stmachConfig(uint32_t packSize, uint32_t duration)
Configures the stateMachine.
bool xsLockConfig
Variable to lock or unlock writing of configuration variables.
void _stmachOverflowBegin(uint32_t tdcFifo, uint32_t aesFifo)
Invoked when an AES or TDC fifo overflow occurs.
Force, reset at any point, select image, 0 - golden.
#define TDC_CH_ALL_MASK
All channels.
volatile WrxInfo * wrxInfo()
Returns the whiteRabbit information structure if available, else NULL.
Hard reset, but only if idle, select image, 0 - golden.
#define LOG_DEF(NAME,...)
Define a logger for a module.
The CLB stare module tracks is responsible for state management of the various sub-systems on the CLB...
static void tdcDisableAll()
Disables all channels.
uint32_t sysSwDateRev()
Returns the Software date revision.
bool pwrInit()
Initializes the powerboard.
Implements a generic logger facility.
Access provides 'introspective' access to process variables.
WhiteRabbit exchange exchanges information between the 2nd LM32 and WhiteRabbit though a small client...
#define logInfo(MSG,...)
Write a log message with formatting on info level.
void _clbStateUpdate(int idx, ClbEvent event, uint8_t status)
Invoked by the subsystem to indicate a state change has happened.
void stmachGetStCommit(uint16_t *tdc, uint16_t *aes)
Debug feature: Get TDC and AES state machine Fifo commits.
void tdcSetChannels(uint32_t channels, uint32_t mask)
Set the enable/disable channels.
#define STMACH_CH_MCH
Bit of state machine Monitoring channel, relative.