跪求程序代码

来源:百度知道 编辑:UC知道 时间:2024/05/14 07:26:09
c语言程序代码
要求就是串口与计算机相连,通过程序控制外设开关,开关是按照系统时间来定的,完整的程序.谢谢大家了.尽量的多一点,越多越好,要交报告了,大家帮帮忙.

//*------------------------------------------------------*/
//* Cexp7.cpp(查询方式全双工串行通信接口实验) */
//* 查询方式全双工串行通信程序 Source File */
//* Copyright (c) 2001 by yezi */
//*------------------------------------------------------*/
#include <conio.h> //kbhit();
#include <stdio.h> //printf();
#include <dos.h> //delay();

#define data51 0x308 //8251A数据口
#define ctrl51 0x309 //8251A命令/状态口
#define ctrl55 0x303 //8255命令口
#define timer2 0x306 //8253的2号计数器端口
#define timctl 0x307 //8253命令口
//#define clk 1193182
#define factor 16 //波特率因子16

unsigned long int clk = 1193182;//8251输入时钟频率(十六进制表示)
//定时常数数组
int tc_table[8]={
110, // 0=110bps
150, // 1=150b/s
300, // 2=300b/s
600, // 3=600b/s
1200, // 4=1200b/s
2400, // 5=2400b/s
4800, // 6=4800b/s