/***************************************************************************** */
struct lpc_desc_private {
uint32_t main_clock;
- uint32_t brown_out_detection_enabled;
+ uint8_t brown_out_detection_enabled;
+ uint8_t need_IRC;
};
static struct lpc_desc_private lpc_private = {
.main_clock = LPC_IRC_OSC_CLK,
.brown_out_detection_enabled = 0,
+ .need_IRC = 1,
};
/***************************************************************************** */
struct lpc_sys_control* sys_ctrl = LPC_SYS_CONTROL;
/* Ask for the same clock status when waking up */
- sys_ctrl->powerdown_awake_cfg = sys_ctrl->powerdown_run_cfg;
+ sys_ctrl->powerdown_wake_cfg = sys_ctrl->powerdown_run_cfg;
/* Set deep_sleep config */
if (lpc_private.brown_out_detection_enabled) {
sys_ctrl->powerdown_sleep_cfg = LPC_DEEP_SLEEP_CFG_NOWDTLOCK_BOD_ON;
sys_ctrl->powerdown_run_cfg &= ~(LPC_POWER_DOWN_IRC);
sys_ctrl->powerdown_run_cfg &= ~(LPC_POWER_DOWN_IRC_OUT);
/* Use IRC clock for main clock */
- sys_ctrl->main_clk_sel = 0;
+ sys_ctrl->main_clk_sel = LPC_MAIN_CLK_SRC_IRC_OSC;
+ lpc_private.need_IRC = 1;
/* Switch the main clock source */
sys_ctrl->main_clk_upd_en = 0;
sys_ctrl->main_clk_upd_en = 1;
/* Setup PLL dividers */
sys_ctrl->sys_pll_ctrl = (((M - 1) & 0x1F) | (N << 5));
/* Set sys_pll_clk to internal RC */
- sys_ctrl->sys_pll_clk_sel = 0;
+ sys_ctrl->sys_pll_clk_sel = LPC_PLL_CLK_SRC_IRC_OSC;
sys_ctrl->sys_pll_clk_upd_en = 0; /* SYSPLLCLKUEN must go from LOW to HIGH */
sys_ctrl->sys_pll_clk_upd_en = 1;
/* Power-up PLL */
/* Wait Until PLL Locked */
while (!(sys_ctrl->sys_pll_status & 0x01));
/* Use PLL as main clock */
- sys_ctrl->main_clk_sel = 0x03;
+ sys_ctrl->main_clk_sel = LPC_MAIN_CLK_SRC_PLL_OUT;
/* Switch the main clock source */
sys_ctrl->main_clk_upd_en = 0;
sys_ctrl->main_clk_upd_en = 1;
uint32_t reserved_11[4];
volatile uint32_t powerdown_sleep_cfg; /* 0x230 : Power-down states in Deep-sleep mode (R/W) */
- volatile uint32_t powerdown_awake_cfg; /* 0x234 : Power-down states after wake-up (R/W) */
+ volatile uint32_t powerdown_wake_cfg; /* 0x234 : Power-down states after wake-up (R/W) */
volatile uint32_t powerdown_run_cfg; /* 0x238 : Power-down configuration Register (R/W) */
uint32_t reserved_12[110];
volatile const uint32_t device_id; /* 0x3F4 : Device ID (R/ ) */
#define LPC_DEEP_SLEEP_CFG_NOWDTLOCK_BOD_ON 0x0000FFF7
#define LPC_DEEP_SLEEP_CFG_NOWDTLOCK_BOD_OFF 0x0000FFFF
+#define LPC_MAIN_CLK_SRC_IRC_OSC 0x00
+#define LPC_MAIN_CLK_SRC_PLL_IN 0x01
+#define LPC_MAIN_CLK_SRC_WATCHDOG_OSC 0x02
+#define LPC_MAIN_CLK_SRC_PLL_OUT 0x03
+
+#define LPC_PLL_CLK_SRC_IRC_OSC 0x00
+#define LPC_PLL_CLK_SRC_EXT_OSC 0x01
+
#define LPC_CLKOUT_SRC_IRC_OSC 0x00
#define LPC_CLKOUT_SRC_XTAL_OSC 0x01
#define LPC_CLKOUT_SRC_WATCHDOG_OSC 0x02