aboutsummaryrefslogtreecommitdiffstats
path: root/os/hal/platforms/LPC214x
diff options
context:
space:
mode:
authorgdisirio <gdisirio@35acf78f-673a-0410-8e92-d51de3d6d3f4>2009-12-08 08:47:14 +0000
committergdisirio <gdisirio@35acf78f-673a-0410-8e92-d51de3d6d3f4>2009-12-08 08:47:14 +0000
commit3ff9afd04851ec97d66d6833520b49dc18f35ea4 (patch)
tree64490d99322e87fa9457efa59808fed5dff2a341 /os/hal/platforms/LPC214x
parent456490bf06d9d6eccf7a02b18fba94058c81f26c (diff)
downloadChibiOS-3ff9afd04851ec97d66d6833520b49dc18f35ea4.tar.gz
ChibiOS-3ff9afd04851ec97d66d6833520b49dc18f35ea4.tar.bz2
ChibiOS-3ff9afd04851ec97d66d6833520b49dc18f35ea4.zip
git-svn-id: svn://svn.code.sf.net/p/chibios/svn/trunk@1389 35acf78f-673a-0410-8e92-d51de3d6d3f4
Diffstat (limited to 'os/hal/platforms/LPC214x')
-rw-r--r--os/hal/platforms/LPC214x/hal_lld.c57
-rw-r--r--os/hal/platforms/LPC214x/hal_lld.h12
2 files changed, 67 insertions, 2 deletions
diff --git a/os/hal/platforms/LPC214x/hal_lld.c b/os/hal/platforms/LPC214x/hal_lld.c
index 09d5c639d..705a42498 100644
--- a/os/hal/platforms/LPC214x/hal_lld.c
+++ b/os/hal/platforms/LPC214x/hal_lld.c
@@ -56,6 +56,20 @@ const LPC214xFIOConfig pal_default_config =
/* Low Level Driver interrupt handlers. */
/*===========================================================================*/
+/*
+ * Non-vectored IRQs handler, the default action can be overridden by
+ * redefining the @p LPC214x_NON_VECTORED_IRQ_HOOK() hook macro.
+ */
+static CH_IRQ_HANDLER(irq_handler) {
+
+ CH_IRQ_PROLOGUE();
+
+ LPC214x_NON_VECTORED_IRQ_HOOK();
+
+ VICVectAddr = 0;
+ CH_IRQ_EPILOGUE();
+}
+
/*===========================================================================*/
/* Low Level Driver exported functions. */
/*===========================================================================*/
@@ -65,6 +79,49 @@ const LPC214xFIOConfig pal_default_config =
*/
void hal_lld_init(void) {
+ vic_init();
+ VICDefVectAddr = (IOREG32)irq_handler;
+
+}
+
+/**
+ * @brief LPC214x clocks and PLL initialization.
+ * @note All the involved constants come from the file @p board.h.
+ */
+void lpc214x_clock_init(void) {
+
+ /*
+ * All peripherals clock disabled by default in order to save power.
+ */
+ PCONP = PCRTC | PCTIM0;
+
+ /*
+ * MAM setup.
+ */
+ MAMTIM = 0x3; /* 3 cycles for flash accesses. */
+ MAMCR = 0x2; /* MAM fully enabled. */
+
+ /*
+ * PLL setup for Fosc=12MHz and CCLK=48MHz.
+ * P=2 M=3.
+ */
+ PLL *pll = PLL0Base;
+ pll->PLL_CFG = 0x23; /* P and M values. */
+ pll->PLL_CON = 0x1; /* Enables the PLL 0. */
+ pll->PLL_FEED = 0xAA;
+ pll->PLL_FEED = 0x55;
+ while (!(pll->PLL_STAT & 0x400))
+ ; /* Wait for PLL lock. */
+
+ pll->PLL_CON = 0x3; /* Connects the PLL. */
+ pll->PLL_FEED = 0xAA;
+ pll->PLL_FEED = 0x55;
+
+ /*
+ * VPB setup.
+ * PCLK = CCLK / 4.
+ */
+ VPBDIV = VPD_D4;
}
/** @} */
diff --git a/os/hal/platforms/LPC214x/hal_lld.h b/os/hal/platforms/LPC214x/hal_lld.h
index 40345ec72..dcedb386c 100644
--- a/os/hal/platforms/LPC214x/hal_lld.h
+++ b/os/hal/platforms/LPC214x/hal_lld.h
@@ -31,13 +31,20 @@
#include "vic.h"
/*===========================================================================*/
-/* Driver pre-compile time settings. */
+/* Driver constants. */
/*===========================================================================*/
/*===========================================================================*/
-/* Driver constants. */
+/* Driver pre-compile time settings. */
/*===========================================================================*/
+/**
+ * @brief Default action for the non vectored IRQ handler, nothing.
+ */
+#if !defined(LPC214x_NON_VECTORED_IRQ_HOOK) || defined(__DOXYGEN__)
+#define LPC214x_NON_VECTORED_IRQ_HOOK()
+#endif
+
/*===========================================================================*/
/* Derived constants and error checks. */
/*===========================================================================*/
@@ -54,6 +61,7 @@
extern "C" {
#endif
void hal_lld_init(void);
+ void lpc214x_clock_init(void);
#ifdef __cplusplus
}
#endif