PIO I2C program interface. More...
PIO I2C program interface.
Files | |
| file | i2c.h | 
| PIO I2C program interface.  | |
Data Structures | |
| struct | pio_program_i2c | 
| PIO I2C program type.  More... | |
| struct | pio_i2c_bus | 
| PIO I2C emulated bus type.  More... | |
Typedefs | |
| typedef i2c_t | pio_i2c_t | 
| PIO I2C descriptor type compatible with i2c_t.  | |
| typedef struct pio_program_i2c | pio_program_i2c_t | 
| PIO I2C program type.  | |
| typedef struct pio_i2c_bus | pio_i2c_bus_t | 
| PIO I2C emulated bus type.  | |
Functions | |
| pio_i2c_bus_t * | pio_i2c_get (pio_i2c_t id) | 
| Get access to a PIO I2C instance configured with PIO_I2C_CONFIG.  More... | |
| unsigned | pio_i2c_numof (void) | 
| Query the number of PIO I2C instances configured with PIO_I2C_CONFIG.  More... | |
| const pio_program_i2c_t * | pio_i2c_get_program (pio_t pio) | 
| Get const I2C program reference.  More... | |
| int | pio_i2c_init_program (pio_t pio) | 
| Create, allocate, and write a PIO I2C program.  More... | |
| void | pio_i2c_deinit_program (pio_t pio) | 
| Free a PIO I2C program.  More... | |
| pio_sm_t | pio_i2c_sm_lock (pio_t pio, pio_i2c_bus_t *i2c) | 
Acquire a PIO state machine of PIO pio to run the PIO I2C program.  More... | |
| void | pio_i2c_sm_unlock (pio_i2c_bus_t *i2c) | 
Release a PIO state machine of PIO pio.  More... | |
| void | pio_i2c_start_programs (void) | 
| Start PIO I2C programs configured with PIO_I2C_CONFIG.  More... | |
| void | pio_i2c_stop_programs (void) | 
| Stop PIO I2C programs configured with PIO_I2C_CONFIG.  | |
| int | pio_i2c_write_program (pio_t pio, pio_program_i2c_t *pro) | 
| Write a PIO I2C program to instruction memory.  More... | |
| int | pio_i2c_init (pio_i2c_bus_t *bus, const pio_program_i2c_t *pro, gpio_t sda, gpio_t scl, unsigned irq) | 
| Setup a state machine to run the I2C program.  More... | |
| void | pio_i2c_acquire (pio_i2c_bus_t *bus) | 
| Get exclusive access to the emulated I2C bus.  More... | |
| void | pio_i2c_release (pio_i2c_bus_t *bus) | 
| Release emulated I2C bus.  More... | |
| int | pio_i2c_read_regs (pio_t pio, pio_sm_t sm, uint16_t addr, uint16_t reg, void *data, size_t len, uint8_t flags) | 
| Emulate i2c_read_regs.  More... | |
| static int | pio_i2c_read_reg (pio_t pio, pio_sm_t sm, uint16_t addr, uint16_t reg, void *data, uint8_t flags) | 
| Emulate i2c_read_reg.  More... | |
| int | pio_i2c_read_bytes (pio_t pio, pio_sm_t sm, uint16_t addr, void *data, size_t len, uint8_t flags) | 
| Emulate i2c_read_bytes.  More... | |
| static int | pio_i2c_read_byte (pio_t pio, pio_sm_t sm, uint16_t addr, void *data, uint8_t flags) | 
| Emulate i2c_read_byte.  More... | |
| int | pio_i2c_write_bytes (pio_t pio, pio_sm_t sm, uint16_t addr, const void *data, size_t len, uint8_t flags) | 
| Emulate i2c_write_bytes.  More... | |
| static int | pio_i2c_write_byte (pio_t pio, pio_sm_t sm, uint16_t addr, uint8_t data, uint8_t flags) | 
| Emulate i2c_write_byte.  More... | |
| int | pio_i2c_write_regs (pio_t pio, pio_sm_t sm, uint16_t addr, uint16_t reg, const void *data, size_t len, uint8_t flags) | 
| Emulate i2c_write_regs.  More... | |
| static int | pio_i2c_write_reg (pio_t pio, pio_sm_t sm, uint16_t addr, uint16_t reg, uint8_t data, uint8_t flags) | 
| Emulate i2c_write_reg.  More... | |
| void pio_i2c_acquire | ( | pio_i2c_bus_t * | bus | ) | 
Get exclusive access to the emulated I2C bus.
| [in] | bus | PIO I2C bus | 
| void pio_i2c_deinit_program | ( | pio_t | pio | ) | 
Free a PIO I2C program.
| [in] | pio | PIO index | 
| pio_i2c_bus_t* pio_i2c_get | ( | pio_i2c_t | id | ) | 
Get access to a PIO I2C instance configured with PIO_I2C_CONFIG.
| [in] | id | PIO I2C ID | 
| const pio_program_i2c_t* pio_i2c_get_program | ( | pio_t | pio | ) | 
Get const I2C program reference.
| [in] | pio | PIO index | 
pio | int pio_i2c_init | ( | pio_i2c_bus_t * | bus, | 
| const pio_program_i2c_t * | pro, | ||
| gpio_t | sda, | ||
| gpio_t | scl, | ||
| unsigned | irq | ||
| ) | 
Setup a state machine to run the I2C program.
pro must have been allocated.| [out] | bus | PIO I2C bus | 
| [in] | pro | Shared program base | 
| [in] | sda | SDA pin | 
| [in] | scl | SCL pin | 
| [in] | irq | IRQ line, 0 or 1 | 
| int pio_i2c_init_program | ( | pio_t | pio | ) | 
Create, allocate, and write a PIO I2C program.
This function does nothing if the program is already created, allocated, and written.
| [in] | pio | PIO index | 
| unsigned pio_i2c_numof | ( | void | ) | 
Query the number of PIO I2C instances configured with PIO_I2C_CONFIG.
      
  | 
  inlinestatic | 
Emulate i2c_read_byte.
| [in] | pio | PIO index | 
| [in] | sm | PIO state machine index | 
| [in] | addr | 7-bit or 10-bit device address (right-aligned) | 
| [out] | data | Memory location to store received data | 
| [in] | flags | Optional flags (see i2c_flags_t) | 
| int pio_i2c_read_bytes | ( | pio_t | pio, | 
| pio_sm_t | sm, | ||
| uint16_t | addr, | ||
| void * | data, | ||
| size_t | len, | ||
| uint8_t | flags | ||
| ) | 
Emulate i2c_read_bytes.
| [in] | pio | PIO index | 
| [in] | sm | PIO state machine index | 
| [in] | addr | 7-bit or 10-bit device address (right-aligned) | 
| [out] | data | Memory location to store received data | 
| [in] | len | The number of bytes to read into data  | 
| [in] | flags | Optional flags (see i2c_flags_t) | 
      
  | 
  inlinestatic | 
Emulate i2c_read_reg.
| [in] | pio | PIO index | 
| [in] | sm | PIO state machine index | 
| [in] | addr | 7-bit or 10-bit device address (right-aligned) | 
| [in] | reg | Register address to read from (8- or 16-bit right-aligned) | 
| [out] | data | Memory location to store received data | 
| [in] | flags | Optional flags (see i2c_flags_t) | 
| int pio_i2c_read_regs | ( | pio_t | pio, | 
| pio_sm_t | sm, | ||
| uint16_t | addr, | ||
| uint16_t | reg, | ||
| void * | data, | ||
| size_t | len, | ||
| uint8_t | flags | ||
| ) | 
Emulate i2c_read_regs.
| [in] | pio | PIO index | 
| [in] | sm | PIO state machine index | 
| [in] | addr | 7-bit or 10-bit device address (right-aligned) | 
| [in] | reg | Register address to read from (8- or 16-bit right-aligned) | 
| [out] | data | Memory location to store received data | 
| [in] | len | The number of bytes to read into data  | 
| [in] | flags | Optional flags (see i2c_flags_t) | 
| void pio_i2c_release | ( | pio_i2c_bus_t * | bus | ) | 
Release emulated I2C bus.
| [in] | bus | PIO I2C bus | 
| pio_sm_t pio_i2c_sm_lock | ( | pio_t | pio, | 
| pio_i2c_bus_t * | i2c | ||
| ) | 
Acquire a PIO state machine of PIO pio to run the PIO I2C program. 
| [in] | pio | PIO index | 
| [out] | i2c | PIO I2C bus | 
| void pio_i2c_sm_unlock | ( | pio_i2c_bus_t * | i2c | ) | 
Release a PIO state machine of PIO pio. 
| [in,out] | i2c | PIO I2C bus | 
| void pio_i2c_start_programs | ( | void | ) | 
Start PIO I2C programs configured with PIO_I2C_CONFIG.
      
  | 
  inlinestatic | 
Emulate i2c_write_byte.
| [in] | pio | PIO index | 
| [in] | sm | PIO state machine index | 
| [in] | addr | 7-bit or 10-bit device address (right-aligned) | 
| [in] | data | Byte to write to the device | 
| [in] | flags | Optional flags (see i2c_flags_t) | 
| int pio_i2c_write_bytes | ( | pio_t | pio, | 
| pio_sm_t | sm, | ||
| uint16_t | addr, | ||
| const void * | data, | ||
| size_t | len, | ||
| uint8_t | flags | ||
| ) | 
Emulate i2c_write_bytes.
| [in] | pio | PIO index | 
| [in] | sm | PIO state machine index | 
| [in] | addr | 7-bit or 10-bit device address (right-aligned) | 
| [in] | data | Array holding the bytes to write to the device | 
| [in] | len | The number of bytes to write | 
| [in] | flags | Optional flags (see i2c_flags_t) | 
| int pio_i2c_write_program | ( | pio_t | pio, | 
| pio_program_i2c_t * | pro | ||
| ) | 
Write a PIO I2C program to instruction memory.
| [in] | pio | PIO index | 
| [in,out] | pro | Allocated PIO I2C program | 
      
  | 
  inlinestatic | 
Emulate i2c_write_reg.
| [in] | pio | PIO index | 
| [in] | sm | PIO state machine index | 
| [in] | addr | 7-bit or 10-bit device address (right-aligned) | 
| [in] | reg | register address to read from (8- or 16-bit, right-aligned) | 
| [in] | data | Array holding the bytes to write to the device | 
| [in] | flags | Optional flags (see i2c_flags_t) | 
| int pio_i2c_write_regs | ( | pio_t | pio, | 
| pio_sm_t | sm, | ||
| uint16_t | addr, | ||
| uint16_t | reg, | ||
| const void * | data, | ||
| size_t | len, | ||
| uint8_t | flags | ||
| ) | 
Emulate i2c_write_regs.
| [in] | pio | PIO index | 
| [in] | sm | PIO state machine index | 
| [in] | addr | 7-bit or 10-bit device address (right-aligned) | 
| [in] | reg | register address to read from (8- or 16-bit, right-aligned) | 
| [in] | data | Array holding the bytes to write to the device | 
| [in] | len | The number of bytes to write | 
| [in] | flags | Optional flags (see i2c_flags_t) |