[Stub] support.
Inter-Integrated Circuit (I2C) peripheral support.
DefinesEnums
- I2C_MSG_READ
- I2C_MSG_10BIT_ADDR
- I2C1_BASE
- I2C2_BASE
- I2C_CR1_SWRST
- I2C_CR1_ALERT
- I2C_CR1_PEC
- I2C_CR1_POS
- I2C_CR1_ACK
- I2C_CR1_START
- I2C_CR1_STOP
- I2C_CR1_PE
- I2C_CR2_LAST
- I2C_CR2_DMAEN
- I2C_CR2_ITBUFEN
- I2C_CR2_ITEVTEN
- I2C_CR2_ITERREN
- I2C_CR2_FREQ
- I2C_CCR_FS
- I2C_CCR_DUTY
- I2C_CCR_CCR
- I2C_SR1_SB
- I2C_SR1_ADDR
- I2C_SR1_BTF
- I2C_SR1_ADD10
- I2C_SR1_STOPF
- I2C_SR1_RXNE
- I2C_SR1_TXE
- I2C_SR1_BERR
- I2C_SR1_ARLO
- I2C_SR1_AF
- I2C_SR1_OVR
- I2C_SR1_PECERR
- I2C_SR1_TIMEOUT
- I2C_SR1_SMBALERT
- I2C_SR2_MSL
- I2C_SR2_BUSY
- I2C_SR2_TRA
- I2C_SR2_GENCALL
- I2C_SR2_SMBDEFAULT
- I2C_SR2_SMBHOST
- I2C_SR2_DUALF
- I2C_SR2_PEC
- I2C_FAST_MODE
- I2C_DUTY_16_9
- I2C_REMAP
- I2C_BUS_RESET
- I2C_ERROR_PROTOCOL
- I2C_ERROR_TIMEOUT
- I2C_IRQ_ERROR
Enable one or more i2c interrupts.
Parameters:
- dev -
i2c device
- irqs -
bitwise-or of: I2C_IRQ_ERROR: Error interrupt I2C_IRQ_EVENT: Event interrupt I2C_IRQ_BUFFER: Buffer interrupt
- I2C_IRQ_EVENT
- I2C_IRQ_BUFFER
Functions
- i2c_state enum
Values:
- I2C_STATE_DISABLED = 0 -
- I2C_STATE_IDLE = 1 -
- I2C_STATE_XFER_DONE = 2 -
- I2C_STATE_BUSY = 3 -
- I2C_STATE_ERROR = -1 -
Variables
- void i2c_master_enable(i2c_dev * dev, uint32 flags)
Initialize an i2c device as bus master.
Parameters:
- dev -
Device to enable
- flags -
Bitwise or of the following I2C options: I2C_FAST_MODE: 400 khz operation I2C_DUTY_16_9: 16/9 Tlow/Thigh duty cycle (only applicable for fast mode) I2C_BUS_RESET: Reset the bus and clock out any hung slaves on initialization I2C_10BIT_ADDRESSING: Enable 10-bit addressing I2C_REMAP: Remap I2C1 to SCL/PB8 SDA/PB9
- int32 i2c_master_xfer(i2c_dev * dev, i2c_msg * msgs, uint16 num, uint32 timeout)
Process an i2c transaction.
Transactions are composed of one or more i2c_msg’s and may be read or write tranfers. Multiple i2c_msg’s will generate a repeated start inbetween messages.
Parameters:
- dev -
i2c device
- msgs -
messages to send/receive
- num -
number of messages to send/receive
- timeout -
bus idle timeout in milliseconds before aborting the transfer. 0 denotes no timeout.
Return: 0 on success I2C_ERROR_PROTOCOL if there was a protocol error. I2C_ERROR_TIMEOUT if the transfer timed out.
- void i2c_bus_reset(const i2c_dev * dev)
Reset an i2c bus by clocking out pulses until any hung slaves release SDA and SCL, then generate a START condition, then a STOP condition.
Parameters:
- dev -
i2c device
- void i2c_disable(i2c_dev * dev)
- void i2c_peripheral_enable(i2c_dev * dev)
turn on an i2c peripheral
Parameters:
- dev -
i2c device
- void i2c_peripheral_disable(i2c_dev * dev)
turn off an i2c peripheral
Parameters:
- dev -
i2c device
- void i2c_write(i2c_dev * dev, uint8 byte)
Fill transmit register.
Parameters:
- dev -
i2c device
- byte -
byte to write
- void i2c_set_input_clk(i2c_dev * dev, uint32 freq)
Set input clock frequency, in mhz.
Parameters:
- dev -
i2c
- freq -
frequency in megahertz (2-36)
- void i2c_set_clk_control(i2c_dev * dev, uint32 val)
Set i2c clock control register.
See RM008
Parameters:
- dev -
i2c device
Return: Par: - void i2c_set_trise(i2c_dev * dev, uint32 trise)
Set SCL rise time.
Parameters:
- dev -
device to configure
- trise -
Maximum rise time in fast/standard mode (See RM008 for formula)
- void i2c_start_condition(i2c_dev * dev)
Generate a start condition on the bus.
Parameters:
- device -
i2c device to use
- void i2c_stop_condition(i2c_dev * dev)
Generate a stop condition on the bus.
Parameters:
- device -
i2c device to use
- void i2c_enable_irq(i2c_dev * dev, uint32 irqs)
- void i2c_disable_irq(i2c_dev * dev, uint32 irqs)
Disable one or more i2c interrupts.
Parameters:
- dev -
i2c device
- irqs -
bitwise-or of: I2C_IRQ_ERROR: Error interrupt I2C_IRQ_EVENT: Event interrupt I2C_IRQ_BUFFER: Buffer interrupt
- void i2c_enable_ack(i2c_dev * dev)
Enable i2c acknowledgment.
Parameters:
- dev -
i2c device
- void i2c_disable_ack(i2c_dev * dev)
Disable i2c acknowledgment.
Parameters:
- dev -
i2c device
class i2c_reg_map
Public Members
- __io uint32 CR1
- __io uint32 CR2
- __io uint32 OAR1
- __io uint32 OAR2
- __io uint32 DR
- __io uint32 SR1
- __io uint32 SR2
- __io uint32 CCR
- __io uint32 TRISE
class i2c_msg
Public Members
- uint16 addr
- uint16 flags
- uint16 length
- uint16 xferred
- uint8 * data
class i2c_dev
Public Members
- i2c_reg_map * regs
- gpio_dev * gpio_port
- uint8 sda_pin
- uint8 scl_pin
- uint8 clk_line
- uint8 ev_nvic_line
- uint8 er_nvic_line
- uint8 state
- uint16 msgs_left
- i2c_msg * msg
- uint32 timestamp
- uint32 error_flags