AT24C256 是256Kbit大小的eeprom,掉电仍可保留数据。本驱动实现了通过I2C总线对AT24C256的读写操作。
#include <asm/io.h>
#include <linux/init.h>
#include <linux/module.h>
#include <linux/delay.h>
MODULE_LICENSE("Dual BSD/GPL");
#include "sti7105.h"
#include "stsys.h"
#include "stddefs.h"
#include "sti2c.h"
#include "stsys.h"
#define I2C1 0x01
//extern U32 at24c256_i2c1_cfg(void);
ST_DeviceName_t PIO_DeviceName[] = {"PIO0","PIO1","PIO2","PIO3","PIO4","PIO5","PIO6","PIO7","PIO8","PIO9","PIO10","PIO11","PIO12","PIO13","PIO14","PIO15","PIO16","PIO17","PIO18","PIO19","PIO20","PIO21","PIO22","PIO23","PIO24","PIO25","PIO26"};
static STI2C_Handle_t I2c_handle;
static U8 init_data[] =
{
1, 0x00,
2, 0xc0,
3, 0x0a,
4, 0xab,
5, 0x08,
6, 0x88,
7, 0x00,
8, 0xcd,
9, 0x0f,
10, 0xf0,
11, 0x7f,
};
U32 static ee_i2c_write(U16 sub_addr,U8 *data,U16 data_size)
{
STI2C_Params_t I2C_Params;
U32 ErrCode;
U32 nread ,nwrite;
U8 buf_write[64];
// U8 buf_read[6