mirror of
https://github.com/danbulant/Cosmos
synced 2026-05-27 22:12:25 +00:00
Some progress on ES1370 (ControlRegister.cs)
This commit is contained in:
parent
d3ac47c85b
commit
d7158849ef
6 changed files with 235 additions and 119 deletions
|
|
@ -1,115 +0,0 @@
|
|||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Linq;
|
||||
using System.Text;
|
||||
using Cosmos.Hardware;
|
||||
namespace Cosmos.Hardware.Audio.Devices.ES1370.Register
|
||||
{
|
||||
//TODO: According to real ES1370 (it's just a copy-and-paste of Kudzu original work)
|
||||
class ConfigurationRegister1
|
||||
{
|
||||
#region Constructor
|
||||
|
||||
private Kernel.MemoryAddressSpace xMem;
|
||||
public static ConfigurationRegister1 Load(Kernel.MemoryAddressSpace aMem)
|
||||
{
|
||||
return new ConfigurationRegister1(aMem);
|
||||
}
|
||||
|
||||
private ConfigurationRegister1(Kernel.MemoryAddressSpace aMem)
|
||||
{
|
||||
xMem = aMem;
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Get or Sets the 8 bits in the Config_1 Register.
|
||||
/// </summary>
|
||||
public byte CONFIG1
|
||||
{
|
||||
get
|
||||
{
|
||||
//return xMem.Read8((UInt32)Register.MainRegister.Bit.Config1);
|
||||
return 0;
|
||||
}
|
||||
set
|
||||
{
|
||||
//xMem.Write8((UInt32)Register.MainRegister.Bit.Config1, value);
|
||||
}
|
||||
}
|
||||
|
||||
#endregion
|
||||
|
||||
#region Register Data
|
||||
|
||||
public bool PowerEnabled
|
||||
{
|
||||
get
|
||||
{ //return GetBit(BitPosition.PMEN);
|
||||
return true;
|
||||
}
|
||||
set
|
||||
{ //SetBit(BitValue.PMEN, value); }
|
||||
}
|
||||
}
|
||||
|
||||
#endregion
|
||||
|
||||
#region Accessors
|
||||
|
||||
private bool GetBit(BitPosition bit)
|
||||
{
|
||||
//return BinaryHelper.CheckBit(this.CONFIG1, (byte)bit);
|
||||
return false;
|
||||
}
|
||||
|
||||
private void SetBit(BitValue bit, bool value)
|
||||
{
|
||||
if (value)
|
||||
this.CONFIG1 = (byte)(this.CONFIG1 | (byte)bit);
|
||||
else
|
||||
this.CONFIG1 = (byte)(this.CONFIG1 & ~(byte)bit);
|
||||
}
|
||||
|
||||
public override string ToString()
|
||||
{
|
||||
//return this.CONFIG1.ToBinary(8);
|
||||
return null;
|
||||
}
|
||||
|
||||
#endregion
|
||||
|
||||
}
|
||||
#region Bits
|
||||
|
||||
[Flags]
|
||||
public enum BitPosition : byte
|
||||
{
|
||||
/*
|
||||
PMEN = 0, //Power Management Enable
|
||||
VPD = 1, //Enable Vital Product Data
|
||||
IOMAP = 2, //I/O Mapping
|
||||
MEMMAP = 3, //Memory mapping
|
||||
LWACT = 4, //LWake Active Mode
|
||||
DVRLOAD = 5,//Driver Load
|
||||
LEDS0 = 6,
|
||||
LEDS1 = 7
|
||||
*/
|
||||
}
|
||||
|
||||
[Flags]
|
||||
public enum BitValue : uint
|
||||
{
|
||||
/*
|
||||
PMEN = BinaryHelper.BitPos.BIT0,
|
||||
VPD = BinaryHelper.BitPos.BIT1,
|
||||
IOMAP = BinaryHelper.BitPos.BIT2,
|
||||
MEMMAP = BinaryHelper.BitPos.BIT3,
|
||||
LWACT = BinaryHelper.BitPos.BIT4,
|
||||
DVRLOAD = BinaryHelper.BitPos.BIT5,
|
||||
LEDS0 = BinaryHelper.BitPos.BIT6,
|
||||
LEDS1 = BinaryHelper.BitPos.BIT7
|
||||
*/
|
||||
}
|
||||
|
||||
#endregion
|
||||
}
|
||||
|
|
@ -0,0 +1,214 @@
|
|||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Linq;
|
||||
using System.Text;
|
||||
using Cosmos.Hardware;
|
||||
namespace Cosmos.Hardware.Audio.Devices.ES1370.Register
|
||||
{
|
||||
class ControlRegister
|
||||
{
|
||||
#region Constructor
|
||||
|
||||
private Kernel.MemoryAddressSpace xMem;
|
||||
public static ControlRegister Load(Kernel.MemoryAddressSpace aMem)
|
||||
{
|
||||
return new ControlRegister(aMem);
|
||||
}
|
||||
|
||||
private ControlRegister(Kernel.MemoryAddressSpace aMem)
|
||||
{
|
||||
xMem = aMem;
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Get or Sets the 8 bits in the Control Register.
|
||||
/// </summary>
|
||||
public byte CONTROL
|
||||
{
|
||||
get
|
||||
{
|
||||
return xMem.Read8((UInt32)Register.MainRegister.Bit.Control);
|
||||
}
|
||||
set
|
||||
{
|
||||
xMem.Write8((UInt32)Register.MainRegister.Bit.Control, value);
|
||||
}
|
||||
}
|
||||
|
||||
#endregion
|
||||
|
||||
#region Register Data
|
||||
|
||||
public bool PowerEnabled
|
||||
{
|
||||
get
|
||||
{
|
||||
return GetBit(BitPosition.SERRDis);
|
||||
}
|
||||
set
|
||||
{
|
||||
SetBit(BitValue.SERRDis, !value);
|
||||
}
|
||||
}
|
||||
|
||||
public bool CodecEnabled
|
||||
{
|
||||
get
|
||||
{
|
||||
return GetBit(BitPosition.CodecEn);
|
||||
}
|
||||
set
|
||||
{
|
||||
SetBit(BitValue.CodecEn, value);
|
||||
}
|
||||
}
|
||||
|
||||
public bool DAC1Enabled
|
||||
{
|
||||
get
|
||||
{
|
||||
return GetBit(BitPosition.DAC1En);
|
||||
}
|
||||
set
|
||||
{
|
||||
SetBit(BitValue.DAC1En, value);
|
||||
}
|
||||
}
|
||||
|
||||
public bool DAC2Enabled
|
||||
{
|
||||
get
|
||||
{
|
||||
return GetBit(BitPosition.DAC2En);
|
||||
}
|
||||
set
|
||||
{
|
||||
SetBit(BitValue.DAC2En, value);
|
||||
}
|
||||
}
|
||||
|
||||
public bool UARTEnabled
|
||||
{
|
||||
get
|
||||
{
|
||||
return GetBit(BitPosition.UARTEn);
|
||||
}
|
||||
set
|
||||
{
|
||||
SetBit(BitValue.UARTEn, value);
|
||||
}
|
||||
}
|
||||
public bool MemoryBusRequestEnabled
|
||||
{
|
||||
get
|
||||
{
|
||||
return GetBit(BitPosition.BREQEn);
|
||||
}
|
||||
set
|
||||
{
|
||||
SetBit(BitValue.BREQEn, value);
|
||||
}
|
||||
}
|
||||
|
||||
public ClockSourceType ClockSourceTypeSelected
|
||||
{
|
||||
get
|
||||
{
|
||||
if(GetBit(BitPosition.MSBB))
|
||||
return ClockSourceType.MPEGClock;
|
||||
else
|
||||
return ClockSourceType.GenClock;
|
||||
}
|
||||
set
|
||||
{
|
||||
if(value.Equals(ClockSourceType.GenClock))
|
||||
SetBit(BitValue.MSBB, true);
|
||||
else
|
||||
SetBit(BitValue.MSBB, false);
|
||||
}
|
||||
}
|
||||
|
||||
public MPEGDataType MPEGDataTypeSelected
|
||||
{
|
||||
get
|
||||
{
|
||||
if (GetBit(BitPosition.MSFMTSEL))
|
||||
return MPEGDataType.I2S;
|
||||
else
|
||||
return MPEGDataType.SONY;
|
||||
}
|
||||
set
|
||||
{
|
||||
if (value.Equals(MPEGDataType.I2S))
|
||||
SetBit(BitValue.MSFMTSEL, true);
|
||||
else
|
||||
SetBit(BitValue.MSFMTSEL, false);
|
||||
}
|
||||
}
|
||||
#endregion
|
||||
|
||||
#region Accessors
|
||||
|
||||
private bool GetBit(BitPosition bit)
|
||||
{
|
||||
return BinaryHelper.CheckBit(this.CONTROL, (byte)bit);
|
||||
}
|
||||
|
||||
private void SetBit(BitValue bit, bool value)
|
||||
{
|
||||
if (value)
|
||||
this.CONTROL = (byte)(this.CONTROL | (byte)bit);
|
||||
else
|
||||
this.CONTROL = (byte)(this.CONTROL & ~(byte)bit);
|
||||
}
|
||||
|
||||
public override string ToString()
|
||||
{
|
||||
//return this.CONTROL.ToBinary(8);
|
||||
return null;
|
||||
}
|
||||
|
||||
#endregion
|
||||
|
||||
}
|
||||
#region Bits
|
||||
|
||||
[Flags]
|
||||
public enum BitPosition : byte
|
||||
{
|
||||
SERRDis=0,
|
||||
CodecEn=1,
|
||||
UARTEn=3,
|
||||
DAC2En=5,
|
||||
DAC1En=6,
|
||||
BREQEn = 7, //memory bus request enable
|
||||
MSBB = 14, //clock source for DAC: gen (0) - MPEG(1)
|
||||
MSFMTSEL=15 //MPEG data SONY(0)/I2S(1)
|
||||
}
|
||||
|
||||
[Flags]
|
||||
public enum BitValue : uint
|
||||
{
|
||||
SERRDis = BinaryHelper.BitPos.BIT0,
|
||||
CodecEn = BinaryHelper.BitPos.BIT1,
|
||||
UARTEn = BinaryHelper.BitPos.BIT3,
|
||||
DAC2En = BinaryHelper.BitPos.BIT5,
|
||||
DAC1En = BinaryHelper.BitPos.BIT6,
|
||||
BREQEn = BinaryHelper.BitPos.BIT7,
|
||||
MSBB = BinaryHelper.BitPos.BIT14,
|
||||
MSFMTSEL = BinaryHelper.BitPos.BIT15
|
||||
}
|
||||
|
||||
public enum ClockSourceType : uint
|
||||
{
|
||||
GenClock=0,
|
||||
MPEGClock=1
|
||||
}
|
||||
|
||||
public enum MPEGDataType : uint
|
||||
{
|
||||
SONY=0,
|
||||
I2S=1
|
||||
}
|
||||
#endregion
|
||||
}
|
||||
|
|
@ -47,15 +47,17 @@ namespace Cosmos.Hardware.Audio.Devices.ES1370.Register
|
|||
|
||||
private bool GetBit(BitPosition bit)
|
||||
{
|
||||
return BinaryHelper.CheckBit(this.IMR, (byte)bit);
|
||||
//return BinaryHelper.CheckBit(this.IMR, (byte)bit);
|
||||
return false;
|
||||
}
|
||||
|
||||
private void SetBit(BitValue bit, bool value)
|
||||
{
|
||||
{/*
|
||||
if (value)
|
||||
this.IMR = (byte)(this.IMR | (byte)bit);
|
||||
else
|
||||
this.IMR = (byte)(this.IMR & ~(byte)bit);
|
||||
*/
|
||||
}
|
||||
|
||||
#endregion
|
||||
|
|
|
|||
|
|
@ -65,15 +65,18 @@ namespace Cosmos.Hardware.Audio.Devices.ES1370.Register
|
|||
|
||||
private bool GetBit(BitPosition bit)
|
||||
{
|
||||
return BinaryHelper.CheckBit(this.ISR, (byte)bit);
|
||||
//return BinaryHelper.CheckBit(this.ISR, (byte)bit);
|
||||
return false;
|
||||
}
|
||||
|
||||
private void SetBit(BitValue bit, bool value)
|
||||
{
|
||||
/*
|
||||
if (value)
|
||||
this.ISR = (byte)(this.ISR | (byte)bit);
|
||||
else
|
||||
this.ISR = (byte)(this.ISR & ~(byte)bit);
|
||||
*/
|
||||
}
|
||||
|
||||
#endregion
|
||||
|
|
|
|||
|
|
@ -0,0 +1,11 @@
|
|||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Linq;
|
||||
using System.Text;
|
||||
|
||||
namespace Cosmos.Hardware.Audio.Devices.ES1370.Register
|
||||
{
|
||||
class SerialInterfaceRegister
|
||||
{
|
||||
}
|
||||
}
|
||||
|
|
@ -52,10 +52,11 @@
|
|||
<ItemGroup>
|
||||
<Compile Include="Audio\Devices\ES1370\ES1370.cs" />
|
||||
<Compile Include="Audio\Devices\ES1370\Register\CommandRegister.cs" />
|
||||
<Compile Include="Audio\Devices\ES1370\Register\ConfigurationRegister1.cs" />
|
||||
<Compile Include="Audio\Devices\ES1370\Register\ControlRegister.cs" />
|
||||
<Compile Include="Audio\Devices\ES1370\Register\InterruptMaskRegister.cs" />
|
||||
<Compile Include="Audio\Devices\ES1370\Register\InterruptStatusRegister.cs" />
|
||||
<Compile Include="Audio\Devices\ES1370\Register\MainRegister.cs" />
|
||||
<Compile Include="Audio\Devices\ES1370\Register\SerialInterfaceRegister.cs" />
|
||||
<Compile Include="BlockDevice.cs" />
|
||||
<Compile Include="USB\USBHost.cs" />
|
||||
<Compile Include="USB\USBHostOHCI.cs" />
|
||||
|
|
|
|||
Loading…
Reference in a new issue