From 74bd23dedc9bcc7bed4d957e00b1f5e29a6f0c1c Mon Sep 17 00:00:00 2001 From: "Jeffrey M. Friesen" Date: Mon, 10 Aug 2020 09:28:07 -0700 Subject: [PATCH] Prevent power switch from working when stormcore gets too hot. Fix bug in median filter. --- hwconf/hw_stormcore_100d.c | 2 +- hwconf/hw_stormcore_100s.h | 4 ++-- hwconf/hw_stormcore_60d.c | 2 +- hwconf/hw_stormcore_60d.h | 6 +++--- utils.c | 2 +- 5 files changed, 8 insertions(+), 8 deletions(-) diff --git a/hwconf/hw_stormcore_100d.c b/hwconf/hw_stormcore_100d.c index a230b456..1b5a749d 100644 --- a/hwconf/hw_stormcore_100d.c +++ b/hwconf/hw_stormcore_100d.c @@ -380,7 +380,7 @@ void smart_switch_shut_down(void) { } bool smart_switch_is_pressed(void) { - if(palReadPad(SWITCH_IN_GPIO, SWITCH_IN_PIN) == 1) + if(palReadPad(SWITCH_IN_GPIO, SWITCH_IN_PIN) == 1 && (mc_interface_temp_fet_filtered() < 68.0)) return true; else return false; diff --git a/hwconf/hw_stormcore_100s.h b/hwconf/hw_stormcore_100s.h index 33b71c1f..ba0237c4 100644 --- a/hwconf/hw_stormcore_100s.h +++ b/hwconf/hw_stormcore_100s.h @@ -240,9 +240,9 @@ #endif // Setting limits -#define HW_LIM_CURRENT -120.0, 120.0 +#define HW_LIM_CURRENT -180.0, 180.0 #define HW_LIM_CURRENT_IN -100.0, 100.0 -#define HW_LIM_CURRENT_ABS 0.0, 160.0 +#define HW_LIM_CURRENT_ABS 0.0, 200.0 #define HW_LIM_VIN 6.0, 92.0 #define HW_LIM_ERPM -200e3, 200e3 #define HW_LIM_DUTY_MIN 0.0, 0.1 diff --git a/hwconf/hw_stormcore_60d.c b/hwconf/hw_stormcore_60d.c index e9d98393..2a2096d0 100644 --- a/hwconf/hw_stormcore_60d.c +++ b/hwconf/hw_stormcore_60d.c @@ -376,7 +376,7 @@ void smart_switch_shut_down(void) { } bool smart_switch_is_pressed(void) { - if(palReadPad(SWITCH_IN_GPIO, SWITCH_IN_PIN) == 1) + if(palReadPad(SWITCH_IN_GPIO, SWITCH_IN_PIN) == 1 && (mc_interface_temp_fet_filtered() < 68.0)) return true; else return false; diff --git a/hwconf/hw_stormcore_60d.h b/hwconf/hw_stormcore_60d.h index 3dbdd16f..046fea93 100644 --- a/hwconf/hw_stormcore_60d.h +++ b/hwconf/hw_stormcore_60d.h @@ -45,11 +45,11 @@ #define SWITCH_PRECHARGED_GPIO GPIOE #define SWITCH_PRECHARGED_PIN 2 #define SWITCH_LED_3_GPIO GPIOD -#define SWITCH_LED_3_PIN 15 +#define SWITCH_LED_3_PIN 11 #define SWITCH_LED_2_GPIO GPIOD #define SWITCH_LED_2_PIN 10 #define SWITCH_LED_1_GPIO GPIOD -#define SWITCH_LED_1_PIN 11 +#define SWITCH_LED_1_PIN 15 #define LED_PWM1_ON() palClearPad(SWITCH_LED_1_GPIO,SWITCH_LED_1_PIN) #define LED_PWM1_OFF() palSetPad(SWITCH_LED_1_GPIO,SWITCH_LED_1_PIN) @@ -212,7 +212,7 @@ #define V_REG 3.3 #endif #ifndef VIN_R1 -#define VIN_R1 68000.0 +#define VIN_R1 39000.0 #endif #ifndef VIN_R2 #define VIN_R2 2200.0 diff --git a/utils.c b/utils.c index 72279e2d..9fae2273 100644 --- a/utils.c +++ b/utils.c @@ -814,7 +814,7 @@ static int uint16_cmp_func (const void *a, const void *b) { uint16_t utils_median_filter_uint16_run(uint16_t *buffer, unsigned int *buffer_index, unsigned int filter_len, uint16_t sample) { - buffer[*buffer_index++] = sample; + buffer[(*buffer_index)++] = sample; *buffer_index %= filter_len; uint16_t buffer_sorted[filter_len]; // Assume we have enough stack space memcpy(buffer_sorted, buffer, sizeof(uint16_t) * filter_len);