📄 bsp.c
字号:
//-----------------------------------------------------
//--函数名:Dbgu.c
//--功 能:使用目标板的Dbgu口的输入和输出
//--公 司:深圳市百特电子
//--设 计:陈斌
//--时 间:2005.11.11
//-----------------------------------------------------
#include "includes.h"
/*
*********************************************************************************************************
* 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);
static void CAN_Init();
extern void AT91F_CAN_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();
CAN_Init();
}
//================================================================================================
static void BSP_IntCtrlInit (void)
{
INT16U i;
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-3; /* 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)
{
// First, enable the clock of the PIO
AT91F_PMC_EnablePeriphClock ( AT91C_BASE_PMC, 1 << AT91C_ID_PIOA ) ;
// then, we configure the PIO Lines corresponding to LED1 to LED4
// to be outputs. No need to set these pins to be driven by the PIO because it is GPIO pins only.
AT91F_PIO_CfgOutput( AT91D_BASE_PIO_LED, AT91B_LED_MASK ) ;
// Clear the LED's. On the EB55 we must apply a "1" to turn off LEDs
AT91F_PIO_SetOutput( AT91D_BASE_PIO_LED, AT91B_LED_MASK ) ;
// Clear the LED's. On the EB55 we must apply a "1" to turn off LEDs
// AT91F_PIO_ClearOutput( AT91D_BASE_PIO_LED, AT91B_LED_MASK ) ;
// Loop forever
// LED_Off(AT91B_LED_MASK); /* 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)
{
}
/*
*********************************************************************************************************
* 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)
{
}
/*
*********************************************************************************************************
* 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 toggle
* 0 indicates that you want ALL the LEDs to be toggle
* 1 toggles LED1 on the board
* .
* .
* 4 toggles LED4 on the board
*********************************************************************************************************
*/
/*
*********************************************************************************************************
* IRQ ISR HANDLER
*
* Description : This function is called by OS_CPU_IRQ_ISR() to determine the source of the interrupt
* and process it accordingly.
*
* Arguments : none
*********************************************************************************************************
*/
void OS_CPU_IRQ_ISR_Handler (void)
{
BSP_PFNCT pfnct;
#if 1
pfnct = (BSP_PFNCT)AT91C_BASE_AIC->AIC_IVR; /* Read the interrupt vector from the VIC */
if (pfnct != (BSP_PFNCT)0) { /* Make sure we don't have a NULL pointer */
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -