30 static volatile Wrx * _wrx = (
volatile Wrx *)(
WRX_BASE);
40 while (_wrx->magic != WRX_MAGIC)
48 if (_wrx->ver != WRX_VERSION) {
49 errSet(ERROR_CTX(E_WRX_EP_VER));
52 logInfo(
"Ok, WRPC up!, Version " STR(WRX_VERSION));
65 if (!_wrxUp)
return NULL;
72 return _wrx->cmd.code != WRX_COMMAND_NONE;
75 static bool wrxReady() {
78 while (_wrx->cmd.code != WRX_COMMAND_NONE) {
84 static inline bool wrxWaitForReply(uint16_t code) {
86 if (!wrxReady())
return false;
88 if (_wrx->info.cmdcode != code) {
97 if (!wrxReady())
return false;
100 _wrx->cmd.code = WRX_COMMAND_AUTONEG_ON;
102 _wrx->cmd.code = WRX_COMMAND_AUTONEG_OFF;
111 if (!_wrxUp)
return 0;
113 return _wrx->info.utcTime;
119 if (!wrxReady())
return false;
121 _wrx->cmd.params.tuneWord = tuneWord;
122 _wrx->cmd.code = WRX_COMMAND_SET_TUNEWORD;
130 if (!wrxReady())
return false;
132 _wrx->cmd.code = WRX_COMMAND_GET_TUNEINFO;
134 if (!wrxWaitForReply(WRX_COMMAND_GET_TUNEINFO))
return false;
136 *info = _wrx->info.cmdreply.tuneInfo;
144 if (!wrxReady())
return false;
146 _wrx->cmd.code = WRX_COMMAND_GET_SFP_VENDOR_SN;
148 if (!wrxWaitForReply(WRX_COMMAND_GET_SFP_VENDOR_SN))
return false;
150 memcpy(sn, _wrx->info.cmdreply.sfpVendorSN, 16);
156 bool wrxSetSFPThreshold(
int index, uint16_t value)
158 if (!wrxReady())
return false;
160 _wrx->cmd.params.threshold.value = value;
161 _wrx->cmd.params.threshold.index = index;
162 _wrx->cmd.code = WRX_COMMAND_SET_THRESHOLD;
bool wrxGetTuneInfo(WrxTuneInfo *info)
Sets the fields of the WrxTuneInfo structure.
#define WRX_BASE
WhiteRabbit exchange address, not a real device.
#define E_NOTFOUND
Generic error: not found (ID or resource.
uint64_t wrxUtcTime()
Returns the UTC time, or 0 if not available.
bool wrxInit()
Initializes the whiteRabbit eXchange.
#define STR(EXPR)
Stringyfies an expression.
void timeDelay(uint32_t msec)
Simple busy-wait delay.
#define E_INVSTATE
Generic error: Module is in a state in which.
static uint32_t timeOutInit(uint32_t msec)
Initializes a timeout with the specified no of msecs.
static bool timeOut(uint32_t to)
Checks whether or not the timeout has expired.
Manages the global system error.
bool wrxSetTuneWord(int32_t tuneWord)
Sets the tune-word.
bool wrxGetSFPSerialNo(char sn[17])
Gets the sfp serial number.
bool wrxUp()
Returns whether or not the WhiteRabbit interface is up and running.
volatile WrxInfo * wrxInfo()
Returns the whiteRabbit information structure if available, else NULL.
#define E_TIMEOUT
Generic error: Timeout error.
bool wrxCmdPending()
Returns whether or not there is a command still pending to be executed.
#define LOG_DEF(NAME,...)
Define a logger for a module.
bool wrxSetAutoNeg(bool on)
Returns autonegotation on or off.
This file assigns all device structures to memory mapped structures.
bool errSet(uint32_t code, const char *error, const char *name)
Sets an error.
Implements a generic logger facility.
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.