#include <htc.h>
#define uint8 unsigned char
#define uint16 unsigned int
__CONFIG(FOSC_HS &WDTE_OFF &BOREN_OFF &PWRTE_OFF &LVP_OFF); //设置配置位
//WDTE_OFF:disable watchdog timer 看门狗禁止
//LVP_OFF:low voltage programming disabled 低电压编程禁止
//FOSC_HS:high speed crystal/resonator 4M以上晶振选择HS高速
//PWRTDIS:disable power up timer
//BOREN_OFF:disable brown out reset
/********************定义数据线************************************************/
#define IIC_SCLK RC3 //24C02时钟线
#define IIC_SDAT RC4 //24C02数据线
/********************定义全局变量**********************************************/
const uint8 disp[] = {0xC0, 0xF9, 0xA4, 0xB0, 0x99, 0x92, 0x82, 0xF8, 0x80, 0x90}; //0~9共阳数码管段码表
uint8 init[8] = {0x59, 0x43, 0x21, 0x11, 0x03, 0x03, 0x09, 0x00}; //EEPROM写初始值数组
uint8 recive[8]; //读EEPROM数据存放数组
/********************函数声明**************************************************/
void IIC_WriteACK(void); //返回应答信号
void IIC_Stop(void); //停止信号
void IIC_Writenoack(void); //无应答信号
void IIC_Start(void); //启动信号
void DelayUS(uint8 delay); //微妙延时
void DelayMS(uint16 delay); //毫秒延时
uint8 IIC_ReadByte(void); //IIC读8位字节数据
uint8 IIC_WriteByte(uint8 data); //IIC写8位字节数据
void Display(uint8 chosebit, uint8 data);
void IIC_Read_Mulit_Data(uint8 commond, uint8 address, uint8 *addrpoint, uint8 bytenum);
void IIC_Write_Mulit_Data(uint8 commond, uint8 reg_addr, uint8 *mdatapointer, uint8 bytenum);
|