Skip to content
GitLab
Projects
Groups
Snippets
Help
Loading...
Help
What's new
10
Help
Support
Community forum
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in
Toggle navigation
Open sidebar
Erik Strand
lufa
Commits
2793c88f
Commit
2793c88f
authored
Jun 05, 2009
by
Dean Camera
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Add master device Host demo makefile.
Copy and convert incomplete Bluetooth Host demo to the library.
parent
d47df1cd
Changes
18
Expand all
Show whitespace changes
Inline
Side-by-side
Showing
18 changed files
with
2558 additions
and
3 deletions
+2558
-3
Demos/Device/ClassDriver/AudioInput/AudioInput.h
Demos/Device/ClassDriver/AudioInput/AudioInput.h
+0
-1
Demos/Device/ClassDriver/AudioOutput/AudioOutput.h
Demos/Device/ClassDriver/AudioOutput/AudioOutput.h
+0
-1
Demos/Host/Incomplete/BluetoothHost/BluetoothACLPackets.c
Demos/Host/Incomplete/BluetoothHost/BluetoothACLPackets.c
+200
-0
Demos/Host/Incomplete/BluetoothHost/BluetoothACLPackets.h
Demos/Host/Incomplete/BluetoothHost/BluetoothACLPackets.h
+121
-0
Demos/Host/Incomplete/BluetoothHost/BluetoothClassCodes.h
Demos/Host/Incomplete/BluetoothHost/BluetoothClassCodes.h
+110
-0
Demos/Host/Incomplete/BluetoothHost/BluetoothHCICommands.c
Demos/Host/Incomplete/BluetoothHost/BluetoothHCICommands.c
+377
-0
Demos/Host/Incomplete/BluetoothHost/BluetoothHCICommands.h
Demos/Host/Incomplete/BluetoothHost/BluetoothHCICommands.h
+190
-0
Demos/Host/Incomplete/BluetoothHost/BluetoothHost.c
Demos/Host/Incomplete/BluetoothHost/BluetoothHost.c
+206
-0
Demos/Host/Incomplete/BluetoothHost/BluetoothHost.h
Demos/Host/Incomplete/BluetoothHost/BluetoothHost.h
+95
-0
Demos/Host/Incomplete/BluetoothHost/BluetoothStack.c
Demos/Host/Incomplete/BluetoothHost/BluetoothStack.c
+88
-0
Demos/Host/Incomplete/BluetoothHost/BluetoothStack.h
Demos/Host/Incomplete/BluetoothHost/BluetoothStack.h
+96
-0
Demos/Host/Incomplete/BluetoothHost/ConfigDescriptor.c
Demos/Host/Incomplete/BluetoothHost/ConfigDescriptor.c
+139
-0
Demos/Host/Incomplete/BluetoothHost/ConfigDescriptor.h
Demos/Host/Incomplete/BluetoothHost/ConfigDescriptor.h
+58
-0
Demos/Host/Incomplete/BluetoothHost/DeviceDescriptor.c
Demos/Host/Incomplete/BluetoothHost/DeviceDescriptor.c
+66
-0
Demos/Host/Incomplete/BluetoothHost/DeviceDescriptor.h
Demos/Host/Incomplete/BluetoothHost/DeviceDescriptor.h
+56
-0
Demos/Host/Incomplete/BluetoothHost/makefile
Demos/Host/Incomplete/BluetoothHost/makefile
+737
-0
Demos/Host/makefile
Demos/Host/makefile
+18
-0
LUFA.pnproj
LUFA.pnproj
+1
-1
No files found.
Demos/Device/ClassDriver/AudioInput/AudioInput.h
View file @
2793c88f
...
@@ -60,7 +60,6 @@
...
@@ -60,7 +60,6 @@
/** Maximum ADC range for the microphone input. */
/** Maximum ADC range for the microphone input. */
#define ADC_MAX_RANGE 0x3FF
#define ADC_MAX_RANGE 0x3FF
/* Macros: */
/** LED mask for the library LED driver, to indicate that the USB interface is not ready. */
/** LED mask for the library LED driver, to indicate that the USB interface is not ready. */
#define LEDMASK_USB_NOTREADY LEDS_LED1
#define LEDMASK_USB_NOTREADY LEDS_LED1
...
...
Demos/Device/ClassDriver/AudioOutput/AudioOutput.h
View file @
2793c88f
...
@@ -98,7 +98,6 @@
...
@@ -98,7 +98,6 @@
#define CSx0 CS10
#define CSx0 CS10
#endif
#endif
/* Macros: */
/** LED mask for the library LED driver, to indicate that the USB interface is not ready. */
/** LED mask for the library LED driver, to indicate that the USB interface is not ready. */
#define LEDMASK_USB_NOTREADY LEDS_LED1
#define LEDMASK_USB_NOTREADY LEDS_LED1
...
...
Demos/Host/Incomplete/BluetoothHost/BluetoothACLPackets.c
0 → 100644
View file @
2793c88f
/*
LUFA Library
Copyright (C) Dean Camera, 2009.
dean [at] fourwalledcubicle [dot] com
www.fourwalledcubicle.com
*/
/*
Copyright 2009 Dean Camera (dean [at] fourwalledcubicle [dot] com)
Permission to use, copy, modify, and distribute this software
and its documentation for any purpose and without fee is hereby
granted, provided that the above copyright notice appear in all
copies and that both that the copyright notice and this
permission notice and warranty disclaimer appear in supporting
documentation, and that the name of the author not be used in
advertising or publicity pertaining to distribution of the
software without specific, written prior permission.
The author disclaim all warranties with regard to this
software, including all implied warranties of merchantability
and fitness. In no event shall the author be liable for any
special, indirect or consequential damages or any damages
whatsoever resulting from loss of use, data or profits, whether
in an action of contract, negligence or other tortious action,
arising out of or in connection with the use or performance of
this software.
*/
#define INCLUDE_FROM_BLUETOOTH_ACLPACKETS_C
#include "BluetoothACLPackets.h"
void
Bluetooth_ProcessACLPackets
(
void
)
{
Bluetooth_ACL_Header_t
ACLPacketHeader
;
Pipe_SelectPipe
(
BLUETOOTH_DATA_IN_PIPE
);
Pipe_SetToken
(
PIPE_TOKEN_IN
);
Pipe_Unfreeze
();
if
(
!
(
Pipe_IsReadWriteAllowed
()))
{
Pipe_Freeze
();
return
;
}
Pipe_Read_Stream_LE
(
&
ACLPacketHeader
,
sizeof
(
ACLPacketHeader
));
Bluetooth_DataPacket_Header_t
DataHeader
;
Pipe_Read_Stream_LE
(
&
DataHeader
,
sizeof
(
DataHeader
));
BT_DEBUG
(
"(ACL) Packet Received"
,
NULL
);
BT_DEBUG
(
"(ACL) -- Connection Handle: 0x%04X"
,
ACLPacketHeader
.
ConnectionHandle
);
BT_DEBUG
(
"(ACL) -- Data Length: 0x%04X"
,
ACLPacketHeader
.
DataLength
);
BT_DEBUG
(
"(ACL) -- Destination Channel: 0x%04X"
,
DataHeader
.
DestinationChannel
);
BT_DEBUG
(
"(ACL) -- Payload Length: 0x%04X"
,
DataHeader
.
PayloadLength
);
if
(
DataHeader
.
DestinationChannel
==
BLUETOOTH_CHANNEL_SIGNALING
)
{
Bluetooth_SignalCommand_Header_t
SignalCommandHeader
;
Pipe_Read_Stream_LE
(
&
SignalCommandHeader
,
sizeof
(
SignalCommandHeader
));
switch
(
SignalCommandHeader
.
Code
)
{
case
BLUETOOTH_SIGNAL_CONNECTION_REQUEST
:
Bluetooth_ProcessSignalPacket_ConnectionRequest
(
&
ACLPacketHeader
,
&
DataHeader
,
&
SignalCommandHeader
);
break
;
case
BLUETOOTH_SIGNAL_CONFIGURATION_REQUEST
:
Bluetooth_ProcessSignalPacket_ConfigurationRequest
(
&
ACLPacketHeader
,
&
DataHeader
,
&
SignalCommandHeader
);
break
;
default:
BT_DEBUG
(
"(ACL) >> Unknown Signalling Command 0x%02X"
,
SignalCommandHeader
.
Code
);
Pipe_Discard_Stream
(
ACLPacketHeader
.
DataLength
);
Pipe_ClearIN
();
Pipe_Freeze
();
break
;
}
}
else
{
uint8_t
DataPayload
[
DataHeader
.
PayloadLength
];
Pipe_Read_Stream_LE
(
&
DataPayload
,
sizeof
(
DataPayload
));
DataHeader
.
PayloadLength
=
0
;
BT_DEBUG
(
"(ACL) -- Data Payload: "
,
NULL
);
for
(
uint16_t
B
=
0
;
B
<
sizeof
(
DataPayload
);
B
++
)
printf
(
"0x%02X "
,
DataPayload
[
B
]);
BT_DEBUG
(
""
,
NULL
);
Pipe_Discard_Stream
(
ACLPacketHeader
.
DataLength
);
Pipe_ClearIN
();
Pipe_Freeze
();
}
}
static
inline
void
Bluetooth_ProcessSignalPacket_ConnectionRequest
(
Bluetooth_ACL_Header_t
*
ACLPacketHeader
,
Bluetooth_DataPacket_Header_t
*
DataHeader
,
Bluetooth_SignalCommand_Header_t
*
SignalCommandHeader
)
{
Bluetooth_SignalCommand_ConnectionRequest_t
ConnectionRequest
;
Pipe_Read_Stream_LE
(
&
ConnectionRequest
,
sizeof
(
ConnectionRequest
));
BT_DEBUG
(
"(ACL) >> L2CAP Connection Request"
,
NULL
);
BT_DEBUG
(
"(ACL) -- PSM: 0x%04X"
,
ConnectionRequest
.
PSM
);
BT_DEBUG
(
"(ACL) -- Source Channel: 0x%04X"
,
ConnectionRequest
.
SourceChannel
);
Pipe_ClearIN
();
Pipe_Freeze
();
Pipe_SelectPipe
(
BLUETOOTH_DATA_OUT_PIPE
);
Pipe_SetToken
(
PIPE_TOKEN_OUT
);
Pipe_Unfreeze
();
Bluetooth_SignalCommand_ConnectionResponse_t
ConnectionResponse
;
ACLPacketHeader
->
DataLength
=
sizeof
(
*
DataHeader
)
+
sizeof
(
*
SignalCommandHeader
)
+
sizeof
(
ConnectionResponse
);
DataHeader
->
PayloadLength
=
sizeof
(
*
SignalCommandHeader
)
+
sizeof
(
ConnectionResponse
);
DataHeader
->
DestinationChannel
=
BLUETOOTH_CHANNEL_SIGNALING
;
SignalCommandHeader
->
Code
=
BLUETOOTH_SIGNAL_CONNECTION_RESPONSE
;
SignalCommandHeader
->
Length
=
sizeof
(
ConnectionResponse
);
Bluetooth_Channel_t
*
ChannelData
=
Bluetooth_InitChannelData
(
ConnectionRequest
.
SourceChannel
,
ConnectionRequest
.
PSM
);
ConnectionResponse
.
Result
=
(
ChannelData
==
NULL
)
?
BLUETOOTH_CONNECTION_REFUSED_RESOURCES
:
BLUETOOTH_CONNECTION_SUCCESSFUL
;
ConnectionResponse
.
DestinationChannel
=
ChannelData
->
LocalNumber
;
ConnectionResponse
.
SourceChannel
=
ChannelData
->
RemoteNumber
;
ConnectionResponse
.
Status
=
0x00
;
Pipe_Write_Stream_LE
(
ACLPacketHeader
,
sizeof
(
*
ACLPacketHeader
));
Pipe_Write_Stream_LE
(
DataHeader
,
sizeof
(
*
DataHeader
));
Pipe_Write_Stream_LE
(
SignalCommandHeader
,
sizeof
(
*
SignalCommandHeader
));
Pipe_Write_Stream_LE
(
&
ConnectionResponse
,
sizeof
(
ConnectionResponse
));
Pipe_ClearOUT
();
Pipe_Freeze
();
BT_DEBUG
(
"(ACL) Packet Sent"
,
NULL
);
BT_DEBUG
(
"(ACL) -- Connection Handle: 0x%04X"
,
ACLPacketHeader
->
ConnectionHandle
);
BT_DEBUG
(
"(ACL) -- Data Length: 0x%04X"
,
ACLPacketHeader
->
DataLength
);
BT_DEBUG
(
"(ACL) -- Destination Channel: 0x%04X"
,
DataHeader
->
DestinationChannel
);
BT_DEBUG
(
"(ACL) -- Payload Length: 0x%04X"
,
DataHeader
->
PayloadLength
);
BT_DEBUG
(
"(ACL) >> L2CAP Connection Response"
,
NULL
);
BT_DEBUG
(
"(ACL) -- Source Channel: 0x%04X"
,
ConnectionResponse
.
SourceChannel
);
BT_DEBUG
(
"(ACL) -- Destination Channel: 0x%04X"
,
ConnectionResponse
.
DestinationChannel
);
}
static
inline
void
Bluetooth_ProcessSignalPacket_ConfigurationRequest
(
Bluetooth_ACL_Header_t
*
ACLPacketHeader
,
Bluetooth_DataPacket_Header_t
*
DataHeader
,
Bluetooth_SignalCommand_Header_t
*
SignalCommandHeader
)
{
Bluetooth_SignalCommand_ConfigurationRequest_t
ConfigurationRequest
;
Pipe_Read_Stream_LE
(
&
ConfigurationRequest
,
sizeof
(
ConfigurationRequest
));
BT_DEBUG
(
"(ACL) >> L2CAP Configuration Request"
,
NULL
);
BT_DEBUG
(
"(ACL) -- Destination Channel: 0x%04X"
,
ConfigurationRequest
.
DestinationChannel
);
Pipe_ClearIN
();
Pipe_Freeze
();
Pipe_SelectPipe
(
BLUETOOTH_DATA_OUT_PIPE
);
Pipe_SetToken
(
PIPE_TOKEN_OUT
);
Pipe_Unfreeze
();
Bluetooth_SignalCommand_ConfigurationResponse_t
ConfigurationResponse
;
ACLPacketHeader
->
DataLength
=
sizeof
(
*
DataHeader
)
+
sizeof
(
*
SignalCommandHeader
)
+
sizeof
(
ConfigurationResponse
);
DataHeader
->
PayloadLength
=
sizeof
(
*
SignalCommandHeader
)
+
sizeof
(
ConfigurationResponse
);
DataHeader
->
DestinationChannel
=
BLUETOOTH_CHANNEL_SIGNALING
;
SignalCommandHeader
->
Code
=
BLUETOOTH_SIGNAL_CONFIGURATION_RESPONSE
;
SignalCommandHeader
->
Length
=
sizeof
(
ConfigurationResponse
);
Bluetooth_Channel_t
*
ChannelData
=
Bluetooth_GetChannelData
(
ConfigurationRequest
.
DestinationChannel
,
CHANNEL_LOOKUP_BY_DESTINATION
);
if
(
ChannelData
!=
NULL
)
ChannelData
->
State
=
Channel_Open
;
// TODO: Add channel config data to the tail of ConfigurationResponse
ConfigurationResponse
.
SourceChannel
=
ChannelData
->
RemoteNumber
;
ConfigurationResponse
.
Flags
=
0x00
;
ConfigurationResponse
.
Result
=
(
ChannelData
!=
NULL
)
?
BLUETOOTH_CONFIGURATION_SUCCESSFUL
:
BLUETOOTH_CONFIGURATION_REJECTED
;
Pipe_Write_Stream_LE
(
ACLPacketHeader
,
sizeof
(
*
ACLPacketHeader
));
Pipe_Write_Stream_LE
(
DataHeader
,
sizeof
(
*
DataHeader
));
Pipe_Write_Stream_LE
(
SignalCommandHeader
,
sizeof
(
*
SignalCommandHeader
));
Pipe_Write_Stream_LE
(
&
ConfigurationResponse
,
sizeof
(
ConfigurationResponse
));
Pipe_ClearOUT
();
Pipe_Freeze
();
BT_DEBUG
(
"(ACL) Packet Sent"
,
NULL
);
BT_DEBUG
(
"(ACL) -- Connection Handle: 0x%04X"
,
ACLPacketHeader
->
ConnectionHandle
);
BT_DEBUG
(
"(ACL) -- Data Length: 0x%04X"
,
ACLPacketHeader
->
DataLength
);
BT_DEBUG
(
"(ACL) -- Destination Channel: 0x%04X"
,
DataHeader
->
DestinationChannel
);
BT_DEBUG
(
"(ACL) -- Payload Length: 0x%04X"
,
DataHeader
->
PayloadLength
);
BT_DEBUG
(
"(ACL) >> L2CAP Configuration Response"
,
NULL
);
}
Demos/Host/Incomplete/BluetoothHost/BluetoothACLPackets.h
0 → 100644
View file @
2793c88f
/*
LUFA Library
Copyright (C) Dean Camera, 2009.
dean [at] fourwalledcubicle [dot] com
www.fourwalledcubicle.com
*/
/*
Copyright 2009 Dean Camera (dean [at] fourwalledcubicle [dot] com)
Permission to use, copy, modify, and distribute this software
and its documentation for any purpose and without fee is hereby
granted, provided that the above copyright notice appear in all
copies and that both that the copyright notice and this
permission notice and warranty disclaimer appear in supporting
documentation, and that the name of the author not be used in
advertising or publicity pertaining to distribution of the
software without specific, written prior permission.
The author disclaim all warranties with regard to this
software, including all implied warranties of merchantability
and fitness. In no event shall the author be liable for any
special, indirect or consequential damages or any damages
whatsoever resulting from loss of use, data or profits, whether
in an action of contract, negligence or other tortious action,
arising out of or in connection with the use or performance of
this software.
*/
#ifndef _BLUETOOTH_ACLPACKETS_
#define _BLUETOOTH_ACLPACKETS_
/* Includes: */
#include <avr/io.h>
#include <string.h>
#include <stdbool.h>
#include <LUFA/Drivers/USB/USB.h>
#include "BluetoothStack.h"
/* Macros: */
#define BLUETOOTH_CHANNEL_SIGNALING 0x0001
#define BLUETOOTH_CHANNEL_CONNECTIONLESS 0x0002
#define BLUETOOTH_SIGNAL_CONNECTION_REQUEST 0x02
#define BLUETOOTH_SIGNAL_CONNECTION_RESPONSE 0x03
#define BLUETOOTH_SIGNAL_CONFIGURATION_REQUEST 0x04
#define BLUETOOTH_SIGNAL_CONFIGURATION_RESPONSE 0x05
#define BLUETOOTH_CONNECTION_SUCCESSFUL 0x0000
#define BLUETOOTH_CONNECTION_REFUSED_RESOURCES 0x0004
#define BLUETOOTH_CONFIGURATION_SUCCESSFUL 0x0000
#define BLUETOOTH_CONFIGURATION_REJECTED 0x0002
#define BLUETOOTH_CONFIGURATION_UNKNOWNOPTIONS 0x0003
/* Type Defines: */
typedef
struct
{
uint16_t
ConnectionHandle
;
uint16_t
DataLength
;
}
Bluetooth_ACL_Header_t
;
typedef
struct
{
uint16_t
PayloadLength
;
uint16_t
DestinationChannel
;
}
Bluetooth_DataPacket_Header_t
;
typedef
struct
{
uint8_t
Code
;
uint8_t
Identifier
;
uint16_t
Length
;
}
Bluetooth_SignalCommand_Header_t
;
typedef
struct
{
uint16_t
PSM
;
uint16_t
SourceChannel
;
}
Bluetooth_SignalCommand_ConnectionRequest_t
;
typedef
struct
{
uint16_t
DestinationChannel
;
uint16_t
SourceChannel
;
uint16_t
Result
;
uint16_t
Status
;
}
Bluetooth_SignalCommand_ConnectionResponse_t
;
typedef
struct
{
uint16_t
DestinationChannel
;
uint16_t
Flags
;
uint8_t
Options
[];
}
Bluetooth_SignalCommand_ConfigurationRequest_t
;
typedef
struct
{
uint16_t
SourceChannel
;
uint16_t
Flags
;
uint16_t
Result
;
uint8_t
Config
;
}
Bluetooth_SignalCommand_ConfigurationResponse_t
;
/* Function Prototypes: */
void
Bluetooth_ProcessACLPackets
(
void
);
#if defined(INCLUDE_FROM_BLUETOOTH_ACLPACKETS_C)
static
inline
void
Bluetooth_ProcessSignalPacket_ConnectionRequest
(
Bluetooth_ACL_Header_t
*
ACLPacketHeader
,
Bluetooth_DataPacket_Header_t
*
DataHeader
,
Bluetooth_SignalCommand_Header_t
*
SignalCommandHeader
);
static
inline
void
Bluetooth_ProcessSignalPacket_ConfigurationRequest
(
Bluetooth_ACL_Header_t
*
ACLPacketHeader
,
Bluetooth_DataPacket_Header_t
*
DataHeader
,
Bluetooth_SignalCommand_Header_t
*
SignalCommandHeader
);
#endif
#endif
Demos/Host/Incomplete/BluetoothHost/BluetoothClassCodes.h
0 → 100644
View file @
2793c88f
/*
LUFA Library
Copyright (C) Dean Camera, 2009.
dean [at] fourwalledcubicle [dot] com
www.fourwalledcubicle.com
*/
/*
Copyright 2009 Dean Camera (dean [at] fourwalledcubicle [dot] com)
Permission to use, copy, modify, and distribute this software
and its documentation for any purpose and without fee is hereby
granted, provided that the above copyright notice appear in all
copies and that both that the copyright notice and this
permission notice and warranty disclaimer appear in supporting
documentation, and that the name of the author not be used in
advertising or publicity pertaining to distribution of the
software without specific, written prior permission.
The author disclaim all warranties with regard to this
software, including all implied warranties of merchantability
and fitness. In no event shall the author be liable for any
special, indirect or consequential damages or any damages
whatsoever resulting from loss of use, data or profits, whether
in an action of contract, negligence or other tortious action,
arising out of or in connection with the use or performance of
this software.
*/
#ifndef _BLUETOOTH_CLASS_CODES_H_
#define _BLUETOOTH_CLASS_CODES_H_
/* Macros: */
#define DEVICE_CLASS_SERVICE_POSITIONING (1UL << 16)
#define DEVICE_CLASS_SERVICE_NETWORKING (1UL << 17)
#define DEVICE_CLASS_SERVICE_RENDERING (1UL << 18)
#define DEVICE_CLASS_SERVICE_CAPTURING (1UL << 19)
#define DEVICE_CLASS_SERVICE_OBJECTTRANSFER (1UL << 20)
#define DEVICE_CLASS_SERVICE_AUDIO (1UL << 21)
#define DEVICE_CLASS_SERVICE_TELEPHONY (1UL << 22)
#define DEVICE_CLASS_SERVICE_INFORMATION (1UL << 23)
#define DEVICE_CLASS_MAJOR_MISC (0x00 << 8)
#define DEVICE_CLASS_MAJOR_COMPUTER (0x01 << 8)
#define DEVICE_CLASS_MAJOR_PHONE (0x02 << 8)
#define DEVICE_CLASS_MAJOR_LAN (0x03 << 8)
#define DEVICE_CLASS_MAJOR_AUDIOVIDEO (0x04 << 8)
#define DEVICE_CLASS_MAJOR_PERIPHERAL (0x05 << 8)
#define DEVICE_CLASS_MAJOR_IMAGING (0x06 << 8)
#define DEVICE_CLASS_MAJOR_UNCLASSIFIED (0x1F << 8)
#define DEVICE_CLASS_MINOR_COMPUTER_UNCATEGORIZED (0x00 << 2)
#define DEVICE_CLASS_MINOR_COMPUTER_DESKTOP (0x01 << 2)
#define DEVICE_CLASS_MINOR_COMPUTER_SERVER (0x02 << 2)
#define DEVICE_CLASS_MINOR_COMPUTER_LAPTOP (0x03 << 2)
#define DEVICE_CLASS_MINOR_COMPUTER_HANDHELD (0x04 << 2)
#define DEVICE_CLASS_MINOR_COMPUTER_PALM (0x05 << 2)
#define DEVICE_CLASS_MINOR_COMPUTER_WEARABLE (0x06 << 2)
#define DEVICE_CLASS_MINOR_PHONE_UNCATEGORIZED (0x00 << 2)
#define DEVICE_CLASS_MINOR_PHONE_CELLULAR (0x01 << 2)
#define DEVICE_CLASS_MINOR_PHONE_CORDLESS (0x02 << 2)
#define DEVICE_CLASS_MINOR_PHONE_SMARTPHONE (0x03 << 2)
#define DEVICE_CLASS_MINOR_PHONE_WIREDMODEM (0x04 << 2)
#define DEVICE_CLASS_MINOR_PHONE_ISDN (0x05 << 2)
#define DEVICE_CLASS_MINOR_LAN_FULLY_AVAILABLE (0x00 << 5)
#define DEVICE_CLASS_MINOR_LAN_1_TO_17_PC_UTILIZED (0x01 << 5)
#define DEVICE_CLASS_MINOR_LAN_17_TO_33_PC_UTILIZED (0x02 << 5)
#define DEVICE_CLASS_MINOR_LAN_33_TO_50_PC_UTILIZED (0x03 << 5)
#define DEVICE_CLASS_MINOR_LAN_50_TO_67_PC_UTILIZED (0x04 << 5)
#define DEVICE_CLASS_MINOR_LAN_67_TO_83_PC_UTILIZED (0x05 << 5)
#define DEVICE_CLASS_MINOR_LAN_83_TO_99_PC_UTILIZED (0x06 << 5)
#define DEVICE_CLASS_MINOR_NO_SERVICE_AVAILABLE (0x07 << 5)
#define DEVICE_CLASS_MINOR_AV_UNCATEGORIZED (0x00 << 2)
#define DEVICE_CLASS_MINOR_AV_HEADSET (0x01 << 2)
#define DEVICE_CLASS_MINOR_AV_HANDSFREE (0x02 << 2)
#define DEVICE_CLASS_MINOR_AV_MICROPHONE (0x04 << 2)
#define DEVICE_CLASS_MINOR_AV_LOUDSPEAKER (0x05 << 2)
#define DEVICE_CLASS_MINOR_AV_HEADPHONES (0x06 << 2)
#define DEVICE_CLASS_MINOR_AV_PORTABLE_AUDIO (0x07 << 2)
#define DEVICE_CLASS_MINOR_AV_CARAUDIO (0x08 << 2)
#define DEVICE_CLASS_MINOR_AV_SETTOP_BOX (0x09 << 2)
#define DEVICE_CLASS_MINOR_AV_HIFI (0x0A << 2)
#define DEVICE_CLASS_MINOR_AV_VCR (0x0B << 2)
#define DEVICE_CLASS_MINOR_AV_VIDEO_CAMERA (0x0C << 2)
#define DEVICE_CLASS_MINOR_AV_CAMCORDER (0x0D << 2)
#define DEVICE_CLASS_MINOR_AV_VIDEO_MONITOR (0x0E << 2)
#define DEVICE_CLASS_MINOR_AV_DISPLAY_AND_LOUDSPEAKER (0x0F << 2)
#define DEVICE_CLASS_MINOR_AV_VIDEO_CONFERENCING (0x10 << 2)
#define DEVICE_CLASS_MINOR_AV_GAMING_TOY (0x12 << 2)
#define DEVICE_CLASS_MINOR_PERIPHERAL_KEYBOARD (0x01 << 6)
#define DEVICE_CLASS_MINOR_PERIPHERAL_POINTING (0x02 << 6)
#define DEVICE_CLASS_MINOR_PERIPHERAL_COMBO (0x03 << 6)
#define DEVICE_CLASS_MINOR_PERIPHERAL_UNCATEGORIZED (0x00 << 2)
#define DEVICE_CLASS_MINOR_PERIPHERAL_JOYSTICK (0x01 << 2)
#define DEVICE_CLASS_MINOR_PERIPHERAL_GAMEPAD (0x02 << 2)
#define DEVICE_CLASS_MINOR_PERIPHERAL_REMOTE_CONTROL (0x03 << 2)
#define DEVICE_CLASS_MINOR_PERIPHERAL_SENSING_DEVICE (0x04 << 2)
#define DEVICE_CLASS_MINOR_PERIPHERAL_DIGITIZER (0x05 << 2)
#define DEVICE_CLASS_MINOR_PERIPHERAL_CARD_READER (0x06 << 2)
#define DEVICE_CLASS_MINOR_IMAGING_DISPLAY (1 << 4)
#define DEVICE_CLASS_MINOR_IMAGING_CAMERA (1 << 5)
#define DEVICE_CLASS_MINOR_IMAGING_SCANNER (1 << 6)
#define DEVICE_CLASS_MINOR_IMAGING_PRINTER (1 << 7)
#endif
Demos/Host/Incomplete/BluetoothHost/BluetoothHCICommands.c
0 → 100644
View file @
2793c88f
/*
LUFA Library
Copyright (C) Dean Camera, 2009.
dean [at] fourwalledcubicle [dot] com
www.fourwalledcubicle.com
*/
/*
Copyright 2009 Dean Camera (dean [at] fourwalledcubicle [dot] com)
Permission to use, copy, modify, and distribute this software
and its documentation for any purpose and without fee is hereby
granted, provided that the above copyright notice appear in all
copies and that both that the copyright notice and this
permission notice and warranty disclaimer appear in supporting
documentation, and that the name of the author not be used in
advertising or publicity pertaining to distribution of the
software without specific, written prior permission.
The author disclaim all warranties with regard to this
software, including all implied warranties of merchantability
and fitness. In no event shall the author be liable for any
special, indirect or consequential damages or any damages
whatsoever resulting from loss of use, data or profits, whether
in an action of contract, negligence or other tortious action,
arising out of or in connection with the use or performance of
this software.
*/
#include "BluetoothHCICommands.h"
static
Bluetooth_HCICommand_Header_t
HCICommandHeader
;
static
Bluetooth_HCIEvent_Header_t
HCIEventHeader
;
uint8_t
Bluetooth_HCIProcessingState
;
static
uint8_t
Bluetooth_TempDeviceAddress
[
6
];
static
uint8_t
Bluetooth_SendHCICommand
(
void
*
Parameters
,
uint8_t
ParamLength
)
{
uint8_t
CommandBuffer
[
sizeof
(
HCICommandHeader
)
+
HCICommandHeader
.
ParameterLength
];
USB_ControlRequest
=
(
USB_Request_Header_t
)
{
bmRequestType:
(
REQDIR_HOSTTODEVICE
|
REQTYPE_CLASS
|
REQREC_DEVICE
),
bRequest:
0
,
wValue:
0
,
wIndex:
0
,
wLength:
sizeof
(
CommandBuffer
)
};
memset
(
CommandBuffer
,
0x00
,
sizeof
(
CommandBuffer
));
memcpy
(
CommandBuffer
,
&
HCICommandHeader
,
sizeof
(
HCICommandHeader
));
if
(
ParamLength
)
memcpy
(
&
CommandBuffer
[
sizeof
(
HCICommandHeader
)],
Parameters
,
ParamLength
);
Pipe_SelectPipe
(
PIPE_CONTROLPIPE
);
return
USB_Host_SendControlRequest
(
CommandBuffer
);
}
static
bool
Bluetooth_GetNextHCIEventHeader
(
void
)
{
Pipe_SelectPipe
(
BLUETOOTH_EVENTS_PIPE
);
Pipe_Unfreeze
();
if
(
!
(
Pipe_IsReadWriteAllowed
()))
{
Pipe_Freeze
();
return
false
;
}
Pipe_Read_Stream_LE
(
&
HCIEventHeader
,
sizeof
(
HCIEventHeader
));
Pipe_Freeze
();
return
true
;
}
static
void
Bluetooth_DiscardRemainingHCIEventParameters
(
void
)
{
Pipe_SelectPipe
(
BLUETOOTH_EVENTS_PIPE
);
Pipe_Unfreeze
();
Pipe_Discard_Stream
(
HCIEventHeader
.
ParameterLength
);
Pipe_ClearIN
();
Pipe_Freeze
();
}
void
Bluetooth_ProcessHCICommands
(
void
)
{
uint8_t
ErrorCode
;
switch
(
Bluetooth_HCIProcessingState
)
{
case
Bluetooth_Init
:
Pipe_SelectPipe
(
BLUETOOTH_EVENTS_PIPE
);
Pipe_SetInfiniteINRequests
();
memset
(
&
Bluetooth_Connection
,
0x00
,
sizeof
(
Bluetooth_Connection
));
Bluetooth_HCIProcessingState
=
Bluetooth_Init_Reset
;
break
;
case
Bluetooth_Init_Reset
:
HCICommandHeader
=
(
Bluetooth_HCICommand_Header_t
)
{
OpCode:
{
OGF
:
OGF_CTRLR_BASEBAND
,
OCF
:
OCF_CTRLR_BASEBAND_RESET
},
ParameterLength:
0
,
};
BT_DEBUG
(
"(HCI) Enter State: Bluetooth_Init_Reset"
,
NULL
);
ErrorCode
=
Bluetooth_SendHCICommand
(
NULL
,
0
);
do
{
while
(
!
(
Bluetooth_GetNextHCIEventHeader
()));
Bluetooth_DiscardRemainingHCIEventParameters
();
}
while
(
HCIEventHeader
.
EventCode
!=
EVENT_COMMAND_COMPLETE
);
Bluetooth_HCIProcessingState
=
Bluetooth_Init_ReadBufferSize
;
break
;
case
Bluetooth_Init_ReadBufferSize
:
HCICommandHeader
=
(
Bluetooth_HCICommand_Header_t
)
{
OpCode:
{
OGF
:
OGF_CTRLR_INFORMATIONAL
,
OCF
:
OGF_CTRLR_INFORMATIONAL_READBUFFERSIZE
},
ParameterLength:
0
,
};
BT_DEBUG
(
"(HCI) Enter State: Bluetooth_Init_ReadBufferSize"
,
NULL
);
ErrorCode
=
Bluetooth_SendHCICommand
(
NULL
,
0
);
do
{
while
(
!
(
Bluetooth_GetNextHCIEventHeader
()));
Bluetooth_DiscardRemainingHCIEventParameters
();
}
while
(
HCIEventHeader
.
EventCode
!=
EVENT_COMMAND_COMPLETE
);
Bluetooth_HCIProcessingState
=
Bluetooth_Init_SetEventMask
;
break
;
case
Bluetooth_Init_SetEventMask
:
HCICommandHeader
=
(
Bluetooth_HCICommand_Header_t
)
{
OpCode:
{
OGF
:
OGF_CTRLR_BASEBAND
,
OCF
:
OCF_CTRLR_BASEBAND_SET_EVENT_MASK
},
ParameterLength: