|
Open Model Railroad Network (OpenMRN)
|
Generic GPIO class implementation. More...
#include <TivaGPIO.hxx>
Public Member Functions | |
| constexpr | TivaGpio () |
| This constructor is constexpr which ensures that the object can be initialized in the data section. | |
| void | write (Value new_state) const OVERRIDE |
| Writes a GPIO output pin (set or clear to a specific state). | |
| void | set () const OVERRIDE |
| Sets the GPIO output pin to high. | |
| void | clr () const OVERRIDE |
| Clears the GPIO output pin to low. | |
| Value | read () const OVERRIDE |
| Retrieves the current Value of a GPIO input pin. | |
| void | set_direction (Direction dir) const OVERRIDE |
| Sets the GPIO direction. | |
| Direction | direction () const OVERRIDE |
| Gets the GPIO direction. | |
| TivaGpio (unsigned number, Mode mode, Value safe=CLR) | |
| Constructor. | |
| ~TivaGpio () | |
| Destructor. | |
| bool | is_set () OVERRIDE |
| Test the GPIO pin to see if it is set. | |
| bool | is_clr () OVERRIDE |
| Test the GPIO pin to see if it is clear. | |
| void | set () OVERRIDE |
| Set the GPIO to a '1'. | |
| void | clr () OVERRIDE |
| Clear the GPIO to a '0'. | |
| void | direction (Mode mode) OVERRIDE |
| Set the GPIO direction. | |
| Mode | direction () OVERRIDE |
| Get the GPIO direction. | |
Public Member Functions inherited from Gpio | |
| constexpr | Gpio () |
| Constructor. | |
| void | write (bool new_state) const |
| Writes a GPIO output pin (set or clear to a specific state). | |
| bool | is_set () const |
| Tests the GPIO input pin to see if it is set. | |
| bool | is_clr () const |
| Tests the GPIO input pin to see if it is clear. | |
Private Member Functions | |
| constexpr volatile uint8_t * | pin_address () const |
| Computes the memory address where the bit referring to this pin can be accessed. | |
| DISALLOW_COPY_AND_ASSIGN (TivaGpio) | |
Private Attributes | |
| uint32_t | base |
| BASE address of the GPIO. | |
Static Private Attributes | |
| static const TivaGpio | instance_ |
| Static instance variable that can be used for libraries expectiong a generic Gpio pointer. | |
Friends | |
| template<class Defs > | |
| struct | GpioShared |
Additional Inherited Members | |
Public Types inherited from Gpio | |
| enum | Value : bool { CLR = false , SET = true , VLOW = CLR , VHIGH = SET } |
| Defines the options for GPIO level. More... | |
| enum class | Direction { DINPUT , DOUTPUT } |
| Defines the options for GPIO direction. More... | |
Generic GPIO class implementation.
Tiva specific implementation of GPIO.
For the Tiva devices, the GPIO number mapping can be found in the GpioMapping enumeration.
Definition at line 72 of file TivaGPIO.hxx.
|
inlineconstexpr |
This constructor is constexpr which ensures that the object can be initialized in the data section.
Definition at line 77 of file TivaGPIO.hxx.
| TivaGpio< GPIO_BASE, GPIO_PIN >::TivaGpio | ( | unsigned | number, |
| Mode | mode, | ||
| Value | safe = CLR |
||
| ) |
Constructor.
| number | GPIO number |
| mode | GPIO mode settings |
| safe | default "safe" value, may go unused for input only pins |
| GPIO | number |
| mode | GPIO mode settings |
| safe | default "safe" value, may go unused for input only pins |
Definition at line 46 of file TivaGPIOGeneric.cxx.
|
inline |
Destructor.
Definition at line 65 of file TivaGPIOGeneric.hxx.
|
inline |
Clear the GPIO to a '0'.
Note: if the GPIO is inverted, this has have the opposite effect of setting the GPIO to a value of '1'.
Definition at line 102 of file TivaGPIOGeneric.hxx.
|
inlinevirtual |
Gets the GPIO direction.
Implements Gpio.
Definition at line 113 of file TivaGPIO.hxx.
| void TivaGpio< GPIO_BASE, GPIO_PIN >::direction | ( | Mode | mode | ) |
Set the GPIO direction.
| mode | INPUT or OUTPUT |
Definition at line 185 of file TivaGPIOGeneric.cxx.
|
inline |
Test the GPIO pin to see if it is clear.
Definition at line 85 of file TivaGPIOGeneric.hxx.
|
inline |
Test the GPIO pin to see if it is set.
Definition at line 74 of file TivaGPIOGeneric.hxx.
|
inlineconstexprprivate |
Computes the memory address where the bit referring to this pin can be accessed.
This address is bit-masked to the single individual pin, so only ever one bit can be read to be non-zero, and setting any other bit than the desired has no effect. This allows write with 0xff and 0x00 to set/clear and read != 0 to test.
Definition at line 142 of file TivaGPIO.hxx.
|
inlinevirtual |
Retrieves the current Value of a GPIO input pin.
Implements Gpio.
Definition at line 96 of file TivaGPIO.hxx.
|
inline |
Set the GPIO to a '1'.
Note: if the GPIO is inverted, this could have the opposite effect of clearing the GPIO to a value of '0'.
Definition at line 94 of file TivaGPIOGeneric.hxx.
|
inlinevirtual |
Sets the GPIO direction.
| dir | INPUT or OUTPUT |
Implements Gpio.
Definition at line 101 of file TivaGPIO.hxx.
|
inlinevirtual |
Writes a GPIO output pin (set or clear to a specific state).
| new_state | the desired output state. See Value. |
Implements Gpio.
Definition at line 81 of file TivaGPIO.hxx.
|
friend |
Definition at line 128 of file TivaGPIO.hxx.
|
private |
BASE address of the GPIO.
Definition at line 119 of file TivaGPIOGeneric.hxx.
|
staticprivate |
Static instance variable that can be used for libraries expectiong a generic Gpio pointer.
Defines the linker symbol for the wrapped Gpio instance.
This instance variable will be initialized by the linker and (assuming the application developer initialized the hardware pins in hw_preinit) is accessible, including virtual methods at static constructor time.
Definition at line 134 of file TivaGPIO.hxx.