diff --git a/firmware/config/boards/STM32F407VET6_Black.bat b/firmware/config/boards/STM32F407VET6_Black.bat index 28094fbcc0..96c7a0bfa7 100644 --- a/firmware/config/boards/STM32F407VET6_Black.bat +++ b/firmware/config/boards/STM32F407VET6_Black.bat @@ -3,7 +3,7 @@ echo "Compiling for https://rusefi.com/forum/viewtopic.php?f=4&t=1489" cd ../.. rem TODO: somehow this -DDUMMY is helping us to not mess up the parameters, why?! rem https://github.com/rusefi/rusefi/issues/684 -set EXTRA_PARAMS="-DDUMMY -DEFI_COMMUNICATION_PIN=GPIOA_7" +set EXTRA_PARAMS="-DDUMMY -DEFI_COMMUNICATION_PIN=Gpio::A7" make -j8 clean call config/boards/common_make.bat \ No newline at end of file diff --git a/firmware/config/boards/STM32F407VET6_Mini.bat b/firmware/config/boards/STM32F407VET6_Mini.bat index c91f842939..e442278d65 100644 --- a/firmware/config/boards/STM32F407VET6_Mini.bat +++ b/firmware/config/boards/STM32F407VET6_Mini.bat @@ -5,7 +5,7 @@ rem TODO: somehow this -DDUMMY is helping us to not mess up the parameters, why? rem https://github.com/rusefi/rusefi/issues/684 rem this board has only 512K flash so using custom FLASH_ADDR rem You probably want "flash0 : org = 0x08000000, len = 450K" in the .ld file -set EXTRA_PARAMS=-DDUMMY -DEFI_COMMUNICATION_PIN=GPIOB_9 -DSTM32_RTCPRE_VALUE=25 ^ +set EXTRA_PARAMS=-DDUMMY -DEFI_COMMUNICATION_PIN=Gpio::B9 -DSTM32_RTCPRE_VALUE=25 ^ -DEFI_INTERNAL_FLASH=FALSE ^ -DHAL_USE_RTC=FALSE ^ -DBOARD_OTG_NOVBUSSENS ^ diff --git a/firmware/config/boards/atlas/board.mk b/firmware/config/boards/atlas/board.mk index 7dbef14126..ae3cc8f806 100644 --- a/firmware/config/boards/atlas/board.mk +++ b/firmware/config/boards/atlas/board.mk @@ -3,7 +3,7 @@ BOARDCPPSRC = $(PROJECT_DIR)/config/boards/atlas/board_configuration.cpp BOARDINC = $(PROJECT_DIR)/config/boards/atlas -#DDEFS += -DLED_CRITICAL_ERROR_BRAIN_PIN=GPIOE_3 +#DDEFS += -DLED_CRITICAL_ERROR_BRAIN_PIN=Gpio::E3 DDEFS += -DFIRMWARE_ID=\"atlas\" # This stuff doesn't work on H7 yet diff --git a/firmware/config/boards/core8/board.h b/firmware/config/boards/core8/board.h index 19eb25ba18..f6dd2cc6e6 100644 --- a/firmware/config/boards/core8/board.h +++ b/firmware/config/boards/core8/board.h @@ -19,10 +19,10 @@ #define EFI_USB_AF 10U #undef EFI_USB_SERIAL_DM -#define EFI_USB_SERIAL_DM GPIOA_11 +#define EFI_USB_SERIAL_DM Gpio::A11 #undef EFI_USB_SERIAL_DP -#define EFI_USB_SERIAL_DP GPIOA_12 +#define EFI_USB_SERIAL_DP Gpio::A12 #undef STM32_SERIAL_USE_USART1 #define STM32_SERIAL_USE_USART1 FALSE @@ -34,10 +34,10 @@ #define TS_PRIMARY_PORT UARTD1 #undef EFI_CONSOLE_TX_BRAIN_PIN -#define EFI_CONSOLE_TX_BRAIN_PIN GPIOA_9 +#define EFI_CONSOLE_TX_BRAIN_PIN Gpio::A9 #undef EFI_CONSOLE_RX_BRAIN_PIN -#define EFI_CONSOLE_RX_BRAIN_PIN GPIOA_10 +#define EFI_CONSOLE_RX_BRAIN_PIN Gpio::A10 #undef EFI_USE_OSC #define EFI_USE_OSC TRUE @@ -67,7 +67,7 @@ #define HAL_VSS_USE_PAL TRUE #undef LED_CRITICAL_ERROR_BRAIN_PIN -#define LED_CRITICAL_ERROR_BRAIN_PIN GPIOG_11 +#define LED_CRITICAL_ERROR_BRAIN_PIN Gpio::G11 // Ignore USB VBUS pin (we're never a host, only a device) #define BOARD_OTG_NOVBUSSENS TRUE diff --git a/firmware/config/boards/core8/board_configuration.cpp b/firmware/config/boards/core8/board_configuration.cpp index a9f66ad04d..16864f0ca2 100644 --- a/firmware/config/boards/core8/board_configuration.cpp +++ b/firmware/config/boards/core8/board_configuration.cpp @@ -11,27 +11,27 @@ static void setInjectorPins() { engineConfiguration->injectionPinMode = OM_DEFAULT; - engineConfiguration->injectionPins[0] = GPIOF_13; - engineConfiguration->injectionPins[1] = GPIOF_14; - engineConfiguration->injectionPins[2] = GPIOD_8; - engineConfiguration->injectionPins[3] = GPIOD_9; - engineConfiguration->injectionPins[4] = GPIOD_10; - engineConfiguration->injectionPins[5] = GPIOD_11; - engineConfiguration->injectionPins[6] = GPIOD_12; - engineConfiguration->injectionPins[7] = GPIOD_13; + engineConfiguration->injectionPins[0] = Gpio::F13; + engineConfiguration->injectionPins[1] = Gpio::F14; + engineConfiguration->injectionPins[2] = Gpio::D8; + engineConfiguration->injectionPins[3] = Gpio::D9; + engineConfiguration->injectionPins[4] = Gpio::D10; + engineConfiguration->injectionPins[5] = Gpio::D11; + engineConfiguration->injectionPins[6] = Gpio::D12; + engineConfiguration->injectionPins[7] = Gpio::D13; } static void setIgnitionPins() { engineConfiguration->ignitionPinMode = OM_DEFAULT; - engineConfiguration->ignitionPins[0] = GPIOE_15; - engineConfiguration->ignitionPins[1] = GPIOE_14; - engineConfiguration->ignitionPins[2] = GPIOE_13; - engineConfiguration->ignitionPins[3] = GPIOE_12; - engineConfiguration->ignitionPins[4] = GPIOE_11; - engineConfiguration->ignitionPins[5] = GPIOF_15; - engineConfiguration->ignitionPins[6] = GPIOG_0; - engineConfiguration->ignitionPins[7] = GPIOG_1; + engineConfiguration->ignitionPins[0] = Gpio::E15; + engineConfiguration->ignitionPins[1] = Gpio::E14; + engineConfiguration->ignitionPins[2] = Gpio::E13; + engineConfiguration->ignitionPins[3] = Gpio::E12; + engineConfiguration->ignitionPins[4] = Gpio::E11; + engineConfiguration->ignitionPins[5] = Gpio::F15; + engineConfiguration->ignitionPins[6] = Gpio::G0; + engineConfiguration->ignitionPins[7] = Gpio::G1; } @@ -47,23 +47,23 @@ static void setEtbConfig() { // Throttle #1 // PWM pin - engineConfiguration->etbIo[0].controlPin = GPIOB_8; + engineConfiguration->etbIo[0].controlPin = Gpio::B8; // DIR pin - engineConfiguration->etbIo[0].directionPin1 = GPIOB_9; + engineConfiguration->etbIo[0].directionPin1 = Gpio::B9; // Disable pin - engineConfiguration->etbIo[0].disablePin = GPIOB_7; + engineConfiguration->etbIo[0].disablePin = Gpio::B7; // Unused - engineConfiguration->etbIo[0].directionPin2 = GPIO_UNASSIGNED; + engineConfiguration->etbIo[0].directionPin2 = Gpio::Unassigned; // Throttle #2 // PWM pin - engineConfiguration->etbIo[1].controlPin = GPIO_UNASSIGNED; + engineConfiguration->etbIo[1].controlPin = Gpio::Unassigned; // DIR pin - engineConfiguration->etbIo[1].directionPin1 = GPIO_UNASSIGNED; + engineConfiguration->etbIo[1].directionPin1 = Gpio::Unassigned; // Disable pin - engineConfiguration->etbIo[1].disablePin = GPIO_UNASSIGNED; + engineConfiguration->etbIo[1].disablePin = Gpio::Unassigned; // Unused - engineConfiguration->etbIo[1].directionPin2 = GPIO_UNASSIGNED; + engineConfiguration->etbIo[1].directionPin2 = Gpio::Unassigned; // we only have pwm/dir, no dira/dirb engineConfiguration->etb_use_two_wires = false; @@ -83,9 +83,9 @@ static void setupVbatt() { } static void setStepperConfig() { - engineConfiguration->idle.stepperDirectionPin = GPIOF_7; - engineConfiguration->idle.stepperStepPin = GPIOF_8; - engineConfiguration->stepperEnablePin = GPIOF_9; + engineConfiguration->idle.stepperDirectionPin = Gpio::F7; + engineConfiguration->idle.stepperStepPin = Gpio::F8; + engineConfiguration->stepperEnablePin = Gpio::F9; } void setBoardConfigOverrides() { @@ -94,20 +94,20 @@ void setBoardConfigOverrides() { setStepperConfig(); // PE3 is error LED, configured in board.mk - engineConfiguration->communicationLedPin = GPIOG_12; - engineConfiguration->runningLedPin = GPIOG_9; - engineConfiguration->warningLedPin = GPIOG_10; + engineConfiguration->communicationLedPin = Gpio::G12; + engineConfiguration->runningLedPin = Gpio::G9; + engineConfiguration->warningLedPin = Gpio::G10; engineConfiguration->clt.config.bias_resistor = 2490; engineConfiguration->iat.config.bias_resistor = 2490; //CAN 1 bus overwrites - engineConfiguration->canRxPin = GPIOD_0; - engineConfiguration->canTxPin = GPIOD_1; + engineConfiguration->canRxPin = Gpio::D0; + engineConfiguration->canTxPin = Gpio::D1; //CAN 2 bus overwrites - engineConfiguration->can2RxPin = GPIOB_5; - engineConfiguration->can2TxPin = GPIOB_6; + engineConfiguration->can2RxPin = Gpio::B5; + engineConfiguration->can2TxPin = Gpio::B6; } static void setupDefaultSensorInputs() { @@ -117,8 +117,8 @@ static void setupDefaultSensorInputs() { engineConfiguration->baroSensor.hwChannel = EFI_ADC_NONE; - engineConfiguration->lps25BaroSensorScl = GPIOB_10; - engineConfiguration->lps25BaroSensorSda = GPIOB_11; + engineConfiguration->lps25BaroSensorScl = Gpio::B10; + engineConfiguration->lps25BaroSensorSda = Gpio::B11; } diff --git a/firmware/config/boards/core8/connectors/main.yaml b/firmware/config/boards/core8/connectors/main.yaml index 0493742854..de87e65413 100644 --- a/firmware/config/boards/core8/connectors/main.yaml +++ b/firmware/config/boards/core8/connectors/main.yaml @@ -1,56 +1,56 @@ pins: # Grey A line - pin: Grey A1 - id: GPIOF_13 + id: F13 class: outputs function: Low Side Output type: inj ts_name: Grey A1 - Injector 1 - pin: Grey A2 - id: GPIOF_14 + id: F14 class: outputs function: Low Side Output type: inj ts_name: Grey A2 - Injector 2 - pin: Grey A3 - id: GPIOD_8 + id: D8 class: outputs function: Low Side Output type: inj ts_name: Grey A3 - Injector 3 - pin: Grey A4 - id: GPIOD_9 + id: D9 class: outputs function: Low Side Output type: inj ts_name: Grey A4 - Injector 4 - pin: Grey A5 - id: GPIOD_10 + id: D10 class: outputs function: Low Side Output type: inj ts_name: Grey A5 - Injector 5 - pin: Grey A6 - id: GPIOD_11 + id: D11 class: outputs function: Low Side Output type: inj ts_name: Grey A6 - Injector 6 - pin: Grey A7 - id: GPIOD_12 + id: D12 class: outputs function: Low Side Output type: inj ts_name: Grey A7 - Injector 7 - pin: Grey A8 - id: GPIOD_13 + id: D13 class: outputs function: Low Side Output type: inj @@ -59,56 +59,56 @@ pins: # Grey B line - pin: Grey B1 - id: GPIOE_15 + id: E15 class: outputs function: High Side Output type: ign ts_name: Grey B1 - Ignition 1 - pin: Grey B2 - id: GPIOE_14 + id: E14 class: outputs function: High Side Output type: ign ts_name: Grey B2 - Ignition 2 - pin: Grey B3 - id: GPIOE_13 + id: E13 class: outputs function: High Side Output type: ign ts_name: Grey B3 - Ignition 3 - pin: Grey B4 - id: GPIOE_12 + id: E12 class: outputs function: High Side Output type: ign ts_name: Grey B4 - Ignition 4 - pin: Grey B5 - id: GPIOE_11 + id: E11 class: outputs function: High Side Output type: ign ts_name: Grey B5 - Ignition 5 - pin: Grey B6 - id: GPIOF_15 + id: F15 class: outputs function: High Side Output type: ign ts_name: Grey B6 - Ignition 6 - pin: Grey B7 - id: GPIOG_0 + id: G0 class: outputs function: High Side Output type: ign ts_name: Grey B7 - Ignition 7 - pin: Grey B8 - id: GPIOG_1 + id: G1 class: outputs function: High Side Output type: ign @@ -159,7 +159,7 @@ pins: ts_name: Grey C7 - Analog Sensor Input - pin: Grey C8 - id: GPIOD_14 + id: D14 class: outputs function: Low Side Output type: ls @@ -168,49 +168,49 @@ pins: # Black A line - pin: Black A1 - id: GPIOG_3 + id: G3 class: outputs function: Low Side Output type: ls ts_name: Black A1 - Low Side Output - pin: Black A2 - id: GPIOG_4 + id: G4 class: outputs function: Low Side Output type: ls ts_name: Black A2 - Low Side Output - pin: Black A3 - id: GPIOG_5 + id: G5 class: outputs function: Low Side Output type: ls ts_name: Black A3 - Low Side Output - pin: Black A4 - id: GPIOG_6 + id: G6 class: outputs function: Low Side Output / DBW_OUT+ type: ls ts_name: Black A4 - Low Side Output / DBW_OUT+ - pin: Black A5 - id: GPIOG_7 + id: G7 class: outputs function: Low Side Output / DBW_OUT- type: ls ts_name: Black A5 - Low Side Output / DBW_OUT- - pin: Black A6 - id: GPIOC_13 + id: C13 class: switch_inputs function: LSU1_IA / Digital Input type: hall ts_name: Black A6 - LSU4.9 PIN 5 / Digital Input 8 - pin: Black A7 - id: GPIOF_1 + id: F1 class: switch_inputs function: LSU1_VGND / Digital Input type: hall @@ -224,28 +224,28 @@ pins: # Black B line - pin: Black B1 - id: GPIOG_2 + id: G2 class: outputs function: Low Side Output type: ls ts_name: Black B1 - Low Side Output - pin: Black B2 - id: GPIOF_5 + id: F5 class: switch_inputs function: Digital Input type: hall ts_name: Black B2 - Digital Input 1 - pin: Black B3 - id: GPIOF_4 + id: F4 class: switch_inputs function: Digital Input type: hall ts_name: Black B3 - Digital Input 2 - pin: Black B4 - id: GPIOF_3 + id: F3 class: switch_inputs function: Digital Input type: hall @@ -258,14 +258,14 @@ pins: ts_name: Black B5 - Analog Sensor Input / Knock 2 - pin: Black B6 - id: GPIOE_6 + id: E6 class: switch_inputs function: LSU1_NERMEST / Digital Input type: hall ts_name: Black B6 - LSU4.9 PIN 6 / Digital Input 7 - pin: Black B7 - id: GPIOF_0 + id: F0 class: switch_inputs function: LSU1_IP / Digital Input type: hall @@ -278,14 +278,14 @@ pins: # Black C line - pin: Black C1 - id: GPIOD_15 + id: D15 class: outputs function: Low Side Output type: ls ts_name: Black C1 - Low Side Output - pin: Black C2 - id: [GPIOE_2, GPIOE_2] + id: [E2, E2] class: [event_inputs, switch_inputs] function: Camshaft Sensor (VR+/Hall) type: hall @@ -304,7 +304,7 @@ pins: ts_name: Crank Sensor VR- - pin: Black C5 - id: [GPIOE_3, GPIOE_3] + id: [E3, E3] class: [event_inputs, switch_inputs] function: Crank Sensor (VR+/Hall) type: hall diff --git a/firmware/config/boards/f429-discovery/board.h b/firmware/config/boards/f429-discovery/board.h index 8a24867397..a0fe30274a 100644 --- a/firmware/config/boards/f429-discovery/board.h +++ b/firmware/config/boards/f429-discovery/board.h @@ -40,9 +40,9 @@ * USB settings */ #define EFI_USB_AF 12U -//#define EFI_USB_SERIAL_ID GPIOA_10 -#define EFI_USB_SERIAL_DM GPIOB_14 -#define EFI_USB_SERIAL_DP GPIOB_15 +//#define EFI_USB_SERIAL_ID Gpio::A10 +#define EFI_USB_SERIAL_DM Gpio::B14 +#define EFI_USB_SERIAL_DP Gpio::B15 /* * Board oscillators-related settings. diff --git a/firmware/config/boards/f429-discovery/board.mk b/firmware/config/boards/f429-discovery/board.mk index e20b7ffb3b..2654be8f9c 100644 --- a/firmware/config/boards/f429-discovery/board.mk +++ b/firmware/config/boards/f429-discovery/board.mk @@ -14,7 +14,7 @@ IS_STM32F429 = yes EFI_HAS_EXT_SDRAM = yes #LED -DDEFS += -DLED_CRITICAL_ERROR_BRAIN_PIN=GPIOG_14 +DDEFS += -DLED_CRITICAL_ERROR_BRAIN_PIN=Gpio::G14 DDEFS += -DSTM32_FSMC_USE_FSMC1=TRUE -DSTM32_SDRAM_USE_SDRAM2=TRUE diff --git a/firmware/config/boards/f429-discovery/board_configuration.cpp b/firmware/config/boards/f429-discovery/board_configuration.cpp index 3663498043..ab26cfb54e 100644 --- a/firmware/config/boards/f429-discovery/board_configuration.cpp +++ b/firmware/config/boards/f429-discovery/board_configuration.cpp @@ -17,7 +17,7 @@ void boardInit(void) * @todo Add your board-specific code, if any. */ void setBoardDefaultConfiguration() { - engineConfiguration->communicationLedPin = GPIO_UNASSIGNED; - engineConfiguration->runningLedPin = GPIOG_13; /* LD3 - green */ - engineConfiguration->warningLedPin = GPIO_UNASSIGNED; + engineConfiguration->communicationLedPin = Gpio::Unassigned; + engineConfiguration->runningLedPin = Gpio::G13; /* LD3 - green */ + engineConfiguration->warningLedPin = Gpio::Unassigned; } diff --git a/firmware/config/boards/frankenso/connectors/main.yaml b/firmware/config/boards/frankenso/connectors/main.yaml index 8a87d12e6b..1b37bbe086 100644 --- a/firmware/config/boards/frankenso/connectors/main.yaml +++ b/firmware/config/boards/frankenso/connectors/main.yaml @@ -4,49 +4,49 @@ pins: - pin: 6 - id: GPIOC_9 + id: C9 class: outputs function: Ignition Coil #1 ts_name: Coil 1F - pin: 7 - id: GPIOE_14 + id: E14 class: outputs function: Ignition Coil #3 ts_name: Coil 1G - pin: 8 - id: GPIOC_7 + id: C7 class: outputs function: Ignition Coil #2 ts_name: Coil 1H - pin: 9 - id: GPIOE_10 + id: E10 class: outputs function: Spare High #5 ts_name: Coil 1I - pin: 12 - id: GPIOE_8 + id: E8 class: outputs function: Spare High #6 ts_name: Coil 1L - pin: 13 - id: GPIOE_12 + id: E12 class: outputs function: Ignition Coil #4 ts_name: Coil 1M - pin: 15 - id: GPIOD_8 + id: D8 class: outputs function: Spare High #8 ts_name: Coil 1O - pin: 16 - id: GPIOD_9 + id: D9 class: outputs function: Spare High #7 ts_name: Coil 1P @@ -76,25 +76,25 @@ pins: function: CAN low - pin: 35 - id: GPIOC_13 + id: C13 class: outputs ts_name: Injector 2M function: Idle Valve Control Solenoid - pin: 36 - id: GPIOD_7 + id: D7 class: outputs ts_name: Injector 2N function: Main Relay - pin: 37 - id: GPIOE_5 + id: E5 class: outputs ts_name: Injector 2O function: Coolant Fan Relay - pin: 38 - id: GPIOE_6 + id: E6 class: outputs ts_name: Injector 2P function: Spare low #2 @@ -176,49 +176,49 @@ pins: function: Coolant Temp Sensor - pin: 57 - id: GPIOE_3 + id: E3 class: outputs ts_name: Injector 3S function: Spare low #1 - pin: 58 - id: GPIOE_4 + id: E4 class: outputs ts_name: Injector 3T function: Fuel Pump Relay - pin: 59 - id: GPIOD_3 + id: D3 class: outputs ts_name: Injector 3U function: Spare low - pin: 60 - id: GPIOE_2 + id: E2 class: outputs ts_name: Injector 3V function: Injector #2 - pin: 61 - id: GPIOB_9 + id: B9 class: outputs ts_name: Injector 3W function: Injector #1 - pin: 62 - id: GPIOD_5 + id: D5 class: outputs ts_name: Injector 3X function: Spare low - pin: 63 - id: GPIOB_8 + id: B8 class: outputs ts_name: Injector 3Y function: Injector #3 - pin: 64 - id: GPIOB_7 + id: B7 class: outputs ts_name: Injector 3Z function: Injector #4 diff --git a/firmware/config/boards/hellen/alphax-2chan/board_configuration.cpp b/firmware/config/boards/hellen/alphax-2chan/board_configuration.cpp index 04f5fee268..d59c3874ba 100644 --- a/firmware/config/boards/hellen/alphax-2chan/board_configuration.cpp +++ b/firmware/config/boards/hellen/alphax-2chan/board_configuration.cpp @@ -25,31 +25,31 @@ static OutputPin alphaCamPullDown; static void setInjectorPins() { engineConfiguration->injectionPins[0] = H144_LS_1; engineConfiguration->injectionPins[1] = H144_LS_2; - engineConfiguration->injectionPins[2] = GPIO_UNASSIGNED; - engineConfiguration->injectionPins[3] = GPIO_UNASSIGNED; + engineConfiguration->injectionPins[2] = Gpio::Unassigned; + engineConfiguration->injectionPins[3] = Gpio::Unassigned; // Disable remainder for (int i = 4; i < MAX_CYLINDER_COUNT;i++) { - engineConfiguration->injectionPins[i] = GPIO_UNASSIGNED; + engineConfiguration->injectionPins[i] = Gpio::Unassigned; } engineConfiguration->injectionPinMode = OM_DEFAULT; - engineConfiguration->clutchDownPin = GPIO_UNASSIGNED; + engineConfiguration->clutchDownPin = Gpio::Unassigned; engineConfiguration->clutchDownPinMode = PI_PULLDOWN; engineConfiguration->launchActivationMode = CLUTCH_INPUT_LAUNCH; - engineConfiguration->malfunctionIndicatorPin = GPIO_UNASSIGNED; + engineConfiguration->malfunctionIndicatorPin = Gpio::Unassigned; } static void setIgnitionPins() { engineConfiguration->ignitionPins[0] = H144_IGN_1; - engineConfiguration->ignitionPins[1] = GPIO_UNASSIGNED; + engineConfiguration->ignitionPins[1] = Gpio::Unassigned; engineConfiguration->ignitionPins[2] = H144_IGN_2; - engineConfiguration->ignitionPins[3] = GPIO_UNASSIGNED; + engineConfiguration->ignitionPins[3] = Gpio::Unassigned; // disable remainder for (int i = 4; i < MAX_CYLINDER_COUNT; i++) { - engineConfiguration->ignitionPins[i] = GPIO_UNASSIGNED; + engineConfiguration->ignitionPins[i] = Gpio::Unassigned; } engineConfiguration->ignitionPinMode = OM_DEFAULT; @@ -72,8 +72,8 @@ static void setupDefaultSensorInputs() { // trigger inputs, hall engineConfiguration->triggerInputPins[0] = H144_IN_CRANK; engineConfiguration->triggerInputPins[1] = H144_IN_CAM; - engineConfiguration->triggerInputPins[2] = GPIO_UNASSIGNED; - engineConfiguration->camInputs[0] = GPIO_UNASSIGNED; + engineConfiguration->triggerInputPins[2] = Gpio::Unassigned; + engineConfiguration->camInputs[0] = Gpio::Unassigned; engineConfiguration->tps1_1AdcChannel = H144_IN_TPS; engineConfiguration->tps2_1AdcChannel = EFI_ADC_NONE; @@ -123,8 +123,8 @@ void setBoardConfigOverrides() { engineConfiguration->clt.config.bias_resistor = 4700; engineConfiguration->iat.config.bias_resistor = 4700; - engineConfiguration->canTxPin = GPIOD_1; - engineConfiguration->canRxPin = GPIOD_0; + engineConfiguration->canTxPin = Gpio::D1; + engineConfiguration->canRxPin = Gpio::D0; } /** @@ -140,10 +140,10 @@ void setBoardDefaultConfiguration() { engineConfiguration->boardUseTempPullUp = true; - engineConfiguration->acSwitch = GPIO_UNASSIGNED; + engineConfiguration->acSwitch = Gpio::Unassigned; engineConfiguration->fuelPumpPin = H144_OUT_PWM2; engineConfiguration->fanPin = H144_OUT_PWM4; - engineConfiguration->mainRelayPin = GPIO_UNASSIGNED; + engineConfiguration->mainRelayPin = Gpio::Unassigned; engineConfiguration->tachOutputPin = H144_OUT_PWM3; // "required" hardware is done - set some reasonable defaults @@ -159,7 +159,7 @@ void setBoardDefaultConfiguration() { engineConfiguration->clutchDownPin = H144_IN_D_2; engineConfiguration->clutchDownPinMode = PI_PULLDOWN; engineConfiguration->launchActivationMode = CLUTCH_INPUT_LAUNCH; -// ? engineConfiguration->malfunctionIndicatorPin = GPIOG_4; //1E - Check Engine Light +// ? engineConfiguration->malfunctionIndicatorPin = Gpio::G4; //1E - Check Engine Light setHellenDefaultVrThresholds(); engineConfiguration->vrThreshold[0].pin = H144_OUT_PWM6; } diff --git a/firmware/config/boards/hellen/alphax-2chan/connectors/main.yaml b/firmware/config/boards/hellen/alphax-2chan/connectors/main.yaml index 1a16a2cc1d..291cf5bc0e 100644 --- a/firmware/config/boards/hellen/alphax-2chan/connectors/main.yaml +++ b/firmware/config/boards/hellen/alphax-2chan/connectors/main.yaml @@ -16,7 +16,7 @@ pins: - pin: A3 # H144_OUT_PWM2 - id: GPIOC_6 + id: C6 class: outputs function: Fuel Pump Relay Output (low) type: ls @@ -25,7 +25,7 @@ pins: - pin: A4 # H144_OUT_PWM3 - id: GPIOC_7 + id: C7 class: outputs function: Tachometer Output ts_name: A4 - Tachometer @@ -38,7 +38,7 @@ pins: - pin: A6 # H144_IGN_1 - id: GPIOC_13 + id: C13 class: outputs function: Smart Ignition A Output type: ign @@ -47,7 +47,7 @@ pins: - pin: A7 # H144_IGN_2 - id: GPIOE_5 + id: E5 class: outputs function: Smart Ignition B Output type: ign @@ -56,7 +56,7 @@ pins: - pin: A8 # H144_LS_1 - id: GPIOG_7 + id: G7 function: Injector A Output class: outputs type: inj @@ -123,7 +123,7 @@ pins: - pin: B8 # H144_LS_2 - id: GPIOG_8 + id: G8 function: Injector B Output class: outputs type: inj @@ -132,7 +132,7 @@ pins: - pin: C1 # H144_OUT_PWM4 - id: GPIOC_8 + id: C8 class: outputs function: Fan Relay or 5A Power Output (low) type: ls @@ -141,7 +141,7 @@ pins: - pin: C2 # H144_IN_D_3 - id: [GPIOE_14, GPIOE_14] + id: [E14, E14] class: [event_inputs, switch_inputs] function: Crank Sensor - type: hall @@ -150,7 +150,7 @@ pins: - pin: C3 # H144_IN_D_1 - id: [GPIOE_12, GPIOE_12] + id: [E12, E12] class: [event_inputs, switch_inputs] function: Crank Sensor + type: hall @@ -159,7 +159,7 @@ pins: - pin: C2C3 # H144_IN_CRANK - id: GPIOB_1 + id: B1 class: event_inputs function: Crank Sensor (VR) type: hall @@ -168,7 +168,7 @@ pins: - pin: C4 # H144_IN_VSS - id: GPIOF_11 + id: F11 class: switch_inputs function: 2Step Digital Input type: hall @@ -187,7 +187,7 @@ pins: - pin: C7 # H144_IN_CAM - id: [GPIOA_6, GPIOA_6, EFI_ADC_6] + id: [A6, A6, EFI_ADC_6] class: [event_inputs, switch_inputs, analog_inputs] function: Camshaft HALL Sensor or Generic Digital Input type: hall @@ -196,7 +196,7 @@ pins: - pin: C8 # H144_OUT_PWM1 - id: GPIOD_13 + id: D13 class: outputs function: Idle Output (low) type: ls diff --git a/firmware/config/boards/hellen/alphax-4chan/board_configuration.cpp b/firmware/config/boards/hellen/alphax-4chan/board_configuration.cpp index f1606d071a..5c7e981e7a 100644 --- a/firmware/config/boards/hellen/alphax-4chan/board_configuration.cpp +++ b/firmware/config/boards/hellen/alphax-4chan/board_configuration.cpp @@ -35,15 +35,15 @@ static void setInjectorPins() { // Disable remainder for (int i = 4; i < MAX_CYLINDER_COUNT;i++) { - engineConfiguration->injectionPins[i] = GPIO_UNASSIGNED; + engineConfiguration->injectionPins[i] = Gpio::Unassigned; } engineConfiguration->injectionPinMode = OM_DEFAULT; - engineConfiguration->clutchDownPin = GPIO_UNASSIGNED; + engineConfiguration->clutchDownPin = Gpio::Unassigned; engineConfiguration->clutchDownPinMode = PI_PULLDOWN; engineConfiguration->launchActivationMode = CLUTCH_INPUT_LAUNCH; - engineConfiguration->malfunctionIndicatorPin = GPIO_UNASSIGNED; + engineConfiguration->malfunctionIndicatorPin = Gpio::Unassigned; } static void setupEtb() { @@ -60,7 +60,7 @@ static void setupEtb() { // Disable pin engineConfiguration->etbIo[0].disablePin = H144_GP2; // Unused - engineConfiguration->etbIo[0].directionPin2 = GPIO_UNASSIGNED; + engineConfiguration->etbIo[0].directionPin2 = Gpio::Unassigned; // we only have pwm/dir, no dira/dirb engineConfiguration->etb_use_two_wires = false; @@ -74,7 +74,7 @@ static void setIgnitionPins() { // disable remainder for (int i = 4; i < MAX_CYLINDER_COUNT; i++) { - engineConfiguration->ignitionPins[i] = GPIO_UNASSIGNED; + engineConfiguration->ignitionPins[i] = Gpio::Unassigned; } engineConfiguration->ignitionPinMode = OM_DEFAULT; @@ -97,8 +97,8 @@ static void setupDefaultSensorInputs() { // trigger inputs, hall engineConfiguration->triggerInputPins[0] = H144_IN_CRANK; engineConfiguration->triggerInputPins[1] = H144_IN_CAM; - engineConfiguration->triggerInputPins[2] = GPIO_UNASSIGNED; - engineConfiguration->camInputs[0] = GPIO_UNASSIGNED; + engineConfiguration->triggerInputPins[2] = Gpio::Unassigned; + engineConfiguration->camInputs[0] = Gpio::Unassigned; engineConfiguration->tps1_1AdcChannel = H144_IN_TPS; engineConfiguration->tps1_2AdcChannel = H144_IN_AUX1; @@ -163,8 +163,8 @@ void setBoardConfigOverrides() { engineConfiguration->clt.config.bias_resistor = 4700; engineConfiguration->iat.config.bias_resistor = 4700; - engineConfiguration->canTxPin = GPIOD_1; - engineConfiguration->canRxPin = GPIOD_0; + engineConfiguration->canTxPin = Gpio::D1; + engineConfiguration->canRxPin = Gpio::D0; } /** @@ -183,7 +183,7 @@ void setBoardDefaultConfiguration() { engineConfiguration->boardUseTempPullUp = true; - engineConfiguration->acSwitch = GPIO_UNASSIGNED; + engineConfiguration->acSwitch = Gpio::Unassigned; engineConfiguration->fuelPumpPin = H144_OUT_IO12; engineConfiguration->fanPin = H144_OUT_IO11; engineConfiguration->mainRelayPin = H144_OUT_IO10; @@ -203,7 +203,7 @@ void setBoardDefaultConfiguration() { engineConfiguration->clutchDownPin = H144_IN_D_2; engineConfiguration->clutchDownPinMode = PI_PULLDOWN; engineConfiguration->launchActivationMode = CLUTCH_INPUT_LAUNCH; -// ? engineConfiguration->malfunctionIndicatorPin = GPIOG_4; //1E - Check Engine Light +// ? engineConfiguration->malfunctionIndicatorPin = Gpio::G4; //1E - Check Engine Light setHellenDefaultVrThresholds(); engineConfiguration->vrThreshold[0].pin = H144_OUT_PWM6; engineConfiguration->vrThreshold[1].pin = H144_OUT_PWM4; diff --git a/firmware/config/boards/hellen/alphax-4chan/connectors/main.yaml b/firmware/config/boards/hellen/alphax-4chan/connectors/main.yaml index 27a2a9d57b..04ea6f97a9 100644 --- a/firmware/config/boards/hellen/alphax-4chan/connectors/main.yaml +++ b/firmware/config/boards/hellen/alphax-4chan/connectors/main.yaml @@ -13,7 +13,7 @@ pins: - pin: A3 # H144_OUT_IO12 - id: GPIOA_8 + id: A8 class: outputs function: Fuel Pump Relay Output (low) type: ls @@ -22,7 +22,7 @@ pins: - pin: A4 # H144_OUT_IO13 - id: GPIOG_6 + id: G6 class: outputs function: Tachometer Output ts_name: A4 - Tachometer @@ -35,7 +35,7 @@ pins: - pin: A6 # H144_IGN_1 - id: GPIOC_13 + id: C13 class: outputs function: Smart Ignition 1 type: ign @@ -44,7 +44,7 @@ pins: - pin: A7 # H144_IGN_2 - id: GPIOE_5 + id: E5 class: outputs function: Smart Ignition 2 Output type: ign @@ -53,7 +53,7 @@ pins: - pin: A8 # H144_LS_1 - id: GPIOG_7 + id: G7 function: Injector 1 Output class: outputs type: inj @@ -120,7 +120,7 @@ pins: - pin: B8 # H144_LS_2 - id: GPIOG_8 + id: G8 function: Injector 2 Output class: outputs type: inj @@ -129,7 +129,7 @@ pins: - pin: C1 # H144_OUT_IO11 - id: GPIOG_2 + id: G2 class: outputs function: Fan Relay or 5A Power Output (low) type: ls @@ -138,7 +138,7 @@ pins: - pin: C2 # H144_IN_D_3 - id: [GPIOE_14, GPIOE_14] + id: [E14, E14] class: [event_inputs, switch_inputs] function: Crank Sensor - type: hall @@ -147,7 +147,7 @@ pins: - pin: C3 # H144_IN_D_1 - id: [GPIOE_12, GPIOE_12] + id: [E12, E12] class: [event_inputs, switch_inputs] function: Crank Sensor + type: hall @@ -156,7 +156,7 @@ pins: - pin: C2C3 # H144_IN_CRANK - id: GPIOB_1 + id: B1 class: event_inputs function: Crank Sensor (VR) type: hall @@ -165,7 +165,7 @@ pins: - pin: C4 # H144_IN_VSS - id: GPIOF_11 + id: F11 class: switch_inputs function: 2Step Digital Input type: hall @@ -184,7 +184,7 @@ pins: - pin: C7 # H144_IN_CAM - id: [GPIOA_6, GPIOA_6, EFI_ADC_6] + id: [A6, A6, EFI_ADC_6] class: [event_inputs, switch_inputs, analog_inputs] function: Camshaft HALL Sensor or Generic Digital Input type: hall @@ -193,7 +193,7 @@ pins: - pin: C8 # H144_OUT_PWM1 - id: GPIOD_13 + id: D13 class: outputs function: Idle Output (low) type: ls @@ -202,7 +202,7 @@ pins: - pin: D1 # H144_LS_3 - id: GPIOD_11 + id: D11 function: Injector 3 class: outputs type: inj @@ -211,7 +211,7 @@ pins: - pin: D2 # H144_OUT_PWM3 - id: GPIOC_7 + id: C7 function: Out Boost class: outputs ts_name: D2 - Out Boost @@ -219,7 +219,7 @@ pins: - pin: D3 # H144_IN_SENS1 - id: GPIOF_3 + id: F3 class: switch_inputs function: Digital Input 2 type: hall @@ -244,7 +244,7 @@ pins: - pin: D6 # H144_IGN_3 - id: GPIOE_4 + id: E4 class: outputs function: Smart Ignition 3 Output type: ign @@ -253,7 +253,7 @@ pins: - pin: D7 # H144_IGN_4 - id: GPIOE_3 + id: E3 class: outputs function: Smart Ignition 4 Output type: ign @@ -267,7 +267,7 @@ pins: - pin: E1 # H144_LS_4 - id: GPIOD_10 + id: D10 function: Injector 4 class: outputs type: inj @@ -276,7 +276,7 @@ pins: - pin: E2 # H144_OUT_IO6 - id: GPIOG_11 + id: G11 function: Out NOS class: outputs ts_name: E2 - Out NOS @@ -284,7 +284,7 @@ pins: - pin: E3 # H144_IN_SENS2 - id: GPIOF_4 + id: F4 class: switch_inputs function: Digital Input 3 type: hall @@ -293,7 +293,7 @@ pins: - pin: E4 # H144_IN_SENS3 - id: GPIOF_5 + id: F5 class: switch_inputs function: Digital Input 4 type: hall @@ -306,7 +306,7 @@ pins: - pin: E6 # H144_IN_D_4 - id: [GPIOE_15, GPIOE_15] + id: [E15, E15] class: [event_inputs, switch_inputs] function: Cam Sensor VR+ as Hall type: hall @@ -315,7 +315,7 @@ pins: - pin: E5E6 # H144_IN_RES1 - id: GPIOF_9 + id: F9 class: event_inputs function: Cam Sensor (VR) type: vr @@ -324,7 +324,7 @@ pins: - pin: E7 # H144_IN_D_AUX4 - id: GPIOA_7 + id: A7 class: event_inputs ts_name: E7 - Flex function: Digital Input / Flex fuel sensor @@ -337,7 +337,7 @@ pins: - pin: F1 # H144_OUT_PWM5 - id: GPIOC_9 + id: C9 class: outputs function: Idle2 Output (low) type: ls @@ -346,7 +346,7 @@ pins: - pin: F2 # H144_OUT_PWM7 - id: GPIOD_15 + id: D15 function: VVT#1 class: outputs type: ls @@ -356,7 +356,7 @@ pins: # also used as knock input (is hard-coded at the moment) - pin: F3 # H144_IN_SENS4 - id: GPIOF_6 + id: F6 class: switch_inputs function: Digital Input 5 / Knock Input type: hall @@ -365,7 +365,7 @@ pins: - pin: F4 # H144_OUT_PWM8 - id: GPIOD_12 + id: D12 function: VVT#2 class: outputs type: ls @@ -374,7 +374,7 @@ pins: - pin: F5 # H144_OUT_IO10 - id: GPIOG_12 + id: G12 class: outputs ts_name: F5 - MAIN function: Main relay control diff --git a/firmware/config/boards/hellen/cypress/board_configuration.cpp b/firmware/config/boards/hellen/cypress/board_configuration.cpp index ea1b1d435a..3fd3038b0a 100644 --- a/firmware/config/boards/hellen/cypress/board_configuration.cpp +++ b/firmware/config/boards/hellen/cypress/board_configuration.cpp @@ -40,9 +40,9 @@ void setBoardDefaultConfiguration() { engineConfiguration->idleStepperReactionTime = 10; engineConfiguration->stepperDirectionPinMode = OM_INVERTED; - engineConfiguration->idle.stepperDirectionPin = GPIO_UNASSIGNED; - engineConfiguration->idle.stepperStepPin = GPIO_UNASSIGNED; - engineConfiguration->stepperEnablePin = GPIO_UNASSIGNED; + engineConfiguration->idle.stepperDirectionPin = Gpio::Unassigned; + engineConfiguration->idle.stepperStepPin = Gpio::Unassigned; + engineConfiguration->stepperEnablePin = Gpio::Unassigned; engineConfiguration->useLinearCltSensor = true; // todo: @@ -64,10 +64,10 @@ void setBoardDefaultConfiguration() { engineConfiguration->mapMinBufferLength = 4; - engineConfiguration->communicationLedPin = GPIO_UNASSIGNED;//GPIOJ_0; - engineConfiguration->runningLedPin = GPIO_UNASSIGNED; - engineConfiguration->warningLedPin = GPIO_UNASSIGNED; - engineConfiguration->triggerErrorPin = GPIO_UNASSIGNED; + engineConfiguration->communicationLedPin = Gpio::Unassigned;//GPIOJ_0; + engineConfiguration->runningLedPin = Gpio::Unassigned; + engineConfiguration->warningLedPin = Gpio::Unassigned; + engineConfiguration->triggerErrorPin = Gpio::Unassigned; engineConfiguration->map.sensor.hwChannel = EFI_ADC_13; engineConfiguration->clt.adcChannel = EFI_ADC_26; @@ -94,19 +94,19 @@ void setBoardDefaultConfiguration() { engineConfiguration->fuelLevelSensor = EFI_ADC_NONE; engineConfiguration->oilPressure.hwChannel = EFI_ADC_NONE; - engineConfiguration->acSwitch = GPIO_UNASSIGNED; - engineConfiguration->triggerInputPins[0] = GPIOB_0; - engineConfiguration->triggerInputPins[1] = GPIO_UNASSIGNED; - engineConfiguration->triggerInputPins[2] = GPIO_UNASSIGNED; + engineConfiguration->acSwitch = Gpio::Unassigned; + engineConfiguration->triggerInputPins[0] = Gpio::B0; + engineConfiguration->triggerInputPins[1] = Gpio::Unassigned; + engineConfiguration->triggerInputPins[2] = Gpio::Unassigned; #if 0 // todo: int i; for (i = 0; i < MAX_CYLINDER_COUNT; i++) - engineConfiguration->injectionPins[i] = GPIO_UNASSIGNED; + engineConfiguration->injectionPins[i] = Gpio::Unassigned; for (i = 0; i < MAX_CYLINDER_COUNT; i++) - engineConfiguration->ignitionPins[i] = GPIO_UNASSIGNED; + engineConfiguration->ignitionPins[i] = Gpio::Unassigned; engineConfiguration->adcVcc = 5.0f; engineConfiguration->analogInputDividerCoefficient = 1; @@ -122,10 +122,10 @@ void setBoardDefaultConfiguration() { void setSerialConfigurationOverrides() { #if 0 engineConfiguration->useSerialPort = true; - engineConfiguration->binarySerialTxPin = GPIOC_7; - engineConfiguration->binarySerialRxPin = GPIOC_6; - engineConfiguration->consoleSerialTxPin = GPIOA_10; - engineConfiguration->consoleSerialRxPin = GPIOA_11; + engineConfiguration->binarySerialTxPin = Gpio::C7; + engineConfiguration->binarySerialRxPin = Gpio::C6; + engineConfiguration->consoleSerialTxPin = Gpio::A10; + engineConfiguration->consoleSerialRxPin = Gpio::A11; engineConfiguration->tunerStudioSerialSpeed = SERIAL_SPEED; engineConfiguration->uartConsoleSerialSpeed = SERIAL_SPEED; #endif diff --git a/firmware/config/boards/hellen/cypress/config/rusefi_config_hellen_cypress.txt b/firmware/config/boards/hellen/cypress/config/rusefi_config_hellen_cypress.txt index f70e35e913..234a973bba 100644 --- a/firmware/config/boards/hellen/cypress/config/rusefi_config_hellen_cypress.txt +++ b/firmware/config/boards/hellen/cypress/config/rusefi_config_hellen_cypress.txt @@ -4,7 +4,7 @@ ! all these #defines are in priority over the "default" values in rusefi_config.txt ! see firmware/config/boards/hellen/cypress/rusefi_hw_enums.h -#define brain_pin_e_enum "NONE", "INVALID", "P00 (A_0)", "P01 (A_1)", "P02 (A_2)", "P03 (A_3)", "P04 (A_4)", "P05 (A_5)", "P06 (A_6)", "P07 (A_7)", "P08 (A_8)", "P09 (A_9)", "P0A (A_10)", "P0B (A_11)", "P0C (A_12)", "P0D (A_13)", "P0E (A_14)", "P0F (A_15)", "P10 (B_0)", "P11 (B_1)", "P12 (B_2)", "P13 (B_3)", "P14 (B_4)", "P15 (B_5)", "P16 (B_6)", "P17 (B_7)", "P18 (B_8)", "P19 (B_9)", "P1A (B_10)", "P1B (B_11)", "P1C (B_12)", "P1D (B_13)", "P1E (B_14)", "P1F (B_15)", "P20 (C_0)", "P21 (C_1)", "P22 (C_2)", "P23 (C_3)", "P24 (C_4)", "P25 (C_5)", "P26 (C_6)", "P27 (C_7)", "P28 (C_8)", "P29 (C_9)", "P2A (C_10)", "P2B (C_11)", "P2C (C_12)", "P2D (C_13)", "P2E (C_14)", "P2F (C_15)", "P30 (D_0)", "P31 (D_1)", "P32 (D_2)", "P33 (D_3)", "P34 (D_4)", "P35 (D_5)", "P36 (D_6)", "P37 (D_7)", "P38 (D_8)", "P39 (D_9)", "P3A (D_10)", "P3B (D_11)", "P3C (D_12)", "P3D (D_13)", "P3E (D_14)", "P3F (D_15)", "P40 (E_0)", "P41 (E_1)", "P42 (E_2)", "P43 (E_3)", "P44 (E_4)", "P45 (E_5)", "P46 (E_6)", "P47 (E_7)", "P48 (E_8)", "P49 (E_9)", "P4A (E_10)", "P4B (E_11)", "P4C (E_12)", "P4D (E_13)", "P4E (E_14)", "P4F (E_15)", "P50 (F_0)", "P51 (F_1)", "P52 (F_2)", "P53 (F_3)", "P54 (F_4)", "P55 (F_5)", "P56 (F_6)", "P57 (F_7)", "P58 (F_8)", "P59 (F_9)", "P5A (F_10)", "P5B (F_11)", "P5C (F_12)", "P5D (F_13)", "P5E (F_14)", "P5F (F_15)", "P70 (G_0)", "P71 (G_1)", "P72 (G_2)", "P73 (G_3)", "P74 (G_4)", "P75 (G_5)", "P76 (G_6)", "P77 (G_7)", "P78 (G_8)", "P79 (G_9)", "P7A (G_10)", "P7B (G_11)", "P7C (G_12)", "P7D (G_13)", "P7E (G_14)", "P7F (G_15)", "PA0 (H_0)", "PA1 (H_1)", "PA2 (H_2)", "PA3 (H_3)", "PA4 (H_4)", "PA5 (H_5)", "PA6 (H_6)", "PA7 (H_7)", "PA8 (H_8)", "PA9 (H_9)", "PAA (H_10)", "PAB (H_11)", "PAC (H_12)", "PAD (H_13)", "PAE (H_14)", "PAF (H_15)", "PB0 (I_0)", "PB1 (I_1)", "PB2 (I_2)", "PB3 (I_3)", "PB4 (I_4)", "PB5 (I_5)", "PB6 (I_6)", "PB7 (I_7)", "PB8 (I_8)", "PB9 (I_9)", "PBA (I_10)", "PBB (I_11)", "PBC (I_12)", "PBD (I_13)", "PBE (I_14)", "PBF (I_15)", "PC0 (J_0)", "PC1 (J_1)", "PC2 (J_2)", "PC3 (J_3)", "PC4 (J_4)", "PC5 (J_5)", "PC6 (J_6)", "PC7 (J_7)", "PC8 (J_8)", "PC9 (J_9)", "PCA (J_10)", "PCB (J_11)", "PCC (J_12)", "PCD (J_13)", "PCE (J_14)", "PCF (J_15)", "PF0 (K_0)", "PF1 (K_1)", "PF2 (K_2)", "PF3 (K_3)", "PF4 (K_4)", "PF5 (K_5)", "PF6 (K_6)", "PF7 (K_7)", "PF8 (K_8)", "PF9 (K_9)", "PFA (K_10)", "PFB (K_11)", "PFC (K_12)", "PFD (K_13)", "PFE (K_14)", "PFF (K_15)", "DRV8860_1", "DRV8860_2", "DRV8860_3", "DRV8860_4", "DRV8860_5", "DRV8860_6", "DRV8860_7", "DRV8860_8", "DRV8860_9", "DRV8860_10", "DRV8860_11", "DRV8860_12", "DRV8860_13", "DRV8860_14", "DRV8860_15", "DRV8860_16" +#define Gpio_enum "NONE", "INVALID", "P00 (A_0)", "P01 (A_1)", "P02 (A_2)", "P03 (A_3)", "P04 (A_4)", "P05 (A_5)", "P06 (A_6)", "P07 (A_7)", "P08 (A_8)", "P09 (A_9)", "P0A (A_10)", "P0B (A_11)", "P0C (A_12)", "P0D (A_13)", "P0E (A_14)", "P0F (A_15)", "P10 (B_0)", "P11 (B_1)", "P12 (B_2)", "P13 (B_3)", "P14 (B_4)", "P15 (B_5)", "P16 (B_6)", "P17 (B_7)", "P18 (B_8)", "P19 (B_9)", "P1A (B_10)", "P1B (B_11)", "P1C (B_12)", "P1D (B_13)", "P1E (B_14)", "P1F (B_15)", "P20 (C_0)", "P21 (C_1)", "P22 (C_2)", "P23 (C_3)", "P24 (C_4)", "P25 (C_5)", "P26 (C_6)", "P27 (C_7)", "P28 (C_8)", "P29 (C_9)", "P2A (C_10)", "P2B (C_11)", "P2C (C_12)", "P2D (C_13)", "P2E (C_14)", "P2F (C_15)", "P30 (D_0)", "P31 (D_1)", "P32 (D_2)", "P33 (D_3)", "P34 (D_4)", "P35 (D_5)", "P36 (D_6)", "P37 (D_7)", "P38 (D_8)", "P39 (D_9)", "P3A (D_10)", "P3B (D_11)", "P3C (D_12)", "P3D (D_13)", "P3E (D_14)", "P3F (D_15)", "P40 (E_0)", "P41 (E_1)", "P42 (E_2)", "P43 (E_3)", "P44 (E_4)", "P45 (E_5)", "P46 (E_6)", "P47 (E_7)", "P48 (E_8)", "P49 (E_9)", "P4A (E_10)", "P4B (E_11)", "P4C (E_12)", "P4D (E_13)", "P4E (E_14)", "P4F (E_15)", "P50 (F_0)", "P51 (F_1)", "P52 (F_2)", "P53 (F_3)", "P54 (F_4)", "P55 (F_5)", "P56 (F_6)", "P57 (F_7)", "P58 (F_8)", "P59 (F_9)", "P5A (F_10)", "P5B (F_11)", "P5C (F_12)", "P5D (F_13)", "P5E (F_14)", "P5F (F_15)", "P70 (G_0)", "P71 (G_1)", "P72 (G_2)", "P73 (G_3)", "P74 (G_4)", "P75 (G_5)", "P76 (G_6)", "P77 (G_7)", "P78 (G_8)", "P79 (G_9)", "P7A (G_10)", "P7B (G_11)", "P7C (G_12)", "P7D (G_13)", "P7E (G_14)", "P7F (G_15)", "PA0 (H_0)", "PA1 (H_1)", "PA2 (H_2)", "PA3 (H_3)", "PA4 (H_4)", "PA5 (H_5)", "PA6 (H_6)", "PA7 (H_7)", "PA8 (H_8)", "PA9 (H_9)", "PAA (H_10)", "PAB (H_11)", "PAC (H_12)", "PAD (H_13)", "PAE (H_14)", "PAF (H_15)", "PB0 (I_0)", "PB1 (I_1)", "PB2 (I_2)", "PB3 (I_3)", "PB4 (I_4)", "PB5 (I_5)", "PB6 (I_6)", "PB7 (I_7)", "PB8 (I_8)", "PB9 (I_9)", "PBA (I_10)", "PBB (I_11)", "PBC (I_12)", "PBD (I_13)", "PBE (I_14)", "PBF (I_15)", "PC0 (J_0)", "PC1 (J_1)", "PC2 (J_2)", "PC3 (J_3)", "PC4 (J_4)", "PC5 (J_5)", "PC6 (J_6)", "PC7 (J_7)", "PC8 (J_8)", "PC9 (J_9)", "PCA (J_10)", "PCB (J_11)", "PCC (J_12)", "PCD (J_13)", "PCE (J_14)", "PCF (J_15)", "PF0 (K_0)", "PF1 (K_1)", "PF2 (K_2)", "PF3 (K_3)", "PF4 (K_4)", "PF5 (K_5)", "PF6 (K_6)", "PF7 (K_7)", "PF8 (K_8)", "PF9 (K_9)", "PFA (K_10)", "PFB (K_11)", "PFC (K_12)", "PFD (K_13)", "PFE (K_14)", "PFF (K_15)", "DRV8860_1", "DRV8860_2", "DRV8860_3", "DRV8860_4", "DRV8860_5", "DRV8860_6", "DRV8860_7", "DRV8860_8", "DRV8860_9", "DRV8860_10", "DRV8860_11", "DRV8860_12", "DRV8860_13", "DRV8860_14", "DRV8860_15", "DRV8860_16" ! Based on Cypress S6E2Cx pinout (144-pin package) #define brain_input_pin_e_enum "NONE", "INVALID", "P00 (A_0)", "P01 (A_1)", "P02 (A_2)", "P03 (A_3)", "P04 (A_4)", "P05 (A_5)", "P06 (A_6)", "P07 (A_7)", "P08 (A_8)", "P09 (A_9)", "P0A (A_10)", "P0B (A_11)", "P0C (A_12)", "P0D (A_13)", "P0E (A_14)", "P0F (A_15)", "P10 (B_0)", "P11 (B_1)", "P12 (B_2)", "P13 (B_3)", "P14 (B_4)", "P15 (B_5)", "P16 (B_6)", "P17 (B_7)", "P18 (B_8)", "P19 (B_9)", "P1A (B_10)", "P1B (B_11)", "P1C (B_12)", "P1D (B_13)", "P1E (B_14)", "P1F (B_15)", "P20 (C_0)", "P21 (C_1)", "P22 (C_2)", "P23 (C_3)", "P24 (C_4)", "P25 (C_5)", "P26 (C_6)", "P27 (C_7)", "P28 (C_8)", "P29 (C_9)", "P2A (C_10)", "P2B (C_11)", "P2C (C_12)", "P2D (C_13)", "P2E (C_14)", "P2F (C_15)", "P30 (D_0)", "P31 (D_1)", "P32 (D_2)", "P33 (D_3)", "P34 (D_4)", "P35 (D_5)", "P36 (D_6)", "P37 (D_7)", "P38 (D_8)", "P39 (D_9)", "P3A (D_10)", "P3B (D_11)", "P3C (D_12)", "P3D (D_13)", "P3E (D_14)", "P3F (D_15)", "P40 (E_0)", "P41 (E_1)", "P42 (E_2)", "P43 (E_3)", "P44 (E_4)", "P45 (E_5)", "P46 (E_6)", "P47 (E_7)", "P48 (E_8)", "P49 (E_9)", "P4A (E_10)", "P4B (E_11)", "P4C (E_12)", "P4D (E_13)", "P4E (E_14)", "P4F (E_15)", "P50 (F_0)", "P51 (F_1)", "P52 (F_2)", "P53 (F_3)", "P54 (F_4)", "P55 (F_5)", "P56 (F_6)", "P57 (F_7)", "P58 (F_8)", "P59 (F_9)", "P5A (F_10)", "P5B (F_11)", "P5C (F_12)", "P5D (F_13)", "P5E (F_14)", "P5F (F_15)", "P70 (G_0)", "P71 (G_1)", "P72 (G_2)", "P73 (G_3)", "P74 (G_4)", "P75 (G_5)", "P76 (G_6)", "P77 (G_7)", "P78 (G_8)", "P79 (G_9)", "P7A (G_10)", "P7B (G_11)", "P7C (G_12)", "P7D (G_13)", "P7E (G_14)", "P7F (G_15)", "PA0 (H_0)", "PA1 (H_1)", "PA2 (H_2)", "PA3 (H_3)", "PA4 (H_4)", "PA5 (H_5)", "PA6 (H_6)", "PA7 (H_7)", "PA8 (H_8)", "PA9 (H_9)", "PAA (H_10)", "PAB (H_11)", "PAC (H_12)", "PAD (H_13)", "PAE (H_14)", "PAF (H_15)", "PB0 (I_0)", "PB1 (I_1)", "PB2 (I_2)", "PB3 (I_3)", "PB4 (I_4)", "PB5 (I_5)", "PB6 (I_6)", "PB7 (I_7)", "PB8 (I_8)", "PB9 (I_9)", "PBA (I_10)", "PBB (I_11)", "PBC (I_12)", "PBD (I_13)", "PBE (I_14)", "PBF (I_15)", "PC0 (J_0)", "PC1 (J_1)", "PC2 (J_2)", "PC3 (J_3)", "PC4 (J_4)", "PC5 (J_5)", "PC6 (J_6)", "PC7 (J_7)", "PC8 (J_8)", "PC9 (J_9)", "PCA (J_10)", "PCB (J_11)", "PCC (J_12)", "PCD (J_13)", "PCE (J_14)", "PCF (J_15)", "PF0 (K_0)", "PF1 (K_1)", "PF2 (K_2)", "PF3 (K_3)", "PF4 (K_4)", "PF5 (K_5)", "PF6 (K_6)", "PF7 (K_7)", "PF8 (K_8)", "PF9 (K_9)", "PFA (K_10)", "PFB (K_11)", "PFC (K_12)", "PFD (K_13)", "PFE (K_14)", "PFF (K_15)", "DRV8860_1", "DRV8860_2", "DRV8860_3", "DRV8860_4", "DRV8860_5", "DRV8860_6", "DRV8860_7", "DRV8860_8", "DRV8860_9", "DRV8860_10", "DRV8860_11", "DRV8860_12", "DRV8860_13", "DRV8860_14", "DRV8860_15", "DRV8860_16" diff --git a/firmware/config/boards/hellen/cypress/efifeatures.h b/firmware/config/boards/hellen/cypress/efifeatures.h index 785cd10a45..7fec6455eb 100644 --- a/firmware/config/boards/hellen/cypress/efifeatures.h +++ b/firmware/config/boards/hellen/cypress/efifeatures.h @@ -250,11 +250,6 @@ #define EFI_SPI3_AF PAL_MODE_ALTERNATIVE_SPI -#define EFI_I2C_SCL_BRAIN_PIN GPIOB_6 - -#define EFI_I2C_SDA_BRAIN_PIN GPIOB_7 -#define EFI_I2C_AF 4 - /** * Patched version of ChibiOS/RT support extra details in the system error messages */ @@ -310,11 +305,11 @@ // LED1 = GPIOJ_15 // LED2 = GPIOJ_0 // LED3 = GPIOJ_12 -// LED4 = GPIOA_0 +// LED4 = Gpio::A0 -#define LED_WARNING_BRAIN_PIN GPIOA_0 +#define LED_WARNING_BRAIN_PIN Gpio::A0 -#define LED_CRITICAL_ERROR_BRAIN_PIN GPIOJ_15 +#define LED_CRITICAL_ERROR_BRAIN_PIN Gpio::J15 #define LED_ERROR_BRAIN_PIN_MODE INVERTED_OUTPUT #define EFI_WARNING_LED FALSE diff --git a/firmware/config/boards/hellen/cypress/rusefi_hw_enums.h b/firmware/config/boards/hellen/cypress/rusefi_hw_enums.h index 5110e9cd37..089689fd5e 100644 --- a/firmware/config/boards/hellen/cypress/rusefi_hw_enums.h +++ b/firmware/config/boards/hellen/cypress/rusefi_hw_enums.h @@ -8,8 +8,6 @@ #pragma once -enum class TestCppStyleEnum : uint8_t { }; - // todo: migrate/unify with pin_output_mode_e? rename? something is messy here // this enum is currently only used for SPI pins typedef enum __attribute__ ((__packed__)) { @@ -23,196 +21,196 @@ typedef enum __attribute__ ((__packed__)) { /** * Hardware pin. This enum is platform-specific. */ -typedef enum __attribute__ ((__packed__)) { - GPIO_UNASSIGNED = 0, - GPIO_INVALID = 1, +enum class Gpio : uint8_t { + Unassigned = 0, + Invalid = 1, - GPIOA_0 = 2, - GPIOA_1 = 3, - GPIOA_2 = 4, - GPIOA_3 = 5, - GPIOA_4 = 6, - GPIOA_5 = 7, - GPIOA_6 = 8, - GPIOA_7 = 9, - GPIOA_8 = 10, - GPIOA_9 = 11, - GPIOA_10 = 12, - GPIOA_11 = 13, - GPIOA_12 = 14, - GPIOA_13 = 15, - GPIOA_14 = 16, - GPIOA_15 = 17, + A0 = 2, + A1 = 3, + A2 = 4, + A3 = 5, + A4 = 6, + A5 = 7, + A6 = 8, + A7 = 9, + A8 = 10, + A9 = 11, + A10 = 12, + A11 = 13, + A12 = 14, + A13 = 15, + A14 = 16, + A15 = 17, - GPIOB_0 = 18, - GPIOB_1 = 19, - GPIOB_2 = 20, - GPIOB_3 = 21, - GPIOB_4 = 22, - GPIOB_5 = 23, - GPIOB_6 = 24, - GPIOB_7 = 25, - GPIOB_8 = 26, - GPIOB_9 = 27, - GPIOB_10 = 28, - GPIOB_11 = 29, - GPIOB_12 = 30, - GPIOB_13 = 31, - GPIOB_14 = 32, - GPIOB_15 = 33, + B0 = 18, + B1 = 19, + B2 = 20, + B3 = 21, + B4 = 22, + B5 = 23, + B6 = 24, + B7 = 25, + B8 = 26, + B9 = 27, + B10 = 28, + B11 = 29, + B12 = 30, + B13 = 31, + B14 = 32, + B15 = 33, - GPIOC_0 = 34, - GPIOC_1 = 35, - GPIOC_2 = 36, - GPIOC_3 = 37, - GPIOC_4 = 38, - GPIOC_5 = 39, - GPIOC_6 = 40, - GPIOC_7 = 41, - GPIOC_8 = 42, - GPIOC_9 = 43, - GPIOC_10 = 44, - GPIOC_11 = 45, - GPIOC_12 = 46, - GPIOC_13 = 47, - GPIOC_14 = 48, - GPIOC_15 = 49, + C0 = 34, + C1 = 35, + C2 = 36, + C3 = 37, + C4 = 38, + C5 = 39, + C6 = 40, + C7 = 41, + C8 = 42, + C9 = 43, + C10 = 44, + C11 = 45, + C12 = 46, + C13 = 47, + C14 = 48, + C15 = 49, - GPIOD_0 = 50, - GPIOD_1 = 51, - GPIOD_2 = 52, - GPIOD_3 = 53, - GPIOD_4 = 54, - GPIOD_5 = 55, - GPIOD_6 = 56, - GPIOD_7 = 57, - GPIOD_8 = 58, - GPIOD_9 = 59, - GPIOD_10 = 60, - GPIOD_11 = 61, - GPIOD_12 = 62, - GPIOD_13 = 63, - GPIOD_14 = 64, - GPIOD_15 = 65, + D0 = 50, + D1 = 51, + D2 = 52, + D3 = 53, + D4 = 54, + D5 = 55, + D6 = 56, + D7 = 57, + D8 = 58, + D9 = 59, + D10 = 60, + D11 = 61, + D12 = 62, + D13 = 63, + D14 = 64, + D15 = 65, - GPIOE_0 = 66, - GPIOE_1 = 67, - GPIOE_2 = 68, - GPIOE_3 = 69, - GPIOE_4 = 70, - GPIOE_5 = 71, - GPIOE_6 = 72, - GPIOE_7 = 73, - GPIOE_8 = 74, - GPIOE_9 = 75, - GPIOE_10 = 76, - GPIOE_11 = 77, - GPIOE_12 = 78, - GPIOE_13 = 79, - GPIOE_14 = 80, - GPIOE_15 = 81, + E0 = 66, + E1 = 67, + E2 = 68, + E3 = 69, + E4 = 70, + E5 = 71, + E6 = 72, + E7 = 73, + E8 = 74, + E9 = 75, + E10 = 76, + E11 = 77, + E12 = 78, + E13 = 79, + E14 = 80, + E15 = 81, - GPIOF_0 = 82, - GPIOF_1 = 83, - GPIOF_2 = 84, - GPIOF_3 = 85, - GPIOF_4 = 86, - GPIOF_5 = 87, - GPIOF_6 = 88, - GPIOF_7 = 89, - GPIOF_8 = 90, - GPIOF_9 = 91, - GPIOF_10 = 92, - GPIOF_11 = 93, - GPIOF_12 = 94, - GPIOF_13 = 95, - GPIOF_14 = 96, - GPIOF_15 = 97, + F0 = 82, + F1 = 83, + F2 = 84, + F3 = 85, + F4 = 86, + F5 = 87, + F6 = 88, + F7 = 89, + F8 = 90, + F9 = 91, + F10 = 92, + F11 = 93, + F12 = 94, + F13 = 95, + F14 = 96, + F15 = 97, - GPIOG_0 = 98, - GPIOG_1 = 99, - GPIOG_2 = 100, - GPIOG_3 = 101, - GPIOG_4 = 102, - GPIOG_5 = 103, - GPIOG_6 = 104, - GPIOG_7 = 105, - GPIOG_8 = 106, - GPIOG_9 = 107, - GPIOG_10 = 108, - GPIOG_11 = 109, - GPIOG_12 = 110, - GPIOG_13 = 111, - GPIOG_14 = 112, - GPIOG_15 = 113, + G0 = 98, + G1 = 99, + G2 = 100, + G3 = 101, + G4 = 102, + G5 = 103, + G6 = 104, + G7 = 105, + G8 = 106, + G9 = 107, + G10 = 108, + G11 = 109, + G12 = 110, + G13 = 111, + G14 = 112, + G15 = 113, - GPIOH_0 = 114, - GPIOH_1 = 115, - GPIOH_2 = 116, - GPIOH_3 = 117, - GPIOH_4 = 118, - GPIOH_5 = 119, - GPIOH_6 = 120, - GPIOH_7 = 121, - GPIOH_8 = 122, - GPIOH_9 = 123, - GPIOH_10 = 124, - GPIOH_11 = 125, - GPIOH_12 = 126, - GPIOH_13 = 127, - GPIOH_14 = 128, - GPIOH_15 = 129, + H0 = 114, + H1 = 115, + H2 = 116, + H3 = 117, + H4 = 118, + H5 = 119, + H6 = 120, + H7 = 121, + H8 = 122, + H9 = 123, + H10 = 124, + H11 = 125, + H12 = 126, + H13 = 127, + H14 = 128, + H15 = 129, - GPIOI_0 = 130, - GPIOI_1 = 131, - GPIOI_2 = 132, - GPIOI_3 = 133, - GPIOI_4 = 134, - GPIOI_5 = 135, - GPIOI_6 = 136, - GPIOI_7 = 137, - GPIOI_8 = 138, - GPIOI_9 = 139, - GPIOI_10 = 140, - GPIOI_11 = 141, - GPIOI_12 = 142, - GPIOI_13 = 143, - GPIOI_14 = 144, - GPIOI_15 = 145, + I0 = 130, + I1 = 131, + I2 = 132, + I3 = 133, + I4 = 134, + I5 = 135, + I6 = 136, + I7 = 137, + I8 = 138, + I9 = 139, + I10 = 140, + I11 = 141, + I12 = 142, + I13 = 143, + I14 = 144, + I15 = 145, - GPIOJ_0 = 146, - GPIOJ_1 = 147, - GPIOJ_2 = 148, - GPIOJ_3 = 149, - GPIOJ_4 = 150, - GPIOJ_5 = 151, - GPIOJ_6 = 152, - GPIOJ_7 = 153, - GPIOJ_8 = 154, - GPIOJ_9 = 155, - GPIOJ_10 = 156, - GPIOJ_11 = 157, - GPIOJ_12 = 158, - GPIOJ_13 = 159, - GPIOJ_14 = 160, - GPIOJ_15 = 161, + J0 = 146, + J1 = 147, + J2 = 148, + J3 = 149, + J4 = 150, + J5 = 151, + J6 = 152, + J7 = 153, + J8 = 154, + J9 = 155, + J10 = 156, + J11 = 157, + J12 = 158, + J13 = 159, + J14 = 160, + J15 = 161, - GPIOK_0 = 162, - GPIOK_1 = 163, - GPIOK_2 = 164, - GPIOK_3 = 165, - GPIOK_4 = 166, - GPIOK_5 = 167, - GPIOK_6 = 168, - GPIOK_7 = 169, - GPIOK_8 = 170, - GPIOK_9 = 171, - GPIOK_10 = 172, - GPIOK_11 = 173, - GPIOK_12 = 174, - GPIOK_13 = 175, - GPIOK_14 = 176, - GPIOK_15 = 177, + K0 = 162, + K1 = 163, + K2 = 164, + K3 = 165, + K4 = 166, + K5 = 167, + K6 = 168, + K7 = 169, + K8 = 170, + K9 = 171, + K10 = 172, + K11 = 173, + K12 = 174, + K13 = 175, + K14 = 176, + K15 = 177, DRV8860_PIN_1 = 178, DRV8860_PIN_2 = 179, @@ -230,14 +228,13 @@ typedef enum __attribute__ ((__packed__)) { DRV8860_PIN_14 = 191, DRV8860_PIN_15 = 192, DRV8860_PIN_16 = 193, - -} brain_pin_e; +}; /* Plase keep updating this defines */ -#define BRAIN_PIN_ONCHIP_LAST GPIOK_15 -#define BRAIN_PIN_ONCHIP_PINS (BRAIN_PIN_ONCHIP_LAST - GPIOA_0 + 1) -#define BRAIN_PIN_LAST DRV8860_PIN_16 -#define BRAIN_PIN_TOTAL_PINS (BRAIN_PIN_LAST - GPIOA_0 + 1) +#define BRAIN_PIN_ONCHIP_LAST Gpio::K15 +#define BRAIN_PIN_ONCHIP_PINS (BRAIN_PIN_ONCHIP_LAST - Gpio::A0 + 1) +#define BRAIN_PIN_LAST Gpio::DRV8860_PIN_16 +#define BRAIN_PIN_TOTAL_PINS (BRAIN_PIN_LAST - Gpio::A0 + 1) typedef enum __attribute__ ((__packed__)) { EFI_ADC_NONE = 0, diff --git a/firmware/config/boards/hellen/harley81/board_configuration.cpp b/firmware/config/boards/hellen/harley81/board_configuration.cpp index 07a645e266..07eb273244 100644 --- a/firmware/config/boards/hellen/harley81/board_configuration.cpp +++ b/firmware/config/boards/hellen/harley81/board_configuration.cpp @@ -23,31 +23,31 @@ static OutputPin alphaCrankNPullUp; static void setInjectorPins() { engineConfiguration->injectionPins[0] = H144_LS_1; engineConfiguration->injectionPins[1] = H144_LS_2; - engineConfiguration->injectionPins[2] = GPIO_UNASSIGNED; - engineConfiguration->injectionPins[3] = GPIO_UNASSIGNED; + engineConfiguration->injectionPins[2] = Gpio::Unassigned; + engineConfiguration->injectionPins[3] = Gpio::Unassigned; // Disable remainder for (int i = 4; i < MAX_CYLINDER_COUNT;i++) { - engineConfiguration->injectionPins[i] = GPIO_UNASSIGNED; + engineConfiguration->injectionPins[i] = Gpio::Unassigned; } engineConfiguration->injectionPinMode = OM_DEFAULT; - engineConfiguration->clutchDownPin = GPIO_UNASSIGNED; + engineConfiguration->clutchDownPin = Gpio::Unassigned; engineConfiguration->clutchDownPinMode = PI_PULLDOWN; engineConfiguration->launchActivationMode = CLUTCH_INPUT_LAUNCH; - engineConfiguration->malfunctionIndicatorPin = GPIO_UNASSIGNED; + engineConfiguration->malfunctionIndicatorPin = Gpio::Unassigned; } static void setIgnitionPins() { engineConfiguration->ignitionPins[0] = H144_IGN_1; engineConfiguration->ignitionPins[1] = H144_IGN_2; - engineConfiguration->ignitionPins[2] = GPIO_UNASSIGNED; - engineConfiguration->ignitionPins[3] = GPIO_UNASSIGNED; + engineConfiguration->ignitionPins[2] = Gpio::Unassigned; + engineConfiguration->ignitionPins[3] = Gpio::Unassigned; // disable remainder for (int i = 4; i < MAX_CYLINDER_COUNT; i++) { - engineConfiguration->ignitionPins[i] = GPIO_UNASSIGNED; + engineConfiguration->ignitionPins[i] = Gpio::Unassigned; } engineConfiguration->ignitionPinMode = OM_DEFAULT; @@ -67,7 +67,7 @@ static void setupEtb() { // Disable pin engineConfiguration->etbIo[0].disablePin = H144_OUT_IO1; // Unused - engineConfiguration->etbIo[0].directionPin2 = GPIO_UNASSIGNED; + engineConfiguration->etbIo[0].directionPin2 = Gpio::Unassigned; // we only have pwm/dir, no dira/dirb engineConfiguration->etb_use_two_wires = false; @@ -89,9 +89,9 @@ static void setupVbatt() { static void setupDefaultSensorInputs() { // trigger inputs, hall engineConfiguration->triggerInputPins[0] = H144_IN_SENS4; - engineConfiguration->triggerInputPins[1] = GPIO_UNASSIGNED; - engineConfiguration->triggerInputPins[2] = GPIO_UNASSIGNED; - engineConfiguration->camInputs[0] = GPIO_UNASSIGNED; + engineConfiguration->triggerInputPins[1] = Gpio::Unassigned; + engineConfiguration->triggerInputPins[2] = Gpio::Unassigned; + engineConfiguration->camInputs[0] = Gpio::Unassigned; engineConfiguration->vehicleSpeedSensorInputPin = H144_IN_VSS; @@ -143,8 +143,8 @@ void setBoardConfigOverrides() { engineConfiguration->clt.config.bias_resistor = 4700; engineConfiguration->iat.config.bias_resistor = 4700; - engineConfiguration->canTxPin = GPIOD_1; - engineConfiguration->canRxPin = GPIOD_0; + engineConfiguration->canTxPin = Gpio::D1; + engineConfiguration->canRxPin = Gpio::D0; } void setSerialConfigurationOverrides() { @@ -167,10 +167,10 @@ void setBoardDefaultConfiguration() { setInjectorPins(); setIgnitionPins(); setupEtb(); - engineConfiguration->acSwitch = GPIO_UNASSIGNED; + engineConfiguration->acSwitch = Gpio::Unassigned; engineConfiguration->fuelPumpPin = H144_OUT_PWM2; engineConfiguration->fanPin = H144_OUT_PWM4; - engineConfiguration->mainRelayPin = GPIO_UNASSIGNED; + engineConfiguration->mainRelayPin = Gpio::Unassigned; engineConfiguration->tachOutputPin = H144_OUT_PWM3; // "required" hardware is done - set some reasonable defaults @@ -186,7 +186,7 @@ void setBoardDefaultConfiguration() { engineConfiguration->clutchDownPin = H144_IN_D_2; engineConfiguration->clutchDownPinMode = PI_PULLDOWN; engineConfiguration->launchActivationMode = CLUTCH_INPUT_LAUNCH; -// ? engineConfiguration->malfunctionIndicatorPin = GPIOG_4; //1E - Check Engine Light +// ? engineConfiguration->malfunctionIndicatorPin = Gpio::G4; //1E - Check Engine Light setHellenDefaultVrThresholds(); engineConfiguration->vrThreshold[0].pin = H144_OUT_PWM6; } diff --git a/firmware/config/boards/hellen/harley81/connectors/harley81.yaml b/firmware/config/boards/hellen/harley81/connectors/harley81.yaml index 9f9232641e..24b3d90243 100644 --- a/firmware/config/boards/hellen/harley81/connectors/harley81.yaml +++ b/firmware/config/boards/hellen/harley81/connectors/harley81.yaml @@ -1,19 +1,19 @@ pins: - pin: auxMain #H144_OUT_IO7 - id: GPIOG_3 + id: G3 class: outputs ts_name: auxMain - pin: auxWastegate #H176_OUT_PWM3 - id: GPIOC_7 + id: C7 class: outputs ts_name: auxWastegate - pin: 1 # H144_OUT_PWM7 - id: GPIOD_15 + id: D15 class: outputs function: Right Oil Cooling Fan ts_name: 1 Right Oil Cooling @@ -28,7 +28,7 @@ pins: - pin: 4 # H144_OUT_PWM6 - id: GPIOD_14 + id: D14 class: outputs function: Left Oil Cooling Fan ts_name: 4 Left Oil Fan @@ -42,28 +42,28 @@ pins: - pin: 6 # H144_LS_1 - id: GPIOG_7 + id: G7 class: outputs function: Front Injector ts_name: 6 Front Injector - pin: 7 # H144_LS_2 - id: GPIOG_8 + id: G8 class: outputs function: Rear Injector ts_name: 7 Rear Injector - pin: 8 # H144_OUT_IO6 - id: GPIOG_11 + id: G11 class: outputs function: Rear ACR ts_name: 8 Rear ACR - pin: 11 # H144_IN_SENS4 - id: GPIOF_6 + id: F6 class: event_inputs function: Crank Sensor VR- Negative Input ts_name: 11 Crank VR- @@ -80,7 +80,7 @@ pins: - pin: 24 # H144_IGN_1 - id: GPIOC_13 + id: C13 class: outputs ts_name: 24 Front Coil function: Front Coil @@ -88,7 +88,7 @@ pins: - pin: 25 # H144_OUT_IO5 - id: GPIOD_2 + id: D2 class: outputs ts_name: 25 Front ACR function: Front ACR @@ -152,7 +152,7 @@ pins: - pin: 43 # H144_IGN_2 - id: GPIOE_5 + id: E5 class: outputs ts_name: 43 Rear Coil function: Rear Coil @@ -180,7 +180,7 @@ pins: - pin: 51 # H144_IN_VSS - id: GPIOF_11 + id: F11 class: event_inputs ts_name: 51 - VSS function: VSS in @@ -207,7 +207,7 @@ pins: - pin: 61 # low6 huh? # H144_OUT_IO3 - id: GPIOG_14 + id: G14 class: outputs ts_name: 61 Reverse Gear function: Reverse Gear @@ -215,7 +215,7 @@ pins: - pin: 63 # low7 huh? # H144_OUT_IO4 - id: GPIOG_5 + id: G5 class: outputs ts_name: 63 Cooling Pump function: Cooling Pump diff --git a/firmware/config/boards/hellen/hellen-common144.mk b/firmware/config/boards/hellen/hellen-common144.mk index 9eb6ee898a..c15490ca0e 100644 --- a/firmware/config/boards/hellen/hellen-common144.mk +++ b/firmware/config/boards/hellen/hellen-common144.mk @@ -6,6 +6,6 @@ endif DDEFS += $(LED_CRITICAL_ERROR_BRAIN_PIN) -PRIMARY_COMMUNICATION_PORT_USART2=-DEFI_CONSOLE_TX_BRAIN_PIN=GPIOD_6 -DEFI_CONSOLE_RX_BRAIN_PIN=GPIOD_5 -DTS_PRIMARY_PORT=UARTD2 -DSTM32_UART_USE_USART2=1 +PRIMARY_COMMUNICATION_PORT_USART2=-DEFI_CONSOLE_TX_BRAIN_PIN=Gpio::D6 -DEFI_CONSOLE_RX_BRAIN_PIN=Gpio::D5 -DTS_PRIMARY_PORT=UARTD2 -DSTM32_UART_USE_USART2=1 include $(BOARDS_DIR)/hellen/hellen-common.mk \ No newline at end of file diff --git a/firmware/config/boards/hellen/hellen-nb1/board_configuration.cpp b/firmware/config/boards/hellen/hellen-nb1/board_configuration.cpp index b17e73c805..8fac3638f9 100644 --- a/firmware/config/boards/hellen/hellen-nb1/board_configuration.cpp +++ b/firmware/config/boards/hellen/hellen-nb1/board_configuration.cpp @@ -22,12 +22,12 @@ static void setInjectorPins() { // Disable remainder for (int i = 4; i < MAX_CYLINDER_COUNT;i++) { - engineConfiguration->injectionPins[i] = GPIO_UNASSIGNED; + engineConfiguration->injectionPins[i] = Gpio::Unassigned; } engineConfiguration->injectionPinMode = OM_DEFAULT; - engineConfiguration->clutchDownPin = GPIOC_4; // Clutch switch input + engineConfiguration->clutchDownPin = Gpio::C4; // Clutch switch input engineConfiguration->clutchDownPinMode = PI_PULLDOWN; engineConfiguration->launchActivationMode = CLUTCH_INPUT_LAUNCH; engineConfiguration->malfunctionIndicatorPin = H144_OUT_IO8; @@ -35,13 +35,13 @@ static void setInjectorPins() { static void setIgnitionPins() { engineConfiguration->ignitionPins[0] = H144_IGN_1; - engineConfiguration->ignitionPins[1] = GPIO_UNASSIGNED; + engineConfiguration->ignitionPins[1] = Gpio::Unassigned; engineConfiguration->ignitionPins[2] = H144_IGN_2; - engineConfiguration->ignitionPins[3] = GPIO_UNASSIGNED; + engineConfiguration->ignitionPins[3] = Gpio::Unassigned; // disable remainder for (int i = 4; i < MAX_CYLINDER_COUNT; i++) { - engineConfiguration->ignitionPins[i] = GPIO_UNASSIGNED; + engineConfiguration->ignitionPins[i] = Gpio::Unassigned; } engineConfiguration->ignitionPinMode = OM_DEFAULT; @@ -64,8 +64,8 @@ static void setupVbatt() { static void setupDefaultSensorInputs() { // trigger inputs, hall engineConfiguration->triggerInputPins[0] = H144_IN_CRANK; - engineConfiguration->triggerInputPins[1] = GPIO_UNASSIGNED; - engineConfiguration->triggerInputPins[2] = GPIO_UNASSIGNED; + engineConfiguration->triggerInputPins[1] = Gpio::Unassigned; + engineConfiguration->triggerInputPins[2] = Gpio::Unassigned; engineConfiguration->camInputs[0] = H144_IN_CAM; engineConfiguration->tps1_1AdcChannel = EFI_ADC_4; @@ -92,8 +92,8 @@ void setBoardConfigOverrides() { engineConfiguration->clt.config.bias_resistor = 4700; engineConfiguration->iat.config.bias_resistor = 4700; - engineConfiguration->canTxPin = GPIOD_1; - engineConfiguration->canRxPin = GPIOD_0; + engineConfiguration->canTxPin = Gpio::D1; + engineConfiguration->canRxPin = Gpio::D0; if (engineConfiguration->trigger.type == TT_MAZDA_MIATA_NB1) { engineConfiguration->trigger.type = TT_MIATA_VVT; @@ -123,10 +123,10 @@ void setBoardDefaultConfiguration() { engineConfiguration->boostControlPin = H144_LS_6; engineConfiguration->acSwitch = H144_IN_D_AUX3; engineConfiguration->acRelayPin = H144_OUT_IO6; - engineConfiguration->fuelPumpPin = GPIOG_2; // OUT_IO9 - engineConfiguration->idle.solenoidPin = GPIOD_14; // OUT_PWM5 - engineConfiguration->fanPin = GPIOD_12; // OUT_PWM8 - engineConfiguration->mainRelayPin = GPIOI_2; // OUT_LOW3 + engineConfiguration->fuelPumpPin = Gpio::G2; // OUT_IO9 + engineConfiguration->idle.solenoidPin = Gpio::D14; // OUT_PWM5 + engineConfiguration->fanPin = Gpio::D12; // OUT_PWM8 + engineConfiguration->mainRelayPin = Gpio::I2; // OUT_LOW3 engineConfiguration->tachOutputPin = H144_OUT_PWM1; engineConfiguration->alternatorControlPin = H144_OUT_PWM7; engineConfiguration->fan2Pin = H144_OUT_IO2; @@ -144,7 +144,7 @@ void setBoardDefaultConfiguration() { engineConfiguration->clutchDownPin = H144_IN_D_2; engineConfiguration->clutchDownPinMode = PI_PULLDOWN; engineConfiguration->launchActivationMode = CLUTCH_INPUT_LAUNCH; -// ? engineConfiguration->malfunctionIndicatorPin = GPIOG_4; //1E - Check Engine Light +// ? engineConfiguration->malfunctionIndicatorPin = Gpio::G4; //1E - Check Engine Light } /** diff --git a/firmware/config/boards/hellen/hellen-nb1/connectors/main.yaml b/firmware/config/boards/hellen/hellen-nb1/connectors/main.yaml index c0121c565f..e21c0a1c53 100644 --- a/firmware/config/boards/hellen/hellen-nb1/connectors/main.yaml +++ b/firmware/config/boards/hellen/hellen-nb1/connectors/main.yaml @@ -20,26 +20,26 @@ pins: type: can - pin: 1F - id: [GPIOF_9, ADC3_CHANNEL_7] + id: [F9, ADC3_CHANNEL_7] class: [switch_inputs, analog_inputs] ts_name: 1F - Brake/RES1 function: Brake Switch - pin: 1E - id: GPIOG_4 + id: G4 class: outputs ts_name: 1E - Check Engine Light function: Check Engine Light type: ls - pin: 1G - id: [GPIOF_10, EFI_ADC_3] + id: [F10, EFI_ADC_3] class: [switch_inputs, analog_inputs] ts_name: 1G - Steering/RES2 function: Power Steering Switch - pin: 1I - id: GPIOA_9 + id: A9 class: outputs ts_name: 1I AC Fan Relay function: AC Fan Relay @@ -49,27 +49,27 @@ pins: type: ls - pin: 1O - id: GPIOD_15 + id: D15 class: outputs ts_name: 1O - ALTERN function: PWM signal to control alternator field voltage type: ls - pin: 1P - id: [GPIOC_5, EFI_ADC_15] + id: [C5, EFI_ADC_15] class: [switch_inputs, analog_inputs] ts_name: 1P - AC Switch function: A/C Pressure In - pin: 1Q - id: GPIOG_12 + id: G12 class: outputs ts_name: 1Q - Aternator Warning Lamp function: Alternator Warning Light type: ls - pin: 1R - id: GPIOD_12 + id: D12 class: outputs ts_name: 1R - ECF function: Engine Radiator Fan @@ -77,26 +77,26 @@ pins: - pin: 1S #H144_OUT_IO6 - id: GPIOG_11 + id: G11 class: outputs ts_name: 1S - AC Relay function: A/C Relay type: ls - pin: 1U - id: GPIOD_3 + id: D3 class: outputs ts_name: 1U - O2H function: Front O2 sens. heater - pin: 1V - id: GPIOE_14 + id: E14 class: switch_inputs ts_name: 1V - Neutral function: Neutral Switch - pin: 2A - id: [GPIOB_0, EFI_ADC_8] + id: [B0, EFI_ADC_8] class: [switch_inputs, analog_inputs] ts_name: 2A - Pressure Input function: FTP input @@ -115,7 +115,7 @@ pins: - pin: 2D # H144_IN_VSS - id: GPIOF_11 + id: F11 class: event_inputs ts_name: 2D - VSS function: VSS in @@ -127,13 +127,13 @@ pins: function: CLT sensor - pin: 2F - id: GPIOF_7 + id: F7 class: analog_inputs ts_name: 2M - KNOCK function: Knock sens. in - pin: 2H - id: [GPIOA_6, EFI_ADC_6] + id: [A6, EFI_ADC_6] class: [event_inputs, analog_inputs] ts_name: 2H - CAM function: Camshaft Sensor @@ -142,14 +142,14 @@ pins: function: +5v - pin: 2J - id: [GPIOB_1, EFI_ADC_9] + id: [B1, EFI_ADC_9] class: [event_inputs, analog_inputs] ts_name: 2J - CRANK function: Crankshaft Sensor - pin: 2K # H144_OUT_PWM1 - id: GPIOD_13 + id: D13 class: outputs ts_name: 2K - TACH function: Tach Out @@ -171,7 +171,7 @@ pins: function: GND - pin: 3D - id: [GPIOC_1, EFI_ADC_11] + id: [C1, EFI_ADC_11] class: [outputs, analog_inputs] ts_name: 3D - MAP function: MAP INPUT @@ -191,40 +191,40 @@ pins: function: GND - pin: 3G - id: GPIOC_13 + id: C13 class: outputs ts_name: 3G - IGN_1 (1&4) function: Coil #1 type: ign - pin: 3H - id: GPIOE_5 + id: E5 class: outputs ts_name: 3H - IGN_2 (2&3) function: Coil #2 type: ign - pin: 3I - id: GPIOE_13 + id: E13 class: switch_inputs ts_name: 3I - Clutch function: Clutch Switch - pin: 3J - id: GPIOF_3 + id: F3 class: switch_inputs ts_name: 3J - O2S2 function: Rear O2 Sensor Signal - pin: 3M - id: GPIOD_14 + id: D14 class: outputs ts_name: 2Q - IDLE function: IAC (negative), with diode type: ls - pin: 3N - id: GPIOG_2 + id: G2 class: outputs ts_name: 2M US / 2P EUROPE - FPUMP function: Fuel Pump Relay @@ -234,55 +234,55 @@ pins: funtion: +12v - pin: 3Q - id: GPIOF_14 + id: F14 class: outputs ts_name: 3Q - VICS function: VICS type: inj - pin: 3S - id: [GPIOA_7, EFI_ADC_7] + id: [A7, EFI_ADC_7] class: [switch_inputs, analog_inputs] ts_name: 3S - EGR BOOST IN function: EGR BOOST - pin: 3T - id: GPIOF_12 + id: F12 class: outputs ts_name: 3T/4D - BOOST OUT function: BOOST OUT type: inj - pin: 3V - id: GPIOG_13 + id: G13 class: outputs ts_name: 3V - O2H2 function: Rear O2 sensor heater type: ls - pin: 3W - id: GPIOG_7 + id: G7 class: outputs ts_name: 3W - INJ_1 function: Injector #1 type: inj - pin: 3X - id: GPIOG_8 + id: G8 class: outputs ts_name: 3X - INJ_2 function: Injector #2 type: inj - pin: 3Y - id: GPIOD_11 + id: D11 class: outputs ts_name: 3Y - INJ_3 function: Injector #3 type: inj - pin: 3Z - id: GPIOD_10 + id: D10 class: outputs ts_name: 3Z - INJ_4 function: Injector #4 @@ -292,13 +292,13 @@ pins: function: GND - pin: 4B - id: GPIOE_12 + id: E12 class: event_inputs ts_name: 4B - DIGITAL/FLEX function: DIGITAL - pin: 4C - id: [GPIOC_4, EFI_ADC_14] + id: [C4, EFI_ADC_14] class: [switch_inputs, analog_inputs] ts_name: 4C - IN TEMP/PPS2 function: TEMP OR PPS2 @@ -308,7 +308,7 @@ pins: - pin: 4E - id: GPIOD_9 + id: D9 class: outputs ts_name: 4E - VVT function: VVT Oil Control Valve neg. @@ -336,27 +336,27 @@ pins: function: WBO - pin: int_pps1 - id: [GPIOA_3] + id: [A3] class: [switch_inputs] ts_name: PPS1 - pin: int_tps2 - id: [GPIOA_1, EFI_ADC_1] + id: [A1, EFI_ADC_1] class: [switch_inputs, analog_inputs] ts_name: TPS1 - pin: int_etb+ - id: GPIOC_7 + id: C7 class: outputs ts_name: ETB + - pin: int_etb- - id: GPIOC_8 + id: C8 class: outputs ts_name: ETB - - pin: int_etb_EN - id: GPIOC_6 + id: C6 class: outputs ts_name: ETB EN diff --git a/firmware/config/boards/hellen/hellen121nissan/board_configuration.cpp b/firmware/config/boards/hellen/hellen121nissan/board_configuration.cpp index a6c5103a76..848776beda 100644 --- a/firmware/config/boards/hellen/hellen121nissan/board_configuration.cpp +++ b/firmware/config/boards/hellen/hellen121nissan/board_configuration.cpp @@ -25,7 +25,7 @@ static void setInjectorPins() { // Disable remainder for (int i = 6; i < MAX_CYLINDER_COUNT;i++) { - engineConfiguration->injectionPins[i] = GPIO_UNASSIGNED; + engineConfiguration->injectionPins[i] = Gpio::Unassigned; } engineConfiguration->injectionPinMode = OM_DEFAULT; @@ -41,7 +41,7 @@ static void setIgnitionPins() { // disable remainder for (int i = 6; i < MAX_CYLINDER_COUNT; i++) { - engineConfiguration->ignitionPins[i] = GPIO_UNASSIGNED; + engineConfiguration->ignitionPins[i] = Gpio::Unassigned; } engineConfiguration->ignitionPinMode = OM_DEFAULT; @@ -64,8 +64,8 @@ static void setupVbatt() { static void setupDefaultSensorInputs() { // trigger inputs engineConfiguration->triggerInputPins[0] = H144_IN_CRANK; - engineConfiguration->triggerInputPins[1] = GPIO_UNASSIGNED; - engineConfiguration->triggerInputPins[2] = GPIO_UNASSIGNED; + engineConfiguration->triggerInputPins[1] = Gpio::Unassigned; + engineConfiguration->triggerInputPins[2] = Gpio::Unassigned; // Direct hall-only cam input engineConfiguration->camInputs[0] = H144_IN_CAM; // todo: remove from default since 4 cylinder does not use it @@ -125,20 +125,20 @@ void setBoardDefaultConfiguration() { engineConfiguration->enableSoftwareKnock = true; engineConfiguration->canNbcType = CAN_BUS_NISSAN_VQ; - engineConfiguration->canTxPin = GPIOD_1; - engineConfiguration->canRxPin = GPIOD_0; + engineConfiguration->canTxPin = Gpio::D1; + engineConfiguration->canRxPin = Gpio::D0; - engineConfiguration->fuelPumpPin = GPIOD_12; // OUT_IO9 // 113 Fuel Pump Relay - engineConfiguration->idle.solenoidPin = GPIO_UNASSIGNED; -// engineConfiguration->fanPin = GPIOD_12; // OUT_PWM8 - engineConfiguration->mainRelayPin = GPIOG_14; // pin: 111a, OUT_IO3 + engineConfiguration->fuelPumpPin = Gpio::D12; // OUT_IO9 // 113 Fuel Pump Relay + engineConfiguration->idle.solenoidPin = Gpio::Unassigned; +// engineConfiguration->fanPin = Gpio::D12; // OUT_PWM8 + engineConfiguration->mainRelayPin = Gpio::G14; // pin: 111a, OUT_IO3 // "required" hardware is done - set some reasonable defaults setupDefaultSensorInputs(); - engineConfiguration->etbIo[0].directionPin1 = GPIOD_15; // out_pwm7 - engineConfiguration->etbIo[0].directionPin2 = GPIOD_14; // out_pwm6 - engineConfiguration->etbIo[0].controlPin = GPIOD_13; // ETB_EN out_pwm1 + engineConfiguration->etbIo[0].directionPin1 = Gpio::D15; // out_pwm7 + engineConfiguration->etbIo[0].directionPin2 = Gpio::D14; // out_pwm6 + engineConfiguration->etbIo[0].controlPin = Gpio::D13; // ETB_EN out_pwm1 engineConfiguration->etb_use_two_wires = true; // Some sensible defaults for other options @@ -160,7 +160,7 @@ void setBoardDefaultConfiguration() { engineConfiguration->crankingInjectionMode = IM_SIMULTANEOUS; engineConfiguration->injectionMode = IM_SIMULTANEOUS;//IM_BATCH;// IM_SEQUENTIAL; - engineConfiguration->luaOutputPins[0] = GPIOG_5; // 104 ETB Relay + engineConfiguration->luaOutputPins[0] = Gpio::G5; // 104 ETB Relay engineConfiguration->throttlePedalUpVoltage = 0.75; engineConfiguration->throttlePedalWOTVoltage = 4.45; @@ -183,14 +183,14 @@ void setBoardDefaultConfiguration() { void setSdCardConfigurationOverrides() { engineConfiguration->sdCardSpiDevice = SPI_DEVICE_3; - engineConfiguration->spi3mosiPin = GPIOC_12; - engineConfiguration->spi3misoPin = GPIOC_11; - engineConfiguration->spi3sckPin = GPIOC_10; - engineConfiguration->sdCardCsPin = GPIOA_15; + engineConfiguration->spi3mosiPin = Gpio::C12; + engineConfiguration->spi3misoPin = Gpio::C11; + engineConfiguration->spi3sckPin = Gpio::C10; + engineConfiguration->sdCardCsPin = Gpio::A15; -// engineConfiguration->spi2mosiPin = GPIOB_15; -// engineConfiguration->spi2misoPin = GPIOB_14; -// engineConfiguration->spi2sckPin = GPIOB_13; -// engineConfiguration->sdCardCsPin = GPIOB_12; +// engineConfiguration->spi2mosiPin = Gpio::B15; +// engineConfiguration->spi2misoPin = Gpio::B14; +// engineConfiguration->spi2sckPin = Gpio::B13; +// engineConfiguration->sdCardCsPin = Gpio::B12; engineConfiguration->is_enabled_spi_3 = true; } diff --git a/firmware/config/boards/hellen/hellen121nissan/connectors/main.yaml b/firmware/config/boards/hellen/hellen121nissan/connectors/main.yaml index c2420ca3f1..8b67f5085b 100644 --- a/firmware/config/boards/hellen/hellen121nissan/connectors/main.yaml +++ b/firmware/config/boards/hellen/hellen121nissan/connectors/main.yaml @@ -20,14 +20,14 @@ pins: function: USB - - pin: 10a - id: GPIOF_13 + id: F13 ts_name: 10 - VTC Left class: outputs function: Intake VTC solenoid Bank 2 # OUT_C-IVC_L OUT_INJ7 - pin: 11a - id: GPIOF_14 + id: F14 ts_name: 11 - VTC Right class: outputs function: Intake VTC solenoid Bank 1 @@ -36,20 +36,20 @@ pins: - pin: 13a function: Crank Sensor # IN_CRANK AIN24 A24 - id: [GPIOB_1] + id: [B1] class: [event_inputs] ts_name: 13 - Crank - pin: 14a function: Cam Sensor Left # IN_CAM_L IN_CAM AIN19 A19 - id: [GPIOA_6] + id: [A6] class: [event_inputs] ts_name: 14 - Cam Left - pin: 21a # Q307 - id: GPIOD_9 + id: D9 class: outputs ts_name: 21 - INJ_5 function: Injector 5 @@ -57,7 +57,7 @@ pins: - pin: 22a # Q309 - id: GPIOD_11 + id: D11 class: outputs ts_name: 22 - INJ_3 function: Injector 3 @@ -65,14 +65,14 @@ pins: - pin: 23a # Q312 - id: GPIOG_7 + id: G7 class: outputs ts_name: 23 - INJ_1 function: Injector 1 type: inj - pin: 29a - id: GPIOD_3 + id: D3 ts_name: 29 - VIAS class: outputs function: VIAS control Solenoid @@ -80,7 +80,7 @@ pins: - pin: 33a function: Cam Sensor Right # IN_CAM_R IN_AUX4 AIN20 A20 - id: [GPIOA_7] + id: [A7] class: [event_inputs] ts_name: 33 - Cam Right @@ -92,7 +92,7 @@ pins: - pin: 40a # Q311 - id: GPIOF_12 + id: F12 class: outputs ts_name: 40 - INJ_6 function: Injector 6 @@ -100,7 +100,7 @@ pins: - pin: 41a # Q310 - id: GPIOD_10 + id: D10 class: outputs ts_name: 41 - INJ_4 function: Injector 4 @@ -108,7 +108,7 @@ pins: - pin: 42a # Q305 - id: GPIOG_8 + id: G8 class: outputs ts_name: 42 - INJ_2 function: Injector 2 @@ -129,21 +129,21 @@ pins: function: TPS 1 sensor input - pin: 60a - id: GPIOE_2 + id: E2 class: outputs ts_name: 60 - Coil 5 function: Coil 5 type: ign - pin: 61a - id: GPIOE_4 + id: E4 class: outputs ts_name: 61 - Coil 3 function: Coil 3 type: ign - pin: 62a - id: GPIOC_13 + id: C13 class: outputs ts_name: 62 - Coil 1 function: Coil 1 @@ -191,21 +191,21 @@ pins: function: GNDA - pin: 79a - id: GPIOB_8 + id: B8 class: outputs ts_name: 79 - Coil 6 function: Coil 6 type: ign - pin: 80a - id: GPIOE_3 + id: E3 class: outputs ts_name: 80 - Coil 4 function: Coil 4 type: ign - pin: 81a - id: GPIOE_5 + id: E5 class: outputs ts_name: 81 - Coil 2 function: Coil 2 @@ -242,20 +242,20 @@ pins: function: PPS 2 sensor input - pin: 101a - id: GPIOF_9 + id: F9 class: switch_inputs ts_name: 101 - Brake Input function: Brake Switch - pin: 102a - id: GPIOF_10 + id: F10 class: switch_inputs ts_name: 102 - Power Steering Input function: Power Steering Switch - pin: 104a # LOW6_DIODE _IO4 - id: GPIOG_5 + id: G5 class: outputs ts_name: 104 ETB Relay function: ETB relay control @@ -278,7 +278,7 @@ pins: - pin: 111a # OUT_IO3 - id: GPIOG_14 + id: G14 class: outputs ts_name: 111 Main Relay function: Main relay control @@ -286,7 +286,7 @@ pins: - pin: 113a # OUT_PWM8 - id: GPIOD_12 + id: D12 class: outputs ts_name: 113 Fuel Pump Relay function: Fuel Pump control diff --git a/firmware/config/boards/hellen/hellen121vag/board_configuration.cpp b/firmware/config/boards/hellen/hellen121vag/board_configuration.cpp index a8f5b31c4f..622d9a4795 100644 --- a/firmware/config/boards/hellen/hellen121vag/board_configuration.cpp +++ b/firmware/config/boards/hellen/hellen121vag/board_configuration.cpp @@ -16,33 +16,33 @@ #include "hellen_meta.h" static void setInjectorPins() { - engineConfiguration->injectionPins[0] = GPIOG_7; // 96 - INJ_1 - engineConfiguration->injectionPins[1] = GPIOG_8; - engineConfiguration->injectionPins[2] = GPIOD_11; // 97 - INJ_3 - engineConfiguration->injectionPins[3] = GPIOD_10; + engineConfiguration->injectionPins[0] = Gpio::G7; // 96 - INJ_1 + engineConfiguration->injectionPins[1] = Gpio::G8; + engineConfiguration->injectionPins[2] = Gpio::D11; // 97 - INJ_3 + engineConfiguration->injectionPins[3] = Gpio::D10; // Disable remainder for (int i = 4; i < MAX_CYLINDER_COUNT;i++) { - engineConfiguration->injectionPins[i] = GPIO_UNASSIGNED; + engineConfiguration->injectionPins[i] = Gpio::Unassigned; } engineConfiguration->injectionPinMode = OM_DEFAULT; } static void setIgnitionPins() { - engineConfiguration->ignitionPins[0] = GPIOI_8; // 102 - IGN_1 - engineConfiguration->ignitionPins[1] = GPIOE_5 ; // 7 - IGN_2 - engineConfiguration->ignitionPins[2] = GPIOE_4; // 111 - IGN_3 - engineConfiguration->ignitionPins[3] = GPIOE_3; // 94 - IGN_4 + engineConfiguration->ignitionPins[0] = Gpio::I8; // 102 - IGN_1 + engineConfiguration->ignitionPins[1] = Gpio::E5 ; // 7 - IGN_2 + engineConfiguration->ignitionPins[2] = Gpio::E4; // 111 - IGN_3 + engineConfiguration->ignitionPins[3] = Gpio::E3; // 94 - IGN_4 - //engineConfiguration->ignitionPins[4] = GPIOE_2; - //engineConfiguration->ignitionPins[5] = GPIOI_5; - //engineConfiguration->ignitionPins[6] = GPIOI_6; - //engineConfiguration->ignitionPins[7] = GPIOI_7; + //engineConfiguration->ignitionPins[4] = Gpio::E2; + //engineConfiguration->ignitionPins[5] = Gpio::I5; + //engineConfiguration->ignitionPins[6] = Gpio::I6; + //engineConfiguration->ignitionPins[7] = Gpio::I7; // disable remainder for (int i = 4; i < MAX_CYLINDER_COUNT; i++) { - engineConfiguration->ignitionPins[i] = GPIO_UNASSIGNED; + engineConfiguration->ignitionPins[i] = Gpio::Unassigned; } engineConfiguration->ignitionPinMode = OM_DEFAULT; @@ -64,11 +64,11 @@ static void setupVbatt() { static void setupDefaultSensorInputs() { // trigger inputs - engineConfiguration->triggerInputPins[0] = GPIOB_1; // 82 - VR - engineConfiguration->triggerInputPins[1] = GPIO_UNASSIGNED; - engineConfiguration->triggerInputPins[2] = GPIO_UNASSIGNED; + engineConfiguration->triggerInputPins[0] = Gpio::B1; // 82 - VR + engineConfiguration->triggerInputPins[1] = Gpio::Unassigned; + engineConfiguration->triggerInputPins[2] = Gpio::Unassigned; // Direct hall-only cam input - engineConfiguration->camInputs[0] = GPIOA_6; // 86 - CAM1 + engineConfiguration->camInputs[0] = Gpio::A6; // 86 - CAM1 engineConfiguration->tps1_1AdcChannel = H144_IN_TPS; // 92 - TPS 1 engineConfiguration->tps1_2AdcChannel = H144_IN_AUX1; @@ -104,8 +104,8 @@ void setBoardConfigOverrides() { engineConfiguration->clt.config.bias_resistor = 4700; engineConfiguration->iat.config.bias_resistor = 4700; - engineConfiguration->canTxPin = GPIOD_1; - engineConfiguration->canRxPin = GPIOD_0; + engineConfiguration->canTxPin = Gpio::D1; + engineConfiguration->canRxPin = Gpio::D0; } void setSerialConfigurationOverrides() { @@ -128,9 +128,9 @@ void setBoardDefaultConfiguration() { setInjectorPins(); setIgnitionPins(); - engineConfiguration->etbIo[0].directionPin1 = GPIOC_6; // out_pwm2 - engineConfiguration->etbIo[0].directionPin2 = GPIOC_7; // out_pwm3 - engineConfiguration->etbIo[0].controlPin = GPIOA_8; // ETB_EN out_io12 + engineConfiguration->etbIo[0].directionPin1 = Gpio::C6; // out_pwm2 + engineConfiguration->etbIo[0].directionPin2 = Gpio::C7; // out_pwm3 + engineConfiguration->etbIo[0].controlPin = Gpio::A8; // ETB_EN out_io12 engineConfiguration->etb_use_two_wires = true; setBoschVAGETB(); @@ -148,10 +148,10 @@ void setBoardDefaultConfiguration() { engineConfiguration->enableSoftwareKnock = true; engineConfiguration->fuelPumpPin = H144_OUT_IO3; - engineConfiguration->malfunctionIndicatorPin = GPIOG_4; // 47 - CEL + engineConfiguration->malfunctionIndicatorPin = Gpio::G4; // 47 - CEL engineConfiguration->tachOutputPin = H144_OUT_PWM7; - engineConfiguration->idle.solenoidPin = GPIOD_14; // OUT_PWM5 - engineConfiguration->fanPin = GPIOD_12; // OUT_PWM8 + engineConfiguration->idle.solenoidPin = Gpio::D14; // OUT_PWM5 + engineConfiguration->fanPin = Gpio::D12; // OUT_PWM8 engineConfiguration->mainRelayPin = H144_OUT_IO1; // engineConfiguration->injectorCompensationMode @@ -182,14 +182,14 @@ void setBoardDefaultConfiguration() { void setSdCardConfigurationOverrides() { engineConfiguration->sdCardSpiDevice = SPI_DEVICE_3; - engineConfiguration->spi3mosiPin = GPIOC_12; - engineConfiguration->spi3misoPin = GPIOC_11; - engineConfiguration->spi3sckPin = GPIOC_10; - engineConfiguration->sdCardCsPin = GPIOA_15; + engineConfiguration->spi3mosiPin = Gpio::C12; + engineConfiguration->spi3misoPin = Gpio::C11; + engineConfiguration->spi3sckPin = Gpio::C10; + engineConfiguration->sdCardCsPin = Gpio::A15; -// engineConfiguration->spi2mosiPin = GPIOB_15; -// engineConfiguration->spi2misoPin = GPIOB_14; -// engineConfiguration->spi2sckPin = GPIOB_13; -// engineConfiguration->sdCardCsPin = GPIOB_12; +// engineConfiguration->spi2mosiPin = Gpio::B15; +// engineConfiguration->spi2misoPin = Gpio::B14; +// engineConfiguration->spi2sckPin = Gpio::B13; +// engineConfiguration->sdCardCsPin = Gpio::B12; engineConfiguration->is_enabled_spi_3 = true; } diff --git a/firmware/config/boards/hellen/hellen121vag/connectors/main.yaml b/firmware/config/boards/hellen/hellen121vag/connectors/main.yaml index 09c8ecfa45..97d4f9b204 100644 --- a/firmware/config/boards/hellen/hellen121vag/connectors/main.yaml +++ b/firmware/config/boards/hellen/hellen121vag/connectors/main.yaml @@ -1,6 +1,6 @@ pins: - pin: MR - id: GPIOI_2 + id: I2 class: outputs ts_name: Main Relay function: OUT_MAIN @@ -22,13 +22,13 @@ pins: function: LSU Heat - - pin: 7a - id: GPIOE_5 + id: E5 class: outputs ts_name: 7 - IGN_2 type: ign - pin: 8a - id: GPIOI_6 + id: I6 class: outputs ts_name: 8 - IGN_7 type: ign @@ -40,13 +40,13 @@ pins: function: O2 sensor signal - pin: 18a - id: GPIOC_9 + id: C9 class: outputs ts_name: 18 - VVT2 B1 function: OUT_VVT2_B1 - pin: 19a - id: GPIOF_13 + id: F13 class: outputs ts_name: 19 - INJ 7 function: OUT_INJ7 @@ -56,7 +56,7 @@ pins: function: Main relay A - pin: 22a - id: GPIOI_0 + id: I0 class: outputs ts_name: 22 - VVT1 1 function: OUT_VVT1_1 @@ -65,7 +65,7 @@ pins: function: Main relay B - pin: 24a - id: GPIOF_14 + id: F14 class: outputs ts_name: 24 - INJ 8 function: OUT_INJ8 @@ -109,26 +109,26 @@ pins: function: GNDA - pin: 37 - id: GPIOD_13 + id: D13 class: outputs ts_name: 37 - TACH function: Tach Out type: ls - pin: 38 - id: [GPIOF_9, ADC3_CHANNEL_7] + id: [F9, ADC3_CHANNEL_7] class: [switch_inputs, analog_inputs] ts_name: 48 - IN RES1 function: IN_RES1 - pin: 39 - id: [GPIOF_10] + id: [F10] class: [switch_inputs] ts_name: 39 - IN RES2 function: IN_RES2 - pin: 47a - id: GPIOG_4 + id: G4 class: outputs ts_name: 47 - CEL function: MIL Control @@ -148,19 +148,19 @@ pins: - pin: 54a # H144_IN_VSS - id: GPIOF_11 + id: F11 class: event_inputs ts_name: 54 - VSS function: VSS in - pin: 55a - id: GPIOE_12 + id: E12 ts_name: In D1 class: switch_inputs function: IN_D1 - pin: 57a - id: GPIOE_13 + id: E13 ts_name: In D2 class: switch_inputs function: IN_D2 @@ -174,7 +174,7 @@ pins: type: can - pin: 65a - id: GPIOH_14 + id: H14 class: outputs ts_name: 65 - Fuel Pump function: Fuel Pump Relay @@ -187,25 +187,25 @@ pins: function: LSU_CALIBR_RES - pin: 75a - id: GPIOE_14 + id: E14 ts_name: In D3 class: switch_inputs function: IN_D3 - pin: 76a - id: GPIOE_15 + id: E15 ts_name: In D4 class: switch_inputs function: IN_D4 - pin: 81a - id: GPIOD_15 + id: D15 class: outputs function: OUT_FUEL_CONSUMPTION - pin: 82a function: Crank Sensor - id: [GPIOB_1] + id: [B1] class: [event_inputs] ts_name: 82 - VR @@ -226,26 +226,26 @@ pins: function: IAT sensor - pin: 86a - id: [GPIOA_6, EFI_ADC_6] + id: [A6, EFI_ADC_6] class: [event_inputs, analog_inputs] ts_name: 86 - CAM1 function: Camshaft Sensor 1 - pin: 87a - id: [GPIOA_7, EFI_ADC_7] + id: [A7, EFI_ADC_7] class: [event_inputs, analog_inputs] ts_name: 87 - CAM2 function: Camshaft Sensor 2 - pin: 88a - id: GPIOD_10 + id: D10 class: outputs ts_name: 88 - INJ_4 function: Injector #4 type: inj - pin: 89a - id: GPIOG_8 + id: G8 class: outputs ts_name: 89 - INJ_2 function: Injector #2 @@ -270,26 +270,26 @@ pins: function: CLT sensor - pin: 94a - id: GPIOE_3 + id: E3 class: outputs ts_name: 94 - IGN_4 type: ign - pin: 95a - id: GPIOI_7 + id: I7 class: outputs ts_name: 95 - IGN_8 type: ign - pin: 96a - id: GPIOG_7 + id: G7 class: outputs ts_name: 96 - INJ_1 function: Injector #1 type: inj - pin: 97a - id: GPIOD_11 + id: D11 class: outputs ts_name: 97 - INJ_3 function: Injector #3 @@ -302,32 +302,32 @@ pins: function: GNDA - pin: 101a - id: [GPIOC_1, EFI_ADC_11] + id: [C1, EFI_ADC_11] class: [outputs, analog_inputs] ts_name: 101 - MAP2 function: Map2 - pin: 102a - id: GPIOI_8 + id: I8 class: outputs ts_name: 102 - IGN_1 function: Coil #1 type: ign - pin: 103a - id: GPIOE_2 + id: E2 class: outputs ts_name: 103 - IGN_5 type: ign - pin: 104a - id: GPIOA_9 + id: A9 class: outputs ts_name: 104 Wastegate function: OUT_WASTEGATE - pin: 105a - id: GPIOD_14 + id: D14 class: outputs ts_name: 105 - IDLE function: IAC @@ -346,51 +346,51 @@ pins: function: GNDA - pin: 110a - id: GPIOI_5 + id: I5 class: outputs ts_name: 110 - IGN_6 type: ign - pin: 111a - id: GPIOE_4 + id: E4 class: outputs ts_name: 111 - IGN_3 type: ign - pin: 112a - id: GPIOF_12 + id: F12 class: outputs ts_name: 112 INJ 6 function: INJ_6 type: inj - pin: 113a - id: GPIOD_9 + id: D9 class: outputs ts_name: 113 INJ 5 function: INJ_5 type: inj - pin: 115a - id: GPIOG_3 + id: G3 class: outputs ts_name: 115 - VVT1_2 function: OUT_VVT1_2 - pin: 117a - id: GPIOC_6 + id: C6 class: outputs ts_name: 117 ETB_OUT+ function: +ETB_OUT - pin: 118a - id: GPIOC_7 + id: C7 class: outputs ts_name: 118 ETB_OUT- function: -ETB_OUT - pin: 120a - id: GPIOC_8 + id: C8 class: outputs ts_name: 120 - VVT2 B2 function: OUT_VVT2_B2 diff --git a/firmware/config/boards/hellen/hellen121vag/knock_config.h b/firmware/config/boards/hellen/hellen121vag/knock_config.h index be15db88b1..a4e32de5ab 100644 --- a/firmware/config/boards/hellen/hellen121vag/knock_config.h +++ b/firmware/config/boards/hellen/hellen121vag/knock_config.h @@ -9,7 +9,7 @@ // knock 1 - pin PF7 #define KNOCK_ADC_CH1 ADC_CHANNEL_IN5 -#define KNOCK_PIN_CH1 GPIOF_7 +#define KNOCK_PIN_CH1 Gpio::F7 // Sample rate & time - depends on the exact MCU #define KNOCK_SAMPLE_TIME ADC_SAMPLE_84 diff --git a/firmware/config/boards/hellen/hellen128/board_configuration.cpp b/firmware/config/boards/hellen/hellen128/board_configuration.cpp index 48f988de38..144a3b0995 100644 --- a/firmware/config/boards/hellen/hellen128/board_configuration.cpp +++ b/firmware/config/boards/hellen/hellen128/board_configuration.cpp @@ -28,25 +28,25 @@ static void setInjectorPins() { // Disable remainder for (int i = 8; i < MAX_CYLINDER_COUNT;i++) { - engineConfiguration->injectionPins[i] = GPIO_UNASSIGNED; + engineConfiguration->injectionPins[i] = Gpio::Unassigned; } engineConfiguration->injectionPinMode = OM_DEFAULT; } static void setIgnitionPins() { - engineConfiguration->ignitionPins[0] = GPIOI_8; - engineConfiguration->ignitionPins[1] = GPIOE_5; - engineConfiguration->ignitionPins[2] = GPIOE_4; - engineConfiguration->ignitionPins[3] = GPIOE_3; - engineConfiguration->ignitionPins[4] = GPIOE_2; - engineConfiguration->ignitionPins[5] = GPIOI_5; - engineConfiguration->ignitionPins[6] = GPIOI_6; - engineConfiguration->ignitionPins[7] = GPIOI_7; + engineConfiguration->ignitionPins[0] = Gpio::I8; + engineConfiguration->ignitionPins[1] = Gpio::E5; + engineConfiguration->ignitionPins[2] = Gpio::E4; + engineConfiguration->ignitionPins[3] = Gpio::E3; + engineConfiguration->ignitionPins[4] = Gpio::E2; + engineConfiguration->ignitionPins[5] = Gpio::I5; + engineConfiguration->ignitionPins[6] = Gpio::I6; + engineConfiguration->ignitionPins[7] = Gpio::I7; // disable remainder for (int i = 8; i < MAX_CYLINDER_COUNT; i++) { - engineConfiguration->ignitionPins[i] = GPIO_UNASSIGNED; + engineConfiguration->ignitionPins[i] = Gpio::Unassigned; } engineConfiguration->ignitionPinMode = OM_DEFAULT; @@ -68,11 +68,11 @@ static void setupVbatt() { static void setupDefaultSensorInputs() { // trigger inputs - engineConfiguration->triggerInputPins[0] = GPIOB_1; - engineConfiguration->triggerInputPins[1] = GPIO_UNASSIGNED; - engineConfiguration->triggerInputPins[2] = GPIO_UNASSIGNED; + engineConfiguration->triggerInputPins[0] = Gpio::B1; + engineConfiguration->triggerInputPins[1] = Gpio::Unassigned; + engineConfiguration->triggerInputPins[2] = Gpio::Unassigned; // Direct hall-only cam input - engineConfiguration->camInputs[0] = GPIOA_6; + engineConfiguration->camInputs[0] = Gpio::A6; engineConfiguration->tps1_1AdcChannel = EFI_ADC_4; engineConfiguration->tps1_2AdcChannel = EFI_ADC_8; @@ -96,7 +96,7 @@ static void setHellen128ETBConfig() { uint8_t variant[2]={0xff,0xff}; //same pins as for LPS25 - m_i2c.init(GPIOB_10, GPIOB_11); + m_i2c.init(Gpio::B10, Gpio::B11); m_i2c.read(0x20, variant, sizeof(variant)); efiPrintf ("BoardID [%02x%02x] ", variant[0],variant[1] ); @@ -117,17 +117,17 @@ static void setHellen128ETBConfig() { // Disable pin engineConfiguration->etbIo[0].disablePin = H176_OUT_PWM1; // Unused - engineConfiguration->etbIo[0].directionPin2 = GPIO_UNASSIGNED; + engineConfiguration->etbIo[0].directionPin2 = Gpio::Unassigned; //ETB2 // PWM pin - engineConfiguration->etbIo[1].controlPin = GPIOI_2; + engineConfiguration->etbIo[1].controlPin = Gpio::I2; // DIR pin - engineConfiguration->etbIo[1].directionPin1 = GPIOH_13; + engineConfiguration->etbIo[1].directionPin1 = Gpio::H13; // Disable pin - engineConfiguration->etbIo[1].disablePin = GPIOB_7; + engineConfiguration->etbIo[1].disablePin = Gpio::B7; // Unused - engineConfiguration->etbIo[1].directionPin2 = GPIO_UNASSIGNED; + engineConfiguration->etbIo[1].directionPin2 = Gpio::Unassigned; // we only have pwm/dir, no dira/dirb engineConfiguration->etb_use_two_wires = false; @@ -179,10 +179,10 @@ void setBoardDefaultConfiguration() { engineConfiguration->enableSoftwareKnock = true; - engineConfiguration->fuelPumpPin = GPIOD_15; - engineConfiguration->idle.solenoidPin = GPIO_UNASSIGNED; - engineConfiguration->fanPin = GPIOD_12; // OUT_PWM8 - engineConfiguration->mainRelayPin = GPIO_UNASSIGNED; + engineConfiguration->fuelPumpPin = Gpio::D15; + engineConfiguration->idle.solenoidPin = Gpio::Unassigned; + engineConfiguration->fanPin = Gpio::D12; // OUT_PWM8 + engineConfiguration->mainRelayPin = Gpio::Unassigned; engineConfiguration->starterControlPin = H176_OUT_IO10; engineConfiguration->startStopButtonPin = H176_IN_A16; @@ -216,7 +216,7 @@ void setBoardDefaultConfiguration() { engineConfiguration->throttlePedalSecondaryWOTVoltage = 4.24; setHellenDefaultVrThresholds(); - engineConfiguration->vrThreshold[0].pin = GPIOD_14; + engineConfiguration->vrThreshold[0].pin = Gpio::D14; hellenWbo(); } diff --git a/firmware/config/boards/hellen/hellen128/connectors/main.yaml b/firmware/config/boards/hellen/hellen128/connectors/main.yaml index f13c028ae4..2cef858246 100644 --- a/firmware/config/boards/hellen/hellen128/connectors/main.yaml +++ b/firmware/config/boards/hellen/hellen128/connectors/main.yaml @@ -33,34 +33,34 @@ pins: #Outputs (via Test Points) - pin: P19 # LOW11 IO9 - id: GPIOI_1 + id: I1 class: outputs ts_name: P19_OUT_LOW11 type: ls - pin: P34 # LOW8 IO6 - id: GPIOH_15 + id: H15 class: outputs ts_name: P34_OUT_LOW8 - pin: P35 # LOW12 IO10 - id: GPIOI_0 + id: I0 class: outputs ts_name: P35_OUT_LOW9 type: ls - pin: P33 # SOLENOID_B2 PWM5 - id: GPIOC_9 + id: C9 class: outputs ts_name: P33_PWM5 type: ls - pin: P18 # OUT_PP2 OUT_IO12 - id: GPIOA_8 + id: A8 class: outputs ts_name: P18_OUT_PP2 type: ls @@ -88,7 +88,7 @@ pins: function: NC - pin: A6 - id: GPIOD_12 + id: D12 class: outputs ts_name: A6 - Fan Control function: low side control @@ -176,7 +176,7 @@ pins: function: NC - pin: C21 - id: GPIOH_14 + id: H14 class: outputs ts_name: C21 - Evap Purge Control function: low side solenoid control @@ -191,13 +191,13 @@ pins: type: gnd - pin: C24 - id: [GPIOA_3, EFI_ADC_3] + id: [A3, EFI_ADC_3] class: [event_inputs, analog_inputs] ts_name: C24 - PPS1 function: PPS1 analog input - pin: C25 - id: [GPIOC_4, EFI_ADC_14] + id: [C4, EFI_ADC_14] class: [event_inputs, analog_inputs] ts_name: C25 - PPS2 function: PPS2 analog input @@ -214,7 +214,7 @@ pins: function: NC - pin: C29 - id: GPIOD_15 + id: D15 class: outputs ts_name: C29 - Fuel Pump function: low side relay control @@ -251,7 +251,7 @@ pins: function: K-line/Lin - pin: C40 - id: [GPIOF_10] + id: [F10] class: [switch_inputs] ts_name: C40 - start button function: Start button @@ -329,28 +329,28 @@ pins: function: Test Point P14 - pin: E1 - id: GPIOG_7 + id: G7 class: outputs ts_name: E1 - LS1 function: Low-Side Switch 1 type: inj - pin: E2 - id: GPIOG_8 + id: G8 class: outputs ts_name: E2- LS2 function: Low-Side Switch 2 type: inj - pin: E3 - id: GPIOD_11 + id: D11 class: outputs ts_name: E3 - LS3 function: Low-Side Switch 3 type: inj - pin: E4 - id: GPIOD_10 + id: D10 class: outputs ts_name: E4 - LS4/VVT function: "Low-Side Switch 4/ VVT control" @@ -381,14 +381,14 @@ pins: function: Test Point P42 - pin: E13 - id: GPIOD_9 + id: D9 class: outputs ts_name: E13 - INJ 4 function: injector output 4 type: inj - pin: E14 - id: GPIOF_12 + id: F12 class: outputs ts_name: E14 - INJ 2 function: injector output 2 @@ -420,7 +420,7 @@ pins: type: 5v - pin: E23 - id: [GPIOC_1, EFI_ADC_11] + id: [C1, EFI_ADC_11] class: [event_inputs, analog_inputs] ts_name: E23 - MAP function: analog input MAP @@ -432,7 +432,7 @@ pins: - pin: E25 # H144_LS_7 - id: GPIOF_13 + id: F13 class: outputs ts_name: E25 - INJ 1 function: injector output 1 @@ -440,7 +440,7 @@ pins: - pin: E26 # H144_LS_8 - id: GPIOF_14 + id: F14 class: outputs ts_name: E26 - INJ 3 function: injector output 3 @@ -454,7 +454,7 @@ pins: type: gnd - pin: E29 - id: [GPIOC_2, EFI_ADC_12] + id: [C2, EFI_ADC_12] class: [event_inputs, analog_inputs] ts_name: E29 - Coolant Temp function: analog input CLT @@ -464,7 +464,7 @@ pins: function: NC - pin: E31 - id: [GPIOA_4, EFI_ADC_4] + id: [A4, EFI_ADC_4] class: [event_inputs, analog_inputs] ts_name: E31 - TPS1 function: analog input TPS1 @@ -479,7 +479,7 @@ pins: type: 5v - pin: E34 - id: [GPIOB_0, EFI_ADC_8] + id: [B0, EFI_ADC_8] class: [event_inputs, analog_inputs] ts_name: E34 - TPS2 function: analog input TPS2 @@ -492,7 +492,7 @@ pins: function: NC - pin: E37 - id: [GPIOB_1, EFI_ADC_9] + id: [B1, EFI_ADC_9] class: [event_inputs, analog_inputs] ts_name: E37 - Crank Input function: VR- @@ -507,7 +507,7 @@ pins: type: gnd - pin: E40 - id: [GPIOA_6, EFI_ADC_6] + id: [A6, EFI_ADC_6] class: [event_inputs, analog_inputs] ts_name: E40 - IN_CAM function: digital input CAM input (Hall) @@ -529,7 +529,7 @@ pins: function: knock2 sensor signal - pin: E45 - id: [GPIOC_3, EFI_ADC_13] + id: [C3, EFI_ADC_13] class: [event_inputs, analog_inputs] ts_name: E45 - IAT function: analog input IAT @@ -540,7 +540,7 @@ pins: type: 5v - pin: E47 - id: [GPIOC_0, EFI_ADC_10] + id: [C0, EFI_ADC_10] class: [event_inputs, analog_inputs] ts_name: E47 - MAF function: analog input @@ -562,7 +562,7 @@ pins: function: NC - pin: F4 - id: GPIOE_2 + id: E2 class: outputs ts_name: F4 - IGN 5 function: igniter @@ -575,7 +575,7 @@ pins: - pin: F6 # OUT_IGN3 Q5 # used as Coil#2 on M104 - id: GPIOE_4 + id: E4 class: outputs ts_name: F6 - IGN 3 function: igniter @@ -590,7 +590,7 @@ pins: type: gnd - pin: F9 - id: GPIOI_6 + id: I6 class: outputs ts_name: F9 - IGN 7 function: igniter @@ -601,7 +601,7 @@ pins: type: ign - pin: F11 - id: GPIOI_7 + id: I7 class: outputs ts_name: F11 - IGN 8 function: igniter @@ -615,7 +615,7 @@ pins: # OUT_IGN4 Q3 # CLK230 # used as Coil#1 on M104 https://github.com/rusefi/rusefi/wiki/1997-e320 - id: GPIOE_3 + id: E3 class: outputs ts_name: F13 - IGN 4 function: igniter @@ -630,14 +630,14 @@ pins: type: gnd - pin: F16 - id: GPIOE_5 + id: E5 class: outputs ts_name: F16 - IGN 2 function: igniter type: ign - pin: F17 - id: GPIOI_5 + id: I5 class: outputs ts_name: F17 - IGN 6 function: igniter @@ -655,7 +655,7 @@ pins: # OUT_IGN1 Q1 # CLK230 # Used as coil#3 on M104 - id: GPIOI_8 + id: I8 class: outputs ts_name: F20 - IGN 1 function: igniter diff --git a/firmware/config/boards/hellen/hellen154hyundai/board_configuration.cpp b/firmware/config/boards/hellen/hellen154hyundai/board_configuration.cpp index ce975a2830..4236c0059d 100644 --- a/firmware/config/boards/hellen/hellen154hyundai/board_configuration.cpp +++ b/firmware/config/boards/hellen/hellen154hyundai/board_configuration.cpp @@ -23,21 +23,21 @@ static void setInjectorPins() { // Disable remainder for (int i = 4; i < MAX_CYLINDER_COUNT;i++) { - engineConfiguration->injectionPins[i] = GPIO_UNASSIGNED; + engineConfiguration->injectionPins[i] = Gpio::Unassigned; } engineConfiguration->injectionPinMode = OM_DEFAULT; } static void setIgnitionPins() { - engineConfiguration->ignitionPins[0] = GPIOC_13; - engineConfiguration->ignitionPins[1] = GPIOE_5; - engineConfiguration->ignitionPins[2] = GPIOE_4; - engineConfiguration->ignitionPins[3] = GPIOE_3; + engineConfiguration->ignitionPins[0] = Gpio::C13; + engineConfiguration->ignitionPins[1] = Gpio::E5; + engineConfiguration->ignitionPins[2] = Gpio::E4; + engineConfiguration->ignitionPins[3] = Gpio::E3; // disable remainder for (int i = 4; i < MAX_CYLINDER_COUNT; i++) { - engineConfiguration->ignitionPins[i] = GPIO_UNASSIGNED; + engineConfiguration->ignitionPins[i] = Gpio::Unassigned; } engineConfiguration->ignitionPinMode = OM_DEFAULT; @@ -60,8 +60,8 @@ static void setupVbatt() { static void setupDefaultSensorInputs() { // trigger inputs engineConfiguration->triggerInputPins[0] = H144_IN_CRANK; - engineConfiguration->triggerInputPins[1] = GPIO_UNASSIGNED; - engineConfiguration->triggerInputPins[2] = GPIO_UNASSIGNED; + engineConfiguration->triggerInputPins[1] = Gpio::Unassigned; + engineConfiguration->triggerInputPins[2] = Gpio::Unassigned; // Direct hall-only cam input engineConfiguration->camInputs[0] = H144_IN_CAM; engineConfiguration->camInputs[1 * CAMS_PER_BANK] = H144_IN_D_AUX4; @@ -110,9 +110,9 @@ void setBoardConfigOverrides() { if (hellenBoardId == 0) { // first revision of did not have Hellen Board ID // https://github.com/rusefi/hellen154hyundai/issues/55 - engineConfiguration->etbIo[1].directionPin1 = GPIO_UNASSIGNED; - engineConfiguration->etbIo[1].directionPin2 = GPIO_UNASSIGNED; - engineConfiguration->etbIo[1].controlPin = GPIO_UNASSIGNED; + engineConfiguration->etbIo[1].directionPin1 = Gpio::Unassigned; + engineConfiguration->etbIo[1].directionPin2 = Gpio::Unassigned; + engineConfiguration->etbIo[1].controlPin = Gpio::Unassigned; if (isFirstInvocation) { isFirstInvocation = false; @@ -153,9 +153,9 @@ void setBoardDefaultConfiguration() { engineConfiguration->canRxPin = H176_CAN_RX; engineConfiguration->fuelPumpPin = H144_OUT_IO9; -// engineConfiguration->idle.solenoidPin = GPIOD_14; // OUT_PWM5 -// engineConfiguration->fanPin = GPIOD_12; // OUT_PWM8 - engineConfiguration->mainRelayPin = GPIOG_14; // pin: 111a, OUT_IO3 +// engineConfiguration->idle.solenoidPin = Gpio::D14; // OUT_PWM5 +// engineConfiguration->fanPin = Gpio::D12; // OUT_PWM8 + engineConfiguration->mainRelayPin = Gpio::G14; // pin: 111a, OUT_IO3 engineConfiguration->malfunctionIndicatorPin = H144_OUT_PWM8; engineConfiguration->brakePedalPin = H144_IN_RES3; diff --git a/firmware/config/boards/hellen/hellen154hyundai/connectors/main.yaml b/firmware/config/boards/hellen/hellen154hyundai/connectors/main.yaml index 00bea3575a..9e290c1d3d 100644 --- a/firmware/config/boards/hellen/hellen154hyundai/connectors/main.yaml +++ b/firmware/config/boards/hellen/hellen154hyundai/connectors/main.yaml @@ -3,19 +3,19 @@ pins: - pin: P66 # LOW3 IO1 - id: GPIOD_3 + id: D3 class: outputs ts_name: Aux P66 - pin: P67 # LOW4 IO2 - id: GPIOA_9 + id: A9 class: outputs ts_name: Aux P67 - pin: P68 # LOW6 IO4 - id: GPIOG_5 + id: G5 class: outputs ts_name: Aux P68 @@ -66,7 +66,7 @@ pins: - pin: K15 # cam2 IN_AUX4 - id: [GPIOA_7] + id: [A7] function: Cam Sensor class: [event_inputs] ts_name: Cam - K15 @@ -78,7 +78,7 @@ pins: - pin: K17 function: Crank Sensor # IN_CRANK AIN24 A24 - id: [GPIOB_1] + id: [B1] class: [event_inputs] ts_name: Crank - K17 @@ -93,28 +93,28 @@ pins: ts_name: BK2 Wastegate Position - 22 - pin: K25 - id: GPIOG_7 + id: G7 class: outputs ts_name: INJ_1 k25 function: Injector 1 type: inj - pin: K26 - id: GPIOG_8 + id: G8 class: outputs ts_name: INJ_2 k26 function: Injector 2 type: inj - pin: K27 - id: GPIOD_11 + id: D11 class: outputs ts_name: INJ_3 k27 function: Injector 3 type: inj - pin: K28 - id: GPIOD_10 + id: D10 class: outputs ts_name: INJ_4 k28 function: Injector 4 @@ -167,7 +167,7 @@ pins: - pin: K40 # H144_IN_VSS - id: GPIOF_11 + id: F11 class: event_inputs ts_name: K40 VSS function: Vehicle Speed Sensor @@ -181,7 +181,7 @@ pins: - pin: K47 # H144_LS_7 - id: GPIOF_13 + id: F13 class: outputs ts_name: K48 BK1 Wastegate Solenoid function: BK1 Wastegate Solenoid @@ -215,7 +215,7 @@ pins: - pin: K62 # cam1 IN_CAM - id: [GPIOA_6] + id: [A6] function: Cam Sensor class: [event_inputs] ts_name: Cam - K62 @@ -226,7 +226,7 @@ pins: - pin: K64 # H144_OUT_IO3 - id: GPIOG_14 + id: G14 class: outputs ts_name: Main Relay K64 function: Main relay control @@ -234,21 +234,21 @@ pins: - pin: K65 # H144_OUT_IO7 - id: GPIOG_3 + id: G3 class: outputs ts_name: Fan Relay Low function: Fan relay low - pin: K65 # H144_LS_5 - id: GPIOD_9 + id: D9 class: outputs ts_name: VVT1 function: VVT1 - pin: K68 # H144_LS_6 - id: GPIOF_12 + id: F12 class: outputs ts_name: VVT2 function: VVT2 @@ -256,7 +256,7 @@ pins: - pin: K70 # H144_OUT_IO9 - id: GPIOG_13 + id: G13 class: outputs ts_name: Fuel Pump K70 function: Fuel Pump Relay @@ -299,14 +299,14 @@ pins: - pin: K86 # H144_OUT_PWM7 - id: GPIOD_15 + id: D15 class: outputs ts_name: Tacho function: Tachometer - pin: K87 # H144_OUT_IO10 - id: GPIOG_12 + id: G12 class: outputs ts_name: K87 AC Relay function: A/C Relay @@ -314,20 +314,20 @@ pins: - pin: K88 # H144_OUT_IO8 - id: GPIOG_4 + id: G4 class: outputs ts_name: Fan Relay HI function: Fan relay high - pin: K92 # H144_OUT_PWM8 - id: GPIOD_12 + id: D12 class: outputs ts_name: MIL function: Check Engine Light - pin: A1 - id: GPIOE_3 + id: E3 class: outputs ts_name: Coil 4 function: Coil 4 @@ -340,7 +340,7 @@ pins: function: Ground - pin: A16 - id: GPIOE_5 + id: E5 class: outputs ts_name: Coil 2 function: Coil 2 @@ -348,14 +348,14 @@ pins: - pin: A29 # H144_IN_RES3 - id: GPIOF_8 + id: F8 class: switch_inputs ts_name: A29 Brake Input function: Brake Switch - pin: A31 - id: GPIOC_13 + id: C13 class: outputs ts_name: Coil 1 function: Coil 1 @@ -363,7 +363,7 @@ pins: - pin: A43 # H144_IN_RES2 - id: GPIOF_10 + id: F10 class: switch_inputs ts_name: A43 Clutch Input function: Clutch Input @@ -372,7 +372,7 @@ pins: function: BK2 DC Wastegate Pos - pin: A46 - id: GPIOE_4 + id: E4 class: outputs ts_name: Coil 3 function: Coil 3 @@ -380,7 +380,7 @@ pins: - pin: A57 # H144_IN_RES1 - id: GPIOF_9 + id: F9 class: switch_inputs ts_name: A57 AC Request function: AC Request Switch diff --git a/firmware/config/boards/hellen/hellen154hyundai/knock_config.h b/firmware/config/boards/hellen/hellen154hyundai/knock_config.h index be15db88b1..a4e32de5ab 100644 --- a/firmware/config/boards/hellen/hellen154hyundai/knock_config.h +++ b/firmware/config/boards/hellen/hellen154hyundai/knock_config.h @@ -9,7 +9,7 @@ // knock 1 - pin PF7 #define KNOCK_ADC_CH1 ADC_CHANNEL_IN5 -#define KNOCK_PIN_CH1 GPIOF_7 +#define KNOCK_PIN_CH1 Gpio::F7 // Sample rate & time - depends on the exact MCU #define KNOCK_SAMPLE_TIME ADC_SAMPLE_84 diff --git a/firmware/config/boards/hellen/hellen64_miataNA6_94/board.h b/firmware/config/boards/hellen/hellen64_miataNA6_94/board.h index ccaadd4c34..3b9d60b520 100644 --- a/firmware/config/boards/hellen/hellen64_miataNA6_94/board.h +++ b/firmware/config/boards/hellen/hellen64_miataNA6_94/board.h @@ -33,8 +33,8 @@ #define BOARD_NAME "HellenNA6" #define EFI_USB_AF 10U -#define EFI_USB_SERIAL_DM GPIOA_11 -#define EFI_USB_SERIAL_DP GPIOA_12 +#define EFI_USB_SERIAL_DM Gpio::A11 +#define EFI_USB_SERIAL_DP Gpio::A12 // Ignore USB VBUS pin (we're never a host, only a device) #define BOARD_OTG_NOVBUSSENS TRUE diff --git a/firmware/config/boards/hellen/hellen64_miataNA6_94/board_configuration.cpp b/firmware/config/boards/hellen/hellen64_miataNA6_94/board_configuration.cpp index 5aa9c477f9..b1d5b149b4 100644 --- a/firmware/config/boards/hellen/hellen64_miataNA6_94/board_configuration.cpp +++ b/firmware/config/boards/hellen/hellen64_miataNA6_94/board_configuration.cpp @@ -16,37 +16,37 @@ static void setInjectorPins() { engineConfiguration->injectionPins[0] = H176_LS_1; - engineConfiguration->injectionPins[1] = GPIOG_8; - engineConfiguration->injectionPins[2] = GPIOD_11; - engineConfiguration->injectionPins[3] = GPIOD_10; + engineConfiguration->injectionPins[1] = Gpio::G8; + engineConfiguration->injectionPins[2] = Gpio::D11; + engineConfiguration->injectionPins[3] = Gpio::D10; // Disable remainder for (int i = 4; i < MAX_CYLINDER_COUNT;i++) { - engineConfiguration->injectionPins[i] = GPIO_UNASSIGNED; + engineConfiguration->injectionPins[i] = Gpio::Unassigned; } engineConfiguration->injectionPinMode = OM_DEFAULT; - engineConfiguration->clutchDownPin = GPIOC_4; // Clutch switch input + engineConfiguration->clutchDownPin = Gpio::C4; // Clutch switch input engineConfiguration->clutchDownPinMode = PI_PULLDOWN; engineConfiguration->launchActivationMode = CLUTCH_INPUT_LAUNCH; - engineConfiguration->malfunctionIndicatorPin = GPIOG_4; //1E - Check Engine Light + engineConfiguration->malfunctionIndicatorPin = Gpio::G4; //1E - Check Engine Light } static void setIgnitionPins() { - engineConfiguration->ignitionPins[0] = GPIOI_8; // 3F - IGN_1 (1&4) - engineConfiguration->ignitionPins[1] = GPIO_UNASSIGNED ; // GPIOE_4 - engineConfiguration->ignitionPins[2] = GPIOE_5; // 3I - IGN_2 (2&3) - engineConfiguration->ignitionPins[3] = GPIO_UNASSIGNED; // GPIOE_3 + engineConfiguration->ignitionPins[0] = Gpio::I8; // 3F - IGN_1 (1&4) + engineConfiguration->ignitionPins[1] = Gpio::Unassigned ; // Gpio::E4 + engineConfiguration->ignitionPins[2] = Gpio::E5; // 3I - IGN_2 (2&3) + engineConfiguration->ignitionPins[3] = Gpio::Unassigned; // Gpio::E3 - //engineConfiguration->ignitionPins[4] = GPIOE_2; - //engineConfiguration->ignitionPins[5] = GPIOI_5; - //engineConfiguration->ignitionPins[6] = GPIOI_6; - //engineConfiguration->ignitionPins[7] = GPIOI_7; + //engineConfiguration->ignitionPins[4] = Gpio::E2; + //engineConfiguration->ignitionPins[5] = Gpio::I5; + //engineConfiguration->ignitionPins[6] = Gpio::I6; + //engineConfiguration->ignitionPins[7] = Gpio::I7; // disable remainder for (int i = 4; i < MAX_CYLINDER_COUNT; i++) { - engineConfiguration->ignitionPins[i] = GPIO_UNASSIGNED; + engineConfiguration->ignitionPins[i] = Gpio::Unassigned; } engineConfiguration->ignitionPinMode = OM_DEFAULT; @@ -68,10 +68,10 @@ static void setupVbatt() { static void setupDefaultSensorInputs() { // trigger inputs, hall - engineConfiguration->triggerInputPins[0] = GPIOA_6; - engineConfiguration->triggerInputPins[1] = GPIOB_1; - engineConfiguration->triggerInputPins[2] = GPIO_UNASSIGNED; - engineConfiguration->camInputs[0] = GPIO_UNASSIGNED; + engineConfiguration->triggerInputPins[0] = Gpio::A6; + engineConfiguration->triggerInputPins[1] = Gpio::B1; + engineConfiguration->triggerInputPins[2] = Gpio::Unassigned; + engineConfiguration->camInputs[0] = Gpio::Unassigned; engineConfiguration->tps1_1AdcChannel = EFI_ADC_4; engineConfiguration->tps2_1AdcChannel = EFI_ADC_NONE; @@ -126,13 +126,13 @@ void setBoardDefaultConfiguration() { engineConfiguration->enableSoftwareKnock = true; // these stm32 pins do not match hellen_meta, is that because hellenNA6 is not using latest MCU version? - engineConfiguration->acRelayPin = GPIOH_15; // 1J - AC Relay - engineConfiguration->fuelPumpPin = GPIOG_2; // OUT_IO9 - engineConfiguration->idle.solenoidPin = GPIOD_14; // OUT_PWM5 - engineConfiguration->fanPin = GPIOD_12; // OUT_PWM8 - engineConfiguration->mainRelayPin = GPIOI_2; // OUT_LOW3 - engineConfiguration->tachOutputPin = GPIOI_0; - engineConfiguration->malfunctionIndicatorPin = GPIOG_9; + engineConfiguration->acRelayPin = Gpio::H15; // 1J - AC Relay + engineConfiguration->fuelPumpPin = Gpio::G2; // OUT_IO9 + engineConfiguration->idle.solenoidPin = Gpio::D14; // OUT_PWM5 + engineConfiguration->fanPin = Gpio::D12; // OUT_PWM8 + engineConfiguration->mainRelayPin = Gpio::I2; // OUT_LOW3 + engineConfiguration->tachOutputPin = Gpio::I0; + engineConfiguration->malfunctionIndicatorPin = Gpio::G9; engineConfiguration->vehicleSpeedSensorInputPin = H144_IN_VSS; @@ -154,14 +154,14 @@ void setBoardDefaultConfiguration() { void setSdCardConfigurationOverrides() { engineConfiguration->sdCardSpiDevice = SPI_DEVICE_3; - engineConfiguration->spi3mosiPin = GPIOC_12; - engineConfiguration->spi3misoPin = GPIOC_11; - engineConfiguration->spi3sckPin = GPIOC_10; - engineConfiguration->sdCardCsPin = GPIOA_15; + engineConfiguration->spi3mosiPin = Gpio::C12; + engineConfiguration->spi3misoPin = Gpio::C11; + engineConfiguration->spi3sckPin = Gpio::C10; + engineConfiguration->sdCardCsPin = Gpio::A15; -// engineConfiguration->spi2mosiPin = GPIOB_15; -// engineConfiguration->spi2misoPin = GPIOB_14; -// engineConfiguration->spi2sckPin = GPIOB_13; -// engineConfiguration->sdCardCsPin = GPIOB_12; +// engineConfiguration->spi2mosiPin = Gpio::B15; +// engineConfiguration->spi2misoPin = Gpio::B14; +// engineConfiguration->spi2sckPin = Gpio::B13; +// engineConfiguration->sdCardCsPin = Gpio::B12; engineConfiguration->is_enabled_spi_3 = true; } diff --git a/firmware/config/boards/hellen/hellen64_miataNA6_94/connectors/main.yaml b/firmware/config/boards/hellen/hellen64_miataNA6_94/connectors/main.yaml index c07d5067c0..4440bd8fed 100644 --- a/firmware/config/boards/hellen/hellen64_miataNA6_94/connectors/main.yaml +++ b/firmware/config/boards/hellen/hellen64_miataNA6_94/connectors/main.yaml @@ -24,20 +24,20 @@ pins: type: can - pin: 1E - id: GPIOG_9 + id: G9 class: outputs ts_name: 1E - Check Engine Light function: Check Engine Light type: ls - pin: 1G - id: GPIOI_8 + id: I8 class: outputs ts_name: 1G - Ignition 1 & 4 type: ign - pin: 1H - id: GPIOE_5 + id: E5 class: outputs ts_name: 1H - Ignition 2 & 3 type: ign @@ -47,14 +47,14 @@ pins: type: gnd - pin: 1J - id: GPIOH_15 + id: H15 class: outputs ts_name: 1J - AC Relay function: A/C Relay type: ls - pin: 1L - id: GPIOD_12 + id: D12 class: outputs ts_name: Radiator Fan function: Radiator Fan Relay @@ -62,7 +62,7 @@ pins: - pin: 1M # H144_IN_VSS - id: GPIOF_11 + id: F11 class: event_inputs ts_name: 1M - VSS function: VSS IN @@ -72,7 +72,7 @@ pins: function: Sensor +5V - pin: 1Q - id: [GPIOC_5, EFI_ADC_15] + id: [C5, EFI_ADC_15] class: [switch_inputs, analog_inputs] ts_name: 1Q AC Switch function: A/C switch input @@ -90,7 +90,7 @@ pins: function: EGR Solenoid - pin: 1V - id: [GPIOC_4, EFI_ADC_14] + id: [C4, EFI_ADC_14] class: [switch_inputs, analog_inputs] ts_name: 1V - Clutch Switch function: Clutch switch input @@ -121,14 +121,14 @@ pins: function: WBO Vs - pin: 2I - id: GPIOF_14 + id: F14 class: outputs ts_name: 2I - VVT function: VVT Output type: ls - pin: 2J - id: GPIOF_12 + id: F12 class: outputs ts_name: 2J - Boost Control function: Boost Control Solenoid @@ -137,19 +137,19 @@ pins: function: GND - pin: 2L - id: GPIOF_3 + id: F3 class: event_inputs ts_name: 2L - Flex Fuel function: Flex Fuel Input - pin: 2M - id: [GPIOC_1, EFI_ADC_11] + id: [C1, EFI_ADC_11] class: [switch_inputs, analog_inputs] ts_name: 2M - Pressure Sensor function: pressure input - pin: 2N - id: [GPIOA_1, EFI_ADC_1] + id: [A1, EFI_ADC_1] class: [switch_inputs, analog_inputs] ts_name: 2N - Temperature Sensor function: temp input @@ -181,7 +181,7 @@ pins: color: white - pin: 3E - id: GPIOB_1 + id: B1 class: event_inputs ts_name: 3E - CRANK function: Crankshaft Sensor @@ -192,13 +192,13 @@ pins: color: white - pin: 3G - id: GPIOA_6 + id: A6 class: event_inputs ts_name: 3G - CAM function: Camshaft Sensor - pin: 3I - id: GPIOI_0 + id: I0 class: outputs ts_name: Tachometer function: tachometer @@ -230,13 +230,13 @@ pins: function: IAT sensor - pin: 3S - id: GPIOD_9 + id: D9 class: outputs ts_name: 3S - A/C Fan 94-95 function: A/C Fan - pin: 3T - id: GPIOG_2 + id: G2 class: outputs ts_name: Fuel Pump Relay function: Fuel Pump Relay @@ -255,35 +255,35 @@ pins: function: CLT sensor - pin: 3U - id: GPIOG_7 + id: G7 class: outputs ts_name: 3U - Injector 1 function: Injector #1 type: inj - pin: 3V - id: GPIOG_8 + id: G8 class: outputs ts_name: 3V - Injector 2 function: Injector #2 type: inj - pin: 3W - id: GPIOD_14 + id: D14 class: outputs ts_name: 3W - IDLE function: IAC idle type: ls - pin: 3Y - id: GPIOD_11 + id: D11 class: outputs ts_name: 3Y - Injector 3 function: Injector #3 type: inj - pin: 3Z - id: GPIOD_10 + id: D10 class: outputs ts_name: 3Z - Injector 4 function: Injector #4 diff --git a/firmware/config/boards/hellen/hellen64_miataNA6_94/knock_config.h b/firmware/config/boards/hellen/hellen64_miataNA6_94/knock_config.h index be15db88b1..a4e32de5ab 100644 --- a/firmware/config/boards/hellen/hellen64_miataNA6_94/knock_config.h +++ b/firmware/config/boards/hellen/hellen64_miataNA6_94/knock_config.h @@ -9,7 +9,7 @@ // knock 1 - pin PF7 #define KNOCK_ADC_CH1 ADC_CHANNEL_IN5 -#define KNOCK_PIN_CH1 GPIOF_7 +#define KNOCK_PIN_CH1 Gpio::F7 // Sample rate & time - depends on the exact MCU #define KNOCK_SAMPLE_TIME ADC_SAMPLE_84 diff --git a/firmware/config/boards/hellen/hellen72/board.h b/firmware/config/boards/hellen/hellen72/board.h index 6a21638774..b2173c0025 100644 --- a/firmware/config/boards/hellen/hellen72/board.h +++ b/firmware/config/boards/hellen/hellen72/board.h @@ -33,8 +33,8 @@ #define BOARD_NAME "Hellen72" #define EFI_USB_AF 10U -#define EFI_USB_SERIAL_DM GPIOA_11 -#define EFI_USB_SERIAL_DP GPIOA_12 +#define EFI_USB_SERIAL_DM Gpio::A11 +#define EFI_USB_SERIAL_DP Gpio::A12 // Ignore USB VBUS pin (we're never a host, only a device) #define BOARD_OTG_NOVBUSSENS TRUE diff --git a/firmware/config/boards/hellen/hellen72/board_configuration.cpp b/firmware/config/boards/hellen/hellen72/board_configuration.cpp index 2dceb05be0..279b5f512e 100644 --- a/firmware/config/boards/hellen/hellen72/board_configuration.cpp +++ b/firmware/config/boards/hellen/hellen72/board_configuration.cpp @@ -15,38 +15,38 @@ #include "hellen_meta.h" static void setInjectorPins() { - engineConfiguration->injectionPins[0] = GPIOG_7; - engineConfiguration->injectionPins[1] = GPIOG_8; - engineConfiguration->injectionPins[2] = GPIOD_11; - engineConfiguration->injectionPins[3] = GPIOD_10; + engineConfiguration->injectionPins[0] = Gpio::G7; + engineConfiguration->injectionPins[1] = Gpio::G8; + engineConfiguration->injectionPins[2] = Gpio::D11; + engineConfiguration->injectionPins[3] = Gpio::D10; - //engineConfiguration->injectionPins[4] = GPIOD_9; - //engineConfiguration->injectionPins[5] = GPIOF_12; - //engineConfiguration->injectionPins[6] = GPIOF_13; - //engineConfiguration->injectionPins[7] = GPIOF_14; + //engineConfiguration->injectionPins[4] = Gpio::D9; + //engineConfiguration->injectionPins[5] = Gpio::F12; + //engineConfiguration->injectionPins[6] = Gpio::F13; + //engineConfiguration->injectionPins[7] = Gpio::F14; // Disable remainder for (int i = 4; i < MAX_CYLINDER_COUNT;i++) { - engineConfiguration->injectionPins[i] = GPIO_UNASSIGNED; + engineConfiguration->injectionPins[i] = Gpio::Unassigned; } engineConfiguration->injectionPinMode = OM_DEFAULT; } static void setIgnitionPins() { - engineConfiguration->ignitionPins[0] = GPIOI_8; // 3F - IGN_1 (1&4) - engineConfiguration->ignitionPins[1] = GPIO_UNASSIGNED ; // GPIOE_4 - engineConfiguration->ignitionPins[2] = GPIOE_5; // 3I - IGN_2 (2&3) - engineConfiguration->ignitionPins[3] = GPIO_UNASSIGNED; // GPIOE_3 + engineConfiguration->ignitionPins[0] = Gpio::I8; // 3F - IGN_1 (1&4) + engineConfiguration->ignitionPins[1] = Gpio::Unassigned ; // Gpio::E4 + engineConfiguration->ignitionPins[2] = Gpio::E5; // 3I - IGN_2 (2&3) + engineConfiguration->ignitionPins[3] = Gpio::Unassigned; // Gpio::E3 - //engineConfiguration->ignitionPins[4] = GPIOE_2; - //engineConfiguration->ignitionPins[5] = GPIOI_5; - //engineConfiguration->ignitionPins[6] = GPIOI_6; - //engineConfiguration->ignitionPins[7] = GPIOI_7; + //engineConfiguration->ignitionPins[4] = Gpio::E2; + //engineConfiguration->ignitionPins[5] = Gpio::I5; + //engineConfiguration->ignitionPins[6] = Gpio::I6; + //engineConfiguration->ignitionPins[7] = Gpio::I7; // disable remainder for (int i = 4; i < MAX_CYLINDER_COUNT; i++) { - engineConfiguration->ignitionPins[i] = GPIO_UNASSIGNED; + engineConfiguration->ignitionPins[i] = Gpio::Unassigned; } engineConfiguration->ignitionPinMode = OM_DEFAULT; @@ -68,11 +68,11 @@ static void setupVbatt() { static void setupDefaultSensorInputs() { // trigger inputs - engineConfiguration->triggerInputPins[0] = GPIOB_1; - engineConfiguration->triggerInputPins[1] = GPIO_UNASSIGNED; - engineConfiguration->triggerInputPins[2] = GPIO_UNASSIGNED; + engineConfiguration->triggerInputPins[0] = Gpio::B1; + engineConfiguration->triggerInputPins[1] = Gpio::Unassigned; + engineConfiguration->triggerInputPins[2] = Gpio::Unassigned; // Direct hall-only cam input - engineConfiguration->camInputs[0] = GPIOA_6; + engineConfiguration->camInputs[0] = Gpio::A6; engineConfiguration->tps1_1AdcChannel = EFI_ADC_4; engineConfiguration->tps2_1AdcChannel = EFI_ADC_NONE; @@ -98,8 +98,8 @@ void setBoardConfigOverrides() { engineConfiguration->clt.config.bias_resistor = 4700; engineConfiguration->iat.config.bias_resistor = 4700; - engineConfiguration->canTxPin = GPIOD_1; - engineConfiguration->canRxPin = GPIOD_0; + engineConfiguration->canTxPin = Gpio::D1; + engineConfiguration->canRxPin = Gpio::D0; } void setSerialConfigurationOverrides() { @@ -126,24 +126,24 @@ void setBoardDefaultConfiguration() { engineConfiguration->enableSoftwareKnock = true; - engineConfiguration->acRelayPin = GPIOH_15; - engineConfiguration->acSwitch = GPIOB_0; + engineConfiguration->acRelayPin = Gpio::H15; + engineConfiguration->acSwitch = Gpio::B0; engineConfiguration->acSwitchMode = PI_PULLUP; engineConfiguration->vehicleSpeedSensorInputPin = H144_IN_VSS; engineConfiguration->clutchDownPin = H144_IN_RES3; engineConfiguration->clutchDownPinInverted = true; - engineConfiguration->fuelPumpPin = GPIOG_2; // OUT_IO9 - engineConfiguration->idle.solenoidPin = GPIOD_14; // OUT_PWM5 - engineConfiguration->fanPin = GPIOD_12; // OUT_PWM8 - engineConfiguration->fan2Pin = GPIOD_9; + engineConfiguration->fuelPumpPin = Gpio::G2; // OUT_IO9 + engineConfiguration->idle.solenoidPin = Gpio::D14; // OUT_PWM5 + engineConfiguration->fanPin = Gpio::D12; // OUT_PWM8 + engineConfiguration->fan2Pin = Gpio::D9; engineConfiguration->enableFan2WithAc = true; - engineConfiguration->mainRelayPin = GPIOI_2; // OUT_LOW3 - engineConfiguration->vvtPins[0] = GPIOI_0; // 4R - VVT (O5) + engineConfiguration->mainRelayPin = Gpio::I2; // OUT_LOW3 + engineConfiguration->vvtPins[0] = Gpio::I0; // 4R - VVT (O5) - engineConfiguration->tachOutputPin = GPIOD_13; // 3O - TACH (PWM7) - engineConfiguration->alternatorControlPin = GPIOD_15; // 3M - ALTERN (PWM6) + engineConfiguration->tachOutputPin = Gpio::D13; // 3O - TACH (PWM7) + engineConfiguration->alternatorControlPin = Gpio::D15; // 3M - ALTERN (PWM6) // "required" hardware is done - set some reasonable defaults @@ -166,14 +166,14 @@ void setBoardDefaultConfiguration() { void setSdCardConfigurationOverrides() { engineConfiguration->sdCardSpiDevice = SPI_DEVICE_3; - engineConfiguration->spi3mosiPin = GPIOC_12; - engineConfiguration->spi3misoPin = GPIOC_11; - engineConfiguration->spi3sckPin = GPIOC_10; - engineConfiguration->sdCardCsPin = GPIOA_15; + engineConfiguration->spi3mosiPin = Gpio::C12; + engineConfiguration->spi3misoPin = Gpio::C11; + engineConfiguration->spi3sckPin = Gpio::C10; + engineConfiguration->sdCardCsPin = Gpio::A15; -// engineConfiguration->spi2mosiPin = GPIOB_15; -// engineConfiguration->spi2misoPin = GPIOB_14; -// engineConfiguration->spi2sckPin = GPIOB_13; -// engineConfiguration->sdCardCsPin = GPIOB_12; +// engineConfiguration->spi2mosiPin = Gpio::B15; +// engineConfiguration->spi2misoPin = Gpio::B14; +// engineConfiguration->spi2sckPin = Gpio::B13; +// engineConfiguration->sdCardCsPin = Gpio::B12; engineConfiguration->is_enabled_spi_3 = true; } diff --git a/firmware/config/boards/hellen/hellen72/connectors/main.yaml b/firmware/config/boards/hellen/hellen72/connectors/main.yaml index 8e6a7cc5be..27fe1b35c3 100644 --- a/firmware/config/boards/hellen/hellen72/connectors/main.yaml +++ b/firmware/config/boards/hellen/hellen72/connectors/main.yaml @@ -6,7 +6,7 @@ pins: - pin: 2A # INJ1 Q312 - id: GPIOG_7 + id: G7 class: outputs ts_name: 2A - INJ_1 function: Injector #1 @@ -14,7 +14,7 @@ pins: color: orange Y1 - pin: 2B - id: GPIOD_12 + id: D12 class: outputs ts_name: 2B - ECF (PWM8) function: Engine Radiator Fan @@ -22,7 +22,7 @@ pins: type: ls - pin: 2C - id: GPIOD_9 + id: D9 class: outputs ts_name: 2C - AC Fan / INJ_5 function: AC Radiator fan @@ -30,7 +30,7 @@ pins: - pin: 2D #INJ2 Q305 - id: GPIOG_8 + id: G8 class: outputs ts_name: 2D - INJ_2 function: Injector #2 @@ -38,14 +38,14 @@ pins: color: blue Y1 - pin: 2E - id: GPIOC_7 + id: C7 class: outputs ts_name: 2E - COIL_A2 (PWM2) function: EGR Valve #1 Coil type: ls - pin: 2F - id: GPIOC_6 + id: C6 class: outputs ts_name: 2E - COIL_A1 (PWM1) function: EGR Valve #2 Coil @@ -53,7 +53,7 @@ pins: - pin: 2G #INJ3 Q309 - id: GPIOD_11 + id: D11 class: outputs ts_name: 2G - INJ_3 function: Injector #3 @@ -61,14 +61,14 @@ pins: color: white Y1 - pin: 2H - id: GPIOC_9 + id: C9 class: outputs ts_name: 2H - COIL_B2 (PWM4) function: EGR Valve #3 Coil type: ls - pin: 2I - id: GPIOC_8 + id: C8 class: outputs ts_name: 2I - COIL_B1 (PWM3) function: EGR Valve #4 Coil @@ -76,7 +76,7 @@ pins: - pin: 2J #INJ4 Q310 - id: GPIOD_10 + id: D10 class: outputs ts_name: 2J - INJ_4 function: Injector #4 @@ -84,14 +84,14 @@ pins: color: green Y1 - pin: 2K - id: GPIOH_15 + id: H15 class: outputs ts_name: 2K - AC (O4) function: A/C Relay type: ls - pin: 2M - id: GPIOG_2 + id: G2 class: outputs ts_name: 2M - FPUMP (O9) function: Fuel Pump Relay @@ -99,14 +99,14 @@ pins: color: red B4 - pin: 2N - id: GPIOF_12 + id: F12 class: outputs ts_name: 2N - VTSC / INJ_6 function: VTCS Control type: inj - pin: 2O - id: GPIOE_4 + id: E4 class: outputs ts_name: 2O - IGN_3 type: ign @@ -116,7 +116,7 @@ pins: color: red, short wire - pin: 2Q - id: GPIOD_14 + id: D14 class: outputs ts_name: 2Q - IDLE (PWM5) function: IAC (negative) idle, with diode @@ -124,7 +124,7 @@ pins: color: blue B4 - pin: 2R - id: GPIOG_4 + id: G4 class: outputs ts_name: 2R - CE (O11) function: MIL Control @@ -142,28 +142,28 @@ pins: color: black W4, sliced for MAP - pin: 3C - id: GPIOF_13 + id: F13 class: outputs ts_name: 3C - Purge Solenoid / INJ_7 function: Purge Control Solenoid type: inj - pin: 3D - id: GPIOF_14 + id: F14 class: outputs ts_name: 3D - EGR Solenoid / INJ_8 function: EGR Boost sens. sol. type: inj - pin: 3E - id: GPIOG_3 + id: G3 class: outputs ts_name: 3E - CANIST (O10) function: CDCV (EVAP canister purge valve) Control type: ls - pin: 3F - id: GPIOI_8 + id: I8 class: outputs ts_name: 3F - IGN_1 (1&4) function: Coil #1 @@ -171,7 +171,7 @@ pins: color: white B4 - pin: 3H - id: GPIOI_2 + id: I2 class: outputs ts_name: 3H - MAIN (O1) function: Main relay control @@ -179,7 +179,7 @@ pins: color: white or red, R5 - pin: 3I - id: GPIOE_5 + id: E5 class: outputs ts_name: 3I - IGN_2 (2&3) function: Coil #2 @@ -187,7 +187,7 @@ pins: color: orange B4 - pin: 3J - id: GPIOH_14 + id: H14 class: outputs ts_name: 3J - O2H (O3) function: Front O2 sens. heater GND @@ -197,13 +197,13 @@ pins: function: NC - pin: 3L - id: [GPIOI_6, EFI_ADC_1] + id: [I6, EFI_ADC_1] class: [outputs, analog_inputs] ts_name: 3L - IGN_7 / AFR type: ign - pin: 3M - id: GPIOD_15 + id: D15 class: outputs ts_name: 3M - ALTERN (PWM6) function: PWM signal to control alternator field voltage @@ -211,13 +211,13 @@ pins: color: orange R5 - pin: 3N - id: GPIOE_3 + id: E3 class: outputs ts_name: 3N - IGN_4 type: ign - pin: 3O - id: GPIOD_13 + id: D13 class: outputs ts_name: 3O - TACH (PWM7) function: Tach Out @@ -225,7 +225,7 @@ pins: color: green B4 - pin: 3P - id: GPIOA_9 + id: A9 class: outputs ts_name: 3P - O2H2 (O7) function: Rear O2 sensor heater @@ -239,21 +239,21 @@ pins: - pin: 3T # H144_IN_VSS - id: GPIOF_11 + id: F11 class: event_inputs ts_name: 3T - VSS (D5) function: VSS in color: blue W3 - pin: 3U - id: GPIOH_13 + id: H13 class: outputs ts_name: 3U - AWARN (O2) function: Alternator Warning Light type: ls - pin: 3V - id: [GPIOA_6, EFI_ADC_6] + id: [A6, EFI_ADC_6] class: [event_inputs, analog_inputs] ts_name: 3V - CAM (A19) function: Camshaft Sensor @@ -266,14 +266,14 @@ pins: function: NC - pin: 3Y - id: [GPIOB_1, EFI_ADC_9] + id: [B1, EFI_ADC_9] class: [event_inputs, analog_inputs] ts_name: 3Y - CRANK (A24) function: Crankshaft Sensor color: white W3 - pin: 3Z - id: GPIOE_2 + id: E2 class: outputs ts_name: 3Z - IGN_5 / GNDA type: ign @@ -284,13 +284,13 @@ pins: color: black W4 - pin: 4B - id: [GPIOF_9, ADC3_CHANNEL_7] + id: [F9, ADC3_CHANNEL_7] class: [switch_inputs, analog_inputs] ts_name: 4B - Brake/RES1 (A7) function: Brake Switch - pin: 4C - id: [GPIOF_10, EFI_ADC_3] + id: [F10, EFI_ADC_3] class: [switch_inputs, analog_inputs] ts_name: 4C - Steering/RES2 (A16) function: Power Steering Switch @@ -302,32 +302,32 @@ pins: function: DTM switching (Diagnostic Terminal?) - pin: 4F - id: [GPIOB_0, EFI_ADC_8] + id: [B0, EFI_ADC_8] class: [switch_inputs, analog_inputs] ts_name: 4F - AC_PRES/AUX1 (A23) function: A/C Pressure In - pin: 4H - id: [GPIOC_4, EFI_ADC_14] + id: [C4, EFI_ADC_14] class: [switch_inputs, analog_inputs] ts_name: 4H - Neutral/AUX2 (A21) function: Neutral Switch - pin: 4I # H144_IN_RES3 - id: GPIOF_8 + id: F8 class: switch_inputs ts_name: 4I - Clutch (A8) function: Clutch Switch - pin: 4J - id: [GPIOA_7, EFI_ADC_7] + id: [A7, EFI_ADC_7] class: [switch_inputs, analog_inputs] ts_name: 4J - VTCS/AUX4 (A20) function: VTCS ca. switch - pin: 4K - id: GPIOI_5 + id: I5 class: outputs ts_name: 4K - IGN_6 / +5V_MAP type: ign @@ -369,7 +369,7 @@ pins: function: NC - pin: 4R - id: GPIOI_0 + id: I0 class: outputs ts_name: 4R - VVT (O5) function: VVT Oil Control Valve neg. @@ -398,7 +398,7 @@ pins: function: Alternator output voltage - pin: 4U - id: [GPIOI_7, EFI_ADC_11] + id: [I7, EFI_ADC_11] class: [outputs, analog_inputs] ts_name: 4U - MAP2/Ign8 (A10) function: NC, extra main relay for diode diff --git a/firmware/config/boards/hellen/hellen72/knock_config.h b/firmware/config/boards/hellen/hellen72/knock_config.h index be15db88b1..a4e32de5ab 100644 --- a/firmware/config/boards/hellen/hellen72/knock_config.h +++ b/firmware/config/boards/hellen/hellen72/knock_config.h @@ -9,7 +9,7 @@ // knock 1 - pin PF7 #define KNOCK_ADC_CH1 ADC_CHANNEL_IN5 -#define KNOCK_PIN_CH1 GPIOF_7 +#define KNOCK_PIN_CH1 Gpio::F7 // Sample rate & time - depends on the exact MCU #define KNOCK_SAMPLE_TIME ADC_SAMPLE_84 diff --git a/firmware/config/boards/hellen/hellen81/board.h b/firmware/config/boards/hellen/hellen81/board.h index 4659a06f63..a99cfdf58a 100644 --- a/firmware/config/boards/hellen/hellen81/board.h +++ b/firmware/config/boards/hellen/hellen81/board.h @@ -33,8 +33,8 @@ #define BOARD_NAME "Hellen81" #define EFI_USB_AF 10U -#define EFI_USB_SERIAL_DM GPIOA_11 -#define EFI_USB_SERIAL_DP GPIOA_12 +#define EFI_USB_SERIAL_DM Gpio::A11 +#define EFI_USB_SERIAL_DP Gpio::A12 // Ignore USB VBUS pin (we're never a host, only a device) #define BOARD_OTG_NOVBUSSENS TRUE diff --git a/firmware/config/boards/hellen/hellen81/board_configuration.cpp b/firmware/config/boards/hellen/hellen81/board_configuration.cpp index b292bf7dbf..9428f555bf 100644 --- a/firmware/config/boards/hellen/hellen81/board_configuration.cpp +++ b/firmware/config/boards/hellen/hellen81/board_configuration.cpp @@ -14,33 +14,33 @@ #include "hellen_meta.h" static void setInjectorPins() { - engineConfiguration->injectionPins[0] = GPIOG_7; - engineConfiguration->injectionPins[1] = GPIOG_8; - engineConfiguration->injectionPins[2] = GPIOD_11; - engineConfiguration->injectionPins[3] = GPIOD_10; + engineConfiguration->injectionPins[0] = Gpio::G7; + engineConfiguration->injectionPins[1] = Gpio::G8; + engineConfiguration->injectionPins[2] = Gpio::D11; + engineConfiguration->injectionPins[3] = Gpio::D10; - //engineConfiguration->injectionPins[4] = GPIOD_9; - //engineConfiguration->injectionPins[5] = GPIOF_12; - //engineConfiguration->injectionPins[6] = GPIOF_13; - //engineConfiguration->injectionPins[7] = GPIOF_14; + //engineConfiguration->injectionPins[4] = Gpio::D9; + //engineConfiguration->injectionPins[5] = Gpio::F12; + //engineConfiguration->injectionPins[6] = Gpio::F13; + //engineConfiguration->injectionPins[7] = Gpio::F14; // Disable remainder for (int i = 4; i < MAX_CYLINDER_COUNT;i++) { - engineConfiguration->injectionPins[i] = GPIO_UNASSIGNED; + engineConfiguration->injectionPins[i] = Gpio::Unassigned; } engineConfiguration->injectionPinMode = OM_DEFAULT; } static void setIgnitionPins() { - engineConfiguration->ignitionPins[0] = GPIOI_8; - engineConfiguration->ignitionPins[1] = GPIOE_5; - engineConfiguration->ignitionPins[2] = GPIOE_4; - engineConfiguration->ignitionPins[3] = GPIOE_3; + engineConfiguration->ignitionPins[0] = Gpio::I8; + engineConfiguration->ignitionPins[1] = Gpio::E5; + engineConfiguration->ignitionPins[2] = Gpio::E4; + engineConfiguration->ignitionPins[3] = Gpio::E3; // disable remainder for (int i = 4; i < MAX_CYLINDER_COUNT; i++) { - engineConfiguration->ignitionPins[i] = GPIO_UNASSIGNED; + engineConfiguration->ignitionPins[i] = Gpio::Unassigned; } engineConfiguration->ignitionPinMode = OM_DEFAULT; @@ -50,14 +50,14 @@ static void setLedPins() { #ifdef EFI_COMMUNICATION_PIN engineConfiguration->communicationLedPin = EFI_COMMUNICATION_PIN; #else - engineConfiguration->communicationLedPin = GPIOH_10; + engineConfiguration->communicationLedPin = Gpio::H10; #endif /* EFI_COMMUNICATION_PIN */ //!!!!!!!!!!! - engineConfiguration->runningLedPin = GPIO_UNASSIGNED; - //engineConfiguration->runningLedPin = GPIOH_9; // green + engineConfiguration->runningLedPin = Gpio::Unassigned; + //engineConfiguration->runningLedPin = Gpio::H9; // green - engineConfiguration->warningLedPin = GPIOH_11; // yellow + engineConfiguration->warningLedPin = Gpio::H11; // yellow } static void setupVbatt() { @@ -76,11 +76,11 @@ static void setupVbatt() { static void setupDefaultSensorInputs() { // trigger inputs - engineConfiguration->triggerInputPins[0] = GPIOB_1; - engineConfiguration->triggerInputPins[1] = GPIO_UNASSIGNED; - engineConfiguration->triggerInputPins[2] = GPIO_UNASSIGNED; + engineConfiguration->triggerInputPins[0] = Gpio::B1; + engineConfiguration->triggerInputPins[1] = Gpio::Unassigned; + engineConfiguration->triggerInputPins[2] = Gpio::Unassigned; // Direct hall-only cam input - engineConfiguration->camInputs[0] = GPIOA_6; + engineConfiguration->camInputs[0] = Gpio::A6; engineConfiguration->tps1_1AdcChannel = EFI_ADC_4; engineConfiguration->tps2_1AdcChannel = EFI_ADC_NONE; @@ -106,8 +106,8 @@ void setBoardConfigOverrides() { engineConfiguration->clt.config.bias_resistor = 4700; engineConfiguration->iat.config.bias_resistor = 4700; - engineConfiguration->canTxPin = GPIOD_1; - engineConfiguration->canRxPin = GPIOD_0; + engineConfiguration->canTxPin = Gpio::D1; + engineConfiguration->canRxPin = Gpio::D0; } void setSerialConfigurationOverrides() { @@ -132,20 +132,20 @@ void setBoardDefaultConfiguration() { engineConfiguration->isSdCardEnabled = true; - engineConfiguration->canTxPin = GPIOD_1; - engineConfiguration->canRxPin = GPIOD_0; + engineConfiguration->canTxPin = Gpio::D1; + engineConfiguration->canRxPin = Gpio::D0; - engineConfiguration->fuelPumpPin = GPIOG_2; // OUT_IO9 - engineConfiguration->fanPin = GPIOD_12; // OUT_PWM8 - engineConfiguration->mainRelayPin = GPIOI_2; // OUT_LOW3 - engineConfiguration->tachOutputPin = GPIOD_14; // OUT_PWM6 + engineConfiguration->fuelPumpPin = Gpio::G2; // OUT_IO9 + engineConfiguration->fanPin = Gpio::D12; // OUT_PWM8 + engineConfiguration->mainRelayPin = Gpio::I2; // OUT_LOW3 + engineConfiguration->tachOutputPin = Gpio::D14; // OUT_PWM6 engineConfiguration->useStepperIdle = true; engineConfiguration->useHbridgesToDriveIdleStepper = true; - engineConfiguration->stepperDcIo[0].directionPin1 = GPIOC_6; // COIL_A1 = OUT_PWM2 - engineConfiguration->stepperDcIo[0].directionPin2 = GPIOC_7; // COIL_A2 = OUT_PWM3 - engineConfiguration->stepperDcIo[1].directionPin1 = GPIOC_8; // COIL_B1 = OUT_PWM4 - engineConfiguration->stepperDcIo[1].directionPin2 = GPIOC_9; // COIL_B2 = OUT_PWM5 + engineConfiguration->stepperDcIo[0].directionPin1 = Gpio::C6; // COIL_A1 = OUT_PWM2 + engineConfiguration->stepperDcIo[0].directionPin2 = Gpio::C7; // COIL_A2 = OUT_PWM3 + engineConfiguration->stepperDcIo[1].directionPin1 = Gpio::C8; // COIL_B1 = OUT_PWM4 + engineConfiguration->stepperDcIo[1].directionPin2 = Gpio::C9; // COIL_B2 = OUT_PWM5 // "required" hardware is done - set some reasonable defaults setupDefaultSensorInputs(); @@ -167,19 +167,19 @@ void setSdCardConfigurationOverrides() { #if 1 engineConfiguration->sdCardSpiDevice = SPI_DEVICE_2; - engineConfiguration->spi2mosiPin = GPIOB_15; - engineConfiguration->spi2misoPin = GPIOB_14; - engineConfiguration->spi2sckPin = GPIOB_13; - engineConfiguration->sdCardCsPin = GPIOB_12; + engineConfiguration->spi2mosiPin = Gpio::B15; + engineConfiguration->spi2misoPin = Gpio::B14; + engineConfiguration->spi2sckPin = Gpio::B13; + engineConfiguration->sdCardCsPin = Gpio::B12; engineConfiguration->is_enabled_spi_2 = true; #else engineConfiguration->sdCardSpiDevice = SPI_DEVICE_3; - engineConfiguration->spi3mosiPin = GPIOC_12; - engineConfiguration->spi3misoPin = GPIOC_11; - engineConfiguration->spi3sckPin = GPIOC_10; - engineConfiguration->sdCardCsPin = GPIOA_15; + engineConfiguration->spi3mosiPin = Gpio::C12; + engineConfiguration->spi3misoPin = Gpio::C11; + engineConfiguration->spi3sckPin = Gpio::C10; + engineConfiguration->sdCardCsPin = Gpio::A15; engineConfiguration->is_enabled_spi_3 = true; #endif diff --git a/firmware/config/boards/hellen/hellen81/connectors/main.yaml b/firmware/config/boards/hellen/hellen81/connectors/main.yaml index 5e28f267db..dfeda84fcf 100644 --- a/firmware/config/boards/hellen/hellen81/connectors/main.yaml +++ b/firmware/config/boards/hellen/hellen81/connectors/main.yaml @@ -4,7 +4,7 @@ pins: - pin: 1 function: Ignition 2 Output - id: GPIOE_5 + id: E5 class: outputs ts_name: 1 - IGN_2 type: ign @@ -12,7 +12,7 @@ pins: - pin: 2 function: Ignition 3 (2+3) Output - id: GPIOE_4 + id: E4 class: outputs ts_name: 2 - IGN_3 type: ign @@ -25,7 +25,7 @@ pins: - pin: 4 function: Ignition 4 Output - id: GPIOE_3 + id: E3 class: outputs ts_name: 4 - IGN_4 type: ign @@ -33,7 +33,7 @@ pins: - pin: 5 function: Ignition 1 (1+4) Output - id: GPIOI_8 + id: I8 class: outputs ts_name: 5 - IGN_1 type: ign @@ -41,7 +41,7 @@ pins: - pin: 6 function: Injector 2 Output - id: GPIOG_8 + id: G8 class: outputs ts_name: 6 - INJ_2 type: inj @@ -49,7 +49,7 @@ pins: - pin: 7 function: Injector 3 Output - id: GPIOD_11 + id: D11 class: outputs ts_name: 7 - INJ_3 type: inj @@ -57,28 +57,28 @@ pins: - pin: 8 function: Engine Speed (Tachometer) Signal Output (push-pull) - id: GPIOD_14 + id: D14 class: outputs ts_name: 8 - OUT_TACH color: green - pin: 9 function: Fuel Level / CLT Analog Input - id: GPIOF_5 + id: F5 class: analog_inputs ts_name: 9 - IN_SENS3 color: white - pin: 10 function: Fuel consumption Output (push-pull) / CLT? - id: GPIOD_15 + id: D15 class: outputs ts_name: 10 - OUT_FUEL color: green - pin: 11 function: Reserved High-side Output (high) - id: GPIOH_13 + id: H13 class: outputs ts_name: 11 - OUT_HIGH type: gp_high @@ -98,7 +98,7 @@ pins: - pin: 14 function: Main Relay Output - id: GPIOI_2 + id: I2 class: outputs ts_name: 14 - OUT_MAIN type: ls @@ -106,7 +106,7 @@ pins: - pin: 15 function: Crankshaft Sensor (+) Input - id: [GPIOB_1, EFI_ADC_9] + id: [B1, EFI_ADC_9] class: [event_inputs, analog_inputs] ts_name: 15 - IN_CRANK (A24) color: white @@ -140,7 +140,7 @@ pins: - pin: 21 function: Ignition 8 Output - id: GPIOE_6 + id: E6 class: outputs ts_name: 21 - IGN_8 type: ign @@ -148,7 +148,7 @@ pins: - pin: 22 function: Ignition 7 Output - id: GPIOB_9 + id: B9 class: outputs ts_name: 22 - IGN_7 type: ign @@ -156,7 +156,7 @@ pins: - pin: 23 function: Ignition 6 Output - id: GPIOB_8 + id: B8 class: outputs ts_name: 23 - IGN_6 type: ign @@ -164,7 +164,7 @@ pins: - pin: 24 function: Ignition 5 Output - id: GPIOE_2 + id: E2 class: outputs ts_name: 24 - IGN_5 type: ign @@ -172,7 +172,7 @@ pins: - pin: 25 function: Injector 6 Output - id: GPIOF_12 + id: F12 class: outputs ts_name: 25 - INJ_6 type: inj @@ -184,7 +184,7 @@ pins: - pin: 27 function: Injector 1 Output - id: GPIOG_7 + id: G7 class: outputs ts_name: 27 - INJ_1 type: inj @@ -192,7 +192,7 @@ pins: - pin: 28 function: Oxygen Sensor 2 Heating Output (low) - id: GPIOA_9 + id: A9 class: outputs ts_name: 28 - OUT_O2H2 type: ls @@ -204,7 +204,7 @@ pins: - pin: 30 function: Injector 5 Output - id: GPIOD_9 + id: D9 class: outputs ts_name: 30 - INJ_5 type: inj @@ -212,7 +212,7 @@ pins: - pin: 31 function: CheckEngine Lamp Output (low) - id: GPIOG_4 + id: G4 class: outputs ts_name: 31 - OUT_CE type: ls @@ -293,7 +293,7 @@ pins: - pin: 46 function: Canister Purge Valve Output (low) - id: GPIOG_3 + id: G3 class: outputs ts_name: 46 - OUT_CANIST type: ls @@ -301,7 +301,7 @@ pins: - pin: 47 function: Injector 4 Output - id: GPIOD_10 + id: D10 class: outputs ts_name: 47 - INJ_4 type: inj @@ -309,7 +309,7 @@ pins: - pin: 48 function: O2 LSF Heating Output (low) - id: GPIOH_14 + id: H14 class: outputs ts_name: 48 - OUT_O2H type: ls @@ -317,7 +317,7 @@ pins: - pin: 49 function: Canister heater Output (low) - id: GPIOI_1 + id: I1 class: outputs ts_name: 49 - OUT_HEATER type: ls @@ -325,7 +325,7 @@ pins: - pin: 50 function: Starter Relay Output (low) / HOTLamp / Idle2(Mikas) - id: GPIOI_0 + id: I0 class: outputs ts_name: 50 - OUT_STARTER type: ls @@ -366,14 +366,14 @@ pins: - pin: 59 function: Vehicle Speed Sensor (VSS) digital input # H144_IN_VSS - id: GPIOF_11 + id: F11 class: event_inputs ts_name: 59 - IN_VSS color: white - pin: 60 function: Reserved Push-Pull Output (push-pull) - id: GPIOD_13 + id: D13 class: outputs ts_name: 60 - OUT_IO color: green @@ -392,35 +392,35 @@ pins: - pin: 64 function: Solenoid B2 output (push-pull) / Stepper A (or D) - id: GPIOC_9 + id: C9 class: outputs ts_name: 64 - OUT_COIL_B2 color: green - pin: 65 function: Solenoid B1 output (push-pull) / Stepper D (or C) - id: GPIOC_8 + id: C8 class: outputs ts_name: 65 - OUT_COIL_B1 color: green - pin: 66 function: Solenoid A2 output (push-pull) / Stepper C (or B) - id: GPIOC_7 + id: C7 class: outputs ts_name: 66 - OUT_COIL_A2 color: green - pin: 67 function: Solenoid A1 output (push-pull) / Stepper B (or A) - id: GPIOC_6 + id: C6 class: outputs ts_name: 67 - OUT_COIL_A1 color: green - pin: 68 function: Electric Cooling Fan (ECF) Relay Output (low) - id: GPIOD_12 + id: D12 class: outputs ts_name: 68 - OUT_ECF type: ls @@ -428,7 +428,7 @@ pins: - pin: 69 function: A/C Relay Output (low) - id: GPIOH_15 + id: H15 class: outputs ts_name: 69 - OUT_AC type: ls @@ -436,7 +436,7 @@ pins: - pin: 70 function: Fuel Pump Relay Output (low) - id: GPIOG_2 + id: G2 class: outputs ts_name: 70 - OUT_PUMP type: ls @@ -447,7 +447,7 @@ pins: - pin: 72 function: Injector 7 Output - id: GPIOF_13 + id: F13 class: outputs ts_name: 72 - INJ_7 type: inj @@ -455,7 +455,7 @@ pins: - pin: 73 function: Injector 8 Output - id: GPIOF_14 + id: F14 class: outputs ts_name: 73 - INJ_8 type: inj @@ -463,28 +463,28 @@ pins: - pin: 74 function: Inertia switch (crash detect) Input - id: [GPIOB_0, EFI_ADC_8] + id: [B0, EFI_ADC_8] class: [event_inputs, analog_inputs] ts_name: 74 - IN_AUX1 color: white - pin: 75 function: A/C Switch Input - id: [GPIOC_4, EFI_ADC_14] + id: [C4, EFI_ADC_14] class: [event_inputs, analog_inputs] ts_name: 75 - IN_AUX2 color: white - pin: 76 function: Power Steering Input - id: [GPIOC_5, EFI_ADC_15] + id: [C5, EFI_ADC_15] class: [event_inputs, analog_inputs] ts_name: 76 - IN_AUX3 color: white - pin: 77 function: Clutch switch Input - id: [GPIOA_7, EFI_ADC_7] + id: [A7, EFI_ADC_7] class: [event_inputs, analog_inputs] ts_name: 77 - IN_AUX4 color: white @@ -498,7 +498,7 @@ pins: - pin: 79 function: Cam/Phase Sensor Input - id: [GPIOA_6, EFI_ADC_6] + id: [A6, EFI_ADC_6] class: [event_inputs, analog_inputs] ts_name: 79 - IN_CAM color: white diff --git a/firmware/config/boards/hellen/hellen88bmw/board_configuration.cpp b/firmware/config/boards/hellen/hellen88bmw/board_configuration.cpp index b9545b8b17..a4bd6456ef 100644 --- a/firmware/config/boards/hellen/hellen88bmw/board_configuration.cpp +++ b/firmware/config/boards/hellen/hellen88bmw/board_configuration.cpp @@ -24,23 +24,23 @@ static void setInjectorPins() { // Disable remainder for (int i = 6; i < MAX_CYLINDER_COUNT;i++) { - engineConfiguration->injectionPins[i] = GPIO_UNASSIGNED; + engineConfiguration->injectionPins[i] = Gpio::Unassigned; } engineConfiguration->injectionPinMode = OM_DEFAULT; } static void setIgnitionPins() { - engineConfiguration->ignitionPins[0] = GPIOC_13; - engineConfiguration->ignitionPins[1] = GPIOE_5; - engineConfiguration->ignitionPins[2] = GPIOE_4; - engineConfiguration->ignitionPins[3] = GPIOE_3; - engineConfiguration->ignitionPins[4] = GPIOE_2; - engineConfiguration->ignitionPins[5] = GPIOB_8; + engineConfiguration->ignitionPins[0] = Gpio::C13; + engineConfiguration->ignitionPins[1] = Gpio::E5; + engineConfiguration->ignitionPins[2] = Gpio::E4; + engineConfiguration->ignitionPins[3] = Gpio::E3; + engineConfiguration->ignitionPins[4] = Gpio::E2; + engineConfiguration->ignitionPins[5] = Gpio::B8; // disable remainder for (int i = 6; i < MAX_CYLINDER_COUNT; i++) { - engineConfiguration->ignitionPins[i] = GPIO_UNASSIGNED; + engineConfiguration->ignitionPins[i] = Gpio::Unassigned; } engineConfiguration->ignitionPinMode = OM_DEFAULT; @@ -63,8 +63,8 @@ static void setupVbatt() { static void setupDefaultSensorInputs() { // trigger inputs engineConfiguration->triggerInputPins[0] = H144_IN_CRANK; - engineConfiguration->triggerInputPins[1] = GPIO_UNASSIGNED; - engineConfiguration->triggerInputPins[2] = GPIO_UNASSIGNED; + engineConfiguration->triggerInputPins[1] = Gpio::Unassigned; + engineConfiguration->triggerInputPins[2] = Gpio::Unassigned; // Direct hall-only cam input engineConfiguration->camInputs[0] = H144_IN_CAM; @@ -121,21 +121,21 @@ void setBoardDefaultConfiguration() { engineConfiguration->enableSoftwareKnock = true; engineConfiguration->canNbcType = CAN_BUS_NISSAN_VQ; - engineConfiguration->canTxPin = GPIOD_1; - engineConfiguration->canRxPin = GPIOD_0; + engineConfiguration->canTxPin = Gpio::D1; + engineConfiguration->canRxPin = Gpio::D0; - engineConfiguration->fuelPumpPin = GPIOD_12; // OUT_IO9 // 113 Fuel Pump Relay + engineConfiguration->fuelPumpPin = Gpio::D12; // OUT_IO9 // 113 Fuel Pump Relay engineConfiguration->idle.solenoidPin = H144_OUT_PWM5; -// engineConfiguration->fanPin = GPIOD_12; // OUT_PWM8 - engineConfiguration->mainRelayPin = GPIOG_14; // pin: 111a, OUT_IO3 +// engineConfiguration->fanPin = Gpio::D12; // OUT_PWM8 + engineConfiguration->mainRelayPin = Gpio::G14; // pin: 111a, OUT_IO3 engineConfiguration->tachOutputPin = H144_OUT_PWM7; // "required" hardware is done - set some reasonable defaults setupDefaultSensorInputs(); - engineConfiguration->etbIo[0].directionPin1 = GPIOD_15; // out_pwm7 - engineConfiguration->etbIo[0].directionPin2 = GPIOD_14; // out_pwm6 - engineConfiguration->etbIo[0].controlPin = GPIOD_13; // ETB_EN out_pwm1 + engineConfiguration->etbIo[0].directionPin1 = Gpio::D15; // out_pwm7 + engineConfiguration->etbIo[0].directionPin2 = Gpio::D14; // out_pwm6 + engineConfiguration->etbIo[0].controlPin = Gpio::D13; // ETB_EN out_pwm1 engineConfiguration->etb_use_two_wires = true; // Some sensible defaults for other options @@ -155,7 +155,7 @@ void setBoardDefaultConfiguration() { engineConfiguration->crankingInjectionMode = IM_SIMULTANEOUS; engineConfiguration->injectionMode = IM_SIMULTANEOUS;//IM_BATCH;// IM_SEQUENTIAL; - engineConfiguration->luaOutputPins[0] = GPIOG_5; // 104 ETB Relay + engineConfiguration->luaOutputPins[0] = Gpio::G5; // 104 ETB Relay engineConfiguration->throttlePedalUpVoltage = 0.75; engineConfiguration->throttlePedalWOTVoltage = 4.45; @@ -178,14 +178,14 @@ void setBoardDefaultConfiguration() { void setSdCardConfigurationOverrides() { engineConfiguration->sdCardSpiDevice = SPI_DEVICE_3; - engineConfiguration->spi3mosiPin = GPIOC_12; - engineConfiguration->spi3misoPin = GPIOC_11; - engineConfiguration->spi3sckPin = GPIOC_10; - engineConfiguration->sdCardCsPin = GPIOA_15; + engineConfiguration->spi3mosiPin = Gpio::C12; + engineConfiguration->spi3misoPin = Gpio::C11; + engineConfiguration->spi3sckPin = Gpio::C10; + engineConfiguration->sdCardCsPin = Gpio::A15; -// engineConfiguration->spi2mosiPin = GPIOB_15; -// engineConfiguration->spi2misoPin = GPIOB_14; -// engineConfiguration->spi2sckPin = GPIOB_13; -// engineConfiguration->sdCardCsPin = GPIOB_12; +// engineConfiguration->spi2mosiPin = Gpio::B15; +// engineConfiguration->spi2misoPin = Gpio::B14; +// engineConfiguration->spi2sckPin = Gpio::B13; +// engineConfiguration->sdCardCsPin = Gpio::B12; engineConfiguration->is_enabled_spi_3 = true; } diff --git a/firmware/config/boards/hellen/hellen88bmw/connectors/main.yaml b/firmware/config/boards/hellen/hellen88bmw/connectors/main.yaml index b49a452f2b..c03742f7c6 100644 --- a/firmware/config/boards/hellen/hellen88bmw/connectors/main.yaml +++ b/firmware/config/boards/hellen/hellen88bmw/connectors/main.yaml @@ -2,40 +2,40 @@ pins: - pin: 1 - id: GPIOG_14 + id: G14 class: outputs function: Fuel Pump Relay Output (low) ts_name: 1 - OUT_PUMP - pin: 2 # H144_OUT_PWM8 - id: GPIOD_12 + id: D12 class: outputs ts_name: 2 - IdleC - pin: 3 - id: GPIOD_9 + id: D9 function: Injector 5 Output class: outputs ts_name: 3 - INJ_5 type: inj - pin: 4 - id: GPIOF_12 + id: F12 function: Injector 6 Output class: outputs ts_name: 4 - INJ_6 type: inj - pin: 5 - id: GPIOD_10 + id: D10 function: Injector 4 Output class: outputs ts_name: 5 - INJ_4 type: inj - pin: 7 - id: GPIOF_13 + id: F13 function: Injector 7/VVT Output class: outputs ts_name: 7 - INJ_7/VVT @@ -45,40 +45,40 @@ pins: ts_name: CEL - pin: 16 - id: [GPIOB_1, EFI_ADC_9] + id: [B1, EFI_ADC_9] class: [event_inputs, analog_inputs] ts_name: 16 - CRANK function: Crankshaft Sensor - pin: 17 - id: [GPIOA_6, EFI_ADC_6] + id: [A6, EFI_ADC_6] class: [event_inputs, analog_inputs] ts_name: 17 - CAM function: Camshaft Sensor - pin: 23 - id: GPIOE_3 + id: E3 class: outputs ts_name: 23 - Coil 4 function: Coil 4 type: ign - pin: 24 - id: GPIOB_8 + id: B8 class: outputs ts_name: 24 - Coil 6 function: Coil 6 type: ign - pin: 25 - id: GPIOE_2 + id: E2 class: outputs ts_name: 25 - Coil 5 function: Coil 5 type: ign - pin: 27 - id: GPIOD_3 + id: D3 class: outputs ts_name: 27 - MAIN function: Main relay control @@ -86,33 +86,33 @@ pins: - pin: 29 # H144_OUT_PWM5 - id: GPIOC_9 + id: C9 class: outputs ts_name: 29 - Idle - pin: 31 - id: GPIOD_11 + id: D11 function: Injector 3 Output class: outputs ts_name: 31 - INJ_3 type: inj - pin: 32 - id: GPIOG_8 + id: G8 function: Injector 2 Output class: outputs ts_name: 32 - INJ_2 type: inj - pin: 33 - id: GPIOG_7 + id: G7 function: Injector 1 Output class: outputs ts_name: 33 - INJ_1 type: inj - pin: 35 - id: GPIOF_14 + id: F14 function: Injector 8 Output class: outputs ts_name: 35 - INJ_8 @@ -126,12 +126,12 @@ pins: - pin: 47 # H144_OUT_PWM7 - id: GPIOD_15 + id: D15 class: outputs ts_name: 47 - Tach - pin: 50 - id: GPIOC_13 + id: C13 class: outputs ts_name: 50 - Coil 1 function: Coil 1 @@ -139,14 +139,14 @@ pins: - pin: 51 - id: GPIOE_5 + id: E5 class: outputs ts_name: 51 - Coil 2 function: Coil 2 type: ign - pin: 52 - id: GPIOE_4 + id: E4 class: outputs ts_name: 52 - Coil 3 function: Coil 3 diff --git a/firmware/config/boards/hellen/hellenNA8_96/board_configuration.cpp b/firmware/config/boards/hellen/hellenNA8_96/board_configuration.cpp index 5e89395338..927b093d8c 100644 --- a/firmware/config/boards/hellen/hellenNA8_96/board_configuration.cpp +++ b/firmware/config/boards/hellen/hellenNA8_96/board_configuration.cpp @@ -22,12 +22,12 @@ static void setInjectorPins() { // Disable remainder for (int i = 4; i < MAX_CYLINDER_COUNT;i++) { - engineConfiguration->injectionPins[i] = GPIO_UNASSIGNED; + engineConfiguration->injectionPins[i] = Gpio::Unassigned; } engineConfiguration->injectionPinMode = OM_DEFAULT; - engineConfiguration->clutchDownPin = GPIOC_4; // Clutch switch input + engineConfiguration->clutchDownPin = Gpio::C4; // Clutch switch input engineConfiguration->clutchDownPinMode = PI_PULLDOWN; engineConfiguration->launchActivationMode = CLUTCH_INPUT_LAUNCH; engineConfiguration->malfunctionIndicatorPin = H144_OUT_IO8; @@ -35,13 +35,13 @@ static void setInjectorPins() { static void setIgnitionPins() { engineConfiguration->ignitionPins[0] = H144_IGN_1; - engineConfiguration->ignitionPins[1] = GPIO_UNASSIGNED; + engineConfiguration->ignitionPins[1] = Gpio::Unassigned; engineConfiguration->ignitionPins[2] = H144_IGN_2; - engineConfiguration->ignitionPins[3] = GPIO_UNASSIGNED; + engineConfiguration->ignitionPins[3] = Gpio::Unassigned; // disable remainder for (int i = 4; i < MAX_CYLINDER_COUNT; i++) { - engineConfiguration->ignitionPins[i] = GPIO_UNASSIGNED; + engineConfiguration->ignitionPins[i] = Gpio::Unassigned; } engineConfiguration->ignitionPinMode = OM_DEFAULT; @@ -65,8 +65,8 @@ static void setupDefaultSensorInputs() { // trigger inputs, hall engineConfiguration->triggerInputPins[0] = H144_IN_CAM; engineConfiguration->triggerInputPins[1] = H144_IN_CRANK; - engineConfiguration->triggerInputPins[2] = GPIO_UNASSIGNED; - engineConfiguration->camInputs[0] = GPIO_UNASSIGNED; + engineConfiguration->triggerInputPins[2] = Gpio::Unassigned; + engineConfiguration->camInputs[0] = Gpio::Unassigned; engineConfiguration->tps1_1AdcChannel = EFI_ADC_4; engineConfiguration->tps2_1AdcChannel = EFI_ADC_NONE; @@ -92,13 +92,13 @@ void setBoardConfigOverrides() { engineConfiguration->clt.config.bias_resistor = 4700; engineConfiguration->iat.config.bias_resistor = 4700; - engineConfiguration->canTxPin = GPIOD_1; - engineConfiguration->canRxPin = GPIOD_0; + engineConfiguration->canTxPin = Gpio::D1; + engineConfiguration->canRxPin = Gpio::D0; engineConfiguration->etb_use_two_wires = true; - engineConfiguration->etbIo[0].directionPin1 = GPIOC_7; // PWM 3 - engineConfiguration->etbIo[0].directionPin2 = GPIOC_8; // PWM 4 - engineConfiguration->etbIo[0].controlPin = GPIOC_6; // PWM 2 + engineConfiguration->etbIo[0].directionPin1 = Gpio::C7; // PWM 3 + engineConfiguration->etbIo[0].directionPin2 = Gpio::C8; // PWM 4 + engineConfiguration->etbIo[0].controlPin = Gpio::C6; // PWM 2 } void setSerialConfigurationOverrides() { @@ -128,10 +128,10 @@ void setBoardDefaultConfiguration() { engineConfiguration->boostControlPin = H144_LS_6; engineConfiguration->acSwitch = H144_IN_D_AUX3; engineConfiguration->acRelayPin = H144_OUT_IO6; - engineConfiguration->fuelPumpPin = GPIOG_2; // OUT_IO9 - engineConfiguration->idle.solenoidPin = GPIOD_14; // OUT_PWM5 - engineConfiguration->fanPin = GPIOD_12; // OUT_PWM8 - engineConfiguration->mainRelayPin = GPIOI_2; // OUT_LOW3 + engineConfiguration->fuelPumpPin = Gpio::G2; // OUT_IO9 + engineConfiguration->idle.solenoidPin = Gpio::D14; // OUT_PWM5 + engineConfiguration->fanPin = Gpio::D12; // OUT_PWM8 + engineConfiguration->mainRelayPin = Gpio::I2; // OUT_LOW3 engineConfiguration->tachOutputPin = H144_OUT_PWM1; engineConfiguration->alternatorControlPin = H144_OUT_PWM7; engineConfiguration->fan2Pin = H144_OUT_IO2; @@ -149,7 +149,7 @@ void setBoardDefaultConfiguration() { engineConfiguration->clutchDownPin = H144_IN_D_2; engineConfiguration->clutchDownPinMode = PI_PULLDOWN; engineConfiguration->launchActivationMode = CLUTCH_INPUT_LAUNCH; -// ? engineConfiguration->malfunctionIndicatorPin = GPIOG_4; //1E - Check Engine Light +// ? engineConfiguration->malfunctionIndicatorPin = Gpio::G4; //1E - Check Engine Light } /** diff --git a/firmware/config/boards/hellen/hellenNA8_96/compile_hellenNA8_96.sh b/firmware/config/boards/hellen/hellenNA8_96/compile_hellenNA8_96.sh old mode 100644 new mode 100755 index 6af1da137a..73976231d1 --- a/firmware/config/boards/hellen/hellenNA8_96/compile_hellenNA8_96.sh +++ b/firmware/config/boards/hellen/hellenNA8_96/compile_hellenNA8_96.sh @@ -1,4 +1,4 @@ #!/bin/bash cd .. -bash ../common_make.sh hellen/hellen-nb1 ARCH_STM32F4 +bash ../common_make.sh hellen/hellenNA8_96 ARCH_STM32F4 diff --git a/firmware/config/boards/hellen/hellenNA8_96/connectors/main.yaml b/firmware/config/boards/hellen/hellenNA8_96/connectors/main.yaml index f6a4f5f34d..9ac6d46866 100644 --- a/firmware/config/boards/hellen/hellenNA8_96/connectors/main.yaml +++ b/firmware/config/boards/hellen/hellenNA8_96/connectors/main.yaml @@ -5,14 +5,14 @@ pins: - pin: 1A - id: GPIOD_12 + id: D12 class: outputs ts_name: 1A - ECF function: Engine Radiator Fan type: ls - pin: 1B - id: GPIOA_9 + id: A9 class: outputs ts_name: 1B - AC Fan Relay function: AC Fan Relay @@ -22,14 +22,14 @@ pins: type: can - pin: 1E - id: GPIOG_4 + id: G4 class: outputs ts_name: 1E - Check Engine Light function: Check Engine Light type: ls - pin: 1G - id: GPIOG_11 + id: G11 class: outputs ts_name: 1G - AC Relay function: A/C Relay @@ -40,20 +40,20 @@ pins: type: ls - pin: 1K - id: [GPIOC_5, EFI_ADC_15] + id: [C5, EFI_ADC_15] class: [switch_inputs, analog_inputs] ts_name: 1K - AC Switch function: A/C Pressure In - pin: 1L - id: GPIOE_13 + id: E13 class: switch_inputs ts_name: 1L - Clutch function: Clutch Switch - pin: 1M # H144_IN_VSS - id: GPIOF_11 + id: F11 class: event_inputs ts_name: 1M - VSS function: VSS in @@ -62,26 +62,26 @@ pins: function: GND - pin: 1Q - id: [GPIOF_9, ADC3_CHANNEL_7] + id: [F9, ADC3_CHANNEL_7] class: [switch_inputs, analog_inputs] ts_name: 1Q - Brake/RES1 function: Brake Switch - pin: 1S - id: GPIOF_7 + id: F7 class: analog_inputs ts_name: 2M - KNOCK function: Knock sens. in - pin: 1U - id: GPIOG_2 + id: G2 class: outputs ts_name: 1U - Fuel Pump function: Fuel Pump Relay type: ls - pin: 2A - id: [GPIOB_0, EFI_ADC_8] + id: [B0, EFI_ADC_8] class: [switch_inputs, analog_inputs] ts_name: 2A - Pressure Input function: FTP input @@ -99,7 +99,7 @@ pins: function: Front O2 Sensor Signal - pin: 2D - id: GPIOF_3 + id: F3 class: switch_inputs ts_name: 2D - O2S2 function: Rear O2 Sensor Signal @@ -150,13 +150,13 @@ pins: ts_name: intMAP - pin: 3F - id: [GPIOB_1, EFI_ADC_9] + id: [B1, EFI_ADC_9] class: [event_inputs, analog_inputs] ts_name: 3F - CRANK function: Crankshaft Sensor - pin: 3G - id: [GPIOA_6, EFI_ADC_6] + id: [A6, EFI_ADC_6] class: [event_inputs, analog_inputs] ts_name: 3G - CAM function: Camshaft Sensor @@ -165,69 +165,69 @@ pins: function: +12V - pin: 3L - id: GPIOD_13 + id: D13 class: outputs ts_name: 3L - TACH function: Tach Out type: ls - pin: 3N - id: GPIOC_13 + id: C13 class: outputs ts_name: 3N - IGN_1 (1&4) function: Coil #1 type: ign - pin: 3Q - id: GPIOD_14 + id: D14 class: outputs ts_name: 3Q - IDLE function: IAC (negative), with diode type: ls - pin: 3R - id: GPIOE_5 + id: E5 class: outputs ts_name: 3R - IGN_2 (2&3) function: Coil #2 type: ign - pin: 3S - id: [GPIOA_7, EFI_ADC_7] + id: [A7, EFI_ADC_7] class: [switch_inputs, analog_inputs] ts_name: 3S - EGR BOOST IN function: EGR BOOST - pin: 3U - id: GPIOG_7 + id: G7 class: outputs ts_name: 3U - INJ_1 function: Injector #1 type: inj - pin: 3V - id: GPIOG_8 + id: G8 class: outputs ts_name: 3V - INJ_2 function: Injector #2 type: inj - pin: 3W - id: GPIOD_11 + id: D11 class: outputs ts_name: 3W - INJ_3 function: Injector #3 type: inj - pin: 3X - id: GPIOD_10 + id: D10 class: outputs ts_name: 3X - INJ_4 function: Injector #4 type: inj - pin: 3Z - id: GPIOG_13 + id: G13 class: outputs ts_name: 3Z - O2H2 function: Rear O2 sensor heater @@ -237,26 +237,26 @@ pins: function: GND - pin: 4B - id: GPIOE_12 + id: E12 class: event_inputs ts_name: 4B - DIGITAL/FLEX function: DIGITAL - pin: 4C - id: [GPIOC_4, EFI_ADC_14] + id: [C4, EFI_ADC_14] class: [switch_inputs, analog_inputs] ts_name: 4C - IN TEMP/PPS2 function: TEMP OR PPS2 - pin: 4D - id: GPIOF_12 + id: F12 class: outputs ts_name: 4D - BOOST OUT function: BOOST OUT type: inj - pin: 4E - id: GPIOD_9 + id: D9 class: outputs ts_name: 4E - VVT function: VVT Oil Control Valve neg. @@ -284,27 +284,27 @@ pins: function: WBO - pin: int_pps1 - id: [GPIOA_3, EFI_ADC_3] + id: [A3, EFI_ADC_3] class: [switch_inputs, analog_inputs] ts_name: PPS1 - pin: int_tps2 - id: [GPIOA_1, EFI_ADC_1] + id: [A1, EFI_ADC_1] class: [switch_inputs, analog_inputs] ts_name: TPS1 - pin: int_etb+ - id: GPIOC_7 + id: C7 class: outputs ts_name: ETB + - pin: int_etb- - id: GPIOC_8 + id: C8 class: outputs ts_name: ETB - - pin: int_etb_EN - id: GPIOC_6 + id: C6 class: outputs ts_name: ETB EN diff --git a/firmware/config/boards/hellen/hellen_board_id.cpp b/firmware/config/boards/hellen/hellen_board_id.cpp index 17e7463d20..6e755a08fc 100644 --- a/firmware/config/boards/hellen/hellen_board_id.cpp +++ b/firmware/config/boards/hellen/hellen_board_id.cpp @@ -22,16 +22,16 @@ * * The math proof: * - Charging formula #1: - * Vt = Vññ * (1 - exp(-Tc1 / RC)) + * Vt = V�� * (1 - exp(-Tc1 / RC)) * - Discharging formula: * Vl = Vt * exp(-Td / RC) * - Charging formula #2: - * Vl = Vññ * (1 - exp(-Tl / (RC))) + * Vl = V�� * (1 - exp(-Tl / (RC))) * - Where Tl is a charging time from 0 to Vl: * Tl = Tc1 - Tc2 * - Solve the equations: - * Vl = Vññ * (1 - exp(-Tl / RC)) = Vt * exp(-Td / RC) - * Vññ * (1 - exp(-Tl / RC)) = Vññ * (1 - exp(-Tc1 / RC)) * exp(-Td / RC) + * Vl = V�� * (1 - exp(-Tl / RC)) = Vt * exp(-Td / RC) + * V�� * (1 - exp(-Tl / RC)) = V�� * (1 - exp(-Tc1 / RC)) * exp(-Td / RC) * (1 - exp(-Tl / RC)) = (1 - exp(-Tc1 / RC)) * exp(-Td / RC) * - Simplify the equation: * X = exp(-1/(RC)) @@ -312,9 +312,9 @@ int detectHellenBoardId() { efiPrintf("Starting Hellen Board ID detection..."); efitick_t beginNt = getTimeNowNt(); - // Hellen boards use GPIOF_0 and GPIOF_1. + // Hellen boards use Gpio::F0 and Gpio::F1. const int numPins = 2; - brain_pin_e rPins[numPins] = { GPIOF_0, GPIOF_1 }; + Gpio rPins[numPins] = { Gpio::F0, Gpio::F1 }; // We start from the estimated capacitance, but the real one can be +-10% float C = HELLEN_BOARD_ID_CAPACITOR; diff --git a/firmware/config/boards/hellen/hellen_common.cpp b/firmware/config/boards/hellen/hellen_common.cpp index dfcd6ade30..6d111f8b9d 100644 --- a/firmware/config/boards/hellen/hellen_common.cpp +++ b/firmware/config/boards/hellen/hellen_common.cpp @@ -26,10 +26,10 @@ void setHellen176LedPins() { #ifdef EFI_COMMUNICATION_PIN engineConfiguration->communicationLedPin = EFI_COMMUNICATION_PIN; #else - engineConfiguration->communicationLedPin = GPIOH_10; + engineConfiguration->communicationLedPin = Gpio::H10; #endif /* EFI_COMMUNICATION_PIN */ - engineConfiguration->runningLedPin = GPIOH_9; // green - engineConfiguration->warningLedPin = GPIOH_11; // yellow + engineConfiguration->runningLedPin = Gpio::H9; // green + engineConfiguration->warningLedPin = Gpio::H11; // yellow } // this should be called before setHellenXXXLedPins() diff --git a/firmware/config/boards/hellen/hellen_knock_config.h b/firmware/config/boards/hellen/hellen_knock_config.h index 242e11fe18..71c60b174a 100644 --- a/firmware/config/boards/hellen/hellen_knock_config.h +++ b/firmware/config/boards/hellen/hellen_knock_config.h @@ -9,7 +9,7 @@ // knock 1 - pin PF7 #define KNOCK_ADC_CH1 ADC_CHANNEL_IN5 -#define KNOCK_PIN_CH1 GPIOF_7 +#define KNOCK_PIN_CH1 Gpio::F7 // Sample rate & time - depends on the exact MCU #define KNOCK_SAMPLE_TIME ADC_SAMPLE_84 diff --git a/firmware/config/boards/hellen_meta.h b/firmware/config/boards/hellen_meta.h index 15af97597d..ab9d0a977e 100644 --- a/firmware/config/boards/hellen_meta.h +++ b/firmware/config/boards/hellen_meta.h @@ -17,72 +17,72 @@ int detectHellenBoardId(); void detectHellenBoardType(); // stm32 UART8 -#define H144_UART1_RX GPIOE_0 -#define H144_UART1_TX GPIOE_1 +#define H144_UART1_RX Gpio::E0 +#define H144_UART1_TX Gpio::E1 // stm32 UART2 -#define H144_UART2_RX GPIOD_6 -#define H144_UART2_TX GPIOD_5 +#define H144_UART2_RX Gpio::D6 +#define H144_UART2_TX Gpio::D5 -#define H144_LED1_RED GPIOG_0 -#define H144_LED2 GPIOG_1 -#define H144_LED3 GPIOE_7 -#define H144_LED4 GPIOE_8 +#define H144_LED1_RED Gpio::G0 +#define H144_LED2 Gpio::G1 +#define H144_LED3 Gpio::E7 +#define H144_LED4 Gpio::E8 -#define H176_LED1_RED GPIOH_8 +#define H176_LED1_RED Gpio::H8 -#define H144_LS_1 GPIOG_7 -#define H144_LS_2 GPIOG_8 -#define H144_LS_3 GPIOD_11 -#define H144_LS_4 GPIOD_10 -#define H144_LS_5 GPIOD_9 -#define H144_LS_6 GPIOF_12 -#define H144_LS_7 GPIOF_13 -#define H144_LS_8 GPIOF_14 +#define H144_LS_1 Gpio::G7 +#define H144_LS_2 Gpio::G8 +#define H144_LS_3 Gpio::D11 +#define H144_LS_4 Gpio::D10 +#define H144_LS_5 Gpio::D9 +#define H144_LS_6 Gpio::F12 +#define H144_LS_7 Gpio::F13 +#define H144_LS_8 Gpio::F14 -#define H144_IGN_1 GPIOC_13 -#define H144_IGN_2 GPIOE_5 -#define H144_IGN_3 GPIOE_4 -#define H144_IGN_4 GPIOE_3 -#define H144_IGN_5 GPIOE_2 -#define H144_IGN_6 GPIOB_8 +#define H144_IGN_1 Gpio::C13 +#define H144_IGN_2 Gpio::E5 +#define H144_IGN_3 Gpio::E4 +#define H144_IGN_4 Gpio::E3 +#define H144_IGN_5 Gpio::E2 +#define H144_IGN_6 Gpio::B8 -#define H144_OUT_PWM1 GPIOD_13 -#define H144_OUT_PWM2 GPIOC_6 -#define H144_OUT_PWM3 GPIOC_7 -#define H144_OUT_PWM4 GPIOC_8 -#define H144_OUT_PWM5 GPIOC_9 -#define H144_OUT_PWM6 GPIOD_14 -#define H144_OUT_PWM7 GPIOD_15 -#define H144_OUT_PWM8 GPIOD_12 +#define H144_OUT_PWM1 Gpio::D13 +#define H144_OUT_PWM2 Gpio::C6 +#define H144_OUT_PWM3 Gpio::C7 +#define H144_OUT_PWM4 Gpio::C8 +#define H144_OUT_PWM5 Gpio::C9 +#define H144_OUT_PWM6 Gpio::D14 +#define H144_OUT_PWM7 Gpio::D15 +#define H144_OUT_PWM8 Gpio::D12 // also IO1/IO5 on rev 0.6 -#define H144_GP1 GPIOD_4 +#define H144_GP1 Gpio::D4 // also IO2/IO5 on rev 0.6 -#define H144_GP2 GPIOD_7 +#define H144_GP2 Gpio::D7 -#define H144_OUT_IO1 GPIOD_3 -#define H144_OUT_IO2 GPIOA_9 -#define H144_OUT_IO3 GPIOG_14 -#define H144_OUT_IO4 GPIOG_5 -#define H144_OUT_IO5 GPIOD_2 -#define H144_OUT_IO6 GPIOG_11 -#define H144_OUT_IO7 GPIOG_3 -#define H144_OUT_IO8 GPIOG_4 -#define H144_OUT_IO9 GPIOG_13 -#define H144_OUT_IO10 GPIOG_12 -#define H144_OUT_IO11 GPIOG_2 -#define H144_OUT_IO12 GPIOA_8 -#define H144_OUT_IO13 GPIOG_6 +#define H144_OUT_IO1 Gpio::D3 +#define H144_OUT_IO2 Gpio::A9 +#define H144_OUT_IO3 Gpio::G14 +#define H144_OUT_IO4 Gpio::G5 +#define H144_OUT_IO5 Gpio::D2 +#define H144_OUT_IO6 Gpio::G11 +#define H144_OUT_IO7 Gpio::G3 +#define H144_OUT_IO8 Gpio::G4 +#define H144_OUT_IO9 Gpio::G13 +#define H144_OUT_IO10 Gpio::G12 +#define H144_OUT_IO11 Gpio::G2 +#define H144_OUT_IO12 Gpio::A8 +#define H144_OUT_IO13 Gpio::G6 // A24 -#define H144_IN_CRANK GPIOB_1 +#define H144_IN_CRANK Gpio::B1 // A19 -#define H144_IN_CAM GPIOA_6 +#define H144_IN_CAM Gpio::A6 // DIN5 -#define H144_IN_VSS GPIOF_11 +#define H144_IN_VSS Gpio::F11 // IN_CLT AIN11 PC2 #define H144_IN_CLT EFI_ADC_12 @@ -104,13 +104,13 @@ void detectHellenBoardType(); #define H144_IN_MAP3 EFI_ADC_2 // AIN7 -#define H144_IN_RES1 GPIOF_9 +#define H144_IN_RES1 Gpio::F9 // AIN16 -#define H144_IN_RES2 GPIOF_10 +#define H144_IN_RES2 Gpio::F10 // AIN8 -#define H144_IN_RES3 GPIOF_8 +#define H144_IN_RES3 Gpio::F8 #define H144_IN_AUX1 EFI_ADC_8 @@ -123,55 +123,55 @@ void detectHellenBoardType(); #define H144_IN_AUX4 EFI_ADC_7 // A1 AIN1 no code to use ADC3 as analog -#define H144_IN_SENS1 GPIOF_3 +#define H144_IN_SENS1 Gpio::F3 // A2 AIN2 no code to use ADC3 as analog -#define H144_IN_SENS2 GPIOF_4 +#define H144_IN_SENS2 Gpio::F4 // A3 AIN3 no code to use ADC3 as analog -#define H144_IN_SENS3 GPIOF_5 +#define H144_IN_SENS3 Gpio::F5 // A4 AIN4 no code to use ADC3 as analog -#define H144_IN_SENS4 GPIOF_6 +#define H144_IN_SENS4 Gpio::F6 // IN_O2S AIN13 A13 PA0 #define H144_IN_O2S EFI_ADC_0 // IN_O2S2 AIN12 PA1 #define H144_IN_O2S2 EFI_ADC_1 -#define H144_IN_D_1 GPIOE_12 -#define H144_IN_D_2 GPIOE_13 -#define H144_IN_D_3 GPIOE_14 -#define H144_IN_D_4 GPIOE_15 +#define H144_IN_D_1 Gpio::E12 +#define H144_IN_D_2 Gpio::E13 +#define H144_IN_D_3 Gpio::E14 +#define H144_IN_D_4 Gpio::E15 // A22 -#define H144_IN_D_AUX3 GPIOC_5 +#define H144_IN_D_AUX3 Gpio::C5 // A20 AIN20 -#define H144_IN_D_AUX4 GPIOA_7 +#define H144_IN_D_AUX4 Gpio::A7 -#define H176_LS_1 GPIOG_7 -#define H176_LS_2 GPIOG_8 -#define H176_LS_3 GPIOD_11 -#define H176_LS_4 GPIOD_10 -#define H176_LS_5 GPIOD_9 -#define H176_LS_6 GPIOF_12 -#define H176_LS_7 GPIOF_13 -#define H176_LS_8 GPIOF_14 +#define H176_LS_1 Gpio::G7 +#define H176_LS_2 Gpio::G8 +#define H176_LS_3 Gpio::D11 +#define H176_LS_4 Gpio::D10 +#define H176_LS_5 Gpio::D9 +#define H176_LS_6 Gpio::F12 +#define H176_LS_7 Gpio::F13 +#define H176_LS_8 Gpio::F14 -#define H176_OUT_PWM1 GPIOD_13 -#define H176_OUT_PWM2 GPIOC_6 -#define H176_OUT_PWM3 GPIOC_7 +#define H176_OUT_PWM1 Gpio::D13 +#define H176_OUT_PWM2 Gpio::C6 +#define H176_OUT_PWM3 Gpio::C7 -#define H176_OUT_IO6 GPIOH_15 -#define H176_OUT_IO9 GPIOI_1 -#define H176_OUT_IO10 GPIOI_0 +#define H176_OUT_IO6 Gpio::H15 +#define H176_OUT_IO9 Gpio::I1 +#define H176_OUT_IO10 Gpio::I0 // same pins 144 and 176 -#define H176_CAN_RX GPIOD_0 -#define H176_CAN_TX GPIOD_1 +#define H176_CAN_RX Gpio::D0 +#define H176_CAN_TX Gpio::D1 -#define H176_IN_A16 GPIOF_10 +#define H176_IN_A16 Gpio::F10 // looks like same pins 144 and 176 -#define H_SPI2_MOSI GPIOB_15 -#define H_SPI2_MISO GPIOB_14 -#define H_SPI2_SCK GPIOB_13 -#define H_SPI2_CS GPIOB_12 +#define H_SPI2_MOSI Gpio::B15 +#define H_SPI2_MISO Gpio::B14 +#define H_SPI2_SCK Gpio::B13 +#define H_SPI2_CS Gpio::B12 diff --git a/firmware/config/boards/kinetis/board_configuration.cpp b/firmware/config/boards/kinetis/board_configuration.cpp index c2c49f625c..3f96064bf0 100644 --- a/firmware/config/boards/kinetis/board_configuration.cpp +++ b/firmware/config/boards/kinetis/board_configuration.cpp @@ -63,19 +63,19 @@ void setBoardOverrides() { engineConfiguration->clt.adcChannel = EFI_ADC_14; - engineConfiguration->triggerInputPins[0] = GPIOE_7; - engineConfiguration->triggerInputPins[1] = GPIO_UNASSIGNED; - engineConfiguration->triggerInputPins[2] = GPIO_UNASSIGNED; + engineConfiguration->triggerInputPins[0] = Gpio::E7; + engineConfiguration->triggerInputPins[1] = Gpio::Unassigned; + engineConfiguration->triggerInputPins[2] = Gpio::Unassigned; engineConfiguration->tle6240spiDevice = SPI_DEVICE_1; - engineConfiguration->tle6240_cs = GPIOB_0; + engineConfiguration->tle6240_cs = Gpio::B0; // todo: int i; for (i = 0; i < MAX_CYLINDER_COUNT; i++) - engineConfiguration->injectionPins[i] = GPIO_UNASSIGNED; + engineConfiguration->injectionPins[i] = Gpio::Unassigned; for (i = 0; i < MAX_CYLINDER_COUNT; i++) - engineConfiguration->ignitionPins[i] = GPIO_UNASSIGNED; + engineConfiguration->ignitionPins[i] = Gpio::Unassigned; engineConfiguration->adcVcc = 5.0f; engineConfiguration->analogInputDividerCoefficient = 1; @@ -88,10 +88,10 @@ void setBoardOverrides() { void setSerialConfigurationOverrides() { engineConfiguration->useSerialPort = true; - engineConfiguration->binarySerialTxPin = GPIOC_7; - engineConfiguration->binarySerialRxPin = GPIOC_6; -// engineConfiguration->consoleSerialTxPin = GPIOA_10; -// engineConfiguration->consoleSerialRxPin = GPIOA_11; + engineConfiguration->binarySerialTxPin = Gpio::C7; + engineConfiguration->binarySerialRxPin = Gpio::C6; +// engineConfiguration->consoleSerialTxPin = Gpio::A10; +// engineConfiguration->consoleSerialRxPin = Gpio::A11; engineConfiguration->tunerStudioSerialSpeed = SERIAL_SPEED; engineConfiguration->uartConsoleSerialSpeed = SERIAL_SPEED; } diff --git a/firmware/config/boards/kinetis/config/rusefi_config_kinetis.txt b/firmware/config/boards/kinetis/config/rusefi_config_kinetis.txt index 252d87298e..709ad6ab08 100644 --- a/firmware/config/boards/kinetis/config/rusefi_config_kinetis.txt +++ b/firmware/config/boards/kinetis/config/rusefi_config_kinetis.txt @@ -4,7 +4,7 @@ ! all these #defines are in priority over the "default" values in rusefi_config.txt ! see firmware/config/boards/kinetis/rusefi_hw_enums.h -#define brain_pin_e_enum "NONE", "INVALID", "PA0", "PA1", "PA2", "PA3", "PA4", "PA5", "PA6", "PA7", "PA8", "PA9", "PA10", "PA11", "PA12", "PA13", "PA14", "PA15", "PA16", "PA17", "PB0", "PB1", "PB2", "PB3", "PB4", "PB5", "PB6", "PB7", "PB8", "PB9", "PB10", "PB11", "PB12", "PB13", "PB14", "PB15", "PB16", "PB17", "PC0", "PC1", "PC2", "PC3", "PC4", "PC5", "PC6", "PC7", "PC8", "PC9", "PC10", "PC11", "PC12", "PC13", "PC14", "PC15", "PC16", "PC17", "PD0", "PD1", "PD2", "PD3", "PD4", "PD5", "PD6", "PD7", "PD8", "PD9", "PD10", "PD11", "PD12", "PD13", "PD14", "PD15", "PD16", "PD17", "PE0", "PE1", "PE2", "PE3", "PE4", "PE5", "PE6", "PE7", "PE8", "PE9", "PE10", "PE11", "PE12", "PE13", "PE14", "PE15", "PE16", "PE17", "TLE6240_1", "TLE6240_2", "TLE6240_3", "TLE6240_4", "TLE6240_5", "TLE6240_6", "TLE6240_7", "TLE6240_8", "TLE6240_9", "TLE6240_10", "TLE6240_11", "TLE6240_12", "TLE6240_13", "TLE6240_14", "TLE6240_15", "TLE6240_16" +#define Gpio_enum "NONE", "INVALID", "PA0", "PA1", "PA2", "PA3", "PA4", "PA5", "PA6", "PA7", "PA8", "PA9", "PA10", "PA11", "PA12", "PA13", "PA14", "PA15", "PA16", "PA17", "PB0", "PB1", "PB2", "PB3", "PB4", "PB5", "PB6", "PB7", "PB8", "PB9", "PB10", "PB11", "PB12", "PB13", "PB14", "PB15", "PB16", "PB17", "PC0", "PC1", "PC2", "PC3", "PC4", "PC5", "PC6", "PC7", "PC8", "PC9", "PC10", "PC11", "PC12", "PC13", "PC14", "PC15", "PC16", "PC17", "PD0", "PD1", "PD2", "PD3", "PD4", "PD5", "PD6", "PD7", "PD8", "PD9", "PD10", "PD11", "PD12", "PD13", "PD14", "PD15", "PD16", "PD17", "PE0", "PE1", "PE2", "PE3", "PE4", "PE5", "PE6", "PE7", "PE8", "PE9", "PE10", "PE11", "PE12", "PE13", "PE14", "PE15", "PE16", "PE17", "TLE6240_1", "TLE6240_2", "TLE6240_3", "TLE6240_4", "TLE6240_5", "TLE6240_6", "TLE6240_7", "TLE6240_8", "TLE6240_9", "TLE6240_10", "TLE6240_11", "TLE6240_12", "TLE6240_13", "TLE6240_14", "TLE6240_15", "TLE6240_16" ! Based on Kinetis KE1xF pinout (64-pin package) #define brain_input_pin_e_enum "NONE", "INVALID", "PA0", "PA1", "PA2", "PA3", "PA4", "PA5", "PA6", "PA7", "N/A", "N/A", "PA10", "PA11", "PA12", "PA13", "N/A", "N/A", "N/A", "N/A", "PB0", "PB1", "PB2", "PB3", "PB4", "PB5", "PB6", "PB7", "N/A", "N/A", "N/A", "N/A", "PB12", "PB13", "N/A", "N/A", "N/A", "N/A", "PC0", "PC1", "PC2", "PC3", "PC4", "PC5", "PC6", "PC7", "PC8", "PC9", "N/A", "N/A", "N/A", "N/A", "PC14", "PC15", "PC16", "PC17", "PD0", "PD1", "PD2", "PD3", "PD4", "PD5", "PD6", "PD7", "N/A", "N/A", "N/A", "N/A", "N/A", "N/A", "N/A", "PD15", "PD16", "N/A", "PE0", "PE1", "PE2", "PE3", "PE4", "PE5", "PE6", "PE7", "PE8", "PE9", "PE10", "PE11", "N/A", "N/A", "N/A", "N/A", "N/A", "N/A", "N/A", "N/A", "N/A", "N/A", "N/A", "N/A", "N/A", "N/A", "N/A", "N/A", "N/A", "N/A", "N/A", "N/A", "N/A", "N/A" diff --git a/firmware/config/boards/kinetis/efifeatures.h b/firmware/config/boards/kinetis/efifeatures.h index 2760881158..53eed157dd 100644 --- a/firmware/config/boards/kinetis/efifeatures.h +++ b/firmware/config/boards/kinetis/efifeatures.h @@ -241,11 +241,6 @@ #define EFI_SPI3_AF 3 -#define EFI_I2C_SCL_BRAIN_PIN GPIOB_6 - -#define EFI_I2C_SDA_BRAIN_PIN GPIOB_7 -#define EFI_I2C_AF 4 - /** * Patched version of ChibiOS/RT support extra details in the system error messages */ @@ -266,8 +261,8 @@ #define TS_PRIMARY_PORT UARTD2 #undef TS_SECONDARY_PORT -#define EFI_CONSOLE_TX_BRAIN_PIN GPIOA_10 -#define EFI_CONSOLE_RX_BRAIN_PIN GPIOA_11 +#define EFI_CONSOLE_TX_BRAIN_PIN Gpio::A10 +#define EFI_CONSOLE_RX_BRAIN_PIN Gpio::A11 #define EFI_CONSOLE_AF 3 #define TS_SERIAL_AF 2 @@ -283,9 +278,9 @@ //#define EFI_TRIGGER_DEBUG_BLINK TRUE //#define EFI_TRIGGER_COMP_ADAPTIVE_HYSTERESIS TRUE -#define LED_WARNING_BRAIN_PIN GPIOD_13 +#define LED_WARNING_BRAIN_PIN Gpio::D13 -#define LED_CRITICAL_ERROR_BRAIN_PIN GPIOD_14 +#define LED_CRITICAL_ERROR_BRAIN_PIN Gpio::D14 #define LED_ERROR_BRAIN_PIN_MODE DEFAULT_OUTPUT #define EFI_WARNING_LED FALSE diff --git a/firmware/config/boards/kinetis/rusefi_hw_enums.h b/firmware/config/boards/kinetis/rusefi_hw_enums.h index fa61b4f24f..48d8b2acf8 100644 --- a/firmware/config/boards/kinetis/rusefi_hw_enums.h +++ b/firmware/config/boards/kinetis/rusefi_hw_enums.h @@ -8,8 +8,6 @@ #pragma once -enum class TestCppStyleEnum : uint8_t { }; - // todo: migrate/unify with pin_output_mode_e? rename? something is messy here // this enum is currently only used for SPI pins typedef enum __attribute__ ((__packed__)) { @@ -23,104 +21,104 @@ typedef enum __attribute__ ((__packed__)) { /** * Hardware pin. This enum is platform-specific. */ -typedef enum __attribute__ ((__packed__)) { - GPIO_UNASSIGNED = 0, - GPIO_INVALID = 1, +enum class Gpio : uint8_t { + Unassigned = 0, + Invalid = 1, - GPIOA_0 = 2, - GPIOA_1 = 3, - GPIOA_2 = 4, - GPIOA_3 = 5, - GPIOA_4 = 6, - GPIOA_5 = 7, - GPIOA_6 = 8, - GPIOA_7 = 9, - GPIOA_8 = 10, - GPIOA_9 = 11, - GPIOA_10 = 12, - GPIOA_11 = 13, - GPIOA_12 = 14, - GPIOA_13 = 15, - GPIOA_14 = 16, - GPIOA_15 = 17, - GPIOA_16 = 18, - GPIOA_17 = 19, + A0 = 2, + A1 = 3, + A2 = 4, + A3 = 5, + A4 = 6, + A5 = 7, + A6 = 8, + A7 = 9, + A8 = 10, + A9 = 11, + A10 = 12, + A11 = 13, + A12 = 14, + A13 = 15, + A14 = 16, + A15 = 17, + A16 = 18, + A17 = 19, - GPIOB_0 = 20, - GPIOB_1 = 21, - GPIOB_2 = 22, - GPIOB_3 = 23, - GPIOB_4 = 24, - GPIOB_5 = 25, - GPIOB_6 = 26, - GPIOB_7 = 27, - GPIOB_8 = 28, - GPIOB_9 = 29, - GPIOB_10 = 30, - GPIOB_11 = 31, - GPIOB_12 = 32, - GPIOB_13 = 33, - GPIOB_14 = 34, - GPIOB_15 = 35, - GPIOB_16 = 36, - GPIOB_17 = 37, + B0 = 20, + B1 = 21, + B2 = 22, + B3 = 23, + B4 = 24, + B5 = 25, + B6 = 26, + B7 = 27, + B8 = 28, + B9 = 29, + B10 = 30, + B11 = 31, + B12 = 32, + B13 = 33, + B14 = 34, + B15 = 35, + B16 = 36, + B17 = 37, - GPIOC_0 = 38, - GPIOC_1 = 39, - GPIOC_2 = 40, - GPIOC_3 = 41, - GPIOC_4 = 42, - GPIOC_5 = 43, - GPIOC_6 = 44, - GPIOC_7 = 45, - GPIOC_8 = 46, - GPIOC_9 = 47, - GPIOC_10 = 48, - GPIOC_11 = 49, - GPIOC_12 = 50, - GPIOC_13 = 51, - GPIOC_14 = 52, - GPIOC_15 = 53, - GPIOC_16 = 54, - GPIOC_17 = 55, + C0 = 38, + C1 = 39, + C2 = 40, + C3 = 41, + C4 = 42, + C5 = 43, + C6 = 44, + C7 = 45, + C8 = 46, + C9 = 47, + C10 = 48, + C11 = 49, + C12 = 50, + C13 = 51, + C14 = 52, + C15 = 53, + C16 = 54, + C17 = 55, - GPIOD_0 = 56, - GPIOD_1 = 57, - GPIOD_2 = 58, - GPIOD_3 = 59, - GPIOD_4 = 60, - GPIOD_5 = 61, - GPIOD_6 = 62, - GPIOD_7 = 63, - GPIOD_8 = 64, - GPIOD_9 = 65, - GPIOD_10 = 66, - GPIOD_11 = 67, - GPIOD_12 = 68, - GPIOD_13 = 69, - GPIOD_14 = 70, - GPIOD_15 = 71, - GPIOD_16 = 72, - GPIOD_17 = 73, + D0 = 56, + D1 = 57, + D2 = 58, + D3 = 59, + D4 = 60, + D5 = 61, + D6 = 62, + D7 = 63, + D8 = 64, + D9 = 65, + D10 = 66, + D11 = 67, + D12 = 68, + D13 = 69, + D14 = 70, + D15 = 71, + D16 = 72, + D17 = 73, - GPIOE_0 = 74, - GPIOE_1 = 75, - GPIOE_2 = 76, - GPIOE_3 = 77, - GPIOE_4 = 78, - GPIOE_5 = 79, - GPIOE_6 = 80, - GPIOE_7 = 81, - GPIOE_8 = 82, - GPIOE_9 = 83, - GPIOE_10 = 84, - GPIOE_11 = 85, - GPIOE_12 = 86, - GPIOE_13 = 87, - GPIOE_14 = 88, - GPIOE_15 = 89, - GPIOE_16 = 90, - GPIOE_17 = 91, + E0 = 74, + E1 = 75, + E2 = 76, + E3 = 77, + E4 = 78, + E5 = 79, + E6 = 80, + E7 = 81, + E8 = 82, + E9 = 83, + E10 = 84, + E11 = 85, + E12 = 86, + E13 = 87, + E14 = 88, + E15 = 89, + E16 = 90, + E17 = 91, // TLE6240 pins go right after on chips TLE6240_PIN_1 = 130, @@ -140,13 +138,13 @@ typedef enum __attribute__ ((__packed__)) { TLE6240_PIN_15 = 144, TLE6240_PIN_16 = 145, -} brain_pin_e; +}; /* Plase keep updating these defines */ -#define BRAIN_PIN_ONCHIP_LAST GPIOE_17 -#define BRAIN_PIN_ONCHIP_PINS (BRAIN_PIN_ONCHIP_LAST - GPIOA_0 + 1) -#define BRAIN_PIN_LAST TLE6240_PIN_16 -#define BRAIN_PIN_TOTAL_PINS (BRAIN_PIN_LAST - GPIOA_0 + 1) +#define BRAIN_PIN_ONCHIP_LAST Gpio::E17 +#define BRAIN_PIN_ONCHIP_PINS (BRAIN_PIN_ONCHIP_LAST - Gpio::A0 + 1) +#define BRAIN_PIN_LAST Gpio::TLE6240_PIN_16 +#define BRAIN_PIN_TOTAL_PINS (BRAIN_PIN_LAST - Gpio::A0 + 1) typedef enum __attribute__ ((__packed__)) { EFI_ADC_NONE = 0, diff --git a/firmware/config/boards/microrusefi/!compile-nucleo-Manhattan.bat b/firmware/config/boards/microrusefi/!compile-nucleo-Manhattan.bat index 6a90524963..27185cfc62 100644 --- a/firmware/config/boards/microrusefi/!compile-nucleo-Manhattan.bat +++ b/firmware/config/boards/microrusefi/!compile-nucleo-Manhattan.bat @@ -5,10 +5,10 @@ set PROJECT_BOARD=microrusefi set PROJECT_CPU=ARCH_STM32F7 set VAR_DEF_ENGINE_TYPE = -DDEFAULT_ENGINE_TYPE=BMW_M73_F -set LED_CRITICAL_ERROR_BRAIN_PIN = -DLED_CRITICAL_ERROR_BRAIN_PIN=GPIOB_14 +set LED_CRITICAL_ERROR_BRAIN_PIN = -DLED_CRITICAL_ERROR_BRAIN_PIN=Gpio::B14 set EXTRA_PARAMS=-DDUMMY ^ - -DEFI_COMMUNICATION_PIN=GPIOB_7 + -DEFI_COMMUNICATION_PIN=Gpio::B7 call config/boards/common_make.bat diff --git a/firmware/config/boards/microrusefi/board.mk b/firmware/config/boards/microrusefi/board.mk index f3b3ccc059..3744f94aa2 100644 --- a/firmware/config/boards/microrusefi/board.mk +++ b/firmware/config/boards/microrusefi/board.mk @@ -13,13 +13,13 @@ else endif ifeq ($(LED_CRITICAL_ERROR_BRAIN_PIN),) - LED_CRITICAL_ERROR_BRAIN_PIN = -DLED_CRITICAL_ERROR_BRAIN_PIN=GPIOE_3 + LED_CRITICAL_ERROR_BRAIN_PIN = -DLED_CRITICAL_ERROR_BRAIN_PIN=Gpio::E3 endif # *TEMPORARY* breaking TTL thus breaking Bluetooth for microRusEFI in order to enable SPI3 for SD card # *TODO* need to give people the horrible choice between Bluetooth via TTL or SD card via SPI :( horrible choice -EFI_CONSOLE_TTL_PINS = -DEFI_CONSOLE_TX_BRAIN_PIN=GPIOB_10 -DEFI_CONSOLE_RX_BRAIN_PIN=GPIOB_11 +EFI_CONSOLE_TTL_PINS = -DEFI_CONSOLE_TX_BRAIN_PIN=Gpio::B10 -DEFI_CONSOLE_RX_BRAIN_PIN=Gpio::B11 DDEFS += -DEFI_CAN_SERIAL=TRUE diff --git a/firmware/config/boards/microrusefi/board_configuration.cpp b/firmware/config/boards/microrusefi/board_configuration.cpp index b15cf242a1..f561edfb72 100644 --- a/firmware/config/boards/microrusefi/board_configuration.cpp +++ b/firmware/config/boards/microrusefi/board_configuration.cpp @@ -22,14 +22,14 @@ #include "mre_meta.h" static void setInjectorPins() { - engineConfiguration->injectionPins[0] = TLE8888_PIN_1; - engineConfiguration->injectionPins[1] = TLE8888_PIN_2; - engineConfiguration->injectionPins[2] = TLE8888_PIN_3; - engineConfiguration->injectionPins[3] = TLE8888_PIN_4; + engineConfiguration->injectionPins[0] = Gpio::TLE8888_PIN_1; + engineConfiguration->injectionPins[1] = Gpio::TLE8888_PIN_2; + engineConfiguration->injectionPins[2] = Gpio::TLE8888_PIN_3; + engineConfiguration->injectionPins[3] = Gpio::TLE8888_PIN_4; // Disable remainder for (int i = 4; i < MAX_CYLINDER_COUNT;i++) { - engineConfiguration->injectionPins[i] = GPIO_UNASSIGNED; + engineConfiguration->injectionPins[i] = Gpio::Unassigned; } engineConfiguration->injectionPinMode = OM_DEFAULT; @@ -37,14 +37,14 @@ static void setInjectorPins() { static void setIgnitionPins() { // todo: I wonder if these are not right in light of the network rename and the +12 VP issue? - engineConfiguration->ignitionPins[0] = GPIOD_4; - engineConfiguration->ignitionPins[1] = GPIOD_3; - engineConfiguration->ignitionPins[2] = GPIOD_2; - engineConfiguration->ignitionPins[3] = GPIOD_1; + engineConfiguration->ignitionPins[0] = Gpio::D4; + engineConfiguration->ignitionPins[1] = Gpio::D3; + engineConfiguration->ignitionPins[2] = Gpio::D2; + engineConfiguration->ignitionPins[3] = Gpio::D1; // disable remainder for (int i = 4; i < MAX_CYLINDER_COUNT; i++) { - engineConfiguration->ignitionPins[i] = GPIO_UNASSIGNED; + engineConfiguration->ignitionPins[i] = Gpio::Unassigned; } engineConfiguration->ignitionPinMode = OM_DEFAULT; @@ -54,10 +54,10 @@ static void setLedPins() { #ifdef EFI_COMMUNICATION_PIN engineConfiguration->communicationLedPin = EFI_COMMUNICATION_PIN; #else - engineConfiguration->communicationLedPin = GPIOE_2; // d23 = blue + engineConfiguration->communicationLedPin = Gpio::E2; // d23 = blue #endif /* EFI_COMMUNICATION_PIN */ - engineConfiguration->runningLedPin = GPIOE_4; // d22 = green - engineConfiguration->warningLedPin = GPIOE_1; // d27 = orange or yellow + engineConfiguration->runningLedPin = Gpio::E4; // d22 = green + engineConfiguration->warningLedPin = Gpio::E1; // d27 = orange or yellow } static void setupVbatt() { @@ -86,12 +86,12 @@ static void setupTle8888() { engineConfiguration->is_enabled_spi_1 = true; // Wire up spi1 - engineConfiguration->spi1mosiPin = GPIOB_5; - engineConfiguration->spi1misoPin = GPIOB_4; - engineConfiguration->spi1sckPin = GPIOB_3; + engineConfiguration->spi1mosiPin = Gpio::B5; + engineConfiguration->spi1misoPin = Gpio::B4; + engineConfiguration->spi1sckPin = Gpio::B3; // Chip select - engineConfiguration->tle8888_cs = GPIOD_5; + engineConfiguration->tle8888_cs = Gpio::D5; // SPI device engineConfiguration->tle8888spiDevice = SPI_DEVICE_1; @@ -105,13 +105,13 @@ static void setupEtb() { // DIS - disables motor (enable low) // PWM pin - engineConfiguration->etbIo[0].controlPin = GPIOC_7; + engineConfiguration->etbIo[0].controlPin = Gpio::C7; // DIR pin - engineConfiguration->etbIo[0].directionPin1 = GPIOA_8; + engineConfiguration->etbIo[0].directionPin1 = Gpio::A8; // Disable pin - engineConfiguration->etbIo[0].disablePin = GPIOC_8; + engineConfiguration->etbIo[0].disablePin = Gpio::C8; // Unused - engineConfiguration->etbIo[0].directionPin2 = GPIO_UNASSIGNED; + engineConfiguration->etbIo[0].directionPin2 = Gpio::Unassigned; // we only have pwm/dir, no dira/dirb engineConfiguration->etb_use_two_wires = false; @@ -120,11 +120,11 @@ static void setupEtb() { static void setupDefaultSensorInputs() { // trigger inputs // tle8888 VR conditioner - engineConfiguration->triggerInputPins[0] = GPIOC_6; - engineConfiguration->triggerInputPins[1] = GPIO_UNASSIGNED; - engineConfiguration->triggerInputPins[2] = GPIO_UNASSIGNED; + engineConfiguration->triggerInputPins[0] = Gpio::C6; + engineConfiguration->triggerInputPins[1] = Gpio::Unassigned; + engineConfiguration->triggerInputPins[2] = Gpio::Unassigned; // Direct hall-only cam input - engineConfiguration->camInputs[0] = GPIOA_5; + engineConfiguration->camInputs[0] = Gpio::A5; // open question if it's great to have TPS in default TPS - the down-side is for // vehicles without TPS or for first start without TPS one would have to turn in off @@ -160,16 +160,16 @@ void setBoardConfigOverrides() { engineConfiguration->clt.config.bias_resistor = 2700; engineConfiguration->iat.config.bias_resistor = 2700; - engineConfiguration->canTxPin = GPIOB_6; - engineConfiguration->canRxPin = GPIOB_12; + engineConfiguration->canTxPin = Gpio::B6; + engineConfiguration->canRxPin = Gpio::B12; // SPI for SD card engineConfiguration->is_enabled_spi_3 = true; engineConfiguration->sdCardSpiDevice = SPI_DEVICE_3; - engineConfiguration->spi3mosiPin = GPIOC_12; - engineConfiguration->spi3misoPin = GPIOC_11; - engineConfiguration->spi3sckPin = GPIOC_10; + engineConfiguration->spi3mosiPin = Gpio::C12; + engineConfiguration->spi3misoPin = Gpio::C11; + engineConfiguration->spi3sckPin = Gpio::C10; } void setSerialConfigurationOverrides() { @@ -192,24 +192,24 @@ void setSerialConfigurationOverrides() { void setBoardDefaultConfiguration() { setInjectorPins(); setIgnitionPins(); - engineConfiguration->sdCardCsPin = GPIOB_9; + engineConfiguration->sdCardCsPin = Gpio::B9; // MRE has a special main relay control low side pin // rusEfi firmware is totally not involved with main relay control on microRusEfi board // todo: maybe even set EFI_MAIN_RELAY_CONTROL to FALSE for MRE configuration // TLE8888 half bridges (pushpull, lowside, or high-low) TLE8888_IN11 / TLE8888_OUT21 - // TLE8888_PIN_21: "35 - GP Out 1" - engineConfiguration->fuelPumpPin = TLE8888_PIN_21; + // Gpio::TLE8888_PIN_21: "35 - GP Out 1" + engineConfiguration->fuelPumpPin = Gpio::TLE8888_PIN_21; // engineConfiguration->isSdCardEnabled = true; // TLE8888 high current low side: VVT2 IN9 / OUT5 - // GPIOE_10: "3 - Lowside 2" - engineConfiguration->idle.solenoidPin = TLE8888_PIN_5; + // Gpio::E10: "3 - Lowside 2" + engineConfiguration->idle.solenoidPin = Gpio::TLE8888_PIN_5; - // TLE8888_PIN_22: "34 - GP Out 2" - engineConfiguration->fanPin = TLE8888_PIN_22; + // Gpio::TLE8888_PIN_22: "34 - GP Out 2" + engineConfiguration->fanPin = Gpio::TLE8888_PIN_22; // "required" hardware is done - set some reasonable defaults setupDefaultSensorInputs(); diff --git a/firmware/config/boards/microrusefi/connectors/J4.yaml b/firmware/config/boards/microrusefi/connectors/J4.yaml index 023d087388..3fd01710df 100644 --- a/firmware/config/boards/microrusefi/connectors/J4.yaml +++ b/firmware/config/boards/microrusefi/connectors/J4.yaml @@ -1,24 +1,24 @@ pins: - pin: 3 - id: GPIOB_8 + id: B8 class: outputs function: I2C1_SCL or CAN1_RX ts_name: AUX J2 PB8 - pin: 6 - id: GPIOB_9 + id: B9 class: outputs function: I2C1_SDA or CAN1_TX ts_name: AUX J2 PB9 - pin: 10 - id: GPIOC_12 + id: C12 class: outputs function: SPI3_MOSI or USART3_CK or UART5_TX ts_name: AUX J2 PC12 - pin: 7 - id: GPIOA_15 + id: A15 class: outputs function: SPI3_NSS (Chip Select) ts_name: AUX J2 PA15 diff --git a/firmware/config/boards/microrusefi/connectors/main.yaml b/firmware/config/boards/microrusefi/connectors/main.yaml index 7433ec36c2..ace3e6d225 100644 --- a/firmware/config/boards/microrusefi/connectors/main.yaml +++ b/firmware/config/boards/microrusefi/connectors/main.yaml @@ -57,7 +57,7 @@ pins: # TC4427 ignition outputs (5v) - pin: 9 - id: GPIOD_4 + id: D4 class: outputs color: dark blue function: Ignition 1 @@ -65,7 +65,7 @@ pins: type: ign - pin: 10 - id: GPIOD_3 + id: D3 class: outputs color: dark blue function: Ignition 2 @@ -73,7 +73,7 @@ pins: type: ign - pin: 11 - id: GPIOD_2 + id: D2 class: outputs color: dark blue function: Ignition 3 @@ -81,7 +81,7 @@ pins: type: ign - pin: 12 - id: GPIOD_1 + id: D1 class: outputs color: dark blue function: Ignition 4 @@ -89,7 +89,7 @@ pins: type: ign - pin: 13 - id: GPIOD_6 + id: D6 class: outputs color: yellow function: Alternator (see JP2 jumper note) @@ -98,7 +98,7 @@ pins: # TC4427 general purpose output (selectable 5v/12v) - pin: 14 - id: GPIOD_7 + id: D7 class: outputs color: yellow function: (see JP2 jumper note) @@ -121,7 +121,7 @@ pins: color: red right - pin: 18 - id: [GPIOA_0, EFI_ADC_0] + id: [A0, EFI_ADC_0] class: [switch_inputs, analog_inputs] color: red function: CLT sensor @@ -129,7 +129,7 @@ pins: type: at - pin: 19 - id: [GPIOC_2, EFI_ADC_12] + id: [C2, EFI_ADC_12] class: [switch_inputs, analog_inputs] color: red function: Starting from version 0.5.0 this pin can be used as 5V input for USB connection through main connector (No need to open case to access micro-USB connector) @@ -137,7 +137,7 @@ pins: type: av - pin: 20 - id: [GPIOC_3, EFI_ADC_13] + id: [C3, EFI_ADC_13] class: [switch_inputs, analog_inputs] color: red left function: Throttle position sensor (TPS) @@ -150,14 +150,14 @@ pins: color: dark green - pin: 22 - id: [GPIOA_3, GPIOA_3, EFI_ADC_3] + id: [A3, A3, EFI_ADC_3] class: [event_inputs, switch_inputs, analog_inputs] color: dark green ts_name: 22 - AN temp 4 type: at - pin: 23 - id: [GPIOA_1, EFI_ADC_1] + id: [A1, EFI_ADC_1] class: [switch_inputs, analog_inputs] color: dark green function: IAT sensor @@ -165,7 +165,7 @@ pins: type: at - pin: 24 - id: [GPIOA_2, GPIOA_2, EFI_ADC_2] + id: [A2, A2, EFI_ADC_2] class: [event_inputs, switch_inputs, analog_inputs] color: dark green ts_name: 24 - AN temp 3 @@ -173,21 +173,21 @@ pins: # RC filter input for hall - pin: 25 - id: [GPIOA_5, GPIOA_5] + id: [A5, A5] class: [event_inputs, switch_inputs] color: light blue right ts_name: 25 - Hall Cam type: hall - pin: 26 - id: [GPIOA_6, EFI_ADC_6] + id: [A6, EFI_ADC_6] class: [switch_inputs, analog_inputs] color: light blue ts_name: 26 - AN volt 2 type: av - pin: 27 - id: [GPIOC_0, EFI_ADC_10] + id: [C0, EFI_ADC_10] class: [switch_inputs, analog_inputs] color: light blue function: MAP sensor @@ -195,22 +195,22 @@ pins: type: av - pin: 28 - id: [GPIOA_4, GPIOA_4, EFI_ADC_4] + id: [A4, A4, EFI_ADC_4] class: [outputs, switch_inputs, analog_inputs] color: light blue left function: AN volt 10, for aux see R85 ts_name: 28 - AN volt 10, Aux Reuse type: av - - id: GPIOE_0 + - id: E0 class: outputs ts_name: AUX J6 - - id: GPIOB_11 + - id: B11 class: outputs ts_name: AUX J12 - - id: GPIOB_10 + - id: B10 class: outputs ts_name: AUX J13 @@ -220,14 +220,14 @@ pins: color: pink right - pin: 30 - id: [GPIOC_5, EFI_ADC_15] + id: [C5, EFI_ADC_15] class: [switch_inputs, analog_inputs] color: pink ts_name: 30 - AN volt 7 type: av - pin: 31 - id: [GPIOA_7, EFI_ADC_7] + id: [A7, EFI_ADC_7] class: [switch_inputs, analog_inputs] color: pink function: Throttle Pedal Position Sensor (PPS) @@ -235,7 +235,7 @@ pins: type: av - pin: 32 - id: [GPIOC_4, GPIOC_4, EFI_ADC_14] + id: [C4, C4, EFI_ADC_14] class: [outputs, switch_inputs, analog_inputs] color: pink function: External wideband O2 sensor WBO AFR EGO, for aux see R86 @@ -270,7 +270,7 @@ pins: type: [gp_low, gp_pp] - pin: 36 - id: [GPIOB_0, GPIOB_0, EFI_ADC_8] + id: [B0, B0, EFI_ADC_8] class: [outputs, switch_inputs, analog_inputs] color: orange left function: AN volt 8, for aux see R84 @@ -299,7 +299,7 @@ pins: color: grey - pin: 40 - id: [GPIOB_1, GPIOB_1, EFI_ADC_9] + id: [B1, B1, EFI_ADC_9] class: [outputs, switch_inputs, analog_inputs] color: grey function: AN volt 9, for aux see R30 @@ -337,7 +337,7 @@ pins: color: brown left - pin: 45 - id: GPIOC_6 + id: C6 class: event_inputs color: light green right function: Crank VR+/hall diff --git a/firmware/config/boards/microrusefi/connectors/pads.yaml b/firmware/config/boards/microrusefi/connectors/pads.yaml index 34ad95b97f..169b36121c 100644 --- a/firmware/config/boards/microrusefi/connectors/pads.yaml +++ b/firmware/config/boards/microrusefi/connectors/pads.yaml @@ -1,19 +1,19 @@ pins: - pin: J10 - id: GPIOE_6 + id: E6 class: outputs function: TIM9_CH2 ts_name: AUX J10 PE6 - pin: J11 - id: GPIOE_5 + id: E5 class: outputs function: TIM9_CH1 ts_name: AUX J11 PE5 - pin: J18 - id: GPIOB_7 + id: B7 class: outputs ts_name: AUX J18 PB7 diff --git a/firmware/config/boards/microrusefi/knock_config.h b/firmware/config/boards/microrusefi/knock_config.h index 6bd14abfee..73e5185d56 100644 --- a/firmware/config/boards/microrusefi/knock_config.h +++ b/firmware/config/boards/microrusefi/knock_config.h @@ -9,7 +9,7 @@ // knock 1 - pin PA3 #define KNOCK_ADC_CH1 ADC_CHANNEL_IN3 -#define KNOCK_PIN_CH1 GPIOA_3 +#define KNOCK_PIN_CH1 Gpio::A3 // Sample rate & time - depends on the exact MCU #define KNOCK_SAMPLE_TIME ADC_SAMPLE_84 diff --git a/firmware/config/boards/mre_meta.h b/firmware/config/boards/mre_meta.h index b5a79d5874..388a287cbe 100644 --- a/firmware/config/boards/mre_meta.h +++ b/firmware/config/boards/mre_meta.h @@ -8,7 +8,7 @@ #pragma once // OpenDrain: 4.5A -#define MRE_LS_1 TLE8888_PIN_6 +#define MRE_LS_1 Gpio::TLE8888_PIN_6 // clt = "18 - AN temp 1" // R27 pull-up diff --git a/firmware/config/boards/nucleo_f767/board_configuration.cpp b/firmware/config/boards/nucleo_f767/board_configuration.cpp index 6b755e7032..314df12748 100644 --- a/firmware/config/boards/nucleo_f767/board_configuration.cpp +++ b/firmware/config/boards/nucleo_f767/board_configuration.cpp @@ -15,10 +15,10 @@ void setSerialConfigurationOverrides() { engineConfiguration->useSerialPort = true; - engineConfiguration->binarySerialTxPin = GPIOD_8; - engineConfiguration->binarySerialRxPin = GPIOD_9; -// engineConfiguration->consoleSerialTxPin = GPIOD_8; -// engineConfiguration->consoleSerialRxPin = GPIOD_9; + engineConfiguration->binarySerialTxPin = Gpio::D8; + engineConfiguration->binarySerialRxPin = Gpio::D9; +// engineConfiguration->consoleSerialTxPin = Gpio::D8; +// engineConfiguration->consoleSerialRxPin = Gpio::D9; engineConfiguration->tunerStudioSerialSpeed = SERIAL_SPEED; engineConfiguration->uartConsoleSerialSpeed = SERIAL_SPEED; } @@ -33,8 +33,8 @@ void setSdCardConfigurationOverrides() { void setBoardDefaultConfiguration() { setSerialConfigurationOverrides(); - engineConfiguration->runningLedPin = GPIOB_0; //green LED - engineConfiguration->warningLedPin = GPIO_UNASSIGNED; + engineConfiguration->runningLedPin = Gpio::B0; //green LED + engineConfiguration->warningLedPin = Gpio::Unassigned; #if 0 engineConfiguration->vbattAdcChannel = EFI_ADC_13; engineConfiguration->adcVcc = ADC_VCC; @@ -44,13 +44,13 @@ void setBoardDefaultConfiguration() { // not used for (int i = 0; i < DIGIPOT_COUNT ; i++) { - engineConfiguration->digitalPotentiometerChipSelect[i] = GPIO_UNASSIGNED; + engineConfiguration->digitalPotentiometerChipSelect[i] = Gpio::Unassigned; } - engineConfiguration->triggerSimulatorPins[1] = GPIO_UNASSIGNED; - engineConfiguration->triggerSimulatorPins[2] = GPIO_UNASSIGNED; + engineConfiguration->triggerSimulatorPins[1] = Gpio::Unassigned; + engineConfiguration->triggerSimulatorPins[2] = Gpio::Unassigned; engineConfiguration->triggerSimulatorPinModes[1] = OM_DEFAULT; engineConfiguration->triggerSimulatorPinModes[2] = OM_DEFAULT; - engineConfiguration->vehicleSpeedSensorInputPin = GPIO_UNASSIGNED; + engineConfiguration->vehicleSpeedSensorInputPin = Gpio::Unassigned; ///////////////////////////////////////////////////////// engineConfiguration->is_enabled_spi_1 = false; diff --git a/firmware/config/boards/nucleo_f767/compile_stm32f767_nucleo.sh b/firmware/config/boards/nucleo_f767/compile_stm32f767_nucleo.sh index e65456ba31..8622148aeb 100644 --- a/firmware/config/boards/nucleo_f767/compile_stm32f767_nucleo.sh +++ b/firmware/config/boards/nucleo_f767/compile_stm32f767_nucleo.sh @@ -6,10 +6,10 @@ SCRIPT_NAME="compile_nucleo_f767.sh" echo "Entering $SCRIPT_NAME" export EXTRA_PARAMS="-DDUMMY -DSTM32F767xx \ - -DEFI_INJECTOR_PIN3=GPIO_UNASSIGNED \ + -DEFI_INJECTOR_PIN3=Gpio::Unassigned \ -DFIRMWARE_ID=\\\"nucleo767\\\" \ - -DEFI_COMMUNICATION_PIN=GPIOB_7 \ - -DLED_CRITICAL_ERROR_BRAIN_PIN=GPIOB_14 \ + -DEFI_COMMUNICATION_PIN=Gpio::B7 \ + -DLED_CRITICAL_ERROR_BRAIN_PIN=Gpio::B14 \ -DEFI_ENABLE_ASSERTS=FALSE \ -DCH_DBG_ENABLE_CHECKS=FALSE -DCH_DBG_ENABLE_ASSERTS=FALSE -DCH_DBG_ENABLE_STACK_CHECK=FALSE -DCH_DBG_FILL_THREADS=FALSE -DCH_DBG_THREADS_PROFILING=FALSE" export DEBUG_LEVEL_OPT="-O2" diff --git a/firmware/config/boards/nucleo_f767/compile_stm32f767_osc.sh b/firmware/config/boards/nucleo_f767/compile_stm32f767_osc.sh index 782178e23c..5ba6d4657c 100644 --- a/firmware/config/boards/nucleo_f767/compile_stm32f767_osc.sh +++ b/firmware/config/boards/nucleo_f767/compile_stm32f767_osc.sh @@ -3,10 +3,10 @@ # STM32F767 version of the firmware for F767ZI chip NOT on Nucleo board, with a real oscilattor export EXTRA_PARAMS="-DDUMMY -DSTM32F767xx \ - -DEFI_INJECTOR_PIN3=GPIO_UNASSIGNED \ + -DEFI_INJECTOR_PIN3=Gpio::Unassigned \ -DFIRMWARE_ID=\\\"board767\\\" \ - -DEFI_COMMUNICATION_PIN=GPIOB_7 \ - -DLED_CRITICAL_ERROR_BRAIN_PIN=GPIOB_14 \ + -DEFI_COMMUNICATION_PIN=Gpio::B7 \ + -DLED_CRITICAL_ERROR_BRAIN_PIN=Gpio::B14 \ -DEFI_ENABLE_ASSERTS=FALSE \ -DEFI_USE_OSC=TRUE \ -DCH_DBG_ENABLE_CHECKS=FALSE -DCH_DBG_ENABLE_ASSERTS=FALSE -DCH_DBG_ENABLE_STACK_CHECK=FALSE -DCH_DBG_FILL_THREADS=FALSE -DCH_DBG_THREADS_PROFILING=FALSE" diff --git a/firmware/config/boards/nucleo_h743/board.mk b/firmware/config/boards/nucleo_h743/board.mk index 43bd250c57..c76a19b839 100644 --- a/firmware/config/boards/nucleo_h743/board.mk +++ b/firmware/config/boards/nucleo_h743/board.mk @@ -2,8 +2,8 @@ DDEFS = -DTS_NO_PRIMARY=0 \ -DTS_PRIMARY_PORT=SD3 \ - -DEFI_CONSOLE_TX_BRAIN_PIN=GPIOD_8 \ - -DEFI_CONSOLE_RX_BRAIN_PIN=GPIOD_9 \ + -DEFI_CONSOLE_TX_BRAIN_PIN=Gpio::D8 \ + -DEFI_CONSOLE_RX_BRAIN_PIN=Gpio::D9 \ # Shared variables diff --git a/firmware/config/boards/nucleo_h743/compile_stm32h743_nucleo.sh b/firmware/config/boards/nucleo_h743/compile_stm32h743_nucleo.sh index c1f2fe0042..ed74884890 100644 --- a/firmware/config/boards/nucleo_h743/compile_stm32h743_nucleo.sh +++ b/firmware/config/boards/nucleo_h743/compile_stm32h743_nucleo.sh @@ -6,10 +6,10 @@ SCRIPT_NAME="compile_nucleo_h743.sh" echo "Entering $SCRIPT_NAME" export EXTRA_PARAMS="-DDUMMY \ - -DEFI_INJECTOR_PIN3=GPIO_UNASSIGNED \ + -DEFI_INJECTOR_PIN3=Gpio::Unassigned \ -DFIRMWARE_ID=\\\"nucleoH743\\\" \ - -DEFI_COMMUNICATION_PIN=GPIOB_7 \ - -DLED_CRITICAL_ERROR_BRAIN_PIN=GPIOB_14" + -DEFI_COMMUNICATION_PIN=Gpio::B7 \ + -DLED_CRITICAL_ERROR_BRAIN_PIN=Gpio::B14" export DEBUG_LEVEL_OPT="-O2" bash ../common_make.sh nucleo_h743 ARCH_STM32H7 diff --git a/firmware/config/boards/prometheus/board_configuration.cpp b/firmware/config/boards/prometheus/board_configuration.cpp index b90af4154e..650e7b5c80 100644 --- a/firmware/config/boards/prometheus/board_configuration.cpp +++ b/firmware/config/boards/prometheus/board_configuration.cpp @@ -58,15 +58,15 @@ static void setPrometheusDefaults() { void setPinConfigurationOverrides() { #if 0 - engineConfiguration->injectionPins[0] = is469 ? GPIOD_9 : GPIOB_14; // #1 - engineConfiguration->injectionPins[1] = is469 ? GPIOD_15 : GPIOC_7; // #2 - engineConfiguration->injectionPins[2] = is469 ? GPIOD_10 : GPIOB_15; // #3 - engineConfiguration->injectionPins[3] = is469 ? GPIOD_14 : GPIOC_6; // #4 + engineConfiguration->injectionPins[0] = is469 ? Gpio::D9 : Gpio::B14; // #1 + engineConfiguration->injectionPins[1] = is469 ? Gpio::D15 : Gpio::C7; // #2 + engineConfiguration->injectionPins[2] = is469 ? Gpio::D10 : Gpio::B15; // #3 + engineConfiguration->injectionPins[3] = is469 ? Gpio::D14 : Gpio::C6; // #4 - engineConfiguration->ignitionPins[0] = GPIOA_10; - engineConfiguration->ignitionPins[1] = GPIOA_9; - engineConfiguration->ignitionPins[2] = GPIOA_8; - engineConfiguration->ignitionPins[3] = GPIOA_11; + engineConfiguration->ignitionPins[0] = Gpio::A10; + engineConfiguration->ignitionPins[1] = Gpio::A9; + engineConfiguration->ignitionPins[2] = Gpio::A8; + engineConfiguration->ignitionPins[3] = Gpio::A11; engineConfiguration->ignitionPinMode = OM_INVERTED; enginePins.startInjectionPins(); @@ -99,10 +99,10 @@ void setPinConfigurationOverrides() { void setSerialConfigurationOverrides() { engineConfiguration->useSerialPort = true; - engineConfiguration->binarySerialTxPin = GPIOA_0; - engineConfiguration->binarySerialRxPin = GPIOA_1; -// engineConfiguration->consoleSerialTxPin = GPIOA_0; -// engineConfiguration->consoleSerialRxPin = GPIOA_1; + engineConfiguration->binarySerialTxPin = Gpio::A0; + engineConfiguration->binarySerialRxPin = Gpio::A1; +// engineConfiguration->consoleSerialTxPin = Gpio::A0; +// engineConfiguration->consoleSerialRxPin = Gpio::A1; engineConfiguration->tunerStudioSerialSpeed = SERIAL_SPEED; engineConfiguration->uartConsoleSerialSpeed = SERIAL_SPEED; } @@ -110,7 +110,7 @@ void setSerialConfigurationOverrides() { void setSdCardConfigurationOverrides() { engineConfiguration->is_enabled_spi_1 = true; engineConfiguration->sdCardSpiDevice = SPI_DEVICE_1; - engineConfiguration->sdCardCsPin = GPIOA_2; + engineConfiguration->sdCardCsPin = Gpio::A2; engineConfiguration->isSdCardEnabled = true; } @@ -137,15 +137,15 @@ void setBoardDefaultConfiguration() { engineConfiguration->baroSensor.hwChannel = EFI_ADC_NONE; engineConfiguration->throttlePedalPositionAdcChannel = EFI_ADC_NONE; - engineConfiguration->injectionPins[0] = is469 ? GPIOD_9 : GPIOB_14; // #1 - engineConfiguration->injectionPins[1] = is469 ? GPIOD_15 : GPIOC_7; // #2 - engineConfiguration->injectionPins[2] = is469 ? GPIOD_10 : GPIOB_15; // #3 - engineConfiguration->injectionPins[3] = is469 ? GPIOD_14 : GPIOC_6; // #4 + engineConfiguration->injectionPins[0] = is469 ? Gpio::D9 : Gpio::B14; // #1 + engineConfiguration->injectionPins[1] = is469 ? Gpio::D15 : Gpio::C7; // #2 + engineConfiguration->injectionPins[2] = is469 ? Gpio::D10 : Gpio::B15; // #3 + engineConfiguration->injectionPins[3] = is469 ? Gpio::D14 : Gpio::C6; // #4 - engineConfiguration->ignitionPins[0] = GPIOA_10; - engineConfiguration->ignitionPins[1] = GPIOA_9; - engineConfiguration->ignitionPins[2] = GPIOA_8; - engineConfiguration->ignitionPins[3] = GPIOA_11; + engineConfiguration->ignitionPins[0] = Gpio::A10; + engineConfiguration->ignitionPins[1] = Gpio::A9; + engineConfiguration->ignitionPins[2] = Gpio::A8; + engineConfiguration->ignitionPins[3] = Gpio::A11; engineConfiguration->ignitionPinMode = OM_INVERTED; engineConfiguration->vbattDividerCoeff = ((float) (2 + 10)) / 2; @@ -153,53 +153,53 @@ void setBoardDefaultConfiguration() { engineConfiguration->iat.config.bias_resistor = 2700; engineConfiguration->useStepperIdle = true; - engineConfiguration->idle.stepperDirectionPin = is469 ? GPIOB_14 : GPIOB_12; - engineConfiguration->idle.stepperStepPin = is469 ? GPIOB_15 : GPIOB_13; - engineConfiguration->stepperEnablePin = GPIO_UNASSIGNED; + engineConfiguration->idle.stepperDirectionPin = is469 ? Gpio::B14 : Gpio::B12; + engineConfiguration->idle.stepperStepPin = is469 ? Gpio::B15 : Gpio::B13; + engineConfiguration->stepperEnablePin = Gpio::Unassigned; engineConfiguration->stepperEnablePinMode = OM_DEFAULT; - engineConfiguration->communicationLedPin = GPIO_UNASSIGNED;// GPIOA_13; // yellow LED - engineConfiguration->runningLedPin = GPIOA_13; //GPIOA_13; // yellow LED - engineConfiguration->warningLedPin = GPIO_UNASSIGNED; + engineConfiguration->communicationLedPin = Gpio::Unassigned;// Gpio::A13; // yellow LED + engineConfiguration->runningLedPin = Gpio::A13; //Gpio::A13; // yellow LED + engineConfiguration->warningLedPin = Gpio::Unassigned; - engineConfiguration->triggerInputPins[0] = GPIOA_5; - engineConfiguration->triggerInputPins[1] = GPIO_UNASSIGNED; - engineConfiguration->triggerInputPins[2] = GPIO_UNASSIGNED; - engineConfiguration->camInputs[0] = is469 ? GPIOE_9 : GPIOA_6; + engineConfiguration->triggerInputPins[0] = Gpio::A5; + engineConfiguration->triggerInputPins[1] = Gpio::Unassigned; + engineConfiguration->triggerInputPins[2] = Gpio::Unassigned; + engineConfiguration->camInputs[0] = is469 ? Gpio::E9 : Gpio::A6; - engineConfiguration->tachOutputPin = GPIOC_8; + engineConfiguration->tachOutputPin = Gpio::C8; engineConfiguration->tachOutputPinMode = OM_DEFAULT; - engineConfiguration->fuelPumpPin = is469 ? GPIOD_6 : GPIOB_7; + engineConfiguration->fuelPumpPin = is469 ? Gpio::D6 : Gpio::B7; engineConfiguration->fuelPumpPinMode = OM_DEFAULT; - engineConfiguration->mainRelayPin = is469 ? GPIOB_11 : GPIOB_2; + engineConfiguration->mainRelayPin = is469 ? Gpio::B11 : Gpio::B2; engineConfiguration->mainRelayPinMode = OM_DEFAULT; - engineConfiguration->fanPin = GPIOC_9; + engineConfiguration->fanPin = Gpio::C9; engineConfiguration->fanPinMode = OM_DEFAULT; - engineConfiguration->malfunctionIndicatorPin = GPIOC_1; + engineConfiguration->malfunctionIndicatorPin = Gpio::C1; engineConfiguration->malfunctionIndicatorPinMode = OM_DEFAULT; // debug pad - engineConfiguration->triggerSimulatorPins[0] = GPIOD_8; + engineConfiguration->triggerSimulatorPins[0] = Gpio::D8; engineConfiguration->triggerSimulatorPinModes[0] = OM_DEFAULT; // not used engineConfiguration->displayMode = DM_NONE; - engineConfiguration->HD44780_rs = GPIO_UNASSIGNED; - engineConfiguration->HD44780_e = GPIO_UNASSIGNED; - engineConfiguration->HD44780_db4 = GPIO_UNASSIGNED; - engineConfiguration->HD44780_db5 = GPIO_UNASSIGNED; - engineConfiguration->HD44780_db6 = GPIO_UNASSIGNED; - engineConfiguration->HD44780_db7 = GPIO_UNASSIGNED; + engineConfiguration->HD44780_rs = Gpio::Unassigned; + engineConfiguration->HD44780_e = Gpio::Unassigned; + engineConfiguration->HD44780_db4 = Gpio::Unassigned; + engineConfiguration->HD44780_db5 = Gpio::Unassigned; + engineConfiguration->HD44780_db6 = Gpio::Unassigned; + engineConfiguration->HD44780_db7 = Gpio::Unassigned; for (int i = 0; i < DIGIPOT_COUNT ; i++) { - engineConfiguration->digitalPotentiometerChipSelect[i] = GPIO_UNASSIGNED; + engineConfiguration->digitalPotentiometerChipSelect[i] = Gpio::Unassigned; } - engineConfiguration->triggerSimulatorPins[1] = GPIO_UNASSIGNED; - engineConfiguration->triggerSimulatorPins[2] = GPIO_UNASSIGNED; + engineConfiguration->triggerSimulatorPins[1] = Gpio::Unassigned; + engineConfiguration->triggerSimulatorPins[2] = Gpio::Unassigned; engineConfiguration->triggerSimulatorPinModes[1] = OM_DEFAULT; engineConfiguration->triggerSimulatorPinModes[2] = OM_DEFAULT; - engineConfiguration->vehicleSpeedSensorInputPin = GPIO_UNASSIGNED; + engineConfiguration->vehicleSpeedSensorInputPin = Gpio::Unassigned; ///////////////////////////////////////////////////////// @@ -207,24 +207,24 @@ void setBoardDefaultConfiguration() { engineConfiguration->is_enabled_spi_2 = false; engineConfiguration->is_enabled_spi_3 = true; - engineConfiguration->spi1mosiPin = GPIOB_5; + engineConfiguration->spi1mosiPin = Gpio::B5; engineConfiguration->spi1MosiMode = PO_DEFAULT; // PAL_STM32_OTYPE_PUSHPULL - engineConfiguration->spi1misoPin = GPIOB_4; + engineConfiguration->spi1misoPin = Gpio::B4; engineConfiguration->spi1MisoMode = PO_DEFAULT; // PAL_STM32_OTYPE_PUSHPULL - engineConfiguration->spi1sckPin = GPIOB_3; + engineConfiguration->spi1sckPin = Gpio::B3; engineConfiguration->spi1SckMode = PO_DEFAULT; // PAL_STM32_OTYPE_PUSHPULL - engineConfiguration->spi3mosiPin = GPIOC_12; + engineConfiguration->spi3mosiPin = Gpio::C12; engineConfiguration->spi3MosiMode = PO_OPENDRAIN; // 4 - engineConfiguration->spi3misoPin = GPIOC_11; + engineConfiguration->spi3misoPin = Gpio::C11; engineConfiguration->spi3MisoMode = PO_PULLUP; // 32 - engineConfiguration->spi3sckPin = GPIOC_10; + engineConfiguration->spi3sckPin = Gpio::C10; engineConfiguration->spi3SckMode = PO_OPENDRAIN; // 4 engineConfiguration->hip9011SpiDevice = SPI_DEVICE_3; - engineConfiguration->hip9011CsPin = is469 ? GPIOD_1 : GPIOD_2; + engineConfiguration->hip9011CsPin = is469 ? Gpio::D1 : Gpio::D2; engineConfiguration->hip9011CsPinMode = OM_OPENDRAIN; - engineConfiguration->hip9011IntHoldPin = GPIOC_14; + engineConfiguration->hip9011IntHoldPin = Gpio::C14; engineConfiguration->hip9011IntHoldPinMode = OM_OPENDRAIN; engineConfiguration->hipOutputChannel = EFI_ADC_10; // PC0 engineConfiguration->isHip9011Enabled = true; @@ -232,15 +232,15 @@ void setBoardDefaultConfiguration() { engineConfiguration->cj125SpiDevice = SPI_DEVICE_3; engineConfiguration->cj125ua = is469 ? EFI_ADC_9 : EFI_ADC_8; engineConfiguration->cj125ur = EFI_ADC_12; - engineConfiguration->cj125CsPin = GPIOA_15; + engineConfiguration->cj125CsPin = Gpio::A15; engineConfiguration->cj125CsPinMode = OM_OPENDRAIN; - engineConfiguration->wboHeaterPin = GPIOC_13; - engineConfiguration->o2heaterPin = GPIOC_13; + engineConfiguration->wboHeaterPin = Gpio::C13; + engineConfiguration->o2heaterPin = Gpio::C13; //engineConfiguration->isCJ125Enabled = true; engineConfiguration->isCJ125Enabled = false; - engineConfiguration->canTxPin = GPIOB_9; - engineConfiguration->canRxPin = GPIOB_8; + engineConfiguration->canTxPin = Gpio::B9; + engineConfiguration->canRxPin = Gpio::B8; //!!!!!!!!!!!!!!! #if 1 diff --git a/firmware/config/boards/prometheus/efifeatures.h b/firmware/config/boards/prometheus/efifeatures.h index 022ed5ce6d..1f69220a3b 100644 --- a/firmware/config/boards/prometheus/efifeatures.h +++ b/firmware/config/boards/prometheus/efifeatures.h @@ -66,10 +66,10 @@ #undef EFI_CONSOLE_TX_BRAIN_PIN -#define EFI_CONSOLE_TX_BRAIN_PIN GPIOA_0 +#define EFI_CONSOLE_TX_BRAIN_PIN Gpio::A0 #undef EFI_CONSOLE_RX_BRAIN_PIN -#define EFI_CONSOLE_RX_BRAIN_PIN GPIOA_1 +#define EFI_CONSOLE_RX_BRAIN_PIN Gpio::A1 #undef EFI_CONSOLE_AF #define EFI_CONSOLE_AF 8 @@ -78,7 +78,7 @@ #define TS_SERIAL_AF 8 #undef LED_CRITICAL_ERROR_BRAIN_PIN -#define LED_CRITICAL_ERROR_BRAIN_PIN GPIOA_13 +#define LED_CRITICAL_ERROR_BRAIN_PIN Gpio::A13 #undef LED_ERROR_BRAIN_PIN_MODE #define LED_ERROR_BRAIN_PIN_MODE DEFAULT_OUTPUT diff --git a/firmware/config/boards/proteus/adc_hack.cpp b/firmware/config/boards/proteus/adc_hack.cpp index 9c4413e5f6..5fca76e5e3 100644 --- a/firmware/config/boards/proteus/adc_hack.cpp +++ b/firmware/config/boards/proteus/adc_hack.cpp @@ -28,7 +28,7 @@ static NO_CACHE adcsample_t samples[8]; // we use this as a hook to run near the rest of ADC init... void setAdcChannelOverrides() { - efiSetPadMode("adc input", GPIOF_3, PAL_MODE_INPUT_ANALOG); + efiSetPadMode("adc input", Gpio::F3, PAL_MODE_INPUT_ANALOG); adcStart(&ADCD3, nullptr); } diff --git a/firmware/config/boards/proteus/board.mk b/firmware/config/boards/proteus/board.mk index d972cb3da0..9237f81448 100644 --- a/firmware/config/boards/proteus/board.mk +++ b/firmware/config/boards/proteus/board.mk @@ -9,7 +9,7 @@ ifeq ($(PROJECT_CPU),ARCH_STM32F4) endif DDEFS += -DEFI_USE_OSC=TRUE -DDEFS += -DLED_CRITICAL_ERROR_BRAIN_PIN=GPIOE_3 +DDEFS += -DLED_CRITICAL_ERROR_BRAIN_PIN=Gpio::E3 DDEFS += -DFIRMWARE_ID=\"proteus\" DDEFS += -DEFI_MAIN_RELAY_CONTROL=TRUE @@ -33,7 +33,7 @@ ifeq ($(PROJECT_CPU),ARCH_STM32F4) # Hardware serial port on UART 2 -> PD5/PD6 DDEFS += -DSTM32_UART_USE_USART2=TRUE DDEFS += -DTS_PRIMARY_PORT=UARTD2 - DDEFS += -DEFI_CONSOLE_TX_BRAIN_PIN=GPIOD_5 -DEFI_CONSOLE_RX_BRAIN_PIN=GPIOD_6 + DDEFS += -DEFI_CONSOLE_TX_BRAIN_PIN=Gpio::D5 -DEFI_CONSOLE_RX_BRAIN_PIN=Gpio::D6 endif # We are running on Proteus hardware! diff --git a/firmware/config/boards/proteus/board_configuration.cpp b/firmware/config/boards/proteus/board_configuration.cpp index 349da49f9c..589ecda70c 100644 --- a/firmware/config/boards/proteus/board_configuration.cpp +++ b/firmware/config/boards/proteus/board_configuration.cpp @@ -54,9 +54,9 @@ void setSdCardConfigurationOverrides() { static void setLedPins() { // PE3 is error LED, configured in board.mk - engineConfiguration->communicationLedPin = GPIOE_4; - engineConfiguration->runningLedPin = GPIOE_5; - engineConfiguration->warningLedPin = GPIOE_6; + engineConfiguration->communicationLedPin = Gpio::E4; + engineConfiguration->runningLedPin = Gpio::E5; + engineConfiguration->warningLedPin = Gpio::E6; } static void setupVbatt() { @@ -81,23 +81,23 @@ static void setupEtb() { // Throttle #1 // PWM pin - engineConfiguration->etbIo[0].controlPin = GPIOD_12; + engineConfiguration->etbIo[0].controlPin = Gpio::D12; // DIR pin - engineConfiguration->etbIo[0].directionPin1 = GPIOD_10; + engineConfiguration->etbIo[0].directionPin1 = Gpio::D10; // Disable pin - engineConfiguration->etbIo[0].disablePin = GPIOD_11; + engineConfiguration->etbIo[0].disablePin = Gpio::D11; // Unused - engineConfiguration->etbIo[0].directionPin2 = GPIO_UNASSIGNED; + engineConfiguration->etbIo[0].directionPin2 = Gpio::Unassigned; // Throttle #2 // PWM pin - engineConfiguration->etbIo[1].controlPin = GPIOD_13; + engineConfiguration->etbIo[1].controlPin = Gpio::D13; // DIR pin - engineConfiguration->etbIo[1].directionPin1 = GPIOD_9; + engineConfiguration->etbIo[1].directionPin1 = Gpio::D9; // Disable pin - engineConfiguration->etbIo[1].disablePin = GPIOD_8; + engineConfiguration->etbIo[1].disablePin = Gpio::D8; // Unused - engineConfiguration->etbIo[1].directionPin2 = GPIO_UNASSIGNED; + engineConfiguration->etbIo[1].directionPin2 = Gpio::Unassigned; // we only have pwm/dir, no dira/dirb engineConfiguration->etb_use_two_wires = false; @@ -112,11 +112,11 @@ static void setupDefaultSensorInputs() { #else // Digital channel 1 as default - others not set engineConfiguration->triggerInputPins[0] = PROTEUS_DIGITAL_1; - engineConfiguration->camInputs[0] = GPIO_UNASSIGNED; + engineConfiguration->camInputs[0] = Gpio::Unassigned; #endif - engineConfiguration->triggerInputPins[1] = GPIO_UNASSIGNED; - engineConfiguration->triggerInputPins[2] = GPIO_UNASSIGNED; + engineConfiguration->triggerInputPins[1] = Gpio::Unassigned; + engineConfiguration->triggerInputPins[2] = Gpio::Unassigned; engineConfiguration->clt.adcChannel = PROTEUS_IN_CLT; @@ -131,12 +131,12 @@ static void setupDefaultSensorInputs() { static void setupSdCard() { engineConfiguration->sdCardSpiDevice = SPI_DEVICE_3; - engineConfiguration->sdCardCsPin = GPIOD_2; + engineConfiguration->sdCardCsPin = Gpio::D2; engineConfiguration->is_enabled_spi_3 = true; - engineConfiguration->spi3sckPin = GPIOC_10; - engineConfiguration->spi3misoPin = GPIOC_11; - engineConfiguration->spi3mosiPin = GPIOC_12; + engineConfiguration->spi3sckPin = Gpio::C10; + engineConfiguration->spi3misoPin = Gpio::C11; + engineConfiguration->spi3mosiPin = Gpio::C12; } void setBoardConfigOverrides() { @@ -147,16 +147,16 @@ void setBoardConfigOverrides() { engineConfiguration->clt.config.bias_resistor = 2700; engineConfiguration->iat.config.bias_resistor = 2700; - engineConfiguration->canTxPin = GPIOD_1; - engineConfiguration->canRxPin = GPIOD_0; + engineConfiguration->canTxPin = Gpio::D1; + engineConfiguration->canRxPin = Gpio::D0; #if defined(STM32F4) || defined(STM32F7) - engineConfiguration->can2RxPin = GPIOB_12; - engineConfiguration->can2TxPin = GPIOB_13; + engineConfiguration->can2RxPin = Gpio::B12; + engineConfiguration->can2TxPin = Gpio::B13; #endif - engineConfiguration->lps25BaroSensorScl = GPIOB_10; - engineConfiguration->lps25BaroSensorSda = GPIOB_11; + engineConfiguration->lps25BaroSensorScl = Gpio::B10; + engineConfiguration->lps25BaroSensorSda = Gpio::B11; } void setSerialConfigurationOverrides() { @@ -202,8 +202,8 @@ void setBoardDefaultConfiguration() { // If we're running as hardware CI, borrow a few extra pins for that #ifdef HARDWARE_CI - engineConfiguration->triggerSimulatorPins[0] = GPIOG_3; - engineConfiguration->triggerSimulatorPins[1] = GPIOG_2; + engineConfiguration->triggerSimulatorPins[0] = Gpio::G3; + engineConfiguration->triggerSimulatorPins[1] = Gpio::G2; #endif } diff --git a/firmware/config/boards/proteus/connectors/black23.yaml b/firmware/config/boards/proteus/connectors/black23.yaml index 79d7c5aa1c..d9f6965b9a 100644 --- a/firmware/config/boards/proteus/connectors/black23.yaml +++ b/firmware/config/boards/proteus/connectors/black23.yaml @@ -1,20 +1,20 @@ pins: - pin: 1 - id: [GPIOE_11, GPIOE_11] + id: [E11, E11] class: [event_inputs, switch_inputs] function: Digital trigger/switch input for instance Hall type CAM ts_name: Digital 2 type: din - pin: 2 - id: [GPIOE_12, GPIOE_12] + id: [E12, E12] class: [event_inputs, switch_inputs] function: Digital trigger/switch input for instance VSS ts_name: Digital 3 type: din - pin: 3 - id: [GPIOE_14, GPIOE_14] + id: [E14, E14] class: [event_inputs, switch_inputs] function: Digital trigger/switch input for instance Start Button ts_name: Digital 4 @@ -24,7 +24,7 @@ pins: function: "Variable Reluctance #2 positive" type: vr - - id: GPIOE_8 + - id: E8 class: event_inputs ts_name: VR 2 @@ -32,7 +32,7 @@ pins: function: "Variable Reluctance #1 positive" type: vr - - id: GPIOE_7 + - id: E7 class: event_inputs ts_name: VR 1 @@ -49,21 +49,21 @@ pins: type: etb - pin: 9 - id: [GPIOE_13, GPIOE_13] + id: [E13, E13] class: [event_inputs, switch_inputs] function: Digital trigger/switch input ts_name: Digital 5 type: din - pin: 10 - id: [GPIOC_6, GPIOC_6] + id: [C6, C6] class: [event_inputs, switch_inputs] function: Digital trigger/switch input ts_name: Digital 1 type: din - pin: 11 - id: [GPIOE_15, GPIOE_15] + id: [E15, E15] class: [event_inputs, switch_inputs] function: Digital trigger/switch input ts_name: Digital 6 @@ -119,32 +119,32 @@ pins: type: 12v - pin: PD8 - id: GPIOD_8 + id: D8 class: outputs ts_name: STM32 PD8 - pin: PD9 - id: GPIOD_9 + id: D9 class: outputs ts_name: STM32 PD9 - pin: PD10 - id: GPIOD_10 + id: D10 class: outputs ts_name: STM32 PD10 - pin: PD11 - id: GPIOD_11 + id: D11 class: outputs ts_name: STM32 PD11 - pin: PD12 - id: GPIOD_12 + id: D12 class: outputs ts_name: STM32 PD12 - pin: PD13 - id: GPIOD_13 + id: D13 class: outputs ts_name: STM32 PD13 diff --git a/firmware/config/boards/proteus/connectors/black35.yaml b/firmware/config/boards/proteus/connectors/black35.yaml index d3a9988d9e..40cfdd28c7 100644 --- a/firmware/config/boards/proteus/connectors/black35.yaml +++ b/firmware/config/boards/proteus/connectors/black35.yaml @@ -1,111 +1,111 @@ pins: - pin: 1 - id: GPIOA_8 + id: A8 function: output class: outputs ts_name: Highside 2 type: hs - pin: 2 - id: GPIOA_9 + id: A9 function: output class: outputs ts_name: Highside 1 type: hs - pin: 3 - id: GPIOD_7 + id: D7 function: "Injector #1" class: outputs ts_name: Lowside 1 type: ls - pin: 4 - id: GPIOG_10 + id: G10 function: "Injector #3" class: outputs ts_name: Lowside 3 type: ls - pin: 5 - id: GPIOG_12 + id: G12 function: "Injector #5" class: outputs ts_name: Lowside 5 type: ls - pin: 6 - id: GPIOG_13 + id: G13 function: "Injector #6" class: outputs ts_name: Lowside 6 type: ls - pin: 7 - id: GPIOG_14 + id: G14 function: "Injector #7" class: outputs ts_name: Lowside 7 type: ls - pin: 8 - id: GPIOB_5 + id: B5 function: "Injector #9" class: outputs ts_name: Lowside 9 type: ls - pin: 9 - id: GPIOB_7 + id: B7 function: "Injector #11" class: outputs ts_name: Lowside 11 type: ls - pin: 10 - id: GPIOB_9 + id: B9 function: main relay class: outputs ts_name: Lowside 13 type: ls - pin: 11 - id: GPIOE_0 + id: E0 function: Lowside output class: outputs ts_name: Lowside 14 type: ls - pin: 12 - id: GPIOE_1 + id: E1 function: radiator fan relay class: outputs ts_name: Lowside 15 type: ls - pin: 13 - id: GPIOD_15 + id: D15 function: output class: outputs ts_name: Highside 3 type: hs - pin: 14 - id: GPIOD_14 + id: D14 function: output class: outputs ts_name: Highside 4 type: hs - pin: 15 - id: GPIOG_9 + id: G9 function: "Injector #2" class: outputs ts_name: Lowside 2 type: ls - pin: 16 - id: GPIOG_11 + id: G11 function: "Injector #4" class: outputs ts_name: Lowside 4 @@ -120,35 +120,35 @@ pins: type: gnd - pin: 19 - id: GPIOB_4 + id: B4 function: "Injector #8" class: outputs ts_name: Lowside 8 type: ls - pin: 20 - id: GPIOB_6 + id: B6 function: "Injector #10" class: outputs ts_name: Lowside 10 type: ls - pin: 21 - id: GPIOB_8 + id: B8 function: "Injector #12" class: outputs ts_name: Lowside 12 type: ls - pin: 22 - id: GPIOC_9 + id: C9 function: Ignition cylinder 3 class: outputs ts_name: Ign 3 type: hl - pin: 23 - id: GPIOE_2 + id: E2 function: Fuel Pump class: outputs ts_name: Lowside 16 @@ -159,77 +159,77 @@ pins: type: gnd - pin: 25 - id: GPIOG_2 + id: G2 function: Ignition cylinder 12 class: outputs ts_name: Ign 12 type: hl - pin: 26 - id: GPIOG_3 + id: G3 function: Ignition cylinder 11 class: outputs ts_name: Ign 11 type: hl - pin: 27 - id: GPIOG_4 + id: G4 function: Ignition cylinder 10 class: outputs ts_name: Ign 10 type: hl - pin: 28 - id: GPIOG_5 + id: G5 function: Ignition cylinder 9 class: outputs ts_name: Ign 9 type: hl - pin: 29 - id: GPIOG_6 + id: G6 function: Ignition cylinder 8 class: outputs ts_name: Ign 8 type: hl - pin: 30 - id: GPIOG_7 + id: G7 function: Ignition cylinder 7 class: outputs ts_name: Ign 7 type: hl - pin: 31 - id: GPIOG_8 + id: G8 function: Ignition cylinder 6 class: outputs ts_name: Ign 6 type: hl - pin: 32 - id: GPIOC_7 + id: C7 function: Ignition cylinder 5 class: outputs ts_name: Ign 5 type: hl - pin: 33 - id: GPIOC_8 + id: C8 function: Ignition cylinder 4 class: outputs ts_name: Ign 4 type: hl - pin: 34 - id: GPIOD_3 + id: D3 function: Ignition cylinder 2 class: outputs ts_name: Ign 2 type: hl - pin: 35 - id: GPIOD_4 + id: D4 function: Ignition cylinder 1 class: outputs ts_name: Ign 1 diff --git a/firmware/config/boards/proteus/connectors/white35.yaml b/firmware/config/boards/proteus/connectors/white35.yaml index 923cede95e..5f9ceee968 100644 --- a/firmware/config/boards/proteus/connectors/white35.yaml +++ b/firmware/config/boards/proteus/connectors/white35.yaml @@ -48,56 +48,56 @@ pins: type: 12v - pin: 13 - id: [GPIOC_0, EFI_ADC_10] + id: [C0, EFI_ADC_10] class: [switch_inputs, analog_inputs] ts_name: Analog Volt 1 function: "Analog Voltage Input #1 MAP" type: av - pin: 14 - id: [GPIOC_2, EFI_ADC_12] + id: [C2, EFI_ADC_12] class: [switch_inputs, analog_inputs] ts_name: Analog Volt 3 function: "Analog Voltage Input #3" type: av - pin: 15 - id: [GPIOA_0, EFI_ADC_0] + id: [A0, EFI_ADC_0] class: [switch_inputs, analog_inputs] ts_name: Analog Volt 5 function: "Analog Voltage Input #5" type: av - pin: 16 - id: [GPIOA_2, EFI_ADC_2] + id: [A2, EFI_ADC_2] class: [switch_inputs, analog_inputs] ts_name: Analog Volt 7 function: "Analog Voltage Input #7" type: av - pin: 17 - id: [GPIOA_4, EFI_ADC_4] + id: [A4, EFI_ADC_4] class: [switch_inputs, analog_inputs] ts_name: Analog Volt 9 function: "Analog Voltage Input #9" type: av - pin: 18 - id: [GPIOA_6, EFI_ADC_6] + id: [A6, EFI_ADC_6] class: [switch_inputs, analog_inputs] ts_name: Analog Volt 11 function: "Analog Voltage Input #11" type: av - pin: 19 - id: [GPIOC_4, EFI_ADC_14] + id: [C4, EFI_ADC_14] class: [switch_inputs, analog_inputs] ts_name: Analog Temp 1 function: "Analog Thermistor Input #1" type: at - pin: 20 - id: [GPIOB_0, EFI_ADC_8] + id: [B0, EFI_ADC_8] class: [switch_inputs, analog_inputs] ts_name: Analog Temp 3 function: "Analog Thermistor Input #3 (CLT)" @@ -116,35 +116,35 @@ pins: type: sgnd - pin: 24 - id: [GPIOC_1, EFI_ADC_11] + id: [C1, EFI_ADC_11] class: [switch_inputs, analog_inputs] ts_name: Analog Volt 2 function: "Analog Voltage Input #2 TPS" type: av - pin: 25 - id: [GPIOC_3, EFI_ADC_13] + id: [C3, EFI_ADC_13] class: [switch_inputs, analog_inputs] ts_name: Analog Volt 4 function: "Analog Voltage Input #4" type: av - pin: 26 - id: [GPIOA_1, EFI_ADC_1] + id: [A1, EFI_ADC_1] class: [switch_inputs, analog_inputs] ts_name: Analog Volt 6 function: "Analog Voltage Input #6" type: av - pin: 27 - id: [GPIOA_3, EFI_ADC_3] + id: [A3, EFI_ADC_3] class: [switch_inputs, analog_inputs] ts_name: Analog Volt 8 function: "Analog Voltage Input #8" type: av - pin: 28 - id: [GPIOA_5, EFI_ADC_5] + id: [A5, EFI_ADC_5] class: [switch_inputs, analog_inputs] ts_name: Analog Volt 10 function: "Analog Voltage Input #10" @@ -155,14 +155,14 @@ pins: type: sgnd - pin: 30 - id: [GPIOC_5, EFI_ADC_15] + id: [C5, EFI_ADC_15] class: [switch_inputs, analog_inputs] ts_name: Analog Temp 2 function: Intake air temperature IAT type: at - pin: 31 - id: [GPIOB_1, EFI_ADC_9] + id: [B1, EFI_ADC_9] class: [switch_inputs, analog_inputs] ts_name: Analog Temp 4 function: "Analog Thermistor Input #4" diff --git a/firmware/config/boards/proteus/knock_config.h b/firmware/config/boards/proteus/knock_config.h index e2ab3fc55a..78138682c8 100644 --- a/firmware/config/boards/proteus/knock_config.h +++ b/firmware/config/boards/proteus/knock_config.h @@ -9,12 +9,12 @@ // knock 1 - pin PF4 #define KNOCK_ADC_CH1 ADC_CHANNEL_IN14 -#define KNOCK_PIN_CH1 GPIOF_4 +#define KNOCK_PIN_CH1 Gpio::F4 // knock 2 - pin PF5 #define KNOCK_HAS_CH2 true #define KNOCK_ADC_CH2 ADC_CHANNEL_IN15 -#define KNOCK_PIN_CH2 GPIOF_5 +#define KNOCK_PIN_CH2 Gpio::F5 // Sample rate & time - depends on the exact MCU #define KNOCK_SAMPLE_TIME ADC_SAMPLE_84 diff --git a/firmware/config/boards/proteus_meta.h b/firmware/config/boards/proteus_meta.h index 5e434ab44d..bb5294d7b6 100644 --- a/firmware/config/boards/proteus_meta.h +++ b/firmware/config/boards/proteus_meta.h @@ -7,68 +7,68 @@ #pragma once -#define PROTEUS_LS_1 GPIOD_7 +#define PROTEUS_LS_1 Gpio::D7 // pin 15/black35 -#define PROTEUS_LS_2 GPIOG_9 +#define PROTEUS_LS_2 Gpio::G9 // pin 4/black35 -#define PROTEUS_LS_3 GPIOG_10 +#define PROTEUS_LS_3 Gpio::G10 // pin 16/black35 -#define PROTEUS_LS_4 GPIOG_11 +#define PROTEUS_LS_4 Gpio::G11 // pin 5/black35 -#define PROTEUS_LS_5 GPIOG_12 +#define PROTEUS_LS_5 Gpio::G12 // pin 6/black35 -#define PROTEUS_LS_6 GPIOG_13 +#define PROTEUS_LS_6 Gpio::G13 // pin 7/black35 -#define PROTEUS_LS_7 GPIOG_14 -#define PROTEUS_LS_8 GPIOB_4 -#define PROTEUS_LS_9 GPIOB_5 +#define PROTEUS_LS_7 Gpio::G14 +#define PROTEUS_LS_8 Gpio::B4 +#define PROTEUS_LS_9 Gpio::B5 // pin 20/black35 -#define PROTEUS_LS_10 GPIOB_6 -#define PROTEUS_LS_11 GPIOB_7 -#define PROTEUS_LS_12 GPIOB_8 +#define PROTEUS_LS_10 Gpio::B6 +#define PROTEUS_LS_11 Gpio::B7 +#define PROTEUS_LS_12 Gpio::B8 // pin 10/black35 -#define PROTEUS_LS_13 GPIOB_9 -#define PROTEUS_LS_14 GPIOE_0 +#define PROTEUS_LS_13 Gpio::B9 +#define PROTEUS_LS_14 Gpio::E0 // pin 12/black35 -#define PROTEUS_LS_15 GPIOE_1 +#define PROTEUS_LS_15 Gpio::E1 // pin 23/black35 -#define PROTEUS_LS_16 GPIOE_2 +#define PROTEUS_LS_16 Gpio::E2 // pin 2/black35 -#define PROTEUS_HS_1 GPIOA_9 +#define PROTEUS_HS_1 Gpio::A9 // pin 1/black35 -#define PROTEUS_HS_2 GPIOA_8 +#define PROTEUS_HS_2 Gpio::A8 -#define PROTEUS_HS_3 GPIOD_15 +#define PROTEUS_HS_3 Gpio::D15 -#define PROTEUS_HS_4 GPIOD_14 +#define PROTEUS_HS_4 Gpio::D14 // pin 35/black35 -#define PROTEUS_IGN_1 GPIOD_4 +#define PROTEUS_IGN_1 Gpio::D4 // pin 34/black35 -#define PROTEUS_IGN_2 GPIOD_3 +#define PROTEUS_IGN_2 Gpio::D3 // pin 22/black35 -#define PROTEUS_IGN_3 GPIOC_9 -#define PROTEUS_IGN_4 GPIOC_8 -#define PROTEUS_IGN_5 GPIOC_7 -#define PROTEUS_IGN_6 GPIOG_8 -#define PROTEUS_IGN_7 GPIOG_7 -#define PROTEUS_IGN_8 GPIOG_6 -#define PROTEUS_IGN_9 GPIOG_5 -#define PROTEUS_IGN_10 GPIOG_4 -#define PROTEUS_IGN_11 GPIOG_3 -#define PROTEUS_IGN_12 GPIOG_2 +#define PROTEUS_IGN_3 Gpio::C9 +#define PROTEUS_IGN_4 Gpio::C8 +#define PROTEUS_IGN_5 Gpio::C7 +#define PROTEUS_IGN_6 Gpio::G8 +#define PROTEUS_IGN_7 Gpio::G7 +#define PROTEUS_IGN_8 Gpio::G6 +#define PROTEUS_IGN_9 Gpio::G5 +#define PROTEUS_IGN_10 Gpio::G4 +#define PROTEUS_IGN_11 Gpio::G3 +#define PROTEUS_IGN_12 Gpio::G2 // Analog Temp 1 = PC4 #define PROTEUS_IN_ANALOG_TEMP_1 EFI_ADC_14 @@ -119,12 +119,12 @@ // PA6 #define PROTEUS_IN_ANALOG_VOLT_11 EFI_ADC_6 -#define PROTEUS_VR_1 GPIOE_7 -#define PROTEUS_VR_2 GPIOE_8 +#define PROTEUS_VR_1 Gpio::E7 +#define PROTEUS_VR_2 Gpio::E8 -#define PROTEUS_DIGITAL_1 GPIOC_6 -#define PROTEUS_DIGITAL_2 GPIOE_11 -#define PROTEUS_DIGITAL_3 GPIOE_12 -#define PROTEUS_DIGITAL_4 GPIOE_14 -#define PROTEUS_DIGITAL_5 GPIOE_13 -#define PROTEUS_DIGITAL_6 GPIOE_15 +#define PROTEUS_DIGITAL_1 Gpio::C6 +#define PROTEUS_DIGITAL_2 Gpio::E11 +#define PROTEUS_DIGITAL_3 Gpio::E12 +#define PROTEUS_DIGITAL_4 Gpio::E14 +#define PROTEUS_DIGITAL_5 Gpio::E13 +#define PROTEUS_DIGITAL_6 Gpio::E15 diff --git a/firmware/config/boards/skeleton/board.mk b/firmware/config/boards/skeleton/board.mk index 5deb35f3eb..b0945d24c3 100644 --- a/firmware/config/boards/skeleton/board.mk +++ b/firmware/config/boards/skeleton/board.mk @@ -10,4 +10,4 @@ endif DDEFS += -DDEFAULT_ENGINE_TYPE=DEFAULT_FRANKENSO # Add them all together -DDEFS += -DEFI_USE_OSC=TRUE -DLED_CRITICAL_ERROR_BRAIN_PIN=GPIOE_3 -DFIRMWARE_ID=\"skeleton\" +DDEFS += -DEFI_USE_OSC=TRUE -DLED_CRITICAL_ERROR_BRAIN_PIN=Gpio::E3 -DFIRMWARE_ID=\"skeleton\" diff --git a/firmware/config/boards/skeleton/board_configuration.cpp b/firmware/config/boards/skeleton/board_configuration.cpp index be542283e2..b25333632f 100644 --- a/firmware/config/boards/skeleton/board_configuration.cpp +++ b/firmware/config/boards/skeleton/board_configuration.cpp @@ -36,12 +36,12 @@ static void setupTle8888() { // Enable the SPI channel and set up the SPI pins engineConfiguration->is_enabled_spi_3 = true; - engineConfiguration->spi3mosiPin = GPIOB_5; - engineConfiguration->spi3misoPin = GPIOB_4; - engineConfiguration->spi3sckPin = GPIOB_3; + engineConfiguration->spi3mosiPin = Gpio::B5; + engineConfiguration->spi3misoPin = Gpio::B4; + engineConfiguration->spi3sckPin = Gpio::B3; // SPI chip select is often independent of the SPI pin limitations - engineConfiguration->tle8888_cs = GPIOD_5; + engineConfiguration->tle8888_cs = Gpio::D5; // Set SPI device engineConfiguration->tle8888spiDevice = SPI_DEVICE_3; @@ -59,9 +59,9 @@ static void setupTle9201Etb() { // This chip has PWM/DIR, not dira/dirb engineConfiguration->etb_use_two_wires = false; // PWM and DIR pins - engineConfiguration->etbIo[0].controlPin = GPIOC_7; - engineConfiguration->etbIo[0].directionPin1 = GPIOA_8; - engineConfiguration->etbIo[0].directionPin2 = GPIO_UNASSIGNED; + engineConfiguration->etbIo[0].controlPin = Gpio::C7; + engineConfiguration->etbIo[0].directionPin1 = Gpio::A8; + engineConfiguration->etbIo[0].directionPin2 = Gpio::Unassigned; } // Configure key sensors inputs. @@ -72,10 +72,10 @@ static void setupDefaultSensorInputs() { // Engine rotation position sensors // Trigger is our primary timing signal, and usually comes from the crank. // trigger inputs up TRIGGER_SUPPORTED_CHANNELS (2) - engineConfiguration->triggerInputPins[0] = GPIOC_6; - engineConfiguration->triggerInputPins[1] = GPIO_UNASSIGNED; + engineConfiguration->triggerInputPins[0] = Gpio::C6; + engineConfiguration->triggerInputPins[1] = Gpio::Unassigned; // A secondary Cam signal up to CAM_INPUTS_COUNT (4) - engineConfiguration->camInputs[0] = GPIOA_5; + engineConfiguration->camInputs[0] = Gpio::A5; // Throttle Body Position Sensors, second channel is a check/fail-safe // tps = "20 - AN volt 5" @@ -84,7 +84,7 @@ static void setupDefaultSensorInputs() { // Throttle pedal inputs // Idle/Up/Closed (no pressure on pedal) pin - engineConfiguration->throttlePedalUpPin = GPIO_UNASSIGNED; + engineConfiguration->throttlePedalUpPin = Gpio::Unassigned; // If the ETB has analog feedback we can use it for closed loop control. engineConfiguration->throttlePedalPositionAdcChannel = EFI_ADC_2; @@ -128,32 +128,32 @@ void setBoardDefaultConfiguration() { // Set indicator LED pins. // This is often redundant with efifeatures.h or the run-time config - engineConfiguration->triggerErrorPin = GPIOE_1; - engineConfiguration->communicationLedPin = GPIOE_2; - engineConfiguration->runningLedPin = GPIOE_4; - engineConfiguration->warningLedPin = GPIOE_5; - engineConfiguration->errorLedPin = GPIOE_7; + engineConfiguration->triggerErrorPin = Gpio::E1; + engineConfiguration->communicationLedPin = Gpio::E2; + engineConfiguration->runningLedPin = Gpio::E4; + engineConfiguration->warningLedPin = Gpio::E5; + engineConfiguration->errorLedPin = Gpio::E7; // Set injector pins and the pin output mode engineConfiguration->injectionPinMode = OM_DEFAULT; - engineConfiguration->injectionPins[0] = GPIOE_14; - engineConfiguration->injectionPins[1] = GPIOE_13; - engineConfiguration->injectionPins[2] = GPIOE_12; - engineConfiguration->injectionPins[3] = GPIOE_11; + engineConfiguration->injectionPins[0] = Gpio::E14; + engineConfiguration->injectionPins[1] = Gpio::E13; + engineConfiguration->injectionPins[2] = Gpio::E12; + engineConfiguration->injectionPins[3] = Gpio::E11; // Disable the remainder only when they may never be assigned for (int i = 4; i < MAX_CYLINDER_COUNT;i++) { - engineConfiguration->injectionPins[i] = GPIO_UNASSIGNED; + engineConfiguration->injectionPins[i] = Gpio::Unassigned; } // Do the same for ignition outputs engineConfiguration->ignitionPinMode = OM_DEFAULT; - engineConfiguration->ignitionPins[0] = GPIOD_4; - engineConfiguration->ignitionPins[1] = GPIOD_3; - engineConfiguration->ignitionPins[2] = GPIOD_2; - engineConfiguration->ignitionPins[3] = GPIOD_1; + engineConfiguration->ignitionPins[0] = Gpio::D4; + engineConfiguration->ignitionPins[1] = Gpio::D3; + engineConfiguration->ignitionPins[2] = Gpio::D2; + engineConfiguration->ignitionPins[3] = Gpio::D1; // Disable remainder for (int i = 4; i < MAX_CYLINDER_COUNT; i++) { - engineConfiguration->ignitionPins[i] = GPIO_UNASSIGNED; + engineConfiguration->ignitionPins[i] = Gpio::Unassigned; } // Board-specific scaling values to convert ADC fraction to Volts. @@ -184,17 +184,17 @@ void setBoardDefaultConfiguration() { // Configure the TLE8888 half bridges (pushpull, lowside, or high-low) // TLE8888_IN11 -> TLE8888_OUT21 - // TLE8888_PIN_21: "35 - GP Out 1" - engineConfiguration->fuelPumpPin = TLE8888_PIN_21; + // Gpio::TLE8888_PIN_21: "35 - GP Out 1" + engineConfiguration->fuelPumpPin = Gpio::TLE8888_PIN_21; // TLE8888 high current low side: VVT2 IN9 / OUT5 - // TLE8888_PIN_4: "3 - Lowside 2" - engineConfiguration->idle.solenoidPin = TLE8888_PIN_5; + // Gpio::TLE8888_PIN_4: "3 - Lowside 2" + engineConfiguration->idle.solenoidPin = Gpio::TLE8888_PIN_5; - // TLE8888_PIN_22: "34 - GP Out 2" - engineConfiguration->fanPin = TLE8888_PIN_22; + // Gpio::TLE8888_PIN_22: "34 - GP Out 2" + engineConfiguration->fanPin = Gpio::TLE8888_PIN_22; // The "required" hardware is done - set some reasonable input defaults setupDefaultSensorInputs(); diff --git a/firmware/config/boards/skeleton/connectors/main.yaml b/firmware/config/boards/skeleton/connectors/main.yaml index 72733e996f..7ede2da947 100644 --- a/firmware/config/boards/skeleton/connectors/main.yaml +++ b/firmware/config/boards/skeleton/connectors/main.yaml @@ -32,7 +32,7 @@ pins: # TC4427 ignition outputs (5v) - pin: 9 - id: GPIOD_4 + id: D4 class: outputs color: dark blue function: Ignition 1 @@ -40,7 +40,7 @@ pins: type: ign - pin: 10 - id: GPIOD_3 + id: D3 class: outputs color: dark blue function: Ignition 2 @@ -48,7 +48,7 @@ pins: type: ign - pin: 11 - id: GPIOD_2 + id: D2 class: outputs color: dark blue function: Ignition 3 @@ -56,7 +56,7 @@ pins: type: ign - pin: 12 - id: GPIOD_1 + id: D1 class: outputs color: dark blue function: Ignition 4 @@ -64,7 +64,7 @@ pins: type: ign - pin: 13 - id: GPIOD_6 + id: D6 class: outputs color: yellow function: Alternator (see JP2 jumper note) @@ -73,7 +73,7 @@ pins: # TC4427 general purpose output (selectable 5v/12v) - pin: 14 - id: GPIOD_7 + id: D7 class: outputs color: yellow function: (see JP2 jumper note) @@ -81,7 +81,7 @@ pins: type: gp_high - pin: 18 - id: [GPIOA_0, EFI_ADC_0] + id: [A0, EFI_ADC_0] class: [switch_inputs, analog_inputs] color: red function: CLT sensor @@ -89,7 +89,7 @@ pins: type: at - pin: 19 - id: [GPIOC_2, EFI_ADC_12] + id: [C2, EFI_ADC_12] class: [switch_inputs, analog_inputs] color: red function: Starting from version 0.5.0 this pin can be used as 5V input for USB connection through main connector (No need to open case to access micro-USB connector) @@ -97,7 +97,7 @@ pins: type: av - pin: 20 - id: [GPIOC_3, EFI_ADC_13] + id: [C3, EFI_ADC_13] class: [switch_inputs, analog_inputs] color: red left function: Throttle position sensor (TPS) @@ -105,14 +105,14 @@ pins: type: av - pin: 22 - id: [GPIOA_3, EFI_ADC_3] + id: [A3, EFI_ADC_3] class: [switch_inputs, analog_inputs] color: dark green ts_name: 22 - AN temp 4 type: at - pin: 23 - id: [GPIOA_1, EFI_ADC_1] + id: [A1, EFI_ADC_1] class: [switch_inputs, analog_inputs] color: dark green function: IAT sensor @@ -120,7 +120,7 @@ pins: type: at - pin: 24 - id: [GPIOA_2, EFI_ADC_2] + id: [A2, EFI_ADC_2] class: [switch_inputs, analog_inputs] color: dark green ts_name: 24 - AN temp 3 @@ -128,21 +128,21 @@ pins: # RC filter input for hall - pin: 25 - id: [GPIOA_5, GPIOA_5] + id: [A5, A5] class: [event_inputs, switch_inputs] color: light blue right ts_name: 25 - Hall Cam type: hall - pin: 26 - id: [GPIOA_6, EFI_ADC_6] + id: [A6, EFI_ADC_6] class: [switch_inputs, analog_inputs] color: light blue ts_name: 26 - AN volt 2 type: av - pin: 27 - id: [GPIOC_0, EFI_ADC_10] + id: [C0, EFI_ADC_10] class: [switch_inputs, analog_inputs] color: light blue function: MAP sensor @@ -150,21 +150,21 @@ pins: type: av - pin: 28 - id: [GPIOA_4, EFI_ADC_4] + id: [A4, EFI_ADC_4] class: [switch_inputs, analog_inputs] color: light blue left ts_name: 28 - AN volt 10 type: av - pin: 30 - id: [GPIOC_5, EFI_ADC_15] + id: [C5, EFI_ADC_15] class: [switch_inputs, analog_inputs] color: pink ts_name: 30 - AN volt 7 type: av - pin: 31 - id: [GPIOA_7, EFI_ADC_7] + id: [A7, EFI_ADC_7] class: [switch_inputs, analog_inputs] color: pink function: Throttle Pedal Position Sensor (PPS) @@ -172,7 +172,7 @@ pins: type: av - pin: 32 - id: [GPIOC_4, EFI_ADC_14] + id: [C4, EFI_ADC_14] class: [switch_inputs, analog_inputs] color: pink function: External wideband O2 sensor @@ -207,7 +207,7 @@ pins: type: [gp_low, gp_pp] - pin: 36 - id: [GPIOB_0, EFI_ADC_8] + id: [B0, EFI_ADC_8] class: [switch_inputs, analog_inputs] color: orange left ts_name: 36 - AN volt 8 @@ -230,7 +230,7 @@ pins: type: inj - pin: 40 - id: [GPIOB_1, EFI_ADC_9] + id: [B1, EFI_ADC_9] class: [switch_inputs, analog_inputs] color: grey ts_name: 40 - AN volt 9 @@ -262,7 +262,7 @@ pins: type: [gp_low, gp_pp] - pin: 45 - id: GPIOC_6 + id: C6 class: event_inputs color: light green right function: Crank VR+/hall diff --git a/firmware/config/boards/skeleton/efifeatures.h b/firmware/config/boards/skeleton/efifeatures.h index be9c1bb7f1..52a0dc238d 100644 --- a/firmware/config/boards/skeleton/efifeatures.h +++ b/firmware/config/boards/skeleton/efifeatures.h @@ -239,11 +239,6 @@ #define EFI_SPI3_AF 6 -#define EFI_I2C_SCL_BRAIN_PIN GPIOB_6 - -#define EFI_I2C_SDA_BRAIN_PIN GPIOB_7 -#define EFI_I2C_AF 4 - /** * Patched version of ChibiOS/RT support extra details in the system error messages */ @@ -294,7 +289,7 @@ #endif #ifndef LED_CRITICAL_ERROR_BRAIN_PIN -#define LED_CRITICAL_ERROR_BRAIN_PIN GPIOD_14 +#define LED_CRITICAL_ERROR_BRAIN_PIN Gpio::D14 #endif #ifndef LED_ERROR_BRAIN_PIN_MODE #define LED_ERROR_BRAIN_PIN_MODE DEFAULT_OUTPUT @@ -339,8 +334,8 @@ // todo: start using consoleSerial{Tx,Rx}Pin #define EFI_CONSOLE_AF 7 #define TS_SERIAL_AF 7 -#define EFI_CONSOLE_TX_BRAIN_PIN GPIOC_10 -#define EFI_CONSOLE_RX_BRAIN_PIN GPIOC_11 +#define EFI_CONSOLE_TX_BRAIN_PIN Gpio::C10 +#define EFI_CONSOLE_RX_BRAIN_PIN Gpio::C11 // todo: document the limitations of DMA mode for the UART. #undef TS_UART_DMA_MODE diff --git a/firmware/config/boards/subaru_eg33/board.h b/firmware/config/boards/subaru_eg33/board.h index 1aa6acb1f2..dc22fa1ac0 100644 --- a/firmware/config/boards/subaru_eg33/board.h +++ b/firmware/config/boards/subaru_eg33/board.h @@ -14,9 +14,9 @@ #define BOARD_NAME "Subaru EG33/STM32F765 for RusEFI" #define EFI_USB_AF 10U -//#define EFI_USB_SERIAL_ID GPIOA_10 -#define EFI_USB_SERIAL_DM GPIOA_11 -#define EFI_USB_SERIAL_DP GPIOA_12 +//#define EFI_USB_SERIAL_ID Gpio::A10 +#define EFI_USB_SERIAL_DM Gpio::A11 +#define EFI_USB_SERIAL_DP Gpio::A12 /* * Board oscillators-related settings. diff --git a/firmware/config/boards/subaru_eg33/board.mk b/firmware/config/boards/subaru_eg33/board.mk index 28f440dc79..46aadc9649 100644 --- a/firmware/config/boards/subaru_eg33/board.mk +++ b/firmware/config/boards/subaru_eg33/board.mk @@ -14,7 +14,7 @@ ifeq ($(USE_BOOTLOADER),yes) endif #LED -DDEFS += -DLED_CRITICAL_ERROR_BRAIN_PIN=GPIOG_7 +DDEFS += -DLED_CRITICAL_ERROR_BRAIN_PIN=Gpio::G7 # We are running on Subaru EG33 hardware! DDEFS += -DHW_SUBARU_EG33=1 diff --git a/firmware/config/boards/subaru_eg33/board_configuration.cpp b/firmware/config/boards/subaru_eg33/board_configuration.cpp index e93da7365b..a3c8607856 100644 --- a/firmware/config/boards/subaru_eg33/board_configuration.cpp +++ b/firmware/config/boards/subaru_eg33/board_configuration.cpp @@ -13,11 +13,11 @@ void setSerialConfigurationOverrides() { engineConfiguration->useSerialPort = false; - engineConfiguration->binarySerialTxPin = GPIOE_1; - engineConfiguration->binarySerialRxPin = GPIOE_0; + engineConfiguration->binarySerialTxPin = Gpio::E1; + engineConfiguration->binarySerialRxPin = Gpio::E0; /* actually Bluetooth/WiFi interface */ - //engineConfiguration->consoleSerialTxPin = GPIOC_10; - //engineConfiguration->consoleSerialRxPin = GPIOC_11; + //engineConfiguration->consoleSerialTxPin = Gpio::C10; + //engineConfiguration->consoleSerialRxPin = Gpio::C11; engineConfiguration->tunerStudioSerialSpeed = SERIAL_SPEED; engineConfiguration->uartConsoleSerialSpeed = SERIAL_SPEED; } @@ -25,7 +25,7 @@ void setSerialConfigurationOverrides() { void setSdCardConfigurationOverrides() { engineConfiguration->is_enabled_spi_1 = false; engineConfiguration->sdCardSpiDevice = SPI_DEVICE_1; - engineConfiguration->sdCardCsPin = GPIOA_2; + engineConfiguration->sdCardCsPin = Gpio::A2; engineConfiguration->isSdCardEnabled = false; } @@ -72,62 +72,62 @@ void setBoardDefaultConfiguration() { engineConfiguration->throttlePedalPositionAdcChannel = EFI_ADC_NONE; /* Injectors */ - engineConfiguration->injectionPins[1 - 1] = MC33810_0_OUT_0; - engineConfiguration->injectionPins[2 - 1] = MC33810_1_OUT_0; - engineConfiguration->injectionPins[3 - 1] = MC33810_0_OUT_1; - engineConfiguration->injectionPins[4 - 1] = MC33810_1_OUT_1; - engineConfiguration->injectionPins[5 - 1] = MC33810_0_OUT_2; - engineConfiguration->injectionPins[6 - 1] = MC33810_1_OUT_2; + engineConfiguration->injectionPins[1 - 1] = Gpio::MC33810_0_OUT_0; + engineConfiguration->injectionPins[2 - 1] = Gpio::MC33810_1_OUT_0; + engineConfiguration->injectionPins[3 - 1] = Gpio::MC33810_0_OUT_1; + engineConfiguration->injectionPins[4 - 1] = Gpio::MC33810_1_OUT_1; + engineConfiguration->injectionPins[5 - 1] = Gpio::MC33810_0_OUT_2; + engineConfiguration->injectionPins[6 - 1] = Gpio::MC33810_1_OUT_2; /* Additional, not used for EG33 */ - engineConfiguration->injectionPins[7 - 1] = MC33810_0_OUT_3; - engineConfiguration->injectionPins[8 - 1] = MC33810_1_OUT_3; + engineConfiguration->injectionPins[7 - 1] = Gpio::MC33810_0_OUT_3; + engineConfiguration->injectionPins[8 - 1] = Gpio::MC33810_1_OUT_3; /* Ignition */ - engineConfiguration->ignitionPins[1 - 1] = MC33810_1_GD_3; - engineConfiguration->ignitionPins[2 - 1] = MC33810_1_GD_2; - engineConfiguration->ignitionPins[3 - 1] = MC33810_0_GD_1; - engineConfiguration->ignitionPins[4 - 1] = MC33810_0_GD_0; - engineConfiguration->ignitionPins[5 - 1] = MC33810_0_GD_3; - engineConfiguration->ignitionPins[6 - 1] = MC33810_1_GD_1; + engineConfiguration->ignitionPins[1 - 1] = Gpio::MC33810_1_GD_3; + engineConfiguration->ignitionPins[2 - 1] = Gpio::MC33810_1_GD_2; + engineConfiguration->ignitionPins[3 - 1] = Gpio::MC33810_0_GD_1; + engineConfiguration->ignitionPins[4 - 1] = Gpio::MC33810_0_GD_0; + engineConfiguration->ignitionPins[5 - 1] = Gpio::MC33810_0_GD_3; + engineConfiguration->ignitionPins[6 - 1] = Gpio::MC33810_1_GD_1; /* Additional, not used for EG33 */ - engineConfiguration->ignitionPins[7 - 1] = MC33810_0_GD_2; - engineConfiguration->ignitionPins[8 - 1] = MC33810_1_GD_0; + engineConfiguration->ignitionPins[7 - 1] = Gpio::MC33810_0_GD_2; + engineConfiguration->ignitionPins[8 - 1] = Gpio::MC33810_1_GD_0; //engineConfiguration->ignitionPinMode = OM_INVERTED; // Idle configuration engineConfiguration->useStepperIdle = false; engineConfiguration->isDoubleSolenoidIdle = true; - engineConfiguration->idle.solenoidPin = TLE6240_PIN_11; - engineConfiguration->secondSolenoidPin = TLE6240_PIN_12; + engineConfiguration->idle.solenoidPin = Gpio::TLE6240_PIN_11; + engineConfiguration->secondSolenoidPin = Gpio::TLE6240_PIN_12; - engineConfiguration->communicationLedPin = GPIOG_6; /* LD1 - green */ - engineConfiguration->runningLedPin = GPIOG_8; /* LD3 - yellow */ - engineConfiguration->warningLedPin = GPIO_UNASSIGNED; /* LD3 - yellow*/ + engineConfiguration->communicationLedPin = Gpio::G6; /* LD1 - green */ + engineConfiguration->runningLedPin = Gpio::G8; /* LD3 - yellow */ + engineConfiguration->warningLedPin = Gpio::Unassigned; /* LD3 - yellow*/ //engineConfiguration->unusedErrorPin = LED_ERROR_BRAIN_PIN; /* LD2 - red */ /* IF you have BOTH camshaft position sensor and crankshaft position sensor * camshaft is always trigger#1 input and then crankshaft is trigger#2. */ - engineConfiguration->triggerInputPins[0] = GPIOH_12; /* cam */ - engineConfiguration->triggerInputPins[1] = GPIOH_10; /* crank pos #1 */ - engineConfiguration->triggerInputPins[2] = GPIOE_9; /* crank pos #2 */ - engineConfiguration->camInputs[0] = GPIO_UNASSIGNED; + engineConfiguration->triggerInputPins[0] = Gpio::H12; /* cam */ + engineConfiguration->triggerInputPins[1] = Gpio::H10; /* crank pos #1 */ + engineConfiguration->triggerInputPins[2] = Gpio::E9; /* crank pos #2 */ + engineConfiguration->camInputs[0] = Gpio::Unassigned; /* SPI devices: mess of board and engine configurations */ /* TLE6240 */ engineConfiguration->tle6240spiDevice = SPI_DEVICE_4; - engineConfiguration->tle6240_cs = GPIOE_15; /* SPI4_NSS0 */ + engineConfiguration->tle6240_cs = Gpio::E15; /* SPI4_NSS0 */ engineConfiguration->tle6240_csPinMode = OM_OPENDRAIN; /* MC33972 */ engineConfiguration->mc33972spiDevice = SPI_DEVICE_4; - engineConfiguration->mc33972_cs = GPIOE_10; /* SPI4_NSS2 */ + engineConfiguration->mc33972_cs = Gpio::E10; /* SPI4_NSS2 */ engineConfiguration->mc33972_csPinMode = OM_DEFAULT; /* TLE6240 - OUT3, also PG2 through 3.3V-> 5.0V level translator - not installed */ - engineConfiguration->tachOutputPin = TLE6240_PIN_2; + engineConfiguration->tachOutputPin = Gpio::TLE6240_PIN_2; engineConfiguration->tachOutputPinMode = OM_DEFAULT; /* spi driven - TLE6240 - OUT5 */ - engineConfiguration->fuelPumpPin = TLE6240_PIN_5; + engineConfiguration->fuelPumpPin = Gpio::TLE6240_PIN_5; engineConfiguration->fuelPumpPinMode = OM_DEFAULT; /* Self shutdown ouput: @@ -137,32 +137,32 @@ void setBoardDefaultConfiguration() { * So ECU does not need to drive this signal. * The only puprose of this output is to keep ECU powered to finish some stuff before power off itself * To support this we need to sense ING input from key switch */ - //engineConfiguration->mainRelayPin = GPIOH_7; + //engineConfiguration->mainRelayPin = Gpio::H7; //engineConfiguration->mainRelayPinMode = OM_DEFAULT; /* spi driven - TLE6240 - OUT1, OUT2 */ - engineConfiguration->fanPin = TLE6240_PIN_1; + engineConfiguration->fanPin = Gpio::TLE6240_PIN_1; engineConfiguration->fanPinMode = OM_DEFAULT; /* TODO: second fan */ - //engineConfiguration->fanPin[1] = TLE6240_PIN_2; + //engineConfiguration->fanPin[1] = Gpio::TLE6240_2; //engineConfiguration->fanPinMode[1] = OM_DEFAULT; /* spi driven - TLE6240 - OUT8 */ - engineConfiguration->malfunctionIndicatorPin = TLE6240_PIN_7; + engineConfiguration->malfunctionIndicatorPin = Gpio::TLE6240_PIN_7; engineConfiguration->malfunctionIndicatorPinMode = OM_DEFAULT; /* not used */ engineConfiguration->displayMode = DM_NONE; - engineConfiguration->HD44780_rs = GPIO_UNASSIGNED; - engineConfiguration->HD44780_e = GPIO_UNASSIGNED; - engineConfiguration->HD44780_db4 = GPIO_UNASSIGNED; - engineConfiguration->HD44780_db5 = GPIO_UNASSIGNED; - engineConfiguration->HD44780_db6 = GPIO_UNASSIGNED; - engineConfiguration->HD44780_db7 = GPIO_UNASSIGNED; - engineConfiguration->digitalPotentiometerChipSelect[0] = GPIO_UNASSIGNED; - engineConfiguration->digitalPotentiometerChipSelect[1] = GPIO_UNASSIGNED; - engineConfiguration->digitalPotentiometerChipSelect[2] = GPIO_UNASSIGNED; - engineConfiguration->digitalPotentiometerChipSelect[3] = GPIO_UNASSIGNED; - engineConfiguration->vehicleSpeedSensorInputPin = GPIO_UNASSIGNED; + engineConfiguration->HD44780_rs = Gpio::Unassigned; + engineConfiguration->HD44780_e = Gpio::Unassigned; + engineConfiguration->HD44780_db4 = Gpio::Unassigned; + engineConfiguration->HD44780_db5 = Gpio::Unassigned; + engineConfiguration->HD44780_db6 = Gpio::Unassigned; + engineConfiguration->HD44780_db7 = Gpio::Unassigned; + engineConfiguration->digitalPotentiometerChipSelect[0] = Gpio::Unassigned; + engineConfiguration->digitalPotentiometerChipSelect[1] = Gpio::Unassigned; + engineConfiguration->digitalPotentiometerChipSelect[2] = Gpio::Unassigned; + engineConfiguration->digitalPotentiometerChipSelect[3] = Gpio::Unassigned; + engineConfiguration->vehicleSpeedSensorInputPin = Gpio::Unassigned; /* SPIs */ engineConfiguration->is_enabled_spi_1 = true; @@ -170,18 +170,18 @@ void setBoardDefaultConfiguration() { engineConfiguration->is_enabled_spi_3 = true; engineConfiguration->is_enabled_spi_4 = true; - engineConfiguration->spi1mosiPin = GPIO_UNASSIGNED; + engineConfiguration->spi1mosiPin = Gpio::Unassigned; engineConfiguration->spi1MosiMode = PO_DEFAULT; - engineConfiguration->spi1misoPin = GPIO_UNASSIGNED; + engineConfiguration->spi1misoPin = Gpio::Unassigned; engineConfiguration->spi1MisoMode = PO_DEFAULT; - engineConfiguration->spi1sckPin = GPIO_UNASSIGNED; + engineConfiguration->spi1sckPin = Gpio::Unassigned; engineConfiguration->spi1SckMode = PO_DEFAULT; - engineConfiguration->spi3mosiPin = GPIOC_12; + engineConfiguration->spi3mosiPin = Gpio::C12; engineConfiguration->spi3MosiMode = PO_DEFAULT; - engineConfiguration->spi3misoPin = GPIOC_11; + engineConfiguration->spi3misoPin = Gpio::C11; engineConfiguration->spi3MisoMode = PO_DEFAULT; - engineConfiguration->spi3sckPin = GPIOC_10; + engineConfiguration->spi3sckPin = Gpio::C10; engineConfiguration->spi3SckMode = PO_DEFAULT; /* TODO: add settings for SPI4 */ @@ -189,9 +189,9 @@ void setBoardDefaultConfiguration() { /* Knock sensor */ /* Interface settings */ engineConfiguration->hip9011SpiDevice = SPI_DEVICE_4; - engineConfiguration->hip9011CsPin = GPIOE_11; /* SPI4_NSS1 */ + engineConfiguration->hip9011CsPin = Gpio::E11; /* SPI4_NSS1 */ engineConfiguration->hip9011CsPinMode = OM_OPENDRAIN; - engineConfiguration->hip9011IntHoldPin = GPIOH_8; + engineConfiguration->hip9011IntHoldPin = Gpio::H8; engineConfiguration->hip9011IntHoldPinMode = OM_OPENDRAIN; engineConfiguration->hipOutputChannel = EFI_ADC_7; /* PA7 */ engineConfiguration->isHip9011Enabled = true; @@ -220,24 +220,24 @@ void setBoardDefaultConfiguration() { engineConfiguration->cylinderBankSelect[6 - 1] = 1; /* Misc settings */ - engineConfiguration->acSwitch = MC33972_PIN_22; + engineConfiguration->acSwitch = Gpio::MC33972_PIN_22; engineConfiguration->acSwitchMode = PI_DEFAULT; /* This board also has AC clutch output: */ - engineConfiguration->acRelayPin = TLE6240_PIN_15; + engineConfiguration->acRelayPin = Gpio::TLE6240_PIN_15; engineConfiguration->maxAcRpm = 3000; engineConfiguration->acIdleRpmBump = 200; engineConfiguration->isCJ125Enabled = false; /* CAN */ - engineConfiguration->canTxPin = GPIOD_1; - engineConfiguration->canRxPin = GPIOD_0; + engineConfiguration->canTxPin = Gpio::D1; + engineConfiguration->canRxPin = Gpio::D0; /* not used pins with testpads */ - engineConfiguration->triggerSimulatorPins[0] = GPIOH_2; - engineConfiguration->triggerSimulatorPins[1] = GPIOH_3; - engineConfiguration->triggerSimulatorPins[2] = GPIOH_4; + engineConfiguration->triggerSimulatorPins[0] = Gpio::H2; + engineConfiguration->triggerSimulatorPins[1] = Gpio::H3; + engineConfiguration->triggerSimulatorPins[2] = Gpio::H4; engineConfiguration->triggerSimulatorPinModes[0] = OM_DEFAULT; engineConfiguration->triggerSimulatorPinModes[1] = OM_DEFAULT; engineConfiguration->triggerSimulatorPinModes[2] = OM_DEFAULT; @@ -330,11 +330,11 @@ static void board_init_ext_gpios() { int ret; - ret = mc33810_add(MC33810_0_OUT_0, 0, &mc33810_odd); + ret = mc33810_add(Gpio::MC33810_0_OUT_0, 0, &mc33810_odd); if (ret < 0) { /* error */ } - ret = mc33810_add(MC33810_1_OUT_0, 1, &mc33810_even); + ret = mc33810_add(Gpio::MC33810_1_OUT_0, 1, &mc33810_even); if (ret < 0) { /* error */ } diff --git a/firmware/config/boards/subaru_eg33/connectors/A-B59.yaml b/firmware/config/boards/subaru_eg33/connectors/A-B59.yaml index 9f0d300e77..b7b78803a2 100644 --- a/firmware/config/boards/subaru_eg33/connectors/A-B59.yaml +++ b/firmware/config/boards/subaru_eg33/connectors/A-B59.yaml @@ -44,14 +44,14 @@ pins: type: av - pin: 7 - id: GPIOH_12 + id: H12 class: event_inputs function: Cam VR+ ts_name: A07 - Cam VR+ type: vr - pin: 8 - id: GPIOE_9 + id: E9 class: event_inputs function: Crank 2 VR+ ts_name: A08 - Crank 2 VR+ diff --git a/firmware/config/boards/subaru_eg33/connectors/B-B60.yaml b/firmware/config/boards/subaru_eg33/connectors/B-B60.yaml index ed3b41a13b..c7f8361ebb 100644 --- a/firmware/config/boards/subaru_eg33/connectors/B-B60.yaml +++ b/firmware/config/boards/subaru_eg33/connectors/B-B60.yaml @@ -34,7 +34,7 @@ pins: type: sgnd - pin: 7 - id: GPIO_UNASSIGNED + id: Unassigned class: switch_inputs function: Power Steering Switch ts_name: B07 - Power Steering Switch @@ -62,7 +62,7 @@ pins: type: av - pin: 11 - id: GPIOD_14 + id: D14 class: event_inputs function: Speed Din ts_name: B11 - Speed Din diff --git a/firmware/config/boards/subaru_eg33/connectors/C-B61.yaml b/firmware/config/boards/subaru_eg33/connectors/C-B61.yaml index 7123aa7d98..66892a92ef 100644 --- a/firmware/config/boards/subaru_eg33/connectors/C-B61.yaml +++ b/firmware/config/boards/subaru_eg33/connectors/C-B61.yaml @@ -2,7 +2,7 @@ pins: - pin: 1 - id: GPIOH_10 + id: H10 class: event_inputs function: Crank 1 VR+ ts_name: A08 - Crank 1 VR+ diff --git a/firmware/config/boards/subaru_eg33/connectors/D-B62.yaml b/firmware/config/boards/subaru_eg33/connectors/D-B62.yaml index 84eb10d840..0bc536b74a 100644 --- a/firmware/config/boards/subaru_eg33/connectors/D-B62.yaml +++ b/firmware/config/boards/subaru_eg33/connectors/D-B62.yaml @@ -31,7 +31,7 @@ pins: type: av - pin: 5 - id: GPIOH_7 + id: H7 class: outputs function: Self Shutdown ts_name: D05 - Self Shutdown diff --git a/firmware/config/boards/subaru_eg33/rusefi_hw_enums.h b/firmware/config/boards/subaru_eg33/rusefi_hw_enums.h index 7943114a26..fd8af25a4a 100644 --- a/firmware/config/boards/subaru_eg33/rusefi_hw_enums.h +++ b/firmware/config/boards/subaru_eg33/rusefi_hw_enums.h @@ -7,8 +7,6 @@ #pragma once -enum class TestCppStyleEnum : uint8_t { }; - // todo: migrate/unify with pin_output_mode_e? rename? something is messy here // this enum is currently only used for SPI pins typedef enum __attribute__ ((__packed__)) { @@ -22,162 +20,162 @@ typedef enum __attribute__ ((__packed__)) { /** * Hardware pin. This enum is platform-specific. */ -typedef enum __attribute__ ((__packed__)) { - GPIO_UNASSIGNED = 0, - GPIO_INVALID = 1, +enum class Gpio : uint8_t { + Unassigned = 0, + Invalid = 1, - GPIOA_0 = 2, - GPIOA_1 = 3, - GPIOA_2 = 4, - GPIOA_3 = 5, - GPIOA_4 = 6, - GPIOA_5 = 7, - GPIOA_6 = 8, - GPIOA_7 = 9, - GPIOA_8 = 10, - GPIOA_9 = 11, - GPIOA_10 = 12, - GPIOA_11 = 13, - GPIOA_12 = 14, - GPIOA_13 = 15, - GPIOA_14 = 16, - GPIOA_15 = 17, + A0 = 2, + A1 = 3, + A2 = 4, + A3 = 5, + A4 = 6, + A5 = 7, + A6 = 8, + A7 = 9, + A8 = 10, + A9 = 11, + A10 = 12, + A11 = 13, + A12 = 14, + A13 = 15, + A14 = 16, + A15 = 17, - GPIOB_0 = 18, - GPIOB_1 = 19, - GPIOB_2 = 20, - GPIOB_3 = 21, - GPIOB_4 = 22, - GPIOB_5 = 23, - GPIOB_6 = 24, - GPIOB_7 = 25, - GPIOB_8 = 26, - GPIOB_9 = 27, - GPIOB_10 = 28, - GPIOB_11 = 29, - GPIOB_12 = 30, - GPIOB_13 = 31, - GPIOB_14 = 32, - GPIOB_15 = 33, + B0 = 18, + B1 = 19, + B2 = 20, + B3 = 21, + B4 = 22, + B5 = 23, + B6 = 24, + B7 = 25, + B8 = 26, + B9 = 27, + B10 = 28, + B11 = 29, + B12 = 30, + B13 = 31, + B14 = 32, + B15 = 33, - GPIOC_0 = 34, - GPIOC_1 = 35, - GPIOC_2 = 36, - GPIOC_3 = 37, - GPIOC_4 = 38, - GPIOC_5 = 39, - GPIOC_6 = 40, - GPIOC_7 = 41, - GPIOC_8 = 42, - GPIOC_9 = 43, - GPIOC_10 = 44, - GPIOC_11 = 45, - GPIOC_12 = 46, - GPIOC_13 = 47, - GPIOC_14 = 48, - GPIOC_15 = 49, + C0 = 34, + C1 = 35, + C2 = 36, + C3 = 37, + C4 = 38, + C5 = 39, + C6 = 40, + C7 = 41, + C8 = 42, + C9 = 43, + C10 = 44, + C11 = 45, + C12 = 46, + C13 = 47, + C14 = 48, + C15 = 49, - GPIOD_0 = 50, - GPIOD_1 = 51, - GPIOD_2 = 52, - GPIOD_3 = 53, - GPIOD_4 = 54, - GPIOD_5 = 55, - GPIOD_6 = 56, - GPIOD_7 = 57, - GPIOD_8 = 58, - GPIOD_9 = 59, - GPIOD_10 = 60, - GPIOD_11 = 61, - GPIOD_12 = 62, - GPIOD_13 = 63, - GPIOD_14 = 64, - GPIOD_15 = 65, + D0 = 50, + D1 = 51, + D2 = 52, + D3 = 53, + D4 = 54, + D5 = 55, + D6 = 56, + D7 = 57, + D8 = 58, + D9 = 59, + D10 = 60, + D11 = 61, + D12 = 62, + D13 = 63, + D14 = 64, + D15 = 65, - GPIOE_0 = 66, - GPIOE_1 = 67, - GPIOE_2 = 68, - GPIOE_3 = 69, - GPIOE_4 = 70, - GPIOE_5 = 71, - GPIOE_6 = 72, - GPIOE_7 = 73, - GPIOE_8 = 74, - GPIOE_9 = 75, - GPIOE_10 = 76, - GPIOE_11 = 77, - GPIOE_12 = 78, - GPIOE_13 = 79, - GPIOE_14 = 80, - GPIOE_15 = 81, + E0 = 66, + E1 = 67, + E2 = 68, + E3 = 69, + E4 = 70, + E5 = 71, + E6 = 72, + E7 = 73, + E8 = 74, + E9 = 75, + E10 = 76, + E11 = 77, + E12 = 78, + E13 = 79, + E14 = 80, + E15 = 81, - GPIOF_0 = 82, - GPIOF_1 = 83, - GPIOF_2 = 84, - GPIOF_3 = 85, - GPIOF_4 = 86, - GPIOF_5 = 87, - GPIOF_6 = 88, - GPIOF_7 = 89, - GPIOF_8 = 90, - GPIOF_9 = 91, - GPIOF_10 = 92, - GPIOF_11 = 93, - GPIOF_12 = 94, - GPIOF_13 = 95, - GPIOF_14 = 96, - GPIOF_15 = 97, + F0 = 82, + F1 = 83, + F2 = 84, + F3 = 85, + F4 = 86, + F5 = 87, + F6 = 88, + F7 = 89, + F8 = 90, + F9 = 91, + F10 = 92, + F11 = 93, + F12 = 94, + F13 = 95, + F14 = 96, + F15 = 97, - GPIOG_0 = 98, - GPIOG_1 = 99, - GPIOG_2 = 100, - GPIOG_3 = 101, - GPIOG_4 = 102, - GPIOG_5 = 103, - GPIOG_6 = 104, - GPIOG_7 = 105, - GPIOG_8 = 106, - GPIOG_9 = 107, - GPIOG_10 = 108, - GPIOG_11 = 109, - GPIOG_12 = 110, - GPIOG_13 = 111, - GPIOG_14 = 112, - GPIOG_15 = 113, + G0 = 98, + G1 = 99, + G2 = 100, + G3 = 101, + G4 = 102, + G5 = 103, + G6 = 104, + G7 = 105, + G8 = 106, + G9 = 107, + G10 = 108, + G11 = 109, + G12 = 110, + G13 = 111, + G14 = 112, + G15 = 113, - GPIOH_0 = 114, - GPIOH_1 = 115, - GPIOH_2 = 116, - GPIOH_3 = 117, - GPIOH_4 = 118, - GPIOH_5 = 119, - GPIOH_6 = 120, - GPIOH_7 = 121, - GPIOH_8 = 122, - GPIOH_9 = 123, - GPIOH_10 = 124, - GPIOH_11 = 125, - GPIOH_12 = 126, - GPIOH_13 = 127, - GPIOH_14 = 128, - GPIOH_15 = 129, + H0 = 114, + H1 = 115, + H2 = 116, + H3 = 117, + H4 = 118, + H5 = 119, + H6 = 120, + H7 = 121, + H8 = 122, + H9 = 123, + H10 = 124, + H11 = 125, + H12 = 126, + H13 = 127, + H14 = 128, + H15 = 129, - GPIOI_0 = 130, - GPIOI_1 = 131, - GPIOI_2 = 132, - GPIOI_3 = 133, - GPIOI_4 = 134, - GPIOI_5 = 135, - GPIOI_6 = 136, - GPIOI_7 = 137, - GPIOI_8 = 138, - GPIOI_9 = 139, - GPIOI_10 = 140, - GPIOI_11 = 141, - GPIOI_12 = 142, - GPIOI_13 = 143, - GPIOI_14 = 144, - GPIOI_15 = 145, + I0 = 130, + I1 = 131, + I2 = 132, + I3 = 133, + I4 = 134, + I5 = 135, + I6 = 136, + I7 = 137, + I8 = 138, + I9 = 139, + I10 = 140, + I11 = 141, + I12 = 142, + I13 = 143, + I14 = 144, + I15 = 145, TLE6240_PIN_1 = 146, TLE6240_PIN_2 = 147, @@ -236,13 +234,13 @@ typedef enum __attribute__ ((__packed__)) { MC33810_1_GD_1 = 197, MC33810_1_GD_2 = 198, MC33810_1_GD_3 = 199, -} brain_pin_e; +}; /* Plase keep updating these defines */ -#define BRAIN_PIN_ONCHIP_LAST GPIOI_15 -#define BRAIN_PIN_ONCHIP_PINS (BRAIN_PIN_ONCHIP_LAST - GPIOA_0 + 1) -#define BRAIN_PIN_LAST MC33810_1_GD_3 -#define BRAIN_PIN_TOTAL_PINS (BRAIN_PIN_LAST - GPIOA_0 + 1) +#define BRAIN_PIN_ONCHIP_LAST Gpio::I15 +#define BRAIN_PIN_ONCHIP_PINS (BRAIN_PIN_ONCHIP_LAST - Gpio::A0 + 1) +#define BRAIN_PIN_LAST Gpio::MC33810_1_GD_3 +#define BRAIN_PIN_TOTAL_PINS (BRAIN_PIN_LAST - Gpio::A0 + 1) /* Plase keep updating these defines */ typedef enum __attribute__ ((__packed__)) { diff --git a/firmware/config/boards/tdg-pdm8/board.mk b/firmware/config/boards/tdg-pdm8/board.mk index 5ac3657c94..22a075f9d8 100644 --- a/firmware/config/boards/tdg-pdm8/board.mk +++ b/firmware/config/boards/tdg-pdm8/board.mk @@ -3,7 +3,7 @@ BOARDCPPSRC = $(PROJECT_DIR)/config/boards/tdg-pdm8/board_configuration.cpp PROJECT_CPU = ARCH_STM32F4 -DDEFS += -DLED_CRITICAL_ERROR_BRAIN_PIN=GPIOC_11 +DDEFS += -DLED_CRITICAL_ERROR_BRAIN_PIN=Gpio::C11 # We're running on TDG PDM hardware! DDEFS += -DHW_TDG_PDM8=1 diff --git a/firmware/config/boards/tdg-pdm8/board_configuration.cpp b/firmware/config/boards/tdg-pdm8/board_configuration.cpp index abcacca562..546427155c 100644 --- a/firmware/config/boards/tdg-pdm8/board_configuration.cpp +++ b/firmware/config/boards/tdg-pdm8/board_configuration.cpp @@ -11,6 +11,6 @@ void setBoardConfigOverrides() { engineConfiguration->vbattDividerCoeff = 11; engineConfiguration->vbattAdcChannel = EFI_ADC_4; - engineConfiguration->canTxPin = GPIOA_12; - engineConfiguration->canRxPin = GPIOA_11; + engineConfiguration->canTxPin = Gpio::A12; + engineConfiguration->canRxPin = Gpio::A11; } diff --git a/firmware/config/boards/tdg-pdm8/connectors/main.yaml b/firmware/config/boards/tdg-pdm8/connectors/main.yaml index 442e209005..ae288cf640 100644 --- a/firmware/config/boards/tdg-pdm8/connectors/main.yaml +++ b/firmware/config/boards/tdg-pdm8/connectors/main.yaml @@ -7,56 +7,56 @@ pins: ts_name: Battery Sense - pin: 3/13 - id: GPIOA_10 + id: A10 class: outputs function: High Side Output type: hs ts_name: Out 8 - pin: 4/14 - id: GPIOA_9 + id: A9 class: outputs function: High Side Output type: hs ts_name: Out 7 - pin: 5/15 - id: GPIOA_8 + id: A8 class: outputs function: High Side Output type: hs ts_name: Out 6 - pin: 6/16 - id: GPIOC_9 + id: C9 class: outputs function: High Side Output type: hs ts_name: Out 5 - pin: 7/17 - id: GPIOA_3 + id: A3 class: outputs function: High Side Output type: hs ts_name: Out 4 - pin: 8/18 - id: GPIOA_2 + id: A2 class: outputs function: High Side Output type: hs ts_name: Out 3 - pin: 9/19 - id: GPIOA_1 + id: A1 class: outputs function: High Side Output type: hs ts_name: Out 2 - pin: 10/20 - id: GPIOA_0 + id: A0 class: outputs function: High Side Output type: hs diff --git a/firmware/config/engines/GY6_139QMB.cpp b/firmware/config/engines/GY6_139QMB.cpp index 0d944b81d0..a801712683 100644 --- a/firmware/config/engines/GY6_139QMB.cpp +++ b/firmware/config/engines/GY6_139QMB.cpp @@ -40,8 +40,8 @@ void setGy6139qmbDefaultEngineConfiguration() { engineConfiguration->trigger.customTotalToothCount = 8; engineConfiguration->trigger.customSkippedToothCount = 1; - engineConfiguration->injectionPins[0] = GPIOC_9; - engineConfiguration->ignitionPins[0] = GPIOC_8; + engineConfiguration->injectionPins[0] = Gpio::C9; + engineConfiguration->ignitionPins[0] = Gpio::C8; // set injection_mode 1 engineConfiguration->injectionMode = IM_SEQUENTIAL; diff --git a/firmware/config/engines/bmw_m73.cpp b/firmware/config/engines/bmw_m73.cpp index ddd0281e11..7926a78d84 100644 --- a/firmware/config/engines/bmw_m73.cpp +++ b/firmware/config/engines/bmw_m73.cpp @@ -135,26 +135,26 @@ void setEngineBMW_M73_Manhattan() { Nucleo boards - first step is to confirm that I can blink via each pin going clockwise from top-right corner -GPIOA_10 USD ID -GPIOA_11 USD DM -GPIOA_12 USD DP +Gpio::A10 USD ID +Gpio::A11 USD DM +Gpio::A12 USD DP E_4: running Good GPIO: -GPIOC_9 ETB#1 -GPIOC_8 ETB#1 -GPIOB_8 ETB#2 -GPIOB_9 ETB#2 -GPIOC_5 -GPIOA_7 -GPIOA_6 +Gpio::C9 ETB#1 +Gpio::C8 ETB#1 +Gpio::B8 ETB#2 +Gpio::B9 ETB#2 +Gpio::C5 +Gpio::A7 +Gpio::A6 */ - engineConfiguration->fuelPumpPin = GPIO_UNASSIGNED; - engineConfiguration->idle.solenoidPin = GPIO_UNASSIGNED; - engineConfiguration->fanPin = GPIO_UNASSIGNED; + engineConfiguration->fuelPumpPin = Gpio::Unassigned; + engineConfiguration->idle.solenoidPin = Gpio::Unassigned; + engineConfiguration->fanPin = Gpio::Unassigned; /** * Yellow op-amp board @@ -177,35 +177,35 @@ GPIOA_6 engineConfiguration->tps2_1AdcChannel = EFI_ADC_4; // PA4 // PWM pin - engineConfiguration->etbIo[0].controlPin = GPIO_UNASSIGNED; + engineConfiguration->etbIo[0].controlPin = Gpio::Unassigned; // DIR pin - engineConfiguration->etbIo[0].directionPin1 = GPIOC_8; - engineConfiguration->etbIo[0].directionPin2 = GPIOC_9; + engineConfiguration->etbIo[0].directionPin1 = Gpio::C8; + engineConfiguration->etbIo[0].directionPin2 = Gpio::C9; engineConfiguration->etb_use_two_wires = true; // PWM pin - engineConfiguration->etbIo[1].controlPin = GPIO_UNASSIGNED; + engineConfiguration->etbIo[1].controlPin = Gpio::Unassigned; // DIR pin - engineConfiguration->etbIo[1].directionPin1 = GPIOB_9; - engineConfiguration->etbIo[1].directionPin2 = GPIOB_8; + engineConfiguration->etbIo[1].directionPin1 = Gpio::B9; + engineConfiguration->etbIo[1].directionPin2 = Gpio::B8; engineConfiguration->tps2Min = engineConfiguration->tpsMin; engineConfiguration->tps2Max = engineConfiguration->tpsMax; - engineConfiguration->injectionPins[0] = GPIO_UNASSIGNED; - engineConfiguration->injectionPins[1] = GPIO_UNASSIGNED; - engineConfiguration->injectionPins[2] = GPIO_UNASSIGNED; - engineConfiguration->injectionPins[3] = GPIO_UNASSIGNED; - engineConfiguration->injectionPins[4] = GPIO_UNASSIGNED; - engineConfiguration->injectionPins[5] = GPIO_UNASSIGNED; + engineConfiguration->injectionPins[0] = Gpio::Unassigned; + engineConfiguration->injectionPins[1] = Gpio::Unassigned; + engineConfiguration->injectionPins[2] = Gpio::Unassigned; + engineConfiguration->injectionPins[3] = Gpio::Unassigned; + engineConfiguration->injectionPins[4] = Gpio::Unassigned; + engineConfiguration->injectionPins[5] = Gpio::Unassigned; - engineConfiguration->injectionPins[6] = GPIO_UNASSIGNED; - engineConfiguration->injectionPins[7] = GPIO_UNASSIGNED; - engineConfiguration->injectionPins[8] = GPIO_UNASSIGNED; - engineConfiguration->injectionPins[9] = GPIO_UNASSIGNED; - engineConfiguration->injectionPins[10] = GPIO_UNASSIGNED; - engineConfiguration->injectionPins[11] = GPIO_UNASSIGNED; + engineConfiguration->injectionPins[6] = Gpio::Unassigned; + engineConfiguration->injectionPins[7] = Gpio::Unassigned; + engineConfiguration->injectionPins[8] = Gpio::Unassigned; + engineConfiguration->injectionPins[9] = Gpio::Unassigned; + engineConfiguration->injectionPins[10] = Gpio::Unassigned; + engineConfiguration->injectionPins[11] = Gpio::Unassigned; } /** @@ -259,7 +259,7 @@ void setEngineBMW_M73_Proteus() { // set_trigger_input_pin 0 PE7 engineConfiguration->triggerInputPins[0] = PROTEUS_VR_1; - // GPIOE_11: "Digital 2" + // Gpio::E11: "Digital 2" engineConfiguration->camInputs[0] = PROTEUS_DIGITAL_2; // set vbatt_divider 8.16 @@ -272,10 +272,10 @@ void setEngineBMW_M73_Proteus() { engineConfiguration->clt.adcChannel = PROTEUS_IN_ANALOG_TEMP_4; - // GPIOE_0: "Lowside 14" - engineConfiguration->starterControlPin = GPIOE_0; - // GPIOE_12: "Digital 3" - engineConfiguration->startStopButtonPin = GPIOE_12; + // Gpio::E0: "Lowside 14" + engineConfiguration->starterControlPin = Gpio::E0; + // Gpio::E12: "Digital 3" + engineConfiguration->startStopButtonPin = Gpio::E12; engineConfiguration->startStopButtonMode = PI_PULLUP; setProteusHitachiEtbDefaults(); diff --git a/firmware/config/engines/bmw_m73_mre.cpp b/firmware/config/engines/bmw_m73_mre.cpp index 89e3c11cde..9ca19e5d00 100644 --- a/firmware/config/engines/bmw_m73_mre.cpp +++ b/firmware/config/engines/bmw_m73_mre.cpp @@ -84,11 +84,11 @@ void setEngineBMW_M73_microRusEfi() { engineConfiguration->etb.iFactor = 0.35; // 22 - AN Temp 4, orange wire - engineConfiguration->startStopButtonPin = GPIOA_3; + engineConfiguration->startStopButtonPin = Gpio::A3; #if (BOARD_TLE8888_COUNT > 0) // "43 - GP Out 4" - engineConfiguration->starterControlPin = TLE8888_PIN_24; + engineConfiguration->starterControlPin = Gpio::TLE8888_PIN_24; #endif /* BOARD_TLE8888_COUNT */ diff --git a/firmware/config/engines/chevrolet_camaro_4.cpp b/firmware/config/engines/chevrolet_camaro_4.cpp index 783b4d2ef7..56a0b1e937 100644 --- a/firmware/config/engines/chevrolet_camaro_4.cpp +++ b/firmware/config/engines/chevrolet_camaro_4.cpp @@ -24,8 +24,8 @@ void setCamaro4() { strcpy(engineConfiguration->engineMake, ENGINE_MAKE_GM); engineConfiguration->specs.firingOrder = FO_1_8_7_2_6_5_4_3; - engineConfiguration->triggerInputPins[0] = GPIOA_5; - engineConfiguration->triggerInputPins[1] = GPIOC_6; + engineConfiguration->triggerInputPins[0] = Gpio::A5; + engineConfiguration->triggerInputPins[1] = Gpio::C6; engineConfiguration->injectionMode = IM_BATCH; engineConfiguration->twoWireBatchInjection = true; @@ -56,31 +56,31 @@ void setCamaro4() { engineConfiguration->afr.hwChannel = EFI_ADC_13; - engineConfiguration->idle.solenoidPin = GPIO_UNASSIGNED; - engineConfiguration->fuelPumpPin = GPIO_UNASSIGNED; + engineConfiguration->idle.solenoidPin = Gpio::Unassigned; + engineConfiguration->fuelPumpPin = Gpio::Unassigned; - engineConfiguration->injectionPins[0] = GPIOE_6; - engineConfiguration->injectionPins[1] = GPIOE_5; - engineConfiguration->injectionPins[2] = GPIOD_7; - engineConfiguration->injectionPins[3] = GPIOC_13; - engineConfiguration->injectionPins[4] = GPIOE_3; - engineConfiguration->injectionPins[5] = GPIOE_4; - engineConfiguration->injectionPins[6] = GPIOD_3; - engineConfiguration->injectionPins[7] = GPIOE_2; + engineConfiguration->injectionPins[0] = Gpio::E6; + engineConfiguration->injectionPins[1] = Gpio::E5; + engineConfiguration->injectionPins[2] = Gpio::D7; + engineConfiguration->injectionPins[3] = Gpio::C13; + engineConfiguration->injectionPins[4] = Gpio::E3; + engineConfiguration->injectionPins[5] = Gpio::E4; + engineConfiguration->injectionPins[6] = Gpio::D3; + engineConfiguration->injectionPins[7] = Gpio::E2; - engineConfiguration->ignitionPins[0] = GPIOC_9; - engineConfiguration->ignitionPins[1] = GPIOC_7; - engineConfiguration->ignitionPins[2] = GPIOE_14; - engineConfiguration->ignitionPins[3] = GPIOE_12; - engineConfiguration->ignitionPins[4] = GPIOE_10; - engineConfiguration->ignitionPins[5] = GPIOE_8; - engineConfiguration->ignitionPins[6] = GPIOD_9; - engineConfiguration->ignitionPins[7] = GPIOD_8; + engineConfiguration->ignitionPins[0] = Gpio::C9; + engineConfiguration->ignitionPins[1] = Gpio::C7; + engineConfiguration->ignitionPins[2] = Gpio::E14; + engineConfiguration->ignitionPins[3] = Gpio::E12; + engineConfiguration->ignitionPins[4] = Gpio::E10; + engineConfiguration->ignitionPins[5] = Gpio::E8; + engineConfiguration->ignitionPins[6] = Gpio::D9; + engineConfiguration->ignitionPins[7] = Gpio::D8; - engineConfiguration->fuelPumpPin = GPIOB_8; - engineConfiguration->fanPin = GPIO_UNASSIGNED; - engineConfiguration->mainRelayPin = GPIOD_5; + engineConfiguration->fuelPumpPin = Gpio::B8; + engineConfiguration->fanPin = Gpio::Unassigned; + engineConfiguration->mainRelayPin = Gpio::D5; } diff --git a/firmware/config/engines/citroenBerlingoTU3JP.cpp b/firmware/config/engines/citroenBerlingoTU3JP.cpp index 7397e6ae0e..1b7d40a6af 100644 --- a/firmware/config/engines/citroenBerlingoTU3JP.cpp +++ b/firmware/config/engines/citroenBerlingoTU3JP.cpp @@ -56,35 +56,35 @@ void setCitroenBerlingoTU3JPConfiguration() { // Frankenstein lo-side output #11: PB8 Main relay // Frankenstein lo-side output #12: PB9 Fuel pump - engineConfiguration->ignitionPins[0] = GPIOC_14; - engineConfiguration->ignitionPins[1] = GPIO_UNASSIGNED; - engineConfiguration->ignitionPins[2] = GPIOC_15; - engineConfiguration->ignitionPins[3] = GPIO_UNASSIGNED; + engineConfiguration->ignitionPins[0] = Gpio::C14; + engineConfiguration->ignitionPins[1] = Gpio::Unassigned; + engineConfiguration->ignitionPins[2] = Gpio::C15; + engineConfiguration->ignitionPins[3] = Gpio::Unassigned; engineConfiguration->injector.flow = 137; //SIEMENS DEKA VAZ20734 - engineConfiguration->injectionPins[0] = GPIOE_6; - engineConfiguration->injectionPins[1] = GPIOC_13; - engineConfiguration->injectionPins[2] = GPIO_UNASSIGNED; - engineConfiguration->injectionPins[3] = GPIO_UNASSIGNED; + engineConfiguration->injectionPins[0] = Gpio::E6; + engineConfiguration->injectionPins[1] = Gpio::C13; + engineConfiguration->injectionPins[2] = Gpio::Unassigned; + engineConfiguration->injectionPins[3] = Gpio::Unassigned; - engineConfiguration->fanPin = GPIOE_0; + engineConfiguration->fanPin = Gpio::E0; engineConfiguration->fanPinMode = OM_DEFAULT; engineConfiguration->fanOffTemperature = 95; engineConfiguration->fanOnTemperature = 99; - engineConfiguration->malfunctionIndicatorPin = GPIOE_1; + engineConfiguration->malfunctionIndicatorPin = Gpio::E1; engineConfiguration->malfunctionIndicatorPinMode = OM_DEFAULT; - engineConfiguration->mainRelayPin = GPIOB_8; + engineConfiguration->mainRelayPin = Gpio::B8; - engineConfiguration->fuelPumpPin = GPIOB_9; + engineConfiguration->fuelPumpPin = Gpio::B9; engineConfiguration->fuelPumpPinMode = OM_DEFAULT; setFrankenso_01_LCD(engineConfiguration); -// engineConfiguration->o2heaterPin = GPIOC_13; -// engineConfiguration->logicAnalyzerPins[1] = GPIO_UNASSIGNED; +// engineConfiguration->o2heaterPin = Gpio::C13; +// engineConfiguration->logicAnalyzerPins[1] = Gpio::Unassigned; /** * Inputs diff --git a/firmware/config/engines/custom_engine.cpp b/firmware/config/engines/custom_engine.cpp index 243efde3f7..4ccaec8317 100644 --- a/firmware/config/engines/custom_engine.cpp +++ b/firmware/config/engines/custom_engine.cpp @@ -66,21 +66,21 @@ void runSchedulingPrecisionTestIfNeeded(void) { #endif /* EFI_PROD_CODE */ void setFrankenso_01_LCD(engine_configuration_s *engineConfiguration) { - engineConfiguration->HD44780_rs = GPIOE_7; - engineConfiguration->HD44780_e = GPIOE_9; - engineConfiguration->HD44780_db4 = GPIOE_11; - engineConfiguration->HD44780_db5 = GPIOE_13; - engineConfiguration->HD44780_db6 = GPIOE_15; - engineConfiguration->HD44780_db7 = GPIOB_10; + engineConfiguration->HD44780_rs = Gpio::E7; + engineConfiguration->HD44780_e = Gpio::E9; + engineConfiguration->HD44780_db4 = Gpio::E11; + engineConfiguration->HD44780_db5 = Gpio::E13; + engineConfiguration->HD44780_db6 = Gpio::E15; + engineConfiguration->HD44780_db7 = Gpio::B10; } void disableLCD(engine_configuration_s *engineConfiguration) { - engineConfiguration->HD44780_rs = GPIO_UNASSIGNED; - engineConfiguration->HD44780_e = GPIO_UNASSIGNED; - engineConfiguration->HD44780_db4 = GPIO_UNASSIGNED; - engineConfiguration->HD44780_db5 = GPIO_UNASSIGNED; - engineConfiguration->HD44780_db6 = GPIO_UNASSIGNED; - engineConfiguration->HD44780_db7 = GPIO_UNASSIGNED; + engineConfiguration->HD44780_rs = Gpio::Unassigned; + engineConfiguration->HD44780_e = Gpio::Unassigned; + engineConfiguration->HD44780_db4 = Gpio::Unassigned; + engineConfiguration->HD44780_db5 = Gpio::Unassigned; + engineConfiguration->HD44780_db6 = Gpio::Unassigned; + engineConfiguration->HD44780_db7 = Gpio::Unassigned; } // todo: should this be part of more default configurations? @@ -135,17 +135,17 @@ void setFrankensoConfiguration() { // Frankenso low out #11: PB8 injector #3 // Frankenso low out #12: PB7 injector #4 - engineConfiguration->fuelPumpPin = GPIOE_4; - engineConfiguration->mainRelayPin = GPIOD_7; - engineConfiguration->idle.solenoidPin = GPIOC_13; + engineConfiguration->fuelPumpPin = Gpio::E4; + engineConfiguration->mainRelayPin = Gpio::D7; + engineConfiguration->idle.solenoidPin = Gpio::C13; - engineConfiguration->fanPin = GPIOE_5; + engineConfiguration->fanPin = Gpio::E5; - engineConfiguration->injectionPins[0] = GPIOB_9; // #1 - engineConfiguration->injectionPins[1] = GPIOE_2; // #2 - engineConfiguration->injectionPins[2] = GPIOB_8; // #3 + engineConfiguration->injectionPins[0] = Gpio::B9; // #1 + engineConfiguration->injectionPins[1] = Gpio::E2; // #2 + engineConfiguration->injectionPins[2] = Gpio::B8; // #3 #ifndef EFI_INJECTOR_PIN3 - engineConfiguration->injectionPins[3] = GPIOB_7; // #4 + engineConfiguration->injectionPins[3] = Gpio::B7; // #4 #else /* EFI_INJECTOR_PIN3 */ engineConfiguration->injectionPins[3] = EFI_INJECTOR_PIN3; // #4 #endif /* EFI_INJECTOR_PIN3 */ @@ -153,14 +153,14 @@ void setFrankensoConfiguration() { setAlgorithm(LM_SPEED_DENSITY); #if EFI_PWM_TESTER - engineConfiguration->injectionPins[4] = GPIOC_8; // #5 - engineConfiguration->injectionPins[5] = GPIOD_10; // #6 - engineConfiguration->injectionPins[6] = GPIOD_9; - engineConfiguration->injectionPins[7] = GPIOD_11; - engineConfiguration->injectionPins[8] = GPIOD_0; - engineConfiguration->injectionPins[9] = GPIOB_11; - engineConfiguration->injectionPins[10] = GPIOC_7; - engineConfiguration->injectionPins[11] = GPIOE_4; + engineConfiguration->injectionPins[4] = Gpio::C8; // #5 + engineConfiguration->injectionPins[5] = Gpio::D10; // #6 + engineConfiguration->injectionPins[6] = Gpio::D9; + engineConfiguration->injectionPins[7] = Gpio::D11; + engineConfiguration->injectionPins[8] = Gpio::D0; + engineConfiguration->injectionPins[9] = Gpio::B11; + engineConfiguration->injectionPins[10] = Gpio::C7; + engineConfiguration->injectionPins[11] = Gpio::E4; /** * We want to initialize all outputs for test @@ -169,20 +169,20 @@ void setFrankensoConfiguration() { engineConfiguration->displayMode = DM_NONE; #else /* EFI_PWM_TESTER */ - engineConfiguration->injectionPins[4] = GPIO_UNASSIGNED; - engineConfiguration->injectionPins[5] = GPIO_UNASSIGNED; - engineConfiguration->injectionPins[6] = GPIO_UNASSIGNED; - engineConfiguration->injectionPins[7] = GPIO_UNASSIGNED; - engineConfiguration->injectionPins[8] = GPIO_UNASSIGNED; - engineConfiguration->injectionPins[9] = GPIO_UNASSIGNED; - engineConfiguration->injectionPins[10] = GPIO_UNASSIGNED; - engineConfiguration->injectionPins[11] = GPIO_UNASSIGNED; + engineConfiguration->injectionPins[4] = Gpio::Unassigned; + engineConfiguration->injectionPins[5] = Gpio::Unassigned; + engineConfiguration->injectionPins[6] = Gpio::Unassigned; + engineConfiguration->injectionPins[7] = Gpio::Unassigned; + engineConfiguration->injectionPins[8] = Gpio::Unassigned; + engineConfiguration->injectionPins[9] = Gpio::Unassigned; + engineConfiguration->injectionPins[10] = Gpio::Unassigned; + engineConfiguration->injectionPins[11] = Gpio::Unassigned; - engineConfiguration->ignitionPins[0] = GPIOE_14; - engineConfiguration->ignitionPins[1] = GPIOC_7; - engineConfiguration->ignitionPins[2] = GPIOC_9; + engineConfiguration->ignitionPins[0] = Gpio::E14; + engineConfiguration->ignitionPins[1] = Gpio::C7; + engineConfiguration->ignitionPins[2] = Gpio::C9; // set_ignition_pin 4 PE10 - engineConfiguration->ignitionPins[3] = GPIOE_10; + engineConfiguration->ignitionPins[3] = Gpio::E10; #endif /* EFI_PWM_TESTER */ // todo: 8.2 or 10k? @@ -208,38 +208,38 @@ void setFrankensoBoardTestConfiguration() { // set ignition_mode 1 engineConfiguration->ignitionMode = IM_INDIVIDUAL_COILS; - engineConfiguration->injectionPins[0] = GPIOB_7; // injector in default pinout - engineConfiguration->injectionPins[1] = GPIOB_8; // injector in default pinout - engineConfiguration->injectionPins[2] = GPIOB_9; // injector in default pinout - engineConfiguration->injectionPins[3] = GPIOC_13; + engineConfiguration->injectionPins[0] = Gpio::B7; // injector in default pinout + engineConfiguration->injectionPins[1] = Gpio::B8; // injector in default pinout + engineConfiguration->injectionPins[2] = Gpio::B9; // injector in default pinout + engineConfiguration->injectionPins[3] = Gpio::C13; - engineConfiguration->injectionPins[4] = GPIOD_3; - engineConfiguration->injectionPins[5] = GPIOD_5; - engineConfiguration->injectionPins[6] = GPIOD_7; - engineConfiguration->injectionPins[7] = GPIOE_2; // injector in default pinout - engineConfiguration->injectionPins[8] = GPIOE_3; - engineConfiguration->injectionPins[9] = GPIOE_4; - engineConfiguration->injectionPins[10] = GPIOE_5; - engineConfiguration->injectionPins[11] = GPIOE_6; + engineConfiguration->injectionPins[4] = Gpio::D3; + engineConfiguration->injectionPins[5] = Gpio::D5; + engineConfiguration->injectionPins[6] = Gpio::D7; + engineConfiguration->injectionPins[7] = Gpio::E2; // injector in default pinout + engineConfiguration->injectionPins[8] = Gpio::E3; + engineConfiguration->injectionPins[9] = Gpio::E4; + engineConfiguration->injectionPins[10] = Gpio::E5; + engineConfiguration->injectionPins[11] = Gpio::E6; - engineConfiguration->fuelPumpPin = GPIO_UNASSIGNED; - engineConfiguration->mainRelayPin = GPIO_UNASSIGNED; - engineConfiguration->idle.solenoidPin = GPIO_UNASSIGNED; - engineConfiguration->fanPin = GPIO_UNASSIGNED; + engineConfiguration->fuelPumpPin = Gpio::Unassigned; + engineConfiguration->mainRelayPin = Gpio::Unassigned; + engineConfiguration->idle.solenoidPin = Gpio::Unassigned; + engineConfiguration->fanPin = Gpio::Unassigned; - engineConfiguration->ignitionPins[0] = GPIOC_9; // coil in default pinout - engineConfiguration->ignitionPins[1] = GPIOC_7; // coil in default pinout - engineConfiguration->ignitionPins[2] = GPIOE_10; // coil in default pinout - engineConfiguration->ignitionPins[3] = GPIOE_8; // Miata VVT tach + engineConfiguration->ignitionPins[0] = Gpio::C9; // coil in default pinout + engineConfiguration->ignitionPins[1] = Gpio::C7; // coil in default pinout + engineConfiguration->ignitionPins[2] = Gpio::E10; // coil in default pinout + engineConfiguration->ignitionPins[3] = Gpio::E8; // Miata VVT tach - engineConfiguration->ignitionPins[4] = GPIOE_14; // coil in default pinout - engineConfiguration->ignitionPins[5] = GPIOE_12; - engineConfiguration->ignitionPins[6] = GPIOD_8; - engineConfiguration->ignitionPins[7] = GPIOD_9; + engineConfiguration->ignitionPins[4] = Gpio::E14; // coil in default pinout + engineConfiguration->ignitionPins[5] = Gpio::E12; + engineConfiguration->ignitionPins[6] = Gpio::D8; + engineConfiguration->ignitionPins[7] = Gpio::D9; - engineConfiguration->ignitionPins[8] = GPIOE_0; // brain board, not discovery - engineConfiguration->ignitionPins[9] = GPIOE_1; // brain board, not discovery + engineConfiguration->ignitionPins[8] = Gpio::E0; // brain board, not discovery + engineConfiguration->ignitionPins[9] = Gpio::E1; // brain board, not discovery } @@ -261,16 +261,16 @@ void setEtbTestConfiguration() { engineConfiguration->trigger.type = TT_TOOTHED_WHEEL_60_2; - engineConfiguration->ignitionPins[0] = GPIO_UNASSIGNED; - engineConfiguration->ignitionPins[1] = GPIO_UNASSIGNED; - engineConfiguration->ignitionPins[2] = GPIO_UNASSIGNED; - engineConfiguration->ignitionPins[3] = GPIO_UNASSIGNED; + engineConfiguration->ignitionPins[0] = Gpio::Unassigned; + engineConfiguration->ignitionPins[1] = Gpio::Unassigned; + engineConfiguration->ignitionPins[2] = Gpio::Unassigned; + engineConfiguration->ignitionPins[3] = Gpio::Unassigned; /** * remember that some H-bridges require 5v control lines, not just 3v logic outputs we have on stm32 */ - engineConfiguration->etbIo[0].directionPin1 = GPIOC_7; // Frankenso high-side in order to get 5v control - engineConfiguration->etbIo[0].directionPin2 = GPIOC_9; - engineConfiguration->etbIo[0].controlPin = GPIOE_14; + engineConfiguration->etbIo[0].directionPin1 = Gpio::C7; // Frankenso high-side in order to get 5v control + engineConfiguration->etbIo[0].directionPin2 = Gpio::C9; + engineConfiguration->etbIo[0].controlPin = Gpio::E14; #if EFI_ELECTRONIC_THROTTLE_BODY setBoschVNH2SP30Curve(); @@ -282,9 +282,9 @@ void setEtbTestConfiguration() { // turning off other PWMs to simplify debugging engineConfiguration->triggerSimulatorFrequency = 0; - engineConfiguration->stepperEnablePin = GPIO_UNASSIGNED; - engineConfiguration->idle.stepperStepPin = GPIO_UNASSIGNED; - engineConfiguration->idle.stepperDirectionPin = GPIO_UNASSIGNED; + engineConfiguration->stepperEnablePin = Gpio::Unassigned; + engineConfiguration->idle.stepperStepPin = Gpio::Unassigned; + engineConfiguration->idle.stepperDirectionPin = Gpio::Unassigned; engineConfiguration->useStepperIdle = true; // no analog dividers - all sensors with 3v supply, naked discovery bench setup @@ -336,11 +336,11 @@ static I2CEepromFileStream ifile; */ void setEepromTestConfiguration() { engineConfiguration->useEeprom = true; - engineConfiguration->ignitionPins[2] = GPIO_UNASSIGNED; + engineConfiguration->ignitionPins[2] = Gpio::Unassigned; // dirty hack - brain_pin_markUnused(GPIOC_9); - efiSetPadMode("I2C", GPIOA_8, PAL_MODE_ALTERNATE(4)); - efiSetPadMode("I2C", GPIOC_9, PAL_MODE_ALTERNATE(4)); + brain_pin_markUnused(Gpio::C9); + efiSetPadMode("I2C", Gpio::A8, PAL_MODE_ALTERNATE(4)); + efiSetPadMode("I2C", Gpio::C9, PAL_MODE_ALTERNATE(4)); addConsoleActionI("ee_read", @@ -372,15 +372,15 @@ void setL9779TestConfiguration() { engineConfiguration->is_enabled_spi_3 = true; // Wire up spi3 // green - engineConfiguration->spi3mosiPin = GPIOB_5; + engineConfiguration->spi3mosiPin = Gpio::B5; // blue - engineConfiguration->spi3misoPin = GPIOB_4; + engineConfiguration->spi3misoPin = Gpio::B4; // white - engineConfiguration->spi3sckPin = GPIOB_3; + engineConfiguration->spi3sckPin = Gpio::B3; engineConfiguration->l9779spiDevice = SPI_DEVICE_3; // orange - engineConfiguration->l9779_cs = GPIOD_5; + engineConfiguration->l9779_cs = Gpio::D5; } // TLE8888_BENCH_ENGINE @@ -393,28 +393,28 @@ void setTle8888TestConfiguration() { engineConfiguration->crankingInjectionMode = IM_SEQUENTIAL; #if defined(STM32_HAS_GPIOG) && STM32_HAS_GPIOG - engineConfiguration->ignitionPins[0] = GPIOG_3; - engineConfiguration->ignitionPins[1] = GPIOG_4; - engineConfiguration->ignitionPins[2] = GPIOG_5; - engineConfiguration->ignitionPins[3] = GPIOG_6; - engineConfiguration->ignitionPins[4] = GPIOG_7; - engineConfiguration->ignitionPins[5] = GPIOG_8; + engineConfiguration->ignitionPins[0] = Gpio::G3; + engineConfiguration->ignitionPins[1] = Gpio::G4; + engineConfiguration->ignitionPins[2] = Gpio::G5; + engineConfiguration->ignitionPins[3] = Gpio::G6; + engineConfiguration->ignitionPins[4] = Gpio::G7; + engineConfiguration->ignitionPins[5] = Gpio::G8; #endif /* STM32_HAS_GPIOG */ - engineConfiguration->ignitionPins[6] = GPIOC_6; - engineConfiguration->ignitionPins[7] = GPIOC_7; + engineConfiguration->ignitionPins[6] = Gpio::C6; + engineConfiguration->ignitionPins[7] = Gpio::C7; #if (BOARD_TLE8888_COUNT > 0) engineConfiguration->tle8888spiDevice = SPI_DEVICE_1; - engineConfiguration->tle8888_cs = GPIOD_5; + engineConfiguration->tle8888_cs = Gpio::D5; // PB3 is nicely both SWO and SPI1 SCK so logic analyzer could be used on SWO header - engineConfiguration->spi1mosiPin = GPIOB_5; - engineConfiguration->spi1misoPin = GPIOB_4; - engineConfiguration->spi1sckPin = GPIOB_3; // please note that this pin is also SWO/SWD - Single Wire debug Output + engineConfiguration->spi1mosiPin = Gpio::B5; + engineConfiguration->spi1misoPin = Gpio::B4; + engineConfiguration->spi1sckPin = Gpio::B3; // please note that this pin is also SWO/SWD - Single Wire debug Output engineConfiguration->is_enabled_spi_1 = true; engineConfiguration->debugMode = DBG_TLE8888; - engineConfiguration->fuelPumpPin = TLE8888_PIN_20; + engineConfiguration->fuelPumpPin = Gpio::TLE8888_PIN_20; #endif /* BOARD_TLE8888_COUNT */ engineConfiguration->throttlePedalPositionAdcChannel = EFI_ADC_9; // PB1 // just any non-empty value for now @@ -425,9 +425,9 @@ void setTle8888TestConfiguration() { // IN2 PF14 // SF PF11 #if defined(STM32_HAS_GPIOF) && STM32_HAS_GPIOF - engineConfiguration->etbIo[0].directionPin1 = GPIOF_15; - engineConfiguration->etbIo[0].directionPin2 = GPIOF_14; - engineConfiguration->etbIo[0].disablePin = GPIOF_12; + engineConfiguration->etbIo[0].directionPin1 = Gpio::F15; + engineConfiguration->etbIo[0].directionPin2 = Gpio::F14; + engineConfiguration->etbIo[0].disablePin = Gpio::F12; #endif /* STM32_HAS_GPIOF */ engineConfiguration->etb_use_two_wires = true; engineConfiguration->isHip9011Enabled = false; @@ -439,9 +439,9 @@ void setTle8888TestConfiguration() { // IN2 PE4 // SF PE3 - engineConfiguration->etbIo[0].directionPin1 = GPIOE_2; - engineConfiguration->etbIo[0].directionPin2 = GPIOE_4; - engineConfiguration->etbIo[0].disablePin = GPIOE_5; + engineConfiguration->etbIo[0].directionPin1 = Gpio::E2; + engineConfiguration->etbIo[0].directionPin2 = Gpio::E4; + engineConfiguration->etbIo[0].disablePin = Gpio::E5; engineConfiguration->tps1_1AdcChannel = EFI_ADC_3; // PA3 @@ -523,64 +523,64 @@ static void mreBoardOldTest() { engineConfiguration->specs.firingOrder = FO_1_10_9_4_3_6_5_8_7_2; // red LED #1 - engineConfiguration->ignitionPins[1 - 1] = GPIOD_4; - engineConfiguration->ignitionPins[10 - 1] = GPIOD_3; - engineConfiguration->ignitionPins[9 - 1] = GPIOD_6; - engineConfiguration->ignitionPins[4 - 1] = GPIOD_7; - engineConfiguration->ignitionPins[3 - 1] = GPIOD_1; - engineConfiguration->ignitionPins[6 - 1] = GPIOD_2; - engineConfiguration->ignitionPins[1] = GPIO_UNASSIGNED; - engineConfiguration->ignitionPins[4] = GPIO_UNASSIGNED; - engineConfiguration->ignitionPins[6] = GPIO_UNASSIGNED; - engineConfiguration->ignitionPins[7] = GPIO_UNASSIGNED; + engineConfiguration->ignitionPins[1 - 1] = Gpio::D4; + engineConfiguration->ignitionPins[10 - 1] = Gpio::D3; + engineConfiguration->ignitionPins[9 - 1] = Gpio::D6; + engineConfiguration->ignitionPins[4 - 1] = Gpio::D7; + engineConfiguration->ignitionPins[3 - 1] = Gpio::D1; + engineConfiguration->ignitionPins[6 - 1] = Gpio::D2; + engineConfiguration->ignitionPins[1] = Gpio::Unassigned; + engineConfiguration->ignitionPins[4] = Gpio::Unassigned; + engineConfiguration->ignitionPins[6] = Gpio::Unassigned; + engineConfiguration->ignitionPins[7] = Gpio::Unassigned; - engineConfiguration->fuelPumpPin = GPIO_UNASSIGNED; - engineConfiguration->idle.solenoidPin = GPIO_UNASSIGNED; - engineConfiguration->fanPin = GPIO_UNASSIGNED; + engineConfiguration->fuelPumpPin = Gpio::Unassigned; + engineConfiguration->idle.solenoidPin = Gpio::Unassigned; + engineConfiguration->fanPin = Gpio::Unassigned; // fuel pump is useful to test power on/off scenario -// engineConfiguration->fuelPumpPin = TLE8888_PIN_22; +// engineConfiguration->fuelPumpPin = Gpio::TLE8888_PIN_22; // LED #1 - // TLE8888_PIN_22: "34 - GP Out 2" - engineConfiguration->injectionPins[1 - 1] = TLE8888_PIN_22; + // Gpio::TLE8888_PIN_22: "34 - GP Out 2" + engineConfiguration->injectionPins[1 - 1] = Gpio::TLE8888_PIN_22; // LED #2 - // TLE8888_PIN_23: "33 - GP Out 3" - engineConfiguration->injectionPins[10 - 1] = TLE8888_PIN_23; + // Gpio::TLE8888_PIN_23: "33 - GP Out 3" + engineConfiguration->injectionPins[10 - 1] = Gpio::TLE8888_PIN_23; - // TLE8888_PIN_1: LED #3 - INJ#2 - engineConfiguration->injectionPins[9 - 1] = TLE8888_PIN_1; + // Gpio::TLE8888_PIN_1: LED #3 - INJ#2 + engineConfiguration->injectionPins[9 - 1] = Gpio::TLE8888_PIN_1; - // TLE8888_PIN_2: LED #4 - INJ#1 - engineConfiguration->injectionPins[4 - 1] = TLE8888_PIN_2; + // Gpio::TLE8888_PIN_2: LED #4 - INJ#1 + engineConfiguration->injectionPins[4 - 1] = Gpio::TLE8888_PIN_2; - // TLE8888_PIN_3: LED #5 - INJ#3 - engineConfiguration->injectionPins[3 - 1] = TLE8888_PIN_3; + // Gpio::TLE8888_PIN_3: LED #5 - INJ#3 + engineConfiguration->injectionPins[3 - 1] = Gpio::TLE8888_PIN_3; - // TLE8888_PIN_4: LED #6 - INJ#4 - engineConfiguration->injectionPins[6 - 1] = TLE8888_PIN_4; + // Gpio::TLE8888_PIN_4: LED #6 - INJ#4 + engineConfiguration->injectionPins[6 - 1] = Gpio::TLE8888_PIN_4; // LED #7 - // TLE8888_PIN_24: "43 - GP Out 4" - engineConfiguration->injectionPins[5 - 1] = TLE8888_PIN_24; + // Gpio::TLE8888_PIN_24: "43 - GP Out 4" + engineConfiguration->injectionPins[5 - 1] = Gpio::TLE8888_PIN_24; // LED #8 // TLE8888 half bridges (pushpull, lowside, or high-low) IN12 - // TLE8888_PIN_21: "35 - GP Out 1" - engineConfiguration->injectionPins[8 - 1] = TLE8888_PIN_21; + // Gpio::TLE8888_PIN_21: "35 - GP Out 1" + engineConfiguration->injectionPins[8 - 1] = Gpio::TLE8888_PIN_21; // LED #9 // TLE8888 high current low side: IN10 - // TLE8888_PIN_6: "7 - Lowside 1" - engineConfiguration->injectionPins[7 - 1] = TLE8888_PIN_6; + // Gpio::TLE8888_PIN_6: "7 - Lowside 1" + engineConfiguration->injectionPins[7 - 1] = Gpio::TLE8888_PIN_6; // LED #10 // TLE8888 high current low side: VVT2 IN9 / OUT5 - // TLE8888_PIN_5: "3 - Lowside 2" - engineConfiguration->injectionPins[2 - 1] = TLE8888_PIN_5; + // Gpio::TLE8888_PIN_5: "3 - Lowside 2" + engineConfiguration->injectionPins[2 - 1] = Gpio::TLE8888_PIN_5; #endif /* BOARD_TLE8888_COUNT */ } @@ -598,23 +598,23 @@ void proteusBoardTest() { engineConfiguration->injectionMode = IM_SEQUENTIAL; engineConfiguration->crankingInjectionMode = IM_SEQUENTIAL; - engineConfiguration->mainRelayPin = GPIO_UNASSIGNED; - engineConfiguration->fanPin = GPIO_UNASSIGNED; - engineConfiguration->fuelPumpPin = GPIO_UNASSIGNED; + engineConfiguration->mainRelayPin = Gpio::Unassigned; + engineConfiguration->fanPin = Gpio::Unassigned; + engineConfiguration->fuelPumpPin = Gpio::Unassigned; #if EFI_PROD_CODE engineConfiguration->injectionPins[0] = PROTEUS_LS_1; engineConfiguration->injectionPins[1] = PROTEUS_LS_2; engineConfiguration->injectionPins[2] = PROTEUS_LS_3; engineConfiguration->injectionPins[3] = PROTEUS_LS_4; - engineConfiguration->injectionPins[4] = GPIOG_12;// "Lowside 5" - engineConfiguration->injectionPins[5] = GPIOG_13;// "Lowside 6" - engineConfiguration->injectionPins[6] = GPIOB_5;// "Lowside 9" - engineConfiguration->injectionPins[7] = GPIOB_4;// "Lowside 8" - engineConfiguration->injectionPins[8] = GPIOB_7;// "Lowside 11" + engineConfiguration->injectionPins[4] = Gpio::G12;// "Lowside 5" + engineConfiguration->injectionPins[5] = Gpio::G13;// "Lowside 6" + engineConfiguration->injectionPins[6] = Gpio::B5;// "Lowside 9" + engineConfiguration->injectionPins[7] = Gpio::B4;// "Lowside 8" + engineConfiguration->injectionPins[8] = Gpio::B7;// "Lowside 11" engineConfiguration->injectionPins[9] = PROTEUS_LS_10; - engineConfiguration->injectionPins[10] = GPIOB_8;// "Lowside 12" - engineConfiguration->injectionPins[11] = GPIOB_9;// "Lowside 13" # pin 10/black35 + engineConfiguration->injectionPins[10] = Gpio::B8;// "Lowside 12" + engineConfiguration->injectionPins[11] = Gpio::B9;// "Lowside 13" # pin 10/black35 @@ -626,7 +626,7 @@ void proteusBoardTest() { engineConfiguration->ignitionPins[4] = PROTEUS_IGN_6; engineConfiguration->ignitionPins[5] = PROTEUS_IGN_7; - engineConfiguration->ignitionPins[6] = GPIOD_15;// "Highside 3" # pin 13/black35 + engineConfiguration->ignitionPins[6] = Gpio::D15;// "Highside 3" # pin 13/black35 engineConfiguration->ignitionPins[7] = PROTEUS_IGN_3; engineConfiguration->ignitionPins[8] = PROTEUS_IGN_9; engineConfiguration->ignitionPins[9] = PROTEUS_IGN_8; @@ -642,10 +642,10 @@ void proteusBoardTest() { void mreBCM() { for (int i = 0; i < MAX_CYLINDER_COUNT;i++) { - engineConfiguration->ignitionPins[i] = GPIO_UNASSIGNED; - engineConfiguration->injectionPins[i] = GPIO_UNASSIGNED; + engineConfiguration->ignitionPins[i] = Gpio::Unassigned; + engineConfiguration->injectionPins[i] = Gpio::Unassigned; } - engineConfiguration->fanPin = GPIO_UNASSIGNED; + engineConfiguration->fanPin = Gpio::Unassigned; engineConfiguration->consumeObdSensors = true; } @@ -703,62 +703,62 @@ void mreBoardNewTest() { engineConfiguration->specs.firingOrder = FO_1_2_3_4_5_6_7_8_9_10_11_12; #if (BOARD_TLE8888_COUNT > 0) - engineConfiguration->ignitionPins[1 - 1] = GPIOD_6; - engineConfiguration->ignitionPins[2 - 1] = GPIOD_7; - engineConfiguration->ignitionPins[3 - 1] = GPIOD_1; - engineConfiguration->ignitionPins[4 - 1] = GPIOD_2; - engineConfiguration->ignitionPins[5 - 1] = GPIOD_3; - engineConfiguration->ignitionPins[6 - 1] = GPIOD_4; + engineConfiguration->ignitionPins[1 - 1] = Gpio::D6; + engineConfiguration->ignitionPins[2 - 1] = Gpio::D7; + engineConfiguration->ignitionPins[3 - 1] = Gpio::D1; + engineConfiguration->ignitionPins[4 - 1] = Gpio::D2; + engineConfiguration->ignitionPins[5 - 1] = Gpio::D3; + engineConfiguration->ignitionPins[6 - 1] = Gpio::D4; - engineConfiguration->ignitionPins[7 - 1] = TLE8888_PIN_11; - engineConfiguration->ignitionPins[8 - 1] = TLE8888_PIN_12; + engineConfiguration->ignitionPins[7 - 1] = Gpio::TLE8888_PIN_11; + engineConfiguration->ignitionPins[8 - 1] = Gpio::TLE8888_PIN_12; // LED #8 // TLE8888 half bridges (pushpull, lowside, or high-low) IN12 - // TLE8888_PIN_21: "35 - GP Out 1" - engineConfiguration->ignitionPins[9 - 1] = TLE8888_PIN_21; + // Gpio::TLE8888_PIN_21: "35 - GP Out 1" + engineConfiguration->ignitionPins[9 - 1] = Gpio::TLE8888_PIN_21; // LED #1 - // TLE8888_PIN_22: "34 - GP Out 2" - engineConfiguration->ignitionPins[10- 1] = TLE8888_PIN_22; + // Gpio::TLE8888_PIN_22: "34 - GP Out 2" + engineConfiguration->ignitionPins[10- 1] = Gpio::TLE8888_PIN_22; // LED #2 - // TLE8888_PIN_23: "33 - GP Out 3" - engineConfiguration->ignitionPins[11 - 1] = TLE8888_PIN_23; + // Gpio::TLE8888_PIN_23: "33 - GP Out 3" + engineConfiguration->ignitionPins[11 - 1] = Gpio::TLE8888_PIN_23; // LED #7 - // TLE8888_PIN_24: "43 - GP Out 4" - engineConfiguration->ignitionPins[12 - 1] = TLE8888_PIN_24; + // Gpio::TLE8888_PIN_24: "43 - GP Out 4" + engineConfiguration->ignitionPins[12 - 1] = Gpio::TLE8888_PIN_24; engineConfiguration->afr.hwChannel = EFI_ADC_6; engineConfiguration->throttlePedalPositionAdcChannel = EFI_ADC_NONE; // TLE8888 high current low side: IN10 - // TLE8888_PIN_6: "7 - Lowside 1" - engineConfiguration->injectionPins[1 - 1] = TLE8888_PIN_6; + // Gpio::TLE8888_PIN_6: "7 - Lowside 1" + engineConfiguration->injectionPins[1 - 1] = Gpio::TLE8888_PIN_6; // TLE8888 high current low side: VVT2 IN9 / OUT5 - // TLE8888_PIN_5: "3 - Lowside 2" - engineConfiguration->injectionPins[2 - 1] = TLE8888_PIN_5; + // Gpio::TLE8888_PIN_5: "3 - Lowside 2" + engineConfiguration->injectionPins[2 - 1] = Gpio::TLE8888_PIN_5; - // TLE8888_PIN_4: INJ#4 - engineConfiguration->injectionPins[3 - 1] = TLE8888_PIN_4; - // TLE8888_PIN_3: INJ#3 - engineConfiguration->injectionPins[4 - 1] = TLE8888_PIN_3; - // TLE8888_PIN_2: INJ#2 - engineConfiguration->injectionPins[5 - 1] = TLE8888_PIN_2; - // TLE8888_PIN_1: LED #3 - INJ#1 - engineConfiguration->injectionPins[6 - 1] = TLE8888_PIN_1; + // Gpio::TLE8888_PIN_4: INJ#4 + engineConfiguration->injectionPins[3 - 1] = Gpio::TLE8888_PIN_4; + // Gpio::TLE8888_PIN_3: INJ#3 + engineConfiguration->injectionPins[4 - 1] = Gpio::TLE8888_PIN_3; + // Gpio::TLE8888_PIN_2: INJ#2 + engineConfiguration->injectionPins[5 - 1] = Gpio::TLE8888_PIN_2; + // Gpio::TLE8888_PIN_1: LED #3 - INJ#1 + engineConfiguration->injectionPins[6 - 1] = Gpio::TLE8888_PIN_1; - engineConfiguration->injectionPins[7 - 1] = GPIOA_4; // AV10 - engineConfiguration->injectionPins[8 - 1] = GPIOB_1; // AV9 - engineConfiguration->injectionPins[9 - 1] = GPIOB_0; // AV8 - engineConfiguration->injectionPins[10 - 1] = GPIOC_4; // AV6 + engineConfiguration->injectionPins[7 - 1] = Gpio::A4; // AV10 + engineConfiguration->injectionPins[8 - 1] = Gpio::B1; // AV9 + engineConfiguration->injectionPins[9 - 1] = Gpio::B0; // AV8 + engineConfiguration->injectionPins[10 - 1] = Gpio::C4; // AV6 - engineConfiguration->injectionPins[11- 1] = TLE8888_PIN_13; + engineConfiguration->injectionPins[11- 1] = Gpio::TLE8888_PIN_13; - engineConfiguration->injectionPins[12- 1] = TLE8888_PIN_10; + engineConfiguration->injectionPins[12- 1] = Gpio::TLE8888_PIN_10; #endif /* BOARD_TLE8888_COUNT */ } @@ -821,12 +821,12 @@ void setRotary() { strcpy(engineConfiguration->vehicleName, "test"); engineConfiguration->ignitionMode = IM_INDIVIDUAL_COILS; - engineConfiguration->injectionPins[2] = GPIO_UNASSIGNED; // injector in default pinout - engineConfiguration->injectionPins[3] = GPIO_UNASSIGNED; + engineConfiguration->injectionPins[2] = Gpio::Unassigned; // injector in default pinout + engineConfiguration->injectionPins[3] = Gpio::Unassigned; engineConfiguration->enableTrailingSparks = true; - engineConfiguration->trailingCoilPins[0] = GPIOC_9; - engineConfiguration->trailingCoilPins[1] = GPIOE_10; + engineConfiguration->trailingCoilPins[0] = Gpio::C9; + engineConfiguration->trailingCoilPins[1] = Gpio::E10; } /** @@ -842,32 +842,32 @@ void setTest33816EngineConfiguration() { // default spi3sckPin PB3 - engineConfiguration->triggerSimulatorPins[0] = GPIO_UNASSIGNED; - engineConfiguration->triggerSimulatorPins[1] = GPIO_UNASSIGNED; - engineConfiguration->triggerSimulatorPins[2] = GPIO_UNASSIGNED; + engineConfiguration->triggerSimulatorPins[0] = Gpio::Unassigned; + engineConfiguration->triggerSimulatorPins[1] = Gpio::Unassigned; + engineConfiguration->triggerSimulatorPins[2] = Gpio::Unassigned; - engineConfiguration->injectionPins[0] = GPIOB_9; // #1 - engineConfiguration->injectionPins[1] = GPIOE_2; // #2 - engineConfiguration->injectionPins[2] = GPIOB_8; // #3 - engineConfiguration->injectionPins[3] = GPIOB_7; // #4 + engineConfiguration->injectionPins[0] = Gpio::B9; // #1 + engineConfiguration->injectionPins[1] = Gpio::E2; // #2 + engineConfiguration->injectionPins[2] = Gpio::B8; // #3 + engineConfiguration->injectionPins[3] = Gpio::B7; // #4 // blue - engineConfiguration->mc33816_cs = GPIOD_7; + engineConfiguration->mc33816_cs = Gpio::D7; // green - engineConfiguration->mc33816_rstb = GPIOD_4; - engineConfiguration->sdCardCsPin = GPIO_UNASSIGNED; + engineConfiguration->mc33816_rstb = Gpio::D4; + engineConfiguration->sdCardCsPin = Gpio::Unassigned; // yellow - engineConfiguration->mc33816_driven = GPIOD_6; + engineConfiguration->mc33816_driven = Gpio::D6; - engineConfiguration->mc33816_flag0 = GPIOD_3; + engineConfiguration->mc33816_flag0 = Gpio::D3; // enable_spi 3 engineConfiguration->is_enabled_spi_3 = true; // Wire up spi3 - engineConfiguration->spi3mosiPin = GPIOB_5; - engineConfiguration->spi3misoPin = GPIOB_4; - engineConfiguration->spi3sckPin = GPIOB_3; + engineConfiguration->spi3mosiPin = Gpio::B5; + engineConfiguration->spi3misoPin = Gpio::B4; + engineConfiguration->spi3sckPin = Gpio::B3; engineConfiguration->isSdCardEnabled = false; @@ -898,9 +898,9 @@ void proteusLuaDemo() { -20, -18, -17, 0, 20, 21, 22, 25 }; - engineConfiguration->luaOutputPins[0] = GPIOD_12; - engineConfiguration->luaOutputPins[1] = GPIOD_10; - engineConfiguration->luaOutputPins[2] = GPIOD_11; + engineConfiguration->luaOutputPins[0] = Gpio::D12; + engineConfiguration->luaOutputPins[1] = Gpio::D10; + engineConfiguration->luaOutputPins[2] = Gpio::D11; setLinearCurve(engineConfiguration->scriptCurve2Bins, 0, 8000, 1); setLinearCurve(engineConfiguration->scriptCurve2, 0, 100, 1); @@ -913,11 +913,11 @@ void proteusLuaDemo() { // ETB direction #1 PD10 - engineConfiguration->etbIo[0].directionPin1 = GPIO_UNASSIGNED; + engineConfiguration->etbIo[0].directionPin1 = Gpio::Unassigned; // ETB control PD12 - engineConfiguration->etbIo[0].controlPin = GPIO_UNASSIGNED; + engineConfiguration->etbIo[0].controlPin = Gpio::Unassigned; // ETB disable PD11 - engineConfiguration->etbIo[0].disablePin = GPIO_UNASSIGNED; + engineConfiguration->etbIo[0].disablePin = Gpio::Unassigned; /** controlIndex = 0 diff --git a/firmware/config/engines/dodge_neon.cpp b/firmware/config/engines/dodge_neon.cpp index 5cf40f3c3e..c64cd24e26 100644 --- a/firmware/config/engines/dodge_neon.cpp +++ b/firmware/config/engines/dodge_neon.cpp @@ -29,10 +29,10 @@ void setDodgeNeon1995EngineConfiguration() { // engineConfiguration->spi2MosiMode = PAL_STM32_OTYPE_OPENDRAIN; // 4 // engineConfiguration->spi2MisoMode = PAL_STM32_PUDR_PULLUP; // 32 - // engineConfiguration->spi2mosiPin = GPIOB_15; - // engineConfiguration->spi2misoPin = GPIOB_14; - // engineConfiguration->spi2sckPin = GPIOB_13; - engineConfiguration->cj125CsPin = GPIOB_0; // rev 0.4 + // engineConfiguration->spi2mosiPin = Gpio::B15; + // engineConfiguration->spi2misoPin = Gpio::B14; + // engineConfiguration->spi2sckPin = Gpio::B13; + engineConfiguration->cj125CsPin = Gpio::B0; // rev 0.4 engineConfiguration->isCJ125Enabled = true; engineConfiguration->is_enabled_spi_2 = true; @@ -86,12 +86,12 @@ void setDodgeNeon1995EngineConfiguration() { // Frankenstein: low side - out #11: PB8 // Frankenstein: low side - out #12: PB9 - engineConfiguration->injectionPins[0] = GPIOB_9; // Frankenstein: low side - out #12 - engineConfiguration->injectionPins[1] = GPIOB_8; // Frankenstein: low side - out #11 - engineConfiguration->injectionPins[2] = GPIOE_3; // Frankenstein: low side - out #8 - engineConfiguration->injectionPins[3] = GPIOE_5; // Frankenstein: low side - out #6 + engineConfiguration->injectionPins[0] = Gpio::B9; // Frankenstein: low side - out #12 + engineConfiguration->injectionPins[1] = Gpio::B8; // Frankenstein: low side - out #11 + engineConfiguration->injectionPins[2] = Gpio::E3; // Frankenstein: low side - out #8 + engineConfiguration->injectionPins[3] = Gpio::E5; // Frankenstein: low side - out #6 - engineConfiguration->fuelPumpPin = GPIOC_13; // Frankenstein: low side - out #4 + engineConfiguration->fuelPumpPin = Gpio::C13; // Frankenstein: low side - out #4 engineConfiguration->fuelPumpPinMode = OM_DEFAULT; engineConfiguration->mapErrorDetectionTooHigh = 120; @@ -102,9 +102,9 @@ void setDodgeNeon1995EngineConfiguration() { // Frankenstein: high side #1: PE8 // Frankenstein: high side #2: PE10 - engineConfiguration->ignitionPins[0] = GPIOE_8; // Frankenstein: high side #1 - engineConfiguration->ignitionPins[1] = GPIO_UNASSIGNED; - engineConfiguration->ignitionPins[2] = GPIOE_10; // // Frankenstein: high side #2 + engineConfiguration->ignitionPins[0] = Gpio::E8; // Frankenstein: high side #1 + engineConfiguration->ignitionPins[1] = Gpio::Unassigned; + engineConfiguration->ignitionPins[2] = Gpio::E10; // // Frankenstein: high side #2 // set ignition_pin_mode 0 engineConfiguration->ignitionPinMode = OM_DEFAULT; @@ -156,7 +156,7 @@ void setDodgeNeonNGCEngineConfiguration() { setFuelTablesLoadBin(20, 120); - engineConfiguration->malfunctionIndicatorPin = GPIO_UNASSIGNED; + engineConfiguration->malfunctionIndicatorPin = Gpio::Unassigned; /** * PA4 Wideband O2 Sensor @@ -182,29 +182,29 @@ void setDodgeNeonNGCEngineConfiguration() { // Frankenso low out #11: PB8 injector #1 // Frankenso low out #12: PB7 injector #4 - engineConfiguration->fanPin = GPIOD_7; + engineConfiguration->fanPin = Gpio::D7; - engineConfiguration->injectionPins[0] = GPIOB_8; - engineConfiguration->injectionPins[1] = GPIOB_9; - engineConfiguration->injectionPins[2] = GPIOE_2; - engineConfiguration->injectionPins[3] = GPIOB_7; + engineConfiguration->injectionPins[0] = Gpio::B8; + engineConfiguration->injectionPins[1] = Gpio::B9; + engineConfiguration->injectionPins[2] = Gpio::E2; + engineConfiguration->injectionPins[3] = Gpio::B7; - engineConfiguration->ignitionPins[0] = GPIOC_9; - engineConfiguration->ignitionPins[1] = GPIO_UNASSIGNED; - engineConfiguration->ignitionPins[2] = GPIOE_8; - engineConfiguration->ignitionPins[3] = GPIO_UNASSIGNED; + engineConfiguration->ignitionPins[0] = Gpio::C9; + engineConfiguration->ignitionPins[1] = Gpio::Unassigned; + engineConfiguration->ignitionPins[2] = Gpio::E8; + engineConfiguration->ignitionPins[3] = Gpio::Unassigned; - engineConfiguration->mainRelayPin = GPIOE_6; + engineConfiguration->mainRelayPin = Gpio::E6; - engineConfiguration->idle.solenoidPin = GPIOC_13; + engineConfiguration->idle.solenoidPin = Gpio::C13; engineConfiguration->idle.solenoidFrequency = 300; engineConfiguration->manIdlePosition = 36; - engineConfiguration->fuelPumpPin = GPIOE_3; + engineConfiguration->fuelPumpPin = Gpio::E3; engineConfiguration->fuelPumpPinMode = OM_DEFAULT; - engineConfiguration->triggerInputPins[0] = GPIOA_5; - engineConfiguration->triggerInputPins[1] = GPIOC_6; + engineConfiguration->triggerInputPins[0] = Gpio::A5; + engineConfiguration->triggerInputPins[1] = Gpio::C6; /** * Frankenso analog #1 PC2 ADC12 CLT @@ -258,12 +258,12 @@ void setDodgeNeonNGCEngineConfiguration() { engineConfiguration->cylinderBore = 87.5; - engineConfiguration->clutchDownPin = GPIOC_12; + engineConfiguration->clutchDownPin = Gpio::C12; engineConfiguration->clutchDownPinMode = PI_PULLUP; -// engineConfiguration->clutchUpPin = GPIOA_14; // note SWCLK - conflict with SWD +// engineConfiguration->clutchUpPin = Gpio::A14; // note SWCLK - conflict with SWD engineConfiguration->clutchUpPinMode = PI_PULLUP; -// engineConfiguration->vehicleSpeedSensorInputPin = GPIOA_8; +// engineConfiguration->vehicleSpeedSensorInputPin = Gpio::A8; engineConfiguration->fanOnTemperature = 92; engineConfiguration->fanOffTemperature = 89; @@ -274,7 +274,7 @@ void setDodgeNeonNGCEngineConfiguration() { engineConfiguration->tunerStudioSerialSpeed = 19200; setAlgorithm(LM_SPEED_DENSITY); -//temp engineConfiguration->alternatorControlPin = GPIOD_5; +//temp engineConfiguration->alternatorControlPin = Gpio::D5; engineConfiguration->targetVBatt = 14.0; engineConfiguration->alternatorControl.offset = 20; engineConfiguration->alternatorControl.pFactor = 20; diff --git a/firmware/config/engines/ford_1995_inline_6.cpp b/firmware/config/engines/ford_1995_inline_6.cpp index 762a59a5bb..3126187f9c 100644 --- a/firmware/config/engines/ford_1995_inline_6.cpp +++ b/firmware/config/engines/ford_1995_inline_6.cpp @@ -79,13 +79,13 @@ void setFordInline6() { // output 5 is PC13 // output 6 is PC15 - engineConfiguration->fuelPumpPin = GPIOC_13; - engineConfiguration->injectionPins[0] = GPIOB_9; - engineConfiguration->injectionPins[1] = GPIOE_3; - engineConfiguration->ignitionPins[0] = GPIOC_15; + engineConfiguration->fuelPumpPin = Gpio::C13; + engineConfiguration->injectionPins[0] = Gpio::B9; + engineConfiguration->injectionPins[1] = Gpio::E3; + engineConfiguration->ignitionPins[0] = Gpio::C15; - engineConfiguration->injectionPins[2] = GPIO_UNASSIGNED; - engineConfiguration->fanPin = GPIO_UNASSIGNED; + engineConfiguration->injectionPins[2] = Gpio::Unassigned; + engineConfiguration->fanPin = Gpio::Unassigned; engineConfiguration->tpsMin = convertVoltageTo10bitADC(1.250); engineConfiguration->tpsMax = convertVoltageTo10bitADC(4.538); @@ -93,6 +93,6 @@ void setFordInline6() { // engineConfiguration->vbattAdcChannel = 0; // engineConfiguration->mafAdcChannel = EFI_ADC_1; - engineConfiguration->triggerInputPins[0] = GPIOA_8; - engineConfiguration->triggerInputPins[1] = GPIOA_5; + engineConfiguration->triggerInputPins[0] = Gpio::A8; + engineConfiguration->triggerInputPins[1] = Gpio::A5; } diff --git a/firmware/config/engines/ford_aspire.cpp b/firmware/config/engines/ford_aspire.cpp index a6b71fd632..96baa84cfd 100644 --- a/firmware/config/engines/ford_aspire.cpp +++ b/firmware/config/engines/ford_aspire.cpp @@ -78,10 +78,10 @@ void setFordAspireEngineConfiguration() { engineConfiguration->useOnlyRisingEdgeForTrigger = true; engineConfiguration->trigger.type = TT_FORD_ASPIRE; - engineConfiguration->triggerInputDebugPins[0] = GPIOC_15; + engineConfiguration->triggerInputDebugPins[0] = Gpio::C15; - engineConfiguration->injectionPins[4] = GPIO_UNASSIGNED; - engineConfiguration->injectionPins[5] = GPIO_UNASSIGNED; + engineConfiguration->injectionPins[4] = Gpio::Unassigned; + engineConfiguration->injectionPins[5] = Gpio::Unassigned; engineConfiguration->HD44780width = 20; engineConfiguration->HD44780height = 4; diff --git a/firmware/config/engines/ford_festiva.cpp b/firmware/config/engines/ford_festiva.cpp index 9a4bdd67c6..9f2145cfe7 100644 --- a/firmware/config/engines/ford_festiva.cpp +++ b/firmware/config/engines/ford_festiva.cpp @@ -102,16 +102,16 @@ void setFordEscortGt() { copyTable(config->veTable, racingFestivaVeTable); -// engineConfiguration->triggerInputPins[0] = GPIOC_6; // 2G YEL/BLU -// engineConfiguration->triggerInputPins[1] = GPIOA_5; // 2E White CKP +// engineConfiguration->triggerInputPins[0] = Gpio::C6; // 2G YEL/BLU +// engineConfiguration->triggerInputPins[1] = Gpio::A5; // 2E White CKP // in case of SOHC distributor we only have one signal -// engineConfiguration->triggerInputPins[0] = GPIOA_5; // 2E White CKP -// engineConfiguration->triggerInputPins[1] = GPIO_UNASSIGNED; +// engineConfiguration->triggerInputPins[0] = Gpio::A5; // 2E White CKP +// engineConfiguration->triggerInputPins[1] = Gpio::Unassigned; // in case of DOHC distributor we have two signals - engineConfiguration->triggerInputPins[0] = GPIOC_6; - engineConfiguration->triggerInputPins[1] = GPIOA_5; // 2E White CKP + engineConfiguration->triggerInputPins[0] = Gpio::C6; + engineConfiguration->triggerInputPins[1] = Gpio::A5; // 2E White CKP // Denso 195500-2180 engineConfiguration->injector.flow = 265; @@ -155,10 +155,10 @@ void setFordEscortGt() { // W12 PE8 // W13 PE12 - engineConfiguration->ignitionPins[0] = GPIOC_9; - engineConfiguration->ignitionPins[1] = GPIOC_7; - engineConfiguration->ignitionPins[2] = GPIOE_8; - engineConfiguration->ignitionPins[3] = GPIOE_12; + engineConfiguration->ignitionPins[0] = Gpio::C9; + engineConfiguration->ignitionPins[1] = Gpio::C7; + engineConfiguration->ignitionPins[2] = Gpio::E8; + engineConfiguration->ignitionPins[3] = Gpio::E12; engineConfiguration->ignitionPinMode = OM_DEFAULT; engineConfiguration->ignitionMode = IM_INDIVIDUAL_COILS; @@ -179,15 +179,15 @@ void setFordEscortGt() { // Frankenso low out #11: PB8 // Frankenso low out #12: PB7 - engineConfiguration->injectionPins[0] = GPIOD_3; - engineConfiguration->injectionPins[1] = GPIOE_2; + engineConfiguration->injectionPins[0] = Gpio::D3; + engineConfiguration->injectionPins[1] = Gpio::E2; // 40% idle is good default engineConfiguration->idle.solenoidFrequency = 300; - engineConfiguration->idle.solenoidPin = GPIOB_9; + engineConfiguration->idle.solenoidPin = Gpio::B9; - engineConfiguration->malfunctionIndicatorPin = GPIOE_5; + engineConfiguration->malfunctionIndicatorPin = Gpio::E5; engineConfiguration->malfunctionIndicatorPinMode = OM_DEFAULT; engineConfiguration->tunerStudioSerialSpeed = 19200; diff --git a/firmware/config/engines/honda_600.cpp b/firmware/config/engines/honda_600.cpp index c5bfe6c90c..7090f78b89 100644 --- a/firmware/config/engines/honda_600.cpp +++ b/firmware/config/engines/honda_600.cpp @@ -28,8 +28,8 @@ void setHonda600() { engineConfiguration->fuelAlgorithm = LM_ALPHA_N; // upside down wiring - engineConfiguration->triggerInputPins[0] = GPIOA_5; - engineConfiguration->triggerInputPins[1] = GPIOC_6; + engineConfiguration->triggerInputPins[0] = Gpio::A5; + engineConfiguration->triggerInputPins[1] = Gpio::C6; // set global_trigger_offset_angle 180 @@ -95,33 +95,33 @@ void setHonda600() { // Frankenso low out #11: PB8 injector #3 // Frankenso low out #12: PB7 injector #4 - engineConfiguration->fuelPumpPin = GPIOE_4; - engineConfiguration->mainRelayPin = GPIOD_7; - engineConfiguration->idle.solenoidPin = GPIOC_13; + engineConfiguration->fuelPumpPin = Gpio::E4; + engineConfiguration->mainRelayPin = Gpio::D7; + engineConfiguration->idle.solenoidPin = Gpio::C13; - engineConfiguration->fanPin = GPIOE_5; + engineConfiguration->fanPin = Gpio::E5; - engineConfiguration->injectionPins[0] = GPIOB_9; // #1 - engineConfiguration->injectionPins[1] = GPIOD_5; // #2 - engineConfiguration->injectionPins[2] = GPIOB_7; // #3 - engineConfiguration->injectionPins[3] = GPIOB_8; // #4 + engineConfiguration->injectionPins[0] = Gpio::B9; // #1 + engineConfiguration->injectionPins[1] = Gpio::D5; // #2 + engineConfiguration->injectionPins[2] = Gpio::B7; // #3 + engineConfiguration->injectionPins[3] = Gpio::B8; // #4 setDefaultCustomMaps(); setAlgorithm(LM_ALPHA_N); - engineConfiguration->injectionPins[4] = GPIO_UNASSIGNED; - engineConfiguration->injectionPins[5] = GPIO_UNASSIGNED; - engineConfiguration->injectionPins[6] = GPIO_UNASSIGNED; - engineConfiguration->injectionPins[7] = GPIO_UNASSIGNED; - engineConfiguration->injectionPins[8] = GPIO_UNASSIGNED; - engineConfiguration->injectionPins[9] = GPIO_UNASSIGNED; - engineConfiguration->injectionPins[10] = GPIO_UNASSIGNED; - engineConfiguration->injectionPins[11] = GPIO_UNASSIGNED; + engineConfiguration->injectionPins[4] = Gpio::Unassigned; + engineConfiguration->injectionPins[5] = Gpio::Unassigned; + engineConfiguration->injectionPins[6] = Gpio::Unassigned; + engineConfiguration->injectionPins[7] = Gpio::Unassigned; + engineConfiguration->injectionPins[8] = Gpio::Unassigned; + engineConfiguration->injectionPins[9] = Gpio::Unassigned; + engineConfiguration->injectionPins[10] = Gpio::Unassigned; + engineConfiguration->injectionPins[11] = Gpio::Unassigned; - engineConfiguration->ignitionPins[0] = GPIOE_14; - engineConfiguration->ignitionPins[1] = GPIOC_7; - engineConfiguration->ignitionPins[2] = GPIOE_10; - engineConfiguration->ignitionPins[3] = GPIOC_9; // #4 + engineConfiguration->ignitionPins[0] = Gpio::E14; + engineConfiguration->ignitionPins[1] = Gpio::C7; + engineConfiguration->ignitionPins[2] = Gpio::E10; + engineConfiguration->ignitionPins[3] = Gpio::C9; // #4 // todo: 8.2 or 10k? engineConfiguration->vbattDividerCoeff = ((float) (10 + 33)) / 10 * 2; diff --git a/firmware/config/engines/honda_accord.cpp b/firmware/config/engines/honda_accord.cpp index ffba02ed2c..6371edca57 100644 --- a/firmware/config/engines/honda_accord.cpp +++ b/firmware/config/engines/honda_accord.cpp @@ -132,23 +132,23 @@ static void setHondaAccordConfigurationCommon() { // Frankenso low out #10: PD5 Injector #3 // Frankenso low out #11: PB8 injector #1 // Frankenso low out #12: PB7 injector #4 - engineConfiguration->fuelPumpPin = GPIOE_3; + engineConfiguration->fuelPumpPin = Gpio::E3; engineConfiguration->fuelPumpPinMode = OM_DEFAULT; - engineConfiguration->malfunctionIndicatorPin = GPIOE_2; + engineConfiguration->malfunctionIndicatorPin = Gpio::E2; engineConfiguration->malfunctionIndicatorPinMode = OM_DEFAULT; - engineConfiguration->fanPin = GPIOE_4; // blue wire + engineConfiguration->fanPin = Gpio::E4; // blue wire - engineConfiguration->idle.solenoidPin = GPIOD_3; // green wire + engineConfiguration->idle.solenoidPin = Gpio::D3; // green wire - engineConfiguration->injectionPins[0] = GPIOB_8; - engineConfiguration->injectionPins[1] = GPIOB_9; - engineConfiguration->injectionPins[2] = GPIOD_5; - engineConfiguration->injectionPins[3] = GPIOB_7; + engineConfiguration->injectionPins[0] = Gpio::B8; + engineConfiguration->injectionPins[1] = Gpio::B9; + engineConfiguration->injectionPins[2] = Gpio::D5; + engineConfiguration->injectionPins[3] = Gpio::B7; - engineConfiguration->ignitionPins[0] = GPIOE_12; // white wire - engineConfiguration->ignitionPins[1] = GPIO_UNASSIGNED; - engineConfiguration->ignitionPins[2] = GPIO_UNASSIGNED; - engineConfiguration->ignitionPins[3] = GPIO_UNASSIGNED; + engineConfiguration->ignitionPins[0] = Gpio::E12; // white wire + engineConfiguration->ignitionPins[1] = Gpio::Unassigned; + engineConfiguration->ignitionPins[2] = Gpio::Unassigned; + engineConfiguration->ignitionPins[3] = Gpio::Unassigned; setFrankenso_01_LCD(engineConfiguration); diff --git a/firmware/config/engines/honda_k_dbc.cpp b/firmware/config/engines/honda_k_dbc.cpp index 1d35752ec2..9881351261 100644 --- a/firmware/config/engines/honda_k_dbc.cpp +++ b/firmware/config/engines/honda_k_dbc.cpp @@ -80,7 +80,7 @@ void setProteusHondaElement2003() { engineConfiguration->clt.adcChannel = PROTEUS_IN_ANALOG_TEMP_2; engineConfiguration->tps1_1AdcChannel = PROTEUS_IN_ANALOG_VOLT_3; engineConfiguration->map.sensor.hwChannel = PROTEUS_IN_ANALOG_VOLT_6; - engineConfiguration->fanPin = GPIO_UNASSIGNED; + engineConfiguration->fanPin = Gpio::Unassigned; engineConfiguration->mainRelayPin = PROTEUS_LS_9; diff --git a/firmware/config/engines/mazda_miata.cpp b/firmware/config/engines/mazda_miata.cpp index 9293552e27..2c9cdccc0c 100644 --- a/firmware/config/engines/mazda_miata.cpp +++ b/firmware/config/engines/mazda_miata.cpp @@ -76,8 +76,8 @@ static void commonMiataNa() { engineConfiguration->trigger.type = TT_MAZDA_MIATA_NA; engineConfiguration->engineChartSize = 100; - engineConfiguration->triggerInputPins[0] = GPIOC_6; // 2G YEL/BLU - engineConfiguration->triggerInputPins[1] = GPIOA_5; // 2E White CKP + engineConfiguration->triggerInputPins[0] = Gpio::C6; // 2G YEL/BLU + engineConfiguration->triggerInputPins[1] = Gpio::A5; // 2E White CKP engineConfiguration->ignitionMode = IM_WASTED_SPARK; @@ -90,10 +90,10 @@ static void commonMiataNa() { // Frankenstein: high side #5 is PC9 // Frankenstein: high side #6 is PC7 - engineConfiguration->ignitionPins[0] = GPIOE_12; // Frankenstein: high side #3 - engineConfiguration->ignitionPins[1] = GPIOE_14; // Frankenstein: high side #4 - engineConfiguration->ignitionPins[2] = GPIO_UNASSIGNED; - engineConfiguration->ignitionPins[3] = GPIO_UNASSIGNED; + engineConfiguration->ignitionPins[0] = Gpio::E12; // Frankenstein: high side #3 + engineConfiguration->ignitionPins[1] = Gpio::E14; // Frankenstein: high side #4 + engineConfiguration->ignitionPins[2] = Gpio::Unassigned; + engineConfiguration->ignitionPins[3] = Gpio::Unassigned; engineConfiguration->ignitionPinMode = OM_DEFAULT; engineConfiguration->cranking.baseFuel = 24; @@ -113,7 +113,7 @@ void common079721_2351() { engineConfiguration->specs.cylindersCount = 4; engineConfiguration->specs.firingOrder = FO_1_3_4_2; - engineConfiguration->fuelPumpPin = GPIO_UNASSIGNED; // fuel pump is not controlled by ECU on this engine + engineConfiguration->fuelPumpPin = Gpio::Unassigned; // fuel pump is not controlled by ECU on this engine // set cranking_injection_mode 0 engineConfiguration->crankingInjectionMode = IM_SIMULTANEOUS; @@ -151,31 +151,31 @@ void setFrankensteinMiata1996() { #endif // upside down - engineConfiguration->triggerInputPins[0] = GPIOA_5; - engineConfiguration->triggerInputPins[1] = GPIOC_6; + engineConfiguration->triggerInputPins[0] = Gpio::A5; + engineConfiguration->triggerInputPins[1] = Gpio::C6; - engineConfiguration->fuelPumpPin = GPIOE_4; - engineConfiguration->idle.solenoidPin = GPIOE_5; + engineConfiguration->fuelPumpPin = Gpio::E4; + engineConfiguration->idle.solenoidPin = Gpio::E5; engineConfiguration->mafAdcChannel = EFI_ADC_1; engineConfiguration->clt.adcChannel = EFI_ADC_11; engineConfiguration->tps1_1AdcChannel = EFI_ADC_13; - engineConfiguration->ignitionPins[0] = GPIOE_12; // Frankenstein: high side #3 - engineConfiguration->ignitionPins[1] = GPIO_UNASSIGNED; - engineConfiguration->ignitionPins[2] = GPIOE_14; // Frankenstein: high side #4 - engineConfiguration->ignitionPins[3] = GPIO_UNASSIGNED; + engineConfiguration->ignitionPins[0] = Gpio::E12; // Frankenstein: high side #3 + engineConfiguration->ignitionPins[1] = Gpio::Unassigned; + engineConfiguration->ignitionPins[2] = Gpio::E14; // Frankenstein: high side #4 + engineConfiguration->ignitionPins[3] = Gpio::Unassigned; engineConfiguration->ignitionPinMode = OM_DEFAULT; // harness is sequential but we have a limited board engineConfiguration->crankingInjectionMode = IM_BATCH; engineConfiguration->injectionMode = IM_BATCH; - engineConfiguration->injectionPins[0] = GPIOB_9; // Frankenstein: low side - out #12 - engineConfiguration->injectionPins[1] = GPIOB_8; // Frankenstein: low side - out #11 - engineConfiguration->injectionPins[2] = GPIO_UNASSIGNED; - engineConfiguration->injectionPins[3] = GPIO_UNASSIGNED; - engineConfiguration->injectionPins[4] = GPIO_UNASSIGNED; - engineConfiguration->injectionPins[5] = GPIO_UNASSIGNED; + engineConfiguration->injectionPins[0] = Gpio::B9; // Frankenstein: low side - out #12 + engineConfiguration->injectionPins[1] = Gpio::B8; // Frankenstein: low side - out #11 + engineConfiguration->injectionPins[2] = Gpio::Unassigned; + engineConfiguration->injectionPins[3] = Gpio::Unassigned; + engineConfiguration->injectionPins[4] = Gpio::Unassigned; + engineConfiguration->injectionPins[5] = Gpio::Unassigned; engineConfiguration->injectionPinMode = OM_DEFAULT; } diff --git a/firmware/config/engines/mazda_miata_1_6.cpp b/firmware/config/engines/mazda_miata_1_6.cpp index 8ee05c58e5..cea3b34683 100644 --- a/firmware/config/engines/mazda_miata_1_6.cpp +++ b/firmware/config/engines/mazda_miata_1_6.cpp @@ -245,12 +245,12 @@ static void miataNAcommonEngineSettings() { static void miataNAcommon() { - engineConfiguration->idle.solenoidPin = GPIOB_9; // this W61 <> W61 jumper, pin 3W + engineConfiguration->idle.solenoidPin = Gpio::B9; // this W61 <> W61 jumper, pin 3W - engineConfiguration->ignitionPins[0] = GPIOE_14; // Frankenso high side - pin 1G - engineConfiguration->ignitionPins[1] = GPIO_UNASSIGNED; - engineConfiguration->ignitionPins[2] = GPIOC_7; // Frankenso high side - pin 1H - engineConfiguration->ignitionPins[3] = GPIO_UNASSIGNED; + engineConfiguration->ignitionPins[0] = Gpio::E14; // Frankenso high side - pin 1G + engineConfiguration->ignitionPins[1] = Gpio::Unassigned; + engineConfiguration->ignitionPins[2] = Gpio::C7; // Frankenso high side - pin 1H + engineConfiguration->ignitionPins[3] = Gpio::Unassigned; } /** @@ -276,28 +276,28 @@ void setMiataNA6_MAP_Frankenso() { engineConfiguration->isSdCardEnabled = true; - engineConfiguration->injectionPins[0] = GPIOD_3; // #1&3 pin 3U - engineConfiguration->injectionPins[1] = GPIOE_2; // #2&4 pin 3V - engineConfiguration->injectionPins[2] = GPIO_UNASSIGNED; - engineConfiguration->injectionPins[3] = GPIO_UNASSIGNED; + engineConfiguration->injectionPins[0] = Gpio::D3; // #1&3 pin 3U + engineConfiguration->injectionPins[1] = Gpio::E2; // #2&4 pin 3V + engineConfiguration->injectionPins[2] = Gpio::Unassigned; + engineConfiguration->injectionPins[3] = Gpio::Unassigned; // white wire from 1E - TOP of W4 to BOTTOM W62 - engineConfiguration->malfunctionIndicatorPin = GPIOD_5; + engineConfiguration->malfunctionIndicatorPin = Gpio::D5; // yellow wire from 1V/W22 to bottom of W48 - engineConfiguration->clutchDownPin = GPIOA_3; + engineConfiguration->clutchDownPin = Gpio::A3; engineConfiguration->clutchDownPinMode = PI_PULLUP; // 110mm red wire from 1N/W14 to bottom of W45 - engineConfiguration->throttlePedalUpPin = GPIOA_7; + engineConfiguration->throttlePedalUpPin = Gpio::A7; // green wire from 1Q/W17 to bottom of W46 - engineConfiguration->acSwitch = GPIOA_6; + engineConfiguration->acSwitch = Gpio::A6; #if ! EFI_UNIT_TEST // W57 PE3 A/C compressor relay out - engineConfiguration->acRelayPin = GPIOE_3; + engineConfiguration->acRelayPin = Gpio::E3; // W58 PE4 A/C fan relay out #endif /* EFI_UNIT_TEST */ @@ -339,11 +339,11 @@ void setMiataNA6_VAF_MRE() { void setMiataNA6_MAP_MRE() { miataNAcommonEngineSettings(); - engineConfiguration->triggerInputPins[0] = GPIOA_5; - engineConfiguration->triggerInputPins[1] = GPIOC_6; - engineConfiguration->camInputs[0] = GPIO_UNASSIGNED; + engineConfiguration->triggerInputPins[0] = Gpio::A5; + engineConfiguration->triggerInputPins[1] = Gpio::C6; + engineConfiguration->camInputs[0] = Gpio::Unassigned; - engineConfiguration->fuelPumpPin = GPIO_UNASSIGNED; + engineConfiguration->fuelPumpPin = Gpio::Unassigned; engineConfiguration->twoWireBatchInjection = true; @@ -378,7 +378,7 @@ void setMiataNA6_MAP_MRE() { engineConfiguration->idleTimingPidDeadZone = 10; // EFI_ADC_3: "22 - AN temp 4" - engineConfiguration->acSwitch = GPIOA_3; + engineConfiguration->acSwitch = Gpio::A3; #if HW_MICRO_RUSEFI // todo: ask Stefan to clarify this @@ -393,14 +393,14 @@ void setMiataNA6_MAP_MRE() { #if (BOARD_TLE8888_COUNT > 0) - // GPIOG_1: "Clutch Switch" - engineConfiguration->clutchDownPin = GPIOG_1; + // Gpio::G1: "Clutch Switch" + engineConfiguration->clutchDownPin = Gpio::G1; - engineConfiguration->fanPin = GPIO_UNASSIGNED; + engineConfiguration->fanPin = Gpio::Unassigned; - // TLE8888_PIN_23: "33 - GP Out 3" - engineConfiguration->malfunctionIndicatorPin = TLE8888_PIN_23; + // Gpio::TLE8888_PIN_23: "33 - GP Out 3" + engineConfiguration->malfunctionIndicatorPin = Gpio::TLE8888_PIN_23; #endif /* BOARD_TLE8888_COUNT */ } @@ -410,7 +410,7 @@ void setMiata94_MAP_MRE() { #if (BOARD_TLE8888_COUNT > 0) // "35 - GP Out 1" - engineConfiguration->fuelPumpPin = TLE8888_PIN_21; + engineConfiguration->fuelPumpPin = Gpio::TLE8888_PIN_21; #endif /* BOARD_TLE8888_COUNT */ engineConfiguration->injectionMode = IM_SEQUENTIAL; @@ -440,7 +440,7 @@ void setHellenNA94() { engineConfiguration->fan2OnTemperature = 95; engineConfiguration->fan2OffTemperature = 91; - engineConfiguration->fan2Pin = GPIOD_9; // 3S - A/C Fan 94-95 + engineConfiguration->fan2Pin = Gpio::D9; // 3S - A/C Fan 94-95 } void setHellenNA6() { diff --git a/firmware/config/engines/mazda_miata_custom_hunchback.cpp b/firmware/config/engines/mazda_miata_custom_hunchback.cpp index ebf8de56b6..b077d97bc7 100644 --- a/firmware/config/engines/mazda_miata_custom_hunchback.cpp +++ b/firmware/config/engines/mazda_miata_custom_hunchback.cpp @@ -94,7 +94,7 @@ void setMazdaMiata2003EngineConfigurationNaFuelRail() { copyArray(config->lambdaRpmBins, mazda_miata_nb2_targetLambdaRpmBins); copyArray(config->lambdaLoadBins, mazda_miata_nb2_targetLambdaLoadBins); - engineConfiguration->ignitionPins[2] = GPIOC_7; + engineConfiguration->ignitionPins[2] = Gpio::C7; // Frankenso analog #7 pin 3J, W48 top <>W48 bottom jumper, not OEM engineConfiguration->afr.hwChannel = EFI_ADC_3; // PA3 diff --git a/firmware/config/engines/mazda_miata_na8.cpp b/firmware/config/engines/mazda_miata_na8.cpp index f8efe180ef..348f06d6fb 100644 --- a/firmware/config/engines/mazda_miata_na8.cpp +++ b/firmware/config/engines/mazda_miata_na8.cpp @@ -41,10 +41,10 @@ void setMazdaMiataNA8Configuration() { engineConfiguration->vbattDividerCoeff = 9.75;// ((float) (8.2 + 33)) / 8.2 * 2; - engineConfiguration->injectionPins[0] = GPIOD_3; // #1 pin 3U - engineConfiguration->injectionPins[1] = GPIOE_2; // #2 pin 3V - engineConfiguration->injectionPins[2] = GPIOB_8; // #3 pin 3Y - engineConfiguration->injectionPins[3] = GPIOB_7; // #4 pin 3Z + engineConfiguration->injectionPins[0] = Gpio::D3; // #1 pin 3U + engineConfiguration->injectionPins[1] = Gpio::E2; // #2 pin 3V + engineConfiguration->injectionPins[2] = Gpio::B8; // #3 pin 3Y + engineConfiguration->injectionPins[3] = Gpio::B7; // #4 pin 3Z engineConfiguration->injectionMode = IM_SEQUENTIAL; } diff --git a/firmware/config/engines/mazda_miata_vvt.cpp b/firmware/config/engines/mazda_miata_vvt.cpp index dec54a3a03..43b0c4e583 100644 --- a/firmware/config/engines/mazda_miata_vvt.cpp +++ b/firmware/config/engines/mazda_miata_vvt.cpp @@ -6,16 +6,16 @@ * Frankenso MAZDA_MIATA_2003 * set engine_type 47 * - * coil1/4 (p1 +5 VP) GPIOE_14 - * coil2/2 (p1 +5 VP) GPIOC_9 - * tachometer +5 VP (p3 +12 VP) GPIOE_8 - * alternator +5 VP (p3 +12 VP) GPIOE_10 - * ETB PWM GPIOE_6 inverted low-side with pull-up - * ETB dir1 GPIOE_12 - * ETB dir2 GPIOC_7 + * coil1/4 (p1 +5 VP) Gpio::E14 + * coil2/2 (p1 +5 VP) Gpio::C9 + * tachometer +5 VP (p3 +12 VP) Gpio::E8 + * alternator +5 VP (p3 +12 VP) Gpio::E10 + * ETB PWM Gpio::E6 inverted low-side with pull-up + * ETB dir1 Gpio::E12 + * ETB dir2 Gpio::C7 * - * COP ion #1 GPIOD_8 - * COP ion #3 GPIOD_9 + * COP ion #1 Gpio::D8 + * COP ion #3 Gpio::D9 * * @date Oct 4, 2016 * @author Andrey Belomutskiy, (c) 2012-2020 @@ -33,14 +33,14 @@ * Cam vvt input PC6 (3G in Miata board) blue * Wideband input PA3 (3J in Miata board) * - * coil1/4 (p1 +5 VP) GPIOE_14 - * coil2/2 (p1 +5 VP) GPIOC_7 + * coil1/4 (p1 +5 VP) Gpio::E14 + * coil2/2 (p1 +5 VP) Gpio::C7 * - * tachometer +5 VP (p3 +12 VP) GPIOE_8 - * alternator +5 VP (p3 +12 VP) GPIOE_10 + * tachometer +5 VP (p3 +12 VP) Gpio::E8 + * alternator +5 VP (p3 +12 VP) Gpio::E10 * - * VVT solenoid on aux PID#1 GPIOE_3 - * warning light GPIOE_6 + * VVT solenoid on aux PID#1 Gpio::E3 + * warning light Gpio::E6 * * * idle solenoid PC13 on middle harness plug. diodes seem to be in the harness @@ -404,24 +404,24 @@ void setMazdaMiata2003EngineConfiguration() { setMazdaMiataEngineNB2Defaults(); -// engineConfiguration->triggerInputPins[0] = GPIOA_8; // custom Frankenso wiring in order to use SPI1 for accelerometer - engineConfiguration->triggerInputPins[0] = GPIOA_5; // board still not modified - engineConfiguration->triggerInputPins[1] = GPIO_UNASSIGNED; - engineConfiguration->camInputs[0] = GPIOC_6; +// engineConfiguration->triggerInputPins[0] = Gpio::A8; // custom Frankenso wiring in order to use SPI1 for accelerometer + engineConfiguration->triggerInputPins[0] = Gpio::A5; // board still not modified + engineConfiguration->triggerInputPins[1] = Gpio::Unassigned; + engineConfiguration->camInputs[0] = Gpio::C6; // engineConfiguration->is_enabled_spi_1 = true; engineConfiguration->twoWireBatchInjection = true; // this is needed for #492 testing - engineConfiguration->alternatorControlPin = GPIOE_10; + engineConfiguration->alternatorControlPin = Gpio::E10; engineConfiguration->alternatorControlPinMode = OM_OPENDRAIN; -// engineConfiguration->vehicleSpeedSensorInputPin = GPIOA_8; +// engineConfiguration->vehicleSpeedSensorInputPin = Gpio::A8; - engineConfiguration->vvtPins[0] = GPIOE_3; // VVT solenoid control + engineConfiguration->vvtPins[0] = Gpio::E3; // VVT solenoid control // high-side driver with +12v VP jumper - engineConfiguration->tachOutputPin = GPIOE_8; // tachometer + engineConfiguration->tachOutputPin = Gpio::E8; // tachometer // set global_trigger_offset_angle 0 engineConfiguration->globalTriggerAngleOffset = 0; @@ -440,17 +440,17 @@ void setMazdaMiata2003EngineConfiguration() { * Miata coil on #4 PE14 - white ECU wire "1&4" */ - engineConfiguration->ignitionPins[0] = GPIOE_14; - engineConfiguration->ignitionPins[1] = GPIO_UNASSIGNED; - engineConfiguration->ignitionPins[2] = GPIOC_9; - engineConfiguration->ignitionPins[3] = GPIO_UNASSIGNED; + engineConfiguration->ignitionPins[0] = Gpio::E14; + engineConfiguration->ignitionPins[1] = Gpio::Unassigned; + engineConfiguration->ignitionPins[2] = Gpio::C9; + engineConfiguration->ignitionPins[3] = Gpio::Unassigned; - engineConfiguration->malfunctionIndicatorPin = GPIOD_5; + engineConfiguration->malfunctionIndicatorPin = Gpio::D5; -// engineConfiguration->malfunctionIndicatorPin = GPIOD_9; +// engineConfiguration->malfunctionIndicatorPin = Gpio::D9; // engineConfiguration->malfunctionIndicatorPinMode = OM_INVERTED; // todo: blue jumper wire - what is it?! @@ -504,12 +504,12 @@ void setMazdaMiata2003EngineConfiguration() { // PWM engineConfiguration->etb_use_two_wires = true; - engineConfiguration->etbIo[0].controlPin = GPIO_UNASSIGNED; + engineConfiguration->etbIo[0].controlPin = Gpio::Unassigned; // - engineConfiguration->etbIo[0].directionPin1 = GPIOE_12; // orange + engineConfiguration->etbIo[0].directionPin1 = Gpio::E12; // orange // - engineConfiguration->etbIo[0].directionPin2 = GPIOC_7; // white/blue + engineConfiguration->etbIo[0].directionPin2 = Gpio::C7; // white/blue // set_analog_input_pin tps PC3 engineConfiguration->tps1_1AdcChannel = EFI_ADC_13; // PC3 blue @@ -554,7 +554,7 @@ void setMazdaMiata2003EngineConfiguration() { void setMazdaMiata2003EngineConfigurationBoardTest() { setMazdaMiata2003EngineConfiguration(); - engineConfiguration->ignitionPins[2] = GPIOC_7; + engineConfiguration->ignitionPins[2] = Gpio::C7; // Frankenso analog #7 pin 3J, W48 top <>W48 bottom jumper, not OEM. Make sure 500K pull-down on Frankenso engineConfiguration->afr.hwChannel = EFI_ADC_3; // PA3 @@ -576,20 +576,20 @@ static void setMiataNB2_MRE_common() { // tps1_1AdcChannel input is inherited from boards/microrusefi/board_configuration.cpp // afr.hwChannel input is inherited from boards/microrusefi/board_configuration.cpp - engineConfiguration->ignitionPins[1] = GPIO_UNASSIGNED; - engineConfiguration->ignitionPins[3] = GPIO_UNASSIGNED; + engineConfiguration->ignitionPins[1] = Gpio::Unassigned; + engineConfiguration->ignitionPins[3] = Gpio::Unassigned; - engineConfiguration->camInputs[0] = GPIOA_5; + engineConfiguration->camInputs[0] = Gpio::A5; /** * By default "auto detection mode for VR sensor signals" is used * We know that for short & strange Hall (?) signals like Miata NB2 crank sensor this does not work well above certain RPM. */ engineConfiguration->tle8888mode = TL_MANUAL; - // GPIOD_6: "13 - GP Out 6" - selected to +12v - engineConfiguration->alternatorControlPin = GPIOD_6; - // GPIOD_7: "14 - GP Out 5" - selected to +12v - engineConfiguration->tachOutputPin = GPIOD_7; // tachometer + // Gpio::D6: "13 - GP Out 6" - selected to +12v + engineConfiguration->alternatorControlPin = Gpio::D6; + // Gpio::D7: "14 - GP Out 5" - selected to +12v + engineConfiguration->tachOutputPin = Gpio::D7; // tachometer engineConfiguration->tachPulsePerRev = 2; engineConfiguration->isSdCardEnabled = true; @@ -600,18 +600,18 @@ static void setMiataNB2_MRE_common() { // # TLE8888 high current low side: VVT1 IN10 / OUT6 - // TLE8888_PIN_6: "7 - Lowside 1" - engineConfiguration->vvtPins[0] = TLE8888_PIN_6; // VVT solenoid control + // Gpio::TLE8888_PIN_6: "7 - Lowside 1" + engineConfiguration->vvtPins[0] = Gpio::TLE8888_PIN_6; // VVT solenoid control - // TLE8888_PIN_23: "33 - GP Out 3" - engineConfiguration->malfunctionIndicatorPin = TLE8888_PIN_23; + // Gpio::TLE8888_PIN_23: "33 - GP Out 3" + engineConfiguration->malfunctionIndicatorPin = Gpio::TLE8888_PIN_23; // todo: alternator warn // ? // todo: AC fan - // TLE8888_PIN_24: "43 - GP Out 4" + // Gpio::TLE8888_PIN_24: "43 - GP Out 4" // set_analog_input_pin pps PA7 // EFI_ADC_7: "31 - AN volt 3" - PA7 @@ -690,7 +690,7 @@ void setMiataNB2_Proteus_TCU() { engineConfiguration->trigger.customSkippedToothCount = 0; - engineConfiguration->triggerInputPins[0] = GPIO_UNASSIGNED; + engineConfiguration->triggerInputPins[0] = Gpio::Unassigned; engineConfiguration->tcuInputSpeedSensorPin = PROTEUS_VR_1; engineConfiguration->vehicleSpeedSensorInputPin = PROTEUS_VR_2; @@ -700,15 +700,15 @@ void setMiataNB2_Proteus_TCU() { engineConfiguration->vssToothCount = 22; // "Highside 2" - engineConfiguration->tcu_solenoid[0] = GPIOA_8; + engineConfiguration->tcu_solenoid[0] = Gpio::A8; // "Highside 1" - engineConfiguration->tcu_solenoid[1] = GPIOA_9; + engineConfiguration->tcu_solenoid[1] = Gpio::A9; // "Digital 1" green - engineConfiguration->tcuUpshiftButtonPin = GPIOC_6; + engineConfiguration->tcuUpshiftButtonPin = Gpio::C6; engineConfiguration->tcuUpshiftButtonPinMode = PI_PULLUP; // "Digital 6" white - engineConfiguration->tcuDownshiftButtonPin = GPIOE_15; + engineConfiguration->tcuDownshiftButtonPin = Gpio::E15; engineConfiguration->tcuDownshiftButtonPinMode = PI_PULLUP; // R @@ -738,25 +738,25 @@ void setMiataNB2_Proteus_TCU() { void setMiataNB2_ProteusEngineConfiguration() { setMazdaMiataEngineNB2Defaults(); - engineConfiguration->triggerInputPins[0] = GPIOC_6; // pin 10/black23 - engineConfiguration->triggerInputPins[1] = GPIO_UNASSIGNED; - engineConfiguration->camInputs[0] = GPIOE_11; // pin 1/black23 + engineConfiguration->triggerInputPins[0] = Gpio::C6; // pin 10/black23 + engineConfiguration->triggerInputPins[1] = Gpio::Unassigned; + engineConfiguration->camInputs[0] = Gpio::E11; // pin 1/black23 - engineConfiguration->alternatorControlPin = GPIOA_8; // "Highside 2" # pin 1/black35 + engineConfiguration->alternatorControlPin = Gpio::A8; // "Highside 2" # pin 1/black35 - engineConfiguration->vvtPins[0] = GPIOB_5; // VVT solenoid control # pin 8/black35 + engineConfiguration->vvtPins[0] = Gpio::B5; // VVT solenoid control # pin 8/black35 // high-side driver with +12v VP jumper - engineConfiguration->tachOutputPin = GPIOA_9; // tachometer + engineConfiguration->tachOutputPin = Gpio::A9; // tachometer engineConfiguration->tachPulsePerRev = 2; engineConfiguration->ignitionMode = IM_WASTED_SPARK; #if EFI_PROD_CODE engineConfiguration->ignitionPins[0] = PROTEUS_IGN_1; - engineConfiguration->ignitionPins[1] = GPIO_UNASSIGNED; + engineConfiguration->ignitionPins[1] = Gpio::Unassigned; engineConfiguration->ignitionPins[2] = PROTEUS_IGN_3; - engineConfiguration->ignitionPins[3] = GPIO_UNASSIGNED; + engineConfiguration->ignitionPins[3] = Gpio::Unassigned; engineConfiguration->crankingInjectionMode = IM_SIMULTANEOUS; engineConfiguration->injectionMode = IM_SEQUENTIAL; @@ -790,9 +790,9 @@ void setMiataNB2_ProteusEngineConfiguration() { engineConfiguration->idle.solenoidPin = PROTEUS_LS_7; - engineConfiguration->fanPin = GPIOB_7; + engineConfiguration->fanPin = Gpio::B7; - engineConfiguration->mainRelayPin = GPIOG_12; + engineConfiguration->mainRelayPin = Gpio::G12; #endif // EFI_PROD_CODE diff --git a/firmware/config/engines/mercedes.cpp b/firmware/config/engines/mercedes.cpp index d8414d633b..7b32c84dcb 100644 --- a/firmware/config/engines/mercedes.cpp +++ b/firmware/config/engines/mercedes.cpp @@ -22,10 +22,10 @@ void setHellenMercedes128_4_cyl() { engineConfiguration->injectionPins[1] = H176_LS_6; engineConfiguration->injectionPins[2] = H176_LS_8; engineConfiguration->injectionPins[3] = H176_LS_5; - engineConfiguration->injectionPins[4] = GPIO_UNASSIGNED; - engineConfiguration->injectionPins[5] = GPIO_UNASSIGNED; - engineConfiguration->injectionPins[6] = GPIO_UNASSIGNED; - engineConfiguration->injectionPins[7] = GPIO_UNASSIGNED; + engineConfiguration->injectionPins[4] = Gpio::Unassigned; + engineConfiguration->injectionPins[5] = Gpio::Unassigned; + engineConfiguration->injectionPins[6] = Gpio::Unassigned; + engineConfiguration->injectionPins[7] = Gpio::Unassigned; #endif // HW_HELLEN } diff --git a/firmware/config/engines/mitsubishi.cpp b/firmware/config/engines/mitsubishi.cpp index c662edd1d8..667f53e20c 100644 --- a/firmware/config/engines/mitsubishi.cpp +++ b/firmware/config/engines/mitsubishi.cpp @@ -53,19 +53,19 @@ void setMitsubishiConfiguration() { // Frankenstein: low side - out #11: PB8 // Frankenstein: low side - out #12: PB9 - engineConfiguration->injectionPins[0] = GPIOB_9; // Frankenstein: low side - out #12 - engineConfiguration->injectionPins[1] = GPIOB_8; // Frankenstein: low side - out #11 - engineConfiguration->injectionPins[2] = GPIOE_3; // Frankenstein: low side - out #8 - engineConfiguration->injectionPins[3] = GPIOE_5; // Frankenstein: low side - out #6 + engineConfiguration->injectionPins[0] = Gpio::B9; // Frankenstein: low side - out #12 + engineConfiguration->injectionPins[1] = Gpio::B8; // Frankenstein: low side - out #11 + engineConfiguration->injectionPins[2] = Gpio::E3; // Frankenstein: low side - out #8 + engineConfiguration->injectionPins[3] = Gpio::E5; // Frankenstein: low side - out #6 // Frankenstein: high side #1: PE8 // Frankenstein: high side #2: PE10 - engineConfiguration->ignitionPins[0] = GPIOE_8; // Frankenstein: high side #1 - engineConfiguration->ignitionPins[1] = GPIO_UNASSIGNED; - engineConfiguration->ignitionPins[2] = GPIOE_10; // // Frankenstein: high side #2 - engineConfiguration->ignitionPins[3] = GPIO_UNASSIGNED; + engineConfiguration->ignitionPins[0] = Gpio::E8; // Frankenstein: high side #1 + engineConfiguration->ignitionPins[1] = Gpio::Unassigned; + engineConfiguration->ignitionPins[2] = Gpio::E10; // // Frankenstein: high side #2 + engineConfiguration->ignitionPins[3] = Gpio::Unassigned; engineConfiguration->HD44780width = 20; engineConfiguration->HD44780height = 4; diff --git a/firmware/config/engines/nissan_primera.cpp b/firmware/config/engines/nissan_primera.cpp index 9ba19eca66..1a8e3011fa 100644 --- a/firmware/config/engines/nissan_primera.cpp +++ b/firmware/config/engines/nissan_primera.cpp @@ -17,8 +17,8 @@ void setNissanPrimeraEngineConfiguration() { engineConfiguration->trigger.type = TT_NISSAN_SR20VE; - engineConfiguration->auxValves[0] = GPIOE_14; - engineConfiguration->auxValves[1] = GPIOE_12; + engineConfiguration->auxValves[0] = Gpio::E14; + engineConfiguration->auxValves[1] = Gpio::E12; } void setNissanPrimeraEngineConfiguration_360() { diff --git a/firmware/config/engines/nissan_vq.cpp b/firmware/config/engines/nissan_vq.cpp index d2809f02f2..f069783101 100644 --- a/firmware/config/engines/nissan_vq.cpp +++ b/firmware/config/engines/nissan_vq.cpp @@ -15,7 +15,7 @@ void setHellen121nissanQR() { engineConfiguration->specs.displacement = 2; strcpy(engineConfiguration->engineCode, "QR"); - engineConfiguration->camInputs[1 * CAMS_PER_BANK] = GPIO_UNASSIGNED; + engineConfiguration->camInputs[1 * CAMS_PER_BANK] = Gpio::Unassigned; engineConfiguration->vvtMode[0] = VVT_NISSAN_VQ; diff --git a/firmware/config/engines/sachs.cpp b/firmware/config/engines/sachs.cpp index f0457ebbe7..ba1cf76f78 100644 --- a/firmware/config/engines/sachs.cpp +++ b/firmware/config/engines/sachs.cpp @@ -70,12 +70,12 @@ void setSachs() { // Frankenstein: low side - out #11: PB8 // Frankenstein: low side - out #12: PB9 - engineConfiguration->triggerInputPins[0] = GPIOA_5; - engineConfiguration->triggerInputPins[1] = GPIO_UNASSIGNED; + engineConfiguration->triggerInputPins[0] = Gpio::A5; + engineConfiguration->triggerInputPins[1] = Gpio::Unassigned; - engineConfiguration->injectionPins[0] = GPIOC_15; + engineConfiguration->injectionPins[0] = Gpio::C15; - engineConfiguration->fuelPumpPin = GPIOE_6; + engineConfiguration->fuelPumpPin = Gpio::E6; // todo: extract a method? figure out something smarter setTimingRpmBin(800, 15000); diff --git a/firmware/config/engines/subaru.cpp b/firmware/config/engines/subaru.cpp index aa5683d441..f28a4256fc 100644 --- a/firmware/config/engines/subaru.cpp +++ b/firmware/config/engines/subaru.cpp @@ -24,13 +24,13 @@ void setSubaru2003Wrx() { engineConfiguration->useStepperIdle = true; // See http://rusefi.com/forum/viewtopic.php?f=4&t=1161 - engineConfiguration->idle.stepperDirectionPin = GPIOD_1; // top stepper drive pin, white wire recommended - engineConfiguration->idle.stepperStepPin = GPIOD_6; // yellow wire recommended - engineConfiguration->stepperEnablePin = GPIOB_1; // bottom stepper driver board pin, blue wire recommended + engineConfiguration->idle.stepperDirectionPin = Gpio::D1; // top stepper drive pin, white wire recommended + engineConfiguration->idle.stepperStepPin = Gpio::D6; // yellow wire recommended + engineConfiguration->stepperEnablePin = Gpio::B1; // bottom stepper driver board pin, blue wire recommended - engineConfiguration->triggerSimulatorPins[0] = GPIO_UNASSIGNED; // we want to avoid PD1 conflict - engineConfiguration->triggerSimulatorPins[1] = GPIO_UNASSIGNED; - engineConfiguration->triggerSimulatorPins[2] = GPIO_UNASSIGNED; + engineConfiguration->triggerSimulatorPins[0] = Gpio::Unassigned; // we want to avoid PD1 conflict + engineConfiguration->triggerSimulatorPins[1] = Gpio::Unassigned; + engineConfiguration->triggerSimulatorPins[2] = Gpio::Unassigned; } /** @@ -52,8 +52,8 @@ void setSubaruEJ18_MRE() { engineConfiguration->ignitionMode = IM_WASTED_SPARK; #if (BOARD_TLE8888_COUNT > 0) - // TLE8888_PIN_23: "33 - GP Out 3" - engineConfiguration->malfunctionIndicatorPin = TLE8888_PIN_23; + // Gpio::TLE8888_PIN_23: "33 - GP Out 3" + engineConfiguration->malfunctionIndicatorPin = Gpio::TLE8888_PIN_23; #endif /* BOARD_TLE8888_COUNT */ // this car has high-side main relay WOW so we have to hard wire it to ignition switch diff --git a/firmware/config/engines/test_engine.cpp b/firmware/config/engines/test_engine.cpp index 16a3956847..7625b773ab 100644 --- a/firmware/config/engines/test_engine.cpp +++ b/firmware/config/engines/test_engine.cpp @@ -39,14 +39,14 @@ void setTestCamEngineConfiguration() { engineConfiguration->ignitionMode = IM_ONE_COIL; setConstantDwell(3); // 50% duty cycle @ 5000 rpm - engineConfiguration->malfunctionIndicatorPin = GPIO_UNASSIGNED; + engineConfiguration->malfunctionIndicatorPin = Gpio::Unassigned; - engineConfiguration->ignitionPins[0] = GPIOC_7; // #1 - engineConfiguration->ignitionPins[1] = GPIO_UNASSIGNED; // #2 - engineConfiguration->ignitionPins[2] = GPIO_UNASSIGNED; // #3 - engineConfiguration->ignitionPins[3] = GPIO_UNASSIGNED; // #4 - engineConfiguration->ignitionPins[4] = GPIO_UNASSIGNED; // #5 - engineConfiguration->ignitionPins[5] = GPIO_UNASSIGNED; // #6 + engineConfiguration->ignitionPins[0] = Gpio::C7; // #1 + engineConfiguration->ignitionPins[1] = Gpio::Unassigned; // #2 + engineConfiguration->ignitionPins[2] = Gpio::Unassigned; // #3 + engineConfiguration->ignitionPins[3] = Gpio::Unassigned; // #4 + engineConfiguration->ignitionPins[4] = Gpio::Unassigned; // #5 + engineConfiguration->ignitionPins[5] = Gpio::Unassigned; // #6 } @@ -71,8 +71,8 @@ void setTestVVTEngineConfiguration() { // set algorithm 3 setAlgorithm(LM_SPEED_DENSITY); - engineConfiguration->triggerInputPins[1] = GPIO_UNASSIGNED; - engineConfiguration->camInputs[0] = GPIOA_5; + engineConfiguration->triggerInputPins[1] = Gpio::Unassigned; + engineConfiguration->camInputs[0] = Gpio::A5; // set global_trigger_offset_angle 0 engineConfiguration->globalTriggerAngleOffset = 0; @@ -107,12 +107,12 @@ void setProteusAnalogPwmTest() { engineConfiguration->trigger.type = TT_ONE; // Disable trigger stim - engineConfiguration->triggerSimulatorPins[0] = GPIO_UNASSIGNED; - engineConfiguration->triggerSimulatorPins[1] = GPIO_UNASSIGNED; - engineConfiguration->triggerSimulatorPins[2] = GPIO_UNASSIGNED; + engineConfiguration->triggerSimulatorPins[0] = Gpio::Unassigned; + engineConfiguration->triggerSimulatorPins[1] = Gpio::Unassigned; + engineConfiguration->triggerSimulatorPins[2] = Gpio::Unassigned; // The idle control pin is connected to the default TPS input, analog volt 2 - engineConfiguration->idle.solenoidPin = GPIOG_4; + engineConfiguration->idle.solenoidPin = Gpio::G4; // 5893hz is coprime with the analog sample rate, 500hz, so hopefully we get less aliasing engineConfiguration->idle.solenoidFrequency = 5893; diff --git a/firmware/config/engines/toyota_jzs147.cpp b/firmware/config/engines/toyota_jzs147.cpp index 160bee7617..d35d85b232 100644 --- a/firmware/config/engines/toyota_jzs147.cpp +++ b/firmware/config/engines/toyota_jzs147.cpp @@ -32,22 +32,22 @@ static void common2jz() { // set ignition_mode 1 engineConfiguration->ignitionMode = IM_INDIVIDUAL_COILS; - engineConfiguration->ignitionPins[0] = GPIOE_14; - engineConfiguration->ignitionPins[1] = GPIOC_7; - engineConfiguration->ignitionPins[2] = GPIOC_9; - engineConfiguration->ignitionPins[3] = GPIOE_10; - engineConfiguration->ignitionPins[4] = GPIOE_8; - engineConfiguration->ignitionPins[5] = GPIOE_12; + engineConfiguration->ignitionPins[0] = Gpio::E14; + engineConfiguration->ignitionPins[1] = Gpio::C7; + engineConfiguration->ignitionPins[2] = Gpio::C9; + engineConfiguration->ignitionPins[3] = Gpio::E10; + engineConfiguration->ignitionPins[4] = Gpio::E8; + engineConfiguration->ignitionPins[5] = Gpio::E12; - engineConfiguration->injectionPins[0] = GPIOB_9; // #1 - engineConfiguration->injectionPins[1] = GPIOE_2; // #2 - engineConfiguration->injectionPins[2] = GPIOB_8; // #3 - engineConfiguration->injectionPins[3] = GPIOB_7; // #4 - engineConfiguration->injectionPins[4] = GPIOE_3; // #5 - engineConfiguration->injectionPins[5] = GPIOE_4; // #6 + engineConfiguration->injectionPins[0] = Gpio::B9; // #1 + engineConfiguration->injectionPins[1] = Gpio::E2; // #2 + engineConfiguration->injectionPins[2] = Gpio::B8; // #3 + engineConfiguration->injectionPins[3] = Gpio::B7; // #4 + engineConfiguration->injectionPins[4] = Gpio::E3; // #5 + engineConfiguration->injectionPins[5] = Gpio::E4; // #6 - engineConfiguration->fuelPumpPin = GPIO_UNASSIGNED; + engineConfiguration->fuelPumpPin = Gpio::Unassigned; // chartsize 450 engineConfiguration->engineChartSize = 450; @@ -87,8 +87,8 @@ void setToyota_jzs147EngineConfiguration() { // engineConfiguration->injectionMode = IM_BATCH; // engineConfiguration->twoWireBatchInjection = true; -// engineConfiguration->triggerInputPins[0] = GPIOA_5; -// engineConfiguration->triggerInputPins[1] = GPIOC_6; +// engineConfiguration->triggerInputPins[0] = Gpio::A5; +// engineConfiguration->triggerInputPins[1] = Gpio::C6; engineConfiguration->isSdCardEnabled = false; @@ -105,10 +105,10 @@ void setToyota_2jz_vics() { setCrankOperationMode(); engineConfiguration->trigger.type = TT_TOOTHED_WHEEL_36_2; - engineConfiguration->triggerInputPins[0] = GPIOA_5; // crank sensor - engineConfiguration->triggerInputPins[1] = GPIO_UNASSIGNED; // cam sensor will he handled by custom vtti code + engineConfiguration->triggerInputPins[0] = Gpio::A5; // crank sensor + engineConfiguration->triggerInputPins[1] = Gpio::Unassigned; // cam sensor will he handled by custom vtti code - engineConfiguration->camInputs[0] = GPIOC_6; + engineConfiguration->camInputs[0] = Gpio::C6; engineConfiguration->vvtMode[0] = VVT_2JZ; // set global_trigger_offset_angle 155 @@ -127,7 +127,7 @@ void setToyota_2jz_vics() { // engineConfiguration->scriptSetting[4] = 175 - 45; // engineConfiguration->scriptSetting[5] = 175 + 45; - engineConfiguration->vvtPins[0] = GPIOE_3; // VVT solenoid control + engineConfiguration->vvtPins[0] = Gpio::E3; // VVT solenoid control // Mazda VVT settings have nothing to do wit Toyota 2JZ settings but those are a good starting point for settings setMazdaNB2VVTSettings(); diff --git a/firmware/config/engines/vw.cpp b/firmware/config/engines/vw.cpp index 7d20635329..009ba99d96 100644 --- a/firmware/config/engines/vw.cpp +++ b/firmware/config/engines/vw.cpp @@ -42,10 +42,10 @@ void setVwAba() { engineConfiguration->ignitionMode = IM_ONE_COIL; - engineConfiguration->ignitionPins[0] = GPIOE_14; // Frankenso high side - pin 1G - engineConfiguration->ignitionPins[1] = GPIO_UNASSIGNED; - engineConfiguration->ignitionPins[2] = GPIO_UNASSIGNED; - engineConfiguration->ignitionPins[3] = GPIO_UNASSIGNED; + engineConfiguration->ignitionPins[0] = Gpio::E14; // Frankenso high side - pin 1G + engineConfiguration->ignitionPins[1] = Gpio::Unassigned; + engineConfiguration->ignitionPins[2] = Gpio::Unassigned; + engineConfiguration->ignitionPins[3] = Gpio::Unassigned; engineConfiguration->ignitionPinMode = OM_DEFAULT; engineConfiguration->idlePositionSensor = EFI_ADC_3; // PA3 @@ -77,7 +77,7 @@ void setHellen121Vag_v6_cyl() { engineConfiguration->specs.cylindersCount = 6; engineConfiguration->specs.displacement = 2.7; - engineConfiguration->camInputs[1 * CAMS_PER_BANK] = GPIOA_7; // 87a + engineConfiguration->camInputs[1 * CAMS_PER_BANK] = Gpio::A7; // 87a engineConfiguration->specs.firingOrder = FO_1_4_3_6_2_5; } diff --git a/firmware/config/engines/vw_b6.cpp b/firmware/config/engines/vw_b6.cpp index 79bf2703c0..86f3f3892f 100644 --- a/firmware/config/engines/vw_b6.cpp +++ b/firmware/config/engines/vw_b6.cpp @@ -80,32 +80,32 @@ void setVwPassatB6() { engineConfiguration->mc33816spiDevice = SPI_DEVICE_3; // RED - engineConfiguration->spi3mosiPin = GPIOC_12; + engineConfiguration->spi3mosiPin = Gpio::C12; // YELLOW - engineConfiguration->spi3misoPin = GPIOC_11; + engineConfiguration->spi3misoPin = Gpio::C11; // BROWN - engineConfiguration->spi3sckPin = GPIOC_10; - engineConfiguration->sdCardCsPin = GPIO_UNASSIGNED; + engineConfiguration->spi3sckPin = Gpio::C10; + engineConfiguration->sdCardCsPin = Gpio::Unassigned; engineConfiguration->is_enabled_spi_3 = true; // J8 orange - engineConfiguration->mc33816_cs = GPIOB_8; + engineConfiguration->mc33816_cs = Gpio::B8; // J8 Grey - engineConfiguration->mc33816_rstb = GPIOA_15; + engineConfiguration->mc33816_rstb = Gpio::A15; // J8 Dark BLUE - engineConfiguration->mc33816_driven = GPIOB_9; + engineConfiguration->mc33816_driven = Gpio::B9; // J9 violet - engineConfiguration->mc33816_flag0 = GPIOC_13; + engineConfiguration->mc33816_flag0 = Gpio::C13; // J10 Dark BLUE - engineConfiguration->injectionPins[0] = GPIOE_6; + engineConfiguration->injectionPins[0] = Gpio::E6; // J11 green - engineConfiguration->injectionPins[1] = GPIOE_5; + engineConfiguration->injectionPins[1] = Gpio::E5; // J18 grey - engineConfiguration->injectionPins[2] = GPIOB_7; + engineConfiguration->injectionPins[2] = Gpio::B7; // J6 white - engineConfiguration->injectionPins[3] = GPIOE_0; + engineConfiguration->injectionPins[3] = Gpio::E0; gppwm_channel *lowPressureFuelPumpControl = &engineConfiguration->gppwm[1]; @@ -115,7 +115,7 @@ void setVwPassatB6() { lowPressureFuelPumpControl->dutyIfError = 50; setTable(lowPressureFuelPumpControl->table, (uint8_t)50); // "42 - Injector 4", somehow GP4 did not work? not enough current? not happy with diode? - lowPressureFuelPumpControl->pin = TLE8888_PIN_4; + lowPressureFuelPumpControl->pin = Gpio::TLE8888_PIN_4; gppwm_channel *coolantControl = &engineConfiguration->gppwm[0]; @@ -124,7 +124,7 @@ void setVwPassatB6() { coolantControl->pwmFrequency = 25; coolantControl->loadAxis = GPPWM_FuelLoad; // Volkswage wants 10% for fan to be OFF, between pull-up and low side control we need to invert that value - // todo system lua for duty driven by CLT? (3, GPIOE_0, "0.15 90 coolant 120 min max 90 - 30 / 0.8 * +", 25); + // todo system lua for duty driven by CLT? (3, Gpio::E0, "0.15 90 coolant 120 min max 90 - 30 / 0.8 * +", 25); int value = 100 - 10; coolantControl->dutyIfError = value; setTable(coolantControl->table, (uint8_t)value); @@ -137,11 +137,11 @@ void setVwPassatB6() { } } */ - coolantControl->pin = TLE8888_PIN_5; // "3 - Lowside 2" + coolantControl->pin = Gpio::TLE8888_PIN_5; // "3 - Lowside 2" // "7 - Lowside 1" //engineConfiguration->hpfpValvePin = MRE_LS_1; engineConfiguration->disablePrimaryUart = true; - engineConfiguration->hpfpValvePin = GPIOB_10; // AUX J13 + engineConfiguration->hpfpValvePin = Gpio::B10; // AUX J13 engineConfiguration->hpfpCamLobes = 3; engineConfiguration->hpfpPumpVolume = 0.290; engineConfiguration->hpfpMinAngle = 10; @@ -163,8 +163,8 @@ void setVwPassatB6() { // https://rusefi.com/forum/viewtopic.php?p=38235#p38235 engineConfiguration->injector.flow = 1200; - engineConfiguration->idle.solenoidPin = GPIO_UNASSIGNED; - engineConfiguration->fanPin = GPIO_UNASSIGNED; + engineConfiguration->idle.solenoidPin = Gpio::Unassigned; + engineConfiguration->fanPin = Gpio::Unassigned; engineConfiguration->useETBforIdleControl = true; engineConfiguration->injectionMode = IM_SEQUENTIAL; diff --git a/firmware/config/stm32f4ems/efifeatures.h b/firmware/config/stm32f4ems/efifeatures.h index 59eee79a92..28fd3d9cdf 100644 --- a/firmware/config/stm32f4ems/efifeatures.h +++ b/firmware/config/stm32f4ems/efifeatures.h @@ -352,11 +352,6 @@ #define EFI_SPI3_AF 6 -#define EFI_I2C_SCL_BRAIN_PIN GPIOB_6 - -#define EFI_I2C_SDA_BRAIN_PIN GPIOB_7 -#define EFI_I2C_AF 4 - /** * Patched version of ChibiOS/RT support extra details in the system error messages */ @@ -395,11 +390,11 @@ // todo: start using consoleSerialTxPin? Not sure #ifndef EFI_CONSOLE_TX_BRAIN_PIN -#define EFI_CONSOLE_TX_BRAIN_PIN GPIOC_10 +#define EFI_CONSOLE_TX_BRAIN_PIN Gpio::C10 #endif // todo: start using consoleSerialRxPin? Not sure #ifndef EFI_CONSOLE_RX_BRAIN_PIN -#define EFI_CONSOLE_RX_BRAIN_PIN GPIOC_11 +#define EFI_CONSOLE_RX_BRAIN_PIN Gpio::C11 #endif // todo: this should be detected automatically based on pin selection // https://github.com/rusefi/rusefi/issues/3536 @@ -414,7 +409,7 @@ #endif #ifndef LED_CRITICAL_ERROR_BRAIN_PIN -#define LED_CRITICAL_ERROR_BRAIN_PIN GPIOD_14 +#define LED_CRITICAL_ERROR_BRAIN_PIN Gpio::D14 #endif #ifndef LED_ERROR_BRAIN_PIN_MODE #define LED_ERROR_BRAIN_PIN_MODE DEFAULT_OUTPUT diff --git a/firmware/config/stm32f7ems/efifeatures.h b/firmware/config/stm32f7ems/efifeatures.h index 2b49dd9888..0106e3dd58 100644 --- a/firmware/config/stm32f7ems/efifeatures.h +++ b/firmware/config/stm32f7ems/efifeatures.h @@ -54,11 +54,11 @@ // todo: start using consoleSerialTxPin? Not sure #undef EFI_CONSOLE_TX_BRAIN_PIN -#define EFI_CONSOLE_TX_BRAIN_PIN GPIOD_8 +#define EFI_CONSOLE_TX_BRAIN_PIN Gpio::D8 // todo: start using consoleSerialRxPin? Not sure #undef EFI_CONSOLE_RX_BRAIN_PIN -#define EFI_CONSOLE_RX_BRAIN_PIN GPIOD_9 +#define EFI_CONSOLE_RX_BRAIN_PIN Gpio::D9 #define EFI_USE_COMPRESSED_INI_MSD diff --git a/firmware/console/ethernet_console.cpp b/firmware/console/ethernet_console.cpp index ff826c34c8..8c0957908c 100644 --- a/firmware/console/ethernet_console.cpp +++ b/firmware/console/ethernet_console.cpp @@ -83,19 +83,19 @@ static EthernetThread ethernetConsole; void startEthernetConsole() { #ifndef STM32H7 // TODO: why does this break H7? I thought the pins were the same? - efiSetPadMode("ethernet", GPIOA_1, PAL_MODE_ALTERNATE(0xb)); - efiSetPadMode("ethernet", GPIOA_2, PAL_MODE_ALTERNATE(0xb)); - efiSetPadMode("ethernet", GPIOA_7, PAL_MODE_ALTERNATE(0xb)); + efiSetPadMode("ethernet", Gpio::A1, PAL_MODE_ALTERNATE(0xb)); + efiSetPadMode("ethernet", Gpio::A2, PAL_MODE_ALTERNATE(0xb)); + efiSetPadMode("ethernet", Gpio::A7, PAL_MODE_ALTERNATE(0xb)); - efiSetPadMode("ethernet", GPIOC_1, PAL_MODE_ALTERNATE(0xb)); - efiSetPadMode("ethernet", GPIOC_4, PAL_MODE_ALTERNATE(0xb)); - efiSetPadMode("ethernet", GPIOC_5, PAL_MODE_ALTERNATE(0xb)); + efiSetPadMode("ethernet", Gpio::C1, PAL_MODE_ALTERNATE(0xb)); + efiSetPadMode("ethernet", Gpio::C4, PAL_MODE_ALTERNATE(0xb)); + efiSetPadMode("ethernet", Gpio::C5, PAL_MODE_ALTERNATE(0xb)); - efiSetPadMode("ethernet", GPIOD_5, PAL_MODE_ALTERNATE(0xb)); + efiSetPadMode("ethernet", Gpio::D5, PAL_MODE_ALTERNATE(0xb)); - efiSetPadMode("ethernet", GPIOG_11, PAL_MODE_ALTERNATE(0xb)); - efiSetPadMode("ethernet", GPIOG_13, PAL_MODE_ALTERNATE(0xb)); - efiSetPadMode("ethernet", GPIOG_14, PAL_MODE_ALTERNATE(0xb)); + efiSetPadMode("ethernet", Gpio::G11, PAL_MODE_ALTERNATE(0xb)); + efiSetPadMode("ethernet", Gpio::G13, PAL_MODE_ALTERNATE(0xb)); + efiSetPadMode("ethernet", Gpio::G14, PAL_MODE_ALTERNATE(0xb)); #endif // STM32H7 ethernetConsole.Start(); diff --git a/firmware/console/status_loop.cpp b/firmware/console/status_loop.cpp index 471b4a8160..cc98758f74 100644 --- a/firmware/console/status_loop.cpp +++ b/firmware/console/status_loop.cpp @@ -164,7 +164,7 @@ static void printRusefiVersion(const char *engineTypeName, const char *firmwareB // Inform the console about the mapping between a pin's logical name (for example, injector 3) // and the physical MCU pin backing that function (for example, PE3) static void printOutPin(const char *pinName, brain_pin_e hwPin) { - if (hwPin == GPIO_UNASSIGNED || hwPin == GPIO_INVALID) { + if (hwPin == Gpio::Unassigned || hwPin == Gpio::Invalid) { return; } const char *hwPinName; diff --git a/firmware/controllers/actuators/boost_control.cpp b/firmware/controllers/actuators/boost_control.cpp index 3f9dfa1a68..78405d4974 100644 --- a/firmware/controllers/actuators/boost_control.cpp +++ b/firmware/controllers/actuators/boost_control.cpp @@ -173,7 +173,6 @@ void setDefaultBoostParameters() { engineConfiguration->boostPid.iFactor = 0.3; engineConfiguration->boostPid.maxValue = 20; engineConfiguration->boostPid.minValue = -20; - engineConfiguration->boostControlPin = GPIO_UNASSIGNED; engineConfiguration->boostControlPinMode = OM_DEFAULT; setLinearCurve(config->boostRpmBins, 0, 8000, 1); diff --git a/firmware/controllers/actuators/dc_motors.cpp b/firmware/controllers/actuators/dc_motors.cpp index 92141adda7..8007f7bf4e 100644 --- a/firmware/controllers/actuators/dc_motors.cpp +++ b/firmware/controllers/actuators/dc_motors.cpp @@ -136,10 +136,10 @@ DcMotor* initDcMotor(brain_pin_e coil_p, brain_pin_e coil_m, size_t index) { hw.start( true, /* useTwoWires */ - GPIO_UNASSIGNED, /* pinEnable */ + Gpio::Unassigned, /* pinEnable */ coil_p, coil_m, - GPIO_UNASSIGNED, /* pinDisable */ + Gpio::Unassigned, /* pinDisable */ engineConfiguration->stepperDcInvertedPins, &engine->executor, engineConfiguration->etbFreq /* same in case of stepper? */ diff --git a/firmware/controllers/algo/engine_configuration.cpp b/firmware/controllers/algo/engine_configuration.cpp index a52d32e263..c3fc6455aa 100644 --- a/firmware/controllers/algo/engine_configuration.cpp +++ b/firmware/controllers/algo/engine_configuration.cpp @@ -259,19 +259,19 @@ void setDefaultBasePins() { #ifdef EFI_WARNING_PIN engineConfiguration->warningLedPin = EFI_WARNING_PIN; #else - engineConfiguration->warningLedPin = GPIOD_13; // orange LED on discovery + engineConfiguration->warningLedPin = Gpio::D13; // orange LED on discovery #endif #ifdef EFI_COMMUNICATION_PIN engineConfiguration->communicationLedPin = EFI_COMMUNICATION_PIN; #else - engineConfiguration->communicationLedPin = GPIOD_15; // blue LED on discovery + engineConfiguration->communicationLedPin = Gpio::D15; // blue LED on discovery #endif #ifdef EFI_RUNNING_PIN engineConfiguration->runningLedPin = EFI_RUNNING_PIN; #else - engineConfiguration->runningLedPin = GPIOD_12; // green LED on discovery + engineConfiguration->runningLedPin = Gpio::D12; // green LED on discovery #endif #if EFI_PROD_CODE @@ -283,8 +283,8 @@ void setDefaultBasePins() { // set UART pads configuration based on the board // needed also by bootloader code engineConfiguration->useSerialPort = true; - engineConfiguration->binarySerialTxPin = GPIOC_10; - engineConfiguration->binarySerialRxPin = GPIOC_11; + engineConfiguration->binarySerialTxPin = Gpio::C10; + engineConfiguration->binarySerialRxPin = Gpio::C11; engineConfiguration->tunerStudioSerialSpeed = TS_DEFAULT_SPEED; engineConfiguration->uartConsoleSerialSpeed = 115200; @@ -299,7 +299,7 @@ void setDefaultBasePins() { void setDefaultSdCardParameters() { engineConfiguration->is_enabled_spi_3 = true; engineConfiguration->sdCardSpiDevice = SPI_DEVICE_3; - engineConfiguration->sdCardCsPin = GPIOD_4; + engineConfiguration->sdCardCsPin = Gpio::D4; engineConfiguration->isSdCardEnabled = true; #if EFI_PROD_CODE @@ -351,16 +351,16 @@ static void setDefaultIdleSpeedTarget() { } static void setDefaultFrankensoStepperIdleParameters() { - engineConfiguration->idle.stepperDirectionPin = GPIOE_10; - engineConfiguration->idle.stepperStepPin = GPIOE_12; - engineConfiguration->stepperEnablePin = GPIOE_14; + engineConfiguration->idle.stepperDirectionPin = Gpio::E10; + engineConfiguration->idle.stepperStepPin = Gpio::E12; + engineConfiguration->stepperEnablePin = Gpio::E14; engineConfiguration->idleStepperReactionTime = 10; engineConfiguration->idleStepperTotalSteps = 150; } static void setCanFrankensoDefaults() { - engineConfiguration->canTxPin = GPIOB_6; - engineConfiguration->canRxPin = GPIOB_12; + engineConfiguration->canTxPin = Gpio::B6; + engineConfiguration->canRxPin = Gpio::B12; } /** @@ -376,7 +376,7 @@ void setDefaultGppwmParameters() { for (size_t i = 0; i < efi::size(engineConfiguration->gppwm); i++) { auto& cfg = engineConfiguration->gppwm[i]; - cfg.pin = GPIO_UNASSIGNED; + cfg.pin = Gpio::Unassigned; cfg.dutyIfError = 0; cfg.onAboveDuty = 60; cfg.offBelowDuty = 50; @@ -411,7 +411,7 @@ static void setHip9011FrankensoPinout() { /** * SPI on PB13/14/15 */ - // engineConfiguration->hip9011CsPin = GPIOD_0; // rev 0.1 + // engineConfiguration->hip9011CsPin = Gpio::D0; // rev 0.1 engineConfiguration->isHip9011Enabled = true; engineConfiguration->hip9011PrescalerAndSDO = HIP_8MHZ_PRESCALER; // 8MHz chip @@ -421,11 +421,11 @@ static void setHip9011FrankensoPinout() { #ifdef EFI_HIP_CS_PIN engineConfiguration->hip9011CsPin = EFI_HIP_CS_PIN; #else - engineConfiguration->hip9011CsPin = GPIOB_0; // rev 0.4 + engineConfiguration->hip9011CsPin = Gpio::B0; // rev 0.4 #endif engineConfiguration->hip9011CsPinMode = OM_OPENDRAIN; - engineConfiguration->hip9011IntHoldPin = GPIOB_11; + engineConfiguration->hip9011IntHoldPin = Gpio::B11; engineConfiguration->hip9011IntHoldPinMode = OM_OPENDRAIN; engineConfiguration->spi2SckMode = PO_OPENDRAIN; // 4 @@ -722,33 +722,33 @@ void setDefaultFrankensoConfiguration() { engineConfiguration->hip9011SpiDevice = SPI_DEVICE_2; engineConfiguration->cj125SpiDevice = SPI_DEVICE_2; -// engineConfiguration->gps_rx_pin = GPIOB_7; -// engineConfiguration->gps_tx_pin = GPIOB_6; +// engineConfiguration->gps_rx_pin = Gpio::B7; +// engineConfiguration->gps_tx_pin = Gpio::B6; - engineConfiguration->triggerSimulatorPins[0] = GPIOD_1; - engineConfiguration->triggerSimulatorPins[1] = GPIOD_2; + engineConfiguration->triggerSimulatorPins[0] = Gpio::D1; + engineConfiguration->triggerSimulatorPins[1] = Gpio::D2; - engineConfiguration->triggerInputPins[0] = GPIOC_6; - engineConfiguration->triggerInputPins[1] = GPIOA_5; + engineConfiguration->triggerInputPins[0] = Gpio::C6; + engineConfiguration->triggerInputPins[1] = Gpio::A5; // set this to SPI_DEVICE_3 to enable stimulation //engineConfiguration->digitalPotentiometerSpiDevice = SPI_DEVICE_3; - engineConfiguration->digitalPotentiometerChipSelect[0] = GPIOD_7; - engineConfiguration->digitalPotentiometerChipSelect[1] = GPIO_UNASSIGNED; - engineConfiguration->digitalPotentiometerChipSelect[2] = GPIOD_5; - engineConfiguration->digitalPotentiometerChipSelect[3] = GPIO_UNASSIGNED; + engineConfiguration->digitalPotentiometerChipSelect[0] = Gpio::D7; + engineConfiguration->digitalPotentiometerChipSelect[1] = Gpio::Unassigned; + engineConfiguration->digitalPotentiometerChipSelect[2] = Gpio::D5; + engineConfiguration->digitalPotentiometerChipSelect[3] = Gpio::Unassigned; - engineConfiguration->spi1mosiPin = GPIOB_5; - engineConfiguration->spi1misoPin = GPIOB_4; - engineConfiguration->spi1sckPin = GPIOB_3; // please note that this pin is also SWO/SWD - Single Wire debug Output + engineConfiguration->spi1mosiPin = Gpio::B5; + engineConfiguration->spi1misoPin = Gpio::B4; + engineConfiguration->spi1sckPin = Gpio::B3; // please note that this pin is also SWO/SWD - Single Wire debug Output - engineConfiguration->spi2mosiPin = GPIOB_15; - engineConfiguration->spi2misoPin = GPIOB_14; - engineConfiguration->spi2sckPin = GPIOB_13; + engineConfiguration->spi2mosiPin = Gpio::B15; + engineConfiguration->spi2misoPin = Gpio::B14; + engineConfiguration->spi2sckPin = Gpio::B13; - engineConfiguration->spi3mosiPin = GPIOB_5; - engineConfiguration->spi3misoPin = GPIOB_4; - engineConfiguration->spi3sckPin = GPIOB_3; + engineConfiguration->spi3mosiPin = Gpio::B5; + engineConfiguration->spi3misoPin = Gpio::B4; + engineConfiguration->spi3sckPin = Gpio::B3; // set optional subsystem configs #if EFI_MEMS @@ -1189,11 +1189,11 @@ void commonFrankensoAnalogInputs(engine_configuration_s *engineConfiguration) { void setFrankenso0_1_joystick(engine_configuration_s *engineConfiguration) { - engineConfiguration->joystickCenterPin = GPIOC_8; - engineConfiguration->joystickAPin = GPIOD_10; - engineConfiguration->joystickBPin = GPIO_UNASSIGNED; - engineConfiguration->joystickCPin = GPIO_UNASSIGNED; - engineConfiguration->joystickDPin = GPIOD_11; + engineConfiguration->joystickCenterPin = Gpio::C8; + engineConfiguration->joystickAPin = Gpio::D10; + engineConfiguration->joystickBPin = Gpio::Unassigned; + engineConfiguration->joystickCPin = Gpio::Unassigned; + engineConfiguration->joystickDPin = Gpio::D11; } // These symbols are weak so that a board_configuration.cpp file can override them diff --git a/firmware/controllers/algo/engine_configuration.h b/firmware/controllers/algo/engine_configuration.h index 433a55f38c..443578718a 100644 --- a/firmware/controllers/algo/engine_configuration.h +++ b/firmware/controllers/algo/engine_configuration.h @@ -93,7 +93,7 @@ extern engine_configuration_s & activeConfiguration; // so we need to tell the firmware that it's "void" (i.e. zeroed, invalid) by setting a special flag variable, // and then we consider 'x' as changed if it's just non-zero. extern bool isActiveConfigurationVoid; -#define isConfigurationChanged(x) ((engineConfiguration->x != activeConfiguration.x) || (isActiveConfigurationVoid && engineConfiguration->x != 0)) +#define isConfigurationChanged(x) ((engineConfiguration->x != activeConfiguration.x) || (isActiveConfigurationVoid && (int)(engineConfiguration->x) != 0)) #endif /* EFI_ACTIVE_CONFIGURATION_IN_FLASH */ #define isPinOrModeChanged(pin, mode) (isConfigurationChanged(pin) || isConfigurationChanged(mode)) diff --git a/firmware/controllers/algo/rusefi_enums.h b/firmware/controllers/algo/rusefi_enums.h index 77ff7c95b6..6b39769330 100644 --- a/firmware/controllers/algo/rusefi_enums.h +++ b/firmware/controllers/algo/rusefi_enums.h @@ -395,8 +395,6 @@ typedef enum { Force_4_bytes_size_ego_sensor = ENUM_32_BITS, } ego_sensor_e; -typedef brain_pin_e output_pin_e; - typedef enum { MT_CUSTOM = 0, MT_DENSO183 = 1, diff --git a/firmware/controllers/algo/rusefi_hw_enums.h b/firmware/controllers/algo/rusefi_hw_enums.h index bec99523f4..0df6c40b13 100644 --- a/firmware/controllers/algo/rusefi_hw_enums.h +++ b/firmware/controllers/algo/rusefi_hw_enums.h @@ -7,8 +7,6 @@ #pragma once -enum class TestCppStyleEnum : uint8_t { }; - // todo: migrate/unify with pin_output_mode_e? rename? something is messy here // this enum is currently only used for SPI pins typedef enum __attribute__ ((__packed__)) { @@ -22,164 +20,164 @@ typedef enum __attribute__ ((__packed__)) { /** * Hardware pin. This enum is platform-specific. */ -typedef enum __attribute__ ((__packed__)) { - GPIO_UNASSIGNED = 0, +enum class Gpio : uint8_t { + Unassigned = 0, // only used as return value of 'parseBrainPin' function do we really this this logic special value at all?! - GPIO_INVALID = 1, + Invalid = 1, - GPIOA_0 = 2, - GPIOA_1 = 3, - GPIOA_2 = 4, - GPIOA_3 = 5, - GPIOA_4 = 6, - GPIOA_5 = 7, - GPIOA_6 = 8, - GPIOA_7 = 9, - GPIOA_8 = 10, - GPIOA_9 = 11, - GPIOA_10 = 12, - GPIOA_11 = 13, - GPIOA_12 = 14, - GPIOA_13 = 15, - GPIOA_14 = 16, - GPIOA_15 = 17, + A0 = 2, + A1 = 3, + A2 = 4, + A3 = 5, + A4 = 6, + A5 = 7, + A6 = 8, + A7 = 9, + A8 = 10, + A9 = 11, + A10 = 12, + A11 = 13, + A12 = 14, + A13 = 15, + A14 = 16, + A15 = 17, - GPIOB_0 = 18, - GPIOB_1 = 19, - GPIOB_2 = 20, - GPIOB_3 = 21, - GPIOB_4 = 22, - GPIOB_5 = 23, - GPIOB_6 = 24, - GPIOB_7 = 25, - GPIOB_8 = 26, - GPIOB_9 = 27, - GPIOB_10 = 28, - GPIOB_11 = 29, - GPIOB_12 = 30, - GPIOB_13 = 31, - GPIOB_14 = 32, - GPIOB_15 = 33, + B0 = 18, + B1 = 19, + B2 = 20, + B3 = 21, + B4 = 22, + B5 = 23, + B6 = 24, + B7 = 25, + B8 = 26, + B9 = 27, + B10 = 28, + B11 = 29, + B12 = 30, + B13 = 31, + B14 = 32, + B15 = 33, - GPIOC_0 = 34, - GPIOC_1 = 35, - GPIOC_2 = 36, - GPIOC_3 = 37, - GPIOC_4 = 38, - GPIOC_5 = 39, - GPIOC_6 = 40, - GPIOC_7 = 41, - GPIOC_8 = 42, - GPIOC_9 = 43, - GPIOC_10 = 44, - GPIOC_11 = 45, - GPIOC_12 = 46, - GPIOC_13 = 47, - GPIOC_14 = 48, - GPIOC_15 = 49, + C0 = 34, + C1 = 35, + C2 = 36, + C3 = 37, + C4 = 38, + C5 = 39, + C6 = 40, + C7 = 41, + C8 = 42, + C9 = 43, + C10 = 44, + C11 = 45, + C12 = 46, + C13 = 47, + C14 = 48, + C15 = 49, - GPIOD_0 = 50, - GPIOD_1 = 51, - GPIOD_2 = 52, - GPIOD_3 = 53, - GPIOD_4 = 54, - GPIOD_5 = 55, - GPIOD_6 = 56, - GPIOD_7 = 57, - GPIOD_8 = 58, - GPIOD_9 = 59, - GPIOD_10 = 60, - GPIOD_11 = 61, - GPIOD_12 = 62, - GPIOD_13 = 63, - GPIOD_14 = 64, - GPIOD_15 = 65, + D0 = 50, + D1 = 51, + D2 = 52, + D3 = 53, + D4 = 54, + D5 = 55, + D6 = 56, + D7 = 57, + D8 = 58, + D9 = 59, + D10 = 60, + D11 = 61, + D12 = 62, + D13 = 63, + D14 = 64, + D15 = 65, - GPIOE_0 = 66, - GPIOE_1 = 67, - GPIOE_2 = 68, - GPIOE_3 = 69, - GPIOE_4 = 70, - GPIOE_5 = 71, - GPIOE_6 = 72, - GPIOE_7 = 73, - GPIOE_8 = 74, - GPIOE_9 = 75, - GPIOE_10 = 76, - GPIOE_11 = 77, - GPIOE_12 = 78, - GPIOE_13 = 79, - GPIOE_14 = 80, - GPIOE_15 = 81, + E0 = 66, + E1 = 67, + E2 = 68, + E3 = 69, + E4 = 70, + E5 = 71, + E6 = 72, + E7 = 73, + E8 = 74, + E9 = 75, + E10 = 76, + E11 = 77, + E12 = 78, + E13 = 79, + E14 = 80, + E15 = 81, - GPIOF_0 = 82, - GPIOF_1 = 83, - GPIOF_2 = 84, - GPIOF_3 = 85, - GPIOF_4 = 86, - GPIOF_5 = 87, - GPIOF_6 = 88, - GPIOF_7 = 89, - GPIOF_8 = 90, - GPIOF_9 = 91, - GPIOF_10 = 92, - GPIOF_11 = 93, - GPIOF_12 = 94, - GPIOF_13 = 95, - GPIOF_14 = 96, - GPIOF_15 = 97, + F0 = 82, + F1 = 83, + F2 = 84, + F3 = 85, + F4 = 86, + F5 = 87, + F6 = 88, + F7 = 89, + F8 = 90, + F9 = 91, + F10 = 92, + F11 = 93, + F12 = 94, + F13 = 95, + F14 = 96, + F15 = 97, - GPIOG_0 = 98, - GPIOG_1 = 99, - GPIOG_2 = 100, - GPIOG_3 = 101, - GPIOG_4 = 102, - GPIOG_5 = 103, - GPIOG_6 = 104, - GPIOG_7 = 105, - GPIOG_8 = 106, - GPIOG_9 = 107, - GPIOG_10 = 108, - GPIOG_11 = 109, - GPIOG_12 = 110, - GPIOG_13 = 111, - GPIOG_14 = 112, - GPIOG_15 = 113, + G0 = 98, + G1 = 99, + G2 = 100, + G3 = 101, + G4 = 102, + G5 = 103, + G6 = 104, + G7 = 105, + G8 = 106, + G9 = 107, + G10 = 108, + G11 = 109, + G12 = 110, + G13 = 111, + G14 = 112, + G15 = 113, - GPIOH_0 = 114, - GPIOH_1 = 115, - GPIOH_2 = 116, - GPIOH_3 = 117, - GPIOH_4 = 118, - GPIOH_5 = 119, - GPIOH_6 = 120, - GPIOH_7 = 121, - GPIOH_8 = 122, - GPIOH_9 = 123, - GPIOH_10 = 124, - GPIOH_11 = 125, - GPIOH_12 = 126, - GPIOH_13 = 127, - GPIOH_14 = 128, - GPIOH_15 = 129, + H0 = 114, + H1 = 115, + H2 = 116, + H3 = 117, + H4 = 118, + H5 = 119, + H6 = 120, + H7 = 121, + H8 = 122, + H9 = 123, + H10 = 124, + H11 = 125, + H12 = 126, + H13 = 127, + H14 = 128, + H15 = 129, /* Used by 176-pin STM32 MCUs */ - GPIOI_0 = 130, - GPIOI_1 = 131, - GPIOI_2 = 132, - GPIOI_3 = 133, - GPIOI_4 = 134, - GPIOI_5 = 135, - GPIOI_6 = 136, - GPIOI_7 = 137, - GPIOI_8 = 138, - GPIOI_9 = 139, - GPIOI_10 = 140, - GPIOI_11 = 141, - GPIOI_12 = 142, - GPIOI_13 = 143, - GPIOI_14 = 144, - GPIOI_15 = 145, + I0 = 130, + I1 = 131, + I2 = 132, + I3 = 133, + I4 = 134, + I5 = 135, + I6 = 136, + I7 = 137, + I8 = 138, + I9 = 139, + I10 = 140, + I11 = 141, + I12 = 142, + I13 = 143, + I14 = 144, + I15 = 145, /* MC33972 pins go right after on_chip pins */ MC33972_PIN_1 = 146, @@ -271,13 +269,13 @@ typedef enum __attribute__ ((__packed__)) { L9779_OUT_28 = 246, L9779_OUT_MRD = 247, L9779_PIN_KEY = 248, -} brain_pin_e; +}; /* Please keep updating these defines */ -#define BRAIN_PIN_ONCHIP_LAST GPIOI_15 -#define BRAIN_PIN_ONCHIP_PINS (BRAIN_PIN_ONCHIP_LAST - GPIOA_0 + 1) -#define BRAIN_PIN_LAST L9779_PIN_KEY -#define BRAIN_PIN_TOTAL_PINS (BRAIN_PIN_LAST - GPIOA_0 + 1) +#define BRAIN_PIN_ONCHIP_LAST Gpio::I15 +#define BRAIN_PIN_ONCHIP_PINS (BRAIN_PIN_ONCHIP_LAST - Gpio::A0 + 1) +#define BRAIN_PIN_LAST Gpio::L9779_PIN_KEY +#define BRAIN_PIN_TOTAL_PINS (BRAIN_PIN_LAST - Gpio::A0 + 1) /** * Frankenso analog #1 PC2 ADC12 diff --git a/firmware/controllers/algo/rusefi_types.h b/firmware/controllers/algo/rusefi_types.h index 3011b52722..4560aca6b0 100644 --- a/firmware/controllers/algo/rusefi_types.h +++ b/firmware/controllers/algo/rusefi_types.h @@ -104,6 +104,8 @@ using gppwm_note_t = char[GPPWM_NOTE_SIZE]; using le_formula_t = char[LE_COMMAND_LENGTH]; +using brain_pin_e = Gpio; + using egt_cs_array_t = brain_pin_e[EGT_CHANNEL_COUNT]; using pwm_freq_t = int16_t; @@ -112,6 +114,7 @@ using script_setting_t = float; using brain_input_pin_e = brain_pin_e; using switch_input_pin_e = brain_pin_e; +using output_pin_e = brain_pin_e; typedef void (*VoidPtr)(void*); diff --git a/firmware/controllers/engine_controller.cpp b/firmware/controllers/engine_controller.cpp index 3932def917..db6719046e 100644 --- a/firmware/controllers/engine_controller.cpp +++ b/firmware/controllers/engine_controller.cpp @@ -623,7 +623,7 @@ bool validateConfig() { for (size_t index = 0; index < efi::size(engineConfiguration->vrThreshold); index++) { auto& cfg = engineConfiguration->vrThreshold[index]; - if (cfg.pin == GPIO_UNASSIGNED) { + if (cfg.pin == Gpio::Unassigned) { continue; } ensureArrayIsAscending("VR Bins", cfg.rpmBins); @@ -648,13 +648,13 @@ bool validateConfig() { } // VVT - if (engineConfiguration->camInputs[0] != GPIO_UNASSIGNED) { + if (engineConfiguration->camInputs[0] != Gpio::Unassigned) { ensureArrayIsAscending("VVT intake load", config->vvtTable1LoadBins); ensureArrayIsAscending("VVT intake RPM", config->vvtTable1RpmBins); } #if CAM_INPUTS_COUNT != 1 - if (engineConfiguration->camInputs[1] != GPIO_UNASSIGNED) { + if (engineConfiguration->camInputs[1] != Gpio::Unassigned) { ensureArrayIsAscending("VVT exhaust load", config->vvtTable2LoadBins); ensureArrayIsAscending("VVT exhaust RPM", config->vvtTable2RpmBins); } diff --git a/firmware/controllers/lua/lua_hooks.cpp b/firmware/controllers/lua/lua_hooks.cpp index e42c39c804..411ea10b8f 100644 --- a/firmware/controllers/lua/lua_hooks.cpp +++ b/firmware/controllers/lua/lua_hooks.cpp @@ -31,7 +31,7 @@ static int lua_readpin(lua_State* l) { auto msg = luaL_checkstring(l, 1); #if EFI_PROD_CODE brain_pin_e pin = parseBrainPin(msg); - if (pin == GPIO_INVALID) { + if (!isBrainPinValid(pin)) { lua_pushnil(l); } else { int physicalValue = palReadPad(getHwPort("read", pin), getHwPin("read", pin)); diff --git a/firmware/controllers/sensors/frequency_sensor.cpp b/firmware/controllers/sensors/frequency_sensor.cpp index b570da7466..888bbb9501 100644 --- a/firmware/controllers/sensors/frequency_sensor.cpp +++ b/firmware/controllers/sensors/frequency_sensor.cpp @@ -49,7 +49,7 @@ void FrequencySensor::deInit() { efiExtiDisablePin(m_pin); #endif - m_pin = GPIO_UNASSIGNED; + m_pin = Gpio::Unassigned; } void FrequencySensor::onEdge(efitick_t nowNt) { diff --git a/firmware/controllers/sensors/frequency_sensor.h b/firmware/controllers/sensors/frequency_sensor.h index b137a91285..691a4ec9d6 100644 --- a/firmware/controllers/sensors/frequency_sensor.h +++ b/firmware/controllers/sensors/frequency_sensor.h @@ -15,7 +15,7 @@ public: private: Timer m_edgeTimer; - brain_pin_e m_pin = GPIO_UNASSIGNED; + brain_pin_e m_pin = Gpio::Unassigned; Biquad m_filter; }; diff --git a/firmware/controllers/sensors/vr_pwm.cpp b/firmware/controllers/sensors/vr_pwm.cpp index 710917099f..aec7b4dc0a 100644 --- a/firmware/controllers/sensors/vr_pwm.cpp +++ b/firmware/controllers/sensors/vr_pwm.cpp @@ -8,7 +8,7 @@ static SimplePwm pwms[VR_THRESHOLD_COUNT]; static void updateVrPwm(int rpm, size_t index) { auto& cfg = engineConfiguration->vrThreshold[index]; - if (cfg.pin == GPIO_UNASSIGNED) { + if (!isBrainPinValid(cfg.pin)) { return; } @@ -33,7 +33,7 @@ void initVrPwm() { for (size_t i = 0; i < efi::size(engineConfiguration->vrThreshold); i++) { auto& cfg = engineConfiguration->vrThreshold[i]; - if (cfg.pin == GPIO_UNASSIGNED) { + if (!isBrainPinValid(cfg.pin)) { continue; } diff --git a/firmware/controllers/settings.cpp b/firmware/controllers/settings.cpp index 0a253b6e32..2bacad22f7 100644 --- a/firmware/controllers/settings.cpp +++ b/firmware/controllers/settings.cpp @@ -425,7 +425,7 @@ static void setPotSpi(int spi) { static brain_pin_e parseBrainPinWithErrorMessage(const char *pinName) { brain_pin_e pin = parseBrainPin(pinName); - if (pin == GPIO_INVALID) { + if (pin == Gpio::Invalid) { efiPrintf("invalid pin name [%s]", pinName); } return pin; @@ -442,7 +442,7 @@ static void setIgnitionPin(const char *indexStr, const char *pinName) { if (index < 0 || index >= MAX_CYLINDER_COUNT) return; brain_pin_e pin = parseBrainPinWithErrorMessage(pinName); - if (pin == GPIO_INVALID) { + if (pin == Gpio::Invalid) { return; } efiPrintf("setting ignition pin[%d] to %s please save&restart", index, hwPortname(pin)); @@ -453,7 +453,7 @@ static void setIgnitionPin(const char *indexStr, const char *pinName) { // this method is useful for desperate time debugging void readPin(const char *pinName) { brain_pin_e pin = parseBrainPinWithErrorMessage(pinName); - if (pin == GPIO_INVALID) { + if (pin == Gpio::Invalid) { return; } int physicalValue = palReadPad(getHwPort("read", pin), getHwPin("read", pin)); @@ -464,7 +464,7 @@ void readPin(const char *pinName) { // this method is useful for desperate time debugging or hardware validation static void benchSetPinValue(const char *pinName, int bit) { brain_pin_e pin = parseBrainPinWithErrorMessage(pinName); - if (pin == GPIO_INVALID) { + if (pin == Gpio::Invalid) { return; } palWritePad(getHwPort("write", pin), getHwPin("write", pin), bit); @@ -482,7 +482,7 @@ static void benchSetPin(const char *pinName) { static void setIndividualPin(const char *pinName, brain_pin_e *targetPin, const char *name) { brain_pin_e pin = parseBrainPinWithErrorMessage(pinName); - if (pin == GPIO_INVALID) { + if (pin == Gpio::Invalid) { return; } efiPrintf("setting %s pin to %s please save&restart", name, hwPortname(pin)); @@ -553,7 +553,7 @@ static void setInjectionPin(const char *indexStr, const char *pinName) { if (index < 0 || index >= MAX_CYLINDER_COUNT) return; brain_pin_e pin = parseBrainPinWithErrorMessage(pinName); - if (pin == GPIO_INVALID) { + if (pin == Gpio::Invalid) { return; } efiPrintf("setting injection pin[%d] to %s please save&restart", index, hwPortname(pin)); @@ -572,7 +572,7 @@ static void setTriggerInputPin(const char *indexStr, const char *pinName) { if (index < 0 || index > 2) return; brain_pin_e pin = parseBrainPinWithErrorMessage(pinName); - if (pin == GPIO_INVALID) { + if (pin == Gpio::Invalid) { return; } efiPrintf("setting trigger pin[%d] to %s please save&restart", index, hwPortname(pin)); @@ -597,7 +597,7 @@ static void setEgtCSPin(const char *indexStr, const char *pinName) { if (index < 0 || index >= EGT_CHANNEL_COUNT) return; brain_pin_e pin = parseBrainPinWithErrorMessage(pinName); - if (pin == GPIO_INVALID) { + if (pin == Gpio::Invalid) { return; } efiPrintf("setting EGT CS pin[%d] to %s please save&restart", index, hwPortname(pin)); @@ -610,7 +610,7 @@ static void setTriggerSimulatorPin(const char *indexStr, const char *pinName) { if (index < 0 || index >= TRIGGER_SIMULATOR_PIN_COUNT) return; brain_pin_e pin = parseBrainPinWithErrorMessage(pinName); - if (pin == GPIO_INVALID) { + if (pin == Gpio::Invalid) { return; } efiPrintf("setting trigger simulator pin[%d] to %s please save&restart", index, hwPortname(pin)); @@ -623,7 +623,7 @@ static void setTriggerSimulatorPin(const char *indexStr, const char *pinName) { // set_analog_input_pin afr none static void setAnalogInputPin(const char *sensorStr, const char *pinName) { brain_pin_e pin = parseBrainPinWithErrorMessage(pinName); - if (pin == GPIO_INVALID) { + if (pin == Gpio::Invalid) { return; } adc_channel_e channel = getAdcChannel(pin); @@ -663,7 +663,7 @@ static void setLogicInputPin(const char *indexStr, const char *pinName) { return; } brain_pin_e pin = parseBrainPinWithErrorMessage(pinName); - if (pin == GPIO_INVALID) { + if (pin == Gpio::Invalid) { return; } efiPrintf("setting logic input pin[%d] to %s please save&restart", index, hwPortname(pin)); @@ -673,7 +673,7 @@ static void setLogicInputPin(const char *indexStr, const char *pinName) { static void showPinFunction(const char *pinName) { brain_pin_e pin = parseBrainPinWithErrorMessage(pinName); - if (pin == GPIO_INVALID) { + if (pin == Gpio::Invalid) { return; } efiPrintf("Pin %s: [%s]", pinName, getPinFunction(pin)); diff --git a/firmware/controllers/system/efi_gpio.cpp b/firmware/controllers/system/efi_gpio.cpp index b247572da0..23ce194668 100644 --- a/firmware/controllers/system/efi_gpio.cpp +++ b/firmware/controllers/system/efi_gpio.cpp @@ -408,7 +408,7 @@ bool OutputPin::getAndSet(int logicValue) { // This function is only used on real hardware #if EFI_PROD_CODE void OutputPin::setOnchipValue(int electricalValue) { - if (brainPin == GPIO_UNASSIGNED || brainPin == GPIO_INVALID) { + if (brainPin == Gpio::Unassigned || brainPin == Gpio::Invalid) { // todo: make 'setOnchipValue' or 'reportsetOnchipValueError' virtual and override for NamedOutputPin? warning(CUSTOM_ERR_6586, "attempting to change unassigned pin"); return; @@ -608,7 +608,7 @@ void OutputPin::deInit() { #endif /* EFI_GPIO_HARDWARE */ // Clear the pin so that it won't get set any more - brainPin = GPIO_UNASSIGNED; + brainPin = Gpio::Unassigned; } #if EFI_GPIO_HARDWARE diff --git a/firmware/controllers/system/efi_gpio.h b/firmware/controllers/system/efi_gpio.h index 6c12ac5cfb..3db75fe24d 100644 --- a/firmware/controllers/system/efi_gpio.h +++ b/firmware/controllers/system/efi_gpio.h @@ -69,7 +69,7 @@ public: int unitTestTurnedOnCounter = 0; #endif - brain_pin_e brainPin = GPIO_UNASSIGNED; + brain_pin_e brainPin = Gpio::Unassigned; #if (EFI_GPIO_HARDWARE && (BOARD_EXT_GPIOCHIPS > 0)) /* used for external pins */ diff --git a/firmware/controllers/trigger/trigger_central.cpp b/firmware/controllers/trigger/trigger_central.cpp index 57ff51a5a8..2fc696ffd6 100644 --- a/firmware/controllers/trigger/trigger_central.cpp +++ b/firmware/controllers/trigger/trigger_central.cpp @@ -124,12 +124,12 @@ static void turnOffAllDebugFields(void *arg) { (void)arg; #if EFI_PROD_CODE for (int index = 0;indextriggerInputDebugPins[index] != GPIO_UNASSIGNED) { + if (engineConfiguration->triggerInputDebugPins[index] != Gpio::Unassigned) { writePad("trigger debug", engineConfiguration->triggerInputDebugPins[index], 0); } } for (int index = 0;indexcamInputsDebug[index] != GPIO_UNASSIGNED) { + if (engineConfiguration->camInputsDebug[index] != Gpio::Unassigned) { writePad("cam debug", engineConfiguration->camInputsDebug[index], 0); } } @@ -190,7 +190,7 @@ static void logFront(bool isImportantFront, efitick_t nowNt, int index) { extern const char *vvtNames[]; const char *vvtName = vvtNames[index]; - if (isImportantFront && engineConfiguration->camInputsDebug[index] != GPIO_UNASSIGNED) { + if (isImportantFront && engineConfiguration->camInputsDebug[index] != Gpio::Unassigned) { #if EFI_PROD_CODE writePad("cam debug", engineConfiguration->camInputsDebug[index], 1); #endif /* EFI_PROD_CODE */ @@ -462,7 +462,7 @@ void handleShaftSignal(int signalIndex, bool isRising, efitick_t timestamp) { } } - if (engineConfiguration->triggerInputDebugPins[signalIndex] != GPIO_UNASSIGNED) { + if (engineConfiguration->triggerInputDebugPins[signalIndex] != Gpio::Unassigned) { #if EFI_PROD_CODE writePad("trigger debug", engineConfiguration->triggerInputDebugPins[signalIndex], 1); #endif /* EFI_PROD_CODE */ @@ -917,15 +917,15 @@ bool TriggerCentral::isTriggerConfigChanged() { } void validateTriggerInputs() { - if (engineConfiguration->triggerInputPins[0] == GPIO_UNASSIGNED && engineConfiguration->triggerInputPins[1] != GPIO_UNASSIGNED) { + if (engineConfiguration->triggerInputPins[0] == Gpio::Unassigned && engineConfiguration->triggerInputPins[1] != Gpio::Unassigned) { firmwareError(OBD_PCM_Processor_Fault, "First trigger channel is missing"); } - if (engineConfiguration->camInputs[0] == GPIO_UNASSIGNED && engineConfiguration->camInputs[1] != GPIO_UNASSIGNED) { + if (engineConfiguration->camInputs[0] == Gpio::Unassigned && engineConfiguration->camInputs[1] != Gpio::Unassigned) { firmwareError(OBD_PCM_Processor_Fault, "If you only have cam on exhaust please pretend that it's on intake in configuration"); } - if (engineConfiguration->camInputs[0] == GPIO_UNASSIGNED && engineConfiguration->camInputs[2] != GPIO_UNASSIGNED) { + if (engineConfiguration->camInputs[0] == Gpio::Unassigned && engineConfiguration->camInputs[2] != Gpio::Unassigned) { firmwareError(OBD_PCM_Processor_Fault, "First bank cam input is required if second bank specified"); } } diff --git a/firmware/hw_layer/debounce.cpp b/firmware/hw_layer/debounce.cpp index a68f7fb103..c50dd1cde7 100644 --- a/firmware/hw_layer/debounce.cpp +++ b/firmware/hw_layer/debounce.cpp @@ -57,7 +57,7 @@ void ButtonDebounce::stopConfiguration () { #if ! EFI_ACTIVE_CONFIGURATION_IN_FLASH if (*m_pin != active_pin || *m_mode != active_mode) { #else - if (*m_pin != active_pin || *m_mode != active_mode || (isActiveConfigurationVoid && (*m_pin != 0 || *m_mode != 0))) { + if (*m_pin != active_pin || *m_mode != active_mode || (isActiveConfigurationVoid && ((int)(*m_pin) != 0 || (int)(*m_mode) != 0))) { #endif /* EFI_ACTIVE_CONFIGURATION_IN_FLASH */ #if EFI_PROD_CODE efiSetPadUnused(active_pin); diff --git a/firmware/hw_layer/debounce.h b/firmware/hw_layer/debounce.h index 5378f5db3b..a45af0d258 100644 --- a/firmware/hw_layer/debounce.h +++ b/firmware/hw_layer/debounce.h @@ -29,7 +29,7 @@ private: efitick_t m_threshold; efitick_t timeLast; brain_pin_e *m_pin; - brain_pin_e active_pin = GPIO_UNASSIGNED; + brain_pin_e active_pin = Gpio::Unassigned; pin_input_mode_e *m_mode; pin_input_mode_e active_mode = PI_DEFAULT; bool storedValue = false; diff --git a/firmware/hw_layer/digital_input/digital_input.h b/firmware/hw_layer/digital_input/digital_input.h index e8a8be4e37..d543c52427 100644 --- a/firmware/hw_layer/digital_input/digital_input.h +++ b/firmware/hw_layer/digital_input/digital_input.h @@ -16,7 +16,7 @@ struct digital_input_s { #endif /* HAL_USE_ICU */ volatile bool started = false; - brain_pin_e brainPin = GPIO_UNASSIGNED; + brain_pin_e brainPin = Gpio::Unassigned; IntListenerArray<1> widthListeners; IntListenerArray<1> periodListeners; diff --git a/firmware/hw_layer/digital_input/digital_input_exti.cpp b/firmware/hw_layer/digital_input/digital_input_exti.cpp index fc00aab3b7..93c0ed1049 100644 --- a/firmware/hw_layer/digital_input/digital_input_exti.cpp +++ b/firmware/hw_layer/digital_input/digital_input_exti.cpp @@ -36,7 +36,7 @@ static ExtiChannel channels[16]; // 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, ExtiCallback cb, void *cb_data) { - /* paranoid check, in case of GPIO_UNASSIGNED getHwPort will return NULL + /* paranoid check, in case of Gpio::Unassigned getHwPort will return NULL * and we will fail on next check */ if (!isBrainPinValid(brainPin)) { return; @@ -79,7 +79,7 @@ void efiExtiEnablePin(const char *msg, brain_pin_e brainPin, uint32_t mode, Exti void efiExtiDisablePin(brain_pin_e brainPin) { - /* paranoid check, in case of GPIO_UNASSIGNED getHwPort will return NULL + /* paranoid check, in case of Gpio::Unassigned getHwPort will return NULL * and we will fail on next check */ if (!isBrainPinValid(brainPin)) return; diff --git a/firmware/hw_layer/digital_input/digital_input_icu.cpp b/firmware/hw_layer/digital_input/digital_input_icu.cpp index 59fdbce43f..61c3a2c4f1 100644 --- a/firmware/hw_layer/digital_input/digital_input_icu.cpp +++ b/firmware/hw_layer/digital_input/digital_input_icu.cpp @@ -126,21 +126,21 @@ static uint32_t getAlternateFunctions(ICUDriver *driver) { icuchannel_t getInputCaptureChannel(brain_pin_e hwPin) { switch (hwPin) { - case GPIOA_5: // TIM2 stm32f4discovery/Frankenso default - case GPIOA_6: // TIM3 - case GPIOA_8: // TIM1 - case GPIOA_15: // TIM2 - case GPIOC_6: // TIM3 stm32f4discovery/Frankenso default - case GPIOE_9: // TIM1 + case Gpio::A5: // TIM2 stm32f4discovery/Frankenso default + case Gpio::A6: // TIM3 + case Gpio::A8: // TIM1 + case Gpio::A15: // TIM2 + case Gpio::C6: // TIM3 stm32f4discovery/Frankenso default + case Gpio::E9: // TIM1 return ICU_CHANNEL_1; - case GPIOA_1: // TIM2 - case GPIOA_7: // TIM3 - case GPIOA_9: // TIM1 - case GPIOB_3: // TIM2 - case GPIOB_5: // TIM2 - case GPIOC_7: // TIM3 - case GPIOE_11: // TIM1 + case Gpio::A1: // TIM2 + case Gpio::A7: // TIM3 + case Gpio::A9: // TIM1 + case Gpio::B3: // TIM2 + case Gpio::B5: // TIM2 + case Gpio::C7: // TIM3 + case Gpio::E11: // TIM1 return ICU_CHANNEL_2; default: firmwareError(CUSTOM_ERR_ICU_PIN, "Unexpected hw pin in getInputCaptureChannel %s", hwPortname(hwPin)); @@ -163,42 +163,42 @@ ICUDriver * getInputCaptureDriver(const char *msg, brain_pin_e hwPin) { return NULL; } #if STM32_ICU_USE_TIM1 - if (hwPin == GPIOA_8 || - hwPin == GPIOA_9 || - hwPin == GPIOE_9 || - hwPin == GPIOE_11) { + if (hwPin == Gpio::A8 || + hwPin == Gpio::A9 || + hwPin == Gpio::E9 || + hwPin == Gpio::E11) { return &ICUD1; } #endif #if STM32_ICU_USE_TIM2 - if (hwPin == GPIOA_1 || - hwPin == GPIOA_5 || - hwPin == GPIOA_15 || - hwPin == GPIOB_3) { + if (hwPin == Gpio::A1 || + hwPin == Gpio::A5 || + hwPin == Gpio::A15 || + hwPin == Gpio::B3) { return &ICUD2; } #endif #if STM32_ICU_USE_TIM3 - if (hwPin == GPIOA_6 || - hwPin == GPIOA_7 || - hwPin == GPIOB_4 || - hwPin == GPIOB_5 || - hwPin == GPIOC_6 || - hwPin == GPIOC_7) { + if (hwPin == Gpio::A6 || + hwPin == Gpio::A7 || + hwPin == Gpio::B4 || + hwPin == Gpio::B5 || + hwPin == Gpio::C6 || + hwPin == Gpio::C7) { return &ICUD3; } #endif #if STM32_ICU_USE_TIM8 - if (hwPin == GPIOC_6 || - hwPin == GPIOC_7) { + if (hwPin == Gpio::C6 || + hwPin == Gpio::C7) { return &ICUD8; } #endif #if STM32_ICU_USE_TIM9 - if (hwPin == GPIOA_2 || - hwPin == GPIOA_3 || - hwPin == GPIOE_5 || - hwPin == GPIOE_6) { + if (hwPin == Gpio::A2 || + hwPin == Gpio::A3 || + hwPin == Gpio::E5 || + hwPin == Gpio::E6) { return &ICUD9; } #endif diff --git a/firmware/hw_layer/drivers/can/can_hw.cpp b/firmware/hw_layer/drivers/can/can_hw.cpp index 682d6c9749..68474a6f99 100644 --- a/firmware/hw_layer/drivers/can/can_hw.cpp +++ b/firmware/hw_layer/drivers/can/can_hw.cpp @@ -200,8 +200,8 @@ void postCanState() { #endif /* EFI_TUNER_STUDIO */ void enableFrankensoCan() { - engineConfiguration->canTxPin = GPIOB_6; - engineConfiguration->canRxPin = GPIOB_12; + engineConfiguration->canTxPin = Gpio::B6; + engineConfiguration->canRxPin = Gpio::B12; engineConfiguration->canReadEnabled = false; } @@ -221,7 +221,7 @@ void startCanPins() { // Validate pins if (!isValidCanTxPin(engineConfiguration->canTxPin)) { - if (engineConfiguration->canTxPin == GPIO_UNASSIGNED) { + if (engineConfiguration->canTxPin == Gpio::Unassigned) { // todo: smarter online change of settings, kill isCanEnabled with fire return; } @@ -230,7 +230,7 @@ void startCanPins() { } if (!isValidCanRxPin(engineConfiguration->canRxPin)) { - if (engineConfiguration->canRxPin == GPIO_UNASSIGNED) { + if (engineConfiguration->canRxPin == Gpio::Unassigned) { // todo: smarter online change of settings, kill isCanEnabled with fire return; } diff --git a/firmware/hw_layer/drivers/gpio/core.cpp b/firmware/hw_layer/drivers/gpio/core.cpp index 8fd72c406f..3898626330 100644 --- a/firmware/hw_layer/drivers/gpio/core.cpp +++ b/firmware/hw_layer/drivers/gpio/core.cpp @@ -128,12 +128,12 @@ int gpiochip_register(brain_pin_e base, const char *name, GpioChip& gpioChip, si return -1; /* outside? */ - if (((size_t)base + size - 1 > BRAIN_PIN_LAST) || (base <= BRAIN_PIN_ONCHIP_LAST)) + if ((base + size - 1 > BRAIN_PIN_LAST) || (base <= BRAIN_PIN_ONCHIP_LAST)) return -1; /* check for overlap with other chips */ for (int i = 0; i < BOARD_EXT_GPIOCHIPS; i++) { - if (chips[i].base != 0) { + if (chips[i].base != Gpio::Unassigned) { #define in_range(a, b, c) (((a) > (b)) && ((a) < (c))) if (in_range(base, chips[i].base, chips[i].base + chips[i].size)) return -1; @@ -146,7 +146,7 @@ int gpiochip_register(brain_pin_e base, const char *name, GpioChip& gpioChip, si /* find free gpiochip struct */ for (int i = 0; i < BOARD_EXT_GPIOCHIPS; i++) { - if (chips[i].base == 0) { + if (chips[i].base == Gpio::Unassigned) { chip = &chips[i]; break; } @@ -164,7 +164,8 @@ int gpiochip_register(brain_pin_e base, const char *name, GpioChip& gpioChip, si chip->size = size; chip->gpio_names = nullptr; - return base; + // TODO: this cast seems wrong? + return (int)base; } @@ -188,7 +189,7 @@ int gpiochip_unregister(brain_pin_e base) /* unregister chip */ chip->name = nullptr; chip->chip = nullptr; - chip->base = GPIO_UNASSIGNED; + chip->base = Gpio::Unassigned; chip->size = 0; chip->gpio_names = nullptr; @@ -226,13 +227,13 @@ int gpiochips_init(void) for (int i = 0; i < BOARD_EXT_GPIOCHIPS; i++) { gpiochip *chip = &chips[i]; - if (!chip->base) + if (chip->base == Gpio::Unassigned) continue; if (chip->chip->init() < 0) { /* remove chip if it fails to init */ /* TODO: we will have a gap, is it ok? */ - chip->base = GPIO_UNASSIGNED; + chip->base = Gpio::Unassigned; } else { pins_added += chip->size; } @@ -328,7 +329,7 @@ int gpiochips_get_total_pins(void) for (i = 0; i < BOARD_EXT_GPIOCHIPS; i++) { gpiochip *chip = &chips[i]; - if (!chip->base) + if (chip->base == Gpio::Unassigned) continue; cnt += chip->size; diff --git a/firmware/hw_layer/drivers/serial/serial_hw.cpp b/firmware/hw_layer/drivers/serial/serial_hw.cpp index b0ce1f3523..b11723d386 100644 --- a/firmware/hw_layer/drivers/serial/serial_hw.cpp +++ b/firmware/hw_layer/drivers/serial/serial_hw.cpp @@ -49,9 +49,9 @@ void stopAuxSerialPins() { } void startAuxSerialPins() { - if (engineConfiguration->auxSerialTxPin) + if (isBrainPinValid(engineConfiguration->auxSerialTxPin)) efiSetPadMode("AuxSerial TX", engineConfiguration->auxSerialTxPin, PAL_MODE_ALTERNATE(8)); - if (engineConfiguration->auxSerialRxPin) + if (isBrainPinValid(engineConfiguration->auxSerialRxPin)) efiSetPadMode("AuxSerial RX", engineConfiguration->auxSerialRxPin, PAL_MODE_ALTERNATE(8)); enableAuxSerial(); @@ -60,12 +60,12 @@ void startAuxSerialPins() { void initAuxSerial(void) { addConsoleAction("auxinfo", auxInfo); - isSerialEnabled = - (engineConfiguration->auxSerialTxPin) || // we need at least one pin set - (engineConfiguration->auxSerialRxPin); + isSerialRXEnabled = isBrainPinValid(engineConfiguration->auxSerialRxPin); + isSerialTXEnabled = isBrainPinValid(engineConfiguration->auxSerialTxPin); - isSerialRXEnabled = engineConfiguration->auxSerialRxPin; - isSerialTXEnabled = engineConfiguration->auxSerialTxPin; + isSerialEnabled = + isSerialRXEnabled || // we need at least one pin set + isSerialTXEnabled; // exit if no pin is configured if (!isSerialEnabled) diff --git a/firmware/hw_layer/pin_repository.cpp b/firmware/hw_layer/pin_repository.cpp index e5ca8b3864..517c52c758 100644 --- a/firmware/hw_layer/pin_repository.cpp +++ b/firmware/hw_layer/pin_repository.cpp @@ -22,9 +22,8 @@ const char* & getBrainUsedPin(unsigned int idx) { } /* Common for firmware and unit tests */ -bool isBrainPinValid(brain_pin_e brainPin) -{ - if ((brainPin == GPIO_UNASSIGNED) || (brainPin == GPIO_INVALID)) +bool isBrainPinValid(brain_pin_e brainPin) { + if ((brainPin == Gpio::Unassigned) || (brainPin == Gpio::Invalid)) return false; if (brainPin > BRAIN_PIN_LAST) @@ -37,10 +36,10 @@ bool isBrainPinValid(brain_pin_e brainPin) int brainPin_to_index(brain_pin_e brainPin) { unsigned int i; - if (brainPin < GPIOA_0) + if (brainPin < Gpio::A0) return -1; - i = brainPin - GPIOA_0; + i = brainPin - Gpio::A0; if (i >= getBrainPinTotalNum()) return -1; @@ -132,9 +131,9 @@ void pinDiag2string(char *buffer, size_t size, brain_pin_diag_e pin_diag) { static brain_pin_e index_to_brainPin(unsigned int i) { if (i < getBrainPinTotalNum()) - return (brain_pin_e)((int)GPIOA_0 + i);; + return Gpio::A0 + i; - return GPIO_INVALID; + return Gpio::Invalid; } static void reportPins() { @@ -194,10 +193,10 @@ __attribute__((weak)) const char * getBoardSpecificPinName(brain_pin_e /*brainPi } const char *hwPortname(brain_pin_e brainPin) { - if (brainPin == GPIO_INVALID) { + if (brainPin == Gpio::Invalid) { return "INVALID"; } - if (brainPin == GPIO_UNASSIGNED) { + if (brainPin == Gpio::Unassigned) { return "NONE"; } const char * boardSpecificPinName = getBoardSpecificPinName(brainPin); @@ -249,7 +248,7 @@ void initPinRepository(void) { bool brain_pin_is_onchip(brain_pin_e brainPin) { - if ((brainPin < GPIOA_0) || (brainPin > BRAIN_PIN_ONCHIP_LAST)) + if ((brainPin < Gpio::A0) || (brainPin > BRAIN_PIN_ONCHIP_LAST)) return false; return true; diff --git a/firmware/hw_layer/ports/cypress/cypress_common.cpp b/firmware/hw_layer/ports/cypress/cypress_common.cpp index 110784ef01..d1b81443b5 100644 --- a/firmware/hw_layer/ports/cypress/cypress_common.cpp +++ b/firmware/hw_layer/ports/cypress/cypress_common.cpp @@ -31,116 +31,116 @@ brain_pin_e getAdcChannelBrainPin(const char *msg, adc_channel_e hwChannel) { // todo: replace this with an array :) switch (hwChannel) { case EFI_ADC_0: - return GPIOB_0; + return Gpio::B0; case EFI_ADC_1: - return GPIOB_1; + return Gpio::B1; case EFI_ADC_2: - return GPIOB_2; + return Gpio::B2; case EFI_ADC_3: - return GPIOB_3; + return Gpio::B3; case EFI_ADC_4: - return GPIOB_4; + return Gpio::B4; case EFI_ADC_5: - return GPIOB_5; + return Gpio::B5; case EFI_ADC_6: - return GPIO_INVALID; + return Gpio::Invalid; case EFI_ADC_7: - return GPIO_INVALID; + return Gpio::Invalid; case EFI_ADC_8: - return GPIOB_8; + return Gpio::B8; case EFI_ADC_9: - return GPIOB_9; + return Gpio::B9; case EFI_ADC_10: - return GPIO_INVALID; + return Gpio::Invalid; case EFI_ADC_11: - return GPIO_INVALID; + return Gpio::Invalid; case EFI_ADC_12: - return GPIOB_12; + return Gpio::B12; case EFI_ADC_13: - return GPIOB_13; + return Gpio::B13; case EFI_ADC_14: - return GPIOB_14; + return Gpio::B14; case EFI_ADC_15: - return GPIOB_15; + return Gpio::B15; case EFI_ADC_16: - return GPIO_INVALID; + return Gpio::Invalid; case EFI_ADC_17: - return GPIO_INVALID; + return Gpio::Invalid; case EFI_ADC_18: - return GPIO_INVALID; + return Gpio::Invalid; case EFI_ADC_19: - return GPIO_INVALID; + return Gpio::Invalid; case EFI_ADC_20: - return GPIO_INVALID; + return Gpio::Invalid; case EFI_ADC_21: - return GPIO_INVALID; + return Gpio::Invalid; case EFI_ADC_22: - return GPIO_INVALID; + return Gpio::Invalid; case EFI_ADC_23: - return GPIO_INVALID; + return Gpio::Invalid; case EFI_ADC_24: - return GPIOC_10; + return Gpio::C10; case EFI_ADC_25: - return GPIOC_9; + return Gpio::C9; case EFI_ADC_26: - return GPIOC_8; + return Gpio::C8; case EFI_ADC_27: - return GPIOC_7; + return Gpio::C7; case EFI_ADC_28: - return GPIOC_5; + return Gpio::C5; case EFI_ADC_29: - return GPIOC_4; + return Gpio::C4; case EFI_ADC_30: - return GPIOC_3; + return Gpio::C3; case EFI_ADC_31: - return GPIOC_2; + return Gpio::C2; default: firmwareError(CUSTOM_ERR_ADC_UNKNOWN_CHANNEL, "Unknown hw channel %d [%s]", hwChannel, msg); - return GPIO_INVALID; + return Gpio::Invalid; } } adc_channel_e getAdcChannel(brain_pin_e pin) { switch (pin) { - case GPIOB_0: + case Gpio::B0: return EFI_ADC_0; - case GPIOB_1: + case Gpio::B1: return EFI_ADC_1; - case GPIOB_2: + case Gpio::B2: return EFI_ADC_2; - case GPIOB_3: + case Gpio::B3: return EFI_ADC_3; - case GPIOB_4: + case Gpio::B4: return EFI_ADC_4; - case GPIOB_5: + case Gpio::B5: return EFI_ADC_5; - case GPIOB_8: + case Gpio::B8: return EFI_ADC_8; - case GPIOB_9: + case Gpio::B9: return EFI_ADC_9; - case GPIOB_12: + case Gpio::B12: return EFI_ADC_12; - case GPIOB_13: + case Gpio::B13: return EFI_ADC_13; - case GPIOB_14: + case Gpio::B14: return EFI_ADC_14; - case GPIOB_15: + case Gpio::B15: return EFI_ADC_15; - case GPIOC_10: + case Gpio::C10: return EFI_ADC_24; - case GPIOC_9: + case Gpio::C9: return EFI_ADC_25; - case GPIOC_8: + case Gpio::C8: return EFI_ADC_26; - case GPIOC_7: + case Gpio::C7: return EFI_ADC_27; - case GPIOC_5: + case Gpio::C5: return EFI_ADC_28; - case GPIOC_4: + case Gpio::C4: return EFI_ADC_29; - case GPIOC_3: + case Gpio::C3: return EFI_ADC_30; - case GPIOC_2: + case Gpio::C2: return EFI_ADC_31; default: return EFI_ADC_ERROR; diff --git a/firmware/hw_layer/ports/cypress/cypress_pins.cpp b/firmware/hw_layer/ports/cypress/cypress_pins.cpp index c325b76ea2..2d11cb41b6 100644 --- a/firmware/hw_layer/ports/cypress/cypress_pins.cpp +++ b/firmware/hw_layer/ports/cypress/cypress_pins.cpp @@ -28,7 +28,7 @@ static ioportid_t ports[] = { }; static brain_pin_e portMap[16] = { - GPIOA_0, GPIOB_0, GPIOC_0, GPIOD_0, GPIOE_0, GPIOF_0, GPIO_INVALID, GPIOG_0, GPIO_INVALID, GPIO_INVALID, GPIOH_0, GPIOI_0, GPIOJ_0, GPIO_INVALID, GPIO_INVALID, GPIOK_0 + Gpio::A0, Gpio::B0, Gpio::C0, Gpio::D0, Gpio::E0, Gpio::F0, Gpio::Invalid, Gpio::G0, Gpio::Invalid, Gpio::Invalid, Gpio::H0, Gpio::I0, Gpio::J0, Gpio::Invalid, Gpio::Invalid, Gpio::K0 }; #include "pin_repository.h" @@ -92,11 +92,11 @@ static int getPortIndex(ioportid_t port) { } ioportid_t getBrainPinPort(brain_pin_e brainPin) { - return ports[(brainPin - GPIOA_0) / PORT_SIZE]; + return ports[(brainPin - Gpio::A0) / PORT_SIZE]; } int getBrainPinIndex(brain_pin_e brainPin) { - return (brainPin - GPIOA_0) % PORT_SIZE; + return (brainPin - Gpio::A0) % PORT_SIZE; } int getBrainPinIndex(ioportid_t port, ioportmask_t pin) { @@ -106,10 +106,10 @@ int getBrainPinIndex(ioportid_t port, ioportmask_t pin) { ioportid_t getHwPort(const char *msg, brain_pin_e brainPin) { if (!isBrainPinValid(brainPin)) { - firmwareError(CUSTOM_ERR_INVALID_PIN, "%s: Invalid brain_pin_e: %d", msg, brainPin); + firmwareError(CUSTOM_ERR_INVALID_PIN, "%s: Invalid Gpio: %d", msg, brainPin); return GPIO_NULL; } - return ports[(brainPin - GPIOA_0) / PORT_SIZE]; + return ports[(brainPin - Gpio::A0) / PORT_SIZE]; } /** @@ -130,14 +130,14 @@ ioportmask_t getHwPin(const char *msg, brain_pin_e brainPin) /** * Parse string representation of physical pin into brain_pin_e ordinal. * - * @return GPIO_UNASSIGNED for "none", GPIO_INVALID for invalid entry + * @return Gpio::Unassigned for "none", Gpio::Invalid for invalid entry */ brain_pin_e parseBrainPin(const char *str) { if (strEqual(str, "none")) - return GPIO_UNASSIGNED; + return Gpio::Unassigned; // todo: create method toLowerCase? if (str[0] != 'p' && str[0] != 'P') { - return GPIO_INVALID; + return Gpio::Invalid; } char port = str[1]; if (port >= 'a' && port <= 'z') { @@ -147,14 +147,14 @@ brain_pin_e parseBrainPin(const char *str) { } else if (port >= '0' && port <= '9') { port = 0 + (port - '0'); } else { - return GPIO_INVALID; + return Gpio::Invalid; } brain_pin_e basePin = portMap[(int)port]; - if (basePin == GPIO_INVALID) - return GPIO_INVALID; + if (basePin == Gpio::Invalid) + return Gpio::Invalid; const char *pinStr = str + 2; int pin = atoi(pinStr); - return (brain_pin_e)(basePin + pin); + return basePin + pin; } unsigned int getBrainPinOnchipNum(void) { diff --git a/firmware/hw_layer/ports/cypress/mpu_util.cpp b/firmware/hw_layer/ports/cypress/mpu_util.cpp index bcf493a48d..deabdc280a 100644 --- a/firmware/hw_layer/ports/cypress/mpu_util.cpp +++ b/firmware/hw_layer/ports/cypress/mpu_util.cpp @@ -88,7 +88,7 @@ brain_pin_e getMisoPin(spi_device_e device) { default: break; } - return GPIO_UNASSIGNED; + return Gpio::Unassigned; } brain_pin_e getMosiPin(spi_device_e device) { @@ -102,7 +102,7 @@ brain_pin_e getMosiPin(spi_device_e device) { default: break; } - return GPIO_UNASSIGNED; + return Gpio::Unassigned; } brain_pin_e getSckPin(spi_device_e device) { @@ -116,7 +116,7 @@ brain_pin_e getSckPin(spi_device_e device) { default: break; } - return GPIO_UNASSIGNED; + return Gpio::Unassigned; } void turnOnSpi(spi_device_e device) { @@ -200,19 +200,19 @@ BOR_Result_t BOR_Set(BOR_Level_t BORValue) { #if EFI_CAN_SUPPORT || defined(__DOXYGEN__) static bool isValidCan1RxPin(brain_pin_e pin) { - return pin == GPIOA_11 || pin == GPIOB_8 || pin == GPIOD_0; + return pin == Gpio::A11 || pin == Gpio::B8 || pin == Gpio::D0; } static bool isValidCan1TxPin(brain_pin_e pin) { - return pin == GPIOA_12 || pin == GPIOB_9 || pin == GPIOD_1; + return pin == Gpio::A12 || pin == Gpio::B9 || pin == Gpio::D1; } static bool isValidCan2RxPin(brain_pin_e pin) { - return pin == GPIOB_5 || pin == GPIOB_12; + return pin == Gpio::B5 || pin == Gpio::B12; } static bool isValidCan2TxPin(brain_pin_e pin) { - return pin == GPIOB_6 || pin == GPIOB_13; + return pin == Gpio::B6 || pin == Gpio::B13; } bool isValidCanTxPin(brain_pin_e pin) { diff --git a/firmware/hw_layer/ports/kinetis/kinetis_common.cpp b/firmware/hw_layer/ports/kinetis/kinetis_common.cpp index 9e15a077c1..3082959dd1 100644 --- a/firmware/hw_layer/ports/kinetis/kinetis_common.cpp +++ b/firmware/hw_layer/ports/kinetis/kinetis_common.cpp @@ -33,76 +33,76 @@ brain_pin_e getAdcChannelBrainPin(const char *msg, adc_channel_e hwChannel) { // todo: replace this with an array :) switch (hwChannel) { case EFI_ADC_0: - return GPIOA_2; + return Gpio::A2; case EFI_ADC_1: - return GPIOA_3; + return Gpio::A3; case EFI_ADC_2: - return GPIO_INVALID; + return Gpio::Invalid; case EFI_ADC_3: - return GPIOD_3; + return Gpio::D3; case EFI_ADC_4: - return GPIO_INVALID; + return Gpio::Invalid; case EFI_ADC_5: - return GPIO_INVALID; + return Gpio::Invalid; case EFI_ADC_6: - return GPIO_INVALID; + return Gpio::Invalid; case EFI_ADC_7: - return GPIOB_12; + return Gpio::B12; case EFI_ADC_8: - return GPIOB_13; + return Gpio::B13; case EFI_ADC_9: - return GPIO_INVALID; + return Gpio::Invalid; case EFI_ADC_10: - return GPIOE_2; + return Gpio::E2; case EFI_ADC_11: - return GPIO_INVALID; + return Gpio::Invalid; case EFI_ADC_12: - return GPIOC_14; + return Gpio::C14; case EFI_ADC_13: - return GPIOC_15; + return Gpio::C15; case EFI_ADC_14: - return GPIOC_16; + return Gpio::C16; case EFI_ADC_15: - return GPIOC_17; + return Gpio::C17; default: firmwareError(CUSTOM_ERR_ADC_UNKNOWN_CHANNEL, "Unknown hw channel %d [%s]", hwChannel, msg); - return GPIO_INVALID; + return Gpio::Invalid; } } adc_channel_e getAdcChannel(brain_pin_e pin) { switch (pin) { - case GPIOA_2: + case Gpio::A2: return EFI_ADC_0; - case GPIOA_3: + case Gpio::A3: return EFI_ADC_1; - //case GPIOA_2: + //case Gpio::A2: // return EFI_ADC_2; - case GPIOD_3: + case Gpio::D3: return EFI_ADC_3; - //case GPIOA_4: + //case Gpio::A4: // return EFI_ADC_4; - //case GPIOA_5: + //case Gpio::A5: // return EFI_ADC_5; - //case GPIOA_6: + //case Gpio::A6: // return EFI_ADC_6; - case GPIOB_12: + case Gpio::B12: return EFI_ADC_7; - case GPIOB_13: + case Gpio::B13: return EFI_ADC_8; - //case GPIOB_1: + //case Gpio::B1: // return EFI_ADC_9; - case GPIOE_2: + case Gpio::E2: return EFI_ADC_10; - //case GPIOC_1: + //case Gpio::C1: // return EFI_ADC_11; - case GPIOC_14: + case Gpio::C14: return EFI_ADC_12; - case GPIOC_15: + case Gpio::C15: return EFI_ADC_13; - case GPIOC_16: + case Gpio::C16: return EFI_ADC_14; - case GPIOC_17: + case Gpio::C17: return EFI_ADC_15; default: return EFI_ADC_ERROR; diff --git a/firmware/hw_layer/ports/kinetis/kinetis_pins.cpp b/firmware/hw_layer/ports/kinetis/kinetis_pins.cpp index 6b941db2ba..3044ca2c83 100644 --- a/firmware/hw_layer/ports/kinetis/kinetis_pins.cpp +++ b/firmware/hw_layer/ports/kinetis/kinetis_pins.cpp @@ -55,11 +55,11 @@ static int getPortIndex(ioportid_t port) { } ioportid_t getBrainPinPort(brain_pin_e brainPin) { - return ports[(brainPin - GPIOA_0) / PORT_SIZE]; + return ports[(brainPin - Gpio::A0) / PORT_SIZE]; } int getBrainPinIndex(brain_pin_e brainPin) { - return (brainPin - GPIOA_0) % PORT_SIZE; + return (brainPin - Gpio::A0) % PORT_SIZE; } int getPortPinIndex(ioportid_t port, ioportmask_t pin) { @@ -69,10 +69,10 @@ int getPortPinIndex(ioportid_t port, ioportmask_t pin) { ioportid_t getHwPort(const char *msg, brain_pin_e brainPin) { if (!isBrainPinValid(brainPin)) { - firmwareError(CUSTOM_ERR_INVALID_PIN, "%s: Invalid brain_pin_e: %d", msg, brainPin); + firmwareError(CUSTOM_ERR_INVALID_PIN, "%s: Invalid Gpio: %d", msg, brainPin); return GPIO_NULL; } - return ports[(brainPin - GPIOA_0) / PORT_SIZE]; + return ports[(brainPin - Gpio::A0) / PORT_SIZE]; } /** @@ -86,34 +86,34 @@ ioportmask_t getHwPin(const char *msg, brain_pin_e brainPin) if (brain_pin_is_onchip(brainPin)) return getBrainPinIndex(brainPin); - firmwareError(CUSTOM_ERR_INVALID_PIN, "%s: Invalid on-chip brain_pin_e: %d", msg, brainPin); + firmwareError(CUSTOM_ERR_INVALID_PIN, "%s: Invalid on-chip Gpio: %d", msg, brainPin); return EFI_ERROR_CODE; } /** - * Parse string representation of physical pin into brain_pin_e ordinal. + * Parse string representation of physical pin into Gpio ordinal. * - * @return GPIO_UNASSIGNED for "none", GPIO_INVALID for invalid entry + * @return Gpio::Unassigned for "none", Gpio::Invalid for invalid entry */ brain_pin_e parseBrainPin(const char *str) { if (strEqual(str, "none")) - return GPIO_UNASSIGNED; + return Gpio::Unassigned; // todo: create method toLowerCase? if (str[0] != 'p' && str[0] != 'P') { - return GPIO_INVALID; + return Gpio::Invalid; } char port = str[1]; brain_pin_e basePin; if (port >= 'a' && port <= 'z') { - basePin = (brain_pin_e) ((int) GPIOA_0 + PORT_SIZE * (port - 'a')); + basePin = (Gpio::A0 + PORT_SIZE * (port - 'a')); } else if (port >= 'A' && port <= 'Z') { - basePin = (brain_pin_e) ((int) GPIOA_0 + PORT_SIZE * (port - 'A')); + basePin = (Gpio::A0 + PORT_SIZE * (port - 'A')); } else { - return GPIO_INVALID; + return Gpio::Invalid; } const char *pinStr = str + 2; int pin = atoi(pinStr); - return (brain_pin_e)(basePin + pin); + return basePin + pin; } unsigned int getBrainPinOnchipNum(void) { diff --git a/firmware/hw_layer/ports/kinetis/mpu_util.cpp b/firmware/hw_layer/ports/kinetis/mpu_util.cpp index ef44013e71..939f843654 100644 --- a/firmware/hw_layer/ports/kinetis/mpu_util.cpp +++ b/firmware/hw_layer/ports/kinetis/mpu_util.cpp @@ -80,7 +80,7 @@ brain_pin_e getMisoPin(spi_device_e device) { default: break; } - return GPIO_UNASSIGNED; + return Gpio::Unassigned; } brain_pin_e getMosiPin(spi_device_e device) { @@ -94,7 +94,7 @@ brain_pin_e getMosiPin(spi_device_e device) { default: break; } - return GPIO_UNASSIGNED; + return Gpio::Unassigned; } brain_pin_e getSckPin(spi_device_e device) { @@ -108,7 +108,7 @@ brain_pin_e getSckPin(spi_device_e device) { default: break; } - return GPIO_UNASSIGNED; + return Gpio::Unassigned; } void turnOnSpi(spi_device_e device) { @@ -192,19 +192,19 @@ BOR_Result_t BOR_Set(BOR_Level_t BORValue) { #if EFI_CAN_SUPPORT || defined(__DOXYGEN__) static bool isValidCan1RxPin(brain_pin_e pin) { - return pin == GPIOA_11 || pin == GPIOB_8 || pin == GPIOD_0; + return pin == Gpio::A11 || pin == Gpio::B8 || pin == Gpio::D0; } static bool isValidCan1TxPin(brain_pin_e pin) { - return pin == GPIOA_12 || pin == GPIOB_9 || pin == GPIOD_1; + return pin == Gpio::A12 || pin == Gpio::B9 || pin == Gpio::D1; } static bool isValidCan2RxPin(brain_pin_e pin) { - return pin == GPIOB_5 || pin == GPIOB_12; + return pin == Gpio::B5 || pin == Gpio::B12; } static bool isValidCan2TxPin(brain_pin_e pin) { - return pin == GPIOB_6 || pin == GPIOB_13; + return pin == Gpio::B6 || pin == Gpio::B13; } bool isValidCanTxPin(brain_pin_e pin) { diff --git a/firmware/hw_layer/ports/stm32/stm32_common.cpp b/firmware/hw_layer/ports/stm32/stm32_common.cpp index f109bf30f1..ef33b7968f 100644 --- a/firmware/hw_layer/ports/stm32/stm32_common.cpp +++ b/firmware/hw_layer/ports/stm32/stm32_common.cpp @@ -51,78 +51,78 @@ brain_pin_e getAdcChannelBrainPin(const char *msg, adc_channel_e hwChannel) { // todo: replace this with an array :) switch (hwChannel) { case EFI_ADC_0: - return GPIOA_0; + return Gpio::A0; case EFI_ADC_1: - return GPIOA_1; + return Gpio::A1; case EFI_ADC_2: - return GPIOA_2; + return Gpio::A2; case EFI_ADC_3: - return GPIOA_3; + return Gpio::A3; case EFI_ADC_4: - return GPIOA_4; + return Gpio::A4; case EFI_ADC_5: - return GPIOA_5; + return Gpio::A5; case EFI_ADC_6: - return GPIOA_6; + return Gpio::A6; case EFI_ADC_7: - return GPIOA_7; + return Gpio::A7; case EFI_ADC_8: - return GPIOB_0; + return Gpio::B0; case EFI_ADC_9: - return GPIOB_1; + return Gpio::B1; case EFI_ADC_10: - return GPIOC_0; + return Gpio::C0; case EFI_ADC_11: - return GPIOC_1; + return Gpio::C1; case EFI_ADC_12: - return GPIOC_2; + return Gpio::C2; case EFI_ADC_13: - return GPIOC_3; + return Gpio::C3; case EFI_ADC_14: - return GPIOC_4; + return Gpio::C4; case EFI_ADC_15: - return GPIOC_5; + return Gpio::C5; default: firmwareError(CUSTOM_ERR_ADC_UNKNOWN_CHANNEL, "Unknown hw channel %d [%s]", hwChannel, msg); - return GPIO_INVALID; + return Gpio::Invalid; } } adc_channel_e getAdcChannel(brain_pin_e pin) { switch (pin) { - case GPIOA_0: + case Gpio::A0: return EFI_ADC_0; - case GPIOA_1: + case Gpio::A1: return EFI_ADC_1; - case GPIOA_2: + case Gpio::A2: return EFI_ADC_2; - case GPIOA_3: + case Gpio::A3: return EFI_ADC_3; - case GPIOA_4: + case Gpio::A4: return EFI_ADC_4; - case GPIOA_5: + case Gpio::A5: return EFI_ADC_5; - case GPIOA_6: + case Gpio::A6: return EFI_ADC_6; - case GPIOA_7: + case Gpio::A7: return EFI_ADC_7; - case GPIOB_0: + case Gpio::B0: return EFI_ADC_8; - case GPIOB_1: + case Gpio::B1: return EFI_ADC_9; - case GPIOC_0: + case Gpio::C0: return EFI_ADC_10; - case GPIOC_1: + case Gpio::C1: return EFI_ADC_11; - case GPIOC_2: + case Gpio::C2: return EFI_ADC_12; - case GPIOC_3: + case Gpio::C3: return EFI_ADC_13; - case GPIOC_4: + case Gpio::C4: return EFI_ADC_14; - case GPIOC_5: + case Gpio::C5: return EFI_ADC_15; - case GPIO_UNASSIGNED: + case Gpio::Unassigned: return EFI_ADC_NONE; default: firmwareError(OBD_PCM_Processor_Fault, "getAdcChannel %d", pin); @@ -226,48 +226,48 @@ private: static expected getConfigForPin(brain_pin_e pin) { switch (pin) { #if STM32_PWM_USE_TIM1 - case GPIOA_8: return stm32_pwm_config{&PWMD1, 0, 1}; - case GPIOA_9: return stm32_pwm_config{&PWMD1, 1, 1}; - case GPIOA_10: return stm32_pwm_config{&PWMD1, 2, 1}; - case GPIOA_11: return stm32_pwm_config{&PWMD1, 3, 1}; + case Gpio::A8: return stm32_pwm_config{&PWMD1, 0, 1}; + case Gpio::A9: return stm32_pwm_config{&PWMD1, 1, 1}; + case Gpio::A10: return stm32_pwm_config{&PWMD1, 2, 1}; + case Gpio::A11: return stm32_pwm_config{&PWMD1, 3, 1}; - case GPIOE_9: return stm32_pwm_config{&PWMD1, 0, 1}; - case GPIOE_11: return stm32_pwm_config{&PWMD1, 1, 1}; - case GPIOE_13: return stm32_pwm_config{&PWMD1, 2, 1}; - case GPIOE_14: return stm32_pwm_config{&PWMD1, 3, 1}; + case Gpio::E9: return stm32_pwm_config{&PWMD1, 0, 1}; + case Gpio::E11: return stm32_pwm_config{&PWMD1, 1, 1}; + case Gpio::E13: return stm32_pwm_config{&PWMD1, 2, 1}; + case Gpio::E14: return stm32_pwm_config{&PWMD1, 3, 1}; #endif #if STM32_PWM_USE_TIM2 - case GPIOA_15: return stm32_pwm_config{&PWMD2, 0, 1}; - case GPIOB_3: return stm32_pwm_config{&PWMD2, 1, 1}; - case GPIOB_10: return stm32_pwm_config{&PWMD2, 2, 1}; - case GPIOB_11: return stm32_pwm_config{&PWMD2, 3, 1}; + case Gpio::A15: return stm32_pwm_config{&PWMD2, 0, 1}; + case Gpio::B3: return stm32_pwm_config{&PWMD2, 1, 1}; + case Gpio::B10: return stm32_pwm_config{&PWMD2, 2, 1}; + case Gpio::B11: return stm32_pwm_config{&PWMD2, 3, 1}; #endif #if STM32_PWM_USE_TIM3 - case GPIOB_4: return stm32_pwm_config{&PWMD3, 0, 2}; - case GPIOB_5: return stm32_pwm_config{&PWMD3, 1, 2}; + case Gpio::B4: return stm32_pwm_config{&PWMD3, 0, 2}; + case Gpio::B5: return stm32_pwm_config{&PWMD3, 1, 2}; #endif #if STM32_PWM_USE_TIM4 - case GPIOB_6: return stm32_pwm_config{&PWMD4, 0, 2}; - case GPIOB_7: return stm32_pwm_config{&PWMD4, 1, 2}; - case GPIOB_8: return stm32_pwm_config{&PWMD4, 2, 2}; - case GPIOB_9: return stm32_pwm_config{&PWMD4, 3, 2}; + case Gpio::B6: return stm32_pwm_config{&PWMD4, 0, 2}; + case Gpio::B7: return stm32_pwm_config{&PWMD4, 1, 2}; + case Gpio::B8: return stm32_pwm_config{&PWMD4, 2, 2}; + case Gpio::B9: return stm32_pwm_config{&PWMD4, 3, 2}; - case GPIOD_12: return stm32_pwm_config{&PWMD4, 0, 2}; - case GPIOD_13: return stm32_pwm_config{&PWMD4, 1, 2}; - case GPIOD_14: return stm32_pwm_config{&PWMD4, 2, 2}; - case GPIOD_15: return stm32_pwm_config{&PWMD4, 3, 2}; + case Gpio::D12: return stm32_pwm_config{&PWMD4, 0, 2}; + case Gpio::D13: return stm32_pwm_config{&PWMD4, 1, 2}; + case Gpio::D14: return stm32_pwm_config{&PWMD4, 2, 2}; + case Gpio::D15: return stm32_pwm_config{&PWMD4, 3, 2}; #endif #if STM32_PWM_USE_TIM5 - case GPIOA_0: return stm32_pwm_config{&PWMD5, 0, 2}; - case GPIOA_1: return stm32_pwm_config{&PWMD5, 1, 2}; - case GPIOA_2: return stm32_pwm_config{&PWMD5, 2, 2}; - case GPIOA_3: return stm32_pwm_config{&PWMD5, 3, 2}; + case Gpio::A0: return stm32_pwm_config{&PWMD5, 0, 2}; + case Gpio::A1: return stm32_pwm_config{&PWMD5, 1, 2}; + case Gpio::A2: return stm32_pwm_config{&PWMD5, 2, 2}; + case Gpio::A3: return stm32_pwm_config{&PWMD5, 3, 2}; #endif #if STM32_PWM_USE_TIM8 - case GPIOC_6: return stm32_pwm_config{&PWMD8, 0, 3}; - case GPIOC_7: return stm32_pwm_config{&PWMD8, 1, 3}; - case GPIOC_8: return stm32_pwm_config{&PWMD8, 2, 3}; - case GPIOC_9: return stm32_pwm_config{&PWMD8, 3, 3}; + case Gpio::C6: return stm32_pwm_config{&PWMD8, 0, 3}; + case Gpio::C7: return stm32_pwm_config{&PWMD8, 1, 3}; + case Gpio::C8: return stm32_pwm_config{&PWMD8, 2, 3}; + case Gpio::C9: return stm32_pwm_config{&PWMD8, 3, 3}; #endif default: return unexpected; } @@ -330,11 +330,11 @@ void jump_to_bootloader() { #if EFI_AUX_SERIAL static bool isValidUART6TxPin(brain_pin_e pin) { - return pin == GPIOC_6 || pin == GPIOG_14; + return pin == Gpio::C6 || pin == Gpio::G14; } static bool isValidUART6RxPin(brain_pin_e pin) { - return pin == GPIOC_7 || pin == GPIOG_9; + return pin == Gpio::C7 || pin == Gpio::G9; } bool isValidSerialTxPin(brain_pin_e pin) { @@ -588,7 +588,7 @@ brain_pin_e getMisoPin(spi_device_e device) { default: break; } - return GPIO_UNASSIGNED; + return Gpio::Unassigned; } brain_pin_e getMosiPin(spi_device_e device) { @@ -602,7 +602,7 @@ brain_pin_e getMosiPin(spi_device_e device) { default: break; } - return GPIO_UNASSIGNED; + return Gpio::Unassigned; } brain_pin_e getSckPin(spi_device_e device) { @@ -616,7 +616,7 @@ brain_pin_e getSckPin(spi_device_e device) { default: break; } - return GPIO_UNASSIGNED; + return Gpio::Unassigned; } void turnOnSpi(spi_device_e device) { @@ -755,19 +755,19 @@ SPIConfig mmc_ls_spicfg = { #if EFI_CAN_SUPPORT static bool isValidCan1RxPin(brain_pin_e pin) { - return pin == GPIOA_11 || pin == GPIOB_8 || pin == GPIOD_0; + return pin == Gpio::A11 || pin == Gpio::B8 || pin == Gpio::D0; } static bool isValidCan1TxPin(brain_pin_e pin) { - return pin == GPIOA_12 || pin == GPIOB_9 || pin == GPIOD_1; + return pin == Gpio::A12 || pin == Gpio::B9 || pin == Gpio::D1; } static bool isValidCan2RxPin(brain_pin_e pin) { - return pin == GPIOB_5 || pin == GPIOB_12; + return pin == Gpio::B5 || pin == Gpio::B12; } static bool isValidCan2TxPin(brain_pin_e pin) { - return pin == GPIOB_6 || pin == GPIOB_13; + return pin == Gpio::B6 || pin == Gpio::B13; } bool isValidCanTxPin(brain_pin_e pin) { @@ -779,7 +779,7 @@ bool isValidCanRxPin(brain_pin_e pin) { } CANDriver* detectCanDevice(brain_pin_e pinRx, brain_pin_e pinTx) { - if (pinRx == GPIO_UNASSIGNED && pinTx == GPIO_UNASSIGNED) { + if (pinRx == Gpio::Unassigned && pinTx == Gpio::Unassigned) { return nullptr; } #if STM32_CAN_USE_CAN1 || STM32_CAN_USE_FDCAN1 diff --git a/firmware/hw_layer/ports/stm32/stm32_pins.cpp b/firmware/hw_layer/ports/stm32/stm32_pins.cpp index 81edf345f8..d0c8c141cc 100644 --- a/firmware/hw_layer/ports/stm32/stm32_pins.cpp +++ b/firmware/hw_layer/ports/stm32/stm32_pins.cpp @@ -141,11 +141,11 @@ static int getPortIndex(ioportid_t port) { } ioportid_t getBrainPinPort(brain_pin_e brainPin) { - return ports[(brainPin - GPIOA_0) / PORT_SIZE]; + return ports[(brainPin - Gpio::A0) / PORT_SIZE]; } int getBrainPinIndex(brain_pin_e brainPin) { - return (brainPin - GPIOA_0) % PORT_SIZE; + return (brainPin - Gpio::A0) % PORT_SIZE; } int getPortPinIndex(ioportid_t port, ioportmask_t pin) { @@ -159,11 +159,11 @@ ioportid_t getHwPort(const char *msg, brain_pin_e brainPin) { if (!isBrainPinValid(brainPin)) { /* * https://github.com/dron0gus please help - firmwareError(CUSTOM_ERR_INVALID_PIN, "%s: Invalid brain_pin_e: %d", msg, brainPin); + firmwareError(CUSTOM_ERR_INVALID_PIN, "%s: Invalid Gpio: %d", msg, brainPin); */ return GPIO_NULL; } - return ports[(brainPin - GPIOA_0) / PORT_SIZE]; + return ports[(brainPin - Gpio::A0) / PORT_SIZE]; } /** @@ -177,30 +177,30 @@ ioportmask_t getHwPin(const char *msg, brain_pin_e brainPin) if (brain_pin_is_onchip(brainPin)) return getBrainPinIndex(brainPin); - firmwareError(CUSTOM_ERR_INVALID_PIN, "%s: Invalid on-chip brain_pin_e: %d", msg, brainPin); + firmwareError(CUSTOM_ERR_INVALID_PIN, "%s: Invalid on-chip Gpio: %d", msg, brainPin); return EFI_ERROR_CODE; } /** - * Parse string representation of physical pin into brain_pin_e ordinal. + * Parse string representation of physical pin into Gpio ordinal. * - * @return GPIO_UNASSIGNED for "none", GPIO_INVALID for invalid entry + * @return Gpio::Unassigned for "none", Gpio::Invalid for invalid entry */ brain_pin_e parseBrainPin(const char *str) { if (strEqual(str, "none")) - return GPIO_UNASSIGNED; + return Gpio::Unassigned; // todo: create method toLowerCase? if (str[0] != 'p' && str[0] != 'P') { - return GPIO_INVALID; + return Gpio::Invalid; } char port = str[1]; brain_pin_e basePin; if (port >= 'a' && port <= 'z') { - basePin = (brain_pin_e) ((int) GPIOA_0 + PORT_SIZE * (port - 'a')); + basePin = Gpio::A0 + PORT_SIZE * (port - 'a'); } else if (port >= 'A' && port <= 'Z') { - basePin = (brain_pin_e) ((int) GPIOA_0 + PORT_SIZE * (port - 'A')); + basePin = Gpio::A0 + PORT_SIZE * (port - 'A'); } else { - return GPIO_INVALID; + return Gpio::Invalid; } const char *pinStr = str + 2; int pin = atoi(pinStr); diff --git a/firmware/hw_layer/ports/stm32/stm32f4/board.h b/firmware/hw_layer/ports/stm32/stm32f4/board.h index 3db07ac049..ada37d1e06 100644 --- a/firmware/hw_layer/ports/stm32/stm32f4/board.h +++ b/firmware/hw_layer/ports/stm32/stm32f4/board.h @@ -27,8 +27,8 @@ #define BOARD_NAME "F4 for rusEFI" #define EFI_USB_AF 10U -#define EFI_USB_SERIAL_DM GPIOA_11 -#define EFI_USB_SERIAL_DP GPIOA_12 +#define EFI_USB_SERIAL_DM Gpio::A11 +#define EFI_USB_SERIAL_DP Gpio::A12 // Ignore USB VBUS pin (we're never a host, only a device) #define BOARD_OTG_NOVBUSSENS TRUE diff --git a/firmware/hw_layer/ports/stm32/stm32f7/board.h b/firmware/hw_layer/ports/stm32/stm32f7/board.h index 3f2f11b60c..e26f031de5 100644 --- a/firmware/hw_layer/ports/stm32/stm32f7/board.h +++ b/firmware/hw_layer/ports/stm32/stm32f7/board.h @@ -33,8 +33,8 @@ #define BOARD_NAME "F7 for rusEFI" #define EFI_USB_AF 10U -#define EFI_USB_SERIAL_DM GPIOA_11 -#define EFI_USB_SERIAL_DP GPIOA_12 +#define EFI_USB_SERIAL_DM Gpio::A11 +#define EFI_USB_SERIAL_DP Gpio::A12 // Ignore USB VBUS pin (we're never a host, only a device) #define BOARD_OTG_NOVBUSSENS TRUE diff --git a/firmware/hw_layer/ports/stm32/stm32h7/board.h b/firmware/hw_layer/ports/stm32/stm32h7/board.h index 26c4945907..7323473dc0 100644 --- a/firmware/hw_layer/ports/stm32/stm32h7/board.h +++ b/firmware/hw_layer/ports/stm32/stm32h7/board.h @@ -32,8 +32,8 @@ #define BOARD_NAME "H7 rusEFI" #define EFI_USB_AF 10U -#define EFI_USB_SERIAL_DM GPIOA_11 -#define EFI_USB_SERIAL_DP GPIOA_12 +#define EFI_USB_SERIAL_DM Gpio::A11 +#define EFI_USB_SERIAL_DP Gpio::A12 /* * input-floating is the default pin mode. input-output boards should provision appropriate pull-ups/pull-downs. diff --git a/firmware/hw_layer/sensors/accelerometer.cpp b/firmware/hw_layer/sensors/accelerometer.cpp index 062b151f2d..0b2792e9cb 100644 --- a/firmware/hw_layer/sensors/accelerometer.cpp +++ b/firmware/hw_layer/sensors/accelerometer.cpp @@ -45,13 +45,13 @@ static const SPIConfig accelerometerCfg = { #endif /* EFI_MEMS */ void configureAccelerometerPins() { -// engineConfiguration->LIS302DLCsPin = GPIOE_3; // we have a conflict with VVT output on Miata +// engineConfiguration->LIS302DLCsPin = Gpio::E3; // we have a conflict with VVT output on Miata // engineConfiguration->is_enabled_spi_1 = true; // we have a conflict with PA5 input pin // stm32f4discovery defaults - engineConfiguration->spi1mosiPin = GPIOA_7; - engineConfiguration->spi1misoPin = GPIOA_6; - engineConfiguration->spi1sckPin = GPIOA_5; + engineConfiguration->spi1mosiPin = Gpio::A7; + engineConfiguration->spi1misoPin = Gpio::A6; + engineConfiguration->spi1sckPin = Gpio::A5; } diff --git a/firmware/hw_layer/sensors/cj125.cpp b/firmware/hw_layer/sensors/cj125.cpp index 2946208b76..ec3d69826b 100644 --- a/firmware/hw_layer/sensors/cj125.cpp +++ b/firmware/hw_layer/sensors/cj125.cpp @@ -647,19 +647,19 @@ void initCJ125() { // engineConfiguration->spi2SckMode = PAL_STM32_OTYPE_OPENDRAIN; // 4 // engineConfiguration->spi2MosiMode = PAL_STM32_OTYPE_OPENDRAIN; // 4 // engineConfiguration->spi2MisoMode = PAL_STM32_PUDR_PULLUP; // 32 -// engineConfiguration->cj125CsPin = GPIOA_15; +// engineConfiguration->cj125CsPin = Gpio::A15; // engineConfiguration->cj125CsPinMode = OM_OPENDRAIN; void cj125defaultPinout() { engineConfiguration->cj125ua = EFI_ADC_13; // PC3 engineConfiguration->cj125ur = EFI_ADC_4; // PA4 - engineConfiguration->wboHeaterPin = GPIOC_13; + engineConfiguration->wboHeaterPin = Gpio::C13; - engineConfiguration->spi2mosiPin = GPIOB_15; - engineConfiguration->spi2misoPin = GPIOB_14; - engineConfiguration->spi2sckPin = GPIOB_13; + engineConfiguration->spi2mosiPin = Gpio::B15; + engineConfiguration->spi2misoPin = Gpio::B14; + engineConfiguration->spi2sckPin = Gpio::B13; - engineConfiguration->cj125CsPin = GPIOB_0; + engineConfiguration->cj125CsPin = Gpio::B0; engineConfiguration->isCJ125Enabled = true; engineConfiguration->is_enabled_spi_2 = true; engineConfiguration->cj125SpiDevice = SPI_DEVICE_2; diff --git a/firmware/hw_layer/smart_gpio.cpp b/firmware/hw_layer/smart_gpio.cpp index f56c9897a3..b0c2941a0b 100644 --- a/firmware/hw_layer/smart_gpio.cpp +++ b/firmware/hw_layer/smart_gpio.cpp @@ -219,9 +219,9 @@ void initSmartGpio() { tle6240.spi_config.ssport = getHwPort("tle6240 CS", engineConfiguration->tle6240_cs); tle6240.spi_config.sspad = getHwPin("tle6240 CS", engineConfiguration->tle6240_cs); tle6240.spi_bus = getSpiDevice(engineConfiguration->tle6240spiDevice); - int ret = tle6240_add(TLE6240_PIN_1, 0, &tle6240); + int ret = tle6240_add(Gpio::TLE6240_PIN_1, 0, &tle6240); - efiAssertVoid(OBD_PCM_Processor_Fault, ret == TLE6240_PIN_1, "tle6240"); + efiAssertVoid(OBD_PCM_Processor_Fault, ret == (int)Gpio::TLE6240_PIN_1, "tle6240"); } #endif /* (BOARD_TLE6240_COUNT > 0) */ @@ -232,9 +232,9 @@ void initSmartGpio() { mc33972.spi_config.sspad = getHwPin("mc33972 CS", engineConfiguration->mc33972_cs); mc33972.spi_bus = getSpiDevice(engineConfiguration->mc33972spiDevice); // todo: propogate 'basePinOffset' parameter - int ret = mc33972_add(MC33972_PIN_1, 0, &mc33972); + int ret = mc33972_add(Gpio::MC33972_PIN_1, 0, &mc33972); - efiAssertVoid(OBD_PCM_Processor_Fault, ret == MC33972_PIN_1, "mc33972"); + efiAssertVoid(OBD_PCM_Processor_Fault, ret == (int)Gpio::MC33972_PIN_1, "mc33972"); } #endif /* (BOARD_MC33972_COUNT > 0) */ @@ -245,9 +245,9 @@ void initSmartGpio() { l9779_cfg.spi_config.sspad = getHwPin("l9779 CS", engineConfiguration->l9779_cs); l9779_cfg.spi_bus = getSpiDevice(engineConfiguration->l9779spiDevice); // todo: propogate 'basePinOffset' parameter - int ret = l9779_add(L9779_IGN_1, 0, &l9779_cfg); + int ret = l9779_add(Gpio::L9779_IGN_1, 0, &l9779_cfg); - efiAssertVoid(OBD_PCM_Processor_Fault, ret == L9779_IGN_1, "l9779"); + efiAssertVoid(OBD_PCM_Processor_Fault, ret == (int)Gpio::L9779_IGN_1, "l9779"); } #endif /* (BOARD_L9779_COUNT > 0) */ @@ -262,9 +262,9 @@ void initSmartGpio() { tle8888_cfg.stepper = engineConfiguration->useTLE8888_stepper; /* spi_bus == null checked in _add function */ - int ret = tle8888_add(TLE8888_PIN_1, 0, &tle8888_cfg); + int ret = tle8888_add(Gpio::TLE8888_PIN_1, 0, &tle8888_cfg); - efiAssertVoid(OBD_PCM_Processor_Fault, ret == TLE8888_PIN_1, "tle8888"); + efiAssertVoid(OBD_PCM_Processor_Fault, ret == (int)Gpio::TLE8888_PIN_1, "tle8888"); } #endif /* (BOARD_TLE8888_COUNT > 0) */ @@ -273,9 +273,9 @@ void initSmartGpio() { drv8860.spi_config.ssport = getHwPort("drv8860 CS", engineConfiguration->drv8860_cs); drv8860.spi_config.sspad = getHwPin("drv8860 CS", engineConfiguration->drv8860_cs); drv8860.spi_bus = getSpiDevice(engineConfiguration->drv8860spiDevice); - int ret = drv8860_add(DRV8860_PIN_1, 0, &drv8860); + int ret = drv8860_add(Gpio::DRV8860_PIN_1, 0, &drv8860); - efiAssertVoid(OBD_PCM_Processor_Fault, ret == DRV8860_PIN_1, "drv8860"); + efiAssertVoid(OBD_PCM_Processor_Fault, ret == (int)Gpio::DRV8860_PIN_1, "drv8860"); } #endif /* (BOARD_DRV8860_COUNT > 0) */ diff --git a/firmware/integration/rusefi_config.txt b/firmware/integration/rusefi_config.txt index d6104dd541..6dfe47681d 100644 --- a/firmware/integration/rusefi_config.txt +++ b/firmware/integration/rusefi_config.txt @@ -327,16 +327,16 @@ custom vvt_mode_e 1 bits, U08, @OFFSET@, [0:4], @@vvt_mode_e_enum@@ custom brain_input_pin_e 1 bits, U08, @OFFSET@, [0:7], @@brain_input_pin_e_enum@@ ! -! 'brain_pin_e' is the most flexible kind of pin +! 'Gpio' is the most flexible kind of pin ! 'output_pin_e' is a brain pin known to be routed to control an output on your specific board ! 'brain_input_pin_e' is XXX ! 'switch_input_pin_e' is a slow digital input suitable for clutch or brake pedal switch but not suitable for VSS or Flex sensor input ! -#define brain_pin_e_enum "NONE", "INVALID", "PA0", "PA1", "PA2", "PA3", "PA4", "PA5", "PA6", "PA7", "PA8", "PA9", "PA10", "PA11", "PA12", "PA13", "PA14", "PA15", "PB0", "PB1", "PB2", "PB3", "PB4", "PB5", "PB6", "PB7", "PB8", "PB9", "PB10", "PB11", "PB12", "PB13", "PB14", "PB15", "PC0", "PC1", "PC2", "PC3", "PC4", "PC5", "PC6", "PC7", "PC8", "PC9", "PC10", "PC11", "PC12", "PC13", "PC14", "PC15", "PD0", "PD1", "PD2", "PD3", "PD4", "PD5", "PD6", "PD7", "PD8", "PD9", "PD10", "PD11", "PD12", "PD13", "PD14", "PD15", "PE0", "PE1", "PE2", "PE3", "PE4", "PE5", "PE6", "PE7", "PE8", "PE9", "PE10", "PE11", "PE12", "PE13", "PE14", "PE15", "PF0", "PF1", "PF2", "PF3", "PF4", "PF5", "PF6", "PF7", "PF8", "PF9", "PF10", "PF11", "PF12", "PF13", "PF14", "PF15", "PG0", "PG1", "PG2", "PG3", "PG4", "PG5", "PG6", "PG7", "PG8", "PG9", "PG10", "PG11", "PG12", "PG13", "PG14", "PG15", "PH0", "PH1", "PH2", "PH3", "PH4", "PH5", "PH6", "PH7", "PH8", "PH9", "PH10", "PH11", "PH12", "PH13", "PH14", "PH15", "PI0", "PI1", "PI2", "PI3", "PI4", "PI5", "PI6", "PI7", "PI8", "PI9", "PI10", "PI11", "PI12", "PI13", "PI14", "PI15", "INVALID", "INVALID", "INVALID", "INVALID", "INVALID", "INVALID", "INVALID", "INVALID", "INVALID", "INVALID", "INVALID", "INVALID", "INVALID", "INVALID" +#define Gpio_enum "NONE", "INVALID", "PA0", "PA1", "PA2", "PA3", "PA4", "PA5", "PA6", "PA7", "PA8", "PA9", "PA10", "PA11", "PA12", "PA13", "PA14", "PA15", "PB0", "PB1", "PB2", "PB3", "PB4", "PB5", "PB6", "PB7", "PB8", "PB9", "PB10", "PB11", "PB12", "PB13", "PB14", "PB15", "PC0", "PC1", "PC2", "PC3", "PC4", "PC5", "PC6", "PC7", "PC8", "PC9", "PC10", "PC11", "PC12", "PC13", "PC14", "PC15", "PD0", "PD1", "PD2", "PD3", "PD4", "PD5", "PD6", "PD7", "PD8", "PD9", "PD10", "PD11", "PD12", "PD13", "PD14", "PD15", "PE0", "PE1", "PE2", "PE3", "PE4", "PE5", "PE6", "PE7", "PE8", "PE9", "PE10", "PE11", "PE12", "PE13", "PE14", "PE15", "PF0", "PF1", "PF2", "PF3", "PF4", "PF5", "PF6", "PF7", "PF8", "PF9", "PF10", "PF11", "PF12", "PF13", "PF14", "PF15", "PG0", "PG1", "PG2", "PG3", "PG4", "PG5", "PG6", "PG7", "PG8", "PG9", "PG10", "PG11", "PG12", "PG13", "PG14", "PG15", "PH0", "PH1", "PH2", "PH3", "PH4", "PH5", "PH6", "PH7", "PH8", "PH9", "PH10", "PH11", "PH12", "PH13", "PH14", "PH15", "PI0", "PI1", "PI2", "PI3", "PI4", "PI5", "PI6", "PI7", "PI8", "PI9", "PI10", "PI11", "PI12", "PI13", "PI14", "PI15", "INVALID", "INVALID", "INVALID", "INVALID", "INVALID", "INVALID", "INVALID", "INVALID", "INVALID", "INVALID", "INVALID", "INVALID", "INVALID", "INVALID" #define switch_input_pin_e_enum "NONE", "INVALID", "PA0", "PA1", "PA2", "PA3", "PA4", "PA5", "PA6", "PA7", "PA8", "PA9", "PA10", "PA11", "PA12", "PA13", "PA14", "PA15", "PB0", "PB1", "PB2", "PB3", "PB4", "PB5", "PB6", "PB7", "PB8", "PB9", "PB10", "PB11", "PB12", "PB13", "PB14", "PB15", "PC0", "PC1", "PC2", "PC3", "PC4", "PC5", "PC6", "PC7", "PC8", "PC9", "PC10", "PC11", "PC12", "PC13", "PC14", "PC15", "PD0", "PD1", "PD2", "PD3", "PD4", "PD5", "PD6", "PD7", "PD8", "PD9", "PD10", "PD11", "PD12", "PD13", "PD14", "PD15", "PE0", "PE1", "PE2", "PE3", "PE4", "PE5", "PE6", "PE7", "PE8", "PE9", "PE10", "PE11", "PE12", "PE13", "PE14", "PE15", "PF0", "PF1", "PF2", "PF3", "PF4", "PF5", "PF6", "PF7", "PF8", "PF9", "PF10", "PF11", "PF12", "PF13", "PF14", "PF15", "PG0", "PG1", "PG2", "PG3", "PG4", "PG5", "PG6", "PG7", "PG8", "PG9", "PG10", "PG11", "PG12", "PG13", "PG14", "PG15", "PH0", "PH1", "PH2", "PH3", "PH4", "PH5", "PH6", "PH7", "PH8", "PH9", "PH10", "PH11", "PH12", "PH13", "PH14", "PH15", "PI0", "PI1", "PI2", "PI3", "PI4", "PI5", "PI6", "PI7", "PI8", "PI9", "PI10", "PI11", "PI12", "PI13", "PI14", "PI15", "INVALID", "INVALID", "INVALID", "INVALID", "INVALID", "INVALID", "INVALID", "INVALID", "INVALID", "INVALID", "INVALID", "INVALID", "INVALID", "INVALID" -custom brain_pin_e 1 bits, U08, @OFFSET@, [0:7], @@brain_pin_e_enum@@ +custom Gpio 1 bits, U08, @OFFSET@, [0:7], @@Gpio_enum@@ custom switch_input_pin_e 1 bits, U08, @OFFSET@, [0:7], @@switch_input_pin_e_enum@@ #define output_pin_e_enum "NONE", "INVALID", "PA0", "PA1", "PA2", "PA3", "PA4", "PA5", "PA6", "PA7", "PA8", "PA9", "PA10", "PA11", "PA12", "PA13", "PA14", "PA15", "PB0", "PB1", "PB2", "PB3", "PB4", "PB5", "PB6", "PB7", "PB8", "PB9", "PB10", "PB11", "PB12", "PB13", "PB14", "PB15", "PC0", "PC1", "PC2", "PC3", "PC4", "PC5", "PC6", "PC7", "PC8", "PC9", "PC10", "PC11", "PC12", "PC13", "PC14", "PC15", "PD0", "PD1", "PD2", "PD3", "PD4", "PD5", "PD6", "PD7", "PD8", "PD9", "PD10", "PD11", "PD12", "PD13", "PD14", "PD15", "PE0", "PE1", "PE2", "PE3", "PE4", "PE5", "PE6", "PE7", "PE8", "PE9", "PE10", "PE11", "PE12", "PE13", "PE14", "PE15", "PF0", "PF1", "PF2", "PF3", "PF4", "PF5", "PF6", "PF7", "PF8", "PF9", "PF10", "PF11", "PF12", "PF13", "PF14", "PF15", "PG0", "PG1", "PG2", "PG3", "PG4", "PG5", "PG6", "PG7", "PG8", "PG9", "PG10", "PG11", "PG12", "PG13", "PG14", "PG15", "PH0", "PH1", "PH2", "PH3", "PH4", "PH5", "PH6", "PH7", "PH8", "PH9", "PH10", "PH11", "PH12", "PH13", "PH14", "PH15", "PI0", "PI1", "PI2", "PI3", "PI4", "PI5", "PI6", "PI7", "PI8", "PI9", "PI10", "PI11", "PI12", "PI13", "PI14", "PI15", "MC33972_1", "MC33972_2", "MC33972_3", "MC33972_4", "MC33972_5", "MC33972_6", "MC33972_7", "MC33972_8", "MC33972_9", "MC33972_10", "MC33972_11", "MC33972_12", "MC33972_13", "MC33972_14", "MC33972_15", "MC33972_16", "MC33972_17", "MC33972_18", "MC33972_19", "MC33972_20", "MC33972_21", "MC33972_22", "TLE8888_1", "TLE8888_2", "TLE8888_3", "TLE8888_4", "TLE8888_5", "TLE8888_6", "TLE8888_7", "TLE8888_8", "TLE8888_9", "TLE8888_10", "TLE8888_11", "TLE8888_12", "TLE8888_13", "TLE8888_14", "TLE8888_15", "TLE8888_16", "TLE8888_17", "TLE8888_18", "TLE8888_19", "TLE8888_20", "TLE8888_21", "TLE8888_22", "TLE8888_23", "TLE8888_24", "TLE8888_25", "TLE8888_26", "TLE8888_27", "TLE8888_28", "INVALID", "INVALID", "INVALID", "TLE6240_1", "TLE6240_2", "TLE6240_3", "TLE6240_4", "TLE6240_5", "TLE6240_6", "TLE6240_7", "TLE6240_8", "TLE6240_9", "TLE6240_10", "TLE6240_11", "TLE6240_12", "TLE6240_13", "TLE6240_14", "TLE6240_15", "TLE6240_16", "INVALID", "INVALID", "INVALID", "INVALID", "INVALID", "INVALID", "INVALID", "INVALID", "INVALID", "INVALID", "INVALID" @@ -349,9 +349,9 @@ custom pin_output_mode_e 1 bits, U08, @OFFSET@, [0:1], @@pin_output_mode_e_enum@ custom pin_input_mode_e 1 bits, U08, @OFFSET@, [0:1], @@pin_input_mode_e_enum@@ struct spi_pins - brain_pin_e mosiPin; - brain_pin_e misoPin; - brain_pin_e sckPin; + Gpio mosiPin; + Gpio misoPin; + Gpio sckPin; end_struct @@ -630,7 +630,7 @@ end_struct afr_sensor_s afr adc_channel_e throttlePedalPositionAdcChannel;Electronic throttle pedal position first channel\nSee throttlePedalPositionSecondAdcChannel for second channel\nSee also tps1_1AdcChannel\nset_analog_input_pin pps X\nSee throttlePedalUpVoltage and throttlePedalWOTVoltage - brain_pin_e tle6240_cs; + Gpio tle6240_cs; pin_output_mode_e tle6240_csPinMode; switch_input_pin_e throttlePedalUpPin;+Throttle Pedal not pressed switch - used on some older vehicles like early Mazda Miata @@ -642,16 +642,16 @@ struct idle_hardware_s int solenoidFrequency;;"Hz", 1, 0, 0, 3000, 0 output_pin_e solenoidPin - brain_pin_e stepperDirectionPin - brain_pin_e stepperStepPin + Gpio stepperDirectionPin + Gpio stepperStepPin pin_output_mode_e solenoidPinMode end_struct struct dc_io - brain_pin_e directionPin1; - brain_pin_e directionPin2; - brain_pin_e controlPin;Acts as EN pin in two-wire mode - brain_pin_e disablePin; + Gpio directionPin1; + Gpio directionPin2; + Gpio controlPin;Acts as EN pin in two-wire mode + Gpio disablePin; end_struct idle_hardware_s idle; @@ -666,7 +666,7 @@ uint8_t knockRetardMaximum;+Maximum amount of knock retard.;"deg", 1, 0, 0, 30, uint16_t autoscale vssGearRatio;Number of turns of your vehicle speed sensor per turn of the wheels. For example if your sensor is on the transmission output, enter your axle/differential ratio. If you are using a hub-mounted sensor, enter a value of 1.0.; "ratio", 0.001, 0, 0, 60, 3 uint8_t vssToothCount;Number of pulses output per revolution of the shaft where your VSS is mounted. For example, GM applications of the T56 output 17 pulses per revolution of the transmission output shaft.;"count", 1, 0, 1, 100, 0 - brain_pin_e l9779_cs; + Gpio l9779_cs; ! todo: rename to triggerSimulatorRpm @@ -677,16 +677,16 @@ uint8_t knockRetardMaximum;+Maximum amount of knock retard.;"deg", 1, 0, 0, 30, pin_output_mode_e injectionPinMode; pin_output_mode_e ignitionPinMode; - brain_pin_e HD44780_rs; - brain_pin_e HD44780_e; + Gpio HD44780_rs; + Gpio HD44780_e; - brain_pin_e HD44780_db4; - brain_pin_e HD44780_db5; - brain_pin_e HD44780_db6; - brain_pin_e HD44780_db7; + Gpio HD44780_db4; + Gpio HD44780_db5; + Gpio HD44780_db6; + Gpio HD44780_db7; - brain_pin_e gps_rx_pin; - brain_pin_e gps_tx_pin; + Gpio gps_rx_pin; + Gpio gps_tx_pin; output_pin_e fuelPumpPin; pin_output_mode_e fuelPumpPinMode; @@ -700,15 +700,15 @@ switch_input_pin_e clutchDownPin;+Some cars have a switch to indicate that clutc pin_output_mode_e alternatorControlPinMode; pin_input_mode_e clutchDownPinMode; - brain_pin_e[DIGIPOT_COUNT iterate] digitalPotentiometerChipSelect; + Gpio[DIGIPOT_COUNT iterate] digitalPotentiometerChipSelect; pin_output_mode_e electronicThrottlePin1Mode; - brain_pin_e wboHeaterPin;set_cj125_heater_pin XXX - brain_pin_e cj125CsPin;set_cj125_cs_pin XXX + Gpio wboHeaterPin;set_cj125_heater_pin XXX + Gpio cj125CsPin;set_cj125_cs_pin XXX spi_device_e max31855spiDevice; - brain_pin_e debugTriggerSync; + Gpio debugTriggerSync; spi_device_e digitalPotentiometerSpiDevice;Digital Potentiometer is used by stock ECU stimulation code - brain_pin_e mc33972_cs; + Gpio mc33972_cs; pin_output_mode_e mc33972_csPinMode; custom adc_channel_mode_e 4 bits, U32, @OFFSET@, [0:1], "Off", "Slow", "Fast" @@ -729,9 +729,9 @@ custom adc_channel_mode_e 4 bits, U32, @OFFSET@, [0:1], "Off", "Slow", "Fast" pin_output_mode_e tachOutputPinMode; output_pin_e mainRelayPin; - brain_pin_e sdCardCsPin; - brain_pin_e canTxPin;set_can_tx_pin X - brain_pin_e canRxPin;set_can_rx_pin X + Gpio sdCardCsPin; + Gpio canTxPin;set_can_tx_pin X + Gpio canRxPin;set_can_rx_pin X pin_input_mode_e throttlePedalUpPinMode; uint8_t acIdleExtraOffset;+Additional idle % while A/C is active;"%", 1, 0, 0, 100, 0 @@ -752,7 +752,7 @@ pin_input_mode_e throttlePedalUpPinMode; float compressionRatio;+Just for reference really, not taken into account by any logic at this point;"CR", 1, 0, 0, 300, 1 - brain_pin_e[TRIGGER_SIMULATOR_PIN_COUNT iterate] triggerSimulatorPins;Each rusEFI piece can provide synthetic trigger signal for external ECU. Sometimes these wires are routed back into trigger inputs of the same rusEFI board.\nSee also directSelfStimulation which is different. + Gpio[TRIGGER_SIMULATOR_PIN_COUNT iterate] triggerSimulatorPins;Each rusEFI piece can provide synthetic trigger signal for external ECU. Sometimes these wires are routed back into trigger inputs of the same rusEFI board.\nSee also directSelfStimulation which is different. pin_output_mode_e[TRIGGER_SIMULATOR_PIN_COUNT iterate] triggerSimulatorPinModes; output_pin_e o2heaterPin;+Narrow band o2 heater, not used for CJ125. 'ON' if engine is running, 'OFF' if stopped or cranking. See wboHeaterPin pin_output_mode_e o2heaterPinModeTodO; @@ -795,8 +795,8 @@ bit is_enabled_spi_2 brain_input_pin_e[LOGIC_ANALYZER_CHANNEL_COUNT iterate] logicAnalyzerPins; pin_output_mode_e mainRelayPinMode; - brain_pin_e hip9011CsPin; - brain_pin_e hip9011IntHoldPin; + Gpio hip9011CsPin; + Gpio hip9011IntHoldPin; pin_output_mode_e hip9011IntHoldPinMode; ! 536870911 = 2^29-1, the maximum valid extended ID @@ -821,8 +821,8 @@ output_pin_e acFanPin;+Optional Radiator Fan used with A/C int16_t idlePidRpmUpperLimit;+How far above idle speed do we consider idling?\nFor example, if target = 800, this param = 200, then anything below 1000 RPM is considered idle.;"RPM", 1, 0, 0, 500, 0 uint16_t autoscale applyNonlinearBelowPulse;+Apply nonlinearity correction below a pulse of this duration. Pulses longer than this duration will receive no adjustment.;"ms", {1/1000}, 0, 0, 30, 3 - brain_pin_e lps25BaroSensorScl - brain_pin_e lps25BaroSensorSda + Gpio lps25BaroSensorScl + Gpio lps25BaroSensorSda brain_input_pin_e vehicleSpeedSensorInputPin; switch_input_pin_e clutchUpPin;+Some vehicles have a switch to indicate that clutch pedal is all the way up @@ -830,9 +830,9 @@ output_pin_e acFanPin;+Optional Radiator Fan used with A/C InjectorNonlinearMode injectorNonlinearMode pin_input_mode_e clutchUpPinMode; - brain_pin_e[EGT_CHANNEL_COUNT iterate] max31855_cs; + Gpio[EGT_CHANNEL_COUNT iterate] max31855_cs; brain_input_pin_e flexSensorPin;+Continental/GM flex fuel sensor, 50-150hz type; - brain_pin_e test557pin + Gpio test557pin pin_output_mode_e stepperDirectionPinMode; spi_device_e mc33972spiDevice; @@ -843,7 +843,7 @@ output_pin_e acFanPin;+Optional Radiator Fan used with A/C custom uart_device_e 1 bits, U08, @OFFSET@, [0:1], "Off", "UART1", "UART2", "UART3" int16_t sdCardPeriodMs;+SD card logging period, in milliseconds;"ms", 1, 0, 0, 30000, 0 adc_channel_e idlePositionSensor; - brain_pin_e debugMapAveraging; + Gpio debugMapAveraging; output_pin_e starterRelayDisablePin; pin_output_mode_e starterRelayDisablePinMode;On some vehicles we can disable starter once engine is already running output_pin_e secondSolenoidPin;Some Subaru and some Mazda use double-solenoid idle air valve @@ -857,7 +857,7 @@ custom uart_device_e 1 bits, U08, @OFFSET@, [0:1], "Off", "UART1", "UART2", "UAR int16_t antiLagRpmTreshold;;"rpm", 1, 0, 0, 20000, 0 uint16_t startCrankingDuration;+Maximum time to crank starter when start/stop button is pressed;"Seconds", 1, 0, 0, 30, 0 - brain_pin_e triggerErrorPin;+This pin is used for debugging - snap a logic analyzer on it and see if it's ever high + Gpio triggerErrorPin;+This pin is used for debugging - snap a logic analyzer on it and see if it's ever high pin_output_mode_e triggerErrorPinMode; output_pin_e acRelayPin; pin_output_mode_e acRelayPinMode; @@ -868,24 +868,24 @@ custom script_setting_t 4 scalar, F32, @OFFSET@, "", 1, 0, 0, 18000, 2 script_setting_t[SCRIPT_SETTING_COUNT iterate] scriptSetting; ! todo: migrate to spi_pins & combine with spi pin modes - brain_pin_e spi1mosiPin; - brain_pin_e spi1misoPin; - brain_pin_e spi1sckPin; - brain_pin_e spi2mosiPin; + Gpio spi1mosiPin; + Gpio spi1misoPin; + Gpio spi1sckPin; + Gpio spi2mosiPin; - brain_pin_e spi2misoPin; - brain_pin_e spi2sckPin; - brain_pin_e spi3mosiPin; - brain_pin_e spi3misoPin; + Gpio spi2misoPin; + Gpio spi2sckPin; + Gpio spi3mosiPin; + Gpio spi3misoPin; - brain_pin_e spi3sckPin; - brain_pin_e cdmInputPin;+Saab Combustion Detection Module knock signal input pin\nalso known as Saab Ion Sensing Module; - brain_pin_e joystickCenterPin; - brain_pin_e joystickAPin; + Gpio spi3sckPin; + Gpio cdmInputPin;+Saab Combustion Detection Module knock signal input pin\nalso known as Saab Ion Sensing Module; + Gpio joystickCenterPin; + Gpio joystickAPin; - brain_pin_e joystickBPin; - brain_pin_e joystickCPin; - brain_pin_e joystickDPin; + Gpio joystickBPin; + Gpio joystickCPin; + Gpio joystickDPin; uart_device_e consoleUartDevice; @@ -990,9 +990,9 @@ bit verboseCan2,"Print all","Do not print";Print incoming and outgoing second bu etb_function_e[ETB_COUNT iterate] etbFunctions spi_device_e drv8860spiDevice; - brain_pin_e drv8860_cs; + Gpio drv8860_cs; pin_output_mode_e drv8860_csPinMode; - brain_pin_e drv8860_miso; + Gpio drv8860_miso; uint16_t[FUEL_LEVEL_TABLE_COUNT] autoscale fuelLevelBins;;"volt", {1/@@PACK_MULT_VOLTAGE@@}, 0, 0, 5, 3 @@ -1004,7 +1004,7 @@ bit verboseCan2,"Print all","Do not print";Print incoming and outgoing second bu struct vr_threshold_s uint8_t[6] autoscale rpmBins;;"rpm", @@RPM_1_BYTE_PACKING_MULT@@, 0, 0, 12000, 0 uint8_t[6] autoscale values;;"volts", {1/@@PACK_PERCENT_BYTE_MULT@@}, 0, 0, 2.5, 2 - brain_pin_e pin; + Gpio pin; end_struct ! todo: should be '3' since we are dreaming of Honda triple-channel distributor @@ -1098,7 +1098,7 @@ bit unused_1484_bit_31 float turboSpeedSensorMultiplier;;"mult", 1, 0, 0, 7000, 3 - brain_pin_e[CAM_INPUTS_COUNT iterate] camInputsDebug; + Gpio[CAM_INPUTS_COUNT iterate] camInputsDebug; uint8_t[CAM_INPUTS_COUNT_padding] camInputsDebugPadding;; int16_t acIdleRpmBump;+Extra idle target speed when A/C is enabled. Some cars need the extra speed to keep the AC efficient while idling.;"RPM", 1, 0, 0, 1000, 0 @@ -1136,13 +1136,13 @@ custom pin_mode_e 1 bits, U08, @OFFSET@, [0:6], @@pin_mode_e_enum@@ float wwaeTau;+Length of time the deposited wall fuel takes to dissipate after the start of acceleration. ;"Seconds", 1, 0, 0, 3, 2 pid_s alternatorControl; pid_s etb; - brain_pin_e[TRIGGER_INPUT_PIN_COUNT iterate] triggerInputDebugPins; + Gpio[TRIGGER_INPUT_PIN_COUNT iterate] triggerInputDebugPins; brain_input_pin_e turboSpeedSensorInputPin; int16_t tps2Min;Closed throttle#2. todo: extract these two fields into a structure\nSee also tps2_1AdcChannel\nset tps2_min X;"ADC", 1, 0, 0, 1023, 0 int16_t tps2Max;Full throttle#2. tpsMax value as 10 bit ADC value. Not Voltage!\nSee also tps1_1AdcChannel\nset tps2_max X;"ADC", 1, 0, 0, 1023, 0 output_pin_e starterControlPin;See also startStopButtonPin pin_input_mode_e startStopButtonMode; - brain_pin_e mc33816_flag0; + Gpio mc33816_flag0; uint8_t tachPulsePerRev;;"Pulse", 1, 0, 1, 255, 0 ! todo: mapErrorDetectionIdleTooLow? 30kPa is usually lowest on idle @@ -1153,12 +1153,12 @@ int16_t tps2Max;Full throttle#2. tpsMax value as 10 bit ADC value. Not Voltage!\ pid_s idleRpmPid;See cltIdleRpmBins float wwaeBeta;+0 = No fuel settling on port walls 1 = All the fuel settling on port walls setting this to 0 disables the wall wetting enrichment. ;"Fraction", 1, 0, 0, 1, 2 - brain_pin_e communicationLedPin;+blue LED on many rusEFI boards.\nBlue Communication LED which is expected to blink at 50% duty cycle during normal board operation.\nIf USB communication cable is connected Blue LED starts to blink faster. - brain_pin_e runningLedPin;+Green LED on many rusEFI boards.\nOff if engine is stopped, blinks if engine is cranking, solid if engine is running. - brain_pin_e binarySerialTxPin;See also EFI_CONSOLE_RX_BRAIN_PIN - brain_pin_e binarySerialRxPin; + Gpio communicationLedPin;+blue LED on many rusEFI boards.\nBlue Communication LED which is expected to blink at 50% duty cycle during normal board operation.\nIf USB communication cable is connected Blue LED starts to blink faster. + Gpio runningLedPin;+Green LED on many rusEFI boards.\nOff if engine is stopped, blinks if engine is cranking, solid if engine is running. + Gpio binarySerialTxPin;See also EFI_CONSOLE_RX_BRAIN_PIN + Gpio binarySerialRxPin; - brain_pin_e[AUX_DIGITAL_VALVE_COUNT iterate] auxValves + Gpio[AUX_DIGITAL_VALVE_COUNT iterate] auxValves switch_input_pin_e tcuUpshiftButtonPin switch_input_pin_e tcuDownshiftButtonPin @@ -1178,10 +1178,10 @@ int16_t tps2Max;Full throttle#2. tpsMax value as 10 bit ADC value. Not Voltage!\ int16_t iacByTpsTaper;+Extra IAC, in percent between 0 and 100, tapered between zero and idle deactivation TPS value;"percent", 1, 0, 0, 500, 0 - brain_pin_e auxSerialTxPin;Auxiliary sensor serial, not to be confused with secondary calibration serial\nset_aux_tx_pin X; - brain_pin_e warningLedPin; - brain_pin_e auxSerialRxPin;Auxiliary sensor serial, not to be confused with secondary calibration serial\nset_aux_rx_pin X; - brain_pin_e LIS302DLCsPin; + Gpio auxSerialTxPin;Auxiliary sensor serial, not to be confused with secondary calibration serial\nset_aux_tx_pin X; + Gpio warningLedPin; + Gpio auxSerialRxPin;Auxiliary sensor serial, not to be confused with secondary calibration serial\nset_aux_rx_pin X; + Gpio LIS302DLCsPin; uint8_t autoscale tpsAccelLookback;+How long to look back for TPS-based acceleration enrichment. Increasing this time will trigger enrichment for longer when a throttle position change occurs.;"sec", 0.05, 0, 0, 5, 2 @@ -1238,8 +1238,8 @@ int16_t tps2Max;Full throttle#2. tpsMax value as 10 bit ADC value. Not Voltage!\ uint8_t benchTestCount;;"count", 1, 0, 0, 250, 1 uint8_t autoscale benchTestOnTime;;"ms", 5, 0, 0, 2000, 1 pin_input_mode_e launchActivatePinMode; - brain_pin_e can2TxPin;set_can2_tx_pin X - brain_pin_e can2RxPin;set_can2_rx_pin X + Gpio can2TxPin;set_can2_tx_pin X + Gpio can2RxPin;set_can2_rx_pin X pin_output_mode_e starterControlPinMode; adc_channel_e wastegatePositionSensor; load_override_e ignOverrideMode;+Override the Y axis (load) value used for the ignition table.\nAdvanced users only: If you aren't sure you need this, you probably don't need this. @@ -1336,8 +1336,8 @@ custom stepper_num_micro_steps_e 1 bits, U08, @OFFSET@, [0:3], @@stepper_num_mic pin_mode_e spi3MisoMode; pin_output_mode_e stepperEnablePinMode; - brain_pin_e mc33816_rstb;ResetB - brain_pin_e mc33816_driven + Gpio mc33816_rstb;ResetB + Gpio mc33816_driven switch_input_pin_e brakePedalPin;Brake pedal switch adc_channel_e cj125ua;lambda input @@ -1366,15 +1366,15 @@ custom stepper_num_micro_steps_e 1 bits, U08, @OFFSET@, [0:3], @@stepper_num_mic float[SCRIPT_CURVE_8] scriptCurve4Bins;;"x", 1, 0, -999, 1000, 3 float[SCRIPT_CURVE_8] scriptCurve4;;"y", 1, 0, -999, 1000, 3 - brain_pin_e stepperEnablePin; - brain_pin_e tle8888_cs; + Gpio stepperEnablePin; + Gpio tle8888_cs; pin_output_mode_e tle8888_csPinMode; - brain_pin_e mc33816_cs; + Gpio mc33816_cs; float[CRANKING_ADVANCE_CURVE_SIZE] crankingAdvanceBins;+Optional timing advance table for Cranking (see useSeparateAdvanceForCranking);"RPM", 1, 0, 0, 18000, 2 float[CRANKING_ADVANCE_CURVE_SIZE] crankingAdvance ;+Optional timing advance table for Cranking (see useSeparateAdvanceForCranking);"deg", 1, 0, -20, 90, 2 - brain_pin_e[SERVO_COUNT iterate] servoOutputPins;todo: more comments + Gpio[SERVO_COUNT iterate] servoOutputPins;todo: more comments int16_t coastingFuelCutRpmHigh;+This sets the RPM above which fuel cut is active.;"rpm", 1, 0, 0, 5000, 0 int16_t coastingFuelCutRpmLow;+This sets the RPM below which fuel cut is deactivated, this prevents jerking or issues transitioning to idle;"rpm", 1, 0, 0, 5000, 0 diff --git a/firmware/util/efilib.h b/firmware/util/efilib.h index 2d9cb72f22..6b7bb22bbc 100644 --- a/firmware/util/efilib.h +++ b/firmware/util/efilib.h @@ -177,6 +177,23 @@ bool isInRange(T min, T val, T max) { return val >= min && val <= max; } +static constexpr size_t operator-(Gpio a, Gpio b) { + return (size_t)a - (size_t)b; +} + +static constexpr Gpio operator-(Gpio a, size_t b) { + return (Gpio)((size_t)a - b); +} + +static constexpr Gpio operator+(Gpio a, size_t b) { + return (Gpio)((size_t)a + b); +} + +static constexpr Gpio operator+(size_t a, Gpio b) { + // addition is commutative, just use the other operator + return b + a; +} + #endif /* __cplusplus */ #if defined(__cplusplus) && defined(__OPTIMIZE__) diff --git a/java_tools/ConfigDefinition.jar b/java_tools/ConfigDefinition.jar index ab0e34e7d1..6f7d7b2b2b 100644 Binary files a/java_tools/ConfigDefinition.jar and b/java_tools/ConfigDefinition.jar differ diff --git a/java_tools/configuration_definition/src/main/java/com/rusefi/PinType.java b/java_tools/configuration_definition/src/main/java/com/rusefi/PinType.java index acda271011..81a45f870d 100644 --- a/java_tools/configuration_definition/src/main/java/com/rusefi/PinType.java +++ b/java_tools/configuration_definition/src/main/java/com/rusefi/PinType.java @@ -1,10 +1,10 @@ package com.rusefi; public enum PinType { - OUTPUTS("output_pin_e_enum", "brain_pin_e", "GPIO_UNASSIGNED"), + OUTPUTS("output_pin_e_enum", "Gpio", "Unassigned"), ANALOG_INPUTS("adc_channel_e_enum", "adc_channel_e", "EFI_ADC_NONE"), - EVENT_INPUTS("brain_input_pin_e_enum", "brain_pin_e", "GPIO_UNASSIGNED"), - SWITCH_INPUTS("switch_input_pin_e_enum", "brain_pin_e", "GPIO_UNASSIGNED"); + EVENT_INPUTS("brain_input_pin_e_enum", "Gpio", "Unassigned"), + SWITCH_INPUTS("switch_input_pin_e_enum", "Gpio", "Unassigned"); private final String outputEnumName; diff --git a/java_tools/configuration_definition/src/main/java/com/rusefi/PinoutLogic.java b/java_tools/configuration_definition/src/main/java/com/rusefi/PinoutLogic.java index f199c917f0..5348b2a697 100644 --- a/java_tools/configuration_definition/src/main/java/com/rusefi/PinoutLogic.java +++ b/java_tools/configuration_definition/src/main/java/com/rusefi/PinoutLogic.java @@ -162,9 +162,9 @@ public class PinoutLogic { getTsNameByIdFile.append("\tswitch(brainPin) {\n"); for (Map.Entry e : tsNameById.entrySet()) { - if (!e.getKey().startsWith("GPIO")) // we only support GPIO pins at the moment no support for ADC + if (e.getKey().contains("ADC")) // we only support GPIO pins at the moment no support for ADC continue; - getTsNameByIdFile.append("\t\tcase " + e.getKey() + ": return " + quote(e.getValue()) + ";\n"); + getTsNameByIdFile.append("\t\tcase Gpio::" + e.getKey() + ": return " + quote(e.getValue()) + ";\n"); } getTsNameByIdFile.append("\t\tdefault: return nullptr;\n"); diff --git a/java_tools/enum_to_string/src/test/java/com/rusefi/EnumToStringTest.java b/java_tools/enum_to_string/src/test/java/com/rusefi/EnumToStringTest.java index 86d1211f35..b4e56099e7 100644 --- a/java_tools/enum_to_string/src/test/java/com/rusefi/EnumToStringTest.java +++ b/java_tools/enum_to_string/src/test/java/com/rusefi/EnumToStringTest.java @@ -36,31 +36,31 @@ public class EnumToStringTest { public void parseEnum() throws IOException { final StringReader reader = new StringReader( "typedef enum {\n" + - "\tGPIO_UNASSIGNED = 0,\n" + - "\tGPIO_INVALID = 1,\n" + + "\tGpio::Unassigned = 0,\n" + + "\tGpio::Invalid = 1,\n" + "\tGPIO_HEX = 0xA1,\n" + - "}brain_pin_e; // hello"); + "}Gpio; // hello"); EnumsReader enumsReader = new EnumsReader().read(reader); EnumToString enumToString = process(enumsReader); - List values = new ArrayList<>(enumsReader.getEnums().get("brain_pin_e").values.values()); + List values = new ArrayList<>(enumsReader.getEnums().get("Gpio").values.values()); assertEquals(3, values.size()); Value first = values.get(0); assertEquals("GPIO_HEX", first.getName()); assertEquals("0xA1", first.getValue()); Value second = values.get(1); - assertEquals("GPIO_INVALID", second.getName()); + assertEquals("Gpio::Invalid", second.getName()); assertEquals("1", second.getValue()); - assertEquals("const char *getBrain_pin_e(brain_pin_e value){\n" + + assertEquals("const char *getGpio(Gpio value){\n" + "switch(value) {\n" + "case GPIO_HEX:\n" + " return \"GPIO_HEX\";\n" + - "case GPIO_INVALID:\n" + - " return \"GPIO_INVALID\";\n" + - "case GPIO_UNASSIGNED:\n" + - " return \"GPIO_UNASSIGNED\";\n" + + "case Gpio::Invalid:\n" + + " return \"Gpio::Invalid\";\n" + + "case Gpio::Unassigned:\n" + + " return \"Gpio::Unassigned\";\n" + " }\n" + " return NULL;\n" + "}\n", enumToString.getCppFileContent()); @@ -70,17 +70,17 @@ public class EnumToStringTest { public void parsePackedEnum() throws IOException { final StringReader reader = new StringReader( "typedef enum __attribute__ ((__packed__)) {\n" + - "\tGPIO_UNASSIGNED = 0,\n" + - "\tGPIO_INVALID = 1,\n" + - "} brain_pin_e ;"); + "\tGpio::Unassigned = 0,\n" + + "\tGpio::Invalid = 1,\n" + + "} Gpio ;"); EnumsReader enumsReader = new EnumsReader().read(reader); EnumToString enumToString = process(enumsReader); - assertEquals("const char *getBrain_pin_e(brain_pin_e value){\n" + + assertEquals("const char *getGpio(Gpio value){\n" + "switch(value) {\n" + - "case GPIO_INVALID:\n" + - " return \"GPIO_INVALID\";\n" + - "case GPIO_UNASSIGNED:\n" + - " return \"GPIO_UNASSIGNED\";\n" + + "case Gpio::Invalid:\n" + + " return \"Gpio::Invalid\";\n" + + "case Gpio::Unassigned:\n" + + " return \"Gpio::Unassigned\";\n" + " }\n" + " return NULL;\n" + "}\n", enumToString.getCppFileContent()); @@ -90,17 +90,17 @@ public class EnumToStringTest { public void parsePackedFancyEnum() throws IOException { final StringReader reader = new StringReader( "enum class myEnum : uint8_t {\n" + - "\tGPIO_UNASSIGNED = 0,\n" + - "\tGPIO_INVALID = 1,\n" + - "} brain_pin_e ;"); + "\tGpio::Unassigned = 0,\n" + + "\tGpio::Invalid = 1,\n" + + "} Gpio ;"); EnumsReader enumsReader = new EnumsReader().read(reader); EnumToString enumToString = process(enumsReader); assertEquals("const char *getMyEnum(myEnum value){\n" + "switch(value) {\n" + - "case myEnum::GPIO_INVALID:\n" + - " return \"GPIO_INVALID\";\n" + - "case myEnum::GPIO_UNASSIGNED:\n" + - " return \"GPIO_UNASSIGNED\";\n" + + "case myEnum::Gpio::Invalid:\n" + + " return \"Gpio::Invalid\";\n" + + "case myEnum::Gpio::Unassigned:\n" + + " return \"Gpio::Unassigned\";\n" + " }\n" + " return NULL;\n" + "}\n", enumToString.getCppFileContent()); @@ -110,16 +110,16 @@ public class EnumToStringTest { public void parseEnumWithoutExplicitValues() throws IOException { final StringReader reader = new StringReader( "typedef enum {\n" + - "\tGPIO_UNASSIGNED,\n" + - "\tGPIO_INVALID,\n" + + "\tGpio::Unassigned,\n" + + "\tGpio::Invalid,\n" + "\tGPIO_HEX,\n" + - "}brain_pin_e; // hello"); + "}Gpio; // hello"); EnumsReader enumsReader = new EnumsReader().read(reader); - EnumsReader.EnumState brain_pin_e = enumsReader.getEnums().get("brain_pin_e"); - assertEquals(2, brain_pin_e.values.get("GPIO_HEX").getIntValue()); + EnumsReader.EnumState Gpio = enumsReader.getEnums().get("Gpio"); + assertEquals(2, Gpio.values.get("GPIO_HEX").getIntValue()); VariableRegistry registry = new VariableRegistry(); - List listByOrdinal = EnumsReader.getSortedByOrder(registry, brain_pin_e.values); + List listByOrdinal = EnumsReader.getSortedByOrder(registry, Gpio.values); assertEquals(0, listByOrdinal.get(0).getIntValue()); for (Map.Entry e : enumsReader.getEnums().entrySet()) { @@ -131,9 +131,9 @@ public class EnumToStringTest { "\n" + "\n" + "\n" + - "public enum brain_pin_e {\n" + - "\tGPIO_UNASSIGNED,\n" + - "\tGPIO_INVALID,\n" + + "public enum Gpio {\n" + + "\tGpio::Unassigned,\n" + + "\tGpio::Invalid,\n" + "\tGPIO_HEX,\n" + "}\n", a); } @@ -184,8 +184,8 @@ public class EnumToStringTest { public void testWithInput() throws IOException { final StringReader reader = new StringReader( "typedef enum {\n" + - "\tGPIO_UNASSIGNED = XXXX,\n" + - "}brain_pin_e; // hello"); + "\tGpio::Unassigned = XXXX,\n" + + "}Gpio; // hello"); VariableRegistry registry = new VariableRegistry(); registry.readPrependValues(new StringReader("#define XXXX 0")); @@ -198,8 +198,8 @@ public class EnumToStringTest { "\n" + "\n" + "\n" + - "public enum brain_pin_e {\n" + - "\tGPIO_UNASSIGNED,\n" + + "public enum Gpio {\n" + + "\tGpio::Unassigned,\n" + "}\n", java); } } @@ -208,8 +208,8 @@ public class EnumToStringTest { public void testWithInputOutOfOrder() throws IOException { final StringReader reader = new StringReader( "typedef enum {\n" + - "\tGPIO_UNASSIGNED = XXXX,\n" + - "}brain_pin_e; // hello"); + "\tGpio::Unassigned = XXXX,\n" + + "}Gpio; // hello"); VariableRegistry registry = new VariableRegistry(); registry.readPrependValues(new StringReader("#define XXXX 12")); @@ -222,8 +222,8 @@ public class EnumToStringTest { "\n" + "\n" + "\n" + - "public enum brain_pin_e {\n" + - "\tGPIO_UNASSIGNED,\n" + + "public enum Gpio {\n" + + "\tGpio::Unassigned,\n" + "}\n", java); } } @@ -233,10 +233,10 @@ public class EnumToStringTest { public void parseCommentedOutEnumWithoutExplicitValues() throws IOException { final StringReader reader = new StringReader( "typedef enum {\n" + - "\t//GPIO_UNASSIGNED,\n" + - "\tGPIO_INVALID,\n" + + "\t//Gpio::Unassigned,\n" + + "\tGpio::Invalid,\n" + "\tGPIO_HEX,\n" + - "}brain_pin_e; // hello"); + "}Gpio; // hello"); EnumsReader enumsReader = new EnumsReader().read(reader); VariableRegistry registry = new VariableRegistry(); @@ -250,8 +250,8 @@ public class EnumToStringTest { "\n" + "\n" + "\n" + - "public enum brain_pin_e {\n" + - "\tGPIO_INVALID,\n" + + "public enum Gpio {\n" + + "\tGpio::Invalid,\n" + "\tGPIO_HEX,\n" + "}\n", a); } diff --git a/unit_tests/tests/actuators/test_fuel_pump.cpp b/unit_tests/tests/actuators/test_fuel_pump.cpp index 10940c30e3..0562e21eb8 100644 --- a/unit_tests/tests/actuators/test_fuel_pump.cpp +++ b/unit_tests/tests/actuators/test_fuel_pump.cpp @@ -17,7 +17,7 @@ TEST(Actuators, FuelPump) { FuelPumpController dut; // Mock a fuel pump pin - engineConfiguration->fuelPumpPin = GPIOA_0; + engineConfiguration->fuelPumpPin = Gpio::A0; // Re-init so it picks up the new config enginePins.fuelPumpRelay.init(); @@ -26,14 +26,14 @@ TEST(Actuators, FuelPump) { dut.onIgnitionStateChanged(true); dut.onSlowCallback(); // Pump should be on! - EXPECT_TRUE(efiReadPin(GPIOA_0)); + EXPECT_TRUE(efiReadPin(Gpio::A0)); // Long time since ecu start, haven't seen trigger yet dut.onIgnitionStateChanged(true); timeNowUs += 10e6; dut.onSlowCallback(); // Pump should be off! - EXPECT_FALSE(efiReadPin(GPIOA_0)); + EXPECT_FALSE(efiReadPin(Gpio::A0)); // Long time since ecu start, just saw a trigger! dut.onIgnitionStateChanged(true); @@ -41,12 +41,12 @@ TEST(Actuators, FuelPump) { engine->triggerCentral.handleShaftSignal(SHAFT_PRIMARY_FALLING, timeNowUs * US_TO_NT_MULTIPLIER); dut.onSlowCallback(); // Pump should be on! - EXPECT_TRUE(efiReadPin(GPIOA_0)); + EXPECT_TRUE(efiReadPin(Gpio::A0)); // ECU just started, and we just saw a trigger! dut.onIgnitionStateChanged(true); engine->triggerCentral.handleShaftSignal(SHAFT_PRIMARY_FALLING, timeNowUs * US_TO_NT_MULTIPLIER); dut.onSlowCallback(); // Pump should be on! - EXPECT_TRUE(efiReadPin(GPIOA_0)); + EXPECT_TRUE(efiReadPin(Gpio::A0)); } diff --git a/unit_tests/tests/sensor/test_frequency_sensor.cpp b/unit_tests/tests/sensor/test_frequency_sensor.cpp index 27889fa816..66248ce5b6 100644 --- a/unit_tests/tests/sensor/test_frequency_sensor.cpp +++ b/unit_tests/tests/sensor/test_frequency_sensor.cpp @@ -22,7 +22,7 @@ public: void SetUp() override { // If somehow prodcode will be unwrapped for test it MAYBE! will fire with error. // At least we must init FlexSensor somehow - dut.initIfValid(GPIOA_0, identityFunc, 0.1f); + dut.initIfValid(Gpio::A0, identityFunc, 0.1f); } /* diff --git a/unit_tests/tests/test_change_engine_type.cpp b/unit_tests/tests/test_change_engine_type.cpp index ef664c833b..65d6f40218 100644 --- a/unit_tests/tests/test_change_engine_type.cpp +++ b/unit_tests/tests/test_change_engine_type.cpp @@ -16,8 +16,8 @@ TEST(misc, changeEngineType) { EngineTestHelper eth (FORD_ASPIRE_1996); brain_pin_e brainPin = engineConfiguration->triggerInputDebugPins[0]; - ASSERT_TRUE(brainPin != GPIO_UNASSIGNED); - ASSERT_TRUE(activeConfiguration.triggerInputDebugPins[0] != GPIO_UNASSIGNED); + ASSERT_TRUE(brainPin != Gpio::Unassigned); + ASSERT_TRUE(activeConfiguration.triggerInputDebugPins[0] != Gpio::Unassigned); int pinIndex = brainPin_to_index(brainPin); ASSERT_TRUE(nullptr != getBrainUsedPin(pinIndex)); @@ -26,10 +26,10 @@ TEST(misc, changeEngineType) { // now let's change into engine type without triggerInputDebugPins and assert shut down setEngineType((int)CITROEN_TU3JP); - ASSERT_TRUE(activeConfiguration.triggerInputDebugPins[0] == GPIO_UNASSIGNED); + ASSERT_TRUE(activeConfiguration.triggerInputDebugPins[0] == Gpio::Unassigned); - ASSERT_TRUE(engineConfiguration->triggerInputDebugPins[0] == GPIO_UNASSIGNED); - ASSERT_TRUE(engineConfiguration->triggerInputDebugPins[0] == GPIO_UNASSIGNED); + ASSERT_TRUE(engineConfiguration->triggerInputDebugPins[0] == Gpio::Unassigned); + ASSERT_TRUE(engineConfiguration->triggerInputDebugPins[0] == Gpio::Unassigned); ASSERT_TRUE(nullptr == getBrainUsedPin(pinIndex)); } diff --git a/unit_tests/tests/test_gpio.cpp b/unit_tests/tests/test_gpio.cpp index 7ba52a6d9b..47c578c819 100644 --- a/unit_tests/tests/test_gpio.cpp +++ b/unit_tests/tests/test_gpio.cpp @@ -6,14 +6,14 @@ TEST(gpio, testPinInitNonInverted) { OutputPin dut; // Set the "hardware" pin to on initially - setMockState(GPIOA_6, true); - ASSERT_TRUE(efiReadPin(GPIOA_6)); + setMockState(Gpio::A6, true); + ASSERT_TRUE(efiReadPin(Gpio::A6)); // this should turn it off pin_output_mode_e mode = OM_DEFAULT; - dut.initPin("test", GPIOA_6, &mode); + dut.initPin("test", Gpio::A6, &mode); - EXPECT_FALSE(efiReadPin(GPIOA_6)); + EXPECT_FALSE(efiReadPin(Gpio::A6)); } TEST(gpio, testPinInitInverted) { @@ -22,56 +22,56 @@ TEST(gpio, testPinInitInverted) { OutputPin dut; // Set the "hardware" pin to off initially - setMockState(GPIOA_6, false); - ASSERT_FALSE(efiReadPin(GPIOA_6)); + setMockState(Gpio::A6, false); + ASSERT_FALSE(efiReadPin(Gpio::A6)); // this should turn it off pin_output_mode_e mode = OM_INVERTED; - dut.initPin("test", GPIOA_6, &mode); + dut.initPin("test", Gpio::A6, &mode); - EXPECT_TRUE(efiReadPin(GPIOA_6)); + EXPECT_TRUE(efiReadPin(Gpio::A6)); } TEST(gpio, multipleInit) { OutputPin dut; // Initial setup should be ok - EXPECT_NO_FATAL_ERROR(dut.initPin("testPin", GPIOA_6)); + EXPECT_NO_FATAL_ERROR(dut.initPin("testPin", Gpio::A6)); // Reinit with the same pin should be ok - EXPECT_NO_FATAL_ERROR(dut.initPin("testPin", GPIOA_6)); + EXPECT_NO_FATAL_ERROR(dut.initPin("testPin", Gpio::A6)); // Reinit with DIFFERENT pin should fail - EXPECT_FATAL_ERROR(dut.initPin("testPin", GPIOB_5)); + EXPECT_FATAL_ERROR(dut.initPin("testPin", Gpio::B5)); } TEST(gpio, deInit) { OutputPin dut; // Initial setup should be ok - EXPECT_NO_FATAL_ERROR(dut.initPin("testPin", GPIOA_6)); + EXPECT_NO_FATAL_ERROR(dut.initPin("testPin", Gpio::A6)); dut.deInit(); // Reinit with DIFFERENT pin should work after deinit - EXPECT_NO_FATAL_ERROR(dut.initPin("testPin", GPIOB_5)); + EXPECT_NO_FATAL_ERROR(dut.initPin("testPin", Gpio::B5)); } TEST(gpio, pinSetNotInverted) { OutputPin dut; pin_output_mode_e mode = OM_DEFAULT; - dut.initPin("test", GPIOA_6, &mode); + dut.initPin("test", Gpio::A6, &mode); // Initial state should be logic 0 - EXPECT_FALSE(efiReadPin(GPIOA_6)); + EXPECT_FALSE(efiReadPin(Gpio::A6)); dut.setValue(true); - EXPECT_TRUE(efiReadPin(GPIOA_6)); + EXPECT_TRUE(efiReadPin(Gpio::A6)); EXPECT_TRUE(dut.getLogicValue()); dut.setValue(false); - EXPECT_FALSE(efiReadPin(GPIOA_6)); + EXPECT_FALSE(efiReadPin(Gpio::A6)); EXPECT_FALSE(dut.getLogicValue()); } @@ -79,16 +79,16 @@ TEST(gpio, pinSetInverted) { OutputPin dut; pin_output_mode_e mode = OM_INVERTED; - dut.initPin("test", GPIOA_6, &mode); + dut.initPin("test", Gpio::A6, &mode); // Initial state should be logic 0 - EXPECT_TRUE(efiReadPin(GPIOA_6)); + EXPECT_TRUE(efiReadPin(Gpio::A6)); dut.setValue(true); - EXPECT_FALSE(efiReadPin(GPIOA_6)); + EXPECT_FALSE(efiReadPin(Gpio::A6)); EXPECT_TRUE(dut.getLogicValue()); dut.setValue(false); - EXPECT_TRUE(efiReadPin(GPIOA_6)); + EXPECT_TRUE(efiReadPin(Gpio::A6)); EXPECT_FALSE(dut.getLogicValue()); } diff --git a/unit_tests/tests/test_gpiochip.cpp b/unit_tests/tests/test_gpiochip.cpp index 7f6eceb65c..65e2cd0250 100644 --- a/unit_tests/tests/test_gpiochip.cpp +++ b/unit_tests/tests/test_gpiochip.cpp @@ -95,24 +95,24 @@ TEST(gpioext, testGpioExt) { EXPECT_EQ(2, initcalls); /* gpio reads */ - EXPECT_TRUE(gpiochips_readPad((brain_pin_e)(chip1_base + 0)) == 0); - EXPECT_TRUE(gpiochips_readPad((brain_pin_e)(chip1_base + 1)) != 0); + EXPECT_TRUE(gpiochips_readPad((Gpio)(chip1_base + 0)) == 0); + EXPECT_TRUE(gpiochips_readPad((Gpio)(chip1_base + 1)) != 0); /* gpio write */ - gpiochips_writePad((brain_pin_e)(chip2_base + 0), 0); - gpiochips_writePad((brain_pin_e)(chip2_base + 1), 1); + gpiochips_writePad((Gpio)(chip2_base + 0), 0); + gpiochips_writePad((Gpio)(chip2_base + 1), 1); EXPECT_EQ(0x02, io_state); /* try to access failed chip */ - EXPECT_FALSE(gpiochips_writePad((brain_pin_e)(chip3_base + 0), 0) >= 0); - EXPECT_FALSE(gpiochips_writePad((brain_pin_e)(chip3_base + 1), 1) >= 0); + EXPECT_FALSE(gpiochips_writePad((Gpio)(chip3_base + 0), 0) >= 0); + EXPECT_FALSE(gpiochips_writePad((Gpio)(chip3_base + 1), 1) >= 0); EXPECT_EQ(0, calls_to_failed_chip); /* read/write outside range */ - EXPECT_TRUE(gpiochips_readPad((brain_pin_e)(chip1_base - 1)) < 0); - EXPECT_TRUE(gpiochips_writePad((brain_pin_e)(chip1_base - 1), 1) < 0); + EXPECT_TRUE(gpiochips_readPad((Gpio)(chip1_base - 1)) < 0); + EXPECT_TRUE(gpiochips_writePad((Gpio)(chip1_base - 1), 1) < 0); - EXPECT_TRUE(gpiochips_readPad((brain_pin_e)(chip3_base + 16)) < 0); - EXPECT_TRUE(gpiochips_writePad((brain_pin_e)(chip3_base + 16), 1) < 0); + EXPECT_TRUE(gpiochips_readPad((Gpio)(chip3_base + 16)) < 0); + EXPECT_TRUE(gpiochips_writePad((Gpio)(chip3_base + 16), 1) < 0); } diff --git a/unit_tests/tests/test_hpfp.cpp b/unit_tests/tests/test_hpfp.cpp index db44188124..35e1593b88 100755 --- a/unit_tests/tests/test_hpfp.cpp +++ b/unit_tests/tests/test_hpfp.cpp @@ -268,7 +268,7 @@ TEST(HPFP, Schedule) { // This will call the fast callback routine engine->rpmCalculator.setRpmValue(1000); engine->injectionMass[0] = 0.05 /* cc/cyl */ * fuelDensity; - engineConfiguration->hpfpValvePin = GPIOA_2; // arbitrary + engineConfiguration->hpfpValvePin = Gpio::A2; // arbitrary hpfp.onFastCallback(); // First event was scheduled by setRpmValue with 0 injection mass. So, it's off. diff --git a/unit_tests/tests/test_hpfp_integrated.cpp b/unit_tests/tests/test_hpfp_integrated.cpp index e0c97126e4..ee680a0d32 100644 --- a/unit_tests/tests/test_hpfp_integrated.cpp +++ b/unit_tests/tests/test_hpfp_integrated.cpp @@ -9,7 +9,7 @@ TEST(HPFP, IntegratedSchedule) { EngineTestHelper eth(TEST_ENGINE, [](engine_configuration_s* engineConfiguration) { - engineConfiguration->hpfpValvePin = GPIOA_2; // arbitrary + engineConfiguration->hpfpValvePin = Gpio::A2; // arbitrary }); engineConfiguration->specs.cylindersCount = 4; diff --git a/unit_tests/tests/test_launch.cpp b/unit_tests/tests/test_launch.cpp index 5d9d01168a..0ad4fb2268 100644 --- a/unit_tests/tests/test_launch.cpp +++ b/unit_tests/tests/test_launch.cpp @@ -63,7 +63,7 @@ TEST(LaunchControl, SwitchInputCondition) { //active by switch engineConfiguration->launchActivationMode = SWITCH_INPUT_LAUNCH; - engineConfiguration->launchActivatePin = GPIOG_1; + engineConfiguration->launchActivatePin = Gpio::G1; setMockState(engineConfiguration->launchActivatePin, true); EXPECT_TRUE(dut.isInsideSwitchCondition()); @@ -72,7 +72,7 @@ TEST(LaunchControl, SwitchInputCondition) { //by clutch engineConfiguration->launchActivationMode = CLUTCH_INPUT_LAUNCH; - engineConfiguration->clutchDownPin = GPIOG_2; + engineConfiguration->clutchDownPin = Gpio::G2; engineConfiguration->clutchDownPinMode = PI_PULLUP; setMockState(engineConfiguration->clutchDownPin, true); engine->updateSwitchInputs(); diff --git a/unit_tests/tests/trigger/test_cam_vvt_input.cpp b/unit_tests/tests/trigger/test_cam_vvt_input.cpp index 16620084e9..d0ebc78553 100644 --- a/unit_tests/tests/trigger/test_cam_vvt_input.cpp +++ b/unit_tests/tests/trigger/test_cam_vvt_input.cpp @@ -89,7 +89,7 @@ TEST(trigger, testCamInput) { engineConfiguration->vvtMode[0] = VVT_FIRST_HALF; engineConfiguration->vvtOffsets[0] = 360; eth.setTriggerType(TT_ONE); - engineConfiguration->camInputs[0] = GPIOA_10; // we just need to indicate that we have CAM + engineConfiguration->camInputs[0] = Gpio::A10; // we just need to indicate that we have CAM ASSERT_EQ( 0, round(Sensor::getOrZero(SensorType::Rpm))) << "testCamInput RPM"; diff --git a/unit_tests/tests/trigger/test_map_cam.cpp b/unit_tests/tests/trigger/test_map_cam.cpp index 55a39d9ede..31679a1e6e 100644 --- a/unit_tests/tests/trigger/test_map_cam.cpp +++ b/unit_tests/tests/trigger/test_map_cam.cpp @@ -9,7 +9,7 @@ TEST(trigger, map_cam_by_magic_point) { EngineTestHelper eth(TEST_CRANK_ENGINE); engineConfiguration->isFasterEngineSpinUpEnabled = false; - engineConfiguration->camInputs[0] = GPIOA_0; + engineConfiguration->camInputs[0] = Gpio::A0; engineConfiguration->vvtMode[0] = VVT_MAP_V_TWIN_ANOTHER; eth.engine.periodicFastCallback(); // trigger limp mode ASSERT_FALSE(eth.engine.limpManager.allowIgnition()); diff --git a/unit_tests/tests/trigger/test_quad_cam.cpp b/unit_tests/tests/trigger/test_quad_cam.cpp index 8df5f0ed02..5e7760ddc1 100644 --- a/unit_tests/tests/trigger/test_quad_cam.cpp +++ b/unit_tests/tests/trigger/test_quad_cam.cpp @@ -17,7 +17,7 @@ TEST(trigger, testQuadCam) { engineConfiguration->vvtMode[0] = VVT_FIRST_HALF; engineConfiguration->vvtMode[1] = VVT_FIRST_HALF; - engineConfiguration->camInputs[0] = GPIOA_10; // we just need to indicate that we have CAM + engineConfiguration->camInputs[0] = Gpio::A10; // we just need to indicate that we have CAM // this crank trigger would be easier to test, crank shape is less important for this test eth.setTriggerType(TT_ONE);