For with fix for disconnection notifications

Fork of nRF51822 by Nordic Semiconductor

Committer:
bogdanm
Date:
Wed Mar 26 14:38:17 2014 +0000
Revision:
0:eff01767de02
Child:
4:534c2146e5ec
Initial import of the nRF51822 code

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
bogdanm 0:eff01767de02 22 /**************************************************************************/
bogdanm 0:eff01767de02 23 /*!
bogdanm 0:eff01767de02 24 @brief Constructor
bogdanm 0:eff01767de02 25 */
bogdanm 0:eff01767de02 26 /**************************************************************************/
bogdanm 0:eff01767de02 27 nRF51822n::nRF51822n(void)
bogdanm 0:eff01767de02 28 {
bogdanm 0:eff01767de02 29 }
bogdanm 0:eff01767de02 30
bogdanm 0:eff01767de02 31 /**************************************************************************/
bogdanm 0:eff01767de02 32 /*!
bogdanm 0:eff01767de02 33 @brief Destructor
bogdanm 0:eff01767de02 34 */
bogdanm 0:eff01767de02 35 /**************************************************************************/
bogdanm 0:eff01767de02 36 nRF51822n::~nRF51822n(void)
bogdanm 0:eff01767de02 37 {
bogdanm 0:eff01767de02 38 }
bogdanm 0:eff01767de02 39
bogdanm 0:eff01767de02 40 /**************************************************************************/
bogdanm 0:eff01767de02 41 /*!
bogdanm 0:eff01767de02 42 @brief Initialises anything required to start using BLE
bogdanm 0:eff01767de02 43
bogdanm 0:eff01767de02 44 @returns ble_error_t
bogdanm 0:eff01767de02 45
bogdanm 0:eff01767de02 46 @retval BLE_ERROR_NONE
bogdanm 0:eff01767de02 47 Everything executed properly
bogdanm 0:eff01767de02 48
bogdanm 0:eff01767de02 49 @section EXAMPLE
bogdanm 0:eff01767de02 50
bogdanm 0:eff01767de02 51 @code
bogdanm 0:eff01767de02 52
bogdanm 0:eff01767de02 53 @endcode
bogdanm 0:eff01767de02 54 */
bogdanm 0:eff01767de02 55 /**************************************************************************/
bogdanm 0:eff01767de02 56 ble_error_t nRF51822n::init(void)
bogdanm 0:eff01767de02 57 {
bogdanm 0:eff01767de02 58 /* ToDo: Clear memory contents, reset the SD, etc. */
bogdanm 0:eff01767de02 59 btle_init();
bogdanm 0:eff01767de02 60
bogdanm 0:eff01767de02 61 return BLE_ERROR_NONE;
bogdanm 0:eff01767de02 62 }
bogdanm 0:eff01767de02 63
bogdanm 0:eff01767de02 64 /**************************************************************************/
bogdanm 0:eff01767de02 65 /*!
bogdanm 0:eff01767de02 66 @brief Resets the BLE HW, removing any existing services and
bogdanm 0:eff01767de02 67 characteristics
bogdanm 0:eff01767de02 68
bogdanm 0:eff01767de02 69 @returns ble_error_t
bogdanm 0:eff01767de02 70
bogdanm 0:eff01767de02 71 @retval BLE_ERROR_NONE
bogdanm 0:eff01767de02 72 Everything executed properly
bogdanm 0:eff01767de02 73
bogdanm 0:eff01767de02 74 @section EXAMPLE
bogdanm 0:eff01767de02 75
bogdanm 0:eff01767de02 76 @code
bogdanm 0:eff01767de02 77
bogdanm 0:eff01767de02 78 @endcode
bogdanm 0:eff01767de02 79 */
bogdanm 0:eff01767de02 80 /**************************************************************************/
bogdanm 0:eff01767de02 81 ble_error_t nRF51822n::reset(void)
bogdanm 0:eff01767de02 82 {
bogdanm 0:eff01767de02 83 wait(0.5);
bogdanm 0:eff01767de02 84
bogdanm 0:eff01767de02 85 /* Wait for the radio to come back up */
bogdanm 0:eff01767de02 86 wait(1);
bogdanm 0:eff01767de02 87
bogdanm 0:eff01767de02 88 return BLE_ERROR_NONE;
bogdanm 0:eff01767de02 89 }