HW layer for the Nucleo board, it only work with old BLE_API
Dependents: Hello_BLE F446RE-BLE
Fork of X_NUCLEO_IDB0XA1 by
BlueNRGDevice.h@129:57997390c086, 2015-11-03 (annotated)
- Committer:
- leonardoaraujosantos
- Date:
- Tue Nov 03 23:10:27 2015 +0000
- Revision:
- 129:57997390c086
- Parent:
- 120:554a95afbd16
Changing pin D13
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 void waitForEvent(void); |
apalmieri | 110:1232b39de5cc | 65 | |
apalmieri | 110:1232b39de5cc | 66 | virtual GattClient& getGattClient() { |
apalmieri | 110:1232b39de5cc | 67 | return *gattClient; |
apalmieri | 110:1232b39de5cc | 68 | } |
apalmieri | 110:1232b39de5cc | 69 | |
apalmieri | 110:1232b39de5cc | 70 | virtual SecurityManager& getSecurityManager() { |
apalmieri | 110:1232b39de5cc | 71 | return *sm; |
apalmieri | 110:1232b39de5cc | 72 | } |
apalmieri | 110:1232b39de5cc | 73 | |
apalmieri | 110:1232b39de5cc | 74 | virtual const SecurityManager& getSecurityManager() const { |
apalmieri | 110:1232b39de5cc | 75 | return *sm; |
apalmieri | 110:1232b39de5cc | 76 | } |
Andrea Palmieri |
77:332b416123b4 | 77 | ble_error_t reset(void); |
Silvio Lucio Oliva |
70:d20d30f59b1c | 78 | bool getIsInitialized(void); |
Antonio Vilei |
74:c4526f8284d5 | 79 | |
Antonio Vilei |
74:c4526f8284d5 | 80 | bool dataPresent(); |
Antonio Vilei |
74:c4526f8284d5 | 81 | int32_t spiRead(uint8_t *buffer, uint8_t buff_size); |
Antonio Vilei |
74:c4526f8284d5 | 82 | int32_t spiWrite(uint8_t* data1, uint8_t* data2, uint8_t Nb_bytes1, uint8_t Nb_bytes2); |
Antonio Vilei |
74:c4526f8284d5 | 83 | void disable_irq(); |
Andrea Palmieri |
77:332b416123b4 | 84 | void enable_irq(); |
Silvio Lucio Oliva |
70:d20d30f59b1c | 85 | |
Silvio Lucio Oliva |
70:d20d30f59b1c | 86 | private: |
Silvio Lucio Oliva |
70:d20d30f59b1c | 87 | bool isInitialized; |
Antonio Vilei |
74:c4526f8284d5 | 88 | |
Antonio Vilei |
74:c4526f8284d5 | 89 | SPI spi_; |
Antonio Vilei |
74:c4526f8284d5 | 90 | DigitalOut nCS_; |
Antonio Vilei |
74:c4526f8284d5 | 91 | DigitalOut rst_; |
Antonio Vilei |
74:c4526f8284d5 | 92 | InterruptIn irq_; |
apalmieri | 110:1232b39de5cc | 93 | |
apalmieri | 110:1232b39de5cc | 94 | //FIXME: TBI (by now just placeholders to let build |
apalmieri | 110:1232b39de5cc | 95 | /*** betzw: placeholders ***/ |
apalmieri | 110:1232b39de5cc | 96 | GattClient *gattClient; |
apalmieri | 110:1232b39de5cc | 97 | SecurityManager *sm; |
Silvio Lucio Oliva |
70:d20d30f59b1c | 98 | }; |
Silvio Lucio Oliva |
70:d20d30f59b1c | 99 | |
Silvio Lucio Oliva |
70:d20d30f59b1c | 100 | #endif |