WPILib  2014.0
WPIRoboticsLibraryforFRC
 All Classes Functions Variables Pages
Public Member Functions | Static Public Member Functions | Protected Member Functions | Friends | List of all members
DigitalModule Class Reference
Inheritance diagram for DigitalModule:
Module SensorBase ErrorBase

Public Member Functions

void SetPWM (uint32_t channel, uint8_t value)
 
uint8_t GetPWM (uint32_t channel)
 
void SetPWMPeriodScale (uint32_t channel, uint32_t squelchMask)
 
void SetRelayForward (uint32_t channel, bool on)
 
void SetRelayReverse (uint32_t channel, bool on)
 
bool GetRelayForward (uint32_t channel)
 
uint8_t GetRelayForward ()
 
bool GetRelayReverse (uint32_t channel)
 
uint8_t GetRelayReverse ()
 
bool AllocateDIO (uint32_t channel, bool input)
 
void FreeDIO (uint32_t channel)
 
void SetDIO (uint32_t channel, short value)
 
bool GetDIO (uint32_t channel)
 
uint16_t GetDIO ()
 
bool GetDIODirection (uint32_t channel)
 
uint16_t GetDIODirection ()
 
void Pulse (uint32_t channel, float pulseLength)
 
bool IsPulsing (uint32_t channel)
 
bool IsPulsing ()
 
uint32_t AllocateDO_PWM ()
 
void FreeDO_PWM (uint32_t pwmGenerator)
 
void SetDO_PWMRate (float rate)
 
void SetDO_PWMDutyCycle (uint32_t pwmGenerator, float dutyCycle)
 
void SetDO_PWMOutputChannel (uint32_t pwmGenerator, uint32_t channel)
 
uint16_t GetLoopTiming ()
 
I2CGetI2C (uint32_t address)
 
- Public Member Functions inherited from Module
nLoadOut::tModuleType GetType ()
 
uint8_t GetNumber ()
 
- Public Member Functions inherited from SensorBase
 SensorBase ()
 
virtual ~SensorBase ()
 
- Public Member Functions inherited from ErrorBase
virtual ErrorGetError ()
 Retrieve the current error. Get the current error information associated with this sensor.
 
virtual const ErrorGetError () const
 
virtual void SetErrnoError (const char *contextMessage, const char *filename, const char *function, uint32_t lineNumber) const
 Set error information associated with a C library call that set an error to the "errno" global variable. More...
 
virtual void SetImaqError (int success, const char *contextMessage, const char *filename, const char *function, uint32_t lineNumber) const
 Set the current error information associated from the nivision Imaq API. More...
 
virtual void SetError (Error::Code code, const char *contextMessage, const char *filename, const char *function, uint32_t lineNumber) const
 Set the current error information associated with this sensor. More...
 
virtual void SetWPIError (const char *errorMessage, const char *contextMessage, const char *filename, const char *function, uint32_t lineNumber) const
 Set the current error information associated with this sensor. More...
 
virtual void CloneError (ErrorBase *rhs) const
 
virtual void ClearError () const
 Clear the current error information associated with this sensor.
 
virtual bool StatusIsFatal () const
 Check if the current error code represents a fatal error. More...
 

Static Public Member Functions

static DigitalModuleGetInstance (uint8_t moduleNumber)
 
static uint8_t RemapDigitalChannel (uint32_t channel)
 
static uint8_t UnmapDigitalChannel (uint32_t channel)
 
- Static Public Member Functions inherited from Module
static ModuleGetModule (nLoadOut::tModuleType type, uint8_t number)
 
- Static Public Member Functions inherited from SensorBase
static void DeleteSingletons ()
 
static uint32_t GetDefaultAnalogModule ()
 
static uint32_t GetDefaultDigitalModule ()
 
static uint32_t GetDefaultSolenoidModule ()
 
static bool CheckAnalogModule (uint8_t moduleNumber)
 
static bool CheckDigitalModule (uint8_t moduleNumber)
 
static bool CheckPWMModule (uint8_t moduleNumber)
 
static bool CheckRelayModule (uint8_t moduleNumber)
 
static bool CheckSolenoidModule (uint8_t moduleNumber)
 
static bool CheckDigitalChannel (uint32_t channel)
 
static bool CheckRelayChannel (uint32_t channel)
 
static bool CheckPWMChannel (uint32_t channel)
 
static bool CheckAnalogChannel (uint32_t channel)
 
static bool CheckSolenoidChannel (uint32_t channel)
 
- Static Public Member Functions inherited from ErrorBase
static void SetGlobalError (Error::Code code, const char *contextMessage, const char *filename, const char *function, uint32_t lineNumber)
 
static void SetGlobalWPIError (const char *errorMessage, const char *contextMessage, const char *filename, const char *function, uint32_t lineNumber)
 
static ErrorGetGlobalError ()
 

Protected Member Functions

 DigitalModule (uint8_t moduleNumber)
 
- Protected Member Functions inherited from Module
 Module (nLoadOut::tModuleType type, uint8_t number)
 
virtual ~Module ()
 
- Protected Member Functions inherited from SensorBase
void AddToSingletonList ()
 
- Protected Member Functions inherited from ErrorBase
 ErrorBase ()
 Initialize the instance status to 0 for now.
 

Friends

class I2C
 
class Module
 

Additional Inherited Members

- Static Public Attributes inherited from SensorBase
static const uint32_t kSystemClockTicksPerMicrosecond = 40
 
static const uint32_t kDigitalChannels = 14
 
static const uint32_t kAnalogChannels = 8
 
static const uint32_t kAnalogModules = 2
 
static const uint32_t kDigitalModules = 2
 
static const uint32_t kSolenoidChannels = 8
 
static const uint32_t kSolenoidModules = 2
 
static const uint32_t kPwmChannels = 10
 
static const uint32_t kRelayChannels = 8
 
static const uint32_t kChassisSlots = 8
 
- Protected Attributes inherited from Module
nLoadOut::tModuleType m_moduleType
 The type of module represented.
 
uint8_t m_moduleNumber
 The module index within the module type.
 
- Protected Attributes inherited from ErrorBase
Error m_error
 
- Static Protected Attributes inherited from ErrorBase
static SEM_ID _globalErrorMutex = semMCreate(SEM_Q_PRIORITY | SEM_DELETE_SAFE | SEM_INVERSION_SAFE)
 
static Error _globalError
 

Constructor & Destructor Documentation

DigitalModule::DigitalModule ( uint8_t  moduleNumber)
explicitprotected

Create a new instance of an digital module. Create an instance of the digital module object. Initialize all the parameters to reasonable values on start. Setting a global value on an digital module can be done only once unless subsequent values are set the previously set value. Digital modules are a singleton, so the constructor is never called outside of this class.

Parameters
moduleNumberThe digital module to create (1 or 2).

Member Function Documentation

bool DigitalModule::AllocateDIO ( uint32_t  channel,
bool  input 
)

Allocate Digital I/O channels. Allocate channels so that they are not accidently reused. Also the direction is set at the time of the allocation.

Parameters
channelThe Digital I/O channel
inputIf true open as input; if false open as output
Returns
Was successfully allocated
uint32_t DigitalModule::AllocateDO_PWM ( )

Allocate a DO PWM Generator. Allocate PWM generators so that they are not accidently reused.

Returns
PWM Generator refnum
void DigitalModule::FreeDIO ( uint32_t  channel)

Free the resource associated with a digital I/O channel.

Parameters
channelThe Digital I/O channel to free
void DigitalModule::FreeDO_PWM ( uint32_t  pwmGenerator)

Free the resource associated with a DO PWM generator.

Parameters
pwmGeneratorThe pwmGen to free that was allocated with AllocateDO_PWM()
bool DigitalModule::GetDIO ( uint32_t  channel)

Read a digital I/O bit from the FPGA. Get a single value from a digital I/O channel.

Parameters
channelThe digital I/O channel
Returns
The state of the specified channel
uint16_t DigitalModule::GetDIO ( )

Read the state of all the Digital I/O lines from the FPGA These are not remapped to logical order. They are still in hardware order.

bool DigitalModule::GetDIODirection ( uint32_t  channel)

Read the direction of a the Digital I/O lines A 1 bit means output and a 0 bit means input.

Parameters
channelThe digital I/O channel
Returns
The direction of the specified channel
uint16_t DigitalModule::GetDIODirection ( )

Read the direction of all the Digital I/O lines from the FPGA A 1 bit means output and a 0 bit means input. These are not remapped to logical order. They are still in hardware order.

I2C * DigitalModule::GetI2C ( uint32_t  address)

Return a pointer to an I2C object for this digital module The caller is responsible for deleting the pointer.

Parameters
addressThe address of the device on the I2C bus
Returns
A pointer to an I2C object to talk to the device at address
DigitalModule * DigitalModule::GetInstance ( uint8_t  moduleNumber)
static

Get an instance of an Digital Module. Singleton digital module creation where a module is allocated on the first use and the same module is returned on subsequent uses.

Parameters
moduleNumberThe digital module to get (1 or 2).
uint16_t DigitalModule::GetLoopTiming ( )

Get the loop timing of the Digital Module

Returns
The loop time
uint8_t DigitalModule::GetPWM ( uint32_t  channel)

Get a value from a PWM channel. The values range from 0 to 255.

Parameters
channelThe PWM channel to read from.
Returns
The raw PWM value.
bool DigitalModule::GetRelayForward ( uint32_t  channel)

Get the current state of the forward relay channel

uint8_t DigitalModule::GetRelayForward ( )

Get the current state of all of the forward relay channels on this module.

bool DigitalModule::GetRelayReverse ( uint32_t  channel)

Get the current state of the reverse relay channel

uint8_t DigitalModule::GetRelayReverse ( )

Get the current state of all of the reverse relay channels on this module.

bool DigitalModule::IsPulsing ( uint32_t  channel)

Check a DIO line to see if it is currently generating a pulse.

Returns
A pulse is in progress
bool DigitalModule::IsPulsing ( )

Check if any DIO line is currently generating a pulse.

Returns
A pulse on some line is in progress
void DigitalModule::Pulse ( uint32_t  channel,
float  pulseLength 
)

Generate a single pulse. Write a pulse to the specified digital output channel. There can only be a single pulse going at any time.

Parameters
channelThe Digital Output channel that the pulse should be output on
pulseLengthThe active length of the pulse (in seconds)
void DigitalModule::SetDIO ( uint32_t  channel,
short  value 
)

Write a digital I/O bit to the FPGA. Set a single value on a digital I/O channel.

Parameters
channelThe Digital I/O channel
valueThe state to set the digital channel (if it is configured as an output)
void DigitalModule::SetDO_PWMDutyCycle ( uint32_t  pwmGenerator,
float  dutyCycle 
)

Configure the duty-cycle of the PWM generator

Parameters
pwmGeneratorThe generator index reserved by AllocateDO_PWM()
dutyCycleThe percent duty cycle to output [0..1].
void DigitalModule::SetDO_PWMOutputChannel ( uint32_t  pwmGenerator,
uint32_t  channel 
)

Configure which DO channel the PWM siganl is output on

Parameters
pwmGeneratorThe generator index reserved by AllocateDO_PWM()
channelThe Digital Output channel to output on
void DigitalModule::SetDO_PWMRate ( float  rate)

Change the frequency of the DO PWM generator.

The valid range is from 0.6 Hz to 19 kHz. The frequency resolution is logarithmic.

Parameters
rateThe frequency to output all digital output PWM signals on this module.
void DigitalModule::SetPWM ( uint32_t  channel,
uint8_t  value 
)

Set a PWM channel to the desired value. The values range from 0 to 255 and the period is controlled by the PWM Period and MinHigh registers.

Parameters
channelThe PWM channel to set.
valueThe PWM value to set.
void DigitalModule::SetPWMPeriodScale ( uint32_t  channel,
uint32_t  squelchMask 
)

Set how how often the PWM signal is squelched, thus scaling the period.

Parameters
channelThe PWM channel to configure.
squelchMaskThe 2-bit mask of outputs to squelch.
void DigitalModule::SetRelayForward ( uint32_t  channel,
bool  on 
)

Set the state of a relay. Set the state of a relay output to be forward. Relays have two outputs and each is independently set to 0v or 12v.

void DigitalModule::SetRelayReverse ( uint32_t  channel,
bool  on 
)

Set the state of a relay. Set the state of a relay output to be reverse. Relays have two outputs and each is independently set to 0v or 12v.


The documentation for this class was generated from the following files: