42 #include "debug/Checkpoint.hh"
56 :
BasicPioDevice(p, 0xfff), scl(1), sda(1), state(IDLE), currBit(7),
57 i2cAddr(0x00), message(0x00)
61 for (
auto d : p->devices) {
107 d.second->i2cStart();
164 panic(
"Invalid state on posedge of clock in I2CBus::write.\n");
175 uint8_t msg = pkt->
get<uint8_t>();
180 scl = (msg & 1) ? 1 :
scl;
181 sda = (msg & 2) ? 1 :
sda;
184 scl = (msg & 1) ? 0 :
scl;
185 sda = (msg & 2) ? 0 :
sda;
195 uint8_t msg = pkt->
get<uint8_t>();
203 uint8_t msg = pkt->
get<uint8_t>();
211 uint8_t msg = pkt->
get<uint8_t>();
218 DPRINTF(Checkpoint,
"Serializing I2C bus.\n");
230 DPRINTF(Checkpoint,
"Unserializing I2C bus.\n");
240 I2CBusParams::create()
void set(T v, ByteOrder endian)
Set the value in the data pointer to v using the specified endianness.
std::map< uint8_t, I2CDevice * > devices
All the slave i2c devices that are connected to this bus.
enum I2CState state
State used by I2CBus::write to determine what stage of an i2c transmission it is currently in...
uint8_t i2cAddr
Key used to access a device in the slave devices map.
bool isClockSet(PacketPtr pkt) const
Clock set check.
static const int SB_CONTROLS
Read [and Set] serial control bits: Bit [0] is SCL Bit [1] is SDA.
T get(ByteOrder endian) const
Get the data in the packet byte swapped from the specified endianness.
uint8_t message
8-bit buffer used to send and receive messages bit by bit.
#define UNSERIALIZE_SCALAR(scalar)
All i2c devices should derive from this class.
void makeAtomicResponse()
uint64_t Tick
Tick count type.
I2CBus(const I2CBusParams *p)
4KB - see e.g.
void updateSignals(PacketPtr pkt)
Update data (sda) and clock (scl) to match any transitions specified by pkt.
Tick read(PacketPtr pkt) override
Reads will always be to SB_CONTROLS.
Tick write(PacketPtr pkt) override
The default i2c bus driver used by the realview pbx board writes to this device one bit at a time...
void unserialize(CheckpointIn &cp) override
Unserialize an object.
uint64_t Addr
Address type This will probably be moved somewhere else in the near future.
A Packet is used to encapsulate a transfer between two objects in the memory system (e...
int currBit
Order of the bit of the current message that is being sent or received (0 - 7).
bool isEnd(PacketPtr pkt) const
i2c end signal check
#define SERIALIZE_SCALAR(scalar)
#define UNSERIALIZE_ENUM(scalar)
std::ostream CheckpointOut
static const int SB_CONTROLC
Clear control bits.
void serialize(CheckpointOut &cp) const override
Serialize an object.
Tick pioDelay
Delay that the device experinces on an access.
uint8_t scl
I2C clock wire (0, 1).
bool isStart(PacketPtr pkt) const
i2c start signal check
Addr pioAddr
Address that the device listens to.
uint8_t sda
I2C data wire (0, 1)
Implementiation of an i2c bus.
#define SERIALIZE_ENUM(scalar)