RTEMS: I2C Device Driver

| RTEMS 5.4-rc2

Loading...
Searching...
No Matches
Modules | Files | Data Structures | Macros | Functions
I2C Device Driver
Device Drivers » Inter-Integrated Circuit (I2C) Driver

## Modules
| EEPROM Driver
| Driver for EEPROM device.
| GPIO NXP PCA9535 Driver
| Driver for NXP PCA9535 16-bit GPIO device.
| Switch NXP PCA9535 Driver
| Driver for NXP PCA9548A 8-channel switch device.
| Temperature Sensor LM75A Driver
| Driver for NXP or Texas Instruments LM75A temperature sensor.

## Files
file | i2c-dev.c
| Inter-Integrated Circuit (I2C) Bus Implementation.

## Data Structures
struct | i2c_dev
| I2C slave device control. More...

## Macros
#define | I2C_DEV_IO_CONTROL 0x900
| Base number for device IO control commands.

## Functions
int | i2c_dev_init (i2c_dev *dev, const char *bus_path, uint16_t address)
| Initializes a device control.
i2c_dev * | i2c_dev_alloc_and_init (size_t size, const char *bus_path, uint16_t address)
| Allocates a device control from the heap and initializes it.
void | i2c_dev_destroy (i2c_dev *dev)
| Destroys a device control.
void | i2c_dev_destroy_and_free (i2c_dev *dev)
| Destroys a device control and frees its memory.
int | i2c_dev_register (i2c_dev *dev, const char *dev_path)
| Registers a device control.

## Detailed Description

## Function Documentation

## ◆ i2c_dev_alloc_and_init()

i2c_dev * i2c_dev_alloc_and_init | ( | size_t | size,
|  | const char * | bus_path,
|  | uint16_t | address
| ) |  |

Allocates a device control from the heap and initializes it.

After a sucessful allocation and initialization the device control must be destroyed via i2c_dev_destroy_and_free(). A registered device control will be automatically destroyed in case the device file is unlinked. Make sure to call i2c_dev_destroy_and_free() in a custom destruction handler.

Parameters

  [in] | size | The size of the device control. This enables the addition of device specific data to the base device control. The device control is zero initialized.
  [in] | bus_path | The path to the bus device file.
  [in] | address | The address of the device.

Return values

  non-NULL | The new device control.
  NULL | An error occurred. The errno is set to indicate the error.

See also
  i2c_dev_register()

## ◆ i2c_dev_destroy()

void i2c_dev_destroy | ( | i2c_dev * | dev | ) |

Destroys a device control.

Parameters

  [in] | dev | The device control.

## ◆ i2c_dev_destroy_and_free()

void i2c_dev_destroy_and_free | ( | i2c_dev * | dev | ) |

Destroys a device control and frees its memory.

Parameters

  [in] | dev | The device control.

## ◆ i2c_dev_init()

int i2c_dev_init | ( | i2c_dev * | dev,
|  | const char * | bus_path,
|  | uint16_t | address
| ) |  |

Initializes a device control.

After a sucessful initialization the device control must be destroyed via i2c_dev_destroy(). A registered device control will be automatically destroyed in case the device file is unlinked. Make sure to call i2c_dev_destroy_and_free() in a custom destruction handler.

Parameters

  [in] | device | The device control.
  [in] | bus_path | The path to the bus device file.
  [in] | address | The address of the device.

Return values

  0 | Successful operation.
  -1 | An error occurred. The errno is set to indicate the error.

See also
  i2c_dev_register()

## ◆ i2c_dev_register()

int i2c_dev_register | ( | i2c_dev * | dev,
|  | const char * | dev_path
| ) |  |

Registers a device control.

This function claims ownership of the device control regardless if the registration is successful or not.

Parameters

  [in] | dev | The dev control.
  [in] | dev_path | The path to the device file of the device.

Return values

  0 | Successful operation.
  -1 | An error occurred. The errno is set to indicate the error.