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

📄 bsp.c

📁 这个是我将UCOS移植到LPC系列的基本模版,大家可以下载下来参考下,和ZLG的完全不一样,并不是采用软中断实现任务切换,更加稳定.如果有问题可以rayeryanglei@126.com
💻 C
字号:
/*
*********************************************************************************************************
*                                university of electronic technology and science of china
*									electronic engineer school
*                           (c) Copyright 2003-2010, wangzheng
*                                           All Rights Reserved
*
* File    : bsp.c
* By      : wangzheng
* Version : V1.0
*********************************************************************************************************
*/

#include "includes.h"



void OS_CPU_IRQ_ISR_Handler(void) 
{
	PFNCT	pfnct;
	pfnct = (PFNCT) VIC_IRQ;  		// read service function address
	while(pfnct != (PFNCT)0 )		// serve all interrupt device
	{
		pfnct( );				   	// serve interrupt device
		pfnct = (PFNCT) VIC_IRQ;	// read again
	}
}

/******************************************************************************************
*
*******************************************************************************************/

void OS_CPU_FIQ_ISR_Handler(void)
{
	PFNCT	pfnct;
	pfnct = (PFNCT) VIC_FIQ;
	while(pfnct != (PFNCT)0 )
	{
		pfnct();
		pfnct = (PFNCT) VIC_FIQ;	 // please reference above function
	}
}


/******************************************************************************************
*					 Timer0_ex    system clcok 
*******************************************************************************************/
void Timer0_Execpetion(void)
{
 
    T0IR = 0x01;
    VICVectAddr = 0;
	OSTimeTick( );
    
}
/******************************************************************************************
*
*******************************************************************************************/
void Timer0_Init()
{
    T0IR = 0xffffffff;
    T0TC = 0;
    T0TCR = 0x01;
    T0MCR = 0x03;
    T0MR0 = (Fpclk / OS_TICKS_PER_SEC);
}
/******************************************************************************************
*
*******************************************************************************************/

void  UART0_Init( INT32U UART_BPS )
{  

   INT16U  Fdiv;

   PINSEL0 = 0x00000005;	 		// line pin 
   U0LCR = 0x83;		             
   Fdiv = (Fpclk / 16) / UART_BPS;   
   U0DLM = Fdiv / 256;							
   U0DLL = Fdiv % 256;						
   U0LCR = 0x03;
}

void Def_Execpetion()
{
}
/******************************************************************************************
*
*******************************************************************************************/

void VIC_Init()
{
	
    VICIntEnClr = 0xffffffff;
 //   VICDefVectAddr = (INT32U)OS_CPU_FIQ_ISR;

	/* timer 0 interrupte*/

    VICVectAddr0 = (INT32U)Timer0_Execpetion;
    VICVectCntl0 = (0x20 | 0x04);  // TIMER0 config as IRQ, use slot0
    VICIntEnable = 1 << 4;
	
	/* rtl8019 interrupte EINT2 */
/*
	VICVectAddr1 = (INT32U)rtl8019_isr;
	VICVectCntl1 = (0x20 | 16);   //EINT2 config as IRQ ,use slot 1
	VICIntEnable = 1 << 16;
*/

//	VICVectAddr1 = (INT32U)UART1_ISR;
//	VICVectCntl1 = (0x20 | 7);		// UART1 config as IRQ, use slot 2
//	VICIntEnable = 1 << 7;
	
//	VICVectAddr2 = (INT32U)UART0_ISR;
//	VICVectCntl2 = (0x20 | 6);		// UART0 config as IRQ, use slot 3
//	VICIntEnable = 1 << 6;

//    VICVectAddr3 = (INT32U)RTC_ISR;
//    VICVectCntl3 = (0x20|13);
//    VICIntEnable = 1<<13;

//    VICVectAddr3 = (INT32U)I2c_ISR;
//    VICVectCntl3 = (0x20|9);
//    VICIntEnable = 1<<9;

	
}


void EINT_init(void)
{
	PINSEL0 =  (PINSEL0 &0xffffcfff ) | 0xc000;	// select P0.7 as EXTINT2.
	EXTMODE  = EXTMODE  | 0x00;	// EXTINT 2 is level trig
	EXTPOLAR = EXTPOLAR | 0x04;	// positive level

}
	



/******************************************************************************************
*
*******************************************************************************************/

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

	OS_ENTER_CRITICAL( );

	Timer0_Init( );
	UART0_Init(115200 );

//	EINT_init( );	
	VIC_Init( );

	OS_EXIT_CRITICAL( );
}

⌨️ 快捷键说明

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