This commit is contained in:
2024-07-15 01:39:23 +08:00
commit 917a4cc7cd
9 changed files with 318 additions and 0 deletions

26
include/intrins.h Normal file
View File

@ -0,0 +1,26 @@
#ifndef _INTRINS_H_
#define _INTRINS_H_
/* warning: __push __pop 使用堆栈临时保存 sfr 数据,必需成对使用!
__push(x);
... // 保护代码块
__pop(x) //缺少无该语句编译不会出错,但运行错误!
*/
#define __push(x) __asm push _##x __endasm /* void _push_ (unsigned char _sfr); */
#define __pop(x) __asm pop _##x __endasm /* void _pop_ (unsigned char _sfr); */
#define _push_ __push  /*兼容 keil c51*/
#define _pop_ __pop  /*兼容 keil c51*/
/* 安全使用保护宏:
pushSfr(x);
... // 受保护代码块
popSfr(x) // 缺少无该语句编译出错,确保生成正确代码。
*/
#define pushSfr(x) do{\
__push(x)
#define popSfr(x) __pop(x);\
}while(0)
#endif //_INTRINS_H_

21
include/public.h Normal file
View File

@ -0,0 +1,21 @@
#ifndef _public_H
#define _public_H
// #include "reg52.h"
#include <8052.h>
typedef unsigned int u16;
typedef unsigned char u8;
// 用于自动重启的变量
__sfr __at (0xE7) ISP_CONTR;
#define RESET_PASSWORD_LENGTH 6
extern char __xdata reset_password[RESET_PASSWORD_LENGTH];
extern char __xdata receice_password[RESET_PASSWORD_LENGTH];
void delay_10us(u16 ten_us);
void delay_ms(u16 ms);
u8 auto_reset(u8 rec_data);
#endif

22
include/uart.h Normal file
View File

@ -0,0 +1,22 @@
/**************************************************************************************
深圳市普中科技有限公司PRECHIN 普中)
技术支持www.prechin.net
实验名称:串口通信实验
接线说明:
实验现象:下载程序后,当串口助手发送数据给单片机,单片机原封不动转发给串口助手显示
注意事项使用黄色跳线帽将CH340旁的P5端子的UTX和P30短接URX和P31短接出厂默认已短接好
***************************************************************************************/
#ifndef _uart_H
#define _uart_H
#include "public.h"
extern __bit busy;
void uart_init(u8 baud);
void send_string(char *s);
void send_data(u8 dat);
int putchar(char c);
#endif