1 /* $NetBSD: bcsp.h,v 1.1 2007/09/30 04:07:42 kiyohara Exp $ */
3 * Copyright (c) 2007 KIYOHARA Takashi
6 * Redistribution and use in source and binary forms, with or without
7 * modification, are permitted provided that the following conditions
9 * 1. Redistributions of source code must retain the above copyright
10 * notice, this list of conditions and the following disclaimer.
11 * 2. Redistributions in binary form must reproduce the above copyright
12 * notice, this list of conditions and the following disclaimer in the
13 * documentation and/or other materials provided with the distribution.
15 * THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR
16 * IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
17 * WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
18 * DISCLAIMED. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT,
19 * INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
20 * (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR
21 * SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
22 * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT,
23 * STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN
24 * ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
25 * POSSIBILITY OF SUCH DAMAGE.
28 #ifndef _DEV_BLUETOOTH_BCSP_H_
29 #define _DEV_BLUETOOTH_BCSP_H_
32 * BlueCore Serial Protocol definitions
36 * Reference to bcore-sp-012p.
38 /* BCSP packet header */
41 #if BYTE_ORDER == BIG_ENDIAN
42 uint8_t plen1
:4; /* Payload Length (bits 0-3) */
43 uint8_t ident
:4; /* Protocol Identifier */
45 uint8_t ident
:4; /* Protocol Identifier */
46 uint8_t plen1
:4; /* Payload Length (bits 0-3) */
48 uint8_t plen2
; /* Payload Length (bits 4-11) */
49 uint8_t csum
; /* Checksum */
51 } __packed bcsp_hdr_t
;
53 #define BCSP_FLAGS_SEQ_SHIFT 0
54 #define BCSP_FLAGS_SEQ_MASK 0x07
55 #define BCSP_FLAGS_SEQ(n) \
56 (((n) & BCSP_FLAGS_SEQ_MASK) >> BCSP_FLAGS_SEQ_SHIFT)
57 #define BCSP_FLAGS_ACK_SHIFT 3
58 #define BCSP_FLAGS_ACK_MASK 0x38
59 #define BCSP_FLAGS_ACK(n) \
60 (((n) & BCSP_FLAGS_ACK_MASK) >> BCSP_FLAGS_ACK_SHIFT)
61 #define BCSP_FLAGS_CRC_PRESENT 0x40
62 #define BCSP_FLAGS_PROTOCOL_TYPE 0x80
63 #define BCSP_FLAGS_PROTOCOL_REL 0x80
65 #define BCSP_SET_PLEN(hdrp, n) \
67 (hdrp)->plen1 = ((n) & 0x00f); \
68 (hdrp)->plen2 = ((n) >> 4); \
70 #define BCSP_GET_PLEN(hdrp) ((hdrp)->plen1 | ((hdrp)->plen2 << 4))
72 #define BCSP_GET_CSUM(hdrp) \
73 (0xff - (uint8_t)((hdrp)->flags + ((hdrp)->plen1 << 4) + \
74 (hdrp)->ident + (hdrp)->plen2))
75 #define BCSP_SET_CSUM(hdrp) ((hdrp)->csum = BCSP_GET_CSUM(hdrp))
78 #define BCSP_IDENT_ACKPKT 0 /* Used by MUX Layer */
79 /* Other Protocol Identifier values described to bcore-sp-007P */
82 /* definitions of SLIP Layer */
83 #define BCSP_SLIP_PKTSTART 0xc0
84 #define BCSP_SLIP_PKTEND BCSP_SLIP_PKTSTART
85 #define BCSP_SLIP_ESCAPE 0xdb
86 #define BCSP_SLIP_ESCAPE_PKTEND 0xdc
87 #define BCSP_SLIP_ESCAPE_ESCAPE 0xdd
90 /* definitions of Sequencing Layer */
91 #define BCSP_SEQ_TX_TIMEOUT (hz / 4) /* 250 msec */
92 #define BCSP_SEQ_TX_WINSIZE 4
93 #define BCSP_SEQ_TX_RETRY_LIMIT 20
97 * Reference to bcore-sp-007p.
100 #define BCSP_CHANNEL_LE 1 /* defined in [BCSPLE] */
101 #define BCSP_CHANNEL_BCCMD 2 /* defined in [BCCMD] */
102 #define BCSP_CHANNEL_HQ 3 /* defined in [HQ] */
103 #define BCSP_CHANNEL_DEVMGT 4 /* defined by BlueStack */
104 #define BCSP_CHANNEL_HCI_CMDEVT 5 /* HCI Command and Event */
105 #define BCSP_CHANNEL_HCI_ACL 6 /* HCI ACL data */
106 #define BCSP_CHANNEL_HCI_SCO 7 /* HCI SCO data */
107 #define BCSP_CHANNEL_L2CAP 8 /* defined by BlueStack */
108 #define BCSP_CHANNEL_RFCOMM 9 /* defined by BlueStack */
109 #define BCSP_CHANNEL_SDP 10 /* defined by BlueStack */
111 #define BCSP_CHANNEL_DFU 12 /* defined in [DFUPROT] */
112 #define BCSP_CHANNEL_VM 13 /* Virtual Machine */
116 * Reference to bcore-sp-008p ??
117 * Link Establishment Protocol
125 #define BCSP_LE_SYNC { 0xda, 0xdc, 0xed, 0xed }
126 #define BCSP_LE_SYNCRESP { 0xac, 0xaf, 0xef, 0xee }
127 #define BCSP_LE_CONF { 0xad, 0xef, 0xac, 0xed }
128 #define BCSP_LE_CONFRESP { 0xde, 0xad, 0xd0, 0xd0 }
130 #define BCSP_LE_TSHY_TIMEOUT hz /* XXXX: 1sec ? */
131 #define BCSP_LE_TCONF_TIMEOUT hz /* XXXX: 1sec ? */
133 #endif /* !_DEV_BLUETOOTH_BCSP_H_ */