40 static uint32_t _chEnabled = 0;
42 static
void optReset()
50 for (i = 0; i < OPT_CH_COUNT; ++i)
52 opt.chan_status[i] = 0;
53 opt.chan_config[i] = 0;
64 for (i = 0; i < OPT_CH_COUNT; ++i)
66 opt.chan_status[i] = 0;
67 opt.pmt_id[i] = 0xFFFFFFFF;
69 int brd = _OCT_BRD(i);
72 if (! ( opt.chan_status[i] & OPT_SYS_ERR_ANY) ) {
76 if (!
octoPMTID(brd, ch, &(opt.pmt_id[i]), &idFault)) {
87 static bool optConfig()
94 for (i = 0; i < OPT_CH_COUNT; ++i)
96 int brd = _OCT_BRD(i);
99 opt.chan_status[i] = 0;
100 if ((opt.chan_enable &
BIT(i)) || (opt.chan_config[i] & 0x40) ) {
103 if (!
octoInitChan(brd, ch, opt.pmt_highvolt[i], opt.pmt_threshold[i])) chOk =
false;
104 if ((!(sys.sys_disable & SYS_SYS_DISABLE_HV)) && chOk && !
octoHighVoltage(brd, ch,
true)) chOk =
false;
106 _chEnabled |=
BIT(i);
112 _chEnabled |=
BIT(i);
117 logError(
"Failed to initialize channel %d (brd=%s, ch=%d)",
118 i, brd == 0 ?
"small" :
"large", ch);
134 static bool optUnConfig()
140 for (i = 0; i < OPT_CH_COUNT; ++i)
142 opt.chan_status[i] = 0;
144 int brd = _OCT_BRD(i);
159 bool _showErrOnce =
true;
163 uint32_t fault[2] = { 0xFFFFFFFF, 0xFFFFFFFF };
170 if ((opt.chan_enable & _OCT_LARGE_MASK) != 0)
178 if ((opt.chan_enable & _OCT_SMALL_MASK) != 0)
186 if (
errHas() && _showErrOnce) {
191 _showErrOnce =
false;
195 for (i = 0; i < OPT_CH_COUNT; ++i)
197 int brd = _OCT_BRD(i);
206 if ((fault[brd] & (1 << ch)) == 0)
218 bool _subsOptUpdate(
ClbState state, uint32_t time)
226 void _subsOptExecEvent (
ClbEvent event)
235 opt.nano_period = 0xc35;
236 opt.nano_pcount = 100;
237 opt.nano_volt = 30000;
239 opt.hr_veto_thres = 0x7d0;
240 opt.mulhit_ena_ch = 0x7FFFFFF;
241 opt.hr_veto_ena_ch= 0x7FFFFFF;
242 opt.hr_veto_ena_ch= 0x7FFFFFF;
243 opt.min_tot=0x00000004;
256 if (sys.sys_run_ena & SYS_SYS_RUN_ENA_NANO)
258 if (!
nanoConfig(opt.nano_delay, opt.nano_period, opt.nano_length, opt.nano_pcount)) {
262 if ((!etIsDisabled(SYS_SYS_DISABLE_NANO_STEP_UP))) {
264 etCheckFailure(SYS_SYS_FAIL_NANO_STEP_UP);
284 if (!(sys.sys_disable & SYS_SYS_DISABLE_HV))
logWarn(
"** High Voltage enabled! Be careful! **");
300 logWarn(
"Failed set LED voltage to 0 on power board");
bool errHas()
Returns whether there is an error pending.
This module implements the functionality required by the octopus board (large).
This module provides access to the peripherals on the power board.
bool nanoConfig(uint32_t delay, uint32_t period, uint32_t width, uint32_t noOfPulses)
Configures the nano-beacon.
bool octoHighVoltage(int brd, int ch, bool hvOn)
Turns the high-voltage on or off.
ClbEvent
All state change events.
void tdcReset()
Resets the TDC to defaults.
void tdcSetMultiHitEnabled(uint32_t channels)
Sets on which channels the mutli-hit veto must be enabled.
#define BIT(N)
Makes a value with the specified bit set.
#define OPT_STS_ERR_OVERCUR
Over current.
void tdcSetMinTot(uint32_t m_tot)
Sets the HR veto rate per time-slice.
void octoResetBoard(int brd)
#define OPT_STS_WARN_ID
ID is inconsistent.
bool octoInitChan(int brd, int ch, uint8_t highVolt, uint8_t threshold)
Initializes a channel on the octopus board.
bool octoPMTID(int brd, int ch, uint32_t *id, bool *pmtIdFault)
Reads a PMT ID.
uint8_t clbSys2Idx[6]
Mapping from subsystem ID to index.
#define logWarn(MSG,...)
Format a log message with warning level.
static void nanoEnable(NanoEnable nanoEnable)
Enable or disable the nano-beacon.
#define PRMS_HV_V2DAC(V)
Converts the high voltage value into the high voltage DAC byte value.
#define OCTO_BRD_SMALL
Octo small.
#define OCTO_BRD_LARGE
Octo large.
void tdcSetHRVeto(uint32_t thrs)
Sets the Minimun ToT width allowed.
Manages the global system error.
Undefined => Idle, for internal use only.
void errPrint(bool clear)
Prints the last error.
#define TDC_CH_ALL_MASK
All channels.
void errClear()
Clears the current error.
bool octoDeinitChan(int brd, int ch)
De-Initializes a channel on the octopus board.
#define OPT_STS_ENABLED
Enabled.
bool optUpdate()
Updates the status of the optics.
void tdcSetHrvEnabled(uint32_t channels)
Sets on which channels the high-rate veto must be applied.
#define logError(MSG,...)
Format a log message with fatal level.
#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...
bool octoReadFault(int brd, uint32_t *fault)
Reads the fault register of the CLPD.
static void tdcDisableAll()
Disables all channels.
This driver interfaces with the PROMiS PMT ASIC.
#define PRMS_THRS_MV2DAC(MV)
Converts a threshold value in milliVolts to the DAC value.
bool pwrSetLED(uint32_t mv)
Set the LED output in millivolts.
Implements a generic logger facility.
void _clbStateUpdate(int idx, ClbEvent event, uint8_t status)
Invoked by the subsystem to indicate a state change has happened.
Undefined state (prior to module init, should never be seen on shore)
#define OPT_STS_ERR_COMM
I2C communication error.
void tdcSetChannels(uint32_t channels, uint32_t mask)
Set the enable/disable channels.