Hardware/LPC/NCT677X.cs
changeset 246 59024371cd50
parent 245 f8e72b2efcc0
child 265 961c07a3bd78
     1.1 --- a/Hardware/LPC/NCT677X.cs	Sun Nov 21 17:31:25 2010 +0000
     1.2 +++ b/Hardware/LPC/NCT677X.cs	Wed Dec 08 19:23:13 2010 +0000
     1.3 @@ -62,7 +62,7 @@
     1.4        Ring0.WriteIoPort(port + DATA_REGISTER_OFFSET, bank);
     1.5        Ring0.WriteIoPort(port + ADDRESS_REGISTER_OFFSET, register);
     1.6        return Ring0.ReadIoPort(port + DATA_REGISTER_OFFSET);
     1.7 -    }
     1.8 +    } 
     1.9  
    1.10      // Consts 
    1.11      private const ushort NUVOTON_VENDOR_ID = 0x5CA3;
    1.12 @@ -147,19 +147,23 @@
    1.13        }
    1.14  
    1.15        for (int i = 0; i < TEMPERATURE_REG.Length; i++) {
    1.16 -        float value = ReadByte(TEMPERATURE_REG[i]);
    1.17 +        int value = ((sbyte)ReadByte(TEMPERATURE_REG[i])) << 1;
    1.18          if (TEMPERATURE_HALF_BIT[i] > 0) {
    1.19 -          value += 0.5f * ((ReadByte(TEMPERATURE_HALF_REG[i]) >> 
    1.20 +          value |= ((ReadByte(TEMPERATURE_HALF_REG[i]) >>
    1.21              TEMPERATURE_HALF_BIT[i]) & 0x1);
    1.22          }
    1.23  
    1.24          TemperatureSource source = (TemperatureSource)
    1.25            ReadByte(TEMPERATURE_SRC_REG[i]);
    1.26  
    1.27 +        float? temperature = 0.5f * value;
    1.28 +        if (temperature > 125 || temperature < -55)
    1.29 +          temperature = null;
    1.30 +
    1.31          switch (source) {
    1.32 -          case TemperatureSource.CPUTIN: temperatures[0] = value; break;
    1.33 -          case TemperatureSource.AUXTIN: temperatures[1] = value; break;
    1.34 -          case TemperatureSource.SYSTIN: temperatures[2] = value; break;
    1.35 +          case TemperatureSource.CPUTIN: temperatures[0] = temperature; break;
    1.36 +          case TemperatureSource.AUXTIN: temperatures[1] = temperature; break;
    1.37 +          case TemperatureSource.SYSTIN: temperatures[2] = temperature; break;
    1.38          }
    1.39        }
    1.40  
    1.41 @@ -187,33 +191,35 @@
    1.42        if (!Ring0.WaitIsaBusMutex(100))
    1.43          return r.ToString();
    1.44  
    1.45 +      ushort[] addresses = new ushort[] { 
    1.46 +        0x000, 0x010, 0x020, 0x030, 0x040, 0x050, 0x060, 0x070,
    1.47 +        0x100, 0x110, 0x120, 0x130, 0x140, 0x150, 
    1.48 +        0x200,        0x220, 0x230, 0x240, 0x250,
    1.49 +        0x300,        0x320, 0x330, 0x340, 
    1.50 +        0x400, 0x410, 0x420,        0x440, 0x450, 0x460, 
    1.51 +        0x500,                             0x550, 
    1.52 +        0x600, 0x610 ,0x620, 0x630, 0x640, 0x650, 0x660, 0x670, 
    1.53 +        0xA00, 0xA10, 0xA20, 0xA30,        0xA50, 0xA60, 0xA70, 
    1.54 +        0xB00, 0xB10, 0xB20, 0xB30,        0xB50, 0xB60, 0xB70, 
    1.55 +        0xC00, 0xC10, 0xC20, 0xC30,        0xC50, 0xC60, 0xC70,
    1.56 +        0xD00, 0xD10, 0xD20, 0xD30,        0xD50, 0xD60, 
    1.57 +        0xE00, 0xE10, 0xE20, 0xE30, 
    1.58 +        0xF00, 0xF10, 0xF20, 0xF30};
    1.59 +
    1.60        r.AppendLine("Hardware Monitor Registers");
    1.61        r.AppendLine();
    1.62        r.AppendLine("       00 01 02 03 04 05 06 07 08 09 0A 0B 0C 0D 0E 0F");
    1.63        r.AppendLine();
    1.64 -      for (int i = 0; i <= 0x7; i++) {
    1.65 -        r.Append(" ");
    1.66 -        r.Append((i << 4).ToString("X3", CultureInfo.InvariantCulture));
    1.67 -        r.Append("  ");
    1.68 -        for (int j = 0; j <= 0xF; j++) {
    1.69 +      foreach (ushort address in addresses) {
    1.70            r.Append(" ");
    1.71 -          r.Append(ReadByte((ushort)((i << 4) | j)).ToString(
    1.72 -            "X2", CultureInfo.InvariantCulture));
    1.73 -        }
    1.74 -        r.AppendLine();
    1.75 -      }
    1.76 -      for (int bank = 1; bank <= 15; bank++) {
    1.77 -        for (int i = 0x5; i < 0x6; i++) {
    1.78 -          r.Append(" ");
    1.79 -          r.Append((i << 4).ToString("X3", CultureInfo.InvariantCulture));
    1.80 +          r.Append(address.ToString("X3", CultureInfo.InvariantCulture));
    1.81            r.Append("  ");
    1.82 -          for (int j = 0; j <= 0xF; j++) {
    1.83 +          for (ushort j = 0; j <= 0xF; j++) {
    1.84              r.Append(" ");
    1.85 -            r.Append(ReadByte((ushort)((bank << 8) | (i << 4) | j)).ToString(
    1.86 +            r.Append(ReadByte((ushort)(address | j)).ToString(
    1.87                "X2", CultureInfo.InvariantCulture));
    1.88            }
    1.89            r.AppendLine();
    1.90 -        }
    1.91        }
    1.92        r.AppendLine();
    1.93