time to panic and revert more

This commit is contained in:
rusefi 2019-11-12 21:42:44 -05:00
parent 4a8b8336c4
commit 4b1c1e72ab
16 changed files with 28 additions and 44 deletions

View File

@ -2072,7 +2072,7 @@ typedef enum {
CUSTOM_ERR_6706 = 6706,
CUSTOM_ERR_TIMER_TEST_CALLBACK_NOT_HAPPENED = 6707,
CUSTOM_ERR_TIMER_TEST_CALLBACK_WRONG_TIME = 6708,
CUSTOM_ERR_6709 = 6709,
CUSTOM_ERR_PIN_COUNT_TOO_LARGE = 6709,
CUSTOM_DUTY_INVALID = 6710,
CUSTOM_DUTY_TOO_HIGH = 6711,
CUSTOM_ERR_PWM_STATE_ASSERT = 6712,

View File

@ -8,14 +8,15 @@
#ifndef ERROR_HANDLING_H_
#define ERROR_HANDLING_H_
#include "global.h"
#include "obd_error_codes.h"
#ifdef __cplusplus
extern "C"
{
#endif /* __cplusplus */
#include "global.h"
#include "obd_error_codes.h"
/**
* Something is wrong, but we can live with it: some minor sensor is disconnected
* or something like that
@ -30,7 +31,7 @@ typedef uint8_t fatal_msg_t[200];
*
* see also warning()
*/
void firmwareError(obd_code_e code, const char *fmt, ...);
EXTERNC void firmwareError(obd_code_e code, const char *fmt, ...);
#define hasFirmwareError() hasFirmwareErrorFlag

View File

@ -839,6 +839,6 @@ int getRusEfiVersion(void) {
if (initBootloader() != 0)
return 123;
#endif /* EFI_BOOTLOADER_INCLUDE_CODE */
return 20191112;
return 20191110;
}
#endif /* EFI_UNIT_TEST */

View File

@ -52,20 +52,18 @@ EnginePins::EnginePins() {
dizzyOutput.name = PROTOCOL_DIZZY_NAME;
tachOut.name = PROTOCOL_TACH_NAME;
//todo:uncomment static_assert(efi::size(sparkNames) >= IGNITION_PIN_COUNT, "Too many ignition pins");
efiAssertVoid(CUSTOM_ERR_PIN_COUNT_TOO_LARGE, (sizeof(sparkNames) / sizeof(char*)) >= IGNITION_PIN_COUNT, "spark pin count");
for (int i = 0; i < IGNITION_PIN_COUNT;i++) {
enginePins.coils[i].name = sparkNames[i];
enginePins.coils[i].shortName = sparkShortNames[i];
}
//todo:uncomment static_assert(efi::size(injectorNames) >= INJECTION_PIN_COUNT, "Too many injection pins");
efiAssertVoid(CUSTOM_ERR_PIN_COUNT_TOO_LARGE, (sizeof(injectorNames) / sizeof(char*)) >= INJECTION_PIN_COUNT, "inj pin count");
for (int i = 0; i < INJECTION_PIN_COUNT;i++) {
enginePins.injectors[i].injectorIndex = i;
enginePins.injectors[i].name = injectorNames[i];
enginePins.injectors[i].shortName = injectorShortNames[i];
}
//todo:uncomment static_assert(efi::size(auxValveShortNames) >= AUX_DIGITAL_VALVE_COUNT, "Too many aux valve pins");
efiAssertVoid(CUSTOM_ERR_PIN_COUNT_TOO_LARGE, (sizeof(auxValveShortNames) / sizeof(char*)) >= AUX_DIGITAL_VALVE_COUNT, "aux pin count");
for (int i = 0; i < AUX_DIGITAL_VALVE_COUNT;i++) {
enginePins.auxValve[i].name = auxValveShortNames[i];
}

View File

@ -117,7 +117,7 @@ static void initWave(const char *name, int index) {
if (reader->hw != NULL) {
reader->hw->setWidthCallback((VoidInt)(void*) waAnaWidthCallback, (void*) reader);
reader->hw->setPeriodCallback((VoidInt)(void*) waIcuPeriodCallback, (void*) reader);
reader->hw->setPeridoCallback((VoidInt)(void*) waIcuPeriodCallback, (void*) reader);
}
print("wave%d input on %s\r\n", index, hwPortname(brainPin));

View File

@ -15,8 +15,6 @@
#ifndef GLOBAL_H_
#define GLOBAL_H_
#include "common_headers.h"
#ifdef __cplusplus
extern "C"
{
@ -24,6 +22,7 @@ extern "C"
// todo: remove this from here and rely on os_access.h. unfortunately hal.h includes ch.h :(
#include <hal.h>
#include "common_headers.h"
// this is about MISRA not liking 'time.h'. todo: figure out something
#if defined __GNUC__

View File

@ -11,6 +11,6 @@ void digital_input_s::setWidthCallback(VoidInt handler, void *arg) {
widthListeners.registerCallback(handler, arg);
}
void digital_input_s::setPeriodCallback(VoidInt handler, void *arg) {
void digital_input_s::setPeridoCallback(VoidInt handler, void *arg) {
periodListeners.registerCallback(handler, arg);
}

View File

@ -23,5 +23,5 @@ typedef struct {
// Width/Period names are historically inherited from ICU implementation, todo: migrate to better names, high/low? rise/hall?
void setWidthCallback(VoidInt handler, void *arg);
void setPeriodCallback(VoidInt handler, void *arg);
void setPeridoCallback(VoidInt handler, void *arg);
} digital_input_s;

View File

@ -23,23 +23,23 @@
static ioportmask_t ext_used = 0;
// EXT is not able to give you the front direction but you could read the pin in the callback.
void efiExtiEnablePin(const char *msg, brain_pin_e brainPin, uint32_t mode, palcallback_t cb, void *cb_data) {
int efiExtiEnablePin(const char *msg, brain_pin_e brainPin, uint32_t mode, palcallback_t cb, void *cb_data) {
/* paranoid check, in case of GPIO_UNASSIGNED getHwPort will return NULL
* and we will fail on next check */
if (brainPin == GPIO_UNASSIGNED)
return;
return -1;
ioportid_t port = getHwPort(msg, brainPin);
if (port == NULL)
return;
return -1;
int index = getHwPin(msg, brainPin);
/* is this index already used? */
if (ext_used & PAL_PORT_BIT(index)) {
firmwareError(CUSTOM_ERR_PIN_ALREADY_USED_2, "%s: pin %d: exti index already used", msg, brainPin);
return;
return -1;
}
ioline_t line = PAL_LINE(port, index);
@ -48,6 +48,8 @@ void efiExtiEnablePin(const char *msg, brain_pin_e brainPin, uint32_t mode, palc
/* mark used */
ext_used |= PAL_PORT_BIT(index);
return 0;
}
void efiExtiDisablePin(brain_pin_e brainPin)

View File

@ -8,6 +8,6 @@
#include "digital_input.h"
#if HAL_USE_PAL
void efiExtiEnablePin(const char *msg, brain_pin_e pin, uint32_t mode, palcallback_t cb, void *cb_data);
int efiExtiEnablePin(const char *msg, brain_pin_e pin, uint32_t mode, palcallback_t cb, void *cb_data);
void efiExtiDisablePin(brain_pin_e brainPin);
#endif /* HAL_USE_PAL */

View File

@ -233,7 +233,7 @@ digital_input_s * addWaveAnalyzerDriver(const char *msg, brain_pin_e brainPin) {
/**
* turns pin off and returns digital_input_s back into registeredIcus pool
*/
void stopDigitalCapture(const char *msg, brain_pin_e brainPin) {
void removeWaveAnalyzerDriver(const char *msg, brain_pin_e brainPin) {
if (brainPin == GPIO_UNASSIGNED) {
return;
}

View File

@ -20,7 +20,7 @@ void turnOffCapturePin(brain_pin_e brainPin);
digital_input_s *addWaveAnalyzerDriver(const char *msg, brain_pin_e brainPin);
void startInputDriver(const char *msg, /*nullable*/digital_input_s *hw, bool isActiveHigh);
void stopDigitalCapture(const char *msg, brain_pin_e brainPin);
void removeWaveAnalyzerDriver(const char *msg, brain_pin_e brainPin);
//Nullable
ICUDriver * getInputCaptureDriver(const char *msg, brain_pin_e hwPin);

View File

@ -189,9 +189,6 @@ static void timerValidationCallback(void *arg) {
* helps to make sure our GPT hardware settings are somewhat right
*/
static void validateHardwareTimer() {
if (hasFirmwareError()) {
return;
}
testSchedulingStart = currentTimeMillis();
// to save RAM let's use 'watchDogBuddy' here once before we enable watchdog
@ -211,7 +208,7 @@ void initMicrosecondTimer(void) {
lastSetTimerTimeNt = getTimeNowNt();
//todo:uncomment validateHardwareTimer();
validateHardwareTimer();
watchDogBuddyCallback(NULL);
#if EFI_EMULATE_POSITION_SENSORS

View File

@ -64,20 +64,18 @@ static void cam_callback(void *arg) {
}
}
void turnOnTriggerInputPin(const char *msg, int index, bool isTriggerShaft) {
brain_pin_e brainPin = isTriggerShaft ? CONFIGB(triggerInputPins)[index] : engineConfiguration->camInputs[index];
int turnOnTriggerInputPin(const char *msg, brain_pin_e brainPin, bool isVvtShaft) {
scheduleMsg(logger, "turnOnTriggerInputPin(PAL) %s %s", msg, hwPortname(brainPin));
/* TODO:
* * do not set to both edges if we need only one
* * simplify callback in case of one edge */
ioline_t pal_line = PAL_LINE(getHwPort("trg", brainPin), getHwPin("trg", brainPin));
efiExtiEnablePin(msg, brainPin, PAL_EVENT_MODE_BOTH_EDGES, isVvtShaft ? shaft_callback : cam_callback, (void *)pal_line);
return efiExtiEnablePin(msg, brainPin, PAL_EVENT_MODE_BOTH_EDGES, isVvtShaft ? shaft_callback : cam_callback, (void *)pal_line);
}
void turnOffTriggerInputPin(brain_pin_e brainPin) {
stopDigitalCapture("trigger", brainPin);
efiExtiDisablePin(brainPin);
}
void setPrimaryChannel(brain_pin_e brainPin) {

View File

@ -67,7 +67,7 @@ bool hasVehicleSpeedSensor() {
}
void stopVSSPins(void) {
stopDigitalCapture("VSS", activeConfiguration.bc.vehicleSpeedSensorInputPin);
removeWaveAnalyzerDriver("VSS", activeConfiguration.bc.vehicleSpeedSensorInputPin);
}
void startVSSPins(void) {

View File

@ -74,17 +74,6 @@ float expf_taylor(float x);
#ifdef __cplusplus
}
// C++ helpers go here
namespace efi
{
template <class T, size_t N>
constexpr size_t size(const T (&)[N])
{
return N;
}
} // namespace efi
#endif /* __cplusplus */
#endif /* EFILIB_H_ */