Previous version which works for my stm32f401 Nucleo board

Fork of X_NUCLEO_IDB0XA1 by ST

Committer:
Wolfgang Betz
Date:
Thu Jul 23 14:48:36 2015 +0200
Revision:
93:728699ac5613
Parent:
92:709d44dc869a
Parent:
77:332b416123b4
Child:
95:e1f7ce04e71b
Merge branch 'master' of hg::http://wobetz@developer.mbed.org/teams/ST-Expansion-SW-Team/code/X_NUCLEO_IDB0XA1 into idb0xa1-split

Who changed what in which revision?

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