Previous version which works for my stm32f401 Nucleo board
Fork of X_NUCLEO_IDB0XA1 by
BlueNRGDevice.h@77:332b416123b4, 2015-06-23 (annotated)
- Committer:
- Andrea Palmieri
- Date:
- Tue Jun 23 17:44:59 2015 +0200
- Revision:
- 77:332b416123b4
- Parent:
- 75:8d763da1ccc7
- Child:
- 93:728699ac5613
Update BLE_API and mbed Libs
- BLE_API Revision 713 corresponding to github Release 0.4.0 (commit d80fec885c)
- mbed Revision 101
Signed-off-by: Andrea Palmieri <andrea.palmieri@st.com>
Who changed what in which revision?
User | Revision | Line number | New 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>© 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 GattClient& getGattClient(); |
Andrea Palmieri |
77:332b416123b4 | 65 | virtual SecurityManager& getSecurityManager(); |
Andrea Palmieri |
77:332b416123b4 | 66 | virtual const SecurityManager& getSecurityManager() const; |
Andrea Palmieri |
77:332b416123b4 | 67 | virtual void waitForEvent(void); |
Silvio Lucio Oliva |
70:d20d30f59b1c | 68 | |
Andrea Palmieri |
77:332b416123b4 | 69 | ble_error_t reset(void); |
Silvio Lucio Oliva |
70:d20d30f59b1c | 70 | bool getIsInitialized(void); |
Antonio Vilei |
74:c4526f8284d5 | 71 | |
Antonio Vilei |
74:c4526f8284d5 | 72 | bool dataPresent(); |
Antonio Vilei |
74:c4526f8284d5 | 73 | int32_t spiRead(uint8_t *buffer, uint8_t buff_size); |
Antonio Vilei |
74:c4526f8284d5 | 74 | int32_t spiWrite(uint8_t* data1, uint8_t* data2, uint8_t Nb_bytes1, uint8_t Nb_bytes2); |
Antonio Vilei |
74:c4526f8284d5 | 75 | void disable_irq(); |
Andrea Palmieri |
77:332b416123b4 | 76 | void enable_irq(); |
Silvio Lucio Oliva |
70:d20d30f59b1c | 77 | |
Silvio Lucio Oliva |
70:d20d30f59b1c | 78 | private: |
Silvio Lucio Oliva |
70:d20d30f59b1c | 79 | bool isInitialized; |
Antonio Vilei |
74:c4526f8284d5 | 80 | |
Antonio Vilei |
74:c4526f8284d5 | 81 | SPI spi_; |
Antonio Vilei |
74:c4526f8284d5 | 82 | DigitalOut nCS_; |
Antonio Vilei |
74:c4526f8284d5 | 83 | DigitalOut rst_; |
Antonio Vilei |
74:c4526f8284d5 | 84 | InterruptIn irq_; |
Silvio Lucio Oliva |
70:d20d30f59b1c | 85 | }; |
Silvio Lucio Oliva |
70:d20d30f59b1c | 86 | |
Silvio Lucio Oliva |
70:d20d30f59b1c | 87 | #endif |