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_arch.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_arch.c:

Go to the source code of this file.

Macros

#define I2C_BUSY   0x20
 
#define I2C_MAX_RESET_FAIL_COUNT   20
 
#define SPURIOUS_INTERRUPT(_periph, _status, _event)   { if (_status == I2CAddrWrSent) abort_and_reset(_periph);}
 
#define OUT_OF_SYNC_STATE_MACHINE(_periph, _status, _event)   { abort_and_reset(_periph);}
 

Functions

static void start_transaction (struct i2c_periph *p)
 
static void end_of_transaction (struct i2c_periph *p)
 
static void i2c_hard_reset (struct i2c_periph *p)
 
static void i2c_reset_init (struct i2c_periph *p)
 
static void i2c_delay (void)
 
static void i2c_apply_config (struct i2c_periph *p)
 
static void abort_and_reset (struct i2c_periph *p)
 
static void on_status_start_requested (struct i2c_periph *periph, struct i2c_transaction *trans, uint32_t event)
 
static void on_status_addr_wr_sent (struct i2c_periph *periph, struct i2c_transaction *trans, uint32_t event)
 
static void on_status_sending_byte (struct i2c_periph *periph, struct i2c_transaction *trans, uint32_t event)
 
static void on_status_stop_requested (struct i2c_periph *periph, struct i2c_transaction *trans, uint32_t event)
 
static void on_status_addr_rd_sent (struct i2c_periph *periph, struct i2c_transaction *trans, uint32_t event)
 
static void on_status_reading_byte (struct i2c_periph *periph, struct i2c_transaction *trans, uint32_t event)
 
static void on_status_reading_last_byte (struct i2c_periph *periph, struct i2c_transaction *trans, uint32_t event)
 
static void on_status_restart_requested (struct i2c_periph *periph, struct i2c_transaction *trans, uint32_t event)
 
void i2c_event (void)
 
static void i2c_driver_event (struct i2c_periph *p, uint32_t event)
 
static void i2c_error (struct i2c_periph *p)
 
bool_t i2c_idle (struct i2c_periph *p)
 
bool_t i2c_submit (struct i2c_periph *p, struct i2c_transaction *t)
 

Macro Definition Documentation

#define I2C_BUSY   0x20

Definition at line 14 of file i2c_arch.c.

Referenced by i2c_hard_reset().

#define I2C_MAX_RESET_FAIL_COUNT   20

Definition at line 18 of file i2c_arch.c.

Referenced by i2c_hard_reset().

#define OUT_OF_SYNC_STATE_MACHINE (   _periph,
  _status,
  _event 
)    { abort_and_reset(_periph);}

Definition at line 26 of file i2c_arch.c.

Referenced by i2c_driver_event().

#define SPURIOUS_INTERRUPT (   _periph,
  _status,
  _event 
)    { if (_status == I2CAddrWrSent) abort_and_reset(_periph);}

Function Documentation

static void abort_and_reset ( struct i2c_periph p)
inlinestatic

Definition at line 80 of file i2c_arch.c.

References end_of_transaction(), i2c_hard_reset(), I2CTransFailed, i2c_periph::reg_addr, i2c_transaction::status, i2c_periph::trans, and i2c_periph::trans_extract_idx.

Referenced by i2c_error().

+ Here is the call graph for this function:

+ Here is the caller graph for this function:

static void end_of_transaction ( struct i2c_periph p)
inlinestatic

Definition at line 67 of file i2c_arch.c.

References I2C_TRANSACTION_QUEUE_LEN, I2CIdle, start_transaction(), i2c_periph::status, i2c_periph::trans_extract_idx, and i2c_periph::trans_insert_idx.

Referenced by abort_and_reset(), and on_status_stop_requested().

+ Here is the call graph for this function:

+ Here is the caller graph for this function:

static void i2c_apply_config ( struct i2c_periph p)
inlinestatic

Definition at line 62 of file i2c_arch.c.

References i2c_periph::init_struct, and i2c_periph::reg_addr.

Referenced by i2c_hard_reset().

+ Here is the caller graph for this function:

static void i2c_delay ( void  )
inlinestatic

Definition at line 57 of file i2c_arch.c.

Referenced by i2c_hard_reset().

+ Here is the caller graph for this function:

void i2c_event ( void  )

Definition at line 290 of file i2c_arch.c.

static void i2c_hard_reset ( struct i2c_periph p)
inlinestatic

Definition at line 367 of file i2c_arch.c.

References i2c_apply_config(), I2C_BUSY, i2c_delay(), I2C_MAX_RESET_FAIL_COUNT, i2c_periph::reg_addr, i2c_periph::scl_pin, and i2c_periph::sda_pin.

Referenced by abort_and_reset(), and i2c_reset_init().

+ Here is the call graph for this function:

+ Here is the caller graph for this function:

bool_t i2c_idle ( struct i2c_periph p)

Definition at line 603 of file i2c_arch.c.

References i2c_periph::reg_addr.

static void i2c_reset_init ( struct i2c_periph p)
inlinestatic

Definition at line 438 of file i2c_arch.c.

References i2c_hard_reset(), and i2c_periph::reg_addr.

+ Here is the call graph for this function:

bool_t i2c_submit ( struct i2c_periph p,
struct i2c_transaction t 
)
static void on_status_addr_rd_sent ( struct i2c_periph periph,
struct i2c_transaction trans,
uint32_t  event 
)
inlinestatic

Definition at line 204 of file i2c_arch.c.

References I2CAddrRdSent, I2CReadingByte, I2CReadingLastByte, i2c_periph::idx_buf, i2c_transaction::len_r, i2c_periph::reg_addr, SPURIOUS_INTERRUPT, and i2c_periph::status.

Referenced by i2c_driver_event().

+ Here is the caller graph for this function:

static void on_status_addr_wr_sent ( struct i2c_periph periph,
struct i2c_transaction trans,
uint32_t  event 
)
inlinestatic
static void on_status_reading_byte ( struct i2c_periph periph,
struct i2c_transaction trans,
uint32_t  event 
)
inlinestatic

Definition at line 235 of file i2c_arch.c.

References i2c_transaction::buf, I2CReadingByte, I2CStopRequested, i2c_periph::idx_buf, i2c_transaction::len_r, i2c_periph::reg_addr, SPURIOUS_INTERRUPT, and i2c_periph::status.

Referenced by i2c_driver_event().

+ Here is the caller graph for this function:

static void on_status_reading_last_byte ( struct i2c_periph periph,
struct i2c_transaction trans,
uint32_t  event 
)
inlinestatic

Definition at line 263 of file i2c_arch.c.

References i2c_transaction::buf, I2CReadingLastByte, I2CStopRequested, i2c_periph::idx_buf, i2c_periph::reg_addr, SPURIOUS_INTERRUPT, and i2c_periph::status.

Referenced by i2c_driver_event().

+ Here is the caller graph for this function:

static void on_status_restart_requested ( struct i2c_periph periph,
struct i2c_transaction trans,
uint32_t  event 
)
inlinestatic

Definition at line 283 of file i2c_arch.c.

References I2CAddrRdSent, i2c_periph::reg_addr, i2c_transaction::slave_addr, and i2c_periph::status.

Referenced by i2c_driver_event().

+ Here is the caller graph for this function:

static void on_status_sending_byte ( struct i2c_periph periph,
struct i2c_transaction trans,
uint32_t  event 
)
inlinestatic
static void on_status_start_requested ( struct i2c_periph periph,
struct i2c_transaction trans,
uint32_t  event 
)
inlinestatic

Definition at line 102 of file i2c_arch.c.

References I2CAddrRdSent, I2CAddrWrSent, I2CTransRx, i2c_periph::reg_addr, i2c_transaction::slave_addr, i2c_periph::status, and i2c_transaction::type.

Referenced by i2c_driver_event().

+ Here is the caller graph for this function:

static void on_status_stop_requested ( struct i2c_periph periph,
struct i2c_transaction trans,
uint32_t  event 
)
inlinestatic

Definition at line 187 of file i2c_arch.c.

References i2c_transaction::buf, end_of_transaction(), I2CTransSuccess, i2c_periph::idx_buf, i2c_transaction::len_r, i2c_periph::reg_addr, and i2c_transaction::status.

Referenced by i2c_driver_event().

+ Here is the call graph for this function:

+ Here is the caller graph for this function:

static void start_transaction ( struct i2c_periph p)
static

Definition at line 634 of file i2c_arch.c.

References I2CStartRequested, i2c_periph::idx_buf, i2c_periph::reg_addr, and i2c_periph::status.

Referenced by end_of_transaction(), and i2c_submit().

+ Here is the caller graph for this function: