project

Fork of X_NUCLEO_IDB0XA1 by ST

Embed: (wiki syntax)

« Back to documentation index

Show/hide line numbers BlueNRGDevice.h Source File

BlueNRGDevice.h

Go to the documentation of this file.
00001 /* mbed Microcontroller Library
00002 * Copyright (c) 2006-2013 ARM Limited
00003 *
00004 * Licensed under the Apache License, Version 2.0 (the "License");
00005 * you may not use this file except in compliance with the License.
00006 * You may obtain a copy of the License at
00007 *
00008 *     http://www.apache.org/licenses/LICENSE-2.0
00009 *
00010 * Unless required by applicable law or agreed to in writing, software
00011 * distributed under the License is distributed on an "AS IS" BASIS,
00012 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
00013 * See the License for the specific language governing permissions and
00014 * limitations under the License.
00015 */
00016 
00017 /**
00018   ******************************************************************************
00019   * @file    BlueNRGDevice.h 
00020   * @author  STMicroelectronics
00021   * @brief   Header file for BLEDeviceInstanceBase based BlueNRGDevice
00022   ******************************************************************************
00023   * @copy
00024   *
00025   * THE PRESENT FIRMWARE WHICH IS FOR GUIDANCE ONLY AIMS AT PROVIDING CUSTOMERS
00026   * WITH CODING INFORMATION REGARDING THEIR PRODUCTS IN ORDER FOR THEM TO SAVE
00027   * TIME. AS A RESULT, STMICROELECTRONICS SHALL NOT BE HELD LIABLE FOR ANY
00028   * DIRECT, INDIRECT OR CONSEQUENTIAL DAMAGES WITH RESPECT TO ANY CLAIMS ARISING
00029   * FROM THE CONTENT OF SUCH FIRMWARE AND/OR THE USE MADE BY CUSTOMERS OF THE
00030   * CODING INFORMATION CONTAINED HEREIN IN CONNECTION WITH THEIR PRODUCTS.
00031   *
00032   * <h2><center>&copy; COPYRIGHT 2013 STMicroelectronics</center></h2>
00033   */ 
00034   
00035 #ifndef __BLUENRG_DEVICE_H__
00036 #define __BLUENRG_DEVICE_H__
00037 
00038 #define BLUENRG
00039 #define DEBUG_BLUENRG_USER
00040 
00041 #include "btle.h"
00042 
00043 #include "mbed.h"
00044 #include "ble/blecommon.h"
00045 #include "ble/BLEInstanceBase.h"
00046 #include "ble/BLE.h"
00047 #include "BlueNRGGap.h"
00048 #include "BlueNRGGattServer.h"
00049 #include "BlueNRGGattClient.h"
00050 
00051 
00052 class BlueNRGDevice : public BLEInstanceBase
00053 {
00054 
00055 public:
00056     BlueNRGDevice(PinName mosi, PinName miso, PinName sck, PinName cs, PinName rst, PinName irq);
00057     virtual ~BlueNRGDevice(void);
00058 
00059     virtual ble_error_t init(BLE::InstanceID_t instanceID, FunctionPointerWithContext<BLE::InitializationCompleteCallbackContext *> callback);
00060     virtual ble_error_t shutdown(void);   
00061     virtual const char *getVersion(void);
00062     virtual Gap&        getGap();
00063     virtual const Gap&  getGap() const;
00064     virtual GattServer& getGattServer();
00065     virtual const GattServer& getGattServer() const;
00066     virtual void        waitForEvent(void);
00067     
00068     virtual GattClient& getGattClient() {
00069         return BlueNRGGattClient::getInstance();
00070     }
00071 
00072     virtual SecurityManager& getSecurityManager() {
00073         return *sm;
00074     }
00075 
00076     virtual const SecurityManager& getSecurityManager() const {
00077         return *sm;
00078     }
00079     ble_error_t reset(void);
00080     virtual bool hasInitialized(void) const {
00081         return isInitialized;
00082     }
00083 
00084     bool dataPresent();
00085     int32_t spiRead(uint8_t *buffer, uint8_t buff_size);
00086     int32_t spiWrite(uint8_t* data1, uint8_t* data2, uint8_t Nb_bytes1, uint8_t Nb_bytes2);
00087     void disable_irq();
00088     void enable_irq();
00089     
00090 private:
00091     bool isInitialized;
00092 
00093     SPI         spi_;
00094     DigitalOut  nCS_;
00095     DigitalOut  rst_;
00096     InterruptIn irq_;
00097 
00098     //FIXME: TBI (by now just placeholders to let build
00099     /*** betzw: placeholders ***/
00100     SecurityManager *sm;
00101 };
00102 
00103 #endif