Classes | Public Types | Public Member Functions | Public Attributes | Private Types | Private Member Functions | Private Attributes | List of all members
I2C Class Reference

#include <i2c.h>

Classes

class  Debug_History
 

Public Types

enum  : int8_t { RESULT_ERROR = 0, RESULT_SUCCESS = 1, RESULT_BUSY = -1 }
 

Public Member Functions

bool check_busy ()
 
void handle_error ()
 
void handle_event ()
 
void hardware_failure ()
 
void init (const i2c_hardware_struct_t *c)
 
uint16_t num_errors ()
 
int8_t read (uint8_t addr, uint8_t reg, uint8_t num_bytes, uint8_t *data, void(*callback)(uint8_t)=nullptr, bool blocking=false)
 
int8_t read (uint8_t addr, uint8_t reg, uint8_t *data)
 
void transfer_complete_cb ()
 
void unstick ()
 
int8_t write (uint8_t addr, uint8_t reg, uint8_t data, void(*callback)(uint8_t), bool blocking=false)
 
int8_t write (uint8_t addr, uint8_t reg, uint8_t data)
 

Public Attributes

void(* cb_ )(uint8_t)
 
Debug_History event_history_
 
Debug_History interrupt_history_
 
uint64_t last_event_us_
 

Private Types

enum  {
  SB = 0x0001, ADDR = 0x0002, BTF = 0x0004, ADD10 = 0x0008,
  STOPF = 0x0010, RES1 = 0x0020, RXNE = 0x0040, TXE = 0x0080,
  BERR = 0x0100, ARLO = 0x0200, AF = 0x0400, OVR = 0x0800,
  PEC_ERR = 0x1000, RES2 = 0x2000, TIMEOUT = 0x4000, SMB_ALERT = 0x8000,
  MSL = 0x1 << 16, BUSY = 0x2 << 16, TRA = 0x4 << 16, RES3 = 0x8 << 16,
  GEN_CALL = 0x10 << 16, SMBDE_FAULT = 0x20 << 16, DUALF = 0x40 << 16
}
 
enum  current_status_t { IDLE, READING, WRITING }
 

Private Member Functions

void handle_hardware_failure ()
 

Private Attributes

volatile uint8_t addr_
 
const i2c_hardware_struct_tc_
 
volatile current_status_t current_status_
 
volatile uint8_t data_
 
DMA_InitTypeDef DMA_InitStructure_
 
bool done_ = false
 
uint16_t error_count_ = 0
 
volatile uint8_t len_
 
volatile uint8_t reg_
 
volatile uint8_t return_code_
 
GPIO scl_
 
GPIO sda_
 
bool subaddress_sent_ = false
 

Detailed Description

Definition at line 40 of file i2c.h.

Member Enumeration Documentation

anonymous enum
private
Enumerator
SB 
ADDR 
BTF 
ADD10 
STOPF 
RES1 
RXNE 
TXE 
BERR 
ARLO 
AF 
OVR 
PEC_ERR 
RES2 
TIMEOUT 
SMB_ALERT 
MSL 
BUSY 
TRA 
RES3 
GEN_CALL 
SMBDE_FAULT 
DUALF 

Definition at line 45 of file i2c.h.

anonymous enum : int8_t
Enumerator
RESULT_ERROR 
RESULT_SUCCESS 
RESULT_BUSY 

Definition at line 105 of file i2c.h.

enum I2C::current_status_t
private
Enumerator
IDLE 
READING 
WRITING 

Definition at line 76 of file i2c.h.

Member Function Documentation

bool I2C::check_busy ( )

Definition at line 511 of file i2c.cpp.

void I2C::handle_error ( )

Definition at line 395 of file i2c.cpp.

void I2C::handle_event ( )

Definition at line 413 of file i2c.cpp.

void I2C::handle_hardware_failure ( )
private

Definition at line 385 of file i2c.cpp.

void I2C::hardware_failure ( )
void I2C::init ( const i2c_hardware_struct_t c)

Definition at line 53 of file i2c.cpp.

uint16_t I2C::num_errors ( )
inline

Definition at line 146 of file i2c.h.

int8_t I2C::read ( uint8_t  addr,
uint8_t  reg,
uint8_t  num_bytes,
uint8_t *  data,
void(*)(uint8_t)  callback = nullptr,
bool  blocking = false 
)

Definition at line 179 of file i2c.cpp.

int8_t I2C::read ( uint8_t  addr,
uint8_t  reg,
uint8_t *  data 
)

Definition at line 237 of file i2c.cpp.

void I2C::transfer_complete_cb ( )

Definition at line 227 of file i2c.cpp.

void I2C::unstick ( )

Definition at line 125 of file i2c.cpp.

int8_t I2C::write ( uint8_t  addr,
uint8_t  reg,
uint8_t  data,
void(*)(uint8_t)  callback,
bool  blocking = false 
)

Definition at line 298 of file i2c.cpp.

int8_t I2C::write ( uint8_t  addr,
uint8_t  reg,
uint8_t  data 
)

Definition at line 334 of file i2c.cpp.

Member Data Documentation

volatile uint8_t I2C::addr_
private

Definition at line 94 of file i2c.h.

const i2c_hardware_struct_t* I2C::c_
private

Definition at line 101 of file i2c.h.

void(* I2C::cb_) (uint8_t)

Definition at line 133 of file i2c.h.

volatile current_status_t I2C::current_status_
private

Definition at line 89 of file i2c.h.

volatile uint8_t I2C::data_
private

Definition at line 97 of file i2c.h.

DMA_InitTypeDef I2C::DMA_InitStructure_
private

Definition at line 99 of file i2c.h.

bool I2C::done_ = false
private

Definition at line 92 of file i2c.h.

uint16_t I2C::error_count_ = 0
private

Definition at line 86 of file i2c.h.

Debug_History I2C::event_history_

Definition at line 128 of file i2c.h.

Debug_History I2C::interrupt_history_

Definition at line 129 of file i2c.h.

uint64_t I2C::last_event_us_

Definition at line 131 of file i2c.h.

volatile uint8_t I2C::len_
private

Definition at line 96 of file i2c.h.

volatile uint8_t I2C::reg_
private

Definition at line 95 of file i2c.h.

volatile uint8_t I2C::return_code_
private

Definition at line 90 of file i2c.h.

GPIO I2C::scl_
private

Definition at line 83 of file i2c.h.

GPIO I2C::sda_
private

Definition at line 84 of file i2c.h.

bool I2C::subaddress_sent_ = false
private

Definition at line 91 of file i2c.h.


The documentation for this class was generated from the following files:


rosflight_firmware
Author(s): Daniel Koch , James Jackson
autogenerated on Wed Jul 3 2019 19:59:31