/********************** SN8P2501B 4M __interrupt IntIn() StartOneTImeSample(void) **********************/ typedef struct { unsigned char u8WihtchIOCharge; unsigned long u16ChargeTimeIo; // unsigned long u16ChargeTimeHumi; // }ChargeTyPe; #define CHARGE_HUMIDITY_IO_HIGH() FP21 = 1 #define CHARGE_HUNIDITY_IO_LOW() FP21 = 0 #define CHARGE_IO_HIGH() FP20 = 1 #define CHARGE_IO_LOW() FP20 = 0 #define CHARGE_IO_HI() P2M = 0X00 #define F_data 20 __interrupt IntIn() { WDTR = 0X5A; // T0C = F_data; m_st_ChargeType.u8WihtchIOCharge++; if(m_st_ChargeType.u8WihtchIOCharge&0x80) // { if(m_st_ChargeType.u8WihtchIOCharge >= 0x84) // 3:1 { CHARGE_HUNIDITY_IO_LOW(); m_st_ChargeType.u8WihtchIOCharge = 0x80; } else if(m_st_ChargeType.u8WihtchIOCharge >= 0x81) { CHARGE_HUMIDITY_IO_HIGH(); } } else { if(m_st_ChargeType.u8WihtchIOCharge == 0x01)// { CHARGE_IO_HIGH(); } else if(m_st_ChargeType.u8WihtchIOCharge == 0x04)// 3:1 { CHARGE_IO_LOW(); m_st_ChargeType.u8WihtchIOCharge = 0x00; } } m_st_ChargeType.u16ChargeTimeIo++; FT0IRQ = 0; //clear t0 irq flag } void StartOneTImeSample(void) { CHARGE_IO_HI(); //P1 m_st_ChargeType.u16ChargeTimeIo = 0; // if(m_st_ChargeType.u8WihtchIOCharge&0x80) { FP21M = 1; // CHARGE_HUNIDITY_IO_LOW(); } else { FP20M = 1; // CHARGE_IO_LOW(); } delay1N(2); // T0C = F_data; // FT0ENB = 1;// // while(1) { if(FP22) // { FT0ENB = 0;// , if(m_st_ChargeType.u8WihtchIOCharge&0x80)// { m_st_ChargeType.u16ChargeTimeHumi = m_st_ChargeType.u16ChargeTimeIo; } break; } } P2M = 0X23; P2 = 0X00;// FP22M = 1; FP22 = 0; delay1N(100); FP22M = 0; }
时间: 2024-04-15 21:25:16 浏览: 192
I/O口模式-postman body方式提交数据详解
这段代码是使用 SN8P2501B 微控制器来实现对 HGL12A 的驱动程序。代码中定义了一个 ChargeType 结构体,包含了用于充电时间的变量。接下来定义了一些宏,用于控制充电引脚的高低电平状态。在 IntIn() 中断函数中,根据 u8WihtchIOCharge 的值来控制充电引脚的状态和切换。在 StartOneTImeSample() 函数中,首先配置充电引脚的模式和初始状态,然后通过延时和定时器来进行充电时间的测量,并将结果存储在 u16ChargeTimeIo 和 u16ChargeTimeHumi 变量中。
请注意,这段代码仅提供了部分片段,并且缺少一些关键的信息,如函数定义、相关引脚配置等。如果你需要完整的驱动程序,请提供更完整的代码或详细的需求描述,以便我能够更好地帮助你。
阅读全文