WPILib 2012
WPILibRoboticsLibraryforFRC
Public Member Functions | Static Public Member Functions | Protected Member Functions | Friends
DigitalModule Class Reference
Inheritance diagram for DigitalModule:
Module SensorBase ErrorBase

List of all members.

Public Member Functions

void SetPWM (UINT32 channel, UINT8 value)
UINT8 GetPWM (UINT32 channel)
void SetPWMPeriodScale (UINT32 channel, UINT32 squelchMask)
void SetRelayForward (UINT32 channel, bool on)
void SetRelayReverse (UINT32 channel, bool on)
bool GetRelayForward (UINT32 channel)
UINT8 GetRelayForward ()
bool GetRelayReverse (UINT32 channel)
UINT8 GetRelayReverse ()
bool AllocateDIO (UINT32 channel, bool input)
void FreeDIO (UINT32 channel)
void SetDIO (UINT32 channel, short value)
bool GetDIO (UINT32 channel)
UINT16 GetDIO ()
bool GetDIODirection (UINT32 channel)
UINT16 GetDIODirection ()
void Pulse (UINT32 channel, float pulseLength)
bool IsPulsing (UINT32 channel)
bool IsPulsing ()
UINT32 AllocateDO_PWM ()
void FreeDO_PWM (UINT32 pwmGenerator)
void SetDO_PWMRate (float rate)
void SetDO_PWMDutyCycle (UINT32 pwmGenerator, float dutyCycle)
void SetDO_PWMOutputChannel (UINT32 pwmGenerator, UINT32 channel)
I2CGetI2C (UINT32 address)

Static Public Member Functions

static DigitalModuleGetInstance (UINT8 moduleNumber)
static UINT8 RemapDigitalChannel (UINT32 channel)
static UINT8 UnmapDigitalChannel (UINT32 channel)

Protected Member Functions

 DigitalModule (UINT8 moduleNumber)

Friends

class I2C
class Module

Constructor & Destructor Documentation

DigitalModule::DigitalModule ( UINT8  moduleNumber) [explicit, protected]

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  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 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  channel)

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

Parameters:
channelThe Digital I/O channel to free
void DigitalModule::FreeDO_PWM ( UINT32  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  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 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.

UINT16 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.

bool DigitalModule::GetDIODirection ( UINT32  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
I2C * DigitalModule::GetI2C ( UINT32  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  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).
UINT8 DigitalModule::GetPWM ( UINT32  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  channel)

Get the current state of the forward relay channel

UINT8 DigitalModule::GetRelayForward ( )

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

UINT8 DigitalModule::GetRelayReverse ( )

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

bool DigitalModule::GetRelayReverse ( UINT32  channel)

Get the current state of the reverse relay channel

bool DigitalModule::IsPulsing ( )

Check if any DIO line is currently generating a pulse.

Returns:
A pulse on some line is in progress
bool DigitalModule::IsPulsing ( UINT32  channel)

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

Returns:
A pulse is in progress
void DigitalModule::Pulse ( UINT32  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  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  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  pwmGenerator,
UINT32  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  channel,
UINT8  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  channel,
UINT32  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  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  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:
 All Classes Functions Variables