My fork of X_NUCLEO_IDB0XA1

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 #ifdef YOTTA_CFG_MBED_OS
00044     #include "mbed-drivers/mbed.h"
00045 #else
00046     #include "mbed.h"
00047 #endif 
00048 #include "ble/blecommon.h"
00049 #include "ble/BLEInstanceBase.h"
00050 #include "ble/BLE.h"
00051 #include "BlueNRGGap.h"
00052 #include "BlueNRGGattServer.h"
00053 #include "BlueNRGGattClient.h"
00054 
00055 
00056 class BlueNRGDevice : public BLEInstanceBase
00057 {
00058 
00059 public:
00060     BlueNRGDevice(PinName mosi, PinName miso, PinName sck, PinName cs, PinName rst, PinName irq);
00061     virtual ~BlueNRGDevice(void);
00062 
00063     virtual ble_error_t init(BLE::InstanceID_t instanceID, FunctionPointerWithContext<BLE::InitializationCompleteCallbackContext *> callback);
00064     virtual ble_error_t shutdown(void);   
00065     virtual const char *getVersion(void);
00066     virtual Gap&        getGap();
00067     virtual const Gap&  getGap() const;
00068     virtual GattServer& getGattServer();
00069     virtual const GattServer& getGattServer() const;
00070     virtual void        waitForEvent(void);
00071     
00072     virtual GattClient& getGattClient() {
00073         return BlueNRGGattClient::getInstance();
00074     }
00075 
00076     virtual SecurityManager& getSecurityManager() {
00077         return *sm;
00078     }
00079 
00080     virtual const SecurityManager& getSecurityManager() const {
00081         return *sm;
00082     }
00083     void reset(void);
00084     virtual bool hasInitialized(void) const {
00085         return isInitialized;
00086     }
00087 
00088     uint8_t getUpdaterHardwareVersion(uint8_t *hw_version);
00089     int updateFirmware(const uint8_t *fw_image, uint32_t fw_size);
00090     bool dataPresent();
00091     int32_t spiRead(uint8_t *buffer, uint8_t buff_size);
00092     int32_t spiWrite(uint8_t* data1, uint8_t* data2, uint8_t Nb_bytes1, uint8_t Nb_bytes2);
00093     void disable_irq();
00094     void enable_irq();
00095 
00096     virtual void processEvents();
00097     
00098 private:
00099     bool isInitialized;
00100 
00101     SPI         spi_;
00102     DigitalOut  nCS_;
00103     DigitalOut  rst_;
00104     InterruptIn irq_;
00105 
00106     //FIXME: TBI (by now just placeholders to let build
00107     /*** betzw: placeholders ***/
00108     SecurityManager *sm;
00109 };
00110 
00111 #endif