äìÉ`çêÉ UART Host Transport Summarydownload.maritex.com.pl/pdfs/wi/UART Host.pdf · Host...

18
_äìÉ`çêÉ» UART Host Transport Summary February 2004 CSR Cambridge Science Park Milton Road Cambridge CB4 0WH United Kingdom Registered in England 3665875 Tel: +44 (0)1223 692000 Fax: +44 (0)1223 692001 www.csr.com bcore-rp-002Pb © Copyright CSR 2002-2004 This material is subject to CSR’s non-disclosure agreement.

Transcript of äìÉ`çêÉ UART Host Transport Summarydownload.maritex.com.pl/pdfs/wi/UART Host.pdf · Host...

Page 1: äìÉ`çêÉ UART Host Transport Summarydownload.maritex.com.pl/pdfs/wi/UART Host.pdf · Host Transport Overview _ ä ì É ` ç ê É U A R T from five to three if requ H o s t

_äìÉ`çêÉ»

UART Host Transport Summary

February 2004

CSR Cambridge Science Park

Milton Road Cambridge CB4 0WH

United Kingdom Registered in England 3665875

Tel: +44 (0)1223 692000 Fax: +44 (0)1223 692001

www.csr.com

bcore-rp-002Pb © Copyright CSR 2002-2004 This material is subject to CSR’s non-disclosure agreement.

Page 2: äìÉ`çêÉ UART Host Transport Summarydownload.maritex.com.pl/pdfs/wi/UART Host.pdf · Host Transport Overview _ ä ì É ` ç ê É U A R T from five to three if requ H o s t

Contents

_äìÉ`çêÉ

UA

RT H

ost Transport Summ

ary

Contents 1 Introduction .................................................................................................................................................... 3 2 Host Transport Overview .............................................................................................................................. 4

2.1 H3 (RS232).............................................................................................................................................. 5 2.2 H4 (UART)............................................................................................................................................... 6 2.3 BCSP ..................................................................................................................................................... 6 2.4 Comparison Table ................................................................................................................................... 7

3 BCSP Versions............................................................................................................................................... 8 3.1 ABCSP and YABCSP.............................................................................................................................. 8

3.1.1 ABCSP and YABCSP Implementation ......................................................................................... 8 3.1.2 Scheduling ABCSP and YABCSP Operations ............................................................................. 9 3.1.3 Configuring ABCSP and YABCSP ............................................................................................... 9

3.2 µBCSP Engine......................................................................................................................................... 9 3.2.1 Implementating µBCSP.............................................................................................................. 10 3.2.2 Scheduling µBCSP Operations .................................................................................................. 10 3.2.3 Configuring µBCSP.................................................................................................................... 10 3.2.4 Code Size .................................................................................................................................. 10

4 Document References ................................................................................................................................. 16 Acronyms and Definitions.................................................................................................................................. 17 Record of Changes ............................................................................................................................................. 18

List of Figures

Figure 2.1: Host and Bluetooth Hardware Communications Protocol ..................................................................... 4 Figure 2.2: UART Stacks ........................................................................................................................................ 6 Figure 3.1: ABCSP Library Flow ............................................................................................................................. 9

List of Tables

Table 2.1: Host Transport Layer Comparison ......................................................................................................... 7 Table 3.1: Comparison Between BCSP Variants and H4...................................................................................... 15

bcore-rp-002Pb © Copyright CSR 2002-2004 This material is subject to CSR’s non-disclosure agreement. Page 2 of 18

Page 3: äìÉ`çêÉ UART Host Transport Summarydownload.maritex.com.pl/pdfs/wi/UART Host.pdf · Host Transport Overview _ ä ì É ` ç ê É U A R T from five to three if requ H o s t

Introduction

_äìÉ`çêÉ

UA

RT H

ost Transport Summ

ary

1 Introduction The Bluetooth® specification v1.2 details a number of communication layers and protocols that allow the transmission and reception of data and the control of Bluetooth wireless technology links by the host application. This summary describes the different host transports that can work over the universal asynchronous receiver and transmitter (UART). These include the standard Bluetooth protocols H3 and H4 and the _äìÉ`çêÉ» Serial Protocol (BCSP) developed by CSR. The summary presents three versions of BCSP designed for embedded systems.

bcore-rp-002Pb © Copyright CSR 2002-2004 This material is subject to CSR’s non-disclosure agreement. Page 3 of 18

Page 4: äìÉ`çêÉ UART Host Transport Summarydownload.maritex.com.pl/pdfs/wi/UART Host.pdf · Host Transport Overview _ ä ì É ` ç ê É U A R T from five to three if requ H o s t

Host Transport Overview

_äìÉ`çêÉ

UA

RT H

ost Transport Summ

ary

2 Host Transport Overview The Bluetooth Specification details a protocol for communication between the Host and the Bluetooth hardware called the host controller interface (HCI). shows how the protocol layers are commonly split with some layers:

Figure 2.1

Figure 2.1: Host and Bluetooth Hardware Communications Protocol

L2CAP and above residing on the host

The link manager (LM) and below residing on the Bluetooth hardware

Note: The Bluetooth hardware is also called the host controller (HC).

Bluetooth Host

Higher Layer Driver

HCI Driver

Physical Bus Driver

Physical Bus

Bluetooth Hardware

HCI Firmware

Link ManagerFirmware

Baseband Controller

Physical Bus Firmware

Software FirmwareFirmware/Hardware

HCI defines the control and the bulk of data structures to be passed between the host and the Bluetooth hardware, but it says nothing about how these should be carried between the two units, i.e., HCI is itself transport independent.

The Bluetooth specification defines two host transports to be used to carry HCI data between the host and the Bluetooth hardware over a UART link. These two transports are H3 and H4; in addition, CSR has designed another UART host transport called BCSP as a robust alternative to H4. This section examines all these UART host transports.

bcore-rp-002Pb © Copyright CSR 2002-2004 This material is subject to CSR’s non-disclosure agreement. Page 4 of 18

Page 5: äìÉ`çêÉ UART Host Transport Summarydownload.maritex.com.pl/pdfs/wi/UART Host.pdf · Host Transport Overview _ ä ì É ` ç ê É U A R T from five to three if requ H o s t

Host Transport Overview

_äìÉ`çêÉ

UA

RT H

ost Transport Summ

ary

2.1 H3 (RS232)

The H3 host transport requires a minimum of three communication lines:

Receive (Rx)

Transmit (Tx)

Common

There are also two optional lines normally used for hardware flow control:

Ready to Send (RTS)

Clear to Send (CTS)

Before transmission of HCI data a negotiation packet configures the link for baud rate, parity, stop bit, error response delay (Tdetect) and protocol.

The Bluetooth specification includes two different protocols:

Hardware Sync. where the RTS/CTS lines are used for signalling error detection and re-synchronising

Consistent overhead byte stuffing (COBS) where the hardware flow control lines are optional and error detection and handling is performed via dedicated sync and error messages

When implementing H3, Bluetooth devices can support only one of these options, but hosts must be able to support both. Both protocols involve:

The receiving end checking incoming messages for the following errors:

Parity errors for Hardware Sync.

Parity errors and/or cyclic redundancy check (CRC) errors for COBS

Signal the sending end if they are detected

Under COBS protocol, only the offending packet is retransmitted

Under Hardware Sync. transmission is restarted with the offending packet and the original sequence resumed with all subsequent packets being retransmitted in order

The sending end to maintain a buffer of all transmitted packets until it can be certain that a retransmission will not be required. Certainty can only be achieved when the maximum time for the receiving end to check the packet and signal an error has passed. This is defined in the negotiation packet by Tdetect.

With its sequencing and error messages and need to retransmit single packets out of sequence, COBS adds an additional processing overhead.

If H3 support is required on a device where a large transmission buffer is available, for example in the case of a personal computer (PC), or the receiving end has a short Tdetect, then implementation is straightforward. If however, the receiving device has a long Tdetect or random access memory (RAM) for the buffer is at a premium, then implementation can be very unattractive.

As Bluetooth devices are designed to be low cost, it is hard to justify the extra RAM required for H3, especially given its other disadvantages:

The extra processing required for COBS resulting in the bandwidth being processor limited to below the maximum required for full speed Bluetooth communications

The error detection for Hardware Sync is restricted to parity bits

bcore-rp-002Pb © Copyright CSR 2002-2004 This material is subject to CSR’s non-disclosure agreement. Page 5 of 18

Page 6: äìÉ`çêÉ UART Host Transport Summarydownload.maritex.com.pl/pdfs/wi/UART Host.pdf · Host Transport Overview _ ä ì É ` ç ê É U A R T from five to three if requ H o s t

Host Transport Overview

_äìÉ`çêÉ

UA

RT H

ost Transport Summ

ary

2.2

2.3 BCSP

H4 (UART)

H4 is the simplest of the Bluetooth standard host transports. It is intended to operate over an RS232 link with no parity. Hardware flow control is required. HCI commands are transmitted directly with the addition of a packet indicator to indicate:

Command Event

Synchronous connection-oriented (SCO) Data

Asynchronous connectionless (ACL) Data

The disadvantage with H4 is its poor error detection; with no parity, it can only detect:

An incorrect HCI packet indicator

A corrupted HCI command

The length of an HCI packet is out of range

With the absence of any error recovery strategy when something does go wrong, the only way to recover is to reset the bus and restart communications. This often means reforming the Bluetooth links.

Its advantage is that it is simple, cheap and easy to implement at both the Host and Bluetooth device but it is not robust.

BCSP was developed by CSR to provide a more reliable alternative to the H4 host transport protocol. It operates over a similar RS232 link, but hardware flow control is optional so the number of connections can be reduced from five to three if required. HCI messages are placed in a packet whose format allows the addition of the following features:

Option for unreliable or reliable links

For unreliable links there is software flow control and sequencing

For Reliable links there is acknowledgement of receipt for each packet

Option for CRC on all messages

8-bit checksum on packet headers

Simple error recovery strategy

Rest of Host System

UART Stack

UART

UART Link

Rest of HostController System

UART Stack

UART

Figure 2.2: UART Stacks

bcore-rp-002Pb © Copyright CSR 2002-2004 This material is subject to CSR’s non-disclosure agreement. Page 6 of 18

Before any transmission begins, a link establishment procedure permits synchronisation without hardware flow control lines. BCSP packets also include logical channel identifiers to separate Command, Event, ACL and SCO messages. Additional channel allocations also allow direct communications into the upper layers of an on-chip RFCOMM build along with manufacturer specific private channel commands.

Page 7: äìÉ`çêÉ UART Host Transport Summarydownload.maritex.com.pl/pdfs/wi/UART Host.pdf · Host Transport Overview _ ä ì É ` ç ê É U A R T from five to three if requ H o s t

Host Transport Overview

_äìÉ`çêÉ

UA

RT H

ost Transport Summ

ary

2.4

An instance of the BCSP stack runs on both the host and the host controller. The top of the BCSP presents:

One bi-directional reliable datagram service

One bi-directional unreliable datagram service

Higher layers of the stack can be built upon the two-datagram services.

BlueCore devices contain dedicated hardware to improve performance when using BCSP. The extra information in the BCSP packet header makes this possible.

The hardware checks the packet for completeness and validity, including checksums and CRCs, and routes the payload to its destination using direct memory access (DMA). This reduces the load on the processor to one interrupt per packet with one of two potential benefits:

More processing power for other tasks

Greater opportunity for the processor to sleep and reduce current

Whether either of these benefits can be realised will depend on how the BlueCore device is used within the application.

Comparison Table

Table 2.1

Table 2.1: Host Transport Layer Comparison

compares the various UART based host transports protocols.

H3-RS232

COBS Hardware H4-UART BCSP

Physical Interface Serial Serial Serial Serial Serial Lines Required 3 or 5 5 5 3 or 5 Top Speed (Mbits/s) 0.5 1.0 1.1 1.0

Parity error Check - CRC Error Check or Better - - Recovery on Error Detection (1) (1) No (Reset) Tolerance of Lost Characters Good(1) Average(1) No Good Tolerance of Line Noise Good Good Poor Good

Works with Hardware Flow Control - Works without Hardware Flow Control - Support Host Wake-up - - - Native Support for Other Layers - - -

Note: (1) May require large buffer

bcore-rp-002Pb © Copyright CSR 2002-2004 This material is subject to CSR’s non-disclosure agreement. Page 7 of 18

Page 8: äìÉ`çêÉ UART Host Transport Summarydownload.maritex.com.pl/pdfs/wi/UART Host.pdf · Host Transport Overview _ ä ì É ` ç ê É U A R T from five to three if requ H o s t

BCSP Versions

_äìÉ`çêÉ

UA

RT H

ost Transport Summ

ary

3.1

3 BCSP Versions In small embedded applications, BCSP consumes too much RAM. CSR provides other BSSP implementations for different applications.

Currently four versions of BCSP are available:

Full version, described in the BCSP User Guide

ABCSP, designed to fit embedded applications and described in ABCSP Overview

YABCSP, designed to fit embedded applications and described in YABCSP Overview. (YABCSP was written with almost the same interface as ABCSP and shares many of its functions.)

µBCSP (MicroBCSP), designed to fit embedded applications and described in the µBCSP User Guide

ABCSP, YABCSP and µBCSP are contained in separate zip files, available on the CSR support website at www.csrsupport.com. YABCSP and µBCSP source files include examples of implementations for Microsoft Windows® systems

This section provides a summary of the characteristics and differences between ABCSP, YABCSP and µBCSP. provides a comparison between these versions of BCSP with H4. Table 3.1

ABCSP and YABCSP

ABCSP is intended for embedded applications where RAM usage is important. It requires complex integration with its host environment and is biased to minimise its consumption of the host’s resources. It complies with the BCSP specification with no restrictions; any violations of the specification should not impact any design implementation.

YABCSP is intended for use in applications that require minimum processing power. The impact of this optimisation is that it uses more and larger chunks of RAM than ABCSP. Hence, in spite of using the same memory management interface, the internal use works differently. It works on internal data buffer (which size is determined by the maximum length of the payload field of a transmitted BCSP packet).

3.1.1 ABCSP and YABCSP Implementation

Code for both ABCSP and YABCSP is divided into two sections, the source code and the interface files. These interfaces are as follows:

Code common types

Event reporting

Unrecoverable errors

Memory management

Environment’s Transmit message support

Environment’s Receive message support

Environment’s for the Timer functions

ABCSP and YABCSP do not have internal message structure and only deal with message references; therefore, a specific interface is required for message support. As all message management is delegated to the higher layers, including the message storage, a memory management interface is included. For instance, the external code is responsible for allocating the size of the buffer to the ABCSP and YABCSP engines’ requirements. The interface consists of functions to:

Access the raw bytes in a message

Obtain storage to write bytes into a message

Obtain buffer to output the UART

bcore-rp-002Pb © Copyright CSR 2002-2004 This material is subject to CSR’s non-disclosure agreement. Page 8 of 18

Page 9: äìÉ`çêÉ UART Host Transport Summarydownload.maritex.com.pl/pdfs/wi/UART Host.pdf · Host Transport Overview _ ä ì É ` ç ê É U A R T from five to three if requ H o s t

BCSP Versions

Implementing these interfaces consist in replacing macros of the source header files by external environment functions. The role of these macros is well documented in the configuration header files.

_äìÉ`çêÉ

UA

RT H

ost Transport Summ

ary

A complete description of the interfaces is available in the ABCSP Overview and the YABCSP Overview.

3.1.2 Scheduling ABCSP and YABCSP Operations

The library contains no internal scheduler; it depends on the function calls to drive the code. For example, the transmit path is driven "down" by calls to abcsp_sendmsg() and abcsp_pumptxmsgs(); these result in calls to ABCSP_UART_SENDBYTES().

Similarly, the receive path is driven "up" by calls to abcsp_uart_deliverbytes(), resulting in calls to ABCSP_UART_SENDBYTES().

abcsp library

abcsp_sendmsg()

abcsp_pumptxmsgs() ABCSP_DELIVERMSG()

ABCSP_UART_SENDBYTES() abcsp_uart_deliverbytes()

abcsp_init()

Figure 3.1: ABCSP Library Flow

3.1.3 Configuring ABCSP and YABCSP The periods of all the timers can be set separately. These periods are:

Link Establishment Tshy timer

Link Establishment Tconf timer

BCSP Acknowledgement Timeout timer

The CRC field is optional on BCSP messages

The maximum length of the payload field of a received BCSP packet

The number of BCSP messages that can be handled by the ABCSP library's transmit path at a time

3.2 µBCSP Engine

µBCSP engine is intended for very small embedded environments where the cost of providing program memory space and RAM space are the major primary concerns regarding the impact on overall system costs. µBCSP has a very simple interface and is easy to port. Link establishment is fully implemented and allows the peer reset detection and reporting.

Although µBCSP complies with the BCSP specification, it has one main restriction: the size of the sliding window is set to one packet. This use of the single window reduces the buffering requirements of BCSP and helps to simplify the complexity of the acknowledgement (ACK) scheme. The overall effect of the single window scheme is to reduce the RAM and read only memory (ROM) requirements on the host. The disadvantage of the single sliding window is on the speed of data throughput.

Note: The µBCSP engine has no timeout and retry mechanism, as this will be system specific.

bcore-rp-002Pb © Copyright CSR 2002-2004 This material is subject to CSR’s non-disclosure agreement. Page 9 of 18

Page 10: äìÉ`çêÉ UART Host Transport Summarydownload.maritex.com.pl/pdfs/wi/UART Host.pdf · Host Transport Overview _ ä ì É ` ç ê É U A R T from five to three if requ H o s t

BCSP Versions

bcore-rp-002Pb © Copyright CSR 2002-2004 This material is subject to CSR’s non-disclosure agreement. Page 10 of 18

The µBCSP Engine consists of one source file and two header files representing 600 lines of C code. This code compiles and links to:

3.2.4 Code Size

The present version of the µBCSP engine has the following configurations:

3.2.3 Configuring µBCSP

The function ubcsp_poll() needs to be processed periodically and it returns as a parameter the state of the engine. This state is represented by a variable, which can take the following values:

µBCSP is based on a polling strategy.

3.2.2 Scheduling µBCSP Operations

The µBCSP engine interface is based on four functions:

The µBCSP interface is composed of the engine interface and the UART interface.

3.2.1 Implementating µBCSP

The period to run the ubcsp_poll() has to be carefully chosen. Several parameters have to be taken into account such as baud rate, latency, presence of a FIFO, etc.

This function returns a value either showing that an immediate running of the engine is necessary or that a delay before the next process is acceptable.

µBCSP does not have any interface for message support because it does have an internal message structure. The external message structure has to fit to this internal structure. Consequently, the storage of the message payload is internal to the engine and is based on two separate buffers allocated statically. The external code has no means to control the memory management.

The UART interface is based on two functions:

ubcsp_poll()

1351 bytes for Pentium PC with no CRC

1737 bytes for Pentium PC with CRC

The CRC field is optional on BCSP messages.

The delay between the return of the polling function and the call to the appropriate µBCSP function.

UBCSP_PEER_RESET means the BlueCore device has reset.

UBCSP_PACKET_RECEIVED means a new packet was received. Another packet will not be received until the ubcsp_receive_packet() function is called again.

UBCSP_PACKET_SENT means a new packet can be sent.

put_uart()

get_uart()

ubcsp_receive_packet()

ubcsp_send_packet()

ubcsp_initialize()

_äìÉ`çêÉ

UA

RT H

ost Transport Summ

ary

Page 11: äìÉ`çêÉ UART Host Transport Summarydownload.maritex.com.pl/pdfs/wi/UART Host.pdf · Host Transport Overview _ ä ì É ` ç ê É U A R T from five to three if requ H o s t

BC

SP V

ersi

ons

_äìÉ`çêÉ UART Host Transport Summary

H

4-U

ART

BC

SPµB

CSP

AB

CSP

YAB

CSP

Phys

ical

Inte

rface

Se

rial

Seria

l Se

rial

Seria

l Se

rial

Seria

l Lin

es

Req

uire

d 5

3 or

5

3 or

5

3 or

5

3 or

5

Parit

y Er

ror C

heck

N

o Ev

en

Even

Ev

en

Even

C

RC

Erro

r Che

ck

or B

ette

r N

o

Yes(1

)Ye

s(1)

Yes(1

)Ye

s(1)

Dat

a Lo

st

Det

ectio

n N

o

Ye

sYe

sYe

sYe

s

Rec

over

y on

Erro

r D

etec

tion

No(2

)

Ye

sN

o(3)

Yes

Yes

Wor

ks w

ith

Har

dwar

e Fl

ow

Con

trol

Yes

Yes

Yes

Yes

Yes

Wor

ks w

ithou

t H

ardw

are

Flow

C

ontro

l N

o

Ye

sYe

sYe

sYe

s

Supp

orts

Hos

t W

ake-

up

No

Yes

Yes

Yes

Yes

Initi

alis

e Fu

nctio

n C

all

Init()

void

initialiseStack

BCSPStack * stack)

ubcsp_initialize()

abcsp_init()

abcsp_init()

get_uart()

ReadFile()

get_uart()

ABCSP_UART_SENDBYTES

(…)

ABCSP_UART_SENDBYTES

(…)

U

ART

API

put_uart()

WriteFile()

put_uart()

abcsp_uart_

deliverbytes (…)

abcsp_uart_

deliverbytes(…)

b

core

-rp-0

02Pb

©

Cop

yrig

ht C

SR 2

002-

2004

Th

is m

ater

ial i

s su

bjec

t to

CSR

’s n

on-d

iscl

osur

e ag

reem

ent.

Page

11

of 1

8

Page 12: äìÉ`çêÉ UART Host Transport Summarydownload.maritex.com.pl/pdfs/wi/UART Host.pdf · Host Transport Overview _ ä ì É ` ç ê É U A R T from five to three if requ H o s t

BC

SP V

ersi

ons

_äìÉ`çêÉ UART Host Transport Summary

H

4-U

ART

BC

SPµB

CSP

AB

CSP

YAB

CSP

Stac

k O

rgan

isat

ion,

Sc

hedu

ler

Dep

ends

on

the

impl

emen

tatio

n.

The

stac

k co

nsis

ts o

f a

core

gen

eric

eng

ine,

w

hich

has

four

I/O

poi

nts;

tw

o by

te-o

rient

ed b

uffe

rs

and

two

trans

fer-r

eque

st

queu

es. I

nter

nally

, the

st

ack

cont

ains

a n

umbe

r of

co-

oper

ativ

e ta

sks

whi

ch s

hare

a s

ingl

e st

ack

spac

e an

d w

hich

ar

e m

anag

ed b

y a

sim

ple

sche

dule

r. void

(*enterCS)(void

*envState)

void

(*leaveCS)(void

*envState)

Th

ese

two

func

tions

are

us

ed to

ent

er a

nd le

ave

a cr

itica

l sec

tion.

Thi

s is

re

quire

d to

saf

ely

man

age

the

trans

fer-

requ

est q

ueue

s.

void

(*signal)(void *

envState) ;

Th

e si

gnal

func

tion

is

calle

d w

hene

ver a

new

tra

nsfe

r-req

uest

is a

dded

to

a q

ueue

by

the

user

. Ty

pica

lly th

is fu

nctio

n is

us

ed to

wak

e-up

the

stac

k-th

read

.

Base

d on

a p

ollin

g sy

stem

, th

e fu

nctio

n to

cal

l reg

ular

ly

is ubcsp_poll()

. Th

e fu

nctio

n ubcsp_poll()

will

retu

rn a

par

amet

er th

at

indi

cate

s w

heth

er o

r not

BC

SP n

eeds

to d

o an

y pr

oces

sing

. It m

odifi

es a

va

riabl

e to

sig

nal t

o th

e ca

lling

func

tion

whe

ther

a

BCSP

pac

ket c

an b

e se

nt

or re

ceiv

ed. I

t is

also

the

func

tion

that

act

ually

sen

ds

or re

ceiv

es a

cha

ract

er

from

the

UAR

T.

The

envi

ronm

ent i

s re

quire

d to

pr

ovid

e a

set o

f tim

ers

to

supp

ort f

or B

CSP

’s

retra

nsm

issi

on m

echa

nism

an

d fo

r the

BC

SP li

nk-

esta

blis

hmen

t's ti

mer

s.

ABC

SP s

tack

requ

ires

that

AB

CSP

cod

e sh

ould

be

able

to

requ

est e

xter

nal c

ode

to c

all

inte

rnal

func

tions

(suc

h as

abcsp_pumptxmsgs()

). Sc

hedu

ling

oper

atio

ns is

the

resp

onsi

bilit

y of

the

deve

lope

r.

The

envi

ronm

ent i

s re

quire

d to

pr

ovid

e a

set o

f tim

ers

to

supp

ort f

or B

CSP

's

retra

nsm

issi

on m

echa

nism

an

d fo

r the

BC

SP li

nk-

esta

blis

hmen

t's ti

mer

s.

ABC

SP s

tack

requ

ires

that

AB

CSP

cod

e sh

ould

be

able

to

requ

est e

xter

nal c

ode

to c

all

inte

rnal

func

tions

(suc

h as

abcsp_pumptxmsgs()

). Sc

hedu

ling

oper

atio

ns is

the

resp

onsi

bilit

y of

the

deve

lope

r.

bco

re-rp

-002

Pb

© C

opyr

ight

CSR

200

2-20

04

This

mat

eria

l is

subj

ect t

o C

SR’s

non

-dis

clos

ure

agre

emen

t. Pa

ge 1

2 of

18

Page 13: äìÉ`çêÉ UART Host Transport Summarydownload.maritex.com.pl/pdfs/wi/UART Host.pdf · Host Transport Overview _ ä ì É ` ç ê É U A R T from five to three if requ H o s t

BC

SP V

ersi

ons

_äìÉ`çêÉ UART Host Transport Summary

H

4-U

ART

BC

SPµB

CSP

AB

CSP

YAB

CSP

Tran

smit

Fu

nctio

ns

SendACLData (…)

SendCommand (…)

SendSCOData (…)

uint16

numFreeSlotsInRec

eiveBuffer(BCSPSt

ack * stack)

void

writeByteToReceiv

eBuffer(BCSPStack

* stack,uint8

data)

ubcsp_send_packet

(…)

µBC

SP u

ses

a w

indo

w

size

of o

ne p

acke

t th

eref

ore

only

one

pac

ket

can

be s

ent a

t a ti

me.

The

ov

eral

l effe

ct o

f the

sin

gle

win

dow

sch

eme

is to

re

duce

the

RAM

and

RO

M

requ

irem

ents

on

the

host

..

To s

end

a m

essa

ge, h

ighe

r la

yer c

ode

calls

abcsp_sendmsg()

; thi

s pl

aces

the

mes

sage

into

a

queu

e w

ithin

the

libra

ry. T

he

high

er la

yer c

ode

then

re

peat

edly

cal

ls

abcsp_pumptxmsgs()

to

trans

late

the

mes

sage

into

its

BCSP

wire

form

at a

nd p

ush

thes

e by

tes

out o

f the

bot

tom

of

the

libra

ry v

ia

ABCSP_UART_SENDBYTES

()

.

To s

end

a m

essa

ge, h

ighe

r la

yer c

ode

calls

abcsp_sendmsg()

; thi

s pl

aces

the

mes

sage

into

a

queu

e w

ithin

the

libra

ry. T

he

high

er la

yer c

ode

then

re

peat

edly

cal

ls

abcsp_pumptxmsgs()

to

trans

late

the

mes

sage

into

its

BCSP

wire

form

at a

nd p

ush

thes

e by

tes

out o

f the

bot

tom

of

the

libra

ry v

ia

ABCSP_UART_SENDBYTES

()

.

Rec

eive

Fu

nctio

ns

RecvCommand (…)

RecvACLData (…)

RecvSCOData (…)

uint16

numBytesInTransmi

tBuffer(BCSPStack

* stack);

uint8

readByteFromTrans

mitBuffer(BCSPSta

ck * stack);

If th

e ac

tivity

arg

umen

t in

dica

tes

a pa

cket

was

re

ceiv

ed, t

hen

this

pac

ket

need

s to

be

proc

esse

d in

an

ext

erna

l fun

ctio

n.

It w

ill th

en s

et-u

p th

e en

gine

to re

ceiv

e an

othe

r pa

cket

by

callin

g ubcsp_receive_pack

et()

.

For i

nbou

nd m

essa

ges

the

UAR

T dr

iver

cod

e pa

sses

BC

SP w

ire fo

rmat

byt

es in

to

the

libra

ry v

ia c

alls

to

abcsp_uart_deliverby

tes()

. Whe

n th

e lib

rary

has

al

l of t

he b

ytes

to fo

rm a

co

mpl

ete

high

er la

yer

mes

sage

it c

alls

ABCSP_DELIVERMSG()

to

pass

this

to h

ighe

r lay

er c

ode.

For i

nbou

nd m

essa

ges

the

UAR

T dr

iver

cod

e pa

sses

BC

SP w

ire fo

rmat

byt

es in

to

the

libra

ry v

ia c

alls

to

abcsp_uart_deliverby

tes()

. Whe

n th

e lib

rary

has

al

l of t

he b

ytes

to fo

rm a

co

mpl

ete

high

er la

yer

mes

sage

it c

alls

ABCSP_DELIVERMSG()

to

pass

this

to h

ighe

r lay

er c

ode.

bco

re-rp

-002

Pb

© C

opyr

ight

CSR

200

2-20

04

This

mat

eria

l is

subj

ect t

o C

SR’s

non

-dis

clos

ure

agre

emen

t. Pa

ge 1

3 of

18

Page 14: äìÉ`çêÉ UART Host Transport Summarydownload.maritex.com.pl/pdfs/wi/UART Host.pdf · Host Transport Overview _ ä ì É ` ç ê É U A R T from five to three if requ H o s t

BC

SP V

ersi

ons

_äìÉ`çêÉ UART Host Transport Summary

H

4-U

ART

BC

SPµB

CSP

AB

CSP

YAB

CSP

Rec

over

y M

echa

nism

N

o Ba

sed

on re

trans

mit

stra

tegy

. St

ack

inte

rnal

sch

edul

er

is in

cha

rge

of th

e re

trans

mis

sion

, all

the

timer

s fu

nctio

ns a

re

impl

emen

ted.

The

refo

re,

no ti

mer

s in

terfa

ce.

Poss

ible

, but

not

im

plem

ente

d. T

here

is n

o re

trans

mis

sion

mec

hani

sm

impl

emen

ted

ther

efor

e th

ere

are

no ti

mer

s.

Base

d on

retra

nsm

it st

rate

gy.

(The

env

ironm

ent i

s re

quire

d to

pro

vide

a ti

mer

for B

CSP

's

retra

nsm

issi

on m

echa

nism

). AB

CSP

relia

ble

mes

sage

s ar

e pl

aced

in a

que

ue w

hich

can

gr

ow to

a fi

xed

max

imum

le

ngth

that

mat

ches

the

BCSP

tra

nsm

it w

indo

w s

ize.

Base

d on

retra

nsm

it st

rate

gy.

(The

env

ironm

ent i

s re

quire

d to

pro

vide

a ti

mer

for B

CSP

's

retra

nsm

issi

on m

echa

nism

). AB

CSP

relia

ble

mes

sage

s ar

e pl

aced

in a

que

ue w

hich

can

gr

ow to

a fi

xed

max

imum

le

ngth

that

mat

ches

the

BCSP

tra

nsm

it w

indo

w s

ize.

M

emor

y M

anag

emen

t D

epen

ds o

n th

e im

plem

enta

tion

void *

(*allocMem)(void

* envState,uint32

size)

; void

(*freeMem)(void *

envState,void*)

; Th

ese

two

func

tions

are

us

ed to

allo

cate

and

free

m

emor

y.

Stor

age

of th

e m

essa

ge

payl

oad

is in

tern

al to

the

engi

ne (b

ased

on

two

sepa

rate

buf

fers

allo

cate

d st

atic

ally

one

for t

rans

mit

and

one

for r

ecei

ve) w

hich

re

duce

s th

e co

de s

ize.

Del

egat

e al

l the

mem

ory

man

agem

ent t

o ex

tern

al c

ode;

it

asks

for a

cces

s to

ext

erna

l bu

ffers

: via

ABCSP_xxMSG_GETBUF()

. Se

t of f

unct

ions

for t

his

purp

ose

need

s to

be

writ

ten

by

the

deve

lope

r. Ex

tern

al c

ode

choo

ses

the

size

of t

he re

turn

ed b

uffe

r (if

a bu

ffer i

s av

aila

ble!

).

Del

egat

e al

l the

mem

ory

man

agem

ent t

o ex

tern

al c

ode;

it

asks

for a

cces

s to

ext

erna

l bu

ffers

: via

ABCSP_xxMSG_GETBUF()

. Se

t of f

unct

ions

for t

his

purp

ose

need

s to

be

writ

ten

by

the

deve

lope

r.

Deb

ug M

essa

ges

Dep

ends

on

the

impl

emen

tatio

n Se

vera

l typ

es o

f mac

ros

are

used

for d

ebug

ging

. Li

nk E

stab

lishm

ent a

nd

Erro

r mes

sage

s R

epor

t sig

nific

ant e

vent

s to

the

exte

rnal

env

ironm

ent,

two

cate

gorie

s in

form

ativ

e an

d pa

nic

even

ts.

Rep

ort s

igni

fican

t eve

nts

to th

e ex

tern

al e

nviro

nmen

t, tw

o ca

tego

ries

info

rmat

ive

and

pani

c ev

ents

. b

core

-rp-0

02Pb

©

Cop

yrig

ht C

SR 2

002-

2004

Th

is m

ater

ial i

s su

bjec

t to

CSR

’s n

on-d

iscl

osur

e ag

reem

ent.

Page

14

of 1

8

Page 15: äìÉ`çêÉ UART Host Transport Summarydownload.maritex.com.pl/pdfs/wi/UART Host.pdf · Host Transport Overview _ ä ì É ` ç ê É U A R T from five to three if requ H o s t

_äìÉ`çêÉ UART Host Transport Summary

BC

SP V

ersi

ons

bco

re-rp

-002

Pb

© C

opyr

ight

CSR

200

2-20

04

This

mat

eria

l is

subj

ect t

o C

SR’s

non

-dis

clos

ure

agre

emen

t. Pa

ge 1

5 of

18

H

4-U

T B

CSP

B

CSP

Y

BC

SP

ARµB

CSP

A

A

Con

figur

atio

n D

epen

ds o

n th

e im

plem

enta

tion.

Pa

cket

ack

now

ledg

emen

t tim

eout

. Tr

ansm

it w

indo

w s

ize

(in

pack

ets)

. (M

inim

um v

alue

is

1. M

axim

um v

alue

is

the

rang

e of

the

ACK

Fiel

d, m

inus

one

.) N

umbe

r of t

imes

a

mes

sage

is re

sent

bef

ore

decl

arin

g th

e lin

k ha

s fa

iled.

C

RC

fiel

d is

opt

iona

l on

BCSP

mes

sage

s.

The

dela

y be

twee

n th

e re

turn

of t

he p

ollin

g fu

nctio

n an

d th

e ca

ll to

the

appr

opria

te µ

BCSP

fu

nctio

n.

The

CR

C fi

eld

is o

ptio

nal

on B

CSP

mes

sage

s.

The

perio

ds o

f all

the

timer

s ca

n be

set

sep

arat

ely

(Lin

k Es

tabl

ishm

ent T

shy t

imer

, Lin

k Es

tabl

ishm

ent T

conf ti

mer

, and

BC

SP A

ckno

wle

dgm

ent

Tim

eout

tim

er).

CR

C fi

eld

is o

ptio

nal o

n BC

SP

mes

sage

s.

Max

imum

leng

th o

f the

pa

yloa

d fie

ld o

f a re

ceiv

ed

BCSP

pac

ket.

Num

ber o

f BC

SP m

essa

ges

that

can

be

hand

led

by th

e AB

CSP

libr

ary'

s tra

nsm

it pa

th

at a

tim

e.

The

perio

ds o

f all

the

timer

s ca

n be

set

sep

arat

ely

(Lin

k Es

tabl

ishm

ent T

shy t

imer

, Lin

k Es

tabl

ishm

ent T

conf ti

mer

, and

BC

SP A

ckno

wle

dgm

ent

Tim

eout

tim

er).

The

CR

C fi

eld

is o

ptio

nal o

n BC

SP m

essa

ges.

M

axim

um le

ngth

of p

aylo

ad

field

of a

rece

ived

BC

SP

pack

et a

nd s

ize

of in

tern

al

buffe

r for

UAR

T ou

tput

. N

umbe

r of B

CSP

mes

sage

s th

at c

an b

e ha

ndle

d by

the

ABC

SP li

brar

y's

trans

mit

path

at

a ti

me.

C

ode

Size

D

epen

ds o

n th

e im

plem

enta

tion.

D

esig

ned

to ru

n on

a

host

sys

tem

with

at l

east

60

0 by

tes

of R

AM a

nd

appr

oxim

atel

y 58

kb to

8k

b of

RO

M.

Com

pose

d of

two

files

(one

so

urce

and

one

hea

der).

R

epre

sent

ing

abou

t 600

lin

es o

f C c

ode.

C

ompi

led

unde

r Pen

tium

it

repr

esen

ts 1

700

byte

s w

ith

CR

C a

nd w

ithou

t CR

C

abou

t 130

0 by

tes.

Com

pose

d of

36

files

into

th

ree

dire

ctor

ies.

Rep

rese

ntin

g ab

out 1

700

lines

of C

cod

e.

Com

pile

d un

der P

entiu

m it

re

pres

ents

abo

ut 2

500

byte

s w

ith C

RC

.

Com

pile

d un

der A

RM

AD

S 1.

1 it

repr

esen

ts a

bout

700

0 by

tes

with

CR

C.

Tabl

e 3.

1: C

ompa

rison

Bet

wee

n B

CSP

Var

iant

s an

d H

4

(3)

Unl

ess

reco

very

stra

tegy

is im

plem

ente

d

(2)

Res

et n

eces

sary

Not

e: (1)

Opt

iona

l

Page 16: äìÉ`çêÉ UART Host Transport Summarydownload.maritex.com.pl/pdfs/wi/UART Host.pdf · Host Transport Overview _ ä ì É ` ç ê É U A R T from five to three if requ H o s t

Document References

_äìÉ`çêÉ

UA

RT H

ost Transport Summ

ary

4 Document References Document Reference

Specification of the Bluetooth System V1.1, 22 February 2001 and v1.2, 05 November 2003 BlueCore Serial Protocol (BCSP) bcore-sp-012P BCSP Channel Allocations bcore-sp-007P BCSP Link Establishment Protocol bcore-sp-008P ABCSP Overview CSR document AN111 YABCSP Overview CSR document bcore-an-012P

µBCSP User Guide CSR document bcor-ug-001P

bcore-rp-002Pb © Copyright CSR 2002-2004 This material is subject to CSR’s non-disclosure agreement. Page 16 of 18

Page 17: äìÉ`çêÉ UART Host Transport Summarydownload.maritex.com.pl/pdfs/wi/UART Host.pdf · Host Transport Overview _ ä ì É ` ç ê É U A R T from five to three if requ H o s t

Acronyms and Definitions

_äìÉ`çêÉ

UA

RT H

ost Transport Summ

ary

Acronyms and Definitions ABCSP Another BlueCore Serial Protocol ACK ACKnowledge ACL Asynchronous Connection-Less BCSP BlueCore Serial Protocol BlueCore Group term for CSR’s range of Bluetooth wireless technology chips Bluetooth® Set of technologies providing audio and data transfer over short-range radio connections Bluetooth SIG Bluetooth Special Interest Group COBS Consistent Overhead Byte Stuffing CRC Cyclic Redundancy Check CSR Cambridge Silicon Radio CTS Clear to Send DMA Direct Memory Access FIFO First In, First Out HC Host Controller HCI Host Controller Interface L2CAP Logical Link Control and Adaptation Protocol (protocol layer)

µBCSP “Micro” BlueCore Serial Protocol

PC Personal Computer RAM Random Access Memory RFCOMM RF Communications ROM Read Only Memory RS232 Serial communications standard RTS Ready To Send Rx Receive/Receiver SCO Synchronous Connection-Oriented Tx Transmit/Transmitter UART Universal Asynchronous Receiver Transmitter

bcore-rp-002Pb © Copyright CSR 2002-2004 This material is subject to CSR’s non-disclosure agreement. Page 17 of 18

Page 18: äìÉ`çêÉ UART Host Transport Summarydownload.maritex.com.pl/pdfs/wi/UART Host.pdf · Host Transport Overview _ ä ì É ` ç ê É U A R T from five to three if requ H o s t

Record of Changes

bcore-rp-002Pb © Copyright CSR 2002-2004 This material is subject to CSR’s non-disclosure agreement. Page 18 of 18

_äìÉ`çêÉ

UA

RT H

ost Transport Summ

ary

Record of Changes Date: Revision Reason for Change:

01 MAY 02 a Original publication of this document (CSR reference: bcore-rp-002Pa) 09 FEB 04 b Updated to include YABCSP (CSR reference: bcore-rp-002Pb)

UART Host Transport Summary

bcore-rp-002Pb

February 2004

Bluetooth® and the Bluetooth logos are trademarks owned by Bluetooth SIG, Inc. and licensed to CSR.

_äìÉ`çêÉ is a trademark of CSR.

All other product, service and company names are trademarks, registered trademarks or service marks of their respective owners.

CSR’s products are not authorised for use in life-support or safety-critical applications.