//--------------------------------------------------------------------------- #include #pragma hdrstop #include #include "IRQSAMPc.h" #include "Win32IRQ.h" #include "ACCES32.h" #include "IRQThrd.h" unsigned char Success; IRQThread *thrd; //--------------------------------------------------------------------------- #pragma package(smart_init) #pragma resource "*.dfm" TForm1 *Form1; //--------------------------------------------------------------------------- __fastcall TForm1::TForm1(TComponent* Owner) : TForm(Owner) { } //--------------------------------------------------------------------------- void __fastcall TForm1::ExitButtonClick(TObject *Sender) { Close(); } //--------------------------------------------------------------------------- void __fastcall TForm1::InitButtonClick(TObject *Sender) { short BusType; unsigned char IRQ, BN, Method; unsigned long BaseAddress, ClearOffset; if (BusTypeCombo->Text == "ISA") BusType = Isa; else if (BusTypeCombo->Text == "PCI") BusType = PCIBus; else BusType = InterfaceTypeUndefined; IRQ = StrToInt(IRQEdit->Text); sscanf(BaseEdit->Text.c_str(), "%lx", &BaseAddress); sscanf(LatchEdit->Text.c_str(), "%lx", &ClearOffset); try { BN = StrToInt(BusNumberEdit->Text); } catch (EConvertError &error) { BN = 0; } if (WriteRadio->Checked) Method = WRITE_TO_CLEAR; else Method = READ_TO_CLEAR; Success = InitGenDriver(BaseAddress, IRQ, BusType, BN, ClearOffset, Method); if (Success) StatusLabel->Caption = "Setup card using Write Port, then press Start Acquisition"; else StatusLabel->Caption = "Driver Error During Initialization"; } //--------------------------------------------------------------------------- void __fastcall TForm1::WriteButtonClick(TObject *Sender) { unsigned long Base; unsigned long Offset; unsigned long Value; sscanf(BaseEdit->Text.c_str(), "%lx", &Base); sscanf(OffsetEdit->Text.c_str(), "%lx", &Offset); sscanf(ValueEdit->Text.c_str(), "%lx", &Value); OutPortB(Base+Offset, Value); } //--------------------------------------------------------------------------- void __fastcall TForm1::StartButtonClick(TObject *Sender) { StartButton->Enabled = false; thrd = new IRQThread(false); AbortButton->Enabled = true; } //--------------------------------------------------------------------------- void __fastcall TForm1::ReadButtonClick(TObject *Sender) { unsigned long Base; unsigned long Offset; unsigned short Value; sscanf(BaseEdit->Text.c_str(), "%lx", &Base); sscanf(OffsetEdit->Text.c_str(), "%lx", &Offset); Value = InPortB(Base+Offset); ValueEdit->Text = IntToHex(Value, 2); } //--------------------------------------------------------------------------- void __fastcall TForm1::AbortButtonClick(TObject *Sender) { thrd->Terminate(); AbortRequest(); StatusLabel->Caption = "Aborted - press Start Acquisition to resume"; AbortButton->Enabled = false; StartButton->Enabled = true; } //--------------------------------------------------------------------------- void __fastcall TForm1::FormCreate(TObject *Sender) { if (InPortB(0x61) == 0xAA55) { Application->MessageBox("ACCESNT.SYS not detected. Please copy ACCESNT.SYS into [NT]/system32/drivers and re-run this sample.", "Warning", IDOK); } } //---------------------------------------------------------------------------