テスト用

Fork of nRF51822 by Nordic Semiconductor

Committer:
Rohit Grover
Date:
Fri May 23 09:01:52 2014 +0100
Revision:
4:534c2146e5ec
Parent:
0:eff01767de02
Child:
16:d8161e2af6c6
nRF51822n now has a different base class; it extends BLEDeviceInstanceBase

Who changed what in which revision?

UserRevisionLine numberNew contents of line
bogdanm 0:eff01767de02 1 /* mbed Microcontroller Library
bogdanm 0:eff01767de02 2 * Copyright (c) 2006-2013 ARM Limited
bogdanm 0:eff01767de02 3 *
bogdanm 0:eff01767de02 4 * Licensed under the Apache License, Version 2.0 (the "License");
bogdanm 0:eff01767de02 5 * you may not use this file except in compliance with the License.
bogdanm 0:eff01767de02 6 * You may obtain a copy of the License at
bogdanm 0:eff01767de02 7 *
bogdanm 0:eff01767de02 8 * http://www.apache.org/licenses/LICENSE-2.0
bogdanm 0:eff01767de02 9 *
bogdanm 0:eff01767de02 10 * Unless required by applicable law or agreed to in writing, software
bogdanm 0:eff01767de02 11 * distributed under the License is distributed on an "AS IS" BASIS,
bogdanm 0:eff01767de02 12 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
bogdanm 0:eff01767de02 13 * See the License for the specific language governing permissions and
bogdanm 0:eff01767de02 14 * limitations under the License.
bogdanm 0:eff01767de02 15 */
bogdanm 0:eff01767de02 16
bogdanm 0:eff01767de02 17 #include "mbed.h"
bogdanm 0:eff01767de02 18 #include "nRF51822n.h"
bogdanm 0:eff01767de02 19
bogdanm 0:eff01767de02 20 #include "btle/btle.h"
bogdanm 0:eff01767de02 21
Rohit Grover 4:534c2146e5ec 22 /**
Rohit Grover 4:534c2146e5ec 23 * The singleton which represents the nRF51822 transport for the BLEDevice.
Rohit Grover 4:534c2146e5ec 24 */
Rohit Grover 4:534c2146e5ec 25 static nRF51822n deviceInstance;
Rohit Grover 4:534c2146e5ec 26
Rohit Grover 4:534c2146e5ec 27 /**
Rohit Grover 4:534c2146e5ec 28 * BLE-API requires an implementation of the following function in order to
Rohit Grover 4:534c2146e5ec 29 * obtain its transport handle.
Rohit Grover 4:534c2146e5ec 30 */
Rohit Grover 4:534c2146e5ec 31 BLEDeviceInstanceBase *
Rohit Grover 4:534c2146e5ec 32 createBLEDeviceInstance(void) {
Rohit Grover 4:534c2146e5ec 33 return (&deviceInstance);
Rohit Grover 4:534c2146e5ec 34 }
Rohit Grover 4:534c2146e5ec 35
bogdanm 0:eff01767de02 36 /**************************************************************************/
bogdanm 0:eff01767de02 37 /*!
bogdanm 0:eff01767de02 38 @brief Constructor
bogdanm 0:eff01767de02 39 */
bogdanm 0:eff01767de02 40 /**************************************************************************/
bogdanm 0:eff01767de02 41 nRF51822n::nRF51822n(void)
bogdanm 0:eff01767de02 42 {
bogdanm 0:eff01767de02 43 }
bogdanm 0:eff01767de02 44
bogdanm 0:eff01767de02 45 /**************************************************************************/
bogdanm 0:eff01767de02 46 /*!
bogdanm 0:eff01767de02 47 @brief Destructor
bogdanm 0:eff01767de02 48 */
bogdanm 0:eff01767de02 49 /**************************************************************************/
bogdanm 0:eff01767de02 50 nRF51822n::~nRF51822n(void)
bogdanm 0:eff01767de02 51 {
bogdanm 0:eff01767de02 52 }
bogdanm 0:eff01767de02 53
bogdanm 0:eff01767de02 54 /**************************************************************************/
bogdanm 0:eff01767de02 55 /*!
bogdanm 0:eff01767de02 56 @brief Initialises anything required to start using BLE
bogdanm 0:eff01767de02 57
bogdanm 0:eff01767de02 58 @returns ble_error_t
bogdanm 0:eff01767de02 59
bogdanm 0:eff01767de02 60 @retval BLE_ERROR_NONE
bogdanm 0:eff01767de02 61 Everything executed properly
bogdanm 0:eff01767de02 62
bogdanm 0:eff01767de02 63 @section EXAMPLE
bogdanm 0:eff01767de02 64
bogdanm 0:eff01767de02 65 @code
bogdanm 0:eff01767de02 66
bogdanm 0:eff01767de02 67 @endcode
bogdanm 0:eff01767de02 68 */
bogdanm 0:eff01767de02 69 /**************************************************************************/
bogdanm 0:eff01767de02 70 ble_error_t nRF51822n::init(void)
bogdanm 0:eff01767de02 71 {
bogdanm 0:eff01767de02 72 /* ToDo: Clear memory contents, reset the SD, etc. */
bogdanm 0:eff01767de02 73 btle_init();
bogdanm 0:eff01767de02 74
bogdanm 0:eff01767de02 75 return BLE_ERROR_NONE;
bogdanm 0:eff01767de02 76 }
bogdanm 0:eff01767de02 77
bogdanm 0:eff01767de02 78 /**************************************************************************/
bogdanm 0:eff01767de02 79 /*!
bogdanm 0:eff01767de02 80 @brief Resets the BLE HW, removing any existing services and
bogdanm 0:eff01767de02 81 characteristics
bogdanm 0:eff01767de02 82
bogdanm 0:eff01767de02 83 @returns ble_error_t
bogdanm 0:eff01767de02 84
bogdanm 0:eff01767de02 85 @retval BLE_ERROR_NONE
bogdanm 0:eff01767de02 86 Everything executed properly
bogdanm 0:eff01767de02 87
bogdanm 0:eff01767de02 88 @section EXAMPLE
bogdanm 0:eff01767de02 89
bogdanm 0:eff01767de02 90 @code
bogdanm 0:eff01767de02 91
bogdanm 0:eff01767de02 92 @endcode
bogdanm 0:eff01767de02 93 */
bogdanm 0:eff01767de02 94 /**************************************************************************/
bogdanm 0:eff01767de02 95 ble_error_t nRF51822n::reset(void)
bogdanm 0:eff01767de02 96 {
bogdanm 0:eff01767de02 97 wait(0.5);
bogdanm 0:eff01767de02 98
bogdanm 0:eff01767de02 99 /* Wait for the radio to come back up */
bogdanm 0:eff01767de02 100 wait(1);
bogdanm 0:eff01767de02 101
bogdanm 0:eff01767de02 102 return BLE_ERROR_NONE;
bogdanm 0:eff01767de02 103 }