APM:Libraries
Public Types | Public Member Functions | Private Member Functions | Private Attributes | List of all members
Soft_I2C Class Reference

#include <tim_i2c.h>

Collaboration diagram for Soft_I2C:
[legend]

Public Types

enum  STATE {
  START, A_0L, A_0H, A_1L,
  A_1H, A_2L, A_2H, A_3L,
  A_3H, A_4L, A_4H, A_5L,
  A_5H, A_6L, A_6H, A_7L,
  A_7H, A_AL, A_AH, W_0L,
  W_0H, W_1L, W_1H, W_2L,
  W_2H, W_3L, W_3H, W_4L,
  W_4H, W_5L, W_5H, W_6L,
  W_6H, W_7L, W_7H, W_AL,
  W_AH, STOP, STOP2, RESTART,
  RESTART2, DUMMY, R_0L, R_0H,
  R_1L, R_1H, R_2L, R_2H,
  R_3L, R_3H, R_4L, R_4H,
  R_5L, R_5H, R_6L, R_6H,
  R_7L, R_7H, R_AL, R_AH
}
 
typedef enum Soft_I2C::STATE State
 

Public Member Functions

 Soft_I2C ()
 
void init ()
 
void init_hw (const gpio_dev *scl_dev, uint8_t scl_bit, const gpio_dev *sda_dev, uint8_t sda_bit, const timer_dev *tim)
 
uint8_t writeBuffer (uint8_t addr_, uint8_t len_, const uint8_t *data)
 
uint8_t read (uint8_t addr_, uint8_t reg, uint8_t len, uint8_t *buf)
 
uint8_t transfer (uint8_t addr, uint8_t send_len, const uint8_t *send, uint8_t len, uint8_t *buf)
 
bool bus_reset (void)
 
void set_low_speed (bool s)
 

Private Member Functions

void tick ()
 
bool _start (void)
 
uint8_t wait_done ()
 

Private Attributes

const gpio_dev_scl_dev
 
uint8_t _scl_bit
 
const gpio_dev_sda_dev
 
uint8_t _sda_bit
 
const timer_dev_timer
 
volatile GPIO_TypeDef * scl_port
 
uint16_t scl_pin
 
volatile GPIO_TypeDef * sda_port
 
uint16_t sda_pin
 
volatile bool done
 
volatile uint8_t result
 
volatile State state
 
bool f_sda
 
bool wait_scl
 
bool was_restart
 
uint8_t data
 
const uint8_t * send
 
uint8_t send_len
 
uint8_t * recv
 
uint8_t recv_len
 
uint8_t _addr
 
uint16_t bit_time
 

Detailed Description

Definition at line 15 of file tim_i2c.h.

Member Typedef Documentation

◆ State

Member Enumeration Documentation

◆ STATE

Enumerator
START 
A_0L 
A_0H 
A_1L 
A_1H 
A_2L 
A_2H 
A_3L 
A_3H 
A_4L 
A_4H 
A_5L 
A_5H 
A_6L 
A_6H 
A_7L 
A_7H 
A_AL 
A_AH 
W_0L 
W_0H 
W_1L 
W_1H 
W_2L 
W_2H 
W_3L 
W_3H 
W_4L 
W_4H 
W_5L 
W_5H 
W_6L 
W_6H 
W_7L 
W_7H 
W_AL 
W_AH 
STOP 
STOP2 
RESTART 
RESTART2 
DUMMY 
R_0L 
R_0H 
R_1L 
R_1H 
R_2L 
R_2H 
R_3L 
R_3H 
R_4L 
R_4H 
R_5L 
R_5H 
R_6L 
R_6H 
R_7L 
R_7H 
R_AL 
R_AH 

Definition at line 18 of file tim_i2c.h.

Constructor & Destructor Documentation

◆ Soft_I2C()

Soft_I2C::Soft_I2C ( )

Definition at line 106 of file tim_i2c.cpp.

Member Function Documentation

◆ _start()

bool Soft_I2C::_start ( void  )
private

Definition at line 417 of file tim_i2c.cpp.

Referenced by read(), set_low_speed(), transfer(), and writeBuffer().

Here is the call graph for this function:
Here is the caller graph for this function:

◆ bus_reset()

bool Soft_I2C::bus_reset ( void  )

Definition at line 567 of file tim_i2c.cpp.

Referenced by F4Light::I2CDevice::transfer().

Here is the call graph for this function:
Here is the caller graph for this function:

◆ init()

void Soft_I2C::init ( void  )

Definition at line 143 of file tim_i2c.cpp.

Referenced by F4Light::I2CDevice::init().

Here is the caller graph for this function:

◆ init_hw()

void Soft_I2C::init_hw ( const gpio_dev scl_dev,
uint8_t  scl_bit,
const gpio_dev sda_dev,
uint8_t  sda_bit,
const timer_dev tim 
)

Definition at line 114 of file tim_i2c.cpp.

Referenced by F4Light::I2CDevice::init().

Here is the call graph for this function:
Here is the caller graph for this function:

◆ read()

uint8_t Soft_I2C::read ( uint8_t  addr_,
uint8_t  reg,
uint8_t  len,
uint8_t *  buf 
)

Definition at line 532 of file tim_i2c.cpp.

Referenced by F4Light::I2CDevice::transfer().

Here is the call graph for this function:
Here is the caller graph for this function:

◆ set_low_speed()

void Soft_I2C::set_low_speed ( bool  s)
inline

Definition at line 107 of file tim_i2c.h.

Referenced by F4Light::I2CDevice::init().

Here is the call graph for this function:
Here is the caller graph for this function:

◆ tick()

void Soft_I2C::tick ( void  )
private

Definition at line 148 of file tim_i2c.cpp.

Referenced by _start(), and set_low_speed().

Here is the call graph for this function:
Here is the caller graph for this function:

◆ transfer()

uint8_t Soft_I2C::transfer ( uint8_t  addr,
uint8_t  send_len,
const uint8_t *  send,
uint8_t  len,
uint8_t *  buf 
)

Definition at line 549 of file tim_i2c.cpp.

Referenced by F4Light::I2CDevice::transfer().

Here is the call graph for this function:
Here is the caller graph for this function:

◆ wait_done()

uint8_t Soft_I2C::wait_done ( )
private

Definition at line 471 of file tim_i2c.cpp.

Referenced by read(), set_low_speed(), transfer(), and writeBuffer().

Here is the call graph for this function:
Here is the caller graph for this function:

◆ writeBuffer()

uint8_t Soft_I2C::writeBuffer ( uint8_t  addr_,
uint8_t  len_,
const uint8_t *  data 
)

Definition at line 516 of file tim_i2c.cpp.

Referenced by F4Light::I2CDevice::transfer().

Here is the call graph for this function:
Here is the caller graph for this function:

Member Data Documentation

◆ _addr

uint8_t Soft_I2C::_addr
private

Definition at line 140 of file tim_i2c.h.

Referenced by _start(), read(), tick(), transfer(), and writeBuffer().

◆ _scl_bit

uint8_t Soft_I2C::_scl_bit
private

Definition at line 117 of file tim_i2c.h.

Referenced by init_hw().

◆ _scl_dev

const gpio_dev* Soft_I2C::_scl_dev
private

Definition at line 116 of file tim_i2c.h.

Referenced by init_hw().

◆ _sda_bit

uint8_t Soft_I2C::_sda_bit
private

Definition at line 119 of file tim_i2c.h.

Referenced by init_hw().

◆ _sda_dev

const gpio_dev* Soft_I2C::_sda_dev
private

Definition at line 118 of file tim_i2c.h.

Referenced by init_hw().

◆ _timer

const timer_dev* Soft_I2C::_timer
private

Definition at line 120 of file tim_i2c.h.

Referenced by _start(), init_hw(), tick(), and wait_done().

◆ bit_time

uint16_t Soft_I2C::bit_time
private

Definition at line 142 of file tim_i2c.h.

Referenced by _start().

◆ data

uint8_t Soft_I2C::data
private

Definition at line 134 of file tim_i2c.h.

Referenced by _start(), and tick().

◆ done

volatile bool Soft_I2C::done
private

Definition at line 127 of file tim_i2c.h.

Referenced by _start(), tick(), and wait_done().

◆ f_sda

bool Soft_I2C::f_sda
private

Definition at line 130 of file tim_i2c.h.

Referenced by _start(), and tick().

◆ recv

uint8_t* Soft_I2C::recv
private

Definition at line 138 of file tim_i2c.h.

Referenced by read(), tick(), and transfer().

◆ recv_len

uint8_t Soft_I2C::recv_len
private

Definition at line 139 of file tim_i2c.h.

Referenced by read(), tick(), transfer(), wait_done(), and writeBuffer().

◆ result

volatile uint8_t Soft_I2C::result
private

Definition at line 128 of file tim_i2c.h.

Referenced by _start(), tick(), and wait_done().

◆ scl_pin

uint16_t Soft_I2C::scl_pin
private

Definition at line 123 of file tim_i2c.h.

Referenced by init_hw().

◆ scl_port

volatile GPIO_TypeDef* Soft_I2C::scl_port
private

Definition at line 122 of file tim_i2c.h.

Referenced by init_hw().

◆ sda_pin

uint16_t Soft_I2C::sda_pin
private

Definition at line 125 of file tim_i2c.h.

Referenced by init_hw().

◆ sda_port

volatile GPIO_TypeDef* Soft_I2C::sda_port
private

Definition at line 124 of file tim_i2c.h.

Referenced by init_hw().

◆ send

const uint8_t* Soft_I2C::send
private

Definition at line 136 of file tim_i2c.h.

Referenced by read(), tick(), transfer(), and writeBuffer().

◆ send_len

uint8_t Soft_I2C::send_len
private

Definition at line 137 of file tim_i2c.h.

Referenced by read(), tick(), transfer(), wait_done(), and writeBuffer().

◆ state

volatile State Soft_I2C::state
private

Definition at line 129 of file tim_i2c.h.

Referenced by _start(), tick(), and wait_done().

◆ wait_scl

bool Soft_I2C::wait_scl
private

Definition at line 131 of file tim_i2c.h.

Referenced by _start(), and tick().

◆ was_restart

bool Soft_I2C::was_restart
private

Definition at line 132 of file tim_i2c.h.

Referenced by _start(), and tick().


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