@web-font-path: "roboto-debian.css";
Loading...
Searching...
No Matches
i2c.h File Reference
#include "pico.h"
#include "pico/time.h"
#include "hardware/structs/i2c.h"
#include "hardware/regs/dreq.h"
Include dependency graph for i2c.h:
This graph shows which files directly or indirectly include this file:

Go to the source code of this file.

Data Structures

struct  i2c_inst

Macros

#define PARAM_ASSERTIONS_ENABLED_HARDWARE_I2C   0
#define I2C_NUM(i2c)
 Returns the I2C number for a I2C instance.
#define I2C_INSTANCE(num)
 Returns the I2C instance with the given I2C number.
#define I2C_DREQ_NUM(i2c, is_tx)
 Returns the dreq_num_t used for pacing DMA transfers to or from this I2C instance. If is_tx is true, then it is for transfers to the I2C instance else for transfers from the I2C instance.
#define i2c_hw_index(i2c)

Typedefs

typedef struct i2c_inst i2c_inst_t

Functions

uint i2c_init (i2c_inst_t *i2c, uint baudrate)
 Initialise the I2C HW block.
void i2c_deinit (i2c_inst_t *i2c)
 Disable the I2C HW block.
uint i2c_set_baudrate (i2c_inst_t *i2c, uint baudrate)
 Set I2C baudrate.
void i2c_set_slave_mode (i2c_inst_t *i2c, bool slave, uint8_t addr)
 Set I2C port to slave mode.
static uint i2c_get_index (i2c_inst_t *i2c)
 Convert I2C instance to hardware instance number.
static i2c_hw_ti2c_get_hw (i2c_inst_t *i2c)
 Return pointer to structure containing i2c hardware registers.
static i2c_inst_t * i2c_get_instance (uint num)
 Convert I2C hardware instance number to I2C instance.
int i2c_write_blocking_until (i2c_inst_t *i2c, uint8_t addr, const uint8_t *src, size_t len, bool nostop, absolute_time_t until)
 Attempt to write specified number of bytes to address, blocking until the specified absolute time is reached.
int i2c_read_blocking_until (i2c_inst_t *i2c, uint8_t addr, uint8_t *dst, size_t len, bool nostop, absolute_time_t until)
 Attempt to read specified number of bytes from address, blocking until the specified absolute time is reached.
static int i2c_write_timeout_us (i2c_inst_t *i2c, uint8_t addr, const uint8_t *src, size_t len, bool nostop, uint timeout_us)
 Attempt to write specified number of bytes to address, with timeout.
int i2c_write_timeout_per_char_us (i2c_inst_t *i2c, uint8_t addr, const uint8_t *src, size_t len, bool nostop, uint timeout_per_char_us)
static int i2c_read_timeout_us (i2c_inst_t *i2c, uint8_t addr, uint8_t *dst, size_t len, bool nostop, uint timeout_us)
 Attempt to read specified number of bytes from address, with timeout.
int i2c_read_timeout_per_char_us (i2c_inst_t *i2c, uint8_t addr, uint8_t *dst, size_t len, bool nostop, uint timeout_per_char_us)
int i2c_write_blocking (i2c_inst_t *i2c, uint8_t addr, const uint8_t *src, size_t len, bool nostop)
 Attempt to write specified number of bytes to address, blocking.
int i2c_write_burst_blocking (i2c_inst_t *i2c, uint8_t addr, const uint8_t *src, size_t len)
 Attempt to write specified number of bytes to address, blocking in burst mode.
int i2c_read_blocking (i2c_inst_t *i2c, uint8_t addr, uint8_t *dst, size_t len, bool nostop)
 Attempt to read specified number of bytes from address, blocking.
int i2c_read_burst_blocking (i2c_inst_t *i2c, uint8_t addr, uint8_t *dst, size_t len)
 Attempt to read specified number of bytes from address, blocking in burst mode.
static size_t i2c_get_write_available (i2c_inst_t *i2c)
 Determine non-blocking write space available.
static size_t i2c_get_read_available (i2c_inst_t *i2c)
 Determine number of bytes received.
static void i2c_write_raw_blocking (i2c_inst_t *i2c, const uint8_t *src, size_t len)
 Write direct to TX FIFO.
static void i2c_read_raw_blocking (i2c_inst_t *i2c, uint8_t *dst, size_t len)
 Read direct from RX FIFO.
static uint8_t i2c_read_byte_raw (i2c_inst_t *i2c)
 Pop a byte from I2C Rx FIFO.
static void i2c_write_byte_raw (i2c_inst_t *i2c, uint8_t value)
 Push a byte into I2C Tx FIFO.
static uint i2c_get_dreq (i2c_inst_t *i2c, bool is_tx)
 Return the DREQ to use for pacing transfers to/from a particular I2C instance.
#define i2c0   (&i2c0_inst)
 Identifier for I2C HW Block 0.
#define i2c1   (&i2c1_inst)
 Identifier for I2C HW Block 1.
i2c_inst_t i2c0_inst
i2c_inst_t i2c1_inst

Macro Definition Documentation

◆ i2c_hw_index

#define i2c_hw_index ( i2c)
Value:
static uint i2c_get_index(i2c_inst_t *i2c)
Convert I2C instance to hardware instance number.
Definition i2c.h:204