47 lines
1.2 KiB
C
47 lines
1.2 KiB
C
#ifndef _BL24C512_H_
|
|
#define _BL24C512_H_
|
|
|
|
#include "stm32f10x.h"
|
|
#include "Basedefine.h"
|
|
|
|
#define SDA_MODE_IN TRUE
|
|
#define SDA_MODE_OUT FALSE
|
|
|
|
#define EEPROM_PAGE_SIZE 128
|
|
|
|
|
|
#define BL24C512ADDR 0xA0
|
|
#define ADDRMAX 65535
|
|
|
|
|
|
#define SDA_PIN GPIO_Pin_7
|
|
#define SDA_PIN_PORT GPIOB
|
|
#define SDA_PIN_CLK RCC_APB2Periph_GPIOB
|
|
|
|
#define SCL_PIN GPIO_Pin_6
|
|
#define SCL_PIN_PORT GPIOB
|
|
#define SCL_PIN_CLK RCC_APB2Periph_GPIOB
|
|
|
|
|
|
#define SDA_HIGH() GPIO_SetBits(SDA_PIN_PORT, SDA_PIN)
|
|
#define SDA_LOW() GPIO_ResetBits(SDA_PIN_PORT, SDA_PIN)
|
|
|
|
#define SCL_HIGH() GPIO_SetBits(SCL_PIN_PORT, SCL_PIN)
|
|
#define SCL_LOW() GPIO_ResetBits(SCL_PIN_PORT, SCL_PIN)
|
|
|
|
#define GET_SDA() GPIO_ReadInputDataBit(SDA_PIN_PORT, SDA_PIN)
|
|
|
|
|
|
void delayedus(u8 n);
|
|
void bl24c512_init(void);
|
|
bool I2C_eeprom_write_byte(u16 addr, u8 data);
|
|
bool I2C_eeprom_Read_byte(u16 addr, u8 *data);
|
|
bool I2C_eeprom_write_buf(u16 addr, u8 * buf, u16 length);
|
|
bool I2C_eeprom_read_buf(u16 addr, u8 * buf, u16 length);
|
|
void I2C_test(void);
|
|
void IIC_test_write(void);
|
|
void IIC_test_read(void);
|
|
void self_test_eeprom(void);
|
|
|
|
#endif
|