isa sensors detect.old

来自「pipe类 pipe类 pipe类 pipe类 pipe类」· OLD 代码 · 共 65 行

OLD
65
字号

function IsKnownChip(ChipID: Word): byte;
var i: integer;
begin
  result := 0;
  if ChipID in [0, $FF] then exit;
  for i := 0 to KnownSensorsCount - 1 do
    if ISA_Sensors[i].ID = ChipID then
    begin
      result := i;
      exit;
    end;
end;

procedure AddISAChip(isaSensorNum: byte; isaBasePort: word);
begin
  inc(fChipCount);
  SetLength(faChips, fChipCount);
  with faChips[fChipCount - 1], ISA_Sensors[isaSensorNum] do
  begin
    Chip.SensorNum := isaSensorNum;
    Chip.isaBasePort := isaBasePort;
    Chip.ChipProp.Presets:=ChipProp.Presets;
    Chip.ChipProp.VoltagesCount:=ChipProp.VoltagesCount;
    Chip.ChipProp.TemperaturesCount:=ChipProp.TemperaturesCount;
    Chip.ChipProp.RPMsCount:=ChipProp.RPMsCount;
    Chip.ChipProp.PWMsCount:=ChipProp.PWMsCount;
    //Chip.BusAccessStr := 'ISA @' + DWordToHexStr(isaBasePort, false) + 'h';
    if (id = $101) then Chip.NameStr:=format('Unknown Winbond chip[ID=%xh]', [GetWinbondChipID(isaBasePort)])
    else Chip.NameStr:=Name;
    Chip.BusAccessStr := 'ISA ' +  format('%xh',[isaBasePort]);
    GetTemperatureMethod := TM;
    GetVoltageMethod := VM;
    SetVoltageMethod := SM;
    GetFanMethod := FM;
  end;
end;

procedure DetectISASensors;
var i, j: integer; TmpChipID: Word;
begin
  for i := 0 to High(ISABasePorts) do
  begin
    TmpChipID := GetISAChipID(ISABasePorts[i]);
    j := IsKnownChip(TmpChipID);
    if j <> 0 then
      AddISAChip(j, ISABasePorts[i]);
  end;
end;

function tMonitoring.GetISAChipID(BasePort: word): Word;
var i: integer;
begin
  result := 0;
  if not WaitForBusReady(bISA) then exit;
  try
    for i := 0 to High(aISAChipDetectMethods) do
    begin
      result := aISAChipDetectMethods[i].Method(BasePort);
      if result <> 0 then exit;
    end;
  finally
    SetBusReady(bISA);
  end;
end;

⌨️ 快捷键说明

复制代码Ctrl + C
搜索代码Ctrl + F
全屏模式F11
增大字号Ctrl + =
减小字号Ctrl + -
显示快捷键?