diff --git a/Electronics/PCB (KiCAD)/Motherboard/RevD/CARs/CAR066 - 16U2 toggles reset ~2.5 seconds after powerup/Behavior.png b/Electronics/PCB (KiCAD)/Motherboard/RevD/CARs/CAR066 - 16U2 toggles reset ~2.5 seconds after powerup/Behavior.png new file mode 100644 index 00000000..92cd13fc Binary files /dev/null and b/Electronics/PCB (KiCAD)/Motherboard/RevD/CARs/CAR066 - 16U2 toggles reset ~2.5 seconds after powerup/Behavior.png differ diff --git a/Electronics/PCB (KiCAD)/Motherboard/RevD/CARs/CAR066 - 16U2 toggles reset ~2.5 seconds after powerup/CAR066 - 16U2 toggles reset pin ~2.5 seconds after powerup.txt b/Electronics/PCB (KiCAD)/Motherboard/RevD/CARs/CAR066 - 16U2 toggles reset ~2.5 seconds after powerup/CAR066 - 16U2 toggles reset pin ~2.5 seconds after powerup.txt new file mode 100644 index 00000000..5ab7acce --- /dev/null +++ b/Electronics/PCB (KiCAD)/Motherboard/RevD/CARs/CAR066 - 16U2 toggles reset ~2.5 seconds after powerup/CAR066 - 16U2 toggles reset pin ~2.5 seconds after powerup.txt @@ -0,0 +1,3 @@ +16U2 toggle PD7 ~2.5 seconds after powerup. This causes pulse on MEGA2560's reset pin, which briefly disables Mega's output pins... but for some reason doesn't actually reset program execution. + +This only occurs when USB cable is connected during powerup. Given that a USB cable typically powers the 5V rail, this won't actually ever occur; in my testing that lead to this CAR, my USB cable's 5V wire was cut. \ No newline at end of file diff --git a/Firmware/firmwareLiBCM/config.h b/Firmware/firmwareLiBCM/config.h index 90f95a1c..1d06dbb4 100644 --- a/Firmware/firmwareLiBCM/config.h +++ b/Firmware/firmwareLiBCM/config.h @@ -1,4 +1,4 @@ -//Copyright 2021-2023(c) John Sullivan +//Copyright 2021-2024(c) John Sullivan //github.com/doppelhub/Honda_Insight_LiBCM //config.h - compile time configuration parameters @@ -7,8 +7,8 @@ #define config_h #include "src/libcm.h" - #define FW_VERSION "0.9.4b" - #define BUILD_DATE "2024JUL09" + #define FW_VERSION "0.9.4d" + #define BUILD_DATE "2024JUL23" ////////////////////////////////////////////////////////////////// @@ -46,6 +46,8 @@ #define LCD_4X20_CONNECTED //display included with all LiBCM Kits //#define LIDISPLAY_CONNECTED //optional color touch screen display //JTS2doLater: mudder has not yet tested this code. Use at your own risk. + //you don't need to change any settings below this line (but you can if you know what you're doing): + //__________________________________________________________________________________________________ ////////////////////////////////////////////////////////////////// diff --git a/Firmware/firmwareLiBCM/firmwareLiBCM.ino b/Firmware/firmwareLiBCM/firmwareLiBCM.ino index 46d03b1d..ad5a83be 100644 --- a/Firmware/firmwareLiBCM/firmwareLiBCM.ino +++ b/Firmware/firmwareLiBCM/firmwareLiBCM.ino @@ -1,31 +1,30 @@ -//Copyright 2021-2023(c) John Sullivan +//Copyright 2021-2024(c) John Sullivan //github.com/doppelhub/Honda_Insight_LiBCM //Lithium battery BMS for G1 Honda Insight. Replaces OEM BCM module. #include "src/libcm.h" -void setup() //~t=2 milliseconds, BUT NOTE this doesn't include CPU_CLOCK warmup or bootloader delay +void setup() { + //getting here takes ~02 milliseconds after poweron reset + //getting here takes ~16 milliseconds after IMA switch on gpio_begin(); wdt_disable(); + LiControl_begin(); //SPI errors until initialized + LTC68042configure_initialize(); Serial.begin(115200); //USB METSCI_begin(); BATTSCI_begin(); heater_begin(); - LiDisplay_begin(); - LiControl_begin(); - LTC68042configure_initialize(); eeprom_begin(); + LiDisplay_begin(); + + if (gpio_keyStateNow() == GPIO_KEY_ON) { keyOn_coldBootTasks(); } + else { debugUSB_printWelcomeMessage(); } bringupTester_gridcharger(); bringupTester_motherboard(); - if (gpio_keyStateNow() == GPIO_KEY_ON){ LED(3,ON); } //turn LED3 on if LiBCM (re)boots while driving - - Serial.print(F("\n\nLiBCM v" FW_VERSION ", " BUILD_DATE "\n'$HELP' for info\n")); - debugUSB_printHardwareRevision(); - debugUSB_printConfigParameters(); - wdt_enable(WDTO_2S); //set watchdog reset vector to 2 seconds } diff --git a/Firmware/firmwareLiBCM/src/BringupTester.cpp b/Firmware/firmwareLiBCM/src/BringupTester.cpp index a2ae9d35..cbe124cf 100644 --- a/Firmware/firmwareLiBCM/src/BringupTester.cpp +++ b/Firmware/firmwareLiBCM/src/BringupTester.cpp @@ -1,4 +1,4 @@ -//Copyright 2021-2023(c) John Sullivan +//Copyright 2021-2024(c) John Sullivan //Tests PCB (using custom external hardware) //Not used when deployed in vehicle diff --git a/Firmware/firmwareLiBCM/src/BringupTester.h b/Firmware/firmwareLiBCM/src/BringupTester.h index a75b6e7f..51ce1604 100644 --- a/Firmware/firmwareLiBCM/src/BringupTester.h +++ b/Firmware/firmwareLiBCM/src/BringupTester.h @@ -1,4 +1,4 @@ -//Copyright 2021-2023(c) John Sullivan +//Copyright 2021-2024(c) John Sullivan //github.com/doppelhub/Honda_Insight_LiBCM #ifndef bringuptester_h diff --git a/Firmware/firmwareLiBCM/src/LTC68042cell.cpp b/Firmware/firmwareLiBCM/src/LTC68042cell.cpp index 936ee90d..c59df03e 100644 --- a/Firmware/firmwareLiBCM/src/LTC68042cell.cpp +++ b/Firmware/firmwareLiBCM/src/LTC68042cell.cpp @@ -1,4 +1,4 @@ -//Copyright 2021-2023(c) John Sullivan +//Copyright 2021-2024(c) John Sullivan //github.com/doppelhub/Honda_Insight_LiBCM //LTC6804 cell voltage data processor and related functions @@ -289,7 +289,7 @@ bool LTC68042cell_nextVoltages(void) else if (presentState == LTC_STATE_FIRSTRUN) { //LTC6804 ICs were previously off - LTC68042configure_programVolatileDefaults(); + LTC68042configure_programVolatileDefaults(); startCellConversion(); presentState = LTC_STATE_GATHER; } diff --git a/Firmware/firmwareLiBCM/src/LTC68042cell.h b/Firmware/firmwareLiBCM/src/LTC68042cell.h index 27c324a5..a7fea5fb 100644 --- a/Firmware/firmwareLiBCM/src/LTC68042cell.h +++ b/Firmware/firmwareLiBCM/src/LTC68042cell.h @@ -1,4 +1,4 @@ -//Copyright 2021-2023(c) John Sullivan +//Copyright 2021-2024(c) John Sullivan //github.com/doppelhub/Honda_Insight_LiBCM #ifndef LTC68042cell_h @@ -11,6 +11,8 @@ #define GATHERING_CELL_DATA 0 #define CELL_DATA_PROCESSED 1 + #define LTC6804_MAX_CONVERSION_TIME_ms 5 //4.43 ms in '2kHz' sampling mode + bool LTC68042cell_nextVoltages(void); void LTC68042cell_acquireAllCellVoltages(void); diff --git a/Firmware/firmwareLiBCM/src/LTC68042configure.cpp b/Firmware/firmwareLiBCM/src/LTC68042configure.cpp index 65f0882a..7e82baa9 100644 --- a/Firmware/firmwareLiBCM/src/LTC68042configure.cpp +++ b/Firmware/firmwareLiBCM/src/LTC68042configure.cpp @@ -1,4 +1,4 @@ -//Copyright 2021-2023(c) John Sullivan +//Copyright 2021-2024(c) John Sullivan //github.com/doppelhub/Honda_Insight_LiBCM //LTC6804 configuration functions @@ -103,46 +103,50 @@ bool LTC68042configure_doesActualPackSizeMatchUserConfig(void) { bool helper_doesActualPackSizeMatchUserConfig = true; - if (gpio_keyStateNow() == GPIO_KEY_OFF) //we don't have time to run this test if the key is on when LiBCM first boots - { - LTC6804_adax(); //send any broadcast command - delay(6); //wait for all LTC6804 ICs to process this command + #if defined RUN_BRINGUP_TESTER_MOTHERBOARD //don't verify cell count + #elif defined RUN_BRINGUP_TESTER_GRIDCHARGER //don't verify cell count + #else + if (gpio_keyStateNow() == GPIO_KEY_OFF) //we don't have time to run this test if the key is on when LiBCM first boots + { + LTC6804_adax(); //send any broadcast command + delay(6); //wait for all LTC6804 ICs to process this command - //read data back from either QTY4 ICs (if user selects PACK_IS_48S in config.h), or QTY5 ICs (if user selects PACK_IS_60S in config.h) - //we don't care about the actual data; only that the PEC error count doesn't increment - uint8_t errorCount_allUserSpecifiedLTC6804s = LTC6804_rdaux(0,TOTAL_IC,FIRST_IC_ADDR); + //read data back from either QTY4 ICs (if user selects PACK_IS_48S in config.h), or QTY5 ICs (if user selects PACK_IS_60S in config.h) + //we don't care about the actual data; only that the PEC error count doesn't increment + uint8_t errorCount_allUserSpecifiedLTC6804s = LTC6804_rdaux(0,TOTAL_IC,FIRST_IC_ADDR); - if (errorCount_allUserSpecifiedLTC6804s != 0) { helper_doesActualPackSizeMatchUserConfig = false; } //at least one IC had data transmissions errors + if (errorCount_allUserSpecifiedLTC6804s != 0) { helper_doesActualPackSizeMatchUserConfig = false; } //at least one IC had data transmissions errors - if (TOTAL_IC == 4) - { - uint8_t errorCount_onlyFifthLTC6804 = LTC6804_rdaux(0,1,FIRST_IC_ADDR+4); + if (TOTAL_IC == 4) + { + uint8_t errorCount_onlyFifthLTC6804 = LTC6804_rdaux(0,1,FIRST_IC_ADDR+4); - //the fifth LTC6804 (cells 49:60) should be unpowered (i.e. it should return errors) - if (errorCount_onlyFifthLTC6804 == 0) { helper_doesActualPackSizeMatchUserConfig = false; } - } + //the fifth LTC6804 (cells 49:60) should be unpowered (i.e. it should return errors) + if (errorCount_onlyFifthLTC6804 == 0) { helper_doesActualPackSizeMatchUserConfig = false; } + } - if (helper_doesActualPackSizeMatchUserConfig == false) - { - //fatal error - //alert user and then turn off + if (helper_doesActualPackSizeMatchUserConfig == false) + { + //fatal error + //alert user and then turn off - Serial.print(F("\nError: measured cell count disagrees with user specified cell count in config.h")); + Serial.print(F("\nError: measured cell count disagrees with user specified cell count in config.h")); - lcdTransmit_begin(); - delay(50); //delay doesn't matter because this is a fatal error - lcdTransmit_displayOn(); - delay(50); //delay doesn't matter because this is a fatal error - lcdTransmit_Warning(LCD_WARN_CELL_COUNT); + lcdTransmit_begin(); + delay(50); //delay doesn't matter because this is a fatal error + lcdTransmit_displayOn(); + delay(50); //delay doesn't matter because this is a fatal error + lcdTransmit_Warning(LCD_WARN_CELL_COUNT); - gpio_turnBuzzer_on_highFreq(); //call GPIO directly - - wdt_disable(); //turn off watchdog to prevent reset + gpio_turnBuzzer_on_highFreq(); //call GPIO directly + + wdt_disable(); //turn off watchdog to prevent reset - delay(10000); //give the user enough time to read error message - gpio_turnLiBCM_off(); //game over... thanks for playing + delay(10000); //give the user enough time to read error message + gpio_turnLiBCM_off(); //game over... thanks for playing + } } - } + #endif return helper_doesActualPackSizeMatchUserConfig; } @@ -152,12 +156,16 @@ bool LTC68042configure_doesActualPackSizeMatchUserConfig(void) void LTC68042configure_initialize(void) { spi_enable(SPI_CLOCK_DIV64); //JTS2doLater: increase clock speed //DIV16 & DIV32 work on bench +} - #if defined RUN_BRINGUP_TESTER_MOTHERBOARD //don't verify cell count - #elif defined RUN_BRINGUP_TESTER_GRIDCHARGER //don't verify cell count - #else - LTC68042configure_doesActualPackSizeMatchUserConfig(); //verify cell count matches - #endif +///////////////////////////////////////////////////////////////////////////////////////// + +void LTC68042configure_pulseChipSelectLow(uint16_t lowPulsePeriod_us) +{ + digitalWrite(PIN_SPI_CS,LOW); //low edge wakes up LTC + delayMicroseconds(lowPulsePeriod_us); //wait specified time for LTC to wake + digitalWrite(PIN_SPI_CS,HIGH); + lastTimeDataSent_millis = millis(); } ///////////////////////////////////////////////////////////////////////////////////////// @@ -172,10 +180,7 @@ bool LTC68042configure_wakeupCore(void) if ((uint32_t)(millis() - lastTimeDataSent_millis) > T_SLEEP_WATCHDOG_MILLIS) { //LTC6804 core (probably) asleep - digitalWrite(PIN_SPI_CS,LOW); //wake up core - delayMicroseconds(300); // Guarantees the LTC6804 is in standby (tWake = 300 us max) - digitalWrite(PIN_SPI_CS,HIGH); - lastTimeDataSent_millis = millis(); + LTC68042configure_pulseChipSelectLow(SPECIFIED_MAX_WAKEUP_TIME_LTCCORE_MICROSECONDS); wasCoreAlreadyAwake = LTC6804_CORE_JUST_WOKE_UP; } @@ -192,10 +197,7 @@ void LTC68042configure_wakeupIsoSPI(void) if ((uint32_t)(millis() - lastTimeDataSent_millis) > T_IDLE_isoSPI_MILLIS) { //LTC6804 isoSPI might be asleep (tIDLE elapsed) - digitalWrite(PIN_SPI_CS,LOW); - delayMicroseconds(10); //Guarantees isoSPI is in ready mode (tWAKE = 10 us max) - digitalWrite(PIN_SPI_CS,HIGH); - lastTimeDataSent_millis = millis(); + LTC68042configure_pulseChipSelectLow(SPECIFIED_MAX_WAKEUP_TIME_isoSPI_MICROSECONDS); } } @@ -254,6 +256,8 @@ void LTC68042configure_spiWriteRead(uint8_t tx_Data[],//array of data to be writ for (uint8_t i = 0; i < tx_len; i++) { spi_write(tx_Data[i]); } for (uint8_t i = 0; i < rx_len; i++) { rx_data[i] = (uint8_t)spi_read(0xFF); } digitalWrite(PIN_SPI_CS,HIGH); + + lastTimeDataSent_millis = millis(); } ///////////////////////////////////////////////////////////////////////////////////////// diff --git a/Firmware/firmwareLiBCM/src/LTC68042configure.h b/Firmware/firmwareLiBCM/src/LTC68042configure.h index 0656ebd1..4c2c1d35 100644 --- a/Firmware/firmwareLiBCM/src/LTC68042configure.h +++ b/Firmware/firmwareLiBCM/src/LTC68042configure.h @@ -1,4 +1,4 @@ -//Copyright 2021-2023(c) John Sullivan +//Copyright 2021-2024(c) John Sullivan //github.com/doppelhub/Honda_Insight_LiBCM #ifndef LTC68042configure_h @@ -25,6 +25,8 @@ #define FIRST_IC_ADDR 2 //lowest address. All additional IC addresses must be sequential #define CELLS_PER_IC 12 //Each LTC6804 measures QTY12 cells + #define SPECIFIED_MAX_WAKEUP_TIME_LTCCORE_MICROSECONDS 300 //guarantees LTC6804 is in 'standby' mode (tWake = 300 us max) + #define SPECIFIED_MAX_WAKEUP_TIME_isoSPI_MICROSECONDS 10 //guarantees isoSPI is in 'ready' mode (tWAKE = 10 us max) // |CHG | Dec |Channels to convert | // |----|------|----------------------| @@ -191,4 +193,8 @@ void LTC68042configure_setBalanceResistors(uint8_t icAddress, uint16_t cellBitmap, uint8_t softwareTimeout); + bool LTC68042configure_doesActualPackSizeMatchUserConfig(void); + + void LTC68042configure_pulseChipSelectLow(uint16_t lowPulsePeriod_us); + #endif diff --git a/Firmware/firmwareLiBCM/src/LTC68042gpio.cpp b/Firmware/firmwareLiBCM/src/LTC68042gpio.cpp index bb245788..d81957df 100644 --- a/Firmware/firmwareLiBCM/src/LTC68042gpio.cpp +++ b/Firmware/firmwareLiBCM/src/LTC68042gpio.cpp @@ -1,4 +1,4 @@ -//Copyright 2021-2023(c) John Sullivan +//Copyright 2021-2024(c) John Sullivan //github.com/doppelhub/Honda_Insight_LiBCM //LTC6804 gpio (e.g. temperature) data and various functions diff --git a/Firmware/firmwareLiBCM/src/LTC68042gpio.h b/Firmware/firmwareLiBCM/src/LTC68042gpio.h index af2bb66c..7cf427c8 100644 --- a/Firmware/firmwareLiBCM/src/LTC68042gpio.h +++ b/Firmware/firmwareLiBCM/src/LTC68042gpio.h @@ -1,4 +1,4 @@ -//Copyright 2021-2023(c) John Sullivan +//Copyright 2021-2024(c) John Sullivan //github.com/doppelhub/Honda_Insight_LiBCM #ifndef LTC68042gpio_h diff --git a/Firmware/firmwareLiBCM/src/LTC68042result.cpp b/Firmware/firmwareLiBCM/src/LTC68042result.cpp index 531c8212..6e28a380 100755 --- a/Firmware/firmwareLiBCM/src/LTC68042result.cpp +++ b/Firmware/firmwareLiBCM/src/LTC68042result.cpp @@ -1,4 +1,4 @@ -//Copyright 2021-2023(c) John Sullivan +//Copyright 2021-2024(c) John Sullivan //github.com/doppelhub/Honda_Insight_LiBCM //The latest results gathered from LTC6804 are stored here. diff --git a/Firmware/firmwareLiBCM/src/LTC68042result.h b/Firmware/firmwareLiBCM/src/LTC68042result.h index 4a906520..7bad13cc 100755 --- a/Firmware/firmwareLiBCM/src/LTC68042result.h +++ b/Firmware/firmwareLiBCM/src/LTC68042result.h @@ -1,4 +1,4 @@ -//Copyright 2021-2023(c) John Sullivan +//Copyright 2021-2024(c) John Sullivan //github.com/doppelhub/Honda_Insight_LiBCM #ifndef LTC68042result_h diff --git a/Firmware/firmwareLiBCM/src/LiControl.cpp b/Firmware/firmwareLiBCM/src/LiControl.cpp index c760e93d..f93dac5c 100644 --- a/Firmware/firmwareLiBCM/src/LiControl.cpp +++ b/Firmware/firmwareLiBCM/src/LiControl.cpp @@ -1,4 +1,4 @@ -//Copyright 2021-2023(c) John Sullivan +//Copyright 2021-2024(c) John Sullivan //github.com/doppelhub/Honda_Insight_LiBCM #include "libcm.h" diff --git a/Firmware/firmwareLiBCM/src/LiControl.h b/Firmware/firmwareLiBCM/src/LiControl.h index 897734b8..ea212113 100644 --- a/Firmware/firmwareLiBCM/src/LiControl.h +++ b/Firmware/firmwareLiBCM/src/LiControl.h @@ -1,4 +1,4 @@ -//Copyright 2021-2023(c) John Sullivan +//Copyright 2021-2024(c) John Sullivan //github.com/doppelhub/Honda_Insight_LiBCM #ifndef LiControl_h diff --git a/Firmware/firmwareLiBCM/src/LiDisplay.cpp b/Firmware/firmwareLiBCM/src/LiDisplay.cpp index 0742aa9d..0c5a9c07 100644 --- a/Firmware/firmwareLiBCM/src/LiDisplay.cpp +++ b/Firmware/firmwareLiBCM/src/LiDisplay.cpp @@ -1,4 +1,4 @@ -//Copyright 2021-2023(c) John Sullivan +//Copyright 2021-2024(c) John Sullivan //github.com/doppelhub/Honda_Insight_LiBCM //LiDisplay (HMI) Serial Functions @@ -90,7 +90,6 @@ const uint16_t editableParamMinMax[2][2] = { void LiDisplay_begin(void) { #ifdef LIDISPLAY_CONNECTED - Serial.print(F("\nLiDisplay BEGIN")); #ifdef BATTERY_TYPE_47AhFoMoCo #undef LIDISPLAY_GRIDCHARGE_PAGE_ID diff --git a/Firmware/firmwareLiBCM/src/LiDisplay.h b/Firmware/firmwareLiBCM/src/LiDisplay.h index d2d40cff..4d6ecec0 100644 --- a/Firmware/firmwareLiBCM/src/LiDisplay.h +++ b/Firmware/firmwareLiBCM/src/LiDisplay.h @@ -1,4 +1,4 @@ -//Copyright 2021-2023(c) John Sullivan +//Copyright 2021-2024(c) John Sullivan //github.com/doppelhub/Honda_Insight_LiBCM #ifndef lidisplay_h diff --git a/Firmware/firmwareLiBCM/src/SoC.cpp b/Firmware/firmwareLiBCM/src/SoC.cpp index 41106d9b..65261651 100644 --- a/Firmware/firmwareLiBCM/src/SoC.cpp +++ b/Firmware/firmwareLiBCM/src/SoC.cpp @@ -1,4 +1,4 @@ -//Copyright 2021-2023(c) John Sullivan +//Copyright 2021-2024(c) John Sullivan //github.com/doppelhub/Honda_Insight_LiBCM //maintains battery state of charge diff --git a/Firmware/firmwareLiBCM/src/SoC.h b/Firmware/firmwareLiBCM/src/SoC.h index 53ac4e47..71f113df 100644 --- a/Firmware/firmwareLiBCM/src/SoC.h +++ b/Firmware/firmwareLiBCM/src/SoC.h @@ -1,4 +1,4 @@ -//Copyright 2021-2023(c) John Sullivan +//Copyright 2021-2024(c) John Sullivan //github.com/doppelhub/Honda_Insight_LiBCM #ifndef soc_h diff --git a/Firmware/firmwareLiBCM/src/USB_userInterface.cpp b/Firmware/firmwareLiBCM/src/USB_userInterface.cpp index 32ac0243..b42e2da5 100644 --- a/Firmware/firmwareLiBCM/src/USB_userInterface.cpp +++ b/Firmware/firmwareLiBCM/src/USB_userInterface.cpp @@ -1,4 +1,4 @@ -//Copyright 2021-2023(c) John Sullivan +//Copyright 2021-2024(c) John Sullivan //github.com/doppelhub/Honda_Insight_LiBCM //Handles user interactions with LiBCM (data query/response) @@ -53,16 +53,11 @@ void USB_userInterface_runTestCode(uint8_t testToRun) } else if (testToRun == '2') { - gpio_turnPowerSensors_on(); - Serial.print(F("Calibrating Current Sensor")); - adc_calibrateBatteryCurrentSensorOffset(); + printText_UNUSED(); } else if (testToRun == '3') { - Serial.print(F("updateBatteryCurrent")); - adc_updateBatteryCurrent(); - Serial.print(F("\ndeciAmps: ")); - Serial.print(adc_getLatestBatteryCurrent_deciAmps()); + printText_UNUSED(); } else if (testToRun == '4') { @@ -86,9 +81,7 @@ void USB_userInterface_runTestCode(uint8_t testToRun) } else if (testToRun == '9') { - Serial.print(F("\nadcResult_CurrentSensor(10b): ")); - Serial.print(analogRead(PIN_BATTCURRENT)); - adc_calibrateBatteryCurrentSensorOffset(); + printText_UNUSED(); } //Lettered tests ($TESTA/B/C) are permanent, for user testing during product troubleshooting @@ -131,6 +124,7 @@ void printHelp(void) { Serial.print(F("\n\nLiBCM commands:" "\n -'$BOOT': restart LiBCM" + "\n -'$OFF': turn LiBCM off (for testing purposes)" "\n -'$TESTR': run LTC6804 VREF test" "\n -'$TESTW': battery temp & SoC history" "\n -'$TESTH': blink heater LED" @@ -214,6 +208,28 @@ void USB_userInterface_executeUserInput(void) rebootLiBCM(); } + //$OFF + else if ((line[1] == 'O') && (line[2] == 'F') && (line[3] == 'F')) + { + Serial.print(F("\nUnplug USB cable before the counter gets to zero:")); + Serial.print(F("\nLiBCM turning off in ")); + for (uint8_t ii=5; ii!=0 ;ii--) + { + Serial.print('\n'); + Serial.print(ii); + for (uint8_t jj=10; jj!=0; jj--) + { + Serial.print('.'); + delay(100); + wdt_reset(); //Feed watchdog + } + } + + Serial.print(F("\nYou didn't unplug the cable fast enough. LiBCM will reboot instead.")); + delay(50); //wait for transmit buffer to empty + gpio_turnLiBCM_off(); + } + //$TEST else if ((line[1] == 'T') && (line[2] == 'E') && (line[3] == 'S') && (line[4] == 'T')) { USB_userInterface_runTestCode(line[5]); } diff --git a/Firmware/firmwareLiBCM/src/USB_userInterface.h b/Firmware/firmwareLiBCM/src/USB_userInterface.h index 7f0017c1..4dac9a1d 100644 --- a/Firmware/firmwareLiBCM/src/USB_userInterface.h +++ b/Firmware/firmwareLiBCM/src/USB_userInterface.h @@ -1,4 +1,4 @@ -//Copyright 2021-2023(c) John Sullivan +//Copyright 2021-2024(c) John Sullivan //github.com/doppelhub/Honda_Insight_LiBCM #ifndef USB_userInterface_h diff --git a/Firmware/firmwareLiBCM/src/adc.cpp b/Firmware/firmwareLiBCM/src/adc.cpp index 624767ba..30d5e88e 100644 --- a/Firmware/firmwareLiBCM/src/adc.cpp +++ b/Firmware/firmwareLiBCM/src/adc.cpp @@ -1,4 +1,4 @@ -//Copyright 2021-2023(c) John Sullivan +//Copyright 2021-2024(c) John Sullivan //github.com/doppelhub/Honda_Insight_LiBCM //handles all ADC calls @@ -98,22 +98,27 @@ void adc_updateBatteryCurrent(void) //JTS2doNext: call this function immediately at keyOn //MCM closes pre-contactor ~190 ms after keyOn //MCM closes main contactor ~330 ms after keyOn -void adc_calibrateBatteryCurrentSensorOffset(void) +void adc_calibrateBatteryCurrentSensorOffset(uint8_t isDebugTextSent) { uint16_t adcResult = analogRead(PIN_BATTCURRENT); - int8_t delta = ADC_NOMINAL_0A_COUNTS - adcResult; - - Serial.print(F("\nADC 0A offset: ")); - Serial.print(delta); + bool didTestPass = false; //verify returned value is in the right ballpark if ((delta > -10) && (delta < +10)) { calibratedCurrentSensorOffset = delta; - Serial.print(F(" (pass)")); + didTestPass = true; } - else { Serial.print(F(" (fail)")); } + + if (isDebugTextSent == DEBUG_TEXT_ENABLED) + { + Serial.print(F("\nADC 0A offset: ")); + Serial.print(delta); + + if (didTestPass == true) { Serial.print(F(" (pass)")); } + else { Serial.print(F(" (fail)")); } + } } ///////////////////////////////////////////////////////////////////////////////////////// diff --git a/Firmware/firmwareLiBCM/src/adc.h b/Firmware/firmwareLiBCM/src/adc.h index 47aaa54b..e6089d21 100644 --- a/Firmware/firmwareLiBCM/src/adc.h +++ b/Firmware/firmwareLiBCM/src/adc.h @@ -1,4 +1,4 @@ -//Copyright 2021-2023(c) John Sullivan +//Copyright 2021-2024(c) John Sullivan //github.com/doppelhub/Honda_Insight_LiBCM #ifndef adc_h @@ -16,7 +16,7 @@ uint16_t adc_getTemperature(uint8_t tempToMeasure); - void adc_calibrateBatteryCurrentSensorOffset(void); + void adc_calibrateBatteryCurrentSensorOffset(uint8_t isDebugTextSent); #define ADC_NOMINAL_0A_COUNTS 332 //calculated ADC 10b result when no current flows through sensor #define ADC_MILLIAMPS_PER_COUNT 215 //Derivation here: ~/Electronics/PCB (KiCAD)/RevC/V&V/OEM Current Sensor.ods diff --git a/Firmware/firmwareLiBCM/src/batteryHistory.cpp b/Firmware/firmwareLiBCM/src/batteryHistory.cpp index 3ca49346..948d628c 100644 --- a/Firmware/firmwareLiBCM/src/batteryHistory.cpp +++ b/Firmware/firmwareLiBCM/src/batteryHistory.cpp @@ -1,4 +1,4 @@ -//Copyright 2021-2023(c) John Sullivan +//Copyright 2021-2024(c) John Sullivan //github.com/doppelhub/Honda_Insight_LiBCM //2D array stores total hours battery has spent at each temperature and SoC combination diff --git a/Firmware/firmwareLiBCM/src/batteryHistory.h b/Firmware/firmwareLiBCM/src/batteryHistory.h index 324826b9..823e13c7 100644 --- a/Firmware/firmwareLiBCM/src/batteryHistory.h +++ b/Firmware/firmwareLiBCM/src/batteryHistory.h @@ -1,4 +1,4 @@ -//Copyright 2021-2023(c) John Sullivan +//Copyright 2021-2024(c) John Sullivan //github.com/doppelhub/Honda_Insight_LiBCM #ifndef batteryHistory_h diff --git a/Firmware/firmwareLiBCM/src/battsci.cpp b/Firmware/firmwareLiBCM/src/battsci.cpp index 6c2fcf18..dd854bd0 100755 --- a/Firmware/firmwareLiBCM/src/battsci.cpp +++ b/Firmware/firmwareLiBCM/src/battsci.cpp @@ -1,4 +1,4 @@ -//Copyright 2021-2023(c) John Sullivan +//Copyright 2021-2024(c) John Sullivan //github.com/doppelhub/Honda_Insight_LiBCM //BATTSCI Serial Functions @@ -39,6 +39,7 @@ const uint16_t remap_actualToSpoofedSoC[101] = { 1000, //LiCBM SoC = 100% }; //Data empirically gathered from OEM NiMH IMA system //see ../Firmware/Prototype Building Blocks/Remap SoC.ods for calculations +//JTS2doNow: Changing to "uint16_t previousOutputSoC_deciPercent;" allows OEM SoC gauge to work uint16_t previousOutputSoC_deciPercent = remap_actualToSpoofedSoC[SoC_getBatteryStateNow_percent()]; diff --git a/Firmware/firmwareLiBCM/src/battsci.h b/Firmware/firmwareLiBCM/src/battsci.h index a9bc9381..c35824b7 100755 --- a/Firmware/firmwareLiBCM/src/battsci.h +++ b/Firmware/firmwareLiBCM/src/battsci.h @@ -1,4 +1,4 @@ -//Copyright 2021-2023(c) John Sullivan +//Copyright 2021-2024(c) John Sullivan //github.com/doppelhub/Honda_Insight_LiBCM #ifndef battsci_h diff --git a/Firmware/firmwareLiBCM/src/cellBalance.cpp b/Firmware/firmwareLiBCM/src/cellBalance.cpp index b686519a..bd54e69a 100755 --- a/Firmware/firmwareLiBCM/src/cellBalance.cpp +++ b/Firmware/firmwareLiBCM/src/cellBalance.cpp @@ -1,4 +1,4 @@ -//Copyright 2021-2023(c) John Sullivan +//Copyright 2021-2024(c) John Sullivan //github.com/doppelhub/Honda_Insight_LiBCM //cell balancing Functions diff --git a/Firmware/firmwareLiBCM/src/cellBalance.h b/Firmware/firmwareLiBCM/src/cellBalance.h index 3a1cf6ab..c5e2566e 100755 --- a/Firmware/firmwareLiBCM/src/cellBalance.h +++ b/Firmware/firmwareLiBCM/src/cellBalance.h @@ -1,4 +1,4 @@ -//Copyright 2021-2023(c) John Sullivan +//Copyright 2021-2024(c) John Sullivan //github.com/doppelhub/Honda_Insight_LiBCM #ifndef cellbalance_h diff --git a/Firmware/firmwareLiBCM/src/cpu_map.h b/Firmware/firmwareLiBCM/src/cpu_map.h index 867cd5bf..5371855f 100755 --- a/Firmware/firmwareLiBCM/src/cpu_map.h +++ b/Firmware/firmwareLiBCM/src/cpu_map.h @@ -1,4 +1,4 @@ -//Copyright 2021-2023(c) John Sullivan +//Copyright 2021-2024(c) John Sullivan //github.com/doppelhub/Honda_Insight_LiBCM //cpu_map.h - CPU and pin mapping configuration file diff --git a/Firmware/firmwareLiBCM/src/debugLED.cpp b/Firmware/firmwareLiBCM/src/debugLED.cpp index 665bfa39..e7f7ae0a 100644 --- a/Firmware/firmwareLiBCM/src/debugLED.cpp +++ b/Firmware/firmwareLiBCM/src/debugLED.cpp @@ -1,4 +1,4 @@ -//Copyright 2021-2023(c) John Sullivan +//Copyright 2021-2024(c) John Sullivan //github.com/doppelhub/Honda_Insight_LiBCM //debug stuff diff --git a/Firmware/firmwareLiBCM/src/debugLED.h b/Firmware/firmwareLiBCM/src/debugLED.h index bbc3ff16..395551cc 100644 --- a/Firmware/firmwareLiBCM/src/debugLED.h +++ b/Firmware/firmwareLiBCM/src/debugLED.h @@ -1,4 +1,4 @@ -//Copyright 2021-2023(c) John Sullivan +//Copyright 2021-2024(c) John Sullivan //github.com/doppelhub/Honda_Insight_LiBCM #ifndef debugLED_h diff --git a/Firmware/firmwareLiBCM/src/debugUSB.cpp b/Firmware/firmwareLiBCM/src/debugUSB.cpp index ad280ebd..c2dbfc61 100644 --- a/Firmware/firmwareLiBCM/src/debugUSB.cpp +++ b/Firmware/firmwareLiBCM/src/debugUSB.cpp @@ -1,4 +1,4 @@ -//Copyright 2021-2023(c) John Sullivan +//Copyright 2021-2024(c) John Sullivan //github.com/doppelhub/Honda_Insight_LiBCM //Handles serial debug data transfers from LIBCM to host @@ -295,3 +295,12 @@ void debugUSB_printConfigParameters(void) } ///////////////////////////////////////////////////////////////////////////////////////// + +void debugUSB_printWelcomeMessage(void) +{ + Serial.print(F("\n\nLiBCM v" FW_VERSION ", " BUILD_DATE "\n'$HELP' for info\n")); + debugUSB_printHardwareRevision(); + debugUSB_printConfigParameters(); +} + +///////////////////////////////////////////////////////////////////////////////////////// diff --git a/Firmware/firmwareLiBCM/src/debugUSB.h b/Firmware/firmwareLiBCM/src/debugUSB.h index b35cdaa5..4f7e502c 100644 --- a/Firmware/firmwareLiBCM/src/debugUSB.h +++ b/Firmware/firmwareLiBCM/src/debugUSB.h @@ -1,12 +1,15 @@ -//Copyright 2021-2023(c) John Sullivan +//Copyright 2021-2024(c) John Sullivan //github.com/doppelhub/Honda_Insight_LiBCM #ifndef debugUSB_h #define debugUSB_h - #define TWO_DECIMAL_PLACES 2 + #define TWO_DECIMAL_PLACES 2 #define FOUR_DECIMAL_PLACES 4 + #define DEBUG_TEXT_ENABLED 1 + #define DEBUG_TEXT_DISABLED 0 + void debugUSB_printLatestData(void); void debugUSB_printLatest_data_gridCharger(void); @@ -18,15 +21,13 @@ void debugUSB_printCellBalanceStatus(void); - void debugUSB_printHardwareRevision(void); - void debugUSB_dataTypeToStream_set(uint8_t dataType); uint8_t debugUSB_dataTypeToStream_get(void); void debugUSB_dataUpdatePeriod_ms_set(uint16_t newPeriod); uint16_t debugUSB_dataUpdatePeriod_ms_get(void); - void debugUSB_printConfigParameters(void); + void debugUSB_printWelcomeMessage(void); #define DEBUGUSB_STREAM_POWER 0x11 #define DEBUGUSB_STREAM_BATTMETSCI 0x22 diff --git a/Firmware/firmwareLiBCM/src/fan.cpp b/Firmware/firmwareLiBCM/src/fan.cpp index 3717e10d..b5c9f42c 100644 --- a/Firmware/firmwareLiBCM/src/fan.cpp +++ b/Firmware/firmwareLiBCM/src/fan.cpp @@ -1,4 +1,4 @@ -//Copyright 2021-2023(c) John Sullivan +//Copyright 2021-2024(c) John Sullivan //github.com/doppelhub/Honda_Insight_LiBCM //handles fans diff --git a/Firmware/firmwareLiBCM/src/gpio.cpp b/Firmware/firmwareLiBCM/src/gpio.cpp index 218fdb05..c4f9e91d 100644 --- a/Firmware/firmwareLiBCM/src/gpio.cpp +++ b/Firmware/firmwareLiBCM/src/gpio.cpp @@ -1,4 +1,4 @@ -//Copyright 2021-2023(c) John Sullivan +//Copyright 2021-2024(c) John Sullivan //github.com/doppelhub/Honda_Insight_LiBCM //all digitalRead(), digitalWrite(), analogRead(), analogWrite() functions live here @@ -39,16 +39,11 @@ void gpio_begin(void) digitalWrite(PIN_TURNOFFLiBCM,LOW); pinMode(PIN_HMI_EN,OUTPUT); - - //Controls BCM current sensor, constant 5V load, and BATTSCI/METSCI biasing pinMode(PIN_SENSOR_EN,OUTPUT); - gpio_turnPowerSensors_on(); //if the key is off when LiBCM first powers up, the keyOff handler will turn the sensors back off - pinMode(PIN_LED1,OUTPUT); pinMode(PIN_LED2,OUTPUT); pinMode(PIN_LED3,OUTPUT); pinMode(PIN_LED4,OUTPUT); - analogWrite(PIN_MCME_PWM,0); pinMode(PIN_FAN_PWM,OUTPUT); pinMode(PIN_FANOEM_LOW,OUTPUT); diff --git a/Firmware/firmwareLiBCM/src/gridCharger.cpp b/Firmware/firmwareLiBCM/src/gridCharger.cpp index 5b8641cc..665b62ff 100644 --- a/Firmware/firmwareLiBCM/src/gridCharger.cpp +++ b/Firmware/firmwareLiBCM/src/gridCharger.cpp @@ -1,4 +1,4 @@ -//Copyright 2021-2023(c) John Sullivan +//Copyright 2021-2024(c) John Sullivan //github.com/doppelhub/Honda_Insight_LiBCM #include "libcm.h" @@ -121,7 +121,7 @@ void chargerControlSignals_handler(void) if (isChargingAllowed_previous != YES__CHARGING_ALLOWED) { Serial.print(F("\nCharging")); - adc_calibrateBatteryCurrentSensorOffset(); + adc_calibrateBatteryCurrentSensorOffset(DEBUG_TEXT_ENABLED); } runFansIfNeeded(); //JTS2doLater: run fans as needed even when charging not allowed (e.g. to cool a hot pack) diff --git a/Firmware/firmwareLiBCM/src/gridCharger.h b/Firmware/firmwareLiBCM/src/gridCharger.h index 2b3ce471..9240a7af 100644 --- a/Firmware/firmwareLiBCM/src/gridCharger.h +++ b/Firmware/firmwareLiBCM/src/gridCharger.h @@ -1,4 +1,4 @@ -//Copyright 2021-2023(c) John Sullivan +//Copyright 2021-2024(c) John Sullivan //github.com/doppelhub/Honda_Insight_LiBCM #ifndef gridCharger_h diff --git a/Firmware/firmwareLiBCM/src/key.cpp b/Firmware/firmwareLiBCM/src/key.cpp index 007005dc..fb2b772a 100755 --- a/Firmware/firmwareLiBCM/src/key.cpp +++ b/Firmware/firmwareLiBCM/src/key.cpp @@ -1,4 +1,4 @@ -//Copyright 2021-2023(c) John Sullivan +//Copyright 2021-2024(c) John Sullivan //github.com/doppelhub/Honda_Insight_LiBCM //functions related to ignition (key) status @@ -21,12 +21,13 @@ void key_handleKeyEvent_off(void) METSCI_disable(); LTC68042cell_acquireAllCellVoltages(); SoC_updateUsingLatestOpenCircuitVoltage(); //JTS2doLater: Add ten minute delay before VoC->SoC LUT - adc_calibrateBatteryCurrentSensorOffset(); + adc_calibrateBatteryCurrentSensorOffset(DEBUG_TEXT_ENABLED); gpio_turnPowerSensors_off(); LTC68042configure_handleKeyStateChange(); vPackSpoof_handleKeyOFF(); //JTS2doLater: Add built-in test suite, including VREF, VCELL, Balancing, temp verify (batt and OEM), etc. eeprom_checkForExpiredFirmware(); + LTC68042configure_doesActualPackSizeMatchUserConfig(); time_latestKeyOff_ms_set(millis()); //MUST RUN LAST! } @@ -42,6 +43,7 @@ void key_handleKeyEvent_on(void) gpio_turnPowerSensors_on(); LTC68042configure_programVolatileDefaults(); //turn discharge resistors off, set ADC LPF, etc. LTC68042configure_handleKeyStateChange(); + vPackSpoof_handleKeyON(); LED(1,HIGH); time_latestKeyOn_ms_set(millis()); //MUST RUN LAST! @@ -49,10 +51,12 @@ void key_handleKeyEvent_on(void) ///////////////////////////////////////////////////////////////////////////////////////// +//JTS2doLater: make 'KEYSTATE_OFF_JUSTOCCURRED' persist for one second (before reporting 'keyOff') bool key_didStateChange(void) { bool didKeyStateChange = NO; + //JTS2doLater: move to handler if (gpio_keyStateNow() == GPIO_KEY_ON) { keyState_sampled = KEYSTATE_ON; } else { keyState_sampled = KEYSTATE_OFF; } @@ -99,3 +103,28 @@ uint8_t key_getSampledState(void) } ///////////////////////////////////////////////////////////////////////////////////////// + +void keyOn_coldBootTasks(void) +{ + //initialize hardware + gpio_turnPowerSensors_on(); + LTC68042configure_pulseChipSelectLow(SPECIFIED_MAX_WAKEUP_TIME_LTCCORE_MICROSECONDS); //wake LTC6804 + LTC68042cell_nextVoltages(); //first call starts LTC6804 conversion + uint32_t timeSinceLTC6804conversionStarted_us = millis(); + + //other startup initialization tasks + vPackSpoof_handleKeyON(); + keyState_previous = KEYSTATE_ON; //prevent key_handleKeyEvent_on() from repeating many of these tasks + METSCI_enable(); + LED(3,ON); + + //process cell voltages + while(millis() - timeSinceLTC6804conversionStarted_us < LTC6804_MAX_CONVERSION_TIME_ms) { ; } //wait for conversion to finish + while(LTC68042cell_nextVoltages() != CELL_DATA_PROCESSED) { ; } //read all cell voltages back + vPackSpoof_setVoltage(); + SoC_setBatteryStateNow_percent(SoC_estimateFromRestingCellVoltage_percent()); + BATTSCI_enable(); //must occur after we have valid Vcell data + adc_calibrateBatteryCurrentSensorOffset(DEBUG_TEXT_DISABLED); //current sensor settles almost immediately +} + +///////////////////////////////////////////////////////////////////////////////////////// diff --git a/Firmware/firmwareLiBCM/src/key.h b/Firmware/firmwareLiBCM/src/key.h index e07ac5d9..986c5cb5 100755 --- a/Firmware/firmwareLiBCM/src/key.h +++ b/Firmware/firmwareLiBCM/src/key.h @@ -10,4 +10,6 @@ uint8_t key_getSampledState(void); + void keyOn_coldBootTasks(void); + #endif diff --git a/Firmware/firmwareLiBCM/src/lcdState.cpp b/Firmware/firmwareLiBCM/src/lcdState.cpp index 926344b2..da675704 100755 --- a/Firmware/firmwareLiBCM/src/lcdState.cpp +++ b/Firmware/firmwareLiBCM/src/lcdState.cpp @@ -1,4 +1,4 @@ -//Copyright 2021-2023(c) John Sullivan +//Copyright 2021-2024(c) John Sullivan //github.com/doppelhub/Honda_Insight_LiBCM //state machine that controls 4x20 lcd display. diff --git a/Firmware/firmwareLiBCM/src/lcdTransmit.cpp b/Firmware/firmwareLiBCM/src/lcdTransmit.cpp index 85c9d959..0f5da630 100755 --- a/Firmware/firmwareLiBCM/src/lcdTransmit.cpp +++ b/Firmware/firmwareLiBCM/src/lcdTransmit.cpp @@ -1,4 +1,4 @@ -//Copyright 2021-2023(c) John Sullivan +//Copyright 2021-2024(c) John Sullivan //github.com/doppelhub/Honda_Insight_LiBCM //handles all communication with 4x20 lcd display diff --git a/Firmware/firmwareLiBCM/src/lcdTransmit.h b/Firmware/firmwareLiBCM/src/lcdTransmit.h index efb1512d..03fb7cb3 100644 --- a/Firmware/firmwareLiBCM/src/lcdTransmit.h +++ b/Firmware/firmwareLiBCM/src/lcdTransmit.h @@ -1,4 +1,4 @@ -//Copyright 2021-2023(c) John Sullivan +//Copyright 2021-2024(c) John Sullivan //github.com/doppelhub/Honda_Insight_LiBCM #ifndef lcdTransmit_h diff --git a/Firmware/firmwareLiBCM/src/lcd_I2C.cpp b/Firmware/firmwareLiBCM/src/lcd_I2C.cpp index 2eca95a4..9318d31e 100755 --- a/Firmware/firmwareLiBCM/src/lcd_I2C.cpp +++ b/Firmware/firmwareLiBCM/src/lcd_I2C.cpp @@ -1,4 +1,4 @@ -//Copyright 2021-2023(c) John Sullivan +//Copyright 2021-2024(c) John Sullivan //github.com/doppelhub/Honda_Insight_LiBCM /* diff --git a/Firmware/firmwareLiBCM/src/lcd_I2C.h b/Firmware/firmwareLiBCM/src/lcd_I2C.h index 749f27ee..b9d16818 100755 --- a/Firmware/firmwareLiBCM/src/lcd_I2C.h +++ b/Firmware/firmwareLiBCM/src/lcd_I2C.h @@ -1,4 +1,4 @@ -//Copyright 2021-2023(c) John Sullivan +//Copyright 2021-2024(c) John Sullivan //github.com/doppelhub/Honda_Insight_LiBCM /* diff --git a/Firmware/firmwareLiBCM/src/libcm.h b/Firmware/firmwareLiBCM/src/libcm.h index c9984ca5..891ab0be 100644 --- a/Firmware/firmwareLiBCM/src/libcm.h +++ b/Firmware/firmwareLiBCM/src/libcm.h @@ -1,4 +1,4 @@ -//Copyright 2021-2023(c) John Sullivan +//Copyright 2021-2024(c) John Sullivan //github.com/doppelhub/Honda_Insight_LiBCM //main LiBCM include file diff --git a/Firmware/firmwareLiBCM/src/metsci.cpp b/Firmware/firmwareLiBCM/src/metsci.cpp index fedde3c2..b0e3e31f 100644 --- a/Firmware/firmwareLiBCM/src/metsci.cpp +++ b/Firmware/firmwareLiBCM/src/metsci.cpp @@ -1,4 +1,4 @@ -//Copyright 2021-2023(c) John Sullivan +//Copyright 2021-2024(c) John Sullivan //github.com/doppelhub/Honda_Insight_LiBCM //METSCI Serial Functions diff --git a/Firmware/firmwareLiBCM/src/metsci.h b/Firmware/firmwareLiBCM/src/metsci.h index 73d267e2..219764d7 100644 --- a/Firmware/firmwareLiBCM/src/metsci.h +++ b/Firmware/firmwareLiBCM/src/metsci.h @@ -1,4 +1,4 @@ -//Copyright 2021-2023(c) John Sullivan +//Copyright 2021-2024(c) John Sullivan //github.com/doppelhub/Honda_Insight_LiBCM #ifndef metsci_h diff --git a/Firmware/firmwareLiBCM/src/status.cpp b/Firmware/firmwareLiBCM/src/status.cpp index 42b59d80..e8da9336 100644 --- a/Firmware/firmwareLiBCM/src/status.cpp +++ b/Firmware/firmwareLiBCM/src/status.cpp @@ -1,4 +1,4 @@ -//Copyright 2021-2023(c) John Sullivan +//Copyright 2021-2024(c) John Sullivan //github.com/doppelhub/Honda_Insight_LiBCM //Stores runtime execution information //used to debug LiBCM diff --git a/Firmware/firmwareLiBCM/src/status.h b/Firmware/firmwareLiBCM/src/status.h index 6ff0cf68..d23ec4e3 100644 --- a/Firmware/firmwareLiBCM/src/status.h +++ b/Firmware/firmwareLiBCM/src/status.h @@ -1,4 +1,4 @@ -//Copyright 2021-2023(c) John Sullivan +//Copyright 2021-2024(c) John Sullivan //github.com/doppelhub/Honda_Insight_LiBCM #ifndef runtimeStatus_h diff --git a/Firmware/firmwareLiBCM/src/temperature.cpp b/Firmware/firmwareLiBCM/src/temperature.cpp index 27b791b2..06def460 100644 --- a/Firmware/firmwareLiBCM/src/temperature.cpp +++ b/Firmware/firmwareLiBCM/src/temperature.cpp @@ -1,4 +1,4 @@ -//Copyright 2021-2023(c) John Sullivan +//Copyright 2021-2024(c) John Sullivan //github.com/doppelhub/Honda_Insight_LiBCM //measures OEM temperature sensors @@ -206,7 +206,7 @@ void temperature_handler(void) uint8_t keyState_Now = key_getSampledState(); //prevent mid-loop key state change - keyState_Now = turnSensorsOff_whenKeyStateChanges(keyState_Now); + keyState_Now = turnSensorsOff_whenKeyStateChanges(keyState_Now); //JTS2doNow: function returns value meant for tempSensorState //writing to wrong variable? static uint32_t latestTempMeasurement_ms = 0; static uint32_t latestSensorTurnon_ms = 0; diff --git a/Firmware/firmwareLiBCM/src/temperature.h b/Firmware/firmwareLiBCM/src/temperature.h index de56a877..6325e05b 100644 --- a/Firmware/firmwareLiBCM/src/temperature.h +++ b/Firmware/firmwareLiBCM/src/temperature.h @@ -1,4 +1,4 @@ -//Copyright 2021-2023(c) John Sullivan +//Copyright 2021-2024(c) John Sullivan //github.com/doppelhub/Honda_Insight_LiBCM #ifndef temperature_h diff --git a/Firmware/firmwareLiBCM/src/time.cpp b/Firmware/firmwareLiBCM/src/time.cpp index 3225d9d8..cf7c7dbd 100755 --- a/Firmware/firmwareLiBCM/src/time.cpp +++ b/Firmware/firmwareLiBCM/src/time.cpp @@ -1,4 +1,4 @@ -//Copyright 2021-2023(c) John Sullivan +//Copyright 2021-2024(c) John Sullivan //github.com/doppelhub/Honda_Insight_LiBCM //stores various system millisecond timers @@ -148,7 +148,7 @@ uint16_t time_hertz_to_milliseconds(uint8_t hertz) void time_handler(void) { - updateKeyOffTaskFlag(); + if (key_getSampledState() == KEYSTATE_OFF) { updateKeyOffTaskFlag(); } } ///////////////////////////////////////////////////////////////////////////////////////// diff --git a/Firmware/firmwareLiBCM/src/vPackSpoof.cpp b/Firmware/firmwareLiBCM/src/vPackSpoof.cpp index 79f41d39..2a03b8aa 100755 --- a/Firmware/firmwareLiBCM/src/vPackSpoof.cpp +++ b/Firmware/firmwareLiBCM/src/vPackSpoof.cpp @@ -1,4 +1,4 @@ -//Copyright 2021-2023(c) John Sullivan +//Copyright 2021-2024(c) John Sullivan //github.com/doppelhub/Honda_Insight_LiBCM /*The MCM measures pack voltage in three different spots: @@ -20,14 +20,18 @@ uint8_t vPackSpoof_getSpoofedPackVoltage(void) { return spoofedPackVoltage; } ///////////////////////////////////////////////////////////////////////////////////////// -void vPackSpoof_handleKeyON(void) { ; } +void vPackSpoof_handleKeyON(void) +{ + analogWrite(PIN_VPIN_OUT_PWM, 0); + analogWrite(PIN_MCME_PWM , 0); +} ///////////////////////////////////////////////////////////////////////////////////////// void vPackSpoof_handleKeyOFF(void) { - pinMode(PIN_VPIN_OUT_PWM,INPUT); //set VPIN high impedance (to save power) - pinMode(PIN_MCME_PWM, INPUT); //Set MCMe high impedance (to save power) + pinMode(PIN_VPIN_OUT_PWM, INPUT); //set VPIN high impedance (to save power) + pinMode(PIN_MCME_PWM, INPUT); //Set MCMe high impedance (to save power) } ///////////////////////////////////////////////////////////////////////////////////////// @@ -241,8 +245,8 @@ void vPackSpoof_setVoltage(void) { spoofVoltage_calculateValue(); //result saved in 'spoofedPackVoltage' - spoofVoltage_VPINout(); spoofVoltageMCMe(); + spoofVoltage_VPINout(); BATTSCI_setPackVoltage(spoofedPackVoltage); } diff --git a/Firmware/firmwareLiBCM/src/vPackSpoof.h b/Firmware/firmwareLiBCM/src/vPackSpoof.h index bcdf13be..02b09657 100644 --- a/Firmware/firmwareLiBCM/src/vPackSpoof.h +++ b/Firmware/firmwareLiBCM/src/vPackSpoof.h @@ -1,4 +1,4 @@ -//Copyright 2021-2023(c) John Sullivan +//Copyright 2021-2024(c) John Sullivan //github.com/doppelhub/Honda_Insight_LiBCM #ifndef vpackspoof_h