BLE_API wrapper library for STMicroelectronics' BlueNRG Bluetooth Low Energy expansion board shield (Component)

Dependents:   Nucleo_Zumo_BLE_IDB04A1 contest_IOT5 contest_IOT6 contest_IOT_10 ... more

Fork of X_NUCLEO_IDB0XA1 by ST Expansion SW Team

Arduino Connector Compatibility Warning

X-NUCLEO-IDB04A1 and X-NUCLEO-IDB05A1 are Arduino compatible with an exception: instead of using pin D13 for the SPI clock, they use pin D3. The default configuration for this library is having the SPI clock on pin D3.

To be fully Arduino compatible, X-NUCLEO-IDB04A1 and X-NUCLEO-IDB05A1 need a small HW patch.

For X-NUCLEO-IDB04A1 this patch consists in removing zero resistor R10 and instead soldering zero resistor R11. For X-NUCLEO-IDB05A1 this patch consists in removing zero resistor R4 and instead soldering zero resistor R6.

In case you patch your board, then you also have to configure this library to use pin D13 to drive the SPI clock (see macro IDB0XA1_D13_PATCH in file x_nucleo_idb0xa1_targets.h).

If you use pin D13 for the SPI clock, please be aware that on STM32 Nucleo boards you may not drive the LED, otherwise you will get a conflict: the LED on STM32 Nucleo boards is connected to pin D13.

Referring to the current list of tested platforms (see X-NUCLEO-IDB04A1 and X-NUCLEO-IDB05A1 pages), the patch is required by ST-Nucleo-F103RB; ST-Nucleo-F302R8; ST-Nucleo-F411RE; and ST-Nucleo-F446RE.

Committer:
Andrea Palmieri
Date:
Fri Sep 16 12:03:25 2016 +0200
Revision:
307:fa98703ece8e
Parent:
278:a5209d8cfd61
Sync with 21bfd161ace255bb6214d6b74cae1fd30b3e24c9

2016-09-16 11:53:47+02:00: Andrea Palmieri
Get rid of warnings

Who changed what in which revision?

UserRevisionLine numberNew contents of line
Wolfgang Betz 130:770ce14d3d15 1 /* mbed Microcontroller Library
Wolfgang Betz 130:770ce14d3d15 2 * Copyright (c) 2006-2013 ARM Limited
Wolfgang Betz 130:770ce14d3d15 3 *
Wolfgang Betz 130:770ce14d3d15 4 * Licensed under the Apache License, Version 2.0 (the "License");
Wolfgang Betz 130:770ce14d3d15 5 * you may not use this file except in compliance with the License.
Wolfgang Betz 130:770ce14d3d15 6 * You may obtain a copy of the License at
Wolfgang Betz 130:770ce14d3d15 7 *
Wolfgang Betz 130:770ce14d3d15 8 * http://www.apache.org/licenses/LICENSE-2.0
Wolfgang Betz 130:770ce14d3d15 9 *
Wolfgang Betz 130:770ce14d3d15 10 * Unless required by applicable law or agreed to in writing, software
Wolfgang Betz 130:770ce14d3d15 11 * distributed under the License is distributed on an "AS IS" BASIS,
Wolfgang Betz 130:770ce14d3d15 12 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
Wolfgang Betz 130:770ce14d3d15 13 * See the License for the specific language governing permissions and
Wolfgang Betz 130:770ce14d3d15 14 * limitations under the License.
Wolfgang Betz 130:770ce14d3d15 15 */
Wolfgang Betz 130:770ce14d3d15 16
Wolfgang Betz 130:770ce14d3d15 17 /**
Wolfgang Betz 130:770ce14d3d15 18 ******************************************************************************
Wolfgang Betz 130:770ce14d3d15 19 * @file BlueNRGDevice.h
Wolfgang Betz 130:770ce14d3d15 20 * @author STMicroelectronics
Wolfgang Betz 130:770ce14d3d15 21 * @brief Header file for BLEDeviceInstanceBase based BlueNRGDevice
Wolfgang Betz 130:770ce14d3d15 22 ******************************************************************************
Wolfgang Betz 130:770ce14d3d15 23 * @copy
Wolfgang Betz 130:770ce14d3d15 24 *
Wolfgang Betz 130:770ce14d3d15 25 * THE PRESENT FIRMWARE WHICH IS FOR GUIDANCE ONLY AIMS AT PROVIDING CUSTOMERS
Wolfgang Betz 130:770ce14d3d15 26 * WITH CODING INFORMATION REGARDING THEIR PRODUCTS IN ORDER FOR THEM TO SAVE
Wolfgang Betz 130:770ce14d3d15 27 * TIME. AS A RESULT, STMICROELECTRONICS SHALL NOT BE HELD LIABLE FOR ANY
Wolfgang Betz 130:770ce14d3d15 28 * DIRECT, INDIRECT OR CONSEQUENTIAL DAMAGES WITH RESPECT TO ANY CLAIMS ARISING
Wolfgang Betz 130:770ce14d3d15 29 * FROM THE CONTENT OF SUCH FIRMWARE AND/OR THE USE MADE BY CUSTOMERS OF THE
Wolfgang Betz 130:770ce14d3d15 30 * CODING INFORMATION CONTAINED HEREIN IN CONNECTION WITH THEIR PRODUCTS.
Wolfgang Betz 130:770ce14d3d15 31 *
Wolfgang Betz 130:770ce14d3d15 32 * <h2><center>&copy; COPYRIGHT 2013 STMicroelectronics</center></h2>
Wolfgang Betz 130:770ce14d3d15 33 */
Wolfgang Betz 130:770ce14d3d15 34
Wolfgang Betz 130:770ce14d3d15 35 #ifndef __BLUENRG_DEVICE_H__
Wolfgang Betz 130:770ce14d3d15 36 #define __BLUENRG_DEVICE_H__
Wolfgang Betz 130:770ce14d3d15 37
Wolfgang Betz 130:770ce14d3d15 38 #define BLUENRG
Wolfgang Betz 130:770ce14d3d15 39 #define DEBUG_BLUENRG_USER
Wolfgang Betz 130:770ce14d3d15 40
Wolfgang Betz 130:770ce14d3d15 41 #include "btle.h"
Wolfgang Betz 130:770ce14d3d15 42
Vincent Coubard 278:a5209d8cfd61 43 #ifdef YOTTA_CFG_MBED_OS
Vincent Coubard 278:a5209d8cfd61 44 #include "mbed-drivers/mbed.h"
Vincent Coubard 278:a5209d8cfd61 45 #else
Vincent Coubard 278:a5209d8cfd61 46 #include "mbed.h"
Vincent Coubard 278:a5209d8cfd61 47 #endif
Wolfgang Betz 131:e09947216ccb 48 #include "ble/blecommon.h"
Andrea Palmieri 167:abc42e7158a6 49 #include "ble/BLEInstanceBase.h"
Wolfgang Betz 131:e09947216ccb 50 #include "ble/BLE.h"
Wolfgang Betz 130:770ce14d3d15 51 #include "BlueNRGGap.h"
Wolfgang Betz 130:770ce14d3d15 52 #include "BlueNRGGattServer.h"
Wolfgang Betz 132:51056160fa4a 53 #include "BlueNRGGattClient.h"
Wolfgang Betz 130:770ce14d3d15 54
Wolfgang Betz 130:770ce14d3d15 55
Wolfgang Betz 130:770ce14d3d15 56 class BlueNRGDevice : public BLEInstanceBase
Wolfgang Betz 130:770ce14d3d15 57 {
Wolfgang Betz 130:770ce14d3d15 58
Wolfgang Betz 130:770ce14d3d15 59 public:
Wolfgang Betz 130:770ce14d3d15 60 BlueNRGDevice(PinName mosi, PinName miso, PinName sck, PinName cs, PinName rst, PinName irq);
Wolfgang Betz 130:770ce14d3d15 61 virtual ~BlueNRGDevice(void);
Wolfgang Betz 130:770ce14d3d15 62
Andrea Palmieri 167:abc42e7158a6 63 virtual ble_error_t init(BLE::InstanceID_t instanceID, FunctionPointerWithContext<BLE::InitializationCompleteCallbackContext *> callback);
Wolfgang Betz 130:770ce14d3d15 64 virtual ble_error_t shutdown(void);
Wolfgang Betz 130:770ce14d3d15 65 virtual const char *getVersion(void);
Wolfgang Betz 130:770ce14d3d15 66 virtual Gap& getGap();
Wolfgang Betz 130:770ce14d3d15 67 virtual const Gap& getGap() const;
Wolfgang Betz 130:770ce14d3d15 68 virtual GattServer& getGattServer();
Wolfgang Betz 130:770ce14d3d15 69 virtual const GattServer& getGattServer() const;
Wolfgang Betz 130:770ce14d3d15 70 virtual void waitForEvent(void);
Wolfgang Betz 130:770ce14d3d15 71
Wolfgang Betz 130:770ce14d3d15 72 virtual GattClient& getGattClient() {
Wolfgang Betz 132:51056160fa4a 73 return BlueNRGGattClient::getInstance();
Wolfgang Betz 130:770ce14d3d15 74 }
Wolfgang Betz 130:770ce14d3d15 75
Wolfgang Betz 130:770ce14d3d15 76 virtual SecurityManager& getSecurityManager() {
Wolfgang Betz 130:770ce14d3d15 77 return *sm;
Wolfgang Betz 130:770ce14d3d15 78 }
Wolfgang Betz 130:770ce14d3d15 79
Wolfgang Betz 130:770ce14d3d15 80 virtual const SecurityManager& getSecurityManager() const {
Wolfgang Betz 130:770ce14d3d15 81 return *sm;
Wolfgang Betz 130:770ce14d3d15 82 }
Andrea Palmieri 229:9981f62cdb1a 83 void reset(void);
Andrea Palmieri 167:abc42e7158a6 84 virtual bool hasInitialized(void) const {
Andrea Palmieri 167:abc42e7158a6 85 return isInitialized;
Andrea Palmieri 167:abc42e7158a6 86 }
Wolfgang Betz 130:770ce14d3d15 87
Antonio Vilei 245:6830f71c197c 88 uint8_t getUpdaterHardwareVersion(uint8_t *hw_version);
Antonio Vilei 245:6830f71c197c 89 int updateFirmware(const uint8_t *fw_image, uint32_t fw_size);
Wolfgang Betz 130:770ce14d3d15 90 bool dataPresent();
Wolfgang Betz 130:770ce14d3d15 91 int32_t spiRead(uint8_t *buffer, uint8_t buff_size);
Wolfgang Betz 130:770ce14d3d15 92 int32_t spiWrite(uint8_t* data1, uint8_t* data2, uint8_t Nb_bytes1, uint8_t Nb_bytes2);
Wolfgang Betz 130:770ce14d3d15 93 void disable_irq();
Wolfgang Betz 130:770ce14d3d15 94 void enable_irq();
Vincent Coubard 264:1e754a01869e 95
Vincent Coubard 264:1e754a01869e 96 virtual void processEvents();
Wolfgang Betz 130:770ce14d3d15 97
Wolfgang Betz 130:770ce14d3d15 98 private:
Wolfgang Betz 130:770ce14d3d15 99 bool isInitialized;
Wolfgang Betz 130:770ce14d3d15 100
Wolfgang Betz 130:770ce14d3d15 101 SPI spi_;
Wolfgang Betz 130:770ce14d3d15 102 DigitalOut nCS_;
Wolfgang Betz 130:770ce14d3d15 103 DigitalOut rst_;
Wolfgang Betz 130:770ce14d3d15 104 InterruptIn irq_;
Wolfgang Betz 130:770ce14d3d15 105
Wolfgang Betz 130:770ce14d3d15 106 //FIXME: TBI (by now just placeholders to let build
Wolfgang Betz 130:770ce14d3d15 107 /*** betzw: placeholders ***/
Wolfgang Betz 130:770ce14d3d15 108 SecurityManager *sm;
Wolfgang Betz 130:770ce14d3d15 109 };
Wolfgang Betz 130:770ce14d3d15 110
Vincent Coubard 264:1e754a01869e 111 #endif