pflib v2.7.0-1-gd371ab6a
Polarfire Interaction Library
I2C.h
1#ifndef PFLIB_I2C_H_
2#define PFLIB_I2C_H_
3
4#include "pflib/WishboneTarget.h"
5#include <vector>
6
7namespace pflib {
8
13class I2C : public WishboneTarget {
14 public:
15 I2C(WishboneInterface* wb, int target = tgt_I2C)
16 : WishboneTarget(wb,target) {}
17
22 void set_active_bus(int ibus);
23
27 int get_active_bus();
28
32 int get_bus_count();
33
37 void set_bus_speed(int speed=100);
38
42 int get_bus_speed();
43
48 void write_byte(uint8_t i2c_dev_addr, uint8_t data);
49
54 uint8_t read_byte(uint8_t i2c_dev_addr);
55
60 std::vector<uint8_t> general_write_read(uint8_t i2c_dev_addr, const std::vector<uint8_t>& wdata, int nread=0);
61
62
66 void backplane_hack(bool enable);
67
68 private:
73
75 bool i2c_wait(bool nack_ok=false);
76
77};
78
79}
80
81#endif // PFLIB_I2C_H_
Class which encapsulates the I2C controller in the Polarfire.
Definition: I2C.h:13
int get_active_bus()
Get the currently active bus.
Definition: I2C.cxx:43
uint8_t read_byte(uint8_t i2c_dev_addr)
Read a single byte using the efficient interface.
Definition: I2C.cxx:128
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.
Definition: I2C.cxx:146
int get_bus_speed()
Get the speed for the bus in kbps.
Definition: I2C.cxx:60
void set_active_bus(int ibus)
Pick the active bus Set the value -1 to determ.
Definition: I2C.cxx:31
bool i2c_wait(bool nack_ok=false)
utility for software-mode I2C
Definition: I2C.cxx:105
void backplane_hack(bool enable)
Turn on/off the horrible hack for the V1 backplane.
Definition: I2C.cxx:67
int get_bus_count()
Get the number of available busses.
Definition: I2C.cxx:47
int usec_per_byte_
microseconds per byte
Definition: I2C.h:72
void write_byte(uint8_t i2c_dev_addr, uint8_t data)
Write a single byte using the efficient interface, and wait for completion.
Definition: I2C.cxx:72
void set_bus_speed(int speed=100)
Set the speed for the bus in kbps.
Definition: I2C.cxx:51
Abstract interface for wishbone transactions, used by ~all classes in pflib.
Definition: WishboneInterface.h:15
Parent class for standard wishbone targets providing some utilities.
Definition: WishboneTarget.h:29
WishboneTarget(WishboneInterface *wb, int target)
simply store pointer to interface and target we will interact with
Definition: WishboneTarget.h:34
Polarfire Interaction Library.
Definition: Backend.h:8