Classes | Macros | Typedefs | Functions | Variables
drv_i2c.c File Reference
#include <stdbool.h>
#include <stdio.h>
#include <string.h>
#include "stm32f10x_conf.h"
#include "drv_system.h"
#include "drv_gpio.h"
#include "drv_i2c.h"
Include dependency graph for drv_i2c.c:

Go to the source code of this file.

Classes

struct  i2cDevice_t
 

Macros

#define I2C_DEFAULT_TIMEOUT   30000
 
#define I2C_DEVICE   (I2CDEV_2)
 

Typedefs

typedef struct i2cDevice_t i2cDevice_t
 

Functions

void I2C1_ER_IRQHandler (void)
 
void I2C1_EV_IRQHandler (void)
 
void I2C2_ER_IRQHandler (void)
 
void I2C2_EV_IRQHandler (void)
 
static void i2c_er_handler (void)
 
static void i2c_ev_handler (void)
 
static void i2c_init_buffer (void)
 
static void i2c_job_handler (void)
 
void i2c_queue_job (i2cJobType_t type, uint8_t addr_, uint8_t reg_, uint8_t *data, uint8_t length, volatile uint8_t *status_, void(*CB)(uint8_t))
 
uint16_t i2cGetErrorCounter (void)
 
static bool i2cHandleHardwareFailure (void)
 
void i2cInit (I2CDevice index)
 
bool i2cRead (uint8_t addr_, uint8_t reg_, uint8_t len, uint8_t *buf)
 
bool i2cReadAsync (uint8_t addr_, uint8_t reg_, uint8_t len, uint8_t *buf, volatile uint8_t *status_, void(*CB)(uint8_t))
 
static void i2cUnstick (void)
 
bool i2cWrite (uint8_t addr_, uint8_t reg_, uint8_t data)
 
bool i2cWriteAsync (uint8_t addr_, uint8_t reg_, uint8_t len_, uint8_t *buf_, volatile uint8_t *status_, void(*CB)(uint8_t))
 
bool i2cWriteBuffer (uint8_t addr_, uint8_t reg_, uint8_t len_, uint8_t *data)
 

Variables

static volatile uint8_t addr
 
static volatile bool busy
 
static volatile uint8_t bytes
 
static void(* complete_CB )(uint8_t)
 
static volatile bool error = false
 
static i2cJob_t i2c_buffer [I2C_BUFFER_SIZE+10]
 
static volatile uint8_t i2c_buffer_count
 
static volatile uint8_t i2c_buffer_head
 
static bool i2c_buffer_lock = false
 
static volatile uint8_t i2c_buffer_tail
 
static volatile uint16_t i2cErrorCount = 0
 
static const i2cDevice_t i2cHardwareMap []
 
static I2C_TypeDefI2Cx = NULL
 
static I2CDevice I2Cx_index
 
static volatile uint8_t * read_p
 
static volatile uint8_t reading
 
static volatile uint8_t reg
 
static volatile uint8_t * status
 
static volatile uint8_t * write_p
 
static volatile uint8_t writing
 

Macro Definition Documentation

#define I2C_DEFAULT_TIMEOUT   30000

Definition at line 89 of file drv_i2c.c.

#define I2C_DEVICE   (I2CDEV_2)

Definition at line 22 of file drv_i2c.c.

Typedef Documentation

typedef struct i2cDevice_t i2cDevice_t

Function Documentation

void I2C1_ER_IRQHandler ( void  )

Definition at line 69 of file drv_i2c.c.

void I2C1_EV_IRQHandler ( void  )

Definition at line 74 of file drv_i2c.c.

void I2C2_ER_IRQHandler ( void  )

Definition at line 79 of file drv_i2c.c.

void I2C2_EV_IRQHandler ( void  )

Definition at line 84 of file drv_i2c.c.

static void i2c_er_handler ( void  )
static

Definition at line 262 of file drv_i2c.c.

void i2c_ev_handler ( void  )
static

Definition at line 304 of file drv_i2c.c.

void i2c_init_buffer ( void  )
static

Definition at line 620 of file drv_i2c.c.

void i2c_job_handler ( void  )
static

Definition at line 528 of file drv_i2c.c.

void i2c_queue_job ( i2cJobType_t  type,
uint8_t  addr_,
uint8_t  reg_,
uint8_t *  data,
uint8_t  length,
volatile uint8_t *  status_,
void(*)(uint8_t)  CB 
)

Definition at line 579 of file drv_i2c.c.

uint16_t i2cGetErrorCounter ( void  )

Definition at line 467 of file drv_i2c.c.

static bool i2cHandleHardwareFailure ( void  )
static

Definition at line 105 of file drv_i2c.c.

void i2cInit ( I2CDevice  index)

Definition at line 420 of file drv_i2c.c.

bool i2cRead ( uint8_t  addr_,
uint8_t  reg_,
uint8_t  len,
uint8_t *  buf 
)

Definition at line 157 of file drv_i2c.c.

bool i2cReadAsync ( uint8_t  addr_,
uint8_t  reg_,
uint8_t  len,
uint8_t *  buf,
volatile uint8_t *  status_,
void(*)(uint8_t)  CB 
)

Definition at line 196 of file drv_i2c.c.

static void i2cUnstick ( void  )
static

Definition at line 472 of file drv_i2c.c.

bool i2cWrite ( uint8_t  addr_,
uint8_t  reg_,
uint8_t  data 
)

Definition at line 152 of file drv_i2c.c.

bool i2cWriteAsync ( uint8_t  addr_,
uint8_t  reg_,
uint8_t  len_,
uint8_t *  buf_,
volatile uint8_t *  status_,
void(*)(uint8_t)  CB 
)

Definition at line 229 of file drv_i2c.c.

bool i2cWriteBuffer ( uint8_t  addr_,
uint8_t  reg_,
uint8_t  len_,
uint8_t *  data 
)

Definition at line 113 of file drv_i2c.c.

Variable Documentation

volatile uint8_t addr
static

Definition at line 95 of file drv_i2c.c.

volatile bool busy
static

Definition at line 93 of file drv_i2c.c.

volatile uint8_t bytes
static

Definition at line 97 of file drv_i2c.c.

void(* complete_CB) (uint8_t)
static

Definition at line 103 of file drv_i2c.c.

volatile bool error = false
static

Definition at line 92 of file drv_i2c.c.

i2cJob_t i2c_buffer[I2C_BUFFER_SIZE+10]
static

Definition at line 41 of file drv_i2c.c.

volatile uint8_t i2c_buffer_count
static

Definition at line 44 of file drv_i2c.c.

volatile uint8_t i2c_buffer_head
static

Definition at line 42 of file drv_i2c.c.

bool i2c_buffer_lock = false
static

Definition at line 40 of file drv_i2c.c.

volatile uint8_t i2c_buffer_tail
static

Definition at line 43 of file drv_i2c.c.

volatile uint16_t i2cErrorCount = 0
static

Definition at line 90 of file drv_i2c.c.

const i2cDevice_t i2cHardwareMap[]
static
Initial value:
= {
{ I2C1, GPIOB, Pin_6, Pin_7, I2C1_EV_IRQn, I2C1_ER_IRQn, RCC_APB1Periph_I2C1 },
{ I2C2, GPIOB, Pin_10, Pin_11, I2C2_EV_IRQn, I2C2_ER_IRQn, RCC_APB1Periph_I2C2 },
}
#define GPIOB
Definition: stm32f4xx.h:2111
Definition: drv_gpio.h:48
#define I2C2
Definition: stm32f4xx.h:2061
#define I2C1
Definition: stm32f4xx.h:2060
Definition: drv_gpio.h:49

Definition at line 58 of file drv_i2c.c.

I2C_TypeDef* I2Cx = NULL
static

Definition at line 64 of file drv_i2c.c.

I2CDevice I2Cx_index
static

Definition at line 66 of file drv_i2c.c.

volatile uint8_t* read_p
static

Definition at line 101 of file drv_i2c.c.

volatile uint8_t reading
static

Definition at line 99 of file drv_i2c.c.

volatile uint8_t reg
static

Definition at line 96 of file drv_i2c.c.

volatile uint8_t* status
static

Definition at line 102 of file drv_i2c.c.

volatile uint8_t* write_p
static

Definition at line 100 of file drv_i2c.c.

volatile uint8_t writing
static

Definition at line 98 of file drv_i2c.c.



rosflight_firmware
Author(s): Daniel Koch , James Jackson
autogenerated on Thu Apr 15 2021 05:07:50