|
Paparazzi UAS
v5.18.0_stable
Paparazzi is a free software Unmanned Aircraft System.
|
Go to the documentation of this file.
30 #ifndef MCU_PERIPH_I2C_H
31 #define MCU_PERIPH_I2C_H
35 #include "mcu_periph/i2c_arch.h"
84 #define I2C_BUF_LEN 32
132 #ifndef I2C_TRANSACTION_QUEUE_LEN
133 #define I2C_TRANSACTION_QUEUE_LEN 8
181 #define ZEROS_ERR_COUNTER(_i2c_err) { \
182 _i2c_err.wd_reset_cnt = 0; \
183 _i2c_err.queue_full_cnt = 0; \
184 _i2c_err.ack_fail_cnt = 0; \
185 _i2c_err.miss_start_stop_cnt = 0; \
186 _i2c_err.arb_lost_cnt = 0; \
187 _i2c_err.over_under_cnt = 0; \
188 _i2c_err.pec_recep_cnt = 0; \
189 _i2c_err.timeout_tlow_cnt = 0; \
190 _i2c_err.smbus_alert_cnt = 0; \
191 _i2c_err.unexpected_event_cnt = 0; \
192 _i2c_err.last_unexpected_event = 0; \
193 _i2c_err.er_irq_cnt = 0; \
200 extern void i2c0_init(
void);
208 extern void i2c1_init(
void);
216 extern void i2c2_init(
void);
224 extern void i2c3_init(
void);
232 extern void i2c4_init(
void);
239 extern void softi2c0_init(
void);
245 extern void softi2c1_init(
void);
267 return p->submit(
p, t);
275 p->setbitrate(
p, bitrate);
I2CTransactionType
I2C transaction type.
volatile uint16_t ack_fail_cnt
volatile uint8_t buf[I2C_BUF_LEN]
Transaction buffer With I2C_BUF_LEN number of bytes.
volatile uint16_t miss_start_stop_cnt
uint16_t len_r
Number of bytes to read/receive.
volatile uint16_t arb_lost_cnt
void i2c_setbitrate_fn_t(struct i2c_periph *p, int bitrate)
@ I2CTransTx
transmit only transaction
void i2c_init(struct i2c_periph *p)
Initialize I2C peripheral.
void i2c_event(void)
i2c_event() function
volatile uint16_t queue_full_cnt
struct i2c_errors * errors
@ I2CTransFailed
transaction failed
bool i2c_blocking_transceive(struct i2c_periph *p, struct i2c_transaction *t, uint8_t s_addr, uint8_t len_w, uint16_t len_r)
Submit a write/read transaction and wait for it to complete.
uint8_t trans_extract_idx
static bool i2c_idle(struct i2c_periph *p)
Check if I2C bus is idle.
uint8_t len_w
Number of bytes to write/transmit.
volatile uint32_t er_irq_cnt
@ I2CTransSuccess
transaction successfully finished by I2C driver
bool i2c_idle_fn_t(struct i2c_periph *p)
i2c_setbitrate_fn_t * setbitrate
bool i2c_transmit(struct i2c_periph *p, struct i2c_transaction *t, uint8_t s_addr, uint8_t len)
Submit a write only transaction.
@ I2CTransRx
receive only transaction
#define I2C_BUF_LEN
I2C buffer length.
struct i2c_transaction * trans[I2C_TRANSACTION_QUEUE_LEN]
bool i2c_transceive(struct i2c_periph *p, struct i2c_transaction *t, uint8_t s_addr, uint8_t len_w, uint16_t len_r)
Submit a write/read transaction.
@ I2CTransRunning
transaction is currently ongoing
enum I2CTransactionStatus status
Transaction status.
volatile uint16_t unexpected_event_cnt
volatile uint16_t over_under_cnt
bool i2c_blocking_receive(struct i2c_periph *p, struct i2c_transaction *t, uint8_t s_addr, uint16_t len)
Submit a read only transaction and wait for it to complete.
@ I2CTransTxRx
transmit and receive transaction
I2C transaction structure.
uint8_t slave_addr
Slave address.
static void i2c_setbitrate(struct i2c_periph *p, int bitrate)
Set I2C bitrate.
I2CTransactionStatus
I2C transaction status.
#define I2C_TRANSACTION_QUEUE_LEN
I2C transaction queue length.
volatile uint16_t smbus_alert_cnt
@ I2CTransPending
transaction is pending in queue
void i2c_spin_fn_t(struct i2c_periph *p)
I2CStatus
I2C peripheral status.
bool i2c_submit_fn_t(struct i2c_periph *p, struct i2c_transaction *t)
@ I2CTransDone
transaction set to done by user level
volatile int16_t watchdog
volatile uint32_t last_unexpected_event
static bool i2c_submit(struct i2c_periph *p, struct i2c_transaction *t)
Submit a I2C transaction.
volatile uint16_t wd_reset_cnt
enum I2CTransactionType type
Transaction type.
bool i2c_blocking_transmit(struct i2c_periph *p, struct i2c_transaction *t, uint8_t s_addr, uint8_t len)
Submit a write only transaction and wait for it to complete.
volatile uint16_t timeout_tlow_cnt
volatile uint16_t pec_recep_cnt
bool i2c_receive(struct i2c_periph *p, struct i2c_transaction *t, uint8_t s_addr, uint16_t len)
Submit a read only transaction.