pflib v2.7.0-1-gd371ab6a
Polarfire Interaction Library
pflib::I2C Class Reference

Class which encapsulates the I2C controller in the Polarfire. More...

#include <I2C.h>

Inheritance diagram for pflib::I2C:
[legend]
Collaboration diagram for pflib::I2C:
[legend]

Public Member Functions

 I2C (WishboneInterface *wb, int target=tgt_I2C)
 
void set_active_bus (int ibus)
 Pick the active bus Set the value -1 to determ.
 
int get_active_bus ()
 Get the currently active bus.
 
int get_bus_count ()
 Get the number of available busses.
 
void set_bus_speed (int speed=100)
 Set the speed for the bus in kbps.
 
int get_bus_speed ()
 Get the speed for the bus in kbps.
 
void write_byte (uint8_t i2c_dev_addr, uint8_t data)
 Write a single byte using the efficient interface, and wait for completion. More...
 
uint8_t read_byte (uint8_t i2c_dev_addr)
 Read a single byte using the efficient interface. More...
 
std::vector< uint8_t > general_write_read (uint8_t i2c_dev_addr, const std::vector< uint8_t > &wdata, int nread=0)
 Carry out a write of zero or more bytes followed a by a read of zero or more bytes. More...
 
void backplane_hack (bool enable)
 Turn on/off the horrible hack for the V1 backplane.
 
- Public Member Functions inherited from pflib::WishboneTarget
 WishboneTarget (WishboneInterface *wb, int target)
 simply store pointer to interface and target we will interact with
 
int target_type ()
 Get the Wishbone target type/flavor by number.
 
std::string target_type_str ()
 Get the Wishbone target type/flavor by name if known.
 
int firmware_version ()
 Get the subblock firmware version.
 

Private Member Functions

bool i2c_wait (bool nack_ok=false)
 utility for software-mode I2C
 

Private Attributes

int usec_per_byte_
 microseconds per byte
 

Additional Inherited Members

- Protected Member Functions inherited from pflib::WishboneTarget
void wb_write (uint32_t addr, uint32_t data)
 Write data to an address on the target stored within us. More...
 
uint32_t wb_read (uint32_t addr)
 Read data from address on the target stored within us. More...
 
void wb_rmw (uint32_t addr, uint32_t data, uint32_t mask)
 Read the word at the address and then put our data bits into that address using the provided mask. More...
 
- Protected Attributes inherited from pflib::WishboneTarget
WishboneInterfacewb_
 Handle to the interface.
 
int target_
 Target id.
 

Detailed Description

Class which encapsulates the I2C controller in the Polarfire.

Member Function Documentation

◆ general_write_read()

std::vector< uint8_t > pflib::I2C::general_write_read ( uint8_t  i2c_dev_addr,
const std::vector< uint8_t > &  wdata,
int  nread = 0 
)

Carry out a write of zero or more bytes followed a by a read of zero or more bytes.

If either write or read is zero bytes long, it is omitted. Currently implemented using software (slow), while waiting for better support in the firmware.

Exceptions
pflib::Exceptionin the case of I2C communication failure

◆ read_byte()

uint8_t pflib::I2C::read_byte ( uint8_t  i2c_dev_addr)

Read a single byte using the efficient interface.

Exceptions
pflib::Exceptionin the case of I2C communication failure

◆ write_byte()

void pflib::I2C::write_byte ( uint8_t  i2c_dev_addr,
uint8_t  data 
)

Write a single byte using the efficient interface, and wait for completion.

Exceptions
pflib::Exceptionin the case of I2C communication failure

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