HAL implemented for LPC214x.

git-svn-id: svn://svn.code.sf.net/p/chibios/svn/trunk@1392 35acf78f-673a-0410-8e92-d51de3d6d3f4
This commit is contained in:
gdisirio 2009-12-08 10:36:29 +00:00
parent 4682a4476e
commit 93fc8b5777
17 changed files with 334 additions and 179 deletions

View File

@ -44,6 +44,8 @@ LDSCRIPT = ch.ld
# Imported source files
CHIBIOS = ../..
include ${CHIBIOS}/os/hal/hal.mk
include ${CHIBIOS}/os/hal/platforms/LPC214x/platform.mk
include ${CHIBIOS}/os/ports/GCC/ARM7/port.mk
include ${CHIBIOS}/os/kernel/kernel.mk
include ${CHIBIOS}/test/test.mk
@ -53,11 +55,8 @@ include ${CHIBIOS}/test/test.mk
CSRC = ${PORTSRC} \
${KERNSRC} \
${TESTSRC} \
${CHIBIOS}/os/io/pal.c \
${CHIBIOS}/os/io/serial.c \
${CHIBIOS}/os/io/platforms/LPC214x/pal_lld.c \
${CHIBIOS}/os/io/platforms/LPC214x/serial_lld.c \
${CHIBIOS}/os/io/platforms/LPC214x/vic.c \
${HALSRC} \
${PLATFORMSRC} \
${CHIBIOS}/os/various/evtimer.c \
board.c
@ -89,9 +88,7 @@ TCPPSRC =
ASMSRC = $(PORTASM) \
${CHIBIOS}/os/ports/GCC/ARM7/LPC214x/vectors.s
INCDIR = $(PORTINC) $(KERNINC) $(TESTINC) \
${CHIBIOS}/os/io \
${CHIBIOS}/os/io/platforms/LPC214x \
INCDIR = $(PORTINC) $(KERNINC) $(TESTINC) $(HALINC) $(PLATFORMINC) \
${CHIBIOS}/os/various \
${CHIBIOS}/os/ports/GCC/ARM7/LPC214x

View File

@ -17,30 +17,14 @@
along with this program. If not, see <http://www.gnu.org/licenses/>.
*/
#include <ch.h>
#include <pal.h>
#include <serial.h>
#include "ch.h"
#include "hal.h"
#include "lpc214x.h"
#include "vic.h"
//#include "lpc214x_ssp.h"
#include "board.h"
//#include "mmcsd.h"
//#include "buzzer.h"
/*
* Non-vectored IRQs handling here.
*/
static CH_IRQ_HANDLER(IrqHandler) {
CH_IRQ_PROLOGUE();
/* nothing */
VICVectAddr = 0;
CH_IRQ_EPILOGUE();
}
#define VAL_TC0_PRESCALER 0
/*
* Timer 0 IRQ handling here.
@ -58,18 +42,6 @@ static CH_IRQ_HANDLER(T0IrqHandler) {
CH_IRQ_EPILOGUE();
}
/*
* Digital I/O ports static configuration as defined in @p board.h.
*/
static const LPC214xFIOConfig config =
{
VAL_PINSEL0,
VAL_PINSEL1,
VAL_PINSEL2,
{VAL_FIO0PIN, VAL_FIO0DIR},
{VAL_FIO1PIN, VAL_FIO1DIR}
};
/*
* Early initialization code.
* This initialization is performed just after reset before BSS and DATA
@ -77,43 +49,7 @@ static const LPC214xFIOConfig config =
*/
void hwinit0(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;
/*
* I/O pins configuration.
*/
palInit(&config);
lpc214x_clock_init();
}
/*
@ -124,10 +60,9 @@ void hwinit0(void) {
void hwinit1(void) {
/*
* Interrupt vectors assignment.
* HAL initialization.
*/
vic_init();
VICDefVectAddr = (IOREG32)IrqHandler;
halInit();
/*
* System Timer initialization, 1ms intervals.
@ -144,7 +79,6 @@ void hwinit1(void) {
/*
* Other subsystems.
*/
sdInit();
// ssp_init();
// InitMMC();
// InitBuzzer();

View File

@ -20,8 +20,6 @@
#ifndef _BOARD_H_
#define _BOARD_H_
#include "lpc214x.h"
#define BOARD_OLIMEX_LCP_P2148
/*
@ -32,8 +30,6 @@
#define CCLK 48000000
#define PCLK 12000000
#define VAL_TC0_PRESCALER 0
/*
* Pins configuration for Olimex LPC-P2148.
*

View File

@ -0,0 +1,96 @@
/*
ChibiOS/RT - Copyright (C) 2006-2007 Giovanni Di Sirio.
This file is part of ChibiOS/RT.
ChibiOS/RT is free software; you can redistribute it and/or modify
it under the terms of the GNU General Public License as published by
the Free Software Foundation; either version 3 of the License, or
(at your option) any later version.
ChibiOS/RT is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
GNU General Public License for more details.
You should have received a copy of the GNU General Public License
along with this program. If not, see <http://www.gnu.org/licenses/>.
*/
/**
* @file templates/halconf.h
* @brief HAL configuration header.
* @addtogroup HAL_CONF
* @{
*/
/*
* HAL configuration file, this file allows to enable or disable the various
* device drivers from your application. You may also use this file in order
* to change the device drivers settings found in the low level drivers
* headers, just define here the new settings and those will override the
* defaults defined in the LLD headers.
*/
#ifndef _HALCONF_H_
#define _HALCONF_H_
/**
* @brief Enables the PAL subsystem.
*/
#if !defined(CH_HAL_USE_PAL) || defined(__DOXYGEN__)
#define CH_HAL_USE_PAL TRUE
#endif
/**
* @brief Enables the ADC subsystem.
*/
#if !defined(CH_HAL_USE_ADC) || defined(__DOXYGEN__)
#define CH_HAL_USE_ADC FALSE
#endif
/**
* @brief Enables the CAN subsystem.
*/
#if !defined(CH_HAL_USE_CAN) || defined(__DOXYGEN__)
#define CH_HAL_USE_CAN FALSE
#endif
/**
* @brief Enables the MAC subsystem.
*/
#if !defined(CH_HAL_USE_MAC) || defined(__DOXYGEN__)
#define CH_HAL_USE_MAC FALSE
#endif
/**
* @brief Enables the PWM subsystem.
*/
#if !defined(CH_HAL_USE_PWM) || defined(__DOXYGEN__)
#define CH_HAL_USE_PWM FALSE
#endif
/**
* @brief Enables the SERIAL subsystem.
*/
#if !defined(CH_HAL_USE_SERIAL) || defined(__DOXYGEN__)
#define CH_HAL_USE_SERIAL TRUE
#endif
/**
* @brief Enables the SPI subsystem.
*/
#if !defined(CH_HAL_USE_SPI) || defined(__DOXYGEN__)
#define CH_HAL_USE_SPI FALSE
#endif
/**
* @brief Enables the MMC_SPI subsystem.
*/
#if !defined(CH_HAL_USE_MMC_SPI) || defined(__DOXYGEN__)
#define CH_HAL_USE_MMC_SPI FALSE
#endif
#endif /* _HALCONF_H_ */
/** @} */

View File

@ -17,13 +17,10 @@
along with this program. If not, see <http://www.gnu.org/licenses/>.
*/
#include <ch.hpp>
#include <pal.h>
#include <serial.h>
#include <test.h>
#include <evtimer.h>
#include "board.h"
#include "ch.hpp"
#include "hal.h"
#include "test.h"
#include "evtimer.h"
#define BOTH_BUTTONS (PAL_PORT_BIT(PA_BUTTON1) | PAL_PORT_BIT(PA_BUTTON2))

View File

@ -44,6 +44,8 @@ LDSCRIPT = ch.ld
# Imported source files
CHIBIOS = ../..
include ${CHIBIOS}/os/hal/hal.mk
include ${CHIBIOS}/os/hal/platforms/LPC214x/platform.mk
include ${CHIBIOS}/os/ports/GCC/ARM7/port.mk
include ${CHIBIOS}/os/kernel/kernel.mk
#include ${CHIBIOS}/test/test.mk
@ -53,9 +55,8 @@ include ${CHIBIOS}/os/kernel/kernel.mk
CSRC = ${PORTSRC} \
${KERNSRC} \
${TESTSRC} \
${CHIBIOS}/os/io/pal.c \
${CHIBIOS}/os/io/platforms/LPC214x/pal_lld.c \
${CHIBIOS}/os/io/platforms/LPC214x/vic.c \
${HALSRC} \
${PLATFORMSRC} \
board.c main.c
# C++ sources that can be compiled in ARM or THUMB mode depending on the global
@ -86,9 +87,7 @@ TCPPSRC =
ASMSRC = $(PORTASM) \
${CHIBIOS}/os/ports/GCC/ARM7/LPC214x/vectors.s
INCDIR = $(PORTINC) $(KERNINC) $(TESTINC) \
${CHIBIOS}/os/io \
${CHIBIOS}/os/io/platforms/LPC214x \
INCDIR = $(PORTINC) $(KERNINC) $(TESTINC) $(HALINC) $(PLATFORMINC) \
${CHIBIOS}/os/various \
${CHIBIOS}/os/ports/GCC/ARM7/LPC214x

View File

@ -17,30 +17,14 @@
along with this program. If not, see <http://www.gnu.org/licenses/>.
*/
#include <ch.h>
#include <pal.h>
#include "ch.h"
#include "hal.h"
#include "lpc214x.h"
#include "vic.h"
//#include "lpc214x_serial.h"
//#include "lpc214x_ssp.h"
#include "board.h"
//#include "mmcsd.h"
//#include "buzzer.h"
/*
* Non-vectored IRQs handling here.
*/
static CH_IRQ_HANDLER(IrqHandler) {
CH_IRQ_PROLOGUE();
/* nothing */
VICVectAddr = 0;
CH_IRQ_EPILOGUE();
}
#define VAL_TC0_PRESCALER 0
/*
* Timer 0 IRQ handling here.
@ -58,18 +42,6 @@ static CH_IRQ_HANDLER(T0IrqHandler) {
CH_IRQ_EPILOGUE();
}
/*
* Digital I/O ports static configuration as defined in @p board.h.
*/
static const LPC214xFIOConfig config =
{
VAL_PINSEL0,
VAL_PINSEL1,
VAL_PINSEL2,
{VAL_FIO0PIN, VAL_FIO0DIR},
{VAL_FIO1PIN, VAL_FIO1DIR}
};
/*
* Early initialization code.
* This initialization is performed just after reset before BSS and DATA
@ -77,43 +49,7 @@ static const LPC214xFIOConfig config =
*/
void hwinit0(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;
/*
* I/O pins configuration.
*/
palInit(&config);
lpc214x_clock_init();
}
/*
@ -124,10 +60,9 @@ void hwinit0(void) {
void hwinit1(void) {
/*
* Interrupt vectors assignment.
* HAL initialization.
*/
vic_init();
VICDefVectAddr = (IOREG32)IrqHandler;
halInit();
/*
* System Timer initialization, 1ms intervals.
@ -144,7 +79,6 @@ void hwinit1(void) {
/*
* Other subsystems.
*/
// sdInit();
// ssp_init();
// InitMMC();
// InitBuzzer();

View File

@ -20,8 +20,6 @@
#ifndef _BOARD_H_
#define _BOARD_H_
#include "lpc214x.h"
#define BOARD_OLIMEX_LCP_P2148
/*
@ -32,8 +30,6 @@
#define CCLK 48000000
#define PCLK 12000000
#define VAL_TC0_PRESCALER 0
/*
* Pins configuration for Olimex LPC-P2148.
*

View File

@ -0,0 +1,96 @@
/*
ChibiOS/RT - Copyright (C) 2006-2007 Giovanni Di Sirio.
This file is part of ChibiOS/RT.
ChibiOS/RT is free software; you can redistribute it and/or modify
it under the terms of the GNU General Public License as published by
the Free Software Foundation; either version 3 of the License, or
(at your option) any later version.
ChibiOS/RT is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
GNU General Public License for more details.
You should have received a copy of the GNU General Public License
along with this program. If not, see <http://www.gnu.org/licenses/>.
*/
/**
* @file templates/halconf.h
* @brief HAL configuration header.
* @addtogroup HAL_CONF
* @{
*/
/*
* HAL configuration file, this file allows to enable or disable the various
* device drivers from your application. You may also use this file in order
* to change the device drivers settings found in the low level drivers
* headers, just define here the new settings and those will override the
* defaults defined in the LLD headers.
*/
#ifndef _HALCONF_H_
#define _HALCONF_H_
/**
* @brief Enables the PAL subsystem.
*/
#if !defined(CH_HAL_USE_PAL) || defined(__DOXYGEN__)
#define CH_HAL_USE_PAL TRUE
#endif
/**
* @brief Enables the ADC subsystem.
*/
#if !defined(CH_HAL_USE_ADC) || defined(__DOXYGEN__)
#define CH_HAL_USE_ADC FALSE
#endif
/**
* @brief Enables the CAN subsystem.
*/
#if !defined(CH_HAL_USE_CAN) || defined(__DOXYGEN__)
#define CH_HAL_USE_CAN FALSE
#endif
/**
* @brief Enables the MAC subsystem.
*/
#if !defined(CH_HAL_USE_MAC) || defined(__DOXYGEN__)
#define CH_HAL_USE_MAC FALSE
#endif
/**
* @brief Enables the PWM subsystem.
*/
#if !defined(CH_HAL_USE_PWM) || defined(__DOXYGEN__)
#define CH_HAL_USE_PWM FALSE
#endif
/**
* @brief Enables the SERIAL subsystem.
*/
#if !defined(CH_HAL_USE_SERIAL) || defined(__DOXYGEN__)
#define CH_HAL_USE_SERIAL FALSE
#endif
/**
* @brief Enables the SPI subsystem.
*/
#if !defined(CH_HAL_USE_SPI) || defined(__DOXYGEN__)
#define CH_HAL_USE_SPI FALSE
#endif
/**
* @brief Enables the MMC_SPI subsystem.
*/
#if !defined(CH_HAL_USE_MMC_SPI) || defined(__DOXYGEN__)
#define CH_HAL_USE_MMC_SPI FALSE
#endif
#endif /* _HALCONF_H_ */
/** @} */

View File

@ -17,10 +17,8 @@
along with this program. If not, see <http://www.gnu.org/licenses/>.
*/
#include <ch.h>
#include <pal.h>
#include "board.h"
#include "ch.h"
#include "hal.h"
/*
* Red LEDs blinker thread, times are in milliseconds.

View File

@ -0,0 +1,96 @@
/*
ChibiOS/RT - Copyright (C) 2006-2007 Giovanni Di Sirio.
This file is part of ChibiOS/RT.
ChibiOS/RT is free software; you can redistribute it and/or modify
it under the terms of the GNU General Public License as published by
the Free Software Foundation; either version 3 of the License, or
(at your option) any later version.
ChibiOS/RT is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
GNU General Public License for more details.
You should have received a copy of the GNU General Public License
along with this program. If not, see <http://www.gnu.org/licenses/>.
*/
/**
* @file templates/halconf.h
* @brief HAL configuration header.
* @addtogroup HAL_CONF
* @{
*/
/*
* HAL configuration file, this file allows to enable or disable the various
* device drivers from your application. You may also use this file in order
* to change the device drivers settings found in the low level drivers
* headers, just define here the new settings and those will override the
* defaults defined in the LLD headers.
*/
#ifndef _HALCONF_H_
#define _HALCONF_H_
/**
* @brief Enables the PAL subsystem.
*/
#if !defined(CH_HAL_USE_PAL) || defined(__DOXYGEN__)
#define CH_HAL_USE_PAL TRUE
#endif
/**
* @brief Enables the ADC subsystem.
*/
#if !defined(CH_HAL_USE_ADC) || defined(__DOXYGEN__)
#define CH_HAL_USE_ADC FALSE
#endif
/**
* @brief Enables the CAN subsystem.
*/
#if !defined(CH_HAL_USE_CAN) || defined(__DOXYGEN__)
#define CH_HAL_USE_CAN FALSE
#endif
/**
* @brief Enables the MAC subsystem.
*/
#if !defined(CH_HAL_USE_MAC) || defined(__DOXYGEN__)
#define CH_HAL_USE_MAC FALSE
#endif
/**
* @brief Enables the PWM subsystem.
*/
#if !defined(CH_HAL_USE_PWM) || defined(__DOXYGEN__)
#define CH_HAL_USE_PWM FALSE
#endif
/**
* @brief Enables the SERIAL subsystem.
*/
#if !defined(CH_HAL_USE_SERIAL) || defined(__DOXYGEN__)
#define CH_HAL_USE_SERIAL TRUE
#endif
/**
* @brief Enables the SPI subsystem.
*/
#if !defined(CH_HAL_USE_SPI) || defined(__DOXYGEN__)
#define CH_HAL_USE_SPI FALSE
#endif
/**
* @brief Enables the MMC_SPI subsystem.
*/
#if !defined(CH_HAL_USE_MMC_SPI) || defined(__DOXYGEN__)
#define CH_HAL_USE_MMC_SPI FALSE
#endif
#endif /* _HALCONF_H_ */
/** @} */

View File

@ -294,6 +294,6 @@ void sd_lld_stop(SerialDriver *sdp) {
#endif
}
#endif /* CH_HAL_USE_SPI */
#endif /* CH_HAL_USE_SERIAL */
/** @} */

View File

@ -154,7 +154,7 @@ extern "C" {
#endif
/** @endcond*/
#endif /* CH_HAL_USE_SPI */
#endif /* CH_HAL_USE_SERIAL */
#endif /* _SERIAL_LLD_H_ */

View File

@ -27,6 +27,8 @@
#include "ch.h"
#include "hal.h"
#if CH_HAL_USE_PAL || defined(__DOXYGEN__)
/**
* @brief LPC214x I/O ports configuration.
* @details FIO units and PINSEL registers initialization.
@ -86,4 +88,6 @@ void _pal_lld_setgroupmode(ioportid_t port,
}
}
#endif /* CH_HAL_USE_PAL */
/** @} */

View File

@ -27,6 +27,8 @@
#ifndef _PAL_LLD_H_
#define _PAL_LLD_H_
#if CH_HAL_USE_PAL || defined(__DOXYGEN__)
/*===========================================================================*/
/* Unsupported modes and specific modes */
/*===========================================================================*/
@ -248,6 +250,8 @@ extern "C" {
}
#endif
#endif /* CH_HAL_USE_PAL */
#endif /* _PAL_LLD_H_ */
/** @} */

View File

@ -27,6 +27,8 @@
#include "ch.h"
#include "hal.h"
#if CH_HAL_USE_SERIAL || defined(__DOXYGEN__)
#if USE_LPC214x_UART0 || defined(__DOXYGEN__)
/** @brief UART0 serial driver identifier.*/
SerialDriver SD1;
@ -331,4 +333,6 @@ void sd_lld_stop(SerialDriver *sdp) {
#endif
}
#endif /* CH_HAL_USE_SERIAL */
/** @} */

View File

@ -27,6 +27,8 @@
#ifndef _SERIAL_LLD_H_
#define _SERIAL_LLD_H_
#if CH_HAL_USE_SERIAL || defined(__DOXYGEN__)
/*===========================================================================*/
/* Driver pre-compile time settings. */
/*===========================================================================*/
@ -169,6 +171,8 @@ extern "C" {
#endif
/** @endcond*/
#endif /* CH_HAL_USE_SERIAL */
#endif /* _SERIAL_LLD_H_ */
/** @} */