📄 test.c
字号:
#include "includes.h"
#include "def.h"
#include "option.h"
#include "2410addr.h"
#include "2410lib.h"
#include "2410slib.h"
#include "mmu.h"
void Isr_Init(void);
void HaltUndef(void);
void HaltSwi(void);
void HaltPabort(void);
void HaltDabort(void);
OS_STK TestTaskStk[100];
void TestTask(void *pdata)
{
int led_state = 0;
pdata = pdata;
Led_Display(0);
if(rGPHCON != 0x2afaaa)
{
Led_Display(3);
rGPHCON = 0x2afaaa;
Uart_Printf("enter TestTask");
}
/*
An auto reload timer is set in three setups:
1) Witre the initial value into TCNTBn and TCMPBn
2) Set the manual update bit of the corressponding timer, it is recommended that you configure
the inverter on/off bit(whether use inverter or not)
3) Set start bit of the corressponding timer to start the timer(and clear the manual update bit)
*/
//初始化时钟节拍中断(中断)
pISR_TIMER4 = (unsigned)OSTickISR;
/* TCFG0 0x51000000 R/W Configure the two 8-bit prescalers 0x00000000
[31:24] [26:16] [15:8] [7:0]
Reserved Dead zone length Prescaler 1(Timer 2,3,4) Prescaler 0(Timer 0,1)
0x00 0x00 0x00 0x00
*/
rTCFG0 = 0x0000ff00; //Prescaler 1 [15:8] These 8 bits determine prescaler value for Timer 2, 3 and 4.
/*TCFG1 0x51000004 R/W 5-MUX & DMA mode selecton register 0x00000000
[31:24] [23:20] [19:16] [15:12] [11:8] [7:4] [3:0]
Reserved DMA mode MUX4 for PWM Timer 4 MUX3 MUX2 MUX1 MUX0
0x0 0x0 0011
No select(all interrupt) 1/16
*/
rTCFG1 = 0x00030000;
/*TCNTB4 0x5100003C R/W Timer 4 count buffer register 0x00000000
[15:0]
Set count buffer value for Timer 4
0x00000000
*/
rTCNTB4 = 0x2fff;
/*TCNTO4 0x51000040 R Timer 4 count observation register 0x00000000
*/
/*TCON 0x51000008 R/W Timer control register 0x00000000
[22] [21] [20] [19] [18] [17] [16] [15][14][13][12] ....
Timer 4 auto reload on/off Timer 4 manual update Timer 4 start/stop Timer 3 auot reload on/off 3 output inverter om/off 3 manual update 3 start/stop 2 ...
0-one-shot 1-auto reload 1-Update TCNTB4 1-start for Timer 4
*/
rTCON = 0x00600000;
rTCON = 0x00500000;
//使能中断
rINTMSK = ~(BIT_TIMER4);
if(rGPHCON != 0x2afaaa)
{
rGPHCON = 0x2afaaa;
Uart_Printf("TestTask");
}
while(1)
{
Uart_Printf("TestTask start to Delay");
OSTimeDly(1);
Uart_Printf("TestTask stop to Delay");
if(0 == led_state)
{
led_state = 1;
//Led_Display(3);
Uart_Printf("L3");
}
else
{
led_state = 0;
//Led_Display(0);
Uart_Printf("L0");
}
}
}
void TestMain (void)
{
//MMU_Init();
#if ADS10
__rt_lib_init(); //for ADS 1.0
#endif
//ChangeClockDivider(0,0); // 1:1:1
//ChangeClockDivider(1,0); // 1:2:2
ChangeClockDivider(1,1); // 1:2:4
//ChangeMPllValue(0x92,0x4,0x2); // FCLK=50MHz
//ChangeMPllValue(0x96,0x5,0x1); // FCLK=135428571Hz
// ChangeMPllValue(0x2a,0x1,0x0); // FCLK=200MHz
// ChangeMPllValue(0x5c,0x1,0x1); // FCLK=200MHz
// ChangeMPllValue(0x5c,0x4,0x0); // FCLK=200MHz
// ChangeMPllValue(0x8e,0x7,0x0); // FCLK=200MHz
ChangeMPllValue(0xa1,0x3,0x1); // FCLK=202.8MHz
// ChangeMPllValue(0x66,0x1,0x1); // FCLK=220MHz
// ChangeMPllValue(0x69,0x1,0x1); // FCLK=226MHz
// ChangeMPllValue(0x96,0x2,0x1); // FCLK=237MHz
Port_Init();
Isr_Init();
//Rtc_Init();
Uart_Init(0,115200);
Uart_Select(0);
//Check whether or not the POWER_OFF wake-up.
// Delay(0); //calibrate Delay()
// Check_PowerOffWakeUp(); //It's needed for power-off STOP mode test.
Uart_Printf("\n\nSMDK2410 Board (MCU S3C2410) Test Program Ver 1.1(20020801) FCLK = %d Hz\n\n", FCLK);
Uart_Printf("seni: enter OSInit\n");
while(0)
{
int i;
i = Uart_GetIntNum();
Led_Display(i);
if(100 == i)
break;
}
Led_Display(0);
while(0)
{
//int i;
//Uart_Printf("\n\nSMDK2410 Board (MCU S3C2410) Test Program Ver 1.1(20020801) FCLK = %d Hz\n\n", FCLK);
//Led_Display(3);
//Uart_Printf("seni: select led to dispaly\n");
//i = Uart_GetIntNum();
Led_Display(rGPFDAT >> 1);
//Uart_Printf("\n");
}
OSInit();
Uart_Printf("seni: enter OSTaskCreate\n");
while(0)
{
int i;
i = Uart_GetIntNum();
Led_Display(i);
if(100 == i)
break;
}
OSTaskCreate(TestTask, (void *)0, &TestTaskStk[99], 0);
Uart_Printf("seni: enter OSStart\n");
while(0)
{
int i;
i = Uart_GetIntNum();
Led_Display(i);
if(100 == i)
break;
}
OSStart();
//Uart_Printf("seni: exit OSStart\n");
while(0)
{
int i;
i = Uart_GetIntNum();
Led_Display(i);
if(100 == i)
break;
}
}
//===================================================================
void Isr_Init(void)
{
pISR_UNDEF = (unsigned)HaltUndef;
pISR_SWI = (unsigned)HaltSwi;
pISR_PABORT = (unsigned)HaltPabort;
pISR_DABORT = (unsigned)HaltDabort;
rINTMOD = 0x0; //All=IRQ mode
// rINTCON=0x5; //Non-vectored,IRQ enable,FIQ disable
rINTMSK = BIT_ALLMSK; //All interrupt is masked.
rINTSUBMSK = BIT_SUB_ALLMSK; //All sub-interrupt is masked. <- April 01, 2002 SOP
// rINTSUBMSK = ~(BIT_SUB_RXD0); //Enable Rx0 Default value=0x7ff
// rINTMSK = ~(BIT_UART0); //Enable UART0 Default value=0xffffffff
// pISR_UART0=(unsigned)RxInt; //pISR_FIQ,pISR_IRQ must be initialized
}
//===================================================================
void HaltUndef(void)
{
Uart_Printf("Undefined instruction exception.\n");
while(1);
}
//===================================================================
void HaltSwi(void)
{
Uart_Printf("SWI exception.\n");
while(1);
}
//===================================================================
void HaltPabort(void)
{
Uart_Printf("Pabort exception.\n");
while(1);
}
//===================================================================
void HaltDabort(void)
{
Uart_Printf("Dabort exception.\n");
while(1);
}
void HaltUartInterrupt(void)
{
Led_Display(3);
Uart_Printf("UART exception.\n");
while(1);
}
void TRACE_ARM(unsigned int x)
{
Uart_Printf("%d is ok!\n", x);
}
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -