added raspberryp i specific code
This commit is contained in:
parent
501a8919a3
commit
45eb9cbe2b
@ -1 +1,3 @@
|
|||||||
|
target_sources(${LIB_FSFW_HAL_NAME} PRIVATE
|
||||||
|
GpioRPi.cpp
|
||||||
|
)
|
37
linux/rpi/GpioRPi.cpp
Normal file
37
linux/rpi/GpioRPi.cpp
Normal file
@ -0,0 +1,37 @@
|
|||||||
|
#include "GpioRPi.h"
|
||||||
|
#include "../GpioCookie.h"
|
||||||
|
#include <FSFWConfig.h>
|
||||||
|
|
||||||
|
#include <fsfw/serviceinterface/ServiceInterface.h>
|
||||||
|
|
||||||
|
|
||||||
|
ReturnValue_t gpio::createRpiGpioConfig(GpioCookie* cookie, gpioId_t gpioId, int bcmPin,
|
||||||
|
std::string consumer, gpio::Direction direction, int initValue) {
|
||||||
|
if(cookie == nullptr) {
|
||||||
|
return HasReturnvaluesIF::RETURN_FAILED;
|
||||||
|
}
|
||||||
|
|
||||||
|
GpiodRegular config;
|
||||||
|
/* Default chipname for Raspberry Pi. There is still gpiochip1 for expansion, but most users
|
||||||
|
will not need this */
|
||||||
|
config.chipname = "gpiochip0";
|
||||||
|
|
||||||
|
config.consumer = consumer;
|
||||||
|
config.direction = direction;
|
||||||
|
config.initValue = initValue;
|
||||||
|
|
||||||
|
/* Sanity check for the BCM pins before assigning it */
|
||||||
|
if(bcmPin > 27) {
|
||||||
|
#if FSFW_VERBOSE_LEVEL >= 1
|
||||||
|
#if FSFW_CPP_OSTREAM_ENABLED == 1
|
||||||
|
sif::error << "createRpiGpioConfig: BCM pin " << bcmPin << " invalid!" << std::endl;
|
||||||
|
#else
|
||||||
|
sif::printError("createRpiGpioConfig: BCM pin %d invalid!\n", bcmPin);
|
||||||
|
#endif /* FSFW_CPP_OSTREAM_ENABLED == 1 */
|
||||||
|
#endif /* FSFW_VERBOSE_LEVEL >= 1 */
|
||||||
|
return HasReturnvaluesIF::RETURN_FAILED;
|
||||||
|
}
|
||||||
|
config.lineNum = bcmPin;
|
||||||
|
cookie->addGpio(gpioId, config);
|
||||||
|
return HasReturnvaluesIF::RETURN_OK;
|
||||||
|
}
|
26
linux/rpi/GpioRPi.h
Normal file
26
linux/rpi/GpioRPi.h
Normal file
@ -0,0 +1,26 @@
|
|||||||
|
#ifndef BSP_RPI_GPIO_GPIORPI_H_
|
||||||
|
#define BSP_RPI_GPIO_GPIORPI_H_
|
||||||
|
|
||||||
|
#include <fsfw/returnvalues/HasReturnvaluesIF.h>
|
||||||
|
#include "../gpioDefinitions.h"
|
||||||
|
|
||||||
|
class GpioCookie;
|
||||||
|
|
||||||
|
namespace gpio {
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Create a GpioConfig_t. This function does a sanity check on the BCM pin number and fails if the
|
||||||
|
* BCM pin is invalid.
|
||||||
|
* @param cookie Adds the configuration to this cookie directly
|
||||||
|
* @param gpioId ID which identifies the GPIO configuration
|
||||||
|
* @param bcmPin Raspberry Pi BCM pin
|
||||||
|
* @param consumer Information string
|
||||||
|
* @param direction GPIO direction
|
||||||
|
* @param initValue Intial value for output pins, 0 for low, 1 for high
|
||||||
|
* @return
|
||||||
|
*/
|
||||||
|
ReturnValue_t createRpiGpioConfig(GpioCookie* cookie, gpioId_t gpioId, int bcmPin,
|
||||||
|
std::string consumer, gpio::Direction direction, int initValue);
|
||||||
|
}
|
||||||
|
|
||||||
|
#endif /* BSP_RPI_GPIO_GPIORPI_H_ */
|
Loading…
Reference in New Issue
Block a user