![]()  | 
  
    RTEMS
    5.1
    
   | 
 
Files | |
| file | i2c-bus.c | 
| Inter-Integrated Circuit (I2C) Bus Implementation.  | |
Data Structures | |
| struct | i2c_bus | 
| I2C bus control.  More... | |
Macros | |
| #define | I2C_BUS_CLOCK_DEFAULT 100000 | 
| Default I2C bus clock in Hz.  | |
Functions | |
| int | i2c_bus_init (i2c_bus *bus) | 
| Initializes a bus control.  More... | |
| i2c_bus * | i2c_bus_alloc_and_init (size_t size) | 
| Allocates a bus control from the heap and initializes it.  More... | |
| void | i2c_bus_destroy (i2c_bus *bus) | 
| Destroys a bus control.  More... | |
| void | i2c_bus_destroy_and_free (i2c_bus *bus) | 
| Destroys a bus control and frees its memory.  More... | |
| int | i2c_bus_register (i2c_bus *bus, const char *bus_path) | 
| Registers a bus control.  More... | |
| void | i2c_bus_obtain (i2c_bus *bus) | 
| Obtains the bus.  More... | |
| void | i2c_bus_release (i2c_bus *bus) | 
| Releases the bus.  More... | |
| int | i2c_bus_transfer (i2c_bus *bus, i2c_msg *msgs, uint32_t msg_count) | 
| Transfers I2C messages.  More... | |
I2C IO Control Commands | |
| #define | I2C_BUS_OBTAIN 0x800 | 
| Obtains the bus.  More... | |
| #define | I2C_BUS_RELEASE 0x801 | 
| Releases the bus.  More... | |
| #define | I2C_BUS_GET_CONTROL 0x802 | 
| Gets the bus control.  More... | |
| #define | I2C_BUS_SET_CLOCK 0x803 | 
| Sets the bus clock in Hz.  More... | |
| #define I2C_BUS_GET_CONTROL 0x802 | 
Gets the bus control.
The argument type is a pointer to i2c_bus pointer.
| #define I2C_BUS_OBTAIN 0x800 | 
Obtains the bus.
This command has no argument.
| #define I2C_BUS_RELEASE 0x801 | 
Releases the bus.
This command has no argument.
| #define I2C_BUS_SET_CLOCK 0x803 | 
Sets the bus clock in Hz.
The argument type is unsigned long.
| i2c_bus* i2c_bus_alloc_and_init | ( | size_t | size | ) | 
Allocates a bus control from the heap and initializes it.
After a sucessful allocation and initialization the bus control must be destroyed via i2c_bus_destroy_and_free(). A registered bus control will be automatically destroyed in case the device file is unlinked. Make sure to call i2c_bus_destroy_and_free() in a custom destruction handler.
| [in] | size | The size of the bus control. This enables the addition of bus controller specific data to the base bus control. The bus control is zero initialized. | 
| non-NULL | The new bus control. | 
| NULL | An error occurred. The errno is set to indicate the error. | 
| void i2c_bus_destroy | ( | i2c_bus * | bus | ) | 
Destroys a bus control.
| [in] | bus | The bus control. | 
| void i2c_bus_destroy_and_free | ( | i2c_bus * | bus | ) | 
Destroys a bus control and frees its memory.
| [in] | bus | The bus control. | 
| int i2c_bus_init | ( | i2c_bus * | bus | ) | 
Initializes a bus control.
After a sucessful initialization the bus control must be destroyed via i2c_bus_destroy(). A registered bus control will be automatically destroyed in case the device file is unlinked. Make sure to call i2c_bus_destroy() in a custom destruction handler.
| [in] | bus | The bus control. | 
| 0 | Successful operation. | 
| -1 | An error occurred. The errno is set to indicate the error. | 
| void i2c_bus_obtain | ( | i2c_bus * | bus | ) | 
Obtains the bus.
| [in] | bus | The bus control. | 
| int i2c_bus_register | ( | i2c_bus * | bus, | 
| const char * | bus_path | ||
| ) | 
Registers a bus control.
This function claims ownership of the bus control regardless if the registration is successful or not.
| [in] | bus | The bus control. | 
| [in] | bus_path | The path to the bus device file. | 
| 0 | Successful operation. | 
| -1 | An error occurred. The errno is set to indicate the error. | 
| void i2c_bus_release | ( | i2c_bus * | bus | ) | 
Releases the bus.
| [in] | bus | The bus control. | 
Transfers I2C messages.
The bus is obtained before the transfer and released afterwards.
| [in] | bus | The bus control. | 
| [in] | msgs | The messages to transfer. | 
| [in] | msg_count | The count of messages to transfer. It must be positive. | 
| 0 | Successful operation. | 
| negative | Negative error number in case of an error. | 
 1.8.15