2022-01-08 17:13:15 -08:00
# include "pch.h"
2022-01-09 14:40:08 -08:00
# include "hellen_meta.h"
2022-01-08 17:13:15 -08:00
void hellenWbo ( ) {
engineConfiguration - > enableAemXSeries = true ;
}
void setHellenDefaultVrThresholds ( ) {
for ( int i = 0 ; i < VR_THRESHOLD_COUNT ; i + + ) {
setLinearCurve ( engineConfiguration - > vrThreshold [ i ] . rpmBins , 600 , 7000 , 100 ) ;
setLinearCurve ( engineConfiguration - > vrThreshold [ i ] . values , 0.6 , 1.2 , 0.1 ) ;
}
}
2022-01-09 14:40:08 -08:00
void setHellen144LedPins ( ) {
# ifdef EFI_COMMUNICATION_PIN
engineConfiguration - > communicationLedPin = EFI_COMMUNICATION_PIN ;
# else
2022-03-12 12:40:33 -08:00
engineConfiguration - > communicationLedPin = H144_LED3 ;
2022-01-09 14:40:08 -08:00
# endif /* EFI_COMMUNICATION_PIN */
2022-03-12 12:40:33 -08:00
engineConfiguration - > runningLedPin = H144_LED2 ;
engineConfiguration - > warningLedPin = H144_LED4 ;
2022-01-09 14:40:08 -08:00
}
void setHellen176LedPins ( ) {
# ifdef EFI_COMMUNICATION_PIN
engineConfiguration - > communicationLedPin = EFI_COMMUNICATION_PIN ;
# else
engineConfiguration - > communicationLedPin = GPIOH_10 ;
# endif /* EFI_COMMUNICATION_PIN */
engineConfiguration - > runningLedPin = GPIOH_9 ; // green
engineConfiguration - > warningLedPin = GPIOH_11 ; // yellow
}
// this should be called before setHellenXXXLedPins()
2022-02-03 08:24:31 -08:00
void detectHellenMcuType ( ) {
2022-01-16 11:51:26 -08:00
// we test the red LED1 pin because the red LED used has the smallest voltage drop,
2022-01-09 14:40:08 -08:00
// and thus can be detected more accurately
static const brain_pin_e led1Pins [ 2 ] = {
// LED1 pin of the 176-pin mcu module (we check it first!)
2022-01-16 11:51:26 -08:00
H176_LED1_RED ,
2022-01-09 14:40:08 -08:00
// LED1 pin of the 144-pin mcu module
2022-01-16 11:51:26 -08:00
H144_LED1_RED ,
2022-01-09 14:40:08 -08:00
} ;
int padState [ 2 ] ;
// check each mcu module type sequentially
for ( int mcuType = 0 ; mcuType < 2 ; mcuType + + ) {
brain_pin_e ledPin = led1Pins [ mcuType ] ;
// set LED1 pin to output & clear the state (discharge parasitic capacitance)
palSetPadMode ( getBrainPinPort ( ledPin ) , getBrainPinIndex ( ledPin ) , PAL_MODE_OUTPUT_PUSHPULL ) ;
palClearPad ( getBrainPinPort ( ledPin ) , getBrainPinIndex ( ledPin ) ) ;
// set LED1 pin to input
palSetPadMode ( getBrainPinPort ( ledPin ) , getBrainPinIndex ( ledPin ) , PAL_MODE_INPUT ) ; // todo: currently we don't use PAL_MODE_INPUT_PULLDOWN - needs more testing
// wait for the pin state to settle down
chThdSleepMilliseconds ( 1 ) ;
// get the pin states
padState [ mcuType ] = 1 ;
for ( int i = 0 ; i < 4 ; i + + ) {
// we get "1" only if all readings are "1"
padState [ mcuType ] & = palReadPad ( getBrainPinPort ( ledPin ) , getBrainPinIndex ( ledPin ) ) ;
}
}
efiPrintf ( " Hellen board pin states = %d %d " , padState [ 0 ] , padState [ 1 ] ) ;
if ( padState [ 0 ] & & ! padState [ 1 ] ) {
efiPrintf ( " * Hellen 176-pin mcu detected! " ) ;
}
else if ( ! padState [ 0 ] & & padState [ 1 ] ) {
efiPrintf ( " * Hellen 144-pin mcu detected! " ) ;
} else {
efiPrintf ( " * Cannot detect Hellen mcu module! " ) ;
}
}
2022-02-03 08:24:31 -08:00
void detectHellenBoardType ( ) {
detectHellenMcuType ( ) ;
detectHellenBoardId ( ) ;
}