📄 main.c
字号:
/*
* main.c - demo program
*
* Author: li ming <admin@lumit.org>
* Date: 2008-4-16
* Copyleft: http://www.lumit.org
*/
#include "led.h"
#include "beep.h"
#include "timer.h"
#include "int0.h"
#include "uart.h"
#include "irq.h"
/* delay for about one second */
static void delay(int time)
{
int i, j;
for(i = 0; i < time; i++)
for(j = 0; j < 65536; j++)
;
}
void int0_hooker(void)
{
return;
}
void timer_hooker(void)
{
return ;
}
void uart0_hooker(void)
{
/* beep on */
beep_on();
delay(10);
beep_off();
}
/* find in startup.s */
extern void irq_handler(void);
int main(void)
{
int i = 0;
char ch;
install_irq_handler( irq_handler );
timer_install_irq_hooker( timer_hooker );
int0_install_irq_hooker( int0_hooker );
uart0_install_irq_hooker( uart0_hooker );
/* Clear all existing pending bit */
clear_irq_pending();
/* Unmask the timer interrupt and the int0 and uart0_recv interrupt */
unmask_irq(0);
unmask_irq(4); // tx interrupt
unmask_irq(5); // rx interrupt
unmask_irq(10);
/* Level1: Clear ARM Core CPSR I-bit */
__asm
{
MOV r0,0x53
MSR CPSR_cxsf, r0
}
led_init();
beep_init();
int0_init();
int0_enable_irq();
timer_init();
timer_enable_irq();
uart0_init();
uart0_enable_recv_irq();
uart0_enable_send_irq();
while(++i)
{
/*
led_on(i%2);
delay(50);
led_off(i%2);
delay(50);
*/
ch = uart0_getchar();
if( ch == '\r' ) // 0x0d
{
uart0_putchar('\r');
uart0_putchar('\n');
continue;
}
if( ch == '\b' ) // 0x08
{
uart0_putchar('\b');
uart0_putchar(' ');
uart0_putchar('\b');
continue;
}
if( ch != 0 )
uart0_putchar(ch);
}
return 0;
}
void __rt_entry(void)
{
main();
}
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -