您的位置 首页 知识

stm32之模仿i2c驱动ht16c22

iic.h文件如下:#ifndef_stm32f103_myi2c_h_#define_stm32f103_myi2c_h_//IO方向设置#defineSDA_IN(){GPIOB->CRH=

iic.h文件如下:


#ifndef _stm32f103_myi2c_h_
#define _stm32f103_myi2c_h_

//IO方向设置
#define SDA_IN() {GPIOB->CRH&=0XFFFF0FFF;GPIOB->CRH|=8<<12;}
#define SDA_OUT() {GPIOB->CRH&=0XFFFF0FFF;GPIOB->CRH|=3<<12;} //IO操作函数
#define IIC_SCL PBout(10) //SCL
#define IIC_SDA PBout(11) //SDA
#define READ_SDA PBin(11) //输入SDA

//ht16c22内部 参数设置
#define SlaveAddress 0x7e //0x7e

#define ModeSet 0x8c //80Hz,turn on sys and LCD bias,1/3 bias

#define VlcdAdjust 0x70 //0x7F –Vlcd=0.6VDD,Seg Pin,enable internal voltage

#define Blink 0xC0 //封闭闪耀

//IIC一切操作函数
void IIC_Init(void); //初始化IIC的IO口
void IIC_Start(void); //发送IIC开端信号
void IIC_Stop(void); //发送IIC中止信号
void IIC_Send_Byte(u8 txd); //IIC发送一个字节
u8 IIC_Read_Byte(unsigned char ack);//IIC读取一个字节
u8 IIC_Wait_Ack(void); //IIC等候ACK信号
void IIC_Ack(void); //IIC发送ACK信号
void IIC_NAck(void); //IIC不发送ACK信号

void IIC_Write_One_Byte(u8 daddr,u8 addr,u8 data);
u8 IIC_Read_One_Byte(u8 daddr,u8 addr);
void ht16c22_init(void);
void ht16c22_display(unsigned char add,unsigned char dat);
void ht16c22_test(void);
unsigned char ht16c22_read(unsigned add);
void ht16c22_dis_num(int num);
void ht16c22_dis_staus(int num);
void ht16c22_dis_bat(int num);
void ht16c22_dis_month2(int num);

/////////////////////////////////////////////////////////////////////////////////
void status_digital(int num);//——–2
void signal_digital(int num);//——–4
void battery_digital(int num);//——-4
void clock_digital(void);
void first_digital(int num);//月1——2
void first_digital_dismiss(void );//月份1不显现
void second_digital(int num);//月2\———-10
void second_digital_dismiss(void);//月份2不显现
void month_digital(void);
void third_digital(int num);//day1—-4
void third_digital_dismiss(void );//day1 dismiss
void fourth_digital(int num);//day2——–9
//day2 dismiss
void fourth_digital_dismiss(void );
//hour1
void fifth_digital(int num);//——3
void fifth_digital_dismiss(void );//hour1 dismiss

void sixth_digital(int num);//hour2——–9
void sixth_digital_dismiss(void);//hour2 dismiss
void mao_digital(void );
//minute1 dismiss
void seventh_digital_dismiss(void );
//minute1
void seventh_digital(int num);//———6
//minute2
void eight_digital(int num);//———–9
void eight_digital_dismiss(void);//minute dismiss
void nineth_digital(int num);//hum2——-9
void nineth_o_digital(void );
void nineth_dismiss_digital(void );

//hum3
void tenth_digital(int num);//——–9
void tenth_digital_dismiss(void);
void tenth_ON_digital(void);
void the_on_off_digital(int num);//——2
void tenth_OF_digital(void );
//hum4
void eleventh_digital(int num);//——-9
void eleventh_digital_dismiss(void );
//hum fuhao
void temp_digital(int num);//——–9
void dot_digital(int num);//—–2
void minus_digital(void );
void set_above_digital(int num);//—2
void set_alarm_digital(int num);//—-2
void set_speaker_digital(int num);//—-2
//tem2
void temp_high_digital(int num);//——-9
void temp_high_digital_off(void );
void temp_Middle_digital(int num);//tem3//———9
void temp_Middle_digital_off(void );
//tem4
void temp_Last_digital(int number);//——–9
void temp_Last_digital_off(void );
void dot_temp_digital(int num);//—–2
void temp_digital_new(int num);//—–2
void humid_digital_new(int num);//—2
void addr_digital(int number);//—-9
void addr_digital_dismiss(void);
void baud_digital(int num);//—-9
void baud_digital_dismiss(void);
void temp_minus_digital(int num);//——–2
void print_digital(int num);//—2
void log_digital(int num);//——–2
void erase_digital(int num);//——–2
#endif

iic.c文件内容为:


/********************************copyright ythuitong by wit_yuan**************************/
#include “bsp.h”

//////////////////////////////////////////////////////////////////////////
// 函数名 : IIC_Init
// 功用 : 初始化i2c
// 参数 : void
// 作者 : wit_yuan
// 时刻 : 2014-11-07
////////////////////////////////////////////////////////////////////////////
void IIC_Init(void)
{
GPIO_InitTypeDef GPIO_InitStructure;
RCC_APB2PeriphClockCmd( RCC_APB2Periph_GPIOB, ENABLE );
GPIO_InitStructure.GPIO_Pin = GPIO_Pin_10|GPIO_Pin_11;
GPIO_InitStructure.GPIO_Mode = GPIO_Mode_Out_OD ; //推挽输出
GPIO_InitStructure.GPIO_Speed = GPIO_Speed_50MHz;
GPIO_Init(GPIOB, &GPIO_InitStructure);
GPIO_SetBits(GPIOB,GPIO_Pin_10|GPIO_Pin_11); //PB10,PB11 输出高
}
//////////////////////////////////////////////////////////////////////////
// 函数名 : IIC_Start
// 功用 : i2c起始信号
// 参数 : void
// 作者 : wit_yuan
// 时刻 : 2014-11-07
////////////////////////////////////////////////////////////////////////////
void IIC_Start(void)
{
SDA_OUT(); //sda线输出
IIC_SDA=1;
IIC_SCL=1;
Delay_us(4);
IIC_SDA=0; //START:when CLK is high,DATA change form high to low
Delay_us(4);
IIC_SCL=0; //钳住I2C总线,预备发送或接纳数据
}
//////////////////////////////////////////////////////////////////////////
// 函数名 : IIC_Stop
// 功用 : i2c完毕信号
// 参数 : void
// 作者 : wit_yuan
// 时刻 : 2014-11-07
////////////////////////////////////////////////////////////////////////////
void IIC_Stop(void)
{
SDA_OUT();//sda线输出
IIC_SCL=0;
IIC_SDA=0;//STOP:when CLK is high DATA change form low to high
Delay_us(4);
IIC_SCL=1;
IIC_SDA=1;//发送I2C总线完毕信号
Delay_us(4);
}
//////////////////////////////////////////////////////////////////////////
// 函数名 : IIC_Wait_Ack
// 功用 : 等候i2c的应对信号
// 参数 : void
// 作者 : wit_yuan
// 时刻 : 2014-11-07
////////////////////////////////////////////////////////////////////////////
//等候应对信号到来
//回来值:1,接纳应对失利
// 0,接纳应对成功
u8 IIC_Wait_Ack(void)
{
u8 ucErrTime=0;
SDA_IN(); //SDA设置为输入
IIC_SDA=1;
Delay_us(1);
IIC_SCL=1;
Delay_us(1);
while(READ_SDA)
{
ucErrTime++;
if(ucErrTime>250)
{
IIC_Stop();
return 1;
}
}
IIC_SCL=0;//时钟输出0
return 0;
}
//////////////////////////////////////////////////////////////////////////
// 函数名 : IIC_Ack
// 功用 : 发生i2c的ack应对信号
// 参数 : void
// 作者 : wit_yuan
// 时刻 : 2014-11-07
////////////////////////////////////////////////////////////////////////////
//发生ACK应对
void IIC_Ack(void)
{
IIC_SCL=0;
SDA_OUT();
IIC_SDA=0;
Delay_us(2);
IIC_SCL=1;
Delay_us(2);
IIC_SCL=0;
}
//不发生ACK应对
void IIC_NAck(void)
{
IIC_SCL=0;
SDA_OUT();
IIC_SDA=1;
Delay_us(2);
IIC_SCL=1;
Delay_us(2);
IIC_SCL=0;
}
//IIC发送一个字节
//回来从机有无应对
//1,有应对
//0,无应对
void IIC_Send_Byte(u8 txd)
{
u8 t;
SDA_OUT();
IIC_SCL=0;//拉低时钟开端数据传输
for(t=0;t<8;t++)
{
//IIC_SDA=(txd&0x80)>>7;
if((txd&0x80)>>7)
IIC_SDA=1;
else
IIC_SDA=0;
txd<<=1;
Delay_us(2);
IIC_SCL=1;
Delay_us(2);
IIC_SCL=0;
Delay_us(2);
}
}
//读1个字节,ack=1时,发送ACK,ack=0,发送nACK
u8 IIC_Read_Byte(unsigned char ack)
{
unsigned char i,receive=0;
SDA_IN();//SDA设置为输入
for(i=0;i<8;i++ )
{
IIC_SCL=0;
Delay_us(2);
IIC_SCL=1;
receive<<=1;
if(READ_SDA)receive++;
Delay_us(1);
}
if (!ack)
IIC_NAck();//发送nACK
else
IIC_Ack(); //发送ACK
return receive;
}

void ht16c22_init(void)
{
IIC_Start();
IIC_Send_Byte(SlaveAddress); // SlaveAddress 0x7e
IIC_Wait_Ack();
IIC_Send_Byte(ModeSet); // ModeSet 0x8C 80Hz,turn on sys and LCD bias,1/3 bias
IIC_Wait_Ack();
IIC_Send_Byte(Blink); // Blink 0xC0 //封闭闪耀
IIC_Wait_Ack();
IIC_Stop();
}
void ht16c22_display(unsigned char add,unsigned char dat)
{
IIC_Start();
IIC_Send_Byte(SlaveAddress); // SlaveAddress 0x7e
IIC_Wait_Ack();
IIC_Send_Byte(add); // address
IIC_Wait_Ack();
IIC_Send_Byte(dat);
IIC_Wait_Ack();
IIC_Stop();
}

void ht16c22_test(void)
{
ht16c22_display(0x00,0xd7);
ht16c22_display(0x01,0x00);
ht16c22_display(0x02,0x00);
ht16c22_display(0x03,0x00);
ht16c22_display(0x04,0x00);
ht16c22_display(0x05,0x00);
ht16c22_display(0x06,0x00);
ht16c22_display(0x07,0x00);
ht16c22_display(0x08,0x00);
ht16c22_display(0x09,0x00);
ht16c22_display(0x0A,0x00);
ht16c22_display(0x0B,0x00);
ht16c22_display(0x0C,0x00);
ht16c22_display(0x0D,0x00);
ht16c22_display(0x0E,0x00);
ht16c22_display(0x0F,0x00);
ht16c22_display(0x10,0x00);
ht16c22_display(0x11,0x00);
ht16c22_display(0x12,0x00);
ht16c22_display(0x13,0x00);
ht16c22_display(0x14,0x00);
ht16c22_display(0x15,0x00);

}
unsigned char ht16c22_read(unsigned add)
{
unsigned temp;
IIC_Start();
IIC_Send_Byte(SlaveAddress); // SlaveAddress 0x7e
IIC_Wait_Ack();
IIC_Send_Byte(add); // address
IIC_Wait_Ack();
IIC_Stop();
IIC_Start();
IIC_Send_Byte(SlaveAddress+1); // SlaveAddress 0x7e
IIC_Wait_Ack();
temp = IIC_Read_Byte(1);
IIC_Stop();
return temp;
}

void ht16c22_dis_num(int num)
{
switch(num)
{
case 0:
ht16c22_display(0x00,0x00);
ht16c22_display(0x00,0xd7);
break;
case 1:
ht16c22_display(0x00,0x00);
ht16c22_display(0x00,0x06);
break;
case 2:
ht16c22_display(0x00,0x00);
ht16c22_display(0x00,0xe3);
break;
case 3:
ht16c22_display(0x00,0x00);
ht16c22_display(0x00,0xa7);
break;
case 4:
ht16c22_display(0x00,0x00);
ht16c22_display(0x00,0x36);
break;
case 5:
ht16c22_display(0x00,0x00);
ht16c22_display(0x00,0xb5);
break;
case 6:
ht16c22_display(0x00,0x00);
ht16c22_display(0x00,0xf5);
break;
case 7:
ht16c22_display(0x00,0x00);
ht16c22_display(0x00,0x07);
break;
case 8:
ht16c22_display(0x00,0x00);
ht16c22_display(0x00,0xf7);
break;
case 9:
ht16c22_display(0x00,0x00);
ht16c22_display(0x00,0xb7);
break;
default:

break;
}

}
//信号状况与电池电量共用地址0x0c的8位,操作信号状况需求先把电池电量保存。电池电量是高4位,信号状况时低4位
void ht16c22_dis_staus(int num)
{

int temp;
temp = ht16c22_read(0x0c);
ht16c22_display(0x0c,(~0x0f)&temp);
switch(num)
{
case 0:
ht16c22_display(0x0c,0x01 | temp);

break;

case 1:
ht16c22_display(0x0c,0x03 | temp);
break;

case 2:
ht16c22_display(0x0c,0x07 | temp);
break;

case 3:
ht16c22_display(0x0c,0x0f | temp);
break;
default:
break;

}
}

void ht16c22_dis_bat(int num)
{
int temp;
temp = ht16c22_read(0x0c);
ht16c22_display(0x0c,(~0x70)&temp);
switch(num)
{
case 0:
ht16c22_display(0x0c,0x80 | temp);

break;

case 1:
ht16c22_display(0x0c,0x90 | temp);
break;

case 2:
ht16c22_display(0x0c,0xb0 | temp);
break;

case 3:
ht16c22_display(0x0c,0xf0 | temp);
break;
default:
break;
}
}

//————-月份十位显现————–
// 0—不显现 1—显现
//ht16c22 地址 0x0d

//月份1不显现
void first_digital_dismiss(void )
{
int temp;
temp = ht16c22_read(0x0d);
ht16c22_display(0x0d,(~0x7f)&temp);

}

//月2不显现
void second_digital_dismiss(void)
{
int temp;
temp = ht16c22_read(0x0e);
ht16c22_display(0x0e,(~0x7f)&temp);
}

//day1

//day1 dismiss
void third_digital_dismiss(void )
{
int temp;
temp = ht16c22_read(0x0f);
ht16c22_display(0x0f,(~0x7f)&temp);
}
//day2

//day2 dismiss
void fourth_digital_dismiss(void )
{
int temp;
temp = ht16c22_read(0x10);
ht16c22_display(0x10,(~0x7f)&temp);
}
//hour1

//hour1 dismiss
void fifth_digital_dismiss(void )
{
int temp;
temp = ht16c22_read(0x11);
ht16c22_display(0x11,(~0x7f)&temp);
}
//hour2

//hour2 dismiss
void sixth_digital_dismiss(void)
{
int temp;
temp = ht16c22_read(0x12);
ht16c22_display(0x12,(~0x7f)&temp);
}

//minute1 dismiss
void seventh_digital_dismiss(void )
{
int temp;
temp = ht16c22_read(0x13);
ht16c22_display(0x13,(~0x7f)&temp);
}
//minute

//minute2 dismiss
void eight_digital_dismiss(void)
{
int temp;
temp = ht16c22_read(0x14);
ht16c22_display(0x14,(~0x7f)&temp);
}

//hum2

void nineth_o_digital(void )
{
int temp;
temp = ht16c22_read(0x02);
ht16c22_display(0x02,(~0xF7)&temp);
temp = ht16c22_read(0x02);
ht16c22_display(0x02,0xe4 | temp);
}
void nineth_dismiss_digital(void )
{
int temp;
temp = ht16c22_read(0x02);
ht16c22_display(0x02,(~0xF7)&temp);
}
//hum3
void tenth_digital(int num)
{
int temp;
temp = ht16c22_read(0x01);
ht16c22_display(0x01,(~0xF7)&temp);
switch(num)
{
case 0:
temp = ht16c22_read(0x01);
ht16c22_display(0x01,0xd7 | temp);
break;

case 1:
temp = ht16c22_read(0x01);
ht16c22_display(0x01,0x06 | temp);
break;

case 2:
temp = ht16c22_read(0x01);
ht16c22_display(0x01,0xe3 | temp);
break;

case 3:
temp = ht16c22_read(0x01);
ht16c22_display(0x01,0xa7 | temp);
break;

case 4:
temp = ht16c22_read(0x01);
ht16c22_display(0x01,0x36 | temp);

break;

case 5:
temp = ht16c22_read(0x01);
ht16c22_display(0x01,0xb5 | temp);
break;

case 6:
temp = ht16c22_read(0x01);
ht16c22_display(0x01,0xf5 | temp);
break;

case 7:
temp = ht16c22_read(0x01);
ht16c22_display(0x01,0x17 | temp);
break;

case 8:
temp = ht16c22_read(0x01);
ht16c22_display(0x01,0xf7 | temp);
break;

case 9:
temp = ht16c22_read(0x01);
ht16c22_display(0x01,0xb7 | temp);
break;
}
}
void tenth_digital_dismiss(void )
{
int temp;
temp = ht16c22_read(0x01);
ht16c22_display(0x01,(~0xF7)&temp);
}
void tenth_ON_digital(void )
{
int temp;
temp = ht16c22_read(0x01);
ht16c22_display(0x01,(~0xF7)&temp);
temp = ht16c22_read(0x01);
ht16c22_display(0x01,0x57 | temp);
}

void the_on_off_digital(int num)
{
int temp_o;
int temp_n;
temp_o = ht16c22_read(0x02);
ht16c22_display(0x02,(~0xF7)&temp_o);
temp_n = ht16c22_read(0x01);
ht16c22_display(0x01,(~0xF7)&temp_n);
switch(num)
{
case 0:
temp_o = ht16c22_read(0x02);
ht16c22_display(0x02,( ~0xf7) & temp_o);
temp_n = ht16c22_read(0x01);
ht16c22_display(0x01,( ~0xf7) & temp_n);

break;

case 1:
temp_o = ht16c22_read(0x02);
ht16c22_display(0x02,0xe4 | temp_o);
temp_n = ht16c22_read(0x01);
ht16c22_display(0x01,0x57 | temp_n);
break;

case 2:
temp_o = ht16c22_read(0x02);
ht16c22_display(0x02,0xe4 | temp_o);
temp_n = ht16c22_read(0x01);
ht16c22_display(0x01,0x71 | temp_n);
break;
}

}
void tenth_OF_digital(void )
{
int temp;
temp = ht16c22_read(0x01);
ht16c22_display(0x01,(~0xF7)&temp);
temp = ht16c22_read(0x01);
ht16c22_display(0x01,0x71 | temp);
}
//hum4
void eleventh_digital(int num)
{
int temp;
temp = ht16c22_read(0x00);
ht16c22_display(0x00,(~0xF7)&temp);
switch(num)
{
case 0:
temp = ht16c22_read(0x00);
ht16c22_display(0x00,0xd7 | temp);

break;

case 1:
temp = ht16c22_read(0x00);
ht16c22_display(0x00,0x06 | temp);
break;

case 2:
temp = ht16c22_read(0x00);
ht16c22_display(0x00,0xe3 | temp);
break;

case 3:
temp = ht16c22_read(0x00);
ht16c22_display(0x00,0xa7 | temp);
break;

case 4:
temp = ht16c22_read(0x00);
ht16c22_display(0x00,0x36 | temp);

break;

case 5:
temp = ht16c22_read(0x00);
ht16c22_display(0x00,0xb5 | temp);
break;

case 6:
temp = ht16c22_read(0x00);
ht16c22_display(0x00,0xf5 | temp);
break;

case 7:
temp = ht16c22_read(0x00);
ht16c22_display(0x00,0x17 | temp);
break;

case 8:
temp = ht16c22_read(0x00);
ht16c22_display(0x00,0xf7 | temp);
break;

case 9:
temp = ht16c22_read(0x00);
ht16c22_display(0x00,0xb7 | temp);
break;
}
}
void eleventh_digital_dismiss(void )
{
int temp;
temp = ht16c22_read(0x00);
ht16c22_display(0x00,(~0xF7)&temp);
}
//hum fuhao
void temp_digital(int num)
{
int temp;
temp = ht16c22_read(0x02);
ht16c22_display(0x02,(~0x08)&temp);
switch(num)
{
case 0:
temp = ht16c22_read(0x02);
ht16c22_display(0x02,(~0x08) & temp);

break;

case 1:
temp = ht16c22_read(0x02);
ht16c22_display(0x02,0x08 | temp);
break;
}
}

void dot_digital(int num)
{
int temp;
temp = ht16c22_read(0x01);
ht16c22_display(0x01,(~0x08)&temp);
switch(num)
{
case 0:
temp = ht16c22_read(0x01);
ht16c22_display(0x01,(~0x08) & temp);

break;

case 1:
temp = ht16c22_read(0x01);
ht16c22_display(0x01,0x08 | temp);
break;
}
}
void minus_digital()
{
int temp;
temp = ht16c22_read(0x00);
ht16c22_display(0x00,(~0x08)&temp);
temp = ht16c22_read(0x00);
ht16c22_display(0x00,0x08 | temp);
}
void set_above_digital(int num)
{
int temp;
temp = ht16c22_read(0x0e);
ht16c22_display(0x0e,(~0xF7)&temp);
switch(num)
{
case 0:
temp = ht16c22_read(0x0e);
ht16c22_display(0x0e,0x80 | temp);

break;

case 1:
temp = ht16c22_read(0x0e);
ht16c22_display(0x0e,0x80 | temp);
break;
}
}
void set_low_digital(int num)
{
int temp;
temp = ht16c22_read(0x0e);
ht16c22_display(0x0e,(~0xF7)&temp);
switch(num)
{
case 0:
temp = ht16c22_read(0x0e);
ht16c22_display(0x0e,0x80 | temp);

break;

case 1:
temp = ht16c22_read(0x0e);
ht16c22_display(0x0e,0x80 | temp);
break;
}
}

void set_alarm_digital(int num)
{
int temp;
temp = ht16c22_read(0x0f);
ht16c22_display(0x0f,(~0x80)&temp);
switch(num)
{
case 0:
temp = ht16c22_read(0x0f);
ht16c22_display(0x0f,(~0x80)&temp);

break;

case 1:
temp = ht16c22_read(0x0f);
ht16c22_display(0x0f,0x80 | temp);
break;
}
}

//tem2
void temp_high_digital(int num)
{
int temp;
temp = ht16c22_read(0x07);
ht16c22_display(0x07,(~0xF7)&temp);
switch(num)
{
case 0:
temp = ht16c22_read(0x07);
ht16c22_display(0x07,0xf5 | temp);

break;

case 1:
temp = ht16c22_read(0x07);
ht16c22_display(0x07,0x60 | temp);
break;

case 2:
temp = ht16c22_read(0x07);
ht16c22_display(0x07,0xd3 | temp);
break;

case 3:
temp = ht16c22_read(0x07);
ht16c22_display(0x07,0xf2 | temp);
break;

case 4:
temp = ht16c22_read(0x07);
ht16c22_display(0x07,0x66 | temp);

break;

case 5:
temp = ht16c22_read(0x07);
ht16c22_display(0x07,0xb6 | temp);
break;

case 6:
temp = ht16c22_read(0x07);
ht16c22_display(0x07,0xb7 | temp);
break;

case 7:
temp = ht16c22_read(0x07);
ht16c22_display(0x07,0xe4 | temp);
break;

case 8:
temp = ht16c22_read(0x07);
ht16c22_display(0x07,0xf7 | temp);
break;

case 9:
temp = ht16c22_read(0x07);
ht16c22_display(0x07,0xf6 | temp);
break;
}
}
void temp_high_digital_off(void )
{
int temp;
temp = ht16c22_read(0x07);
ht16c22_display(0x07,(~0xF7)&temp);
}
//tem3
void temp_Middle_digital(int num)
{
int temp;
temp = ht16c22_read(0x08);
ht16c22_display(0x08,(~0xF7)&temp);
switch(num)
{
case 0:
temp = ht16c22_read(0x08);
ht16c22_display(0x08,0xf5 | temp);

break;

case 1:
temp = ht16c22_read(0x08);
ht16c22_display(0x08,0x60 | temp);
break;

case 2:
temp = ht16c22_read(0x08);
ht16c22_display(0x08,0xd3 | temp);
break;

case 3:
temp = ht16c22_read(0x08);
ht16c22_display(0x08,0xf2 | temp);
break;

case 4:
temp = ht16c22_read(0x08);
ht16c22_display(0x08,0x66 | temp);

break;

case 5:
temp = ht16c22_read(0x08);
ht16c22_display(0x08,0xb6 | temp);
break;

case 6:
temp = ht16c22_read(0x08);
ht16c22_display(0x08,0xb7 | temp);
break;

case 7:
temp = ht16c22_read(0x08);
ht16c22_display(0x08,0xe0 | temp);
break;

case 8:
temp = ht16c22_read(0x08);
ht16c22_display(0x08,0xf7 | temp);
break;

case 9:
temp = ht16c22_read(0x08);
ht16c22_display(0x08,0xf6 | temp);
break;
}
}

void temp_Middle_digital_off(void )
{
int temp;
temp = ht16c22_read(0x08);
ht16c22_display(0x08,(~0xF7)&temp);
}
//tem4
void temp_Last_digital(int number)
{
int temp;
temp = ht16c22_read(0x09);
ht16c22_display(0x09,(~0xF7)&temp);
switch(number)
{
case 0:
temp = ht16c22_read(0x09);
ht16c22_display(0x09,0xf5 | temp);

break;

case 1:
temp = ht16c22_read(0x09);
ht16c22_display(0x09,0x60 | temp);
break;

case 2:
temp = ht16c22_read(0x09);
ht16c22_display(0x09,0xd3 | temp);
break;

case 3:
temp = ht16c22_read(0x09);
ht16c22_display(0x09,0xf2 | temp);
break;

case 4:
temp = ht16c22_read(0x09);
ht16c22_display(0x09,0x66 | temp);

break;

case 5:
temp = ht16c22_read(0x09);
ht16c22_display(0x09,0xb6 | temp);
break;

case 6:
temp = ht16c22_read(0x09);
ht16c22_display(0x09,0xb7 | temp);
break;

case 7:
temp = ht16c22_read(0x09);
ht16c22_display(0x09,0xe0 | temp);
break;

case 8:
temp = ht16c22_read(0x09);
ht16c22_display(0x09,0xf7 | temp);
break;

case 9:
temp = ht16c22_read(0x09);
ht16c22_display(0x09,0xf6 | temp);
break;
}
}

void temp_Last_digital_off(void )
{
int temp;
temp = ht16c22_read(0x09);
ht16c22_display(0x09,(~0xF7)&temp);
}
void dot_temp_digital(int num)
{
int temp;
temp = ht16c22_read(0x08);
ht16c22_display(0x08,(~0x08)&temp);
switch(num)
{
case 0:
temp = ht16c22_read(0x08);
ht16c22_display(0x08,(~0x08)& temp);

break;

case 1:
temp = ht16c22_read(0x08);
ht16c22_display(0x08,0x08 | temp);
break;
}
}

void temp_digital_new(int num)
{
int temp;
temp = ht16c22_read(0x09);
ht16c22_display(0x09,(~0x08)&temp);
switch(num)
{
case 0:
temp = ht16c22_read(0x09);
ht16c22_display(0x09,(~0x08) & temp);

break;
case 1:
temp = ht16c22_read(0x09);
ht16c22_display(0x09,0x08 | temp);
break;
}
}

void humid_digital_new(int num)
{
int temp;
temp = ht16c22_read(0x00);
ht16c22_display(0x00,(~0x08)&temp);
switch(num)
{
case 0:
temp = ht16c22_read(0x00);
ht16c22_display(0x00,(~0x08) & temp);

break;

case 1:
temp = ht16c22_read(0x00);
ht16c22_display(0x00,0x08 | temp);
break;
}
}
void addr_digital(int number)
{
int temp;
temp = ht16c22_read(0x05);
ht16c22_display(0x05,(~0xF7)&temp);
switch(number)
{
case 0:
temp = ht16c22_read(0x05);
ht16c22_display(0x05,0xf5 | temp);

break;

case 1:
temp = ht16c22_read(0x05);
ht16c22_display(0x05,0x60 | temp);
break;

case 2:
temp = ht16c22_read(0x05);
ht16c22_display(0x05,0xd3 | temp);
break;

case 3:
temp = ht16c22_read(0x05);
ht16c22_display(0x05,0xf2 | temp);
break;

case 4:
temp = ht16c22_read(0x05);
ht16c22_display(0x05,0x66 | temp);

break;

case 5:
temp = ht16c22_read(0x05);
ht16c22_display(0x05,0xb6 | temp);
break;

case 6:
temp = ht16c22_read(0x05);
ht16c22_display(0x05,0xb7 | temp);
break;

case 7:
temp = ht16c22_read(0x05);
ht16c22_display(0x05,0xe0 | temp);
break;

case 8:
temp = ht16c22_read(0x05);
ht16c22_display(0x05,0xf7 | temp);
break;

case 9:
temp = ht16c22_read(0x05);
ht16c22_display(0x05,0xf6 | temp);
break;
case 10:
temp = ht16c22_read(0x05);
ht16c22_display(0x05,0xe7 | temp);
break;
}
}

void addr_digital_dismiss(void)
{
int temp;
temp = ht16c22_read(0x05);
ht16c22_display(0x05,(~0xF7)&temp);
}

void baud_digital(int num)
{
int temp;
temp = ht16c22_read(0x04);
ht16c22_display(0x04,(~0xF7)&temp);
switch(num)
{
case 0:
temp = ht16c22_read(0x04);
ht16c22_display(0x04,0xd7 | temp);

break;

case 1:
temp = ht16c22_read(0x04);
ht16c22_display(0x04,0x06 | temp);
break;

case 2:
temp = ht16c22_read(0x04);
ht16c22_display(0x04,0xe3 | temp);
break;

case 3:
temp = ht16c22_read(0x04);
ht16c22_display(0x04,0xa7 | temp);
break;

case 4:
temp = ht16c22_read(0x04);
ht16c22_display(0x04,0x36 | temp);

break;

case 5:
temp = ht16c22_read(0x04);
ht16c22_display(0x04,0xb5 | temp);
break;

case 6:
temp = ht16c22_read(0x04);
ht16c22_display(0x04,0xf5 | temp);
break;

case 7:
temp = ht16c22_read(0x04);
ht16c22_display(0x04,0x17 | temp);
break;

case 8:
temp = ht16c22_read(0x04);
ht16c22_display(0x04,0xf7 | temp);
break;

case 9:
temp = ht16c22_read(0x04);
ht16c22_display(0x04,0xb7 | temp);
break;
}
}
void baud_digital_dismiss(void)
{
int temp;
temp = ht16c22_read(0x04);
ht16c22_display(0x04,(~0xF7)&temp);
}

void temp_minus_digital(int num)
{
int temp;
temp = ht16c22_read(0x06);
ht16c22_display(0x06,(~0xF7)&temp);
switch(num)
{
case 0:
temp = ht16c22_read(0x06);
ht16c22_display(0x06,(~0xF7)& temp);

break;

case 1:
temp = ht16c22_read(0x06);
ht16c22_display(0x06,0x02| temp);
break;
}
}

/************************************end of file 2014-11-07*********************************/

好了,不解说了,这也是富丽的完毕了。

声明:本文内容来自网络转载或用户投稿,文章版权归原作者和原出处所有。文中观点,不代表本站立场。若有侵权请联系本站删除(kf@86ic.com)https://www.86ic.net/zhishi/252303.html

为您推荐

联系我们

联系我们

在线咨询: QQ交谈

邮箱: kf@86ic.com

关注微信
微信扫一扫关注我们

微信扫一扫关注我们

返回顶部