diff options
Diffstat (limited to 'board/servo_micro')
-rw-r--r-- | board/servo_micro/board.c | 10 | ||||
-rw-r--r-- | board/servo_micro/board.h | 4 |
2 files changed, 14 insertions, 0 deletions
diff --git a/board/servo_micro/board.c b/board/servo_micro/board.c index 7d9bd0bac5..ca97b1fbd7 100644 --- a/board/servo_micro/board.c +++ b/board/servo_micro/board.c @@ -13,6 +13,7 @@ #include "queue_policies.h" #include "registers.h" #include "spi.h" +#include "system.h" #include "task.h" #include "timer.h" #include "update_fw.h" @@ -673,6 +674,15 @@ const unsigned int i2c_ports_used = ARRAY_SIZE(i2c_ports); int usb_i2c_board_is_enabled(void) { return 1; } +void pvd_interrupt(void) { + /* Clear Pending Register */ + STM32_EXTI_PR = EXTI_PVD_EVENT; + /* Handle recovery by rebooting the system */ + system_reset(0); +} + +DECLARE_IRQ(STM32_IRQ_PVD, pvd_interrupt, HOOK_PRIO_FIRST); + /****************************************************************************** * Initialize board. */ diff --git a/board/servo_micro/board.h b/board/servo_micro/board.h index 99fa722fb4..9a0ca5824d 100644 --- a/board/servo_micro/board.h +++ b/board/servo_micro/board.h @@ -32,6 +32,10 @@ /* Optional features */ #define CONFIG_STM_HWTIMER32 #define CONFIG_HW_CRC +#define CONFIG_PVD +/* See 'Programmable voltage detector characteristics' in the STM32F072x8 Datasheet. + PVD Threshold 1 corresponds to a falling voltage threshold of min:2.09V, max:2.27V. */ +#define PVD_THRESHOLD (1) /* USB Configuration */ #define CONFIG_USB |