Частина тексту файла (без зображень, графіків і формул):
Національний університет
“Львівська політехніка”
Кафедра ЕОМ
Лабораторна робота
З дисципліни “Периферійні пристрої”
На тему: “Інтерфейс USB”
Львів – 2006
Універсальний інтерфейс USB.
USB (Universal Serial Bus – універсальна послідовна шина) є промисловим стандартом розширення архітектури PC, орієнтованим на інтеграцію з телефонією і пристроями побутової електроніки. Версія 1.0 було опублікована в січні 1996 року. Архітектура USB визначається наступними показниками:
Легко реалізуюче розширення периферії PC.
Дешеве рішення, яке підтримує швидкість передачі до 12 Мбит/с.
Повна підтримка в реальному часі передачі аудіо- і відео- даних.
Гнучкість протоколу змішаної передачі ізохронних даних і асинхронних повідомлень.
Інтеграція з пристроями, які випускаються.
Доступ в PC всіх конфігурацій і розмірів.
Забезпечення стандартного інтерфейса, спроможного швидко захопити ринок.
Створення нових класів пристроїв, які розширюють PC.
З точки зору користувача, є зручні наступні риси USB:
Простота кабельної системи і підключень.
Закриті подробиці електричного підключення від користувача.
Самоідентифікуючі ПП, автоматичний зв’язок устройств з драйверами і конфігурування.
Можливість динамічного підключення і конфігурування ПП.
З середини 1996 року випускаються PC з встроїним контроллером USB, який реалізується чіпсетом. Вже появились модеми, клавіатури, сканери, динаміки і інші пристрої вводу/виводу з підтримкою USB, а також монітори з USB-адаптерами – вони грають роль концентраторів для підключення інших пристроїв.
unit USB;
interface
uses
Windows, Messages, SysUtils, Variants, Classes, Graphics, Controls, Forms,
Dialogs, ExtCtrls, jpeg, StdCtrls;
type
mt = file of char;
TForm1 = class(TForm)
Button1: TButton;
Button2: TButton;
Memo1: TMemo;
Image1: TImage;
Image2: TImage;
Image3: TImage;
Image4: TImage;
Image5: TImage;
GroupBox1: TGroupBox;
Button3: TButton;
Button4: TButton;
Edit1: TEdit;
Edit2: TEdit;
Button5: TButton;
Button6: TButton;
Edit3: TEdit;
Label1: TLabel;
Button7: TButton;
Edit4: TEdit;
procedure FormCreate(Sender: TObject);
procedure Button2Click(Sender: TObject);
procedure Button1Click(Sender: TObject);
procedure Button7Click(Sender: TObject);
procedure Button4Click(Sender: TObject);
procedure Button5Click(Sender: TObject);
procedure Button6Click(Sender: TObject);
procedure Button3Click(Sender: TObject);
private
{ Private declarations }
public
f:mt;
ch :string[20];
{ Public declarations }
end;
var
Form1: TForm1;
implementation
{$R *.dfm}
procedure TForm1.FormCreate(Sender: TObject);
begin
memo1.Clear;
end;
procedure TForm1.Button2Click(Sender: TObject);
begin
Image3.Visible:=TRUE;
Image5.Visible:=FALSE;
GroupBox1.Visible:=TRUE;
Button4.Visible:=TRUE;
Button3.Visible:=FALSE;
Edit1.Visible:=FALSE;
Edit2.Visible:=TRUE;
Edit4.Visible:=TRUE;
Button5.Visible:=TRUE;
Button6.Visible:=TRUE;
Edit3.Visible:=TRUE;
Edit1.Clear;
Edit2.Clear;
Edit3.Clear;
Edit4.Clear;
//memo1.SetSelTextBuf('HOST: sending SETUP '+'FLASH: received SETUP ');
memo1.Text:='HOST: sending SETUP '+
'FLASH: received SETUP '+
'FLASH: sending ACK '+
'HOST: received ACK '+
'HOST: sending DATA0 with GET_DESCRIPTOR '+
'FLASH: received DATA0 with GET_DESCRIPTOR '+
'FLASH: sending descriptor '+
'HOST: received descriptor '+
'HOST: sending ACK';
//memo1.SetTextBuf('FLASH: sending ACK ');
//memo1.SetTextBuf('HOST: received ACK ');
//memo1.SetTextBuf('HOST: sending DATA0 with GET_DESCRIPTOR ');
//memo1.SetTextBuf('FLASH: received DATA0 with GET_DESCRIPTOR ');
//memo1.SetTextBuf('FLASH: sending descriptor ');
//memo1.SetTextBuf('HOST: received descriptor ' +
//'HOST: sending ACK');
end;
procedure TForm1.Button1Click(Sender: TObject);
begin
memo1.Clear;
Image3.Visible:=FALSE;
Image5.Visible:=TRUE;
GroupBox1.Visible:=TRUE;
Button4.Visible:=FALSE;
Button3.Visible:=TRUE;
Edit1.Visible:=TRUE;
Edit2.Visible:=FALSE;
Edit4.Visible:=FALSE;
Button5.Visible:=FALSE;
Button6.Visible:=FALSE;
Edit3.Visible:=FALSE;
Edit1.Clear;
Edit2.Clear;
Edit3.Clear;
Edit4.Clear;
memo1.Text:='HOST: sending SETUP ' +
' PRINTER: received SETUP ' +
' PRINTER: sending ACK ' +
' HOST: received ACK ' +
' HOST: sending DATA0 with GET_DESCRIPTOR '+
' PRINTER: received DATA0 with GET_DESCRIPTOR ' +
' PRINTER: sending descriptor ' +
' HOST: received descriptor ' +
' HOST: sending ACK ' ;
end;
procedure TForm1.Button7Click(Sender: TObject);
begin
close();
end;
procedure TForm1.Button4Click(Sender: TObject);
begin
AssignFile(f,'flesh\'+ edit2.text);
memo1.Text:='HOST: sending OUT '+
'FLASH: received OUT '+
'HOST: sending DATA0 with CreateFile '+
'FLASH: received DATA0 with CreateFile '+
'FLASH: sending ACK '+
'HOST: sending OUT '+
'FLASH: received OUT '+
'HOST: sending DATA0 with '+ edit2.text +
' FLASH: received DATA0 with '+ edit2.text +
' FLASH: sending ACK'
end;
procedure TForm1.Button5Click(Sender: TObject);
var
pc:string[255];
i: integer;
begin
pc:=Edit3.Text;
Rewrite(f);
for i:=1 to length(pc) do
begin
Write(f,pc[i]);
end;
CloseFile(f);
memo1.Text:='HOST: sending OUT '+
' FLASH: received OUT '+
' HOST: sending DATA0 with Write ' +
' FLASH: received DATA0 with Write ' +
' FLASH: sending ACK ' +
' HOST: sending OUT ' +
' FLASH: received OUT ' +
' HOST: sending DATA0 with '+ edit2.Text+
' FLASH: received DATA0 with ' + edit2.Text+
' FLASH: sending ACK ' +
' HOST: sending OUT' +
' FLASH: received OUT ' +
' HOST: sending DATA0 with '+Edit3.Text+
' FLASH: received DATA0 with '+Edit3.Text+
' FLASH: sending ACK'
end;
procedure TForm1.Button6Click(Sender: TObject);
var
iFileLength:integer;
Buf:string[255];
ch:char;
i:integer;
begin
edit4.Clear;
reset(f);
i:=1;
while not eof(f) do
begin
read(f,char(buf[i]));
i:=i+1;
end;
edit4.Text:=Buf;
CloseFile(f);
memo1.Text:='HOST: sending OUT '+
' FLASH: received OUT '+
' HOST: sending DATA0 with Read ' +
' FLASH: received DATA0 with Read' +
' FLASH: sending ACK ' +
' HOST: sending OUT ' +
' FLASH: received OUT ' +
' HOST: sending DATA0 with '+ edit2.Text+
' FLASH: received DATA0 with ' + edit2.Text+
' FLASH: sending ACK ' +
' HOST: sending IN' +
' FLASH: received IN ' +
' HOST: sending DATA0 with '+Edit4.Text+
' FLASH: received DATA0 with '+Edit4.Text+
' FLASH: sending ACK'
end;
procedure TForm1.Button3Click(Sender: TObject);
begin
memo1.Text:='HOST: sending OUT ' +
' PRINTER: received OUT ' +
' HOST: sending DATA0 with '+edit1.text+
' PRINTER: received DATA0 with ' + edit1.text +
' PRINTER: sending ACK ';
end;
end.
Вигляд вікна програми:
Висновки: На лабораторній роботі було реалізована програмна модель протокольного рівня універсального інтерфейсу USB. Я ознайомився і зрозумів пронцип роботи цього інтерфейсу.