Paparazzi UAS  v5.10_stable-5-g83a0da5-dirty
Paparazzi is a free software Unmanned Aircraft System.
 All Data Structures Namespaces Files Functions Variables Typedefs Enumerations Enumerator Macros Modules Pages
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 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...
 

Detailed Description

Handling of I2C hardware for STM32.

Definition in file i2c_arch.c.

Macro Definition Documentation

#define __I2C_REG_CRITICAL_ZONE_START   __disable_irq();

Definition at line 70 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 71 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))
#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 51 of file i2c_arch.c.

Referenced by i2c_irq().

#define NVIC_I2C1_IRQ_PRIO   0

Definition at line 75 of file i2c_arch.c.

#define NVIC_I2C2_IRQ_PRIO   0

Definition at line 76 of file i2c_arch.c.

#define NVIC_I2C3_IRQ_PRIO   0

Definition at line 77 of file i2c_arch.c.

#define WD_DELAY   20

Definition at line 1244 of file i2c_arch.c.

Referenced by i2c_submit().

#define WD_RECOVERY_TICKS   18

Definition at line 1245 of file i2c_arch.c.

Enumeration Type Documentation

Enumerator
STMI2C_SubTra_Busy 
STMI2C_SubTra_Ready_StopRequested 
STMI2C_SubTra_Ready 
STMI2C_SubTra_Error 

Definition at line 217 of file i2c_arch.c.

Function Documentation

static void __disable_irq ( void  )
inlinestatic

Definition at line 65 of file i2c_arch.c.

Referenced by i2c_setbitrate(), and i2c_submit().

+ Here is the caller graph for this function:

static void __enable_irq ( void  )
inlinestatic

Definition at line 66 of file i2c_arch.c.

Referenced by i2c_setbitrate(), and i2c_submit().

+ Here is the caller graph for this function:

static void i2c_error ( struct i2c_periph periph)
inlinestatic
static void PPRZ_I2C_SEND_START ( struct i2c_periph periph)
inlinestatic

Definition at line 173 of file i2c_arch.c.

References I2CStartRequested, i2c_periph::idx_buf, LED1_OFF(), LED1_ON(), LED2_OFF(), LED2_ON(), LED_SHOW_ACTIVE_BITS(), i2c_periph::reg_addr, i2c_periph::status, and i2c_periph::watchdog.

Referenced by i2c_irq(), and i2c_submit().

+ Here is the call graph for this function:

+ Here is the caller graph for this function:

static void PPRZ_I2C_SEND_STOP ( uint32_t  i2c)
inlinestatic

Definition at line 158 of file i2c_arch.c.

References LED1_OFF(), LED1_ON(), LED2_OFF(), and LED2_ON().

Referenced by i2c_irq(), stmi2c_read1(), stmi2c_read2(), and stmi2c_readmany().

+ Here is the call graph for this function:

+ Here is the caller graph for this function:

static void stmi2c_clear_pending_interrupts ( uint32_t  i2c)
inlinestatic

Definition at line 597 of file i2c_arch.c.

References BIT_X_IS_SET_IN_REG.

Referenced by i2c_irq().

+ Here is the caller graph for this function:

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