完成time3设置,用于提供系统时间

This commit is contained in:
jxh
2025-03-19 18:22:32 +08:00
parent d93e502437
commit 8f5aa0e0a7
9 changed files with 113 additions and 42 deletions

22
Lib/KeyScan.c Normal file
View File

@ -0,0 +1,22 @@
#include "KeyScan.h"
void main() {
Key_Init(); // 初始化按键模块
Timer0_Init(); // 配置1ms定时器
while(1) {
// 在定时器中断服务例程中调用Key_Scan()
if(Get_KeyEvents()) {
// 执行按键处理逻辑
uint8_t keys = Get_KeyEvents();
if(keys & 0x08) { /* KEY1处理 */ }
if(keys & 0x04) { /* KEY2处理 */ }
// ...其他按键处理
}
}
}
// // Timer0中断服务函数
// void Timer0_ISR() interrupt 1 {
// Key_Scan(); // 定时扫描按键
// }

16
Lib/KeyScan.h Normal file
View File

@ -0,0 +1,16 @@
/* KeyScan.h - 按键模块接口 */
#ifndef __KEY_SCAN_H__
#define __KEY_SCAN_H__
// 按键引脚定义(与硬件布局一致)
sbit KEY1 = P3^0;
sbit KEY2 = P3^1;
sbit KEY3 = P3^2;
sbit KEY4 = P3^3;
// 函数声明
void Key_Init(void);
void Key_Scan(void);
uint8_t Get_KeyEvents(void);
#endif

View File

@ -2,7 +2,7 @@
#define __DELAY_H__
#include "config.h"
#include "timer4.h"
#include "timer.h"
void Delay_Init (void);
void DelayUs (u16 us);