© 2000 Ubicom, Inc. All rights reserved. - 6 - www.ubicom.com AN16 SX IrDA Virtual Peripheral Implementation 3.2.2  Frame Transparency Prior to transmission extra escape characters are added
to ensure payload data cannot prematurely terminate the
frame by conflicting with a control byte. The application of
transparency covers all data between the BOF and EOF
bytes including the FCS. The control escape (CE) byte is
defined as $7D. Any instance of a BOF, EOF, or CE in the
data is encoded by inserting a CE byte followed by the
original data byte xored with $20.
After  transparency  bytes  have  been  applied  the  only
instance of a BOF will be at the start of a frame thus if a
BOF is received at any point any existing data will be dis-
carded and the payload data started again.
3.2.3   Receive API As  a  frame  is  being  received  the  payload  bytes  are
passed to the payload layer using fl2plRxData. When the
end of the frame is detected, fl2plRxValid or fl2plError will
be  called  indicating  that  the  frame  is  complete  and  the
payload data was valid /erroneous.
The frame can be rejected by the payload layer by calling
pl2flRxIgnore   or   by   calling   pl2flTxStart   to   transmit   a
frame  (see  Transmit  API).  When  a  frame  is  rejected  in
this   manner,   the   receive   state   is   reset   to   idle,   thus
fl2plRxValid/fl2plRxError will not be called.
It  should  be  noted  that  the  framing  layer  does  not  time
out.  If  transmission  is  interrupted  part  way  through  a
frame then fl2plRxError will not be called until the start of
a new frame is detected. If a higher layer times out and
requests  that  a  frame  be  transmitted  then  the  receive
state is reset thus fl2plRxError will not be called.
The fl2lapMediaBusy indication is used by the lap layer to
reset  the  media  idle  test  and  is  called  before  any  other
receive call.
3.2.4   Receive State machine Table 3-1 shows the Framing Layer Receive State Machine. fl2plRxData (w=Data) A byte of payload data has been received fl2plRxValid () The payload data is complete and has been validated. fl2plRxError () The payload data passed is invalid. pl2flRxIgnore () The payload layer has no interest in the frame. fl2lapMediaBusy () A byte has been received Figure 3-2. Framing Layer Receive API Table 3-1.   Framing Layer Receive State Machine Current State Event Action Next State Idle RxAvail = BOF Begin RxAvail = Other Idle Begin RxAvail = BOF Begin RxAvail = EOF Idle RxAvail = CE Reset FCS.
Add data to FCS.
Pass RxData to payload layer via FIFO buffer.
Control RxAvail = Other Indicate data error to payload layer (fl2plRxError). Payload Payload RxAvail = BOF Indicate data valid to payload layer (fl2plRxValid). Begin RxAvail = EOF & FCS = valid Indicate data error to payload layer (fl2plRxError). Idle RxAvail = EOF & FCS = invalid Idle RxAvail = CE Add data to FCS
Pass RxData to payload layer via FIFO buffer.
Control RxAvail = Other Indicate data error to payload layer (fl2plRxError). Payload