32#ifdef LIBOPENCM3_I2C_H
34#ifndef LIBOPENCM3_I2C_COMMON_V1_H
35#define LIBOPENCM3_I2C_COMMON_V1_H
58#define I2C_CR1(i2c_base) MMIO32((i2c_base) + 0x00)
59#define I2C1_CR1 I2C_CR1(I2C1)
60#define I2C2_CR1 I2C_CR1(I2C2)
63#define I2C_CR2(i2c_base) MMIO32((i2c_base) + 0x04)
64#define I2C1_CR2 I2C_CR2(I2C1)
65#define I2C2_CR2 I2C_CR2(I2C2)
68#define I2C_OAR1(i2c_base) MMIO32((i2c_base) + 0x08)
69#define I2C1_OAR1 I2C_OAR1(I2C1)
70#define I2C2_OAR1 I2C_OAR1(I2C2)
73#define I2C_OAR2(i2c_base) MMIO32((i2c_base) + 0x0c)
74#define I2C1_OAR2 I2C_OAR2(I2C1)
75#define I2C2_OAR2 I2C_OAR2(I2C2)
78#define I2C_DR(i2c_base) MMIO32((i2c_base) + 0x10)
79#define I2C1_DR I2C_DR(I2C1)
80#define I2C2_DR I2C_DR(I2C2)
83#define I2C_SR1(i2c_base) MMIO32((i2c_base) + 0x14)
84#define I2C1_SR1 I2C_SR1(I2C1)
85#define I2C2_SR1 I2C_SR1(I2C2)
88#define I2C_SR2(i2c_base) MMIO32((i2c_base) + 0x18)
89#define I2C1_SR2 I2C_SR2(I2C1)
90#define I2C2_SR2 I2C_SR2(I2C2)
93#define I2C_CCR(i2c_base) MMIO32((i2c_base) + 0x1c)
94#define I2C1_CCR I2C_CCR(I2C1)
95#define I2C2_CCR I2C_CCR(I2C2)
98#define I2C_TRISE(i2c_base) MMIO32((i2c_base) + 0x20)
99#define I2C1_TRISE I2C_TRISE(I2C1)
100#define I2C2_TRISE I2C_TRISE(I2C2)
104#define I2C3_CR1 I2C_CR1(I2C3)
105#define I2C3_CR2 I2C_CR2(I2C3)
106#define I2C3_OAR1 I2C_OAR1(I2C3)
107#define I2C3_OAR2 I2C_OAR2(I2C3)
108#define I2C3_DR I2C_DR(I2C3)
109#define I2C3_SR1 I2C_SR1(I2C3)
110#define I2C3_SR2 I2C_SR2(I2C3)
111#define I2C3_CCR I2C_CCR(I2C3)
112#define I2C3_TRISE I2C_TRISE(I2C3)
118#define I2C_CR1_SWRST (1 << 15)
123#define I2C_CR1_ALERT (1 << 13)
126#define I2C_CR1_PEC (1 << 12)
129#define I2C_CR1_POS (1 << 11)
132#define I2C_CR1_ACK (1 << 10)
135#define I2C_CR1_STOP (1 << 9)
138#define I2C_CR1_START (1 << 8)
141#define I2C_CR1_NOSTRETCH (1 << 7)
144#define I2C_CR1_ENGC (1 << 6)
147#define I2C_CR1_ENPEC (1 << 5)
150#define I2C_CR1_ENARP (1 << 4)
153#define I2C_CR1_SMBTYPE (1 << 3)
158#define I2C_CR1_SMBUS (1 << 1)
161#define I2C_CR1_PE (1 << 0)
168#define I2C_CR2_LAST (1 << 12)
171#define I2C_CR2_DMAEN (1 << 11)
174#define I2C_CR2_ITBUFEN (1 << 10)
177#define I2C_CR2_ITEVTEN (1 << 9)
180#define I2C_CR2_ITERREN (1 << 8)
226} __attribute__ ((deprecated(
"Replace _nMHZ with n directly")));
232#define I2C_OAR1_ADDMODE (1 << 15)
233#define I2C_OAR1_ADDMODE_7BIT 0
234#define I2C_OAR1_ADDMODE_10BIT 1
249#define I2C_OAR2_ENDUAL (1 << 0)
260#define I2C_SR1_SMBALERT (1 << 15)
263#define I2C_SR1_TIMEOUT (1 << 14)
268#define I2C_SR1_PECERR (1 << 12)
271#define I2C_SR1_OVR (1 << 11)
274#define I2C_SR1_AF (1 << 10)
277#define I2C_SR1_ARLO (1 << 9)
280#define I2C_SR1_BERR (1 << 8)
283#define I2C_SR1_TxE (1 << 7)
286#define I2C_SR1_RxNE (1 << 6)
291#define I2C_SR1_STOPF (1 << 4)
294#define I2C_SR1_ADD10 (1 << 3)
297#define I2C_SR1_BTF (1 << 2)
300#define I2C_SR1_ADDR (1 << 1)
303#define I2C_SR1_SB (1 << 0)
310#define I2C_SR2_DUALF (1 << 7)
313#define I2C_SR2_SMBHOST (1 << 6)
316#define I2C_SR2_SMBDEFAULT (1 << 5)
319#define I2C_SR2_GENCALL (1 << 4)
324#define I2C_SR2_TRA (1 << 2)
327#define I2C_SR2_BUSY (1 << 1)
330#define I2C_SR2_MSL (1 << 0)
335#define I2C_CCR_FS (1 << 15)
342#define I2C_CCR_DUTY (1 << 14)
343#define I2C_CCR_DUTY_DIV2 0
344#define I2C_CCR_DUTY_16_DIV_9 1
417void i2c_transfer7(uint32_t i2c, uint8_t addr,
const uint8_t *w,
size_t wn, uint8_t *r,
size_t rn);
425#warning "i2c_common_v1.h should not be included explicitly, only via i2c.h"
void i2c_disable_interrupt(uint32_t i2c, uint32_t interrupt)
I2C Disable Interrupt.
void i2c_enable_interrupt(uint32_t i2c, uint32_t interrupt)
I2C Enable Interrupt.
void i2c_disable_ack(uint32_t i2c)
I2C Disable ACK.
void i2c_set_dma_last_transfer(uint32_t i2c)
I2C Set DMA last transfer.
void i2c_nack_current(uint32_t i2c)
I2C NACK Next Byte.
void i2c_set_fast_mode(uint32_t i2c)
I2C Set Fast Mode.
void i2c_enable_ack(uint32_t i2c)
I2C Enable ACK.
void i2c_send_start(uint32_t i2c)
I2C Send Start Condition.
void i2c_set_clock_frequency(uint32_t i2c, uint8_t freq)
I2C Set Peripheral Clock Frequency.
void i2c_peripheral_disable(uint32_t i2c)
I2C Peripheral Disable.
void i2c_set_own_7bit_slave_address_two(uint32_t i2c, uint8_t slave)
I2C Set the secondary 7 bit Slave Address for the Peripheral.
void i2c_set_dutycycle(uint32_t i2c, uint32_t dutycycle)
I2C Set clock duty cycle.
void i2c_set_own_7bit_slave_address(uint32_t i2c, uint8_t slave)
I2C Set the 7 bit Slave Address for the Peripheral.
void i2c_disable_dual_addressing_mode(uint32_t i2c)
I2C Disable dual addressing mode for the Peripheral.
void i2c_set_standard_mode(uint32_t i2c)
I2C Set Standard Mode.
void i2c_set_trise(uint32_t i2c, uint16_t trise)
I2C Set the Rise Time.
void i2c_send_stop(uint32_t i2c)
I2C Send Stop Condition.
void i2c_peripheral_enable(uint32_t i2c)
I2C Peripheral Enable.
i2c_speeds
I2C speed modes.
void i2c_nack_next(uint32_t i2c)
I2C NACK Next Byte.
void i2c_set_own_10bit_slave_address(uint32_t i2c, uint16_t slave)
I2C Set the 10 bit Slave Address for the Peripheral.
void i2c_disable_dma(uint32_t i2c)
I2C Disable DMA.
void i2c_send_data(uint32_t i2c, uint8_t data)
I2C Send Data.
void i2c_clear_dma_last_transfer(uint32_t i2c)
I2C Clear DMA last transfer.
uint8_t i2c_get_data(uint32_t i2c)
I2C Get Data.
void i2c_clear_stop(uint32_t i2c)
I2C Clear Stop Flag.
void i2c_set_ccr(uint32_t i2c, uint16_t freq)
I2C Set Bus Clock Frequency.
void i2c_send_7bit_address(uint32_t i2c, uint8_t slave, uint8_t readwrite)
I2C Send the 7-bit Slave Address.
void i2c_enable_dual_addressing_mode(uint32_t i2c)
I2C Enable dual addressing mode for the Peripheral.
void i2c_transfer7(uint32_t i2c, uint8_t addr, const uint8_t *w, size_t wn, uint8_t *r, size_t rn)
Run a write/read transaction to a given 7bit i2c address If both write & read are provided,...
void i2c_enable_dma(uint32_t i2c)
I2C Enable DMA.
void i2c_set_speed(uint32_t i2c, enum i2c_speeds speed, uint32_t clock_megahz)
Set the i2c communication speed.