File tree 1 file changed +7
-1
lines changed
src/platforms/common/stm32
1 file changed +7
-1
lines changed Original file line number Diff line number Diff line change @@ -35,6 +35,7 @@ uint32_t target_clk_divider = 0;
35
35
static size_t morse_tick = 0 ;
36
36
#if defined(PLATFORM_HAS_POWER_SWITCH ) && defined(STM32F1 )
37
37
static uint8_t monitor_ticks = 0 ;
38
+ static uint8_t monitor_error_count = 0 ;
38
39
39
40
/* Derived from calculating (1.2V / 3.0V) * 4096 */
40
41
#define ADC_VREFINT_MAX 1638U
@@ -119,7 +120,12 @@ void sys_tick_handler(void)
119
120
120
121
/* Now compare the reference against the known good range */
121
122
if (ref > ADC_VREFINT_MAX || ref < ADC_VREFINT_MIN ) {
122
- /* Something's wrong, so turn tpwr off and set the morse blink pattern */
123
+ monitor_error_count ++ ;
124
+ } else if (monitor_error_count )
125
+ monitor_error_count -- ;
126
+
127
+ /* Something's wrong, and it is not a glitch, so turn tpwr off and set the morse blink pattern */
128
+ if (monitor_error_count > 3 ) {
123
129
platform_target_set_power (false);
124
130
morse ("TPWR ERROR" , true);
125
131
}
You can’t perform that action at this time.
0 commit comments