2021-10-02 21:59:34 -07:00
|
|
|
/*
|
|
|
|
* hellen_meta.h
|
|
|
|
*
|
|
|
|
* @date Oct 2, 2021
|
|
|
|
* @author Andrey Belomutskiy, (c) 2012-2021
|
|
|
|
*/
|
|
|
|
|
|
|
|
#pragma once
|
|
|
|
|
2023-03-25 12:06:31 -07:00
|
|
|
// see https://github.com/andreika-git/hellen-one/blob/master/board_id/board_ids.csv
|
2022-09-13 15:13:58 -07:00
|
|
|
#define BOARD_ID_154hyundai_c 10
|
2023-05-07 21:56:43 -07:00
|
|
|
#define BOARD_ID_154hyundai_d 201
|
|
|
|
|
2023-08-08 16:48:52 -07:00
|
|
|
#define BOARD_ID_2chan_b 3
|
|
|
|
#define BOARD_ID_2chan_c 5
|
2023-02-13 11:10:38 -08:00
|
|
|
#define BOARD_ID_2chan_d 107
|
2023-08-08 16:48:52 -07:00
|
|
|
// mega-module starts here
|
2023-03-25 12:06:31 -07:00
|
|
|
#define BOARD_ID_2chan_e 112
|
|
|
|
#define BOARD_ID_2chan_f 115
|
2023-08-08 16:48:52 -07:00
|
|
|
#define BOARD_ID_2chan_g 210
|
2022-09-13 15:13:58 -07:00
|
|
|
|
2023-05-07 06:59:52 -07:00
|
|
|
#define BOARD_ID_4chan_d 103
|
|
|
|
#define BOARD_ID_4chan_e 105
|
|
|
|
#define BOARD_ID_4chan_f 113
|
|
|
|
#define BOARD_ID_4chan_g 203
|
2023-05-07 22:05:41 -07:00
|
|
|
#define BOARD_ID_4chan_h 114
|
2023-05-07 06:59:52 -07:00
|
|
|
|
2022-01-08 17:13:15 -08:00
|
|
|
void hellenWbo();
|
|
|
|
|
2023-02-13 10:16:52 -08:00
|
|
|
void setHellenMegaEnPin();
|
2023-07-28 21:02:05 -07:00
|
|
|
void setHellenEnPin(Gpio pin);
|
2023-06-10 19:02:04 -07:00
|
|
|
void setHellen64MegaEnPin();
|
2023-05-13 14:08:55 -07:00
|
|
|
void hellenBoardStandBy();
|
2023-02-27 09:43:47 -08:00
|
|
|
void configureHellenMegaAccCS2Pin();
|
2023-05-09 16:33:47 -07:00
|
|
|
void configureHellenCanTerminator();
|
2022-01-09 14:40:08 -08:00
|
|
|
|
2022-09-29 21:37:05 -07:00
|
|
|
void setHellenCan();
|
2023-06-10 19:02:04 -07:00
|
|
|
void setHellen64Can();
|
2022-09-29 21:37:05 -07:00
|
|
|
|
2022-02-03 08:24:31 -08:00
|
|
|
int detectHellenBoardId();
|
2022-01-09 14:40:08 -08:00
|
|
|
void detectHellenBoardType();
|
|
|
|
|
2023-06-10 19:02:04 -07:00
|
|
|
#define H64_LED1_RED Gpio::B0
|
|
|
|
#define H64_LED2_BLUE Gpio::B1
|
|
|
|
|
2023-09-09 17:10:25 -07:00
|
|
|
#define H64_IO1 C13
|
|
|
|
#define H64_SPI1_CS1 D2
|
2023-06-10 19:02:04 -07:00
|
|
|
|
2023-09-09 17:10:25 -07:00
|
|
|
#define H64_OUT_PWM1 B7
|
2023-09-02 18:14:06 -07:00
|
|
|
#define H64_OUT_PWM2 C8
|
2023-09-09 17:10:25 -07:00
|
|
|
#define H64_OUT_PWM3 C9
|
2023-09-02 18:14:06 -07:00
|
|
|
#define H64_OUT_PWM4 A8
|
2023-09-09 17:10:25 -07:00
|
|
|
#define H64_OUT_PWM5 A9
|
|
|
|
#define H64_OUT_PWM6 A15
|
2023-06-10 20:44:31 -07:00
|
|
|
|
2022-01-16 19:57:52 -08:00
|
|
|
// stm32 UART8
|
2022-04-28 14:32:39 -07:00
|
|
|
#define H144_UART1_RX Gpio::E0
|
|
|
|
#define H144_UART1_TX Gpio::E1
|
2022-01-16 19:57:52 -08:00
|
|
|
|
|
|
|
// stm32 UART2
|
2022-04-28 14:32:39 -07:00
|
|
|
#define H144_UART2_RX Gpio::D6
|
|
|
|
#define H144_UART2_TX Gpio::D5
|
|
|
|
|
|
|
|
#define H144_LED1_RED Gpio::G0
|
|
|
|
#define H144_LED2 Gpio::G1
|
|
|
|
#define H144_LED3 Gpio::E7
|
|
|
|
#define H144_LED4 Gpio::E8
|
|
|
|
|
2023-03-27 05:57:01 -07:00
|
|
|
#define H144_USB1ID Gpio::A10
|
|
|
|
|
2022-04-28 14:32:39 -07:00
|
|
|
#define H176_LED1_RED Gpio::H8
|
|
|
|
|
2023-08-27 18:55:55 -07:00
|
|
|
#define H144_LS_1 G7
|
|
|
|
#define H144_LS_2 G8
|
|
|
|
#define H144_LS_3 D11
|
|
|
|
#define H144_LS_4 D10
|
|
|
|
#define H144_LS_5 D9
|
|
|
|
#define H144_LS_6 F12
|
|
|
|
#define H144_LS_7 F13
|
|
|
|
#define H144_LS_8 F14
|
|
|
|
|
|
|
|
#define H144_IGN_1 C13
|
|
|
|
#define H144_IGN_2 E5
|
|
|
|
#define H144_IGN_3 E4
|
|
|
|
#define H144_IGN_4 E3
|
|
|
|
#define H144_IGN_5 E2
|
|
|
|
#define H144_IGN_6 B8
|
|
|
|
#define H144_IGN_7 B9
|
|
|
|
#define H144_IGN_8 E6
|
2022-05-22 21:20:41 -07:00
|
|
|
|
|
|
|
#define H176_IGN_1 Gpio::I8
|
|
|
|
#define H176_IGN_2 Gpio::E5
|
|
|
|
#define H176_IGN_3 Gpio::E4
|
|
|
|
#define H176_IGN_4 Gpio::E3
|
|
|
|
#define H176_IGN_5 Gpio::E2
|
2022-04-28 14:32:39 -07:00
|
|
|
|
2023-08-27 18:55:55 -07:00
|
|
|
#define H144_OUT_PWM1 D13
|
2023-08-27 20:10:13 -07:00
|
|
|
#define H144_OUT_PWM2 C6
|
2023-08-27 18:55:55 -07:00
|
|
|
#define H144_OUT_PWM3 C7
|
2023-08-27 20:10:13 -07:00
|
|
|
#define H144_OUT_PWM4 C8
|
|
|
|
#define H144_OUT_PWM5 C9
|
|
|
|
#define H144_OUT_PWM6 D14
|
|
|
|
#define H144_OUT_PWM7 D15
|
|
|
|
#define H144_OUT_PWM8 D12
|
2021-10-09 13:51:07 -07:00
|
|
|
|
|
|
|
|
2022-03-30 12:55:42 -07:00
|
|
|
// also IO1/IO5 on rev 0.6
|
2022-04-28 14:32:39 -07:00
|
|
|
#define H144_GP1 Gpio::D4
|
2022-03-30 12:55:42 -07:00
|
|
|
// also IO2/IO5 on rev 0.6
|
2022-04-28 14:32:39 -07:00
|
|
|
#define H144_GP2 Gpio::D7
|
2023-08-27 18:55:55 -07:00
|
|
|
#define H144_GP3 G10
|
2023-01-02 08:30:40 -08:00
|
|
|
#define H144_GP4 Gpio::G9
|
|
|
|
#define H144_GP5 Gpio::G15
|
|
|
|
#define H144_GP6 Gpio::D8
|
|
|
|
#define H144_GP7 Gpio::F15
|
|
|
|
#define H144_GP8 Gpio::E10
|
|
|
|
#define H144_GP9 Gpio::F2
|
2022-04-28 14:32:39 -07:00
|
|
|
|
2023-08-27 20:10:13 -07:00
|
|
|
#define H144_OUT_IO1 D3
|
|
|
|
#define H144_OUT_IO2 A9
|
|
|
|
#define H144_OUT_IO3 G14
|
|
|
|
#define H144_OUT_IO4 G5
|
|
|
|
#define H144_OUT_IO5 D2
|
2023-08-27 18:55:55 -07:00
|
|
|
#define H144_OUT_IO6 G11
|
2023-08-27 20:10:13 -07:00
|
|
|
#define H144_OUT_IO7 G3
|
|
|
|
#define H144_OUT_IO8 G4
|
|
|
|
#define H144_OUT_IO9 G13
|
2023-08-27 18:55:55 -07:00
|
|
|
#define H144_OUT_IO10 G12
|
|
|
|
#define H144_OUT_IO11 G2
|
|
|
|
#define H144_OUT_IO12 A8
|
|
|
|
#define H144_OUT_IO13 G6
|
2021-10-09 13:24:38 -07:00
|
|
|
|
2021-10-10 18:46:26 -07:00
|
|
|
// A24
|
2023-09-02 18:14:06 -07:00
|
|
|
#define H144_IN_CRANK B1
|
2022-06-08 09:33:37 -07:00
|
|
|
#define H144_IN_CRANK_ANALOG EFI_ADC_9
|
2021-10-10 18:46:26 -07:00
|
|
|
// A19
|
2023-09-02 18:14:06 -07:00
|
|
|
#define H144_IN_CAM A6
|
2022-06-08 09:33:37 -07:00
|
|
|
#define H144_IN_CAM_ANALOG EFI_ADC_6
|
2021-10-10 18:46:26 -07:00
|
|
|
// DIN5
|
2023-09-02 18:14:06 -07:00
|
|
|
#define H144_IN_VSS F11
|
2021-10-10 18:46:26 -07:00
|
|
|
|
2021-10-09 20:34:33 -07:00
|
|
|
// IN_CLT AIN11 PC2
|
|
|
|
#define H144_IN_CLT EFI_ADC_12
|
2022-01-09 07:56:16 -08:00
|
|
|
// IN_IAT AIN14 PC3
|
2021-10-09 20:34:33 -07:00
|
|
|
#define H144_IN_IAT EFI_ADC_13
|
|
|
|
|
2022-01-09 07:56:16 -08:00
|
|
|
// IN_PPS AIN18 PA3
|
2021-10-16 15:19:30 -07:00
|
|
|
#define H144_IN_PPS EFI_ADC_3
|
2022-01-16 13:15:12 -08:00
|
|
|
// IN_TPS AIN17 PA4
|
|
|
|
#define H144_IN_TPS EFI_ADC_4
|
|
|
|
// VIGN PA5
|
|
|
|
#define H144_IN_VBATT EFI_ADC_5
|
2021-10-16 15:19:30 -07:00
|
|
|
|
2023-04-18 13:57:43 -07:00
|
|
|
// muxed
|
|
|
|
#define H144_IN_TPS2 EFI_ADC_20
|
|
|
|
|
2021-10-12 17:53:00 -07:00
|
|
|
// IN_MAP1 AIN9 PC0
|
|
|
|
#define H144_IN_MAP1 EFI_ADC_10
|
2021-11-09 12:33:01 -08:00
|
|
|
// AIN10 PC1
|
|
|
|
#define H144_IN_MAP2 EFI_ADC_11
|
2022-01-12 10:34:21 -08:00
|
|
|
// AIN15 A15 PA2
|
|
|
|
#define H144_IN_MAP3 EFI_ADC_2
|
2023-03-11 11:47:12 -08:00
|
|
|
#define H144_IN_MAP3_DIGITAL Gpio::A2
|
2021-10-12 17:53:00 -07:00
|
|
|
|
2021-12-17 10:51:46 -08:00
|
|
|
// AIN7
|
2023-09-03 19:56:30 -07:00
|
|
|
#define H144_IN_RES1 F9
|
2021-12-17 10:51:46 -08:00
|
|
|
|
|
|
|
// AIN16
|
2023-09-03 19:56:30 -07:00
|
|
|
#define H144_IN_RES2 F10
|
2022-12-18 13:56:43 -08:00
|
|
|
#define H144_ADC_IN_RES2 ADC_CHANNEL_IN8
|
2021-12-17 10:51:46 -08:00
|
|
|
|
|
|
|
// AIN8
|
2023-09-03 19:56:30 -07:00
|
|
|
#define H144_IN_RES3 F8
|
2022-12-18 13:56:43 -08:00
|
|
|
#define H144_ADC_IN_RES3 ADC_CHANNEL_IN6
|
2021-12-17 10:51:46 -08:00
|
|
|
|
|
|
|
|
2021-10-09 20:34:33 -07:00
|
|
|
#define H144_IN_AUX1 EFI_ADC_8
|
|
|
|
//
|
|
|
|
#define H144_IN_AUX2 EFI_ADC_14
|
|
|
|
|
2021-11-09 12:33:01 -08:00
|
|
|
// AIN22 PC5
|
|
|
|
#define H144_IN_AUX3 EFI_ADC_15
|
|
|
|
// AIN20 PA7
|
|
|
|
#define H144_IN_AUX4 EFI_ADC_7
|
|
|
|
|
2021-12-16 13:13:59 -08:00
|
|
|
// A1 AIN1 no code to use ADC3 as analog
|
2023-09-04 13:44:41 -07:00
|
|
|
#define H144_IN_SENS1 F3
|
2021-12-16 13:13:59 -08:00
|
|
|
// A2 AIN2 no code to use ADC3 as analog
|
2023-09-02 18:14:06 -07:00
|
|
|
#define H144_IN_SENS2 F4
|
2021-12-16 13:13:59 -08:00
|
|
|
// A3 AIN3 no code to use ADC3 as analog
|
2023-09-02 18:14:06 -07:00
|
|
|
#define H144_IN_SENS3 F5
|
2021-12-16 13:13:59 -08:00
|
|
|
// A4 AIN4 no code to use ADC3 as analog
|
2023-09-02 18:14:06 -07:00
|
|
|
#define H144_IN_SENS4 F6
|
2021-12-16 13:13:59 -08:00
|
|
|
|
2022-04-07 00:24:23 -07:00
|
|
|
// IN_O2S AIN13 A13 PA0
|
|
|
|
#define H144_IN_O2S EFI_ADC_0
|
2022-01-09 07:56:16 -08:00
|
|
|
// IN_O2S2 AIN12 PA1
|
2021-10-12 17:53:00 -07:00
|
|
|
#define H144_IN_O2S2 EFI_ADC_1
|
|
|
|
|
2023-05-15 12:04:52 -07:00
|
|
|
// IN_D1(old) or IN_DIG8(new/mega-module)
|
2023-09-02 18:14:06 -07:00
|
|
|
#define H144_IN_D_1 E12
|
2023-05-15 12:04:52 -07:00
|
|
|
// IN_D2(old) or IN_DIG9(new/mm)
|
2023-09-02 19:29:58 -07:00
|
|
|
#define H144_IN_D_2 E13
|
2023-01-29 16:20:51 -08:00
|
|
|
// IN_D3(old) or IN_DIG10(new)
|
2023-09-02 18:14:06 -07:00
|
|
|
#define H144_IN_D_3 E14
|
2023-01-29 16:20:51 -08:00
|
|
|
// IN_D4(old) or IN_DIG11(new)
|
2023-09-02 19:29:58 -07:00
|
|
|
#define H144_IN_D_4 E15
|
2022-01-09 07:56:16 -08:00
|
|
|
|
2021-10-11 21:02:49 -07:00
|
|
|
// A22
|
2023-09-02 19:35:50 -07:00
|
|
|
#define H144_IN_D_AUX3 C5
|
2021-10-17 11:21:09 -07:00
|
|
|
// A20 AIN20
|
2023-09-02 19:35:50 -07:00
|
|
|
#define H144_IN_D_AUX4 A7
|
2021-10-10 18:46:26 -07:00
|
|
|
|
2022-04-28 14:32:39 -07:00
|
|
|
#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
|
2021-10-02 21:59:34 -07:00
|
|
|
|
2022-04-28 14:32:39 -07:00
|
|
|
#define H176_OUT_PWM1 Gpio::D13
|
|
|
|
#define H176_OUT_PWM2 Gpio::C6
|
|
|
|
#define H176_OUT_PWM3 Gpio::C7
|
2021-10-07 14:35:27 -07:00
|
|
|
|
2022-04-28 14:32:39 -07:00
|
|
|
#define H176_OUT_IO6 Gpio::H15
|
|
|
|
#define H176_OUT_IO9 Gpio::I1
|
|
|
|
#define H176_OUT_IO10 Gpio::I0
|
2021-10-07 14:48:01 -07:00
|
|
|
|
2021-10-09 13:51:07 -07:00
|
|
|
// same pins 144 and 176
|
2022-04-28 14:32:39 -07:00
|
|
|
#define H176_CAN_RX Gpio::D0
|
|
|
|
#define H176_CAN_TX Gpio::D1
|
2021-10-07 16:16:28 -07:00
|
|
|
|
2022-04-28 14:32:39 -07:00
|
|
|
#define H176_IN_A16 Gpio::F10
|
2021-10-17 20:15:23 -07:00
|
|
|
|
2022-12-07 07:14:10 -08:00
|
|
|
#define H_SPI1_MOSI Gpio::B5
|
|
|
|
#define H_SPI1_MISO Gpio::B4
|
|
|
|
#define H_SPI1_SCK Gpio::B3
|
|
|
|
#define H_SPI1_CS1 Gpio::B6
|
|
|
|
#define H_SPI1_CS2 Gpio::B7
|
2021-10-17 20:15:23 -07:00
|
|
|
|
|
|
|
// looks like same pins 144 and 176
|
2022-04-28 14:32:39 -07:00
|
|
|
#define H_SPI2_MOSI Gpio::B15
|
|
|
|
#define H_SPI2_MISO Gpio::B14
|
|
|
|
#define H_SPI2_SCK Gpio::B13
|
|
|
|
#define H_SPI2_CS Gpio::B12
|
2022-06-07 14:21:51 -07:00
|
|
|
|
|
|
|
#define H_SPI3_MOSI Gpio::C12
|
|
|
|
#define H_SPI3_MISO Gpio::C11
|
|
|
|
#define H_SPI3_SCK Gpio::C10
|
|
|
|
#define H_SPI3_CS Gpio::A15
|
2022-06-23 12:02:13 -07:00
|
|
|
|
2023-06-10 19:02:04 -07:00
|
|
|
static void setHellenSdCardSpi1NoCS() {
|
2023-02-27 08:07:00 -08:00
|
|
|
engineConfiguration->isSdCardEnabled = true;
|
2023-02-13 11:10:38 -08:00
|
|
|
engineConfiguration->sdCardSpiDevice = SPI_DEVICE_1;
|
|
|
|
engineConfiguration->spi1mosiPin = H_SPI1_MOSI;
|
|
|
|
engineConfiguration->spi1misoPin = H_SPI1_MISO;
|
|
|
|
engineConfiguration->spi1sckPin = H_SPI1_SCK;
|
|
|
|
engineConfiguration->is_enabled_spi_1 = true;
|
|
|
|
}
|
|
|
|
|
2023-06-10 19:02:04 -07:00
|
|
|
static void setHellenSdCardSpi1() {
|
|
|
|
setHellenSdCardSpi1NoCS();
|
|
|
|
engineConfiguration->sdCardCsPin = H_SPI1_CS1;
|
|
|
|
}
|
|
|
|
|
|
|
|
static void setHellen64SdCardSpi1() {
|
|
|
|
setHellenSdCardSpi1NoCS();
|
2023-09-09 17:10:25 -07:00
|
|
|
engineConfiguration->sdCardCsPin = Gpio::H64_SPI1_CS1;
|
2023-06-10 19:02:04 -07:00
|
|
|
}
|
|
|
|
|
2022-06-23 12:02:13 -07:00
|
|
|
static void setHellenSdCardSpi2() {
|
2023-02-27 08:07:00 -08:00
|
|
|
engineConfiguration->isSdCardEnabled = true;
|
2022-06-23 12:02:13 -07:00
|
|
|
engineConfiguration->sdCardSpiDevice = SPI_DEVICE_2;
|
|
|
|
engineConfiguration->spi2mosiPin = H_SPI2_MOSI;
|
|
|
|
engineConfiguration->spi2misoPin = H_SPI2_MISO;
|
|
|
|
engineConfiguration->spi2sckPin = H_SPI2_SCK;
|
|
|
|
engineConfiguration->sdCardCsPin = H_SPI2_CS;
|
|
|
|
engineConfiguration->is_enabled_spi_2 = true;
|
|
|
|
}
|
|
|
|
|
|
|
|
static void setHellenSdCardSpi3() {
|
2023-02-27 08:07:00 -08:00
|
|
|
engineConfiguration->isSdCardEnabled = true;
|
2022-06-23 12:02:13 -07:00
|
|
|
engineConfiguration->sdCardSpiDevice = SPI_DEVICE_3;
|
|
|
|
engineConfiguration->spi3mosiPin = H_SPI3_MOSI;
|
|
|
|
engineConfiguration->spi3misoPin = H_SPI3_MISO;
|
|
|
|
engineConfiguration->spi3sckPin = H_SPI3_SCK;
|
|
|
|
engineConfiguration->sdCardCsPin = H_SPI3_CS;
|
|
|
|
engineConfiguration->is_enabled_spi_3 = true;
|
|
|
|
}
|
2023-02-15 12:01:41 -08:00
|
|
|
|
|
|
|
// *pullups* files CLT R211 IAT R213
|
|
|
|
#define HELLEN_DEFAULT_AT_PULLUP 4700
|
|
|
|
|
2023-09-10 08:49:33 -07:00
|
|
|
static void setDefaultHellenAtPullUps() {
|
2023-02-15 12:01:41 -08:00
|
|
|
engineConfiguration->clt.config.bias_resistor = HELLEN_DEFAULT_AT_PULLUP;
|
|
|
|
engineConfiguration->iat.config.bias_resistor = HELLEN_DEFAULT_AT_PULLUP;
|
|
|
|
}
|
2023-03-15 11:46:52 -07:00
|
|
|
|
|
|
|
static void setHellenMMbaro() {
|
|
|
|
engineConfiguration->lps25BaroSensorScl = Gpio::B10;
|
|
|
|
engineConfiguration->lps25BaroSensorSda = Gpio::B11;
|
|
|
|
}
|