3
* BlueZ - Bluetooth protocol stack for Linux
5
* Copyright (C) 2000-2005 CSR Ltd.
8
* Permission is hereby granted, free of charge, to any person obtaining
9
* a copy of this software and associated documentation files (the
10
* "Software"), to deal in the Software without restriction, including
11
* without limitation the rights to use, copy, modify, merge, publish,
12
* distribute, sublicense, and/or sell copies of the Software, and to
13
* permit persons to whom the Software is furnished to do so, subject to
14
* the following conditions:
16
* The above copyright notice and this permission notice shall be included
17
* in all copies or substantial portions of the Software.
19
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
20
* EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
21
* MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT.
22
* IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY
23
* CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT,
24
* TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE
25
* SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
29
#ifndef UBCSP_INCLUDE_H
30
#define UBCSP_INCLUDE_H
32
/*****************************************************************************/
33
/*****************************************************************************/
34
/*****************************************************************************/
38
/** MicroBCSP - a very low cost implementation of the BCSP protocol **/
40
/*****************************************************************************/
42
/* If we wish to use CRC's, then change 0 to 1 in the next line */
45
/* Define some basic types - change these for your architecture */
46
typedef unsigned char uint8;
47
typedef unsigned short uint16;
48
typedef unsigned int uint32;
49
typedef signed char int8;
50
typedef signed short int16;
51
typedef signed int int32;
53
/* The defines below require a printf function to be available */
55
/* Do we want to show packet errors in debug output */
56
#define SHOW_PACKET_ERRORS 0
58
/* Do we want to show Link Establishment State transitions in debug output */
59
#define SHOW_LE_STATES 0
61
/*****************************************************************************/
65
/** This is description of a bcsp packet for the upper layer **/
67
/*****************************************************************************/
71
uint8 channel; /* Which Channel this packet is to/from */
72
uint8 reliable; /* Is this packet reliable */
73
uint8 use_crc; /* Does this packet use CRC data protection */
74
uint16 length; /* What is the length of the payload data */
75
uint8 *payload; /* The payload data itself - size of length */
78
/*****************************************************************************/
80
/** ubcsp_configuration **/
82
/** This is the main configuration of the ubcsp engine **/
83
/** All state variables are stored in this structure **/
85
/*****************************************************************************/
87
enum ubcsp_link_establishment_state
89
ubcsp_le_uninitialized,
94
enum ubcsp_link_establishment_packet
103
struct ubcsp_configuration
105
uint8 link_establishment_state;
106
uint8 link_establishment_resp;
107
uint8 link_establishment_packet;
109
uint8 sequence_number:3;
112
struct ubcsp_packet *send_packet;
113
struct ubcsp_packet *receive_packet;
115
uint8 receive_header_checksum;
116
uint8 receive_slip_escape;
119
uint8 send_header_checksum;
124
uint8 send_slip_escape;
128
uint8 *next_send_ptr;
129
int32 next_send_size;
134
/*****************************************************************************/
136
/** ubcsp_poll sets activity from an OR of these flags **/
138
/*****************************************************************************/
140
#define UBCSP_PACKET_SENT 0x01
141
#define UBCSP_PACKET_RECEIVED 0x02
142
#define UBCSP_PEER_RESET 0x04
143
#define UBCSP_PACKET_ACK 0x08
145
/*****************************************************************************/
147
/** This is the functional interface for ucbsp **/
149
/*****************************************************************************/
151
void ubcsp_initialize (void);
152
void ubcsp_send_packet (struct ubcsp_packet *send_packet);
153
void ubcsp_receive_packet (struct ubcsp_packet *receive_packet);
154
uint8 ubcsp_poll (uint8 *activity);
156
/*****************************************************************************/
158
/** Slip Escape Values **/
160
/*****************************************************************************/
162
#define SLIP_FRAME 0xC0
163
#define SLIP_ESCAPE 0xDB
164
#define SLIP_ESCAPE_FRAME 0xDC
165
#define SLIP_ESCAPE_ESCAPE 0xDD
167
/*****************************************************************************/
168
/*****************************************************************************/
169
/*****************************************************************************/
171
/*****************************************************************************/
173
/** These functions need to be linked into your system **/
175
/*****************************************************************************/
177
/*****************************************************************************/
179
/** put_uart outputs a single octet over the UART Tx line **/
181
/*****************************************************************************/
183
extern void put_uart (uint8);
185
/*****************************************************************************/
187
/** get_uart receives a single octet over the UART Rx line **/
188
/** if no octet is available, then this returns 0 **/
189
/** if an octet was read, then this is returned in the argument and **/
190
/** the function returns 1 **/
192
/*****************************************************************************/
194
extern uint8 get_uart (uint8 *);
196
/*****************************************************************************/
198
/** These defines should be changed to your systems concept of 100ms **/
200
/*****************************************************************************/
202
#define UBCSP_POLL_TIME_IMMEDIATE 0
203
#define UBCSP_POLL_TIME_DELAY 25
205
/*****************************************************************************/
206
/*****************************************************************************/
207
/*****************************************************************************/