F´ Flight Software - C/C++ Documentation  devel
A framework for building embedded system applications to NASA flight quality standards.
Drv::LinuxGpioDriver Class Reference

#include <Drv/LinuxGpioDriver/LinuxGpioDriver.hpp>

Inheritance diagram for Drv::LinuxGpioDriver:
Drv::LinuxGpioDriverComponentBase Fw::PassiveComponentBase Fw::ObjBase

Public Types

enum  GpioConfiguration {
  GPIO_OUTPUT , GPIO_INPUT , GPIO_INTERRUPT_RISING_EDGE , GPIO_INTERRUPT_FALLING_EDGE ,
  GPIO_INTERRUPT_BOTH_RISING_AND_FALLING_EDGES , MAX_GPIO_CONFIGURATION
}
 configure the GPIO pin More...
 

Public Member Functions

 LinuxGpioDriver (const char *const compName)
 
 ~LinuxGpioDriver ()
 
Os::File::Status open (const char *device, const U32 gpio, const GpioConfiguration &configuration, const Fw::Logic &default_state=Fw::Logic::LOW)
 open a GPIO pin for use in the system More...
 
Drv::GpioStatus start (const FwSizeType priority=Os::Task::TASK_DEFAULT, const FwSizeType stackSize=Os::Task::TASK_DEFAULT, const FwSizeType cpuAffinity=Os::Task::TASK_DEFAULT, const PlatformUIntType identifier=static_cast< PlatformUIntType >(Os::Task::TASK_DEFAULT))
 start interrupt detection thread More...
 
void stop ()
 stop interrupt detection thread More...
 
void join ()
 join interrupt detection thread More...
 
- Public Member Functions inherited from Drv::LinuxGpioDriverComponentBase
void init (FwEnumStoreType instance=0)
 Initialize LinuxGpioDriverComponentBase object. More...
 
Drv::InputGpioReadPortget_gpioRead_InputPort (FwIndexType portNum)
 
Drv::InputGpioWritePortget_gpioWrite_InputPort (FwIndexType portNum)
 
void set_Log_OutputPort (FwIndexType portNum, Fw::InputLogPort *port)
 Connect port to Log[portNum]. More...
 
void set_Time_OutputPort (FwIndexType portNum, Fw::InputTimePort *port)
 Connect port to Time[portNum]. More...
 
void set_gpioInterrupt_OutputPort (FwIndexType portNum, Svc::InputCyclePort *port)
 Connect port to gpioInterrupt[portNum]. More...
 
- Public Member Functions inherited from Fw::PassiveComponentBase
void setIdBase (const U32)
 Set the ID base. More...
 
U32 getIdBase () const
 

Static Public Attributes

static constexpr FwSizeType GPIO_POLL_TIMEOUT = 500
 

Additional Inherited Members

- Protected Types inherited from Drv::LinuxGpioDriverComponentBase
enum  { NUM_GPIOREAD_INPUT_PORTS = 1 , NUM_GPIOWRITE_INPUT_PORTS = 1 }
 Enumerations for numbers of typed input ports. More...
 
enum  { NUM_LOG_OUTPUT_PORTS = 1 , NUM_LOGTEXT_OUTPUT_PORTS = 1 , NUM_TIME_OUTPUT_PORTS = 1 }
 Enumerations for numbers of special output ports. More...
 
enum  { NUM_GPIOINTERRUPT_OUTPUT_PORTS = 1 }
 Enumerations for numbers of typed output ports. More...
 
enum  {
  EVENTID_OPENCHIP = 0x0 , EVENTID_OPENCHIPERROR = 0x1 , EVENTID_OPENPINERROR = 0x2 , EVENTID_INTERRUPTREADERROR = 0x3 ,
  EVENTID_POLLINGERROR = 0x4
}
 Event IDs. More...
 
- Protected Member Functions inherited from Drv::LinuxGpioDriverComponentBase
 LinuxGpioDriverComponentBase (const char *compName="")
 Construct LinuxGpioDriverComponentBase object. More...
 
virtual ~LinuxGpioDriverComponentBase ()
 Destroy LinuxGpioDriverComponentBase object. More...
 
FwIndexType getNum_gpioRead_InputPorts () const
 
FwIndexType getNum_gpioWrite_InputPorts () const
 
FwIndexType getNum_Log_OutputPorts () const
 
FwIndexType getNum_Time_OutputPorts () const
 
FwIndexType getNum_gpioInterrupt_OutputPorts () const
 
bool isConnected_Log_OutputPort (FwIndexType portNum)
 
bool isConnected_Time_OutputPort (FwIndexType portNum)
 
bool isConnected_gpioInterrupt_OutputPort (FwIndexType portNum)
 
Drv::GpioStatus gpioRead_handlerBase (FwIndexType portNum, Fw::Logic &state)
 Handler base-class function for input port gpioRead. More...
 
Drv::GpioStatus gpioWrite_handlerBase (FwIndexType portNum, const Fw::Logic &state)
 Handler base-class function for input port gpioWrite. More...
 
void gpioInterrupt_out (FwIndexType portNum, Os::RawTime &cycleStart)
 Invoke output port gpioInterrupt. More...
 
void log_DIAGNOSTIC_OpenChip (const Fw::StringBase &chip, const Fw::StringBase &chipLabel, U32 pin, const Fw::StringBase &pinMessage)
 Log event OpenChip. More...
 
void log_WARNING_HI_OpenChipError (const Fw::StringBase &chip, Os::FileStatus status)
 Log event OpenChipError. More...
 
void log_WARNING_HI_OpenPinError (const Fw::StringBase &chip, U32 pin, const Fw::StringBase &pinMessage, Os::FileStatus status)
 Log event OpenPinError. More...
 
void log_WARNING_HI_InterruptReadError (U32 expected, U32 got)
 Log event InterruptReadError. More...
 
void log_WARNING_HI_PollingError (I32 error_number)
 Log event PollingError. More...
 
Fw::Time getTime ()
 
- Protected Member Functions inherited from Fw::PassiveComponentBase
 PassiveComponentBase (const char *name)
 Named constructor. More...
 
virtual ~PassiveComponentBase ()
 Destructor. More...
 
void init (NATIVE_INT_TYPE instance)
 Initialization function. More...
 
NATIVE_INT_TYPE getInstance () const
 
- Protected Member Functions inherited from Fw::ObjBase
 ObjBase (const char *name)
 ObjBase constructor. More...
 
virtual ~ObjBase ()
 Destructor. More...
 
void init ()
 Object initializer. More...
 

Detailed Description

Definition at line 23 of file LinuxGpioDriver.hpp.

Member Enumeration Documentation

◆ GpioConfiguration

configure the GPIO pin

Configure the GPIO pin for use in this driver. Only one mode may be selected as a time.

Enumerator
GPIO_OUTPUT 

Output GPIO pin for direct writing.

GPIO_INPUT 

Input GPIO pin for direct reading.

GPIO_INTERRUPT_RISING_EDGE 

Input GPIO pin triggers interrupt port on rising edge.

GPIO_INTERRUPT_FALLING_EDGE 

Input GPIO pin triggers interrupt port on falling edge.

GPIO_INTERRUPT_BOTH_RISING_AND_FALLING_EDGES 

Input GPIO pin triggers interrupt port on both edges.

MAX_GPIO_CONFIGURATION 

Definition at line 42 of file LinuxGpioDriver.hpp.

Constructor & Destructor Documentation

◆ LinuxGpioDriver()

Drv::LinuxGpioDriver::LinuxGpioDriver ( const char *const  compName)

Construct object LinuxGpioDriver

Parameters
compNameThe component name

Definition at line 22 of file LinuxGpioDriverCommon.cpp.

◆ ~LinuxGpioDriver()

Drv::LinuxGpioDriver::~LinuxGpioDriver ( )

Destroy object LinuxGpioDriver

Definition at line 124 of file LinuxGpioDriver.cpp.

Member Function Documentation

◆ join()

void Drv::LinuxGpioDriver::join ( )

join interrupt detection thread

Definition at line 50 of file LinuxGpioDriverCommon.cpp.

◆ open()

Os::File::Status Drv::LinuxGpioDriver::open ( const char *  device,
const U32  gpio,
const GpioConfiguration configuration,
const Fw::Logic default_state = Fw::Logic::LOW 
)

open a GPIO pin for use in the system

This function opens and configures a GPIO pin. User must supply the device path and the gpio pin registered to that device. Pin configuration is also accepted and supports: input, output, and interrupts on either edge.

If the user selects output, a default state can be set with the default_state flag.

Parameters
device/dev/gpiochip* path for this pin's bank
gpiopin or line number on the above chip
configurationpin configuration
default_statedefault state when using output configuration
Returns
status of the gpio open OP_OK on success, something else on error

Definition at line 183 of file LinuxGpioDriver.cpp.

◆ start()

Drv::GpioStatus Drv::LinuxGpioDriver::start ( const FwSizeType  priority = Os::Task::TASK_DEFAULT,
const FwSizeType  stackSize = Os::Task::TASK_DEFAULT,
const FwSizeType  cpuAffinity = Os::Task::TASK_DEFAULT,
const PlatformUIntType  identifier = static_cast<PlatformUIntType>(Os::Task::TASK_DEFAULT) 
)

start interrupt detection thread

Definition at line 24 of file LinuxGpioDriverCommon.cpp.

◆ stop()

void Drv::LinuxGpioDriver::stop ( )

stop interrupt detection thread

Definition at line 45 of file LinuxGpioDriverCommon.cpp.

Member Data Documentation

◆ GPIO_POLL_TIMEOUT

constexpr FwSizeType Drv::LinuxGpioDriver::GPIO_POLL_TIMEOUT = 500
staticconstexpr

Definition at line 25 of file LinuxGpioDriver.hpp.


The documentation for this class was generated from the following files: