Paparazzi UAS  v7.0_unstable
Paparazzi is a free software Unmanned Aircraft System.
i2c_arch.c File Reference

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"
+ Include dependency graph for i2c_arch.c:

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 bool i2c_stm32_idle (struct i2c_periph *periph)
 
static bool i2c_stm32_submit (struct i2c_periph *periph, struct i2c_transaction *t)
 
static void i2c_stm32_setbitrate (struct i2c_periph *periph, int bitrate)
 
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_event (void)
 i2c_event() function More...
 

Detailed Description

Handling of I2C hardware for STM32.

Definition in file i2c_arch.c.

Macro Definition Documentation

◆ __I2C_REG_CRITICAL_ZONE_START

#define __I2C_REG_CRITICAL_ZONE_START   __disable_irq();

Definition at line 71 of file i2c_arch.c.

◆ __I2C_REG_CRITICAL_ZONE_STOP

#define __I2C_REG_CRITICAL_ZONE_STOP   __enable_irq();

Definition at line 72 of file i2c_arch.c.

◆ BIT_X_IS_SET_IN_REG

#define BIT_X_IS_SET_IN_REG (   X,
  REG 
)    (((REG) & (X)) == (X))

Definition at line 62 of file i2c_arch.c.

◆ I2C_SR1_ERR_MASK

#define I2C_SR1_ERR_MASK
Value:
(I2C_SR1_SMBALERT | \
I2C_SR1_TIMEOUT | \
I2C_SR1_PECERR | \
I2C_SR1_OVR | \
I2C_SR1_AF | \
I2C_SR1_ARLO | \
I2C_SR1_BERR)

Definition at line 52 of file i2c_arch.c.

◆ NVIC_I2C1_IRQ_PRIO

#define NVIC_I2C1_IRQ_PRIO   0

Definition at line 76 of file i2c_arch.c.

◆ NVIC_I2C2_IRQ_PRIO

#define NVIC_I2C2_IRQ_PRIO   0

Definition at line 77 of file i2c_arch.c.

◆ NVIC_I2C3_IRQ_PRIO

#define NVIC_I2C3_IRQ_PRIO   0

Definition at line 78 of file i2c_arch.c.

◆ WD_DELAY

#define WD_DELAY   20

Definition at line 1155 of file i2c_arch.c.

◆ WD_RECOVERY_TICKS

#define WD_RECOVERY_TICKS   18

Definition at line 1156 of file i2c_arch.c.

Enumeration Type Documentation

◆ STMI2CSubTransactionStatus

Enumerator
STMI2C_SubTra_Busy 
STMI2C_SubTra_Ready_StopRequested 
STMI2C_SubTra_Ready 
STMI2C_SubTra_Error 

Definition at line 211 of file i2c_arch.c.

Function Documentation

◆ __disable_irq()

static void __disable_irq ( void  )
inlinestatic

Definition at line 66 of file i2c_arch.c.

Referenced by i2c_stm32_setbitrate(), i2c_stm32_submit(), and mcu_deep_sleep().

+ Here is the caller graph for this function:

◆ __enable_irq()

static void __enable_irq ( void  )
inlinestatic

Definition at line 67 of file i2c_arch.c.

Referenced by i2c_stm32_setbitrate(), i2c_stm32_submit(), and mcu_deep_sleep().

+ Here is the caller graph for this function:

◆ i2c_error()

◆ i2c_irq()

◆ i2c_stm32_idle()

static bool i2c_stm32_idle ( struct i2c_periph periph)
static

Definition at line 1366 of file i2c_arch.c.

References BIT_X_IS_SET_IN_REG, I2CIdle, if(), i2c_periph::reg_addr, and i2c_periph::status.

+ Here is the call graph for this function:

◆ i2c_stm32_setbitrate()

static void i2c_stm32_setbitrate ( struct i2c_periph periph,
int  bitrate 
)
static

Definition at line 1071 of file i2c_arch.c.

References __disable_irq(), __enable_irq(), i2c_idle(), if(), and i2c_periph::reg_addr.

+ Here is the call graph for this function:

◆ i2c_stm32_submit()

◆ PPRZ_I2C_SEND_START()

static void PPRZ_I2C_SEND_START ( struct i2c_periph periph)
inlinestatic

Definition at line 180 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_stm32_submit().

+ Here is the caller graph for this function:

◆ PPRZ_I2C_SEND_STOP()

static void PPRZ_I2C_SEND_STOP ( uint32_t  i2c)
inlinestatic

Definition at line 172 of file i2c_arch.c.

Referenced by i2c_irq().

+ Here is the caller graph for this function:

◆ stmi2c_clear_pending_interrupts()

static void stmi2c_clear_pending_interrupts ( uint32_t  i2c)
inlinestatic

Definition at line 563 of file i2c_arch.c.

References BIT_X_IS_SET_IN_REG, and dummy.

Referenced by i2c_irq().

+ Here is the caller graph for this function:

◆ stmi2c_read1()

static enum STMI2CSubTransactionStatus stmi2c_read1 ( uint32_t  i2c,
struct i2c_periph periph,
struct i2c_transaction trans 
)
inlinestatic

Definition at line 180 of file i2c_arch.c.

Referenced by i2c_irq().

+ Here is the caller graph for this function:

◆ stmi2c_read2()

static enum STMI2CSubTransactionStatus stmi2c_read2 ( uint32_t  i2c,
struct i2c_periph periph,
struct i2c_transaction trans 
)
inlinestatic

Definition at line 180 of file i2c_arch.c.

Referenced by i2c_irq().

+ Here is the caller graph for this function:

◆ stmi2c_readmany()

static enum STMI2CSubTransactionStatus stmi2c_readmany ( uint32_t  i2c,
struct i2c_periph periph,
struct i2c_transaction trans 
)
inlinestatic

Definition at line 180 of file i2c_arch.c.

Referenced by i2c_irq().

+ Here is the caller graph for this function:

◆ stmi2c_send()

static enum STMI2CSubTransactionStatus stmi2c_send ( uint32_t  i2c,
struct i2c_periph periph,
struct i2c_transaction trans 
)
inlinestatic

Definition at line 180 of file i2c_arch.c.

Referenced by i2c_irq().

+ Here is the caller graph for this function: