uhal.c
来自「三星2410的一些DEMO小例程」· C语言 代码 · 共 286 行
C
286 行
/* ARM board targetting source file.
file name: uhal.c
date: 2005.11
used for s3c2410
*/
#include <stdarg.h>
#include <string.h>
#include <stdio.h>
#include "2410addr.h"
#include "2410lib.h"
#include "uhal.h"
#include "Def.h"
//changed by zhl, I put the cs8900if_service as a task here
//#include "netif/cs8900if.h"
#include "includes.h"
extern void OSISR(void);
extern void ARMDisableInt(void);
extern void FISR(void);
__irq void do_firq(void)
{
Uart_Printf("!!!Enter FIRQ.");
}
void BreakPoint(void)
{
Uart_Printf("!!!Enter break point.");
// while(1) {
// Led_Display(0xf);
// Delay(1000);
// Led_Display(0x0);
// Delay(1000);
//}//while
}//BreakPoint
void OutDebug(unsigned int num)
{
Uart_Printf("\r\n***STACK***:%d\r\n", num);
}//OutDebug
//Initialze interrupts.
void uHALr_InitInterrupts(void)
{
rINTMOD = 0x0; //All=IRQ mode
rINTMSK = BIT_ALLMSK; //All interrupt is masked.
// rINTSUBMSK = BIT_SUB_ALLMSK; //All sub-interrupt is masked. <- April 01, 2002 SOP
}//uHALr_InitInterrupts
//Initialize timer that is used OS.
void uHALr_InitTimers(void)
{
rTCFG0= 0x00000000; // prescaler0 = 0
rTCFG1= 0x00000000; // mux0 = 1/2
//timetick is 1000, FCLK=200MHZ
rTCNTB0= PCLK/OS_TICKS_PER_SEC/2; //tick=1000;
rTCMPB0= 0x0;
rTCON=0x2; //update mode for TCNTB0 and TCMPB0.
rTCON=0x9; //timer0 = auto reload, start
}//uHALr_InitTimers
int I_COUNT=0;
void DebugUNDEF(void)
{
Uart_Printf("!!!Enter UNDEFINED. %d\r\n", I_COUNT);
// while(1) {
// Led_Display(0xf);
// Delay(1000);
// Led_Display(0x0);
// Delay(1000);
//}//while
}//BreakPoint
void DebugSWI(void)
{
Uart_Printf("!!!Enter SWI. %d\r\n", I_COUNT);
// while(1) {
// Led_Display(0xf);
// Delay(1000);
// Led_Display(0x0);
// Delay(1000);
//}//while
}
void DebugABORT(void)
{
Uart_Printf("!!!Enter ABORT 0\r\n");
// while(1) {
// Led_Display(0xf);
// Delay(1000);
// Led_Display(0x0);
// Delay(1000);
//}//while
}
void DebugABORT1(void)
{
Uart_Printf("!!!Enter ABORT 1\r\n");
// while(1) {
// Led_Display(0xf);
// Delay(1000);
// Led_Display(0x0);
// Delay(1000);
//}//while
}
__irq void DebugFIQ(void)
{
Uart_Printf("!!!Enter FIQ. %d\r\n", I_COUNT);
// while(1) {
// Led_Display(0xf);
// Delay(1000);
// Led_Display(0x0);
// Delay(1000);
//}//while
}
U32 show=1;
void do_irq(void)
{
U32 irqWhich=0;///,m=0;
irqWhich = rINTPND ;
//Uart_Printf("%x",rINTPND);
switch (irqWhich)
{
case BIT_TIMER0 :
rSRCPND &= BIT_TIMER0;
rINTPND |= BIT_TIMER0;
OSTimeTick();
break;
/*
case BIT_EINT8_23:
//Uart_Printf("%x",rEINTPEND);
m= rEINTPEND;
switch(m)
{
case 0x200 :
//Uart_Printf("%x",rEINTPEND);
cs8900_interrupt();
rSRCPND &= BIT_EINT8_23;
rINTPND |= BIT_EINT8_23;
show=rINTPND;
rEINTPEND|=(1<<9);
//Uart_Printf("\nInt9 is good\n");
break;
default:break;
}
break;
*/
default:break;
}
}
//we make cs8900if_service as a ucos task
/*
void cs8900if_service_task(void)
{
cs8900if_service(cs8900if_netif);
}
*/
/*** Called by ARMTargetStart() ***/
void uHALr_InstallIrqHandler(void)
{
pISR_TIMER0 = (unsigned) UCOS_IRQHandler;
pISR_UNDEF = (unsigned) DebugUNDEF;
pISR_SWI = (unsigned) DebugSWI;
pISR_PABORT = (unsigned) DebugABORT;
pISR_DABORT = (unsigned) DebugABORT1;
// pISR_RESERVED
// pISR_IRQ = (unsigned) 0;
pISR_FIQ = (unsigned) BreakPoint;
pISR_EINT0 = (unsigned) BreakPoint;
pISR_EINT1 = (unsigned) BreakPoint;
pISR_EINT2 = (unsigned) BreakPoint;
pISR_EINT3 = (unsigned) BreakPoint;
pISR_EINT4_7 = (unsigned) BreakPoint;
pISR_EINT8_23 = (unsigned) UCOS_IRQHandler;
pISR_NOTUSED6 = (unsigned) BreakPoint;
pISR_BAT_FLT = (unsigned) BreakPoint;
pISR_TICK = (unsigned) BreakPoint;
pISR_WDT = (unsigned) BreakPoint;
// pISR_TIMER0 = (unsigned) BreakPoint;
pISR_TIMER1 = (unsigned) BreakPoint;
pISR_TIMER2 = (unsigned) BreakPoint;
pISR_TIMER3 = (unsigned) BreakPoint;
pISR_TIMER4 = (unsigned) BreakPoint;
pISR_UART2 = (unsigned) BreakPoint;
pISR_LCD = (unsigned) BreakPoint;
pISR_DMA0 = (unsigned) BreakPoint;
pISR_DMA1 = (unsigned) BreakPoint;
pISR_DMA2 = (unsigned) BreakPoint;
pISR_DMA3 = (unsigned) BreakPoint;
pISR_SDI = (unsigned) BreakPoint;
pISR_SPI0 = (unsigned) BreakPoint;
pISR_UART1 = (unsigned) BreakPoint;
pISR_NOTUSED24 = (unsigned) BreakPoint;
pISR_USBD = (unsigned) BreakPoint;
pISR_USBH = (unsigned) BreakPoint;
pISR_IIC = (unsigned) BreakPoint;
pISR_UART0 = (unsigned) BreakPoint;
pISR_SPI1 = (unsigned) BreakPoint;
pISR_RTC = (unsigned) BreakPoint;
pISR_ADC = (unsigned) BreakPoint;
}
//Start system timer & enable the interrupt.
void uHALr_EnableTimer(void)
{
//Non-vectored,IRQ enable,FIQ enable
//rINTMOD=6 //EINT1 & EINT2 configured for firq
rINTPND=0x00000000;
//rINTMSK=~(BIT_GLOBAL | BIT_EINT1 | BIT_EINT2); //Default value=0x7ffffff
//Non maksed TIMER0 .
rINTMSK&=(~(BIT_TIMER0 )); //Default value=0x7ffffff
}//uHALr_EnableTimer
#define BUILD_DATE "Date: " __DATE__ "\n"
/*
* Initialize an ARM Target board
*/
void ARMTargetInit(void)
{
/* ---- Tell the world who we are ---------------------------------- */
Uart_Printf("\nSAMSUNG board\n");
Uart_Printf(uHAL_VERSION_STRING);
Uart_Printf("\n");
Uart_Printf(uHAL_AUTHOR_STRING);
Uart_Printf("\n");
Uart_Printf(BUILD_DATE);
Uart_Printf("\n");
/* ---- disable interrupts (IRQs) --------------------------------- */
uHALr_InitInterrupts();
uHALr_InitTimers();
} /* targetInit */
/* start the ARM target running */
void ARMTargetStart(void)
{
/* request the system timer */
uHALr_InstallIrqHandler();
/* Start system timer & enable the interrupt. */
uHALr_EnableTimer();
// Uart_Printf("lab12!!!!!!!");
}
⌨️ 快捷键说明
复制代码Ctrl + C
搜索代码Ctrl + F
全屏模式F11
增大字号Ctrl + =
减小字号Ctrl + -
显示快捷键?