Modules | |
IO Indices | |
Indices (0-63) for each of the processor's IO lines. | |
IO Bits | |
The values to use to create a mask to pass into any of the Bits style functions. | |
Functions | |
int | Io_Start (int index, bool lock) |
Get access to an IO line, possibly locking it. | |
int | Io_Stop (int index) |
Release your lock on an IO line, possibly deactivating it. | |
bool | Io_GetActive (int index) |
Read whether an IO pin is in use. | |
int | Io_SetDirection (int index, bool output) |
Set whether an IO line is an output or an input. | |
bool | Io_GetDirection (int index) |
Read whether an IO line is an output or an input. | |
int | Io_SetValue (int index, bool value) |
Turn an IO line on or off. | |
bool | Io_GetValue (int index) |
Read whether an IO line, presumably set as an output, is on or off. | |
int | Io_SetPeripheralA (int index) |
Configure an IO line to be part of its peripheral A. | |
int | Io_SetPeripheralB (int index) |
Configure an IO line to be part of its peripheral B. | |
int | Io_SetPio (int index, bool enable) |
Configure an IO line to be a general purpose IO. | |
bool | Io_GetPio (int index) |
Read whether an IO line is configured as a general purpose IO. | |
int | Io_SetPullup (int index, bool enable) |
Set the pullup resistor for an IO line on or off. | |
bool | Io_GetPullup (int index) |
Read whether the pullup resistor for an IO line on or off. | |
void | Io_SetValueBits (longlong bits, longlong values) |
Set the values of a batch of IO lines at once. | |
void | Io_SetDirectionBits (longlong bits, bool output) |
Set a batch of IO lines to a particular direction (in or out) at once. | |
void | Io_SetPioBits (longlong bits, bool enable) |
Set a batch of IO lines to being general IOs at once. | |
longlong | Io_GetValueBits () |
Get a bitmask with the output values of all the IO lines. | |
longlong | Io_GetPullupBits () |
Get a bitmask with the state of the internal pullup for all the IO lines. | |
longlong | Io_GetPioBits () |
Get a bitmask indicating PIO configuration for all the IO lines. | |
longlong | Io_GetDirectionBits () |
Get a bitmask indicating the in-or-out configuration for all the IO lines. |
The 64 IO (Input/Output) lines on the Make Controller are grouped into 2 ports of 32 lines each, port A and port B. Each line has many parameters that can be configured:
In addition, all IO pins serve at least double and sometimes triple duty, being general IO lines and also being IO lines for one or more of the controller's many on-chip peripherals, such as the Ethernet system, USB system, SPI, UART, etc. To help address this, the IO system provides a mechanism to "lock" the IO lines, so that you can always be sure that your line has not been altered by some other system while you weren't looking.
To find the index to use for a single line, please see IO Indices. For the constants to help create masks for the Bits style, please see IO Bits.
bool Io_GetActive | ( | int | index | ) |
Read whether an IO pin is in use.
index | An int specifying which IO line. Use the appropriate entry from the IO Indices |
if( Io_GetActive( IO_PA23 ) ) { // it's already active } else { // not yet active }
bool Io_GetDirection | ( | int | index | ) |
Read whether an IO line is an output or an input.
index | An int specifying which IO line. Use the appropriate entry from the IO Indices |
// Check whether IO 23 is an output or input if( Io_GetDirection( IO_PA23 ) ) { // then we're an output } else { // we're an input }
longlong Io_GetDirectionBits | ( | void | ) |
Get a bitmask indicating the in-or-out configuration for all the IO lines.
longlong directions = Io_GetDirectionBits( ); if( directions & IO_PA18_BIT ) { // then we know PA18 is configured as an output }
bool Io_GetPio | ( | int | index | ) |
Read whether an IO line is configured as a general purpose IO.
index | An int specifying which IO line. Use the appropriate entry from the IO Indices |
longlong Io_GetPioBits | ( | void | ) |
Get a bitmask indicating PIO configuration for all the IO lines.
longlong pios = Io_GetPioBits( ); if( pios & IO_PA18_BIT ) { // then we know PA18 is configured as a PIO }
bool Io_GetPullup | ( | int | index | ) |
Read whether the pullup resistor for an IO line on or off.
index | An int specifying which IO line. Use the appropriate entry from the IO Indices |
// Turn on the pullup for IO 17 Io_GetPullup( IO_PA17 );
longlong Io_GetPullupBits | ( | void | ) |
Get a bitmask with the state of the internal pullup for all the IO lines.
longlong pullups = Io_GetPullupBits( ); if( pullups & IO_PA18_BIT ) { // then we know PA18 has its pullup turned on }
bool Io_GetValue | ( | int | index | ) |
Read whether an IO line, presumably set as an output, is on or off.
index | An int specifying which IO line. Use the appropriate entry from the IO Indices |
// Turn on IO 17 Io_SetValue( IO_PA17, 1 );
longlong Io_GetValueBits | ( | void | ) |
Get a bitmask with the output values of all the IO lines.
longlong values = Io_GetValueBits( ); if( values & IO_PA18_BIT ) { // then we know PA18 is configured as an output }
int Io_SetDirection | ( | int | index, | |
bool | output | |||
) |
Set whether an IO line is an output or an input.
Use the IO_INPUT and IO_OUTPUT symbols to avoid confusion.
index | An int specifying which IO line. Use the appropriate entry from the IO Indices | |
output | Specify 1 for an output, or 0 for an input. |
// Set io23 to an input if( Io_SetDirection( IO_PA23, IO_INPUT ) == CONTROLLER_OK ) { // success }
void Io_SetDirectionBits | ( | longlong | bits, | |
bool | output | |||
) |
Set a batch of IO lines to a particular direction (in or out) at once.
bits | The bitmask containing the IO lines you'd like to configure - see IO Bits. Must be a longlong to accommodate all 64 bits. | |
output | true to set the lines as outputs, false to set them as inputs |
int Io_SetPeripheralA | ( | int | index | ) |
Configure an IO line to be part of its peripheral A.
index | An int specifying which IO line. Use the appropriate entry from the IO Indices |
int Io_SetPeripheralB | ( | int | index | ) |
Configure an IO line to be part of its peripheral B.
index | An int specifying which IO line. Use the appropriate entry from the IO Indices |
int Io_SetPio | ( | int | index, | |
bool | enable | |||
) |
Configure an IO line to be a general purpose IO.
index | An int specifying which IO line. Use the appropriate entry from the IO Indices | |
enable | Whether to enable a pin as a PIO or disable it, reverting to an unconfigured state. |
void Io_SetPioBits | ( | longlong | bits, | |
bool | enable | |||
) |
int Io_SetPullup | ( | int | index, | |
bool | enable | |||
) |
Set the pullup resistor for an IO line on or off.
index | An int specifying which IO line. Use the appropriate entry from the IO Indices | |
enable | Non-zero for on, 0 for off. |
// Turn on the pullup for IO 17 Io_SetPullup( IO_PA17, 1 );
int Io_SetValue | ( | int | index, | |
bool | value | |||
) |
Turn an IO line on or off.
This IO should have already been set to be an output via Io_SetDirection( )
index | An int specifying which IO line. Use the appropriate entry from the IO Indices | |
value | Non-zero for on, 0 for off. |
// Turn on IO 17 Io_SetValue( IO_PA17, 1 );
void Io_SetValueBits | ( | longlong | bits, | |
longlong | values | |||
) |
Set the values of a batch of IO lines at once.
bits | The bitmask containing the IO lines you'd like to configure - see IO Bits. Must be a longlong to accommodate all 64 bits. | |
values | The mask of 0 or non-0 values that you'd like to write into those lines. |
int Io_Start | ( | int | index, | |
bool | lock | |||
) |
Get access to an IO line, possibly locking it.
index | The IO line to start - use the appropriate entry from IO Indices | |
lock | Whether to lock this line from being used by another system. |
if( Io_Start(IO_PA18, true) == CONTROLLER_OK) { // then we have access to PA18 and successfully locked it } else // can't use PA18
int Io_Stop | ( | int | index | ) |
Release your lock on an IO line, possibly deactivating it.
When you call Io_Stop(), it will remove the lock you placed on the line. If no other systems are using it, the line will be deactivated.
index | The IO line to stop - use the appropriate entry from IO Indices |