/** * Read the current counter value. * Read the value at this instant. It may still be running, so it reflects the current value. Next * time it is read, it might have a different value. */ INT32 Counter::Get() { INT32 value = m_counter->readOutput_Value(&status); wpi_assertCleanStatus(status); return value; }
/** * Set external direction mode on this counter. * Counts are sourced on the Up counter input. * The Down counter input represents the direction to count. */ void Counter::SetExternalDirectionMode() { m_counter->writeConfig_Mode(kExternalDirection, &status); wpi_assertCleanStatus(status); }
/** * Configure the counter to count in up or down based on the length of the input pulse. * This mode is most useful for direction sensitive gear tooth sensors. * @param threshold The pulse length beyond which the counter counts the opposite direction. Units are seconds. */ void Counter::SetPulseLengthMode(float threshold) { m_counter->writeConfig_Mode(kPulseLength, &status); m_counter->writeConfig_PulseLengthThreshold((UINT32)(threshold * 1.0e6) * kSystemClockTicksPerMicrosecond, &status); wpi_assertCleanStatus(status); }
/** * Configure the timeout of the serial port. * * This defines the timeout for transactions with the hardware. * It will affect reads and very large writes. * * @param timeout The number of seconds to to wait for I/O. */ void SerialPort::SetTimeout(float timeout) { ViStatus status = viSetAttribute(m_portHandle, VI_ATTR_TMO_VALUE, (UINT32) (timeout * 1e3)); wpi_assertCleanStatus(status); }
/** * Set standard up / down counting mode on this counter. * Up and down counts are sourced independently from two inputs. */ void Counter::SetUpDownCounterMode() { m_counter->writeConfig_Mode(kTwoPulse, &status); wpi_assertCleanStatus(status); }
/** * The last direction the counter value changed. * @return The last direction the counter value changed. */ bool Counter::GetDirection() { bool value = m_counter->readOutput_Direction(&status); wpi_assertCleanStatus(status); return value; }
/** * Enable or disable the watchdog timer. * * When enabled, you must keep feeding the watchdog timer to * keep the watchdog active, and hence the dangerous parts * (motor outputs, etc.) can keep functioning. * When disabled, the watchdog is immortal and will remain active * even without being fed. It will also ignore any kill commands * while disabled. * * @param enabled Enable or disable the watchdog. */ void Watchdog::SetEnabled(bool enabled) { m_fpgaWatchDog->writeImmortal(!enabled, &status); wpi_assertCleanStatus(status); }
/** * Read how long it has been since the watchdog was last fed. * * @return The number of seconds since last meal. */ double Watchdog::GetTimer() { UINT32 timer = m_fpgaWatchDog->readTimer(&status); wpi_assertCleanStatus(status); return timer / (kSystemClockTicksPerMicrosecond * 1e6); }
/** * Read what the current expiration is. * * @return The number of seconds before starvation following a meal (watchdog starves if it doesn't eat this often). */ double Watchdog::GetExpiration() { UINT32 expiration = m_fpgaWatchDog->readExpiration(&status); wpi_assertCleanStatus(status); return expiration / (kSystemClockTicksPerMicrosecond * 1e6); }
/** * Set the type of flow control to enable on this port. * * By default, flow control is disabled. */ void SerialPort::SetFlowControl(SerialPort::FlowControl flowControl) { ViStatus status = viSetAttribute(m_portHandle, VI_ATTR_ASRL_FLOW_CNTRL, flowControl); wpi_assertCleanStatus(status); }
/** * Put the watchdog out of its misery. * * Don't wait for your dying robot to starve when there is a problem. * Kill it quickly, cleanly, and humanely. */ void Watchdog::Kill() { m_fpgaWatchDog->strobeKill(&status); wpi_assertCleanStatus(status); }
/** * Reset the serial port driver to a known state. * * Empty the transmit and receive buffers in the device and formatted I/O. */ void SerialPort::Reset() { ViStatus status = viClear(m_portHandle); wpi_assertCleanStatus(status); }
/** * Force the output buffer to be written to the port. * * This is used when SetWriteBufferMode() is set to kFlushWhenFull to force a * flush before the buffer is full. */ void SerialPort::Flush() { ViStatus status = viFlush(m_portHandle, VI_WRITE_BUF); wpi_assertCleanStatus(status); }
/** * Specify the flushing behavior of the output buffer. * * When set to kFlushOnAccess, data is synchronously written to the serial port * after each call to either Printf() or Write(). * * When set to kFlushWhenFull, data will only be written to the serial port when * the buffer is full or when Flush() is called. * * @param mode The write buffer mode. */ void SerialPort::SetWriteBufferMode(SerialPort::WriteBufferMode mode) { ViStatus status = viSetAttribute(m_portHandle, VI_ATTR_WR_BUF_OPER_MODE, mode); wpi_assertCleanStatus(status); }
/** * Reset the Counter to zero. * Set the counter value to zero. This doesn't effect the running state of the counter, just sets * the current value to zero. */ void Counter::Reset() { m_counter->strobeReset(&status); wpi_assertCleanStatus(status); }
/** * Configure how many seconds your watchdog can be neglected before it starves to death. * * @param expiration The number of seconds before starvation following a meal (watchdog starves if it doesn't eat this often). */ void Watchdog::SetExpiration(double expiration) { m_fpgaWatchDog->writeExpiration((UINT32)(expiration * (kSystemClockTicksPerMicrosecond * 1e6)), &status); wpi_assertCleanStatus(status); }
/** * Stop the Counter. * Stops the counting but doesn't effect the current value. */ void Counter::Stop() { m_counter->writeConfig_Enable(0, &status); wpi_assertCleanStatus(status); }
/** * Set the number of oversample bits. * * This sets the number of oversample bits. The actual number of oversampled values is 2**bits. * Use oversampling to improve the resolution of your measurements at the expense of sampling rate. * The oversampling is done automatically in the FPGA. * * @param channel Analog channel to configure. * @param bits Number of bits to oversample. */ void AnalogModule::SetOversampleBits(UINT32 channel, UINT32 bits) { m_module->writeOversampleBits(channel - 1, bits, &status); wpi_assertCleanStatus(status); }
/** * Find out if the watchdog is currently enabled or disabled (mortal or immortal). * * @return Enabled or disabled. */ bool Watchdog::GetEnabled() { bool enabled = !m_fpgaWatchDog->readImmortal(&status); wpi_assertCleanStatus(status); return enabled; }
/** * Get the number of oversample bits. * * This gets the number of oversample bits from the FPGA. The actual number of oversampled values is * 2**bits. The oversampling is done automatically in the FPGA. * * @param channel Channel to address. * @return Bits to oversample. */ UINT32 AnalogModule::GetOversampleBits(UINT32 channel) { UINT32 result = m_module->readOversampleBits(channel - 1, &status); wpi_assertCleanStatus(status); return result; }
/** * Check in on the watchdog and make sure he's still kicking. * * This indicates that your watchdog is allowing the system to operate. * It is still possible that the network communications is not allowing the * system to run, but you can check this to make sure it's not your fault. * Check IsSystemActive() for overall system status. * * If the watchdog is disabled, then your watchdog is immortal. * * @return Is the watchdog still alive? */ bool Watchdog::IsAlive() { bool alive = m_fpgaWatchDog->readStatus_Alive(&status); wpi_assertCleanStatus(status); return alive; }
/** * Check if any DIO line is currently generating a pulse. */ bool DigitalModule::IsPulsing() { UINT16 pulseRegister = m_fpgaDIO->readPulse(&status); wpi_assertCleanStatus(status); return pulseRegister != 0; }