📄 frame.c
字号:
/******************************************************************************
uC/OS-II Porting for LPC210x
By: Pary WU <parywu@mail2000.com.tw>
History:
0406271325:parywu
The first stable release.
******************************************************************************/
#include "config.h"
#include "lpc210x.h"
#include "console.h"
#include "irq.h"
#include "frame.h"
#include "ucos_ii.h"
#define PRINTA(a, b) console_putstr(a);console_puthex(b);console_putstr("\r\n");
#define PRINTB(a) console_putstr(a);console_putstr("\r\n");
#if (cDebugMode > 0)
void debugnum(unsigned int num){
unsigned int cpu_sr;
OS_ENTER_CRITICAL();
PRINTA("debugnum=", num);
OS_EXIT_CRITICAL();
}
void debugnpp(unsigned int num){
static unsigned int i = 0;
unsigned int j;
OS_CPU_SR cpu_sr = 0;
OS_ENTER_CRITICAL();
PRINTA("debugnpp=", i++);
OS_EXIT_CRITICAL();
if(num > 0 && i==num){
j = i;
}
}
void dump_TCB(OS_TCB* pcb){
unsigned int cpu_sr;
OS_ENTER_CRITICAL();
PRINTB("TCB>>>>>>>>>>>>>>>>>>>>");
PRINTA("pcb=", (unsigned int)pcb);
PRINTA("dly=", (pcb->OSTCBDly));
PRINTA("sp=", *((unsigned int*)pcb));
//dump_context(*((unsigned int**)pcb));
OS_EXIT_CRITICAL();
}
void dump_all_TCB(){
OS_TCB* ptcb;
unsigned int cpu_sr;
OS_ENTER_CRITICAL();
ptcb = OSTCBList;
PRINTB("dump_all_TCB");
PRINTA("OSTCBCur=", (unsigned int)OSTCBCur);
while (ptcb){
dump_TCB(ptcb);
ptcb = ptcb->OSTCBNext;
}
OS_EXIT_CRITICAL();
}
void dump_current_TCB(void){
dump_TCB(OSTCBCur);
}
void dump_context(unsigned int* regs){
unsigned int cpu_sr;
OS_ENTER_CRITICAL();
PRINTA("cpsr=", regs[15]);
PRINTA("pc=", regs[14]);
PRINTA("lr=", regs[13]);
PRINTA("r12=", regs[12]);
PRINTA("r11=", regs[11]);
PRINTA("r10=", regs[10]);
PRINTA("r9=", regs[9]);
PRINTA("r8=", regs[8]);
PRINTA("r7=", regs[7]);
PRINTA("r6=", regs[6]);
PRINTA("r5=", regs[5]);
PRINTA("r4=", regs[4]);
PRINTA("r3=", regs[3]);
PRINTA("r2=", regs[2]);
PRINTA("r1=", regs[1]);
PRINTA("r0=", regs[0]);
console_putstr("-------\r\n");
OS_EXIT_CRITICAL();
}
#endif /* cDebugMode */
void init_hw(){
// init PLL
rPLLCFG = vPLLCFG;
rPLLCON = PLLCON_PLLE;
rPLLFEED = 0xaa;
rPLLFEED = 0x55;
while(!(rPLLSTAT&PLLSTAT_PLOCK))
continue;
rPLLCON = (PLLCON_PLLE|PLLCON_PLLC);
rPLLFEED = 0xaa;
rPLLFEED = 0x55;
// init MAM
rMAMTIM = vMAMTIM;
rMAMCR = vMAMMODE;
// init VPB for peripherals
rVPBDIV = vVPBDIV;
// init timer0
rT0PC = vT0PC;
rT0MR0 = vT0MR0;
rT0MCR = vT0MCR;
}
void frame_start_tick(void){
rVICIntEnClr = 0xffffffff;
rVICVectAddr = 0;
rVICIntSelect = 0;
/* Timer 0 */
rVICIntEnable = (1<<4);
rT0IR = 0xffffffff;
rT0TCR = 0x02; // reset
rT0TCR = 0x01; // enable it
frame_irq_enable();
}
void frame_main(){
init_hw();
console_init();
rIODIR = 0x00000008;
app_main(); /* should never return */
}
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -