微波EDA网,见证研发工程师的成长!
首页 > 硬件设计 > 嵌入式设计 > stm32之模拟i2c驱动ht16c22

stm32之模拟i2c驱动ht16c22

时间:12-03 来源:互联网 点击:

an**************************/
#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*********************************/

Copyright © 2017-2020 微波EDA网 版权所有

网站地图

Top