ver:init

Committer:
iv123
Date:
Sun Jun 18 16:11:03 2017 +0000
Revision:
0:4946262d6030
Initial commit

Who changed what in which revision?

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