BTstack for Nucleo F401RE/FRDM-KL46Z example program

Dependencies:   F401RE-USBHost mbed

The usage is the same as KL46Z-BTstack_example.
使い方はKL46Z-BTstack_exampleと同じです。
/media/uploads/va009039/f401re-btstack.jpg

Committer:
va009039
Date:
Mon Jun 09 09:03:25 2014 +0000
Revision:
0:a05a07cd6fdf
first commit

Who changed what in which revision?

UserRevisionLine numberNew contents of line
va009039 0:a05a07cd6fdf 1 /*
va009039 0:a05a07cd6fdf 2 * Copyright (C) 2009-2012 by Matthias Ringwald
va009039 0:a05a07cd6fdf 3 *
va009039 0:a05a07cd6fdf 4 * Redistribution and use in source and binary forms, with or without
va009039 0:a05a07cd6fdf 5 * modification, are permitted provided that the following conditions
va009039 0:a05a07cd6fdf 6 * are met:
va009039 0:a05a07cd6fdf 7 *
va009039 0:a05a07cd6fdf 8 * 1. Redistributions of source code must retain the above copyright
va009039 0:a05a07cd6fdf 9 * notice, this list of conditions and the following disclaimer.
va009039 0:a05a07cd6fdf 10 * 2. Redistributions in binary form must reproduce the above copyright
va009039 0:a05a07cd6fdf 11 * notice, this list of conditions and the following disclaimer in the
va009039 0:a05a07cd6fdf 12 * documentation and/or other materials provided with the distribution.
va009039 0:a05a07cd6fdf 13 * 3. Neither the name of the copyright holders nor the names of
va009039 0:a05a07cd6fdf 14 * contributors may be used to endorse or promote products derived
va009039 0:a05a07cd6fdf 15 * from this software without specific prior written permission.
va009039 0:a05a07cd6fdf 16 * 4. Any redistribution, use, or modification is done solely for
va009039 0:a05a07cd6fdf 17 * personal benefit and not for any commercial purpose or for
va009039 0:a05a07cd6fdf 18 * monetary gain.
va009039 0:a05a07cd6fdf 19 *
va009039 0:a05a07cd6fdf 20 * THIS SOFTWARE IS PROVIDED BY MATTHIAS RINGWALD AND CONTRIBUTORS
va009039 0:a05a07cd6fdf 21 * ``AS IS'' AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
va009039 0:a05a07cd6fdf 22 * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS
va009039 0:a05a07cd6fdf 23 * FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL MATTHIAS
va009039 0:a05a07cd6fdf 24 * RINGWALD OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT,
va009039 0:a05a07cd6fdf 25 * INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING,
va009039 0:a05a07cd6fdf 26 * BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS
va009039 0:a05a07cd6fdf 27 * OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED
va009039 0:a05a07cd6fdf 28 * AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY,
va009039 0:a05a07cd6fdf 29 * OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF
va009039 0:a05a07cd6fdf 30 * THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
va009039 0:a05a07cd6fdf 31 * SUCH DAMAGE.
va009039 0:a05a07cd6fdf 32 *
va009039 0:a05a07cd6fdf 33 * Please inquire about commercial licensing options at btstack@ringwald.ch
va009039 0:a05a07cd6fdf 34 *
va009039 0:a05a07cd6fdf 35 */
va009039 0:a05a07cd6fdf 36
va009039 0:a05a07cd6fdf 37 /*
va009039 0:a05a07cd6fdf 38 * hci_transport.h
va009039 0:a05a07cd6fdf 39 *
va009039 0:a05a07cd6fdf 40 * HCI Transport API -- allows BT Daemon to use different transport protcols
va009039 0:a05a07cd6fdf 41 *
va009039 0:a05a07cd6fdf 42 * Created by Matthias Ringwald on 4/29/09.
va009039 0:a05a07cd6fdf 43 *
va009039 0:a05a07cd6fdf 44 */
va009039 0:a05a07cd6fdf 45 #pragma once
va009039 0:a05a07cd6fdf 46
va009039 0:a05a07cd6fdf 47 #include <stdint.h>
va009039 0:a05a07cd6fdf 48 #include <btstack/run_loop.h>
va009039 0:a05a07cd6fdf 49
va009039 0:a05a07cd6fdf 50 #if defined __cplusplus
va009039 0:a05a07cd6fdf 51 extern "C" {
va009039 0:a05a07cd6fdf 52 #endif
va009039 0:a05a07cd6fdf 53
va009039 0:a05a07cd6fdf 54 /* HCI packet types */
va009039 0:a05a07cd6fdf 55 typedef struct {
va009039 0:a05a07cd6fdf 56 int (*open)(void *transport_config);
va009039 0:a05a07cd6fdf 57 int (*close)(void *transport_config);
va009039 0:a05a07cd6fdf 58 int (*send_packet)(uint8_t packet_type, uint8_t *packet, int size);
va009039 0:a05a07cd6fdf 59 void (*register_packet_handler)(void (*handler)(uint8_t packet_type, uint8_t *packet, uint16_t size));
va009039 0:a05a07cd6fdf 60 const char * (*get_transport_name)(void);
va009039 0:a05a07cd6fdf 61 // custom extension for UART transport implementations
va009039 0:a05a07cd6fdf 62 int (*set_baudrate)(uint32_t baudrate);
va009039 0:a05a07cd6fdf 63 // support async transport layers, e.g. IRQ driven without buffers
va009039 0:a05a07cd6fdf 64 int (*can_send_packet_now)(uint8_t packet_type);
va009039 0:a05a07cd6fdf 65 } hci_transport_t;
va009039 0:a05a07cd6fdf 66
va009039 0:a05a07cd6fdf 67 typedef struct {
va009039 0:a05a07cd6fdf 68 const char *device_name;
va009039 0:a05a07cd6fdf 69 uint32_t baudrate_init; // initial baud rate
va009039 0:a05a07cd6fdf 70 uint32_t baudrate_main; // = 0: same as initial baudrate
va009039 0:a05a07cd6fdf 71 int flowcontrol; //
va009039 0:a05a07cd6fdf 72 } hci_uart_config_t;
va009039 0:a05a07cd6fdf 73
va009039 0:a05a07cd6fdf 74
va009039 0:a05a07cd6fdf 75 // inline various hci_transport_X.h files
va009039 0:a05a07cd6fdf 76 extern hci_transport_t * hci_transport_h4_instance(void);
va009039 0:a05a07cd6fdf 77 extern hci_transport_t * hci_transport_h4_dma_instance(void);
va009039 0:a05a07cd6fdf 78 extern hci_transport_t * hci_transport_h4_iphone_instance(void);
va009039 0:a05a07cd6fdf 79 extern hci_transport_t * hci_transport_h5_instance(void);
va009039 0:a05a07cd6fdf 80 extern hci_transport_t * hci_transport_usb_instance(void);
va009039 0:a05a07cd6fdf 81
va009039 0:a05a07cd6fdf 82 // support for "enforece wake device" in h4 - used by iOS power management
va009039 0:a05a07cd6fdf 83 extern void hci_transport_h4_iphone_set_enforce_wake_device(char *path);
va009039 0:a05a07cd6fdf 84
va009039 0:a05a07cd6fdf 85 #if defined __cplusplus
va009039 0:a05a07cd6fdf 86 }
va009039 0:a05a07cd6fdf 87 #endif
va009039 0:a05a07cd6fdf 88