|
发表于 2013-7-4 23:25:21
|
显示全部楼层
- #ifndef ______IRSEND_H_______
- #define ______IRSEND_H_______
- #include "Typedef.h"
- #define IRSENDPORT P0
- #define TIMER9000US (65536-8294) //9mS
- #define TIMER4500US (65536-4147) //4.5mS
- #define TIMER1650US (65536-1520) //1.65mS
- #define TIMER0560US (65536-516) //0.56mS
- #define TIMER40000US (65536-36863) //40mS
- #define TIMER56000US (65536-51609) //56mS
- /* * * * * * * * * * * * * * * * * * * * * * * * * * * * * * *
- * Function :
- * Description : 函数功能、性能描述
- * Calls : 被本函数调用的函数清单
- * Called By : 调用本函数的函数清单
- * Table accessed: 被访问的表(数据库操作用)
- * Tabled Updated: 被修改的表(数据库操作用)
- * Input : 输入参数、取值说明与关系
- * Output : 输出参数、类型说明
- * Return : 函数返回值说明
- * Others : (Screen sequence)
- * * * * * * * * * * * * * * * * * * * * * * * * * * * * * */
- void IrUserTimerConfiguration(void)
- {
- TMOD |= 0x01;
- IRSENDPORT = 0XFF;
- }
- /* * * * * * * * * * * * * * * * * * * * * * * * * * * * * * *
- * Function :
- * Description : 函数功能、性能描述
- * Calls : 被本函数调用的函数清单
- * Called By : 调用本函数的函数清单
- * Table accessed: 被访问的表(数据库操作用)
- * Tabled Updated: 被修改的表(数据库操作用)
- * Input : 输入参数、取值说明与关系
- * Output : 输出参数、类型说明
- * Return : 函数返回值说明
- * Others : (Screen sequence)
- * * * * * * * * * * * * * * * * * * * * * * * * * * * * * */
- void IRWriteOneBit(BIT send_Mode,unsigned int TimerInitValue,unsigned char PassageNumer)
- {
- unsigned char NumBer = 1 << PassageNumer;
- unsigned char onlyOnePassageorAllChang = 20;
-
- if (PassageNumer < 8 && PassageNumer >= 0) onlyOnePassageorAllChang = 0; //单独通道发送
- else if (255 == PassageNumer) onlyOnePassageorAllChang = 1; //所有通道都发送
- TH0 = TimerInitValue >> 8;
- TL0 = TimerInitValue;
- TF0 = 0; //清TF0
- TR0 = 1; //启动定时器0
- if (send_Mode == 0) while(!TF0);
- else while(1)
- {
- if (0 == onlyOnePassageorAllChang) IRSENDPORT &= ~NumBer; //置位相应的通道
- else if (1 == onlyOnePassageorAllChang) IRSENDPORT = 0xff;
-
- if (TF0) break; if (TF0) break;
-
- if (0 == onlyOnePassageorAllChang) IRSENDPORT |= NumBer; //CLR相应通道
- else if (1 == onlyOnePassageorAllChang) IRSENDPORT = 0x00;
-
- if (TF0) break; if (TF0) break; if (TF0) break; if (TF0) break; if (TF0) break;
- if (TF0) break; if (TF0) break; if (TF0) break; if (TF0) break; if (TF0) break;
- }
- TR0 = 0;
- if (0 == onlyOnePassageorAllChang) IRSENDPORT |= NumBer;
- else if (1 == onlyOnePassageorAllChang) IRSENDPORT = 0xff;
- }
- /* * * * * * * * * * * * * * * * * * * * * * * * * * * * * * *
- * Function :
- * Description : 函数功能、性能描述
- * Calls : 被本函数调用的函数清单
- * Called By : 调用本函数的函数清单
- * Table accessed: 被访问的表(数据库操作用)
- * Tabled Updated: 被修改的表(数据库操作用)
- * Input : 输入参数、取值说明与关系
- * Output : 输出参数、类型说明
- * Return : 函数返回值说明
- * Others : (Screen sequence)
- * * * * * * * * * * * * * * * * * * * * * * * * * * * * * */
- void IRWriteOneChar(unsigned char ircode,unsigned char PassageNumer)
- {
- unsigned char I = 0x00;
- for (I = 0;I < 8;I++)
- {
- IRWriteOneBit(1,TIMER0560US,PassageNumer);
- if (ircode & 0x01)
- {
- IRWriteOneBit(0,TIMER1650US,PassageNumer);
- }
- else
- {
- IRWriteOneBit(0,TIMER0560US,PassageNumer);
- }
- ircode >>= 1;
- }
- }
- /* * * * * * * * * * * * * * * * * * * * * * * * * * * * * * *
- * Function :
- * Description : 函数功能、性能描述
- * Calls : 被本函数调用的函数清单
- * Called By : 调用本函数的函数清单
- * Table accessed: 被访问的表(数据库操作用)
- * Tabled Updated: 被修改的表(数据库操作用)
- * Input : 输入参数、取值说明与关系
- * Output : 输出参数、类型说明
- * Return : 函数返回值说明
- * Others : (Screen sequence)
- * * * * * * * * * * * * * * * * * * * * * * * * * * * * * */
- void IrPortWriteIrcode(unsigned char *Ir_Point,unsigned char PassageNumer)
- {
- IRWriteOneBit(1,TIMER9000US,PassageNumer);
- IRWriteOneBit(0,TIMER4500US,PassageNumer);
- IRWriteOneChar(*(Ir_Point+0),PassageNumer);
- IRWriteOneChar(*(Ir_Point+1),PassageNumer);
- IRWriteOneChar(*(Ir_Point+2),PassageNumer);
- IRWriteOneChar(*(Ir_Point+3),PassageNumer);
- IRWriteOneBit(1,TIMER0560US ,PassageNumer);
- IRWriteOneBit(0,TIMER40000US,PassageNumer);
- }
- #endif
复制代码 哈哈,这个是参照论坛的,比较好理解! |
|