© 2000 Ubicom, Inc. All rights reserved.
- 8 -
www.ubicom.com
AN16
SX IrDA Virtual Peripheral Implementation
3.3
LAP LAYER
The primary purpose of the link-access-protocol (LAP) layer
is to manage the link to provide a connection-based bi-
directional reliable data transfer service. It manages the dis-
covery process, the connection process, and the transfer of
data.
The LAP layer implementation is secondary only with two
additional primary features:
Support for initiating XID discovery.
Support for sending unnumbered-information frames.
The LAP layer is implemented in the IrDA Virtual Peripheral
as two parts payload layer and LAP layer.
3.3.1 Discovery
In order for an IrDA device to open a connection with
another IrDA device it must first know it is there and the dis-
covery process must be able to cope with multiple IrDA
devices in range. The discovery (XID) frames pass a 32-bit
device address, hint bits as to the type of device, and a
nickname string that can be displayed to the user.
Both command and response XID processes have been
implemented so that the SX can discover other devices and
be discovered itself.
The discovery process is outside of any connection and so
all frames relating to the discovery process are sent at
9600bps with a minimum turnaround of 10ms.
When a device wishes to discover devices in range it will
transmit a XID command frame indicating slot 0 of N slots
(typically 8). Every device receiving a XID command frame
will generate a random slot number between 0 and N-1 to
send a XID response frame. If the random slot number is 0
then it will transmit a reply immediately, otherwise it will wait
until it receives a XID command frame with a matching slot
number. Once the commander has sent out the N XID com-
mand frames with slot numbers from 0 to N-1 it will send its
own details in a XID command frame with a slot number of
$FF.
The hint bits and nickname field are referred to as the XID
discovery information field and are included in all XID
response frames. For XID command frames only the final
frame with a slot number of $FF will contain this field.
The 32-bit device address is a random number that is cho-
sen at start up. It is possible that 2 devices will choose the
same device address and so the XID frame can be
addressed to specific devices and can request that a new
32-bit address be generated.
The IrDA standard recommends that if a XID command
frame is received with a slot number greater that 0 while a
slot number has not been chosen (i.e. the slot 0 command
frame was missed) then a slot number should be chosen
between the received slot number and the maximum. This
complicates generating the random slot number and
requires registers to keep track of the XID process in case
more XID frames are missed. To avoid this the SX gener-
ates a random slot number every time a slot 0 XID com-
mand frame is detected and will send a XID response when
the slot number matches the chosen slot number. The SX
will respond correctly to a XID discovery as long as the first
frame of the discovery process is received correctly. If the
first frame is missed then the SX will not respond and the
discovery process will have to be repeated.
The random 32-bit device address is chosen at start-up and
will be re-generated if a XID command frame is received
that requests a new address be generated. Address con-
flicts can only detected and corrected by primary IrDA
devices. The IrDA Virtual Peripheral is classed as a second-
ary only device and so does not need to detect conflicts.
The primary service of initiating XID discovery is only pro-
vided for information gathering of other devices in range.
Payload
TxEmpty
Get data from payload layer (fl2plTxData).
Add to FCS.
Last flag not set.
Jump to Send.
Payload
FCS Low
TxEmpty
Data = FCS Low XOR $FF.
Jump to Send
FCS High
FCS High
TxEmpty
Data = FCS High XOR $FF.
Jump to Send
Send End
Send End
TxEmpty
Send EOF byte
Wait End
Wait End
TxEmpty
Indicate complete to payload layer
(fl2plTxComplete)
Idle
(Send)
Data <> BOF or EOF or CE
Send data byte
no change
Data = BOF or EOF or CE
Store current state.
Send CE byte
Control
Control
TxEmpty
Recover stored state.
Send data byte XOR $20
previous state
Table
3-2. Framing Layer Transmit State Machine
Current State
Event
Action
Next State