📄 bsp_init.c
字号:
#include "includes.h"
#include "bsp_init.h"
#define BSP_INT_MODULE
/*
*********************************************************************************************************
* LOCAL DEFINES
*********************************************************************************************************
*/
#define BSP_INT_SRC_NBR 35
/*
*********************************************************************************************************
* LOCAL CONSTANTS
*********************************************************************************************************
*/
/*
*********************************************************************************************************
* LOCAL DATA TYPES
*********************************************************************************************************
*/
/*
*********************************************************************************************************
* LOCAL TABLES
*********************************************************************************************************
*/
static CPU_FNCT_VOID BSP_IntVectTbl[BSP_INT_SRC_NBR];
/*
*********************************************************************************************************
* LOCAL GLOBAL VARIABLES
*********************************************************************************************************
*/
/*
*********************************************************************************************************
* LOCAL FUNCTION PROTOTYPES
*********************************************************************************************************
*/
static void BSP_IntHandler (CPU_DATA int_id);
static void BSP_IntHandlerDummy(void);
/*
*********************************************************************************************************
* LOCAL CONFIGURATION ERRORS
*********************************************************************************************************
*/
/*
*********************************************************************************************************
* BSP_IntClr()
*
* Description : Clear interrupt.
*
* Argument(s) : int_id Interrupt to clear.
*
* Return(s) : none.
*
* Caller(s) : Application.
*
* Note(s) : (1) An interrupt does not need to be cleared within the interrupt controller.
*********************************************************************************************************
*/
void BSP_IntClr (CPU_DATA int_id)
{
}
/*
*********************************************************************************************************
* BSP_IntDis()
*
* Description : Disable interrupt.
*
* Argument(s) : int_id Interrupt to disable.
*
* Return(s) : none.
*
* Caller(s) : Application.
*
* Note(s) : none.
*********************************************************************************************************
*/
void BSP_IntDis (CPU_DATA int_id)
{
if (int_id < BSP_INT_SRC_NBR) {
CPU_IntSrcDis(int_id + 16);
}
}
/*
*********************************************************************************************************
* BSP_IntDisAll()
*
* Description : Disable ALL interrupts.
*
* Argument(s) : none.
*
* Return(s) : none.
*
* Caller(s) : Application.
*
* Note(s) : none.
*********************************************************************************************************
*/
void BSP_IntDisAll (void)
{
CPU_IntDis();
}
/*
*********************************************************************************************************
* BSP_IntEn()
*
* Description : Enable interrupt.
*
* Argument(s) : int_id Interrupt to enable.
*
* Return(s) : none.
*
* Caller(s) : Application.
*
* Note(s) : none.
*********************************************************************************************************
*/
void BSP_IntEn (CPU_DATA int_id)
{
if (int_id < BSP_INT_SRC_NBR) {
CPU_IntSrcEn(int_id + 16);
}
}
/*
*********************************************************************************************************
* BSP_IntVectSet()
*
* Description : Assign ISR handler.
*
* Argument(s) : int_id Interrupt for which vector will be set.
*
* isr Handler to assign
*
* Return(s) : none.
*
* Caller(s) : Application.
*
* Note(s) : none.
*********************************************************************************************************
*/
void BSP_IntVectSet (CPU_DATA int_id,
CPU_FNCT_VOID isr)
{
#if (CPU_CFG_CRITICAL_METHOD == CPU_CRITICAL_METHOD_STATUS_LOCAL)
CPU_SR cpu_sr;
#endif
if (int_id < BSP_INT_SRC_NBR) {
CPU_CRITICAL_ENTER();
BSP_IntVectTbl[int_id] = isr;
CPU_CRITICAL_EXIT();
}
}
/*
*********************************************************************************************************
* BSP_IntPrioSet()
*
* Description : Assign ISR priority.
*
* Argument(s) : int_id Interrupt for which vector will be set.
*
* prio Priority to assign
*
* Return(s) : none.
*
* Caller(s) : Application.
*
* Note(s) : none.
*********************************************************************************************************
*/
void BSP_IntPrioSet (CPU_DATA int_id,
CPU_INT08U prio)
{
#if (CPU_CFG_CRITICAL_METHOD == CPU_CRITICAL_METHOD_STATUS_LOCAL)
CPU_SR cpu_sr;
#endif
if (int_id < BSP_INT_SRC_NBR) {
CPU_CRITICAL_ENTER();
CPU_IntSrcPrioSet(int_id + 16, prio);
CPU_CRITICAL_EXIT();
}
}
/*
*********************************************************************************************************
*********************************************************************************************************
* INTERNAL FUNCTIONS
*********************************************************************************************************
*********************************************************************************************************
*/
/*
*********************************************************************************************************
* BSP_IntInit()
*
* Description : Initialize interrupts:
*
* Argument(s) : none.
*
* Return(s) : none.
*
* Caller(s) : BSP_Init().
*
* Note(s) : none.
*********************************************************************************************************
*/
void BSP_IntInit (void)
{
CPU_DATA int_id;
for (int_id = 0; int_id < BSP_INT_SRC_NBR; int_id++) {
BSP_IntVectSet(int_id, BSP_IntHandlerDummy);
}
}
/*
*********************************************************************************************************
* BSP_IntHandler####()
*
* Description : Handle an interrupt.
*
* Argument(s) : none.
*
* Return(s) : none.
*
* Caller(s) : This is an ISR.
*
* Note(s) : none.
*********************************************************************************************************
*/
void WDT_IRQHandler (void) { BSP_IntHandler(ID_WDT_IRQn); }
void TIMER0_IRQHandler (void) { BSP_IntHandler(ID_TIMER0_IRQn); }
void TIMER1_IRQHandler (void) { BSP_IntHandler(ID_TIMER1_IRQn); }
void TIMER2_IRQHandler (void) { BSP_IntHandler(ID_TIMER2_IRQn); }
void TIMER3_IRQHandler (void) { BSP_IntHandler(ID_TIMER3_IRQn); }
void UART0_IRQHandler (void) { BSP_IntHandler(ID_UART0_IRQn); }
void UART1_IRQHandler (void) { BSP_IntHandler(ID_UART1_IRQn); }
void UART2_IRQHandler (void) { BSP_IntHandler(ID_UART2_IRQn); }
void UART3_IRQHandler (void) { BSP_IntHandler(ID_UART3_IRQn); }
void PWM1_IRQHandler (void) { BSP_IntHandler(ID_PWM1_IRQn); }
void I2C0_IRQHandler (void) { BSP_IntHandler(ID_I2C0_IRQn); }
void I2C1_IRQHandler (void) { BSP_IntHandler(ID_I2C1_IRQn); }
void I2C2_IRQHandler (void) { BSP_IntHandler(ID_I2C2_IRQn); }
void SPI_IRQHandler (void) { BSP_IntHandler(ID_SPI_IRQn); }
void SSP0_IRQHandler (void) { BSP_IntHandler(ID_SSP0_IRQn); }
void SSP1_IRQHandler (void) { BSP_IntHandler(ID_SSP1_IRQn); }
void PLL0_IRQHandler (void) { BSP_IntHandler(ID_PLL0_IRQn); }
void RTC_IRQHandler (void) { BSP_IntHandler(ID_RTC_IRQn); }
void EINT0_IRQHandler (void) { BSP_IntHandler(ID_EINT0_IRQn); }
void EINT1_IRQHandler (void) { BSP_IntHandler(ID_EINT1_IRQn); }
void EINT2_IRQHandler (void) { BSP_IntHandler(ID_EINT2_IRQn); }
void EINT3_IRQHandler (void) { BSP_IntHandler(ID_EINT3_IRQn); }
void ADC_IRQHandler (void) { BSP_IntHandler(ID_ADC_IRQn); }
void BOD_IRQHandler (void) { BSP_IntHandler(ID_BOD_IRQn); }
void USB_IRQHandler (void) { BSP_IntHandler(ID_USB_IRQn); }
void CAN_IRQHandler (void) { BSP_IntHandler(ID_CAN_IRQn); }
void DMA_IRQHandler (void) { BSP_IntHandler(ID_DMA_IRQn); }
void I2S_IRQHandler (void) { BSP_IntHandler(ID_I2S_IRQn); }
void ENET_IRQHandler (void) { BSP_IntHandler(ID_ENET_IRQn); }
void RIT_IRQHandler (void) { BSP_IntHandler(ID_RIT_IRQn); }
void MCPWM_IRQHandler (void) { BSP_IntHandler(ID_MCPWM_IRQn); }
void QEI_IRQHandler (void) { BSP_IntHandler(ID_QEI_IRQn); }
void PLL1_IRQHandler (void) { BSP_IntHandler(ID_PLL1_IRQn); }
void USBActivity_IRQHandler (void) { BSP_IntHandler(ID_USBActivity_IRQn); }
void CANActivity_IRQHandler (void) { BSP_IntHandler(ID_CANActivity_IRQn); }
void UART4_IRQHandler (void) { BSP_IntHandler(ID_UART4_IRQn); }
void SSP2_IRQHandler (void) { BSP_IntHandler(ID_SSP2_IRQn); }
void LCD_IRQHandler (void) { BSP_IntHandler(ID_LCD_IRQn); }
void GPIO_IRQHandler (void) { BSP_IntHandler(ID_GPIO_IRQn); }
void PWM0_IRQHandler (void) { BSP_IntHandler(ID_PWM0_IRQn); }
void EEPROM_IRQHandler (void) { BSP_IntHandler(ID_EEPROM_IRQn); }
/*
*********************************************************************************************************
*********************************************************************************************************
* LOCAL FUNCTIONS
*********************************************************************************************************
*********************************************************************************************************
*/
/*
*********************************************************************************************************
* BSP_IntHandler()
*
* Description : Central interrupt handler.
*
* Argument(s) : int_id Interrupt that will be handled.
*
* Return(s) : none.
*
* Caller(s) : ISR handlers.
*
* Note(s) : none.
*********************************************************************************************************
*/
static void BSP_IntHandler (CPU_DATA int_id)
{
#if (CPU_CFG_CRITICAL_METHOD == CPU_CRITICAL_METHOD_STATUS_LOCAL)
CPU_SR cpu_sr;
#endif
CPU_FNCT_VOID isr;
CPU_CRITICAL_ENTER(); /* Tell uC/OS-II that we are starting an ISR */
OSIntNesting++;
CPU_CRITICAL_EXIT();
if (int_id < BSP_INT_SRC_NBR) {
isr = BSP_IntVectTbl[int_id];
if (isr != (CPU_FNCT_VOID)0) {
isr();
}
}
OSIntExit(); /* Tell uC/OS-II that we are leaving the ISR */
}
/*
*********************************************************************************************************
* BSP_IntHandlerDummy()
*
* Description : Dummy interrupt handler.
*
* Argument(s) : none.
*
* Return(s) : none.
*
* Caller(s) : BSP_IntHandler().
*
* Note(s) : none.
*********************************************************************************************************
*/
static void BSP_IntHandlerDummy (void)
{
}
/***************************************************************************************
*初始化GPIO功能...
*
*
*
*****************************************************************************************
*/
static void BSP_Int_GPIO (void)
{
LPC_IOCON->P0_26 = (0x0)|(0x2<<3)|(0x4<<5);
LPC_GPIO0 -> DIR |= (0x1<<26); //P0.26 output dir
LPC_GPIO0 -> CLR |= (0x1<<26); //P0.26 output 0
}
/***************************************************************************************
*初始化CPU,如时钟,内存...
*
*
*
*****************************************************************************************
*/
void Bsp_init(void){
SystemInit();
SDRAMInit();
CCLK_Frq = CLKPWR_GetCLK(CLKPWR_CLKTYPE_CPU);
BSP_Int_GPIO();
}
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -