?? main.c
字號:
/********************************************************************************/
/* filename : MAIN.c */
/* created : xillinx */
/* descript : 系統的C函數入口 */
/********************************************************************************/
#include "../CPU/CPU.h"
#include "../CFG/CFG.h"
#include "../UART/UART.h"
#include "../LED/LED.h"
#include "../SEG7/SEG7.h"
#include "../HC595/HC595.h"
#include "../KEY/KEY.h"
#include "../TC1602A/TC1602A.h"
unsigned int system_timer=0x00; //* 這是系統需要的定時器變量
/********************************************************************************/
/* fun_name : MAIN_key_timer() */
/* version : v1.00 */
/* created : xillinx */
/********************************************************************************/
void MAIN_key_timer(void)
{ KEY_scan_timer=0x1;
}
/********************************************************************************/
/* fun_name : MAIN_c51_key_scan() */
/* version : v1.00 */
/* created : xillinx */
/* descript : 這個函數需要在定時器里面調用 */
/********************************************************************************/
void MAIN_c51_key_scan(void)
{ unsigned char key_val;
char buffer[0x20];
if(KEY_scan_timer==0x0) //* 定時器沒有到
{ return;
}
KEY_scan_timer=0x0;
key_val=c51_key_scan_process_jitter(); //* 8x3=24MS定時器,掃描鍵盤
if(key_val!=0x0)
{ sprintf(buffer," KEY: %c ",key_val);
LCDT_print_string(0x0,0x0,buffer);
}
key_val=c51_key_scan_hi_process();
switch(key_val)
{
case 0x1:
sprintf(buffer," KEY: %s ","F1");
LCDT_print_string(0x0,0x1,buffer);
break;
case 0x2:
sprintf(buffer," KEY: %s ","F2");
LCDT_print_string(0x0,0x1,buffer);
break;
case 0x3:
sprintf(buffer," KEY: %s ","F3");
LCDT_print_string(0x0,0x1,buffer);
break;
case 0x4:
sprintf(buffer," KEY: %s ","F4");
LCDT_print_string(0x0,0x1,buffer);
break;
default:
break;
}
return;
}
/********************************************************************************/
/* fun_name : MAIN_interrupt_hook_process() */
/* version : v1.00 */
/* created : xillinx */
/* descript : 定時器鉤子函數的處理,如果需要使用這些函數,需要重新掛接,如果不需要 */
/* 不需要做任何事情 */
/********************************************************************************/
void MAIN_interrupt_hook_process (void)
{ CPU_001_tick_process = CPU_interrupt_proc_null; //* 定時器鉤子函數的缺省處理,如果需要使用這些函數,需要重新掛接
CPU_002_tick_process = CPU_interrupt_proc_null;
CPU_004_tick_process = CPU_interrupt_proc_null;
CPU_008_tick_process = CPU_interrupt_proc_null;
CPU_010_tick_process = CPU_interrupt_proc_null;
CPU_020_tick_process = CPU_interrupt_proc_null;
CPU_040_tick_process = CPU_interrupt_proc_null;
CPU_080_tick_process = CPU_interrupt_proc_null;
CPU_100_tick_process = CPU_interrupt_proc_null;
CPU_200_tick_process = CPU_interrupt_proc_null;
CPU_400_tick_process = CPU_interrupt_proc_null;
CPU_extern_0_process = CPU_interrupt_proc_null;
CPU_extern_1_process = CPU_interrupt_proc_null;
CPU_timer_02_process = CPU_interrupt_proc_null;
//* 重新掛接HOOK函數
CPU_001_tick_process = HC595_refresh; //* 2MS
CPU_008_tick_process = MAIN_key_timer; //* 按鍵掃描
CPU_080_tick_process = LED_refresh; //* 128x2=256MS
}
/********************************************************************************/
/* function : main() */
/* recension: xillinx */
/* descript : 主函數入口 */
/********************************************************************************/
void main (void)
{ unsigned int delax=0x8000;
while(delax--)
{ ;
}
LCDT_initialize();
UART_buffer_initilize();
MAIN_interrupt_hook_process(); //* CPU的掛接函數處理
CPU_source_initialize(); //* 控制CPU的資源
SEG7_clear_screen();
SEG7_printf_ascii("1234.567"); //* 測試七段數碼管
UART_printf("融益通訊學習板\r\n"); //* 測試UART串口
LCDT_print_string(0x0,0x0,"rongyitong tech"); /* 測試點陣LCD */
LCDT_print_string(0x0,0x1,"cchhww11@tom.com");
while(1)
{ MAIN_c51_key_scan();
}
}
?? 快捷鍵說明
復制代碼
Ctrl + C
搜索代碼
Ctrl + F
全屏模式
F11
切換主題
Ctrl + Shift + D
顯示快捷鍵
?
增大字號
Ctrl + =
減小字號
Ctrl + -