using Microsoft.SPOT.Hardware;
using Microsoft.SPOT.Emulator;
using Microsoft.SPOT.Emulator.Wpf;
using Microsoft.SPOT.Emulator.Gpio;
using Microsoft.SPOT.Emulator.TouchPanel;
using Microsoft.SPOT.Emulator.BlockStorage;
namespace KioskEmulator
{ public class KioskEmulatorEngine : Emulator2
{ static class Pins
{ public const Cpu.Pin Select = (Cpu.Pin)3;
public const Cpu.Pin LED1 = (Cpu.Pin)48;
public const Cpu.Pin LED2 = (Cpu.Pin)47;
public const Cpu.Pin LED3 = (Cpu.Pin)45;
public const Cpu.Pin RFIDLED = (Cpu.Pin)40;
public const Cpu.Pin MagIrq = (Cpu.Pin)41;
public const Cpu.Pin NfcIrq = (Cpu.Pin)42;
public const Cpu.Pin Touch = TouchGpioPort.DefaultTouchPin;
}
public KioskEmulatorEngine( IEmulator Hal )
: base( Hal )
{ }
/// <summary>Registers default components and settings for this emulator</summary>
protected override void LoadDefaultComponents( )
{ base.LoadDefaultComponents( );
LED1 = RegisterPin( "LED1", Pins.LED1 );
LED2 = RegisterPin( "LED2", Pins.LED2 );
LED3 = RegisterPin( "LED3", Pins.LED3 );
RFIDLED = RegisterPin( "RFIDLED", Pins.RFIDLED );
Select = RegisterPin( "Select", Pins.Select, VirtualKey.Select );
MagIrq = RegisterPin( "MagIrq", Pins.MagIrq );
NfcIrq = RegisterPin( "NfcIrq", Pins.NfcIrq );
RegisterLcd( 320, 240, 16, Pins.Touch );
RegisterBlockStorage( );
base.TimingServices.SystemClockFrequency = 16000000;
base.RamManager.Size = 8 * 1024 * 1024;
base.GpioPorts.MaxPorts = 129;
}
private void RegisterBlockStorage( )
{ EmulatorBlockStorageDevice bs = new EmulatorBlockStorageDevice( );
bs.ComponentId = "EWRFlash";
bs.PersistanceFilename = "EWR.Dat";
bs.MaxSectorWriteTime = 500;
bs.MaxBlockEraseTime = 2000;
// 1 region with 6 blocks for EWR storage only
bs.Regions = new Region[ 1 ];
bs.Regions[ 0 ] = new Region( 1, 64 * 1024, new Block[ 6 ] );
bs.Regions[ 0 ].Blocks[ 0 ] = new Block( BlockStatus.Usage_Storage_A );
bs.Regions[ 0 ].Blocks[ 1 ] = new Block( BlockStatus.Usage_Storage_A );
bs.Regions[ 0 ].Blocks[ 2 ] = new Block( BlockStatus.Usage_Storage_A );
bs.Regions[ 0 ].Blocks[ 3 ] = new Block( BlockStatus.Usage_Storage_B );
bs.Regions[ 0 ].Blocks[ 4 ] = new Block( BlockStatus.Usage_Storage_B );
bs.Regions[ 0 ].Blocks[ 5 ] = new Block( BlockStatus.Usage_Storage_B );
RegisterComponent( bs );
}
#region GPIO Pin Accessors
public GpioPort Select { get; protected set; } public GpioPort LED1 { get; protected set; } public GpioPort LED2 { get; protected set; } public GpioPort LED3 { get; protected set; } public GpioPort RFIDLED { get; protected set; } public GpioPort MagIrq { get; protected set; } public GpioPort NfcIrq { get; protected set; } #endregion
}
}