📄 bsp.c
字号:
/*
*********************************************************************************************************
* Philips LPC210x
* LPC210x Kick Start Card Board Support Package
*
* (c) Copyright 2004, Micrium, Weston, FL
* All Rights Reserved
*
*
* File : BSP.C
* By : Eric Shufro
*********************************************************************************************************
*/
#include <includes.h>
/*
*********************************************************************************************************
* CONSTANTS
*********************************************************************************************************
*/
#define INT_GPT1 26 /* Interrupt vector number for the gen. purpose timer 1 */
#define LED3 (INT16U)(1 << 14) /* resides on ExtendedIO bit 14 */
#define LED4 (INT16U)(1 << 15) /* resides on ExtendedIO bit 14 */
#define BSP_UNDEF_INSTRUCTION_VECTOR_ADDR (*(INT32U *)0xFFFFFEF0L)
#define BSP_SWI_VECTOR_ADDR (*(INT32U *)0xFFFFFEF4L)
#define BSP_PREFETCH_ABORT_VECTOR_ADDR (*(INT32U *)0xFFFFFEF8L)
#define BSP_DATA_ABORT_VECTOR_ADDR (*(INT32U *)0xFFFFFEFCL)
#define BSP_IRQ_VECTOR_ADDR (*(INT32U *)0xFFFFFF00L)
#define BSP_FIQ_VECTOR_ADDR (*(INT32U *)0xFFFFFF04L)
/*
*********************************************************************************************************
* DATA TYPES
*********************************************************************************************************
*/
/*
*********************************************************************************************************
* PROTOTYPES
*********************************************************************************************************
*/
static void PLL_Init(void);
static void BSP_IO_Init(void);
static void AITC_Init(void);
static void Tmr_TickInit(void);
static void Fast_ISR_AITC_Dummy(void); /* Dummy IRQ ISR Handler */
static void Normal_ISR_AITC_Dummy(void); /* Dummy FIQ ISR Handler */
/*
*********************************************************************************************************
* VARIABLES
*********************************************************************************************************
*/
INT32U AITC_SpuriousInt; /* holds the vector number of the spurious ISR */
BSP_FNCT_PTR BSP_IRQ[64]; /* look up table of normal ISRs */
BSP_FNCT_PTR BSP_FIQ[64]; /* look up table of fast ISRs */
/*
*********************************************************************************************************
* BSP INITIALIZATION
*
* Description : This function should be called by your application code before you make use of any of the
* functions found in this module.
*
* Arguments : none
*********************************************************************************************************
*/
void BSP_Init (void)
{
PLL_Init(); /* Use default settings, and restart the MPLL */
AITC_Init(); /* Initialize the Vectored Interrupt Controller */
BSP_IO_Init(); /* Initialize the board's I/Os */
LED_Init(); /* Initialize the I/Os for the LED controls */
Tmr_TickInit(); /* Initialize the uC/OS-II tick interrupt */
}
/*
*********************************************************************************************************
* PLL Initialization
*
* Description : Restart the MPLL and wait for the lock flag.
*
* Arguments : none
*
* Notes : Set MPLL to 266MHZ and SPLL to 288MHZ w/ USB OTG = 48MHZ
*********************************************************************************************************
*/
void PLL_Init (void)
{
CSCR = 0x77180607; /* Val out of reset, PRESC = 4, BCLKDIV=ICLKDIV = 2 */
/* Both SPLL and MPLL enabled */
MPCTL0 = 0x007B1C73; /* Set MPLL to 266.00 MHZ using 32.768 KHZ Ref Freq */
PCDR1 = 0x03070F1F; /* PERCLK1DIV = 32. Faster (less) breaks the GPT! */
CSCR |= MPLL_RESTART; /* Restart the MPLL */
while((MPCTL1 & MPLL_LF) != MPLL_LF)
{
; /* Wait for MPLL Lock */
}
SPCTL0 = 0x83B02227; /* Set SPLL value to 288mhz, USB OTG = 48mhz */
CSCR |= MPLL_RESTART; /* Restart the SPLL */
while((SPCTL1 & SPLL_LF) != SPLL_LF)
{
; /* Wait for SPLL Lock */
}
}
/*
*********************************************************************************************************
* DISABLE ALL INTERRUPTS
*
* Description : This function disables all interrupts from the interrupt controller.
*
* Arguments : none
*********************************************************************************************************
*/
void BSP_IntDisAll (void)
{
INT8U i;
for (i = 0; i < 64; i++) { /* Disable all interrupts, similar to NIMASK = 0x0F */
BSP_IntDis(i);
}
}
/*
*********************************************************************************************************
* INITIALIZE I/Os
*
* Description : This function initializes the GPIO pins
*
* Arguments : none
*
* Note(s) :
*********************************************************************************************************
*/
static void BSP_IO_Init (void)
{
}
/*
*********************************************************************************************************
* BSP INITIALIZATION
*
* Description : This function should be called by your application code before you make use of any of the
* functions found in this module.
*
* Arguments : none
*********************************************************************************************************
*/
void LED_Init (void)
{
LED_Off(0); /* Turn OFF all the LEDs */
}
/*
*********************************************************************************************************
* LED ON
*
* Description : This function is used to control any or all the LEDs on the board.
*
* Arguments : led is the number of the LED to control
* 0 indicates that you want ALL the LEDs to be ON
* 1 turns ON LED1 on the board
* 2 turns ON LED2 on the board
*********************************************************************************************************
*/
void LED_On (INT8U led)
{
switch (led) {
case 0:
ExtendedIO |= LED3;
ExtendedIO |= LED4;
break;
case 1:
ExtendedIO |= LED3;
break;
case 2:
ExtendedIO |= LED4;
break;
}
}
/*
*********************************************************************************************************
* LED OFF
*
* Description : This function is used to control any or all the LEDs on the board.
*
* Arguments : led is the number of the LED to turn OFF
* 0 indicates that you want ALL the LEDs to be OFF
* 1 turns OFF LED1 on the board
* 2 turns OFF LED2 on the board
*********************************************************************************************************
*/
void LED_Off (INT8U led)
{
switch (led) {
case 0:
ExtendedIO &= ~LED3;
ExtendedIO &= ~LED4;
break;
case 1:
ExtendedIO &= ~LED3;
break;
case 2:
ExtendedIO &= ~LED4;
break;
}
}
/*
*********************************************************************************************************
* LED TOGGLE
*
* Description : This function is used to toggle any or all the LEDs on the board.
*
* Arguments : led is the number of the LED to control
* 0 indicates that you want to toggle ALL the LEDs
* 1 toggles LED1 on the board
* 2 toggles LED2 on the board
*********************************************************************************************************
*/
void LED_Toggle (INT8U led)
{
switch (led) {
case 0:
ExtendedIO ^= LED3;
ExtendedIO ^= LED4;
break;
case 1:
ExtendedIO ^= LED3;
break;
case 2:
ExtendedIO ^= LED4;
break;
}
}
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -