F´ Flight Software - C/C++ Documentation
A framework for building embedded system applications to NASA flight quality standards.
Loading...
Searching...
No Matches
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
16namespace Drv {
17
18// ----------------------------------------------------------------------
19// Construction, initialization, and destruction
20// ----------------------------------------------------------------------
21
22LinuxGpioDriver ::LinuxGpioDriver(const char* const compName) : LinuxGpioDriverComponentBase(compName) {}
23
24Drv::GpioStatus LinuxGpioDriver ::start(const FwSizeType priority,
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) {
32 {
33 Os::ScopeLock lock(m_lock);
34 this->m_running = true;
35 }
36 Fw::String name;
37 name.format("%s.interrupt", FW_OPTIONAL_NAME(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
45void LinuxGpioDriver ::stop() {
46 Os::ScopeLock lock(m_lock);
47 this->m_running = false;
48}
49
50void LinuxGpioDriver ::join() {
51 this->m_poller.join();
52}
53
54void LinuxGpioDriver ::interruptFunction(void* self) {
55 FW_ASSERT(self != nullptr);
56 LinuxGpioDriver* component = reinterpret_cast<LinuxGpioDriver*>(self);
57 component->pollLoop();
58}
59
60bool 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
#define FW_OPTIONAL_NAME(name)
Definition FpConfig.h:157
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 format(const CHAR *formatString,...)
write formatted string to buffer
locks a mutex within the current scope
Definition Mutex.hpp:79