picofuse

i2c.h
Go to the documentation of this file.
1 
21 #pragma once
22 #include "deviceio.h"
23 #include "gpio.h"
24 #include <stdbool.h>
25 #include <stdint.h>
26 
33 #ifndef HW_I2C_BAUD_RATE
34 #define HW_I2C_BAUD_RATE 100000
35 #endif
36 
38 // LIFECYCLE
39 
55 hw_deviceio_t *hw_i2c_init_default(uint8_t addr);
56 
68 hw_deviceio_t *hw_i2c_init(uint8_t index, uint8_t addr, hw_gpio_t *sda_pin,
69  hw_gpio_t *scl_pin);
70 
83 hw_deviceio_t *hw_i2c_init_device(const char *device, uint8_t addr);
84 
87 // PROPERTIES
89 
102 uint8_t hw_i2c_count(void);
103 
106 // METHODS
108 
128 bool hw_i2c_detect(hw_deviceio_t *device, uint8_t addr);
129 
struct hw_deviceio_t hw_deviceio_t
Opaque device I/O handle.
Definition: deviceio.h:48
struct hw_gpio_t hw_gpio_t
GPIO logical pin structure.
Definition: gpio.h:50
GPIO (General Purpose Input/Output) interface.
hw_deviceio_t * hw_i2c_init_device(const char *device, uint8_t addr)
Initialize an I2C interface from a platform-specific device path.
bool hw_i2c_detect(hw_deviceio_t *device, uint8_t addr)
Probe whether any device acknowledges an address on a bus.
hw_deviceio_t * hw_i2c_init_default(uint8_t addr)
Initialize an I2C interface using the platform default adapter and pins.
hw_deviceio_t * hw_i2c_init(uint8_t index, uint8_t addr, hw_gpio_t *sda_pin, hw_gpio_t *scl_pin)
Initialize an I2C interface with a specific adapter and pins.
Abstract device I/O interface.
uint8_t hw_i2c_count(void)
Get the total number of available I2C adapters.