Upload
quentin-holmes
View
232
Download
4
Embed Size (px)
Citation preview
Embedded System Lab. II
Device Driver in LinuxDevice Driver in Linux
경희대학교 컴퓨터공학과
조 진 성
Embedded System Lab. II 2
주요내용
주요내용 UART 이해 LCD 이해 Ethernet 이해 USB 이해
Embedded System Lab. II 3
Asynchronous Serial Communication -- UART
Universal asynchronous receiver/transmitter Transmit bits in a single channel
simplex (one way) half-duplex (one direction at a time) full-duplex (two way)
A sequence of bits – packet or character ASCII code – 7 bits for 128 characters (alphabet, numerical, and
control) fixed length or variable length Start, stop, and parity bits
Embedded System Lab. II 4
EIA RS232 Connection and signal
characteristics Data terminal equipment and
data communication equipment Logic '1' (marking) – -3v to -25v
with respect to signal ground Logic “0” (spacing) – +3v to
+25v Not assigned –between -3v and
+3v (a transition region)
Embedded System Lab. II 5
RS232(2)
Flow control (handshaking) signals to avoid buffer overflow or lock-up.
RTS : to prepare the DCE device for accepting transmission
CTS : to inform the DTE device that transmission may begin
DCD: data carrier detected DSR: DCE ready SG: system ground DTR: DTE ready
DTE FEP DB25 DCE MOD DB25
1 FG --------------- 1 FG
2 TX --------------> 2 TX
3 RX <-------------- 3 RX
4 RTS --------------> 4 RTS
5 CTS <-------------- 5 CTS
6 DSR <-------------- 6 DSR
7 SG --------------- 7 SG
8 DCD <-------------- 8 DCD
20 DTR --------------> 20 DTR
Embedded System Lab. II 6
Signal Format for ASCII Character
data, start, stop, and (even or odd) parity bits
Embedded System Lab. II 7
UART(1)
PC Com Port - EIA-574
RS-232 pin out DB-9 pin used for Asynchronous Data
Embedded System Lab. II 8
UART(2)
Is Your Interface a DTE or a DCE? Find out by following these steps: The point of reference for all signals is
the terminal (or PC). ① Measure the DC voltages between (DB25) pins 2 & 7 and between pins 3 & 7. Be
sure the black lead is connected to pin 7 (Signal Ground) and the red lead to whichever pin you are measuring.
② If the voltage on pin 2 (TD) is more negative than -3 Volts, then it is a DTE, otherwise it should be near zero volts.
③ If the voltage on pin 3 (RD) is more negative than -3 Volts, then it is a DCE.
④ If both pins 2 & 3 have a voltage of at least 3 volts, then either you are measuring incorrectly, or your device is not a standard EIA-232 device. Call technical support.
⑤ In general, a DTE provides a voltage on TD, RTS, & DTR, whereas a DCE provides voltage on RD, CTS, DSR, & CD.
Embedded System Lab. II 9
UART(3)
This is a standard 9 to 25 pin cable layout for async data on a PC AT serial cable
Description Signal 9-pin DTE
25-pin DCE
Source DTE or DEC
Carrier Detect CD 1 8 from Modem
Carrier Detect RD 2 3 from Modem
Transmit Data TD 3 2 from Terminal/Computer
Data Terminal Ready DTR 4 20 From Terminal/Computer
Signal Ground SG 5 7 from Modem
Data Set Ready DSR 6 6 from Modem
Request to Send RTS 7 4 from Terminal/Computer
Clear to Send CTS 8 5 from Modem
Ring Indicator RI 9 22 from Modem
Embedded System Lab. II 10
UART(4)
Pin Description EIA
CKT
From
DCE
To
DCE
1 Frame Ground AA
2 Transmitted Data BA D(Data)
3 Received Data BB D
4 Request Data CA C(Control)
5 Clear to Send CB C
6 Signal Set Ready CC C
7 Singnal Gnd/Common Return AB
8 Rcvd. Line Signal Detector CF C
11 Undefined
12 Secondary Rcvd. Line Sig. Detector C
13 Secondary Clear to Send SCB C
Pin Description EIACKT
FromDCE
ToDCE
14 Secondary Transmitted Data SBA D
15 Transmitted Sig.Element Timing
DB T(Timing)
16 Secondary Received Data SBB D
17 Received Sig. Element Timing DD T
18 Undefined
19 Secondary Request to Send SCA C
20 Data Terminal Ready CD C
21 Sig. Quality Detector CG C
22 Ring Indicator CE C
23 Data Sig. Rate Selector(DCE) CI C C
24 Data Sig. Rate Selector(DTE) CH T
25 Undefined
RS-232 interface
RS-232(EIA Std.) applicable to the 25 pin interconnection of Data Terminal Equipment (DTE)and Data Communication Equipment (DCE) using serial binary data
Embedded System Lab. II 11
UART(5)
RS232D used RJ45 type connectors(similar to telephone connectors)
Pin No. Signal Description Abbr. DTE DCE
1 DCE Ready, Ring Indicator DSR/RI
2 Received Line Signal Detector DCD
3 DTE Ready DTR
4 Signal Ground SG
5 Received Data RxD
6 Transmitted Data TxD
7 Clear To Send CTS
8 Request To Send RTS
Embedded System Lab. II 12
Liquid Crystal Display(1) LC( 액정 ) 란 ?
일정 온도 범위에서 유동성을 지닌 액정 상태를 말함 동시에 광학적으로 복굴절성을 나타내는 결정임 보통 물질은 용융 온도에서 고체로부터 투명한 액체로 변화하지만 ,
액정물질은 용융 온도에서 우선 불투명하고 혼탁한 액체로 일단 변화하고 그 후 더욱 온도를 올리면 보통의 투명한 액체로 변화한다 .
액정이란 명칭은 고체상과 액체상의 중간 상태인 액정상을 가리키는 경우와 이러한 액정상을 갖는 물질 그 자체를 가리키는 경우의 두 가지 의미로 사용되고 있다 .
액정 물질의 온도 변화에 의한 상태 변화
Embedded System Lab. II 13
Liquid Crystal Display(2) LCD
액정의 특성을 이용해 만드는 디스플레이
LCD 특징 장점
저소비 전력 ( 수∼수십 μW/cm2) 으로 장시간의 전지구동이 가능한 에너지 절약형이다 .
저전압에서 동작 ( 수∼ 10V) 하므로 직접 IC 구동이 가능하고 구동 전자회로의 소형화 , 간략화가 가능하다 .
Embedded System Lab. II 14
Liquid Crystal Display(3) 소자가 얇고 ( 수 mm), 또한 대형표시 ( 수십 cm 대각 ) 부터 소형표시
( 수 mm 대각 ) 까지 가능하다 . 특히 휴대형 (portable) 기기에 적합하다 . 수광형 표시이므로 밝은 장소에서도 표시가 선명하다 . 표시의 컬러화가 쉽기 때문에 표시기능의 확대 , 다양화가 이루어질 수
있다 . 투사확대 표시나 집적표시가 가능하여 대화면 표시 ( 수 m 대각 ) 가
용이하다 . 단점
비발광형이므로 반사형 표시인 경우 어두운 곳에서 표시의 선명함이 떨어진다 .
선명한 표시가 요구되는 경우 또는 컬러 표시의 경우 후광 (back light) 을 필요로 한다 .
표시 콘트라스트가 보는 방향에 의존하는 경우가 많아서 시각에 제약을 받는다 .
응답시간이 주위 온도에 의존하기 때문에 저온동작 (-30 -40 )∼ ℃ 에 어려움이 있다 .
Embedded System Lab. II 15
LCD 용도 및 분류 LCD 의 분류
형태에 따른 분류 투사형 LCD 직시형 LCD
구동방식에 따른 분류 전기적 구동 (electrically addressed) LCD 광학적 구동 (optically addressed) LCD
Embedded System Lab. II 16
LCD 동작 원리 동작원리
'OFF' 상태는 전압을 가하지 않은 상태를 나타내며 , 편광판을 통과한 빛이 액정의 분자 배열을 따라 꼬여지면서 교차된 다른 편광판을 통과하게 된다 . ( 즉 전압을 가하지 않은 상태에서는 빛이 통과한다 .)
'ON' 상태는 전압을 가한 상태를 나타내며 , 이때에는 전계의 방향을 따라 액정 분자가 일어서면서 편광판을 통과한 빛을 그대로 교차된 편광판에 전달시킴으로써 빛은 편광판에 의해 차단된다 . ( 즉 전압을 가하면 빛이 차단된다 .)
전압을 선택적으로 인가함으로써 상 , 하판의 전극 모양에 따라 원하는 도형 또는 문자를 표시할 수 있게 된다 .
Embedded System Lab. II 17
LCD Hardware overview
MMU
PXA250 Core
PXA255
GP[27:0]
D[31:0]A[31:0]
GPIOGPIO Registers GP[27:0]
Bridge
Interrupt Controller
ICIPICMRICLR
ICCRICFP
FIQ, IRQ
DMADMARegisters
LCD Controller
ADS 7843
Dynamic Memory Controller
SDCKE[1]SDCLK[1]SDCS[0]#
SDRAS#
WE#SDCAS#
DQM[3:0]
MDCNFGMDCAS00MDREFR
LCD CON
LDD[15:0]L-FCLKL-LCLKL-PCLK
LCDControlRegisters
DCLKCS#DINBUSY
PENIRQ#DOUT
GP4
GP5GP26
X+X-
Y-Y+
Inverter Power
L-BIAS
E-PORT0[7:0] GP25E-PORTGP23
E-PORT0 7
TFT LCD & Touch screen
Embedded System Lab. II 18
이더넷 (Ethernet)(1)
Ethernet Commonly used to refer to all carrier sense multiple access
collision detection (CSMA/CD) LANS that generally conform to Ethernet specifications, including IEEE 802.3
Embedded System Lab. II 19
Ethernet(2) 전자적인 특성
신호 방식 (Signaling) 기저대역 (Base-band) 시스템
Manchester digital Encoding• 디지털 대 디지털 부호화• 극형 – 이상 부호화
광대역 (Broadband) 시스템 differential PSK
• 디지털 대 아날로그 부호화 전송속도 (data rate)
1~100Mbps
Embedded System Lab. II 20
Ethernet(3) Baseband:
디지털 신호 ( 이 경우 맨체스터 부호화를 의미 ) 표준
첫 숫자는 Mbps 단위로 데이터 전송율 10Base2: 얇은 동축케이블 이용 , 최장 길이는 185m 10Base5: 굵은 동축케이블 이용 , 최장 길이는 500m 10Base-F: 광케이블을 이용 10Base-T: Twisted Pair cable 이용
광대역 (Broadband): 아날로그 신호 ( 이 경우에는 PSK) 한 가지 표준 : 10Broad36
Embedded System Lab. II 21
Ethernet(4)
IEEE 802
Embedded System Lab. II 22
프레임 형식 (Frame Format) Preamble(7 바이트 ) - alert, timing, start synchronization SFD(Start frame delimiter) - 프레임 시작 DA(Destination address) - 목적지 주소 SA(Source address) - 발신지 주소 PDU 길이 / 유형 802.2 프레임 (PDU) - 46~1500 바이트길이 CRC - 오류 검출 정보 , CRC-32
Ethernet(5)
Embedded System Lab. II 23
Ethernet(6)
제어 (Control) 필드 HDLC 의 제어 필드와 동일
I-Frame
S-Frame
U-Frame
P/F Poll/final bit
N(S) 프레임 송신 번호
N(R) 프레임 수신 번호
Code 비번호나 감시코드
Embedded System Lab. II 24
Ethernet(7) ACCESS Method : CSMA/CD
Carrier Sense Multiple Access with Collision Detection : "Listen before talk" 방식
각 Node 는 Common Line 을 계속적으로 감시하면서 Data 송신 기회 감지 전송 감지 : Listen before talk
경쟁에 의한 엑세스로 충돌 발생 가능 : Collision 발생시 재전송 충돌 검출 : Listen while talk
구현이 간단하지만 , 트래픽 부하가 높을 경우에 충돌로 인한 망 성능 저하 발생 충돌 회수가 네트워크의 성능을 좌우
Embedded System Lab. II 25
Ethernet(8)
CSMA/CD 동작 절차 컴퓨터가 전송을 원할 때는 전송
매체를 감지하고 있다가 채널상에 트래픽이 있으면 트래픽이 끝날 때까지 기다리고 , 신호가 없으면 즉시 전송을 개시
전송도중에도 항상 버스를 감지해서 충돌여부를 감지하며 , 충돌이 발생하면 즉시 전송을 중지 , 다른 스테이션에 충돌을 알리는 jamming 신호 발생
jamming 신호 전송이 끝나면 임의의 시간 동안 대기하였다가 다시 처음부터 시도
채널트래픽여부 ?
프레임 송신 요구
송신 개시
충돌검출 ?
충돌검출 ? jamming발생
송신완료 임의의 시간 대기
Yes
No Yes
No
Yes
No
Carrier Sense
Multi Access
Collision Dection
Embedded System Lab. II 26
Ethernet Hardware 예
PXA255
MD(31:0)
T/F
T/F
Primary Ethernet
Secondary Ethernet
ADDR (15:2)
D(31:0) D(31:0)
DIR OE#
Logic
nCS1nCS2nCS3nCS4
RD_nWR
nPWEnOE
MA(25:0)nDQM(3:0)
WE#OE#A(15:2)DQM(3:0)#
WE#OE#A(15:2)DQM(3:0)#
nCS1nCS2
GPIO(0)
GPIO(1)
INTR0INTR0
Ethernet Controller SMSC 10/100 Ethernet Single Chip LAN91C111 Internal 32Bit Wide Data Path 8Kbytes Internal Memory (Receive and Transmit FIFO Buffers) External 25MHz-output pin for an external PHY and MAC MSC0,1 - Static Chip Select 1,2 (Bank 1,2) Base Address = 0x04000_0000 (Pri) 0x0800_0000(sec)
Embedded System Lab. II 27
Universal Serial Bus – USB(1) Motivation
Connection of the PC to the telephone Ease-of-use Port expansion
Goals for the Universal Serial Bus Ease-of-use for PC peripheral expansion Low-cost solution that supports transfer rates up to 480 Mb/s Full support for real-time data for voice, audio, and video Protocol flexibility for mixed-mode isochronous data transfers and
asynchronous messaging Integration in commodity device technology Comprehension of various PC configurations and form factors Provision of a standard interface capable of quick diffusion into product Enabling new classes of devices that augment the PC’s capability Full backward compatibility of USB 2.0 for devices built to previous
versions of the specification
Embedded System Lab. II 28
Universal Serial Bus – USB (2) Feature
Easy to use for end user Single model for cabling and connectors Electrical details isolated from end user (e.g., bus terminations) Self-identifying peripherals, automatic mapping of function to driver and
configuration Dynamically attachable and reconfigurable peripherals
Wide range of workloads and applications Suitable for device bandwidths ranging from a few kb/s to several hundred
Mb/s Supports isochronous as well as asynchronous transfer types over the
same set of wires Supports concurrent operation of many devices (multiple connections) Supports up to 127 physical devices Supports transfer of multiple data and message streams between the host
and devices Allows compound devices (i.e., peripherals composed of many functions) Lower protocol overhead, resulting in high bus utilization
Embedded System Lab. II 29
Universal Serial Bus – USB (3) Isochronous bandwidth
Guaranteed bandwidth and low latencies appropriate for telephony, audio, video, etc.
Flexibility Supports a wide range of packet sizes, which allows a range of device
buffering options Allows a wide range of device data rates by accommodating packet buffer
size and latencies Flow control for buffer handling is built into the protocol
Robustness Error handling/fault recovery mechanism is built into the protocol Dynamic insertion and removal of devices is identified in user-perceived
real-time Supports identification of faulty devices
Synergy with PC industry Protocol is simple to implement and integrate Consistent with the PC plug-and-play architecture Leverages existing operating system interfaces
Embedded System Lab. II 30
Universal Serial Bus – USB (4) Low-cost implementation
Low-cost subchannel at 1.5 Mb/s Optimized for integration in peripheral and host hardware Suitable for development of low-cost peripherals Low-cost cables and connectors Uses commodity technologies
Upgrade path Architecture upgradeable to support multiple USB Host Controllers in a
system
Embedded System Lab. II 31
Universal Serial Bus – USB (5)
Embedded System Lab. II 32
Universal Serial Bus – USB (6) Taxonomy of Application Space
Embedded System Lab. II 33
Physical Interface
USB H/W Architectural(1)
Embedded System Lab. II 34
USB H/W Architectural(2)
Embedded System Lab. II 35
USB Host Controller Host Controller 의 분류
OHCI(Open Host Controller Interface : Compaq ) UHCI(Universal Host Controller Interface : Intel )
※ 같은 capability 를 제공
USB Core
Host Controller Driver
USB Client Driver
Host Controller(Compaq or Intel)
USB Device
Application
Linux USB Device Driver Stack
Embedded System Lab. II 36
USB Hub
기능 포트 제어
연결 인식 포트 enable/disable reset/resume 신호
데이터 신호 신호 재생 robustness/recover
전력 분배
Embedded System Lab. II 37
USB Data Flow
Type Control Transfers: Used to configure a device at attach time and can be
used for other device-specific purposes, including control of other pipes on the device.
Bulk Data Transfers: Generated or consumed in relatively large and bursty quantities and have wide dynamic latitude in transmission constraints.
Interrupt Data Transfers: Used for timely but reliable delivery of data, for example, characters or coordinates with human-perceptible echo or feedback response characteristics.
Isochronous Data Transfers: Occupy a prenegotiated amount of USB bandwidth with a prenegotiated delivery latency. (Also called streaming real time transfers).
Embedded System Lab. II 38
USB 모델 한 개의 호스트 ( 마스터 모드 ), 다수의 디바이스 (client) USB 모델의 계층
Embedded System Lab. II 39
호스트 계층 USB host controller
매체에 대한 물리적인 연결 low level 프로토콜 처리 (SIE) H/W + S/W
USB system S/W 드라이버층과의 인터페이스 standard device 처리
Client S/W 디바이스 드라이버
주변장치의 기능 처리를 위한 S/W
Embedded System Lab. II 40
디바이스 계층
USB bus interface 매체에 대한 물리적인 연결 low level 프로토콜 처리 (SIE)
USB logical device 호스트에 대한 소자의 common view point high-level 프로토콜 처리
Function 장치에 의해 제공되는 기능
Embedded System Lab. II 41
디바이스 추상화
엔드 포인트 디바이스 끝의 데이터 소스 또는 싱크 고유주소 , unidirection, transfer 특성을 가짐
파이프 호스트 S/W owner 와 디바이스 endpoint 의 결합 호스트 메모리 버퍼에서 엔드포인트 FIFO 의 연결 파이프 통신 모드 : stream( 데이터 ) 과 message(USB 데이터 구조 ) default control pipe : endpoint 0 와의 파이프
인터페이스 파이프의 집합 각 기능에 map 1 개의 S/W client 에 의해 소유됨
Embedded System Lab. II 42
USB 의 상세 형태