From 23f11b188fc6aacd29e7f01a7d8a40853b7655df Mon Sep 17 00:00:00 2001 From: Keith Packard Date: Fri, 21 Jun 2013 19:39:27 -0700 Subject: altos/lpc: Enable brown-out-detector Make sure the processor does something sensible when the power disappears. Signed-off-by: Keith Packard --- src/lpc/ao_timer_lpc.c | 11 ++++++++++- 1 file changed, 10 insertions(+), 1 deletion(-) (limited to 'src/lpc/ao_timer_lpc.c') 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) | -- cgit v1.2.3