Znaleziono 1 wynik

autor: lodek123
09 wrz 2005, 15:44
Forum: Ogólne Dyskusje na Temat Systemów Sterowania CNC
Temat: Oprogramowanie LPT w DELPHI - Pomocy
Odpowiedzi: 9
Odsłony: 4423

Jak Ci to pomoże to proszę:

Jako adresy przy wywołaniu procedur podaj
dla LPT1 - $0378
LPT2 - $0278
dla danych
a dla linii sterujących $0379 i $0279
w/g opisu portu LPT

Pocedury może niezbyt optymalnie napisane, ale działają napewno.

Żeby nie było nieporozumień, tą metodą całość działa tylko pod wcześniejszymi windowsami
95,98,Me
jeżeli potrzebujesz tego pod Win2000, NT lub XP
szukaj biblioteki "io.dll" dla Delphi (i innych)
niestety nie pamiętam linka...

Kod: Zaznacz cały

// funkcja odczytu danej z portu
function odczytaj_z_portu(adres:word):byte; 
var odczyt:byte; 
begin
  asm
    mov DX,adres
    in AL,DX
    mov odczyt,AL
  end; 
 odczytaj_z_portu:=odczyt; 
end; 


// procedura zapisu danych do portu
procedure wpisz_do_portu(adres:word;dana:byte); 
begin
    asm
       mov DX,adres
       mov AL,dana
       out DX,AL
    end; 
end; 


procedure wylacz_bit(adres:word;numer:byte); 
  begin
    case numer of
      0:asm
         mov dx,adres
         in al,dx
         and al,11111110b
         out dx,al
        end; 
      1:asm
         mov dx,adres
         in al,dx
         and al,11111101b
         out dx,al
        end; 
      2:asm
         mov dx,adres
         in al,dx
         and al,11111011b
         out dx,al
        end; 
      3:asm
         mov dx,adres
         in al,dx
         and al,11110111b
         out dx,al
        end; 
      4:asm
         mov dx,adres
         in al,dx
         and al,11101111b
         out dx,al
        end; 
      5:asm
         mov dx,adres
         in al,dx
         and al,11011111b
         out dx,al
        end; 
      6:asm
         mov dx,adres
         in al,dx
         and al,10111111b
         out dx,al
        end; 
      7:asm
         mov dx,adres
         in al,dx
         and al,01111111b
         out dx,al
        end; 
    end; 
  end; 



procedure wlacz_bit(adres:word;numer:byte); 
  begin
    case numer of
      0:asm
         mov dx,adres
         in al,dx
         or al,00000001b
         out dx,al
        end; 
      1:asm
         mov dx,adres
         in al,dx
         or al,00000010b
         out dx,al
        end; 
      2:asm
         mov dx,adres
         in al,dx
         or al,00000100b
         out dx,al
        end; 
      3:asm
         mov dx,adres
         in al,dx
         or al,00001000b
         out dx,al
        end; 
      4:asm
         mov dx,adres
         in al,dx
         or al,00010000b
         out dx,al
        end; 
      5:asm
         mov dx,adres
         in al,dx
         or al,00100000b
         out dx,al
        end; 
      6:asm
         mov dx,adres
         in al,dx
         or al,01000000b
         out dx,al
        end; 
      7:asm
         mov dx,adres
         in al,dx
         or al,10000000b
         out dx,al
        end; 
    end; 
  end;

Wróć do „Oprogramowanie LPT w DELPHI - Pomocy”