F´ Flight Software - C/C++ Documentation  devel
A framework for building embedded system applications to NASA flight quality standards.
All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Pages
LinuxGpioDriverCommon.cpp
Go to the documentation of this file.
1 // ======================================================================
2 // \title LinuxGpioDriverImpl.cpp
3 // \author tcanham
4 // \brief cpp file for LinuxGpioDriver component implementation class
5 //
6 // \copyright
7 // Copyright 2009-2015, by the California Institute of Technology.
8 // ALL RIGHTS RESERVED. United States Government Sponsorship
9 // acknowledged.
10 //
11 // ======================================================================
12 
14 #include <FpConfig.hpp>
15 
16 namespace Drv {
17 
18 // ----------------------------------------------------------------------
19 // Construction, initialization, and destruction
20 // ----------------------------------------------------------------------
21 
22 LinuxGpioDriver ::LinuxGpioDriver(const char* const compName) : LinuxGpioDriverComponentBase(compName) {}
23 
25  const FwSizeType stackSize,
26  const FwSizeType cpuAffinity,
27  const PlatformUIntType identifier) {
29  if (this->m_configuration < GpioConfiguration::MAX_GPIO_CONFIGURATION &&
30  this->m_configuration >= GpioConfiguration::GPIO_INTERRUPT_RISING_EDGE) {
31  status = Drv::GpioStatus::OP_OK;
32  {
33  Os::ScopeLock lock(m_lock);
34  this->m_running = true;
35  }
36  Fw::String name;
37  name.format("%s.interrupt", this->getObjName());
38  Os::Task::Arguments arguments(name, &this->interruptFunction, this, priority, stackSize, cpuAffinity,
39  identifier);
40  this->m_poller.start(arguments);
41  }
42  return status;
43 }
44 
46  Os::ScopeLock lock(m_lock);
47  this->m_running = false;
48 }
49 
51  this->m_poller.join();
52 }
53 
54 void LinuxGpioDriver ::interruptFunction(void* self) {
55  FW_ASSERT(self != nullptr);
56  LinuxGpioDriver* component = reinterpret_cast<LinuxGpioDriver*>(self);
57  component->pollLoop();
58 }
59 
60 bool LinuxGpioDriver ::getRunning() {
61  Os::ScopeLock lock(m_lock);
62  return this->m_running;
63 }
64 
65 } // end namespace Drv
#define FW_ASSERT(...)
Definition: Assert.hpp:14
unsigned int PlatformUIntType
PlatformSizeType FwSizeType
Definition: FpConfig.h:35
C++-compatible configuration header for fprime configuration.
@ INVALID_MODE
Operation not permitted with current configuration.
@ OP_OK
Operation succeeded.
Auto-generated base for LinuxGpioDriver component.
void stop()
stop interrupt detection thread
LinuxGpioDriver(const char *const compName)
void join()
join interrupt detection thread
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
void format(const CHAR *formatString,...)
write formatted string to buffer
Definition: StringBase.cpp:56
locks a mutex within the current scope
Definition: Mutex.hpp:79
Status start(const Arguments &arguments) override
start the task
Definition: Task.cpp:82
Status join() override
block until the task has ended
Definition: Task.cpp:134