auto-sync
This commit is contained in:
parent
b6dbca7202
commit
19464c651e
|
@ -372,6 +372,11 @@ void setDodgeNeonNGCEngineConfiguration(engine_configuration_s *engineConfigurat
|
||||||
boardConfiguration->tunerStudioSerialSpeed = 9600;
|
boardConfiguration->tunerStudioSerialSpeed = 9600;
|
||||||
engineConfiguration->algorithm = LM_SPEED_DENSITY;
|
engineConfiguration->algorithm = LM_SPEED_DENSITY;
|
||||||
|
|
||||||
|
engineConfiguration->isJoystickEnabled = true;
|
||||||
|
boardConfiguration->joystickCenterPin = GPIOD_10;
|
||||||
|
boardConfiguration->joystickCenterA = GPIOD_8;
|
||||||
|
boardConfiguration->joystickCenterC = GPIOD_9;
|
||||||
|
|
||||||
// engineConfiguration->isCanEnabled = true;
|
// engineConfiguration->isCanEnabled = true;
|
||||||
boardConfiguration->canTxPin = GPIOB_6;
|
boardConfiguration->canTxPin = GPIOB_6;
|
||||||
boardConfiguration->canRxPin = GPIOB_12;
|
boardConfiguration->canRxPin = GPIOB_12;
|
||||||
|
|
|
@ -260,7 +260,12 @@ typedef struct {
|
||||||
brain_pin_e spi3sckPin;
|
brain_pin_e spi3sckPin;
|
||||||
|
|
||||||
float hip9011Gain;
|
float hip9011Gain;
|
||||||
int unusedbs[12];
|
brain_pin_e joystickCenterPin;
|
||||||
|
brain_pin_e joystickCenterA;
|
||||||
|
brain_pin_e joystickCenterB;
|
||||||
|
brain_pin_e joystickCenterC;
|
||||||
|
brain_pin_e joystickCenterD;
|
||||||
|
int unusedbs[7];
|
||||||
|
|
||||||
le_formula_t le_formulas[LE_COMMAND_COUNT];
|
le_formula_t le_formulas[LE_COMMAND_COUNT];
|
||||||
|
|
||||||
|
@ -515,6 +520,7 @@ typedef struct {
|
||||||
bool_t canReadEnabled : 1; // bit 7
|
bool_t canReadEnabled : 1; // bit 7
|
||||||
bool_t canWriteEnabled : 1; // bit 8
|
bool_t canWriteEnabled : 1; // bit 8
|
||||||
bool_t hasVehicleSpeedSensor : 1; // bit 9
|
bool_t hasVehicleSpeedSensor : 1; // bit 9
|
||||||
|
bool_t isJoystickEnabled : 1; // bit 10
|
||||||
|
|
||||||
int unused6284;
|
int unused6284;
|
||||||
|
|
||||||
|
|
|
@ -41,7 +41,8 @@
|
||||||
#include "engine_configuration.h"
|
#include "engine_configuration.h"
|
||||||
#include "ec2.h"
|
#include "ec2.h"
|
||||||
|
|
||||||
EXTERN_ENGINE;
|
EXTERN_ENGINE
|
||||||
|
;
|
||||||
extern bool hasFirmwareErrorFlag;
|
extern bool hasFirmwareErrorFlag;
|
||||||
|
|
||||||
static StepperMotor iacMotor;
|
static StepperMotor iacMotor;
|
||||||
|
@ -56,11 +57,13 @@ static bool isSpiInitialized[5] = { false, false, false, false, false };
|
||||||
static void initSpiModule(SPIDriver *driver, brain_pin_e sck, brain_pin_e miso,
|
static void initSpiModule(SPIDriver *driver, brain_pin_e sck, brain_pin_e miso,
|
||||||
brain_pin_e mosi, int af) {
|
brain_pin_e mosi, int af) {
|
||||||
|
|
||||||
|
mySetPadMode("SPI clock", getHwPort(sck), getHwPin(sck),
|
||||||
|
PAL_MODE_ALTERNATE(af));
|
||||||
|
|
||||||
mySetPadMode("SPI clock", getHwPort(sck), getHwPin(sck), PAL_MODE_ALTERNATE(af));
|
mySetPadMode("SPI master out", getHwPort(mosi), getHwPin(mosi),
|
||||||
|
PAL_MODE_ALTERNATE(af));
|
||||||
mySetPadMode("SPI master out", getHwPort(mosi), getHwPin(mosi), PAL_MODE_ALTERNATE(af));
|
mySetPadMode("SPI master in ", getHwPort(miso), getHwPin(miso),
|
||||||
mySetPadMode("SPI master in ", getHwPort(miso), getHwPin(miso), PAL_MODE_ALTERNATE(af));
|
PAL_MODE_ALTERNATE(af));
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
@ -82,8 +85,7 @@ void turnOnSpi(spi_device_e device) {
|
||||||
if (device == SPI_DEVICE_1) {
|
if (device == SPI_DEVICE_1) {
|
||||||
#if STM32_SPI_USE_SPI1
|
#if STM32_SPI_USE_SPI1
|
||||||
// scheduleMsg(&logging, "Turning on SPI1 pins");
|
// scheduleMsg(&logging, "Turning on SPI1 pins");
|
||||||
initSpiModule(&SPID1,
|
initSpiModule(&SPID1, boardConfiguration->spi1sckPin,
|
||||||
boardConfiguration->spi1sckPin,
|
|
||||||
boardConfiguration->spi1misoPin,
|
boardConfiguration->spi1misoPin,
|
||||||
boardConfiguration->spi1mosiPin,
|
boardConfiguration->spi1mosiPin,
|
||||||
EFI_SPI1_AF);
|
EFI_SPI1_AF);
|
||||||
|
@ -92,8 +94,7 @@ void turnOnSpi(spi_device_e device) {
|
||||||
if (device == SPI_DEVICE_2) {
|
if (device == SPI_DEVICE_2) {
|
||||||
#if STM32_SPI_USE_SPI2
|
#if STM32_SPI_USE_SPI2
|
||||||
// scheduleMsg(&logging, "Turning on SPI2 pins");
|
// scheduleMsg(&logging, "Turning on SPI2 pins");
|
||||||
initSpiModule(&SPID2,
|
initSpiModule(&SPID2, boardConfiguration->spi2sckPin,
|
||||||
boardConfiguration->spi2sckPin,
|
|
||||||
boardConfiguration->spi2misoPin,
|
boardConfiguration->spi2misoPin,
|
||||||
boardConfiguration->spi2mosiPin,
|
boardConfiguration->spi2mosiPin,
|
||||||
EFI_SPI2_AF);
|
EFI_SPI2_AF);
|
||||||
|
@ -102,8 +103,7 @@ void turnOnSpi(spi_device_e device) {
|
||||||
if (device == SPI_DEVICE_3) {
|
if (device == SPI_DEVICE_3) {
|
||||||
#if STM32_SPI_USE_SPI3
|
#if STM32_SPI_USE_SPI3
|
||||||
// scheduleMsg(&logging, "Turning on SPI3 pins");
|
// scheduleMsg(&logging, "Turning on SPI3 pins");
|
||||||
initSpiModule(&SPID3,
|
initSpiModule(&SPID3, boardConfiguration->spi3sckPin,
|
||||||
boardConfiguration->spi3sckPin,
|
|
||||||
boardConfiguration->spi3misoPin,
|
boardConfiguration->spi3misoPin,
|
||||||
boardConfiguration->spi3mosiPin,
|
boardConfiguration->spi3mosiPin,
|
||||||
EFI_SPI3_AF);
|
EFI_SPI3_AF);
|
||||||
|
@ -178,19 +178,21 @@ static void sendI2Cbyte(int addr, int data) {
|
||||||
|
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
|
|
||||||
// this is all very lame code, just playing with EXTI for now. TODO: refactor it competely!
|
// this is all very lame code, just playing with EXTI for now. TODO: refactor it competely!
|
||||||
static int joyTotal = 0;
|
static int joyTotal = 0;
|
||||||
static int joyA = 0;
|
static int joyA = 0;
|
||||||
static int joyB = 0;
|
static int joyB = 0;
|
||||||
static int joyC = 0;
|
static int joyC = 0;
|
||||||
|
|
||||||
void initHardware(Logging *logger, Engine *engine) {
|
static Logging *sharedLogger;
|
||||||
|
|
||||||
|
void initHardware(Logging *l, Engine *engine) {
|
||||||
|
sharedLogger = l;
|
||||||
engine_configuration_s *engineConfiguration = engine->engineConfiguration;
|
engine_configuration_s *engineConfiguration = engine->engineConfiguration;
|
||||||
efiAssertVoid(engineConfiguration!=NULL, "engineConfiguration");
|
efiAssertVoid(engineConfiguration!=NULL, "engineConfiguration");
|
||||||
board_configuration_s *boardConfiguration = &engineConfiguration->bc;
|
board_configuration_s *boardConfiguration = &engineConfiguration->bc;
|
||||||
|
|
||||||
printMsg(logger, "initHardware()");
|
printMsg(sharedLogger, "initHardware()");
|
||||||
// todo: enable protection. it's disabled because it takes
|
// todo: enable protection. it's disabled because it takes
|
||||||
// 10 extra seconds to re-flash the chip
|
// 10 extra seconds to re-flash the chip
|
||||||
//flashProtect();
|
//flashProtect();
|
||||||
|
@ -224,7 +226,8 @@ void initHardware(Logging *logger, Engine *engine) {
|
||||||
|
|
||||||
#if EFI_INTERNAL_FLASH
|
#if EFI_INTERNAL_FLASH
|
||||||
|
|
||||||
palSetPadMode(CONFIG_RESET_SWITCH_PORT, CONFIG_RESET_SWITCH_PIN, PAL_MODE_INPUT_PULLUP);
|
palSetPadMode(CONFIG_RESET_SWITCH_PORT, CONFIG_RESET_SWITCH_PIN,
|
||||||
|
PAL_MODE_INPUT_PULLUP);
|
||||||
|
|
||||||
initFlash(engine);
|
initFlash(engine);
|
||||||
/**
|
/**
|
||||||
|
@ -233,7 +236,8 @@ void initHardware(Logging *logger, Engine *engine) {
|
||||||
*/
|
*/
|
||||||
if (SHOULD_INGORE_FLASH()) {
|
if (SHOULD_INGORE_FLASH()) {
|
||||||
engineConfiguration->engineType = FORD_ASPIRE_1996;
|
engineConfiguration->engineType = FORD_ASPIRE_1996;
|
||||||
resetConfigurationExt(logger, engineConfiguration->engineType, engine);
|
resetConfigurationExt(sharedLogger, engineConfiguration->engineType,
|
||||||
|
engine);
|
||||||
writeToFlash();
|
writeToFlash();
|
||||||
} else {
|
} else {
|
||||||
readFromFlash();
|
readFromFlash();
|
||||||
|
@ -247,7 +251,8 @@ void initHardware(Logging *logger, Engine *engine) {
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
mySetPadMode2("board test", boardConfiguration->boardTestModeJumperPin, PAL_MODE_INPUT_PULLUP);
|
mySetPadMode2("board test", boardConfiguration->boardTestModeJumperPin,
|
||||||
|
PAL_MODE_INPUT_PULLUP);
|
||||||
bool isBoardTestMode_b = GET_BOARD_TEST_MODE_VALUE();
|
bool isBoardTestMode_b = GET_BOARD_TEST_MODE_VALUE();
|
||||||
|
|
||||||
#if HAL_USE_ADC || defined(__DOXYGEN__)
|
#if HAL_USE_ADC || defined(__DOXYGEN__)
|
||||||
|
@ -264,10 +269,10 @@ void initHardware(Logging *logger, Engine *engine) {
|
||||||
initOutputPins();
|
initOutputPins();
|
||||||
|
|
||||||
#if EFI_MAX_31855
|
#if EFI_MAX_31855
|
||||||
initMax31855(getSpiDevice(boardConfiguration->max31855spiDevice), boardConfiguration->max31855_cs);
|
initMax31855(getSpiDevice(boardConfiguration->max31855spiDevice),
|
||||||
|
boardConfiguration->max31855_cs);
|
||||||
#endif /* EFI_MAX_31855 */
|
#endif /* EFI_MAX_31855 */
|
||||||
|
|
||||||
|
|
||||||
// iacMotor.initialize(GPIOD_11, GPIOD_10);
|
// iacMotor.initialize(GPIOD_11, GPIOD_10);
|
||||||
|
|
||||||
#if EFI_CAN_SUPPORT
|
#if EFI_CAN_SUPPORT
|
||||||
|
@ -292,7 +297,6 @@ void initHardware(Logging *logger, Engine *engine) {
|
||||||
initHip9011();
|
initHip9011();
|
||||||
#endif /* EFI_HIP_9011 */
|
#endif /* EFI_HIP_9011 */
|
||||||
|
|
||||||
|
|
||||||
#if EFI_FILE_LOGGING
|
#if EFI_FILE_LOGGING
|
||||||
initMmcCard();
|
initMmcCard();
|
||||||
#endif /* EFI_FILE_LOGGING */
|
#endif /* EFI_FILE_LOGGING */
|
||||||
|
@ -334,12 +338,11 @@ void initHardware(Logging *logger, Engine *engine) {
|
||||||
// }
|
// }
|
||||||
// }
|
// }
|
||||||
|
|
||||||
initVehicleSpeed(logger);
|
initVehicleSpeed(sharedLogger);
|
||||||
|
|
||||||
printMsg(logger, "initHardware() OK!");
|
printMsg(sharedLogger, "initHardware() OK!");
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
#if HAL_USE_EXT || defined(__DOXYGEN__)
|
#if HAL_USE_EXT || defined(__DOXYGEN__)
|
||||||
|
|
||||||
// {EXT_CH_MODE_BOTH_EDGES | EXT_CH_MODE_AUTOSTART | EXT_MODE_GPIOA, extcb1},
|
// {EXT_CH_MODE_BOTH_EDGES | EXT_CH_MODE_AUTOSTART | EXT_MODE_GPIOA, extcb1},
|
||||||
|
@ -355,6 +358,11 @@ static void extCallback(EXTDriver *extp, expchannel_t channel) {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
static void joystickInfo(void) {
|
||||||
|
scheduleMsg(sharedLogger, "total %d a %d b %d c %d", joyTotal, joyA, joyB,
|
||||||
|
joyC);
|
||||||
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* EXTI is a funny thing: you can only use same pin on one port. For example, you can use
|
* EXTI is a funny thing: you can only use same pin on one port. For example, you can use
|
||||||
* PA0 PB5 PE2 PD7
|
* PA0 PB5 PE2 PD7
|
||||||
|
@ -363,34 +371,53 @@ static void extCallback(EXTDriver *extp, expchannel_t channel) {
|
||||||
* because pin '0' would be used on two different ports
|
* because pin '0' would be used on two different ports
|
||||||
*/
|
*/
|
||||||
|
|
||||||
static EXTConfig extcfg = { { { EXT_CH_MODE_DISABLED, NULL }, { EXT_CH_MODE_DISABLED, NULL }, { EXT_CH_MODE_DISABLED,
|
static EXTConfig extcfg = { {
|
||||||
NULL }, { EXT_CH_MODE_DISABLED, NULL }, { EXT_CH_MODE_DISABLED, NULL }, { EXT_CH_MODE_DISABLED, NULL }, {
|
/* CH#00 */{ EXT_CH_MODE_DISABLED, NULL },
|
||||||
EXT_CH_MODE_DISABLED, NULL }, { EXT_CH_MODE_DISABLED, NULL }, { EXT_CH_MODE_DISABLED, NULL }, {
|
/* CH#01 */{ EXT_CH_MODE_DISABLED, NULL },
|
||||||
EXT_CH_MODE_DISABLED, NULL }, { EXT_CH_MODE_DISABLED, NULL }, { EXT_CH_MODE_DISABLED, NULL }, {
|
/* CH#02 */{ EXT_CH_MODE_DISABLED, NULL },
|
||||||
EXT_CH_MODE_DISABLED, NULL }, { EXT_CH_MODE_DISABLED, NULL }, { EXT_CH_MODE_DISABLED, NULL }, {
|
/* CH#03 */{ EXT_CH_MODE_DISABLED, NULL },
|
||||||
EXT_CH_MODE_DISABLED, NULL }, { EXT_CH_MODE_DISABLED, NULL }, { EXT_CH_MODE_DISABLED, NULL }, {
|
/* CH#04 */{ EXT_CH_MODE_DISABLED, NULL },
|
||||||
EXT_CH_MODE_DISABLED, NULL }, { EXT_CH_MODE_DISABLED, NULL }, { EXT_CH_MODE_DISABLED, NULL }, {
|
/* CH#05 */{ EXT_CH_MODE_DISABLED, NULL },
|
||||||
EXT_CH_MODE_DISABLED, NULL }, { EXT_CH_MODE_DISABLED, NULL } } };
|
/* CH#06 */{ EXT_CH_MODE_DISABLED, NULL },
|
||||||
|
/* CH#07 */{ EXT_CH_MODE_DISABLED, NULL },
|
||||||
|
/* CH#08 */{ EXT_CH_MODE_DISABLED, NULL },
|
||||||
|
/* CH#09 */{ EXT_CH_MODE_DISABLED, NULL },
|
||||||
|
/* CH#10 */{ EXT_CH_MODE_DISABLED, NULL },
|
||||||
|
/* CH#11 */{ EXT_CH_MODE_DISABLED, NULL },
|
||||||
|
/* CH#12 */{ EXT_CH_MODE_DISABLED, NULL },
|
||||||
|
/* CH#13 */{ EXT_CH_MODE_DISABLED, NULL },
|
||||||
|
/* CH#14 */{ EXT_CH_MODE_DISABLED, NULL },
|
||||||
|
/* CH#15 */{ EXT_CH_MODE_DISABLED, NULL },
|
||||||
|
/* CH#16 */{ EXT_CH_MODE_DISABLED, NULL },
|
||||||
|
/* CH#17 */{ EXT_CH_MODE_DISABLED, NULL },
|
||||||
|
/* CH#18 */{ EXT_CH_MODE_DISABLED, NULL },
|
||||||
|
/* CH#19 */{ EXT_CH_MODE_DISABLED, NULL },
|
||||||
|
/* CH#20 */{ EXT_CH_MODE_DISABLED, NULL },
|
||||||
|
/* CH#21 */{ EXT_CH_MODE_DISABLED, NULL },
|
||||||
|
/* CH#22 */{ EXT_CH_MODE_DISABLED, NULL } } };
|
||||||
|
|
||||||
void initExt(void) {
|
void initExt(void) {
|
||||||
|
if (!engineConfiguration->isJoystickEnabled)
|
||||||
|
return;
|
||||||
|
|
||||||
// if (1 == 1) {
|
extcfg.channels[8].mode = EXT_CH_MODE_BOTH_EDGES | EXT_CH_MODE_AUTOSTART
|
||||||
// return;
|
| EXT_MODE_GPIOC; // PC8
|
||||||
// }
|
|
||||||
|
|
||||||
extcfg.channels[8].mode = EXT_CH_MODE_BOTH_EDGES | EXT_CH_MODE_AUTOSTART | EXT_MODE_GPIOD; // PD8
|
|
||||||
extcfg.channels[8].cb = extCallback;
|
extcfg.channels[8].cb = extCallback;
|
||||||
extcfg.channels[9].mode = EXT_CH_MODE_BOTH_EDGES | EXT_CH_MODE_AUTOSTART | EXT_MODE_GPIOD; // PD9
|
|
||||||
extcfg.channels[9].cb = extCallback;
|
extcfg.channels[10].mode = EXT_CH_MODE_BOTH_EDGES | EXT_CH_MODE_AUTOSTART
|
||||||
extcfg.channels[10].mode = EXT_CH_MODE_BOTH_EDGES | EXT_CH_MODE_AUTOSTART | EXT_MODE_GPIOD; // PD10
|
| EXT_MODE_GPIOD; // PD10
|
||||||
extcfg.channels[10].cb = extCallback;
|
extcfg.channels[10].cb = extCallback;
|
||||||
extcfg.channels[11].mode = EXT_CH_MODE_BOTH_EDGES | EXT_CH_MODE_AUTOSTART | EXT_MODE_GPIOD; // PD11
|
|
||||||
|
extcfg.channels[11].mode = EXT_CH_MODE_BOTH_EDGES | EXT_CH_MODE_AUTOSTART
|
||||||
|
| EXT_MODE_GPIOD; // PD11
|
||||||
extcfg.channels[11].cb = extCallback;
|
extcfg.channels[11].cb = extCallback;
|
||||||
|
|
||||||
mySetPadMode("joy A", GPIOD, 8, PAL_MODE_INPUT_PULLUP);
|
mySetPadMode("joy center", GPIOD, 10, PAL_MODE_INPUT_PULLUP);
|
||||||
mySetPadMode("joy A", GPIOD, 9, PAL_MODE_INPUT_PULLUP);
|
mySetPadMode("joy B", GPIOC, 8, PAL_MODE_INPUT_PULLUP);
|
||||||
mySetPadMode("joy A", GPIOD, 10, PAL_MODE_INPUT_PULLUP);
|
mySetPadMode("joy D", GPIOD, 11, PAL_MODE_INPUT_PULLUP);
|
||||||
mySetPadMode("joy A", GPIOD, 11, PAL_MODE_INPUT_PULLUP);
|
|
||||||
|
extStart(&EXTD1, &extcfg);
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
#endif
|
#endif
|
||||||
|
|
Loading…
Reference in New Issue