rusefi-1/firmware/controllers/system/efiGpio.cpp

70 lines
1.3 KiB
C++
Raw Normal View History

2015-07-10 06:01:56 -07:00
/**
* @file efiGpio.cpp
*
* @date Sep 26, 2014
2015-12-31 13:02:30 -08:00
* @author Andrey Belomutskiy, (c) 2012-2016
2015-07-10 06:01:56 -07:00
*/
#include "main.h"
#if EFI_GPIO
#include "efiGpio.h"
#include "io_pins.h"
#if EFI_PROD_CODE || defined(__DOXYGEN__)
#include "gpio_helper.h"
#endif
pin_output_mode_e OUTPUT_MODE_DEFAULT = OM_DEFAULT;
// todo: clean this mess, this should become 'static'/private
engine_pins_s enginePins;
NamedOutputPin::NamedOutputPin() : OutputPin() {
name = NULL;
}
NamedOutputPin::NamedOutputPin(const char *name) : OutputPin() {
this->name = name;
}
OutputPin::OutputPin() {
modePtr = &OUTPUT_MODE_DEFAULT;
#if EFI_PROD_CODE || defined(__DOXYGEN__)
port = NULL;
pin = 0;
#endif
2016-07-23 16:03:19 -07:00
currentLogicValue = INITIAL_PIN_STATE;
2015-07-10 06:01:56 -07:00
}
2016-01-11 14:01:33 -08:00
bool OutputPin::isInitialized() {
2015-07-10 06:01:56 -07:00
#if EFI_PROD_CODE || defined(__DOXYGEN__)
return port != NULL;
#else
return false;
#endif
}
void OutputPin::setValue(int logicValue) {
doSetOutputPinValue2(this, logicValue);
}
2016-01-11 14:01:33 -08:00
bool OutputPin::getLogicValue() {
2015-07-10 06:01:56 -07:00
return currentLogicValue;
}
void OutputPin::unregister() {
#if EFI_PROD_CODE || defined(__DOXYGEN__)
port = NULL;
#endif
}
void OutputPin::setDefaultPinState(pin_output_mode_e *outputMode) {
#if EFI_GPIO || defined(__DOXYGEN__)
pin_output_mode_e mode = *outputMode;
assertOMode(mode);
this->modePtr = outputMode;
#endif
setValue(false); // initial state
}
#endif /* EFI_GPIO */