summaryrefslogtreecommitdiff
path: root/src/lpc/ao_timer_lpc.c
diff options
context:
space:
mode:
authorKeith Packard <keithp@keithp.com>2013-06-21 19:39:27 -0700
committerKeith Packard <keithp@keithp.com>2013-06-22 00:49:59 -0700
commit23f11b188fc6aacd29e7f01a7d8a40853b7655df (patch)
treeb6dcec2f56e19164044bb497d67edd0e000d588b /src/lpc/ao_timer_lpc.c
parente9e713bc8ab2080d5c1c38570b112f13c886bd11 (diff)
altos/lpc: Enable brown-out-detector
Make sure the processor does something sensible when the power disappears. Signed-off-by: Keith Packard <keithp@keithp.com>
Diffstat (limited to 'src/lpc/ao_timer_lpc.c')
-rw-r--r--src/lpc/ao_timer_lpc.c11
1 files changed, 10 insertions, 1 deletions
diff --git a/src/lpc/ao_timer_lpc.c b/src/lpc/ao_timer_lpc.c
index c0de90a3..44fb410e 100644
--- a/src/lpc/ao_timer_lpc.c
+++ b/src/lpc/ao_timer_lpc.c
@@ -100,6 +100,15 @@ ao_clock_init(void)
(1 << LPC_SCB_SYSAHBCLKCTRL_GPIO) |
(1 << LPC_SCB_SYSAHBCLKCTRL_IOCON));
+ /* Enable the brown-out detection at the highest voltage to
+ * make sure the flash part remains happy
+ */
+
+ lpc_scb.pdruncfg &= ~(1 << LPC_SCB_PDRUNCFG_BOD_PD);
+ lpc_scb.bodctrl = ((LPC_SCB_BOD_BODRSTLEV_2_63 << LPC_SCB_BOD_BODRSTLEV) |
+ (LPC_SCB_BOD_BODINTVAL_RESERVED << LPC_SCB_BOD_BODINTVAL) |
+ (1 << LPC_SCB_BOD_BODRSTENA));
+
/* Turn the IRC clock back on */
lpc_scb.pdruncfg &= ~(1 << LPC_SCB_PDRUNCFG_IRC_PD);
ao_clock_delay();
@@ -194,7 +203,7 @@ ao_clock_init(void)
/* Power down everything we don't need */
lpc_scb.pdruncfg = ((1 << LPC_SCB_PDRUNCFG_IRCOUT_PD) |
(1 << LPC_SCB_PDRUNCFG_IRC_PD) |
- (1 << LPC_SCB_PDRUNCFG_BOD_PD) |
+ (0 << LPC_SCB_PDRUNCFG_BOD_PD) |
(1 << LPC_SCB_PDRUNCFG_ADC_PD) |
(1 << LPC_SCB_PDRUNCFG_WDTOSC_PD) |
(1 << LPC_SCB_PDRUNCFG_USBPLL_PD) |