mirror of
https://github.com/wpilibsuite/allwpilib
synced 2026-07-05 03:21:42 +00:00
Initial checkin of unified hierarchy of WPILib 2015
This commit is contained in:
728
hal/Athena/src/main/native/Analog.cpp
Normal file
728
hal/Athena/src/main/native/Analog.cpp
Normal file
@@ -0,0 +1,728 @@
|
||||
|
||||
#include "HAL/Analog.h"
|
||||
|
||||
#include "Port.h"
|
||||
#include "HAL/Errors.h"
|
||||
#include "HAL/Semaphore.h"
|
||||
#include "ChipObject.h"
|
||||
#include "HAL/cpp/Synchronized.h"
|
||||
#include "HAL/cpp/Resource.h"
|
||||
#include "NetworkCommunication/AICalibration.h"
|
||||
#include "NetworkCommunication/LoadOut.h"
|
||||
|
||||
#include <stdio.h> // TODO: remove printf for debugging
|
||||
|
||||
static const long kTimebase = 40000000; ///< 40 MHz clock
|
||||
static const long kDefaultOversampleBits = 0;
|
||||
static const long kDefaultAverageBits = 7;
|
||||
static const float kDefaultSampleRate = 50000.0;
|
||||
static const uint32_t kAnalogPins = 8;
|
||||
|
||||
static const uint32_t kAccumulatorNumChannels = 2;
|
||||
static const uint32_t kAccumulatorChannels[] = {1, 2};
|
||||
|
||||
struct analog_port_t {
|
||||
Port port;
|
||||
tAccumulator *accumulator;
|
||||
};
|
||||
typedef struct analog_port_t AnalogPort;
|
||||
|
||||
bool analogSampleRateSet = false;
|
||||
MUTEX_ID analogRegisterWindowSemaphore = NULL;
|
||||
tAI* analogSystem = NULL;
|
||||
uint32_t analogNumChannelsToActivate = 0;
|
||||
|
||||
// Utility methods defined below.
|
||||
uint32_t getAnalogNumActiveChannels(int32_t *status);
|
||||
uint32_t getAnalogNumChannelsToActivate(int32_t *status);
|
||||
void setAnalogNumChannelsToActivate(uint32_t channels);
|
||||
|
||||
bool analogSystemInitialized = false;
|
||||
|
||||
/**
|
||||
* Initialize the analog System.
|
||||
*/
|
||||
void initializeAnalog(int32_t *status) {
|
||||
if (analogSystemInitialized) return;
|
||||
analogRegisterWindowSemaphore = initializeMutex(SEMAPHORE_Q_PRIORITY | SEMAPHORE_DELETE_SAFE | SEMAPHORE_INVERSION_SAFE);
|
||||
analogSystem = tAI::create(status);
|
||||
setAnalogNumChannelsToActivate(kAnalogPins);
|
||||
setAnalogSampleRate(kDefaultSampleRate, status);
|
||||
analogSystemInitialized = true;
|
||||
}
|
||||
|
||||
/**
|
||||
* Initialize the analog port using the given port object.
|
||||
*/
|
||||
void* initializeAnalogPort(void* port_pointer, int32_t *status) {
|
||||
initializeAnalog(status);
|
||||
Port* port = (Port*) port_pointer;
|
||||
|
||||
// Initialize port structure
|
||||
AnalogPort* analog_port = new AnalogPort();
|
||||
analog_port->port = *port;
|
||||
if (isAccumulatorChannel(analog_port, status)) {
|
||||
analog_port->accumulator = tAccumulator::create(port->pin - 1, status);
|
||||
} else analog_port->accumulator = NULL;
|
||||
|
||||
// Set default configuration
|
||||
analogSystem->writeScanList(port->pin - 1, port->pin - 1, status);
|
||||
setAnalogAverageBits(analog_port, kDefaultAverageBits, status);
|
||||
setAnalogOversampleBits(analog_port, kDefaultOversampleBits, status);
|
||||
return analog_port;
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* Check that the analog module number is valid.
|
||||
*
|
||||
* @return Analog module is valid and present
|
||||
*/
|
||||
bool checkAnalogModule(uint8_t module) {
|
||||
return module == 1;
|
||||
}
|
||||
|
||||
/**
|
||||
* Check that the analog channel number is value.
|
||||
* Verify that the analog channel number is one of the legal channel numbers. Channel numbers
|
||||
* are 1-based.
|
||||
*
|
||||
* @return Analog channel is valid
|
||||
*/
|
||||
bool checkAnalogChannel(uint32_t pin) {
|
||||
if (pin > 0 && pin <= kAnalogPins)
|
||||
return true;
|
||||
return false;
|
||||
}
|
||||
|
||||
/**
|
||||
* Set the sample rate.
|
||||
*
|
||||
* This is a global setting for the Athena and effects all channels.
|
||||
*
|
||||
* @param samplesPerSecond The number of samples per channel per second.
|
||||
*/
|
||||
void setAnalogSampleRate(double samplesPerSecond, int32_t *status) {
|
||||
// TODO: This will change when variable size scan lists are implemented.
|
||||
// TODO: Need float comparison with epsilon.
|
||||
//wpi_assert(!sampleRateSet || GetSampleRate() == samplesPerSecond);
|
||||
analogSampleRateSet = true;
|
||||
|
||||
// Compute the convert rate
|
||||
uint32_t ticksPerSample = (uint32_t)((float)kTimebase / samplesPerSecond);
|
||||
uint32_t ticksPerConversion = ticksPerSample / getAnalogNumChannelsToActivate(status);
|
||||
// ticksPerConversion must be at least 80
|
||||
if (ticksPerConversion < 80) {
|
||||
if ((*status) >= 0) *status = SAMPLE_RATE_TOO_HIGH;
|
||||
ticksPerConversion = 80;
|
||||
}
|
||||
|
||||
// Atomically set the scan size and the convert rate so that the sample rate is constant
|
||||
tAI::tConfig config;
|
||||
config.ScanSize = getAnalogNumChannelsToActivate(status);
|
||||
config.ConvertRate = ticksPerConversion;
|
||||
analogSystem->writeConfig(config, status);
|
||||
|
||||
// Indicate that the scan size has been commited to hardware.
|
||||
setAnalogNumChannelsToActivate(0);
|
||||
}
|
||||
|
||||
/**
|
||||
* Get the current sample rate.
|
||||
*
|
||||
* This assumes one entry in the scan list.
|
||||
* This is a global setting for the Athena and effects all channels.
|
||||
*
|
||||
* @return Sample rate.
|
||||
*/
|
||||
float getAnalogSampleRate(int32_t *status) {
|
||||
uint32_t ticksPerConversion = analogSystem->readLoopTiming(status);
|
||||
uint32_t ticksPerSample = ticksPerConversion * getAnalogNumActiveChannels(status);
|
||||
return (float)kTimebase / (float)ticksPerSample;
|
||||
}
|
||||
|
||||
/**
|
||||
* Set the sample rate on the module.
|
||||
*
|
||||
* This is a global setting for the module and effects all channels.
|
||||
*
|
||||
* @param module The module to use
|
||||
* @param samplesPerSecond The number of samples per channel per second.
|
||||
*/
|
||||
void setAnalogSampleRateWithModule(uint8_t module, double samplesPerSecond, int32_t *status) {
|
||||
if (checkAnalogModule(module)) {
|
||||
setAnalogSampleRate(samplesPerSecond, status);
|
||||
} else {
|
||||
// XXX: Set error status
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Get the current sample rate on the module.
|
||||
*
|
||||
* This assumes one entry in the scan list.
|
||||
* This is a global setting for the module and effects all channels.
|
||||
*
|
||||
* @param module The module to use
|
||||
* @return Sample rate.
|
||||
*/
|
||||
float getAnalogSampleRateWithModule(uint8_t module, int32_t *status) {
|
||||
if (checkAnalogModule(module)) {
|
||||
return getAnalogSampleRate(status);
|
||||
} else {
|
||||
return -1; // XXX: Set error status
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* Set the number of averaging bits.
|
||||
*
|
||||
* This sets the number of averaging bits. The actual number of averaged samples is 2**bits.
|
||||
* Use averaging to improve the stability of your measurement at the expense of sampling rate.
|
||||
* The averaging is done automatically in the FPGA.
|
||||
*
|
||||
* @param analog_port_pointer Pointer to the analog port to configure.
|
||||
* @param bits Number of bits to average.
|
||||
*/
|
||||
void setAnalogAverageBits(void* analog_port_pointer, uint32_t bits, int32_t *status) {
|
||||
AnalogPort* port = (AnalogPort*) analog_port_pointer;
|
||||
analogSystem->writeAverageBits(port->port.pin - 1, bits, status);
|
||||
}
|
||||
|
||||
/**
|
||||
* Get the number of averaging bits.
|
||||
*
|
||||
* This gets the number of averaging bits from the FPGA. The actual number of averaged samples is 2**bits.
|
||||
* The averaging is done automatically in the FPGA.
|
||||
*
|
||||
* @param analog_port_pointer Pointer to the analog port to use.
|
||||
* @return Bits to average.
|
||||
*/
|
||||
uint32_t getAnalogAverageBits(void* analog_port_pointer, int32_t *status) {
|
||||
AnalogPort* port = (AnalogPort*) analog_port_pointer;
|
||||
uint32_t result = analogSystem->readAverageBits(port->port.pin - 1, status);
|
||||
return result;
|
||||
}
|
||||
|
||||
/**
|
||||
* 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 analog_port_pointer Pointer to the analog port to use.
|
||||
* @param bits Number of bits to oversample.
|
||||
*/
|
||||
void setAnalogOversampleBits(void* analog_port_pointer, uint32_t bits, int32_t *status) {
|
||||
AnalogPort* port = (AnalogPort*) analog_port_pointer;
|
||||
analogSystem->writeOversampleBits(port->port.pin - 1, bits, status);
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* 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 analog_port_pointer Pointer to the analog port to use.
|
||||
* @return Bits to oversample.
|
||||
*/
|
||||
uint32_t getAnalogOversampleBits(void* analog_port_pointer, int32_t *status) {
|
||||
AnalogPort* port = (AnalogPort*) analog_port_pointer;
|
||||
uint32_t result = analogSystem->readOversampleBits(port->port.pin - 1, status);
|
||||
return result;
|
||||
}
|
||||
|
||||
/**
|
||||
* Get a sample straight from the channel on this module.
|
||||
*
|
||||
* The sample is a 12-bit value representing the -10V to 10V range of the A/D converter in the module.
|
||||
* The units are in A/D converter codes. Use GetVoltage() to get the analog value in calibrated units.
|
||||
*
|
||||
* @param analog_port_pointer Pointer to the analog port to use.
|
||||
* @return A sample straight from the channel on this module.
|
||||
*/
|
||||
int16_t getAnalogValue(void* analog_port_pointer, int32_t *status) {
|
||||
AnalogPort* port = (AnalogPort*) analog_port_pointer;
|
||||
int16_t value;
|
||||
checkAnalogChannel(port->port.pin);
|
||||
|
||||
tAI::tReadSelect readSelect;
|
||||
readSelect.Channel = port->port.pin - 1;
|
||||
readSelect.Averaged = false;
|
||||
|
||||
{
|
||||
Synchronized sync(analogRegisterWindowSemaphore);
|
||||
analogSystem->writeReadSelect(readSelect, status);
|
||||
analogSystem->strobeLatchOutput(status);
|
||||
value = (int16_t) analogSystem->readOutput(status);
|
||||
}
|
||||
|
||||
return value;
|
||||
}
|
||||
|
||||
/**
|
||||
* Get a sample from the output of the oversample and average engine for the channel.
|
||||
*
|
||||
* The sample is 12-bit + the value configured in SetOversampleBits().
|
||||
* The value configured in SetAverageBits() will cause this value to be averaged 2**bits number of samples.
|
||||
* This is not a sliding window. The sample will not change until 2**(OversamplBits + AverageBits) samples
|
||||
* have been acquired from the module on this channel.
|
||||
* Use GetAverageVoltage() to get the analog value in calibrated units.
|
||||
*
|
||||
* @param analog_port_pointer Pointer to the analog port to use.
|
||||
* @return A sample from the oversample and average engine for the channel.
|
||||
*/
|
||||
int32_t getAnalogAverageValue(void* analog_port_pointer, int32_t *status) {
|
||||
AnalogPort* port = (AnalogPort*) analog_port_pointer;
|
||||
int16_t value;
|
||||
checkAnalogChannel(port->port.pin);
|
||||
|
||||
tAI::tReadSelect readSelect;
|
||||
readSelect.Channel = port->port.pin - 1;
|
||||
readSelect.Averaged = true;
|
||||
|
||||
{
|
||||
Synchronized sync(analogRegisterWindowSemaphore);
|
||||
analogSystem->writeReadSelect(readSelect, status);
|
||||
analogSystem->strobeLatchOutput(status);
|
||||
value = (int16_t) analogSystem->readOutput(status);
|
||||
}
|
||||
|
||||
return value;
|
||||
}
|
||||
|
||||
/**
|
||||
* Get a scaled sample straight from the channel on this module.
|
||||
*
|
||||
* The value is scaled to units of Volts using the calibrated scaling data from GetLSBWeight() and GetOffset().
|
||||
*
|
||||
* @param analog_port_pointer Pointer to the analog port to use.
|
||||
* @return A scaled sample straight from the channel on this module.
|
||||
*/
|
||||
float getAnalogVoltage(void* analog_port_pointer, int32_t *status) {
|
||||
int16_t value = getAnalogValue(analog_port_pointer, status);
|
||||
uint32_t LSBWeight = getAnalogLSBWeight(analog_port_pointer, status);
|
||||
int32_t offset = getAnalogOffset(analog_port_pointer, status);
|
||||
float voltage = LSBWeight * 1.0e-9 * value - offset * 1.0e-9;
|
||||
return voltage;
|
||||
}
|
||||
|
||||
/**
|
||||
* Get a scaled sample from the output of the oversample and average engine for the channel.
|
||||
*
|
||||
* The value is scaled to units of Volts using the calibrated scaling data from GetLSBWeight() and GetOffset().
|
||||
* Using oversampling will cause this value to be higher resolution, but it will update more slowly.
|
||||
* Using averaging will cause this value to be more stable, but it will update more slowly.
|
||||
*
|
||||
* @param analog_port_pointer Pointer to the analog port to use.
|
||||
* @return A scaled sample from the output of the oversample and average engine for the channel.
|
||||
*/
|
||||
float getAnalogAverageVoltage(void* analog_port_pointer, int32_t *status) {
|
||||
int32_t value = getAnalogAverageValue(analog_port_pointer, status);
|
||||
uint32_t LSBWeight = getAnalogLSBWeight(analog_port_pointer, status);
|
||||
int32_t offset = getAnalogOffset(analog_port_pointer, status);
|
||||
uint32_t oversampleBits = getAnalogOversampleBits(analog_port_pointer, status);
|
||||
float voltage = ((LSBWeight * 1.0e-9 * value) / (float)(1 << oversampleBits)) - offset * 1.0e-9;
|
||||
return voltage;
|
||||
}
|
||||
|
||||
/**
|
||||
* Convert a voltage to a raw value for a specified channel.
|
||||
*
|
||||
* This process depends on the calibration of each channel, so the channel
|
||||
* must be specified.
|
||||
*
|
||||
* @todo This assumes raw values. Oversampling not supported as is.
|
||||
*
|
||||
* @param analog_port_pointer Pointer to the analog port to use.
|
||||
* @param voltage The voltage to convert.
|
||||
* @return The raw value for the channel.
|
||||
*/
|
||||
int32_t getAnalogVoltsToValue(void* analog_port_pointer, double voltage, int32_t *status) {
|
||||
if (voltage > 10.0) {
|
||||
voltage = 10.0;
|
||||
*status = VOLTAGE_OUT_OF_RANGE;
|
||||
}
|
||||
if (voltage < -10.0) {
|
||||
voltage = -10.0;
|
||||
*status = VOLTAGE_OUT_OF_RANGE;
|
||||
}
|
||||
uint32_t LSBWeight = getAnalogLSBWeight(analog_port_pointer, status);
|
||||
int32_t offset = getAnalogOffset(analog_port_pointer, status);
|
||||
int32_t value = (int32_t) ((voltage + offset * 1.0e-9) / (LSBWeight * 1.0e-9));
|
||||
return value;
|
||||
}
|
||||
|
||||
/**
|
||||
* Get the factory scaling least significant bit weight constant.
|
||||
* The least significant bit weight constant for the channel that was calibrated in
|
||||
* manufacturing and stored in an eeprom in the module.
|
||||
*
|
||||
* Volts = ((LSB_Weight * 1e-9) * raw) - (Offset * 1e-9)
|
||||
*
|
||||
* @param analog_port_pointer Pointer to the analog port to use.
|
||||
* @return Least significant bit weight.
|
||||
*/
|
||||
uint32_t getAnalogLSBWeight(void* analog_port_pointer, int32_t *status) {
|
||||
AnalogPort* port = (AnalogPort*) analog_port_pointer;
|
||||
uint32_t lsbWeight = FRC_NetworkCommunication_nAICalibration_getLSBWeight(0, port->port.pin - 1, status); // XXX: aiSystemIndex == 0?
|
||||
return lsbWeight;
|
||||
}
|
||||
|
||||
/**
|
||||
* Get the factory scaling offset constant.
|
||||
* The offset constant for the channel that was calibrated in manufacturing and stored
|
||||
* in an eeprom in the module.
|
||||
*
|
||||
* Volts = ((LSB_Weight * 1e-9) * raw) - (Offset * 1e-9)
|
||||
*
|
||||
* @param analog_port_pointer Pointer to the analog port to use.
|
||||
* @return Offset constant.
|
||||
*/
|
||||
int32_t getAnalogOffset(void* analog_port_pointer, int32_t *status) {
|
||||
AnalogPort* port = (AnalogPort*) analog_port_pointer;
|
||||
int32_t offset = FRC_NetworkCommunication_nAICalibration_getOffset(0, port->port.pin - 1, status); // XXX: aiSystemIndex == 0?
|
||||
return offset;
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* Return the number of channels on the module in use.
|
||||
*
|
||||
* @return Active channels.
|
||||
*/
|
||||
uint32_t getAnalogNumActiveChannels(int32_t *status) {
|
||||
uint32_t scanSize = analogSystem->readConfig_ScanSize(status);
|
||||
if (scanSize == 0)
|
||||
return 8;
|
||||
return scanSize;
|
||||
}
|
||||
|
||||
/**
|
||||
* Get the number of active channels.
|
||||
*
|
||||
* This is an internal function to allow the atomic update of both the
|
||||
* number of active channels and the sample rate.
|
||||
*
|
||||
* When the number of channels changes, use the new value. Otherwise,
|
||||
* return the curent value.
|
||||
*
|
||||
* @return Value to write to the active channels field.
|
||||
*/
|
||||
uint32_t getAnalogNumChannelsToActivate(int32_t *status) {
|
||||
if(analogNumChannelsToActivate == 0) return getAnalogNumActiveChannels(status);
|
||||
return analogNumChannelsToActivate;
|
||||
}
|
||||
|
||||
/**
|
||||
* Set the number of active channels.
|
||||
*
|
||||
* Store the number of active channels to set. Don't actually commit to hardware
|
||||
* until SetSampleRate().
|
||||
*
|
||||
* @param channels Number of active channels.
|
||||
*/
|
||||
void setAnalogNumChannelsToActivate(uint32_t channels) {
|
||||
analogNumChannelsToActivate = channels;
|
||||
}
|
||||
|
||||
//// Accumulator Stuff
|
||||
|
||||
/**
|
||||
* Is the channel attached to an accumulator.
|
||||
*
|
||||
* @return The analog channel is attached to an accumulator.
|
||||
*/
|
||||
bool isAccumulatorChannel(void* analog_port_pointer, int32_t *status) {
|
||||
AnalogPort* port = (AnalogPort*) analog_port_pointer;
|
||||
for (uint32_t i=0; i < kAccumulatorNumChannels; i++) {
|
||||
if (port->port.pin == kAccumulatorChannels[i]) return true;
|
||||
}
|
||||
return false;
|
||||
}
|
||||
|
||||
/**
|
||||
* Initialize the accumulator.
|
||||
*/
|
||||
void initAccumulator(void* analog_port_pointer, int32_t *status) {
|
||||
setAccumulatorCenter(analog_port_pointer, 0, status);
|
||||
resetAccumulator(analog_port_pointer, status);
|
||||
}
|
||||
|
||||
/**
|
||||
* Resets the accumulator to the initial value.
|
||||
*/
|
||||
void resetAccumulator(void* analog_port_pointer, int32_t *status) {
|
||||
AnalogPort* port = (AnalogPort*) analog_port_pointer;
|
||||
if (port->accumulator == NULL) {
|
||||
*status = NULL_PARAMETER;
|
||||
return;
|
||||
}
|
||||
port->accumulator->strobeReset(status);
|
||||
}
|
||||
|
||||
/**
|
||||
* Set the center value of the accumulator.
|
||||
*
|
||||
* The center value is subtracted from each A/D value before it is added to the accumulator. This
|
||||
* is used for the center value of devices like gyros and accelerometers to make integration work
|
||||
* and to take the device offset into account when integrating.
|
||||
*
|
||||
* This center value is based on the output of the oversampled and averaged source from channel 1.
|
||||
* Because of this, any non-zero oversample bits will affect the size of the value for this field.
|
||||
*/
|
||||
void setAccumulatorCenter(void* analog_port_pointer, int32_t center, int32_t *status) {
|
||||
AnalogPort* port = (AnalogPort*) analog_port_pointer;
|
||||
if (port->accumulator == NULL) {
|
||||
*status = NULL_PARAMETER;
|
||||
return;
|
||||
}
|
||||
port->accumulator->writeCenter(center, status);
|
||||
}
|
||||
|
||||
/**
|
||||
* Set the accumulator's deadband.
|
||||
*/
|
||||
void setAccumulatorDeadband(void* analog_port_pointer, int32_t deadband, int32_t *status) {
|
||||
AnalogPort* port = (AnalogPort*) analog_port_pointer;
|
||||
if (port->accumulator == NULL) {
|
||||
*status = NULL_PARAMETER;
|
||||
return;
|
||||
}
|
||||
port->accumulator->writeDeadband(deadband, status);
|
||||
}
|
||||
|
||||
/**
|
||||
* Read the accumulated value.
|
||||
*
|
||||
* Read the value that has been accumulating on channel 1.
|
||||
* The accumulator is attached after the oversample and average engine.
|
||||
*
|
||||
* @return The 64-bit value accumulated since the last Reset().
|
||||
*/
|
||||
int64_t getAccumulatorValue(void* analog_port_pointer, int32_t *status) {
|
||||
AnalogPort* port = (AnalogPort*) analog_port_pointer;
|
||||
if (port->accumulator == NULL) {
|
||||
*status = NULL_PARAMETER;
|
||||
return 0;
|
||||
}
|
||||
int64_t value = port->accumulator->readOutput_Value(status);
|
||||
return value;
|
||||
}
|
||||
|
||||
/**
|
||||
* Read the number of accumulated values.
|
||||
*
|
||||
* Read the count of the accumulated values since the accumulator was last Reset().
|
||||
*
|
||||
* @return The number of times samples from the channel were accumulated.
|
||||
*/
|
||||
uint32_t getAccumulatorCount(void* analog_port_pointer, int32_t *status) {
|
||||
AnalogPort* port = (AnalogPort*) analog_port_pointer;
|
||||
if (port->accumulator == NULL) {
|
||||
*status = NULL_PARAMETER;
|
||||
return 0;
|
||||
}
|
||||
return port->accumulator->readOutput_Count(status);
|
||||
}
|
||||
|
||||
/**
|
||||
* Read the accumulated value and the number of accumulated values atomically.
|
||||
*
|
||||
* This function reads the value and count from the FPGA atomically.
|
||||
* This can be used for averaging.
|
||||
*
|
||||
* @param value Pointer to the 64-bit accumulated output.
|
||||
* @param count Pointer to the number of accumulation cycles.
|
||||
*/
|
||||
void getAccumulatorOutput(void* analog_port_pointer, int64_t *value, uint32_t *count, int32_t *status) {
|
||||
printf("[HAL] getAccumulatorOutput()\n");
|
||||
AnalogPort* port = (AnalogPort*) analog_port_pointer;
|
||||
if (port->accumulator == NULL) {
|
||||
*status = NULL_PARAMETER;
|
||||
return;
|
||||
}
|
||||
if (value == NULL || count == NULL) {
|
||||
*status = NULL_PARAMETER;
|
||||
return;
|
||||
}
|
||||
|
||||
printf("[HAL]\t Getting output...\n");
|
||||
tAccumulator::tOutput output = port->accumulator->readOutput(status);
|
||||
|
||||
printf("[HAL]\t Status: %d, Value: %lld, Count: %d.\n", *status, output.Value, output.Count);
|
||||
printf("[HAL]\t value: %d, value2: %d, value3: %d.\n", output.value, output.value2, output.value3);
|
||||
printf("[HAL]\t Value: %lld, Count: %d.\n", port->accumulator->readOutput_Value(status), port->accumulator->readOutput_Count(status));
|
||||
*value = output.Value;
|
||||
*count = output.Count;
|
||||
}
|
||||
|
||||
|
||||
struct trigger_t {
|
||||
tAnalogTrigger* trigger;
|
||||
AnalogPort* port;
|
||||
uint32_t index;
|
||||
};
|
||||
typedef struct trigger_t AnalogTrigger;
|
||||
|
||||
static Resource *triggers = NULL;
|
||||
|
||||
void* initializeAnalogTrigger(void* port_pointer, uint32_t *index, int32_t *status) {
|
||||
Port* port = (Port*) port_pointer;
|
||||
Resource::CreateResourceObject(&triggers, tAnalogTrigger::kNumSystems);
|
||||
|
||||
AnalogTrigger* trigger = new AnalogTrigger();
|
||||
trigger->port = (AnalogPort*) initializeAnalogPort(port, status);
|
||||
trigger->index = triggers->Allocate("Analog Trigger");
|
||||
*index = trigger->index;
|
||||
// TODO: if (index == ~0ul) { CloneError(triggers); return; }
|
||||
|
||||
trigger->trigger = tAnalogTrigger::create(trigger->index, status);
|
||||
trigger->trigger->writeSourceSelect_Channel(port->pin - 1, status);
|
||||
|
||||
return trigger;
|
||||
}
|
||||
|
||||
void cleanAnalogTrigger(void* analog_trigger_pointer, int32_t *status) {
|
||||
AnalogTrigger* trigger = (AnalogTrigger*) analog_trigger_pointer;
|
||||
triggers->Free(trigger->index);
|
||||
delete trigger->trigger;
|
||||
delete trigger;
|
||||
}
|
||||
|
||||
void setAnalogTriggerLimitsRaw(void* analog_trigger_pointer, int32_t lower, int32_t upper, int32_t *status) {
|
||||
AnalogTrigger* trigger = (AnalogTrigger*) analog_trigger_pointer;
|
||||
if (lower > upper) {
|
||||
*status = ANALOG_TRIGGER_LIMIT_ORDER_ERROR;
|
||||
}
|
||||
trigger->trigger->writeLowerLimit(lower, status);
|
||||
trigger->trigger->writeUpperLimit(upper, status);
|
||||
}
|
||||
|
||||
/**
|
||||
* Set the upper and lower limits of the analog trigger.
|
||||
* The limits are given as floating point voltage values.
|
||||
*/
|
||||
void setAnalogTriggerLimitsVoltage(void* analog_trigger_pointer, double lower, double upper, int32_t *status) {
|
||||
AnalogTrigger* trigger = (AnalogTrigger*) analog_trigger_pointer;
|
||||
if (lower > upper) {
|
||||
*status = ANALOG_TRIGGER_LIMIT_ORDER_ERROR;
|
||||
}
|
||||
// TODO: This depends on the averaged setting. Only raw values will work as is.
|
||||
trigger->trigger->writeLowerLimit(getAnalogVoltsToValue(trigger->port, lower, status), status);
|
||||
trigger->trigger->writeUpperLimit(getAnalogVoltsToValue(trigger->port, upper, status), status);
|
||||
}
|
||||
|
||||
/**
|
||||
* Configure the analog trigger to use the averaged vs. raw values.
|
||||
* If the value is true, then the averaged value is selected for the analog trigger, otherwise
|
||||
* the immediate value is used.
|
||||
*/
|
||||
void setAnalogTriggerAveraged(void* analog_trigger_pointer, bool useAveragedValue, int32_t *status) {
|
||||
AnalogTrigger* trigger = (AnalogTrigger*) analog_trigger_pointer;
|
||||
if (trigger->trigger->readSourceSelect_Filter(status) != 0) {
|
||||
*status = INCOMPATIBLE_STATE;
|
||||
// TODO: wpi_setWPIErrorWithContext(IncompatibleMode, "Hardware does not support average and filtering at the same time.");
|
||||
}
|
||||
trigger->trigger->writeSourceSelect_Averaged(useAveragedValue, status);
|
||||
}
|
||||
|
||||
/**
|
||||
* Configure the analog trigger to use a filtered value.
|
||||
* The analog trigger will operate with a 3 point average rejection filter. This is designed to
|
||||
* help with 360 degree pot applications for the period where the pot crosses through zero.
|
||||
*/
|
||||
void setAnalogTriggerFiltered(void* analog_trigger_pointer, bool useFilteredValue, int32_t *status) {
|
||||
AnalogTrigger* trigger = (AnalogTrigger*) analog_trigger_pointer;
|
||||
if (trigger->trigger->readSourceSelect_Averaged(status) != 0) {
|
||||
*status = INCOMPATIBLE_STATE;
|
||||
// TODO: wpi_setWPIErrorWithContext(IncompatibleMode, "Hardware does not support average and filtering at the same time.");
|
||||
}
|
||||
trigger->trigger->writeSourceSelect_Filter(useFilteredValue, status);
|
||||
}
|
||||
|
||||
/**
|
||||
* Return the InWindow output of the analog trigger.
|
||||
* True if the analog input is between the upper and lower limits.
|
||||
* @return The InWindow output of the analog trigger.
|
||||
*/
|
||||
bool getAnalogTriggerInWindow(void* analog_trigger_pointer, int32_t *status) {
|
||||
AnalogTrigger* trigger = (AnalogTrigger*) analog_trigger_pointer;
|
||||
return trigger->trigger->readOutput_InHysteresis(trigger->index, status) != 0;
|
||||
}
|
||||
|
||||
/**
|
||||
* Return the TriggerState output of the analog trigger.
|
||||
* True if above upper limit.
|
||||
* False if below lower limit.
|
||||
* If in Hysteresis, maintain previous state.
|
||||
* @return The TriggerState output of the analog trigger.
|
||||
*/
|
||||
bool getAnalogTriggerTriggerState(void* analog_trigger_pointer, int32_t *status) {
|
||||
AnalogTrigger* trigger = (AnalogTrigger*) analog_trigger_pointer;
|
||||
return trigger->trigger->readOutput_OverLimit(trigger->index, status) != 0;
|
||||
}
|
||||
|
||||
/**
|
||||
* Get the state of the analog trigger output.
|
||||
* @return The state of the analog trigger output.
|
||||
*/
|
||||
bool getAnalogTriggerOutput(void* analog_trigger_pointer, AnalogTriggerType type, int32_t *status) {
|
||||
AnalogTrigger* trigger = (AnalogTrigger*) analog_trigger_pointer;
|
||||
bool result = false;
|
||||
switch(type) {
|
||||
case kInWindow:
|
||||
result = trigger->trigger->readOutput_InHysteresis(trigger->index, status);
|
||||
break; // XXX: Backport
|
||||
case kState:
|
||||
result = trigger->trigger->readOutput_OverLimit(trigger->index, status);
|
||||
break; // XXX: Backport
|
||||
case kRisingPulse:
|
||||
case kFallingPulse:
|
||||
*status = ANALOG_TRIGGER_PULSE_OUTPUT_ERROR;
|
||||
return false;
|
||||
}
|
||||
return result;
|
||||
}
|
||||
|
||||
|
||||
|
||||
//// Float JNA Hack
|
||||
// Float
|
||||
int getAnalogSampleRateIntHack(int32_t *status) {
|
||||
return floatToInt(getAnalogSampleRate(status));
|
||||
}
|
||||
|
||||
int getAnalogSampleRateWithModuleIntHack(uint8_t module, int32_t *status) {
|
||||
return floatToInt(getAnalogSampleRateWithModuleIntHack(module, status));
|
||||
}
|
||||
|
||||
int getAnalogVoltageIntHack(void* analog_port_pointer, int32_t *status) {
|
||||
return floatToInt(getAnalogVoltage(analog_port_pointer, status));
|
||||
}
|
||||
|
||||
int getAnalogAverageVoltageIntHack(void* analog_port_pointer, int32_t *status) {
|
||||
return floatToInt(getAnalogAverageVoltage(analog_port_pointer, status));
|
||||
}
|
||||
|
||||
|
||||
// Doubles
|
||||
void setAnalogSampleRateIntHack(int samplesPerSecond, int32_t *status) {
|
||||
setAnalogSampleRate(intToFloat(samplesPerSecond), status);
|
||||
}
|
||||
|
||||
void setAnalogSampleRateWithModuleIntHack(uint8_t module, int samplesPerSecond, int32_t *status) {
|
||||
setAnalogSampleRateWithModule(module, intToFloat(samplesPerSecond), status);
|
||||
}
|
||||
|
||||
int32_t getAnalogVoltsToValueIntHack(void* analog_port_pointer, int voltage, int32_t *status) {
|
||||
return getAnalogVoltsToValue(analog_port_pointer, intToFloat(voltage), status);
|
||||
}
|
||||
|
||||
void setAnalogTriggerLimitsVoltageIntHack(void* analog_trigger_pointer, int lower, int upper, int32_t *status) {
|
||||
setAnalogTriggerLimitsVoltage(analog_trigger_pointer, intToFloat(lower), intToFloat(upper), status);
|
||||
}
|
||||
36
hal/Athena/src/main/native/ChipObject.h
Normal file
36
hal/Athena/src/main/native/ChipObject.h
Normal file
@@ -0,0 +1,36 @@
|
||||
/*----------------------------------------------------------------------------*/
|
||||
/* Copyright (c) FIRST 2008. All Rights Reserved. */
|
||||
/* Open Source Software - may be modified and shared by FRC teams. The code */
|
||||
/* must be accompanied by the FIRST BSD license file in $(WIND_BASE)/WPILib. */
|
||||
/*----------------------------------------------------------------------------*/
|
||||
|
||||
#ifndef __ChipObject_h__
|
||||
#define __ChipObject_h__
|
||||
|
||||
#include <stdint.h>
|
||||
#include "ChipObject/NiRio.h"
|
||||
#include "ChipObject/RoboRIO_FRC_ChipObject_Aliases.h"
|
||||
#include "ChipObject/FRC_FPGA_ChipObject_Aliases.h"
|
||||
|
||||
#include "ChipObject/tAccel.h"
|
||||
#include "ChipObject/tAccumulator.h"
|
||||
#include "ChipObject/tAI.h"
|
||||
#include "ChipObject/tAlarm.h"
|
||||
#include "ChipObject/tAnalogTrigger.h"
|
||||
#include "ChipObject/tAO.h"
|
||||
#include "ChipObject/tBIST.h"
|
||||
#include "ChipObject/tCounter.h"
|
||||
#include "ChipObject/tDIO.h"
|
||||
#include "ChipObject/tDMA.h"
|
||||
#include "ChipObject/tEncoder.h"
|
||||
#include "ChipObject/tGlobal.h"
|
||||
#include "ChipObject/tInterrupt.h"
|
||||
#include "ChipObject/tInterruptManager.h"
|
||||
#include "ChipObject/tPower.h"
|
||||
#include "ChipObject/tPWM.h"
|
||||
#include "ChipObject/tRelay.h"
|
||||
#include "ChipObject/tWatchdog.h"
|
||||
|
||||
using namespace nFPGA;
|
||||
using namespace nRoboRIO_FPGANamespace;
|
||||
#endif
|
||||
@@ -0,0 +1,10 @@
|
||||
// Copyright (c) National Instruments 2008. All Rights Reserved.
|
||||
// Do Not Edit... this file is generated!
|
||||
|
||||
#ifndef __FRC_FPGA_ChipObject_Aliases_h__
|
||||
#define __FRC_FPGA_ChipObject_Aliases_h__
|
||||
|
||||
#define nInvariantFPGANamespace nFRC_C0EF_1_1_0
|
||||
#define nRuntimeFPGANamespace nFRC_2012_1_6_4
|
||||
|
||||
#endif // __FRC_FPGA_ChipObject_Aliases_h__
|
||||
9
hal/Athena/src/main/native/ChipObject/NiRio.h
Normal file
9
hal/Athena/src/main/native/ChipObject/NiRio.h
Normal file
@@ -0,0 +1,9 @@
|
||||
// Copyright (c) National Instruments 2008. All Rights Reserved.
|
||||
|
||||
#ifndef __NiRio_h__
|
||||
#define __NiRio_h__
|
||||
|
||||
#include "fpgainterfacecapi/NiFpga.h"
|
||||
typedef NiFpga_Status tRioStatusCode;
|
||||
|
||||
#endif // __NiRio_h__
|
||||
@@ -0,0 +1,9 @@
|
||||
// Copyright (c) National Instruments 2008. All Rights Reserved.
|
||||
// Do Not Edit... this file is generated!
|
||||
|
||||
#ifndef __RoboRIO_FRC_ChipObject_Aliases_h__
|
||||
#define __RoboRIO_FRC_ChipObject_Aliases_h__
|
||||
|
||||
#define nRoboRIO_FPGANamespace nFRC_2015_1_0_2
|
||||
|
||||
#endif // __RoboRIO_FRC_ChipObject_Aliases_h__
|
||||
2312
hal/Athena/src/main/native/ChipObject/fpgainterfacecapi/NiFpga.h
Normal file
2312
hal/Athena/src/main/native/ChipObject/fpgainterfacecapi/NiFpga.h
Normal file
File diff suppressed because it is too large
Load Diff
15
hal/Athena/src/main/native/ChipObject/nInterfaceGlobals.h
Normal file
15
hal/Athena/src/main/native/ChipObject/nInterfaceGlobals.h
Normal file
@@ -0,0 +1,15 @@
|
||||
// Copyright (c) National Instruments 2008. All Rights Reserved.
|
||||
// Do Not Edit... this file is generated!
|
||||
|
||||
#ifndef __nFRC_2015_1_0_2_nInterfaceGlobals_h__
|
||||
#define __nFRC_2015_1_0_2_nInterfaceGlobals_h__
|
||||
|
||||
namespace nFPGA
|
||||
{
|
||||
namespace nFRC_2015_1_0_2
|
||||
{
|
||||
extern unsigned int g_currentTargetClass;
|
||||
}
|
||||
}
|
||||
|
||||
#endif // __nFRC_2015_1_0_2_nInterfaceGlobals_h__
|
||||
42
hal/Athena/src/main/native/ChipObject/printFpgaVersion.h
Normal file
42
hal/Athena/src/main/native/ChipObject/printFpgaVersion.h
Normal file
@@ -0,0 +1,42 @@
|
||||
// Copyright (c) National Instruments 2008. All Rights Reserved.
|
||||
|
||||
#ifndef __printFPGAVersion_h__
|
||||
#define __printFPGAVersion_h__
|
||||
|
||||
namespace nFPGA
|
||||
{
|
||||
|
||||
template<typename ttGlobal>
|
||||
inline void printFPGAVersion(ttGlobal &global)
|
||||
{
|
||||
tRioStatusCode cleanStatus=0;
|
||||
uint32_t hardwareGuid[4];
|
||||
tSystemInterface &system = *global.getSystemInterface();
|
||||
system.getHardwareFpgaSignature(hardwareGuid, &cleanStatus);
|
||||
const uint32_t *softwareGuid = system.getExpectedFPGASignature();
|
||||
printf("FPGA Hardware GUID: 0x");
|
||||
for(int i=0; i<4; i++)
|
||||
{
|
||||
printf("%08X", hardwareGuid[i]);
|
||||
}
|
||||
printf("\n");
|
||||
printf("FPGA Software GUID: 0x");
|
||||
for(int i=0; i<4; i++)
|
||||
{
|
||||
printf("%08X", softwareGuid[i]);
|
||||
}
|
||||
printf("\n");
|
||||
uint16_t fpgaHardwareVersion = global.readVersion(&cleanStatus);
|
||||
uint16_t fpgaSoftwareVersion = system.getExpectedFPGAVersion();
|
||||
printf("FPGA Hardware Version: %X\n", fpgaHardwareVersion);
|
||||
printf("FPGA Software Version: %X\n", fpgaSoftwareVersion);
|
||||
uint32_t fpgaHardwareRevision = global.readRevision(&cleanStatus);
|
||||
uint32_t fpgaSoftwareRevision = system.getExpectedFPGARevision();
|
||||
printf("FPGA Hardware Revision: %X.%X.%X\n", (fpgaHardwareRevision >> 20) & 0xFFF, (fpgaHardwareRevision >> 12) & 0xFF, fpgaHardwareRevision & 0xFFF);
|
||||
printf("FPGA Software Revision: %X.%X.%X\n", (fpgaSoftwareRevision >> 20) & 0xFFF, (fpgaSoftwareRevision >> 12) & 0xFF, fpgaSoftwareRevision & 0xFFF);
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
#endif // __printFPGAVersion_h__
|
||||
|
||||
143
hal/Athena/src/main/native/ChipObject/tAI.h
Normal file
143
hal/Athena/src/main/native/ChipObject/tAI.h
Normal file
@@ -0,0 +1,143 @@
|
||||
// Copyright (c) National Instruments 2008. All Rights Reserved.
|
||||
// Do Not Edit... this file is generated!
|
||||
|
||||
#ifndef __nFRC_2015_1_0_2_AI_h__
|
||||
#define __nFRC_2015_1_0_2_AI_h__
|
||||
|
||||
#include "tSystemInterface.h"
|
||||
|
||||
namespace nFPGA
|
||||
{
|
||||
namespace nFRC_2015_1_0_2
|
||||
{
|
||||
|
||||
class tAI
|
||||
{
|
||||
public:
|
||||
tAI(){}
|
||||
virtual ~tAI(){}
|
||||
|
||||
virtual tSystemInterface* getSystemInterface() = 0;
|
||||
static tAI* create(tRioStatusCode *status);
|
||||
|
||||
typedef enum
|
||||
{
|
||||
kNumSystems = 1,
|
||||
} tIfaceConstants;
|
||||
|
||||
typedef
|
||||
union{
|
||||
struct{
|
||||
#ifdef __vxworks
|
||||
unsigned ScanSize : 3;
|
||||
unsigned ConvertRate : 26;
|
||||
#else
|
||||
unsigned ConvertRate : 26;
|
||||
unsigned ScanSize : 3;
|
||||
#endif
|
||||
};
|
||||
struct{
|
||||
unsigned value : 29;
|
||||
};
|
||||
} tConfig;
|
||||
typedef
|
||||
union{
|
||||
struct{
|
||||
#ifdef __vxworks
|
||||
unsigned Channel : 3;
|
||||
unsigned Averaged : 1;
|
||||
#else
|
||||
unsigned Averaged : 1;
|
||||
unsigned Channel : 3;
|
||||
#endif
|
||||
};
|
||||
struct{
|
||||
unsigned value : 4;
|
||||
};
|
||||
} tReadSelect;
|
||||
|
||||
|
||||
|
||||
typedef enum
|
||||
{
|
||||
} tOutput_IfaceConstants;
|
||||
|
||||
virtual signed int readOutput(tRioStatusCode *status) = 0;
|
||||
|
||||
|
||||
typedef enum
|
||||
{
|
||||
} tConfig_IfaceConstants;
|
||||
|
||||
virtual void writeConfig(tConfig value, tRioStatusCode *status) = 0;
|
||||
virtual void writeConfig_ScanSize(unsigned char value, tRioStatusCode *status) = 0;
|
||||
virtual void writeConfig_ConvertRate(unsigned int value, tRioStatusCode *status) = 0;
|
||||
virtual tConfig readConfig(tRioStatusCode *status) = 0;
|
||||
virtual unsigned char readConfig_ScanSize(tRioStatusCode *status) = 0;
|
||||
virtual unsigned int readConfig_ConvertRate(tRioStatusCode *status) = 0;
|
||||
|
||||
|
||||
typedef enum
|
||||
{
|
||||
} tLoopTiming_IfaceConstants;
|
||||
|
||||
virtual unsigned int readLoopTiming(tRioStatusCode *status) = 0;
|
||||
|
||||
|
||||
typedef enum
|
||||
{
|
||||
kNumOversampleBitsElements = 8,
|
||||
} tOversampleBits_IfaceConstants;
|
||||
|
||||
virtual void writeOversampleBits(unsigned char bitfield_index, unsigned char value, tRioStatusCode *status) = 0;
|
||||
virtual unsigned char readOversampleBits(unsigned char bitfield_index, tRioStatusCode *status) = 0;
|
||||
|
||||
|
||||
typedef enum
|
||||
{
|
||||
kNumAverageBitsElements = 8,
|
||||
} tAverageBits_IfaceConstants;
|
||||
|
||||
virtual void writeAverageBits(unsigned char bitfield_index, unsigned char value, tRioStatusCode *status) = 0;
|
||||
virtual unsigned char readAverageBits(unsigned char bitfield_index, tRioStatusCode *status) = 0;
|
||||
|
||||
|
||||
typedef enum
|
||||
{
|
||||
kNumScanListElements = 8,
|
||||
} tScanList_IfaceConstants;
|
||||
|
||||
virtual void writeScanList(unsigned char bitfield_index, unsigned char value, tRioStatusCode *status) = 0;
|
||||
virtual unsigned char readScanList(unsigned char bitfield_index, tRioStatusCode *status) = 0;
|
||||
|
||||
|
||||
typedef enum
|
||||
{
|
||||
} tLatchOutput_IfaceConstants;
|
||||
|
||||
virtual void strobeLatchOutput(tRioStatusCode *status) = 0;
|
||||
|
||||
|
||||
typedef enum
|
||||
{
|
||||
} tReadSelect_IfaceConstants;
|
||||
|
||||
virtual void writeReadSelect(tReadSelect value, tRioStatusCode *status) = 0;
|
||||
virtual void writeReadSelect_Channel(unsigned char value, tRioStatusCode *status) = 0;
|
||||
virtual void writeReadSelect_Averaged(bool value, tRioStatusCode *status) = 0;
|
||||
virtual tReadSelect readReadSelect(tRioStatusCode *status) = 0;
|
||||
virtual unsigned char readReadSelect_Channel(tRioStatusCode *status) = 0;
|
||||
virtual bool readReadSelect_Averaged(tRioStatusCode *status) = 0;
|
||||
|
||||
|
||||
|
||||
|
||||
private:
|
||||
tAI(const tAI&);
|
||||
void operator=(const tAI&);
|
||||
};
|
||||
|
||||
}
|
||||
}
|
||||
|
||||
#endif // __nFRC_2015_1_0_2_AI_h__
|
||||
59
hal/Athena/src/main/native/ChipObject/tAO.h
Normal file
59
hal/Athena/src/main/native/ChipObject/tAO.h
Normal file
@@ -0,0 +1,59 @@
|
||||
// Copyright (c) National Instruments 2008. All Rights Reserved.
|
||||
// Do Not Edit... this file is generated!
|
||||
|
||||
#ifndef __nFRC_2015_1_0_2_AO_h__
|
||||
#define __nFRC_2015_1_0_2_AO_h__
|
||||
|
||||
#include "tSystemInterface.h"
|
||||
|
||||
namespace nFPGA
|
||||
{
|
||||
namespace nFRC_2015_1_0_2
|
||||
{
|
||||
|
||||
class tAO
|
||||
{
|
||||
public:
|
||||
tAO(){}
|
||||
virtual ~tAO(){}
|
||||
|
||||
virtual tSystemInterface* getSystemInterface() = 0;
|
||||
static tAO* create(tRioStatusCode *status);
|
||||
|
||||
typedef enum
|
||||
{
|
||||
kNumSystems = 1,
|
||||
} tIfaceConstants;
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
typedef enum
|
||||
{
|
||||
kNumMXPRegisters = 2,
|
||||
} tMXP_IfaceConstants;
|
||||
|
||||
virtual void writeMXP(unsigned char reg_index, unsigned short value, tRioStatusCode *status) = 0;
|
||||
virtual unsigned short readMXP(unsigned char reg_index, tRioStatusCode *status) = 0;
|
||||
|
||||
|
||||
typedef enum
|
||||
{
|
||||
kNumValueRegisters = 2,
|
||||
} tValue_IfaceConstants;
|
||||
|
||||
virtual void writeValue(unsigned char reg_index, unsigned short value, tRioStatusCode *status) = 0;
|
||||
virtual unsigned short readValue(unsigned char reg_index, tRioStatusCode *status) = 0;
|
||||
|
||||
|
||||
private:
|
||||
tAO(const tAO&);
|
||||
void operator=(const tAO&);
|
||||
};
|
||||
|
||||
}
|
||||
}
|
||||
|
||||
#endif // __nFRC_2015_1_0_2_AO_h__
|
||||
62
hal/Athena/src/main/native/ChipObject/tAccel.h
Normal file
62
hal/Athena/src/main/native/ChipObject/tAccel.h
Normal file
@@ -0,0 +1,62 @@
|
||||
// Copyright (c) National Instruments 2008. All Rights Reserved.
|
||||
// Do Not Edit... this file is generated!
|
||||
|
||||
#ifndef __nFRC_2015_1_0_2_Accel_h__
|
||||
#define __nFRC_2015_1_0_2_Accel_h__
|
||||
|
||||
#include "tSystemInterface.h"
|
||||
|
||||
namespace nFPGA
|
||||
{
|
||||
namespace nFRC_2015_1_0_2
|
||||
{
|
||||
|
||||
class tAccel
|
||||
{
|
||||
public:
|
||||
tAccel(){}
|
||||
virtual ~tAccel(){}
|
||||
|
||||
virtual tSystemInterface* getSystemInterface() = 0;
|
||||
static tAccel* create(tRioStatusCode *status);
|
||||
|
||||
typedef enum
|
||||
{
|
||||
kNumSystems = 1,
|
||||
} tIfaceConstants;
|
||||
|
||||
|
||||
|
||||
|
||||
typedef enum
|
||||
{
|
||||
} tX_IfaceConstants;
|
||||
|
||||
virtual signed short readX(tRioStatusCode *status) = 0;
|
||||
|
||||
|
||||
typedef enum
|
||||
{
|
||||
} tY_IfaceConstants;
|
||||
|
||||
virtual signed short readY(tRioStatusCode *status) = 0;
|
||||
|
||||
|
||||
typedef enum
|
||||
{
|
||||
} tZ_IfaceConstants;
|
||||
|
||||
virtual signed short readZ(tRioStatusCode *status) = 0;
|
||||
|
||||
|
||||
|
||||
|
||||
private:
|
||||
tAccel(const tAccel&);
|
||||
void operator=(const tAccel&);
|
||||
};
|
||||
|
||||
}
|
||||
}
|
||||
|
||||
#endif // __nFRC_2015_1_0_2_Accel_h__
|
||||
87
hal/Athena/src/main/native/ChipObject/tAccumulator.h
Normal file
87
hal/Athena/src/main/native/ChipObject/tAccumulator.h
Normal file
@@ -0,0 +1,87 @@
|
||||
// Copyright (c) National Instruments 2008. All Rights Reserved.
|
||||
// Do Not Edit... this file is generated!
|
||||
|
||||
#ifndef __nFRC_2015_1_0_2_Accumulator_h__
|
||||
#define __nFRC_2015_1_0_2_Accumulator_h__
|
||||
|
||||
#include "tSystemInterface.h"
|
||||
|
||||
namespace nFPGA
|
||||
{
|
||||
namespace nFRC_2015_1_0_2
|
||||
{
|
||||
|
||||
class tAccumulator
|
||||
{
|
||||
public:
|
||||
tAccumulator(){}
|
||||
virtual ~tAccumulator(){}
|
||||
|
||||
virtual tSystemInterface* getSystemInterface() = 0;
|
||||
static tAccumulator* create(unsigned char sys_index, tRioStatusCode *status);
|
||||
virtual unsigned char getSystemIndex() = 0;
|
||||
|
||||
|
||||
typedef enum
|
||||
{
|
||||
kNumSystems = 2,
|
||||
} tIfaceConstants;
|
||||
|
||||
typedef
|
||||
union{
|
||||
struct{
|
||||
signed long long Value;
|
||||
unsigned Count : 32;
|
||||
};
|
||||
struct{
|
||||
unsigned value : 32;
|
||||
unsigned value2 : 32;
|
||||
unsigned value3 : 32;
|
||||
};
|
||||
} tOutput;
|
||||
|
||||
|
||||
typedef enum
|
||||
{
|
||||
} tOutput_IfaceConstants;
|
||||
|
||||
virtual tOutput readOutput(tRioStatusCode *status) = 0;
|
||||
virtual signed long long readOutput_Value(tRioStatusCode *status) = 0;
|
||||
virtual unsigned int readOutput_Count(tRioStatusCode *status) = 0;
|
||||
|
||||
|
||||
typedef enum
|
||||
{
|
||||
} tCenter_IfaceConstants;
|
||||
|
||||
virtual void writeCenter(signed int value, tRioStatusCode *status) = 0;
|
||||
virtual signed int readCenter(tRioStatusCode *status) = 0;
|
||||
|
||||
|
||||
typedef enum
|
||||
{
|
||||
} tDeadband_IfaceConstants;
|
||||
|
||||
virtual void writeDeadband(signed int value, tRioStatusCode *status) = 0;
|
||||
virtual signed int readDeadband(tRioStatusCode *status) = 0;
|
||||
|
||||
|
||||
typedef enum
|
||||
{
|
||||
} tReset_IfaceConstants;
|
||||
|
||||
virtual void strobeReset(tRioStatusCode *status) = 0;
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
private:
|
||||
tAccumulator(const tAccumulator&);
|
||||
void operator=(const tAccumulator&);
|
||||
};
|
||||
|
||||
}
|
||||
}
|
||||
|
||||
#endif // __nFRC_2015_1_0_2_Accumulator_h__
|
||||
57
hal/Athena/src/main/native/ChipObject/tAlarm.h
Normal file
57
hal/Athena/src/main/native/ChipObject/tAlarm.h
Normal file
@@ -0,0 +1,57 @@
|
||||
// Copyright (c) National Instruments 2008. All Rights Reserved.
|
||||
// Do Not Edit... this file is generated!
|
||||
|
||||
#ifndef __nFRC_2015_1_0_2_Alarm_h__
|
||||
#define __nFRC_2015_1_0_2_Alarm_h__
|
||||
|
||||
#include "tSystemInterface.h"
|
||||
|
||||
namespace nFPGA
|
||||
{
|
||||
namespace nFRC_2015_1_0_2
|
||||
{
|
||||
|
||||
class tAlarm
|
||||
{
|
||||
public:
|
||||
tAlarm(){}
|
||||
virtual ~tAlarm(){}
|
||||
|
||||
virtual tSystemInterface* getSystemInterface() = 0;
|
||||
static tAlarm* create(tRioStatusCode *status);
|
||||
|
||||
typedef enum
|
||||
{
|
||||
kNumSystems = 1,
|
||||
} tIfaceConstants;
|
||||
|
||||
|
||||
|
||||
|
||||
typedef enum
|
||||
{
|
||||
} tEnable_IfaceConstants;
|
||||
|
||||
virtual void writeEnable(bool value, tRioStatusCode *status) = 0;
|
||||
virtual bool readEnable(tRioStatusCode *status) = 0;
|
||||
|
||||
|
||||
typedef enum
|
||||
{
|
||||
} tTriggerTime_IfaceConstants;
|
||||
|
||||
virtual void writeTriggerTime(unsigned int value, tRioStatusCode *status) = 0;
|
||||
virtual unsigned int readTriggerTime(tRioStatusCode *status) = 0;
|
||||
|
||||
|
||||
|
||||
|
||||
private:
|
||||
tAlarm(const tAlarm&);
|
||||
void operator=(const tAlarm&);
|
||||
};
|
||||
|
||||
}
|
||||
}
|
||||
|
||||
#endif // __nFRC_2015_1_0_2_Alarm_h__
|
||||
129
hal/Athena/src/main/native/ChipObject/tAnalogTrigger.h
Normal file
129
hal/Athena/src/main/native/ChipObject/tAnalogTrigger.h
Normal file
@@ -0,0 +1,129 @@
|
||||
// Copyright (c) National Instruments 2008. All Rights Reserved.
|
||||
// Do Not Edit... this file is generated!
|
||||
|
||||
#ifndef __nFRC_2015_1_0_2_AnalogTrigger_h__
|
||||
#define __nFRC_2015_1_0_2_AnalogTrigger_h__
|
||||
|
||||
#include "tSystemInterface.h"
|
||||
|
||||
namespace nFPGA
|
||||
{
|
||||
namespace nFRC_2015_1_0_2
|
||||
{
|
||||
|
||||
class tAnalogTrigger
|
||||
{
|
||||
public:
|
||||
tAnalogTrigger(){}
|
||||
virtual ~tAnalogTrigger(){}
|
||||
|
||||
virtual tSystemInterface* getSystemInterface() = 0;
|
||||
static tAnalogTrigger* create(unsigned char sys_index, tRioStatusCode *status);
|
||||
virtual unsigned char getSystemIndex() = 0;
|
||||
|
||||
|
||||
typedef enum
|
||||
{
|
||||
kNumSystems = 8,
|
||||
} tIfaceConstants;
|
||||
|
||||
typedef
|
||||
union{
|
||||
struct{
|
||||
#ifdef __vxworks
|
||||
unsigned InHysteresis : 1;
|
||||
unsigned OverLimit : 1;
|
||||
unsigned Rising : 1;
|
||||
unsigned Falling : 1;
|
||||
#else
|
||||
unsigned Falling : 1;
|
||||
unsigned Rising : 1;
|
||||
unsigned OverLimit : 1;
|
||||
unsigned InHysteresis : 1;
|
||||
#endif
|
||||
};
|
||||
struct{
|
||||
unsigned value : 4;
|
||||
};
|
||||
} tOutput;
|
||||
typedef
|
||||
union{
|
||||
struct{
|
||||
#ifdef __vxworks
|
||||
unsigned Channel : 3;
|
||||
unsigned Averaged : 1;
|
||||
unsigned Filter : 1;
|
||||
unsigned FloatingRollover : 1;
|
||||
signed RolloverLimit : 8;
|
||||
#else
|
||||
signed RolloverLimit : 8;
|
||||
unsigned FloatingRollover : 1;
|
||||
unsigned Filter : 1;
|
||||
unsigned Averaged : 1;
|
||||
unsigned Channel : 3;
|
||||
#endif
|
||||
};
|
||||
struct{
|
||||
unsigned value : 14;
|
||||
};
|
||||
} tSourceSelect;
|
||||
|
||||
|
||||
typedef enum
|
||||
{
|
||||
} tSourceSelect_IfaceConstants;
|
||||
|
||||
virtual void writeSourceSelect(tSourceSelect value, tRioStatusCode *status) = 0;
|
||||
virtual void writeSourceSelect_Channel(unsigned char value, tRioStatusCode *status) = 0;
|
||||
virtual void writeSourceSelect_Averaged(bool value, tRioStatusCode *status) = 0;
|
||||
virtual void writeSourceSelect_Filter(bool value, tRioStatusCode *status) = 0;
|
||||
virtual void writeSourceSelect_FloatingRollover(bool value, tRioStatusCode *status) = 0;
|
||||
virtual void writeSourceSelect_RolloverLimit(signed short value, tRioStatusCode *status) = 0;
|
||||
virtual tSourceSelect readSourceSelect(tRioStatusCode *status) = 0;
|
||||
virtual unsigned char readSourceSelect_Channel(tRioStatusCode *status) = 0;
|
||||
virtual bool readSourceSelect_Averaged(tRioStatusCode *status) = 0;
|
||||
virtual bool readSourceSelect_Filter(tRioStatusCode *status) = 0;
|
||||
virtual bool readSourceSelect_FloatingRollover(tRioStatusCode *status) = 0;
|
||||
virtual signed short readSourceSelect_RolloverLimit(tRioStatusCode *status) = 0;
|
||||
|
||||
|
||||
typedef enum
|
||||
{
|
||||
} tUpperLimit_IfaceConstants;
|
||||
|
||||
virtual void writeUpperLimit(signed int value, tRioStatusCode *status) = 0;
|
||||
virtual signed int readUpperLimit(tRioStatusCode *status) = 0;
|
||||
|
||||
|
||||
typedef enum
|
||||
{
|
||||
} tLowerLimit_IfaceConstants;
|
||||
|
||||
virtual void writeLowerLimit(signed int value, tRioStatusCode *status) = 0;
|
||||
virtual signed int readLowerLimit(tRioStatusCode *status) = 0;
|
||||
|
||||
|
||||
|
||||
typedef enum
|
||||
{
|
||||
kNumOutputElements = 8,
|
||||
} tOutput_IfaceConstants;
|
||||
|
||||
virtual tOutput readOutput(unsigned char bitfield_index, tRioStatusCode *status) = 0;
|
||||
virtual bool readOutput_InHysteresis(unsigned char bitfield_index, tRioStatusCode *status) = 0;
|
||||
virtual bool readOutput_OverLimit(unsigned char bitfield_index, tRioStatusCode *status) = 0;
|
||||
virtual bool readOutput_Rising(unsigned char bitfield_index, tRioStatusCode *status) = 0;
|
||||
virtual bool readOutput_Falling(unsigned char bitfield_index, tRioStatusCode *status) = 0;
|
||||
|
||||
|
||||
|
||||
|
||||
private:
|
||||
tAnalogTrigger(const tAnalogTrigger&);
|
||||
void operator=(const tAnalogTrigger&);
|
||||
};
|
||||
|
||||
}
|
||||
}
|
||||
|
||||
#endif // __nFRC_2015_1_0_2_AnalogTrigger_h__
|
||||
90
hal/Athena/src/main/native/ChipObject/tBIST.h
Normal file
90
hal/Athena/src/main/native/ChipObject/tBIST.h
Normal file
@@ -0,0 +1,90 @@
|
||||
// Copyright (c) National Instruments 2008. All Rights Reserved.
|
||||
// Do Not Edit... this file is generated!
|
||||
|
||||
#ifndef __nFRC_2015_1_0_2_BIST_h__
|
||||
#define __nFRC_2015_1_0_2_BIST_h__
|
||||
|
||||
#include "tSystemInterface.h"
|
||||
|
||||
namespace nFPGA
|
||||
{
|
||||
namespace nFRC_2015_1_0_2
|
||||
{
|
||||
|
||||
class tBIST
|
||||
{
|
||||
public:
|
||||
tBIST(){}
|
||||
virtual ~tBIST(){}
|
||||
|
||||
virtual tSystemInterface* getSystemInterface() = 0;
|
||||
static tBIST* create(tRioStatusCode *status);
|
||||
|
||||
typedef enum
|
||||
{
|
||||
kNumSystems = 1,
|
||||
} tIfaceConstants;
|
||||
|
||||
|
||||
|
||||
|
||||
typedef enum
|
||||
{
|
||||
} tDO0SquareTicks_IfaceConstants;
|
||||
|
||||
virtual void writeDO0SquareTicks(unsigned int value, tRioStatusCode *status) = 0;
|
||||
virtual unsigned int readDO0SquareTicks(tRioStatusCode *status) = 0;
|
||||
|
||||
|
||||
typedef enum
|
||||
{
|
||||
} tEnable_IfaceConstants;
|
||||
|
||||
virtual void writeEnable(bool value, tRioStatusCode *status) = 0;
|
||||
virtual bool readEnable(tRioStatusCode *status) = 0;
|
||||
|
||||
|
||||
typedef enum
|
||||
{
|
||||
} tDO1SquareEnable_IfaceConstants;
|
||||
|
||||
virtual void writeDO1SquareEnable(bool value, tRioStatusCode *status) = 0;
|
||||
virtual bool readDO1SquareEnable(tRioStatusCode *status) = 0;
|
||||
|
||||
|
||||
typedef enum
|
||||
{
|
||||
} tDO0SquareEnable_IfaceConstants;
|
||||
|
||||
virtual void writeDO0SquareEnable(bool value, tRioStatusCode *status) = 0;
|
||||
virtual bool readDO0SquareEnable(tRioStatusCode *status) = 0;
|
||||
|
||||
|
||||
typedef enum
|
||||
{
|
||||
} tDO1SquareTicks_IfaceConstants;
|
||||
|
||||
virtual void writeDO1SquareTicks(unsigned int value, tRioStatusCode *status) = 0;
|
||||
virtual unsigned int readDO1SquareTicks(tRioStatusCode *status) = 0;
|
||||
|
||||
|
||||
|
||||
|
||||
typedef enum
|
||||
{
|
||||
kNumDORegisters = 2,
|
||||
} tDO_IfaceConstants;
|
||||
|
||||
virtual void writeDO(unsigned char reg_index, bool value, tRioStatusCode *status) = 0;
|
||||
virtual bool readDO(unsigned char reg_index, tRioStatusCode *status) = 0;
|
||||
|
||||
|
||||
private:
|
||||
tBIST(const tBIST&);
|
||||
void operator=(const tBIST&);
|
||||
};
|
||||
|
||||
}
|
||||
}
|
||||
|
||||
#endif // __nFRC_2015_1_0_2_BIST_h__
|
||||
219
hal/Athena/src/main/native/ChipObject/tCounter.h
Normal file
219
hal/Athena/src/main/native/ChipObject/tCounter.h
Normal file
@@ -0,0 +1,219 @@
|
||||
// Copyright (c) National Instruments 2008. All Rights Reserved.
|
||||
// Do Not Edit... this file is generated!
|
||||
|
||||
#ifndef __nFRC_2015_1_0_2_Counter_h__
|
||||
#define __nFRC_2015_1_0_2_Counter_h__
|
||||
|
||||
#include "tSystemInterface.h"
|
||||
|
||||
namespace nFPGA
|
||||
{
|
||||
namespace nFRC_2015_1_0_2
|
||||
{
|
||||
|
||||
class tCounter
|
||||
{
|
||||
public:
|
||||
tCounter(){}
|
||||
virtual ~tCounter(){}
|
||||
|
||||
virtual tSystemInterface* getSystemInterface() = 0;
|
||||
static tCounter* create(unsigned char sys_index, tRioStatusCode *status);
|
||||
virtual unsigned char getSystemIndex() = 0;
|
||||
|
||||
|
||||
typedef enum
|
||||
{
|
||||
kNumSystems = 8,
|
||||
} tIfaceConstants;
|
||||
|
||||
typedef
|
||||
union{
|
||||
struct{
|
||||
#ifdef __vxworks
|
||||
unsigned Direction : 1;
|
||||
signed Value : 31;
|
||||
#else
|
||||
signed Value : 31;
|
||||
unsigned Direction : 1;
|
||||
#endif
|
||||
};
|
||||
struct{
|
||||
unsigned value : 32;
|
||||
};
|
||||
} tOutput;
|
||||
typedef
|
||||
union{
|
||||
struct{
|
||||
#ifdef __vxworks
|
||||
unsigned UpSource_Channel : 4;
|
||||
unsigned UpSource_Module : 1;
|
||||
unsigned UpSource_AnalogTrigger : 1;
|
||||
unsigned DownSource_Channel : 4;
|
||||
unsigned DownSource_Module : 1;
|
||||
unsigned DownSource_AnalogTrigger : 1;
|
||||
unsigned IndexSource_Channel : 4;
|
||||
unsigned IndexSource_Module : 1;
|
||||
unsigned IndexSource_AnalogTrigger : 1;
|
||||
unsigned IndexActiveHigh : 1;
|
||||
unsigned UpRisingEdge : 1;
|
||||
unsigned UpFallingEdge : 1;
|
||||
unsigned DownRisingEdge : 1;
|
||||
unsigned DownFallingEdge : 1;
|
||||
unsigned Mode : 2;
|
||||
unsigned PulseLengthThreshold : 6;
|
||||
unsigned Enable : 1;
|
||||
#else
|
||||
unsigned Enable : 1;
|
||||
unsigned PulseLengthThreshold : 6;
|
||||
unsigned Mode : 2;
|
||||
unsigned DownFallingEdge : 1;
|
||||
unsigned DownRisingEdge : 1;
|
||||
unsigned UpFallingEdge : 1;
|
||||
unsigned UpRisingEdge : 1;
|
||||
unsigned IndexActiveHigh : 1;
|
||||
unsigned IndexSource_AnalogTrigger : 1;
|
||||
unsigned IndexSource_Module : 1;
|
||||
unsigned IndexSource_Channel : 4;
|
||||
unsigned DownSource_AnalogTrigger : 1;
|
||||
unsigned DownSource_Module : 1;
|
||||
unsigned DownSource_Channel : 4;
|
||||
unsigned UpSource_AnalogTrigger : 1;
|
||||
unsigned UpSource_Module : 1;
|
||||
unsigned UpSource_Channel : 4;
|
||||
#endif
|
||||
};
|
||||
struct{
|
||||
unsigned value : 32;
|
||||
};
|
||||
} tConfig;
|
||||
typedef
|
||||
union{
|
||||
struct{
|
||||
#ifdef __vxworks
|
||||
unsigned Period : 23;
|
||||
signed Count : 8;
|
||||
unsigned Stalled : 1;
|
||||
#else
|
||||
unsigned Stalled : 1;
|
||||
signed Count : 8;
|
||||
unsigned Period : 23;
|
||||
#endif
|
||||
};
|
||||
struct{
|
||||
unsigned value : 32;
|
||||
};
|
||||
} tTimerOutput;
|
||||
typedef
|
||||
union{
|
||||
struct{
|
||||
#ifdef __vxworks
|
||||
unsigned StallPeriod : 24;
|
||||
unsigned AverageSize : 7;
|
||||
unsigned UpdateWhenEmpty : 1;
|
||||
#else
|
||||
unsigned UpdateWhenEmpty : 1;
|
||||
unsigned AverageSize : 7;
|
||||
unsigned StallPeriod : 24;
|
||||
#endif
|
||||
};
|
||||
struct{
|
||||
unsigned value : 32;
|
||||
};
|
||||
} tTimerConfig;
|
||||
|
||||
|
||||
typedef enum
|
||||
{
|
||||
} tOutput_IfaceConstants;
|
||||
|
||||
virtual tOutput readOutput(tRioStatusCode *status) = 0;
|
||||
virtual bool readOutput_Direction(tRioStatusCode *status) = 0;
|
||||
virtual signed int readOutput_Value(tRioStatusCode *status) = 0;
|
||||
|
||||
|
||||
typedef enum
|
||||
{
|
||||
} tConfig_IfaceConstants;
|
||||
|
||||
virtual void writeConfig(tConfig value, tRioStatusCode *status) = 0;
|
||||
virtual void writeConfig_UpSource_Channel(unsigned char value, tRioStatusCode *status) = 0;
|
||||
virtual void writeConfig_UpSource_Module(unsigned char value, tRioStatusCode *status) = 0;
|
||||
virtual void writeConfig_UpSource_AnalogTrigger(bool value, tRioStatusCode *status) = 0;
|
||||
virtual void writeConfig_DownSource_Channel(unsigned char value, tRioStatusCode *status) = 0;
|
||||
virtual void writeConfig_DownSource_Module(unsigned char value, tRioStatusCode *status) = 0;
|
||||
virtual void writeConfig_DownSource_AnalogTrigger(bool value, tRioStatusCode *status) = 0;
|
||||
virtual void writeConfig_IndexSource_Channel(unsigned char value, tRioStatusCode *status) = 0;
|
||||
virtual void writeConfig_IndexSource_Module(unsigned char value, tRioStatusCode *status) = 0;
|
||||
virtual void writeConfig_IndexSource_AnalogTrigger(bool value, tRioStatusCode *status) = 0;
|
||||
virtual void writeConfig_IndexActiveHigh(bool value, tRioStatusCode *status) = 0;
|
||||
virtual void writeConfig_UpRisingEdge(bool value, tRioStatusCode *status) = 0;
|
||||
virtual void writeConfig_UpFallingEdge(bool value, tRioStatusCode *status) = 0;
|
||||
virtual void writeConfig_DownRisingEdge(bool value, tRioStatusCode *status) = 0;
|
||||
virtual void writeConfig_DownFallingEdge(bool value, tRioStatusCode *status) = 0;
|
||||
virtual void writeConfig_Mode(unsigned char value, tRioStatusCode *status) = 0;
|
||||
virtual void writeConfig_PulseLengthThreshold(unsigned short value, tRioStatusCode *status) = 0;
|
||||
virtual void writeConfig_Enable(bool value, tRioStatusCode *status) = 0;
|
||||
virtual tConfig readConfig(tRioStatusCode *status) = 0;
|
||||
virtual unsigned char readConfig_UpSource_Channel(tRioStatusCode *status) = 0;
|
||||
virtual unsigned char readConfig_UpSource_Module(tRioStatusCode *status) = 0;
|
||||
virtual bool readConfig_UpSource_AnalogTrigger(tRioStatusCode *status) = 0;
|
||||
virtual unsigned char readConfig_DownSource_Channel(tRioStatusCode *status) = 0;
|
||||
virtual unsigned char readConfig_DownSource_Module(tRioStatusCode *status) = 0;
|
||||
virtual bool readConfig_DownSource_AnalogTrigger(tRioStatusCode *status) = 0;
|
||||
virtual unsigned char readConfig_IndexSource_Channel(tRioStatusCode *status) = 0;
|
||||
virtual unsigned char readConfig_IndexSource_Module(tRioStatusCode *status) = 0;
|
||||
virtual bool readConfig_IndexSource_AnalogTrigger(tRioStatusCode *status) = 0;
|
||||
virtual bool readConfig_IndexActiveHigh(tRioStatusCode *status) = 0;
|
||||
virtual bool readConfig_UpRisingEdge(tRioStatusCode *status) = 0;
|
||||
virtual bool readConfig_UpFallingEdge(tRioStatusCode *status) = 0;
|
||||
virtual bool readConfig_DownRisingEdge(tRioStatusCode *status) = 0;
|
||||
virtual bool readConfig_DownFallingEdge(tRioStatusCode *status) = 0;
|
||||
virtual unsigned char readConfig_Mode(tRioStatusCode *status) = 0;
|
||||
virtual unsigned short readConfig_PulseLengthThreshold(tRioStatusCode *status) = 0;
|
||||
virtual bool readConfig_Enable(tRioStatusCode *status) = 0;
|
||||
|
||||
|
||||
typedef enum
|
||||
{
|
||||
} tTimerOutput_IfaceConstants;
|
||||
|
||||
virtual tTimerOutput readTimerOutput(tRioStatusCode *status) = 0;
|
||||
virtual unsigned int readTimerOutput_Period(tRioStatusCode *status) = 0;
|
||||
virtual signed char readTimerOutput_Count(tRioStatusCode *status) = 0;
|
||||
virtual bool readTimerOutput_Stalled(tRioStatusCode *status) = 0;
|
||||
|
||||
|
||||
typedef enum
|
||||
{
|
||||
} tReset_IfaceConstants;
|
||||
|
||||
virtual void strobeReset(tRioStatusCode *status) = 0;
|
||||
|
||||
|
||||
typedef enum
|
||||
{
|
||||
} tTimerConfig_IfaceConstants;
|
||||
|
||||
virtual void writeTimerConfig(tTimerConfig value, tRioStatusCode *status) = 0;
|
||||
virtual void writeTimerConfig_StallPeriod(unsigned int value, tRioStatusCode *status) = 0;
|
||||
virtual void writeTimerConfig_AverageSize(unsigned char value, tRioStatusCode *status) = 0;
|
||||
virtual void writeTimerConfig_UpdateWhenEmpty(bool value, tRioStatusCode *status) = 0;
|
||||
virtual tTimerConfig readTimerConfig(tRioStatusCode *status) = 0;
|
||||
virtual unsigned int readTimerConfig_StallPeriod(tRioStatusCode *status) = 0;
|
||||
virtual unsigned char readTimerConfig_AverageSize(tRioStatusCode *status) = 0;
|
||||
virtual bool readTimerConfig_UpdateWhenEmpty(tRioStatusCode *status) = 0;
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
private:
|
||||
tCounter(const tCounter&);
|
||||
void operator=(const tCounter&);
|
||||
};
|
||||
|
||||
}
|
||||
}
|
||||
|
||||
#endif // __nFRC_2015_1_0_2_Counter_h__
|
||||
261
hal/Athena/src/main/native/ChipObject/tDIO.h
Normal file
261
hal/Athena/src/main/native/ChipObject/tDIO.h
Normal file
@@ -0,0 +1,261 @@
|
||||
// Copyright (c) National Instruments 2008. All Rights Reserved.
|
||||
// Do Not Edit... this file is generated!
|
||||
|
||||
#ifndef __nFRC_2015_1_0_2_DIO_h__
|
||||
#define __nFRC_2015_1_0_2_DIO_h__
|
||||
|
||||
#include "tSystemInterface.h"
|
||||
|
||||
namespace nFPGA
|
||||
{
|
||||
namespace nFRC_2015_1_0_2
|
||||
{
|
||||
|
||||
class tDIO
|
||||
{
|
||||
public:
|
||||
tDIO(){}
|
||||
virtual ~tDIO(){}
|
||||
|
||||
virtual tSystemInterface* getSystemInterface() = 0;
|
||||
static tDIO* create(tRioStatusCode *status);
|
||||
|
||||
typedef enum
|
||||
{
|
||||
kNumSystems = 1,
|
||||
} tIfaceConstants;
|
||||
|
||||
typedef
|
||||
union{
|
||||
struct{
|
||||
#ifdef __vxworks
|
||||
unsigned Headers : 10;
|
||||
unsigned Reserved : 6;
|
||||
unsigned MXP : 16;
|
||||
#else
|
||||
unsigned MXP : 16;
|
||||
unsigned Reserved : 6;
|
||||
unsigned Headers : 10;
|
||||
#endif
|
||||
};
|
||||
struct{
|
||||
unsigned value : 32;
|
||||
};
|
||||
} tDO;
|
||||
typedef
|
||||
union{
|
||||
struct{
|
||||
#ifdef __vxworks
|
||||
unsigned Headers : 10;
|
||||
unsigned Reserved : 6;
|
||||
unsigned MXP : 16;
|
||||
#else
|
||||
unsigned MXP : 16;
|
||||
unsigned Reserved : 6;
|
||||
unsigned Headers : 10;
|
||||
#endif
|
||||
};
|
||||
struct{
|
||||
unsigned value : 32;
|
||||
};
|
||||
} tOutputEnable;
|
||||
typedef
|
||||
union{
|
||||
struct{
|
||||
#ifdef __vxworks
|
||||
unsigned Headers : 10;
|
||||
unsigned Reserved : 6;
|
||||
unsigned MXP : 16;
|
||||
#else
|
||||
unsigned MXP : 16;
|
||||
unsigned Reserved : 6;
|
||||
unsigned Headers : 10;
|
||||
#endif
|
||||
};
|
||||
struct{
|
||||
unsigned value : 32;
|
||||
};
|
||||
} tPulse;
|
||||
typedef
|
||||
union{
|
||||
struct{
|
||||
#ifdef __vxworks
|
||||
unsigned Headers : 10;
|
||||
unsigned Reserved : 6;
|
||||
unsigned MXP : 16;
|
||||
#else
|
||||
unsigned MXP : 16;
|
||||
unsigned Reserved : 6;
|
||||
unsigned Headers : 10;
|
||||
#endif
|
||||
};
|
||||
struct{
|
||||
unsigned value : 32;
|
||||
};
|
||||
} tDI;
|
||||
typedef
|
||||
union{
|
||||
struct{
|
||||
#ifdef __vxworks
|
||||
unsigned PeriodPower : 6;
|
||||
unsigned OutputSelect_0 : 5;
|
||||
unsigned OutputSelect_1 : 5;
|
||||
unsigned OutputSelect_2 : 5;
|
||||
unsigned OutputSelect_3 : 5;
|
||||
#else
|
||||
unsigned OutputSelect_3 : 5;
|
||||
unsigned OutputSelect_2 : 5;
|
||||
unsigned OutputSelect_1 : 5;
|
||||
unsigned OutputSelect_0 : 5;
|
||||
unsigned PeriodPower : 6;
|
||||
#endif
|
||||
};
|
||||
struct{
|
||||
unsigned value : 26;
|
||||
};
|
||||
} tPWMConfig;
|
||||
|
||||
|
||||
|
||||
typedef enum
|
||||
{
|
||||
} tDO_IfaceConstants;
|
||||
|
||||
virtual void writeDO(tDO value, tRioStatusCode *status) = 0;
|
||||
virtual void writeDO_Headers(unsigned short value, tRioStatusCode *status) = 0;
|
||||
virtual void writeDO_Reserved(unsigned char value, tRioStatusCode *status) = 0;
|
||||
virtual void writeDO_MXP(unsigned short value, tRioStatusCode *status) = 0;
|
||||
virtual tDO readDO(tRioStatusCode *status) = 0;
|
||||
virtual unsigned short readDO_Headers(tRioStatusCode *status) = 0;
|
||||
virtual unsigned char readDO_Reserved(tRioStatusCode *status) = 0;
|
||||
virtual unsigned short readDO_MXP(tRioStatusCode *status) = 0;
|
||||
|
||||
|
||||
typedef enum
|
||||
{
|
||||
kNumPWMDutyCycleElements = 4,
|
||||
} tPWMDutyCycle_IfaceConstants;
|
||||
|
||||
virtual void writePWMDutyCycle(unsigned char bitfield_index, unsigned char value, tRioStatusCode *status) = 0;
|
||||
virtual unsigned char readPWMDutyCycle(unsigned char bitfield_index, tRioStatusCode *status) = 0;
|
||||
|
||||
|
||||
typedef enum
|
||||
{
|
||||
kNumFilterSelectHdrElements = 16,
|
||||
} tFilterSelectHdr_IfaceConstants;
|
||||
|
||||
virtual void writeFilterSelectHdr(unsigned char bitfield_index, unsigned char value, tRioStatusCode *status) = 0;
|
||||
virtual unsigned char readFilterSelectHdr(unsigned char bitfield_index, tRioStatusCode *status) = 0;
|
||||
|
||||
|
||||
typedef enum
|
||||
{
|
||||
kNumFilterPeriodMXPElements = 3,
|
||||
} tFilterPeriodMXP_IfaceConstants;
|
||||
|
||||
virtual void writeFilterPeriodMXP(unsigned char bitfield_index, unsigned char value, tRioStatusCode *status) = 0;
|
||||
virtual unsigned char readFilterPeriodMXP(unsigned char bitfield_index, tRioStatusCode *status) = 0;
|
||||
|
||||
|
||||
typedef enum
|
||||
{
|
||||
} tOutputEnable_IfaceConstants;
|
||||
|
||||
virtual void writeOutputEnable(tOutputEnable value, tRioStatusCode *status) = 0;
|
||||
virtual void writeOutputEnable_Headers(unsigned short value, tRioStatusCode *status) = 0;
|
||||
virtual void writeOutputEnable_Reserved(unsigned char value, tRioStatusCode *status) = 0;
|
||||
virtual void writeOutputEnable_MXP(unsigned short value, tRioStatusCode *status) = 0;
|
||||
virtual tOutputEnable readOutputEnable(tRioStatusCode *status) = 0;
|
||||
virtual unsigned short readOutputEnable_Headers(tRioStatusCode *status) = 0;
|
||||
virtual unsigned char readOutputEnable_Reserved(tRioStatusCode *status) = 0;
|
||||
virtual unsigned short readOutputEnable_MXP(tRioStatusCode *status) = 0;
|
||||
|
||||
|
||||
typedef enum
|
||||
{
|
||||
} tPulse_IfaceConstants;
|
||||
|
||||
virtual void writePulse(tPulse value, tRioStatusCode *status) = 0;
|
||||
virtual void writePulse_Headers(unsigned short value, tRioStatusCode *status) = 0;
|
||||
virtual void writePulse_Reserved(unsigned char value, tRioStatusCode *status) = 0;
|
||||
virtual void writePulse_MXP(unsigned short value, tRioStatusCode *status) = 0;
|
||||
virtual tPulse readPulse(tRioStatusCode *status) = 0;
|
||||
virtual unsigned short readPulse_Headers(tRioStatusCode *status) = 0;
|
||||
virtual unsigned char readPulse_Reserved(tRioStatusCode *status) = 0;
|
||||
virtual unsigned short readPulse_MXP(tRioStatusCode *status) = 0;
|
||||
|
||||
|
||||
typedef enum
|
||||
{
|
||||
} tDI_IfaceConstants;
|
||||
|
||||
virtual tDI readDI(tRioStatusCode *status) = 0;
|
||||
virtual unsigned short readDI_Headers(tRioStatusCode *status) = 0;
|
||||
virtual unsigned char readDI_Reserved(tRioStatusCode *status) = 0;
|
||||
virtual unsigned short readDI_MXP(tRioStatusCode *status) = 0;
|
||||
|
||||
|
||||
typedef enum
|
||||
{
|
||||
} tEnableMXPSpecialFunction_IfaceConstants;
|
||||
|
||||
virtual void writeEnableMXPSpecialFunction(unsigned short value, tRioStatusCode *status) = 0;
|
||||
virtual unsigned short readEnableMXPSpecialFunction(tRioStatusCode *status) = 0;
|
||||
|
||||
|
||||
typedef enum
|
||||
{
|
||||
kNumFilterSelectMXPElements = 16,
|
||||
} tFilterSelectMXP_IfaceConstants;
|
||||
|
||||
virtual void writeFilterSelectMXP(unsigned char bitfield_index, unsigned char value, tRioStatusCode *status) = 0;
|
||||
virtual unsigned char readFilterSelectMXP(unsigned char bitfield_index, tRioStatusCode *status) = 0;
|
||||
|
||||
|
||||
typedef enum
|
||||
{
|
||||
} tPulseLength_IfaceConstants;
|
||||
|
||||
virtual void writePulseLength(unsigned char value, tRioStatusCode *status) = 0;
|
||||
virtual unsigned char readPulseLength(tRioStatusCode *status) = 0;
|
||||
|
||||
|
||||
typedef enum
|
||||
{
|
||||
kNumFilterPeriodHdrElements = 3,
|
||||
} tFilterPeriodHdr_IfaceConstants;
|
||||
|
||||
virtual void writeFilterPeriodHdr(unsigned char bitfield_index, unsigned char value, tRioStatusCode *status) = 0;
|
||||
virtual unsigned char readFilterPeriodHdr(unsigned char bitfield_index, tRioStatusCode *status) = 0;
|
||||
|
||||
|
||||
typedef enum
|
||||
{
|
||||
} tPWMConfig_IfaceConstants;
|
||||
|
||||
virtual void writePWMConfig(tPWMConfig value, tRioStatusCode *status) = 0;
|
||||
virtual void writePWMConfig_PeriodPower(unsigned char value, tRioStatusCode *status) = 0;
|
||||
virtual void writePWMConfig_OutputSelect_0(unsigned char value, tRioStatusCode *status) = 0;
|
||||
virtual void writePWMConfig_OutputSelect_1(unsigned char value, tRioStatusCode *status) = 0;
|
||||
virtual void writePWMConfig_OutputSelect_2(unsigned char value, tRioStatusCode *status) = 0;
|
||||
virtual void writePWMConfig_OutputSelect_3(unsigned char value, tRioStatusCode *status) = 0;
|
||||
virtual tPWMConfig readPWMConfig(tRioStatusCode *status) = 0;
|
||||
virtual unsigned char readPWMConfig_PeriodPower(tRioStatusCode *status) = 0;
|
||||
virtual unsigned char readPWMConfig_OutputSelect_0(tRioStatusCode *status) = 0;
|
||||
virtual unsigned char readPWMConfig_OutputSelect_1(tRioStatusCode *status) = 0;
|
||||
virtual unsigned char readPWMConfig_OutputSelect_2(tRioStatusCode *status) = 0;
|
||||
virtual unsigned char readPWMConfig_OutputSelect_3(tRioStatusCode *status) = 0;
|
||||
|
||||
|
||||
|
||||
|
||||
private:
|
||||
tDIO(const tDIO&);
|
||||
void operator=(const tDIO&);
|
||||
};
|
||||
|
||||
}
|
||||
}
|
||||
|
||||
#endif // __nFRC_2015_1_0_2_DIO_h__
|
||||
188
hal/Athena/src/main/native/ChipObject/tDMA.h
Normal file
188
hal/Athena/src/main/native/ChipObject/tDMA.h
Normal file
@@ -0,0 +1,188 @@
|
||||
// Copyright (c) National Instruments 2008. All Rights Reserved.
|
||||
// Do Not Edit... this file is generated!
|
||||
|
||||
#ifndef __nFRC_2015_1_0_2_DMA_h__
|
||||
#define __nFRC_2015_1_0_2_DMA_h__
|
||||
|
||||
#include "tSystemInterface.h"
|
||||
|
||||
namespace nFPGA
|
||||
{
|
||||
namespace nFRC_2015_1_0_2
|
||||
{
|
||||
|
||||
class tDMA
|
||||
{
|
||||
public:
|
||||
tDMA(){}
|
||||
virtual ~tDMA(){}
|
||||
|
||||
virtual tSystemInterface* getSystemInterface() = 0;
|
||||
static tDMA* create(tRioStatusCode *status);
|
||||
|
||||
typedef enum
|
||||
{
|
||||
kNumSystems = 1,
|
||||
} tIfaceConstants;
|
||||
|
||||
typedef
|
||||
union{
|
||||
struct{
|
||||
#ifdef __vxworks
|
||||
unsigned Pause : 1;
|
||||
unsigned Enable_AI0_Low : 1;
|
||||
unsigned Enable_AI0_High : 1;
|
||||
unsigned Enable_AIAveraged0_Low : 1;
|
||||
unsigned Enable_AIAveraged0_High : 1;
|
||||
unsigned Enable_AI1_Low : 1;
|
||||
unsigned Enable_AI1_High : 1;
|
||||
unsigned Enable_AIAveraged1_Low : 1;
|
||||
unsigned Enable_AIAveraged1_High : 1;
|
||||
unsigned Enable_Accumulator0 : 1;
|
||||
unsigned Enable_Accumulator1 : 1;
|
||||
unsigned Enable_DI : 1;
|
||||
unsigned Enable_AnalogTriggers : 1;
|
||||
unsigned Enable_Counters_Low : 1;
|
||||
unsigned Enable_Counters_High : 1;
|
||||
unsigned Enable_CounterTimers_Low : 1;
|
||||
unsigned Enable_CounterTimers_High : 1;
|
||||
unsigned Enable_Encoders : 1;
|
||||
unsigned Enable_EncoderTimers : 1;
|
||||
unsigned ExternalClock : 1;
|
||||
#else
|
||||
unsigned ExternalClock : 1;
|
||||
unsigned Enable_EncoderTimers : 1;
|
||||
unsigned Enable_Encoders : 1;
|
||||
unsigned Enable_CounterTimers_High : 1;
|
||||
unsigned Enable_CounterTimers_Low : 1;
|
||||
unsigned Enable_Counters_High : 1;
|
||||
unsigned Enable_Counters_Low : 1;
|
||||
unsigned Enable_AnalogTriggers : 1;
|
||||
unsigned Enable_DI : 1;
|
||||
unsigned Enable_Accumulator1 : 1;
|
||||
unsigned Enable_Accumulator0 : 1;
|
||||
unsigned Enable_AIAveraged1_High : 1;
|
||||
unsigned Enable_AIAveraged1_Low : 1;
|
||||
unsigned Enable_AI1_High : 1;
|
||||
unsigned Enable_AI1_Low : 1;
|
||||
unsigned Enable_AIAveraged0_High : 1;
|
||||
unsigned Enable_AIAveraged0_Low : 1;
|
||||
unsigned Enable_AI0_High : 1;
|
||||
unsigned Enable_AI0_Low : 1;
|
||||
unsigned Pause : 1;
|
||||
#endif
|
||||
};
|
||||
struct{
|
||||
unsigned value : 20;
|
||||
};
|
||||
} tConfig;
|
||||
typedef
|
||||
union{
|
||||
struct{
|
||||
#ifdef __vxworks
|
||||
unsigned ExternalClockSource_Channel : 4;
|
||||
unsigned ExternalClockSource_Module : 1;
|
||||
unsigned ExternalClockSource_AnalogTrigger : 1;
|
||||
unsigned RisingEdge : 1;
|
||||
unsigned FallingEdge : 1;
|
||||
#else
|
||||
unsigned FallingEdge : 1;
|
||||
unsigned RisingEdge : 1;
|
||||
unsigned ExternalClockSource_AnalogTrigger : 1;
|
||||
unsigned ExternalClockSource_Module : 1;
|
||||
unsigned ExternalClockSource_Channel : 4;
|
||||
#endif
|
||||
};
|
||||
struct{
|
||||
unsigned value : 8;
|
||||
};
|
||||
} tExternalTriggers;
|
||||
|
||||
|
||||
|
||||
typedef enum
|
||||
{
|
||||
} tRate_IfaceConstants;
|
||||
|
||||
virtual void writeRate(unsigned int value, tRioStatusCode *status) = 0;
|
||||
virtual unsigned int readRate(tRioStatusCode *status) = 0;
|
||||
|
||||
|
||||
typedef enum
|
||||
{
|
||||
} tConfig_IfaceConstants;
|
||||
|
||||
virtual void writeConfig(tConfig value, tRioStatusCode *status) = 0;
|
||||
virtual void writeConfig_Pause(bool value, tRioStatusCode *status) = 0;
|
||||
virtual void writeConfig_Enable_AI0_Low(bool value, tRioStatusCode *status) = 0;
|
||||
virtual void writeConfig_Enable_AI0_High(bool value, tRioStatusCode *status) = 0;
|
||||
virtual void writeConfig_Enable_AIAveraged0_Low(bool value, tRioStatusCode *status) = 0;
|
||||
virtual void writeConfig_Enable_AIAveraged0_High(bool value, tRioStatusCode *status) = 0;
|
||||
virtual void writeConfig_Enable_AI1_Low(bool value, tRioStatusCode *status) = 0;
|
||||
virtual void writeConfig_Enable_AI1_High(bool value, tRioStatusCode *status) = 0;
|
||||
virtual void writeConfig_Enable_AIAveraged1_Low(bool value, tRioStatusCode *status) = 0;
|
||||
virtual void writeConfig_Enable_AIAveraged1_High(bool value, tRioStatusCode *status) = 0;
|
||||
virtual void writeConfig_Enable_Accumulator0(bool value, tRioStatusCode *status) = 0;
|
||||
virtual void writeConfig_Enable_Accumulator1(bool value, tRioStatusCode *status) = 0;
|
||||
virtual void writeConfig_Enable_DI(bool value, tRioStatusCode *status) = 0;
|
||||
virtual void writeConfig_Enable_AnalogTriggers(bool value, tRioStatusCode *status) = 0;
|
||||
virtual void writeConfig_Enable_Counters_Low(bool value, tRioStatusCode *status) = 0;
|
||||
virtual void writeConfig_Enable_Counters_High(bool value, tRioStatusCode *status) = 0;
|
||||
virtual void writeConfig_Enable_CounterTimers_Low(bool value, tRioStatusCode *status) = 0;
|
||||
virtual void writeConfig_Enable_CounterTimers_High(bool value, tRioStatusCode *status) = 0;
|
||||
virtual void writeConfig_Enable_Encoders(bool value, tRioStatusCode *status) = 0;
|
||||
virtual void writeConfig_Enable_EncoderTimers(bool value, tRioStatusCode *status) = 0;
|
||||
virtual void writeConfig_ExternalClock(bool value, tRioStatusCode *status) = 0;
|
||||
virtual tConfig readConfig(tRioStatusCode *status) = 0;
|
||||
virtual bool readConfig_Pause(tRioStatusCode *status) = 0;
|
||||
virtual bool readConfig_Enable_AI0_Low(tRioStatusCode *status) = 0;
|
||||
virtual bool readConfig_Enable_AI0_High(tRioStatusCode *status) = 0;
|
||||
virtual bool readConfig_Enable_AIAveraged0_Low(tRioStatusCode *status) = 0;
|
||||
virtual bool readConfig_Enable_AIAveraged0_High(tRioStatusCode *status) = 0;
|
||||
virtual bool readConfig_Enable_AI1_Low(tRioStatusCode *status) = 0;
|
||||
virtual bool readConfig_Enable_AI1_High(tRioStatusCode *status) = 0;
|
||||
virtual bool readConfig_Enable_AIAveraged1_Low(tRioStatusCode *status) = 0;
|
||||
virtual bool readConfig_Enable_AIAveraged1_High(tRioStatusCode *status) = 0;
|
||||
virtual bool readConfig_Enable_Accumulator0(tRioStatusCode *status) = 0;
|
||||
virtual bool readConfig_Enable_Accumulator1(tRioStatusCode *status) = 0;
|
||||
virtual bool readConfig_Enable_DI(tRioStatusCode *status) = 0;
|
||||
virtual bool readConfig_Enable_AnalogTriggers(tRioStatusCode *status) = 0;
|
||||
virtual bool readConfig_Enable_Counters_Low(tRioStatusCode *status) = 0;
|
||||
virtual bool readConfig_Enable_Counters_High(tRioStatusCode *status) = 0;
|
||||
virtual bool readConfig_Enable_CounterTimers_Low(tRioStatusCode *status) = 0;
|
||||
virtual bool readConfig_Enable_CounterTimers_High(tRioStatusCode *status) = 0;
|
||||
virtual bool readConfig_Enable_Encoders(tRioStatusCode *status) = 0;
|
||||
virtual bool readConfig_Enable_EncoderTimers(tRioStatusCode *status) = 0;
|
||||
virtual bool readConfig_ExternalClock(tRioStatusCode *status) = 0;
|
||||
|
||||
|
||||
typedef enum
|
||||
{
|
||||
kNumExternalTriggersElements = 4,
|
||||
} tExternalTriggers_IfaceConstants;
|
||||
|
||||
virtual void writeExternalTriggers(unsigned char bitfield_index, tExternalTriggers value, tRioStatusCode *status) = 0;
|
||||
virtual void writeExternalTriggers_ExternalClockSource_Channel(unsigned char bitfield_index, unsigned char value, tRioStatusCode *status) = 0;
|
||||
virtual void writeExternalTriggers_ExternalClockSource_Module(unsigned char bitfield_index, unsigned char value, tRioStatusCode *status) = 0;
|
||||
virtual void writeExternalTriggers_ExternalClockSource_AnalogTrigger(unsigned char bitfield_index, bool value, tRioStatusCode *status) = 0;
|
||||
virtual void writeExternalTriggers_RisingEdge(unsigned char bitfield_index, bool value, tRioStatusCode *status) = 0;
|
||||
virtual void writeExternalTriggers_FallingEdge(unsigned char bitfield_index, bool value, tRioStatusCode *status) = 0;
|
||||
virtual tExternalTriggers readExternalTriggers(unsigned char bitfield_index, tRioStatusCode *status) = 0;
|
||||
virtual unsigned char readExternalTriggers_ExternalClockSource_Channel(unsigned char bitfield_index, tRioStatusCode *status) = 0;
|
||||
virtual unsigned char readExternalTriggers_ExternalClockSource_Module(unsigned char bitfield_index, tRioStatusCode *status) = 0;
|
||||
virtual bool readExternalTriggers_ExternalClockSource_AnalogTrigger(unsigned char bitfield_index, tRioStatusCode *status) = 0;
|
||||
virtual bool readExternalTriggers_RisingEdge(unsigned char bitfield_index, tRioStatusCode *status) = 0;
|
||||
virtual bool readExternalTriggers_FallingEdge(unsigned char bitfield_index, tRioStatusCode *status) = 0;
|
||||
|
||||
|
||||
|
||||
|
||||
private:
|
||||
tDMA(const tDMA&);
|
||||
void operator=(const tDMA&);
|
||||
};
|
||||
|
||||
}
|
||||
}
|
||||
|
||||
#endif // __nFRC_2015_1_0_2_DMA_h__
|
||||
46
hal/Athena/src/main/native/ChipObject/tDMAManager.h
Normal file
46
hal/Athena/src/main/native/ChipObject/tDMAManager.h
Normal file
@@ -0,0 +1,46 @@
|
||||
// Class for handling DMA transters.
|
||||
// Copyright (c) National Instruments 2008. All Rights Reserved.
|
||||
|
||||
#ifndef __tDMAManager_h__
|
||||
#define __tDMAManager_h__
|
||||
|
||||
#include "tSystem.h"
|
||||
|
||||
namespace nFPGA
|
||||
{
|
||||
// TODO: Implement DMA Manager
|
||||
/*
|
||||
class tDMAManager : public tSystem
|
||||
{
|
||||
public:
|
||||
tDMAManager(tNIRIO_u32 dmaChannel, tNIRIO_u32 hostBufferSize, tRioStatusCode *status);
|
||||
~tDMAManager();
|
||||
void start(tRioStatusCode *status);
|
||||
void stop(tRioStatusCode *status);
|
||||
bool isStarted() {return _started;}
|
||||
void read(
|
||||
tNIRIO_u32* buf,
|
||||
tNIRIO_u32 num,
|
||||
tNIRIO_u32 timeout,
|
||||
tNIRIO_u32* read,
|
||||
tNIRIO_u32* remaining,
|
||||
tRioStatusCode *status);
|
||||
void write(
|
||||
tNIRIO_u32* buf,
|
||||
tNIRIO_u32 num,
|
||||
tNIRIO_u32 timeout,
|
||||
tNIRIO_u32* remaining,
|
||||
tRioStatusCode *status);
|
||||
private:
|
||||
bool _started;
|
||||
tNIRIO_u32 _dmaChannel;
|
||||
tNIRIO_u32 _hostBufferSize;
|
||||
tDMAChannelDescriptor const *_dmaChannelDescriptor;
|
||||
|
||||
};
|
||||
*/
|
||||
}
|
||||
|
||||
|
||||
#endif // __tDMAManager_h__
|
||||
|
||||
199
hal/Athena/src/main/native/ChipObject/tEncoder.h
Normal file
199
hal/Athena/src/main/native/ChipObject/tEncoder.h
Normal file
@@ -0,0 +1,199 @@
|
||||
// Copyright (c) National Instruments 2008. All Rights Reserved.
|
||||
// Do Not Edit... this file is generated!
|
||||
|
||||
#ifndef __nFRC_2015_1_0_2_Encoder_h__
|
||||
#define __nFRC_2015_1_0_2_Encoder_h__
|
||||
|
||||
#include "tSystemInterface.h"
|
||||
|
||||
namespace nFPGA
|
||||
{
|
||||
namespace nFRC_2015_1_0_2
|
||||
{
|
||||
|
||||
class tEncoder
|
||||
{
|
||||
public:
|
||||
tEncoder(){}
|
||||
virtual ~tEncoder(){}
|
||||
|
||||
virtual tSystemInterface* getSystemInterface() = 0;
|
||||
static tEncoder* create(unsigned char sys_index, tRioStatusCode *status);
|
||||
virtual unsigned char getSystemIndex() = 0;
|
||||
|
||||
|
||||
typedef enum
|
||||
{
|
||||
kNumSystems = 4,
|
||||
} tIfaceConstants;
|
||||
|
||||
typedef
|
||||
union{
|
||||
struct{
|
||||
#ifdef __vxworks
|
||||
unsigned Direction : 1;
|
||||
signed Value : 31;
|
||||
#else
|
||||
signed Value : 31;
|
||||
unsigned Direction : 1;
|
||||
#endif
|
||||
};
|
||||
struct{
|
||||
unsigned value : 32;
|
||||
};
|
||||
} tOutput;
|
||||
typedef
|
||||
union{
|
||||
struct{
|
||||
#ifdef __vxworks
|
||||
unsigned ASource_Channel : 4;
|
||||
unsigned ASource_Module : 1;
|
||||
unsigned ASource_AnalogTrigger : 1;
|
||||
unsigned BSource_Channel : 4;
|
||||
unsigned BSource_Module : 1;
|
||||
unsigned BSource_AnalogTrigger : 1;
|
||||
unsigned IndexSource_Channel : 4;
|
||||
unsigned IndexSource_Module : 1;
|
||||
unsigned IndexSource_AnalogTrigger : 1;
|
||||
unsigned IndexActiveHigh : 1;
|
||||
unsigned Reverse : 1;
|
||||
unsigned Enable : 1;
|
||||
#else
|
||||
unsigned Enable : 1;
|
||||
unsigned Reverse : 1;
|
||||
unsigned IndexActiveHigh : 1;
|
||||
unsigned IndexSource_AnalogTrigger : 1;
|
||||
unsigned IndexSource_Module : 1;
|
||||
unsigned IndexSource_Channel : 4;
|
||||
unsigned BSource_AnalogTrigger : 1;
|
||||
unsigned BSource_Module : 1;
|
||||
unsigned BSource_Channel : 4;
|
||||
unsigned ASource_AnalogTrigger : 1;
|
||||
unsigned ASource_Module : 1;
|
||||
unsigned ASource_Channel : 4;
|
||||
#endif
|
||||
};
|
||||
struct{
|
||||
unsigned value : 21;
|
||||
};
|
||||
} tConfig;
|
||||
typedef
|
||||
union{
|
||||
struct{
|
||||
#ifdef __vxworks
|
||||
unsigned Period : 23;
|
||||
signed Count : 8;
|
||||
unsigned Stalled : 1;
|
||||
#else
|
||||
unsigned Stalled : 1;
|
||||
signed Count : 8;
|
||||
unsigned Period : 23;
|
||||
#endif
|
||||
};
|
||||
struct{
|
||||
unsigned value : 32;
|
||||
};
|
||||
} tTimerOutput;
|
||||
typedef
|
||||
union{
|
||||
struct{
|
||||
#ifdef __vxworks
|
||||
unsigned StallPeriod : 24;
|
||||
unsigned AverageSize : 7;
|
||||
unsigned UpdateWhenEmpty : 1;
|
||||
#else
|
||||
unsigned UpdateWhenEmpty : 1;
|
||||
unsigned AverageSize : 7;
|
||||
unsigned StallPeriod : 24;
|
||||
#endif
|
||||
};
|
||||
struct{
|
||||
unsigned value : 32;
|
||||
};
|
||||
} tTimerConfig;
|
||||
|
||||
|
||||
typedef enum
|
||||
{
|
||||
} tOutput_IfaceConstants;
|
||||
|
||||
virtual tOutput readOutput(tRioStatusCode *status) = 0;
|
||||
virtual bool readOutput_Direction(tRioStatusCode *status) = 0;
|
||||
virtual signed int readOutput_Value(tRioStatusCode *status) = 0;
|
||||
|
||||
|
||||
typedef enum
|
||||
{
|
||||
} tConfig_IfaceConstants;
|
||||
|
||||
virtual void writeConfig(tConfig value, tRioStatusCode *status) = 0;
|
||||
virtual void writeConfig_ASource_Channel(unsigned char value, tRioStatusCode *status) = 0;
|
||||
virtual void writeConfig_ASource_Module(unsigned char value, tRioStatusCode *status) = 0;
|
||||
virtual void writeConfig_ASource_AnalogTrigger(bool value, tRioStatusCode *status) = 0;
|
||||
virtual void writeConfig_BSource_Channel(unsigned char value, tRioStatusCode *status) = 0;
|
||||
virtual void writeConfig_BSource_Module(unsigned char value, tRioStatusCode *status) = 0;
|
||||
virtual void writeConfig_BSource_AnalogTrigger(bool value, tRioStatusCode *status) = 0;
|
||||
virtual void writeConfig_IndexSource_Channel(unsigned char value, tRioStatusCode *status) = 0;
|
||||
virtual void writeConfig_IndexSource_Module(unsigned char value, tRioStatusCode *status) = 0;
|
||||
virtual void writeConfig_IndexSource_AnalogTrigger(bool value, tRioStatusCode *status) = 0;
|
||||
virtual void writeConfig_IndexActiveHigh(bool value, tRioStatusCode *status) = 0;
|
||||
virtual void writeConfig_Reverse(bool value, tRioStatusCode *status) = 0;
|
||||
virtual void writeConfig_Enable(bool value, tRioStatusCode *status) = 0;
|
||||
virtual tConfig readConfig(tRioStatusCode *status) = 0;
|
||||
virtual unsigned char readConfig_ASource_Channel(tRioStatusCode *status) = 0;
|
||||
virtual unsigned char readConfig_ASource_Module(tRioStatusCode *status) = 0;
|
||||
virtual bool readConfig_ASource_AnalogTrigger(tRioStatusCode *status) = 0;
|
||||
virtual unsigned char readConfig_BSource_Channel(tRioStatusCode *status) = 0;
|
||||
virtual unsigned char readConfig_BSource_Module(tRioStatusCode *status) = 0;
|
||||
virtual bool readConfig_BSource_AnalogTrigger(tRioStatusCode *status) = 0;
|
||||
virtual unsigned char readConfig_IndexSource_Channel(tRioStatusCode *status) = 0;
|
||||
virtual unsigned char readConfig_IndexSource_Module(tRioStatusCode *status) = 0;
|
||||
virtual bool readConfig_IndexSource_AnalogTrigger(tRioStatusCode *status) = 0;
|
||||
virtual bool readConfig_IndexActiveHigh(tRioStatusCode *status) = 0;
|
||||
virtual bool readConfig_Reverse(tRioStatusCode *status) = 0;
|
||||
virtual bool readConfig_Enable(tRioStatusCode *status) = 0;
|
||||
|
||||
|
||||
typedef enum
|
||||
{
|
||||
} tTimerOutput_IfaceConstants;
|
||||
|
||||
virtual tTimerOutput readTimerOutput(tRioStatusCode *status) = 0;
|
||||
virtual unsigned int readTimerOutput_Period(tRioStatusCode *status) = 0;
|
||||
virtual signed char readTimerOutput_Count(tRioStatusCode *status) = 0;
|
||||
virtual bool readTimerOutput_Stalled(tRioStatusCode *status) = 0;
|
||||
|
||||
|
||||
typedef enum
|
||||
{
|
||||
} tReset_IfaceConstants;
|
||||
|
||||
virtual void strobeReset(tRioStatusCode *status) = 0;
|
||||
|
||||
|
||||
typedef enum
|
||||
{
|
||||
} tTimerConfig_IfaceConstants;
|
||||
|
||||
virtual void writeTimerConfig(tTimerConfig value, tRioStatusCode *status) = 0;
|
||||
virtual void writeTimerConfig_StallPeriod(unsigned int value, tRioStatusCode *status) = 0;
|
||||
virtual void writeTimerConfig_AverageSize(unsigned char value, tRioStatusCode *status) = 0;
|
||||
virtual void writeTimerConfig_UpdateWhenEmpty(bool value, tRioStatusCode *status) = 0;
|
||||
virtual tTimerConfig readTimerConfig(tRioStatusCode *status) = 0;
|
||||
virtual unsigned int readTimerConfig_StallPeriod(tRioStatusCode *status) = 0;
|
||||
virtual unsigned char readTimerConfig_AverageSize(tRioStatusCode *status) = 0;
|
||||
virtual bool readTimerConfig_UpdateWhenEmpty(tRioStatusCode *status) = 0;
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
private:
|
||||
tEncoder(const tEncoder&);
|
||||
void operator=(const tEncoder&);
|
||||
};
|
||||
|
||||
}
|
||||
}
|
||||
|
||||
#endif // __nFRC_2015_1_0_2_Encoder_h__
|
||||
104
hal/Athena/src/main/native/ChipObject/tGlobal.h
Normal file
104
hal/Athena/src/main/native/ChipObject/tGlobal.h
Normal file
@@ -0,0 +1,104 @@
|
||||
// Copyright (c) National Instruments 2008. All Rights Reserved.
|
||||
// Do Not Edit... this file is generated!
|
||||
|
||||
#ifndef __nFRC_2015_1_0_2_Global_h__
|
||||
#define __nFRC_2015_1_0_2_Global_h__
|
||||
|
||||
#include "tSystemInterface.h"
|
||||
|
||||
namespace nFPGA
|
||||
{
|
||||
namespace nFRC_2015_1_0_2
|
||||
{
|
||||
|
||||
class tGlobal
|
||||
{
|
||||
public:
|
||||
tGlobal(){}
|
||||
virtual ~tGlobal(){}
|
||||
|
||||
virtual tSystemInterface* getSystemInterface() = 0;
|
||||
static tGlobal* create(tRioStatusCode *status);
|
||||
|
||||
typedef enum
|
||||
{
|
||||
kNumSystems = 1,
|
||||
} tIfaceConstants;
|
||||
|
||||
typedef
|
||||
union{
|
||||
struct{
|
||||
#ifdef __vxworks
|
||||
unsigned Radio : 8;
|
||||
unsigned Comm : 8;
|
||||
unsigned Mode : 8;
|
||||
unsigned RSL : 1;
|
||||
#else
|
||||
unsigned RSL : 1;
|
||||
unsigned Mode : 8;
|
||||
unsigned Comm : 8;
|
||||
unsigned Radio : 8;
|
||||
#endif
|
||||
};
|
||||
struct{
|
||||
unsigned value : 25;
|
||||
};
|
||||
} tLEDs;
|
||||
|
||||
|
||||
|
||||
typedef enum
|
||||
{
|
||||
} tLEDs_IfaceConstants;
|
||||
|
||||
virtual void writeLEDs(tLEDs value, tRioStatusCode *status) = 0;
|
||||
virtual void writeLEDs_Radio(unsigned char value, tRioStatusCode *status) = 0;
|
||||
virtual void writeLEDs_Comm(unsigned char value, tRioStatusCode *status) = 0;
|
||||
virtual void writeLEDs_Mode(unsigned char value, tRioStatusCode *status) = 0;
|
||||
virtual void writeLEDs_RSL(bool value, tRioStatusCode *status) = 0;
|
||||
virtual tLEDs readLEDs(tRioStatusCode *status) = 0;
|
||||
virtual unsigned char readLEDs_Radio(tRioStatusCode *status) = 0;
|
||||
virtual unsigned char readLEDs_Comm(tRioStatusCode *status) = 0;
|
||||
virtual unsigned char readLEDs_Mode(tRioStatusCode *status) = 0;
|
||||
virtual bool readLEDs_RSL(tRioStatusCode *status) = 0;
|
||||
|
||||
|
||||
typedef enum
|
||||
{
|
||||
} tVersion_IfaceConstants;
|
||||
|
||||
virtual unsigned short readVersion(tRioStatusCode *status) = 0;
|
||||
|
||||
|
||||
typedef enum
|
||||
{
|
||||
} tLocalTime_IfaceConstants;
|
||||
|
||||
virtual unsigned int readLocalTime(tRioStatusCode *status) = 0;
|
||||
|
||||
|
||||
typedef enum
|
||||
{
|
||||
} tUserButton_IfaceConstants;
|
||||
|
||||
virtual bool readUserButton(tRioStatusCode *status) = 0;
|
||||
|
||||
|
||||
typedef enum
|
||||
{
|
||||
} tRevision_IfaceConstants;
|
||||
|
||||
virtual unsigned int readRevision(tRioStatusCode *status) = 0;
|
||||
|
||||
|
||||
|
||||
|
||||
private:
|
||||
tGlobal(const tGlobal&);
|
||||
void operator=(const tGlobal&);
|
||||
};
|
||||
|
||||
}
|
||||
}
|
||||
|
||||
#endif // __nFRC_2015_1_0_2_Global_h__
|
||||
93
hal/Athena/src/main/native/ChipObject/tInterrupt.h
Normal file
93
hal/Athena/src/main/native/ChipObject/tInterrupt.h
Normal file
@@ -0,0 +1,93 @@
|
||||
// Copyright (c) National Instruments 2008. All Rights Reserved.
|
||||
// Do Not Edit... this file is generated!
|
||||
|
||||
#ifndef __nFRC_2015_1_0_2_Interrupt_h__
|
||||
#define __nFRC_2015_1_0_2_Interrupt_h__
|
||||
|
||||
#include "tSystemInterface.h"
|
||||
|
||||
namespace nFPGA
|
||||
{
|
||||
namespace nFRC_2015_1_0_2
|
||||
{
|
||||
|
||||
class tInterrupt
|
||||
{
|
||||
public:
|
||||
tInterrupt(){}
|
||||
virtual ~tInterrupt(){}
|
||||
|
||||
virtual tSystemInterface* getSystemInterface() = 0;
|
||||
static tInterrupt* create(unsigned char sys_index, tRioStatusCode *status);
|
||||
virtual unsigned char getSystemIndex() = 0;
|
||||
|
||||
|
||||
typedef enum
|
||||
{
|
||||
kNumSystems = 8,
|
||||
} tIfaceConstants;
|
||||
|
||||
typedef
|
||||
union{
|
||||
struct{
|
||||
#ifdef __vxworks
|
||||
unsigned Source_Channel : 4;
|
||||
unsigned Source_Module : 1;
|
||||
unsigned Source_AnalogTrigger : 1;
|
||||
unsigned RisingEdge : 1;
|
||||
unsigned FallingEdge : 1;
|
||||
unsigned WaitForAck : 1;
|
||||
#else
|
||||
unsigned WaitForAck : 1;
|
||||
unsigned FallingEdge : 1;
|
||||
unsigned RisingEdge : 1;
|
||||
unsigned Source_AnalogTrigger : 1;
|
||||
unsigned Source_Module : 1;
|
||||
unsigned Source_Channel : 4;
|
||||
#endif
|
||||
};
|
||||
struct{
|
||||
unsigned value : 9;
|
||||
};
|
||||
} tConfig;
|
||||
|
||||
|
||||
typedef enum
|
||||
{
|
||||
} tTimeStamp_IfaceConstants;
|
||||
|
||||
virtual unsigned int readTimeStamp(tRioStatusCode *status) = 0;
|
||||
|
||||
|
||||
typedef enum
|
||||
{
|
||||
} tConfig_IfaceConstants;
|
||||
|
||||
virtual void writeConfig(tConfig value, tRioStatusCode *status) = 0;
|
||||
virtual void writeConfig_Source_Channel(unsigned char value, tRioStatusCode *status) = 0;
|
||||
virtual void writeConfig_Source_Module(unsigned char value, tRioStatusCode *status) = 0;
|
||||
virtual void writeConfig_Source_AnalogTrigger(bool value, tRioStatusCode *status) = 0;
|
||||
virtual void writeConfig_RisingEdge(bool value, tRioStatusCode *status) = 0;
|
||||
virtual void writeConfig_FallingEdge(bool value, tRioStatusCode *status) = 0;
|
||||
virtual void writeConfig_WaitForAck(bool value, tRioStatusCode *status) = 0;
|
||||
virtual tConfig readConfig(tRioStatusCode *status) = 0;
|
||||
virtual unsigned char readConfig_Source_Channel(tRioStatusCode *status) = 0;
|
||||
virtual unsigned char readConfig_Source_Module(tRioStatusCode *status) = 0;
|
||||
virtual bool readConfig_Source_AnalogTrigger(tRioStatusCode *status) = 0;
|
||||
virtual bool readConfig_RisingEdge(tRioStatusCode *status) = 0;
|
||||
virtual bool readConfig_FallingEdge(tRioStatusCode *status) = 0;
|
||||
virtual bool readConfig_WaitForAck(tRioStatusCode *status) = 0;
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
private:
|
||||
tInterrupt(const tInterrupt&);
|
||||
void operator=(const tInterrupt&);
|
||||
};
|
||||
|
||||
}
|
||||
}
|
||||
|
||||
#endif // __nFRC_2015_1_0_2_Interrupt_h__
|
||||
61
hal/Athena/src/main/native/ChipObject/tInterruptManager.h
Normal file
61
hal/Athena/src/main/native/ChipObject/tInterruptManager.h
Normal file
@@ -0,0 +1,61 @@
|
||||
// Class for handling interrupts.
|
||||
// Copyright (c) National Instruments 2008. All Rights Reserved.
|
||||
|
||||
#ifndef __tInterruptManager_h__
|
||||
#define __tInterruptManager_h__
|
||||
|
||||
#include "tSystem.h"
|
||||
|
||||
namespace ni
|
||||
{
|
||||
namespace dsc
|
||||
{
|
||||
namespace osdep
|
||||
{
|
||||
class CriticalSection;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
namespace nFPGA
|
||||
{
|
||||
|
||||
typedef void (*tInterruptHandler)(uint32_t interruptAssertedMask, void *param);
|
||||
|
||||
class tInterruptManager : public tSystem
|
||||
{
|
||||
public:
|
||||
tInterruptManager(uint32_t interruptMask, bool watcher, tRioStatusCode *status);
|
||||
~tInterruptManager();
|
||||
void registerHandler(tInterruptHandler handler, void *param, tRioStatusCode *status);
|
||||
uint32_t watch(int32_t timeoutInMs, tRioStatusCode *status);
|
||||
void enable(tRioStatusCode *status);
|
||||
void disable(tRioStatusCode *status);
|
||||
bool isEnabled(tRioStatusCode *status);
|
||||
private:
|
||||
class tInterruptThread;
|
||||
friend class tInterruptThread;
|
||||
void handler();
|
||||
static int handlerWrapper(tInterruptManager *pInterrupt);
|
||||
|
||||
void acknowledge(tRioStatusCode *status);
|
||||
void reserve(tRioStatusCode *status);
|
||||
void unreserve(tRioStatusCode *status);
|
||||
tInterruptHandler _handler;
|
||||
uint32_t _interruptMask;
|
||||
tInterruptThread *_thread;
|
||||
NiFpga_IrqContext _rioContext;
|
||||
bool _watcher;
|
||||
bool _enabled;
|
||||
void *_userParam;
|
||||
|
||||
// maintain the interrupts that are already dealt with.
|
||||
static uint32_t _globalInterruptMask;
|
||||
static ni::dsc::osdep::CriticalSection *_globalInterruptMaskSemaphore;
|
||||
};
|
||||
|
||||
}
|
||||
|
||||
|
||||
#endif // __tInterruptManager_h__
|
||||
|
||||
111
hal/Athena/src/main/native/ChipObject/tPWM.h
Normal file
111
hal/Athena/src/main/native/ChipObject/tPWM.h
Normal file
@@ -0,0 +1,111 @@
|
||||
// Copyright (c) National Instruments 2008. All Rights Reserved.
|
||||
// Do Not Edit... this file is generated!
|
||||
|
||||
#ifndef __nFRC_2015_1_0_2_PWM_h__
|
||||
#define __nFRC_2015_1_0_2_PWM_h__
|
||||
|
||||
#include "tSystemInterface.h"
|
||||
|
||||
namespace nFPGA
|
||||
{
|
||||
namespace nFRC_2015_1_0_2
|
||||
{
|
||||
|
||||
class tPWM
|
||||
{
|
||||
public:
|
||||
tPWM(){}
|
||||
virtual ~tPWM(){}
|
||||
|
||||
virtual tSystemInterface* getSystemInterface() = 0;
|
||||
static tPWM* create(tRioStatusCode *status);
|
||||
|
||||
typedef enum
|
||||
{
|
||||
kNumSystems = 1,
|
||||
} tIfaceConstants;
|
||||
|
||||
typedef
|
||||
union{
|
||||
struct{
|
||||
#ifdef __vxworks
|
||||
unsigned Period : 16;
|
||||
unsigned MinHigh : 16;
|
||||
#else
|
||||
unsigned MinHigh : 16;
|
||||
unsigned Period : 16;
|
||||
#endif
|
||||
};
|
||||
struct{
|
||||
unsigned value : 32;
|
||||
};
|
||||
} tConfig;
|
||||
|
||||
|
||||
|
||||
typedef enum
|
||||
{
|
||||
} tConfig_IfaceConstants;
|
||||
|
||||
virtual void writeConfig(tConfig value, tRioStatusCode *status) = 0;
|
||||
virtual void writeConfig_Period(unsigned short value, tRioStatusCode *status) = 0;
|
||||
virtual void writeConfig_MinHigh(unsigned short value, tRioStatusCode *status) = 0;
|
||||
virtual tConfig readConfig(tRioStatusCode *status) = 0;
|
||||
virtual unsigned short readConfig_Period(tRioStatusCode *status) = 0;
|
||||
virtual unsigned short readConfig_MinHigh(tRioStatusCode *status) = 0;
|
||||
|
||||
|
||||
typedef enum
|
||||
{
|
||||
} tLoopTiming_IfaceConstants;
|
||||
|
||||
virtual unsigned short readLoopTiming(tRioStatusCode *status) = 0;
|
||||
|
||||
|
||||
typedef enum
|
||||
{
|
||||
kNumPeriodScaleMXPElements = 10,
|
||||
} tPeriodScaleMXP_IfaceConstants;
|
||||
|
||||
virtual void writePeriodScaleMXP(unsigned char bitfield_index, unsigned char value, tRioStatusCode *status) = 0;
|
||||
virtual unsigned char readPeriodScaleMXP(unsigned char bitfield_index, tRioStatusCode *status) = 0;
|
||||
|
||||
|
||||
typedef enum
|
||||
{
|
||||
kNumPeriodScaleHdrElements = 10,
|
||||
} tPeriodScaleHdr_IfaceConstants;
|
||||
|
||||
virtual void writePeriodScaleHdr(unsigned char bitfield_index, unsigned char value, tRioStatusCode *status) = 0;
|
||||
virtual unsigned char readPeriodScaleHdr(unsigned char bitfield_index, tRioStatusCode *status) = 0;
|
||||
|
||||
|
||||
|
||||
|
||||
typedef enum
|
||||
{
|
||||
kNumHdrRegisters = 10,
|
||||
} tHdr_IfaceConstants;
|
||||
|
||||
virtual void writeHdr(unsigned char reg_index, unsigned short value, tRioStatusCode *status) = 0;
|
||||
virtual unsigned short readHdr(unsigned char reg_index, tRioStatusCode *status) = 0;
|
||||
|
||||
|
||||
typedef enum
|
||||
{
|
||||
kNumMXPRegisters = 10,
|
||||
} tMXP_IfaceConstants;
|
||||
|
||||
virtual void writeMXP(unsigned char reg_index, unsigned short value, tRioStatusCode *status) = 0;
|
||||
virtual unsigned short readMXP(unsigned char reg_index, tRioStatusCode *status) = 0;
|
||||
|
||||
|
||||
private:
|
||||
tPWM(const tPWM&);
|
||||
void operator=(const tPWM&);
|
||||
};
|
||||
|
||||
}
|
||||
}
|
||||
|
||||
#endif // __nFRC_2015_1_0_2_PWM_h__
|
||||
107
hal/Athena/src/main/native/ChipObject/tPower.h
Normal file
107
hal/Athena/src/main/native/ChipObject/tPower.h
Normal file
@@ -0,0 +1,107 @@
|
||||
// Copyright (c) National Instruments 2008. All Rights Reserved.
|
||||
// Do Not Edit... this file is generated!
|
||||
|
||||
#ifndef __nFRC_2015_1_0_2_Power_h__
|
||||
#define __nFRC_2015_1_0_2_Power_h__
|
||||
|
||||
#include "tSystemInterface.h"
|
||||
|
||||
namespace nFPGA
|
||||
{
|
||||
namespace nFRC_2015_1_0_2
|
||||
{
|
||||
|
||||
class tPower
|
||||
{
|
||||
public:
|
||||
tPower(){}
|
||||
virtual ~tPower(){}
|
||||
|
||||
virtual tSystemInterface* getSystemInterface() = 0;
|
||||
static tPower* create(tRioStatusCode *status);
|
||||
|
||||
typedef enum
|
||||
{
|
||||
kNumSystems = 1,
|
||||
} tIfaceConstants;
|
||||
|
||||
typedef
|
||||
union{
|
||||
struct{
|
||||
#ifdef __vxworks
|
||||
unsigned User3V3 : 8;
|
||||
unsigned User5V : 8;
|
||||
signed User6V : 16;
|
||||
#else
|
||||
signed User6V : 16;
|
||||
unsigned User5V : 8;
|
||||
unsigned User3V3 : 8;
|
||||
#endif
|
||||
};
|
||||
struct{
|
||||
unsigned value : 32;
|
||||
};
|
||||
} tStatus;
|
||||
typedef
|
||||
union{
|
||||
struct{
|
||||
#ifdef __vxworks
|
||||
unsigned User3V3 : 1;
|
||||
unsigned User5V : 1;
|
||||
unsigned User6V : 1;
|
||||
#else
|
||||
unsigned User6V : 1;
|
||||
unsigned User5V : 1;
|
||||
unsigned User3V3 : 1;
|
||||
#endif
|
||||
};
|
||||
struct{
|
||||
unsigned value : 3;
|
||||
};
|
||||
} tDisable;
|
||||
|
||||
|
||||
|
||||
typedef enum
|
||||
{
|
||||
} tStatus_IfaceConstants;
|
||||
|
||||
virtual tStatus readStatus(tRioStatusCode *status) = 0;
|
||||
virtual unsigned char readStatus_User3V3(tRioStatusCode *status) = 0;
|
||||
virtual unsigned char readStatus_User5V(tRioStatusCode *status) = 0;
|
||||
virtual signed short readStatus_User6V(tRioStatusCode *status) = 0;
|
||||
|
||||
|
||||
typedef enum
|
||||
{
|
||||
} tDisable_IfaceConstants;
|
||||
|
||||
virtual void writeDisable(tDisable value, tRioStatusCode *status) = 0;
|
||||
virtual void writeDisable_User3V3(bool value, tRioStatusCode *status) = 0;
|
||||
virtual void writeDisable_User5V(bool value, tRioStatusCode *status) = 0;
|
||||
virtual void writeDisable_User6V(bool value, tRioStatusCode *status) = 0;
|
||||
virtual tDisable readDisable(tRioStatusCode *status) = 0;
|
||||
virtual bool readDisable_User3V3(tRioStatusCode *status) = 0;
|
||||
virtual bool readDisable_User5V(tRioStatusCode *status) = 0;
|
||||
virtual bool readDisable_User6V(tRioStatusCode *status) = 0;
|
||||
|
||||
|
||||
typedef enum
|
||||
{
|
||||
} tIndicateOutOfRange_IfaceConstants;
|
||||
|
||||
virtual void writeIndicateOutOfRange(bool value, tRioStatusCode *status) = 0;
|
||||
virtual bool readIndicateOutOfRange(tRioStatusCode *status) = 0;
|
||||
|
||||
|
||||
|
||||
|
||||
private:
|
||||
tPower(const tPower&);
|
||||
void operator=(const tPower&);
|
||||
};
|
||||
|
||||
}
|
||||
}
|
||||
|
||||
#endif // __nFRC_2015_1_0_2_Power_h__
|
||||
68
hal/Athena/src/main/native/ChipObject/tRelay.h
Normal file
68
hal/Athena/src/main/native/ChipObject/tRelay.h
Normal file
@@ -0,0 +1,68 @@
|
||||
// Copyright (c) National Instruments 2008. All Rights Reserved.
|
||||
// Do Not Edit... this file is generated!
|
||||
|
||||
#ifndef __nFRC_2015_1_0_2_Relay_h__
|
||||
#define __nFRC_2015_1_0_2_Relay_h__
|
||||
|
||||
#include "tSystemInterface.h"
|
||||
|
||||
namespace nFPGA
|
||||
{
|
||||
namespace nFRC_2015_1_0_2
|
||||
{
|
||||
|
||||
class tRelay
|
||||
{
|
||||
public:
|
||||
tRelay(){}
|
||||
virtual ~tRelay(){}
|
||||
|
||||
virtual tSystemInterface* getSystemInterface() = 0;
|
||||
static tRelay* create(tRioStatusCode *status);
|
||||
|
||||
typedef enum
|
||||
{
|
||||
kNumSystems = 1,
|
||||
} tIfaceConstants;
|
||||
|
||||
typedef
|
||||
union{
|
||||
struct{
|
||||
#ifdef __vxworks
|
||||
unsigned Forward : 4;
|
||||
unsigned Reverse : 4;
|
||||
#else
|
||||
unsigned Reverse : 4;
|
||||
unsigned Forward : 4;
|
||||
#endif
|
||||
};
|
||||
struct{
|
||||
unsigned value : 8;
|
||||
};
|
||||
} tValue;
|
||||
|
||||
|
||||
|
||||
typedef enum
|
||||
{
|
||||
} tValue_IfaceConstants;
|
||||
|
||||
virtual void writeValue(tValue value, tRioStatusCode *status) = 0;
|
||||
virtual void writeValue_Forward(unsigned char value, tRioStatusCode *status) = 0;
|
||||
virtual void writeValue_Reverse(unsigned char value, tRioStatusCode *status) = 0;
|
||||
virtual tValue readValue(tRioStatusCode *status) = 0;
|
||||
virtual unsigned char readValue_Forward(tRioStatusCode *status) = 0;
|
||||
virtual unsigned char readValue_Reverse(tRioStatusCode *status) = 0;
|
||||
|
||||
|
||||
|
||||
|
||||
private:
|
||||
tRelay(const tRelay&);
|
||||
void operator=(const tRelay&);
|
||||
};
|
||||
|
||||
}
|
||||
}
|
||||
|
||||
#endif // __nFRC_2015_1_0_2_Relay_h__
|
||||
71
hal/Athena/src/main/native/ChipObject/tSysWatchdog.h
Normal file
71
hal/Athena/src/main/native/ChipObject/tSysWatchdog.h
Normal file
@@ -0,0 +1,71 @@
|
||||
// Copyright (c) National Instruments 2008. All Rights Reserved.
|
||||
// Do Not Edit... this file is generated!
|
||||
|
||||
#ifndef __nFRC_2015_1_0_2_SysWatchdog_h__
|
||||
#define __nFRC_2015_1_0_2_SysWatchdog_h__
|
||||
|
||||
#include "tSystemInterface.h"
|
||||
|
||||
namespace nFPGA
|
||||
{
|
||||
namespace nFRC_2015_1_0_2
|
||||
{
|
||||
|
||||
class tSysWatchdog
|
||||
{
|
||||
public:
|
||||
tSysWatchdog(){}
|
||||
virtual ~tSysWatchdog(){}
|
||||
|
||||
virtual tSystemInterface* getSystemInterface() = 0;
|
||||
static tSysWatchdog* create(tRioStatusCode *status);
|
||||
|
||||
typedef enum
|
||||
{
|
||||
kNumSystems = 1,
|
||||
} tIfaceConstants;
|
||||
|
||||
|
||||
|
||||
|
||||
typedef enum
|
||||
{
|
||||
} tCommand_IfaceConstants;
|
||||
|
||||
virtual void writeCommand(unsigned short value, tRioStatusCode *status) = 0;
|
||||
virtual unsigned short readCommand(tRioStatusCode *status) = 0;
|
||||
|
||||
|
||||
typedef enum
|
||||
{
|
||||
} tChallenge_IfaceConstants;
|
||||
|
||||
virtual unsigned char readChallenge(tRioStatusCode *status) = 0;
|
||||
|
||||
|
||||
typedef enum
|
||||
{
|
||||
} tActive_IfaceConstants;
|
||||
|
||||
virtual void writeActive(bool value, tRioStatusCode *status) = 0;
|
||||
virtual bool readActive(tRioStatusCode *status) = 0;
|
||||
|
||||
|
||||
typedef enum
|
||||
{
|
||||
} tTimer_IfaceConstants;
|
||||
|
||||
virtual unsigned int readTimer(tRioStatusCode *status) = 0;
|
||||
|
||||
|
||||
|
||||
|
||||
private:
|
||||
tSysWatchdog(const tSysWatchdog&);
|
||||
void operator=(const tSysWatchdog&);
|
||||
};
|
||||
|
||||
}
|
||||
}
|
||||
|
||||
#endif // __nFRC_2015_1_0_2_SysWatchdog_h__
|
||||
47
hal/Athena/src/main/native/ChipObject/tSystem.h
Normal file
47
hal/Athena/src/main/native/ChipObject/tSystem.h
Normal file
@@ -0,0 +1,47 @@
|
||||
// Base class for generated chip objects
|
||||
// Copyright (c) National Instruments 2008. All Rights Reserved.
|
||||
|
||||
#ifndef __tSystem_h__
|
||||
#define __tSystem_h__
|
||||
|
||||
#include "fpgainterfacecapi/NiFpga.h"
|
||||
typedef NiFpga_Status tRioStatusCode;
|
||||
|
||||
#define FRC_FPGA_PRELOAD_BITFILE
|
||||
|
||||
typedef uint32_t NiFpga_Session;
|
||||
|
||||
namespace nFPGA
|
||||
{
|
||||
|
||||
class tSystem
|
||||
{
|
||||
public:
|
||||
tSystem(tRioStatusCode *status);
|
||||
~tSystem();
|
||||
void getFpgaGuid(uint32_t *guid_ptr, tRioStatusCode *status);
|
||||
|
||||
protected:
|
||||
static NiFpga_Session _DeviceHandle;
|
||||
|
||||
#ifdef FRC_FPGA_PRELOAD_BITFILE
|
||||
void NiFpga_SharedOpen_common(const char* bitfile);
|
||||
NiFpga_Status NiFpga_SharedOpen(const char* bitfile,
|
||||
const char* signature,
|
||||
const char* resource,
|
||||
uint32_t attribute,
|
||||
NiFpga_Session* session);
|
||||
NiFpga_Status NiFpgaLv_SharedOpen(const char* const bitfile,
|
||||
const char* const apiSignature,
|
||||
const char* const resource,
|
||||
const uint32_t attribute,
|
||||
NiFpga_Session* const session);
|
||||
private:
|
||||
static char *_FileName;
|
||||
static char *_Bitfile;
|
||||
#endif
|
||||
};
|
||||
|
||||
}
|
||||
|
||||
#endif // __tSystem_h__
|
||||
26
hal/Athena/src/main/native/ChipObject/tSystemInterface.h
Normal file
26
hal/Athena/src/main/native/ChipObject/tSystemInterface.h
Normal file
@@ -0,0 +1,26 @@
|
||||
// Copyright (c) National Instruments 2008. All Rights Reserved.
|
||||
|
||||
#ifndef __tSystemInterface_h__
|
||||
#define __tSystemInterface_h__
|
||||
|
||||
namespace nFPGA
|
||||
{
|
||||
|
||||
class tSystemInterface
|
||||
{
|
||||
public:
|
||||
tSystemInterface(){}
|
||||
virtual ~tSystemInterface(){}
|
||||
|
||||
virtual const uint16_t getExpectedFPGAVersion()=0;
|
||||
virtual const uint32_t getExpectedFPGARevision()=0;
|
||||
virtual const uint32_t * const getExpectedFPGASignature()=0;
|
||||
virtual void getHardwareFpgaSignature(uint32_t *guid_ptr, tRioStatusCode *status)=0;
|
||||
virtual uint32_t getLVHandle(tRioStatusCode *status)=0;
|
||||
virtual uint32_t getHandle()=0;
|
||||
};
|
||||
|
||||
}
|
||||
|
||||
#endif // __tSystemInterface_h__
|
||||
|
||||
108
hal/Athena/src/main/native/ChipObject/tWatchdog.h
Normal file
108
hal/Athena/src/main/native/ChipObject/tWatchdog.h
Normal file
@@ -0,0 +1,108 @@
|
||||
// Copyright (c) National Instruments 2008. All Rights Reserved.
|
||||
// Do Not Edit... this file is generated!
|
||||
|
||||
#ifndef __nFRC_2015_1_0_2_Watchdog_h__
|
||||
#define __nFRC_2015_1_0_2_Watchdog_h__
|
||||
|
||||
#include "tSystemInterface.h"
|
||||
|
||||
namespace nFPGA
|
||||
{
|
||||
namespace nFRC_2015_1_0_2
|
||||
{
|
||||
|
||||
class tWatchdog
|
||||
{
|
||||
public:
|
||||
tWatchdog(){}
|
||||
virtual ~tWatchdog(){}
|
||||
|
||||
virtual tSystemInterface* getSystemInterface() = 0;
|
||||
static tWatchdog* create(tRioStatusCode *status);
|
||||
|
||||
typedef enum
|
||||
{
|
||||
kNumSystems = 1,
|
||||
} tIfaceConstants;
|
||||
|
||||
typedef
|
||||
union{
|
||||
struct{
|
||||
#ifdef __vxworks
|
||||
unsigned SystemActive : 1;
|
||||
unsigned Alive : 1;
|
||||
unsigned SysDisableCount : 15;
|
||||
unsigned DisableCount : 15;
|
||||
#else
|
||||
unsigned DisableCount : 15;
|
||||
unsigned SysDisableCount : 15;
|
||||
unsigned Alive : 1;
|
||||
unsigned SystemActive : 1;
|
||||
#endif
|
||||
};
|
||||
struct{
|
||||
unsigned value : 32;
|
||||
};
|
||||
} tStatus;
|
||||
|
||||
|
||||
|
||||
typedef enum
|
||||
{
|
||||
} tStatus_IfaceConstants;
|
||||
|
||||
virtual tStatus readStatus(tRioStatusCode *status) = 0;
|
||||
virtual bool readStatus_SystemActive(tRioStatusCode *status) = 0;
|
||||
virtual bool readStatus_Alive(tRioStatusCode *status) = 0;
|
||||
virtual unsigned short readStatus_SysDisableCount(tRioStatusCode *status) = 0;
|
||||
virtual unsigned short readStatus_DisableCount(tRioStatusCode *status) = 0;
|
||||
|
||||
|
||||
typedef enum
|
||||
{
|
||||
} tKill_IfaceConstants;
|
||||
|
||||
virtual void strobeKill(tRioStatusCode *status) = 0;
|
||||
|
||||
|
||||
typedef enum
|
||||
{
|
||||
} tFeed_IfaceConstants;
|
||||
|
||||
virtual void strobeFeed(tRioStatusCode *status) = 0;
|
||||
|
||||
|
||||
typedef enum
|
||||
{
|
||||
} tTimer_IfaceConstants;
|
||||
|
||||
virtual unsigned int readTimer(tRioStatusCode *status) = 0;
|
||||
|
||||
|
||||
typedef enum
|
||||
{
|
||||
} tExpiration_IfaceConstants;
|
||||
|
||||
virtual void writeExpiration(unsigned int value, tRioStatusCode *status) = 0;
|
||||
virtual unsigned int readExpiration(tRioStatusCode *status) = 0;
|
||||
|
||||
|
||||
typedef enum
|
||||
{
|
||||
} tImmortal_IfaceConstants;
|
||||
|
||||
virtual void writeImmortal(bool value, tRioStatusCode *status) = 0;
|
||||
virtual bool readImmortal(tRioStatusCode *status) = 0;
|
||||
|
||||
|
||||
|
||||
|
||||
private:
|
||||
tWatchdog(const tWatchdog&);
|
||||
void operator=(const tWatchdog&);
|
||||
};
|
||||
|
||||
}
|
||||
}
|
||||
|
||||
#endif // __nFRC_2015_1_0_2_Watchdog_h__
|
||||
1563
hal/Athena/src/main/native/Digital.cpp
Normal file
1563
hal/Athena/src/main/native/Digital.cpp
Normal file
File diff suppressed because it is too large
Load Diff
125
hal/Athena/src/main/native/HAL.cpp
Normal file
125
hal/Athena/src/main/native/HAL.cpp
Normal file
@@ -0,0 +1,125 @@
|
||||
|
||||
#include "HAL/HAL.h"
|
||||
|
||||
#include "Port.h"
|
||||
#include "HAL/Errors.h"
|
||||
#include "ChipObject.h"
|
||||
|
||||
// XXX: What to do with solenoids? const uint32_t solenoid_kNumDO7_0Elements = tSolenoid::kNumDO7_0Elements;
|
||||
const uint32_t dio_kNumSystems = tDIO::kNumSystems;
|
||||
const uint32_t interrupt_kNumSystems = tInterrupt::kNumSystems;
|
||||
const uint32_t kSystemClockTicksPerMicrosecond = 40;
|
||||
|
||||
void* getPort(uint8_t pin) {
|
||||
Port* port = new Port();
|
||||
port->pin = pin;
|
||||
port->module = 1;
|
||||
return port;
|
||||
}
|
||||
|
||||
/**
|
||||
* @deprecated Uses module numbers
|
||||
*/
|
||||
void* getPortWithModule(uint8_t module, uint8_t pin) {
|
||||
Port* port = new Port();
|
||||
port->pin = pin;
|
||||
port->module = module;
|
||||
return port;
|
||||
}
|
||||
|
||||
const char* getHALErrorMessage(int32_t code) {
|
||||
if (code == 0) return "";
|
||||
else if (code == SAMPLE_RATE_TOO_HIGH) return SAMPLE_RATE_TOO_HIGH_MESSAGE;
|
||||
else if (code == VOLTAGE_OUT_OF_RANGE) return VOLTAGE_OUT_OF_RANGE_MESSAGE;
|
||||
else if (code == LOOP_TIMING_ERROR) return LOOP_TIMING_ERROR_MESSAGE;
|
||||
else if (code == SPI_WRITE_NO_MOSI) return SPI_WRITE_NO_MOSI_MESSAGE;
|
||||
else if (code == SPI_READ_NO_MISO) return SPI_READ_NO_MISO_MESSAGE;
|
||||
else if (code == SPI_READ_NO_DATA) return SPI_READ_NO_DATA_MESSAGE;
|
||||
else if (code == INCOMPATIBLE_STATE) return INCOMPATIBLE_STATE_MESSAGE;
|
||||
else if (code == NO_AVAILABLE_RESOURCES) return NO_AVAILABLE_RESOURCES_MESSAGE;
|
||||
else if (code == NULL_PARAMETER) return NULL_PARAMETER_MESSAGE;
|
||||
else if (code == ANALOG_TRIGGER_LIMIT_ORDER_ERROR) return ANALOG_TRIGGER_LIMIT_ORDER_ERROR_MESSAGE;
|
||||
else if (code == ANALOG_TRIGGER_PULSE_OUTPUT_ERROR) return ANALOG_TRIGGER_PULSE_OUTPUT_ERROR_MESSAGE;
|
||||
else if (code == PARAMETER_OUT_OF_RANGE) return PARAMETER_OUT_OF_RANGE_MESSAGE;
|
||||
else return "";
|
||||
}
|
||||
|
||||
/**
|
||||
* Return the FPGA Version number.
|
||||
* For now, expect this to be competition year.
|
||||
* @return FPGA Version number.
|
||||
*/
|
||||
uint16_t getFPGAVersion(int32_t *status) {
|
||||
tGlobal *global = tGlobal::create(status);
|
||||
uint16_t version = global->readVersion(status);
|
||||
delete global;
|
||||
return version;
|
||||
}
|
||||
|
||||
/**
|
||||
* Return the FPGA Revision number.
|
||||
* The format of the revision is 3 numbers.
|
||||
* The 12 most significant bits are the Major Revision.
|
||||
* the next 8 bits are the Minor Revision.
|
||||
* The 12 least significant bits are the Build Number.
|
||||
* @return FPGA Revision number.
|
||||
*/
|
||||
uint32_t getFPGARevision(int32_t *status) {
|
||||
tGlobal *global = tGlobal::create(status);
|
||||
uint32_t revision = global->readRevision(status);
|
||||
delete global;
|
||||
return revision;
|
||||
}
|
||||
|
||||
/**
|
||||
* Read the microsecond-resolution timer on the FPGA.
|
||||
*
|
||||
* @return The current time in microseconds according to the FPGA (since FPGA reset).
|
||||
*/
|
||||
uint32_t getFPGATime(int32_t *status) {
|
||||
tGlobal *global = tGlobal::create(status);
|
||||
uint32_t time = global->readLocalTime(status);
|
||||
delete global;
|
||||
return time;
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* Set the state of the FPGA status LED on the cRIO.
|
||||
*/
|
||||
void setFPGALED(uint32_t state, int32_t *status) {
|
||||
// XXX: Not supported?
|
||||
// tGlobal *global = tGlobal::create(status);
|
||||
// global->writeFPGA_LED(state, status);
|
||||
// delete global;
|
||||
}
|
||||
|
||||
/**
|
||||
* Get the current state of the FPGA status LED on the cRIO.
|
||||
* @return The curent state of the FPGA LED.
|
||||
*/
|
||||
int32_t getFPGALED(int32_t *status) {
|
||||
// XXX: Not supported?
|
||||
// tGlobal *global = tGlobal::create(status);
|
||||
// bool ledValue = global->readFPGA_LED(status);
|
||||
// delete global;
|
||||
// return ledValue;
|
||||
return 0; // XXX: Dummy value
|
||||
}
|
||||
|
||||
// TODO: HACKS
|
||||
void NumericArrayResize() {}
|
||||
void RTSetCleanupProc() {}
|
||||
void EDVR_CreateReference() {}
|
||||
void Occur() {}
|
||||
|
||||
void imaqGetErrorText() {}
|
||||
void imaqGetLastError() {}
|
||||
void niTimestamp64() {}
|
||||
|
||||
#include "NetworkCommunication/LoadOut.h"
|
||||
namespace nLoadOut {
|
||||
bool getModulePresence(tModuleType moduleType, uint8_t moduleNumber) {
|
||||
return true;
|
||||
}
|
||||
}
|
||||
86
hal/Athena/src/main/native/Interrupts.cpp
Normal file
86
hal/Athena/src/main/native/Interrupts.cpp
Normal file
@@ -0,0 +1,86 @@
|
||||
|
||||
#include "HAL/Interrupts.h"
|
||||
|
||||
#include "ChipObject.h"
|
||||
|
||||
struct interrupt_t {
|
||||
tInterrupt *anInterrupt;
|
||||
tInterruptManager *manager;
|
||||
};
|
||||
typedef struct interrupt_t Interrupt;
|
||||
|
||||
void* initializeInterrupts(uint32_t interruptIndex, bool watcher, int32_t *status) {
|
||||
Interrupt* anInterrupt = new Interrupt();
|
||||
// Expects the calling leaf class to allocate an interrupt index.
|
||||
anInterrupt->anInterrupt = tInterrupt::create(interruptIndex, status);
|
||||
anInterrupt->anInterrupt->writeConfig_WaitForAck(false, status);
|
||||
anInterrupt->manager = new tInterruptManager(1 << interruptIndex, watcher, status);
|
||||
return anInterrupt;
|
||||
}
|
||||
|
||||
void cleanInterrupts(void* interrupt_pointer, int32_t *status) {
|
||||
Interrupt* anInterrupt = (Interrupt*) interrupt_pointer;
|
||||
delete anInterrupt->anInterrupt;
|
||||
delete anInterrupt->manager;
|
||||
anInterrupt->anInterrupt = NULL;
|
||||
anInterrupt->manager = NULL;
|
||||
}
|
||||
|
||||
/**
|
||||
* In synchronous mode, wait for the defined interrupt to occur.
|
||||
* @param timeout Timeout in seconds
|
||||
*/
|
||||
void waitForInterrupt(void* interrupt_pointer, double timeout, int32_t *status) {
|
||||
Interrupt* anInterrupt = (Interrupt*) interrupt_pointer;
|
||||
anInterrupt->manager->watch((int32_t)(timeout * 1e3), status);
|
||||
}
|
||||
|
||||
/**
|
||||
* Enable interrupts to occur on this input.
|
||||
* oInterrupts are disabled when the RequestInterrupt call is made. This gives time to do the
|
||||
* setup of the other options before starting to field interrupts.
|
||||
*/
|
||||
void enableInterrupts(void* interrupt_pointer, int32_t *status) {
|
||||
Interrupt* anInterrupt = (Interrupt*) interrupt_pointer;
|
||||
anInterrupt->manager->enable(status);
|
||||
}
|
||||
|
||||
/**
|
||||
* Disable Interrupts without without deallocating structures.
|
||||
*/
|
||||
void disableInterrupts(void* interrupt_pointer, int32_t *status) {
|
||||
Interrupt* anInterrupt = (Interrupt*) interrupt_pointer;
|
||||
anInterrupt->manager->disable(status);
|
||||
}
|
||||
|
||||
/**
|
||||
* Return the timestamp for the interrupt that occurred most recently.
|
||||
* This is in the same time domain as GetClock().
|
||||
* @return Timestamp in seconds since boot.
|
||||
*/
|
||||
double readInterruptTimestamp(void* interrupt_pointer, int32_t *status) {
|
||||
Interrupt* anInterrupt = (Interrupt*) interrupt_pointer;
|
||||
uint32_t timestamp = anInterrupt->anInterrupt->readTimeStamp(status);
|
||||
return timestamp * 1e-6;
|
||||
}
|
||||
|
||||
void requestInterrupts(void* interrupt_pointer, uint8_t routing_module, uint32_t routing_pin,
|
||||
bool routing_analog_trigger, int32_t *status) {
|
||||
Interrupt* anInterrupt = (Interrupt*) interrupt_pointer;
|
||||
anInterrupt->anInterrupt->writeConfig_WaitForAck(false, status);
|
||||
anInterrupt->anInterrupt->writeConfig_Source_AnalogTrigger(routing_analog_trigger, status);
|
||||
anInterrupt->anInterrupt->writeConfig_Source_Channel(routing_pin, status);
|
||||
anInterrupt->anInterrupt->writeConfig_Source_Module(routing_module, status);
|
||||
}
|
||||
|
||||
void attachInterruptHandler(void* interrupt_pointer, InterruptHandlerFunction handler,
|
||||
void* param, int32_t *status) {
|
||||
Interrupt* anInterrupt = (Interrupt*) interrupt_pointer;
|
||||
anInterrupt->manager->registerHandler(handler, param, status);
|
||||
}
|
||||
|
||||
void setInterruptUpSourceEdge(void* interrupt_pointer, bool risingEdge, bool fallingEdge, int32_t *status) {
|
||||
Interrupt* anInterrupt = (Interrupt*) interrupt_pointer;
|
||||
anInterrupt->anInterrupt->writeConfig_RisingEdge(risingEdge, status);
|
||||
anInterrupt->anInterrupt->writeConfig_FallingEdge(fallingEdge, status);
|
||||
}
|
||||
@@ -0,0 +1,19 @@
|
||||
|
||||
#ifndef __AICalibration_h__
|
||||
#define __AICalibration_h__
|
||||
|
||||
#include <stdint.h>
|
||||
|
||||
#ifdef __cplusplus
|
||||
extern "C"
|
||||
{
|
||||
#endif
|
||||
|
||||
uint32_t FRC_NetworkCommunication_nAICalibration_getLSBWeight(const uint32_t aiSystemIndex, const uint32_t channel, int32_t *status);
|
||||
int32_t FRC_NetworkCommunication_nAICalibration_getOffset(const uint32_t aiSystemIndex, const uint32_t channel, int32_t *status);
|
||||
|
||||
#ifdef __cplusplus
|
||||
}
|
||||
#endif
|
||||
|
||||
#endif // __AICalibration_h__
|
||||
52
hal/Athena/src/main/native/NetworkCommunication/LoadOut.h
Normal file
52
hal/Athena/src/main/native/NetworkCommunication/LoadOut.h
Normal file
@@ -0,0 +1,52 @@
|
||||
|
||||
#ifndef __LoadOut_h__
|
||||
#define __LoadOut_h__
|
||||
|
||||
#ifdef SIMULATION
|
||||
#include <vxWorks_compat.h>
|
||||
#define EXPORT_FUNC __declspec(dllexport) __cdecl
|
||||
#elif defined (__vxworks)
|
||||
#include <vxWorks.h>
|
||||
#define EXPORT_FUNC
|
||||
#else
|
||||
#include <stdint.h>
|
||||
#define EXPORT_FUNC
|
||||
#endif
|
||||
|
||||
#define kMaxModuleNumber 2
|
||||
namespace nLoadOut
|
||||
{
|
||||
typedef enum {
|
||||
kModuleType_Unknown = 0x00,
|
||||
kModuleType_Analog = 0x01,
|
||||
kModuleType_Digital = 0x02,
|
||||
kModuleType_Solenoid = 0x03,
|
||||
} tModuleType;
|
||||
bool EXPORT_FUNC getModulePresence(tModuleType moduleType, uint8_t moduleNumber);
|
||||
typedef enum {
|
||||
kTargetClass_Unknown = 0x00,
|
||||
kTargetClass_FRC1 = 0x10,
|
||||
kTargetClass_FRC2 = 0x20,
|
||||
kTargetClass_FRC3 = 0x30,
|
||||
kTargetClass_RoboRIO = 0x40,
|
||||
kTargetClass_FRC2_Analog = kTargetClass_FRC2 | kModuleType_Analog,
|
||||
kTargetClass_FRC2_Digital = kTargetClass_FRC2 | kModuleType_Digital,
|
||||
kTargetClass_FRC2_Solenoid = kTargetClass_FRC2 | kModuleType_Solenoid,
|
||||
kTargetClass_FamilyMask = 0xF0,
|
||||
kTargetClass_ModuleMask = 0x0F,
|
||||
} tTargetClass;
|
||||
tTargetClass EXPORT_FUNC getTargetClass();
|
||||
}
|
||||
|
||||
#ifdef __cplusplus
|
||||
extern "C" {
|
||||
#endif
|
||||
|
||||
uint32_t EXPORT_FUNC FRC_NetworkCommunication_nLoadOut_getModulePresence(uint32_t moduleType, uint8_t moduleNumber);
|
||||
uint32_t EXPORT_FUNC FRC_NetworkCommunication_nLoadOut_getTargetClass();
|
||||
|
||||
#ifdef __cplusplus
|
||||
}
|
||||
#endif
|
||||
|
||||
#endif // __LoadOut_h__
|
||||
40
hal/Athena/src/main/native/Notifier.cpp
Normal file
40
hal/Athena/src/main/native/Notifier.cpp
Normal file
@@ -0,0 +1,40 @@
|
||||
|
||||
#include "HAL/Notifier.h"
|
||||
|
||||
#include "ChipObject.h"
|
||||
|
||||
static const uint32_t kTimerInterruptNumber = 28;
|
||||
|
||||
struct notifier_t {
|
||||
tAlarm *alarm;
|
||||
tInterruptManager *manager;
|
||||
};
|
||||
typedef struct notifier_t Notifier;
|
||||
|
||||
void* initializeNotifier(void (*ProcessQueue)(uint32_t, void*), int32_t *status) {
|
||||
Notifier* notifier = new Notifier();
|
||||
notifier->manager = new tInterruptManager(1 << kTimerInterruptNumber, false, status);
|
||||
notifier->manager->registerHandler(ProcessQueue, NULL, status);
|
||||
notifier->manager->enable(status);
|
||||
notifier->alarm = tAlarm::create(status);
|
||||
return notifier;
|
||||
}
|
||||
|
||||
void cleanNotifier(void* notifier_pointer, int32_t *status) {
|
||||
Notifier* notifier = (Notifier*) notifier_pointer;
|
||||
notifier->alarm->writeEnable(false, status);
|
||||
delete notifier->alarm;
|
||||
notifier->alarm = NULL;
|
||||
notifier->manager->disable(status);
|
||||
delete notifier->manager;
|
||||
notifier->manager = NULL;
|
||||
}
|
||||
|
||||
|
||||
void updateNotifierAlarm(void* notifier_pointer, uint32_t triggerTime, int32_t *status) {
|
||||
Notifier* notifier = (Notifier*) notifier_pointer;
|
||||
// write the first item in the queue into the trigger time
|
||||
notifier->alarm->writeTriggerTime(triggerTime, status);
|
||||
// Enable the alarm. The hardware disables itself after each alarm.
|
||||
notifier->alarm->writeEnable(true, status);
|
||||
}
|
||||
11
hal/Athena/src/main/native/Port.h
Normal file
11
hal/Athena/src/main/native/Port.h
Normal file
@@ -0,0 +1,11 @@
|
||||
|
||||
#ifndef HAL_PORT_H
|
||||
#define HAL_PORT_H
|
||||
|
||||
struct port_t {
|
||||
uint8_t pin;
|
||||
uint8_t module;
|
||||
};
|
||||
typedef struct port_t Port;
|
||||
|
||||
#endif
|
||||
120
hal/Athena/src/main/native/Semaphore.cpp
Normal file
120
hal/Athena/src/main/native/Semaphore.cpp
Normal file
@@ -0,0 +1,120 @@
|
||||
|
||||
#include "HAL/Semaphore.h"
|
||||
|
||||
#include "ChipObject.h"
|
||||
|
||||
// See: http://www.vxdev.com/docs/vx55man/vxworks/ref/semMLib.html
|
||||
const uint32_t SEMAPHORE_Q_FIFO= 0x01; // TODO: Support
|
||||
const uint32_t SEMAPHORE_Q_PRIORITY = 0x01; // TODO: Support
|
||||
const uint32_t SEMAPHORE_DELETE_SAFE = 0x04; // TODO: Support
|
||||
const uint32_t SEMAPHORE_INVERSION_SAFE = 0x08; // TODO: Support
|
||||
|
||||
const int32_t SEMAPHORE_NO_WAIT = 0;
|
||||
const int32_t SEMAPHORE_WAIT_FOREVER = -1;
|
||||
|
||||
const uint32_t SEMAPHORE_EMPTY = 0;
|
||||
const uint32_t SEMAPHORE_FULL = 1;
|
||||
|
||||
MUTEX_ID initializeMutex(uint32_t flags) {
|
||||
pthread_mutexattr_t attr;
|
||||
pthread_mutexattr_init(&attr);
|
||||
pthread_mutexattr_settype(&attr, PTHREAD_MUTEX_RECURSIVE);
|
||||
MUTEX_ID sem = new pthread_mutex_t();
|
||||
pthread_mutex_init(sem, &attr);
|
||||
pthread_mutexattr_destroy(&attr);
|
||||
return sem;
|
||||
}
|
||||
|
||||
void deleteMutex(MUTEX_ID sem) {
|
||||
pthread_mutex_destroy(sem);
|
||||
delete sem;
|
||||
}
|
||||
|
||||
/**
|
||||
* Lock the semaphore, blocking until it's available.
|
||||
* @return 0 for success, -1 for error. If -1, the error will be in errno.
|
||||
*/
|
||||
int8_t takeMutex(MUTEX_ID sem, int32_t timeout) {
|
||||
if (timeout == SEMAPHORE_NO_WAIT) {
|
||||
return pthread_mutex_trylock(sem);
|
||||
} else if (timeout == SEMAPHORE_WAIT_FOREVER) {
|
||||
return pthread_mutex_lock(sem);
|
||||
} else {
|
||||
// struct timespec test;
|
||||
// return pthread_mutex_timedlock(sem, );
|
||||
return -1; // TODO: implement timed wait
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Unlock the semaphore.
|
||||
* @return 0 for success, -1 for error. If -1, the error will be in errno.
|
||||
*/
|
||||
int8_t giveMutex(MUTEX_ID sem) {
|
||||
// return semGive(sem);
|
||||
// return sem_post(sem);
|
||||
return pthread_mutex_unlock(sem);
|
||||
}
|
||||
|
||||
SEMAPHORE_ID initializeSemaphore(uint32_t flags, uint32_t initial_value) {
|
||||
SEMAPHORE_ID sem = new sem_t;
|
||||
sem_init(sem, 0, initial_value);
|
||||
return sem;
|
||||
}
|
||||
|
||||
void deleteSemaphore(SEMAPHORE_ID sem) {
|
||||
sem_destroy(sem);
|
||||
delete sem;
|
||||
}
|
||||
|
||||
/**
|
||||
* Lock the semaphore, blocking until it's available.
|
||||
* @return 0 for success, -1 for error. If -1, the error will be in errno.
|
||||
*/
|
||||
int8_t takeSemaphore(SEMAPHORE_ID sem, int32_t timeout) {
|
||||
if (timeout == SEMAPHORE_NO_WAIT) {
|
||||
return sem_trywait(sem);
|
||||
} else if (timeout == SEMAPHORE_WAIT_FOREVER) {
|
||||
return sem_wait(sem);
|
||||
} else {
|
||||
// return sem_timedwait(sem, );
|
||||
return -1; // TODO: implement timed wait
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Unlock the semaphore.
|
||||
* @return 0 for success, -1 for error. If -1, the error will be in errno.
|
||||
*/
|
||||
int8_t giveSemaphore(SEMAPHORE_ID sem) {
|
||||
return sem_post(sem);
|
||||
}
|
||||
|
||||
|
||||
MULTIWAIT_ID initializeMultiWait() {
|
||||
pthread_condattr_t attr;
|
||||
pthread_condattr_init(&attr);
|
||||
MULTIWAIT_ID cond = new pthread_cond_t();
|
||||
pthread_cond_init(cond, &attr);
|
||||
pthread_condattr_destroy(&attr);
|
||||
return cond;
|
||||
}
|
||||
|
||||
void deleteMultiWait(MULTIWAIT_ID sem) {
|
||||
pthread_cond_destroy(sem);
|
||||
delete sem;
|
||||
}
|
||||
|
||||
int8_t takeMultiWait(MULTIWAIT_ID sem, int32_t timeout) {
|
||||
MUTEX_ID m = initializeMutex(NULL);
|
||||
takeMutex(m, SEMAPHORE_WAIT_FOREVER);
|
||||
int8_t val = pthread_cond_wait(sem, m);
|
||||
deleteMutex(m);
|
||||
return val;
|
||||
}
|
||||
|
||||
int8_t giveMultiWait(MULTIWAIT_ID sem) {
|
||||
return pthread_cond_broadcast(sem);
|
||||
}
|
||||
|
||||
|
||||
86
hal/Athena/src/main/native/Solenoid.cpp
Normal file
86
hal/Athena/src/main/native/Solenoid.cpp
Normal file
@@ -0,0 +1,86 @@
|
||||
|
||||
#include "HAL/Solenoid.h"
|
||||
|
||||
#include "Port.h"
|
||||
#include "HAL/Errors.h"
|
||||
#include "ChipObject.h"
|
||||
#include "HAL/cpp/Synchronized.h"
|
||||
#include "NetworkCommunication/LoadOut.h"
|
||||
|
||||
// XXX No solenoid abstraction :(
|
||||
|
||||
// struct solenoid_port_t {
|
||||
// Port port;
|
||||
// tSolenoid *module;
|
||||
// uint32_t PWMGeneratorID;
|
||||
// };
|
||||
// typedef struct solenoid_port_t SolenoidPort;
|
||||
|
||||
// static ReentrantSemaphore solenoidSemaphore;
|
||||
// static tSolenoid* solenoidModules[2] = {NULL, NULL};
|
||||
|
||||
// bool solenoidModulesInitialized = false;
|
||||
|
||||
// /**
|
||||
// * Initialize the digital modules.
|
||||
// */
|
||||
// void initializeSolenoid(int32_t *status) {
|
||||
// if (solenoidModulesInitialized) return;
|
||||
|
||||
// for (unsigned int i = 0; i < (sizeof(solenoidModules)/sizeof(solenoidModules[0])); i++) {
|
||||
// Synchronized sync(solenoidSemaphore);
|
||||
// solenoidModules[i] = tSolenoid::create(status);
|
||||
// }
|
||||
// solenoidModulesInitialized = true;
|
||||
// }
|
||||
|
||||
// void* initializeSolenoidPort(void* port_pointer, int32_t *status) {
|
||||
// initializeSolenoid(status);
|
||||
// Port* port = (Port*) port_pointer;
|
||||
|
||||
// // Initialize port structure
|
||||
// SolenoidPort* solenoid_port = new SolenoidPort();
|
||||
// solenoid_port->port = *port;
|
||||
// solenoid_port->module = solenoidModules[solenoid_port->port.module-1];
|
||||
|
||||
// return solenoid_port;
|
||||
// }
|
||||
|
||||
// bool checkSolenoidModule(uint8_t module) {
|
||||
// if (nLoadOut::getModulePresence(nLoadOut::kModuleType_Solenoid, module - 1))
|
||||
// return true;
|
||||
// return false;
|
||||
// }
|
||||
|
||||
// bool getSolenoid(void* solenoid_port_pointer, int32_t *status) {
|
||||
// SolenoidPort* port = (SolenoidPort*) solenoid_port_pointer;
|
||||
// if (checkSolenoidModule(port->port.module)) {
|
||||
// uint8_t mask = 1 << (port->port.pin - 1);
|
||||
// return (mask & port->module->readDO7_0(port->port.module - 1, status));
|
||||
// }
|
||||
// return false;
|
||||
// }
|
||||
|
||||
// void setSolenoid(void* solenoid_port_pointer, bool value, int32_t *status) {
|
||||
// SolenoidPort* port = (SolenoidPort*) solenoid_port_pointer;
|
||||
// if (checkSolenoidModule(port->port.module)) {
|
||||
// Synchronized sync(solenoidSemaphore);
|
||||
// uint8_t currentValue = port->module->readDO7_0(port->port.module - 1, status);
|
||||
// uint8_t mask = 1 << (port->port.pin - 1);
|
||||
// if (value) currentValue = currentValue | mask; // Flip the bit on
|
||||
// else currentValue = currentValue & ~mask; // Flip the bit off
|
||||
// port->module->writeDO7_0(port->port.module - 1, currentValue, status);
|
||||
// }
|
||||
// }
|
||||
|
||||
// XXX No solenoid abstraction :(
|
||||
|
||||
/**
|
||||
* Initialize the digital modules.
|
||||
*/
|
||||
void initializeSolenoid(int32_t *status) {}
|
||||
void* initializeSolenoidPort(void* port_pointer, int32_t *status) { return NULL; }
|
||||
bool checkSolenoidModule(uint8_t module) { return false; }
|
||||
bool getSolenoid(void* solenoid_port_pointer, int32_t *status) { return false; }
|
||||
void setSolenoid(void* solenoid_port_pointer, bool value, int32_t *status) {}
|
||||
|
||||
100
hal/Athena/src/main/native/Task.cpp
Normal file
100
hal/Athena/src/main/native/Task.cpp
Normal file
@@ -0,0 +1,100 @@
|
||||
|
||||
#include "HAL/Task.h"
|
||||
|
||||
#include "HAL/HAL.h"
|
||||
#include "ChipObject.h"
|
||||
|
||||
#include <stdio.h>
|
||||
#include <signal.h>
|
||||
|
||||
const uint32_t VXWORKS_FP_TASK = 0x01000000;
|
||||
const int32_t HAL_objLib_OBJ_ID_ERROR = -1; // TODO: update to relevant TaskIDError
|
||||
const int32_t HAL_objLib_OBJ_DELETED = -1; // TODO: update to relevant TaskDeletedError
|
||||
const int32_t HAL_taskLib_ILLEGAL_OPTIONS = -1; // TODO: update to relevant TaskOptionsError
|
||||
const int32_t HAL_memLib_NOT_ENOUGH_MEMORY = -1; // TODO: update to relevant TaskMemoryError
|
||||
const int32_t HAL_taskLib_ILLEGAL_PRIORITY = -1; // TODO: update to relevant TaskPriorityError
|
||||
|
||||
typedef struct task_args_t {
|
||||
FUNCPTR fun;
|
||||
char* name;
|
||||
pthread_t** task;
|
||||
uint32_t arg0, arg1, arg2, arg3, arg4,
|
||||
arg5, arg6, arg7, arg8, arg9;
|
||||
} TaskArgs;
|
||||
|
||||
void* startRoutine(void* data) {
|
||||
TaskArgs* args = (TaskArgs*) data;
|
||||
printf("[HAL] Starting task %s...\n", args->name);
|
||||
int val = args->fun(args->arg0, args->arg1, args->arg2, args->arg3, args->arg4,
|
||||
args->arg5, args->arg6, args->arg7, args->arg8, args->arg9);
|
||||
printf("[HAL] Exited task %s with code %i\n", args->name, val);
|
||||
*args->task = NULL;
|
||||
int* ret = new int(); *ret = val;
|
||||
return ret;
|
||||
}
|
||||
|
||||
TASK spawnTask(char * name, int priority, int options, int stackSize,
|
||||
FUNCPTR entryPt, uint32_t arg0, uint32_t arg1, uint32_t arg2,
|
||||
uint32_t arg3, uint32_t arg4, uint32_t arg5, uint32_t arg6,
|
||||
uint32_t arg7, uint32_t arg8, uint32_t arg9) {
|
||||
printf("[HAL] Spawning task %s...\n", name);
|
||||
pthread_t* task = new pthread_t;
|
||||
pthread_attr_t* attr = new pthread_attr_t;
|
||||
pthread_attr_init(attr);
|
||||
TaskArgs* args = new TaskArgs();
|
||||
args->fun = entryPt;
|
||||
args->name = name;
|
||||
args->task = new pthread_t*;
|
||||
*args->task = task;
|
||||
args->arg0 = arg0; args->arg1 = arg1; args->arg2 = arg2; args->arg3 = arg3; args->arg4 = arg4;
|
||||
args->arg5 = arg5; args->arg6 = arg6; args->arg7 = arg7; args->arg8 = arg8; args->arg9 = arg9;
|
||||
if (pthread_create(task, attr, startRoutine, args) == 0) {
|
||||
printf("[HAL] Success\n");
|
||||
pthread_detach(*task);
|
||||
} else {
|
||||
printf("[HAL] Failure\n");
|
||||
task = NULL;
|
||||
}
|
||||
pthread_attr_destroy(attr);
|
||||
return task;
|
||||
}
|
||||
|
||||
STATUS restartTask(TASK task) {
|
||||
return ERROR; // TODO: implement;
|
||||
}
|
||||
|
||||
STATUS deleteTask(TASK task) {
|
||||
return ERROR; // TODO: implement
|
||||
}
|
||||
|
||||
STATUS isTaskReady(TASK task) {
|
||||
return ERROR; // TODO: implement
|
||||
}
|
||||
|
||||
STATUS isTaskSuspended(TASK task) {
|
||||
return ERROR; // TODO: implement
|
||||
}
|
||||
|
||||
STATUS suspendTask(TASK task) {
|
||||
return ERROR; // TODO: implement
|
||||
}
|
||||
|
||||
STATUS resumeTask(TASK task) {
|
||||
return ERROR; // TODO: implement
|
||||
}
|
||||
|
||||
STATUS verifyTaskID(TASK task) {
|
||||
if (task != NULL && pthread_kill(*task, 0) == 0) {
|
||||
return OK;
|
||||
} else {
|
||||
return ERROR;
|
||||
}
|
||||
}
|
||||
|
||||
STATUS setTaskPriority(TASK task, int priority) {
|
||||
return ERROR; // TODO: implement
|
||||
}
|
||||
|
||||
STATUS getTaskPriority(TASK task, int* priority) {
|
||||
return ERROR; // TODO: implement
|
||||
}
|
||||
29
hal/Athena/src/main/native/Utilities.cpp
Normal file
29
hal/Athena/src/main/native/Utilities.cpp
Normal file
@@ -0,0 +1,29 @@
|
||||
|
||||
#include "HAL/Utilities.h"
|
||||
|
||||
#include "HAL/HAL.h"
|
||||
#include "ChipObject.h"
|
||||
|
||||
const int32_t HAL_NO_WAIT = 0;
|
||||
const int32_t HAL_WAIT_FOREVER = -1;
|
||||
|
||||
void delayTicks(int32_t ticks) {
|
||||
struct timespec test, remaining;
|
||||
test.tv_sec = 0;
|
||||
test.tv_nsec = ticks * 3;
|
||||
nanosleep(&test, &remaining);
|
||||
}
|
||||
|
||||
void delayMillis(double ms) {
|
||||
struct timespec test, remaining;
|
||||
test.tv_sec = ms/1000;
|
||||
test.tv_nsec = 1000*(((uint64_t) ms)%1000000);
|
||||
nanosleep(&test, &remaining);
|
||||
}
|
||||
|
||||
void delaySeconds(double s) {
|
||||
struct timespec test, remaining;
|
||||
test.tv_sec = 0;
|
||||
test.tv_nsec = s * 1000000000.0;
|
||||
nanosleep(&test, &remaining);
|
||||
}
|
||||
140
hal/Athena/src/main/native/Watchdog.cpp
Normal file
140
hal/Athena/src/main/native/Watchdog.cpp
Normal file
@@ -0,0 +1,140 @@
|
||||
|
||||
#include "HAL/Watchdog.h"
|
||||
|
||||
#include "HAL/HAL.h"
|
||||
#include "ChipObject.h"
|
||||
|
||||
typedef tWatchdog Watchdog;
|
||||
const double kDefaultWatchdogExpiration = 0.5;
|
||||
|
||||
void* initializeWatchdog(int32_t *status) {
|
||||
Watchdog* watchdog = tWatchdog::create(status);
|
||||
setWatchdogExpiration(watchdog, kDefaultWatchdogExpiration, status);
|
||||
setWatchdogEnabled(watchdog, true, status);
|
||||
return watchdog;
|
||||
}
|
||||
|
||||
void cleanWatchdog(void* watchdog_pointer, int32_t *status) {
|
||||
Watchdog* watchdog = (Watchdog*) watchdog_pointer;
|
||||
setWatchdogEnabled(watchdog, false, status);
|
||||
delete watchdog;
|
||||
}
|
||||
|
||||
/**
|
||||
* Throw the dog a bone.
|
||||
*
|
||||
* When everything is going well, you feed your dog when you get home.
|
||||
* Let's hope you don't drive your car off a bridge on the way home...
|
||||
* Your dog won't get fed and he will starve to death.
|
||||
*
|
||||
* By the way, it's not cool to ask the neighbor (some random task) to
|
||||
* feed your dog for you. He's your responsibility!
|
||||
*
|
||||
* @returns Returns the previous state of the watchdog before feeding it.
|
||||
*/
|
||||
bool feedWatchdog(void* watchdog_pointer, int32_t *status) {
|
||||
Watchdog* watchdog = (Watchdog*) watchdog_pointer;
|
||||
bool previous = getWatchdogEnabled(watchdog_pointer, status);
|
||||
watchdog->strobeFeed(status);
|
||||
return previous;
|
||||
}
|
||||
|
||||
/**
|
||||
* 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 killWatchdog(void* watchdog_pointer, int32_t *status) {
|
||||
Watchdog* watchdog = (Watchdog*) watchdog_pointer;
|
||||
watchdog->strobeKill(status);
|
||||
}
|
||||
|
||||
/**
|
||||
* Read how long it has been since the watchdog was last fed.
|
||||
*
|
||||
* @return The number of seconds since last meal.
|
||||
*/
|
||||
double getWatchdogLastFed(void* watchdog_pointer, int32_t *status) {
|
||||
Watchdog* watchdog = (Watchdog*) watchdog_pointer;
|
||||
uint32_t timer = watchdog->readTimer(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 getWatchdogExpiration(void* watchdog_pointer, int32_t *status) {
|
||||
Watchdog* watchdog = (Watchdog*) watchdog_pointer;
|
||||
uint32_t expiration = watchdog->readExpiration(status);
|
||||
return expiration / (kSystemClockTicksPerMicrosecond * 1e6);
|
||||
}
|
||||
|
||||
/**
|
||||
* 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 setWatchdogExpiration(void* watchdog_pointer, double expiration, int32_t *status) {
|
||||
Watchdog* watchdog = (Watchdog*) watchdog_pointer;
|
||||
watchdog->writeExpiration((uint32_t)(expiration * (kSystemClockTicksPerMicrosecond * 1e6)), status);
|
||||
}
|
||||
|
||||
/**
|
||||
* Find out if the watchdog is currently enabled or disabled (mortal or immortal).
|
||||
*
|
||||
* @return Enabled or disabled.
|
||||
*/
|
||||
bool getWatchdogEnabled(void* watchdog_pointer, int32_t *status) {
|
||||
Watchdog* watchdog = (Watchdog*) watchdog_pointer;
|
||||
bool enabled = !watchdog->readImmortal(status);
|
||||
return enabled;
|
||||
}
|
||||
|
||||
/**
|
||||
* 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 setWatchdogEnabled(void* watchdog_pointer, bool enabled, int32_t *status) {
|
||||
Watchdog* watchdog = (Watchdog*) watchdog_pointer;
|
||||
watchdog->writeImmortal(!enabled, status);
|
||||
}
|
||||
|
||||
/**
|
||||
* 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 isWatchdogAlive(void* watchdog_pointer, int32_t *status) {
|
||||
Watchdog* watchdog = (Watchdog*) watchdog_pointer;
|
||||
bool alive = watchdog->readStatus_Alive(status);
|
||||
return alive;
|
||||
}
|
||||
|
||||
/**
|
||||
* Check on the overall status of the system.
|
||||
*
|
||||
* @return Is the system active (i.e. PWM motor outputs, etc. enabled)?
|
||||
*/
|
||||
bool isWatchdogSystemActive(void* watchdog_pointer, int32_t *status) {
|
||||
Watchdog* watchdog = (Watchdog*) watchdog_pointer;
|
||||
bool alive = watchdog->readStatus_SystemActive(status);
|
||||
return alive;
|
||||
}
|
||||
120
hal/Athena/src/main/native/cpp/Resource.cpp
Normal file
120
hal/Athena/src/main/native/cpp/Resource.cpp
Normal file
@@ -0,0 +1,120 @@
|
||||
/*----------------------------------------------------------------------------*/
|
||||
/* Copyright (c) FIRST 2008. All Rights Reserved. */
|
||||
/* Open Source Software - may be modified and shared by FRC teams. The code */
|
||||
/* must be accompanied by the FIRST BSD license file in $(WIND_BASE)/WPILib. */
|
||||
/*----------------------------------------------------------------------------*/
|
||||
|
||||
#include "HAL/cpp/Resource.h"
|
||||
#include "HAL/Errors.h"
|
||||
#include <cstddef>
|
||||
|
||||
ReentrantSemaphore Resource::m_createLock;
|
||||
|
||||
/**
|
||||
* Allocate storage for a new instance of Resource.
|
||||
* Allocate a bool array of values that will get initialized to indicate that no resources
|
||||
* have been allocated yet. The indicies of the resources are [0 .. elements - 1].
|
||||
*/
|
||||
Resource::Resource(uint32_t elements)
|
||||
{
|
||||
Synchronized sync(m_createLock);
|
||||
m_size = elements;
|
||||
m_isAllocated = new bool[m_size];
|
||||
for (uint32_t i=0; i < m_size; i++)
|
||||
{
|
||||
m_isAllocated[i] = false;
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Factory method to create a Resource allocation-tracker *if* needed.
|
||||
*
|
||||
* @param r -- address of the caller's Resource pointer. If *r == NULL, this
|
||||
* will construct a Resource and make *r point to it. If *r != NULL, i.e.
|
||||
* the caller already has a Resource instance, this won't do anything.
|
||||
* @param elements -- the number of elements for this Resource allocator to
|
||||
* track, that is, it will allocate resource numbers in the range
|
||||
* [0 .. elements - 1].
|
||||
*/
|
||||
/*static*/ void Resource::CreateResourceObject(Resource **r, uint32_t elements)
|
||||
{
|
||||
Synchronized sync(m_createLock);
|
||||
if (*r == NULL)
|
||||
{
|
||||
*r = new Resource(elements);
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Delete the allocated array or resources.
|
||||
* This happens when the module is unloaded (provided it was statically allocated).
|
||||
*/
|
||||
Resource::~Resource()
|
||||
{
|
||||
delete[] m_isAllocated;
|
||||
}
|
||||
|
||||
/**
|
||||
* Allocate a resource.
|
||||
* When a resource is requested, mark it allocated. In this case, a free resource value
|
||||
* within the range is located and returned after it is marked allocated.
|
||||
*/
|
||||
uint32_t Resource::Allocate(const char *resourceDesc)
|
||||
{
|
||||
Synchronized sync(m_allocateLock);
|
||||
for (uint32_t i=0; i < m_size; i++)
|
||||
{
|
||||
if (!m_isAllocated[i])
|
||||
{
|
||||
m_isAllocated[i] = true;
|
||||
return i;
|
||||
}
|
||||
}
|
||||
// TODO: wpi_setWPIErrorWithContext(NoAvailableResources, resourceDesc);
|
||||
return ~0ul;
|
||||
}
|
||||
|
||||
/**
|
||||
* Allocate a specific resource value.
|
||||
* The user requests a specific resource value, i.e. channel number and it is verified
|
||||
* unallocated, then returned.
|
||||
*/
|
||||
uint32_t Resource::Allocate(uint32_t index, const char *resourceDesc)
|
||||
{
|
||||
Synchronized sync(m_allocateLock);
|
||||
if (index >= m_size)
|
||||
{
|
||||
// TODO: wpi_setWPIErrorWithContext(ChannelIndexOutOfRange, resourceDesc);
|
||||
return ~0ul;
|
||||
}
|
||||
if ( m_isAllocated[index] )
|
||||
{
|
||||
// TODO: wpi_setWPIErrorWithContext(ResourceAlreadyAllocated, resourceDesc);
|
||||
return ~0ul;
|
||||
}
|
||||
m_isAllocated[index] = true;
|
||||
return index;
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* Free an allocated resource.
|
||||
* After a resource is no longer needed, for example a destructor is called for a channel assignment
|
||||
* class, Free will release the resource value so it can be reused somewhere else in the program.
|
||||
*/
|
||||
void Resource::Free(uint32_t index)
|
||||
{
|
||||
Synchronized sync(m_allocateLock);
|
||||
if (index == ~0ul) return;
|
||||
if (index >= m_size)
|
||||
{
|
||||
// TODO: wpi_setWPIError(NotAllocated);
|
||||
return;
|
||||
}
|
||||
if (!m_isAllocated[index])
|
||||
{
|
||||
// TODO: wpi_setWPIError(NotAllocated);
|
||||
return;
|
||||
}
|
||||
m_isAllocated[index] = false;
|
||||
}
|
||||
15
hal/Athena/src/main/native/cpp/StackTrace.cpp
Normal file
15
hal/Athena/src/main/native/cpp/StackTrace.cpp
Normal file
@@ -0,0 +1,15 @@
|
||||
|
||||
#include "HAL/cpp/StackTrace.h"
|
||||
|
||||
#include "HAL/HAL.h"
|
||||
#include "../ChipObject.h"
|
||||
#include <stdio.h>
|
||||
|
||||
|
||||
void printCurrentStackTrace() {
|
||||
// TODO: Implement
|
||||
}
|
||||
|
||||
bool getErrnoToName(int32_t errNo, char* name) {
|
||||
return false; // TODO: Implement
|
||||
}
|
||||
49
hal/Athena/src/main/native/cpp/Synchronized.cpp
Normal file
49
hal/Athena/src/main/native/cpp/Synchronized.cpp
Normal file
@@ -0,0 +1,49 @@
|
||||
/*----------------------------------------------------------------------------*/
|
||||
/* Copyright (c) FIRST 2008. All Rights Reserved. */
|
||||
/* Open Source Software - may be modified and shared by FRC teams. The code */
|
||||
/* must be accompanied by the FIRST BSD license file in $(WIND_BASE)/WPILib. */
|
||||
/*----------------------------------------------------------------------------*/
|
||||
|
||||
#include "HAL/cpp/Synchronized.h"
|
||||
#include "HAL/Semaphore.h"
|
||||
|
||||
/**
|
||||
* Synchronized class deals with critical regions.
|
||||
* Declare a Synchronized object at the beginning of a block. That will take the semaphore.
|
||||
* When the code exits from the block it will call the destructor which will give the semaphore.
|
||||
* This ensures that no matter how the block is exited, the semaphore will always be released.
|
||||
* Use the CRITICAL_REGION(SEM_ID) and END_REGION macros to make the code look cleaner (see header file)
|
||||
* @param semaphore The semaphore controlling this critical region.
|
||||
*/
|
||||
Synchronized::Synchronized(MUTEX_ID semaphore)
|
||||
{
|
||||
m_mutex = semaphore;
|
||||
m_semaphore = NULL;
|
||||
takeMutex(m_mutex, SEMAPHORE_WAIT_FOREVER);
|
||||
}
|
||||
|
||||
Synchronized::Synchronized(SEMAPHORE_ID semaphore)
|
||||
{
|
||||
m_mutex = NULL;
|
||||
m_semaphore = semaphore;
|
||||
takeSemaphore(m_semaphore, SEMAPHORE_WAIT_FOREVER);
|
||||
}
|
||||
|
||||
Synchronized::Synchronized(ReentrantSemaphore& semaphore)
|
||||
{
|
||||
m_mutex = semaphore.m_semaphore;
|
||||
m_semaphore = NULL;
|
||||
takeMutex(m_mutex, SEMAPHORE_WAIT_FOREVER);
|
||||
}
|
||||
|
||||
/**
|
||||
* This destructor unlocks the semaphore.
|
||||
*/
|
||||
Synchronized::~Synchronized()
|
||||
{
|
||||
if (m_mutex != NULL) {
|
||||
giveMutex(m_mutex);
|
||||
} else {
|
||||
giveSemaphore(m_semaphore);
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user