dnx RTOS 2.2.0 "Eagle"
 All Data Structures Functions Variables Typedefs Enumerations Enumerator Groups Pages
I2CEE Driver (I2C EEPROM)

Detailed Description

Description

Driver handles 24Cxx devices. The role of driver is handling memory paging and programming times. By using this driver file systems can handle memory without any page restrictions.

Device (drivers) connection table

Grade Device In Out
0 24cXX - I2C interface
1 I2C driver I2C interface /dev/i2c_ee
2 I2CEE driver /dev/i2c_ee /dev/sda
3 File system /dev/sda /mnt

Supported architectures

Details

Meaning of major and minor numbers

Only major number is used to identify device. Only minor number set to 0 is accepted by driver.

Numeration restrictions

The minor number should be set to 0.

Driver initialization

To initialize driver the following code can be used:

driver_init("I2CEE", 0, 0, "/dev/24c32");
driver_init("I2CEE", 1, 0, "/dev/24c64");

Driver release

To release driver the following code can be used:

driver_release("I2CEE", 0, 0);
driver_release("I2CEE", 1, 0);

Driver configuration

Driver can be configured only by ioctl() function. Configuration example:

#include <sys/ioctl.h>
// ...
FILE *dev = fopen("/dev/24c32", "r+");
if (dev) {
static const I2CEE_config_t cfg = {
.i2c_path = "/dev/i2c0", // I2C path
.memory_size = 4096, // 32kb = 4096B
.page_size = 32, // 32B page
.page_prog_time_ms = 10 // 10ms write cycle
}
if (ioctl(fileno(dev), IOCTL_I2CEE__CONFIGURE, &cfg) == 0) {
puts("Configuration success");
} else {
perror("ioctl()");
}
fclose(dev);
} else {
perror("/dev/24c16");
}
// ...

Data write

Data to the driver can be write in the same way as regular file. Driver automatically handles page segmentation and programming time. Data can be not aligned to memory pages.

Data read

Data from the driver can be read in the same way as regular file.

Data Structures

struct  I2CEE_config_t
 

Macros

#define IOCTL_I2CEE__CONFIGURE   _IOW(I2CEE, 0x00, I2CEE_config_t*)
 I2C EEPROM driver configuration. More...
 
#define IOCTL_I2CEE__CONFIGURE_STR   IOCTL_DEVICE__CONFIGURE_STR
 I2C EEPROM driver configuration by using string. More...
 

Data Structure Documentation

struct I2CEE_config_t

Type represent driver configuration.

Data Fields
const char * i2c_path

I2C device file

u32_t memory_size

Memory size in bytes

u16_t page_prog_time_ms

Time of programming single page in milliseconds

u16_t page_size

EEPROM page size in bytes

Macro Definition Documentation

#define IOCTL_I2CEE__CONFIGURE   _IOW(I2CEE, 0x00, I2CEE_config_t*)
Parameters
[WR]I2CEE_config_t* driver configuration.
Returns
On success 0 is returned, otherwise -1.
#define IOCTL_I2CEE__CONFIGURE_STR   IOCTL_DEVICE__CONFIGURE_STR
Parameters
[WR]const char* configuration string
Returns
On success 0 is returned, otherwise -1 and errno code is set.