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

📄 bsp.c

📁 IAR编译环境下的AT91SAM7S64芯片的ucosii系统移植和演示代码。
💻 C
📖 第 1 页 / 共 2 页
字号:
/*
*********************************************************************************************************
*                                            Atmel AT91 SAM7
*                                         Board Support Package
*
*                              (c) Copyright 2004, Micrium, Inc., Weston, FL
*                                          All Rights Reserved
*
*
* File : BSP.C
* By   : Jean J. Labrosse
*********************************************************************************************************
*/

#include <includes.h>

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

#define  BSP_UNDEF_INSTRUCTION_VECTOR_ADDR   (*(INT32U *)0x00000004L)
#define  BSP_SWI_VECTOR_ADDR                 (*(INT32U *)0x00000008L)
#define  BSP_PREFETCH_ABORT_VECTOR_ADDR      (*(INT32U *)0x0000000CL)
#define  BSP_DATA_ABORT_VECTOR_ADDR          (*(INT32U *)0x00000010L)
#define  BSP_IRQ_VECTOR_ADDR                 (*(INT32U *)0x00000018L)
#define  BSP_FIQ_VECTOR_ADDR                 (*(INT32U *)0x0000001CL)

#define  BSP_IRQ_ISR_ADDR                    (*(INT32U *)0x00000038L)
#define  BSP_FIQ_ISR_ADDR                    (*(INT32U *)0x0000003CL)

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

typedef  void (*BSP_PFNCT)(void);

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

static  void  BSP_DummyISR_Handler(void);

static  void  BSP_IntCtrlInit(void);

static  void  Tmr_TickInit(void);
static  void  Tmr_TickISR_Handler(void);


/*
*********************************************************************************************************
*                                           DUMMY IRQ HANDLER
*
* Description : This function is called to handle invalid IRQs
*
* Arguments   : none
*********************************************************************************************************
*/

static  void  BSP_DummyISR_Handler (void)
{
    AT91C_BASE_AIC->AIC_IVR = 0;              /* Debug variant of vector read (protect mode is used)   */
}


/*
*********************************************************************************************************
*                                          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)
{
    BSP_IntCtrlInit();                               /* Initialize the Interrupt Controller            */
    Tmr_TickInit();                                  /* Initialize uC/OS-II's Tick Rate                */
    LED_Init();                                      /* Initialize the I/Os for the LEDs               */
}


/*
*********************************************************************************************************
*                                    INITIALIZE THE INTERRUPT CONTROLLER
*
* Description : This function is called to disable ALL interrupts.
*
* Arguments   : none
*********************************************************************************************************
*/

static  void  BSP_IntCtrlInit (void)
{
    INT16U  i;

    BSP_IRQ_VECTOR_ADDR               =  0xE59FF018;               /* LDR PC,[PC,#0x18] instruction    */
    BSP_IRQ_ISR_ADDR                  =  (INT32U)OS_CPU_IRQ_ISR;   /* IRQ exception vector address     */

    BSP_FIQ_VECTOR_ADDR               =  0xE59FF018;               /* LDR PC,[PC,#0x18] instruction    */
    BSP_FIQ_ISR_ADDR                  =  (INT32U)OS_CPU_FIQ_ISR;   /* FIQ exception vector address     */

    BSP_UNDEF_INSTRUCTION_VECTOR_ADDR =  0xEAFFFFFE;               /* Jump to itself                   */
    BSP_SWI_VECTOR_ADDR               =  0xEAFFFFFE;
    BSP_PREFETCH_ABORT_VECTOR_ADDR    =  0xEAFFFFFE;
    BSP_DATA_ABORT_VECTOR_ADDR        =  0xEAFFFFFE;
    BSP_FIQ_VECTOR_ADDR               =  0xEAFFFFFE;
                                                                   /* - END CODE RUNNING OUT OF RAM -- */



    AT91C_BASE_AIC->AIC_EOICR         =  0x00000000;               /* End-of-interrupt command         */

    for (i = 0; i < 32; i++) {                                     /* Disable all ISRs                 */
        AT91C_BASE_AIC->AIC_SVR[i] = (INT32U)BSP_DummyISR_Handler;
        AT91C_BASE_AIC->AIC_SMR[i] = 0;
    }
}

/*
*********************************************************************************************************
*                                          DISABLE ALL INTERRUPTS
*
* Description : This function is called to disable ALL interrupts.
*
* Arguments   : none
*********************************************************************************************************
*/

void  BSP_IntDisAll (void)
{
    AT91C_BASE_AIC->AIC_IDCR = 0xFFFFFFFF;                         /* Disable all interrupts           */
}

/*
*********************************************************************************************************
*                                         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)
{
    AT91C_BASE_PIOA->PIO_PER  = BSP_LED4 | BSP_LED3 | BSP_LED2 | BSP_LED1; /* Enable register          */
    AT91C_BASE_PIOA->PIO_OER  = BSP_LED4 | BSP_LED3 | BSP_LED2 | BSP_LED1; /* Output enable            */
    AT91C_BASE_PIOA->PIO_IDR  = BSP_LED4 | BSP_LED3 | BSP_LED2 | BSP_LED1;
    LED_Off(BSP_LED_ALL);                                                  /* 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
*                      .
*                      .
*                      4    turns ON LED4 on the board
*********************************************************************************************************
*/

void  LED_On (INT8U led)
{
    switch (led) {
        case 0:
             AT91C_BASE_PIOA->PIO_CODR = BSP_LED4 | BSP_LED3 | BSP_LED2 | BSP_LED1;
             break;

        case 1:
             AT91C_BASE_PIOA->PIO_CODR = BSP_LED1;
             break;

        case 2:
             AT91C_BASE_PIOA->PIO_CODR = BSP_LED2;
             break;

        case 3:
             AT91C_BASE_PIOA->PIO_CODR = BSP_LED3;
             break;

        case 4:
             AT91C_BASE_PIOA->PIO_CODR = BSP_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
*                      .
*                      .
*                      4    turns OFF LED4 on the board
*********************************************************************************************************
*/

void  LED_Off (INT8U led)
{
    switch (led) {
        case 0:
             AT91C_BASE_PIOA->PIO_SODR = BSP_LED4 | BSP_LED3 | BSP_LED2 | BSP_LED1;

⌨️ 快捷键说明

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