⭐ 欢迎来到虫虫下载站! | 📦 资源下载 📁 资源专辑 ℹ️ 关于我们
⭐ 虫虫下载站

📄 bsp.c

📁 ARMLPC2129ucosii283(uCOSII2.83已经移植到arm7,iar环境)
💻 C
📖 第 1 页 / 共 2 页
字号:
/*
*********************************************************************************************************
*                                               Philips LPC214x
*                                 LPC2148 Kick Start Card Board Support Package
*
*                                    (c) Copyright 2006, Micrium, Weston, FL
*                                              All Rights Reserved
*
*
* File : BSP.C
* By   : Jean J. Labrosse
*********************************************************************************************************
*/

#define  BSP_GLOBALS
#include <includes.h>

#define  BSP_DEBUG                           1


/*
*********************************************************************************************************
*                                              CONSTANTS
*********************************************************************************************************
*/

#define  LED_1_BIT                           (CPU_INT32U)(1 << 25)




/*
*********************************************************************************************************
*                                               DATA TYPES
*********************************************************************************************************
*/

typedef  void (*PFNCT)(void);

/*
*********************************************************************************************************
*                                              VARIABLES
*********************************************************************************************************
*/

        CPU_INT32U      Tmr_ReloadCnts;
        CPU_INT32U      VIC_SpuriousInt;

/*
*********************************************************************************************************
*                                              PROTOTYPES
*********************************************************************************************************
*/

static  void  BSP_PLL_Init (void);
static  void  BSP_IO_Init(void);
static  void  BSP_MAM_Init(void);



static  void  Tmr_TickInit(void);

static  void  VIC_Init(void);
static  void  VIC_Dummy(void);
static  void  VIC_DummyWDT(void);
static  void  VIC_DummyTIMER0(void);
static  void  VIC_DummyTIMER1(void);
static  void  VIC_DummyUART0(void);
static  void  VIC_DummyUART1(void);
static  void  VIC_DummyPWM0(void);
static  void  VIC_DummyI2C(void);
static  void  VIC_DummySPI(void);
static  void  VIC_DummyRTC(void);
static  void  VIC_DummyEINT0(void);
static  void  VIC_DummyEINT1(void);
static  void  VIC_DummyEINT2(void);

/*
*********************************************************************************************************
*                                        Set up the PLL
*
* Description: This function sets up and activates the PLL
*********************************************************************************************************
*/

static  void  BSP_PLL_Init (void)
{
#if OS_CRITICAL_METHOD == 3                                     /* Allocate storage for CPU status register                 */
    OS_CPU_SR   cpu_sr = 0;
#endif
    INT16U  loop_ctr;

                                                                /* Configure PLL0, which determines the CPU clock           */
    PLLCFG            = 0x00000023;                             /* Use PLL values of M = 4 and P = 2                        */
    PLLCON_bit.PLLE   = 1;                                      /* Set the PLL Enable bit                                   */

    OS_ENTER_CRITICAL();
    PLLFEED           = 0xAA;                                   /* Write to the PLL Feed register                           */
    PLLFEED           = 0x55;
    OS_EXIT_CRITICAL();

    loop_ctr = 10000;                                           /* Wait for the PLL to lock into the new frequency          */
    while (((PLLSTAT_bit.PLOCK) == 0) && (loop_ctr > 0)) {
        loop_ctr--;
    }

    PLLCON_bit.PLLC   = 1;                                      /* Connect the PLL                                          */

    OS_ENTER_CRITICAL();
    PLLFEED           = 0xAA;                                   /* Write to the PLL Feed register                           */
    PLLFEED           = 0x55;
    OS_EXIT_CRITICAL();

    VPBDIV            = 0x00000002;                             /* Set the VPB frequency to one-half of the CPU clock       */
}

/*
*********************************************************************************************************
*                                      Get the CPU Clock Frequency
*
* Description: This function reads CPU registers to determine the CPU clock frequency of the chip.
*********************************************************************************************************
*/

CPU_INT32U  BSP_CPU_ClkFreq (void)
{
    CPU_INT32U  msel;
    CPU_INT32U  cpu_clk_freq;


    msel         = (CPU_INT32U)(PLLCFG & 0x1F);
    cpu_clk_freq = CPU_OSC_FREQ * (msel + 1);
    return (cpu_clk_freq);
}

/*
*********************************************************************************************************
*                                   Get the Peripheral Clock Frequency
*
* Description: This function reads CPU registers to determine the peripheral clock frequency of the chip.
*********************************************************************************************************
*/

CPU_INT32U  BSP_CPU_ClkFreqPeripheral (void)
{
    CPU_INT32U  msel;
    CPU_INT32U  vpbdiv;
    CPU_INT32U  cpu_clk_freq;
    CPU_INT32U  cpu_peripheral_clk_freq;


    msel         = (CPU_INT32U)(PLLCFG   & 0x1F);
    cpu_clk_freq = CPU_OSC_FREQ * (msel + 1);

    vpbdiv       = (CPU_INT32U)(VPBDIV & 0x03);
    switch (vpbdiv) {
        case 0:
             cpu_peripheral_clk_freq = cpu_clk_freq / 4;
             break;

        case 1:
             cpu_peripheral_clk_freq = cpu_clk_freq;
             break;

        case 2:
             cpu_peripheral_clk_freq = cpu_clk_freq / 2;
             break;

        default:
             cpu_peripheral_clk_freq = cpu_clk_freq / 4;
             break;
    }
    return (cpu_peripheral_clk_freq);
}

/*
*********************************************************************************************************
*                                         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)
{
    MEMMAP                            = 2;                      /* Remap 64 bytes of int. RAM to 0x00                       */


    OS_CPU_InitExceptVect();

    BSP_PLL_Init();                                             /* Initialize PLL0 and the VPB Divider Register             */

    BSP_MAM_Init();                                             /* Initialize the Memory Acceleration Module                */

    BSP_IO_Init();                                              /* Initialize the board's I/Os                              */

    VIC_Init();                                                 /* Initialize the Vectored Interrupt Controller             */

    LED_Init();                                                 /* Initialize the I/Os for the LED controls                 */

    Tmr_TickInit();                                             /* Initialize the uC/OS-II tick interrupt                   */

#ifdef DISP_MODULE_PRESENT
    Tmr1_Init();
#endif
}

/*
*********************************************************************************************************
*                                     DISABLE ALL INTERRUPTS
*
* Description : This function disables all interrupts from the interrupt controller.
*
* Arguments   : none
*********************************************************************************************************
*/

void  BSP_IntDisAll (void)
{
    VICIntEnClear = 0xFFFFFFFFL;                                /* Disable ALL interrupts                                   */
}


/*
*********************************************************************************************************
*                                          INITIALIZE I/Os
*
* Description : This function initializes the GPIO pins.  All the I/O pins are initialized in this function
*               so you don't have to look at multiple places for I/O initialization.
*
* Arguments   : none
*********************************************************************************************************
*/

static  void  BSP_IO_Init (void)
{
    PINSEL0   = 0;
    PINSEL1   = 0;                                /* Use GPIO pins P1.16 to P1.23 for LEDs             */
    IO0DIR   |= 0x0f000000;                       /* Set GPIO pins as outputs                      */
}



/*
*********************************************************************************************************
*                                         GET 'PUSH BUTTON' STATUS
*
* Description : This function is used to get the status of any push button on the board.
*
* Arguments   : push_button    is the number of the push button to probe
*                              1    probe the push button B1
*                              2    probe the push button B2
*********************************************************************************************************
*/


/*
*********************************************************************************************************
*                                         LED INITIALIZATION
*
* Description : This function initializes the board's LEDs
*
* Arguments   : none
*********************************************************************************************************
*/

void  LED_Init (void)
{
  
}

/*
*********************************************************************************************************
*                                             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
*                      .
*                      .
*                     16    turns ON LED16 on the board
*********************************************************************************************************
*/

void  LED_On (CPU_INT08U led)
{
   IO0SET |= 0x02000000;
}

/*
*********************************************************************************************************
*                                             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
*                      .
*                      .
*                     16    turns OFF LED16 on the board
*********************************************************************************************************
*/

void  LED_Off (CPU_INT08U led)
{
    IO0CLR = 0x02000000;
}

/*
*********************************************************************************************************
*                                             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
*                      .
*                      .
*                     16    toggles LED16 on the board
*********************************************************************************************************
*/


⌨️ 快捷键说明

复制代码 Ctrl + C
搜索代码 Ctrl + F
全屏模式 F11
切换主题 Ctrl + Shift + D
显示快捷键 ?
增大字号 Ctrl + =
减小字号 Ctrl + -