File syn_soft_i2c.c¶
FileList > drivers > syn_soft_i2c.c
Go to the source code of this file
#include "../util/syn_assert.h"#include "syn_gpio.h"#include "syn_soft_i2c.h"
Public Functions¶
| Type | Name |
|---|---|
| void | syn_soft_i2c_init (SYN_SoftI2C * i2c, SYN_GPIO_Pin scl, SYN_GPIO_Pin sda, uint32_t delay_loops) Initialize the soft I2C pins. |
| uint8_t | syn_soft_i2c_read (const SYN_SoftI2C * i2c, bool ack) Read a byte from the I2C bus. |
| void | syn_soft_i2c_start (const SYN_SoftI2C * i2c) Generate an I2C START condition. |
| void | syn_soft_i2c_stop (const SYN_SoftI2C * i2c) Generate an I2C STOP condition. |
| bool | syn_soft_i2c_write (const SYN_SoftI2C * i2c, uint8_t data) Write a byte to the I2C bus. |
| bool | syn_soft_i2c_write_read (SYN_SoftI2C * i2c, uint8_t dev_addr, const uint8_t * tx_data, size_t tx_len, uint8_t * rx_data, size_t rx_len) Perform a write-then-read I2C transaction. |
Public Static Functions¶
| Type | Name |
|---|---|
| void | i2c_delay (const SYN_SoftI2C * i2c) |
| void | scl_high (const SYN_SoftI2C * i2c) |
| void | scl_low (const SYN_SoftI2C * i2c) |
| void | sda_high (const SYN_SoftI2C * i2c) |
| void | sda_low (const SYN_SoftI2C * i2c) |
Public Functions Documentation¶
function syn_soft_i2c_init¶
Initialize the soft I2C pins.
void syn_soft_i2c_init (
SYN_SoftI2C * i2c,
SYN_GPIO_Pin scl,
SYN_GPIO_Pin sda,
uint32_t delay_loops
)
Parameters:
i2cPointer to I2C instance.sclSCL pin.sdaSDA pin.delay_loopsNumber of iterations for a half-clock delay.
function syn_soft_i2c_read¶
Read a byte from the I2C bus.
Parameters:
i2cPointer to I2C instance.acktrue to ACK the byte, false to NACK (end of read).
Returns:
The byte read.
function syn_soft_i2c_start¶
Generate an I2C START condition.
Parameters:
i2cPointer to I2C instance.
function syn_soft_i2c_stop¶
Generate an I2C STOP condition.
Parameters:
i2cPointer to I2C instance.
function syn_soft_i2c_write¶
Write a byte to the I2C bus.
Parameters:
i2cPointer to I2C instance.dataByte to write.
Returns:
true if the slave ACKed, false if NACKed.
function syn_soft_i2c_write_read¶
Perform a write-then-read I2C transaction.
bool syn_soft_i2c_write_read (
SYN_SoftI2C * i2c,
uint8_t dev_addr,
const uint8_t * tx_data,
size_t tx_len,
uint8_t * rx_data,
size_t rx_len
)
Sends a START, writes the device address + tx_data, then issues a repeated START, reads rx_len bytes into rx_data, and sends a STOP. This covers the common "write register address, read data" pattern.
Parameters:
i2cI2C instance.dev_addr7-bit device address (will be left-shifted internally).tx_dataData to write (e.g., register address). Can be NULL if tx_len is 0.tx_lenNumber of bytes to write.rx_dataBuffer to read into. Can be NULL if rx_len is 0.rx_lenNumber of bytes to read.
Returns:
true if all bytes were ACKed, false on NACK.
Public Static Functions Documentation¶
function i2c_delay¶
function scl_high¶
function scl_low¶
function sda_high¶
function sda_low¶
The documentation for this class was generated from the following file src/syntropic/drivers/syn_soft_i2c.c