C51中 Putchar、 _getkey(void)的替换
来源:互联网 发布:java与php的优缺点 编辑:程序博客网 时间:2024/06/05 11:38
1、拷贝KEIL C51下LIB目录中的PUTCHAR.C和GETKEY.C文件到你的项目目录下,并且将其添加到你的工程中
2、PUTCHAR.C原代码如下
/***********************************************************************//* This file is part of the C51 Compiler package *//* Copyright KEIL ELEKTRONIK GmbH 1990 - 2002 *//***********************************************************************//* *//* PUTCHAR.C: This routine is the general character output of C51. *//* You may add this file to a uVision2 project. *//* *//* To translate this file use C51 with the following invocation: *//* C51 PUTCHAR.C <memory model> *//* *//* To link the modified PUTCHAR.OBJ file to your application use the *//* following Lx51 invocation: *//* Lx51 <your object file list>, PUTCHAR.OBJ <controls> *//* *//***********************************************************************/#include <reg51.h>#define XON 0x11#define XOFF 0x13/* * putchar (full version): expands '\n' into CR LF and handles * XON/XOFF (Ctrl+S/Ctrl+Q) protocol */char putchar (char c) { if (c == '\n') { if (RI) { if (SBUF == XOFF) { do { RI = 0; while (!RI); } while (SBUF != XON); RI = 0; } } while (!TI); TI = 0; SBUF = 0x0d; /* output CR */ } if (RI) { if (SBUF == XOFF) { do { RI = 0; while (!RI); } while (SBUF != XON); RI = 0; } } while (!TI); TI = 0; return (SBUF = c);}#if 0 // comment out versions below/* * putchar (basic version): expands '\n' into CR LF */char putchar (char c) { if (c == '\n') { while (!TI); TI = 0; SBUF = 0x0d; /* output CR */ } while (!TI); TI = 0; return (SBUF = c);}/* * putchar (mini version): outputs charcter only */char putchar (char c) { while (!TI); TI = 0; return (SBUF = c);}#endif
修改后PUTCHAR.C代码如下:
extern void Serial_Out(unsigned char Serial_Out_Data);//自编<span style="font-family: Arial;">以中断方式</span>向指定的串行口输出一个字节void putchar (char c) {Serial_Out(c);//<span style="font-family: Arial;">自编</span>以中断方式向指定的串行口输出一个字节}3、GETKEY.C原代码如下
/***********************************************************************//* This file is part of the C51 Compiler package *//* Copyright KEIL ELEKTRONIK GmbH 1993 - 2002 *//***********************************************************************//* *//* GETKEY.C: This routine is the general character input of C51. *//* You may add this file to a uVision2 project. *//* *//* To translate this file use C51 with the following invocation: *//* C51 GETKEY.C <memory model> *//* *//* To link the modified GETKEY.OBJ file to your application use the *//* following Lx51 invocation: *//* Lx51 <your object file list>, GETKEY.OBJ <controls> *//* *//***********************************************************************/#include <reg51.h>char _getkey () { char c; while (!RI); c = SBUF; RI = 0; return (c);}修改后GETKEY.C代码如下:
extern unsigned char Serial_In(void);char _getkey () { char c;c=Serial_In(); return (c);}4、编译你的项目即可完成 对void putchar (char c)和_getkey ()的替换
5、可将_getkey ()改写为按键输入,也可将putchar (char c)改为向LCD屏输出
0 0
- C51中 Putchar、 _getkey(void)的替换
- C语言中putchar()函数的使用
- C51中变量的存储
- C语言中getchar与putchar的使用
- putchar的线程安全
- putchar
- putchar()
- putchar
- putchar
- C51中关键字对应的功能
- C51单片机中常用的头文件
- C51中常用的关系符
- Keil C51中变量的使用
- C51中interrupt和using的用法
- Keil C51中printf()函数的说明
- C51中变量的存储器类型有
- C51中关键字volatile的用法
- javascript中void的妙用
- CoreData
- Android Studio美化之优雅的logcat
- 杭电acm2107
- servlet 生成验证图片
- Android背后的设计思想——功能共享机制
- C51中 Putchar、 _getkey(void)的替换
- Android SimpleAdapter 的详解和使用
- ALV 导出报表数据
- Nginx架构
- 杭电acm--2187
- 创建Filter步骤
- UISegmentControl 字体加粗
- 使用回调方法在adapter 更新activtiy 数据
- js让对象延迟500毫秒后显示文本在点击的位置