From 3ff9afd04851ec97d66d6833520b49dc18f35ea4 Mon Sep 17 00:00:00 2001 From: gdisirio Date: Tue, 8 Dec 2009 08:47:14 +0000 Subject: git-svn-id: svn://svn.code.sf.net/p/chibios/svn/trunk@1389 35acf78f-673a-0410-8e92-d51de3d6d3f4 --- os/hal/include/pwm.h | 4 +++ os/hal/platforms/AT91SAM7/hal_lld.c | 5 ++-- os/hal/platforms/AT91SAM7/hal_lld.h | 8 +++--- os/hal/platforms/LPC214x/hal_lld.c | 57 +++++++++++++++++++++++++++++++++++++ os/hal/platforms/LPC214x/hal_lld.h | 12 ++++++-- os/hal/platforms/MSP430/hal_lld.c | 5 ++-- os/hal/platforms/STM32/hal_lld.c | 5 ++-- os/hal/src/pwm.c | 4 +++ os/hal/templates/hal_lld.h | 4 +-- 9 files changed, 90 insertions(+), 14 deletions(-) (limited to 'os') diff --git a/os/hal/include/pwm.h b/os/hal/include/pwm.h index dfc55d30c..a6dda5e71 100644 --- a/os/hal/include/pwm.h +++ b/os/hal/include/pwm.h @@ -27,6 +27,8 @@ #ifndef _PWM_H_ #define _PWM_H_ +#if CH_HAL_USEPWM || defined(__DOXYGEN__) + /** * @brief Driver state machine possible states. */ @@ -82,6 +84,8 @@ extern "C" { } #endif +#endif /* CH_HAL_USEPWM */ + #endif /* _PWM_H_ */ /** @} */ diff --git a/os/hal/platforms/AT91SAM7/hal_lld.c b/os/hal/platforms/AT91SAM7/hal_lld.c index 6da681fcd..b79e40ffe 100644 --- a/os/hal/platforms/AT91SAM7/hal_lld.c +++ b/os/hal/platforms/AT91SAM7/hal_lld.c @@ -35,8 +35,9 @@ /* Low Level Driver local variables. */ /*===========================================================================*/ -/* - * Digital I/O ports static configuration as defined in @p board.h. +/** + * @brief PAL setup. + * @details Digital I/O ports static configuration as defined in @p board.h. */ const AT91SAM7PIOConfig pal_default_config = { diff --git a/os/hal/platforms/AT91SAM7/hal_lld.h b/os/hal/platforms/AT91SAM7/hal_lld.h index 733ef9a51..0a2d97a66 100644 --- a/os/hal/platforms/AT91SAM7/hal_lld.h +++ b/os/hal/platforms/AT91SAM7/hal_lld.h @@ -30,6 +30,10 @@ #include "at91sam7.h" #include "at91lib/aic.h" +/*===========================================================================*/ +/* Driver constants. */ +/*===========================================================================*/ + /*===========================================================================*/ /* Driver pre-compile time settings. */ /*===========================================================================*/ @@ -48,10 +52,6 @@ #define AT91SAM7_USBDIV AT91C_CKGR_USBDIV_1 #endif -/*===========================================================================*/ -/* Driver constants. */ -/*===========================================================================*/ - /*===========================================================================*/ /* Driver data structures and types. */ /*===========================================================================*/ 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 diff --git a/os/hal/platforms/MSP430/hal_lld.c b/os/hal/platforms/MSP430/hal_lld.c index b8ca618d7..65cac60de 100644 --- a/os/hal/platforms/MSP430/hal_lld.c +++ b/os/hal/platforms/MSP430/hal_lld.c @@ -31,8 +31,9 @@ /* Low Level Driver exported variables. */ /*===========================================================================*/ -/* - * Digital I/O ports static configuration as defined in @p board.h. +/** + * @brief PAL setup. + * @details Digital I/O ports static configuration as defined in @p board.h. */ const MSP430DIOConfig pal_default_config = { diff --git a/os/hal/platforms/STM32/hal_lld.c b/os/hal/platforms/STM32/hal_lld.c index b69bbbd9b..892767a00 100644 --- a/os/hal/platforms/STM32/hal_lld.c +++ b/os/hal/platforms/STM32/hal_lld.c @@ -37,8 +37,9 @@ /* Low Level Driver local variables. */ /*===========================================================================*/ -/* - * Digital I/O ports static configuration as defined in @p board.h. +/** + * @brief PAL setup. + * @details Digital I/O ports static configuration as defined in @p board.h. */ const STM32GPIOConfig pal_default_config = { diff --git a/os/hal/src/pwm.c b/os/hal/src/pwm.c index f026a62ef..0e4062124 100644 --- a/os/hal/src/pwm.c +++ b/os/hal/src/pwm.c @@ -27,6 +27,8 @@ #include "ch.h" #include "hal.h" +#if CH_HAL_USE_PWM || defined(__DOXYGEN__) + /** * @brief PWM Driver initialization. */ @@ -148,4 +150,6 @@ void pwmDisableChannel(PWMDriver *pwmp, pwmchannel_t channel) { chSysUnlock(); } +#endif /* CH_HAL_USE_PWM */ + /** @} */ diff --git a/os/hal/templates/hal_lld.h b/os/hal/templates/hal_lld.h index 2f5af5b17..c6dd6e6f7 100644 --- a/os/hal/templates/hal_lld.h +++ b/os/hal/templates/hal_lld.h @@ -28,11 +28,11 @@ #define _HAL_LLD_H_ /*===========================================================================*/ -/* Driver pre-compile time settings. */ +/* Driver constants. */ /*===========================================================================*/ /*===========================================================================*/ -/* Driver constants. */ +/* Driver pre-compile time settings. */ /*===========================================================================*/ /*===========================================================================*/ -- cgit v1.2.3