Simulator (#749)

* Hide trigger_input.cpp if EFI_SHAFT_POSITION_INPUT == FALSE

* hide some hw-specific code under EFI_PROD_CODE
This commit is contained in:
dron0gus 2019-04-13 00:28:19 +03:00 committed by rusefi
parent 8c49426406
commit 86c561c651
4 changed files with 19 additions and 5 deletions

View File

@ -34,10 +34,10 @@ EXTERNC bool brain_pin_markUsed(brain_pin_e brainPin, const char *msg);
EXTERNC void brain_pin_markUnused(brain_pin_e brainPin);
const char * getPinFunction(brain_input_pin_e brainPin);
#if !EFI_UNIT_TEST
#if !EFI_UNIT_TEST && EFI_PROD_CODE
/* For on-chip gpios only */
EXTERNC bool gpio_pin_markUsed(ioportid_t port, ioportmask_t pin, const char *msg);
EXTERNC void gpio_pin_markUnused(ioportid_t port, ioportmask_t pin);
#endif /* EFI_UNIT_TEST */
#endif /* !EFI_UNIT_TEST && EFI_PROD_CODE*/
#endif /* PIN_REPOSITORY_H_ */

View File

@ -116,10 +116,14 @@ static msg_t stThread(StepperMotor *motor) {
StepperMotor::StepperMotor() {
currentPosition = 0;
targetPosition = 0;
#if EFI_PROD_CODE
enablePort = NULL;
enablePin = 0;
stepPort = NULL;
stepPin = 0;
#endif
reactionTime = 0;
totalSteps = 0;
}
@ -143,6 +147,7 @@ void StepperMotor::setDirection(bool isIncrementing) {
}
void StepperMotor::pulse() {
#if EFI_PROD_CODE
palWritePad(enablePort, enablePin, false); // ebable stepper
palWritePad(stepPort, stepPin, true);
@ -151,6 +156,7 @@ void StepperMotor::pulse() {
chThdSleepMilliseconds(reactionTime);
palWritePad(enablePort, enablePin, true); // disable stepper
#endif
}
void StepperMotor::initialize(brain_pin_e stepPin, brain_pin_e directionPin, pin_output_mode_e directionPinMode,
@ -181,10 +187,14 @@ void StepperMotor::initialize(brain_pin_e stepPin, brain_pin_e directionPin, pin
efiSetPadMode("stepper step", stepPin, PAL_MODE_OUTPUT_PUSHPULL);
// todo: start using enablePinMode parameter here #718
efiSetPadMode("stepper enable", enablePin, PAL_MODE_OUTPUT_PUSHPULL);
#if EFI_PROD_CODE
palWritePad(this->enablePort, enablePin, true); // disable stepper
// All pins must be 0 for correct hardware startup (e.g. stepper auto-disabling circuit etc.).
palWritePad(this->stepPort, this->stepPin, false);
#endif
this->directionPin.setValue(false);
this->currentDirection = false;

View File

@ -28,11 +28,14 @@ public:
int totalSteps;
private:
int targetPosition;
#if EFI_PROD_CODE
ioportid_t stepPort;
ioportmask_t stepPin;
ioportid_t enablePort;
ioportmask_t enablePin;
#endif
pin_output_mode_e directionPinMode;

View File

@ -14,7 +14,7 @@
#include "global.h"
#if (EFI_SHAFT_POSITION_INPUT) || defined(__DOXYGEN__)
#if (EFI_SHAFT_POSITION_INPUT && (HAL_USE_PAL == TRUE) || (HAL_USE_ICU == TRUE)) || defined(__DOXYGEN__)
#include "trigger_input.h"
#include "digital_input_hw.h"
@ -34,6 +34,7 @@ static Logging *logger;
int vvtEventRiseCounter = 0;
int vvtEventFallCounter = 0;
#if EFI_PROD_CODE
/* PAL based implementation */
#if (HAL_USE_PAL == TRUE) && (PAL_USE_CALLBACKS == TRUE)
@ -262,7 +263,7 @@ static void setPrimaryChannel(brain_pin_e brainPin) {
}
#endif /* HAL_USE_ICU */
#endif /* EFI_PROD_CODE */
/*==========================================================================*/
/* Exported functions. */
@ -313,4 +314,4 @@ void applyNewTriggerInputPins(void) {
startTriggerInputPins();
}
#endif /* EFI_SHAFT_POSITION_INPUT */
#endif /* (EFI_SHAFT_POSITION_INPUT && (HAL_USE_PAL == TRUE) || (HAL_USE_ICU == TRUE)) */