diff --git a/conf_general.c b/conf_general.c index 9db234e6e9..87c717308a 100644 --- a/conf_general.c +++ b/conf_general.c @@ -1262,7 +1262,7 @@ int conf_general_measure_flux_linkage_openloop(float current, float duty, * Send motor configuration if the detection succeeds. * * @result - * 2: AS5147 detected successfully + * 2: AS5047 detected successfully * 1: Hall sensors detected successfully * 0: No sensors detected and sensorless mode applied successfully * -1: Detection failed diff --git a/hwconf/Ubox/100v/hw_ubox_100_core.c b/hwconf/Ubox/100v/hw_ubox_100_core.c old mode 100644 new mode 100755 index a5a27702c8..06bc5bd055 --- a/hwconf/Ubox/100v/hw_ubox_100_core.c +++ b/hwconf/Ubox/100v/hw_ubox_100_core.c @@ -42,7 +42,7 @@ #define UBOX_QUERY_POWER_KEY_IO() (palReadPad(GPIOC, 13)) -void shutdown_ubox_init(void); +void shutdown_init(void); // Variables static volatile bool i2c_running = false; @@ -131,8 +131,8 @@ void hw_init_gpio(void) { palSetPadMode(GPIOC, 13, PAL_MODE_OUTPUT_OPENDRAIN | PAL_MODE_INPUT_PULLUP); UBOX_POWER_KEY_IO_RELEASE(); - - shutdown_ubox_init(); + + shutdown_init(); } void hw_setup_adc_channels(void) { @@ -287,21 +287,37 @@ float hw100_250_get_temp(void) { // Private variables static bool volatile m_button_pressed = false; static volatile float m_inactivity_time = 0.0; -static THD_WORKING_AREA(shutdown_ubox_thread_wa, 256); +static THD_WORKING_AREA(shutdown_thread_wa, 256); static mutex_t m_sample_mutex; static volatile bool m_init_done = false; static volatile bool m_sampling_disabled = false; // Private functions -static THD_FUNCTION(shutdown_ubox_thread, arg); +static THD_FUNCTION(shutdown_thread, arg); -void shutdown_ubox_init(void) { - chMtxObjectInit(&m_sample_mutex); - chThdCreateStatic(shutdown_ubox_thread_wa, sizeof(shutdown_ubox_thread_wa), NORMALPRIO, shutdown_ubox_thread, NULL); - m_init_done = true; +void shutdown_init(void) { + if(!m_init_done){ + chMtxObjectInit(&m_sample_mutex); + chThdCreateStatic(shutdown_thread_wa, sizeof(shutdown_thread_wa), NORMALPRIO, shutdown_thread, NULL); + m_init_done = true; + } } -static bool do_shutdown_ubox(void) { +void shutdown_reset_timer(void) { + m_inactivity_time = 0.0; +} + +float shutdown_get_inactivity_time(void) { + return m_inactivity_time; +} + +void shutdown_hold(bool hold) { + (void)hold; +} + +// TODO: Doesn't use resample. Maybe in future allow resampling if enPOWER_KEY_TYPE is momentary? +bool do_shutdown(bool resample) { + (void)resample; conf_general_store_backup_data(); chThdSleepMilliseconds(100); @@ -310,7 +326,6 @@ static bool do_shutdown_ubox(void) { return true; } - typedef enum { power_key_type_undecided = 0, power_key_type_momentary, @@ -321,7 +336,7 @@ static enPOWER_KEY_TYPE power_key_type = power_key_type_undecided; static uint32_t power_key_pressed_ms = 0; static bool power_key_pressed_when_power_on = false; -static THD_FUNCTION(shutdown_ubox_thread, arg) { +static THD_FUNCTION(shutdown_thread, arg) { (void)arg; chRegSetThreadName("Shutdown_ubox"); @@ -352,6 +367,7 @@ static THD_FUNCTION(shutdown_ubox_thread, arg) { } } else { if((power_key_pressed_ms > 50) && (power_key_pressed_ms < 500)) { + // TODO: Could toggle different led types here?? power_key_click = 1; } power_key_pressed_ms = 0; @@ -394,7 +410,7 @@ static THD_FUNCTION(shutdown_ubox_thread, arg) { //Inactive after 10 seconds, MCU cancels the enable signal, regulator shuts down if button released. m_inactivity_time += dt; if (m_inactivity_time >= 10.0f) { - do_shutdown_ubox(); + do_shutdown(false); } break; case SHUTDOWN_MODE_ALWAYS_ON: @@ -414,7 +430,7 @@ static THD_FUNCTION(shutdown_ubox_thread, arg) { break; case SHUTDOWN_MODE_TOGGLE_BUTTON_ONLY: if(clicked) { - do_shutdown_ubox(); + do_shutdown(true); } break; default: break; @@ -434,7 +450,7 @@ static THD_FUNCTION(shutdown_ubox_thread, arg) { default: break; } if (m_inactivity_time >= shutdown_timeout) { - do_shutdown_ubox(); + do_shutdown(false); } } else { //Because SHUTDOWN_MODE_ALWAYS_OFF's implementation will check m_inactivity_time. @@ -444,7 +460,7 @@ static THD_FUNCTION(shutdown_ubox_thread, arg) { } if(power_key_pressed_ms > 2000) { - do_shutdown_ubox(); + do_shutdown(true); } } else { m_inactivity_time += dt; diff --git a/hwconf/Ubox/100v/hw_ubox_100_core.h b/hwconf/Ubox/100v/hw_ubox_100_core.h old mode 100644 new mode 100755 index 1257c0af50..9cd2886552 --- a/hwconf/Ubox/100v/hw_ubox_100_core.h +++ b/hwconf/Ubox/100v/hw_ubox_100_core.h @@ -22,6 +22,8 @@ #ifndef HW_UBOX_V2_100_CORE_H_ #define HW_UBOX_V2_100_CORE_H_ +#define HW_SHUTDOWN_CUSTOM + #ifdef HW_UBOX_V2_100 #define HW_NAME "UBOX_V2_100" #elif defined (HW_UBOX_SINGLE_100) diff --git a/hwconf/floatwheel/hw_adv_core.h b/hwconf/floatwheel/hw_adv_core.h index 384a2d69b1..5290af95d0 100644 --- a/hwconf/floatwheel/hw_adv_core.h +++ b/hwconf/floatwheel/hw_adv_core.h @@ -194,11 +194,19 @@ #define HW_SPI_PORT_MISO GPIOA #define HW_SPI_PIN_MISO 6 +#ifdef ADV200 // IMU: BMI160 #define BMI160_SDA_GPIO GPIOB #define BMI160_SDA_PIN 2 #define BMI160_SCL_GPIO GPIOA #define BMI160_SCL_PIN 15 +#else +// LSM6DS3 +#define LSM6DS3_SDA_GPIO GPIOB +#define LSM6DS3_SDA_PIN 2 +#define LSM6DS3_SCL_GPIO GPIOA +#define LSM6DS3_SCL_PIN 15 +#endif // NRF SWD #define NRF5x_SWDIO_GPIO GPIOB diff --git a/hwconf/shutdown.c b/hwconf/shutdown.c index 73e3485759..07ef167645 100644 --- a/hwconf/shutdown.c +++ b/hwconf/shutdown.c @@ -26,7 +26,9 @@ #include "lispif.h" #endif -#ifdef HW_SHUTDOWN_HOLD_ON +#ifdef HW_SHUTDOWN_CUSTOM +// Do nothing. All shutdown functionality is handled in the hardware file. +#elif defined(HW_SHUTDOWN_HOLD_ON) // Private variables bool volatile m_button_pressed = false; diff --git a/package_firmware.py b/package_firmware.py index 06599c1ebf..35073dc4fd 100755 --- a/package_firmware.py +++ b/package_firmware.py @@ -100,7 +100,7 @@ def get_git_revision_short_hash() -> str: package_dict["Little_FOCer"] = [['Little_FOCer', default_name]] package_dict["Little_FOCer_V3"] = [['Little_FOCer_V3', default_name]] package_dict["Little_FOCer_V3_1"] = [['Little_FOCer_V3_1', default_name]] -package_dict["Little_FOCer_4"] = [['Little_FOCer_4', default_name]] +package_dict["Little_FOCer_V4"] = [['Little_FOCer_V4', default_name]] package_dict["TRONIC_250R"] = [['TRONIC_250R', default_name]] package_dict["X12_PRO24"] = [['x12_pro24', default_name]] package_dict["X12_PRO30"] = [['x12_pro30', default_name]]