IIC模拟 && E2PROM
IIC_eeprom.h
#ifndef __IIC_EEPROM_H__ #define __IIC_EEPROM_H__ /***************************************************************************************** 型号 Byte容量 页数 页内字节数 WORD_ADDR位数 WORD_ADDR字节数 x24C01 128Byte 16页 8Byte 7bit 1Byte x24C02 256Byte 32页 8Byte 8bit 1Byte x24C04 512Byte 32页 16Byte 9bit 1Byte x24C08 1024Byte 64页 16Byte 10bit 1Byte x24C16 2048Byte 128页 16Byte 11bit 1Byte x24C32 4096Byte 128页 32Byte 12bit 2Byte x24C64 8192Byte 256页 32Byte 13bit 2Byte x24C128 16384Byte 256页 64Byte 14bit 2Byte x24C256 32768Byte 512页 64Byte 15bit 2Byte x24C512 65536Byte 512页 128Byte 16bit 2Byte *****************************************************************************************/ #define AT24C01 127 #define AT24C02 255 #define AT24C04 511 #define AT24C08 1023 #define AT24C16 2047 #define AT24C32 4095 #define AT24C64 8191 #define AT24C128 16383 #define AT24C256 32767 #define EE_TYPE AT24C128 #define ACK (0) #define NO_ACK (1) #define IIC_SCL_PIN PC1 #define IIC_SDA_PIN PC0 #define IIC_SDA_OUT() GPIO_SetMode(PC, BIT0, GPIO_MODE_OUTPUT) #define IIC_SDA_IN() GPIO_SetMode(PC, BIT0, GPIO_MODE_INPUT) #define SCL_HIGH() PC1 = 1 #define SCL_LOW() PC1 = 0 #define SDA_HIGH() PC0 = 1 #define SDA_LOW() PC0 = 0 #define SDA_READ() PC0 #define Device_ADDR 0xA0 #define WRITE_FLAG 0 #define READ_FLAG 1 void IIC_Init(void); void IIC_Start(void); void IIC_Stop(void); void IIC_SendAck(void); void IIC_SendNoAck(void); uint8_t IIC_WaitforAck(void); void IIC_SendByteData(uint8_t data); uint8_t IIC_RcvByteData(uint8_t ackFlag); void ROM24CXX_WriteOneByte(uint16_t WriteAddr, uint8_t DataToWrite); uint8_t ROM24CXX_ReadOneByte(uint16_t ReadAddr); void ROM24CXX_WriteLenByte(uint16_t WriteAddr, uint32_t DataToWrite, uint8_t Len); void ROM24CXX_Write(uint16_t WriteAddr, uint8_t *pBuffer, uint16_t NumToWrite); uint32_t ROM24CXX_ReadLenByte(uint16_t ReadAddr, uint8_t Len); void ROM24CXX_Read(uint16_t ReadAddr, uint8_t *pBuffer, uint16_t NumToRead); uint8_t ROM24CXX_Check(void); void Eeprom_Proc(void); #endifView Code
IIC_eeprom.c 标签:&&,void,uint8,uint16,IIC,E2PROM,ROM24CXX,define From: https://www.cnblogs.com/panda-w/p/18354375