|
| enum | pin_fn_t {
PIN_FN_0 = 0
, PIN_FN_1 = 1
, PIN_FN_2 = 2
, PIN_FN_3 = 3
,
PIN_FN_IN = 4
, PIN_FN_OUT = 8
, PIN_FN_IN = 4
, PIN_FN_OUT = 8
,
PIN_FN_A
, PIN_FN_B
, PIN_FN_C
, PIN_FN_D
,
PIN_FN_IN = 4
, PIN_FN_OUT = 8
, PIN_FN_0 = 0
, PIN_FN_1 = 1
,
PIN_FN_2 = 2
, PIN_FN_3 = 3
, PIN_FN_4 = 6
, PIN_FN_5 = 7
,
PIN_FN_6 = 8
, PIN_FN_7 = 9
, PIN_FN_8 = 10
, PIN_FN_9 = 11
,
PIN_FN_10 = 12
, PIN_FN_11 = 13
, PIN_FN_12 = 14
, PIN_FN_13 = 15
,
PIN_FN_14 = 16
, PIN_FN_15 = 17
, PIN_FN_16 = 18
, PIN_FN_17 = 19
,
PIN_FN_18 = 20
, PIN_FN_19 = 21
, PIN_FN_20 = 22
, PIN_FN_21 = 23
,
PIN_FN_22 = 24
, PIN_FN_23 = 25
, PIN_FN_24 = 26
, PIN_FN_25 = 27
,
PIN_FN_26 = 28
, PIN_FN_27 = 29
, PIN_FN_28 = 30
, PIN_FN_29 = 31
,
PIN_FN_30 = 32
, PIN_FN_31 = 33
, PIN_FN_32 = 34
, PIN_FN_IN = 4
,
PIN_FN_OUT = 8
, PIN_FN_0 = 0
, PIN_FN_1 = 1
, PIN_FN_2 = 2
,
PIN_FN_3 = 3
, PIN_FN_4 = 6
, PIN_FN_5 = 7
, PIN_FN_6 = 8
,
PIN_FN_7 = 9
, PIN_FN_8 = 10
, PIN_FN_9 = 11
, PIN_FN_10 = 12
,
PIN_FN_11 = 13
, PIN_FN_12 = 14
, PIN_FN_UNKNOWN =0xFE
, PIN_FN_ERR =0xFF
} |
| | Pin Function modes to configure the managed pin(s). More...
|
| enum | pull_t |
| | Pin pullup and pulldown modes to configure the managed pin(s).
|
| enum | pin_fn_t {
PIN_FN_0 = 0
, PIN_FN_1 = 1
, PIN_FN_2 = 2
, PIN_FN_3 = 3
,
PIN_FN_IN = 4
, PIN_FN_OUT = 8
, PIN_FN_IN = 4
, PIN_FN_OUT = 8
,
PIN_FN_A
, PIN_FN_B
, PIN_FN_C
, PIN_FN_D
,
PIN_FN_IN = 4
, PIN_FN_OUT = 8
, PIN_FN_0 = 0
, PIN_FN_1 = 1
,
PIN_FN_2 = 2
, PIN_FN_3 = 3
, PIN_FN_4 = 6
, PIN_FN_5 = 7
,
PIN_FN_6 = 8
, PIN_FN_7 = 9
, PIN_FN_8 = 10
, PIN_FN_9 = 11
,
PIN_FN_10 = 12
, PIN_FN_11 = 13
, PIN_FN_12 = 14
, PIN_FN_13 = 15
,
PIN_FN_14 = 16
, PIN_FN_15 = 17
, PIN_FN_16 = 18
, PIN_FN_17 = 19
,
PIN_FN_18 = 20
, PIN_FN_19 = 21
, PIN_FN_20 = 22
, PIN_FN_21 = 23
,
PIN_FN_22 = 24
, PIN_FN_23 = 25
, PIN_FN_24 = 26
, PIN_FN_25 = 27
,
PIN_FN_26 = 28
, PIN_FN_27 = 29
, PIN_FN_28 = 30
, PIN_FN_29 = 31
,
PIN_FN_30 = 32
, PIN_FN_31 = 33
, PIN_FN_32 = 34
, PIN_FN_IN = 4
,
PIN_FN_OUT = 8
, PIN_FN_0 = 0
, PIN_FN_1 = 1
, PIN_FN_2 = 2
,
PIN_FN_3 = 3
, PIN_FN_4 = 6
, PIN_FN_5 = 7
, PIN_FN_6 = 8
,
PIN_FN_7 = 9
, PIN_FN_8 = 10
, PIN_FN_9 = 11
, PIN_FN_10 = 12
,
PIN_FN_11 = 13
, PIN_FN_12 = 14
, PIN_FN_UNKNOWN =0xFE
, PIN_FN_ERR =0xFF
} |
| | Pin Function modes to configure the managed pin(s). More...
|
| enum | pin_fn_t {
PIN_FN_0 = 0
, PIN_FN_1 = 1
, PIN_FN_2 = 2
, PIN_FN_3 = 3
,
PIN_FN_IN = 4
, PIN_FN_OUT = 8
, PIN_FN_IN = 4
, PIN_FN_OUT = 8
,
PIN_FN_A
, PIN_FN_B
, PIN_FN_C
, PIN_FN_D
,
PIN_FN_IN = 4
, PIN_FN_OUT = 8
, PIN_FN_0 = 0
, PIN_FN_1 = 1
,
PIN_FN_2 = 2
, PIN_FN_3 = 3
, PIN_FN_4 = 6
, PIN_FN_5 = 7
,
PIN_FN_6 = 8
, PIN_FN_7 = 9
, PIN_FN_8 = 10
, PIN_FN_9 = 11
,
PIN_FN_10 = 12
, PIN_FN_11 = 13
, PIN_FN_12 = 14
, PIN_FN_13 = 15
,
PIN_FN_14 = 16
, PIN_FN_15 = 17
, PIN_FN_16 = 18
, PIN_FN_17 = 19
,
PIN_FN_18 = 20
, PIN_FN_19 = 21
, PIN_FN_20 = 22
, PIN_FN_21 = 23
,
PIN_FN_22 = 24
, PIN_FN_23 = 25
, PIN_FN_24 = 26
, PIN_FN_25 = 27
,
PIN_FN_26 = 28
, PIN_FN_27 = 29
, PIN_FN_28 = 30
, PIN_FN_29 = 31
,
PIN_FN_30 = 32
, PIN_FN_31 = 33
, PIN_FN_32 = 34
, PIN_FN_IN = 4
,
PIN_FN_OUT = 8
, PIN_FN_0 = 0
, PIN_FN_1 = 1
, PIN_FN_2 = 2
,
PIN_FN_3 = 3
, PIN_FN_4 = 6
, PIN_FN_5 = 7
, PIN_FN_6 = 8
,
PIN_FN_7 = 9
, PIN_FN_8 = 10
, PIN_FN_9 = 11
, PIN_FN_10 = 12
,
PIN_FN_11 = 13
, PIN_FN_12 = 14
, PIN_FN_UNKNOWN =0xFE
, PIN_FN_ERR =0xFF
} |
| | Pin Function modes to configure the managed pin(s). More...
|
| enum | pull_t |
| | Pin pullup and pulldown modes to configure the managed pin(s).
|
| enum | analogAveraging_t {
ANALOG_AVG_NONE = 0
, ANALOG_AVG_4 = 1
, ANALOG_AVG_8 = 2
, ANALOG_AVG_16 = 3
,
ANALOG_AVG_32 = 4
} |
| | ADC hardware averaging settings for analogSetAveraging(). More...
|
| enum | pin_fn_t {
PIN_FN_0 = 0
, PIN_FN_1 = 1
, PIN_FN_2 = 2
, PIN_FN_3 = 3
,
PIN_FN_IN = 4
, PIN_FN_OUT = 8
, PIN_FN_IN = 4
, PIN_FN_OUT = 8
,
PIN_FN_A
, PIN_FN_B
, PIN_FN_C
, PIN_FN_D
,
PIN_FN_IN = 4
, PIN_FN_OUT = 8
, PIN_FN_0 = 0
, PIN_FN_1 = 1
,
PIN_FN_2 = 2
, PIN_FN_3 = 3
, PIN_FN_4 = 6
, PIN_FN_5 = 7
,
PIN_FN_6 = 8
, PIN_FN_7 = 9
, PIN_FN_8 = 10
, PIN_FN_9 = 11
,
PIN_FN_10 = 12
, PIN_FN_11 = 13
, PIN_FN_12 = 14
, PIN_FN_13 = 15
,
PIN_FN_14 = 16
, PIN_FN_15 = 17
, PIN_FN_16 = 18
, PIN_FN_17 = 19
,
PIN_FN_18 = 20
, PIN_FN_19 = 21
, PIN_FN_20 = 22
, PIN_FN_21 = 23
,
PIN_FN_22 = 24
, PIN_FN_23 = 25
, PIN_FN_24 = 26
, PIN_FN_25 = 27
,
PIN_FN_26 = 28
, PIN_FN_27 = 29
, PIN_FN_28 = 30
, PIN_FN_29 = 31
,
PIN_FN_30 = 32
, PIN_FN_31 = 33
, PIN_FN_32 = 34
, PIN_FN_IN = 4
,
PIN_FN_OUT = 8
, PIN_FN_0 = 0
, PIN_FN_1 = 1
, PIN_FN_2 = 2
,
PIN_FN_3 = 3
, PIN_FN_4 = 6
, PIN_FN_5 = 7
, PIN_FN_6 = 8
,
PIN_FN_7 = 9
, PIN_FN_8 = 10
, PIN_FN_9 = 11
, PIN_FN_10 = 12
,
PIN_FN_11 = 13
, PIN_FN_12 = 14
, PIN_FN_UNKNOWN =0xFE
, PIN_FN_ERR =0xFF
} |
| | Pin Function modes to configure the managed pin(s). More...
|
|
| | PinIO (int j, int n) |
| | Construct a PinIO for a specific cpu pin.
|
| void | set (BOOL b=TRUE) |
| | Drive a value on the pin(s), forcing the pin to a GPIO Output.
|
| BOOL | read () const |
| | Read the line state of the pin(s).
|
|
void | hiz () |
| | Configure the pin(s) to a GPIO Input (high impedance / tristate); the driven value is unaffected.
|
|
void | drive () |
| | Configure the pin(s) to a GPIO Output, without modifying the driven value.
|
| void | function (int ft) const |
| | Set the pin function for the managed pin(s).
|
| void | setFn (int ft) const |
| | Set the pin function for the managed pin(s); alias of function().
|
| int | getFunction () const |
| | Get the pin function currently assigned to the managed pin(s).
|
|
PinIO & | operator= (BOOL b) |
| | Assign a driven value to the pin(s), forcing the pin to a GPIO Output; equivalent to set(b).
|
|
PinIO & | operator= (int i) |
| | Assign a driven value to the pin(s), forcing the pin to a GPIO Output; equivalent to set(i != 0).
|
|
| operator int () |
| | Read the line state of the pin(s) as an int.
|
|
| operator BOOL () |
| | Read the line state of the pin(s) as a BOOL.
|
| void | setFn (pin_fn_t fn) const |
| | Set the pin function for the managed pin(s).
|
| int8_t | getFn () |
| | Get the pin function for the managed pin(s).
|
| void | function (pin_fn_t fn) const |
| | Set the pin function for the managed pin(s); alias of setFn().
|
|
void | hiz () const |
| | Configure the pin(s) to a GPIO Input (high impedance); the driven value is unaffected and takes effect again if the pin is later returned to Output.
|
|
void | drive () const |
| | Configure the pin(s) to a GPIO Output, without modifying the driven value.
|
| bool | readBack () const |
| | Read the pin(s) line state without changing the pin function or direction.
|
| bool | operator! () const |
| | Return the opposite of the driven value of the pin(s), after configuring the pin(s) as an Input.
|
| void | multidrv (bool enable) const |
| | Configure the multidrive/open-drain driver for the pin(s).
|
| void | setHighStrength (bool bHighDrive) |
| | Configure the drive strength of the output driver for the pin(s).
|
| void | PullUp (bool enable) const |
| | Configure the pad Pull Up resistor for the pin(s).
|
| void | PullDown (bool enable) const |
| | Configure the pad Pull Down resistor for the pin(s).
|
| uint16_t | analogRead () const |
| | Read the pin's analog value as a raw ADC count.
|
| bool | SamePin (PinIO &pt) |
| | Test whether another PinIO manages the same pin(s).
|
| void | setFn (pin_fn_t fn) |
| | Set the pin function for the managed pin(s).
|
| void | function (pin_fn_t fn) |
| | Set the pin function for the managed pin(s); alias of setFn().
|
| bool | SamePin (const PinIO &test) |
| | Test whether another PinIO manages the same pin(s).
|
| void | readyAnalog () |
| | Prepare the pin for analog usage (ADC or ACMP) by setting it to Input and disabling the pad pull resistor.
|
|
constexpr uint32_t | analogMaxValue () |
| | The full-scale analog reading: 0xFFF (12-bit ADC).
|
| uint32_t | n () |
| | Read the pin's analog value as a raw ADC count.
|
| double | v () |
| | Read the pin's analog value as a voltage.
|
|
double | volts () |
| | Read the pin's analog value as a voltage; alias of v().
|
|
uint32_t | analogRead () |
| | Read the pin's analog value as a raw ADC count; alias of n().
|
| void | analogEnableSampleWait (bool bWaitForSample) |
| | Select whether analog reads of this pin wait for a fresh conversion.
|
|
| PinIO () |
| | Construct an empty PinIO. Exists for bootstrap compatibility; not intended for general use.
|
| constexpr | PinIO (uint32_t port, uint32_t pin) |
| | Construct a PinIO for a specific cpu pin.
|
| constexpr | PinIO (const PinIO &rhs) |
| | Construct a copy of another PinIO.
|
| void | set () |
| | Set the output latch for the pin(s) High.
|
| void | clr () |
| | Set the output latch for the pin(s) Low.
|
| bool | tgl () |
| | Toggle the driven value for the pin(s) with a single atomic write to the GPIO module's toggle register.
|
| bool | toggle () |
| | Toggle the driven value for the pin(s); alias of tgl().
|
| bool | read () |
| | Read the line state of the pin(s).
|
| void | setPull (pull_t pull) |
| | Configure the pad Pull resistor for the pin(s).
|
|
void | PullUp () |
| | Enable a medium impedance pad Pull Up resistor for the pin(s); equivalent to setPull(PULL_UP_MED).
|
|
void | PullDown () |
| | Enable a weak pad Pull Down resistor for the pin(s); equivalent to setPull(PULL_DOWN_WEAK).
|
| pull_t | getPull () |
| | Get the configured pad Pull resistor setting for the pin(s).
|
| void | setSlew (uint8_t slew) |
| | Set the output pad slew rate.
|
| void | setSpeed (uint8_t speed) |
| | Set the output pad speed/bandwidth.
|
| void | setStrength (uint8_t strength) |
| | Set the output driver drive strength.
|
| void | setOpenDrain (bool enable) |
| | Enable/disable open-drain output for the pin(s).
|
| void | setHyst (bool enable) |
| | Enable/disable the input hysteresis (Schmitt trigger) for the pin(s).
|
| uint8_t | getSlew () |
| | Get the configured slew rate.
|
| uint8_t | getSpeed () |
| | Get the configured pad speed field.
|
| uint8_t | getStrength () |
| | Get the configured drive strength.
|
| bool | getOpenDrain () |
| | Get the open-drain enable state for the pin(s).
|
| bool | getHyst () |
| | Get the input hysteresis (Schmitt trigger) state for the pin(s).
|
|
void | setSchmidt (bool enable) |
| | Enable/disable the input hysteresis (Schmitt trigger); alias of setHyst().
|
|
bool | getSchmidt () |
| | Get the input hysteresis (Schmitt trigger) state; alias of getHyst().
|
|
void | HystOn () |
| | Enable the input hysteresis (Schmitt trigger); equivalent to setHyst(true).
|
|
void | HystOff () |
| | Disable the input hysteresis (Schmitt trigger); equivalent to setHyst(false).
|
|
void | SchmidtOn () |
| | Enable the input hysteresis (Schmitt trigger); equivalent to setHyst(true).
|
|
void | SchmidtOff () |
| | Disable the input hysteresis (Schmitt trigger); equivalent to setHyst(false).
|
|
void | multidrv (bool enable) |
| | Configure the open-drain (multidrive) driver; alias of setOpenDrain().
|
| void | setFn (pin_fn_t fn, bool forceInput=true) |
| | Set the pin function for the managed pin(s).
|
| pin_fn_t | getFn () |
| | Get the pin function for the managed pin(s).
|
| void | function (pin_fn_t fn, bool forceInput=true) |
| | Set the pin function for the managed pin(s); alias of setFn().
|
| bool | operator= (bool val) |
| | Assign a driven value to the pin(s), forcing the pin function to Output.
|
| PinIO & | operator= (const PinIO &rhs) |
| | Assign a driven value to the pin(s) based on the line state of another pin(s), forcing the pin function to Output.
|
| | operator bool () |
| | Read the line state of the pin(s).
|
| bool | operator! () |
| | Return the opposite of the line state of the pin(s).
|
GPIO Pin Class.
Manages the pin function, pad configuration, and GPIO state of one or more pins within a single GPIO module. Assigning a peripheral function also programs the peripheral's input-select (daisy chain) register when one is required, so routing a signal to a pin is a single call.
Typical usage, with pins obtained from the platform pin arrays:
#include <pins.h>
#include <pinconstant.h>
P1[4] = 1;
P1[4] = 0;
bool state = P1[5].read();
P1[4].setStrength(1);
P1[5].PullUp();
#define PINP1_4_FLEXCAN2_TX
P1[4].function(PINP1_4_FLEXCAN2_TX);.
Definition MODRT1171/include/pinconstant.h:29
State accesses use the GPIO module's set/clear/toggle registers, so each call is a single atomic write – no read-modify-write, and no risk of disturbing other pins in the same GPIO module.