xevi/simulation/src/simwire.cpp
Mikael Degerfält 266b3334cb Simple simulation code
Builds a native program on MacOS that runs the NuEVI firmware compiled for x86_64.
Only input is arrow keys for menu buttons for now. Only output is console and display.

Copied some more library files into the simulation folder, and renamed the modified *.cpp files from the libraries to *_sim.cpp.
2019-06-13 20:51:45 +02:00

94 lines
1.5 KiB
C++

#include <stdio.h>
#include "Wire.h"
/********************************
*
*/
SimWire::SimWire( bool verbose )
: verbose_( verbose )
{
}
void SimWire::setClock(uint32_t)
{
// Ignore.. lol
}
void SimWire::begin()
{
}
void SimWire::beginTransmission(uint8_t address)
{
if( verbose_ )
printf("[SimWire::beginTransmission] $%02x\n", address);
}
void SimWire::beginTransmission(int address)
{
beginTransmission((uint8_t)address);
}
uint8_t SimWire::endTransmission()
{
if( verbose_ )
printf("[SimWire::endTransmission]\n");
return 0;
}
uint8_t SimWire::endTransmission(uint8_t what)
{
if( verbose_ )
printf("[SimWire::endTransmission %d]\n", what);
return 0;
}
uint8_t SimWire::requestFrom(uint8_t address, uint8_t count)
{
if( verbose_ )
printf("[SimWire::requestFrom] $%02x for %d bytes\n", address, count);
// TODO: We must check if there is an actual slave for that address.
return 0;
}
int SimWire::read()
{
// TODO: Verify that bus is in read mode.
// if( current_slave_ != NULL ) {
// return current_slave_->i2cReadData( );
// } else {
printf("No slave selected, returning ones\n");
return 0xffu;
// }
}
int SimWire::available()
{
// TODO: This needs to be implemented!!
return 0;
}
size_t SimWire::write(uint8_t __attribute__((unused)) data)
{
// // TODO: Verify that bus is in write mode.
// if( current_slave_ != NULL ) {
// current_slave_->i2cWriteData( data );
// } else {
printf("No slave selected i2c writes to the void.\n");
// }
return 1;
}