Soletta™ Framework
Framework for making IoT devices

Full online documentation | C API Index
 All Data Structures Files Functions Variables Typedefs Enumerations Enumerator Macros Groups Pages
Data Structures | Typedefs | Enumerations | Functions
sol-i2c.h File Reference

These routines are used for I2C access under Soletta. More...

#include <stdbool.h>
#include <stdint.h>
#include <sys/types.h>
#include <sol-macros.h>
#include <sol-buffer.h>

Go to the source code of this file.

Data Structures

struct  sol_i2c_op
 Structure to describe an operation that should be executed by the I2C Dispatcher. More...
 

Typedefs

typedef struct sol_i2c sol_i2c
 I2C handle structure. More...
 
typedef struct sol_i2c_pending sol_i2c_pending
 I2C pending operation handle structure. More...
 

Enumerations

enum  sol_i2c_speed {
  SOL_I2C_SPEED_10KBIT = 0, SOL_I2C_SPEED_100KBIT, SOL_I2C_SPEED_400KBIT, SOL_I2C_SPEED_1MBIT,
  SOL_I2C_SPEED_3MBIT_400KBIT
}
 Enum for I2C bus speed. More...
 

Functions

void sol_i2c_close (struct sol_i2c *i2c)
 Close an I2C bus. More...
 
uint8_t sol_i2c_get_bus (const struct sol_i2c *i2c)
 Get the I2C bus ID. More...
 
uint8_t sol_i2c_get_slave_address (struct sol_i2c *i2c)
 Get the (slave) device address set on an I2C bus (to deliver I2C commands to) More...
 
struct sol_i2csol_i2c_open (uint8_t bus, enum sol_i2c_speed speed)
 Open an I2C bus. More...
 
struct sol_i2csol_i2c_open_raw (uint8_t bus, enum sol_i2c_speed speed)
 Open an I2C bus. More...
 
void sol_i2c_pending_cancel (struct sol_i2c *i2c, struct sol_i2c_pending *pending)
 Cancel a pending operation. More...
 
struct sol_i2c_pendingsol_i2c_read (struct sol_i2c *i2c, uint8_t *data, size_t count, void(*read_cb)(void *cb_data, struct sol_i2c *i2c, uint8_t *data, ssize_t status), const void *cb_data)
 Perform successive asynchronous I2C byte read operations, with no specified register. More...
 
struct sol_i2c_pendingsol_i2c_read_register (struct sol_i2c *i2c, uint8_t reg, uint8_t *data, size_t count, void(*read_reg_cb)(void *cb_data, struct sol_i2c *i2c, uint8_t reg, uint8_t *data, ssize_t status), const void *cb_data)
 Perform an asynchronous I2C read operation on a given device register. More...
 
struct sol_i2c_pendingsol_i2c_read_register_multiple (struct sol_i2c *i2c, uint8_t reg, uint8_t *values, size_t count, uint8_t times, void(*read_reg_multiple_cb)(void *cb_data, struct sol_i2c *i2c, uint8_t reg, uint8_t *data, ssize_t status), const void *cb_data)
 Asynchronous read of an arbitrary number of bytes from a register in repeated bursts of a given length (that start always on the provided register address) More...
 
int sol_i2c_set_slave_address (struct sol_i2c *i2c, uint8_t slave_address)
 Set a (slave) device address on a I2C bus to deliver commands to. More...
 
enum sol_i2c_speed sol_i2c_speed_from_str (const char *speed)
 Converts a string I2C speed to sol_i2c_speed. More...
 
const char * sol_i2c_speed_to_str (enum sol_i2c_speed speed)
 Converts sol_i2c_speed to a string name. More...
 
struct sol_i2c_pendingsol_i2c_write (struct sol_i2c *i2c, uint8_t *data, size_t count, void(*write_cb)(void *cb_data, struct sol_i2c *i2c, uint8_t *data, ssize_t status), const void *cb_data)
 Perform successive asynchronous I2C byte write operations, with no specified register. More...
 
struct sol_i2c_pendingsol_i2c_write_quick (struct sol_i2c *i2c, bool rw, void(*write_quick_cb)(void *cb_data, struct sol_i2c *i2c, ssize_t status), const void *cb_data)
 Perform a I2C write quick operation. More...
 
struct sol_i2c_pendingsol_i2c_write_register (struct sol_i2c *i2c, uint8_t reg, const uint8_t *data, size_t count, void(*write_reg_cb)(void *cb_data, struct sol_i2c *i2c, uint8_t reg, uint8_t *data, ssize_t status), const void *cb_data)
 Perform an asynchronous I2C write operation on a given device register. More...
 
enum  sol_i2c_op_type { SOL_I2C_READ, SOL_I2C_WRITE }
 I²C operation dispatcher. More...
 
typedef struct
sol_i2c_op_set_pending 
sol_i2c_op_set_pending
 I2C Dispatcher pending operation set handle structure. More...
 
struct sol_i2c_op_set_pendingsol_i2c_dispatcher_add_op_set (struct sol_i2c *i2c, uint8_t addr, struct sol_vector *set, void(*cb)(void *cb_data, ssize_t status), void *cb_data, uint32_t delay)
 Add an operation set in the dispatcher's queue of a given I2C bus. More...
 
void sol_i2c_dispatcher_remove_op_set (struct sol_i2c *i2c, struct sol_i2c_op_set_pending *pending)
 Cancel the execution of the pending operation set. More...
 

Detailed Description

These routines are used for I2C access under Soletta.