Synopsis
typedef enum {
PLATFORM_NO_CONNECTION,
PLATFORM_END_OF_LIST
} PLATFORM_PIN_CONNECTION_t;
Description
PLATFORM_PIN_CONNECTION_t is an enumeration that describes a pin connection. A pin
connection is platform-specific and encodes a port and a pin within that
port using a single integer.
There are two distinguished values that the Platform Library uses when
accepting or defining a pin:
-
PLATFORM_NO_CONNECTION in a pin list indicates that there is
no direct connection for this pin. For instance, a button that is not
directly connected to a GPIO will specify this for the pin member
for the button in the button catalog: the button can still be read using
platform_read_button, but the implementation of the Platform Library
will not read directly from the pin for that button. This is useful,
for instance, when a joystick or buttons are analog-encoded using
resistors to change an analog input to indicate which buttons are pressed.
-
PLATFORM_END_OF_LIST indicates the end of a list. Any API call
that requires a list must terminate the list with this value. In addition,
any lists returned by an API call (for instance, platform_led_catalog)
will ensure that the list is correctly terminated by the value.
The pins encoded by the Platform Library must lie in the range 0x00 to
0xF0 inclusive, to allow for future expansion of the API. This allows
a pin to be encoded in a structure using an unsigned char.
In many API prototypes, the pin connection type is int rather than
PLATFORM_PIN_CONNECTION_t for brevity: any argument with type int and name pin is
understood to mean the argument is of type PLATFORM_PIN_CONNECTION_t.
For various platform footprints, a common set of symbols are defined
which map the microprocessor pin to a platform connector. For instance,
As such, on any platform that supports an Arduino footprint, you can
use the symbol ARDUINO_D0 to indicate "the pin connected to Arduino
digital header D0".
Arduino
The following constants are supplied by the Platform Library for evaluation
boards that support an Arduino footprint:
-
ARDUINO_D0 through ARDUINO_D12
- These constants define the pins connected to the Arduino digital headers.
-
ARDUINO_A0 through ARDUINO_A5
- These constants define the pins connected to the Arduino analog headers.
In addition, some synonyms are provided by the Platform Library:
-
ARDUINO_RX and ARDUINO_TX
- Equivalent to ARDUINO_D0 and ARDUINO_D1, for UART communication.
-
ARDUINO_MOSI, ARDUINO_MISO, and ARDUINO_SCK
- Equivalent to ARDUINO_D11, ARDUINO_D12, and ARDUINO_D13,
for SPI communication.
-
ARDUINO_SDA and ARDUINO_SCL
- Equivalent to ARDUINO_A4 and ARDUINO_A5, for I2C communication.
Some Arduino-style platforms, such as the Freedom boards, may also support
the R3 format with:
-
LEONARDO_SCL and LEONARDO_SDA
- For boards that route the A4/A5 signals to SDA/SCL on the digital header,
LEONARDO_SCL will be set to ARDUINO_A4 and LEONARDO_SDA will
be set to ARDUINO_A5. For boards with A4/A5 independent from SDA/SCL,
LEONARDO_SCL and LEONARDO_SDA will be defines as the appropriate
pin connection.
mbed
-
MBED_P4 through MBED_P30
- These constants define the pins connected to the dual-in-line header
pins of an mbed socket.
LaunchPad
-
LAUNCHPAD_A2 through LAUNCHPAD_A7
- These constants define the pins connected to the "A" connector
of a LaunchPad socket.
-
LAUNCHPAD_B2 through LAUNCHPAD_B7
- These constants define the pins connected to the "B" connector
of a LaunchPad socket.
In addition, some synonyms are provided by the Platform Library:
-
LAUNCHPAD_AIN
- Equivalent to LAUNCHPAD_A2, an analog input.
-
LAUNCHPAD_RX and LAUNCHPAD_TX
- Equivalent to LAUNCHPAD_A3 and LAUNCHPAD_A4, for UART communication.
-
LAUNCHPAD_SDA and LAUNCHPAD_SCL
- Equivalent to LAUNCHPAD_B6 and LAUNCHPAD_B7, for I2C communication.
-
LAUNCHPAD_INT_0 and LAUNCHPAD_INT_1
- Equivalent to LAUNCHPAD_A5 and LAUNCHPAD_B3, pins capable
of generating external interrupt requests.
-
LAUNCHPAD_SPI_A_SCK, LAUNCHPAD_SPI_B_SCK,
LAUNCHPAD_MOSI, and LAUNCHPAD_MISO
- Equivalent to LAUNCHPAD_A6, LAUNCHPAD_A7, LAUNCHPAD_B6,
and LAUNCHPAD_B7, for SPI communication.
-
LAUNCHPAD_TMR_OUT
- Equivalent to LAUNCHPAD_B2, for timer event output.