Paparazzi UAS
v5.14.0_stable-0-g3f680d1
Paparazzi is a free software Unmanned Aircraft System.
|
Handling of I2C hardware for STM32. More...
#include "mcu_periph/i2c.h"
#include <BOARD_CONFIG>
#include <libopencm3/stm32/rcc.h>
#include <libopencm3/stm32/gpio.h>
#include <libopencm3/cm3/nvic.h>
#include <libopencm3/cm3/scb.h>
#include "mcu_periph/gpio.h"
#include "mcu_periph/sys_time.h"
Go to the source code of this file.
Macros | |
#define | I2C_SR1_ERR_MASK |
#define | BIT_X_IS_SET_IN_REG(X, REG) (((REG) & (X)) == (X)) |
#define | __I2C_REG_CRITICAL_ZONE_START __disable_irq(); |
#define | __I2C_REG_CRITICAL_ZONE_STOP __enable_irq(); |
#define | NVIC_I2C1_IRQ_PRIO 0 |
#define | NVIC_I2C2_IRQ_PRIO 0 |
#define | NVIC_I2C3_IRQ_PRIO 0 |
#define | WD_DELAY 20 |
#define | WD_RECOVERY_TICKS 18 |
Enumerations | |
enum | STMI2CSubTransactionStatus { STMI2C_SubTra_Busy, STMI2C_SubTra_Ready_StopRequested, STMI2C_SubTra_Ready, STMI2C_SubTra_Error } |
Functions | |
static void | __disable_irq (void) |
static void | __enable_irq (void) |
static void | PPRZ_I2C_SEND_STOP (uint32_t i2c) |
static void | PPRZ_I2C_SEND_START (struct i2c_periph *periph) |
static enum STMI2CSubTransactionStatus | stmi2c_send (uint32_t i2c, struct i2c_periph *periph, struct i2c_transaction *trans) |
static enum STMI2CSubTransactionStatus | stmi2c_read1 (uint32_t i2c, struct i2c_periph *periph, struct i2c_transaction *trans) |
static enum STMI2CSubTransactionStatus | stmi2c_read2 (uint32_t i2c, struct i2c_periph *periph, struct i2c_transaction *trans) |
static enum STMI2CSubTransactionStatus | stmi2c_readmany (uint32_t i2c, struct i2c_periph *periph, struct i2c_transaction *trans) |
static void | i2c_error (struct i2c_periph *periph) |
static void | stmi2c_clear_pending_interrupts (uint32_t i2c) |
static void | i2c_irq (struct i2c_periph *periph) |
void | i2c_setbitrate (struct i2c_periph *periph, int bitrate) |
Set I2C bitrate. More... | |
void | i2c_event (void) |
i2c_event() function More... | |
bool | i2c_submit (struct i2c_periph *periph, struct i2c_transaction *t) |
Submit a I2C transaction. More... | |
bool | i2c_idle (struct i2c_periph *periph) |
Check if I2C bus is idle. More... | |
Handling of I2C hardware for STM32.
Definition in file i2c_arch.c.
#define __I2C_REG_CRITICAL_ZONE_START __disable_irq(); |
Definition at line 66 of file i2c_arch.c.
Referenced by stmi2c_read1(), stmi2c_read2(), and stmi2c_readmany().
#define __I2C_REG_CRITICAL_ZONE_STOP __enable_irq(); |
Definition at line 67 of file i2c_arch.c.
Referenced by stmi2c_read1(), stmi2c_read2(), and stmi2c_readmany().
#define BIT_X_IS_SET_IN_REG | ( | X, | |
REG | |||
) | (((REG) & (X)) == (X)) |
Definition at line 57 of file i2c_arch.c.
Referenced by i2c_idle(), stmi2c_clear_pending_interrupts(), stmi2c_read1(), stmi2c_read2(), stmi2c_readmany(), and stmi2c_send().
#define I2C_SR1_ERR_MASK |
Definition at line 47 of file i2c_arch.c.
Referenced by i2c_irq().
#define NVIC_I2C1_IRQ_PRIO 0 |
Definition at line 71 of file i2c_arch.c.
#define NVIC_I2C2_IRQ_PRIO 0 |
Definition at line 72 of file i2c_arch.c.
#define NVIC_I2C3_IRQ_PRIO 0 |
Definition at line 73 of file i2c_arch.c.
#define WD_DELAY 20 |
Definition at line 1141 of file i2c_arch.c.
Referenced by i2c_submit().
#define WD_RECOVERY_TICKS 18 |
Definition at line 1142 of file i2c_arch.c.
Enumerator | |
---|---|
STMI2C_SubTra_Busy | |
STMI2C_SubTra_Ready_StopRequested | |
STMI2C_SubTra_Ready | |
STMI2C_SubTra_Error |
Definition at line 206 of file i2c_arch.c.
|
inlinestatic |
Definition at line 61 of file i2c_arch.c.
Referenced by i2c_setbitrate(), i2c_submit(), and mcu_deep_sleep().
|
inlinestatic |
Definition at line 62 of file i2c_arch.c.
Referenced by i2c_setbitrate(), i2c_submit(), and mcu_deep_sleep().
|
inlinestatic |
Definition at line 522 of file i2c_arch.c.
References i2c_errors::ack_fail_cnt, i2c_errors::arb_lost_cnt, i2c_errors::er_irq_cnt, i2c_periph::errors, i2c_errors::miss_start_stop_cnt, i2c_errors::over_under_cnt, i2c_errors::pec_recep_cnt, i2c_periph::reg_addr, i2c_errors::smbus_alert_cnt, and i2c_errors::timeout_tlow_cnt.
Referenced by i2c_irq().
|
inlinestatic |
Definition at line 595 of file i2c_arch.c.
References i2c_periph::errors, i2c_error(), I2C_SR1_ERR_MASK, I2C_TRANSACTION_QUEUE_LEN, I2CFailed, I2CIdle, I2CStartRequested, I2CTransFailed, I2CTransRx, I2CTransTxRx, i2c_errors::last_unexpected_event, i2c_transaction::len_r, PPRZ_I2C_SEND_START(), PPRZ_I2C_SEND_STOP(), i2c_periph::reg_addr, i2c_transaction::status, i2c_periph::status, stmi2c_clear_pending_interrupts(), stmi2c_read1(), stmi2c_read2(), stmi2c_readmany(), stmi2c_send(), STMI2C_SubTra_Busy, STMI2C_SubTra_Error, STMI2C_SubTra_Ready, i2c_periph::trans, i2c_periph::trans_extract_idx, i2c_periph::trans_insert_idx, i2c_transaction::type, i2c_errors::unexpected_event_cnt, and i2c_periph::watchdog.
|
inlinestatic |
Definition at line 175 of file i2c_arch.c.
References I2CStartRequested, i2c_periph::idx_buf, i2c_periph::reg_addr, i2c_periph::status, and i2c_periph::watchdog.
Referenced by i2c_irq(), and i2c_submit().
|
inlinestatic |
Definition at line 167 of file i2c_arch.c.
Referenced by i2c_irq(), stmi2c_read1(), stmi2c_read2(), and stmi2c_readmany().
|
inlinestatic |
Definition at line 558 of file i2c_arch.c.
References BIT_X_IS_SET_IN_REG.
Referenced by i2c_irq().
|
inlinestatic |
Definition at line 287 of file i2c_arch.c.
References __I2C_REG_CRITICAL_ZONE_START, __I2C_REG_CRITICAL_ZONE_STOP, BIT_X_IS_SET_IN_REG, i2c_transaction::buf, I2CAddrRdSent, I2CReadingLastByte, I2CStopRequested, I2CTransSuccess, PPRZ_I2C_SEND_STOP(), i2c_transaction::slave_addr, i2c_transaction::status, i2c_periph::status, STMI2C_SubTra_Busy, STMI2C_SubTra_Error, and STMI2C_SubTra_Ready_StopRequested.
Referenced by i2c_irq().
|
inlinestatic |
Definition at line 346 of file i2c_arch.c.
References __I2C_REG_CRITICAL_ZONE_START, __I2C_REG_CRITICAL_ZONE_STOP, BIT_X_IS_SET_IN_REG, i2c_transaction::buf, I2CAddrRdSent, I2CReadingByte, I2CStopRequested, I2CTransSuccess, PPRZ_I2C_SEND_STOP(), i2c_transaction::slave_addr, i2c_transaction::status, i2c_periph::status, STMI2C_SubTra_Busy, STMI2C_SubTra_Error, and STMI2C_SubTra_Ready_StopRequested.
Referenced by i2c_irq().
|
inlinestatic |
Definition at line 412 of file i2c_arch.c.
References __I2C_REG_CRITICAL_ZONE_START, __I2C_REG_CRITICAL_ZONE_STOP, BIT_X_IS_SET_IN_REG, i2c_transaction::buf, I2CAddrRdSent, I2CReadingByte, I2CStopRequested, I2CTransSuccess, i2c_periph::idx_buf, i2c_transaction::len_r, PPRZ_I2C_SEND_STOP(), i2c_transaction::slave_addr, i2c_transaction::status, i2c_periph::status, STMI2C_SubTra_Busy, STMI2C_SubTra_Error, and STMI2C_SubTra_Ready_StopRequested.
Referenced by i2c_irq().
|
inlinestatic |
Definition at line 215 of file i2c_arch.c.
References BIT_X_IS_SET_IN_REG, i2c_transaction::buf, I2CAddrWrSent, I2CSendingByte, I2CTransSuccess, I2CTransTx, i2c_periph::idx_buf, i2c_transaction::len_w, i2c_transaction::slave_addr, i2c_transaction::status, i2c_periph::status, STMI2C_SubTra_Busy, STMI2C_SubTra_Error, STMI2C_SubTra_Ready, and i2c_transaction::type.
Referenced by i2c_irq().