Test code for Grove Node BLE

Dependencies:   BLE_API nRF51822

Fork of BLE_LoopbackUART by Bluetooth Low Energy

Committer:
yihui
Date:
Wed Oct 29 06:23:47 2014 +0000
Revision:
9:05f0b5a3a70a
initial

Who changed what in which revision?

UserRevisionLine numberNew contents of line
yihui 9:05f0b5a3a70a 1 /* mbed Microcontroller Library
yihui 9:05f0b5a3a70a 2 * Copyright (c) 2006-2013 ARM Limited
yihui 9:05f0b5a3a70a 3 *
yihui 9:05f0b5a3a70a 4 * Licensed under the Apache License, Version 2.0 (the "License");
yihui 9:05f0b5a3a70a 5 * you may not use this file except in compliance with the License.
yihui 9:05f0b5a3a70a 6 * You may obtain a copy of the License at
yihui 9:05f0b5a3a70a 7 *
yihui 9:05f0b5a3a70a 8 * http://www.apache.org/licenses/LICENSE-2.0
yihui 9:05f0b5a3a70a 9 *
yihui 9:05f0b5a3a70a 10 * Unless required by applicable law or agreed to in writing, software
yihui 9:05f0b5a3a70a 11 * distributed under the License is distributed on an "AS IS" BASIS,
yihui 9:05f0b5a3a70a 12 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
yihui 9:05f0b5a3a70a 13 * See the License for the specific language governing permissions and
yihui 9:05f0b5a3a70a 14 * limitations under the License.
yihui 9:05f0b5a3a70a 15 */
yihui 9:05f0b5a3a70a 16 #ifndef MBED_INTERFACE_H
yihui 9:05f0b5a3a70a 17 #define MBED_INTERFACE_H
yihui 9:05f0b5a3a70a 18
yihui 9:05f0b5a3a70a 19 #include "device.h"
yihui 9:05f0b5a3a70a 20
yihui 9:05f0b5a3a70a 21 /* Mbed interface mac address
yihui 9:05f0b5a3a70a 22 * if MBED_MAC_ADD_x are zero, interface uid sets mac address,
yihui 9:05f0b5a3a70a 23 * otherwise MAC_ADD_x are used.
yihui 9:05f0b5a3a70a 24 */
yihui 9:05f0b5a3a70a 25 #define MBED_MAC_ADDR_INTERFACE 0x00
yihui 9:05f0b5a3a70a 26 #define MBED_MAC_ADDR_0 MBED_MAC_ADDR_INTERFACE
yihui 9:05f0b5a3a70a 27 #define MBED_MAC_ADDR_1 MBED_MAC_ADDR_INTERFACE
yihui 9:05f0b5a3a70a 28 #define MBED_MAC_ADDR_2 MBED_MAC_ADDR_INTERFACE
yihui 9:05f0b5a3a70a 29 #define MBED_MAC_ADDR_3 MBED_MAC_ADDR_INTERFACE
yihui 9:05f0b5a3a70a 30 #define MBED_MAC_ADDR_4 MBED_MAC_ADDR_INTERFACE
yihui 9:05f0b5a3a70a 31 #define MBED_MAC_ADDR_5 MBED_MAC_ADDR_INTERFACE
yihui 9:05f0b5a3a70a 32 #define MBED_MAC_ADDRESS_SUM (MBED_MAC_ADDR_0 | MBED_MAC_ADDR_1 | MBED_MAC_ADDR_2 | MBED_MAC_ADDR_3 | MBED_MAC_ADDR_4 | MBED_MAC_ADDR_5)
yihui 9:05f0b5a3a70a 33
yihui 9:05f0b5a3a70a 34 #ifdef __cplusplus
yihui 9:05f0b5a3a70a 35 extern "C" {
yihui 9:05f0b5a3a70a 36 #endif
yihui 9:05f0b5a3a70a 37
yihui 9:05f0b5a3a70a 38 #if DEVICE_SEMIHOST
yihui 9:05f0b5a3a70a 39
yihui 9:05f0b5a3a70a 40 /** Functions to control the mbed interface
yihui 9:05f0b5a3a70a 41 *
yihui 9:05f0b5a3a70a 42 * mbed Microcontrollers have a built-in interface to provide functionality such as
yihui 9:05f0b5a3a70a 43 * drag-n-drop download, reset, serial-over-usb, and access to the mbed local file
yihui 9:05f0b5a3a70a 44 * system. These functions provide means to control the interface suing semihost
yihui 9:05f0b5a3a70a 45 * calls it supports.
yihui 9:05f0b5a3a70a 46 */
yihui 9:05f0b5a3a70a 47
yihui 9:05f0b5a3a70a 48 /** Determine whether the mbed interface is connected, based on whether debug is enabled
yihui 9:05f0b5a3a70a 49 *
yihui 9:05f0b5a3a70a 50 * @returns
yihui 9:05f0b5a3a70a 51 * 1 if interface is connected,
yihui 9:05f0b5a3a70a 52 * 0 otherwise
yihui 9:05f0b5a3a70a 53 */
yihui 9:05f0b5a3a70a 54 int mbed_interface_connected(void);
yihui 9:05f0b5a3a70a 55
yihui 9:05f0b5a3a70a 56 /** Instruct the mbed interface to reset, as if the reset button had been pressed
yihui 9:05f0b5a3a70a 57 *
yihui 9:05f0b5a3a70a 58 * @returns
yihui 9:05f0b5a3a70a 59 * 1 if successful,
yihui 9:05f0b5a3a70a 60 * 0 otherwise (e.g. interface not present)
yihui 9:05f0b5a3a70a 61 */
yihui 9:05f0b5a3a70a 62 int mbed_interface_reset(void);
yihui 9:05f0b5a3a70a 63
yihui 9:05f0b5a3a70a 64 /** This will disconnect the debug aspect of the interface, so semihosting will be disabled.
yihui 9:05f0b5a3a70a 65 * The interface will still support the USB serial aspect
yihui 9:05f0b5a3a70a 66 *
yihui 9:05f0b5a3a70a 67 * @returns
yihui 9:05f0b5a3a70a 68 * 0 if successful,
yihui 9:05f0b5a3a70a 69 * -1 otherwise (e.g. interface not present)
yihui 9:05f0b5a3a70a 70 */
yihui 9:05f0b5a3a70a 71 int mbed_interface_disconnect(void);
yihui 9:05f0b5a3a70a 72
yihui 9:05f0b5a3a70a 73 /** This will disconnect the debug aspect of the interface, and if the USB cable is not
yihui 9:05f0b5a3a70a 74 * connected, also power down the interface. If the USB cable is connected, the interface
yihui 9:05f0b5a3a70a 75 * will remain powered up and visible to the host
yihui 9:05f0b5a3a70a 76 *
yihui 9:05f0b5a3a70a 77 * @returns
yihui 9:05f0b5a3a70a 78 * 0 if successful,
yihui 9:05f0b5a3a70a 79 * -1 otherwise (e.g. interface not present)
yihui 9:05f0b5a3a70a 80 */
yihui 9:05f0b5a3a70a 81 int mbed_interface_powerdown(void);
yihui 9:05f0b5a3a70a 82
yihui 9:05f0b5a3a70a 83 /** This returns a string containing the 32-character UID of the mbed interface
yihui 9:05f0b5a3a70a 84 * This is a weak function that can be overwritten if required
yihui 9:05f0b5a3a70a 85 *
yihui 9:05f0b5a3a70a 86 * @param uid A 33-byte array to write the null terminated 32-byte string
yihui 9:05f0b5a3a70a 87 *
yihui 9:05f0b5a3a70a 88 * @returns
yihui 9:05f0b5a3a70a 89 * 0 if successful,
yihui 9:05f0b5a3a70a 90 * -1 otherwise (e.g. interface not present)
yihui 9:05f0b5a3a70a 91 */
yihui 9:05f0b5a3a70a 92 int mbed_interface_uid(char *uid);
yihui 9:05f0b5a3a70a 93
yihui 9:05f0b5a3a70a 94 #endif
yihui 9:05f0b5a3a70a 95
yihui 9:05f0b5a3a70a 96 /** This returns a unique 6-byte MAC address, based on the interface UID
yihui 9:05f0b5a3a70a 97 * If the interface is not present, it returns a default fixed MAC address (00:02:F7:F0:00:00)
yihui 9:05f0b5a3a70a 98 *
yihui 9:05f0b5a3a70a 99 * This is a weak function that can be overwritten if you want to provide your own mechanism to
yihui 9:05f0b5a3a70a 100 * provide a MAC address.
yihui 9:05f0b5a3a70a 101 *
yihui 9:05f0b5a3a70a 102 * @param mac A 6-byte array to write the MAC address
yihui 9:05f0b5a3a70a 103 */
yihui 9:05f0b5a3a70a 104 void mbed_mac_address(char *mac);
yihui 9:05f0b5a3a70a 105
yihui 9:05f0b5a3a70a 106 /** Cause the mbed to flash the BLOD (Blue LEDs Of Death) sequence
yihui 9:05f0b5a3a70a 107 */
yihui 9:05f0b5a3a70a 108 void mbed_die(void);
yihui 9:05f0b5a3a70a 109
yihui 9:05f0b5a3a70a 110 #ifdef __cplusplus
yihui 9:05f0b5a3a70a 111 }
yihui 9:05f0b5a3a70a 112 #endif
yihui 9:05f0b5a3a70a 113
yihui 9:05f0b5a3a70a 114 #endif