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