xous-core/emulation/peripherals/LM3509.cs
Sean Cross 63dc07d633 emulation: get more of the EC working
Signed-off-by: Sean Cross <sean@xobs.io>
2021-09-27 19:42:04 +08:00

53 lines
1.2 KiB
C#

//
// Copyright (c) 2010-2021 Antmicro
//
// This file is licensed under the MIT License.
// Full license text is available in 'licenses/MIT.txt'.
//
using Antmicro.Renode.Logging;
using Antmicro.Renode.Utilities;
using Antmicro.Renode.Peripherals.I2C;
namespace Antmicro.Renode.Peripherals.Mocks
{
public class LM3509 : II2CPeripheral
{
public LM3509()
{
Reset();
}
public void Write(byte[] data)
{
this.Log(LogLevel.Debug, "Written {0} bytes of data: {1}", data.Length, Misc.PrettyPrintCollectionHex(data));
buffer = data;
}
public byte[] Read(int count = 1)
{
this.Log(LogLevel.Debug, "Reading {0} bytes", count);
var result = new byte[count];
for(var i = 0; i < result.Length; i++)
{
result[i] = (i < buffer.Length)
? buffer[i]
: (byte)0;
}
return result;
}
public void FinishTransmission()
{
this.Log(LogLevel.Debug, "Finishing transmission");
}
public void Reset()
{
buffer = new byte[0];
}
private byte[] buffer;
}
}