Paparazzi UAS  v4.0.4_stable-3-gf39211a
Paparazzi is a free software Unmanned Aircraft System.
 All Data Structures Files Functions Variables Typedefs Enumerations Enumerator Macros Pages
i2c_attempt2_nolib.c File Reference
#include "mcu_periph/i2c.h"
#include <stm32/rcc.h>
#include <stm32/gpio.h>
#include <stm32/flash.h>
#include <stm32/misc.h>
+ Include dependency graph for i2c_attempt2_nolib.c:

Go to the source code of this file.

Macros

#define I2C_SR1_BIT_SB   (1<<0)
 
#define I2C_SR1_BIT_ADDR   (1<<1)
 
#define I2C_SR1_BIT_BTF   (1<<2)
 
#define I2C_SR1_BIT_RXNE   (1<<6)
 
#define I2C_SR1_BIT_TXE   (1<<7)
 
#define I2C_SR1_BIT_ERR_BUS   (1<<8)
 
#define I2C_SR1_BIT_ERR_ARLO   (1<<9)
 
#define I2C_SR1_BIT_ERR_AF   (1<<10)
 
#define I2C_SR1_BIT_ERR_OVR   (1<<11)
 
#define I2C_SR1_BITS_ERR   ((1<<8)|(1<<9)|(1<<10)|(1<<11)|(1<<12)|(1<<14)|(1<<15))
 
#define I2C_SR2_BIT_TRA   (1<<2)
 
#define I2C_SR2_BIT_BUSY   (1<<1)
 
#define I2C_SR2_BIT_MSL   (1<<0)
 
#define I2C_CR1_BIT_PE   (1<<0)
 
#define I2C_CR1_BIT_START   (1<<8)
 
#define I2C_CR1_BIT_STOP   (1<<9)
 
#define I2C_CR1_BIT_ACK   (1<<10)
 
#define I2C_CR1_BIT_POS   (1<<11)
 
#define I2C_CR1_BIT_SWRST   (1<<15)
 
#define I2C_CR2_BIT_ITERREN   (1<<8)
 
#define I2C_CR2_BIT_ITEVTEN   (1<<9)
 
#define I2C_CR2_BIT_ITBUFEN   (1<<10)
 
#define BIT_X_IS_SET_IN_REG(X, REG)   (((REG) & (X)) == (X))
 

Enumerations

enum  STMI2CSubTransactionStatus {
  STMI2C_SubTra_Busy, STMI2C_SubTra_Ready_StopRequested, STMI2C_SubTra_Ready, STMI2C_SubTra_Error,
  STMI2C_SubTra_Busy, STMI2C_SubTra_Ready_StopRequested, STMI2C_SubTra_Ready, STMI2C_SubTra_Busy,
  STMI2C_SubTra_Ready_StopRequested, STMI2C_SubTra_Ready, STMI2C_SubTra_Busy, STMI2C_SubTra_Ready_StopRequested,
  STMI2C_SubTra_Ready, STMI2C_SubTra_Error
}
 

Functions

static void PPRZ_I2C_SEND_START (struct i2c_periph *periph)
 
static enum
STMI2CSubTransactionStatus 
stmi2c_send (I2C_TypeDef *regs, struct i2c_periph *periph, struct i2c_transaction *trans)
 
static enum
STMI2CSubTransactionStatus 
stmi2c_read1 (I2C_TypeDef *regs, struct i2c_transaction *trans)
 
static enum
STMI2CSubTransactionStatus 
stmi2c_read2 (I2C_TypeDef *regs, struct i2c_transaction *trans)
 
static enum
STMI2CSubTransactionStatus 
stmi2c_readmany (I2C_TypeDef *regs, struct i2c_periph *periph, struct i2c_transaction *trans)
 
static void stmi2c_clear_pending_interrupts (I2C_TypeDef *regs)
 
static void i2c_error (struct i2c_periph *periph)
 
static void i2c_event (struct i2c_periph *periph)
 
bool_t i2c_submit (struct i2c_periph *periph, struct i2c_transaction *t)
 
bool_t i2c_idle (struct i2c_periph *periph)
 

Macro Definition Documentation

#define BIT_X_IS_SET_IN_REG (   X,
  REG 
)    (((REG) & (X)) == (X))
#define I2C_CR1_BIT_ACK   (1<<10)

Definition at line 124 of file i2c_attempt2_nolib.c.

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

#define I2C_CR1_BIT_PE   (1<<0)

Definition at line 121 of file i2c_attempt2_nolib.c.

#define I2C_CR1_BIT_POS   (1<<11)

Definition at line 125 of file i2c_attempt2_nolib.c.

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

#define I2C_CR1_BIT_START   (1<<8)

Definition at line 122 of file i2c_attempt2_nolib.c.

Referenced by i2c_event(), and PPRZ_I2C_SEND_START().

#define I2C_CR1_BIT_STOP   (1<<9)
#define I2C_CR1_BIT_SWRST   (1<<15)

Definition at line 126 of file i2c_attempt2_nolib.c.

#define I2C_CR2_BIT_ITBUFEN   (1<<10)
#define I2C_CR2_BIT_ITERREN   (1<<8)

Definition at line 130 of file i2c_attempt2_nolib.c.

Referenced by PPRZ_I2C_SEND_START().

#define I2C_CR2_BIT_ITEVTEN   (1<<9)

Definition at line 131 of file i2c_attempt2_nolib.c.

Referenced by PPRZ_I2C_SEND_START().

#define I2C_SR1_BIT_ADDR   (1<<1)
#define I2C_SR1_BIT_BTF   (1<<2)
#define I2C_SR1_BIT_ERR_AF   (1<<10)

Definition at line 108 of file i2c_attempt2_nolib.c.

#define I2C_SR1_BIT_ERR_ARLO   (1<<9)

Definition at line 107 of file i2c_attempt2_nolib.c.

#define I2C_SR1_BIT_ERR_BUS   (1<<8)

Definition at line 106 of file i2c_attempt2_nolib.c.

#define I2C_SR1_BIT_ERR_OVR   (1<<11)

Definition at line 109 of file i2c_attempt2_nolib.c.

#define I2C_SR1_BIT_RXNE   (1<<6)

Definition at line 103 of file i2c_attempt2_nolib.c.

Referenced by stmi2c_read1(), and stmi2c_readmany().

#define I2C_SR1_BIT_SB   (1<<0)
#define I2C_SR1_BIT_TXE   (1<<7)

Definition at line 104 of file i2c_attempt2_nolib.c.

Referenced by stmi2c_send().

#define I2C_SR1_BITS_ERR   ((1<<8)|(1<<9)|(1<<10)|(1<<11)|(1<<12)|(1<<14)|(1<<15))

Definition at line 111 of file i2c_attempt2_nolib.c.

Referenced by i2c_event().

#define I2C_SR2_BIT_BUSY   (1<<1)

Definition at line 116 of file i2c_attempt2_nolib.c.

#define I2C_SR2_BIT_MSL   (1<<0)

Definition at line 117 of file i2c_attempt2_nolib.c.

#define I2C_SR2_BIT_TRA   (1<<2)

Definition at line 115 of file i2c_attempt2_nolib.c.

Enumeration Type Documentation

Enumerator
STMI2C_SubTra_Busy 
STMI2C_SubTra_Ready_StopRequested 
STMI2C_SubTra_Ready 
STMI2C_SubTra_Error 
STMI2C_SubTra_Busy 
STMI2C_SubTra_Ready_StopRequested 
STMI2C_SubTra_Ready 
STMI2C_SubTra_Busy 
STMI2C_SubTra_Ready_StopRequested 
STMI2C_SubTra_Ready 
STMI2C_SubTra_Busy 
STMI2C_SubTra_Ready_StopRequested 
STMI2C_SubTra_Ready 
STMI2C_SubTra_Error 

Definition at line 236 of file i2c_attempt2_nolib.c.

Function Documentation

static void i2c_error ( struct i2c_periph periph)
inlinestatic
bool_t i2c_idle ( struct i2c_periph periph)

Definition at line 1058 of file i2c_attempt2_nolib.c.

References i2c_periph::reg_addr, and RESET.

bool_t i2c_submit ( struct i2c_periph periph,
struct i2c_transaction t 
)
static void PPRZ_I2C_SEND_START ( struct i2c_periph periph)
inlinestatic

Definition at line 144 of file i2c_attempt2_nolib.c.

References BIT_X_IS_SET_IN_REG, I2C_CR1_BIT_START, I2C_CR1_BIT_STOP, I2C_CR2_BIT_ITBUFEN, I2C_CR2_BIT_ITERREN, I2C_CR2_BIT_ITEVTEN, I2CStartRequested, i2c_periph::idx_buf, LED1_OFF(), LED1_ON(), LED2_OFF(), LED2_ON(), i2c_periph::reg_addr, and i2c_periph::status.

Referenced by i2c_event(), and i2c_submit().

+ Here is the call graph for this function:

+ Here is the caller graph for this function:

static void stmi2c_clear_pending_interrupts ( I2C_TypeDef *  regs)
inlinestatic

Definition at line 542 of file i2c_attempt2_nolib.c.

References __attribute__(), BIT_X_IS_SET_IN_REG, I2C_CR2_BIT_ITBUFEN, I2C_SR1_BIT_ADDR, I2C_SR1_BIT_BTF, and I2C_SR1_BIT_SB.

Referenced by i2c_event().

+ Here is the call graph for this function:

+ Here is the caller graph for this function:

static enum STMI2CSubTransactionStatus stmi2c_read1 ( I2C_TypeDef *  regs,
struct i2c_transaction trans 
)
inlinestatic
static enum STMI2CSubTransactionStatus stmi2c_read2 ( I2C_TypeDef *  regs,
struct i2c_transaction trans 
)
inlinestatic
static enum STMI2CSubTransactionStatus stmi2c_send ( I2C_TypeDef *  regs,
struct i2c_periph periph,
struct i2c_transaction trans 
)
inlinestatic