mirror of https://github.com/ARMmbed/mbed-os.git
				
				
				
			Remove Arm Beetle target
Deprecation in preparation for Mbed OS 5.12 and move to IAR8 and ARMC6pull/9833/head
							parent
							
								
									5f38878f3a
								
							
						
					
					
						commit
						176e5779ce
					
				| 
						 | 
				
			
			@ -1,77 +0,0 @@
 | 
			
		|||
/*
 | 
			
		||||
 * PackageLicenseDeclared: Apache-2.0
 | 
			
		||||
 * Copyright (c) 2016 ARM Limited
 | 
			
		||||
 *
 | 
			
		||||
 * Licensed under the Apache License, Version 2.0 (the "License");
 | 
			
		||||
 * you may not use this file except in compliance with the License.
 | 
			
		||||
 * You may obtain a copy of the License at
 | 
			
		||||
 *
 | 
			
		||||
 * http://www.apache.org/licenses/LICENSE-2.0
 | 
			
		||||
 *
 | 
			
		||||
 * Unless required by applicable law or agreed to in writing, software
 | 
			
		||||
 * distributed under the License is distributed on an "AS IS" BASIS,
 | 
			
		||||
 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
 | 
			
		||||
 * See the License for the specific language governing permissions and
 | 
			
		||||
 * limitations under the License.
 | 
			
		||||
 */
 | 
			
		||||
 | 
			
		||||
#ifndef _ARMBLE_H_
 | 
			
		||||
#define _ARMBLE_H_
 | 
			
		||||
 | 
			
		||||
#include "BLE.h"
 | 
			
		||||
#include "blecommon.h"
 | 
			
		||||
#include "BLEInstanceBase.h"
 | 
			
		||||
 | 
			
		||||
#include "ArmGap.h"
 | 
			
		||||
#include "ArmGattServer.h"
 | 
			
		||||
#include "ArmGattClient.h"
 | 
			
		||||
#include "ArmSecurityManager.h"
 | 
			
		||||
 | 
			
		||||
class ArmBLE : public BLEInstanceBase
 | 
			
		||||
{
 | 
			
		||||
public:
 | 
			
		||||
    ArmBLE(void);
 | 
			
		||||
    virtual ~ArmBLE(void);
 | 
			
		||||
 | 
			
		||||
    virtual ble_error_t init(BLE::InstanceID_t instanceID, FunctionPointerWithContext<BLE::InitializationCompleteCallbackContext *> initCallback);
 | 
			
		||||
    virtual bool        hasInitialized(void) const {
 | 
			
		||||
        return initialized;
 | 
			
		||||
    }
 | 
			
		||||
    virtual ble_error_t shutdown(void);
 | 
			
		||||
    virtual const char *getVersion(void);
 | 
			
		||||
 | 
			
		||||
    virtual Gap &getGap() {
 | 
			
		||||
        return ArmGap::getInstance();
 | 
			
		||||
    };
 | 
			
		||||
    virtual const Gap &getGap() const {
 | 
			
		||||
        return ArmGap::getInstance();
 | 
			
		||||
    };
 | 
			
		||||
    virtual GattServer &getGattServer() {
 | 
			
		||||
        return ArmGattServer::getInstance();
 | 
			
		||||
    };
 | 
			
		||||
    virtual const GattServer &getGattServer() const {
 | 
			
		||||
        return ArmGattServer::getInstance();
 | 
			
		||||
    };
 | 
			
		||||
    virtual GattClient &getGattClient() {
 | 
			
		||||
        return ArmGattClient::getInstance();
 | 
			
		||||
    };
 | 
			
		||||
    virtual SecurityManager &getSecurityManager() {
 | 
			
		||||
        return ArmSecurityManager::getInstance();
 | 
			
		||||
    };
 | 
			
		||||
    virtual const SecurityManager &getSecurityManager() const {
 | 
			
		||||
        return ArmSecurityManager::getInstance();
 | 
			
		||||
    };
 | 
			
		||||
 | 
			
		||||
    virtual void waitForEvent(void);
 | 
			
		||||
 | 
			
		||||
    virtual void processEvents();
 | 
			
		||||
 | 
			
		||||
private:
 | 
			
		||||
    bool              initialized;
 | 
			
		||||
    BLE::InstanceID_t instanceID;
 | 
			
		||||
 | 
			
		||||
    static void timeoutCallback(void);
 | 
			
		||||
    void callDispatcher(void);
 | 
			
		||||
};
 | 
			
		||||
 | 
			
		||||
#endif /* _ARMBLE_H_ */
 | 
			
		||||
| 
						 | 
				
			
			@ -1,91 +0,0 @@
 | 
			
		|||
/*
 | 
			
		||||
 * PackageLicenseDeclared: Apache-2.0
 | 
			
		||||
 * Copyright (c) 2016 ARM Limited
 | 
			
		||||
 *
 | 
			
		||||
 * Licensed under the Apache License, Version 2.0 (the "License");
 | 
			
		||||
 * you may not use this file except in compliance with the License.
 | 
			
		||||
 * You may obtain a copy of the License at
 | 
			
		||||
 *
 | 
			
		||||
 * http://www.apache.org/licenses/LICENSE-2.0
 | 
			
		||||
 *
 | 
			
		||||
 * Unless required by applicable law or agreed to in writing, software
 | 
			
		||||
 * distributed under the License is distributed on an "AS IS" BASIS,
 | 
			
		||||
 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
 | 
			
		||||
 * See the License for the specific language governing permissions and
 | 
			
		||||
 * limitations under the License.
 | 
			
		||||
 */
 | 
			
		||||
 | 
			
		||||
#ifndef _ARM_GAP_H_
 | 
			
		||||
#define _ARM_GAP_H_
 | 
			
		||||
 | 
			
		||||
#include "mbed.h"
 | 
			
		||||
#include "blecommon.h"
 | 
			
		||||
#include "GapAdvertisingParams.h"
 | 
			
		||||
#include "GapAdvertisingData.h"
 | 
			
		||||
#include "Gap.h"
 | 
			
		||||
#include "GapScanningParams.h"
 | 
			
		||||
#include "dm_api.h"
 | 
			
		||||
#include "att_api.h"
 | 
			
		||||
 | 
			
		||||
/**************************************************************************/
 | 
			
		||||
/*!
 | 
			
		||||
    \brief
 | 
			
		||||
 | 
			
		||||
*/
 | 
			
		||||
/**************************************************************************/
 | 
			
		||||
class ArmGap : public Gap
 | 
			
		||||
{
 | 
			
		||||
public:
 | 
			
		||||
    static ArmGap &getInstance();
 | 
			
		||||
 | 
			
		||||
    /* Functions that must be implemented from Gap */
 | 
			
		||||
    virtual ble_error_t setAddress(AddressType_t  type,  const Address_t address);
 | 
			
		||||
    virtual ble_error_t getAddress(AddressType_t *typeP, Address_t address);
 | 
			
		||||
    virtual ble_error_t setAdvertisingData(const GapAdvertisingData &, const GapAdvertisingData &);
 | 
			
		||||
 | 
			
		||||
    #define BLE_GAP_ADV_INTERVAL_MIN        0x0020 /**< Minimum Advertising interval in 625 us units, i.e. 20 ms. */
 | 
			
		||||
    #define BLE_GAP_ADV_NONCON_INTERVAL_MIN 0x00A0 /**< Minimum Advertising interval in 625 us units for non connectable mode, i.e. 100 ms. */
 | 
			
		||||
    #define BLE_GAP_ADV_INTERVAL_MAX        0x4000 /**< Armum Advertising interval in 625 us units, i.e. 10.24 s. */
 | 
			
		||||
 | 
			
		||||
    virtual uint16_t getMinAdvertisingInterval(void) const { return BLE_GAP_ADV_INTERVAL_MIN; }
 | 
			
		||||
    virtual uint16_t getMinNonConnectableAdvertisingInterval(void) const { return BLE_GAP_ADV_NONCON_INTERVAL_MIN; }
 | 
			
		||||
    virtual uint16_t getMaxAdvertisingInterval(void) const { return BLE_GAP_ADV_INTERVAL_MAX; }
 | 
			
		||||
 | 
			
		||||
    virtual ble_error_t startAdvertising(const GapAdvertisingParams &);
 | 
			
		||||
    virtual ble_error_t stopAdvertising(void);
 | 
			
		||||
    virtual ble_error_t disconnect(Handle_t connectionHandle, DisconnectionReason_t reason);
 | 
			
		||||
    virtual ble_error_t disconnect(DisconnectionReason_t reason);
 | 
			
		||||
 | 
			
		||||
    virtual ble_error_t setDeviceName(const uint8_t *deviceName);
 | 
			
		||||
    virtual ble_error_t getDeviceName(uint8_t *deviceName, unsigned *lengthP);
 | 
			
		||||
    virtual ble_error_t setAppearance(GapAdvertisingData::Appearance appearance);
 | 
			
		||||
    virtual ble_error_t getAppearance(GapAdvertisingData::Appearance *appearanceP);
 | 
			
		||||
 | 
			
		||||
    virtual ble_error_t setTxPower(int8_t txPower);
 | 
			
		||||
    virtual void        getPermittedTxPowerValues(const int8_t **valueArrayPP, size_t *countP);
 | 
			
		||||
 | 
			
		||||
    void     setConnectionHandle(uint16_t m_connectionHandle);
 | 
			
		||||
    uint16_t getConnectionHandle(void);
 | 
			
		||||
 | 
			
		||||
    virtual ble_error_t getPreferredConnectionParams(ConnectionParams_t *params);
 | 
			
		||||
    virtual ble_error_t setPreferredConnectionParams(const ConnectionParams_t *params);
 | 
			
		||||
    virtual ble_error_t updateConnectionParams(Handle_t handle, const ConnectionParams_t *params);
 | 
			
		||||
 | 
			
		||||
    virtual ble_error_t startRadioScan(const GapScanningParams &scanningParams);
 | 
			
		||||
    virtual ble_error_t stopScan(void);
 | 
			
		||||
 | 
			
		||||
    void     advertisingStopped(void);
 | 
			
		||||
 | 
			
		||||
private:
 | 
			
		||||
    uint16_t m_connectionHandle;
 | 
			
		||||
    addr_type_t m_type;
 | 
			
		||||
    ArmGap() {
 | 
			
		||||
        m_connectionHandle = DM_CONN_ID_NONE;
 | 
			
		||||
        m_type = BLEProtocol::AddressType::RANDOM_STATIC;
 | 
			
		||||
    }
 | 
			
		||||
 | 
			
		||||
    ArmGap(ArmGap const &);
 | 
			
		||||
    void operator=(ArmGap const &);
 | 
			
		||||
};
 | 
			
		||||
 | 
			
		||||
#endif /* _ARM_GAP_H_ */
 | 
			
		||||
| 
						 | 
				
			
			@ -1,42 +0,0 @@
 | 
			
		|||
/*
 | 
			
		||||
 * PackageLicenseDeclared: Apache-2.0
 | 
			
		||||
 * Copyright (c) 2016 ARM Limited
 | 
			
		||||
 *
 | 
			
		||||
 * Licensed under the Apache License, Version 2.0 (the "License");
 | 
			
		||||
 * you may not use this file except in compliance with the License.
 | 
			
		||||
 * You may obtain a copy of the License at
 | 
			
		||||
 *
 | 
			
		||||
 * http://www.apache.org/licenses/LICENSE-2.0
 | 
			
		||||
 *
 | 
			
		||||
 * Unless required by applicable law or agreed to in writing, software
 | 
			
		||||
 * distributed under the License is distributed on an "AS IS" BASIS,
 | 
			
		||||
 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
 | 
			
		||||
 * See the License for the specific language governing permissions and
 | 
			
		||||
 * limitations under the License.
 | 
			
		||||
 */
 | 
			
		||||
 | 
			
		||||
#ifndef _ARM_GATT_CLIENT_H_
 | 
			
		||||
#define _ARM_GATT_CLIENT_H_
 | 
			
		||||
 | 
			
		||||
#include <stddef.h>
 | 
			
		||||
 | 
			
		||||
#include "GattClient.h"
 | 
			
		||||
 | 
			
		||||
class ArmGattClient : public GattClient
 | 
			
		||||
{
 | 
			
		||||
public:
 | 
			
		||||
    static ArmGattClient &getInstance() {
 | 
			
		||||
        static ArmGattClient m_instance;
 | 
			
		||||
        return m_instance;
 | 
			
		||||
    }
 | 
			
		||||
 | 
			
		||||
public:
 | 
			
		||||
    ArmGattClient() {
 | 
			
		||||
        /* empty */
 | 
			
		||||
    }
 | 
			
		||||
 | 
			
		||||
private:
 | 
			
		||||
 | 
			
		||||
};
 | 
			
		||||
 | 
			
		||||
#endif /* _ARM_GATT_CLIENT_H_ */
 | 
			
		||||
| 
						 | 
				
			
			@ -1,68 +0,0 @@
 | 
			
		|||
/*
 | 
			
		||||
 * PackageLicenseDeclared: Apache-2.0
 | 
			
		||||
 * Copyright (c) 2016 ARM Limited
 | 
			
		||||
 *
 | 
			
		||||
 * Licensed under the Apache License, Version 2.0 (the "License");
 | 
			
		||||
 * you may not use this file except in compliance with the License.
 | 
			
		||||
 * You may obtain a copy of the License at
 | 
			
		||||
 *
 | 
			
		||||
 * http://www.apache.org/licenses/LICENSE-2.0
 | 
			
		||||
 *
 | 
			
		||||
 * Unless required by applicable law or agreed to in writing, software
 | 
			
		||||
 * distributed under the License is distributed on an "AS IS" BASIS,
 | 
			
		||||
 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
 | 
			
		||||
 * See the License for the specific language governing permissions and
 | 
			
		||||
 * limitations under the License.
 | 
			
		||||
 */
 | 
			
		||||
 | 
			
		||||
#ifndef _ARM_GATT_SERVER_H_
 | 
			
		||||
#define _ARM_GATT_SERVER_H_
 | 
			
		||||
 | 
			
		||||
#include <stddef.h>
 | 
			
		||||
 | 
			
		||||
#include "blecommon.h"
 | 
			
		||||
#include "GattServer.h"
 | 
			
		||||
#include "generic/wsf_types.h"
 | 
			
		||||
#include "att_api.h"
 | 
			
		||||
 | 
			
		||||
class ArmGattServer : public GattServer
 | 
			
		||||
{
 | 
			
		||||
public:
 | 
			
		||||
    static ArmGattServer &getInstance();
 | 
			
		||||
 | 
			
		||||
    /* Functions that must be implemented from GattServer */
 | 
			
		||||
    virtual ble_error_t addService(GattService &);
 | 
			
		||||
 | 
			
		||||
    virtual ble_error_t read(GattAttribute::Handle_t attributeHandle, uint8_t buffer[], uint16_t *lengthP);
 | 
			
		||||
    virtual ble_error_t read(Gap::Handle_t connectionHandle, GattAttribute::Handle_t attributeHandle, uint8_t buffer[], uint16_t *lengthP);
 | 
			
		||||
    virtual ble_error_t write(GattAttribute::Handle_t, const uint8_t[], uint16_t, bool localOnly = false);
 | 
			
		||||
    virtual ble_error_t write(Gap::Handle_t connectionHandle, GattAttribute::Handle_t, const uint8_t[], uint16_t, bool localOnly = false);
 | 
			
		||||
 | 
			
		||||
    virtual ble_error_t areUpdatesEnabled(const GattCharacteristic &characteristic, bool *enabledP);
 | 
			
		||||
    virtual ble_error_t areUpdatesEnabled(Gap::Handle_t connectionHandle, const GattCharacteristic &characteristic, bool *enabledP);
 | 
			
		||||
 | 
			
		||||
    virtual bool isOnDataReadAvailable() const { return true; }
 | 
			
		||||
 | 
			
		||||
private:
 | 
			
		||||
    static void cccCback(attsCccEvt_t *pEvt);
 | 
			
		||||
    static void attCback(attEvt_t *pEvt);
 | 
			
		||||
    static uint8_t attsReadCback(dmConnId_t connId, uint16_t handle, uint8_t operation, uint16_t offset, attsAttr_t *pAttr);
 | 
			
		||||
    static uint8_t attsWriteCback(dmConnId_t connId, uint16_t handle, uint8_t operation, uint16_t offset, uint16_t len, uint8_t *pValue, attsAttr_t *pAttr);
 | 
			
		||||
 | 
			
		||||
    /*! client characteristic configuration descriptors settings */
 | 
			
		||||
    #define MAX_CCC_CNT 20
 | 
			
		||||
    attsCccSet_t cccSet[MAX_CCC_CNT];
 | 
			
		||||
    uint16_t cccValues[MAX_CCC_CNT];
 | 
			
		||||
    uint16_t cccHandles[MAX_CCC_CNT];
 | 
			
		||||
    uint8_t cccCnt;
 | 
			
		||||
 | 
			
		||||
private:
 | 
			
		||||
    ArmGattServer() : GattServer(), cccSet(), cccValues(), cccHandles(), cccCnt(0) {
 | 
			
		||||
        /* empty */
 | 
			
		||||
    }
 | 
			
		||||
 | 
			
		||||
    ArmGattServer(const ArmGattServer &);
 | 
			
		||||
    const ArmGattServer& operator=(const ArmGattServer &);
 | 
			
		||||
};
 | 
			
		||||
 | 
			
		||||
#endif /* _ARM_GATT_SERVER_H_ */
 | 
			
		||||
| 
						 | 
				
			
			@ -1,39 +0,0 @@
 | 
			
		|||
/*
 | 
			
		||||
 * PackageLicenseDeclared: Apache-2.0
 | 
			
		||||
 * Copyright (c) 2016 ARM Limited
 | 
			
		||||
 *
 | 
			
		||||
 * Licensed under the Apache License, Version 2.0 (the "License");
 | 
			
		||||
 * you may not use this file except in compliance with the License.
 | 
			
		||||
 * You may obtain a copy of the License at
 | 
			
		||||
 *
 | 
			
		||||
 * http://www.apache.org/licenses/LICENSE-2.0
 | 
			
		||||
 *
 | 
			
		||||
 * Unless required by applicable law or agreed to in writing, software
 | 
			
		||||
 * distributed under the License is distributed on an "AS IS" BASIS,
 | 
			
		||||
 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
 | 
			
		||||
 * See the License for the specific language governing permissions and
 | 
			
		||||
 * limitations under the License.
 | 
			
		||||
 */
 | 
			
		||||
 | 
			
		||||
#ifndef _ARM_SECURITY_MANAGER_H_
 | 
			
		||||
#define _ARM_SECURITY_MANAGER_H_
 | 
			
		||||
 | 
			
		||||
#include <stddef.h>
 | 
			
		||||
 | 
			
		||||
#include "SecurityManager.h"
 | 
			
		||||
 | 
			
		||||
class ArmSecurityManager : public SecurityManager
 | 
			
		||||
{
 | 
			
		||||
public:
 | 
			
		||||
    static ArmSecurityManager &getInstance() {
 | 
			
		||||
        static ArmSecurityManager m_instance;
 | 
			
		||||
        return m_instance;
 | 
			
		||||
    }
 | 
			
		||||
 | 
			
		||||
public:
 | 
			
		||||
    ArmSecurityManager() {
 | 
			
		||||
        /* empty */
 | 
			
		||||
    }
 | 
			
		||||
};
 | 
			
		||||
 | 
			
		||||
#endif /* _ARM_SECURITY_MANAGER_H_ */
 | 
			
		||||
| 
						 | 
				
			
			@ -1,569 +0,0 @@
 | 
			
		|||
/*
 | 
			
		||||
 * PackageLicenseDeclared: Apache-2.0
 | 
			
		||||
 * Copyright (c) 2016 ARM Limited
 | 
			
		||||
 *
 | 
			
		||||
 * Licensed under the Apache License, Version 2.0 (the "License");
 | 
			
		||||
 * you may not use this file except in compliance with the License.
 | 
			
		||||
 * You may obtain a copy of the License at
 | 
			
		||||
 *
 | 
			
		||||
 * http://www.apache.org/licenses/LICENSE-2.0
 | 
			
		||||
 *
 | 
			
		||||
 * Unless required by applicable law or agreed to in writing, software
 | 
			
		||||
 * distributed under the License is distributed on an "AS IS" BASIS,
 | 
			
		||||
 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
 | 
			
		||||
 * See the License for the specific language governing permissions and
 | 
			
		||||
 * limitations under the License.
 | 
			
		||||
 */
 | 
			
		||||
 | 
			
		||||
#include "mbed.h"
 | 
			
		||||
#include "ArmBLE.h"
 | 
			
		||||
 | 
			
		||||
extern "C" {
 | 
			
		||||
#include "cordio_sdk_version.h"
 | 
			
		||||
#include "chip.h"
 | 
			
		||||
#include "board.h"
 | 
			
		||||
#include "utils.h"
 | 
			
		||||
 | 
			
		||||
#include "hpal_blep.h"
 | 
			
		||||
#include "hpal_hci.h"
 | 
			
		||||
 | 
			
		||||
#include "ble_init.h"
 | 
			
		||||
#include "main_board.h"
 | 
			
		||||
 | 
			
		||||
#include "wsf_assert.h"
 | 
			
		||||
#include "wsf_buf.h"
 | 
			
		||||
#include "wsf_math.h"
 | 
			
		||||
#include "wsf_msg.h"
 | 
			
		||||
#include "wsf_os.h"
 | 
			
		||||
#include "wsf_mbed_os.h"
 | 
			
		||||
#include "wsf_sec.h"
 | 
			
		||||
#include "wsf_timer.h"
 | 
			
		||||
#include "wsf_types.h"
 | 
			
		||||
#include "wsf_trace.h"
 | 
			
		||||
#include "bstream.h"
 | 
			
		||||
 | 
			
		||||
#include "hci_handler.h"
 | 
			
		||||
#include "hci_tr.h"
 | 
			
		||||
#include "dm_handler.h"
 | 
			
		||||
#include "l2c_handler.h"
 | 
			
		||||
#include "att_handler.h"
 | 
			
		||||
#include "smp_handler.h"
 | 
			
		||||
#include "l2c_api.h"
 | 
			
		||||
#include "att_api.h"
 | 
			
		||||
#include "smp_api.h"
 | 
			
		||||
#include "hci_core.h"
 | 
			
		||||
#include "hci_drv.h"
 | 
			
		||||
}
 | 
			
		||||
 | 
			
		||||
/* Number of WSF buffer pools. */
 | 
			
		||||
#define WSF_BUF_POOLS           4
 | 
			
		||||
 | 
			
		||||
/* Buffer size. */
 | 
			
		||||
#define ACL_BUF_SIZE            256
 | 
			
		||||
 | 
			
		||||
/* Total number of buffers. */
 | 
			
		||||
#define NUM_BUFS                8
 | 
			
		||||
 | 
			
		||||
/* Total size in bytes for buffer memory. */
 | 
			
		||||
#define BUF_MEM_SIZE            (1024 * 4)
 | 
			
		||||
 | 
			
		||||
/*! Free memory for pool buffers. */
 | 
			
		||||
static uint32_t mainBufMem[BUF_MEM_SIZE/sizeof(uint32_t)];
 | 
			
		||||
 | 
			
		||||
/*! Default pool descriptor. */
 | 
			
		||||
static wsfBufPoolDesc_t mainPoolDesc[WSF_BUF_POOLS] =
 | 
			
		||||
{
 | 
			
		||||
  { 16,   8 },
 | 
			
		||||
  { 32,   8 },
 | 
			
		||||
  { 64,   8 },
 | 
			
		||||
  { ACL_BUF_SIZE + 16, NUM_BUFS }
 | 
			
		||||
};
 | 
			
		||||
 | 
			
		||||
/* Store the Event signalling */
 | 
			
		||||
bool isEventsSignaled = false;
 | 
			
		||||
 | 
			
		||||
/*! WSF handler ID */
 | 
			
		||||
wsfHandlerId_t armHandlerId;
 | 
			
		||||
wsfHandlerId_t BleHandlerId;
 | 
			
		||||
static volatile int reset_complete;
 | 
			
		||||
 | 
			
		||||
/* Beetle Internal Functions */
 | 
			
		||||
 | 
			
		||||
/* HCI callback prototypes. */
 | 
			
		||||
static uint8_t *mainHciBufAlloc(uint16_t len);
 | 
			
		||||
static void mainHciBufFree(uint8_t *buf);
 | 
			
		||||
static void mainHciReadDone(uint8_t type, uint8_t *pData, uint16_t len);
 | 
			
		||||
static void mainHciWriteDone(uint8_t type, uint8_t *pData, int32_t err, void *pContext);
 | 
			
		||||
 | 
			
		||||
/*! \brief      HCI callbacks. */
 | 
			
		||||
static const hpalHciCbacks_t mainHciCbacks =
 | 
			
		||||
{
 | 
			
		||||
  mainHciBufAlloc,
 | 
			
		||||
  mainHciBufFree,
 | 
			
		||||
  mainHciReadDone,
 | 
			
		||||
  mainHciWriteDone
 | 
			
		||||
};
 | 
			
		||||
 | 
			
		||||
/**************************************************************************************************
 | 
			
		||||
  Stack HCI
 | 
			
		||||
**************************************************************************************************/
 | 
			
		||||
 | 
			
		||||
/*************************************************************************************************/
 | 
			
		||||
/*!
 | 
			
		||||
 *  \brief    Allocate a buffer for a received message.
 | 
			
		||||
 *
 | 
			
		||||
 *  This function is called from an interrupt context.
 | 
			
		||||
 *
 | 
			
		||||
 *  \param    len     Length of buffer
 | 
			
		||||
 *
 | 
			
		||||
**  \return   Pointer to buffer or NULL if buffer could not be allocated
 | 
			
		||||
 */
 | 
			
		||||
/*************************************************************************************************/
 | 
			
		||||
static uint8_t *mainHciBufAlloc(uint16_t len)
 | 
			
		||||
{
 | 
			
		||||
  return (uint8_t*)WsfMsgAlloc(len);
 | 
			
		||||
}
 | 
			
		||||
 | 
			
		||||
/*************************************************************************************************/
 | 
			
		||||
/*!
 | 
			
		||||
 *  \brief    Free a buffer previously allocated with `BufAlloc()`.
 | 
			
		||||
 *
 | 
			
		||||
 *  \param    pData     Pointer to buffer
 | 
			
		||||
 */
 | 
			
		||||
/*************************************************************************************************/
 | 
			
		||||
static void mainHciBufFree(uint8_t *pData)
 | 
			
		||||
{
 | 
			
		||||
  WsfMsgFree(pData);
 | 
			
		||||
}
 | 
			
		||||
 | 
			
		||||
/*************************************************************************************************/
 | 
			
		||||
/*!
 | 
			
		||||
 *  \brief    Handle read completion.
 | 
			
		||||
 *
 | 
			
		||||
 *  This function is called from an interrupt context.
 | 
			
		||||
 *
 | 
			
		||||
 *  \param    type    Packet type
 | 
			
		||||
 *  \param    pData   Packet data, which was allocated with `BufAlloc()`.  The caller must free
 | 
			
		||||
 *                    this buffer
 | 
			
		||||
 *  \param    len     Length of packet data, in bytes
 | 
			
		||||
 *
 | 
			
		||||
 *  \return   None.
 | 
			
		||||
 */
 | 
			
		||||
/*************************************************************************************************/
 | 
			
		||||
static void mainHciReadDone(uint8_t type, uint8_t *pData, uint16_t len)
 | 
			
		||||
{
 | 
			
		||||
  WSF_ASSERT(align == 0);
 | 
			
		||||
 | 
			
		||||
  switch (type)
 | 
			
		||||
  {
 | 
			
		||||
    /* Route standard types to stack. */
 | 
			
		||||
    case HCI_CMD_TYPE:
 | 
			
		||||
    case HCI_ACL_TYPE:
 | 
			
		||||
    case HCI_EVT_TYPE:
 | 
			
		||||
    {
 | 
			
		||||
      hciCoreRecv(type, pData);
 | 
			
		||||
      break;
 | 
			
		||||
    }
 | 
			
		||||
 | 
			
		||||
    /* We should not get anything else. */
 | 
			
		||||
    default:
 | 
			
		||||
    {
 | 
			
		||||
      WsfMsgFree(pData);
 | 
			
		||||
      break;
 | 
			
		||||
    }
 | 
			
		||||
  }
 | 
			
		||||
}
 | 
			
		||||
 | 
			
		||||
/*************************************************************************************************/
 | 
			
		||||
/*!
 | 
			
		||||
 *  \brief    Handle write completion.
 | 
			
		||||
 *
 | 
			
		||||
 *  This function is called from an interrupt context.
 | 
			
		||||
 *
 | 
			
		||||
 *  \param    type      Packet type.
 | 
			
		||||
 *  \param    pData     Pointer to buffer that held written data, which was passed to
 | 
			
		||||
 *                      `HpalHciWrite()`
 | 
			
		||||
 *  \param    err       Indicates success (0) or error (one of the `HPAL_HCI_ERROR_####` codes)
 | 
			
		||||
 *  \param    pContext  Context pointer passed to `HpalHciWrite()`
 | 
			
		||||
 *
 | 
			
		||||
 *  \return   None.
 | 
			
		||||
 */
 | 
			
		||||
/*************************************************************************************************/
 | 
			
		||||
static void mainHciWriteDone(uint8_t type, uint8_t *pData, int32_t err, void *pContext)
 | 
			
		||||
{
 | 
			
		||||
  switch (type)
 | 
			
		||||
  {
 | 
			
		||||
    case HCI_CMD_TYPE:
 | 
			
		||||
    {
 | 
			
		||||
      WsfMsgFree(pData);
 | 
			
		||||
      break;
 | 
			
		||||
    }
 | 
			
		||||
 | 
			
		||||
    case HCI_ACL_TYPE:
 | 
			
		||||
    {
 | 
			
		||||
      hciCoreTxAclComplete((hciCoreConn_t *)pContext, pData);
 | 
			
		||||
      break;
 | 
			
		||||
    }
 | 
			
		||||
  }
 | 
			
		||||
}
 | 
			
		||||
 | 
			
		||||
/*************************************************************************************************/
 | 
			
		||||
/*!
 | 
			
		||||
 *  \fn     hciTrSendAclData
 | 
			
		||||
 *
 | 
			
		||||
 *  \brief  Send a complete HCI ACL packet to the transport.
 | 
			
		||||
 *
 | 
			
		||||
 *  \param  pContext Connection context.
 | 
			
		||||
 *  \param  pData    WSF msg buffer containing an ACL packet.
 | 
			
		||||
 *
 | 
			
		||||
 *  \return None.
 | 
			
		||||
 */
 | 
			
		||||
/*************************************************************************************************/
 | 
			
		||||
void hciTrSendAclData(void *pContext, uint8_t *pData)
 | 
			
		||||
{
 | 
			
		||||
  uint16_t   len;
 | 
			
		||||
 | 
			
		||||
  /* get 16-bit length */
 | 
			
		||||
  BYTES_TO_UINT16(len, &pData[2]);
 | 
			
		||||
  len += HCI_ACL_HDR_LEN;
 | 
			
		||||
 | 
			
		||||
  /* transmit ACL header and data */
 | 
			
		||||
  HpalHciWrite(HCI_ACL_TYPE, pData, len, pContext);
 | 
			
		||||
}
 | 
			
		||||
 | 
			
		||||
/*************************************************************************************************/
 | 
			
		||||
/*!
 | 
			
		||||
 *  \fn     hciTrSendCmd
 | 
			
		||||
 *
 | 
			
		||||
 *  \brief  Send a complete HCI command to the transport.
 | 
			
		||||
 *
 | 
			
		||||
 *  \param  pData    WSF msg buffer containing an HCI command.
 | 
			
		||||
 *
 | 
			
		||||
 *  \return None.
 | 
			
		||||
 */
 | 
			
		||||
/*************************************************************************************************/
 | 
			
		||||
void hciTrSendCmd(uint8_t *pData)
 | 
			
		||||
{
 | 
			
		||||
  uint8_t   len;
 | 
			
		||||
 | 
			
		||||
  /* get length */
 | 
			
		||||
  len = pData[2] + HCI_CMD_HDR_LEN;
 | 
			
		||||
 | 
			
		||||
  /* dump event for protocol analysis */
 | 
			
		||||
  HCI_PDUMP_CMD(len, pData);
 | 
			
		||||
 | 
			
		||||
  /* transmit ACL header and data */
 | 
			
		||||
  HpalHciWrite(HCI_CMD_TYPE, pData, len, NULL);
 | 
			
		||||
}
 | 
			
		||||
 | 
			
		||||
void beetleCordioReset(void)
 | 
			
		||||
{
 | 
			
		||||
    CORDIO_LLCCTRL_LLC_RESET_ASSERT();
 | 
			
		||||
    CORDIO_LLCCTRL_RESETX_ASSERT();
 | 
			
		||||
    CORDIO_LLCCTRL_VMEM_ON_ASSERT();
 | 
			
		||||
    wait_ms(2);
 | 
			
		||||
    CORDIO_LLCCTRL_RESETX_NEGATE();
 | 
			
		||||
    CORDIO_LLCCTRL_LLC_RESET_NEGATE();
 | 
			
		||||
}
 | 
			
		||||
 | 
			
		||||
/* End Beetle Internal Functions */
 | 
			
		||||
 | 
			
		||||
/**
 | 
			
		||||
 * The singleton which represents the ArmBLE transport for the BLE.
 | 
			
		||||
 */
 | 
			
		||||
static ArmBLE deviceInstance;
 | 
			
		||||
 | 
			
		||||
/**
 | 
			
		||||
 * BLE-API requires an implementation of the following function in order to
 | 
			
		||||
 * obtain its transport handle.
 | 
			
		||||
 */
 | 
			
		||||
BLEInstanceBase *createBLEInstance(void)
 | 
			
		||||
{
 | 
			
		||||
    return (&deviceInstance);
 | 
			
		||||
}
 | 
			
		||||
 | 
			
		||||
ArmBLE::ArmBLE(void) : initialized(false), instanceID(BLE::DEFAULT_INSTANCE)
 | 
			
		||||
{
 | 
			
		||||
}
 | 
			
		||||
 | 
			
		||||
ArmBLE::~ArmBLE(void)
 | 
			
		||||
{
 | 
			
		||||
}
 | 
			
		||||
 | 
			
		||||
const char *ArmBLE::getVersion(void)
 | 
			
		||||
{
 | 
			
		||||
    static char versionString[32];
 | 
			
		||||
 | 
			
		||||
    strncpy(versionString, "unknown", sizeof(versionString));
 | 
			
		||||
 | 
			
		||||
    return versionString;
 | 
			
		||||
}
 | 
			
		||||
 | 
			
		||||
static void DmCback(dmEvt_t *pDmEvt)
 | 
			
		||||
{
 | 
			
		||||
    dmEvt_t *pMsg;
 | 
			
		||||
 | 
			
		||||
    if ((pMsg = (dmEvt_t*)WsfMsgAlloc(sizeof(dmEvt_t))) != NULL)
 | 
			
		||||
    {
 | 
			
		||||
        memcpy(pMsg, pDmEvt, sizeof(dmEvt_t));
 | 
			
		||||
        WsfMsgSend(armHandlerId, pMsg);
 | 
			
		||||
    }
 | 
			
		||||
}
 | 
			
		||||
 | 
			
		||||
static void armHandler(wsfEventMask_t event, wsfMsgHdr_t *pMsg)
 | 
			
		||||
{
 | 
			
		||||
    if (pMsg != NULL)
 | 
			
		||||
    {
 | 
			
		||||
        switch(pMsg->event)
 | 
			
		||||
        {
 | 
			
		||||
            case DM_RESET_CMPL_IND:
 | 
			
		||||
                reset_complete = 1;
 | 
			
		||||
                break;
 | 
			
		||||
            case DM_ADV_START_IND:
 | 
			
		||||
                break;
 | 
			
		||||
            case DM_ADV_STOP_IND:
 | 
			
		||||
                ArmGap::getInstance().advertisingStopped();
 | 
			
		||||
                break;
 | 
			
		||||
            case DM_SCAN_REPORT_IND:
 | 
			
		||||
                {
 | 
			
		||||
                    dmEvt_t *scan = (dmEvt_t*)pMsg;
 | 
			
		||||
                    ArmGap::getInstance().processAdvertisementReport( scan->scanReport.addr,
 | 
			
		||||
                                                                        scan->scanReport.rssi,
 | 
			
		||||
                                                                        (scan->scanReport.eventType == DM_ADV_SCAN_RESPONSE) ? true : false,
 | 
			
		||||
                                                                        (GapAdvertisingParams::AdvertisingType_t)scan->scanReport.eventType,
 | 
			
		||||
                                                                        scan->scanReport.len,
 | 
			
		||||
                                                                        scan->scanReport.pData,
 | 
			
		||||
                                                                        (BLEProtocol::AddressType_t) scan->scanReport.addrType);
 | 
			
		||||
                }
 | 
			
		||||
                break;
 | 
			
		||||
            case DM_CONN_OPEN_IND:
 | 
			
		||||
                {
 | 
			
		||||
                    dmEvt_t *conn = (dmEvt_t*)pMsg;
 | 
			
		||||
                    ArmGap::getInstance().setConnectionHandle(conn->hdr.param);
 | 
			
		||||
                    Gap::ConnectionParams_t params = { conn->connOpen.connInterval, conn->connOpen.connInterval, conn->connOpen.connLatency, conn->connOpen.supTimeout };
 | 
			
		||||
                    Gap::AddressType_t ownAddrType;
 | 
			
		||||
                    Gap::Address_t ownAddr;
 | 
			
		||||
                    ArmGap::getInstance().getAddress(&ownAddrType, ownAddr);
 | 
			
		||||
                    ArmGap::getInstance().processConnectionEvent(conn->hdr.param,
 | 
			
		||||
                                                                   Gap::PERIPHERAL,
 | 
			
		||||
                                                                   (Gap::AddressType_t)conn->connOpen.addrType,
 | 
			
		||||
                                                                   conn->connOpen.peerAddr,
 | 
			
		||||
                                                                   ownAddrType,
 | 
			
		||||
                                                                   ownAddr,
 | 
			
		||||
                                                                   ¶ms);
 | 
			
		||||
                }
 | 
			
		||||
                break;
 | 
			
		||||
            case DM_CONN_CLOSE_IND:
 | 
			
		||||
                {
 | 
			
		||||
                    dmEvt_t *conn = (dmEvt_t*)pMsg;
 | 
			
		||||
                    ArmGap::getInstance().setConnectionHandle(DM_CONN_ID_NONE);
 | 
			
		||||
                    ArmGap::getInstance().processDisconnectionEvent(conn->hdr.param, (Gap::DisconnectionReason_t)conn->connClose.reason);
 | 
			
		||||
                }
 | 
			
		||||
                break;
 | 
			
		||||
            default:
 | 
			
		||||
                break;
 | 
			
		||||
        }
 | 
			
		||||
    }
 | 
			
		||||
}
 | 
			
		||||
 | 
			
		||||
/*
 | 
			
		||||
 * AttServerInitDeInitCback callback is used to Initialize/Deinitialize
 | 
			
		||||
 * the CCC Table of the ATT Server when a remote peer requests to Open
 | 
			
		||||
 * or Close the connection.
 | 
			
		||||
 */
 | 
			
		||||
static void AttServerInitDeInitCback(dmEvt_t *pDmEvt)
 | 
			
		||||
{
 | 
			
		||||
  dmConnId_t connId = (dmConnId_t)pDmEvt->hdr.param;
 | 
			
		||||
 | 
			
		||||
  switch (pDmEvt->hdr.event)
 | 
			
		||||
  {
 | 
			
		||||
    case DM_CONN_OPEN_IND:
 | 
			
		||||
      /* set up CCC table with uninitialized (all zero) values */
 | 
			
		||||
      AttsCccInitTable(connId, NULL);
 | 
			
		||||
      break;
 | 
			
		||||
    case DM_CONN_CLOSE_IND:
 | 
			
		||||
      /* clear CCC table on connection close */
 | 
			
		||||
      AttsCccClearTable(connId);
 | 
			
		||||
      break;
 | 
			
		||||
    default:
 | 
			
		||||
      break;
 | 
			
		||||
  }
 | 
			
		||||
}
 | 
			
		||||
 | 
			
		||||
/*
 | 
			
		||||
 * This function will signal to the user code by calling signalEventsToProcess.
 | 
			
		||||
 * It is registered and called into the Wsf Stack.
 | 
			
		||||
 */
 | 
			
		||||
 static uint32_t signalEvent()
 | 
			
		||||
 {
 | 
			
		||||
     if(isEventsSignaled == false) {
 | 
			
		||||
         isEventsSignaled = true;
 | 
			
		||||
         deviceInstance.signalEventsToProcess(BLE::DEFAULT_INSTANCE);
 | 
			
		||||
     }
 | 
			
		||||
     return BLE_ERROR_NONE;
 | 
			
		||||
 }
 | 
			
		||||
 | 
			
		||||
static void ArmBLEInit(wsfEventMask_t event, wsfMsgHdr_t *pMsg)
 | 
			
		||||
{
 | 
			
		||||
    wsfHandlerId_t handlerId;
 | 
			
		||||
 | 
			
		||||
    /*
 | 
			
		||||
     * The init sequence is taken from the Cordio Stack Porting Guide version
 | 
			
		||||
     * 1.1 Chapter 2.6.
 | 
			
		||||
     */
 | 
			
		||||
 | 
			
		||||
    /* init OS subsystems */
 | 
			
		||||
    /* initialize WSF services */
 | 
			
		||||
    WsfSecInit();
 | 
			
		||||
    /* Disabled WsfSecAesInit(); */
 | 
			
		||||
 | 
			
		||||
    /* initialize HCI */
 | 
			
		||||
    handlerId = WsfOsSetNextHandler(HciHandler);
 | 
			
		||||
    HciHandlerInit(handlerId);
 | 
			
		||||
 | 
			
		||||
    /* initialize DM */
 | 
			
		||||
    handlerId = WsfOsSetNextHandler(DmHandler);
 | 
			
		||||
    DmAdvInit();
 | 
			
		||||
    DmConnInit();
 | 
			
		||||
    DmConnSlaveInit();
 | 
			
		||||
    DmSecInit();
 | 
			
		||||
    DmHandlerInit(handlerId);
 | 
			
		||||
 | 
			
		||||
    /* initialize L2CAP */
 | 
			
		||||
    handlerId = WsfOsSetNextHandler(L2cSlaveHandler);
 | 
			
		||||
    L2cSlaveHandlerInit(handlerId);
 | 
			
		||||
    L2cInit();
 | 
			
		||||
    L2cSlaveInit();
 | 
			
		||||
 | 
			
		||||
    /* initialize ATT */
 | 
			
		||||
    handlerId = WsfOsSetNextHandler(AttHandler);
 | 
			
		||||
    AttHandlerInit(handlerId);
 | 
			
		||||
    AttsInit();
 | 
			
		||||
    AttsIndInit();
 | 
			
		||||
 | 
			
		||||
    /* initialize SMP */
 | 
			
		||||
    handlerId = WsfOsSetNextHandler(SmpHandler);
 | 
			
		||||
    SmpHandlerInit(handlerId);
 | 
			
		||||
    SmprInit();
 | 
			
		||||
 | 
			
		||||
    /* store handler ID */
 | 
			
		||||
    armHandlerId = WsfOsSetNextHandler(armHandler);
 | 
			
		||||
 | 
			
		||||
    /* Register for stack callbacks */
 | 
			
		||||
    HpalHciSetCbacks(&mainHciCbacks);
 | 
			
		||||
    HpalHciSetLoggingLevel(HPAL_HCI_LOGGING_LEVEL_VERBOSE);
 | 
			
		||||
    HpalHciTakeUp();
 | 
			
		||||
 | 
			
		||||
    DmRegister(DmCback);
 | 
			
		||||
    DmConnRegister(DM_CLIENT_ID_APP, DmCback);
 | 
			
		||||
    AttConnRegister(AttServerInitDeInitCback);
 | 
			
		||||
 | 
			
		||||
    /* Register MBED OS Signal Event */
 | 
			
		||||
    mbedOSRegisterSignalEventCallback(&signalEvent);
 | 
			
		||||
 | 
			
		||||
    /* Reset the device */
 | 
			
		||||
    reset_complete = 0;
 | 
			
		||||
    DmDevReset();
 | 
			
		||||
}
 | 
			
		||||
 | 
			
		||||
static void ArmBLEStartCallback(bool_t ok)
 | 
			
		||||
{
 | 
			
		||||
    if (ok)
 | 
			
		||||
    {
 | 
			
		||||
        /* If started up, allow remaining application to run. */
 | 
			
		||||
        WsfSetEvent(BleHandlerId, 1);
 | 
			
		||||
    }
 | 
			
		||||
}
 | 
			
		||||
 | 
			
		||||
ble_error_t ArmBLE::init(BLE::InstanceID_t instanceID, FunctionPointerWithContext<BLE::InitializationCompleteCallbackContext *> initCallback)
 | 
			
		||||
{
 | 
			
		||||
    wsfHandlerId_t handlerId;
 | 
			
		||||
 | 
			
		||||
    beetleCordioReset();
 | 
			
		||||
    Main_BoardInit();
 | 
			
		||||
 | 
			
		||||
    /* init OS subsystems */
 | 
			
		||||
    WsfTimerInit();
 | 
			
		||||
    WsfBufInit(sizeof(mainBufMem), (uint8_t*)mainBufMem, WSF_BUF_POOLS, mainPoolDesc);
 | 
			
		||||
 | 
			
		||||
    /* init stack */
 | 
			
		||||
    handlerId = WsfOsSetNextHandler(HpalBlepHandler);
 | 
			
		||||
    HpalBlepInit(handlerId);
 | 
			
		||||
 | 
			
		||||
    BleHandlerId = WsfOsSetNextHandler(ArmBLEInit);
 | 
			
		||||
    HpalBlepSetStartupCback(ArmBLEStartCallback);
 | 
			
		||||
 | 
			
		||||
    /*
 | 
			
		||||
     * Initialize BLE:
 | 
			
		||||
     * - Download the Cordio FW
 | 
			
		||||
     * - Initialize the lower layers
 | 
			
		||||
     */
 | 
			
		||||
    BleInitStart();
 | 
			
		||||
 | 
			
		||||
    /* Wait for BLE device to boot */
 | 
			
		||||
    while (!reset_complete) {
 | 
			
		||||
        callDispatcher();
 | 
			
		||||
    }
 | 
			
		||||
 | 
			
		||||
    initialized = true;
 | 
			
		||||
    BLE::InitializationCompleteCallbackContext context = {
 | 
			
		||||
        BLE::Instance(instanceID),
 | 
			
		||||
        BLE_ERROR_NONE
 | 
			
		||||
    };
 | 
			
		||||
    initCallback.call(&context);
 | 
			
		||||
    return BLE_ERROR_NONE;
 | 
			
		||||
}
 | 
			
		||||
 | 
			
		||||
ble_error_t ArmBLE::shutdown(void)
 | 
			
		||||
{
 | 
			
		||||
    return BLE_ERROR_NOT_IMPLEMENTED;
 | 
			
		||||
}
 | 
			
		||||
 | 
			
		||||
void ArmBLE::waitForEvent(void)
 | 
			
		||||
{
 | 
			
		||||
    timestamp_t nextTimestamp;
 | 
			
		||||
    bool_t pTimerRunning;
 | 
			
		||||
 | 
			
		||||
    processEvents();
 | 
			
		||||
 | 
			
		||||
    if (wsfOsReadyToSleep()) {
 | 
			
		||||
        // setup an mbed timer for the next Wicentric timeout
 | 
			
		||||
        nextTimestamp = (timestamp_t)WsfTimerNextExpiration(&pTimerRunning) * 1000;
 | 
			
		||||
        if (pTimerRunning) {
 | 
			
		||||
            /*
 | 
			
		||||
            * go to sleep to nextTimestamp: The ble stack here has to inform
 | 
			
		||||
            * the system that is ready and not really go to sleep.
 | 
			
		||||
            * TO BE DONE
 | 
			
		||||
            */
 | 
			
		||||
        }
 | 
			
		||||
    }
 | 
			
		||||
}
 | 
			
		||||
 | 
			
		||||
void ArmBLE::processEvents()
 | 
			
		||||
{
 | 
			
		||||
    if (isEventsSignaled) {
 | 
			
		||||
        isEventsSignaled = false;
 | 
			
		||||
        callDispatcher();
 | 
			
		||||
    }
 | 
			
		||||
}
 | 
			
		||||
 | 
			
		||||
void ArmBLE::timeoutCallback(void)
 | 
			
		||||
{
 | 
			
		||||
    // do nothing. just an interrupt for wake up.
 | 
			
		||||
}
 | 
			
		||||
 | 
			
		||||
void ArmBLE::callDispatcher(void)
 | 
			
		||||
{
 | 
			
		||||
    static uint32_t lastTimeUs = us_ticker_read();
 | 
			
		||||
    uint32_t currTimeUs, deltaTimeMs;
 | 
			
		||||
 | 
			
		||||
    // Update the current Wicentric time
 | 
			
		||||
    currTimeUs = us_ticker_read();
 | 
			
		||||
    deltaTimeMs = (currTimeUs - lastTimeUs) / 1000;
 | 
			
		||||
    if (deltaTimeMs > 0) {
 | 
			
		||||
        WsfTimerUpdate(deltaTimeMs);
 | 
			
		||||
        lastTimeUs += deltaTimeMs * 1000;
 | 
			
		||||
    }
 | 
			
		||||
 | 
			
		||||
    wsfOsDispatcher();
 | 
			
		||||
}
 | 
			
		||||
| 
						 | 
				
			
			@ -1,235 +0,0 @@
 | 
			
		|||
/*
 | 
			
		||||
 * PackageLicenseDeclared: Apache-2.0
 | 
			
		||||
 * Copyright (c) 2016 ARM Limited
 | 
			
		||||
 *
 | 
			
		||||
 * Licensed under the Apache License, Version 2.0 (the "License");
 | 
			
		||||
 * you may not use this file except in compliance with the License.
 | 
			
		||||
 * You may obtain a copy of the License at
 | 
			
		||||
 *
 | 
			
		||||
 * http://www.apache.org/licenses/LICENSE-2.0
 | 
			
		||||
 *
 | 
			
		||||
 * Unless required by applicable law or agreed to in writing, software
 | 
			
		||||
 * distributed under the License is distributed on an "AS IS" BASIS,
 | 
			
		||||
 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
 | 
			
		||||
 * See the License for the specific language governing permissions and
 | 
			
		||||
 * limitations under the License.
 | 
			
		||||
 */
 | 
			
		||||
 | 
			
		||||
#include "ArmGap.h"
 | 
			
		||||
#include "mbed.h"
 | 
			
		||||
 | 
			
		||||
ArmGap &ArmGap::getInstance() {
 | 
			
		||||
    static ArmGap m_instance;
 | 
			
		||||
    return m_instance;
 | 
			
		||||
}
 | 
			
		||||
 | 
			
		||||
ble_error_t ArmGap::setAdvertisingData(const GapAdvertisingData &advData, const GapAdvertisingData &scanResponse)
 | 
			
		||||
{
 | 
			
		||||
    /* Make sure we don't exceed the advertising payload length */
 | 
			
		||||
    if (advData.getPayloadLen() > GAP_ADVERTISING_DATA_MAX_PAYLOAD) {
 | 
			
		||||
        return BLE_ERROR_BUFFER_OVERFLOW;
 | 
			
		||||
    }
 | 
			
		||||
 | 
			
		||||
    /* Make sure we have a payload! */
 | 
			
		||||
    if (advData.getPayloadLen() == 0) {
 | 
			
		||||
        return BLE_ERROR_PARAM_OUT_OF_RANGE;
 | 
			
		||||
    }
 | 
			
		||||
 | 
			
		||||
    /* set advertising and scan response data for discoverable mode */
 | 
			
		||||
    DmAdvSetData(DM_DATA_LOC_ADV, advData.getPayloadLen(), (uint8_t*)advData.getPayload());
 | 
			
		||||
    DmAdvSetData(DM_DATA_LOC_SCAN, scanResponse.getPayloadLen(), (uint8_t*)scanResponse.getPayload());
 | 
			
		||||
 | 
			
		||||
    return BLE_ERROR_NONE;
 | 
			
		||||
}
 | 
			
		||||
 | 
			
		||||
ble_error_t ArmGap::startAdvertising(const GapAdvertisingParams ¶ms)
 | 
			
		||||
{
 | 
			
		||||
    /* Make sure we support the advertising type */
 | 
			
		||||
    if (params.getAdvertisingType() == GapAdvertisingParams::ADV_CONNECTABLE_DIRECTED) {
 | 
			
		||||
        /* ToDo: This requires a proper security implementation, etc. */
 | 
			
		||||
        return BLE_ERROR_NOT_IMPLEMENTED;
 | 
			
		||||
    }
 | 
			
		||||
 | 
			
		||||
    /* Check interval range */
 | 
			
		||||
    if (params.getAdvertisingType() == GapAdvertisingParams::ADV_NON_CONNECTABLE_UNDIRECTED) {
 | 
			
		||||
        /* Min delay is slightly longer for unconnectable devices */
 | 
			
		||||
        if ((params.getInterval() < GapAdvertisingParams::GAP_ADV_PARAMS_INTERVAL_MIN_NONCON) ||
 | 
			
		||||
            (params.getInterval() > GapAdvertisingParams::GAP_ADV_PARAMS_INTERVAL_MAX)) {
 | 
			
		||||
            return BLE_ERROR_PARAM_OUT_OF_RANGE;
 | 
			
		||||
        }
 | 
			
		||||
    } else {
 | 
			
		||||
        if ((params.getInterval() < GapAdvertisingParams::GAP_ADV_PARAMS_INTERVAL_MIN) ||
 | 
			
		||||
            (params.getInterval() > GapAdvertisingParams::GAP_ADV_PARAMS_INTERVAL_MAX)) {
 | 
			
		||||
            return BLE_ERROR_PARAM_OUT_OF_RANGE;
 | 
			
		||||
        }
 | 
			
		||||
    }
 | 
			
		||||
 | 
			
		||||
    /* Check timeout is zero for Connectable Directed */
 | 
			
		||||
    if ((params.getAdvertisingType() == GapAdvertisingParams::ADV_CONNECTABLE_DIRECTED) && (params.getTimeout() != 0)) {
 | 
			
		||||
        /* Timeout must be 0 with this type, although we'll never get here */
 | 
			
		||||
        /* since this isn't implemented yet anyway */
 | 
			
		||||
        return BLE_ERROR_PARAM_OUT_OF_RANGE;
 | 
			
		||||
    }
 | 
			
		||||
 | 
			
		||||
    /* Check timeout for other advertising types */
 | 
			
		||||
    if ((params.getAdvertisingType() != GapAdvertisingParams::ADV_CONNECTABLE_DIRECTED) &&
 | 
			
		||||
        (params.getTimeout() > GapAdvertisingParams::GAP_ADV_PARAMS_TIMEOUT_MAX)) {
 | 
			
		||||
        return BLE_ERROR_PARAM_OUT_OF_RANGE;
 | 
			
		||||
    }
 | 
			
		||||
 | 
			
		||||
    /* Peer Addr Type 0 = Public */
 | 
			
		||||
    uint8_t peerAddrType = 0;
 | 
			
		||||
    uint8_t peerAddr[6];
 | 
			
		||||
    memset(peerAddr, 0, 6);
 | 
			
		||||
 | 
			
		||||
    DmAdvSetInterval(params.getInterval(), params.getInterval());
 | 
			
		||||
    DmAdvStart(params.getAdvertisingType(), params.getTimeout(), peerAddrType, peerAddr);
 | 
			
		||||
 | 
			
		||||
    state.advertising = 1;
 | 
			
		||||
 | 
			
		||||
    return BLE_ERROR_NONE;
 | 
			
		||||
}
 | 
			
		||||
 | 
			
		||||
ble_error_t ArmGap::stopAdvertising(void)
 | 
			
		||||
{
 | 
			
		||||
    DmAdvStop();
 | 
			
		||||
 | 
			
		||||
    state.advertising = 0;
 | 
			
		||||
 | 
			
		||||
    return BLE_ERROR_NONE;
 | 
			
		||||
}
 | 
			
		||||
 | 
			
		||||
void ArmGap::advertisingStopped(void)
 | 
			
		||||
{
 | 
			
		||||
    /* If advertising stopped due to a call to stopAdvertising(), state.advertising will
 | 
			
		||||
     * be '0.' Otherwise, advertising must have stopped due to a timeout
 | 
			
		||||
     */
 | 
			
		||||
    if (state.advertising) {
 | 
			
		||||
        processTimeoutEvent(Gap::TIMEOUT_SRC_ADVERTISING);
 | 
			
		||||
    }
 | 
			
		||||
}
 | 
			
		||||
 | 
			
		||||
ble_error_t ArmGap::disconnect(DisconnectionReason_t reason)
 | 
			
		||||
{
 | 
			
		||||
    DmConnClose(DM_CLIENT_ID_APP, m_connectionHandle, reason);
 | 
			
		||||
 | 
			
		||||
    state.advertising = 0;
 | 
			
		||||
    state.connected = 0;
 | 
			
		||||
 | 
			
		||||
    return BLE_ERROR_NONE;
 | 
			
		||||
}
 | 
			
		||||
 | 
			
		||||
ble_error_t ArmGap::disconnect(Handle_t connectionHandle, DisconnectionReason_t reason)
 | 
			
		||||
{
 | 
			
		||||
    DmConnClose(DM_CLIENT_ID_APP, connectionHandle, reason);
 | 
			
		||||
 | 
			
		||||
    state.advertising = 0;
 | 
			
		||||
    state.connected = 0;
 | 
			
		||||
 | 
			
		||||
    return BLE_ERROR_NONE;
 | 
			
		||||
}
 | 
			
		||||
 | 
			
		||||
ble_error_t ArmGap::getPreferredConnectionParams(ConnectionParams_t *params)
 | 
			
		||||
{
 | 
			
		||||
    return BLE_ERROR_NOT_IMPLEMENTED;
 | 
			
		||||
}
 | 
			
		||||
 | 
			
		||||
ble_error_t ArmGap::setPreferredConnectionParams(const ConnectionParams_t *params)
 | 
			
		||||
{
 | 
			
		||||
    return BLE_ERROR_NOT_IMPLEMENTED;
 | 
			
		||||
}
 | 
			
		||||
 | 
			
		||||
ble_error_t ArmGap::updateConnectionParams(Handle_t handle, const ConnectionParams_t *newParams)
 | 
			
		||||
{
 | 
			
		||||
    if (DmConnCheckIdle(handle) != 0) {
 | 
			
		||||
        return BLE_STACK_BUSY;
 | 
			
		||||
    }
 | 
			
		||||
 | 
			
		||||
    hciConnSpec_t connSpec;
 | 
			
		||||
    connSpec.connIntervalMin = newParams->minConnectionInterval;
 | 
			
		||||
    connSpec.connIntervalMax = newParams->maxConnectionInterval;
 | 
			
		||||
    connSpec.connLatency = newParams->slaveLatency;
 | 
			
		||||
    connSpec.supTimeout = newParams->connectionSupervisionTimeout;
 | 
			
		||||
    DmConnUpdate(handle, &connSpec);
 | 
			
		||||
 | 
			
		||||
    return BLE_ERROR_NONE;
 | 
			
		||||
}
 | 
			
		||||
 | 
			
		||||
ble_error_t ArmGap::startRadioScan(const GapScanningParams &scanningParams)
 | 
			
		||||
{
 | 
			
		||||
    DmScanSetInterval(scanningParams.getInterval(), scanningParams.getWindow());
 | 
			
		||||
 | 
			
		||||
    uint8_t scanType = scanningParams.getActiveScanning() ? DM_SCAN_TYPE_ACTIVE : DM_SCAN_TYPE_PASSIVE;
 | 
			
		||||
    uint32_t duration = (uint32_t)scanningParams.getTimeout() * 1000;
 | 
			
		||||
    if (duration > 0xFFFF) {
 | 
			
		||||
        // saturate to 16-bits
 | 
			
		||||
        duration = 0xFFFF;
 | 
			
		||||
    }
 | 
			
		||||
 | 
			
		||||
    DmScanStart(DM_DISC_MODE_NONE, scanType, TRUE, duration);
 | 
			
		||||
 | 
			
		||||
    return BLE_ERROR_NONE;
 | 
			
		||||
}
 | 
			
		||||
 | 
			
		||||
ble_error_t ArmGap::stopScan(void)
 | 
			
		||||
{
 | 
			
		||||
    DmScanStop();
 | 
			
		||||
    return BLE_ERROR_NONE;
 | 
			
		||||
}
 | 
			
		||||
 | 
			
		||||
void ArmGap::setConnectionHandle(uint16_t connectionHandle)
 | 
			
		||||
{
 | 
			
		||||
    m_connectionHandle = connectionHandle;
 | 
			
		||||
}
 | 
			
		||||
 | 
			
		||||
uint16_t ArmGap::getConnectionHandle(void)
 | 
			
		||||
{
 | 
			
		||||
    return m_connectionHandle;
 | 
			
		||||
}
 | 
			
		||||
 | 
			
		||||
ble_error_t ArmGap::setAddress(AddressType_t type, const Address_t address)
 | 
			
		||||
{
 | 
			
		||||
    return BLE_ERROR_NOT_IMPLEMENTED;
 | 
			
		||||
}
 | 
			
		||||
 | 
			
		||||
ble_error_t ArmGap::getAddress(AddressType_t *typeP, Address_t address)
 | 
			
		||||
{
 | 
			
		||||
    *typeP = m_type;
 | 
			
		||||
    BdaCpy(address, HciGetBdAddr());
 | 
			
		||||
    return BLE_ERROR_NONE;
 | 
			
		||||
}
 | 
			
		||||
 | 
			
		||||
ble_error_t ArmGap::setDeviceName(const uint8_t *deviceName)
 | 
			
		||||
{
 | 
			
		||||
    return BLE_ERROR_NOT_IMPLEMENTED;
 | 
			
		||||
}
 | 
			
		||||
 | 
			
		||||
ble_error_t ArmGap::getDeviceName(uint8_t *deviceName, unsigned *lengthP)
 | 
			
		||||
{
 | 
			
		||||
    return BLE_ERROR_NOT_IMPLEMENTED;
 | 
			
		||||
}
 | 
			
		||||
 | 
			
		||||
ble_error_t ArmGap::setAppearance(GapAdvertisingData::Appearance appearance)
 | 
			
		||||
{
 | 
			
		||||
    return BLE_ERROR_NOT_IMPLEMENTED;
 | 
			
		||||
}
 | 
			
		||||
 | 
			
		||||
ble_error_t ArmGap::getAppearance(GapAdvertisingData::Appearance *appearanceP)
 | 
			
		||||
{
 | 
			
		||||
    return BLE_ERROR_NOT_IMPLEMENTED;
 | 
			
		||||
}
 | 
			
		||||
 | 
			
		||||
ble_error_t ArmGap::setTxPower(int8_t txPower)
 | 
			
		||||
{
 | 
			
		||||
    return BLE_ERROR_NOT_IMPLEMENTED;
 | 
			
		||||
}
 | 
			
		||||
 | 
			
		||||
void ArmGap::getPermittedTxPowerValues(const int8_t **valueArrayPP, size_t *countP)
 | 
			
		||||
{
 | 
			
		||||
    static const int8_t permittedTxValues[] = {
 | 
			
		||||
        -18, -15, -12, -9, -6, -3, 0, 3
 | 
			
		||||
    };
 | 
			
		||||
 | 
			
		||||
    *valueArrayPP = permittedTxValues;
 | 
			
		||||
    *countP = sizeof(permittedTxValues) / sizeof(int8_t);
 | 
			
		||||
}
 | 
			
		||||
| 
						 | 
				
			
			@ -1,426 +0,0 @@
 | 
			
		|||
/*
 | 
			
		||||
 * PackageLicenseDeclared: Apache-2.0
 | 
			
		||||
 * Copyright (c) 2016 ARM Limited
 | 
			
		||||
 *
 | 
			
		||||
 * Licensed under the Apache License, Version 2.0 (the "License");
 | 
			
		||||
 * you may not use this file except in compliance with the License.
 | 
			
		||||
 * You may obtain a copy of the License at
 | 
			
		||||
 *
 | 
			
		||||
 * http://www.apache.org/licenses/LICENSE-2.0
 | 
			
		||||
 *
 | 
			
		||||
 * Unless required by applicable law or agreed to in writing, software
 | 
			
		||||
 * distributed under the License is distributed on an "AS IS" BASIS,
 | 
			
		||||
 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
 | 
			
		||||
 * See the License for the specific language governing permissions and
 | 
			
		||||
 * limitations under the License.
 | 
			
		||||
 */
 | 
			
		||||
 | 
			
		||||
#include "ArmGattServer.h"
 | 
			
		||||
#include "mbed.h"
 | 
			
		||||
#include "ArmGap.h"
 | 
			
		||||
#include "wsf_types.h"
 | 
			
		||||
#include "att_api.h"
 | 
			
		||||
 | 
			
		||||
typedef struct armChar_s {
 | 
			
		||||
    uint16_t descLen;
 | 
			
		||||
    armChar_s() {}
 | 
			
		||||
} armChar_t;
 | 
			
		||||
 | 
			
		||||
typedef struct armService_s armService_t;
 | 
			
		||||
struct armService_s {
 | 
			
		||||
    uint16_t uuidLen;
 | 
			
		||||
    armChar_t *chars;
 | 
			
		||||
    attsGroup_t *attGroup;
 | 
			
		||||
    armService_t *next;
 | 
			
		||||
    armService_s() {}
 | 
			
		||||
};
 | 
			
		||||
 | 
			
		||||
static uint16_t currentHandle = 0x20;
 | 
			
		||||
 | 
			
		||||
static UUID cccUUID(BLE_UUID_DESCRIPTOR_CLIENT_CHAR_CONFIG);
 | 
			
		||||
static const uint16_t cccSize = sizeof(uint16_t);
 | 
			
		||||
 | 
			
		||||
ArmGattServer &ArmGattServer::getInstance() {
 | 
			
		||||
    static ArmGattServer m_instance;
 | 
			
		||||
    return m_instance;
 | 
			
		||||
}
 | 
			
		||||
 | 
			
		||||
ble_error_t ArmGattServer::addService(GattService &service)
 | 
			
		||||
{
 | 
			
		||||
    currentHandle = (currentHandle + 0xF) & ~0xF;
 | 
			
		||||
    uint16_t startHandle = currentHandle;
 | 
			
		||||
 | 
			
		||||
    armService_t *armSvc = new armService_t;
 | 
			
		||||
 | 
			
		||||
    // Create WiCentric attribute group
 | 
			
		||||
    armSvc->attGroup = new attsGroup_t;
 | 
			
		||||
 | 
			
		||||
    // Determine the attribute list length
 | 
			
		||||
    unsigned int attListLen = 1;
 | 
			
		||||
    for (int i = 0; i < service.getCharacteristicCount(); i++) {
 | 
			
		||||
        attListLen += 2;
 | 
			
		||||
        GattCharacteristic *p_char = service.getCharacteristic(i);
 | 
			
		||||
 | 
			
		||||
        if (p_char->getProperties() & (GattCharacteristic::BLE_GATT_CHAR_PROPERTIES_NOTIFY | GattCharacteristic::BLE_GATT_CHAR_PROPERTIES_INDICATE)) {
 | 
			
		||||
            // add a CCCD
 | 
			
		||||
            attListLen++;
 | 
			
		||||
        }
 | 
			
		||||
    }
 | 
			
		||||
 | 
			
		||||
    // Create WiCentric attribute list
 | 
			
		||||
    armSvc->attGroup->pAttr = (attsAttr_t*)malloc(attListLen * sizeof(attsAttr_t));;
 | 
			
		||||
    if (armSvc->attGroup->pAttr == NULL) {
 | 
			
		||||
        return BLE_ERROR_BUFFER_OVERFLOW;
 | 
			
		||||
    }
 | 
			
		||||
 | 
			
		||||
    // Create characteristics
 | 
			
		||||
    armSvc->chars = new armChar_t [service.getCharacteristicCount()];
 | 
			
		||||
 | 
			
		||||
    attsAttr_t *currAtt = armSvc->attGroup->pAttr;
 | 
			
		||||
 | 
			
		||||
    /* Service */
 | 
			
		||||
    currAtt->pUuid = attPrimSvcUuid;
 | 
			
		||||
    if (service.getUUID().shortOrLong() == UUID::UUID_TYPE_LONG) {
 | 
			
		||||
        armSvc->uuidLen = UUID::LENGTH_OF_LONG_UUID;
 | 
			
		||||
    } else {
 | 
			
		||||
        armSvc->uuidLen = sizeof(UUID::ShortUUIDBytes_t);
 | 
			
		||||
    }
 | 
			
		||||
    currAtt->pValue = (uint8_t*)malloc(armSvc->uuidLen);
 | 
			
		||||
    memcpy(currAtt->pValue, service.getUUID().getBaseUUID(), armSvc->uuidLen);
 | 
			
		||||
    currAtt->maxLen = armSvc->uuidLen;
 | 
			
		||||
    currAtt->pLen = &armSvc->uuidLen;
 | 
			
		||||
    currAtt->settings = 0;
 | 
			
		||||
    currAtt->permissions = ATTS_PERMIT_READ;
 | 
			
		||||
 | 
			
		||||
    currAtt++;
 | 
			
		||||
 | 
			
		||||
    /* Add characteristics to the service */
 | 
			
		||||
    for (int i = 0; i < service.getCharacteristicCount(); i++) {
 | 
			
		||||
        GattCharacteristic *p_char = service.getCharacteristic(i);
 | 
			
		||||
 | 
			
		||||
        /* Skip any incompletely defined, read-only characteristics. */
 | 
			
		||||
        if ((p_char->getValueAttribute().getValuePtr() == NULL) &&
 | 
			
		||||
            (p_char->getValueAttribute().getLength() == 0) &&
 | 
			
		||||
            (p_char->getProperties() == GattCharacteristic::BLE_GATT_CHAR_PROPERTIES_READ)) {
 | 
			
		||||
            continue;
 | 
			
		||||
        }
 | 
			
		||||
 | 
			
		||||
        // Create Characteristic Attribute
 | 
			
		||||
        currentHandle += 2;
 | 
			
		||||
        currAtt->pUuid = attChUuid;
 | 
			
		||||
 | 
			
		||||
        p_char->getValueAttribute().setHandle(currentHandle);
 | 
			
		||||
        armSvc->chars[i].descLen = 1 + sizeof(currentHandle) + p_char->getValueAttribute().getUUID().getLen();
 | 
			
		||||
        currAtt->pValue = (uint8_t*)malloc(armSvc->chars[i].descLen);
 | 
			
		||||
        uint8_t *pValue = currAtt->pValue;
 | 
			
		||||
        *pValue++ = p_char->getProperties();
 | 
			
		||||
        memcpy(pValue, ¤tHandle, sizeof(currentHandle));
 | 
			
		||||
        pValue += sizeof(currentHandle);
 | 
			
		||||
        memcpy(pValue, p_char->getValueAttribute().getUUID().getBaseUUID(), p_char->getValueAttribute().getUUID().getLen());
 | 
			
		||||
 | 
			
		||||
        currAtt->pLen = &armSvc->chars[i].descLen;
 | 
			
		||||
        currAtt->maxLen = armSvc->chars[i].descLen;
 | 
			
		||||
        currAtt->settings = 0;
 | 
			
		||||
        currAtt->permissions = ATTS_PERMIT_READ;
 | 
			
		||||
        currAtt++;
 | 
			
		||||
 | 
			
		||||
        // Create Value Attribute
 | 
			
		||||
        currAtt->pUuid = p_char->getValueAttribute().getUUID().getBaseUUID();
 | 
			
		||||
        currAtt->pValue = p_char->getValueAttribute().getValuePtr();
 | 
			
		||||
        currAtt->pLen = p_char->getValueAttribute().getLengthPtr();
 | 
			
		||||
        currAtt->maxLen = p_char->getValueAttribute().getMaxLength();
 | 
			
		||||
        currAtt->settings = ATTS_SET_WRITE_CBACK | ATTS_SET_READ_CBACK;
 | 
			
		||||
        if (p_char->getValueAttribute().hasVariableLength()) {
 | 
			
		||||
            currAtt->settings |= ATTS_SET_VARIABLE_LEN;
 | 
			
		||||
        }
 | 
			
		||||
        if (p_char->getValueAttribute().getUUID().shortOrLong() == UUID::UUID_TYPE_LONG) {
 | 
			
		||||
            currAtt->settings |= ATTS_SET_UUID_128;
 | 
			
		||||
        }
 | 
			
		||||
        currAtt->permissions = 0;
 | 
			
		||||
        if (p_char->getProperties() & GattCharacteristic::BLE_GATT_CHAR_PROPERTIES_READ)  { currAtt->permissions |= ATTS_PERMIT_READ; }
 | 
			
		||||
        if (p_char->getProperties() & GattCharacteristic::BLE_GATT_CHAR_PROPERTIES_WRITE) { currAtt->permissions |= ATTS_PERMIT_WRITE; }
 | 
			
		||||
        currAtt++;
 | 
			
		||||
 | 
			
		||||
        bool cccCreated = false;
 | 
			
		||||
 | 
			
		||||
        for (int i = 0; i < p_char->getDescriptorCount(); i++) {
 | 
			
		||||
            GattAttribute *p_att = p_char->getDescriptor(i);
 | 
			
		||||
 | 
			
		||||
            currentHandle++;
 | 
			
		||||
 | 
			
		||||
            currAtt->pUuid = p_att->getUUID().getBaseUUID();
 | 
			
		||||
            currAtt->pValue = p_att->getValuePtr();
 | 
			
		||||
            currAtt->pLen = p_att->getLengthPtr();
 | 
			
		||||
            currAtt->maxLen = p_att->getMaxLength();
 | 
			
		||||
            currAtt->settings = 0;
 | 
			
		||||
            currAtt->permissions = 0;
 | 
			
		||||
            if (p_att->getUUID().shortOrLong() == UUID::UUID_TYPE_LONG) {
 | 
			
		||||
                currAtt->settings |= ATTS_SET_UUID_128;
 | 
			
		||||
            }
 | 
			
		||||
            if (p_att->getUUID() == UUID(BLE_UUID_DESCRIPTOR_CLIENT_CHAR_CONFIG)) {
 | 
			
		||||
                cccCreated = true;
 | 
			
		||||
                currAtt->settings |= ATTS_SET_CCC;
 | 
			
		||||
                currAtt->permissions |= ATTS_PERMIT_READ;
 | 
			
		||||
                currAtt->permissions |= ATTS_PERMIT_WRITE;
 | 
			
		||||
 | 
			
		||||
                if (cccCnt < MAX_CCC_CNT) {
 | 
			
		||||
                    cccSet[cccCnt].handle = currentHandle;
 | 
			
		||||
                    cccSet[cccCnt].valueRange = 0;
 | 
			
		||||
                    if (p_char->getProperties() & GattCharacteristic::BLE_GATT_CHAR_PROPERTIES_NOTIFY) {
 | 
			
		||||
                        cccSet[cccCnt].valueRange |= ATT_CLIENT_CFG_NOTIFY;
 | 
			
		||||
                    }
 | 
			
		||||
                    if (p_char->getProperties() & GattCharacteristic::BLE_GATT_CHAR_PROPERTIES_INDICATE) {
 | 
			
		||||
                        cccSet[cccCnt].valueRange |= ATT_CLIENT_CFG_INDICATE;
 | 
			
		||||
                    }
 | 
			
		||||
                    cccSet[cccCnt].secLevel = DM_SEC_LEVEL_NONE;
 | 
			
		||||
                    cccHandles[cccCnt] = p_char->getValueAttribute().getHandle();
 | 
			
		||||
                    cccCnt++;
 | 
			
		||||
                } else {
 | 
			
		||||
                    return BLE_ERROR_PARAM_OUT_OF_RANGE;
 | 
			
		||||
                }
 | 
			
		||||
            }
 | 
			
		||||
            currAtt++;
 | 
			
		||||
        }
 | 
			
		||||
 | 
			
		||||
        if (!cccCreated && (p_char->getProperties() & (GattCharacteristic::BLE_GATT_CHAR_PROPERTIES_NOTIFY | GattCharacteristic::BLE_GATT_CHAR_PROPERTIES_INDICATE))) {
 | 
			
		||||
            /* There was not a CCCD included in the descriptors, but this
 | 
			
		||||
             * characteristic is notifiable and/or indicatable. A CCCD is
 | 
			
		||||
             * required so create one now.
 | 
			
		||||
             */
 | 
			
		||||
            if (cccCnt >= MAX_CCC_CNT) {
 | 
			
		||||
                return BLE_ERROR_PARAM_OUT_OF_RANGE;
 | 
			
		||||
            }
 | 
			
		||||
 | 
			
		||||
            currentHandle++;
 | 
			
		||||
 | 
			
		||||
            currAtt->pUuid = cccUUID.getBaseUUID();
 | 
			
		||||
            currAtt->pValue = (uint8_t*)&cccValues[cccCnt];
 | 
			
		||||
            currAtt->pLen = (uint16_t*)&cccSize;
 | 
			
		||||
            currAtt->maxLen = sizeof(uint16_t);
 | 
			
		||||
            currAtt->settings = ATTS_SET_CCC;
 | 
			
		||||
            currAtt->permissions = (ATTS_PERMIT_READ | ATTS_PERMIT_WRITE);
 | 
			
		||||
 | 
			
		||||
            cccSet[cccCnt].handle = currentHandle;
 | 
			
		||||
            cccSet[cccCnt].valueRange = 0;
 | 
			
		||||
            if (p_char->getProperties() & GattCharacteristic::BLE_GATT_CHAR_PROPERTIES_NOTIFY) {
 | 
			
		||||
                cccSet[cccCnt].valueRange |= ATT_CLIENT_CFG_NOTIFY;
 | 
			
		||||
            }
 | 
			
		||||
            if (p_char->getProperties() & GattCharacteristic::BLE_GATT_CHAR_PROPERTIES_INDICATE) {
 | 
			
		||||
                cccSet[cccCnt].valueRange |= ATT_CLIENT_CFG_INDICATE;
 | 
			
		||||
            }
 | 
			
		||||
            cccSet[cccCnt].secLevel = DM_SEC_LEVEL_NONE;
 | 
			
		||||
            cccHandles[cccCnt] = p_char->getValueAttribute().getHandle();
 | 
			
		||||
 | 
			
		||||
            cccCnt++;
 | 
			
		||||
            currAtt++;
 | 
			
		||||
        }
 | 
			
		||||
    }
 | 
			
		||||
 | 
			
		||||
    armSvc->attGroup->pNext = NULL;
 | 
			
		||||
    armSvc->attGroup->readCback = attsReadCback;
 | 
			
		||||
    armSvc->attGroup->writeCback = attsWriteCback;
 | 
			
		||||
    armSvc->attGroup->startHandle = startHandle;
 | 
			
		||||
    armSvc->attGroup->endHandle = currentHandle;
 | 
			
		||||
    AttsAddGroup(armSvc->attGroup);
 | 
			
		||||
 | 
			
		||||
    AttRegister(attCback);
 | 
			
		||||
    AttsCccRegister(cccCnt, (attsCccSet_t*)cccSet, cccCback);
 | 
			
		||||
 | 
			
		||||
    return BLE_ERROR_NONE;
 | 
			
		||||
}
 | 
			
		||||
 | 
			
		||||
ble_error_t ArmGattServer::read(GattAttribute::Handle_t attributeHandle, uint8_t buffer[], uint16_t *const lengthP)
 | 
			
		||||
{
 | 
			
		||||
    if (AttsGetAttr(attributeHandle, lengthP, &buffer) != ATT_SUCCESS) {
 | 
			
		||||
        return BLE_ERROR_PARAM_OUT_OF_RANGE;
 | 
			
		||||
    }
 | 
			
		||||
 | 
			
		||||
    return BLE_ERROR_NONE;
 | 
			
		||||
}
 | 
			
		||||
 | 
			
		||||
ble_error_t ArmGattServer::read(Gap::Handle_t connectionHandle, GattAttribute::Handle_t attributeHandle, uint8_t buffer[], uint16_t *lengthP)
 | 
			
		||||
{
 | 
			
		||||
    // Check to see if this is a CCCD
 | 
			
		||||
    uint8_t idx;
 | 
			
		||||
    for (idx = 0; idx < cccCnt; idx++) {
 | 
			
		||||
        if (attributeHandle == cccSet[idx].handle) {
 | 
			
		||||
            if (connectionHandle == DM_CONN_ID_NONE) { // CCCDs are always 16 bits
 | 
			
		||||
                return BLE_ERROR_PARAM_OUT_OF_RANGE;
 | 
			
		||||
            }
 | 
			
		||||
            *((uint16_t*)buffer) = AttsCccGet(connectionHandle, idx);
 | 
			
		||||
            *lengthP = 2;   // CCCDs are always 16 bits
 | 
			
		||||
            return BLE_ERROR_NONE;
 | 
			
		||||
        }
 | 
			
		||||
    }
 | 
			
		||||
 | 
			
		||||
    // This is not a CCCD. Use the non-connection specific update method.
 | 
			
		||||
    return read(attributeHandle, buffer, lengthP);
 | 
			
		||||
}
 | 
			
		||||
 | 
			
		||||
ble_error_t ArmGattServer::write(GattAttribute::Handle_t attributeHandle, const uint8_t buffer[], uint16_t len, bool localOnly)
 | 
			
		||||
{
 | 
			
		||||
    uint16_t connectionHandle = ArmGap::getInstance().getConnectionHandle();
 | 
			
		||||
 | 
			
		||||
    if (AttsSetAttr(attributeHandle, len, (uint8_t*)buffer) != ATT_SUCCESS) {
 | 
			
		||||
        return BLE_ERROR_PARAM_OUT_OF_RANGE;
 | 
			
		||||
    }
 | 
			
		||||
 | 
			
		||||
    if (!localOnly) {
 | 
			
		||||
        if (connectionHandle != DM_CONN_ID_NONE) {
 | 
			
		||||
 | 
			
		||||
            // Check to see if this characteristic has a CCCD attribute
 | 
			
		||||
            uint8_t idx;
 | 
			
		||||
            for (idx = 0; idx < cccCnt; idx++) {
 | 
			
		||||
                if (attributeHandle == cccHandles[idx]) {
 | 
			
		||||
                    break;
 | 
			
		||||
                }
 | 
			
		||||
            }
 | 
			
		||||
            if (idx < cccCnt) {
 | 
			
		||||
                // This characteristic has a CCCD attribute. Handle notifications and indications.
 | 
			
		||||
                uint16_t cccEnabled = AttsCccEnabled(connectionHandle, idx);
 | 
			
		||||
                if (cccEnabled & ATT_CLIENT_CFG_NOTIFY) {
 | 
			
		||||
                    AttsHandleValueNtf(connectionHandle, attributeHandle, len, (uint8_t*)buffer);
 | 
			
		||||
                }
 | 
			
		||||
                if (cccEnabled & ATT_CLIENT_CFG_INDICATE) {
 | 
			
		||||
                    AttsHandleValueInd(connectionHandle, attributeHandle, len, (uint8_t*)buffer);
 | 
			
		||||
                }
 | 
			
		||||
            }
 | 
			
		||||
        }
 | 
			
		||||
    }
 | 
			
		||||
 | 
			
		||||
    return BLE_ERROR_NONE;
 | 
			
		||||
}
 | 
			
		||||
 | 
			
		||||
ble_error_t ArmGattServer::write(Gap::Handle_t connectionHandle, GattAttribute::Handle_t attributeHandle, const uint8_t buffer[], uint16_t len, bool localOnly)
 | 
			
		||||
{
 | 
			
		||||
    // Check to see if this is a CCCD
 | 
			
		||||
    uint8_t idx;
 | 
			
		||||
    for (idx = 0; idx < cccCnt; idx++) {
 | 
			
		||||
        if (attributeHandle == cccSet[idx].handle) {
 | 
			
		||||
            if ((connectionHandle == DM_CONN_ID_NONE) || (len != 2)) { // CCCDs are always 16 bits
 | 
			
		||||
                return BLE_ERROR_PARAM_OUT_OF_RANGE;
 | 
			
		||||
            }
 | 
			
		||||
            AttsCccSet(connectionHandle, idx, *((uint16_t*)buffer));
 | 
			
		||||
            return BLE_ERROR_NONE;
 | 
			
		||||
        }
 | 
			
		||||
    }
 | 
			
		||||
 | 
			
		||||
    // This is not a CCCD. Use the non-connection specific update method.
 | 
			
		||||
    return write(attributeHandle, buffer, len, localOnly);
 | 
			
		||||
}
 | 
			
		||||
 | 
			
		||||
ble_error_t ArmGattServer::areUpdatesEnabled(const GattCharacteristic &characteristic, bool *enabledP)
 | 
			
		||||
{
 | 
			
		||||
    uint16_t connectionHandle = ArmGap::getInstance().getConnectionHandle();
 | 
			
		||||
 | 
			
		||||
    if (connectionHandle != DM_CONN_ID_NONE) {
 | 
			
		||||
        uint8_t idx;
 | 
			
		||||
        for (idx = 0; idx < cccCnt; idx++) {
 | 
			
		||||
            if (characteristic.getValueHandle() == cccHandles[idx]) {
 | 
			
		||||
                uint16_t cccValue = AttsCccGet(connectionHandle, idx);
 | 
			
		||||
                if (cccValue & ATT_CLIENT_CFG_NOTIFY) {
 | 
			
		||||
                    *enabledP = true;
 | 
			
		||||
                } else {
 | 
			
		||||
                    *enabledP = false;
 | 
			
		||||
                }
 | 
			
		||||
                return BLE_ERROR_NONE;
 | 
			
		||||
            }
 | 
			
		||||
        }
 | 
			
		||||
    }
 | 
			
		||||
 | 
			
		||||
    return BLE_ERROR_PARAM_OUT_OF_RANGE;
 | 
			
		||||
}
 | 
			
		||||
 | 
			
		||||
ble_error_t ArmGattServer::areUpdatesEnabled(Gap::Handle_t connectionHandle, const GattCharacteristic &characteristic, bool *enabledP)
 | 
			
		||||
{
 | 
			
		||||
    if (connectionHandle != DM_CONN_ID_NONE) {
 | 
			
		||||
        uint8_t idx;
 | 
			
		||||
        for (idx = 0; idx < cccCnt; idx++) {
 | 
			
		||||
            if (characteristic.getValueHandle() == cccHandles[idx]) {
 | 
			
		||||
                uint16_t cccValue = AttsCccGet(connectionHandle, idx);
 | 
			
		||||
                if (cccValue & ATT_CLIENT_CFG_NOTIFY) {
 | 
			
		||||
                    *enabledP = true;
 | 
			
		||||
                } else {
 | 
			
		||||
                    *enabledP = false;
 | 
			
		||||
                }
 | 
			
		||||
                return BLE_ERROR_NONE;
 | 
			
		||||
            }
 | 
			
		||||
        }
 | 
			
		||||
    }
 | 
			
		||||
 | 
			
		||||
    return BLE_ERROR_PARAM_OUT_OF_RANGE;
 | 
			
		||||
}
 | 
			
		||||
 | 
			
		||||
void ArmGattServer::cccCback(attsCccEvt_t *pEvt)
 | 
			
		||||
{
 | 
			
		||||
    if (pEvt->value & (ATT_CLIENT_CFG_NOTIFY | ATT_CLIENT_CFG_INDICATE)) {
 | 
			
		||||
        getInstance().handleEvent(GattServerEvents::GATT_EVENT_UPDATES_ENABLED, pEvt->handle);
 | 
			
		||||
    } else {
 | 
			
		||||
        getInstance().handleEvent(GattServerEvents::GATT_EVENT_UPDATES_DISABLED, pEvt->handle);
 | 
			
		||||
    }
 | 
			
		||||
}
 | 
			
		||||
 | 
			
		||||
void ArmGattServer::attCback(attEvt_t *pEvt)
 | 
			
		||||
{
 | 
			
		||||
    if (pEvt->hdr.status == ATT_SUCCESS) {
 | 
			
		||||
        getInstance().handleEvent(GattServerEvents::GATT_EVENT_DATA_SENT, pEvt->handle);
 | 
			
		||||
    }
 | 
			
		||||
}
 | 
			
		||||
 | 
			
		||||
uint8_t ArmGattServer::attsReadCback(dmConnId_t connId, uint16_t handle, uint8_t operation, uint16_t offset, attsAttr_t *pAttr)
 | 
			
		||||
{
 | 
			
		||||
    GattReadCallbackParams cbParams = {
 | 
			
		||||
        /* .connHandle = */ connId,
 | 
			
		||||
        /* .handle     = */ handle,
 | 
			
		||||
        /* .offset     = */ offset,
 | 
			
		||||
        /* .len        = */ *pAttr->pLen,
 | 
			
		||||
        /* .data       = */ pAttr->pValue
 | 
			
		||||
    };
 | 
			
		||||
    getInstance().handleDataReadEvent(&cbParams);
 | 
			
		||||
 | 
			
		||||
    return ATT_SUCCESS;
 | 
			
		||||
}
 | 
			
		||||
 | 
			
		||||
uint8_t ArmGattServer::attsWriteCback(dmConnId_t connId, uint16_t handle, uint8_t operation, uint16_t offset, uint16_t len, uint8_t *pValue, attsAttr_t *pAttr)
 | 
			
		||||
{
 | 
			
		||||
    uint8_t err;
 | 
			
		||||
 | 
			
		||||
    /* TODO: offset is not handled properly */
 | 
			
		||||
    if ((err = AttsSetAttr(handle, len, pValue)) != ATT_SUCCESS) {
 | 
			
		||||
        return err;
 | 
			
		||||
    }
 | 
			
		||||
 | 
			
		||||
    GattWriteCallbackParams::WriteOp_t writeOp;
 | 
			
		||||
    switch (operation) {
 | 
			
		||||
        case ATT_PDU_WRITE_REQ:
 | 
			
		||||
            writeOp = GattWriteCallbackParams::OP_WRITE_REQ;
 | 
			
		||||
            break;
 | 
			
		||||
        case ATT_PDU_WRITE_CMD:
 | 
			
		||||
            writeOp = GattWriteCallbackParams::OP_WRITE_CMD;
 | 
			
		||||
            break;
 | 
			
		||||
        case ATT_PDU_SIGNED_WRITE_CMD:
 | 
			
		||||
            writeOp = GattWriteCallbackParams::OP_SIGN_WRITE_CMD;
 | 
			
		||||
            break;
 | 
			
		||||
        case ATT_PDU_PREP_WRITE_REQ:
 | 
			
		||||
            writeOp = GattWriteCallbackParams::OP_PREP_WRITE_REQ;
 | 
			
		||||
            break;
 | 
			
		||||
        case ATT_PDU_EXEC_WRITE_REQ:
 | 
			
		||||
            writeOp = GattWriteCallbackParams::OP_EXEC_WRITE_REQ_NOW;
 | 
			
		||||
            break;
 | 
			
		||||
        default:
 | 
			
		||||
            writeOp = GattWriteCallbackParams::OP_INVALID;
 | 
			
		||||
            break;
 | 
			
		||||
    }
 | 
			
		||||
 | 
			
		||||
    GattWriteCallbackParams cbParams = {
 | 
			
		||||
        /* .connHandle = */ connId,
 | 
			
		||||
        /* .handle     = */ handle,
 | 
			
		||||
        /* .writeOp    = */ writeOp,
 | 
			
		||||
        /* .offset     = */ offset,
 | 
			
		||||
        /* .len        = */ len,
 | 
			
		||||
        /* .data       = */ pValue
 | 
			
		||||
    };
 | 
			
		||||
    getInstance().handleDataWrittenEvent(&cbParams);
 | 
			
		||||
 | 
			
		||||
    return ATT_SUCCESS;
 | 
			
		||||
}
 | 
			
		||||
| 
						 | 
				
			
			@ -1,82 +0,0 @@
 | 
			
		|||
/* mbed Microcontroller Library
 | 
			
		||||
 * Copyright (c) 2015 ARM Limited
 | 
			
		||||
 *
 | 
			
		||||
 * Licensed under the Apache License, Version 2.0 (the "License");
 | 
			
		||||
 * you may not use this file except in compliance with the License.
 | 
			
		||||
 * You may obtain a copy of the License at
 | 
			
		||||
 *
 | 
			
		||||
 *     http://www.apache.org/licenses/LICENSE-2.0
 | 
			
		||||
 *
 | 
			
		||||
 * Unless required by applicable law or agreed to in writing, software
 | 
			
		||||
 * distributed under the License is distributed on an "AS IS" BASIS,
 | 
			
		||||
 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
 | 
			
		||||
 * See the License for the specific language governing permissions and
 | 
			
		||||
 * limitations under the License.
 | 
			
		||||
 */
 | 
			
		||||
#ifndef MBED_PERIPHERALNAMES_H
 | 
			
		||||
#define MBED_PERIPHERALNAMES_H
 | 
			
		||||
 | 
			
		||||
#include "cmsis.h"
 | 
			
		||||
#include "i2c_def.h"
 | 
			
		||||
#include "spi_def.h"
 | 
			
		||||
 | 
			
		||||
#ifdef __cplusplus
 | 
			
		||||
extern "C" {
 | 
			
		||||
#endif
 | 
			
		||||
 | 
			
		||||
typedef enum {
 | 
			
		||||
    UART_0 = (int)CMSDK_UART0_BASE,
 | 
			
		||||
    UART_1 = (int)CMSDK_UART1_BASE
 | 
			
		||||
} UARTName;
 | 
			
		||||
 | 
			
		||||
typedef enum {
 | 
			
		||||
    I2C_0 = (int)I2C0_BASE,
 | 
			
		||||
    I2C_1 = (int)I2C1_BASE
 | 
			
		||||
 | 
			
		||||
} I2CName;
 | 
			
		||||
 | 
			
		||||
typedef enum {
 | 
			
		||||
    ADC0_0 = 0,
 | 
			
		||||
    ADC0_1,
 | 
			
		||||
    ADC0_2,
 | 
			
		||||
    ADC0_3,
 | 
			
		||||
    ADC0_4,
 | 
			
		||||
    ADC0_5
 | 
			
		||||
} ADCName;
 | 
			
		||||
 | 
			
		||||
typedef enum {
 | 
			
		||||
    SPI_0 = (int)SPI0_BASE,
 | 
			
		||||
    SPI_1 = (int)SPI1_BASE
 | 
			
		||||
} SPIName;
 | 
			
		||||
 | 
			
		||||
typedef enum {
 | 
			
		||||
    PWM_1 = 0,
 | 
			
		||||
    PWM_2,
 | 
			
		||||
    PWM_3,
 | 
			
		||||
    PWM_4,
 | 
			
		||||
    PWM_5,
 | 
			
		||||
    PWM_6,
 | 
			
		||||
    PWM_7,
 | 
			
		||||
    PWM_8,
 | 
			
		||||
    PWM_9,
 | 
			
		||||
    PWM_10,
 | 
			
		||||
    PWM_11
 | 
			
		||||
} PWMName;
 | 
			
		||||
 | 
			
		||||
#define STDIO_UART_TX     UART_TX1
 | 
			
		||||
#define STDIO_UART_RX     UART_RX1
 | 
			
		||||
#define STDIO_UART        UART_1
 | 
			
		||||
 | 
			
		||||
#define MBED_UART0        UART_TX0, UART_RX0
 | 
			
		||||
#define MBED_UART1        UART_TX1, UART_RX1
 | 
			
		||||
#define MBED_UARTUSB      UART_TX1, UART_RX1
 | 
			
		||||
 | 
			
		||||
//USB UART
 | 
			
		||||
#define USBTX   UART_TX1
 | 
			
		||||
#define USBRX   UART_RX1
 | 
			
		||||
 | 
			
		||||
#ifdef __cplusplus
 | 
			
		||||
}
 | 
			
		||||
#endif
 | 
			
		||||
 | 
			
		||||
#endif
 | 
			
		||||
| 
						 | 
				
			
			@ -1,161 +0,0 @@
 | 
			
		|||
/* mbed Microcontroller Library
 | 
			
		||||
 * Copyright (c) 2015 ARM Limited
 | 
			
		||||
 *
 | 
			
		||||
 * Licensed under the Apache License, Version 2.0 (the "License");
 | 
			
		||||
 * you may not use this file except in compliance with the License.
 | 
			
		||||
 * You may obtain a copy of the License at
 | 
			
		||||
 *
 | 
			
		||||
 *     http://www.apache.org/licenses/LICENSE-2.0
 | 
			
		||||
 *
 | 
			
		||||
 * Unless required by applicable law or agreed to in writing, software
 | 
			
		||||
 * distributed under the License is distributed on an "AS IS" BASIS,
 | 
			
		||||
 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
 | 
			
		||||
 * See the License for the specific language governing permissions and
 | 
			
		||||
 * limitations under the License.
 | 
			
		||||
 */
 | 
			
		||||
#ifndef MBED_PINNAMES_H
 | 
			
		||||
#define MBED_PINNAMES_H
 | 
			
		||||
 | 
			
		||||
#include "cmsis.h"
 | 
			
		||||
 | 
			
		||||
#ifdef __cplusplus
 | 
			
		||||
extern "C" {
 | 
			
		||||
#endif
 | 
			
		||||
 | 
			
		||||
typedef enum {
 | 
			
		||||
    PIN_INPUT,
 | 
			
		||||
    PIN_OUTPUT
 | 
			
		||||
} PinDirection;
 | 
			
		||||
 | 
			
		||||
#define PORT_SHIFT  5
 | 
			
		||||
 | 
			
		||||
typedef enum {
 | 
			
		||||
/* BEETLE Pin Names */
 | 
			
		||||
/* GPIO0 */
 | 
			
		||||
    P0_0 = 0,
 | 
			
		||||
    P0_1 = 1,
 | 
			
		||||
    P0_2 = 2,
 | 
			
		||||
    P0_3 = 3,
 | 
			
		||||
    P0_4 = 4,
 | 
			
		||||
    P0_5 = 5,
 | 
			
		||||
    P0_6 = 6,
 | 
			
		||||
    P0_7 = 7,
 | 
			
		||||
    P0_8 = 8,
 | 
			
		||||
    P0_9 = 9,
 | 
			
		||||
    P0_10 = 10,
 | 
			
		||||
    P0_11 = 11,
 | 
			
		||||
    P0_12 = 12,
 | 
			
		||||
    P0_13 = 13,
 | 
			
		||||
    P0_14 = 14,
 | 
			
		||||
    P0_15 = 15,
 | 
			
		||||
 | 
			
		||||
/* GPIO1 */
 | 
			
		||||
    P1_0 = 16,
 | 
			
		||||
    P1_1 = 17,
 | 
			
		||||
    P1_2 = 18,
 | 
			
		||||
    P1_3 = 19,
 | 
			
		||||
    P1_4 = 20,
 | 
			
		||||
    P1_5 = 21,
 | 
			
		||||
    P1_6 = 22,
 | 
			
		||||
    P1_7 = 23,
 | 
			
		||||
    P1_8 = 24,
 | 
			
		||||
    P1_9 = 25,
 | 
			
		||||
    P1_10 = 26,
 | 
			
		||||
    P1_11 = 27,
 | 
			
		||||
    P1_12 = 28,
 | 
			
		||||
    P1_13 = 29,
 | 
			
		||||
    P1_14 = 30,
 | 
			
		||||
    P1_15 = 31,
 | 
			
		||||
 | 
			
		||||
/* Arduino Connector Namings */
 | 
			
		||||
    A0 = 600,
 | 
			
		||||
    A1 = 601,
 | 
			
		||||
    A2 = 602,
 | 
			
		||||
    A3 = 603,
 | 
			
		||||
    A4 = 604,
 | 
			
		||||
    A5 = 605,
 | 
			
		||||
    D0 = P0_0,
 | 
			
		||||
    D1 = P0_1,
 | 
			
		||||
    D2 = P0_2,
 | 
			
		||||
    D3 = P0_3,
 | 
			
		||||
    D4 = P0_4,
 | 
			
		||||
    D5 = P0_5,
 | 
			
		||||
    D6 = P0_6,
 | 
			
		||||
    D7 = P0_7,
 | 
			
		||||
    D8 = P0_8,
 | 
			
		||||
    D9 = P0_9,
 | 
			
		||||
    D10 = P0_10,
 | 
			
		||||
    D11 = P0_11,
 | 
			
		||||
    D12 = P0_12,
 | 
			
		||||
    D13 = P0_13,
 | 
			
		||||
    D14 = P0_14,
 | 
			
		||||
    D15 = P0_15,
 | 
			
		||||
 | 
			
		||||
/* TRACE Ports */
 | 
			
		||||
    TRACECLK = P0_2,
 | 
			
		||||
    TRACED0 = P0_6,
 | 
			
		||||
    TRACED1 = P0_7,
 | 
			
		||||
    TRACED2 = P0_8,
 | 
			
		||||
    TRACED3 = P0_9,
 | 
			
		||||
 | 
			
		||||
/* Other BEETLE Pin Names */
 | 
			
		||||
 | 
			
		||||
    //Shield SPI
 | 
			
		||||
    SHIELD_SPI_SCK = 320,
 | 
			
		||||
    SHIELD_SPI_MOSI = 321,
 | 
			
		||||
    SHIELD_SPI_MISO = 322,
 | 
			
		||||
    SHIELD_SPI_nCS = 323,
 | 
			
		||||
 | 
			
		||||
    //ADC SPI
 | 
			
		||||
    ADC_SPI_MOSI = 650,
 | 
			
		||||
    ADC_SPI_MISO = 651,
 | 
			
		||||
    ADC_SPI_SCK  = 652,
 | 
			
		||||
    ADC_SPI_nCS  = 653,
 | 
			
		||||
 | 
			
		||||
    //Uart
 | 
			
		||||
    UART_TX0 = 400,
 | 
			
		||||
    UART_RX0 = 401,
 | 
			
		||||
    UART_TX1 = 402,
 | 
			
		||||
    UART_RX1 = 403,
 | 
			
		||||
 | 
			
		||||
    //Shield I2C
 | 
			
		||||
    SHIELD_SDA = 504,
 | 
			
		||||
    SHIELD_SCL = 505,
 | 
			
		||||
 | 
			
		||||
    // Internal I2C for temperature and acceleromter sensor
 | 
			
		||||
    SENSOR_SDA = 506,
 | 
			
		||||
    SENSOR_SCL = 507,
 | 
			
		||||
 | 
			
		||||
    // Emulated LEDS
 | 
			
		||||
    /*
 | 
			
		||||
     * Beetle board is built to optimize power consumption therefore does not
 | 
			
		||||
     * provide on-board LEDs. The configuration below is provided only for
 | 
			
		||||
     * compatibility purposes with MBED test suite.
 | 
			
		||||
     * The LEDs [1:4] are emulated and trapped in our GPIO driver.
 | 
			
		||||
     * For more details on how to use a Led on an external PIN via GPIO
 | 
			
		||||
     * configuration please refer to the connected community page below:
 | 
			
		||||
     * https://community.arm.com/docs/DOC-11713
 | 
			
		||||
     */
 | 
			
		||||
    LED1 = 1001,
 | 
			
		||||
    LED2 = 1002,
 | 
			
		||||
    LED3 = 1003,
 | 
			
		||||
    LED4 = 1004,
 | 
			
		||||
 | 
			
		||||
    // Not connected
 | 
			
		||||
    NC = (int)0xFFFFFFFF,
 | 
			
		||||
} PinName;
 | 
			
		||||
 | 
			
		||||
typedef enum {
 | 
			
		||||
    PullUp = 2,
 | 
			
		||||
    PullDown = 1,
 | 
			
		||||
    PullNone = 0,
 | 
			
		||||
    Repeater = 3,
 | 
			
		||||
    OpenDrain = 4,
 | 
			
		||||
    PullDefault = PullDown
 | 
			
		||||
} PinMode;
 | 
			
		||||
 | 
			
		||||
#ifdef __cplusplus
 | 
			
		||||
}
 | 
			
		||||
#endif
 | 
			
		||||
 | 
			
		||||
#endif
 | 
			
		||||
| 
						 | 
				
			
			@ -1,32 +0,0 @@
 | 
			
		|||
/* mbed Microcontroller Library
 | 
			
		||||
 * Copyright (c) 2015 ARM Limited
 | 
			
		||||
 *
 | 
			
		||||
 * Licensed under the Apache License, Version 2.0 (the "License");
 | 
			
		||||
 * you may not use this file except in compliance with the License.
 | 
			
		||||
 * You may obtain a copy of the License at
 | 
			
		||||
 *
 | 
			
		||||
 *     http://www.apache.org/licenses/LICENSE-2.0
 | 
			
		||||
 *
 | 
			
		||||
 * Unless required by applicable law or agreed to in writing, software
 | 
			
		||||
 * distributed under the License is distributed on an "AS IS" BASIS,
 | 
			
		||||
 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
 | 
			
		||||
 * See the License for the specific language governing permissions and
 | 
			
		||||
 * limitations under the License.
 | 
			
		||||
 */
 | 
			
		||||
#ifndef MBED_PORTNAMES_H
 | 
			
		||||
#define MBED_PORTNAMES_H
 | 
			
		||||
 | 
			
		||||
#ifdef __cplusplus
 | 
			
		||||
extern "C" {
 | 
			
		||||
#endif
 | 
			
		||||
 | 
			
		||||
typedef enum {
 | 
			
		||||
    Port0 = 0,
 | 
			
		||||
    Port1 = 1
 | 
			
		||||
} PortName;
 | 
			
		||||
 | 
			
		||||
#ifdef __cplusplus
 | 
			
		||||
}
 | 
			
		||||
#endif
 | 
			
		||||
#endif
 | 
			
		||||
 | 
			
		||||
| 
						 | 
				
			
			@ -1,4 +0,0 @@
 | 
			
		|||
*.o binary
 | 
			
		||||
*.lib binary
 | 
			
		||||
*.a binary
 | 
			
		||||
*.ar binary
 | 
			
		||||
| 
						 | 
				
			
			@ -1,49 +0,0 @@
 | 
			
		|||
Permissive Binary License
 | 
			
		||||
 | 
			
		||||
Version 1.0, September 2015
 | 
			
		||||
 | 
			
		||||
Redistribution.  Redistribution and use in binary form, without
 | 
			
		||||
modification, are permitted provided that the following conditions are
 | 
			
		||||
met:
 | 
			
		||||
 | 
			
		||||
1) Redistributions must reproduce the above copyright notice and the
 | 
			
		||||
   following disclaimer in the documentation and/or other materials
 | 
			
		||||
   provided with the distribution.
 | 
			
		||||
 | 
			
		||||
2) Unless to the extent explicitly permitted by law, no reverse
 | 
			
		||||
   engineering, decompilation, or disassembly of this software is
 | 
			
		||||
   permitted.
 | 
			
		||||
 | 
			
		||||
3) Redistribution as part of a software development kit must include the
 | 
			
		||||
   accompanying file named “DEPENDENCIES” and any dependencies listed in
 | 
			
		||||
   that file.
 | 
			
		||||
 | 
			
		||||
4) Neither the name of the copyright holder nor the names of its
 | 
			
		||||
   contributors may be used to endorse or promote products derived from
 | 
			
		||||
   this software without specific prior written permission.
 | 
			
		||||
 | 
			
		||||
Limited patent license. The copyright holders (and contributors) grant a
 | 
			
		||||
worldwide, non-exclusive, no-charge, royalty-free patent license to
 | 
			
		||||
make, have made, use, offer to sell, sell, import, and otherwise
 | 
			
		||||
transfer this software, where such license applies only to those patent
 | 
			
		||||
claims licensable by the copyright holders (and contributors) that are
 | 
			
		||||
necessarily infringed by this software. This patent license shall not
 | 
			
		||||
apply to any combinations that include this software.  No hardware is
 | 
			
		||||
licensed hereunder.
 | 
			
		||||
 | 
			
		||||
If you institute patent litigation against any entity (including a
 | 
			
		||||
cross-claim or counterclaim in a lawsuit) alleging that the software
 | 
			
		||||
itself infringes your patent(s), then your rights granted under this
 | 
			
		||||
license shall terminate as of the date such litigation is filed.
 | 
			
		||||
 | 
			
		||||
DISCLAIMER. THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND
 | 
			
		||||
CONTRIBUTORS "AS IS." ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT
 | 
			
		||||
NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS
 | 
			
		||||
FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
 | 
			
		||||
HOLDERS OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
 | 
			
		||||
SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED
 | 
			
		||||
TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR
 | 
			
		||||
PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF
 | 
			
		||||
LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING
 | 
			
		||||
NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
 | 
			
		||||
SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
 | 
			
		||||
| 
						 | 
				
			
			@ -1,2 +0,0 @@
 | 
			
		|||
The binary files (cordio.0.0.1.ar and cordio_platform.0.0.1.ar) in this directory are licensed under the
 | 
			
		||||
Permissive Binary License1.0 (PBL-1.0) as can be found in: LICENSE-permissive-binary-license-1.0.txt
 | 
			
		||||
										
											Binary file not shown.
										
									
								
							
										
											Binary file not shown.
										
									
								
							| 
						 | 
				
			
			@ -1,4 +0,0 @@
 | 
			
		|||
*.o binary
 | 
			
		||||
*.lib binary
 | 
			
		||||
*.a binary
 | 
			
		||||
*.ar binary
 | 
			
		||||
| 
						 | 
				
			
			@ -1,49 +0,0 @@
 | 
			
		|||
Permissive Binary License
 | 
			
		||||
 | 
			
		||||
Version 1.0, September 2015
 | 
			
		||||
 | 
			
		||||
Redistribution.  Redistribution and use in binary form, without
 | 
			
		||||
modification, are permitted provided that the following conditions are
 | 
			
		||||
met:
 | 
			
		||||
 | 
			
		||||
1) Redistributions must reproduce the above copyright notice and the
 | 
			
		||||
   following disclaimer in the documentation and/or other materials
 | 
			
		||||
   provided with the distribution.
 | 
			
		||||
 | 
			
		||||
2) Unless to the extent explicitly permitted by law, no reverse
 | 
			
		||||
   engineering, decompilation, or disassembly of this software is
 | 
			
		||||
   permitted.
 | 
			
		||||
 | 
			
		||||
3) Redistribution as part of a software development kit must include the
 | 
			
		||||
   accompanying file named “DEPENDENCIES” and any dependencies listed in
 | 
			
		||||
   that file.
 | 
			
		||||
 | 
			
		||||
4) Neither the name of the copyright holder nor the names of its
 | 
			
		||||
   contributors may be used to endorse or promote products derived from
 | 
			
		||||
   this software without specific prior written permission.
 | 
			
		||||
 | 
			
		||||
Limited patent license. The copyright holders (and contributors) grant a
 | 
			
		||||
worldwide, non-exclusive, no-charge, royalty-free patent license to
 | 
			
		||||
make, have made, use, offer to sell, sell, import, and otherwise
 | 
			
		||||
transfer this software, where such license applies only to those patent
 | 
			
		||||
claims licensable by the copyright holders (and contributors) that are
 | 
			
		||||
necessarily infringed by this software. This patent license shall not
 | 
			
		||||
apply to any combinations that include this software.  No hardware is
 | 
			
		||||
licensed hereunder.
 | 
			
		||||
 | 
			
		||||
If you institute patent litigation against any entity (including a
 | 
			
		||||
cross-claim or counterclaim in a lawsuit) alleging that the software
 | 
			
		||||
itself infringes your patent(s), then your rights granted under this
 | 
			
		||||
license shall terminate as of the date such litigation is filed.
 | 
			
		||||
 | 
			
		||||
DISCLAIMER. THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND
 | 
			
		||||
CONTRIBUTORS "AS IS." ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT
 | 
			
		||||
NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS
 | 
			
		||||
FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
 | 
			
		||||
HOLDERS OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
 | 
			
		||||
SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED
 | 
			
		||||
TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR
 | 
			
		||||
PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF
 | 
			
		||||
LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING
 | 
			
		||||
NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
 | 
			
		||||
SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
 | 
			
		||||
| 
						 | 
				
			
			@ -1,2 +0,0 @@
 | 
			
		|||
The binary files (libcordio.0.0.1.a and libcordio_platform.0.0.1.a) in this directory are licensed under the
 | 
			
		||||
Permissive Binary License1.0 (PBL-1.0) as can be found in: LICENSE-permissive-binary-license-1.0.txt
 | 
			
		||||
										
											Binary file not shown.
										
									
								
							
										
											Binary file not shown.
										
									
								
							| 
						 | 
				
			
			@ -1,4 +0,0 @@
 | 
			
		|||
*.o binary
 | 
			
		||||
*.lib binary
 | 
			
		||||
*.a binary
 | 
			
		||||
*.ar binary
 | 
			
		||||
| 
						 | 
				
			
			@ -1,49 +0,0 @@
 | 
			
		|||
Permissive Binary License
 | 
			
		||||
 | 
			
		||||
Version 1.0, September 2015
 | 
			
		||||
 | 
			
		||||
Redistribution.  Redistribution and use in binary form, without
 | 
			
		||||
modification, are permitted provided that the following conditions are
 | 
			
		||||
met:
 | 
			
		||||
 | 
			
		||||
1) Redistributions must reproduce the above copyright notice and the
 | 
			
		||||
   following disclaimer in the documentation and/or other materials
 | 
			
		||||
   provided with the distribution.
 | 
			
		||||
 | 
			
		||||
2) Unless to the extent explicitly permitted by law, no reverse
 | 
			
		||||
   engineering, decompilation, or disassembly of this software is
 | 
			
		||||
   permitted.
 | 
			
		||||
 | 
			
		||||
3) Redistribution as part of a software development kit must include the
 | 
			
		||||
   accompanying file named “DEPENDENCIES” and any dependencies listed in
 | 
			
		||||
   that file.
 | 
			
		||||
 | 
			
		||||
4) Neither the name of the copyright holder nor the names of its
 | 
			
		||||
   contributors may be used to endorse or promote products derived from
 | 
			
		||||
   this software without specific prior written permission.
 | 
			
		||||
 | 
			
		||||
Limited patent license. The copyright holders (and contributors) grant a
 | 
			
		||||
worldwide, non-exclusive, no-charge, royalty-free patent license to
 | 
			
		||||
make, have made, use, offer to sell, sell, import, and otherwise
 | 
			
		||||
transfer this software, where such license applies only to those patent
 | 
			
		||||
claims licensable by the copyright holders (and contributors) that are
 | 
			
		||||
necessarily infringed by this software. This patent license shall not
 | 
			
		||||
apply to any combinations that include this software.  No hardware is
 | 
			
		||||
licensed hereunder.
 | 
			
		||||
 | 
			
		||||
If you institute patent litigation against any entity (including a
 | 
			
		||||
cross-claim or counterclaim in a lawsuit) alleging that the software
 | 
			
		||||
itself infringes your patent(s), then your rights granted under this
 | 
			
		||||
license shall terminate as of the date such litigation is filed.
 | 
			
		||||
 | 
			
		||||
DISCLAIMER. THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND
 | 
			
		||||
CONTRIBUTORS "AS IS." ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT
 | 
			
		||||
NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS
 | 
			
		||||
FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
 | 
			
		||||
HOLDERS OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
 | 
			
		||||
SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED
 | 
			
		||||
TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR
 | 
			
		||||
PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF
 | 
			
		||||
LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING
 | 
			
		||||
NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
 | 
			
		||||
SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
 | 
			
		||||
| 
						 | 
				
			
			@ -1,2 +0,0 @@
 | 
			
		|||
The binary files (libcordio.0.0.1.a and libcordio_platform.0.0.1.a) in this directory are licensed under the
 | 
			
		||||
Permissive Binary License1.0 (PBL-1.0) as can be found in: LICENSE-permissive-binary-license-1.0.txt
 | 
			
		||||
										
											Binary file not shown.
										
									
								
							
										
											Binary file not shown.
										
									
								
							| 
						 | 
				
			
			@ -1,153 +0,0 @@
 | 
			
		|||
/*
 | 
			
		||||
 * PackageLicenseDeclared: Apache-2.0
 | 
			
		||||
 * Copyright (c) 2016 ARM Limited
 | 
			
		||||
 *
 | 
			
		||||
 * Licensed under the Apache License, Version 2.0 (the "License");
 | 
			
		||||
 * you may not use this file except in compliance with the License.
 | 
			
		||||
 * You may obtain a copy of the License at
 | 
			
		||||
 *
 | 
			
		||||
 * http://www.apache.org/licenses/LICENSE-2.0
 | 
			
		||||
 *
 | 
			
		||||
 * Unless required by applicable law or agreed to in writing, software
 | 
			
		||||
 * distributed under the License is distributed on an "AS IS" BASIS,
 | 
			
		||||
 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
 | 
			
		||||
 * See the License for the specific language governing permissions and
 | 
			
		||||
 * limitations under the License.
 | 
			
		||||
 */
 | 
			
		||||
#include "cmsis.h"
 | 
			
		||||
#include "mbed_assert.h"
 | 
			
		||||
#include "mbed_wait_api.h"
 | 
			
		||||
#include "analogin_api.h"
 | 
			
		||||
#include "gpio_api.h"
 | 
			
		||||
#include "spi_api.h"
 | 
			
		||||
#include "pinmap.h"
 | 
			
		||||
 | 
			
		||||
#if DEVICE_ANALOGIN
 | 
			
		||||
 | 
			
		||||
/*
 | 
			
		||||
 * Channel Address for the next acquisition:
 | 
			
		||||
 * XXAAAXXX XXXXXXXX
 | 
			
		||||
 */
 | 
			
		||||
#define ADC_SPI_ADDRESS  11
 | 
			
		||||
 | 
			
		||||
/* ADC Resolution */
 | 
			
		||||
#define ADC_RESOLUTION  0xFFF
 | 
			
		||||
 | 
			
		||||
/* ADC Voltage Divider */
 | 
			
		||||
#define ADC_DIV   819.0
 | 
			
		||||
 | 
			
		||||
/* PinMap structure for ADC IN */
 | 
			
		||||
static const PinMap PinMap_ADC[] = {
 | 
			
		||||
    {A0, ADC0_0, 0},
 | 
			
		||||
    {A1, ADC0_1, 0},
 | 
			
		||||
    {A2, ADC0_2, 0},
 | 
			
		||||
    {A3, ADC0_3, 0},
 | 
			
		||||
    {A4, ADC0_4, 0},
 | 
			
		||||
    {A5, ADC0_5, 0},
 | 
			
		||||
    {NC, NC, 0}
 | 
			
		||||
};
 | 
			
		||||
 | 
			
		||||
/* ADC SPI Private Data */
 | 
			
		||||
typedef struct {
 | 
			
		||||
    /* ADC SPI */
 | 
			
		||||
    spi_t analogin_spi;
 | 
			
		||||
    /* ADC SPI CS */
 | 
			
		||||
    gpio_t adc_spi_cs_gpio;
 | 
			
		||||
    /* ADC SPI State */
 | 
			
		||||
    uint32_t analog_spi_inited;
 | 
			
		||||
} analogin_spi_t;
 | 
			
		||||
/* ADC SPI Device */
 | 
			
		||||
static analogin_spi_t analogin_spi_dev;
 | 
			
		||||
 | 
			
		||||
/*
 | 
			
		||||
 * ADC SPI CS
 | 
			
		||||
 */
 | 
			
		||||
#define ADC_SPI_CS  P1_2
 | 
			
		||||
 | 
			
		||||
/*
 | 
			
		||||
 * Initialize the analogin peripheral
 | 
			
		||||
 * Configures the pin used by analogin.
 | 
			
		||||
 * obj: The analogin object to initialize
 | 
			
		||||
 * pin: The analogin pin name
 | 
			
		||||
 */
 | 
			
		||||
void analogin_init(analogin_t *obj, PinName pin)
 | 
			
		||||
{
 | 
			
		||||
    /* Initialize ADC Pin */
 | 
			
		||||
    obj->adc = (ADCName)pinmap_peripheral(pin, PinMap_ADC);
 | 
			
		||||
    /* Verify if pin is valid */
 | 
			
		||||
    MBED_ASSERT(obj->adc != (ADCName)NC);
 | 
			
		||||
 | 
			
		||||
    /* Initialize the ADC SPI */
 | 
			
		||||
    if(analogin_spi_dev.analog_spi_inited == 0){
 | 
			
		||||
        /* Initialize SPI for ADC */
 | 
			
		||||
        spi_init(&(analogin_spi_dev.analogin_spi), ADC_SPI_MOSI,
 | 
			
		||||
                ADC_SPI_MISO, ADC_SPI_SCK, ADC_SPI_nCS);
 | 
			
		||||
        spi_format(&(analogin_spi_dev.analogin_spi), 16, 3, 0);
 | 
			
		||||
        /* Set SPI to MAX Freq */
 | 
			
		||||
        spi_frequency(&(analogin_spi_dev.analogin_spi), 0);
 | 
			
		||||
 | 
			
		||||
        /* Initialize CS GPIO */
 | 
			
		||||
        gpio_init_out(&(analogin_spi_dev.adc_spi_cs_gpio), ADC_SPI_CS);
 | 
			
		||||
 | 
			
		||||
        analogin_spi_dev.analog_spi_inited = 1;
 | 
			
		||||
    }
 | 
			
		||||
 | 
			
		||||
    /* If pin is valid assign it to the ADC data structure */
 | 
			
		||||
    obj->pin = pin;
 | 
			
		||||
    obj->pin_number = pin-600;
 | 
			
		||||
    obj->address = (0x0000 | (pin-600));
 | 
			
		||||
 | 
			
		||||
    /* Configure the pinout */
 | 
			
		||||
    pinmap_pinout(pin, PinMap_ADC);
 | 
			
		||||
}
 | 
			
		||||
 | 
			
		||||
/*
 | 
			
		||||
 * Read the value from analogin pin, represented as an unsigned 16bit value
 | 
			
		||||
 * obj: The analogin object
 | 
			
		||||
 * @return: An unsigned 16bit value representing the current input voltage
 | 
			
		||||
 */
 | 
			
		||||
uint16_t analogin_read_u16(analogin_t *obj)
 | 
			
		||||
{
 | 
			
		||||
    uint16_t result = 0;
 | 
			
		||||
 | 
			
		||||
    /*
 | 
			
		||||
     * The ADC SPI hw is 8 bit format, 16 bit emulation is required
 | 
			
		||||
     * in the SPI driver.
 | 
			
		||||
     */
 | 
			
		||||
    /* CS = 1 */
 | 
			
		||||
    gpio_write(&(analogin_spi_dev.adc_spi_cs_gpio), 1);
 | 
			
		||||
    /* Do the first read */
 | 
			
		||||
    (void)spi_master_write(&(analogin_spi_dev.analogin_spi),
 | 
			
		||||
        ((obj->pin_number) << ADC_SPI_ADDRESS));
 | 
			
		||||
    /* CS = 0 */
 | 
			
		||||
    gpio_write(&(analogin_spi_dev.adc_spi_cs_gpio), 0);
 | 
			
		||||
    /* Wait 50 us */
 | 
			
		||||
    wait_us(50);
 | 
			
		||||
    /* CS = 1 */
 | 
			
		||||
    gpio_write(&(analogin_spi_dev.adc_spi_cs_gpio), 1);
 | 
			
		||||
    /* The second read provides the result */
 | 
			
		||||
    result = spi_master_write(&(analogin_spi_dev.analogin_spi),
 | 
			
		||||
        ((obj->pin_number) << ADC_SPI_ADDRESS));
 | 
			
		||||
    /* CS = 0 */
 | 
			
		||||
    gpio_write(&(analogin_spi_dev.adc_spi_cs_gpio), 0);
 | 
			
		||||
 | 
			
		||||
    return result;
 | 
			
		||||
}
 | 
			
		||||
 | 
			
		||||
/*
 | 
			
		||||
 * Read the input voltage, represented as a float in the range [0.0, 1.0]
 | 
			
		||||
 * obj: The analogin object
 | 
			
		||||
 * @return: A floating value representing the current input voltage
 | 
			
		||||
 */
 | 
			
		||||
float analogin_read(analogin_t *obj)
 | 
			
		||||
{
 | 
			
		||||
    uint16_t result = analogin_read_u16(obj);
 | 
			
		||||
    return (float)((result & ADC_RESOLUTION) * 1.0f) / ADC_DIV;
 | 
			
		||||
}
 | 
			
		||||
 | 
			
		||||
const PinMap *analogin_pinmap()
 | 
			
		||||
{
 | 
			
		||||
    return PinMap_ADC;
 | 
			
		||||
}
 | 
			
		||||
 | 
			
		||||
#endif
 | 
			
		||||
| 
						 | 
				
			
			@ -1,49 +0,0 @@
 | 
			
		|||
Permissive Binary License
 | 
			
		||||
 | 
			
		||||
Version 1.0, September 2015
 | 
			
		||||
 | 
			
		||||
Redistribution.  Redistribution and use in binary form, without
 | 
			
		||||
modification, are permitted provided that the following conditions are
 | 
			
		||||
met:
 | 
			
		||||
 | 
			
		||||
1) Redistributions must reproduce the above copyright notice and the
 | 
			
		||||
   following disclaimer in the documentation and/or other materials
 | 
			
		||||
   provided with the distribution.
 | 
			
		||||
 | 
			
		||||
2) Unless to the extent explicitly permitted by law, no reverse
 | 
			
		||||
   engineering, decompilation, or disassembly of this software is
 | 
			
		||||
   permitted.
 | 
			
		||||
 | 
			
		||||
3) Redistribution as part of a software development kit must include the
 | 
			
		||||
   accompanying file named “DEPENDENCIES” and any dependencies listed in
 | 
			
		||||
   that file.
 | 
			
		||||
 | 
			
		||||
4) Neither the name of the copyright holder nor the names of its
 | 
			
		||||
   contributors may be used to endorse or promote products derived from
 | 
			
		||||
   this software without specific prior written permission.
 | 
			
		||||
 | 
			
		||||
Limited patent license. The copyright holders (and contributors) grant a
 | 
			
		||||
worldwide, non-exclusive, no-charge, royalty-free patent license to
 | 
			
		||||
make, have made, use, offer to sell, sell, import, and otherwise
 | 
			
		||||
transfer this software, where such license applies only to those patent
 | 
			
		||||
claims licensable by the copyright holders (and contributors) that are
 | 
			
		||||
necessarily infringed by this software. This patent license shall not
 | 
			
		||||
apply to any combinations that include this software.  No hardware is
 | 
			
		||||
licensed hereunder.
 | 
			
		||||
 | 
			
		||||
If you institute patent litigation against any entity (including a
 | 
			
		||||
cross-claim or counterclaim in a lawsuit) alleging that the software
 | 
			
		||||
itself infringes your patent(s), then your rights granted under this
 | 
			
		||||
license shall terminate as of the date such litigation is filed.
 | 
			
		||||
 | 
			
		||||
DISCLAIMER. THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND
 | 
			
		||||
CONTRIBUTORS "AS IS." ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT
 | 
			
		||||
NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS
 | 
			
		||||
FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
 | 
			
		||||
HOLDERS OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
 | 
			
		||||
SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED
 | 
			
		||||
TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR
 | 
			
		||||
PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF
 | 
			
		||||
LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING
 | 
			
		||||
NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
 | 
			
		||||
SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
 | 
			
		||||
| 
						 | 
				
			
			@ -1,4 +0,0 @@
 | 
			
		|||
*.o binary
 | 
			
		||||
*.lib binary
 | 
			
		||||
*.a binary
 | 
			
		||||
*.ar binary
 | 
			
		||||
										
											Binary file not shown.
										
									
								
							| 
						 | 
				
			
			@ -1,49 +0,0 @@
 | 
			
		|||
Permissive Binary License
 | 
			
		||||
 | 
			
		||||
Version 1.0, September 2015
 | 
			
		||||
 | 
			
		||||
Redistribution.  Redistribution and use in binary form, without
 | 
			
		||||
modification, are permitted provided that the following conditions are
 | 
			
		||||
met:
 | 
			
		||||
 | 
			
		||||
1) Redistributions must reproduce the above copyright notice and the
 | 
			
		||||
   following disclaimer in the documentation and/or other materials
 | 
			
		||||
   provided with the distribution.
 | 
			
		||||
 | 
			
		||||
2) Unless to the extent explicitly permitted by law, no reverse
 | 
			
		||||
   engineering, decompilation, or disassembly of this software is
 | 
			
		||||
   permitted.
 | 
			
		||||
 | 
			
		||||
3) Redistribution as part of a software development kit must include the
 | 
			
		||||
   accompanying file named “DEPENDENCIES” and any dependencies listed in
 | 
			
		||||
   that file.
 | 
			
		||||
 | 
			
		||||
4) Neither the name of the copyright holder nor the names of its
 | 
			
		||||
   contributors may be used to endorse or promote products derived from
 | 
			
		||||
   this software without specific prior written permission.
 | 
			
		||||
 | 
			
		||||
Limited patent license. The copyright holders (and contributors) grant a
 | 
			
		||||
worldwide, non-exclusive, no-charge, royalty-free patent license to
 | 
			
		||||
make, have made, use, offer to sell, sell, import, and otherwise
 | 
			
		||||
transfer this software, where such license applies only to those patent
 | 
			
		||||
claims licensable by the copyright holders (and contributors) that are
 | 
			
		||||
necessarily infringed by this software. This patent license shall not
 | 
			
		||||
apply to any combinations that include this software.  No hardware is
 | 
			
		||||
licensed hereunder.
 | 
			
		||||
 | 
			
		||||
If you institute patent litigation against any entity (including a
 | 
			
		||||
cross-claim or counterclaim in a lawsuit) alleging that the software
 | 
			
		||||
itself infringes your patent(s), then your rights granted under this
 | 
			
		||||
license shall terminate as of the date such litigation is filed.
 | 
			
		||||
 | 
			
		||||
DISCLAIMER. THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND
 | 
			
		||||
CONTRIBUTORS "AS IS." ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT
 | 
			
		||||
NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS
 | 
			
		||||
FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
 | 
			
		||||
HOLDERS OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
 | 
			
		||||
SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED
 | 
			
		||||
TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR
 | 
			
		||||
PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF
 | 
			
		||||
LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING
 | 
			
		||||
NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
 | 
			
		||||
SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
 | 
			
		||||
| 
						 | 
				
			
			@ -1,2 +0,0 @@
 | 
			
		|||
The binary files (CORDIO_RO_2.1.o and TRIM_2.1.o) in this directory are licensed under the
 | 
			
		||||
Permissive Binary License1.0 (PBL-1.0) as can be found in: LICENSE-permissive-binary-license-1.0.txt
 | 
			
		||||
										
											Binary file not shown.
										
									
								
							| 
						 | 
				
			
			@ -1,122 +0,0 @@
 | 
			
		|||
/*************************************************************************************************/
 | 
			
		||||
/*!
 | 
			
		||||
 *  \file   board.h
 | 
			
		||||
 *
 | 
			
		||||
 *  \brief  Board-specific include file for BT4 module board.
 | 
			
		||||
 *
 | 
			
		||||
 *  Copyright (c) 2015-2016 ARM, Ltd., all rights reserved.
 | 
			
		||||
 *  ARM confidential and proprietary.
 | 
			
		||||
 *
 | 
			
		||||
 *  IMPORTANT.  Your use of this file is governed by a Software License Agreement
 | 
			
		||||
 *  ("Agreement") that must be accepted in order to download or otherwise receive a
 | 
			
		||||
 *  copy of this file.  You may not use or copy this file for any purpose other than
 | 
			
		||||
 *  as described in the Agreement.  If you do not agree to all of the terms of the
 | 
			
		||||
 *  Agreement do not use this file and delete all copies in your possession or control;
 | 
			
		||||
 *  if you do not have a copy of the Agreement, you must contact ARM, Ltd. prior
 | 
			
		||||
 *  to any use, copying or further distribution of this software.
 | 
			
		||||
 */
 | 
			
		||||
/*************************************************************************************************/
 | 
			
		||||
 | 
			
		||||
#ifndef BOARD_H
 | 
			
		||||
#define BOARD_H
 | 
			
		||||
 | 
			
		||||
 | 
			
		||||
 | 
			
		||||
/***************************************************************************************************
 | 
			
		||||
** DEVICE
 | 
			
		||||
***************************************************************************************************/
 | 
			
		||||
 | 
			
		||||
/* install defines and installs for device ARM_BEETLE_SOC	*/
 | 
			
		||||
#define ARM_BEETLE_SOC  (1U)
 | 
			
		||||
 | 
			
		||||
/***************************************************************************************************
 | 
			
		||||
** UART & CONSOLE
 | 
			
		||||
***************************************************************************************************/
 | 
			
		||||
#include <drv_uart.h>
 | 
			
		||||
extern const struct drv_uart Drv_UART0;
 | 
			
		||||
#define BOARD_HAS_UART0
 | 
			
		||||
 | 
			
		||||
#include <drv_console.h>
 | 
			
		||||
extern const struct drv_console Drv_Console0;
 | 
			
		||||
 | 
			
		||||
#define BOARD_UART          Drv_UART0
 | 
			
		||||
#define BOARD_CONSOLE       Drv_Console0
 | 
			
		||||
#define BOARD_CONSOLE_NUM   0
 | 
			
		||||
#define BOARD_CONSOLE_BAUD  9600u
 | 
			
		||||
 | 
			
		||||
#define BOARD_HCIPASSTHRU_CONSOLE  Drv_Console0
 | 
			
		||||
#define BOARD_HCIPASSTHRU_NUM      0
 | 
			
		||||
#define BOARD_HCIPASSTHRU_BAUD     9600u
 | 
			
		||||
 | 
			
		||||
#if BOARD_CONSOLE_NUM == BOARD_HCIPASSTHRU_NUM
 | 
			
		||||
# if BOARD_CONSOLE_BAUD != BOARD_HCIPASSTHRU_BAUD
 | 
			
		||||
#  error CONSOLE and HCIPASSTHRU use the same UART, but the bauds are configured different
 | 
			
		||||
# endif
 | 
			
		||||
#endif
 | 
			
		||||
 | 
			
		||||
#define BOARD_TERMINAL_CONSOLE  Drv_Console0
 | 
			
		||||
#define BOARD_TERMINAL_NUM      0
 | 
			
		||||
#define BOARD_TERMINAL_BAUD     9600u
 | 
			
		||||
 | 
			
		||||
/***************************************************************************************************
 | 
			
		||||
** GPIO
 | 
			
		||||
***************************************************************************************************/
 | 
			
		||||
#define BOARD_GPIO_OUTPUT_QUANTITY  1u
 | 
			
		||||
#define BOARD_GPIO_OUTPUT_0         GPIO_GPIO3
 | 
			
		||||
#define BOARD_GPIO_OUTPUTS         {BOARD_GPIO_OUTPUT_0}
 | 
			
		||||
#define BOARD_GPIO_OUTPUTS_MASK    (BOARD_GPIO_OUTPUT_0)
 | 
			
		||||
 | 
			
		||||
/* gpio inputs */
 | 
			
		||||
#define BOARD_HAS_WAKEUP
 | 
			
		||||
 | 
			
		||||
/***************************************************************************************************
 | 
			
		||||
** SPI
 | 
			
		||||
***************************************************************************************************/
 | 
			
		||||
#ifndef  ARM_BEETLE_SOC
 | 
			
		||||
 | 
			
		||||
#define BOARD_SPIFLASH_MAIN_IMAGE_OFFSET      0u
 | 
			
		||||
#define BOARD_SPIFLASH_MAIN_IMAGE_LIMIT   (BOARD_SPIFLASH_NVDATA_OFFSET - 1u)
 | 
			
		||||
#define BOARD_SPIFLASH_NVDATA_LEN           (4u * 1024u)
 | 
			
		||||
#define BOARD_SPIFLASH_NVDATA_OFFSET     (1020u * 1024u)
 | 
			
		||||
#define BOARD_SPIFLASH_NVDATA_LIMIT       (BOARD_SPIFLASH_NVDATA_OFFSET + BOARD_SPIFLASH_NVDATA_LEN - 1u)
 | 
			
		||||
 | 
			
		||||
#else
 | 
			
		||||
/* USING ON CHIP FLASH FROM UPPER UPPER BANK, LINKED THROUGH *.o and SCATTER */
 | 
			
		||||
extern unsigned char    _binary_ASIC_2_1_img_start;
 | 
			
		||||
extern unsigned char    _binary_ASIC_2_1_img_end;
 | 
			
		||||
extern unsigned char    _binary_ASIC_2_1_img_size;
 | 
			
		||||
 | 
			
		||||
#define BOARD_HAS_FLASH_STORAGE
 | 
			
		||||
 | 
			
		||||
#define FLASH_ELF_HDR_JMP_OFFSET                (52U)
 | 
			
		||||
#define BOARD_FLASH_STORAGE_MAIN_IMAGE_OFFSET   (0U)    //jump over the ELF HEADER OF OBJECT
 | 
			
		||||
#define BOARD_FLASH_STORAGE_MAIN_IMAGE_LIMIT    (((74U) * (1024U)) - 1u)    //64K FLASH STORAGE BLOCK
 | 
			
		||||
 | 
			
		||||
#define BOARD_FLASH_STORAGE_NVDATA_OFFSET       (0U)
 | 
			
		||||
#define BOARD_FLASH_STORAGE_NVDATA_LEN          ((4U) * (1024U))    //4K NVM BLOCK SIZE
 | 
			
		||||
#define BOARD_FLASH_STORAGE_NVDATA_LIMIT        (BOARD_FLASH_STORAGE_NVDATA_OFFSET + BOARD_FLASH_STORAGE_NVDATA_LEN - 1u)
 | 
			
		||||
 | 
			
		||||
#define BOARD_FLASH_STORAGE_DATA_LEN_MASK       (0xFFFU);   //Length mask of 4K
 | 
			
		||||
 | 
			
		||||
#endif
 | 
			
		||||
 | 
			
		||||
 | 
			
		||||
 | 
			
		||||
/***************************************************************************************************
 | 
			
		||||
** LLCC
 | 
			
		||||
***************************************************************************************************/
 | 
			
		||||
 | 
			
		||||
#include <drv_llcc.h>
 | 
			
		||||
extern const struct drv_llcc Drv_LLCC;
 | 
			
		||||
 | 
			
		||||
/***************************************************************************************************
 | 
			
		||||
** IDs
 | 
			
		||||
***************************************************************************************************/
 | 
			
		||||
 | 
			
		||||
#define BOARD_MANUFACTURER      "ARM, Ltd."
 | 
			
		||||
#define BOARD_NAME              "BEETLE"
 | 
			
		||||
#define BOARD_NAME_SHORT        "BT4"
 | 
			
		||||
#define BOARD_HW_REVISION       "B"
 | 
			
		||||
#define BOARD_COMPANY_ID        0x01AFu
 | 
			
		||||
 | 
			
		||||
#endif /* BOARD_H */
 | 
			
		||||
| 
						 | 
				
			
			@ -1,358 +0,0 @@
 | 
			
		|||
/*************************************************************************************************/
 | 
			
		||||
/*!
 | 
			
		||||
 *  \file   main_board.h
 | 
			
		||||
 *
 | 
			
		||||
 *  \brief  Board services.
 | 
			
		||||
 *
 | 
			
		||||
 *  Copyright (c) 2015 ARM, Ltd., all rights reserved.
 | 
			
		||||
 *  ARM confidential and proprietary.
 | 
			
		||||
 *
 | 
			
		||||
 *  IMPORTANT.  Your use of this file is governed by a Software License Agreement
 | 
			
		||||
 *  ("Agreement") that must be accepted in order to download or otherwise receive a
 | 
			
		||||
 *  copy of this file.  You may not use or copy this file for any purpose other than
 | 
			
		||||
 *  as described in the Agreement.  If you do not agree to all of the terms of the
 | 
			
		||||
 *  Agreement do not use this file and delete all copies in your possession or control;
 | 
			
		||||
 *  if you do not have a copy of the Agreement, you must contact ARM, Ltd. prior
 | 
			
		||||
 *  to any use, copying or further distribution of this software.
 | 
			
		||||
 */
 | 
			
		||||
/*************************************************************************************************/
 | 
			
		||||
 | 
			
		||||
#ifndef __MAIN_BOARD_H
 | 
			
		||||
#define __MAIN_BOARD_H
 | 
			
		||||
 | 
			
		||||
/***************************************************************************************************
 | 
			
		||||
** INCLUDES
 | 
			
		||||
***************************************************************************************************/
 | 
			
		||||
 | 
			
		||||
#include "chip.h"
 | 
			
		||||
#include "board.h"
 | 
			
		||||
 | 
			
		||||
#include "wsf_types.h"
 | 
			
		||||
 | 
			
		||||
#ifdef __cplusplus
 | 
			
		||||
extern "C" {
 | 
			
		||||
#endif
 | 
			
		||||
 | 
			
		||||
/***************************************************************************************************
 | 
			
		||||
** TYPES
 | 
			
		||||
***************************************************************************************************/
 | 
			
		||||
 | 
			
		||||
/*--------------------------------------------------------------------------------------------------
 | 
			
		||||
** enum main_board_mode
 | 
			
		||||
**
 | 
			
		||||
** DESCRIPTION: Mode of application on board, if detectable at run-time.
 | 
			
		||||
--------------------------------------------------------------------------------------------------*/
 | 
			
		||||
enum main_board_mode {
 | 
			
		||||
    MAIN_BOARD_MODE_DTM                   = 0,
 | 
			
		||||
    MAIN_BOARD_MODE_BEACON                = 1,
 | 
			
		||||
    MAIN_BOARD_MODE_SENSOR                = 2,
 | 
			
		||||
    MAIN_BOARD_MODE_BEACON_NONCONNECTABLE = 3
 | 
			
		||||
};
 | 
			
		||||
 | 
			
		||||
/*--------------------------------------------------------------------------------------------------
 | 
			
		||||
** enum main_board_settings
 | 
			
		||||
**
 | 
			
		||||
** DESCRIPTION: Settings for board, stored in NV data.  These values should not be changed once
 | 
			
		||||
**              used.
 | 
			
		||||
--------------------------------------------------------------------------------------------------*/
 | 
			
		||||
enum main_board_settings {
 | 
			
		||||
    /* Major number (for beacon) [2 bytes] */
 | 
			
		||||
    MAIN_BOARD_SETTING_MAJOR = 0,
 | 
			
		||||
    /* Minor number (for beacon) [2 bytes] */
 | 
			
		||||
    MAIN_BOARD_SETTING_MINOR = 1,
 | 
			
		||||
    /* RSSI reference (for beacon) [2 bytes] */
 | 
			
		||||
    MAIN_BOARD_SETTING_RSSI_REFERENCE = 2,
 | 
			
		||||
    /* HCI logging level [1 byte] */
 | 
			
		||||
    MAIN_BOARD_SETTING_HCI_LOGGING_LEVEL = 3,
 | 
			
		||||
    /* Lock state (for UriBeacon) [1 byte] */
 | 
			
		||||
    MAIN_BOARD_SETTING_LOCK_STATE = 4,
 | 
			
		||||
    /* URI data (for UriBeacon) [18 bytes] */
 | 
			
		||||
    MAIN_BOARD_SETTING_URI_DATA = 5,
 | 
			
		||||
    /* URI flags (for UriBeacon) [1 byte] */
 | 
			
		||||
    MAIN_BOARD_SETTING_URI_FLAGS = 6,
 | 
			
		||||
    /* Advertised tx power levels (for UriBeacon) [4 bytes] */
 | 
			
		||||
    MAIN_BOARD_SETTING_ADVERTISED_TX_POWER_LEVELS = 7,
 | 
			
		||||
    /* Tx power mode (for UriBeacon) [1 byte] */
 | 
			
		||||
    MAIN_BOARD_SETTING_TX_POWER_MODE = 8,
 | 
			
		||||
    /* Beacon period (for beacon) [2 bytes] */
 | 
			
		||||
    MAIN_BOARD_SETTING_BEACON_PERIOD = 9,
 | 
			
		||||
    /* Lock [16 bytes] */
 | 
			
		||||
    MAIN_BOARD_SETTING_LOCK = 10,
 | 
			
		||||
    /* PIN [3 bytes] */
 | 
			
		||||
    MAIN_BOARD_SETTING_PIN = 11,
 | 
			
		||||
    /* Beacon type [1 byte] */
 | 
			
		||||
    MAIN_BOARD_SETTING_BEACON_TYPE = 12,
 | 
			
		||||
};
 | 
			
		||||
 | 
			
		||||
/*--------------------------------------------------------------------------------------------------
 | 
			
		||||
** enum main_board_muxmode
 | 
			
		||||
**
 | 
			
		||||
** DESCRIPTION: Settings for MUX mode of MCU.
 | 
			
		||||
--------------------------------------------------------------------------------------------------*/
 | 
			
		||||
enum main_board_muxmode {
 | 
			
		||||
    MAIN_BOARD_MUXMODE_NORMAL = 0,
 | 
			
		||||
    MAIN_BOARD_MUXMODE_DIGITAL_TEST = 1,
 | 
			
		||||
};
 | 
			
		||||
 | 
			
		||||
/***************************************************************************************************
 | 
			
		||||
** FUNCTIONS
 | 
			
		||||
***************************************************************************************************/
 | 
			
		||||
 | 
			
		||||
/*--------------------------------------------------------------------------------------------------
 | 
			
		||||
** Main_BoardInit()
 | 
			
		||||
**
 | 
			
		||||
** DESCRIPTION: Initialize board.
 | 
			
		||||
--------------------------------------------------------------------------------------------------*/
 | 
			
		||||
void Main_BoardInit(void);
 | 
			
		||||
 | 
			
		||||
/*--------------------------------------------------------------------------------------------------
 | 
			
		||||
** Main_BoardI2cInit()
 | 
			
		||||
**
 | 
			
		||||
** DESCRIPTION: Initialize I2C devices on board.
 | 
			
		||||
--------------------------------------------------------------------------------------------------*/
 | 
			
		||||
#ifdef BOARD_HAS_I2C
 | 
			
		||||
void Main_BoardI2cInit(void);
 | 
			
		||||
#endif
 | 
			
		||||
 | 
			
		||||
/*--------------------------------------------------------------------------------------------------
 | 
			
		||||
** Main_BoardGetMode()
 | 
			
		||||
**
 | 
			
		||||
** DESCRIPTION: Get board mode.
 | 
			
		||||
**
 | 
			
		||||
** RETURNS:     Board mode.
 | 
			
		||||
--------------------------------------------------------------------------------------------------*/
 | 
			
		||||
enum main_board_mode Main_BoardGetMode(void);
 | 
			
		||||
 | 
			
		||||
/*--------------------------------------------------------------------------------------------------
 | 
			
		||||
** Main_BoardNvGetSize()
 | 
			
		||||
**
 | 
			
		||||
** DESCRIPTION: Called to get size of NV memory.
 | 
			
		||||
**
 | 
			
		||||
** RETURNS:     Size of NV memory
 | 
			
		||||
**------------------------------------------------------------------------------------------------*/
 | 
			
		||||
#ifdef BOARD_HAS_SPIFLASH
 | 
			
		||||
size_t Main_BoardNvGetSize(void);
 | 
			
		||||
#endif /* BOARD_HAS_SPIFLASH */
 | 
			
		||||
 | 
			
		||||
/*--------------------------------------------------------------------------------------------------
 | 
			
		||||
** Main_BoardNvRead()
 | 
			
		||||
**
 | 
			
		||||
** DESCRIPTION: Called to read NV data.
 | 
			
		||||
**
 | 
			
		||||
** PARAMETERS:  addr    Address from which to read
 | 
			
		||||
**              buf     Pointer to buffer to receive data
 | 
			
		||||
**              length  Number of bytes to read
 | 
			
		||||
**
 | 
			
		||||
** RETURNS:     Number of bytes read
 | 
			
		||||
**------------------------------------------------------------------------------------------------*/
 | 
			
		||||
#ifdef BOARD_HAS_SPIFLASH
 | 
			
		||||
size_t Main_BoardNvRead(size_t addr, uint8_t *buf, size_t length);
 | 
			
		||||
#endif /* BOARD_HAS_SPIFLASH */
 | 
			
		||||
 | 
			
		||||
/*--------------------------------------------------------------------------------------------------
 | 
			
		||||
** Main_BoardNvWrite()
 | 
			
		||||
**
 | 
			
		||||
** DESCRIPTION: Called to write NV data.
 | 
			
		||||
**
 | 
			
		||||
** PARAMETERS:  addr    Address at which to write
 | 
			
		||||
**              buf     Pointer to buffer with data to write
 | 
			
		||||
**              length  Number of bytes to write
 | 
			
		||||
**
 | 
			
		||||
** RETURNS:     Number of bytes written
 | 
			
		||||
**------------------------------------------------------------------------------------------------*/
 | 
			
		||||
#ifdef BOARD_HAS_SPIFLASH
 | 
			
		||||
size_t Main_BoardNvWrite(size_t addr, const uint8_t *buf, size_t length);
 | 
			
		||||
#endif /* BOARD_HAS_SPIFLASH */
 | 
			
		||||
 | 
			
		||||
/*--------------------------------------------------------------------------------------------------
 | 
			
		||||
** Main_BoardNvErase()
 | 
			
		||||
**
 | 
			
		||||
** DESCRIPTION: Called to erase NV data.
 | 
			
		||||
**
 | 
			
		||||
** RETURNS:     0 or error (if not 0)
 | 
			
		||||
**------------------------------------------------------------------------------------------------*/
 | 
			
		||||
#ifdef BOARD_HAS_SPIFLASH
 | 
			
		||||
int32_t Main_BoardNvErase(void);
 | 
			
		||||
#endif /* BOARD_HAS_SPIFLASH */
 | 
			
		||||
 | 
			
		||||
/*--------------------------------------------------------------------------------------------------
 | 
			
		||||
** Main_BoardSettingsInit()
 | 
			
		||||
**
 | 
			
		||||
** DESCRIPTION: Initialize settings stored in a host blob in the NV data.
 | 
			
		||||
**
 | 
			
		||||
** RETURNS:     0 or error (if not 0)
 | 
			
		||||
**------------------------------------------------------------------------------------------------*/
 | 
			
		||||
#ifdef BOARD_HAS_SPIFLASH
 | 
			
		||||
int32_t Main_BoardSettingsInit(void);
 | 
			
		||||
#endif /* BOARD_HAS_SPIFLASH */
 | 
			
		||||
 | 
			
		||||
/*--------------------------------------------------------------------------------------------------
 | 
			
		||||
** Main_BoardSettingsClear()
 | 
			
		||||
**
 | 
			
		||||
** DESCRIPTION: Clear settings stored in a host blob in the NV data.
 | 
			
		||||
**
 | 
			
		||||
** RETURNS:     0 or error (if not 0)
 | 
			
		||||
**------------------------------------------------------------------------------------------------*/
 | 
			
		||||
#ifdef BOARD_HAS_SPIFLASH
 | 
			
		||||
int32_t Main_BoardSettingsClear(void);
 | 
			
		||||
#endif /* BOARD_HAS_SPIFLASH */
 | 
			
		||||
 | 
			
		||||
/*--------------------------------------------------------------------------------------------------
 | 
			
		||||
** Main_BoardSettingRead()
 | 
			
		||||
**
 | 
			
		||||
** DESCRIPTION: Read a setting stored in a host blob in the NV data.
 | 
			
		||||
**
 | 
			
		||||
** PARAMETERS:  id      ID of the setting
 | 
			
		||||
**              buf     Pointer to buffer that will receive setting value
 | 
			
		||||
**              length  Length of the buffer; if setting is longer, only this many bytes will be
 | 
			
		||||
**                      stored
 | 
			
		||||
**
 | 
			
		||||
** RETURNS:     length of the setting or error (if less than or equal to zero)
 | 
			
		||||
**------------------------------------------------------------------------------------------------*/
 | 
			
		||||
#ifdef BOARD_HAS_SPIFLASH
 | 
			
		||||
int32_t Main_BoardSettingRead(uint8_t id, uint8_t *buf, uint8_t length);
 | 
			
		||||
#endif /* BOARD_HAS_SPIFLASH */
 | 
			
		||||
 | 
			
		||||
/*--------------------------------------------------------------------------------------------------
 | 
			
		||||
** Main_BoardSettingWrite()
 | 
			
		||||
**
 | 
			
		||||
** DESCRIPTION: Write a setting stored in a host blob in the NV data.
 | 
			
		||||
**
 | 
			
		||||
** PARAMETERS:  id      ID of the setting
 | 
			
		||||
**              buf     Pointer to buffer with setting value
 | 
			
		||||
**              length  Length of the buffer; if setting is longer, only this many bytes will be
 | 
			
		||||
**                      read
 | 
			
		||||
**
 | 
			
		||||
** RETURNS:     length of the setting or error (if less than or equal to zero)
 | 
			
		||||
**------------------------------------------------------------------------------------------------*/
 | 
			
		||||
#ifdef BOARD_HAS_SPIFLASH
 | 
			
		||||
int32_t Main_BoardSettingWrite(uint8_t id, const uint8_t *buf, uint8_t length);
 | 
			
		||||
#endif /* BOARD_HAS_SPIFLASH */
 | 
			
		||||
 | 
			
		||||
/*--------------------------------------------------------------------------------------------------
 | 
			
		||||
** Main_BoardSetPmuFeature()
 | 
			
		||||
**
 | 
			
		||||
** DESCRIPTION: Set PMU feature of MCU.
 | 
			
		||||
**
 | 
			
		||||
** PARAMETERS:  req  Requested feature(s).
 | 
			
		||||
**------------------------------------------------------------------------------------------------*/
 | 
			
		||||
void Main_BoardSetPmuFeature(uint8_t req);
 | 
			
		||||
 | 
			
		||||
/*--------------------------------------------------------------------------------------------------
 | 
			
		||||
** Main_BoardGetPmuFeature()
 | 
			
		||||
**
 | 
			
		||||
** DESCRIPTION: Get PMU feature of MCU.
 | 
			
		||||
**
 | 
			
		||||
** RETURNS:     Requested feature(s).
 | 
			
		||||
**------------------------------------------------------------------------------------------------*/
 | 
			
		||||
uint8_t Main_BoardGetPmuFeature(void);
 | 
			
		||||
 | 
			
		||||
/*--------------------------------------------------------------------------------------------------
 | 
			
		||||
** Main_BoardSetMuxMode()
 | 
			
		||||
**
 | 
			
		||||
** DESCRIPTION: Set MUX mode of MCU.
 | 
			
		||||
**
 | 
			
		||||
** PARAMETERS:  mode  Mode to set
 | 
			
		||||
**------------------------------------------------------------------------------------------------*/
 | 
			
		||||
void Main_BoardSetMuxMode(uint8_t mode);
 | 
			
		||||
 | 
			
		||||
/*--------------------------------------------------------------------------------------------------
 | 
			
		||||
** Main_BoardWakeLockInc()
 | 
			
		||||
**
 | 
			
		||||
** DESCRIPTION: Increment counter to keep MCU from entering deep sleep.
 | 
			
		||||
**------------------------------------------------------------------------------------------------*/
 | 
			
		||||
void Main_BoardWakeLockInc(void);
 | 
			
		||||
 | 
			
		||||
/*--------------------------------------------------------------------------------------------------
 | 
			
		||||
** Main_BoardWakeLockDec()
 | 
			
		||||
**
 | 
			
		||||
** DESCRIPTION: Decrement counter to allow MCU to enter deep sleep.
 | 
			
		||||
**------------------------------------------------------------------------------------------------*/
 | 
			
		||||
void Main_BoardWakeLockDec(void);
 | 
			
		||||
 | 
			
		||||
/*--------------------------------------------------------------------------------------------------
 | 
			
		||||
** Main_Board32kTimerSleep()
 | 
			
		||||
**
 | 
			
		||||
** DESCRIPTION: Deep sleep for a certain number of ticks of the 32k timer.
 | 
			
		||||
**
 | 
			
		||||
** PARAMETERS:  ticks  Number of ticks to sleep; 0 to sleep forever
 | 
			
		||||
**              deep   TRUE if sleep should be deep sleep
 | 
			
		||||
**------------------------------------------------------------------------------------------------*/
 | 
			
		||||
void Main_Board32kTimerSleep(uint32_t ticks, bool_t deep);
 | 
			
		||||
 | 
			
		||||
/*--------------------------------------------------------------------------------------------------
 | 
			
		||||
** Main_Board32kTimerRead()
 | 
			
		||||
**
 | 
			
		||||
** DESCRIPTION: Read the 32k timer.
 | 
			
		||||
**
 | 
			
		||||
** Returns:     The timer value
 | 
			
		||||
**------------------------------------------------------------------------------------------------*/
 | 
			
		||||
uint32_t Main_Board32kTimerRead(void);
 | 
			
		||||
 | 
			
		||||
/*--------------------------------------------------------------------------------------------------
 | 
			
		||||
** Main_BoardSetWakeupCallback()
 | 
			
		||||
**
 | 
			
		||||
** DESCRIPTION: Set callback for wakeup interrupt.
 | 
			
		||||
**------------------------------------------------------------------------------------------------*/
 | 
			
		||||
#ifdef BOARD_HAS_WAKEUP
 | 
			
		||||
void Main_BoardSetWakeupCback(void (*wakeupCback)(void));
 | 
			
		||||
#endif
 | 
			
		||||
 | 
			
		||||
/*--------------------------------------------------------------------------------------------------
 | 
			
		||||
** Main_BoardWatchdogTimeout()
 | 
			
		||||
**
 | 
			
		||||
** DESCRIPTION: Set watchdog to expire in certain number of milliseconds, after which the processor
 | 
			
		||||
**              will reset.
 | 
			
		||||
**
 | 
			
		||||
** PARAMETERS:  to_ms  Milliseconds before timeout; 0 to timeout immediately
 | 
			
		||||
**------------------------------------------------------------------------------------------------*/
 | 
			
		||||
void Main_BoardWatchdogTimeout(uint16_t to_ms);
 | 
			
		||||
 | 
			
		||||
/*--------------------------------------------------------------------------------------------------
 | 
			
		||||
** Main_BoardWatchdogCancel()
 | 
			
		||||
**
 | 
			
		||||
** DESCRIPTION: Cancel watchdog timeout, so that the processor will not reset if it expires.
 | 
			
		||||
**------------------------------------------------------------------------------------------------*/
 | 
			
		||||
void Main_BoardWatchdogCancel(void);
 | 
			
		||||
 | 
			
		||||
/*--------------------------------------------------------------------------------------------------
 | 
			
		||||
** Main_BoardGpioSet()
 | 
			
		||||
**
 | 
			
		||||
** DESCRIPTION: Set GPIO output.
 | 
			
		||||
**------------------------------------------------------------------------------------------------*/
 | 
			
		||||
#ifdef BOARD_HAS_GPIO_OUTPUTS
 | 
			
		||||
void Main_BoardGpioSet(uint8_t num);
 | 
			
		||||
#endif
 | 
			
		||||
 | 
			
		||||
/*--------------------------------------------------------------------------------------------------
 | 
			
		||||
** Main_BoardGpioClr()
 | 
			
		||||
**
 | 
			
		||||
** DESCRIPTION: Clear GPIO output.
 | 
			
		||||
**------------------------------------------------------------------------------------------------*/
 | 
			
		||||
#ifdef BOARD_HAS_GPIO_OUTPUTS
 | 
			
		||||
void Main_BoardGpioClr(uint8_t num);
 | 
			
		||||
#endif
 | 
			
		||||
 | 
			
		||||
/*--------------------------------------------------------------------------------------------------
 | 
			
		||||
** Main_BoardGpioToggle()
 | 
			
		||||
**
 | 
			
		||||
** DESCRIPTION: Toggle GPIO output.
 | 
			
		||||
**------------------------------------------------------------------------------------------------*/
 | 
			
		||||
#ifdef BOARD_HAS_GPIO_OUTPUTS
 | 
			
		||||
void Main_BoardGpioToggle(uint8_t num);
 | 
			
		||||
#endif
 | 
			
		||||
 | 
			
		||||
/*--------------------------------------------------------------------------------------------------
 | 
			
		||||
** Main_BoardDelayUsec()
 | 
			
		||||
**
 | 
			
		||||
** DESCRIPTION: Delay for a certain time, in microseconds.
 | 
			
		||||
**
 | 
			
		||||
** PARAMETERS:  delay_us  Microseconds to delay.
 | 
			
		||||
**------------------------------------------------------------------------------------------------*/
 | 
			
		||||
void Main_BoardDelayUsec(uint32_t delay_us);
 | 
			
		||||
 | 
			
		||||
#ifdef __cplusplus
 | 
			
		||||
}
 | 
			
		||||
#endif
 | 
			
		||||
 | 
			
		||||
#endif /* __MAIN_BOARD_H */
 | 
			
		||||
| 
						 | 
				
			
			@ -1,35 +0,0 @@
 | 
			
		|||
/*************************************************************************************************/
 | 
			
		||||
/*!
 | 
			
		||||
 *  \file   chip.h
 | 
			
		||||
 *
 | 
			
		||||
 *  \brief  Include file for SMD TC2.
 | 
			
		||||
 *
 | 
			
		||||
 *  Copyright (c) 2015-2016 ARM, Ltd., all rights reserved.
 | 
			
		||||
 *  ARM confidential and proprietary.
 | 
			
		||||
 *
 | 
			
		||||
 *  IMPORTANT.  Your use of this file is governed by a Software License Agreement
 | 
			
		||||
 *  ("Agreement") that must be accepted in order to download or otherwise receive a
 | 
			
		||||
 *  copy of this file.  You may not use or copy this file for any purpose other than
 | 
			
		||||
 *  as described in the Agreement.  If you do not agree to all of the terms of the
 | 
			
		||||
 *  Agreement do not use this file and delete all copies in your possession or control;
 | 
			
		||||
 *  if you do not have a copy of the Agreement, you must contact ARM, Ltd. prior
 | 
			
		||||
 *  to any use, copying or further distribution of this software.
 | 
			
		||||
 */
 | 
			
		||||
/*************************************************************************************************/
 | 
			
		||||
 | 
			
		||||
#ifndef CHIP_H
 | 
			
		||||
#define CHIP_H
 | 
			
		||||
 | 
			
		||||
#ifdef __cplusplus
 | 
			
		||||
extern "C" {
 | 
			
		||||
#endif
 | 
			
		||||
 | 
			
		||||
#include <CMSDK_BEETLE.h>
 | 
			
		||||
 | 
			
		||||
#include "chip_hw.h"
 | 
			
		||||
 | 
			
		||||
#ifdef __cplusplus
 | 
			
		||||
}
 | 
			
		||||
#endif
 | 
			
		||||
 | 
			
		||||
#endif /* CHIP_H */
 | 
			
		||||
| 
						 | 
				
			
			@ -1,38 +0,0 @@
 | 
			
		|||
/*************************************************************************************************/
 | 
			
		||||
/*!
 | 
			
		||||
 *  \file   chip_hw.h
 | 
			
		||||
 *
 | 
			
		||||
 *  \brief  Low-level chip defines for SMD TC2.
 | 
			
		||||
 *
 | 
			
		||||
 *  Copyright (c) 2015 ARM, Ltd., all rights reserved.
 | 
			
		||||
 *  ARM confidential and proprietary.
 | 
			
		||||
 *
 | 
			
		||||
 *  IMPORTANT.  Your use of this file is governed by a Software License Agreement
 | 
			
		||||
 *  ("Agreement") that must be accepted in order to download or otherwise receive a
 | 
			
		||||
 *  copy of this file.  You may not use or copy this file for any purpose other than
 | 
			
		||||
 *  as described in the Agreement.  If you do not agree to all of the terms of the
 | 
			
		||||
 *  Agreement do not use this file and delete all copies in your possession or control;
 | 
			
		||||
 *  if you do not have a copy of the Agreement, you must contact ARM, Ltd. prior
 | 
			
		||||
 *  to any use, copying or further distribution of this software.
 | 
			
		||||
 */
 | 
			
		||||
/*************************************************************************************************/
 | 
			
		||||
 | 
			
		||||
#ifndef CHIP_HW_H
 | 
			
		||||
#define CHIP_HW_H
 | 
			
		||||
 | 
			
		||||
#ifdef __cplusplus
 | 
			
		||||
extern "C" {
 | 
			
		||||
#endif
 | 
			
		||||
 | 
			
		||||
#define MCU_SRAM_BASE              (0x20000000)
 | 
			
		||||
#define MCU_SRAM_SIZE              (128*1024)
 | 
			
		||||
#define MCU_STACK_SIZE             (1024)
 | 
			
		||||
#define MCU_MIN_HEAP               (1024)
 | 
			
		||||
#define MCU_ROM_BASE               (0x00000000)
 | 
			
		||||
#define MCU_ROM_SIZE               (8*1024)
 | 
			
		||||
 | 
			
		||||
#ifdef __cplusplus
 | 
			
		||||
}
 | 
			
		||||
#endif
 | 
			
		||||
 | 
			
		||||
#endif /* CHIP_HW_H */
 | 
			
		||||
| 
						 | 
				
			
			@ -1,42 +0,0 @@
 | 
			
		|||
/*************************************************************************************************/
 | 
			
		||||
/*!
 | 
			
		||||
 *  \file   ble_init.c
 | 
			
		||||
 *
 | 
			
		||||
 *  \brief  BLE initialization.
 | 
			
		||||
 *
 | 
			
		||||
 *  Copyright (c) 2015 ARM, Ltd., all rights reserved.
 | 
			
		||||
 *  ARM confidential and proprietary.
 | 
			
		||||
 *
 | 
			
		||||
 *  IMPORTANT.  Your use of this file is governed by a Software License Agreement
 | 
			
		||||
 *  ("Agreement") that must be accepted in order to download or otherwise receive a
 | 
			
		||||
 *  copy of this file.  You may not use or copy this file for any purpose other than
 | 
			
		||||
 *  as described in the Agreement.  If you do not agree to all of the terms of the
 | 
			
		||||
 *  Agreement do not use this file and delete all copies in your possession or control;
 | 
			
		||||
 *  if you do not have a copy of the Agreement, you must contact ARM, Ltd. prior
 | 
			
		||||
 *  to any use, copying or further distribution of this software.
 | 
			
		||||
 */
 | 
			
		||||
/*************************************************************************************************/
 | 
			
		||||
 | 
			
		||||
#ifndef BLE_INIT_H
 | 
			
		||||
#define BLE_INIT_H
 | 
			
		||||
 | 
			
		||||
#ifdef __cplusplus
 | 
			
		||||
extern "C" {
 | 
			
		||||
#endif
 | 
			
		||||
 | 
			
		||||
/*************************************************************************************************/
 | 
			
		||||
/*!
 | 
			
		||||
 *  \fn     BleInitStart
 | 
			
		||||
 *
 | 
			
		||||
 *  \brief  Set BLE initialization.
 | 
			
		||||
 *
 | 
			
		||||
 *  \return None.
 | 
			
		||||
 */
 | 
			
		||||
/*************************************************************************************************/
 | 
			
		||||
void BleInitStart(void);
 | 
			
		||||
 | 
			
		||||
#ifdef __cplusplus
 | 
			
		||||
}
 | 
			
		||||
#endif
 | 
			
		||||
 | 
			
		||||
#endif /* BLE_INIT_H */
 | 
			
		||||
| 
						 | 
				
			
			@ -1,79 +0,0 @@
 | 
			
		|||
/*************************************************************************************************/
 | 
			
		||||
/*!
 | 
			
		||||
 *  \file   cordio_tc2_defs.h
 | 
			
		||||
 *
 | 
			
		||||
 *  \brief  Cordio TC2 defines.
 | 
			
		||||
 *
 | 
			
		||||
 *          $Date: 2015-09-28 16:07:14 -0400 (Mon, 28 Sep 2015) $
 | 
			
		||||
 *          $Revision: 4037 $
 | 
			
		||||
 *
 | 
			
		||||
 *  Copyright (c) 2013 Wicentric, Inc., all rights reserved.
 | 
			
		||||
 *  Wicentric confidential and proprietary.
 | 
			
		||||
 *
 | 
			
		||||
 *  IMPORTANT.  Your use of this file is governed by a Software License Agreement
 | 
			
		||||
 *  ("Agreement") that must be accepted in order to download or otherwise receive a
 | 
			
		||||
 *  copy of this file.  You may not use or copy this file for any purpose other than
 | 
			
		||||
 *  as described in the Agreement.  If you do not agree to all of the terms of the
 | 
			
		||||
 *  Agreement do not use this file and delete all copies in your possession or control;
 | 
			
		||||
 *  if you do not have a copy of the Agreement, you must contact Wicentric, Inc. prior
 | 
			
		||||
 *  to any use, copying or further distribution of this software.
 | 
			
		||||
 */
 | 
			
		||||
/*************************************************************************************************/
 | 
			
		||||
 | 
			
		||||
#ifndef CORDIO_TC2_DEFS_H
 | 
			
		||||
#define CORDIO_TC2_DEFS_H
 | 
			
		||||
 | 
			
		||||
#ifdef __cplusplus
 | 
			
		||||
extern "C" {
 | 
			
		||||
#endif
 | 
			
		||||
 | 
			
		||||
/**************************************************************************************************
 | 
			
		||||
  Macros
 | 
			
		||||
**************************************************************************************************/
 | 
			
		||||
 | 
			
		||||
/*! \brief      Expected cookie value for TC2 images. */
 | 
			
		||||
#define CORDIO_TC2_HEADER_COOKIE  0x30444D53
 | 
			
		||||
 | 
			
		||||
/*! \brief      Length of header. */
 | 
			
		||||
#define CORDIO_TC2_HEADER_LEN     24
 | 
			
		||||
 | 
			
		||||
/**************************************************************************************************
 | 
			
		||||
  Data Types
 | 
			
		||||
**************************************************************************************************/
 | 
			
		||||
 | 
			
		||||
/*! \brief      Header for images sought by ROM bootloader. */
 | 
			
		||||
typedef struct
 | 
			
		||||
{
 | 
			
		||||
  uint32_t cookie;                                      /*!< Cookie value. */
 | 
			
		||||
  uint8_t  hdrLen;                                      /*!< Header length, in octets (must be 24).  */
 | 
			
		||||
  uint8_t  type;                                        /*!< Type of image. */
 | 
			
		||||
  uint8_t  revMajor;                                    /*!< Major image revision. */
 | 
			
		||||
  uint8_t  revMinor;                                    /*!< Minor image revision. */
 | 
			
		||||
  uint32_t dataLen;                                     /*!< Length of data, with image flags. */
 | 
			
		||||
  uint32_t offset;                                      /*!< Offset to which image should be copied. */
 | 
			
		||||
  uint32_t entry;                                       /*!< Entry point. */
 | 
			
		||||
  uint32_t crc;                                         /*!< Checksum over header and data. */
 | 
			
		||||
} CordioTc2ImgHdr_t;
 | 
			
		||||
 | 
			
		||||
/*! \brief      Image types. */
 | 
			
		||||
enum
 | 
			
		||||
{
 | 
			
		||||
  CORDIO_TC2_IMG_TYPE_HOST_FW         = 0,              /*!< Host firmware. */
 | 
			
		||||
  CORDIO_TC2_IMG_TYPE_BT4_FW          = 1,              /*!< BT4 firmware. */
 | 
			
		||||
  CORDIO_TC2_IMG_TYPE_BT4_PATCH       = 2,              /*!< BT4 patch. */
 | 
			
		||||
  CORDIO_TC2_IMG_TYPE_BT4_TRIM        = 3,              /*!< BT4 trim. */
 | 
			
		||||
  CORDIO_TC2_IMG_TYPE_HOST_CFG        = 4               /*!< Host configuration. */
 | 
			
		||||
};
 | 
			
		||||
 | 
			
		||||
/*! \brief      Data length bits and fields. */
 | 
			
		||||
enum
 | 
			
		||||
{
 | 
			
		||||
  CORDIO_TC2_DATA_LEN_MASK            = 0x00FFFFFF,     /*!< Data length mask. */
 | 
			
		||||
  CORDIO_TC2_DATA_LEN_FLAG_ENCRYPTED  = (1 << 30)       /*!< Data encrypted flag. */
 | 
			
		||||
};
 | 
			
		||||
 | 
			
		||||
#ifdef __cplusplus
 | 
			
		||||
}
 | 
			
		||||
#endif
 | 
			
		||||
 | 
			
		||||
#endif /* CORDIO_TC2_DEFS_H */
 | 
			
		||||
| 
						 | 
				
			
			@ -1,43 +0,0 @@
 | 
			
		|||
/*************************************************************************************************/
 | 
			
		||||
/*!
 | 
			
		||||
 *  \file   cordio_sdk_version.h
 | 
			
		||||
 *
 | 
			
		||||
 *  \brief  Cordio SDK version.
 | 
			
		||||
 *
 | 
			
		||||
 *          $Date: 2015-10-22 18:45:26 -0400 (Thu, 22 Oct 2015) $
 | 
			
		||||
 *          $Revision: 4273 $
 | 
			
		||||
 *
 | 
			
		||||
 *  Copyright (c) 2015 ARM, Ltd., all rights reserved.
 | 
			
		||||
 *  Wicentric confidential and proprietary.
 | 
			
		||||
 *
 | 
			
		||||
 *  IMPORTANT.  Your use of this file is governed by a Software License Agreement
 | 
			
		||||
 *  ("Agreement") that must be accepted in order to download or otherwise receive a
 | 
			
		||||
 *  copy of this file.  You may not use or copy this file for any purpose other than
 | 
			
		||||
 *  as described in the Agreement.  If you do not agree to all of the terms of the
 | 
			
		||||
 *  Agreement do not use this file and delete all copies in your possession or control;
 | 
			
		||||
 *  if you do not have a copy of the Agreement, you must contact ARM, Ltd. prior
 | 
			
		||||
 *  to any use, copying or further distribution of this software.
 | 
			
		||||
 */
 | 
			
		||||
/*************************************************************************************************/
 | 
			
		||||
 | 
			
		||||
#ifndef CORDIO_SDK_VERSION_H
 | 
			
		||||
#define CORDIO_SDK_VERSION_H
 | 
			
		||||
 | 
			
		||||
#ifdef __cplusplus
 | 
			
		||||
extern "C" {
 | 
			
		||||
#endif
 | 
			
		||||
 | 
			
		||||
/*! \brief    Cordio SDK version string. */
 | 
			
		||||
#define CORDIO_SDK_VERSION "20160509-r7043"
 | 
			
		||||
 | 
			
		||||
/*! \brief    Cordio SDK major version. */
 | 
			
		||||
#define CORDIO_SDK_VERSION_MAJOR 1
 | 
			
		||||
 | 
			
		||||
/*! \brief    Cordio SDK minor version. */
 | 
			
		||||
#define CORDIO_SDK_VERSION_MINOR 1.4
 | 
			
		||||
 | 
			
		||||
#ifdef __cplusplus
 | 
			
		||||
}
 | 
			
		||||
#endif
 | 
			
		||||
 | 
			
		||||
#endif /* CORDIO_SDK_VERSION_H */
 | 
			
		||||
| 
						 | 
				
			
			@ -1,186 +0,0 @@
 | 
			
		|||
/*************************************************************************************************/
 | 
			
		||||
/*!
 | 
			
		||||
 *  \file   drv_console.h
 | 
			
		||||
 *
 | 
			
		||||
 *  \brief  Upper-layer UART driver.
 | 
			
		||||
 *
 | 
			
		||||
 *  Copyright (c) 2015 ARM, Ltd., all rights reserved.
 | 
			
		||||
 *  ARM confidential and proprietary.
 | 
			
		||||
 *
 | 
			
		||||
 *  IMPORTANT.  Your use of this file is governed by a Software License Agreement
 | 
			
		||||
 *  ("Agreement") that must be accepted in order to download or otherwise receive a
 | 
			
		||||
 *  copy of this file.  You may not use or copy this file for any purpose other than
 | 
			
		||||
 *  as described in the Agreement.  If you do not agree to all of the terms of the
 | 
			
		||||
 *  Agreement do not use this file and delete all copies in your possession or control;
 | 
			
		||||
 *  if you do not have a copy of the Agreement, you must contact ARM, Ltd. prior
 | 
			
		||||
 *  to any use, copying or further distribution of this software.
 | 
			
		||||
 */
 | 
			
		||||
/*************************************************************************************************/
 | 
			
		||||
 | 
			
		||||
#ifndef __DRV_CONSOLE_H
 | 
			
		||||
#define __DRV_CONSOLE_H
 | 
			
		||||
 | 
			
		||||
#ifdef __cplusplus
 | 
			
		||||
extern "C" {
 | 
			
		||||
#endif
 | 
			
		||||
 | 
			
		||||
/***************************************************************************************************
 | 
			
		||||
** INCLUDES
 | 
			
		||||
***************************************************************************************************/
 | 
			
		||||
 | 
			
		||||
#include "chip.h"
 | 
			
		||||
#include "board.h"
 | 
			
		||||
 | 
			
		||||
/***************************************************************************************************
 | 
			
		||||
** DEFINES
 | 
			
		||||
***************************************************************************************************/
 | 
			
		||||
 | 
			
		||||
/*--------------------------------------------------------------------------------------------------
 | 
			
		||||
** ENABLE/DISABLE, ON/OFF DEFINES
 | 
			
		||||
**
 | 
			
		||||
** DESCRIPTION: For clarity in enable parameters.
 | 
			
		||||
--------------------------------------------------------------------------------------------------*/
 | 
			
		||||
 | 
			
		||||
#ifndef DRV_ENABLE
 | 
			
		||||
#define DRV_ENABLE  1
 | 
			
		||||
#endif
 | 
			
		||||
 | 
			
		||||
#ifndef DRV_DISABLE
 | 
			
		||||
#define DRV_DISABLE  0
 | 
			
		||||
#endif
 | 
			
		||||
 | 
			
		||||
#ifndef DRV_ON
 | 
			
		||||
#define DRV_ON  1
 | 
			
		||||
#endif
 | 
			
		||||
 | 
			
		||||
#ifndef DRV_OFF
 | 
			
		||||
#define DRV_OFF  0
 | 
			
		||||
#endif
 | 
			
		||||
 | 
			
		||||
/*--------------------------------------------------------------------------------------------------
 | 
			
		||||
** TX/RX DEFINES
 | 
			
		||||
**
 | 
			
		||||
** DESCRIPTION: For tx/rx argument of driver functions.
 | 
			
		||||
--------------------------------------------------------------------------------------------------*/
 | 
			
		||||
 | 
			
		||||
#define DRV_CONSOLE_TX  (1u << 0)
 | 
			
		||||
#define DRV_CONSOLE_RX  (1u << 1)
 | 
			
		||||
 | 
			
		||||
/*--------------------------------------------------------------------------------------------------
 | 
			
		||||
** DRV_CONSOLE_BUF_LEN
 | 
			
		||||
**
 | 
			
		||||
** DESCRIPTION: The maximum length of printed strings.
 | 
			
		||||
**------------------------------------------------------------------------------------------------*/
 | 
			
		||||
#define DRV_CONSOLE_BUF_LEN 128u
 | 
			
		||||
 | 
			
		||||
/***************************************************************************************************
 | 
			
		||||
** TYPES
 | 
			
		||||
***************************************************************************************************/
 | 
			
		||||
 | 
			
		||||
/*----------------------------------------------------------------------------------------------
 | 
			
		||||
** DRV_CONSOLE_RX_CALLBACK_t()
 | 
			
		||||
**
 | 
			
		||||
** DESCRIPTION: Callback for received byte.
 | 
			
		||||
**
 | 
			
		||||
** PARAMETERS:  c  Received byte
 | 
			
		||||
**--------------------------------------------------------------------------------------------*/
 | 
			
		||||
 | 
			
		||||
typedef void (*DRV_CONSOLE_RX_CALLBACK_t)(uint8_t c);
 | 
			
		||||
 | 
			
		||||
/*----------------------------------------------------------------------------------------------
 | 
			
		||||
** DRV_CONSOLE_TX_COMPLETE_CALLBACK_t()
 | 
			
		||||
**
 | 
			
		||||
** DESCRIPTION: Callback for transmission completion.
 | 
			
		||||
**
 | 
			
		||||
** PARAMETERS:  buf  Pointer to buffer that was transmitted
 | 
			
		||||
**--------------------------------------------------------------------------------------------*/
 | 
			
		||||
 | 
			
		||||
typedef void (*DRV_CONSOLE_TX_COMPLETE_CALLBACK_t)(const uint8_t *buf);
 | 
			
		||||
 | 
			
		||||
/*--------------------------------------------------------------------------------------------------
 | 
			
		||||
** struct drv_console
 | 
			
		||||
**
 | 
			
		||||
** DESCRIPTION: Access structure of driver.
 | 
			
		||||
--------------------------------------------------------------------------------------------------*/
 | 
			
		||||
 | 
			
		||||
struct drv_console {
 | 
			
		||||
    /*----------------------------------------------------------------------------------------------
 | 
			
		||||
    ** Initialize()
 | 
			
		||||
    **
 | 
			
		||||
    ** DESCRIPTION: Initialize console.
 | 
			
		||||
    **
 | 
			
		||||
    ** PARAMETERS:  baud   Baud rate
 | 
			
		||||
    **              rx_tx  Indicates allowed modes of driver (DRV_CONSOLE_RX &/| DRV_CONSOLE_TX).
 | 
			
		||||
    **--------------------------------------------------------------------------------------------*/
 | 
			
		||||
    void (*Initialize)(uint32_t baud, uint32_t rx_tx);
 | 
			
		||||
 | 
			
		||||
    /*----------------------------------------------------------------------------------------------
 | 
			
		||||
    ** Receive()
 | 
			
		||||
    **
 | 
			
		||||
    ** DESCRIPTION: Receive data.
 | 
			
		||||
    **
 | 
			
		||||
    ** PARAMETERS:  buf  Pointer to buffer that will receive data
 | 
			
		||||
    **              len  Number of data bytes to data
 | 
			
		||||
    **
 | 
			
		||||
    ** RETURNS:     Number of bytes received
 | 
			
		||||
    **--------------------------------------------------------------------------------------------*/
 | 
			
		||||
    int32_t (*Receive)(uint8_t *buf, uint32_t len);
 | 
			
		||||
 | 
			
		||||
    /*----------------------------------------------------------------------------------------------
 | 
			
		||||
    ** ReceiveAsyncStart()
 | 
			
		||||
    **
 | 
			
		||||
    ** DESCRIPTION: Start receiving data asynchronously.
 | 
			
		||||
    **
 | 
			
		||||
    ** PARAMETERS:  cb  Callback for receive events
 | 
			
		||||
    **
 | 
			
		||||
    ** RETURNS:     0 or error (if not zero)
 | 
			
		||||
    **--------------------------------------------------------------------------------------------*/
 | 
			
		||||
    int32_t (*ReceiveAsyncStart)(DRV_UART_RX_CALLBACK_t cb);
 | 
			
		||||
 | 
			
		||||
    /*----------------------------------------------------------------------------------------------
 | 
			
		||||
    ** ReceiveAsyncStart()
 | 
			
		||||
    **
 | 
			
		||||
    ** DESCRIPTION: Stop receiving data asynchronously.
 | 
			
		||||
    **--------------------------------------------------------------------------------------------*/
 | 
			
		||||
    void (*ReceiveAsyncStop)(void);
 | 
			
		||||
 | 
			
		||||
    /*----------------------------------------------------------------------------------------------
 | 
			
		||||
    ** Transmit()
 | 
			
		||||
    **
 | 
			
		||||
    ** DESCRIPTION: Transmit buffer synchronously, waiting for any active transmission to finish.
 | 
			
		||||
    **
 | 
			
		||||
    ** PARAMETERS:  buf    Pointer to buffer of data to transmit
 | 
			
		||||
    **              len    Number of data bytes to transmit
 | 
			
		||||
    **
 | 
			
		||||
    ** RETURNS:     Number of bytes transmitted
 | 
			
		||||
    **--------------------------------------------------------------------------------------------*/
 | 
			
		||||
    int32_t (*Transmit)(const uint8_t *buf, uint32_t len);
 | 
			
		||||
 | 
			
		||||
    /*----------------------------------------------------------------------------------------------
 | 
			
		||||
    ** TransmitAsync()
 | 
			
		||||
    **
 | 
			
		||||
    ** DESCRIPTION: Transmit buffer asynchronously, waiting for any active transmission to finish.
 | 
			
		||||
    **
 | 
			
		||||
    ** PARAMETERS:  buf  Pointer to buffer of data to transmit
 | 
			
		||||
    **              len  Number of data bytes to transmit
 | 
			
		||||
    **              cb   Pointer to completion callback
 | 
			
		||||
    **
 | 
			
		||||
    ** RETURNS:     0 or error (if not zero)
 | 
			
		||||
    **--------------------------------------------------------------------------------------------*/
 | 
			
		||||
    int32_t (*TransmitAsync)(const uint8_t *buf, uint32_t len, DRV_CONSOLE_TX_COMPLETE_CALLBACK_t cb);
 | 
			
		||||
 | 
			
		||||
    /*----------------------------------------------------------------------------------------------
 | 
			
		||||
    ** GetUART()
 | 
			
		||||
    **
 | 
			
		||||
    ** DESCRIPTION: Get UART associated with this console.
 | 
			
		||||
    **
 | 
			
		||||
    ** RETURNS:     Pointer to UART
 | 
			
		||||
    **--------------------------------------------------------------------------------------------*/
 | 
			
		||||
    const struct drv_uart *(*GetUART)(void);
 | 
			
		||||
};
 | 
			
		||||
 | 
			
		||||
#ifdef __cplusplus
 | 
			
		||||
}
 | 
			
		||||
#endif
 | 
			
		||||
 | 
			
		||||
#endif /* __DRV_CONSOLE_H */
 | 
			
		||||
| 
						 | 
				
			
			@ -1,132 +0,0 @@
 | 
			
		|||
/*************************************************************************************************/
 | 
			
		||||
/*!
 | 
			
		||||
 *  \file   drv_llcc.h
 | 
			
		||||
 *
 | 
			
		||||
 *  \brief  LLCC driver.
 | 
			
		||||
 *
 | 
			
		||||
 *  Copyright (c) 2015 ARM, Ltd., all rights reserved.
 | 
			
		||||
 *  ARM confidential and proprietary.
 | 
			
		||||
 *
 | 
			
		||||
 *  IMPORTANT.  Your use of this file is governed by a Software License Agreement
 | 
			
		||||
 *  ("Agreement") that must be accepted in order to download or otherwise receive a
 | 
			
		||||
 *  copy of this file.  You may not use or copy this file for any purpose other than
 | 
			
		||||
 *  as described in the Agreement.  If you do not agree to all of the terms of the
 | 
			
		||||
 *  Agreement do not use this file and delete all copies in your possession or control;
 | 
			
		||||
 *  if you do not have a copy of the Agreement, you must contact ARM, Ltd. prior
 | 
			
		||||
 *  to any use, copying or further distribution of this software.
 | 
			
		||||
 */
 | 
			
		||||
/*************************************************************************************************/
 | 
			
		||||
 | 
			
		||||
#ifndef __DRV_LLCC_H
 | 
			
		||||
#define __DRV_LLCC_H
 | 
			
		||||
 | 
			
		||||
#ifdef __cplusplus
 | 
			
		||||
extern "C" {
 | 
			
		||||
#endif
 | 
			
		||||
 | 
			
		||||
/***************************************************************************************************
 | 
			
		||||
** INCLUDES
 | 
			
		||||
***************************************************************************************************/
 | 
			
		||||
 | 
			
		||||
#include "chip.h"
 | 
			
		||||
#include "board.h"
 | 
			
		||||
 | 
			
		||||
/***************************************************************************************************
 | 
			
		||||
** CONSTANTS
 | 
			
		||||
***************************************************************************************************/
 | 
			
		||||
 | 
			
		||||
/*--------------------------------------------------------------------------------------------------
 | 
			
		||||
** ENABLE/DISABLE, ON/OFF DEFINES
 | 
			
		||||
**
 | 
			
		||||
** DESCRIPTION: For clarity in enable parameters.
 | 
			
		||||
--------------------------------------------------------------------------------------------------*/
 | 
			
		||||
 | 
			
		||||
#ifndef DRV_ENABLE
 | 
			
		||||
#define DRV_ENABLE  1
 | 
			
		||||
#endif
 | 
			
		||||
 | 
			
		||||
#ifndef DRV_DISABLE
 | 
			
		||||
#define DRV_DISABLE  0
 | 
			
		||||
#endif
 | 
			
		||||
 | 
			
		||||
#ifndef DRV_ON
 | 
			
		||||
#define DRV_ON  1
 | 
			
		||||
#endif
 | 
			
		||||
 | 
			
		||||
#ifndef DRV_OFF
 | 
			
		||||
#define DRV_OFF  0
 | 
			
		||||
#endif
 | 
			
		||||
 | 
			
		||||
/***************************************************************************************************
 | 
			
		||||
** TYPES
 | 
			
		||||
***************************************************************************************************/
 | 
			
		||||
 | 
			
		||||
typedef void (*DRV_LLCC_WD_CALLBACK_t) (uint8_t type, uint8_t *pData, void *pContext, int32_t error);
 | 
			
		||||
typedef void (*DRV_LLCC_RD_CALLBACK_t) (uint8_t type, uint8_t *pData, uint8_t align, uint16_t len);
 | 
			
		||||
typedef void * (*DRV_LLCC_ALLOC_CALLBACK_t) (uint16_t len);
 | 
			
		||||
 | 
			
		||||
/*--------------------------------------------------------------------------------------------------
 | 
			
		||||
** struct drv_llcc
 | 
			
		||||
**
 | 
			
		||||
** DESCRIPTION: Access structure of driver.
 | 
			
		||||
--------------------------------------------------------------------------------------------------*/
 | 
			
		||||
 | 
			
		||||
struct drv_llcc {
 | 
			
		||||
    /*----------------------------------------------------------------------------------------------
 | 
			
		||||
     ** Initialize()
 | 
			
		||||
     **
 | 
			
		||||
     ** DESCRIPTION: Initialize ESS IPCC interface
 | 
			
		||||
     ** RETURNS:     0 or error (if not 0)
 | 
			
		||||
     ---------------------------------------------------------------------------------------------*/
 | 
			
		||||
    int32_t (*Initialize)(void);
 | 
			
		||||
 | 
			
		||||
    /*----------------------------------------------------------------------------------------------
 | 
			
		||||
     ** Reset()
 | 
			
		||||
     **
 | 
			
		||||
     ** DESCRIPTION: Take the ESS IPCC into or out of reset.
 | 
			
		||||
     ** PARAMETERS:  on  If not 0, take the ESS IPCC out of reset
 | 
			
		||||
     ---------------------------------------------------------------------------------------------*/
 | 
			
		||||
    void (*Reset)(int32_t on);
 | 
			
		||||
 | 
			
		||||
    /*----------------------------------------------------------------------------------------------
 | 
			
		||||
     ** SetTxHandler()
 | 
			
		||||
     **
 | 
			
		||||
     ** DESCRIPTION: Set handler for transmit events
 | 
			
		||||
     ** PARAMETERS:  cb       Pointer to callback; if NULL, the default handler is set
 | 
			
		||||
     ---------------------------------------------------------------------------------------------*/
 | 
			
		||||
    void (*SetTxHandler)(DRV_LLCC_WD_CALLBACK_t cb);
 | 
			
		||||
 | 
			
		||||
    /*----------------------------------------------------------------------------------------------
 | 
			
		||||
     ** SetRxHandler()
 | 
			
		||||
     **
 | 
			
		||||
     ** DESCRIPTION: Set handler for receive events
 | 
			
		||||
     ** PARAMETERS:  cb       Pointer to callback; if NULL, the default handler is set
 | 
			
		||||
     ---------------------------------------------------------------------------------------------*/
 | 
			
		||||
    void (*SetRxHandler)(DRV_LLCC_RD_CALLBACK_t cb);
 | 
			
		||||
 | 
			
		||||
     /*----------------------------------------------------------------------------------------------
 | 
			
		||||
     ** SetAllocHandler()
 | 
			
		||||
     **
 | 
			
		||||
     ** DESCRIPTION: Set handler for allocate requests
 | 
			
		||||
     ** PARAMETERS:  cb       Pointer to callback; if NULL, the default handler is set
 | 
			
		||||
     ---------------------------------------------------------------------------------------------*/
 | 
			
		||||
    void (*SetAllocHandler)(DRV_LLCC_ALLOC_CALLBACK_t cb);
 | 
			
		||||
 | 
			
		||||
    /*----------------------------------------------------------------------------------------------
 | 
			
		||||
     ** Write()
 | 
			
		||||
     **
 | 
			
		||||
     ** DESCRIPTION: Write to write channel
 | 
			
		||||
     ** PARAMETERS:  cmd      Command to send
 | 
			
		||||
     **              data     Pointer to buffer with data to send
 | 
			
		||||
     **              num      Number of bytes to write
 | 
			
		||||
     **              context  Context associated with this write
 | 
			
		||||
     ** RETURNS:     Number of bytes written or error (if less than 0)
 | 
			
		||||
     ---------------------------------------------------------------------------------------------*/
 | 
			
		||||
     int32_t (*Write)(uint32_t cmd, const uint8_t *data, uint16_t num, void *context);
 | 
			
		||||
};
 | 
			
		||||
 | 
			
		||||
#ifdef __cplusplus
 | 
			
		||||
}
 | 
			
		||||
#endif
 | 
			
		||||
 | 
			
		||||
#endif /* __DRV_LLCC_H */
 | 
			
		||||
| 
						 | 
				
			
			@ -1,186 +0,0 @@
 | 
			
		|||
/*************************************************************************************************/
 | 
			
		||||
/*!
 | 
			
		||||
 *  \file   drv_uart.h
 | 
			
		||||
 *
 | 
			
		||||
 *  \brief  UART driver.
 | 
			
		||||
 *
 | 
			
		||||
 *  Copyright (c) 2015 ARM, Ltd., all rights reserved.
 | 
			
		||||
 *  ARM confidential and proprietary.
 | 
			
		||||
 *
 | 
			
		||||
 *  IMPORTANT.  Your use of this file is governed by a Software License Agreement
 | 
			
		||||
 *  ("Agreement") that must be accepted in order to download or otherwise receive a
 | 
			
		||||
 *  copy of this file.  You may not use or copy this file for any purpose other than
 | 
			
		||||
 *  as described in the Agreement.  If you do not agree to all of the terms of the
 | 
			
		||||
 *  Agreement do not use this file and delete all copies in your possession or control;
 | 
			
		||||
 *  if you do not have a copy of the Agreement, you must contact ARM, Ltd. prior
 | 
			
		||||
 *  to any use, copying or further distribution of this software.
 | 
			
		||||
 */
 | 
			
		||||
/*************************************************************************************************/
 | 
			
		||||
 | 
			
		||||
#ifndef __DRV_UART_H
 | 
			
		||||
#define __DRV_UART_H
 | 
			
		||||
 | 
			
		||||
#ifdef __cplusplus
 | 
			
		||||
extern "C" {
 | 
			
		||||
#endif
 | 
			
		||||
 | 
			
		||||
/***************************************************************************************************
 | 
			
		||||
** INCLUDES
 | 
			
		||||
***************************************************************************************************/
 | 
			
		||||
 | 
			
		||||
#include "chip.h"
 | 
			
		||||
#include "board.h"
 | 
			
		||||
 | 
			
		||||
/***************************************************************************************************
 | 
			
		||||
** DEFINES
 | 
			
		||||
***************************************************************************************************/
 | 
			
		||||
 | 
			
		||||
/*--------------------------------------------------------------------------------------------------
 | 
			
		||||
** ENABLE/DISABLE, ON/OFF DEFINES
 | 
			
		||||
**
 | 
			
		||||
** DESCRIPTION: For clarity in enable parameters.
 | 
			
		||||
--------------------------------------------------------------------------------------------------*/
 | 
			
		||||
 | 
			
		||||
#ifndef DRV_ENABLE
 | 
			
		||||
#define DRV_ENABLE  1
 | 
			
		||||
#endif
 | 
			
		||||
 | 
			
		||||
#ifndef DRV_DISABLE
 | 
			
		||||
#define DRV_DISABLE  0
 | 
			
		||||
#endif
 | 
			
		||||
 | 
			
		||||
#ifndef DRV_ON
 | 
			
		||||
#define DRV_ON  1
 | 
			
		||||
#endif
 | 
			
		||||
 | 
			
		||||
#ifndef DRV_OFF
 | 
			
		||||
#define DRV_OFF  0
 | 
			
		||||
#endif
 | 
			
		||||
 | 
			
		||||
/*--------------------------------------------------------------------------------------------------
 | 
			
		||||
** TX/RX DEFINES
 | 
			
		||||
**
 | 
			
		||||
** DESCRIPTION: For tx/rx argument of driver functions.
 | 
			
		||||
--------------------------------------------------------------------------------------------------*/
 | 
			
		||||
 | 
			
		||||
#define DRV_UART_TX  (1u << 0)
 | 
			
		||||
#define DRV_UART_RX  (1u << 1)
 | 
			
		||||
 | 
			
		||||
/***************************************************************************************************
 | 
			
		||||
** TYPES
 | 
			
		||||
***************************************************************************************************/
 | 
			
		||||
 | 
			
		||||
/*--------------------------------------------------------------------------------------------------
 | 
			
		||||
** DRV_UART_RX_CALLBACK_t()
 | 
			
		||||
**
 | 
			
		||||
** DESCRIPTION: Callback for received byte.
 | 
			
		||||
**
 | 
			
		||||
** PARAMETERS:  c  Received byte
 | 
			
		||||
**------------------------------------------------------------------------------------------------*/
 | 
			
		||||
 | 
			
		||||
typedef void (*DRV_UART_RX_CALLBACK_t)(uint8_t c);
 | 
			
		||||
 | 
			
		||||
/*--------------------------------------------------------------------------------------------------
 | 
			
		||||
** DRV_UART_TX_COMPLETE_t()
 | 
			
		||||
**
 | 
			
		||||
** DESCRIPTION: Callback for transmit interrupt.
 | 
			
		||||
**------------------------------------------------------------------------------------------------*/
 | 
			
		||||
 | 
			
		||||
typedef void (*DRV_UART_TX_CALLBACK_t)(void);
 | 
			
		||||
 | 
			
		||||
 | 
			
		||||
/*--------------------------------------------------------------------------------------------------
 | 
			
		||||
** DRV_UART_BUF_LEN
 | 
			
		||||
**
 | 
			
		||||
** DESCRIPTION: The maximum length of printed strings.
 | 
			
		||||
**------------------------------------------------------------------------------------------------*/
 | 
			
		||||
#define DRV_UART_BUF_LEN 128u
 | 
			
		||||
 | 
			
		||||
/*--------------------------------------------------------------------------------------------------
 | 
			
		||||
** struct drv_console
 | 
			
		||||
**
 | 
			
		||||
** DESCRIPTION: Access structure of driver.
 | 
			
		||||
--------------------------------------------------------------------------------------------------*/
 | 
			
		||||
struct drv_uart {
 | 
			
		||||
    /*----------------------------------------------------------------------------------------------
 | 
			
		||||
    ** Initialize()
 | 
			
		||||
    **
 | 
			
		||||
    ** DESCRIPTION: Initialize UART.
 | 
			
		||||
    **
 | 
			
		||||
    ** PARAMETERS:  baud   Baud rate
 | 
			
		||||
    **              rx_tx  Indicates allowed modes of driver (DRV_UART_RX &/| DRV_UART_TX).
 | 
			
		||||
    **--------------------------------------------------------------------------------------------*/
 | 
			
		||||
    void (*Initialize)(uint32_t baud, uint32_t rx_tx);
 | 
			
		||||
 | 
			
		||||
    /*----------------------------------------------------------------------------------------------
 | 
			
		||||
    ** Sleep()
 | 
			
		||||
    **
 | 
			
		||||
    ** DESCRIPTION: Allow UART settings to be saved before processor enters deep sleep.
 | 
			
		||||
    **--------------------------------------------------------------------------------------------*/
 | 
			
		||||
    void (*Sleep)(void);
 | 
			
		||||
 | 
			
		||||
    /*----------------------------------------------------------------------------------------------
 | 
			
		||||
    ** Wake()
 | 
			
		||||
    **
 | 
			
		||||
    ** DESCRIPTION: Allow UART settings to be restored after processor exits deep sleep.
 | 
			
		||||
    **--------------------------------------------------------------------------------------------*/
 | 
			
		||||
    void (*Wake)(void);
 | 
			
		||||
 | 
			
		||||
    /*----------------------------------------------------------------------------------------------
 | 
			
		||||
    ** Receive()
 | 
			
		||||
    **
 | 
			
		||||
    ** DESCRIPTION: Receive data.
 | 
			
		||||
    **
 | 
			
		||||
    ** PARAMETERS:  buf  Pointer to buffer that will receive data
 | 
			
		||||
    **              len  Number of data bytes to data
 | 
			
		||||
    **
 | 
			
		||||
    ** RETURNS:     Number of bytes receuved
 | 
			
		||||
    **--------------------------------------------------------------------------------------------*/
 | 
			
		||||
    int32_t (*Receive)(uint8_t *buf, uint32_t len);
 | 
			
		||||
 | 
			
		||||
   /*----------------------------------------------------------------------------------------------
 | 
			
		||||
    ** Transmit()
 | 
			
		||||
    **
 | 
			
		||||
    ** DESCRIPTION: Transmit data.
 | 
			
		||||
    **
 | 
			
		||||
    ** PARAMETERS:  buf  Pointer to buffer of data to transmit
 | 
			
		||||
    **              len  Number of data bytes to transmit
 | 
			
		||||
    **
 | 
			
		||||
    ** RETURNS:     Number of bytes transmitted
 | 
			
		||||
    **--------------------------------------------------------------------------------------------*/
 | 
			
		||||
    int32_t (*Transmit)(const uint8_t *buf, uint32_t len);
 | 
			
		||||
 | 
			
		||||
    /*----------------------------------------------------------------------------------------------
 | 
			
		||||
    ** SetReceiveHandler()
 | 
			
		||||
    **
 | 
			
		||||
    ** DESCRIPTION: Set receive handler.
 | 
			
		||||
    **
 | 
			
		||||
    ** PARAMETERS:  cb  Pointer to callbak
 | 
			
		||||
    **--------------------------------------------------------------------------------------------*/
 | 
			
		||||
    void (*SetReceiveHandler)(DRV_UART_RX_CALLBACK_t cb);
 | 
			
		||||
 | 
			
		||||
    /*----------------------------------------------------------------------------------------------
 | 
			
		||||
    ** SetTransmitHandler()
 | 
			
		||||
    **
 | 
			
		||||
    ** DESCRIPTION: Set transmit handler.
 | 
			
		||||
    **
 | 
			
		||||
    ** PARAMETERS:  cb  Pointer to callbak
 | 
			
		||||
    **--------------------------------------------------------------------------------------------*/
 | 
			
		||||
    void (*SetTransmitHandler)(DRV_UART_TX_CALLBACK_t cb);
 | 
			
		||||
 | 
			
		||||
    /*----------------------------------------------------------------------------------------------
 | 
			
		||||
    ** EnableInterrupt()
 | 
			
		||||
    **
 | 
			
		||||
    ** DESCRIPTION: Enable or disable an interrupt.
 | 
			
		||||
    **
 | 
			
		||||
    ** PARAMETERS:  rx_tx   Select between receive (DRV_UART_RX) or transmit (DRV_UART_TX) interrupt.
 | 
			
		||||
    **              enable  Indicates whether interrupt should be enable (not 0) or disabled (0).
 | 
			
		||||
    **--------------------------------------------------------------------------------------------*/
 | 
			
		||||
    void (*EnableInterrupt)(uint32_t rx_tx, int32_t enable);
 | 
			
		||||
};
 | 
			
		||||
 | 
			
		||||
#ifdef __cplusplus
 | 
			
		||||
}
 | 
			
		||||
#endif
 | 
			
		||||
 | 
			
		||||
#endif /* __DRV_UART_H */
 | 
			
		||||
| 
						 | 
				
			
			@ -1,42 +0,0 @@
 | 
			
		|||
/*************************************************************************************************/
 | 
			
		||||
/*!
 | 
			
		||||
 *  \file   hci_core_ps.h
 | 
			
		||||
 *
 | 
			
		||||
 *  \brief  HCI core platform-specific interfaces for dual-chip.
 | 
			
		||||
 *
 | 
			
		||||
 *          $Date: 2015-06-12 04:19:18 -0700 (Fri, 12 Jun 2015) $
 | 
			
		||||
 *          $Revision: 3061 $
 | 
			
		||||
 *
 | 
			
		||||
 *  Copyright (c) 2013 Wicentric, Inc., all rights reserved.
 | 
			
		||||
 *  Wicentric confidential and proprietary.
 | 
			
		||||
 *
 | 
			
		||||
 *  IMPORTANT.  Your use of this file is governed by a Software License Agreement
 | 
			
		||||
 *  ("Agreement") that must be accepted in order to download or otherwise receive a
 | 
			
		||||
 *  copy of this file.  You may not use or copy this file for any purpose other than
 | 
			
		||||
 *  as described in the Agreement.  If you do not agree to all of the terms of the
 | 
			
		||||
 *  Agreement do not use this file and delete all copies in your possession or control;
 | 
			
		||||
 *  if you do not have a copy of the Agreement, you must contact Wicentric, Inc. prior
 | 
			
		||||
 *  to any use, copying or further distribution of this software.
 | 
			
		||||
 */
 | 
			
		||||
/*************************************************************************************************/
 | 
			
		||||
#ifndef HCI_CORE_PS_H
 | 
			
		||||
#define HCI_CORE_PS_H
 | 
			
		||||
 | 
			
		||||
#ifdef __cplusplus
 | 
			
		||||
extern "C" {
 | 
			
		||||
#endif
 | 
			
		||||
 | 
			
		||||
/**************************************************************************************************
 | 
			
		||||
  Function Declarations
 | 
			
		||||
**************************************************************************************************/
 | 
			
		||||
 | 
			
		||||
void hciCoreResetSequence(uint8_t *pMsg);
 | 
			
		||||
void hciCoreNumCmplPkts(uint8_t *pMsg);
 | 
			
		||||
void hciCoreRecv(uint8_t msgType, uint8_t *pCoreRecvMsg);
 | 
			
		||||
uint8_t hciCoreVsCmdCmplRcvd(uint16_t opcode, uint8_t *pMsg, uint8_t len);
 | 
			
		||||
 | 
			
		||||
#ifdef __cplusplus
 | 
			
		||||
};
 | 
			
		||||
#endif
 | 
			
		||||
 | 
			
		||||
#endif /* HCI_CORE_PS_H */
 | 
			
		||||
| 
						 | 
				
			
			@ -1,112 +0,0 @@
 | 
			
		|||
/*************************************************************************************************/
 | 
			
		||||
/*!
 | 
			
		||||
 *  \file   hci_core.h
 | 
			
		||||
 *
 | 
			
		||||
 *  \brief  HCI core interfaces.
 | 
			
		||||
 *
 | 
			
		||||
 *          $Date: 2016-03-29 11:20:44 -0700 (Tue, 29 Mar 2016) $
 | 
			
		||||
 *          $Revision: 6512 $
 | 
			
		||||
 *
 | 
			
		||||
 *  Copyright (c) 2009 Wicentric, Inc., all rights reserved.
 | 
			
		||||
 *  Wicentric confidential and proprietary.
 | 
			
		||||
 *
 | 
			
		||||
 *  IMPORTANT.  Your use of this file is governed by a Software License Agreement
 | 
			
		||||
 *  ("Agreement") that must be accepted in order to download or otherwise receive a
 | 
			
		||||
 *  copy of this file.  You may not use or copy this file for any purpose other than
 | 
			
		||||
 *  as described in the Agreement.  If you do not agree to all of the terms of the
 | 
			
		||||
 *  Agreement do not use this file and delete all copies in your possession or control;
 | 
			
		||||
 *  if you do not have a copy of the Agreement, you must contact Wicentric, Inc. prior
 | 
			
		||||
 *  to any use, copying or further distribution of this software.
 | 
			
		||||
 */
 | 
			
		||||
/*************************************************************************************************/
 | 
			
		||||
#ifndef HCI_CORE_H
 | 
			
		||||
#define HCI_CORE_H
 | 
			
		||||
 | 
			
		||||
#include "hci_core_ps.h"
 | 
			
		||||
#include "wsf_queue.h"
 | 
			
		||||
#include "wsf_os.h"
 | 
			
		||||
#include "hci_api.h"
 | 
			
		||||
#include "cfg_stack.h"
 | 
			
		||||
 | 
			
		||||
#ifdef __cplusplus
 | 
			
		||||
extern "C" {
 | 
			
		||||
#endif
 | 
			
		||||
 | 
			
		||||
/**************************************************************************************************
 | 
			
		||||
  Data Types
 | 
			
		||||
**************************************************************************************************/
 | 
			
		||||
 | 
			
		||||
/* Per-connection structure for ACL packet accounting */
 | 
			
		||||
typedef struct
 | 
			
		||||
{
 | 
			
		||||
  uint8_t         *pTxAclPkt;                   /* Fragmenting TX ACL packet pointer */
 | 
			
		||||
  uint8_t         *pNextTxFrag;                 /* Next TX ACL packet fragment */
 | 
			
		||||
  uint8_t         *pRxAclPkt;                   /* RX ACL packet pointer */
 | 
			
		||||
  uint8_t         *pNextRxFrag;                 /* Next RX ACL packet fragment */
 | 
			
		||||
  uint16_t        handle;                       /* Connection handle */
 | 
			
		||||
  uint16_t        txAclRemLen;                  /* Fragmenting TX ACL packet remaining length */
 | 
			
		||||
  uint16_t        rxAclRemLen;                  /* Fragmented RX ACL packet remaining length */
 | 
			
		||||
  bool_t          fragmenting;                  /* TRUE if fragmenting a TX ACL packet */
 | 
			
		||||
  bool_t          flowDisabled;                 /* TRUE if data flow disabled */
 | 
			
		||||
  uint8_t         queuedBufs;                   /* Queued ACL buffers on this connection */
 | 
			
		||||
  uint8_t         outBufs;                      /* Outstanding ACL buffers sent to controller */
 | 
			
		||||
} hciCoreConn_t;
 | 
			
		||||
 | 
			
		||||
/* Main control block for dual-chip implementation */
 | 
			
		||||
typedef struct
 | 
			
		||||
{
 | 
			
		||||
  hciCoreConn_t   conn[DM_CONN_MAX];            /* Connection structures */
 | 
			
		||||
  uint8_t         leStates[HCI_LE_STATES_LEN];  /* Controller LE supported states */
 | 
			
		||||
  bdAddr_t        bdAddr;                       /* Bluetooth device address */
 | 
			
		||||
  wsfQueue_t      aclQueue;                     /* HCI ACL TX queue */
 | 
			
		||||
  hciCoreConn_t   *pConnRx;                     /* Connection struct for current transport RX packet */
 | 
			
		||||
  uint16_t        maxRxAclLen;                  /* Maximum reassembled RX ACL packet length */
 | 
			
		||||
  uint16_t        bufSize;                      /* Controller ACL data buffer size */
 | 
			
		||||
  uint8_t         aclQueueHi;                   /* Disable flow when this many ACL buffers queued */
 | 
			
		||||
  uint8_t         aclQueueLo;                   /* Enable flow when this many ACL buffers queued */
 | 
			
		||||
  uint8_t         availBufs;                    /* Current avail ACL data buffers */
 | 
			
		||||
  uint8_t         numBufs;                      /* Controller number of ACL data buffers */
 | 
			
		||||
  uint8_t         whiteListSize;                /* Controller white list size */
 | 
			
		||||
  uint8_t         numCmdPkts;                   /* Controller command packed count */
 | 
			
		||||
  uint8_t         leSupFeat;                    /* Controller LE supported features */
 | 
			
		||||
  int8_t          advTxPwr;                     /* Controller advertising TX power */
 | 
			
		||||
  uint8_t         resListSize;                  /* Controller resolving list size */
 | 
			
		||||
} hciCoreCb_t;
 | 
			
		||||
 | 
			
		||||
/**************************************************************************************************
 | 
			
		||||
  Global Variables
 | 
			
		||||
**************************************************************************************************/
 | 
			
		||||
 | 
			
		||||
/* Control block */
 | 
			
		||||
extern hciCoreCb_t hciCoreCb;
 | 
			
		||||
 | 
			
		||||
/* LE event mask */
 | 
			
		||||
extern const uint8_t hciLeEventMask[HCI_LE_EVT_MASK_LEN];
 | 
			
		||||
 | 
			
		||||
/* Event mask page 2 */
 | 
			
		||||
extern const uint8_t hciEventMaskPage2[HCI_EVT_MASK_LEN];
 | 
			
		||||
 | 
			
		||||
/* LE supported features configuration mask */
 | 
			
		||||
extern uint8_t hciLeSupFeatCfg;
 | 
			
		||||
 | 
			
		||||
/**************************************************************************************************
 | 
			
		||||
  Function Declarations
 | 
			
		||||
**************************************************************************************************/
 | 
			
		||||
 | 
			
		||||
void hciCoreInit(void);
 | 
			
		||||
void hciCoreResetStart(void);
 | 
			
		||||
void hciCoreConnOpen(uint16_t handle);
 | 
			
		||||
void hciCoreConnClose(uint16_t handle);
 | 
			
		||||
hciCoreConn_t *hciCoreConnByHandle(uint16_t handle);
 | 
			
		||||
void hciCoreSendAclData(hciCoreConn_t *pConn, uint8_t *pData);
 | 
			
		||||
void hciCoreTxReady(uint8_t bufs);
 | 
			
		||||
void hciCoreTxAclStart(hciCoreConn_t *pConn, uint16_t len, uint8_t *pData);
 | 
			
		||||
bool_t hciCoreTxAclContinue(hciCoreConn_t *pConn);
 | 
			
		||||
void hciCoreTxAclComplete(hciCoreConn_t *pConn, uint8_t *pData);
 | 
			
		||||
uint8_t *hciCoreAclReassembly(uint8_t *pData);
 | 
			
		||||
 | 
			
		||||
#ifdef __cplusplus
 | 
			
		||||
};
 | 
			
		||||
#endif
 | 
			
		||||
 | 
			
		||||
#endif /* HCI_CORE_H */
 | 
			
		||||
| 
						 | 
				
			
			@ -1,80 +0,0 @@
 | 
			
		|||
/*************************************************************************************************/
 | 
			
		||||
/*!
 | 
			
		||||
 *  \file   hci_drv.h
 | 
			
		||||
 *
 | 
			
		||||
 *  \brief  HCI driver interface.
 | 
			
		||||
 *
 | 
			
		||||
 *          $Date: 2013-01-02 22:19:17 -0800 (Wed, 02 Jan 2013) $
 | 
			
		||||
 *          $Revision: 405 $
 | 
			
		||||
 *
 | 
			
		||||
 *  Copyright (c) 2012 Wicentric, Inc., all rights reserved.
 | 
			
		||||
 *  Wicentric confidential and proprietary.
 | 
			
		||||
 *
 | 
			
		||||
 *  IMPORTANT.  Your use of this file is governed by a Software License Agreement
 | 
			
		||||
 *  ("Agreement") that must be accepted in order to download or otherwise receive a
 | 
			
		||||
 *  copy of this file.  You may not use or copy this file for any purpose other than
 | 
			
		||||
 *  as described in the Agreement.  If you do not agree to all of the terms of the
 | 
			
		||||
 *  Agreement do not use this file and delete all copies in your possession or control;
 | 
			
		||||
 *  if you do not have a copy of the Agreement, you must contact Wicentric, Inc. prior
 | 
			
		||||
 *  to any use, copying or further distribution of this software.
 | 
			
		||||
 */
 | 
			
		||||
/*************************************************************************************************/
 | 
			
		||||
#ifndef HCI_DRV_H
 | 
			
		||||
#define HCI_DRV_H
 | 
			
		||||
 | 
			
		||||
#ifdef __cplusplus
 | 
			
		||||
extern "C" {
 | 
			
		||||
#endif
 | 
			
		||||
 | 
			
		||||
/**************************************************************************************************
 | 
			
		||||
  Function Declarations
 | 
			
		||||
**************************************************************************************************/
 | 
			
		||||
 | 
			
		||||
/*************************************************************************************************/
 | 
			
		||||
/*!
 | 
			
		||||
 *  \fn     hciDrvWrite
 | 
			
		||||
 *
 | 
			
		||||
 *  \brief  Write data the driver.
 | 
			
		||||
 *
 | 
			
		||||
 *  \param  type     HCI packet type
 | 
			
		||||
 *  \param  len      Number of bytes to write.
 | 
			
		||||
 *  \param  pData    Byte array to write.
 | 
			
		||||
 *
 | 
			
		||||
 *  \return Return actual number of data bytes written.
 | 
			
		||||
 *
 | 
			
		||||
 *  \note   The type parameter allows the driver layer to prepend the data with a header on the
 | 
			
		||||
 *          same write transaction.
 | 
			
		||||
 */
 | 
			
		||||
/*************************************************************************************************/
 | 
			
		||||
uint16_t hciDrvWrite(uint8_t type, uint16_t len, uint8_t *pData);
 | 
			
		||||
 | 
			
		||||
/*************************************************************************************************/
 | 
			
		||||
/*!
 | 
			
		||||
 *  \fn     hciDrvRead
 | 
			
		||||
 *
 | 
			
		||||
 *  \brief  Read data bytes from the driver.
 | 
			
		||||
 *
 | 
			
		||||
 *  \param  len      Number of bytes to read.
 | 
			
		||||
 *  \param  pData    Byte array to store data.
 | 
			
		||||
 *
 | 
			
		||||
 *  \return Return actual number of data bytes read.
 | 
			
		||||
 */
 | 
			
		||||
/*************************************************************************************************/
 | 
			
		||||
uint16_t hciDrvRead(uint16_t len, uint8_t *pData);
 | 
			
		||||
 | 
			
		||||
/*************************************************************************************************/
 | 
			
		||||
/*!
 | 
			
		||||
 *  \fn     hciDrvReadyToSleep
 | 
			
		||||
 *
 | 
			
		||||
 *  \brief  Returns TRUE if driver allows MCU to enter low power sleep mode.
 | 
			
		||||
 *
 | 
			
		||||
 *  \return TRUE if ready to sleep, FALSE otherwise.
 | 
			
		||||
 */
 | 
			
		||||
/*************************************************************************************************/
 | 
			
		||||
bool_t hciDrvReadyToSleep(void);
 | 
			
		||||
 | 
			
		||||
#ifdef __cplusplus
 | 
			
		||||
};
 | 
			
		||||
#endif
 | 
			
		||||
 | 
			
		||||
#endif /* HCI_DRV_H */
 | 
			
		||||
| 
						 | 
				
			
			@ -1,42 +0,0 @@
 | 
			
		|||
/*************************************************************************************************/
 | 
			
		||||
/*!
 | 
			
		||||
 *  \file   hci_tr.h
 | 
			
		||||
 *
 | 
			
		||||
 *  \brief  HCI transport interface.
 | 
			
		||||
 *
 | 
			
		||||
 *          $Date: 2015-06-12 04:19:18 -0700 (Fri, 12 Jun 2015) $
 | 
			
		||||
 *          $Revision: 3061 $
 | 
			
		||||
 *
 | 
			
		||||
 *  Copyright (c) 2009 Wicentric, Inc., all rights reserved.
 | 
			
		||||
 *  Wicentric confidential and proprietary.
 | 
			
		||||
 *
 | 
			
		||||
 *  IMPORTANT.  Your use of this file is governed by a Software License Agreement
 | 
			
		||||
 *  ("Agreement") that must be accepted in order to download or otherwise receive a
 | 
			
		||||
 *  copy of this file.  You may not use or copy this file for any purpose other than
 | 
			
		||||
 *  as described in the Agreement.  If you do not agree to all of the terms of the
 | 
			
		||||
 *  Agreement do not use this file and delete all copies in your possession or control;
 | 
			
		||||
 *  if you do not have a copy of the Agreement, you must contact Wicentric, Inc. prior
 | 
			
		||||
 *  to any use, copying or further distribution of this software.
 | 
			
		||||
 */
 | 
			
		||||
/*************************************************************************************************/
 | 
			
		||||
#ifndef HCI_TR_H
 | 
			
		||||
#define HCI_TR_H
 | 
			
		||||
 | 
			
		||||
#ifdef __cplusplus
 | 
			
		||||
extern "C" {
 | 
			
		||||
#endif
 | 
			
		||||
 | 
			
		||||
/**************************************************************************************************
 | 
			
		||||
  Function Declarations
 | 
			
		||||
**************************************************************************************************/
 | 
			
		||||
 | 
			
		||||
void hciTrSendAclData(void *pContext, uint8_t *pAclData);
 | 
			
		||||
void hciTrSendCmd(uint8_t *pCmdData);
 | 
			
		||||
bool_t hciTrInit(uint8_t port, uint32_t baudRate, bool_t flowControl);
 | 
			
		||||
void hciTrShutdown(void);
 | 
			
		||||
 | 
			
		||||
#ifdef __cplusplus
 | 
			
		||||
};
 | 
			
		||||
#endif
 | 
			
		||||
 | 
			
		||||
#endif /* HCI_TR_H */
 | 
			
		||||
| 
						 | 
				
			
			@ -1,362 +0,0 @@
 | 
			
		|||
/*************************************************************************************************/
 | 
			
		||||
/*!
 | 
			
		||||
 *  \file   hpal_blep.h
 | 
			
		||||
 *
 | 
			
		||||
 *  \brief  HPAL BLEP initialization.
 | 
			
		||||
 *
 | 
			
		||||
 *  \internal
 | 
			
		||||
 | 
			
		||||
 *  __LICENSE__
 | 
			
		||||
 *
 | 
			
		||||
 *  Copyright (c) 2015 ARM, Ltd., all rights reserved.
 | 
			
		||||
 *  ARM confidential and proprietary.
 | 
			
		||||
 *
 | 
			
		||||
 *  IMPORTANT.  Your use of this file is governed by a Software License Agreement
 | 
			
		||||
 *  ("Agreement") that must be accepted in order to download or otherwise receive a
 | 
			
		||||
 *  copy of this file.  You may not use or copy this file for any purpose other than
 | 
			
		||||
 *  as described in the Agreement.  If you do not agree to all of the terms of the
 | 
			
		||||
 *  Agreement do not use this file and delete all copies in your possession or control;
 | 
			
		||||
 *  if you do not have a copy of the Agreement, you must contact ARM, Ltd. prior
 | 
			
		||||
 *  to any use, copying or further distribution of this software.
 | 
			
		||||
 | 
			
		||||
 *  \endinternal
 | 
			
		||||
 *
 | 
			
		||||
 *  __USAGE NOTE__
 | 
			
		||||
 *
 | 
			
		||||
 *  main() will usually start Cordio initialization:
 | 
			
		||||
 *
 | 
			
		||||
 *  \code
 | 
			
		||||
 *
 | 
			
		||||
 *    int main()
 | 
			
		||||
 *    {
 | 
			
		||||
 *      wsfHandlerId_t handlerId;
 | 
			
		||||
 *
 | 
			
		||||
 *      // ... initialize platform ...
 | 
			
		||||
 *
 | 
			
		||||
 *      handlerId = WsfOsSetNextHandler(HpalBlepHandler);
 | 
			
		||||
 *      HpalBlepInit(handlerId);
 | 
			
		||||
 *
 | 
			
		||||
 *      // ... add other handlers ...
 | 
			
		||||
 *
 | 
			
		||||
 *      HpalBlepSetStartupCback(mainBlepStartCallback);
 | 
			
		||||
 *      HpalBlepStart(&myBlobCbacks, (void *)&myContext);
 | 
			
		||||
 *
 | 
			
		||||
 *      // ... dispatcher loop ...
 | 
			
		||||
 *
 | 
			
		||||
 *    }
 | 
			
		||||
 *
 | 
			
		||||
 *  \endcode
 | 
			
		||||
 *
 | 
			
		||||
 *  The startup callback will receive a pass/fail indication after startup complees.  The application
 | 
			
		||||
 *  can then assign callbacks for the HCI interface and "take up" the HCI to begin sending commands
 | 
			
		||||
 *  and receiving events.
 | 
			
		||||
 *
 | 
			
		||||
 *  \code
 | 
			
		||||
 *
 | 
			
		||||
 *  static void mainBlepStartCallback(bool_t ok)
 | 
			
		||||
 *  {
 | 
			
		||||
 *    // ... start BLE stack initialization ...
 | 
			
		||||
 *
 | 
			
		||||
 *    HpalHciSetCbacks(&myHciCbacks);
 | 
			
		||||
 *    HpalHciTakeUp();
 | 
			
		||||
 *
 | 
			
		||||
 *    // ... more BLE stack initialization ...
 | 
			
		||||
 *
 | 
			
		||||
 *    // ... start using BLE ...
 | 
			
		||||
 *  }
 | 
			
		||||
 *
 | 
			
		||||
 *  \endcode
 | 
			
		||||
 *
 | 
			
		||||
 *  __STARTUP PROCESS__
 | 
			
		||||
 *
 | 
			
		||||
 *  Setup of the BLEP begins with a @ref STARTUP "VS_Startup event" sent from Cordio.
 | 
			
		||||
 *  The Startup_Flags parameter indicates whether the currently-executing firmware (here the
 | 
			
		||||
 *  bootloader) requires a firmware update to perform Bluetooth LE operations if bit 0x02 is set.
 | 
			
		||||
 *
 | 
			
		||||
 *  If firmware must be updated, the firmware should be retrieved from storage, and a description
 | 
			
		||||
 *  provided to Cordio in a @ref FW_LOAD "VS_Firmware_Load command".  The Status and Extended_Status
 | 
			
		||||
 *  should be checked in the Command_Complete event returned in response.  The firmware data should
 | 
			
		||||
 *  then be supplied with a series of @ref FW_DATA "VS_Firmware_Data commands".  Again, from each
 | 
			
		||||
 *  Command_Complete event returned in response, the Status and Extended_Status should be checked.
 | 
			
		||||
 *  After the Command_Complete event following the final VS_FW_Data command, Cordio will reset and
 | 
			
		||||
 *  the new firmware will begin executing.  Another @ref STARTUP "VS_Startup event" will be sent
 | 
			
		||||
 *  from Cordio.
 | 
			
		||||
 *
 | 
			
		||||
 *  The Startup_Flags parameter from the VS_Startup event will also indicate whether Cordio needs
 | 
			
		||||
 *  a trim update to operate if bit 0x01 is set.  If trim must be updated, the trim should be
 | 
			
		||||
 *  retrieved from storage, and a description provided to Cordio in a @ref TRIM_LOAD "VS_Trim_Load command".
 | 
			
		||||
 *  The Status and Extended_Status should be checked in the Command_Complete event returned in
 | 
			
		||||
 *  response.  The trim data should then be supplied with a series of @ref TRIM_DATA "VS_Trim_Data commands".
 | 
			
		||||
 *  Again, from each Command_Complete event returned in response, the Status and Extended_Status
 | 
			
		||||
 *  should be checked.  Multiple trim blobs may be uploaded sequentially.
 | 
			
		||||
 *
 | 
			
		||||
 *  After the firmware update and trim update (if necessary), Cordio should be ready to process
 | 
			
		||||
 *  standard Bluetooth LE commands.  The Startup_Flags from the last VS_Startup event should
 | 
			
		||||
 *  confirm this by setting bit 0x04.
 | 
			
		||||
 *
 | 
			
		||||
 *  \dot
 | 
			
		||||
 *    digraph G {
 | 
			
		||||
 *      node [shape="oval", color="darkorange", width=2, height=0.6, fixedsize=true];
 | 
			
		||||
 *      edge [color="darkorange"];
 | 
			
		||||
 *
 | 
			
		||||
 *      WAIT_FOR_STARTUP    [label="Wait for STARTUP\n from bootloader"];
 | 
			
		||||
 *      START_FW_LOAD       [label="Start firmware load"];
 | 
			
		||||
 *      DO_FW_LOAD          [label="Load firmware"];
 | 
			
		||||
 *      WAIT_FOR_FW_STARTUP [label="Wait for STARTUP\n from firmware"];
 | 
			
		||||
 *      START_TRIM_LOAD     [label="Start trim load"];
 | 
			
		||||
 *      DO_TRIM_LOAD        [label="Load a trim blob"];
 | 
			
		||||
 *      DONE_FAILURE        [label="Done with error"];
 | 
			
		||||
 *      DONE_SUCCESS        [label="Done with success"];
 | 
			
		||||
 *
 | 
			
		||||
 *      WAIT_FOR_STARTUP -> START_FW_LOAD;
 | 
			
		||||
 *
 | 
			
		||||
 *      START_FW_LOAD -> START_TRIM_LOAD     [label="doesn't\n need fw"];
 | 
			
		||||
 *      START_FW_LOAD -> DO_FW_LOAD;
 | 
			
		||||
 *      DO_FW_LOAD    -> DO_FW_LOAD          [label="more data"];
 | 
			
		||||
 *      DO_FW_LOAD    -> WAIT_FOR_FW_STARTUP [label="no more\n data"];
 | 
			
		||||
 *
 | 
			
		||||
 *      WAIT_FOR_FW_STARTUP -> START_TRIM_LOAD;
 | 
			
		||||
 *
 | 
			
		||||
 *      START_TRIM_LOAD -> DONE_SUCCESS    [label="doesn't\n need trim"];
 | 
			
		||||
 *      START_TRIM_LOAD -> DO_TRIM_LOAD    [label="another\n trim blob"];
 | 
			
		||||
 *      START_TRIM_LOAD -> DONE_SUCCESS    [label="no more\n trim blobs"];
 | 
			
		||||
 *      DO_TRIM_LOAD    -> DO_TRIM_LOAD    [label="more data"];
 | 
			
		||||
 *      DO_TRIM_LOAD    -> START_TRIM_LOAD [label="no more\n data"];
 | 
			
		||||
 *
 | 
			
		||||
 *      WAIT_FOR_STARTUP    -> DONE_FAILURE [label="timeout\n or error"];
 | 
			
		||||
 *      START_FW_LOAD       -> DONE_FAILURE [label="timeout\n or error"];
 | 
			
		||||
 *      DO_FW_LOAD          -> DONE_FAILURE [label="timeout\n or error"];
 | 
			
		||||
 *      WAIT_FOR_FW_STARTUP -> DONE_FAILURE [label="timeout\n or error"];
 | 
			
		||||
 *      START_TRIM_LOAD     -> DONE_FAILURE [label="timeout\n or error"];
 | 
			
		||||
 *      DO_TRIM_LOAD        -> DONE_FAILURE [label="timeout\n or error"];
 | 
			
		||||
 *    }
 | 
			
		||||
 *  \enddot
 | 
			
		||||
 */
 | 
			
		||||
/*************************************************************************************************/
 | 
			
		||||
 | 
			
		||||
#ifndef HPAL_BLEP_H
 | 
			
		||||
#define HPAL_BLEP_H
 | 
			
		||||
 | 
			
		||||
#ifdef __cplusplus
 | 
			
		||||
extern "C" {
 | 
			
		||||
#endif
 | 
			
		||||
 | 
			
		||||
#include "cordio_bt4_defs.h"
 | 
			
		||||
 | 
			
		||||
#include "wsf_types.h"
 | 
			
		||||
#include "wsf_os.h"
 | 
			
		||||
 | 
			
		||||
/**************************************************************************************************
 | 
			
		||||
  Data Types
 | 
			
		||||
**************************************************************************************************/
 | 
			
		||||
 | 
			
		||||
/*************************************************************************************************/
 | 
			
		||||
/*!
 | 
			
		||||
 *  \brief  Header preceding each blob of data.
 | 
			
		||||
 */
 | 
			
		||||
/*************************************************************************************************/
 | 
			
		||||
typedef CordioTc2ImgHdr_t hpalBlepBlobHeader_t;
 | 
			
		||||
 | 
			
		||||
/*************************************************************************************************/
 | 
			
		||||
/*!
 | 
			
		||||
 *  \brief  Callback for BLEP startup status.
 | 
			
		||||
 */
 | 
			
		||||
/*************************************************************************************************/
 | 
			
		||||
typedef void (*hpalBlepStartupCback_t)(bool_t ok);
 | 
			
		||||
 | 
			
		||||
/*************************************************************************************************/
 | 
			
		||||
/*!
 | 
			
		||||
 *  \brief  Storage callbacks invoked during startup to read patch and trim data.
 | 
			
		||||
 */
 | 
			
		||||
/*************************************************************************************************/
 | 
			
		||||
typedef struct
 | 
			
		||||
{
 | 
			
		||||
  /***********************************************************************************************/
 | 
			
		||||
  /*!
 | 
			
		||||
   *  \brief  Setup device for reading from beginning of blob storage.
 | 
			
		||||
   *
 | 
			
		||||
   *  \param  pContext    Context given to HpalBlepStart()
 | 
			
		||||
   *
 | 
			
		||||
   *  \return TRUE if successful
 | 
			
		||||
   */
 | 
			
		||||
  /***********************************************************************************************/
 | 
			
		||||
  bool_t (*StartStorage)(void *pContext);
 | 
			
		||||
 | 
			
		||||
  /***********************************************************************************************/
 | 
			
		||||
  /*!
 | 
			
		||||
   *  \brief  Storage device is no longer needed, so it can be powered down.
 | 
			
		||||
   *
 | 
			
		||||
   *  \param  pContext    Context given to HpalBlepStart()
 | 
			
		||||
   *
 | 
			
		||||
   *  \return TRUE if successful
 | 
			
		||||
   */
 | 
			
		||||
  /***********************************************************************************************/
 | 
			
		||||
  bool_t (*EndStorage)(void *pContext);
 | 
			
		||||
 | 
			
		||||
  /***********************************************************************************************/
 | 
			
		||||
  /*!
 | 
			
		||||
   *  \brief  Read next blob header from storage device.
 | 
			
		||||
   *
 | 
			
		||||
   *  \param  pContext    Context given to HpalBlepStart()
 | 
			
		||||
   *  \param  pHdr        Pointer to structure that will receive header
 | 
			
		||||
   *
 | 
			
		||||
   *  \return TRUE if successful
 | 
			
		||||
   */
 | 
			
		||||
  /***********************************************************************************************/
 | 
			
		||||
  bool_t (*ReadNextBlobHeader)(void *pContext, hpalBlepBlobHeader_t *pHdr);
 | 
			
		||||
 | 
			
		||||
  /***********************************************************************************************/
 | 
			
		||||
  /*!
 | 
			
		||||
   *  \brief  Read more data from current blob at current offset.  Reading data advances the
 | 
			
		||||
   *          offset.
 | 
			
		||||
   *
 | 
			
		||||
   *  \param  pContext    Context given to HpalBlep_Startup()
 | 
			
		||||
   *  \param  pData       Storage for data
 | 
			
		||||
   *  \param  length      Number of bytes to read
 | 
			
		||||
   *
 | 
			
		||||
   *  \return TRUE if successful
 | 
			
		||||
   */
 | 
			
		||||
  /***********************************************************************************************/
 | 
			
		||||
  bool_t (*ReadMoreBlobData)(void *pContext, uint8_t *pData, uint32_t length);
 | 
			
		||||
 | 
			
		||||
  /***********************************************************************************************/
 | 
			
		||||
  /*!
 | 
			
		||||
   * \brief   Advance the offset of the current blob.
 | 
			
		||||
   *
 | 
			
		||||
   * \param   pContext    Context given to HpalBlep_Startup()
 | 
			
		||||
   * \param   length      Number of bytes to skip
 | 
			
		||||
   *
 | 
			
		||||
   * \return  TRUE if successful
 | 
			
		||||
   */
 | 
			
		||||
  /***********************************************************************************************/
 | 
			
		||||
  bool_t (*SkipBlobData)(void *pContext, uint32_t length);
 | 
			
		||||
} hpalBlepStorageCbacks_t;
 | 
			
		||||
 | 
			
		||||
/**************************************************************************************************
 | 
			
		||||
  Function Declarations
 | 
			
		||||
**************************************************************************************************/
 | 
			
		||||
 | 
			
		||||
/*************************************************************************************************/
 | 
			
		||||
/*!
 | 
			
		||||
 *  \brief  Initialize the BLEP startup.
 | 
			
		||||
 *
 | 
			
		||||
 *  \param  handlerId       Handler ID for HpalBlepHandler().
 | 
			
		||||
 *
 | 
			
		||||
 *  \return None.
 | 
			
		||||
 */
 | 
			
		||||
/*************************************************************************************************/
 | 
			
		||||
void HpalBlepInit(wsfHandlerId_t handlerId);
 | 
			
		||||
 | 
			
		||||
/*************************************************************************************************/
 | 
			
		||||
/*!
 | 
			
		||||
 *  \brief  Begin BLEP startup.
 | 
			
		||||
 *
 | 
			
		||||
 *  \param  pCbacks         Storage callbacks.
 | 
			
		||||
 *  \param  pCbackContext   Storage callback context.
 | 
			
		||||
 *
 | 
			
		||||
 *  \return None.
 | 
			
		||||
 */
 | 
			
		||||
/*************************************************************************************************/
 | 
			
		||||
void HpalBlepStart(const hpalBlepStorageCbacks_t *pCbacks, void *pCbackContext);
 | 
			
		||||
 | 
			
		||||
/*************************************************************************************************/
 | 
			
		||||
/*!
 | 
			
		||||
 *  \brief  Set callback that will indicate startup status.
 | 
			
		||||
 *
 | 
			
		||||
 *  \param  cback           Application callback.
 | 
			
		||||
 *
 | 
			
		||||
 *  \return None.
 | 
			
		||||
 */
 | 
			
		||||
/*************************************************************************************************/
 | 
			
		||||
void HpalBlepSetStartupCback(hpalBlepStartupCback_t cback);
 | 
			
		||||
 | 
			
		||||
/*************************************************************************************************/
 | 
			
		||||
/*!
 | 
			
		||||
 *  \brief  Handler for BLEP startup messages.
 | 
			
		||||
 *
 | 
			
		||||
 *  \param  event         WSF event mask.
 | 
			
		||||
 *  \param  pMsg          WSF message.
 | 
			
		||||
 *
 | 
			
		||||
 *  \return None.
 | 
			
		||||
 */
 | 
			
		||||
/*************************************************************************************************/
 | 
			
		||||
void HpalBlepHandler(wsfEventMask_t event, wsfMsgHdr_t *pMsg);
 | 
			
		||||
 | 
			
		||||
/*************************************************************************************************/
 | 
			
		||||
/*!
 | 
			
		||||
 *  @mainpage Host Software Architecture
 | 
			
		||||
 *
 | 
			
		||||
 *  __OVERVIEW__
 | 
			
		||||
 *
 | 
			
		||||
 *  The architecture of a typical host's software can be divided into four basic components: the
 | 
			
		||||
 *  application, a host BLE stack, an RTOS or bare-metal event framework, and the CORDIO Host
 | 
			
		||||
 *  Peripheral Access Library (HPAL).
 | 
			
		||||
 *
 | 
			
		||||
 *  The host BLE stack will provide some API, generally proprietary, for managing connections to
 | 
			
		||||
 *  devices (advertising, scanning, connecting, etc.) and organizing attributes into services and
 | 
			
		||||
 *  accessing the attribute values.
 | 
			
		||||
 *
 | 
			
		||||
 *  The CORDIO HPAL provides to the stack an interface for writing to the standard Bluetooth Host
 | 
			
		||||
 *  Controller Interface (HCI) or receiving alerts when new messages have been received, as well as
 | 
			
		||||
 *  CORDIO-specific startup routines the application (perhaps through the stack) must call before
 | 
			
		||||
 *  HCI transactions begin.  The provided HPAL implementation is independent of host MCU, BLE stack,
 | 
			
		||||
 *  and any (if any) RTOS.  However, the provided startup code does submit and service messages on
 | 
			
		||||
 *  the WSF event-driven OS framework.
 | 
			
		||||
 *
 | 
			
		||||
 *  \dot
 | 
			
		||||
 *    graph G {
 | 
			
		||||
 *      node [shape="polygon", sides=4 color="darkorange", width=2.5 fixedsize=true];
 | 
			
		||||
 *      edge [color="darkorange"];
 | 
			
		||||
 *      splines="ortho";
 | 
			
		||||
 *
 | 
			
		||||
 *      subgraph cluster0 {
 | 
			
		||||
 *        app -- host;
 | 
			
		||||
 *        host -- hpal [label="HCI messages", color="darkorange"];
 | 
			
		||||
 *        hpal -- peripheral [label="LLCC Bus", color="darkorange"];
 | 
			
		||||
 *        color=white;
 | 
			
		||||
 *        ratio=fill;
 | 
			
		||||
 *        edge [style="invis"];
 | 
			
		||||
 *      }
 | 
			
		||||
 *      rtos -- wsf [constraint=false];
 | 
			
		||||
 *      app -- wsf [constraint=false];
 | 
			
		||||
 *      host -- wsf [constraint=false headport="s", tailport="e"];
 | 
			
		||||
 *      hpal -- wsf [constraint=false headport="s", tailport="e"];
 | 
			
		||||
 *
 | 
			
		||||
 *      app [label="Application Profiles\n or Services"];
 | 
			
		||||
 *      host [label="Host\n BLE Stack"];
 | 
			
		||||
 *      hpal [label="CORDIO HPAL"];
 | 
			
		||||
 *      peripheral [label="CORDIO Peripheral"];
 | 
			
		||||
 *
 | 
			
		||||
 *      rtos [label="RTOS or\n Bare-Metal\n Event Framework", width=1.5 height=1.0];
 | 
			
		||||
 *      wsf [label="WSF", width=1.5, height=0.5];
 | 
			
		||||
 *    }
 | 
			
		||||
 *  \enddot
 | 
			
		||||
 *
 | 
			
		||||
 *  __CORDIO HPAL__
 | 
			
		||||
 *
 | 
			
		||||
 *  The CORDIO peripheral has two operational modes.  It enters _statup mode_ after reset, when
 | 
			
		||||
 *  the host software must load firmware and trim patches.  If that sequence is successful, the
 | 
			
		||||
 *  peripheral will enter _HCI mode_, during which the standard HCI interface expected by the host
 | 
			
		||||
 *  BLE stack will be alive.
 | 
			
		||||
 *
 | 
			
		||||
 *  The passage from startup to HCI modes is guided by the module _hpal_blep_ and kicked off with
 | 
			
		||||
 *  a call of the API function \ref HpalBlepStart().  During this process, a series of
 | 
			
		||||
 *  vendor-specific HCI commands and events are exchanged across the LLCC bus.  When startup has
 | 
			
		||||
 *  completed, the startup callback (set with \ref HpalBlepSetStartupCback()) will return
 | 
			
		||||
 *  a status indication; in the event of an error, the LLCC bus will be disabled and the HCI
 | 
			
		||||
 *  interface will be locked to prevent inadvertent access.
 | 
			
		||||
 *
 | 
			
		||||
 *  After a successful startup, the HCI can be accessed directly with the functions in the module
 | 
			
		||||
 *  _hpal_hci_.  Management functions can "take up" (\ref HpalHciTakeUp()) or "take down" (\ref
 | 
			
		||||
 *  HpalHciTakeDown()) the interface.  Writes are performed directly (@\refHpalHci_Write()) and
 | 
			
		||||
 *  completed reads or writes indicated through callbacks (\ref HpalHciSetCbacks()).  A basic
 | 
			
		||||
 *  logging facility will, optionally, dump packet information or contents to a console for
 | 
			
		||||
 *  debugging.
 | 
			
		||||
 */
 | 
			
		||||
/*************************************************************************************************/
 | 
			
		||||
 | 
			
		||||
#ifdef __cplusplus
 | 
			
		||||
};
 | 
			
		||||
#endif
 | 
			
		||||
 | 
			
		||||
#endif /* HPAL_BLEP_H */
 | 
			
		||||
| 
						 | 
				
			
			@ -1,235 +0,0 @@
 | 
			
		|||
/*************************************************************************************************/
 | 
			
		||||
/*!
 | 
			
		||||
 *  \file   hpal_hci.h
 | 
			
		||||
 *
 | 
			
		||||
 *  \brief  HPAL HCI abstraction.
 | 
			
		||||
 *
 | 
			
		||||
 *  \internal
 | 
			
		||||
 | 
			
		||||
 *  Copyright (c) 2015 ARM, Ltd., all rights reserved.
 | 
			
		||||
 *  ARM confidential and proprietary.
 | 
			
		||||
 *
 | 
			
		||||
 *  IMPORTANT.  Your use of this file is governed by a Software License Agreement
 | 
			
		||||
 *  ("Agreement") that must be accepted in order to download or otherwise receive a
 | 
			
		||||
 *  copy of this file.  You may not use or copy this file for any purpose other than
 | 
			
		||||
 *  as described in the Agreement.  If you do not agree to all of the terms of the
 | 
			
		||||
 *  Agreement do not use this file and delete all copies in your possession or control;
 | 
			
		||||
 *  if you do not have a copy of the Agreement, you must contact ARM, Ltd. prior
 | 
			
		||||
 *  to any use, copying or further distribution of this software.
 | 
			
		||||
 *
 | 
			
		||||
 *  \endinternal
 | 
			
		||||
 */
 | 
			
		||||
/*************************************************************************************************/
 | 
			
		||||
 | 
			
		||||
#ifndef HPAL_HCI_H
 | 
			
		||||
#define HPAL_HCI_H
 | 
			
		||||
 | 
			
		||||
#ifdef __cplusplus
 | 
			
		||||
extern "C" {
 | 
			
		||||
#endif
 | 
			
		||||
 | 
			
		||||
#include "wsf_types.h"
 | 
			
		||||
 | 
			
		||||
/**************************************************************************************************
 | 
			
		||||
  Data Types
 | 
			
		||||
**************************************************************************************************/
 | 
			
		||||
 | 
			
		||||
/*************************************************************************************************/
 | 
			
		||||
/*!
 | 
			
		||||
 *  \struct hpalHciCbacks_t
 | 
			
		||||
 *
 | 
			
		||||
 *  \brief  Callbacks for allocating buffers and handling read and write completion.
 | 
			
		||||
 */
 | 
			
		||||
/*************************************************************************************************/
 | 
			
		||||
typedef struct
 | 
			
		||||
{
 | 
			
		||||
    /*********************************************************************************************/
 | 
			
		||||
    /*!
 | 
			
		||||
     * \brief   Allocate a buffer for a received message.
 | 
			
		||||
     *
 | 
			
		||||
     * This function is called from an interrupt context.
 | 
			
		||||
     *
 | 
			
		||||
     * \param   len  Length of buffer
 | 
			
		||||
     *
 | 
			
		||||
     * \return  Pointer to buffer or NULL if buffer could not be allocated
 | 
			
		||||
     */
 | 
			
		||||
    /*********************************************************************************************/
 | 
			
		||||
    uint8_t *(*BufAlloc) (uint16_t len);
 | 
			
		||||
 | 
			
		||||
    /*********************************************************************************************/
 | 
			
		||||
    /*!
 | 
			
		||||
     * \brief   Free a buffer previously allocated with `BufAlloc()`.
 | 
			
		||||
     *
 | 
			
		||||
     * \param   buf  Pointer to buffer
 | 
			
		||||
     */
 | 
			
		||||
    /*********************************************************************************************/
 | 
			
		||||
    void (*BufFree)  (uint8_t *buf);
 | 
			
		||||
 | 
			
		||||
    /*********************************************************************************************/
 | 
			
		||||
    /*!
 | 
			
		||||
     * \brief   Handle read completion.
 | 
			
		||||
     *
 | 
			
		||||
     * This function is called from an interrupt context.
 | 
			
		||||
     *
 | 
			
		||||
     * \param   type    Packet type
 | 
			
		||||
     * \param   pData   Packet data, which was allocated with `BufAlloc()`.  The caller must free
 | 
			
		||||
     *                  this buffer
 | 
			
		||||
     * \param   len     Length of packet data, in bytes
 | 
			
		||||
     *
 | 
			
		||||
     * \return  None.
 | 
			
		||||
     */
 | 
			
		||||
    /*********************************************************************************************/
 | 
			
		||||
    void (*ReadDone) (uint8_t type, uint8_t *pData, uint16_t len);
 | 
			
		||||
 | 
			
		||||
    /*********************************************************************************************/
 | 
			
		||||
    /*!
 | 
			
		||||
     * \brief   Handle write completion.
 | 
			
		||||
     *
 | 
			
		||||
     * This function is called from an interrupt context.
 | 
			
		||||
     *
 | 
			
		||||
     * \parma   type      Packet type.
 | 
			
		||||
     * \param   pData     Pointer to buffer that held written data, which was passed to
 | 
			
		||||
     *                   `HpalHciWrite()`
 | 
			
		||||
     * \param   err       Indicates success (0) or error (one of the `HPAL_HCI_ERROR_####` codes)
 | 
			
		||||
     * \param   pContext  Context pointer passed to `HpalHciWrite()`
 | 
			
		||||
     *
 | 
			
		||||
     * \return  None.
 | 
			
		||||
     *
 | 
			
		||||
     * \ref     ERROR_CODES "error codes"
 | 
			
		||||
     */
 | 
			
		||||
    /*********************************************************************************************/
 | 
			
		||||
    void (*WriteDone)(uint8_t type, uint8_t *pData, int32_t err, void *pContext);
 | 
			
		||||
} hpalHciCbacks_t;
 | 
			
		||||
 | 
			
		||||
/*************************************************************************************************/
 | 
			
		||||
/*!
 | 
			
		||||
 *  \name   Logging levels
 | 
			
		||||
 *  \anchor LOGGING_LEVELS
 | 
			
		||||
 *  \brief  Level of logging information printed about HCI packets received and transmitted.
 | 
			
		||||
 */
 | 
			
		||||
/*************************************************************************************************/
 | 
			
		||||
/*! \{ */
 | 
			
		||||
enum
 | 
			
		||||
{
 | 
			
		||||
    HPAL_HCI_LOGGING_LEVEL_OFF     = 0, /*!< No information will be logged. */
 | 
			
		||||
    HPAL_HCI_LOGGING_LEVEL_INFO    = 1, /*!< Basic details about packets will be interpreted. */
 | 
			
		||||
    HPAL_HCI_LOGGING_LEVEL_VERBOSE = 2  /*!< The full byte contents of packets will be logged. */
 | 
			
		||||
};
 | 
			
		||||
/*! \} */
 | 
			
		||||
 | 
			
		||||
/*! \brief The default log level. */
 | 
			
		||||
#define HPAL_HCI_LOGGING_LEVEL_DEFAULT  HPAL_HCI_LOGGING_LEVEL_OFF
 | 
			
		||||
 | 
			
		||||
/*************************************************************************************************/
 | 
			
		||||
/*!
 | 
			
		||||
 *  \name   Error codes
 | 
			
		||||
 *  \anchor ERROR_CODES
 | 
			
		||||
 *  \brief  An error code returned in the `WriteDone()` callback.
 | 
			
		||||
 */
 | 
			
		||||
/*************************************************************************************************/
 | 
			
		||||
/*! \{ */
 | 
			
		||||
enum
 | 
			
		||||
{
 | 
			
		||||
    HPAL_HCI_ERROR_OK      =  0,  /*!< No error; the operation succeeded. */
 | 
			
		||||
    HPAL_HCI_ERROR_BAD_ACK = -1,  /*!< The write failed because a bad ACK was received. */
 | 
			
		||||
    HPAL_HCI_ERROR_ABORTED = -2,  /*!< The write was aborted. */
 | 
			
		||||
    HPAL_HCI_ERROR_ALLOC   = -3,  /*!< Allocation failed. */
 | 
			
		||||
};
 | 
			
		||||
/*! \} */
 | 
			
		||||
 | 
			
		||||
/**************************************************************************************************
 | 
			
		||||
  Function Declarations
 | 
			
		||||
**************************************************************************************************/
 | 
			
		||||
 | 
			
		||||
/*************************************************************************************************/
 | 
			
		||||
/*!
 | 
			
		||||
 * \brief   Initialize the HCI and prepare software for reading and writing.
 | 
			
		||||
 *
 | 
			
		||||
 * \return  None.
 | 
			
		||||
 *
 | 
			
		||||
 * This function is called by `HpalBlepInit()` and generally should not be called by the
 | 
			
		||||
 * application.
 | 
			
		||||
 */
 | 
			
		||||
/*************************************************************************************************/
 | 
			
		||||
void HpalHciInit(void);
 | 
			
		||||
 | 
			
		||||
/*************************************************************************************************/
 | 
			
		||||
/*!
 | 
			
		||||
 * \brief   Set callbacks for HCI notifications and buffer allocations.
 | 
			
		||||
 *
 | 
			
		||||
 * \param   pCbacks   Pointer to callbacks.  If NULL, the reference to the existing callbacks will be
 | 
			
		||||
 *                    cleared.
 | 
			
		||||
 *
 | 
			
		||||
 * \return  None.
 | 
			
		||||
 */
 | 
			
		||||
/*************************************************************************************************/
 | 
			
		||||
void HpalHciSetCbacks(const hpalHciCbacks_t *pCbacks);
 | 
			
		||||
 | 
			
		||||
/*************************************************************************************************/
 | 
			
		||||
/*!
 | 
			
		||||
 * \brief   Take up the interface (i.e., start receiving messages and be able to transmit).
 | 
			
		||||
 *
 | 
			
		||||
 * \return  None.
 | 
			
		||||
 *
 | 
			
		||||
 * HCI messages will be received and transmissions will be allowed.  The HCI callbacks should have
 | 
			
		||||
 * been set before the interface is taken up.
 | 
			
		||||
 */
 | 
			
		||||
/*************************************************************************************************/
 | 
			
		||||
void HpalHciTakeUp(void);
 | 
			
		||||
 | 
			
		||||
/*************************************************************************************************/
 | 
			
		||||
/*!
 | 
			
		||||
 * \brief   Take down the interface (i.e., stop receiving messages and block transmissions).
 | 
			
		||||
 *
 | 
			
		||||
 * \return  None.
 | 
			
		||||
 *
 | 
			
		||||
 * HCI messages will no longer be received and transmissions (i.e., calls to `HpalHciWrite()`) will
 | 
			
		||||
 * be blocked.  The HCI callbacks can only safely be cleared after the interface is taken down.
 | 
			
		||||
 */
 | 
			
		||||
/*************************************************************************************************/
 | 
			
		||||
void HpalHciTakeDown(void);
 | 
			
		||||
 | 
			
		||||
/*************************************************************************************************/
 | 
			
		||||
/*!
 | 
			
		||||
 * \brief   Fully disable the interface.
 | 
			
		||||
 *
 | 
			
		||||
 * \return  None.
 | 
			
		||||
 *
 | 
			
		||||
 * Disabling the interface may be necessary upon an unexpected event, such as a BLEP-specific
 | 
			
		||||
 * command received after startup is complete.
 | 
			
		||||
 */
 | 
			
		||||
/*************************************************************************************************/
 | 
			
		||||
void HpalHciDisable(void);
 | 
			
		||||
 | 
			
		||||
/*************************************************************************************************/
 | 
			
		||||
/*!
 | 
			
		||||
 * \brief   Enable or disable logging for HCI packets.
 | 
			
		||||
 *
 | 
			
		||||
 * \param   level  logging level
 | 
			
		||||
 *
 | 
			
		||||
 * \return  None.
 | 
			
		||||
 *
 | 
			
		||||
 * \see     \ref LOGGING_LEVELS "logging levels"
 | 
			
		||||
 */
 | 
			
		||||
/*************************************************************************************************/
 | 
			
		||||
void HpalHciSetLoggingLevel(uint8_t level);
 | 
			
		||||
 | 
			
		||||
/*************************************************************************************************/
 | 
			
		||||
/*!
 | 
			
		||||
 * \brief   Write packet to HCI.
 | 
			
		||||
 *
 | 
			
		||||
 * \param   type      Packet type.
 | 
			
		||||
 * \param   pData     Packet data.
 | 
			
		||||
 * \param   len       Packet length, in bytes
 | 
			
		||||
 * \param   pContext  Context pointer that will be returned in the `WriteDone()` callback
 | 
			
		||||
 *
 | 
			
		||||
 * \return  None.
 | 
			
		||||
 */
 | 
			
		||||
/*************************************************************************************************/
 | 
			
		||||
void HpalHciWrite(uint8_t type, const uint8_t *pData, uint16_t len, void *pContext);
 | 
			
		||||
 | 
			
		||||
#ifdef __cplusplus
 | 
			
		||||
};
 | 
			
		||||
#endif
 | 
			
		||||
 | 
			
		||||
#endif /* HPAL_HCI_H */
 | 
			
		||||
| 
						 | 
				
			
			@ -1,576 +0,0 @@
 | 
			
		|||
/*************************************************************************************************/
 | 
			
		||||
/*!
 | 
			
		||||
 *  \file   hci_defs.h
 | 
			
		||||
 *
 | 
			
		||||
 *  \brief  HCI constants and definitions from the Bluetooth specification.
 | 
			
		||||
 *
 | 
			
		||||
 *          $Date: 2016-04-18 22:05:04 -0700 (Mon, 18 Apr 2016) $
 | 
			
		||||
 *          $Revision: 6857 $
 | 
			
		||||
 *
 | 
			
		||||
 *  Copyright (c) 2009 Wicentric, Inc., all rights reserved.
 | 
			
		||||
 *  Wicentric confidential and proprietary.
 | 
			
		||||
 *
 | 
			
		||||
 *  IMPORTANT.  Your use of this file is governed by a Software License Agreement
 | 
			
		||||
 *  ("Agreement") that must be accepted in order to download or otherwise receive a
 | 
			
		||||
 *  copy of this file.  You may not use or copy this file for any purpose other than
 | 
			
		||||
 *  as described in the Agreement.  If you do not agree to all of the terms of the
 | 
			
		||||
 *  Agreement do not use this file and delete all copies in your possession or control;
 | 
			
		||||
 *  if you do not have a copy of the Agreement, you must contact Wicentric, Inc. prior
 | 
			
		||||
 *  to any use, copying or further distribution of this software.
 | 
			
		||||
 */
 | 
			
		||||
/*************************************************************************************************/
 | 
			
		||||
#ifndef HCI_DEFS_H
 | 
			
		||||
#define HCI_DEFS_H
 | 
			
		||||
 | 
			
		||||
#ifdef __cplusplus
 | 
			
		||||
extern "C" {
 | 
			
		||||
#endif
 | 
			
		||||
 | 
			
		||||
/*! Packet definitions */
 | 
			
		||||
#define HCI_CMD_HDR_LEN                   3       /*! Command packet header length */
 | 
			
		||||
#define HCI_ACL_HDR_LEN                   4       /*! ACL packet header length */
 | 
			
		||||
#define HCI_EVT_HDR_LEN                   2       /*! Event packet header length */
 | 
			
		||||
#define HCI_EVT_PARAM_MAX_LEN             255     /*! Maximum length of event packet parameters */
 | 
			
		||||
#define HCI_ACL_DEFAULT_LEN               27      /*! Default maximum ACL packet length */
 | 
			
		||||
#define HCI_PB_FLAG_MASK                  0x3000  /*! ACL packet boundary flag mask */
 | 
			
		||||
#define HCI_PB_START_H2C                  0x0000  /*! Packet boundary flag, start, host-to-controller */
 | 
			
		||||
#define HCI_PB_CONTINUE                   0x1000  /*! Packet boundary flag, continue */
 | 
			
		||||
#define HCI_PB_START_C2H                  0x2000  /*! Packet boundary flag, start, controller-to-host */
 | 
			
		||||
#define HCI_HANDLE_MASK                   0x0FFF  /*! Mask for handle bits in ACL packet */
 | 
			
		||||
#define HCI_HANDLE_NONE                   0xFFFF  /*! Value for invalid handle */
 | 
			
		||||
 | 
			
		||||
/*! Packet types */
 | 
			
		||||
#define HCI_CMD_TYPE                      1       /*! HCI command packet */
 | 
			
		||||
#define HCI_ACL_TYPE                      2       /*! HCI ACL data packet */
 | 
			
		||||
#define HCI_EVT_TYPE                      4       /*! HCI event packet */
 | 
			
		||||
 | 
			
		||||
/*! Error codes */
 | 
			
		||||
#define HCI_SUCCESS                       0x00    /*! Success */
 | 
			
		||||
#define HCI_ERR_UNKNOWN_CMD               0x01    /*! Unknown HCI command */
 | 
			
		||||
#define HCI_ERR_UNKNOWN_HANDLE            0x02    /*! Unknown connection identifier */
 | 
			
		||||
#define HCI_ERR_HARDWARE_FAILURE          0x03    /*! Hardware failure */
 | 
			
		||||
#define HCI_ERR_PAGE_TIMEOUT              0x04    /*! Page timeout */
 | 
			
		||||
#define HCI_ERR_AUTH_FAILURE              0x05    /*! Authentication failure */
 | 
			
		||||
#define HCI_ERR_KEY_MISSING               0x06    /*! PIN or key missing */
 | 
			
		||||
#define HCI_ERR_MEMORY_EXCEEDED           0x07    /*! Memory capacity exceeded */
 | 
			
		||||
#define HCI_ERR_CONN_TIMEOUT              0x08    /*! Connection timeout */
 | 
			
		||||
#define HCI_ERR_CONN_LIMIT                0x09    /*! Connection limit exceeded */
 | 
			
		||||
#define HCI_ERR_SYNCH_CONN_LIMIT          0x0A    /*! Synchronous connection limit exceeded */
 | 
			
		||||
#define HCI_ERR_ACL_CONN_EXISTS           0x0B    /*! ACL connection already exists */
 | 
			
		||||
#define HCI_ERR_CMD_DISALLOWED            0x0C    /*! Command disallowed */
 | 
			
		||||
#define HCI_ERR_REJ_RESOURCES             0x0D    /*! Connection rejected limited resources */
 | 
			
		||||
#define HCI_ERR_REJ_SECURITY              0x0E    /*! Connection rejected security reasons */
 | 
			
		||||
#define HCI_ERR_REJ_BD_ADDR               0x0F    /*! Connection rejected unacceptable BD_ADDR */
 | 
			
		||||
#define HCI_ERR_ACCEPT_TIMEOUT            0x10    /*! Connection accept timeout exceeded */
 | 
			
		||||
#define HCI_ERR_UNSUP_FEAT                0x11    /*! Unsupported feature or parameter value */
 | 
			
		||||
#define HCI_ERR_INVALID_PARAM             0x12    /*! Invalid HCI command parameters */
 | 
			
		||||
#define HCI_ERR_REMOTE_TERMINATED         0x13    /*! Remote user terminated connection */
 | 
			
		||||
#define HCI_ERR_REMOTE_RESOURCES          0x14    /*! Remote device low resources */
 | 
			
		||||
#define HCI_ERR_REMOTE_POWER_OFF          0x15    /*! Remote device power off */
 | 
			
		||||
#define HCI_ERR_LOCAL_TERMINATED          0x16    /*! Connection terminated by local host */
 | 
			
		||||
#define HCI_ERR_REPEATED_ATTEMPTS         0x17    /*! Repeated attempts */
 | 
			
		||||
#define HCI_ERR_PAIRING_NOT_ALLOWED       0x18    /*! Pairing not allowed */
 | 
			
		||||
#define HCI_ERR_UNKNOWN_LMP_PDU           0x19    /*! Unknown LMP PDU */
 | 
			
		||||
#define HCI_ERR_UNSUP_REMOTE_FEAT         0x1A    /*! Unsupported remote feature */
 | 
			
		||||
#define HCI_ERR_SCO_OFFSET                0x1B    /*! SCO offset rejected */
 | 
			
		||||
#define HCI_ERR_SCO_INTERVAL              0x1C    /*! SCO interval rejected */
 | 
			
		||||
#define HCI_ERR_SCO_MODE                  0x1D    /*! SCO air mode rejected */
 | 
			
		||||
#define HCI_ERR_LMP_PARAM                 0x1E    /*! Invalid LMP parameters */
 | 
			
		||||
#define HCI_ERR_UNSPECIFIED               0x1F    /*! Unspecified error */
 | 
			
		||||
#define HCI_ERR_UNSUP_LMP_PARAM           0x20    /*! Unsupported LMP parameter value */
 | 
			
		||||
#define HCI_ERR_ROLE_CHANGE               0x21    /*! Role change not allowed */
 | 
			
		||||
#define HCI_ERR_LL_RESP_TIMEOUT           0x22    /*! LL response timeout */
 | 
			
		||||
#define HCI_ERR_LMP_COLLISION             0x23    /*! LMP error transaction collision */
 | 
			
		||||
#define HCI_ERR_LMP_PDU                   0x24    /*! LMP pdu not allowed */
 | 
			
		||||
#define HCI_ERR_ENCRYPT_MODE              0x25    /*! Encryption mode not acceptable */
 | 
			
		||||
#define HCI_ERR_LINK_KEY                  0x26    /*! Link key can not be changed */
 | 
			
		||||
#define HCI_ERR_UNSUP_QOS                 0x27    /*! Requested qos not supported */
 | 
			
		||||
#define HCI_ERR_INSTANT_PASSED            0x28    /*! Instant passed */
 | 
			
		||||
#define HCI_ERR_UNSUP_UNIT_KEY            0x29    /*! Pairing with unit key not supported */
 | 
			
		||||
#define HCI_ERR_TRANSACT_COLLISION        0x2A    /*! Different transaction collision */
 | 
			
		||||
#define HCI_ERR_CHANNEL_CLASS             0x2E    /*! Channel classification not supported */
 | 
			
		||||
#define HCI_ERR_MEMORY                    0x2F    /*! Insufficient security */
 | 
			
		||||
#define HCI_ERR_PARAMETER_RANGE           0x30    /*! Parameter out of mandatory range */
 | 
			
		||||
#define HCI_ERR_ROLE_SWITCH_PEND          0x32    /*! Role switch pending */
 | 
			
		||||
#define HCI_ERR_RESERVED_SLOT             0x34    /*! Reserved slot violation */
 | 
			
		||||
#define HCI_ERR_ROLE_SWITCH               0x35    /*! Role switch failed */
 | 
			
		||||
#define HCI_ERR_INQ_TOO_LARGE             0x36    /*! Extended inquiry response too large */
 | 
			
		||||
#define HCI_ERR_UNSUP_SSP                 0x37    /*! Secure simple pairing not supported by host */
 | 
			
		||||
#define HCI_ERR_HOST_BUSY_PAIRING         0x38    /*! Host busy - pairing */
 | 
			
		||||
#define HCI_ERR_NO_CHANNEL                0x39    /*! Connection rejected no suitable channel */
 | 
			
		||||
#define HCI_ERR_CONTROLLER_BUSY           0x3A    /*! Controller busy */
 | 
			
		||||
#define HCI_ERR_CONN_INTERVAL             0x3B    /*! Unacceptable connection interval */
 | 
			
		||||
#define HCI_ERR_ADV_TIMEOUT               0x3C    /*! Directed advertising timeout */
 | 
			
		||||
#define HCI_ERR_MIC_FAILURE               0x3D    /*! Connection terminated due to MIC failure */
 | 
			
		||||
#define HCI_ERR_CONN_FAIL                 0x3E    /*! Connection failed to be established */
 | 
			
		||||
#define HCI_ERR_MAC_CONN_FAIL             0x3F    /*! MAC connection failed */
 | 
			
		||||
 | 
			
		||||
/*! Command groups */
 | 
			
		||||
#define HCI_OGF_NOP                       0x00    /*! No operation */
 | 
			
		||||
#define HCI_OGF_LINK_CONTROL              0x01    /*! Link control */
 | 
			
		||||
#define HCI_OGF_LINK_POLICY               0x02    /*! Link policy */
 | 
			
		||||
#define HCI_OGF_CONTROLLER                0x03    /*! Controller and baseband */
 | 
			
		||||
#define HCI_OGF_INFORMATIONAL             0x04    /*! Informational parameters */
 | 
			
		||||
#define HCI_OGF_STATUS                    0x05    /*! Status parameters */
 | 
			
		||||
#define HCI_OGF_TESTING                   0x06    /*! Testing */
 | 
			
		||||
#define HCI_OGF_LE_CONTROLLER             0x08    /*! LE controller */
 | 
			
		||||
#define HCI_OGF_VENDOR_SPEC               0x3F    /*! Vendor specific */
 | 
			
		||||
 | 
			
		||||
/*! NOP command */
 | 
			
		||||
#define HCI_OCF_NOP                       0x00
 | 
			
		||||
 | 
			
		||||
/*! Link control commands */
 | 
			
		||||
#define HCI_OCF_DISCONNECT                0x06
 | 
			
		||||
#define HCI_OCF_READ_REMOTE_VER_INFO      0x1D
 | 
			
		||||
 | 
			
		||||
/*! Link policy commands (none used for LE) */
 | 
			
		||||
 | 
			
		||||
/*! Controller and baseband commands */
 | 
			
		||||
#define HCI_OCF_SET_EVENT_MASK            0x01
 | 
			
		||||
#define HCI_OCF_RESET                     0x03
 | 
			
		||||
#define HCI_OCF_READ_TX_PWR_LVL           0x2D
 | 
			
		||||
#define HCI_OCF_SET_CONTROLLER_TO_HOST_FC 0x31
 | 
			
		||||
#define HCI_OCF_HOST_BUFFER_SIZE          0x33
 | 
			
		||||
#define HCI_OCF_HOST_NUM_CMPL_PKTS        0x35
 | 
			
		||||
#define HCI_OCF_SET_EVENT_MASK_PAGE2      0x63
 | 
			
		||||
#define HCI_OCF_READ_AUTH_PAYLOAD_TO      0x7B
 | 
			
		||||
#define HCI_OCF_WRITE_AUTH_PAYLOAD_TO     0x7C
 | 
			
		||||
 | 
			
		||||
/*! Informational commands */
 | 
			
		||||
#define HCI_OCF_READ_LOCAL_VER_INFO       0x01
 | 
			
		||||
#define HCI_OCF_READ_LOCAL_SUP_CMDS       0x02
 | 
			
		||||
#define HCI_OCF_READ_LOCAL_SUP_FEAT       0x03
 | 
			
		||||
#define HCI_OCF_READ_BUF_SIZE             0x05
 | 
			
		||||
#define HCI_OCF_READ_BD_ADDR              0x09
 | 
			
		||||
 | 
			
		||||
/*! Status commands */
 | 
			
		||||
#define HCI_OCF_READ_RSSI                 0x05
 | 
			
		||||
 | 
			
		||||
/*! LE controller commands */
 | 
			
		||||
#define HCI_OCF_LE_SET_EVENT_MASK         0x01
 | 
			
		||||
#define HCI_OCF_LE_READ_BUF_SIZE          0x02
 | 
			
		||||
#define HCI_OCF_LE_READ_LOCAL_SUP_FEAT    0x03
 | 
			
		||||
#define HCI_OCF_LE_SET_RAND_ADDR          0x05
 | 
			
		||||
#define HCI_OCF_LE_SET_ADV_PARAM          0x06
 | 
			
		||||
#define HCI_OCF_LE_READ_ADV_TX_POWER      0x07
 | 
			
		||||
#define HCI_OCF_LE_SET_ADV_DATA           0x08
 | 
			
		||||
#define HCI_OCF_LE_SET_SCAN_RESP_DATA     0x09
 | 
			
		||||
#define HCI_OCF_LE_SET_ADV_ENABLE         0x0A
 | 
			
		||||
#define HCI_OCF_LE_SET_SCAN_PARAM         0x0B
 | 
			
		||||
#define HCI_OCF_LE_SET_SCAN_ENABLE        0x0C
 | 
			
		||||
#define HCI_OCF_LE_CREATE_CONN            0x0D
 | 
			
		||||
#define HCI_OCF_LE_CREATE_CONN_CANCEL     0x0E
 | 
			
		||||
#define HCI_OCF_LE_READ_WHITE_LIST_SIZE   0x0F
 | 
			
		||||
#define HCI_OCF_LE_CLEAR_WHITE_LIST       0x10
 | 
			
		||||
#define HCI_OCF_LE_ADD_DEV_WHITE_LIST     0x11
 | 
			
		||||
#define HCI_OCF_LE_REMOVE_DEV_WHITE_LIST  0x12
 | 
			
		||||
#define HCI_OCF_LE_CONN_UPDATE            0x13
 | 
			
		||||
#define HCI_OCF_LE_SET_HOST_CHAN_CLASS    0x14
 | 
			
		||||
#define HCI_OCF_LE_READ_CHAN_MAP          0x15
 | 
			
		||||
#define HCI_OCF_LE_READ_REMOTE_FEAT       0x16
 | 
			
		||||
#define HCI_OCF_LE_ENCRYPT                0x17
 | 
			
		||||
#define HCI_OCF_LE_RAND                   0x18
 | 
			
		||||
#define HCI_OCF_LE_START_ENCRYPTION       0x19
 | 
			
		||||
#define HCI_OCF_LE_LTK_REQ_REPL           0x1A
 | 
			
		||||
#define HCI_OCF_LE_LTK_REQ_NEG_REPL       0x1B
 | 
			
		||||
#define HCI_OCF_LE_READ_SUP_STATES        0x1C
 | 
			
		||||
#define HCI_OCF_LE_RECEIVER_TEST          0x1D
 | 
			
		||||
#define HCI_OCF_LE_TRANSMITTER_TEST       0x1E
 | 
			
		||||
#define HCI_OCF_LE_TEST_END               0x1F
 | 
			
		||||
/* New in version 4.1 */
 | 
			
		||||
#define HCI_OCF_LE_REM_CONN_PARAM_REP     0x20
 | 
			
		||||
#define HCI_OCF_LE_REM_CONN_PARAM_NEG_REP 0x21
 | 
			
		||||
/* New in version 4.2 */
 | 
			
		||||
#define HCI_OCF_LE_SET_DATA_LEN            0x22
 | 
			
		||||
#define HCI_OCF_LE_READ_DEF_DATA_LEN       0x23
 | 
			
		||||
#define HCI_OCF_LE_WRITE_DEF_DATA_LEN      0x24
 | 
			
		||||
#define HCI_OCF_LE_READ_LOCAL_P256_PUB_KEY 0x25
 | 
			
		||||
#define HCI_OCF_LE_GENERATE_DHKEY          0x26
 | 
			
		||||
#define HCI_OCF_LE_ADD_DEV_RES_LIST        0x27
 | 
			
		||||
#define HCI_OCF_LE_REMOVE_DEV_RES_LIST     0x28
 | 
			
		||||
#define HCI_OCF_LE_CLEAR_RES_LIST          0x29
 | 
			
		||||
#define HCI_OCF_LE_READ_RES_LIST_SIZE      0x2A
 | 
			
		||||
#define HCI_OCF_LE_READ_PEER_RES_ADDR      0x2B
 | 
			
		||||
#define HCI_OCF_LE_READ_LOCAL_RES_ADDR     0x2C
 | 
			
		||||
#define HCI_OCF_LE_SET_ADDR_RES_ENABLE     0x2D
 | 
			
		||||
#define HCI_OCF_LE_SET_RES_PRIV_ADDR_TO    0x2E
 | 
			
		||||
#define HCI_OCF_LE_READ_MAX_DATA_LEN       0x2F
 | 
			
		||||
 | 
			
		||||
/*! Opcode manipulation macros */
 | 
			
		||||
#define HCI_OPCODE(ogf, ocf)               (((ogf) << 10) + (ocf))
 | 
			
		||||
#define HCI_OGF(opcode)                    ((opcode) >> 10)
 | 
			
		||||
#define HCI_OCF(opcode)                    ((opcode) & 0x03FF)
 | 
			
		||||
 | 
			
		||||
/*! Command opcodes */
 | 
			
		||||
#define HCI_OPCODE_NOP                        HCI_OPCODE(HCI_OGF_NOP, HCI_OCF_NOP)
 | 
			
		||||
 | 
			
		||||
#define HCI_OPCODE_DISCONNECT                 HCI_OPCODE(HCI_OGF_LINK_CONTROL, HCI_OCF_DISCONNECT)
 | 
			
		||||
#define HCI_OPCODE_READ_REMOTE_VER_INFO       HCI_OPCODE(HCI_OGF_LINK_CONTROL, HCI_OCF_READ_REMOTE_VER_INFO)
 | 
			
		||||
 | 
			
		||||
#define HCI_OPCODE_SET_EVENT_MASK             HCI_OPCODE(HCI_OGF_CONTROLLER, HCI_OCF_SET_EVENT_MASK)
 | 
			
		||||
#define HCI_OPCODE_RESET                      HCI_OPCODE(HCI_OGF_CONTROLLER, HCI_OCF_RESET)
 | 
			
		||||
#define HCI_OPCODE_READ_TX_PWR_LVL            HCI_OPCODE(HCI_OGF_CONTROLLER, HCI_OCF_READ_TX_PWR_LVL)
 | 
			
		||||
#define HCI_OPCODE_SET_EVENT_MASK_PAGE2       HCI_OPCODE(HCI_OGF_CONTROLLER, HCI_OCF_SET_EVENT_MASK_PAGE2)
 | 
			
		||||
#define HCI_OPCODE_READ_AUTH_PAYLOAD_TO       HCI_OPCODE(HCI_OGF_CONTROLLER, HCI_OCF_READ_AUTH_PAYLOAD_TO)
 | 
			
		||||
#define HCI_OPCODE_WRITE_AUTH_PAYLOAD_TO      HCI_OPCODE(HCI_OGF_CONTROLLER, HCI_OCF_WRITE_AUTH_PAYLOAD_TO)
 | 
			
		||||
 | 
			
		||||
#define HCI_OPCODE_READ_LOCAL_VER_INFO        HCI_OPCODE(HCI_OGF_INFORMATIONAL, HCI_OCF_READ_LOCAL_VER_INFO)
 | 
			
		||||
#define HCI_OPCODE_READ_LOCAL_SUP_CMDS        HCI_OPCODE(HCI_OGF_INFORMATIONAL, HCI_OCF_READ_LOCAL_SUP_CMDS)
 | 
			
		||||
#define HCI_OPCODE_READ_LOCAL_SUP_FEAT        HCI_OPCODE(HCI_OGF_INFORMATIONAL, HCI_OCF_READ_LOCAL_SUP_FEAT)
 | 
			
		||||
#define HCI_OPCODE_READ_BUF_SIZE              HCI_OPCODE(HCI_OGF_INFORMATIONAL, HCI_OCF_READ_BUF_SIZE)
 | 
			
		||||
#define HCI_OPCODE_READ_BD_ADDR               HCI_OPCODE(HCI_OGF_INFORMATIONAL, HCI_OCF_READ_BD_ADDR)
 | 
			
		||||
 | 
			
		||||
#define HCI_OPCODE_READ_RSSI                  HCI_OPCODE(HCI_OGF_STATUS, HCI_OCF_READ_RSSI)
 | 
			
		||||
 | 
			
		||||
#define HCI_OPCODE_LE_SET_EVENT_MASK          HCI_OPCODE(HCI_OGF_LE_CONTROLLER, HCI_OCF_LE_SET_EVENT_MASK)
 | 
			
		||||
#define HCI_OPCODE_LE_READ_BUF_SIZE           HCI_OPCODE(HCI_OGF_LE_CONTROLLER, HCI_OCF_LE_READ_BUF_SIZE)
 | 
			
		||||
#define HCI_OPCODE_LE_READ_LOCAL_SUP_FEAT     HCI_OPCODE(HCI_OGF_LE_CONTROLLER, HCI_OCF_LE_READ_LOCAL_SUP_FEAT)
 | 
			
		||||
#define HCI_OPCODE_LE_SET_RAND_ADDR           HCI_OPCODE(HCI_OGF_LE_CONTROLLER, HCI_OCF_LE_SET_RAND_ADDR)
 | 
			
		||||
#define HCI_OPCODE_LE_SET_ADV_PARAM           HCI_OPCODE(HCI_OGF_LE_CONTROLLER, HCI_OCF_LE_SET_ADV_PARAM)
 | 
			
		||||
#define HCI_OPCODE_LE_READ_ADV_TX_POWER       HCI_OPCODE(HCI_OGF_LE_CONTROLLER, HCI_OCF_LE_READ_ADV_TX_POWER)
 | 
			
		||||
#define HCI_OPCODE_LE_SET_ADV_DATA            HCI_OPCODE(HCI_OGF_LE_CONTROLLER, HCI_OCF_LE_SET_ADV_DATA)
 | 
			
		||||
#define HCI_OPCODE_LE_SET_SCAN_RESP_DATA      HCI_OPCODE(HCI_OGF_LE_CONTROLLER, HCI_OCF_LE_SET_SCAN_RESP_DATA)
 | 
			
		||||
#define HCI_OPCODE_LE_SET_ADV_ENABLE          HCI_OPCODE(HCI_OGF_LE_CONTROLLER, HCI_OCF_LE_SET_ADV_ENABLE)
 | 
			
		||||
#define HCI_OPCODE_LE_SET_SCAN_PARAM          HCI_OPCODE(HCI_OGF_LE_CONTROLLER, HCI_OCF_LE_SET_SCAN_PARAM)
 | 
			
		||||
#define HCI_OPCODE_LE_SET_SCAN_ENABLE         HCI_OPCODE(HCI_OGF_LE_CONTROLLER, HCI_OCF_LE_SET_SCAN_ENABLE)
 | 
			
		||||
#define HCI_OPCODE_LE_CREATE_CONN             HCI_OPCODE(HCI_OGF_LE_CONTROLLER, HCI_OCF_LE_CREATE_CONN)
 | 
			
		||||
#define HCI_OPCODE_LE_CREATE_CONN_CANCEL      HCI_OPCODE(HCI_OGF_LE_CONTROLLER, HCI_OCF_LE_CREATE_CONN_CANCEL)
 | 
			
		||||
#define HCI_OPCODE_LE_READ_WHITE_LIST_SIZE    HCI_OPCODE(HCI_OGF_LE_CONTROLLER, HCI_OCF_LE_READ_WHITE_LIST_SIZE)
 | 
			
		||||
#define HCI_OPCODE_LE_CLEAR_WHITE_LIST        HCI_OPCODE(HCI_OGF_LE_CONTROLLER, HCI_OCF_LE_CLEAR_WHITE_LIST)
 | 
			
		||||
#define HCI_OPCODE_LE_ADD_DEV_WHITE_LIST      HCI_OPCODE(HCI_OGF_LE_CONTROLLER, HCI_OCF_LE_ADD_DEV_WHITE_LIST)
 | 
			
		||||
#define HCI_OPCODE_LE_REMOVE_DEV_WHITE_LIST   HCI_OPCODE(HCI_OGF_LE_CONTROLLER, HCI_OCF_LE_REMOVE_DEV_WHITE_LIST)
 | 
			
		||||
#define HCI_OPCODE_LE_CONN_UPDATE             HCI_OPCODE(HCI_OGF_LE_CONTROLLER, HCI_OCF_LE_CONN_UPDATE)
 | 
			
		||||
#define HCI_OPCODE_LE_SET_HOST_CHAN_CLASS     HCI_OPCODE(HCI_OGF_LE_CONTROLLER, HCI_OCF_LE_SET_HOST_CHAN_CLASS)
 | 
			
		||||
#define HCI_OPCODE_LE_READ_CHAN_MAP           HCI_OPCODE(HCI_OGF_LE_CONTROLLER, HCI_OCF_LE_READ_CHAN_MAP)
 | 
			
		||||
#define HCI_OPCODE_LE_READ_REMOTE_FEAT        HCI_OPCODE(HCI_OGF_LE_CONTROLLER, HCI_OCF_LE_READ_REMOTE_FEAT)
 | 
			
		||||
#define HCI_OPCODE_LE_ENCRYPT                 HCI_OPCODE(HCI_OGF_LE_CONTROLLER, HCI_OCF_LE_ENCRYPT)
 | 
			
		||||
#define HCI_OPCODE_LE_RAND                    HCI_OPCODE(HCI_OGF_LE_CONTROLLER, HCI_OCF_LE_RAND)
 | 
			
		||||
#define HCI_OPCODE_LE_START_ENCRYPTION        HCI_OPCODE(HCI_OGF_LE_CONTROLLER, HCI_OCF_LE_START_ENCRYPTION)
 | 
			
		||||
#define HCI_OPCODE_LE_LTK_REQ_REPL            HCI_OPCODE(HCI_OGF_LE_CONTROLLER, HCI_OCF_LE_LTK_REQ_REPL)
 | 
			
		||||
#define HCI_OPCODE_LE_LTK_REQ_NEG_REPL        HCI_OPCODE(HCI_OGF_LE_CONTROLLER, HCI_OCF_LE_LTK_REQ_NEG_REPL)
 | 
			
		||||
#define HCI_OPCODE_LE_READ_SUP_STATES         HCI_OPCODE(HCI_OGF_LE_CONTROLLER, HCI_OCF_LE_READ_SUP_STATES)
 | 
			
		||||
#define HCI_OPCODE_LE_RECEIVER_TEST           HCI_OPCODE(HCI_OGF_LE_CONTROLLER, HCI_OCF_LE_RECEIVER_TEST)
 | 
			
		||||
#define HCI_OPCODE_LE_TRANSMITTER_TEST        HCI_OPCODE(HCI_OGF_LE_CONTROLLER, HCI_OCF_LE_TRANSMITTER_TEST)
 | 
			
		||||
#define HCI_OPCODE_LE_TEST_END                HCI_OPCODE(HCI_OGF_LE_CONTROLLER, HCI_OCF_LE_TEST_END)
 | 
			
		||||
#define HCI_OPCODE_LE_REM_CONN_PARAM_REP      HCI_OPCODE(HCI_OGF_LE_CONTROLLER, HCI_OCF_LE_REM_CONN_PARAM_REP)
 | 
			
		||||
#define HCI_OPCODE_LE_REM_CONN_PARAM_NEG_REP  HCI_OPCODE(HCI_OGF_LE_CONTROLLER, HCI_OCF_LE_REM_CONN_PARAM_NEG_REP)
 | 
			
		||||
#define HCI_OPCODE_LE_SET_DATA_LEN            HCI_OPCODE(HCI_OGF_LE_CONTROLLER, HCI_OCF_LE_SET_DATA_LEN)
 | 
			
		||||
#define HCI_OPCODE_LE_READ_DEF_DATA_LEN       HCI_OPCODE(HCI_OGF_LE_CONTROLLER, HCI_OCF_LE_READ_DEF_DATA_LEN)
 | 
			
		||||
#define HCI_OPCODE_LE_WRITE_DEF_DATA_LEN      HCI_OPCODE(HCI_OGF_LE_CONTROLLER, HCI_OCF_LE_WRITE_DEF_DATA_LEN)
 | 
			
		||||
#define HCI_OPCODE_LE_READ_LOCAL_P256_PUB_KEY HCI_OPCODE(HCI_OGF_LE_CONTROLLER, HCI_OCF_LE_READ_LOCAL_P256_PUB_KEY)
 | 
			
		||||
#define HCI_OPCODE_LE_GENERATE_DHKEY          HCI_OPCODE(HCI_OGF_LE_CONTROLLER, HCI_OCF_LE_GENERATE_DHKEY)
 | 
			
		||||
#define HCI_OPCODE_LE_ADD_DEV_RES_LIST        HCI_OPCODE(HCI_OGF_LE_CONTROLLER, HCI_OCF_LE_ADD_DEV_RES_LIST)
 | 
			
		||||
#define HCI_OPCODE_LE_REMOVE_DEV_RES_LIST     HCI_OPCODE(HCI_OGF_LE_CONTROLLER, HCI_OCF_LE_REMOVE_DEV_RES_LIST)
 | 
			
		||||
#define HCI_OPCODE_LE_CLEAR_RES_LIST          HCI_OPCODE(HCI_OGF_LE_CONTROLLER, HCI_OCF_LE_CLEAR_RES_LIST)
 | 
			
		||||
#define HCI_OPCODE_LE_READ_RES_LIST_SIZE      HCI_OPCODE(HCI_OGF_LE_CONTROLLER, HCI_OCF_LE_READ_RES_LIST_SIZE)
 | 
			
		||||
#define HCI_OPCODE_LE_READ_PEER_RES_ADDR      HCI_OPCODE(HCI_OGF_LE_CONTROLLER, HCI_OCF_LE_READ_PEER_RES_ADDR)
 | 
			
		||||
#define HCI_OPCODE_LE_READ_LOCAL_RES_ADDR     HCI_OPCODE(HCI_OGF_LE_CONTROLLER, HCI_OCF_LE_READ_LOCAL_RES_ADDR)
 | 
			
		||||
#define HCI_OPCODE_LE_SET_ADDR_RES_ENABLE     HCI_OPCODE(HCI_OGF_LE_CONTROLLER, HCI_OCF_LE_SET_ADDR_RES_ENABLE)
 | 
			
		||||
#define HCI_OPCODE_LE_SET_RES_PRIV_ADDR_TO    HCI_OPCODE(HCI_OGF_LE_CONTROLLER, HCI_OCF_LE_SET_RES_PRIV_ADDR_TO)
 | 
			
		||||
#define HCI_OPCODE_LE_READ_MAX_DATA_LEN       HCI_OPCODE(HCI_OGF_LE_CONTROLLER, HCI_OCF_LE_READ_MAX_DATA_LEN)
 | 
			
		||||
 | 
			
		||||
 | 
			
		||||
 | 
			
		||||
/*! Command parameter lengths */
 | 
			
		||||
#define HCI_LEN_NOP                        0
 | 
			
		||||
 | 
			
		||||
#define HCI_LEN_DISCONNECT                 3
 | 
			
		||||
#define HCI_LEN_READ_REMOTE_VER_INFO       2
 | 
			
		||||
 | 
			
		||||
#define HCI_LEN_SET_EVENT_MASK             8
 | 
			
		||||
#define HCI_LEN_SET_EVENT_MASK_PAGE2       8
 | 
			
		||||
#define HCI_LEN_RESET                      0
 | 
			
		||||
#define HCI_LEN_READ_TX_PWR_LVL            3
 | 
			
		||||
#define HCI_LEN_SET_CONTROLLER_TO_HOST_FC  1
 | 
			
		||||
#define HCI_LEN_HOST_BUFFER_SIZE           8
 | 
			
		||||
#define HCI_LEN_HOST_NUM_CMPL_PKTS         1
 | 
			
		||||
 | 
			
		||||
#define HCI_LEN_READ_LOCAL_VER_INFO        0
 | 
			
		||||
#define HCI_LEN_READ_LOCAL_SUP_CMDS        0
 | 
			
		||||
#define HCI_LEN_READ_LOCAL_SUP_FEAT        0
 | 
			
		||||
#define HCI_LEN_READ_BUF_SIZE              0
 | 
			
		||||
#define HCI_LEN_READ_BD_ADDR               0
 | 
			
		||||
 | 
			
		||||
#define HCI_LEN_READ_RSSI                  2
 | 
			
		||||
#define HCI_LEN_READ_AUTH_PAYLOAD_TO       2
 | 
			
		||||
#define HCI_LEN_WRITE_AUTH_PAYLOAD_TO      4
 | 
			
		||||
 | 
			
		||||
#define HCI_LEN_LE_SET_EVENT_MASK          8
 | 
			
		||||
#define HCI_LEN_LE_READ_BUF_SIZE           0
 | 
			
		||||
#define HCI_LEN_LE_READ_LOCAL_SUP_FEAT     0
 | 
			
		||||
#define HCI_LEN_LE_SET_RAND_ADDR           6
 | 
			
		||||
#define HCI_LEN_LE_SET_ADV_PARAM           15
 | 
			
		||||
#define HCI_LEN_LE_READ_ADV_TX_POWER       0
 | 
			
		||||
#define HCI_LEN_LE_SET_ADV_DATA            32
 | 
			
		||||
#define HCI_LEN_LE_SET_SCAN_RESP_DATA      32
 | 
			
		||||
#define HCI_LEN_LE_SET_ADV_ENABLE          1
 | 
			
		||||
#define HCI_LEN_LE_SET_SCAN_PARAM          7
 | 
			
		||||
#define HCI_LEN_LE_SET_SCAN_ENABLE         2
 | 
			
		||||
#define HCI_LEN_LE_CREATE_CONN             25
 | 
			
		||||
#define HCI_LEN_LE_CREATE_CONN_CANCEL      0
 | 
			
		||||
#define HCI_LEN_LE_READ_WHITE_LIST_SIZE    0
 | 
			
		||||
#define HCI_LEN_LE_CLEAR_WHITE_LIST        0
 | 
			
		||||
#define HCI_LEN_LE_ADD_DEV_WHITE_LIST      7
 | 
			
		||||
#define HCI_LEN_LE_REMOVE_DEV_WHITE_LIST   7
 | 
			
		||||
#define HCI_LEN_LE_CONN_UPDATE             14
 | 
			
		||||
#define HCI_LEN_LE_SET_HOST_CHAN_CLASS     5
 | 
			
		||||
#define HCI_LEN_LE_READ_CHAN_MAP           2
 | 
			
		||||
#define HCI_LEN_LE_READ_REMOTE_FEAT        2
 | 
			
		||||
#define HCI_LEN_LE_ENCRYPT                 32
 | 
			
		||||
#define HCI_LEN_LE_RAND                    0
 | 
			
		||||
#define HCI_LEN_LE_START_ENCRYPTION        28
 | 
			
		||||
#define HCI_LEN_LE_LTK_REQ_REPL            18
 | 
			
		||||
#define HCI_LEN_LE_LTK_REQ_NEG_REPL        2
 | 
			
		||||
#define HCI_LEN_LE_READ_SUP_STATES         0
 | 
			
		||||
#define HCI_LEN_LE_RECEIVER_TEST           1
 | 
			
		||||
#define HCI_LEN_LE_TRANSMITTER_TEST        3
 | 
			
		||||
#define HCI_LEN_LE_TEST_END                0
 | 
			
		||||
#define HCI_LEN_LE_READ_LOCAL_P256_PUB_KEY 0
 | 
			
		||||
#define HCI_LEN_LE_GENERATE_MAX_DATA       64
 | 
			
		||||
#define HCI_LEN_LE_ADD_DEV_RES_LIST        39
 | 
			
		||||
#define HCI_LEN_LE_REMOVE_DEV_RES_LIST     7
 | 
			
		||||
#define HCI_LEN_LE_CLEAR_RES_LIST          0
 | 
			
		||||
#define HCI_LEN_LE_READ_RES_LIST_SIZE      0
 | 
			
		||||
#define HCI_LEN_LE_READ_PEER_RES_ADDR      7
 | 
			
		||||
#define HCI_LEN_LE_READ_LOCAL_RES_ADDR     7
 | 
			
		||||
#define HCI_LEN_LE_SET_ADDR_RES_ENABLE     1
 | 
			
		||||
#define HCI_LEN_LE_SET_RES_PRIV_ADDR_TO    2
 | 
			
		||||
#define HCI_LEN_LE_REM_CONN_PARAM_REP      14
 | 
			
		||||
#define HCI_LEN_LE_REM_CONN_PARAM_NEG_REP  3
 | 
			
		||||
#define HCI_LEN_LE_SET_DATA_LEN            6
 | 
			
		||||
#define HCI_LEN_LE_READ_DEF_DATA_LEN       0
 | 
			
		||||
#define HCI_LEN_LE_WRITE_DEF_DATA_LEN      4
 | 
			
		||||
#define HCI_LEN_LE_READ_LOCAL_P256_PUB_KEY 0
 | 
			
		||||
#define HCI_LEN_LE_GENERATE_DHKEY          64
 | 
			
		||||
#define HCI_LEN_LE_READ_MAX_DATA_LEN       0
 | 
			
		||||
 | 
			
		||||
/*! Events */
 | 
			
		||||
#define HCI_DISCONNECT_CMPL_EVT           0x05
 | 
			
		||||
#define HCI_ENC_CHANGE_EVT                0x08
 | 
			
		||||
#define HCI_READ_REMOTE_VER_INFO_CMPL_EVT 0x0C
 | 
			
		||||
#define HCI_CMD_CMPL_EVT                  0x0E
 | 
			
		||||
#define HCI_CMD_STATUS_EVT                0x0F
 | 
			
		||||
#define HCI_HW_ERROR_EVT                  0x10
 | 
			
		||||
#define HCI_NUM_CMPL_PKTS_EVT             0x13
 | 
			
		||||
#define HCI_DATA_BUF_OVERFLOW_EVT         0x1A
 | 
			
		||||
#define HCI_ENC_KEY_REFRESH_CMPL_EVT      0x30
 | 
			
		||||
#define HCI_LE_META_EVT                   0x3E
 | 
			
		||||
#define HCI_AUTH_PAYLOAD_TIMEOUT_EVT      0x57
 | 
			
		||||
#define HCI_VENDOR_SPEC_EVT               0xFF
 | 
			
		||||
 | 
			
		||||
/*! LE Subevents */
 | 
			
		||||
#define HCI_LE_CONN_CMPL_EVT              0x01
 | 
			
		||||
#define HCI_LE_ADV_REPORT_EVT             0x02
 | 
			
		||||
#define HCI_LE_CONN_UPDATE_CMPL_EVT       0x03
 | 
			
		||||
#define HCI_LE_READ_REMOTE_FEAT_CMPL_EVT  0x04
 | 
			
		||||
#define HCI_LE_LTK_REQ_EVT                0x05
 | 
			
		||||
/* New in version 4.1 */
 | 
			
		||||
#define HCI_LE_REM_CONN_PARAM_REQ_EVT     0x06
 | 
			
		||||
/* New in version 4.2 */
 | 
			
		||||
#define HCI_LE_DATA_LEN_CHANGE_EVT              0x07
 | 
			
		||||
#define HCI_LE_READ_LOCAL_P256_PUB_KEY_CMPL_EVT 0x08
 | 
			
		||||
#define HCI_LE_GENERATE_DHKEY_CMPL_EVT          0x09
 | 
			
		||||
#define HCI_LE_ENHANCED_CONN_CMPL_EVT           0x0A
 | 
			
		||||
#define HCI_LE_DIRECT_ADV_REPORT_EVT            0x0B
 | 
			
		||||
 | 
			
		||||
/*! Event parameter lengths */
 | 
			
		||||
#define HCI_LEN_DISCONNECT_CMPL           4
 | 
			
		||||
#define HCI_LEN_CMD_CMPL                  3
 | 
			
		||||
#define HCI_LEN_CMD_STATUS                4
 | 
			
		||||
#define HCI_LEN_HW_ERR                    1
 | 
			
		||||
#define HCI_LEN_ENC_CHANGE                4
 | 
			
		||||
#define HCI_LEN_LE_CONN_CMPL              19
 | 
			
		||||
#define HCI_LEN_LE_CONN_UPDATE_CMPL       9
 | 
			
		||||
#define HCI_LEN_LE_READ_REMOTE_FEAT_CMPL  12
 | 
			
		||||
#define HCI_LEN_LE_LTK_REQ                13
 | 
			
		||||
 | 
			
		||||
/*! Supported commands */
 | 
			
		||||
#define HCI_SUP_DISCONNECT                     0x20   /*! Byte 0 */
 | 
			
		||||
#define HCI_SUP_READ_REMOTE_VER_INFO           0x80   /*! Byte 2 */
 | 
			
		||||
#define HCI_SUP_SET_EVENT_MASK                 0x40   /*! Byte 5 */
 | 
			
		||||
#define HCI_SUP_RESET                          0x80   /*! Byte 5 */
 | 
			
		||||
#define HCI_SUP_READ_TX_PWR_LVL                0x04   /*! Byte 10 */
 | 
			
		||||
#define HCI_SUP_READ_LOCAL_VER_INFO            0x08   /*! Byte 14 */
 | 
			
		||||
#define HCI_SUP_READ_LOCAL_SUP_FEAT            0x20   /*! Byte 14 */
 | 
			
		||||
#define HCI_SUP_READ_BD_ADDR                   0x02   /*! Byte 15 */
 | 
			
		||||
#define HCI_SUP_READ_RSSI                      0x20   /*! Byte 15 */
 | 
			
		||||
#define HCI_SUP_SET_EVENT_MASK_PAGE2           0x04   /*! Byte 22 */
 | 
			
		||||
#define HCI_SUP_LE_SET_EVENT_MASK              0x01   /*! Byte 25 */
 | 
			
		||||
#define HCI_SUP_LE_READ_BUF_SIZE               0x02   /*! Byte 25 */
 | 
			
		||||
#define HCI_SUP_LE_READ_LOCAL_SUP_FEAT         0x04   /*! Byte 25 */
 | 
			
		||||
#define HCI_SUP_LE_SET_RAND_ADDR               0x10   /*! Byte 25 */
 | 
			
		||||
#define HCI_SUP_LE_SET_ADV_PARAM               0x20   /*! Byte 25 */
 | 
			
		||||
#define HCI_SUP_LE_READ_ADV_TX_POWER           0x40   /*! Byte 25 */
 | 
			
		||||
#define HCI_SUP_LE_SET_ADV_DATA                0x80   /*! Byte 25 */
 | 
			
		||||
#define HCI_SUP_LE_SET_SCAN_RESP_DATA          0x01   /*! Byte 26 */
 | 
			
		||||
#define HCI_SUP_LE_SET_ADV_ENABLE              0x02   /*! Byte 26 */
 | 
			
		||||
#define HCI_SUP_LE_SET_SCAN_PARAM              0x04   /*! Byte 26 */
 | 
			
		||||
#define HCI_SUP_LE_SET_SCAN_ENABLE             0x08   /*! Byte 26 */
 | 
			
		||||
#define HCI_SUP_LE_CREATE_CONN                 0x10   /*! Byte 26 */
 | 
			
		||||
#define HCI_SUP_LE_CREATE_CONN_CANCEL          0x20   /*! Byte 26 */
 | 
			
		||||
#define HCI_SUP_LE_READ_WHITE_LIST_SIZE        0x40   /*! Byte 26 */
 | 
			
		||||
#define HCI_SUP_LE_CLEAR_WHITE_LIST            0x80   /*! Byte 26 */
 | 
			
		||||
#define HCI_SUP_LE_ADD_DEV_WHITE_LIST          0x01   /*! Byte 27 */
 | 
			
		||||
#define HCI_SUP_LE_REMOVE_DEV_WHITE_LIST       0x02   /*! Byte 27 */
 | 
			
		||||
#define HCI_SUP_LE_CONN_UPDATE                 0x04   /*! Byte 27 */
 | 
			
		||||
#define HCI_SUP_LE_SET_HOST_CHAN_CLASS         0x08   /*! Byte 27 */
 | 
			
		||||
#define HCI_SUP_LE_READ_CHAN_MAP               0x10   /*! Byte 27 */
 | 
			
		||||
#define HCI_SUP_LE_READ_REMOTE_FEAT            0x20   /*! Byte 27 */
 | 
			
		||||
#define HCI_SUP_LE_ENCRYPT                     0x40   /*! Byte 27 */
 | 
			
		||||
#define HCI_SUP_LE_RAND                        0x80   /*! Byte 27 */
 | 
			
		||||
#define HCI_SUP_LE_START_ENCRYPTION            0x01   /*! Byte 28 */
 | 
			
		||||
#define HCI_SUP_LE_LTK_REQ_REPL                0x02   /*! Byte 28 */
 | 
			
		||||
#define HCI_SUP_LE_LTK_REQ_NEG_REPL            0x04   /*! Byte 28 */
 | 
			
		||||
#define HCI_SUP_LE_READ_SUP_STATES             0x08   /*! Byte 28 */
 | 
			
		||||
#define HCI_SUP_LE_RECEIVER_TEST               0x10   /*! Byte 28 */
 | 
			
		||||
#define HCI_SUP_LE_TRANSMITTER_TEST            0x20   /*! Byte 28 */
 | 
			
		||||
#define HCI_SUP_LE_TEST_END                    0x40   /*! Byte 28 */
 | 
			
		||||
#define HCI_SUP_READ_AUTH_PAYLOAD_TO           0x10   /*! Byte 32 */
 | 
			
		||||
#define HCI_SUP_WRITE_AUTH_PAYLOAD_TO          0x20   /*! Byte 32 */
 | 
			
		||||
#define HCI_SUP_LE_REM_CONN_PARAM_REQ_REPL     0x10   /*! Byte 33 */
 | 
			
		||||
#define HCI_SUP_LE_REM_CONN_PARAM_REQ_NEG_REPL 0x20   /*! Byte 33 */
 | 
			
		||||
#define HCI_SUP_LE_SET_DATA_LEN                0x40   /*! Byte 33 */
 | 
			
		||||
#define HCI_SUP_LE_READ_DEF_DATA_LEN           0x80   /*! Byte 33 */
 | 
			
		||||
#define HCI_SUP_LE_WRITE_DEF_DATA_LEN          0x01   /*! Byte 34 */
 | 
			
		||||
#define HCI_SUP_LE_READ_LOCAL_P256_PUB_KEY     0x02   /*! Byte 34 */
 | 
			
		||||
#define HCI_SUP_LE_GENERATE_DHKEY              0x04   /*! Byte 34 */
 | 
			
		||||
#define HCI_SUP_LE_ADD_DEV_RES_LIST_EVT        0x08   /*! Byte 34 */
 | 
			
		||||
#define HCI_SUP_LE_REMOVE_DEV_RES_LIST         0x10   /*! Byte 34 */
 | 
			
		||||
#define HCI_SUP_LE_CLEAR_RES_LIST              0x20   /*! Byte 34 */
 | 
			
		||||
#define HCI_SUP_LE_READ_RES_LIST_SIZE          0x40   /*! Byte 34 */
 | 
			
		||||
#define HCI_SUP_LE_READ_PEER_RES_ADDR          0x80   /*! Byte 34 */
 | 
			
		||||
#define HCI_SUP_LE_READ_LOCAL_RES_ADDR         0x01   /*! Byte 35 */
 | 
			
		||||
#define HCI_SUP_LE_SET_ADDR_RES_ENABLE         0x02   /*! Byte 35 */
 | 
			
		||||
#define HCI_SUP_LE_SET_RES_PRIV_ADDR_TO        0x04   /*! Byte 35 */
 | 
			
		||||
#define HCI_SUP_LE_READ_MAX_DATA_LEN           0x08   /*! Byte 35 */
 | 
			
		||||
 | 
			
		||||
/*! Event mask */
 | 
			
		||||
#define HCI_EVT_MASK_DISCONNECT_CMPL           0x10   /*! Byte 0 */
 | 
			
		||||
#define HCI_EVT_MASK_ENC_CHANGE                0x80   /*! Byte 0 */
 | 
			
		||||
#define HCI_EVT_MASK_READ_REMOTE_VER_INFO_CMPL 0x08   /*! Byte 1 */
 | 
			
		||||
#define HCI_EVT_MASK_HW_ERROR                  0x80   /*! Byte 1 */
 | 
			
		||||
#define HCI_EVT_MASK_DATA_BUF_OVERFLOW         0x02   /*! Byte 3 */
 | 
			
		||||
#define HCI_EVT_MASK_ENC_KEY_REFRESH_CMPL      0x80   /*! Byte 5 */
 | 
			
		||||
#define HCI_EVT_MASK_LE_META                   0x20   /*! Byte 7 */
 | 
			
		||||
 | 
			
		||||
/*! Event mask page 2 */
 | 
			
		||||
#define HCI_EVT_MASK_AUTH_PAYLOAD_TIMEOUT      0x80   /*! Byte 2 */
 | 
			
		||||
 | 
			
		||||
/*! LE event mask */
 | 
			
		||||
#define HCI_EVT_MASK_LE_CONN_CMPL_EVT                0x01   /*! Byte 0 */
 | 
			
		||||
#define HCI_EVT_MASK_LE_ADV_REPORT_EVT               0x02   /*! Byte 0 */
 | 
			
		||||
#define HCI_EVT_MASK_LE_CONN_UPDATE_CMPL_EVT         0x04   /*! Byte 0 */
 | 
			
		||||
#define HCI_EVT_MASK_LE_READ_REMOTE_FEAT_CMPL_EVT    0x08   /*! Byte 0 */
 | 
			
		||||
#define HCI_EVT_MASK_LE_LTK_REQ_EVT                  0x10   /*! Byte 0 */
 | 
			
		||||
#define HCI_EVT_MASK_LE_REMOTE_CONN_PARAM_REQ_EVT    0x20   /*! Byte 0 */
 | 
			
		||||
#define HCI_EVT_MASK_LE_DATA_LEN_CHANGE_EVT          0x40   /*! Byte 0 */
 | 
			
		||||
#define HCI_EVT_MASK_LE_READ_LOCAL_P256_PUB_KEY_CMPL 0x80   /*! Byte 0 */
 | 
			
		||||
#define HCI_EVT_MASK_LE_GENERATE_DHKEY_CMPL          0x01   /*! Byte 1 */
 | 
			
		||||
#define HCI_EVT_MASK_LE_ENHANCED_CONN_CMPL_EVT       0x02   /*! Byte 1 */
 | 
			
		||||
#define HCI_EVT_MASK_LE_DIRECT_ADV_REPORT_EVT        0x04   /*! Byte 1 */
 | 
			
		||||
 | 
			
		||||
/*! LE supported features */
 | 
			
		||||
#define HCI_LE_SUP_FEAT_ENCRYPTION                   0x01   /*! Encryption supported */
 | 
			
		||||
#define HCI_LE_SUP_FEAT_CONN_PARAM_REQ_PROC          0x02   /*! Connection Parameters Request Procedure supported */
 | 
			
		||||
#define HCI_LE_SUP_FEAT_EXT_REJECT_IND               0x04   /*! Extended Reject Indication supported */
 | 
			
		||||
#define HCI_LE_SUP_FEAT_SLV_INIT_FEAT_EXCH           0x08   /*! Slave-Initiated Features Exchange supported */
 | 
			
		||||
#define HCI_LE_SUP_FEAT_LE_PING                      0x10   /*! LE Ping supported */
 | 
			
		||||
#define HCI_LE_SUP_FEAT_DATA_LEN_EXT                 0x20   /*! Data Length Extension supported */
 | 
			
		||||
#define HCI_LE_SUP_FEAT_PRIVACY                      0x40   /*! LL Privacy supported */
 | 
			
		||||
#define HCI_LE_SUP_FEAT_EXT_SCAN_FILT_POLICY         0x80   /*! Extended Scan Filter Policy supported */
 | 
			
		||||
 | 
			
		||||
/*! Advertising command parameters */
 | 
			
		||||
#define HCI_ADV_MIN_INTERVAL              0x0020    /*! Minimum advertising interval */
 | 
			
		||||
#define HCI_ADV_NONCONN_MIN_INTERVAL      0x00A0    /*! Minimum nonconnectable adv. interval */
 | 
			
		||||
#define HCI_ADV_MAX_INTERVAL              0x4000    /*! Maximum advertising interval */
 | 
			
		||||
#define HCI_ADV_TYPE_CONN_UNDIRECT        0x00      /*! Connectable undirected advertising */
 | 
			
		||||
#define HCI_ADV_TYPE_CONN_DIRECT          0x01      /*! Connectable directed high duty cycle advertising */
 | 
			
		||||
#define HCI_ADV_TYPE_DISC_UNDIRECT        0x02      /*! Discoverable undirected advertising */
 | 
			
		||||
#define HCI_ADV_TYPE_NONCONN_UNDIRECT     0x03      /*! Nonconnectable undirected advertising */
 | 
			
		||||
#define HCI_ADV_TYPE_CONN_DIRECT_LO_DUTY  0x04      /*! Connectable directed low duty cycle advertising */
 | 
			
		||||
#define HCI_ADV_CHAN_37                   0x01      /*! Advertising channel 37 */
 | 
			
		||||
#define HCI_ADV_CHAN_38                   0x02      /*! Advertising channel 38 */
 | 
			
		||||
#define HCI_ADV_CHAN_39                   0x04      /*! Advertising channel 39 */
 | 
			
		||||
#define HCI_ADV_FILT_NONE                 0x00      /*! No scan request or connection filtering */
 | 
			
		||||
#define HCI_ADV_FILT_SCAN                 0x01      /*! White list filters scan requests */
 | 
			
		||||
#define HCI_ADV_FILT_CONN                 0x02      /*! White list filters connections */
 | 
			
		||||
#define HCI_ADV_FILT_ALL                  0x03      /*! White list filters scan req. and conn. */
 | 
			
		||||
 | 
			
		||||
/*! Scan command parameters */
 | 
			
		||||
#define HCI_SCAN_TYPE_PASSIVE             0         /*! Passive scan */
 | 
			
		||||
#define HCI_SCAN_TYPE_ACTIVE              1         /*! Active scan */
 | 
			
		||||
#define HCI_SCAN_INTERVAL_MIN             0x0004    /*! Minimum scan interval */
 | 
			
		||||
#define HCI_SCAN_INTERVAL_MAX             0x4000    /*! Maximum scan interval */
 | 
			
		||||
#define HCI_SCAN_INTERVAL_DEFAULT         0x0010    /*! Default scan interval */
 | 
			
		||||
#define HCI_SCAN_WINDOW_MIN               0x0004    /*! Minimum scan window */
 | 
			
		||||
#define HCI_SCAN_WINDOW_MAX               0x4000    /*! Maximum scan window */
 | 
			
		||||
#define HCI_SCAN_WINDOW_DEFAULT           0x0010    /*! Default scan window */
 | 
			
		||||
 | 
			
		||||
/*! Connection command parameters */
 | 
			
		||||
#define HCI_CONN_INTERVAL_MIN             0x0006    /*! Minimum connection interval */
 | 
			
		||||
#define HCI_CONN_INTERVAL_MAX             0x0C80    /*! Maximum connection interval */
 | 
			
		||||
#define HCI_CONN_LATENCY_MAX              0x01F3    /*! Maximum connection latency */
 | 
			
		||||
#define HCI_SUP_TIMEOUT_MIN               0x000A    /*! Minimum supervision timeout */
 | 
			
		||||
#define HCI_SUP_TIMEOUT_MAX               0x0C80    /*! Maximum supervision timeout */
 | 
			
		||||
 | 
			
		||||
/*! Connection event parameters */
 | 
			
		||||
#define HCI_ROLE_MASTER                   0         /*! Role is master */
 | 
			
		||||
#define HCI_ROLE_SLAVE                    1         /*! Role is slave */
 | 
			
		||||
#define HCI_CLOCK_500PPM                  0x00      /*! 500 ppm clock accuracy */
 | 
			
		||||
#define HCI_CLOCK_250PPM                  0x01      /*! 250 ppm clock accuracy */
 | 
			
		||||
#define HCI_CLOCK_150PPM                  0x02      /*! 150 ppm clock accuracy */
 | 
			
		||||
#define HCI_CLOCK_100PPM                  0x03      /*! 100 ppm clock accuracy */
 | 
			
		||||
#define HCI_CLOCK_75PPM                   0x04      /*! 75 ppm clock accuracy */
 | 
			
		||||
#define HCI_CLOCK_50PPM                   0x05      /*! 50 ppm clock accuracy */
 | 
			
		||||
#define HCI_CLOCK_30PPM                   0x06      /*! 30 ppm clock accuracy */
 | 
			
		||||
#define HCI_CLOCK_20PPM                   0x07      /*! 20 ppm clock accuracy */
 | 
			
		||||
 | 
			
		||||
/*! Advertising report event parameters */
 | 
			
		||||
#define HCI_ADV_CONN_UNDIRECT             0x00      /*! Connectable undirected advertising */
 | 
			
		||||
#define HCI_ADV_CONN_DIRECT               0x01      /*! Connectable directed advertising */
 | 
			
		||||
#define HCI_ADV_DISC_UNDIRECT             0x02      /*! Discoverable undirected advertising */
 | 
			
		||||
#define HCI_ADV_NONCONN_UNDIRECT          0x03      /*! Non-connectable undirected advertising */
 | 
			
		||||
#define HCI_ADV_SCAN_RESPONSE             0x04      /*! Scan response */
 | 
			
		||||
 | 
			
		||||
/*! Misc command parameters */
 | 
			
		||||
#define HCI_READ_TX_PWR_CURRENT           0         /*! Read current tx power */
 | 
			
		||||
#define HCI_READ_TX_PWR_MAX               1         /*! Read maximum tx power */
 | 
			
		||||
#define HCI_TX_PWR_MIN                    -30       /*! Minimum tx power dBm */
 | 
			
		||||
#define HCI_TX_PWR_MAX                    20        /*! Maximum tx power dBm */
 | 
			
		||||
#define HCI_VERSION                       6         /*! HCI specification version */
 | 
			
		||||
#define HCI_RSSI_MIN                      -127      /*! Minimum RSSI dBm */
 | 
			
		||||
#define HCI_RSSI_MAX                      20        /*! Maximum RSSI dBm */
 | 
			
		||||
#define HCI_ADDR_TYPE_PUBLIC              0         /*! Public device address */
 | 
			
		||||
#define HCI_ADDR_TYPE_RANDOM              1         /*! Random device address */
 | 
			
		||||
#define HCI_ADDR_TYPE_PUBLIC_IDENTITY     2         /*! Public identity address. */
 | 
			
		||||
#define HCI_ADDR_TYPE_RANDOM_IDENTITY     3         /*! Random identity address. */
 | 
			
		||||
#define HCI_FILT_NONE                     0         /*! Accept all advertising packets */
 | 
			
		||||
#define HCI_FILT_WHITE_LIST               1         /*! Accept from While List only */
 | 
			
		||||
#define HCI_FILT_RES_INIT                 2         /*! Accept directed advertisements with RPAs */
 | 
			
		||||
#define HCI_FILT_WHITE_LIST_RES_INIT      3         /*! Accept from White List or directed advertisements with RPAs */
 | 
			
		||||
#define HCI_ROLE_MASTER                   0         /*! Role is master */
 | 
			
		||||
#define HCI_ROLE_SLAVE                    1         /*! Role is slave */
 | 
			
		||||
 | 
			
		||||
/*! Parameter lengths */
 | 
			
		||||
#define HCI_EVT_MASK_LEN                  8         /*! Length of event mask byte array */
 | 
			
		||||
#define HCI_EVT_MASK_PAGE_2_LEN           8         /*! Length of event mask page 2 byte array */
 | 
			
		||||
#define HCI_LE_EVT_MASK_LEN               8         /*! Length of LE event mask byte array */
 | 
			
		||||
#define HCI_FEAT_LEN                      8         /*! Length of features byte array */
 | 
			
		||||
#define HCI_ADV_DATA_LEN                  31        /*! Length of advertising data */
 | 
			
		||||
#define HCI_SCAN_DATA_LEN                 31        /*! Length of scan response data */
 | 
			
		||||
#define HCI_CHAN_MAP_LEN                  5         /*! Length of channel map byte array */
 | 
			
		||||
#define HCI_KEY_LEN                       16        /*! Length of encryption key */
 | 
			
		||||
#define HCI_ENCRYPT_DATA_LEN              16        /*! Length of data used in encryption */
 | 
			
		||||
#define HCI_RAND_LEN                      8         /*! Length of random number */
 | 
			
		||||
#define HCI_LE_STATES_LEN                 8         /*! Length of LE states byte array */
 | 
			
		||||
#define HCI_P256_KEY_LEN                  64        /*! Length of P256 key */
 | 
			
		||||
#define HCI_DH_KEY_LEN                    32        /*! Length of DH Key */
 | 
			
		||||
 | 
			
		||||
/*! Wicentric company ID */
 | 
			
		||||
#define HCI_ID_WICENTRIC                  0x005F
 | 
			
		||||
 | 
			
		||||
#ifdef __cplusplus
 | 
			
		||||
};
 | 
			
		||||
#endif
 | 
			
		||||
 | 
			
		||||
#endif /* HCI_DEFS_H */
 | 
			
		||||
| 
						 | 
				
			
			@ -1,80 +0,0 @@
 | 
			
		|||
/*************************************************************************************************/
 | 
			
		||||
/*!
 | 
			
		||||
 *  \file   cfg_stack.h
 | 
			
		||||
 *
 | 
			
		||||
 *  \brief  Stack configuration.
 | 
			
		||||
 *
 | 
			
		||||
 *          $Date: 2015-06-12 04:19:18 -0700 (Fri, 12 Jun 2015) $
 | 
			
		||||
 *          $Revision: 3061 $
 | 
			
		||||
 *
 | 
			
		||||
 *  Copyright (c) 2009 Wicentric, Inc., all rights reserved.
 | 
			
		||||
 *  Wicentric confidential and proprietary.
 | 
			
		||||
 *
 | 
			
		||||
 *  IMPORTANT.  Your use of this file is governed by a Software License Agreement
 | 
			
		||||
 *  ("Agreement") that must be accepted in order to download or otherwise receive a
 | 
			
		||||
 *  copy of this file.  You may not use or copy this file for any purpose other than
 | 
			
		||||
 *  as described in the Agreement.  If you do not agree to all of the terms of the
 | 
			
		||||
 *  Agreement do not use this file and delete all copies in your possession or control;
 | 
			
		||||
 *  if you do not have a copy of the Agreement, you must contact Wicentric, Inc. prior
 | 
			
		||||
 *  to any use, copying or further distribution of this software.
 | 
			
		||||
 */
 | 
			
		||||
/*************************************************************************************************/
 | 
			
		||||
#ifndef CFG_STACK_H
 | 
			
		||||
#define CFG_STACK_H
 | 
			
		||||
 | 
			
		||||
 | 
			
		||||
#ifdef __cplusplus
 | 
			
		||||
extern "C" {
 | 
			
		||||
#endif
 | 
			
		||||
 | 
			
		||||
/**************************************************************************************************
 | 
			
		||||
  HCI
 | 
			
		||||
**************************************************************************************************/
 | 
			
		||||
 | 
			
		||||
/*! Vendor specific targets */
 | 
			
		||||
#define HCI_VS_GENERIC        0
 | 
			
		||||
#define HCI_VS_EMM            1
 | 
			
		||||
 | 
			
		||||
/*! Vendor specific target configuration */
 | 
			
		||||
#ifndef HCI_VS_TARGET
 | 
			
		||||
#define HCI_VS_TARGET HCI_VS_GENERIC
 | 
			
		||||
#endif
 | 
			
		||||
 | 
			
		||||
/**************************************************************************************************
 | 
			
		||||
  DM
 | 
			
		||||
**************************************************************************************************/
 | 
			
		||||
 | 
			
		||||
/*! Maximum number of connections */
 | 
			
		||||
#ifndef DM_CONN_MAX
 | 
			
		||||
#define DM_CONN_MAX 3
 | 
			
		||||
#endif
 | 
			
		||||
 | 
			
		||||
/**************************************************************************************************
 | 
			
		||||
  L2C
 | 
			
		||||
**************************************************************************************************/
 | 
			
		||||
 | 
			
		||||
/*! Maximum number of connection oriented channels */
 | 
			
		||||
#ifndef L2C_COC_CHAN_MAX
 | 
			
		||||
#define L2C_COC_CHAN_MAX 8
 | 
			
		||||
#endif
 | 
			
		||||
 | 
			
		||||
/*! Maximum number of connection oriented channel registered clients */
 | 
			
		||||
#ifndef L2C_COC_REG_MAX
 | 
			
		||||
#define L2C_COC_REG_MAX 4
 | 
			
		||||
#endif
 | 
			
		||||
 | 
			
		||||
/**************************************************************************************************
 | 
			
		||||
  ATT
 | 
			
		||||
**************************************************************************************************/
 | 
			
		||||
 | 
			
		||||
/**************************************************************************************************
 | 
			
		||||
  SMP
 | 
			
		||||
**************************************************************************************************/
 | 
			
		||||
 | 
			
		||||
 | 
			
		||||
 | 
			
		||||
#ifdef __cplusplus
 | 
			
		||||
};
 | 
			
		||||
#endif
 | 
			
		||||
 | 
			
		||||
#endif /* CFG_STACK_H */
 | 
			
		||||
| 
						 | 
				
			
			@ -1,942 +0,0 @@
 | 
			
		|||
/*************************************************************************************************/
 | 
			
		||||
/*!
 | 
			
		||||
 *  \file   att_api.h
 | 
			
		||||
 *
 | 
			
		||||
 *  \brief  Attribute protocol client and server API.
 | 
			
		||||
 *
 | 
			
		||||
 *          $Date: 2016-01-06 07:40:44 -0800 (Wed, 06 Jan 2016) $
 | 
			
		||||
 *          $Revision: 5284 $
 | 
			
		||||
 *
 | 
			
		||||
 *  Copyright (c) 2009 Wicentric, Inc., all rights reserved.
 | 
			
		||||
 *  Wicentric confidential and proprietary.
 | 
			
		||||
 *
 | 
			
		||||
 *  IMPORTANT.  Your use of this file is governed by a Software License Agreement
 | 
			
		||||
 *  ("Agreement") that must be accepted in order to download or otherwise receive a
 | 
			
		||||
 *  copy of this file.  You may not use or copy this file for any purpose other than
 | 
			
		||||
 *  as described in the Agreement.  If you do not agree to all of the terms of the
 | 
			
		||||
 *  Agreement do not use this file and delete all copies in your possession or control;
 | 
			
		||||
 *  if you do not have a copy of the Agreement, you must contact Wicentric, Inc. prior
 | 
			
		||||
 *  to any use, copying or further distribution of this software.
 | 
			
		||||
 */
 | 
			
		||||
/*************************************************************************************************/
 | 
			
		||||
#ifndef ATT_API_H
 | 
			
		||||
#define ATT_API_H
 | 
			
		||||
 | 
			
		||||
#include "wsf_timer.h"
 | 
			
		||||
#include "att_defs.h"
 | 
			
		||||
#include "att_uuid.h"
 | 
			
		||||
#include "dm_api.h"
 | 
			
		||||
#include "cfg_stack.h"
 | 
			
		||||
 | 
			
		||||
#ifdef __cplusplus
 | 
			
		||||
extern "C" {
 | 
			
		||||
#endif
 | 
			
		||||
 | 
			
		||||
/**************************************************************************************************
 | 
			
		||||
  Macros
 | 
			
		||||
**************************************************************************************************/
 | 
			
		||||
 | 
			
		||||
/*! ATT server attribute settings */
 | 
			
		||||
#define ATTS_SET_UUID_128           0x01    /*! Set if the UUID is 128 bits in length */
 | 
			
		||||
#define ATTS_SET_WRITE_CBACK        0x02    /*! Set if the group callback is executed when
 | 
			
		||||
                                                this attribute is written by a client device */
 | 
			
		||||
#define ATTS_SET_READ_CBACK         0x04    /*! Set if the group callback is executed when
 | 
			
		||||
                                                this attribute is read by a client device */
 | 
			
		||||
#define ATTS_SET_VARIABLE_LEN       0x08    /*! Set if the attribute has a variable length */
 | 
			
		||||
#define ATTS_SET_ALLOW_OFFSET       0x10    /*! Set if writes are allowed with an offset */
 | 
			
		||||
#define ATTS_SET_CCC                0x20    /*! Set if the attribute is a client characteristic
 | 
			
		||||
                                                configuration descriptor */
 | 
			
		||||
#define ATTS_SET_ALLOW_SIGNED       0x40    /*! Set if signed writes are allowed */
 | 
			
		||||
#define ATTS_SET_REQ_SIGNED         0x80    /*! Set if signed writes are required if link
 | 
			
		||||
                                                is not encrypted */
 | 
			
		||||
 | 
			
		||||
/*! ATT server attribute permissions */
 | 
			
		||||
#define ATTS_PERMIT_READ            0x01    /*! Set if attribute can be read */
 | 
			
		||||
#define ATTS_PERMIT_READ_AUTH       0x02    /*! Set if attribute read requires authentication */
 | 
			
		||||
#define ATTS_PERMIT_READ_AUTHORIZ   0x04    /*! Set if attribute read requires authorization */
 | 
			
		||||
#define ATTS_PERMIT_READ_ENC        0x08    /*! Set if attribute read requires encryption */
 | 
			
		||||
#define ATTS_PERMIT_WRITE           0x10    /*! Set if attribute can be written */
 | 
			
		||||
#define ATTS_PERMIT_WRITE_AUTH      0x20    /*! Set if attribute write requires authentication */
 | 
			
		||||
#define ATTS_PERMIT_WRITE_AUTHORIZ  0x40    /*! Set if attribute write requires authorization */
 | 
			
		||||
#define ATTS_PERMIT_WRITE_ENC       0x80    /*! Set if attribute write requires encryption */
 | 
			
		||||
 | 
			
		||||
/*! ATT client characteristic discovery and configuration settings */
 | 
			
		||||
#define ATTC_SET_UUID_128           0x01    /*! Set if the UUID is 128 bits in length */
 | 
			
		||||
#define ATTC_SET_REQUIRED           0x02    /*! Set if characteristic must be discovered */
 | 
			
		||||
#define ATTC_SET_DESCRIPTOR         0x04    /*! Set if this is a characteristic descriptor */
 | 
			
		||||
 | 
			
		||||
/*! ATT callback events */
 | 
			
		||||
#define ATT_CBACK_START             0x02    /*! ATT callback event starting value */
 | 
			
		||||
enum                                        /*! Internal note: event values match method values */
 | 
			
		||||
{
 | 
			
		||||
  /*! ATT client callback events */
 | 
			
		||||
  ATTC_FIND_INFO_RSP = ATT_CBACK_START,     /*! Find information response */
 | 
			
		||||
  ATTC_FIND_BY_TYPE_VALUE_RSP,              /*! Find by type value response */
 | 
			
		||||
  ATTC_READ_BY_TYPE_RSP,                    /*! Read by type value response */
 | 
			
		||||
  ATTC_READ_RSP,                            /*! Read response */
 | 
			
		||||
  ATTC_READ_LONG_RSP,                       /*! Read long response */
 | 
			
		||||
  ATTC_READ_MULTIPLE_RSP,                   /*! Read multiple response */
 | 
			
		||||
  ATTC_READ_BY_GROUP_TYPE_RSP,              /*! Read group type response */
 | 
			
		||||
  ATTC_WRITE_RSP,                           /*! Write response */
 | 
			
		||||
  ATTC_WRITE_CMD_RSP,                       /*! Write command response */
 | 
			
		||||
  ATTC_PREPARE_WRITE_RSP,                   /*! Prepare write response */
 | 
			
		||||
  ATTC_EXECUTE_WRITE_RSP,                   /*! Execute write response */
 | 
			
		||||
  ATTC_HANDLE_VALUE_NTF,                    /*! Handle value notification */
 | 
			
		||||
  ATTC_HANDLE_VALUE_IND,                    /*! Handle value indication */
 | 
			
		||||
  /*! ATT server callback events */
 | 
			
		||||
  ATTS_HANDLE_VALUE_CNF,                    /*! Handle value confirmation */
 | 
			
		||||
  ATTS_CCC_STATE_IND                        /*! Client chracteristic configuration state change */
 | 
			
		||||
};
 | 
			
		||||
 | 
			
		||||
/*! ATT callback events */
 | 
			
		||||
#define ATT_CBACK_END               ATTS_CCC_STATE_IND  /*! ATT callback event ending value */
 | 
			
		||||
 | 
			
		||||
/*! Base value for HCI error status values passed through ATT */
 | 
			
		||||
#define ATT_HCI_ERR_BASE            0x20
 | 
			
		||||
 | 
			
		||||
/**************************************************************************************************
 | 
			
		||||
  Data Types
 | 
			
		||||
**************************************************************************************************/
 | 
			
		||||
 | 
			
		||||
/*! Configurable parameters */
 | 
			
		||||
typedef struct
 | 
			
		||||
{
 | 
			
		||||
  wsfTimerTicks_t   discIdleTimeout;  /*! ATT server service discovery connection idle timeout in seconds */
 | 
			
		||||
  uint16_t          mtu;              /*! desired ATT MTU */
 | 
			
		||||
  uint8_t           transTimeout;     /*! transcation timeout in seconds */
 | 
			
		||||
  uint8_t           numPrepWrites;    /*! number of queued prepare writes supported by server */
 | 
			
		||||
} attCfg_t;
 | 
			
		||||
 | 
			
		||||
/*!
 | 
			
		||||
 * Attribute server data types
 | 
			
		||||
 */
 | 
			
		||||
 | 
			
		||||
/*! Attribute structure */
 | 
			
		||||
typedef struct
 | 
			
		||||
{
 | 
			
		||||
  uint8_t const     *pUuid;           /*! Pointer to the attribute's UUID */
 | 
			
		||||
  uint8_t           *pValue;          /*! Pointer to the attribute's value */
 | 
			
		||||
  uint16_t          *pLen;            /*! Pointer to the length of the attribute's value */
 | 
			
		||||
  uint16_t          maxLen;           /*! Maximum length of attribute's value */
 | 
			
		||||
  uint8_t           settings;         /*! Attribute settings */
 | 
			
		||||
  uint8_t           permissions;      /*! Attribute permissions */
 | 
			
		||||
} attsAttr_t;
 | 
			
		||||
 | 
			
		||||
/*! Attribute group read callback */
 | 
			
		||||
typedef uint8_t (*attsReadCback_t)(dmConnId_t connId, uint16_t handle, uint8_t operation,
 | 
			
		||||
                                   uint16_t offset, attsAttr_t *pAttr);
 | 
			
		||||
 | 
			
		||||
/*! Attribute group write callback */
 | 
			
		||||
typedef uint8_t (*attsWriteCback_t)(dmConnId_t connId, uint16_t handle, uint8_t operation,
 | 
			
		||||
                                    uint16_t offset, uint16_t len, uint8_t *pValue,
 | 
			
		||||
                                    attsAttr_t *pAttr);
 | 
			
		||||
 | 
			
		||||
/*! Attribute group */
 | 
			
		||||
typedef struct attsGroup_tag
 | 
			
		||||
{
 | 
			
		||||
  struct attsGroup_tag  *pNext;       /*! For internal use only */
 | 
			
		||||
  attsAttr_t            *pAttr;       /*! Pointer to attribute list for this group */
 | 
			
		||||
  attsReadCback_t       readCback;    /*! Read callback function */
 | 
			
		||||
  attsWriteCback_t      writeCback;   /*! Write callback function */
 | 
			
		||||
  uint16_t              startHandle;  /*! The handle of the first attribute in this group */
 | 
			
		||||
  uint16_t              endHandle;    /*! The handle of the last attribute in this group */
 | 
			
		||||
} attsGroup_t;
 | 
			
		||||
 | 
			
		||||
/*! Client characteristc configuration settings */
 | 
			
		||||
typedef struct
 | 
			
		||||
{
 | 
			
		||||
  uint16_t          handle;           /*! Client characteristc configuration descriptor handle */
 | 
			
		||||
  uint16_t          valueRange;       /*! Acceptable value range of the descriptor value */
 | 
			
		||||
  uint8_t           secLevel;         /*! Security level of characteristic value */
 | 
			
		||||
} attsCccSet_t;
 | 
			
		||||
 | 
			
		||||
/*! ATT client structure for characteristic and descriptor discovery */
 | 
			
		||||
typedef struct attcDiscChar_tag
 | 
			
		||||
{
 | 
			
		||||
  uint8_t const           *pUuid;       /*! Pointer to UUID */
 | 
			
		||||
  uint8_t                 settings;     /*! Characteristic discovery settings */
 | 
			
		||||
} attcDiscChar_t;
 | 
			
		||||
 | 
			
		||||
/*! ATT client structure for characteristic and descriptor configuration */
 | 
			
		||||
typedef struct
 | 
			
		||||
{
 | 
			
		||||
  uint8_t const         *pValue;      /*! Pointer to default value or NULL */
 | 
			
		||||
  uint8_t               valueLen;     /*! Default value length */
 | 
			
		||||
  uint8_t               hdlIdx;       /*! Index of its handle in handle list */
 | 
			
		||||
} attcDiscCfg_t;
 | 
			
		||||
 | 
			
		||||
/*! ATT client discovery control block */
 | 
			
		||||
typedef struct
 | 
			
		||||
{
 | 
			
		||||
  attcDiscChar_t        **pCharList;  /*! Characterisic list for discovery */
 | 
			
		||||
  uint16_t              *pHdlList;    /*! Characteristic handle list */
 | 
			
		||||
  attcDiscCfg_t         *pCfgList;    /*! Characterisic list for configuration */
 | 
			
		||||
  uint8_t               charListLen;  /*! Characteristic and handle list length */
 | 
			
		||||
  uint8_t               cfgListLen;   /*! Configuration list length */
 | 
			
		||||
 | 
			
		||||
  /* the following are for internal use only */
 | 
			
		||||
  uint16_t              svcStartHdl;
 | 
			
		||||
  uint16_t              svcEndHdl;
 | 
			
		||||
  uint8_t               charListIdx;
 | 
			
		||||
  uint8_t               endHdlIdx;
 | 
			
		||||
} attcDiscCb_t;
 | 
			
		||||
 | 
			
		||||
/*!
 | 
			
		||||
 * ATT callback parameters:
 | 
			
		||||
 *
 | 
			
		||||
 * \param hdr.event     Callback event
 | 
			
		||||
 * \param hdr.param     DM connection ID
 | 
			
		||||
 * \param hdr.status    Event status:  ATT_SUCCESS or error status
 | 
			
		||||
 * \param pValue        Pointer to value data, valid if valueLen > 0
 | 
			
		||||
 * \param valueLen      Length of value data
 | 
			
		||||
 * \param handle        Attribute handle
 | 
			
		||||
 */
 | 
			
		||||
typedef struct
 | 
			
		||||
{
 | 
			
		||||
  wsfMsgHdr_t           hdr;          /*! Header structure */
 | 
			
		||||
  uint8_t               *pValue;      /*! Value */
 | 
			
		||||
  uint16_t              valueLen;     /*! Value length */
 | 
			
		||||
  uint16_t              handle;       /*! Attribute handle */
 | 
			
		||||
  bool_t                continuing;   /*! TRUE if more response packets expected */
 | 
			
		||||
} attEvt_t;
 | 
			
		||||
 | 
			
		||||
/*! ATTS client characteristic configuration callback structure */
 | 
			
		||||
typedef struct
 | 
			
		||||
{
 | 
			
		||||
  wsfMsgHdr_t           hdr;          /*! Header structure */
 | 
			
		||||
  uint16_t              handle;       /*! CCCD handle */
 | 
			
		||||
  uint16_t              value;        /*! CCCD value */
 | 
			
		||||
  uint8_t               idx;          /*! CCCD settings index */
 | 
			
		||||
} attsCccEvt_t;
 | 
			
		||||
 | 
			
		||||
/*! ATT callback type */
 | 
			
		||||
typedef void (*attCback_t)(attEvt_t *pEvt);
 | 
			
		||||
 | 
			
		||||
/*! ATTS authorization callback type */
 | 
			
		||||
typedef uint8_t (*attsAuthorCback_t)(dmConnId_t connId, uint8_t permit, uint16_t handle);
 | 
			
		||||
 | 
			
		||||
/*! ATTS client characteristic configuration callback */
 | 
			
		||||
typedef void (*attsCccCback_t)(attsCccEvt_t *pEvt);
 | 
			
		||||
 | 
			
		||||
/**************************************************************************************************
 | 
			
		||||
  Global Variables
 | 
			
		||||
**************************************************************************************************/
 | 
			
		||||
 | 
			
		||||
/*! Configuration pointer */
 | 
			
		||||
extern attCfg_t *pAttCfg;
 | 
			
		||||
 | 
			
		||||
/**************************************************************************************************
 | 
			
		||||
  Function Declarations
 | 
			
		||||
**************************************************************************************************/
 | 
			
		||||
 | 
			
		||||
/*************************************************************************************************/
 | 
			
		||||
/*!
 | 
			
		||||
 *  \fn     AttRegister
 | 
			
		||||
 *
 | 
			
		||||
 *  \brief  Register a callback with ATT.
 | 
			
		||||
 *
 | 
			
		||||
 *  \param  cback  Client callback function.
 | 
			
		||||
 *
 | 
			
		||||
 *  \return None.
 | 
			
		||||
 */
 | 
			
		||||
/*************************************************************************************************/
 | 
			
		||||
void AttRegister(attCback_t cback);
 | 
			
		||||
 | 
			
		||||
/*************************************************************************************************/
 | 
			
		||||
/*!
 | 
			
		||||
 *  \fn     AttConnRegister
 | 
			
		||||
 *
 | 
			
		||||
 *  \brief  Register a connection callback with ATT.  The callback is typically used to
 | 
			
		||||
 *          manage the attribute server database.
 | 
			
		||||
 *
 | 
			
		||||
 *  \param  cback  Client callback function.
 | 
			
		||||
 *
 | 
			
		||||
 *  \return None.
 | 
			
		||||
 */
 | 
			
		||||
/*************************************************************************************************/
 | 
			
		||||
void AttConnRegister(dmCback_t cback);
 | 
			
		||||
 | 
			
		||||
 | 
			
		||||
/*************************************************************************************************/
 | 
			
		||||
/*!
 | 
			
		||||
 *  \fn     AttGetMtu
 | 
			
		||||
 *
 | 
			
		||||
 *  \brief  Get the attribute protocol MTU of a connection.
 | 
			
		||||
 *
 | 
			
		||||
 *  \param  connId    DM connection ID.
 | 
			
		||||
 *
 | 
			
		||||
 *  \return MTU of the connection.
 | 
			
		||||
 */
 | 
			
		||||
/*************************************************************************************************/
 | 
			
		||||
uint16_t AttGetMtu(dmConnId_t connId);
 | 
			
		||||
 | 
			
		||||
/*************************************************************************************************/
 | 
			
		||||
/*!
 | 
			
		||||
 *  \fn     AttsInit
 | 
			
		||||
 *
 | 
			
		||||
 *  \brief  Initialize ATT server.
 | 
			
		||||
 *
 | 
			
		||||
 *  \return None.
 | 
			
		||||
 */
 | 
			
		||||
/*************************************************************************************************/
 | 
			
		||||
void AttsInit(void);
 | 
			
		||||
 | 
			
		||||
/*************************************************************************************************/
 | 
			
		||||
/*!
 | 
			
		||||
 *  \fn     AttsIndInit
 | 
			
		||||
 *
 | 
			
		||||
 *  \brief  Initialize ATT server for indications/notifications.
 | 
			
		||||
 *
 | 
			
		||||
 *  \return None.
 | 
			
		||||
 */
 | 
			
		||||
/*************************************************************************************************/
 | 
			
		||||
void AttsIndInit(void);
 | 
			
		||||
 | 
			
		||||
/*************************************************************************************************/
 | 
			
		||||
/*!
 | 
			
		||||
 *  \fn     AttsSignInit
 | 
			
		||||
 *
 | 
			
		||||
 *  \brief  Initialize ATT server for data signing.
 | 
			
		||||
 *
 | 
			
		||||
 *  \return None.
 | 
			
		||||
 */
 | 
			
		||||
/*************************************************************************************************/
 | 
			
		||||
void AttsSignInit(void);
 | 
			
		||||
 | 
			
		||||
/*************************************************************************************************/
 | 
			
		||||
/*!
 | 
			
		||||
 *  \fn     AttsAuthorRegister
 | 
			
		||||
 *
 | 
			
		||||
 *  \brief  Register an authorization callback with the attribute server.
 | 
			
		||||
 *
 | 
			
		||||
 *  \param  cback  Client callback function.
 | 
			
		||||
 *
 | 
			
		||||
 *  \return None.
 | 
			
		||||
 */
 | 
			
		||||
/*************************************************************************************************/
 | 
			
		||||
void AttsAuthorRegister(attsAuthorCback_t cback);
 | 
			
		||||
 | 
			
		||||
/*************************************************************************************************/
 | 
			
		||||
/*!
 | 
			
		||||
 *  \fn     AttsAddGroup
 | 
			
		||||
 *
 | 
			
		||||
 *  \brief  Add an attribute group to the attribute server.
 | 
			
		||||
 *
 | 
			
		||||
 *  \param  pGroup    Pointer to an attribute group structure.
 | 
			
		||||
 *
 | 
			
		||||
 *  \return None.
 | 
			
		||||
 */
 | 
			
		||||
/*************************************************************************************************/
 | 
			
		||||
void AttsAddGroup(attsGroup_t *pGroup);
 | 
			
		||||
 | 
			
		||||
/*************************************************************************************************/
 | 
			
		||||
/*!
 | 
			
		||||
 *  \fn     AttsRemoveGroup
 | 
			
		||||
 *
 | 
			
		||||
 *  \brief  Remove an attribute group from the attribute server.
 | 
			
		||||
 *
 | 
			
		||||
 *  \param  startHandle  Start handle of attribute group to be removed.
 | 
			
		||||
 *
 | 
			
		||||
 *  \return None.
 | 
			
		||||
 */
 | 
			
		||||
/*************************************************************************************************/
 | 
			
		||||
void AttsRemoveGroup(uint16_t startHandle);
 | 
			
		||||
 | 
			
		||||
/*************************************************************************************************/
 | 
			
		||||
/*!
 | 
			
		||||
 *  \fn     AttsSetAttr
 | 
			
		||||
 *
 | 
			
		||||
 *  \brief  Set an attribute value in the attribute server.
 | 
			
		||||
 *
 | 
			
		||||
 *  \param  handle    Attribute handle.
 | 
			
		||||
 *  \param  valueLen  Attribute length.
 | 
			
		||||
 *  \param  pValue    Attribute value.
 | 
			
		||||
 *
 | 
			
		||||
 *  \return ATT_SUCCESS if successful otherwise error.
 | 
			
		||||
 */
 | 
			
		||||
/*************************************************************************************************/
 | 
			
		||||
uint8_t AttsSetAttr(uint16_t handle, uint16_t valueLen, uint8_t *pValue);
 | 
			
		||||
 | 
			
		||||
/*************************************************************************************************/
 | 
			
		||||
/*!
 | 
			
		||||
 *  \fn     AttsGetAttr
 | 
			
		||||
 *
 | 
			
		||||
 *  \brief  Get an attribute value in the attribute server.
 | 
			
		||||
 *
 | 
			
		||||
 *  \param  handle    Attribute handle.
 | 
			
		||||
 *  \param  pLen      Returned attribute length pointer.
 | 
			
		||||
 *  \param  pValue    Returned attribute value pointer.
 | 
			
		||||
 *
 | 
			
		||||
 *  \return ATT_SUCCESS if successful otherwise error.
 | 
			
		||||
 *  \return This function returns the attribute length in pLen and a pointer to the attribute
 | 
			
		||||
 *          value in pValue.
 | 
			
		||||
 */
 | 
			
		||||
/*************************************************************************************************/
 | 
			
		||||
uint8_t AttsGetAttr(uint16_t handle, uint16_t *pLen, uint8_t **pValue);
 | 
			
		||||
 | 
			
		||||
/*************************************************************************************************/
 | 
			
		||||
/*!
 | 
			
		||||
 *  \fn     AttsHandleValueInd
 | 
			
		||||
 *
 | 
			
		||||
 *  \brief  Send an attribute protocol Handle Value Indication.
 | 
			
		||||
 *
 | 
			
		||||
 *  \param  connId      DM connection ID.
 | 
			
		||||
 *  \param  handle      Attribute handle.
 | 
			
		||||
 *  \param  valueLen    Length of value data.
 | 
			
		||||
 *  \param  pValue      Pointer to value data.
 | 
			
		||||
 *
 | 
			
		||||
 *  \return None.
 | 
			
		||||
 */
 | 
			
		||||
/*************************************************************************************************/
 | 
			
		||||
void AttsHandleValueInd(dmConnId_t connId, uint16_t handle, uint16_t valueLen, uint8_t *pValue);
 | 
			
		||||
 | 
			
		||||
/*************************************************************************************************/
 | 
			
		||||
/*!
 | 
			
		||||
 *  \fn     AttsHandleValueNtf
 | 
			
		||||
 *
 | 
			
		||||
 *  \brief  Send an attribute protocol Handle Value Notification.
 | 
			
		||||
 *
 | 
			
		||||
 *  \param  connId      DM connection ID.
 | 
			
		||||
 *  \param  handle      Attribute handle.
 | 
			
		||||
 *  \param  valueLen    Length of value data.
 | 
			
		||||
 *  \param  pValue      Pointer to value data.
 | 
			
		||||
 *
 | 
			
		||||
 *  \return None.
 | 
			
		||||
 */
 | 
			
		||||
/*************************************************************************************************/
 | 
			
		||||
void AttsHandleValueNtf(dmConnId_t connId, uint16_t handle, uint16_t valueLen, uint8_t *pValue);
 | 
			
		||||
 | 
			
		||||
/*************************************************************************************************/
 | 
			
		||||
/*!
 | 
			
		||||
 *  \fn     AttsCccRegister
 | 
			
		||||
 *
 | 
			
		||||
 *  \brief  Register the utility service for managing client characteristic
 | 
			
		||||
 *          configuration descriptors.  This function is typically called once on
 | 
			
		||||
 *          system initialization.
 | 
			
		||||
 *
 | 
			
		||||
 *  \param  setLen  Length of settings array.
 | 
			
		||||
 *  \param  pSet    Array of CCC descriptor settings.
 | 
			
		||||
 *  \param  cback   Client callback function.
 | 
			
		||||
 *
 | 
			
		||||
 *  \return None.
 | 
			
		||||
 */
 | 
			
		||||
/*************************************************************************************************/
 | 
			
		||||
void AttsCccRegister(uint8_t setLen, attsCccSet_t *pSet, attsCccCback_t cback);
 | 
			
		||||
 | 
			
		||||
/*************************************************************************************************/
 | 
			
		||||
/*!
 | 
			
		||||
 *  \fn     AttsCccInitTable
 | 
			
		||||
 *
 | 
			
		||||
 *  \brief  Initialize the client characteristic configuration descriptor value table for a
 | 
			
		||||
 *          connection.  The table is initialized with the values from pCccTbl.  If pCccTbl
 | 
			
		||||
 *          is NULL the table will be initialized to zero.
 | 
			
		||||
 *
 | 
			
		||||
 *          This function must be called when a connection is established or when a
 | 
			
		||||
 *          device is bonded.
 | 
			
		||||
 *
 | 
			
		||||
 *  \param  connId      DM connection ID.
 | 
			
		||||
 *  \param  pCccTbl     Pointer to the descriptor value array.  The length of the array
 | 
			
		||||
 *                      must equal the value of setLen passed to AttsCccRegister().
 | 
			
		||||
 *
 | 
			
		||||
 *  \return None.
 | 
			
		||||
 */
 | 
			
		||||
/*************************************************************************************************/
 | 
			
		||||
void AttsCccInitTable(dmConnId_t connId, uint16_t *pCccTbl);
 | 
			
		||||
 | 
			
		||||
/*************************************************************************************************/
 | 
			
		||||
/*!
 | 
			
		||||
 *  \fn     AttsCccClearTable
 | 
			
		||||
 *
 | 
			
		||||
 *  \brief  Clear and deallocate the client characteristic configuration descriptor value
 | 
			
		||||
 *          table for a connection.  This function must be called when a connection is closed.
 | 
			
		||||
 *
 | 
			
		||||
 *  \param  connId      DM connection ID.
 | 
			
		||||
 *
 | 
			
		||||
 *  \return None.
 | 
			
		||||
 */
 | 
			
		||||
/*************************************************************************************************/
 | 
			
		||||
void AttsCccClearTable(dmConnId_t connId);
 | 
			
		||||
 | 
			
		||||
/*************************************************************************************************/
 | 
			
		||||
/*!
 | 
			
		||||
 *  \fn     AttsCccGet
 | 
			
		||||
 *
 | 
			
		||||
 *  \brief  Get the value of a client characteristic configuration descriptor by its index.
 | 
			
		||||
 *          If not found, return zero.
 | 
			
		||||
 *
 | 
			
		||||
 *  \param  connId      DM connection ID.
 | 
			
		||||
 *  \param  idx         Index of descriptor in CCC descriptor handle table.
 | 
			
		||||
 *
 | 
			
		||||
 *  \return Value of the descriptor.
 | 
			
		||||
 */
 | 
			
		||||
/*************************************************************************************************/
 | 
			
		||||
uint16_t AttsCccGet(dmConnId_t connId, uint8_t idx);
 | 
			
		||||
 | 
			
		||||
/*************************************************************************************************/
 | 
			
		||||
/*!
 | 
			
		||||
 *  \fn     AttsCccSet
 | 
			
		||||
 *
 | 
			
		||||
 *  \brief  Set the value of a client characteristic configuration descriptor by its index.
 | 
			
		||||
 *
 | 
			
		||||
 *  \param  connId      DM connection ID.
 | 
			
		||||
 *  \param  idx         Index of descriptor in CCC descriptor handle table.
 | 
			
		||||
 *  \param  value       Value of the descriptor.
 | 
			
		||||
 *
 | 
			
		||||
 *  \return None.
 | 
			
		||||
 */
 | 
			
		||||
/*************************************************************************************************/
 | 
			
		||||
void AttsCccSet(dmConnId_t connId, uint8_t idx, uint16_t value);
 | 
			
		||||
 | 
			
		||||
/*************************************************************************************************/
 | 
			
		||||
/*!
 | 
			
		||||
 *  \fn     AttsCccEnabled
 | 
			
		||||
 *
 | 
			
		||||
 *  \brief  Check if a client characteristic configuration descriptor is enabled and if
 | 
			
		||||
 *          the characteristic's security level has been met.
 | 
			
		||||
 *
 | 
			
		||||
 *  \param  connId      DM connection ID.
 | 
			
		||||
 *  \param  idx         Index of descriptor in CCC descriptor handle table.
 | 
			
		||||
 *
 | 
			
		||||
 *  \return Value of the descriptor if security level is met, otherwise zero.
 | 
			
		||||
 */
 | 
			
		||||
/*************************************************************************************************/
 | 
			
		||||
uint16_t AttsCccEnabled(dmConnId_t connId, uint8_t idx);
 | 
			
		||||
 | 
			
		||||
/*************************************************************************************************/
 | 
			
		||||
/*!
 | 
			
		||||
 *  \fn     AttsSetCsrk
 | 
			
		||||
 *
 | 
			
		||||
 *  \brief  Set the peer's data signing key on this connection.  This function
 | 
			
		||||
 *          is typically called from the ATT connection callback when the connection is
 | 
			
		||||
 *          established.  The caller is responsible for maintaining the memory that
 | 
			
		||||
 *          contains the key.
 | 
			
		||||
 *
 | 
			
		||||
 *  \param  connId      DM connection ID.
 | 
			
		||||
 *  \param  pCsrk       Pointer to data signing key (CSRK).
 | 
			
		||||
 *
 | 
			
		||||
 *  \return None.
 | 
			
		||||
 */
 | 
			
		||||
/*************************************************************************************************/
 | 
			
		||||
void AttsSetCsrk(dmConnId_t connId, uint8_t *pCsrk);
 | 
			
		||||
 | 
			
		||||
/*************************************************************************************************/
 | 
			
		||||
/*!
 | 
			
		||||
 *  \fn     AttsSetSignCounter
 | 
			
		||||
 *
 | 
			
		||||
 *  \brief  Set the peer's sign counter on this connection.  This function
 | 
			
		||||
 *          is typically called from the ATT connection callback when the connection is
 | 
			
		||||
 *          established.  ATT maintains the value of the sign counter internally and
 | 
			
		||||
 *          sets the value when a signed packet is successfully received.
 | 
			
		||||
 *
 | 
			
		||||
 *  \param  connId      DM connection ID.
 | 
			
		||||
 *  \param  signCounter Sign counter.
 | 
			
		||||
 *
 | 
			
		||||
 *  \return None.
 | 
			
		||||
 */
 | 
			
		||||
/*************************************************************************************************/
 | 
			
		||||
void AttsSetSignCounter(dmConnId_t connId, uint32_t signCounter);
 | 
			
		||||
 | 
			
		||||
/*************************************************************************************************/
 | 
			
		||||
/*!
 | 
			
		||||
 *  \fn     AttsGetSignCounter
 | 
			
		||||
 *
 | 
			
		||||
 *  \brief  Get the current value peer's sign counter on this connection.  This function
 | 
			
		||||
 *          is typically called from the ATT connection callback when the connection is
 | 
			
		||||
 *          closed so the application can store the sign counter for use on future
 | 
			
		||||
 *          connections.
 | 
			
		||||
 *
 | 
			
		||||
 *  \param  connId      DM connection ID.
 | 
			
		||||
 *
 | 
			
		||||
 *  \return Sign counter.
 | 
			
		||||
 */
 | 
			
		||||
/*************************************************************************************************/
 | 
			
		||||
uint32_t AttsGetSignCounter(dmConnId_t connId);
 | 
			
		||||
 | 
			
		||||
/*************************************************************************************************/
 | 
			
		||||
/*!
 | 
			
		||||
 *  \fn     AttcInit
 | 
			
		||||
 *
 | 
			
		||||
 *  \brief  Initialize ATT client.
 | 
			
		||||
 *
 | 
			
		||||
 *  \return None.
 | 
			
		||||
 */
 | 
			
		||||
/*************************************************************************************************/
 | 
			
		||||
void AttcInit(void);
 | 
			
		||||
 | 
			
		||||
/*************************************************************************************************/
 | 
			
		||||
/*!
 | 
			
		||||
 *  \fn     AttcSignInit
 | 
			
		||||
 *
 | 
			
		||||
 *  \brief  Initialize ATT client for data signing.
 | 
			
		||||
 *
 | 
			
		||||
 *  \return None.
 | 
			
		||||
 */
 | 
			
		||||
/*************************************************************************************************/
 | 
			
		||||
void AttcSignInit(void);
 | 
			
		||||
 | 
			
		||||
/*************************************************************************************************/
 | 
			
		||||
/*!
 | 
			
		||||
 *  \fn     AttcFindInfoReq
 | 
			
		||||
 *
 | 
			
		||||
 *  \brief  Initiate an attribute protocol Find Information Request.
 | 
			
		||||
 *
 | 
			
		||||
 *  \param  connId      DM connection ID.
 | 
			
		||||
 *  \param  startHandle Attribute start handle.
 | 
			
		||||
 *  \param  endHandle   Attribute end handle.
 | 
			
		||||
 *  \param  continuing  TRUE if ATTC continues sending requests until complete.
 | 
			
		||||
 *
 | 
			
		||||
 *  \return None.
 | 
			
		||||
 */
 | 
			
		||||
/*************************************************************************************************/
 | 
			
		||||
void AttcFindInfoReq(dmConnId_t connId, uint16_t startHandle, uint16_t endHandle, bool_t continuing);
 | 
			
		||||
 | 
			
		||||
/*************************************************************************************************/
 | 
			
		||||
/*!
 | 
			
		||||
 *  \fn     AttcFindByTypeValueReq
 | 
			
		||||
 *
 | 
			
		||||
 *  \brief  Initiate an attribute protocol Find By Type Value Request.
 | 
			
		||||
 *
 | 
			
		||||
 *  \param  connId      DM connection ID.
 | 
			
		||||
 *  \param  startHandle Attribute start handle.
 | 
			
		||||
 *  \param  endHandle   Attribute end handle.
 | 
			
		||||
 *  \param  uuid16      16-bit UUID to find.
 | 
			
		||||
 *  \param  valueLen    Length of value data.
 | 
			
		||||
 *  \param  pValue      Pointer to value data.
 | 
			
		||||
 *  \param  continuing  TRUE if ATTC continues sending requests until complete.
 | 
			
		||||
 *
 | 
			
		||||
 *  \return None.
 | 
			
		||||
 */
 | 
			
		||||
/*************************************************************************************************/
 | 
			
		||||
void AttcFindByTypeValueReq(dmConnId_t connId, uint16_t startHandle, uint16_t endHandle,
 | 
			
		||||
                            uint16_t uuid16, uint16_t valueLen, uint8_t *pValue, bool_t continuing);
 | 
			
		||||
 | 
			
		||||
/*************************************************************************************************/
 | 
			
		||||
/*!
 | 
			
		||||
 *  \fn     AttcReadByTypeReq
 | 
			
		||||
 *
 | 
			
		||||
 *  \brief  Initiate an attribute protocol Read By Type Request.
 | 
			
		||||
 *
 | 
			
		||||
 *  \param  connId      DM connection ID.
 | 
			
		||||
 *  \param  startHandle Attribute start handle.
 | 
			
		||||
 *  \param  endHandle   Attribute end handle.
 | 
			
		||||
 *  \param  uuidLen     Length of UUID (2 or 16).
 | 
			
		||||
 *  \param  pUuid       Pointer to UUID data.
 | 
			
		||||
 *  \param  continuing  TRUE if ATTC continues sending requests until complete.
 | 
			
		||||
 *
 | 
			
		||||
 *  \return None.
 | 
			
		||||
 */
 | 
			
		||||
/*************************************************************************************************/
 | 
			
		||||
void AttcReadByTypeReq(dmConnId_t connId, uint16_t startHandle, uint16_t endHandle,
 | 
			
		||||
                       uint8_t uuidLen, uint8_t *pUuid, bool_t continuing);
 | 
			
		||||
 | 
			
		||||
/*************************************************************************************************/
 | 
			
		||||
/*!
 | 
			
		||||
 *  \fn     AttcReadReq
 | 
			
		||||
 *
 | 
			
		||||
 *  \brief  Initiate an attribute protocol Read Request.
 | 
			
		||||
 *
 | 
			
		||||
 *  \param  connId    DM connection ID.
 | 
			
		||||
 *  \param  handle    Attribute handle.
 | 
			
		||||
 *
 | 
			
		||||
 *  \return None.
 | 
			
		||||
 */
 | 
			
		||||
/*************************************************************************************************/
 | 
			
		||||
void AttcReadReq(dmConnId_t connId, uint16_t handle);
 | 
			
		||||
 | 
			
		||||
/*************************************************************************************************/
 | 
			
		||||
/*!
 | 
			
		||||
 *  \fn     AttcReadLongReq
 | 
			
		||||
 *
 | 
			
		||||
 *  \brief  Initiate an attribute protocol Read Long Request.
 | 
			
		||||
 *
 | 
			
		||||
 *  \param  connId      DM connection ID.
 | 
			
		||||
 *  \param  handle      Attribute handle.
 | 
			
		||||
 *  \param  offset      Read attribute data starting at this offset.
 | 
			
		||||
 *  \param  continuing  TRUE if ATTC continues sending requests until complete.
 | 
			
		||||
 *
 | 
			
		||||
 *  \return None.
 | 
			
		||||
 */
 | 
			
		||||
/*************************************************************************************************/
 | 
			
		||||
void AttcReadLongReq(dmConnId_t connId, uint16_t handle, uint16_t offset, bool_t continuing);
 | 
			
		||||
 | 
			
		||||
/*************************************************************************************************/
 | 
			
		||||
/*!
 | 
			
		||||
 *  \fn     AttcReadMultipleReq
 | 
			
		||||
 *
 | 
			
		||||
 *  \brief  Initiate an attribute protocol Read Multiple Request.
 | 
			
		||||
 *
 | 
			
		||||
 *  \param  connId      DM connection ID.
 | 
			
		||||
 *  \param  numHandles  Number of handles in attribute handle list.
 | 
			
		||||
 *  \param  pHandles    List of attribute handles.
 | 
			
		||||
 *
 | 
			
		||||
 *  \return None.
 | 
			
		||||
 */
 | 
			
		||||
/*************************************************************************************************/
 | 
			
		||||
void AttcReadMultipleReq(dmConnId_t connId, uint8_t numHandles, uint16_t *pHandles);
 | 
			
		||||
 | 
			
		||||
/*************************************************************************************************/
 | 
			
		||||
/*!
 | 
			
		||||
 *  \fn     AttcReadByGroupTypeReq
 | 
			
		||||
 *
 | 
			
		||||
 *  \brief  Initiate an attribute protocol Read By Group Type Request.
 | 
			
		||||
 *
 | 
			
		||||
 *  \param  connId      DM connection ID.
 | 
			
		||||
 *  \param  startHandle Attribute start handle.
 | 
			
		||||
 *  \param  endHandle   Attribute end handle.
 | 
			
		||||
 *  \param  uuidLen     Length of UUID (2 or 16).
 | 
			
		||||
 *  \param  pUuid       Pointer to UUID data.
 | 
			
		||||
 *  \param  continuing  TRUE if ATTC continues sending requests until complete.
 | 
			
		||||
 *
 | 
			
		||||
 *  \return None.
 | 
			
		||||
 */
 | 
			
		||||
/*************************************************************************************************/
 | 
			
		||||
void AttcReadByGroupTypeReq(dmConnId_t connId, uint16_t startHandle, uint16_t endHandle,
 | 
			
		||||
                            uint8_t uuidLen, uint8_t *pUuid, bool_t continuing);
 | 
			
		||||
 | 
			
		||||
/*************************************************************************************************/
 | 
			
		||||
/*!
 | 
			
		||||
 *  \fn     AttcWriteReq
 | 
			
		||||
 *
 | 
			
		||||
 *  \brief  Initiate an attribute protocol Write Request.
 | 
			
		||||
 *
 | 
			
		||||
 *  \param  connId      DM connection ID.
 | 
			
		||||
 *  \param  handle      Attribute handle.
 | 
			
		||||
 *  \param  valueLen    Length of value data.
 | 
			
		||||
 *  \param  pValue      Pointer to value data.
 | 
			
		||||
 *
 | 
			
		||||
 *  \return None.
 | 
			
		||||
 */
 | 
			
		||||
/*************************************************************************************************/
 | 
			
		||||
void AttcWriteReq(dmConnId_t connId, uint16_t handle, uint16_t valueLen, uint8_t *pValue);
 | 
			
		||||
 | 
			
		||||
/*************************************************************************************************/
 | 
			
		||||
/*!
 | 
			
		||||
 *  \fn     AttcWriteCmd
 | 
			
		||||
 *
 | 
			
		||||
 *  \brief  Initiate an attribute protocol Write Command.
 | 
			
		||||
 *
 | 
			
		||||
 *  \param  connId      DM connection ID.
 | 
			
		||||
 *  \param  handle      Attribute handle.
 | 
			
		||||
 *  \param  valueLen    Length of value data.
 | 
			
		||||
 *  \param  pValue      Pointer to value data.
 | 
			
		||||
 *
 | 
			
		||||
 *  \return None.
 | 
			
		||||
 */
 | 
			
		||||
/*************************************************************************************************/
 | 
			
		||||
void AttcWriteCmd(dmConnId_t connId, uint16_t handle, uint16_t valueLen, uint8_t *pValue);
 | 
			
		||||
 | 
			
		||||
/*************************************************************************************************/
 | 
			
		||||
/*!
 | 
			
		||||
 *  \fn     AttcSignedWriteCmd
 | 
			
		||||
 *
 | 
			
		||||
 *  \brief  Initiate an attribute protocol signed Write Command.
 | 
			
		||||
 *
 | 
			
		||||
 *  \param  connId      DM connection ID.
 | 
			
		||||
 *  \param  handle      Attribute handle.
 | 
			
		||||
 *  \param  signCounter Value of the sign counter.
 | 
			
		||||
 *  \param  valueLen    Length of value data.
 | 
			
		||||
 *  \param  pValue      Pointer to value data.
 | 
			
		||||
 *
 | 
			
		||||
 *  \return None.
 | 
			
		||||
 */
 | 
			
		||||
/*************************************************************************************************/
 | 
			
		||||
void AttcSignedWriteCmd(dmConnId_t connId, uint16_t handle, uint32_t signCounter,
 | 
			
		||||
                        uint16_t valueLen, uint8_t *pValue);
 | 
			
		||||
 | 
			
		||||
/*************************************************************************************************/
 | 
			
		||||
/*!
 | 
			
		||||
 *  \fn     AttcPrepareWriteReq
 | 
			
		||||
 *
 | 
			
		||||
 *  \brief  Initiate an attribute protocol Prepare Write Request.
 | 
			
		||||
 *
 | 
			
		||||
 *  \param  connId      DM connection ID.
 | 
			
		||||
 *  \param  handle      Attribute handle.
 | 
			
		||||
 *  \param  offset      Write attribute data starting at this offset.
 | 
			
		||||
 *  \param  valueLen    Length of value data.
 | 
			
		||||
 *  \param  pValue      Pointer to value data.
 | 
			
		||||
 *  \param  valueByRef  TRUE if pValue data is accessed by reference rather than copied.
 | 
			
		||||
 *  \param  continuing  TRUE if ATTC continues sending requests until complete.
 | 
			
		||||
 *
 | 
			
		||||
 *  \return None.
 | 
			
		||||
 */
 | 
			
		||||
/*************************************************************************************************/
 | 
			
		||||
void AttcPrepareWriteReq(dmConnId_t connId, uint16_t handle, uint16_t offset, uint16_t valueLen,
 | 
			
		||||
                         uint8_t *pValue, bool_t valueByRef, bool_t continuing);
 | 
			
		||||
 | 
			
		||||
/*************************************************************************************************/
 | 
			
		||||
/*!
 | 
			
		||||
 *  \fn     AttcExecuteWriteReq
 | 
			
		||||
 *
 | 
			
		||||
 *  \brief  Initiate an attribute protocol Execute Write Request.
 | 
			
		||||
 *
 | 
			
		||||
 *  \param  connId    DM connection ID.
 | 
			
		||||
 *  \param  writeAll  TRUE to write all queued writes, FALSE to cancel all queued writes.
 | 
			
		||||
 *
 | 
			
		||||
 *  \return None.
 | 
			
		||||
 */
 | 
			
		||||
/*************************************************************************************************/
 | 
			
		||||
void AttcExecuteWriteReq(dmConnId_t connId, bool_t writeAll);
 | 
			
		||||
 | 
			
		||||
/*************************************************************************************************/
 | 
			
		||||
/*!
 | 
			
		||||
 *  \fn     AttcCancelReq
 | 
			
		||||
 *
 | 
			
		||||
 *  \brief  Cancel an attribute protocol request in progress.
 | 
			
		||||
 *
 | 
			
		||||
 *  \param  connId    DM connection ID.
 | 
			
		||||
 *
 | 
			
		||||
 *  \return None.
 | 
			
		||||
 */
 | 
			
		||||
/*************************************************************************************************/
 | 
			
		||||
void AttcCancelReq(dmConnId_t connId);
 | 
			
		||||
 | 
			
		||||
/*************************************************************************************************/
 | 
			
		||||
/*!
 | 
			
		||||
 *  \fn     AttcDiscService
 | 
			
		||||
 *
 | 
			
		||||
 *  \brief  This utility function discovers the given service on a peer device.  Function
 | 
			
		||||
 *          AttcFindByTypeValueReq() is called to initiate the discovery procedure.
 | 
			
		||||
 *
 | 
			
		||||
 *  \param  connId      DM connection ID.
 | 
			
		||||
 *  \param  pCb         Pointer to discovery control block.
 | 
			
		||||
 *  \param  uuidLen     Length of service UUID (2 or 16).
 | 
			
		||||
 *  \param  pUuid       Pointer to service UUID.
 | 
			
		||||
 *
 | 
			
		||||
 *  \return None.
 | 
			
		||||
 */
 | 
			
		||||
/*************************************************************************************************/
 | 
			
		||||
void AttcDiscService(dmConnId_t connId, attcDiscCb_t *pCb, uint8_t uuidLen, uint8_t *pUuid);
 | 
			
		||||
 | 
			
		||||
/*************************************************************************************************/
 | 
			
		||||
/*!
 | 
			
		||||
 *  \fn     AttcDiscServiceCmpl
 | 
			
		||||
 *
 | 
			
		||||
 *  \brief  This utility function processes a service discovery result.  It should be called
 | 
			
		||||
 *          when an ATTC_FIND_BY_TYPE_VALUE_RSP callback event is received after service
 | 
			
		||||
 *          discovery is initiated by calling AttcDiscService().
 | 
			
		||||
 *
 | 
			
		||||
 *  \param  pCb         Pointer to discovery control block.
 | 
			
		||||
 *  \param  pMsg        ATT callback event message.
 | 
			
		||||
 *
 | 
			
		||||
 *  \return ATT_SUCCESS if successful otherwise error.
 | 
			
		||||
 */
 | 
			
		||||
/*************************************************************************************************/
 | 
			
		||||
uint8_t AttcDiscServiceCmpl(attcDiscCb_t *pCb, attEvt_t *pMsg);
 | 
			
		||||
 | 
			
		||||
/*************************************************************************************************/
 | 
			
		||||
/*!
 | 
			
		||||
 *  \fn     AttcDiscCharStart
 | 
			
		||||
 *
 | 
			
		||||
 *  \brief  This utility function starts characteristic and characteristic descriptor
 | 
			
		||||
 *          discovery for a service on a peer device.  The service must have been previously
 | 
			
		||||
 *          discovered by calling AttcDiscService() and AttcDiscServiceCmpl().
 | 
			
		||||
 *
 | 
			
		||||
 *  \param  connId      DM connection ID.
 | 
			
		||||
 *  \param  pCb         Pointer to discovery control block.
 | 
			
		||||
 *
 | 
			
		||||
 *  \return None.
 | 
			
		||||
 */
 | 
			
		||||
/*************************************************************************************************/
 | 
			
		||||
void AttcDiscCharStart(dmConnId_t connId, attcDiscCb_t *pCb);
 | 
			
		||||
 | 
			
		||||
/*************************************************************************************************/
 | 
			
		||||
/*!
 | 
			
		||||
 *  \fn     AttcDiscCharCmpl
 | 
			
		||||
 *
 | 
			
		||||
 *  \brief  This utility function processes a characteristic discovery result.  It should be
 | 
			
		||||
 *          called when an ATTC_READ_BY_TYPE_RSP or ATTC_FIND_INFO_RSP callback event is
 | 
			
		||||
 *          received after characteristic discovery is initiated by calling AttcDiscCharStart().
 | 
			
		||||
 *
 | 
			
		||||
 *  \param  pCb         Pointer to discovery control block.
 | 
			
		||||
 *  \param  pMsg        ATT callback event message.
 | 
			
		||||
 *
 | 
			
		||||
 *  \return ATT_CONTINUING if successful and the discovery procedure is continuing.
 | 
			
		||||
 *          ATT_SUCCESS if the discovery procedure completed successfully.
 | 
			
		||||
 *          Otherwise the discovery procedure failed.
 | 
			
		||||
 */
 | 
			
		||||
/*************************************************************************************************/
 | 
			
		||||
uint8_t AttcDiscCharCmpl(attcDiscCb_t *pCb, attEvt_t *pMsg);
 | 
			
		||||
 | 
			
		||||
/*************************************************************************************************/
 | 
			
		||||
/*!
 | 
			
		||||
 *  \fn     AttcDiscConfigStart
 | 
			
		||||
 *
 | 
			
		||||
 *  \brief  This utility function starts characteristic configuration for characteristics on a
 | 
			
		||||
 *          peer device.  The characteristics must have been previously discovered by calling
 | 
			
		||||
 *          AttcDiscCharStart() and AttcDiscCharCmpl().
 | 
			
		||||
 *
 | 
			
		||||
 *  \param  connId      DM connection ID.
 | 
			
		||||
 *  \param  pCb         Pointer to discovery control block.
 | 
			
		||||
 *
 | 
			
		||||
 *  \return ATT_CONTINUING if successful and configuration procedure is continuing.
 | 
			
		||||
 *          ATT_SUCCESS if nothing to configure.
 | 
			
		||||
 */
 | 
			
		||||
/*************************************************************************************************/
 | 
			
		||||
uint8_t AttcDiscConfigStart(dmConnId_t connId, attcDiscCb_t *pCb);
 | 
			
		||||
 | 
			
		||||
/*************************************************************************************************/
 | 
			
		||||
/*!
 | 
			
		||||
 *  \fn     AttcDiscConfigCmpl
 | 
			
		||||
 *
 | 
			
		||||
 *  \brief  This utility function initiates the next characteristic configuration procedure.
 | 
			
		||||
 *          It should be called when an ATTC_READ_RSP or ATTC_WRITE_RSP callback event is received
 | 
			
		||||
 *          after characteristic configuration is initiated by calling AttcDiscConfigStart().
 | 
			
		||||
 *
 | 
			
		||||
 *  \param  connId      DM connection ID.
 | 
			
		||||
 *  \param  pCb         Pointer to discovery control block.
 | 
			
		||||
 *
 | 
			
		||||
 *  \return ATT_CONTINUING if successful and configuration procedure is continuing.
 | 
			
		||||
 *          ATT_SUCCESS if configuration procedure completed successfully.
 | 
			
		||||
 */
 | 
			
		||||
/*************************************************************************************************/
 | 
			
		||||
uint8_t AttcDiscConfigCmpl(dmConnId_t connId, attcDiscCb_t *pCb);
 | 
			
		||||
 | 
			
		||||
/*************************************************************************************************/
 | 
			
		||||
/*!
 | 
			
		||||
 *  \fn     AttcDiscConfigResume
 | 
			
		||||
 *
 | 
			
		||||
 *  \brief  This utility function resumes the characteristic configuration procedure.  It can
 | 
			
		||||
 *          be called when an ATTC_READ_RSP or ATTC_WRITE_RSP callback event is received
 | 
			
		||||
 *          with failure status to attempt the read or write procedure again.
 | 
			
		||||
 *
 | 
			
		||||
 *  \param  connId      DM connection ID.
 | 
			
		||||
 *  \param  pCb         Pointer to discovery control block.
 | 
			
		||||
 *
 | 
			
		||||
 *  \return ATT_CONTINUING if successful and configuration procedure is continuing.
 | 
			
		||||
 *          ATT_SUCCESS if configuration procedure completed successfully.
 | 
			
		||||
 */
 | 
			
		||||
/*************************************************************************************************/
 | 
			
		||||
uint8_t AttcDiscConfigResume(dmConnId_t connId, attcDiscCb_t *pCb);
 | 
			
		||||
 | 
			
		||||
/*************************************************************************************************/
 | 
			
		||||
/*!
 | 
			
		||||
 *  \fn     AttcMtuReq
 | 
			
		||||
 *
 | 
			
		||||
 *  \brief  For internal use only.
 | 
			
		||||
 *
 | 
			
		||||
 *  \param  connId    DM connection ID.
 | 
			
		||||
 *  \param  mtu       Attribute protocol MTU.
 | 
			
		||||
 *
 | 
			
		||||
 *  \return None.
 | 
			
		||||
 */
 | 
			
		||||
/*************************************************************************************************/
 | 
			
		||||
void AttcMtuReq(dmConnId_t connId, uint16_t mtu);
 | 
			
		||||
 | 
			
		||||
/*************************************************************************************************/
 | 
			
		||||
/*!
 | 
			
		||||
 *  \fn     AttsErrorTest
 | 
			
		||||
 *
 | 
			
		||||
 *  \brief  For testing purposes only.
 | 
			
		||||
 *
 | 
			
		||||
 *  \param  status    ATT status
 | 
			
		||||
 *
 | 
			
		||||
 *  \return None.
 | 
			
		||||
 */
 | 
			
		||||
/*************************************************************************************************/
 | 
			
		||||
void AttsErrorTest(uint8_t status);
 | 
			
		||||
 | 
			
		||||
#ifdef __cplusplus
 | 
			
		||||
};
 | 
			
		||||
#endif
 | 
			
		||||
 | 
			
		||||
#endif /* ATT_API_H */
 | 
			
		||||
| 
						 | 
				
			
			@ -1,222 +0,0 @@
 | 
			
		|||
/*************************************************************************************************/
 | 
			
		||||
/*!
 | 
			
		||||
 *  \file   att_defs.h
 | 
			
		||||
 *        
 | 
			
		||||
 *  \brief  Attribute protocol constants and definitions from the Bluetooth specification.
 | 
			
		||||
 *
 | 
			
		||||
 *          $Date: 2015-09-10 14:58:31 -0700 (Thu, 10 Sep 2015) $
 | 
			
		||||
 *          $Revision: 3838 $
 | 
			
		||||
 *  
 | 
			
		||||
 *  Copyright (c) 2009 Wicentric, Inc., all rights reserved.
 | 
			
		||||
 *  Wicentric confidential and proprietary.
 | 
			
		||||
 *
 | 
			
		||||
 *  IMPORTANT.  Your use of this file is governed by a Software License Agreement
 | 
			
		||||
 *  ("Agreement") that must be accepted in order to download or otherwise receive a
 | 
			
		||||
 *  copy of this file.  You may not use or copy this file for any purpose other than
 | 
			
		||||
 *  as described in the Agreement.  If you do not agree to all of the terms of the
 | 
			
		||||
 *  Agreement do not use this file and delete all copies in your possession or control;
 | 
			
		||||
 *  if you do not have a copy of the Agreement, you must contact Wicentric, Inc. prior
 | 
			
		||||
 *  to any use, copying or further distribution of this software.
 | 
			
		||||
 */
 | 
			
		||||
/*************************************************************************************************/
 | 
			
		||||
#ifndef ATT_DEFS_H
 | 
			
		||||
#define ATT_DEFS_H
 | 
			
		||||
 | 
			
		||||
#ifdef __cplusplus
 | 
			
		||||
extern "C" {
 | 
			
		||||
#endif
 | 
			
		||||
 | 
			
		||||
/**************************************************************************************************
 | 
			
		||||
  Macros
 | 
			
		||||
**************************************************************************************************/
 | 
			
		||||
 | 
			
		||||
/*! Attribute PDU format */
 | 
			
		||||
#define ATT_HDR_LEN                   1         /*! Attribute PDU header length */
 | 
			
		||||
#define ATT_AUTH_SIG_LEN              12        /*! Authentication signature length */
 | 
			
		||||
#define ATT_DEFAULT_MTU               23        /*! Default value of ATT_MTU */
 | 
			
		||||
#define ATT_MAX_MTU                   517       /*! Maximum value of ATT_MTU */
 | 
			
		||||
#define ATT_DEFAULT_PAYLOAD_LEN       20        /*! Default maximum payload length for most PDUs */
 | 
			
		||||
 | 
			
		||||
/*! Attribute value parameters */
 | 
			
		||||
#define ATT_VALUE_MAX_LEN             512       /*! Maximum attribute value length */
 | 
			
		||||
#define ATT_VALUE_MAX_OFFSET          511       /*! Maximum attribute value offset */
 | 
			
		||||
 | 
			
		||||
/*! Transaction timeout */
 | 
			
		||||
#define ATT_MAX_TRANS_TIMEOUT         30        /*! Maximum transaction timeout in seconds */
 | 
			
		||||
 | 
			
		||||
/*! Error codes */
 | 
			
		||||
#define ATT_SUCCESS                   0x00      /*! Operation successful */
 | 
			
		||||
#define ATT_ERR_HANDLE                0x01      /*! Invalid handle */
 | 
			
		||||
#define ATT_ERR_READ                  0x02      /*! Read not permitted */
 | 
			
		||||
#define ATT_ERR_WRITE                 0x03      /*! Write not permitted */
 | 
			
		||||
#define ATT_ERR_INVALID_PDU           0x04      /*! Invalid pdu */
 | 
			
		||||
#define ATT_ERR_AUTH                  0x05      /*! Insufficient authentication */
 | 
			
		||||
#define ATT_ERR_NOT_SUP               0x06      /*! Request not supported */
 | 
			
		||||
#define ATT_ERR_OFFSET                0x07      /*! Invalid offset */
 | 
			
		||||
#define ATT_ERR_AUTHOR                0x08      /*! Insufficient authorization */
 | 
			
		||||
#define ATT_ERR_QUEUE_FULL            0x09      /*! Prepare queue full */
 | 
			
		||||
#define ATT_ERR_NOT_FOUND             0x0A      /*! Attribute not found */
 | 
			
		||||
#define ATT_ERR_NOT_LONG              0x0B      /*! Attribute not long */
 | 
			
		||||
#define ATT_ERR_KEY_SIZE              0x0C      /*! Insufficient encryption key size */
 | 
			
		||||
#define ATT_ERR_LENGTH                0x0D      /*! Invalid attribute value length */
 | 
			
		||||
#define ATT_ERR_UNLIKELY              0x0E      /*! Other unlikely error */
 | 
			
		||||
#define ATT_ERR_ENC                   0x0F      /*! Insufficient encryption */
 | 
			
		||||
#define ATT_ERR_GROUP_TYPE            0x10      /*! Unsupported group type */
 | 
			
		||||
#define ATT_ERR_RESOURCES             0x11      /*! Insufficient resources */
 | 
			
		||||
#define ATT_ERR_CCCD                  0xFD      /*! CCCD improperly configured */
 | 
			
		||||
#define ATT_ERR_IN_PROGRESS           0xFE      /*! Procedure already in progress */
 | 
			
		||||
#define ATT_ERR_RANGE                 0xFF      /*! Value out of range */
 | 
			
		||||
 | 
			
		||||
/*! Proprietary internal error codes */
 | 
			
		||||
#define ATT_ERR_MEMORY                0x70      /*! Out of memory */
 | 
			
		||||
#define ATT_ERR_TIMEOUT               0x71      /*! Transaction timeout */
 | 
			
		||||
#define ATT_ERR_OVERFLOW              0x72      /*! Transaction overflow */
 | 
			
		||||
#define ATT_ERR_INVALID_RSP           0x73      /*! Invalid response PDU */
 | 
			
		||||
#define ATT_ERR_CANCELLED             0x74      /*! Request cancelled */
 | 
			
		||||
#define ATT_ERR_UNDEFINED             0x75      /*! Other undefined error */
 | 
			
		||||
#define ATT_ERR_REQ_NOT_FOUND         0x76      /*! Required characteristic not found */
 | 
			
		||||
#define ATT_ERR_MTU_EXCEEDED          0x77      /*! Attribute PDU length exceeded MTU size */
 | 
			
		||||
#define ATT_CONTINUING                0x78      /*! Procedure continuing */
 | 
			
		||||
 | 
			
		||||
/*! Application error codes */
 | 
			
		||||
#define ATT_ERR_VALUE_RANGE           0x80      /*! Value out of range */
 | 
			
		||||
 | 
			
		||||
/*! PDU types */
 | 
			
		||||
#define ATT_PDU_ERR_RSP               0x01      /*! Error response */
 | 
			
		||||
#define ATT_PDU_MTU_REQ               0x02      /*! Exchange mtu request */
 | 
			
		||||
#define ATT_PDU_MTU_RSP               0x03      /*! Exchange mtu response */
 | 
			
		||||
#define ATT_PDU_FIND_INFO_REQ         0x04      /*! Find information request */
 | 
			
		||||
#define ATT_PDU_FIND_INFO_RSP         0x05      /*! Find information response */
 | 
			
		||||
#define ATT_PDU_FIND_TYPE_REQ         0x06      /*! Find by type value request */
 | 
			
		||||
#define ATT_PDU_FIND_TYPE_RSP         0x07      /*! Find by type value response */
 | 
			
		||||
#define ATT_PDU_READ_TYPE_REQ         0x08      /*! Read by type request */
 | 
			
		||||
#define ATT_PDU_READ_TYPE_RSP         0x09      /*! Read by type response */
 | 
			
		||||
#define ATT_PDU_READ_REQ              0x0A      /*! Read request */
 | 
			
		||||
#define ATT_PDU_READ_RSP              0x0B      /*! Read response */
 | 
			
		||||
#define ATT_PDU_READ_BLOB_REQ         0x0C      /*! Read blob request */
 | 
			
		||||
#define ATT_PDU_READ_BLOB_RSP         0x0D      /*! Read blob response */
 | 
			
		||||
#define ATT_PDU_READ_MULT_REQ         0x0E      /*! Read multiple request */
 | 
			
		||||
#define ATT_PDU_READ_MULT_RSP         0x0F      /*! Read multiple response */
 | 
			
		||||
#define ATT_PDU_READ_GROUP_TYPE_REQ   0x10      /*! Read by group type request */
 | 
			
		||||
#define ATT_PDU_READ_GROUP_TYPE_RSP   0x11      /*! Read by group type response */
 | 
			
		||||
#define ATT_PDU_WRITE_REQ             0x12      /*! Write request */
 | 
			
		||||
#define ATT_PDU_WRITE_RSP             0x13      /*! Write response */
 | 
			
		||||
#define ATT_PDU_WRITE_CMD             0x52      /*! Write command */
 | 
			
		||||
#define ATT_PDU_SIGNED_WRITE_CMD      0xD2      /*! Signed write command */
 | 
			
		||||
#define ATT_PDU_PREP_WRITE_REQ        0x16      /*! Prepare write request */
 | 
			
		||||
#define ATT_PDU_PREP_WRITE_RSP        0x17      /*! Prepare write response */
 | 
			
		||||
#define ATT_PDU_EXEC_WRITE_REQ        0x18      /*! Execute write request */
 | 
			
		||||
#define ATT_PDU_EXEC_WRITE_RSP        0x19      /*! Execute write response */
 | 
			
		||||
#define ATT_PDU_VALUE_NTF             0x1B      /*! Handle value notification */
 | 
			
		||||
#define ATT_PDU_VALUE_IND             0x1D      /*! Handle value indication */
 | 
			
		||||
#define ATT_PDU_VALUE_CNF             0x1E      /*! Handle value confirmation */
 | 
			
		||||
#define ATT_PDU_MAX                   0x1F      /*! PDU Maximum */
 | 
			
		||||
 | 
			
		||||
/*! Length of PDU fixed length fields */
 | 
			
		||||
#define ATT_ERR_RSP_LEN               5
 | 
			
		||||
#define ATT_MTU_REQ_LEN               3
 | 
			
		||||
#define ATT_MTU_RSP_LEN               3
 | 
			
		||||
#define ATT_FIND_INFO_REQ_LEN         5
 | 
			
		||||
#define ATT_FIND_INFO_RSP_LEN         2
 | 
			
		||||
#define ATT_FIND_TYPE_REQ_LEN         7
 | 
			
		||||
#define ATT_FIND_TYPE_RSP_LEN         1
 | 
			
		||||
#define ATT_READ_TYPE_REQ_LEN         5
 | 
			
		||||
#define ATT_READ_TYPE_RSP_LEN         2
 | 
			
		||||
#define ATT_READ_REQ_LEN              3
 | 
			
		||||
#define ATT_READ_RSP_LEN              1
 | 
			
		||||
#define ATT_READ_BLOB_REQ_LEN         5
 | 
			
		||||
#define ATT_READ_BLOB_RSP_LEN         1
 | 
			
		||||
#define ATT_READ_MULT_REQ_LEN         1
 | 
			
		||||
#define ATT_READ_MULT_RSP_LEN         1
 | 
			
		||||
#define ATT_READ_GROUP_TYPE_REQ_LEN   5
 | 
			
		||||
#define ATT_READ_GROUP_TYPE_RSP_LEN   2
 | 
			
		||||
#define ATT_WRITE_REQ_LEN             3
 | 
			
		||||
#define ATT_WRITE_RSP_LEN             1
 | 
			
		||||
#define ATT_WRITE_CMD_LEN             3
 | 
			
		||||
#define ATT_SIGNED_WRITE_CMD_LEN      (ATT_WRITE_CMD_LEN + ATT_AUTH_SIG_LEN)
 | 
			
		||||
#define ATT_PREP_WRITE_REQ_LEN        5
 | 
			
		||||
#define ATT_PREP_WRITE_RSP_LEN        5
 | 
			
		||||
#define ATT_EXEC_WRITE_REQ_LEN        2
 | 
			
		||||
#define ATT_EXEC_WRITE_RSP_LEN        1
 | 
			
		||||
#define ATT_VALUE_NTF_LEN             3
 | 
			
		||||
#define ATT_VALUE_IND_LEN             3
 | 
			
		||||
#define ATT_VALUE_CNF_LEN             1
 | 
			
		||||
 | 
			
		||||
/*! Find information response format */
 | 
			
		||||
#define ATT_FIND_HANDLE_16_UUID       0x01      /*! Handle and 16 bit UUID */
 | 
			
		||||
#define ATT_FIND_HANDLE_128_UUID      0x02      /*! Handle and 128 bit UUID */
 | 
			
		||||
 | 
			
		||||
/*! Execute write request flags */
 | 
			
		||||
#define ATT_EXEC_WRITE_CANCEL         0x00      /*! Cancel all prepared writes */
 | 
			
		||||
#define ATT_EXEC_WRITE_ALL            0x01      /*! Write all pending prepared writes */
 | 
			
		||||
 | 
			
		||||
/*! PDU masks */
 | 
			
		||||
#define ATT_PDU_MASK_SERVER           0x01      /*! Server bit mask */
 | 
			
		||||
#define ATT_PDU_MASK_COMMAND          0x40      /*! Command bit mask */
 | 
			
		||||
#define ATT_PDU_MASK_SIGNED           0x80      /*! Auth signature bit mask */
 | 
			
		||||
 | 
			
		||||
/*! Handles */
 | 
			
		||||
#define ATT_HANDLE_NONE               0x0000
 | 
			
		||||
#define ATT_HANDLE_START              0x0001
 | 
			
		||||
#define ATT_HANDLE_MAX                0xFFFF
 | 
			
		||||
 | 
			
		||||
/*! UUID lengths */
 | 
			
		||||
#define ATT_NO_UUID_LEN               0         /*! Length when no UUID is present ;-) */
 | 
			
		||||
#define ATT_16_UUID_LEN               2         /*! Length in bytes of a 16 bit UUID */
 | 
			
		||||
#define ATT_128_UUID_LEN              16        /*! Length in bytes of a 128 bit UUID */
 | 
			
		||||
 | 
			
		||||
/*! GATT characteristic properties */
 | 
			
		||||
#define ATT_PROP_BROADCAST            0x01      /*! Permit broadcasts */
 | 
			
		||||
#define ATT_PROP_READ                 0x02      /*! Permit reads */
 | 
			
		||||
#define ATT_PROP_WRITE_NO_RSP         0x04      /*! Permit writes without response */
 | 
			
		||||
#define ATT_PROP_WRITE                0x08      /*! Permit writes with response */
 | 
			
		||||
#define ATT_PROP_NOTIFY               0x10      /*! Permit notifications */
 | 
			
		||||
#define ATT_PROP_INDICATE             0x20      /*! Permit indications */
 | 
			
		||||
#define ATT_PROP_AUTHENTICATED        0x40      /*! Permit signed writes */
 | 
			
		||||
#define ATT_PROP_EXTENDED             0x80      /*! More properties defined in extended properties */
 | 
			
		||||
 | 
			
		||||
/*! GATT characteristic extended properties */
 | 
			
		||||
#define ATT_EXT_PROP_RELIABLE_WRITE   0x0001    /*! Permit reliable writes */
 | 
			
		||||
#define ATT_EXT_PROP_WRITEABLE_AUX    0x0002    /*! Permit write to characteristic descriptor */
 | 
			
		||||
 | 
			
		||||
/*! GATT client characteristic configuration */
 | 
			
		||||
#define ATT_CLIENT_CFG_NOTIFY         0x0001    /*! Notify the value */
 | 
			
		||||
#define ATT_CLIENT_CFG_INDICATE       0x0002    /*! Indicate the value */
 | 
			
		||||
 | 
			
		||||
/*! GATT server characteristic configuration */
 | 
			
		||||
#define ATT_SERVER_CFG_BROADCAST      0x0001    /*! Broadcast the value */
 | 
			
		||||
 | 
			
		||||
/*! GATT characteristic format */
 | 
			
		||||
#define ATT_FORMAT_BOOLEAN            0x01      /*! Boolean */
 | 
			
		||||
#define ATT_FORMAT_2BIT               0x02      /*! Unsigned 2 bit integer */
 | 
			
		||||
#define ATT_FORMAT_NIBBLE             0x03      /*! Unsigned 4 bit integer */
 | 
			
		||||
#define ATT_FORMAT_UINT8              0x04      /*! Unsigned 8 bit integer */
 | 
			
		||||
#define ATT_FORMAT_UINT12             0x05      /*! Unsigned 12 bit integer */
 | 
			
		||||
#define ATT_FORMAT_UINT16             0x06      /*! Unsigned 16 bit integer */
 | 
			
		||||
#define ATT_FORMAT_UINT24             0x07      /*! Unsigned 24 bit integer */
 | 
			
		||||
#define ATT_FORMAT_UINT32             0x08      /*! Unsigned 32 bit integer */
 | 
			
		||||
#define ATT_FORMAT_UINT48             0x09      /*! Unsigned 48 bit integer */
 | 
			
		||||
#define ATT_FORMAT_UINT64             0x0A      /*! Unsigned 64 bit integer */
 | 
			
		||||
#define ATT_FORMAT_UINT128            0x0B      /*! Unsigned 128 bit integer */
 | 
			
		||||
#define ATT_FORMAT_SINT8              0x0C      /*! Signed 8 bit integer */
 | 
			
		||||
#define ATT_FORMAT_SINT12             0x0D      /*! Signed 12 bit integer */
 | 
			
		||||
#define ATT_FORMAT_SINT16             0x0E      /*! Signed 16 bit integer */
 | 
			
		||||
#define ATT_FORMAT_SINT24             0x0F      /*! Signed 24 bit integer */
 | 
			
		||||
#define ATT_FORMAT_SINT32             0x10      /*! Signed 32 bit integer */
 | 
			
		||||
#define ATT_FORMAT_SINT48             0x11      /*! Signed 48 bit integer */
 | 
			
		||||
#define ATT_FORMAT_SINT64             0x12      /*! Signed 64 bit integer */
 | 
			
		||||
#define ATT_FORMAT_SINT128            0x13      /*! Signed 128 bit integer */
 | 
			
		||||
#define ATT_FORMAT_FLOAT32            0x14      /*! IEEE-754 32 bit floating point */
 | 
			
		||||
#define ATT_FORMAT_FLOAT64            0x15      /*! IEEE-754 64 bit floating point */
 | 
			
		||||
#define ATT_FORMAT_SFLOAT             0x16      /*! IEEE-11073 16 bit SFLOAT */
 | 
			
		||||
#define ATT_FORMAT_FLOAT              0x17      /*! IEEE-11073 32 bit FLOAT */
 | 
			
		||||
#define ATT_FORMAT_DUINT16            0x18      /*! IEEE-20601 format */
 | 
			
		||||
#define ATT_FORMAT_UTF8               0x19      /*! UTF-8 string */
 | 
			
		||||
#define ATT_FORMAT_UTF16              0x1A      /*! UTF-16 string */
 | 
			
		||||
#define ATT_FORMAT_STRUCT             0x1B      /*! Opaque structure */
 | 
			
		||||
 | 
			
		||||
#ifdef __cplusplus
 | 
			
		||||
};
 | 
			
		||||
#endif
 | 
			
		||||
 | 
			
		||||
#endif /* ATT_DEFS_H */
 | 
			
		||||
| 
						 | 
				
			
			@ -1,67 +0,0 @@
 | 
			
		|||
/*************************************************************************************************/
 | 
			
		||||
/*!
 | 
			
		||||
 *  \file   att_handler.h
 | 
			
		||||
 *
 | 
			
		||||
 *  \brief  Interface to ATT event handler.
 | 
			
		||||
 *
 | 
			
		||||
 *          $Date: 2012-03-29 13:24:04 -0700 (Thu, 29 Mar 2012) $
 | 
			
		||||
 *          $Revision: 287 $
 | 
			
		||||
 *
 | 
			
		||||
 *  Copyright (c) 2009 Wicentric, Inc., all rights reserved.
 | 
			
		||||
 *  Wicentric confidential and proprietary.
 | 
			
		||||
 *
 | 
			
		||||
 *  IMPORTANT.  Your use of this file is governed by a Software License Agreement
 | 
			
		||||
 *  ("Agreement") that must be accepted in order to download or otherwise receive a
 | 
			
		||||
 *  copy of this file.  You may not use or copy this file for any purpose other than
 | 
			
		||||
 *  as described in the Agreement.  If you do not agree to all of the terms of the
 | 
			
		||||
 *  Agreement do not use this file and delete all copies in your possession or control;
 | 
			
		||||
 *  if you do not have a copy of the Agreement, you must contact Wicentric, Inc. prior
 | 
			
		||||
 *  to any use, copying or further distribution of this software.
 | 
			
		||||
 */
 | 
			
		||||
/*************************************************************************************************/
 | 
			
		||||
#ifndef ATT_HANDLER_H
 | 
			
		||||
#define ATT_HANDLER_H
 | 
			
		||||
 | 
			
		||||
#include "wsf_os.h"
 | 
			
		||||
 | 
			
		||||
#ifdef __cplusplus
 | 
			
		||||
extern "C" {
 | 
			
		||||
#endif
 | 
			
		||||
 | 
			
		||||
/**************************************************************************************************
 | 
			
		||||
  Function Declarations
 | 
			
		||||
**************************************************************************************************/
 | 
			
		||||
 | 
			
		||||
/*************************************************************************************************/
 | 
			
		||||
/*!
 | 
			
		||||
 *  \fn     AttHandlerInit
 | 
			
		||||
 *        
 | 
			
		||||
 *  \brief  ATT handler init function called during system initialization.
 | 
			
		||||
 *
 | 
			
		||||
 *  \param  handlerID  WSF handler ID for ATT.
 | 
			
		||||
 *
 | 
			
		||||
 *  \return None.
 | 
			
		||||
 */
 | 
			
		||||
/*************************************************************************************************/
 | 
			
		||||
void AttHandlerInit(wsfHandlerId_t handlerId);
 | 
			
		||||
 | 
			
		||||
 | 
			
		||||
/*************************************************************************************************/
 | 
			
		||||
/*!
 | 
			
		||||
 *  \fn     AttHandler
 | 
			
		||||
 *        
 | 
			
		||||
 *  \brief  WSF event handler for ATT.
 | 
			
		||||
 *
 | 
			
		||||
 *  \param  event   WSF event mask.
 | 
			
		||||
 *  \param  pMsg    WSF message.
 | 
			
		||||
 *
 | 
			
		||||
 *  \return None.
 | 
			
		||||
 */
 | 
			
		||||
/*************************************************************************************************/
 | 
			
		||||
void AttHandler(wsfEventMask_t event, wsfMsgHdr_t *pMsg);
 | 
			
		||||
 | 
			
		||||
#ifdef __cplusplus
 | 
			
		||||
};
 | 
			
		||||
#endif
 | 
			
		||||
 | 
			
		||||
#endif /* ATT_HANDLER_H */
 | 
			
		||||
| 
						 | 
				
			
			@ -1,436 +0,0 @@
 | 
			
		|||
/*************************************************************************************************/
 | 
			
		||||
/*!
 | 
			
		||||
 *  \file   att_uuid.h
 | 
			
		||||
 *        
 | 
			
		||||
 *  \brief  Attribute protocol UUIDs from the Bluetooth specification.
 | 
			
		||||
 *
 | 
			
		||||
 *          $Date: 2015-12-10 08:50:10 -0800 (Thu, 10 Dec 2015) $
 | 
			
		||||
 *          $Revision: 4738 $
 | 
			
		||||
 *  
 | 
			
		||||
 *  Copyright (c) 2011 Wicentric, Inc., all rights reserved.
 | 
			
		||||
 *  Wicentric confidential and proprietary.
 | 
			
		||||
 *
 | 
			
		||||
 *  IMPORTANT.  Your use of this file is governed by a Software License Agreement
 | 
			
		||||
 *  ("Agreement") that must be accepted in order to download or otherwise receive a
 | 
			
		||||
 *  copy of this file.  You may not use or copy this file for any purpose other than
 | 
			
		||||
 *  as described in the Agreement.  If you do not agree to all of the terms of the
 | 
			
		||||
 *  Agreement do not use this file and delete all copies in your possession or control;
 | 
			
		||||
 *  if you do not have a copy of the Agreement, you must contact Wicentric, Inc. prior
 | 
			
		||||
 *  to any use, copying or further distribution of this software.
 | 
			
		||||
 */
 | 
			
		||||
/*************************************************************************************************/
 | 
			
		||||
#ifndef ATT_UUID_H
 | 
			
		||||
#define ATT_UUID_H
 | 
			
		||||
 | 
			
		||||
#include "att_defs.h"
 | 
			
		||||
 | 
			
		||||
#ifdef __cplusplus
 | 
			
		||||
extern "C" {
 | 
			
		||||
#endif
 | 
			
		||||
 | 
			
		||||
/**************************************************************************************************
 | 
			
		||||
  Macros
 | 
			
		||||
**************************************************************************************************/
 | 
			
		||||
 | 
			
		||||
/*! Service UUIDs */
 | 
			
		||||
#define ATT_UUID_GAP_SERVICE                0x1800    /*! Generic Access Profile Service */
 | 
			
		||||
#define ATT_UUID_GATT_SERVICE               0x1801    /*! Generic Attribute Profile Service */
 | 
			
		||||
#define ATT_UUID_IMMEDIATE_ALERT_SERVICE    0x1802    /*! Immediate Alert Service */
 | 
			
		||||
#define ATT_UUID_LINK_LOSS_SERVICE          0x1803    /*! Link Loss Service */
 | 
			
		||||
#define ATT_UUID_TX_POWER_SERVICE           0x1804    /*! Tx Power Service */
 | 
			
		||||
#define ATT_UUID_CURRENT_TIME_SERVICE       0x1805    /*! Current Time Service */
 | 
			
		||||
#define ATT_UUID_REF_TIME_UPDATE_SERVICE    0x1806    /*! Reference Time Update Service */
 | 
			
		||||
#define ATT_UUID_DST_CHANGE_SERVICE         0x1807    /*! Next DST Change Service */
 | 
			
		||||
#define ATT_UUID_GLUCOSE_SERVICE            0x1808    /*! Glucose Service */
 | 
			
		||||
#define ATT_UUID_HEALTH_THERM_SERVICE       0x1809    /*! Health Thermometer Service */
 | 
			
		||||
#define ATT_UUID_DEVICE_INFO_SERVICE        0x180A    /*! Device Information Service */
 | 
			
		||||
#define ATT_UUID_NETWORK_AVAIL_SERVICE      0x180B    /*! Network Availability Service */
 | 
			
		||||
#define ATT_UUID_WATCHDOG_SERVICE           0x180C    /*! Watchdog Service */
 | 
			
		||||
#define ATT_UUID_HEART_RATE_SERVICE         0x180D    /*! Heart Rate Service */
 | 
			
		||||
#define ATT_UUID_PHONE_ALERT_SERVICE        0x180E    /*! Phone Alert Status Service */
 | 
			
		||||
#define ATT_UUID_BATTERY_SERVICE            0x180F    /*! Battery Service */
 | 
			
		||||
#define ATT_UUID_BLOOD_PRESSURE_SERVICE     0x1810    /*! Blood Pressure Service */
 | 
			
		||||
#define ATT_UUID_ALERT_NOTIF_SERVICE        0x1811    /*! Alert Notification Service */
 | 
			
		||||
#define ATT_UUID_HID_SERVICE                0x1812    /*! Human Interface Device Service */
 | 
			
		||||
#define ATT_UUID_SCAN_PARAM_SERVICE         0x1813    /*! Scan Parameter Service */
 | 
			
		||||
 | 
			
		||||
/*! GATT UUIDs */
 | 
			
		||||
#define ATT_UUID_PRIMARY_SERVICE            0x2800    /*! Primary Service */
 | 
			
		||||
#define ATT_UUID_SECONDARY_SERVICE          0x2801    /*! Secondary Service */
 | 
			
		||||
#define ATT_UUID_INCLUDE                    0x2802    /*! Include */
 | 
			
		||||
#define ATT_UUID_CHARACTERISTIC             0x2803    /*! Characteristic */
 | 
			
		||||
 | 
			
		||||
/*! Descriptor UUIDs */
 | 
			
		||||
#define ATT_UUID_CHARACTERISTIC_EXT         0x2900    /*! Characteristic Extended Properties */
 | 
			
		||||
#define ATT_UUID_CHAR_USER_DESC             0x2901    /*! Characteristic User Description */
 | 
			
		||||
#define ATT_UUID_CLIENT_CHAR_CONFIG         0x2902    /*! Client Characteristic Configuration */
 | 
			
		||||
#define ATT_UUID_SERVER_CHAR_CONFIG         0x2903    /*! Server Characteristic Configuration */
 | 
			
		||||
#define ATT_UUID_CHAR_PRES_FORMAT           0x2904    /*! Characteristic Presentation Format */
 | 
			
		||||
#define ATT_UUID_AGGREGATE_FORMAT           0x2905    /*! Characteristic Aggregate Format */
 | 
			
		||||
#define ATT_UUID_VALID_RANGE                0x2906    /*! Valid Range */
 | 
			
		||||
#define ATT_UUID_HID_EXT_REPORT_MAPPING     0x2907    /*! HID External Report ID Mapping */
 | 
			
		||||
#define ATT_UUID_HID_REPORT_ID_MAPPING      0x2908    /*! HID Report ID Mapping */
 | 
			
		||||
 | 
			
		||||
/*! Characteristic UUIDs */
 | 
			
		||||
#define ATT_UUID_DEVICE_NAME                0x2A00    /*! Device Name */
 | 
			
		||||
#define ATT_UUID_APPEARANCE                 0x2A01    /*! Appearance */
 | 
			
		||||
#define ATT_UUID_PERIPH_PRIVACY_FLAG        0x2A02    /*! Peripheral Privacy Flag */
 | 
			
		||||
#define ATT_UUID_RECONN_ADDR                0x2A03    /*! Reconnection Address */
 | 
			
		||||
#define ATT_UUID_PREF_CONN_PARAM            0x2A04    /*! Peripheral Preferred Connection Parameters */
 | 
			
		||||
#define ATT_UUID_SERVICE_CHANGED            0x2A05    /*! Service Changed */
 | 
			
		||||
#define ATT_UUID_ALERT_LEVEL                0x2A06    /*! Alert Level */
 | 
			
		||||
#define ATT_UUID_TX_POWER_LEVEL             0x2A07    /*! Tx Power Level */
 | 
			
		||||
#define ATT_UUID_DATE_TIME                  0x2A08    /*! Date Time */
 | 
			
		||||
#define ATT_UUID_DAY_OF_WEEK                0x2A09    /*! Day of Week */
 | 
			
		||||
#define ATT_UUID_DAY_DATE_TIME              0x2A0A    /*! Day Date Time */
 | 
			
		||||
#define ATT_UUID_EXACT_TIME_100             0x2A0B    /*! Exact Time 100 */
 | 
			
		||||
#define ATT_UUID_EXACT_TIME_256             0x2A0C    /*! Exact Time 256 */
 | 
			
		||||
#define ATT_UUID_DST_OFFSET                 0x2A0D    /*! DST Offset */
 | 
			
		||||
#define ATT_UUID_TIME_ZONE                  0x2A0E    /*! Time Zone */
 | 
			
		||||
#define ATT_UUID_LOCAL_TIME_INFO            0x2A0F    /*! Local Time Information */
 | 
			
		||||
#define ATT_UUID_SECONDARY_TIME_ZONE        0x2A10    /*! Secondary Time Zone */
 | 
			
		||||
#define ATT_UUID_TIME_WITH_DST              0x2A11    /*! Time with DST */
 | 
			
		||||
#define ATT_UUID_TIME_ACCURACY              0x2A12    /*! Time Accuracy */
 | 
			
		||||
#define ATT_UUID_TIME_SOURCE                0x2A13    /*! Time Source */
 | 
			
		||||
#define ATT_UUID_REFERENCE_TIME_INFO        0x2A14    /*! Reference Time Information */
 | 
			
		||||
#define ATT_UUID_TIME_BROADCAST             0x2A15    /*! Time Broadcast */
 | 
			
		||||
#define ATT_UUID_TIME_UPDATE_CP             0x2A16    /*! Time Update Control Point */
 | 
			
		||||
#define ATT_UUID_TIME_UPDATE_STATE          0x2A17    /*! Time Update State */
 | 
			
		||||
#define ATT_UUID_GLUCOSE_MEAS               0x2A18    /*! Glucose Measurement */
 | 
			
		||||
#define ATT_UUID_BATTERY_LEVEL              0x2A19    /*! Battery Level */
 | 
			
		||||
#define ATT_UUID_BATTERY_POWER_STATE        0x2A1A    /*! Battery Power State */
 | 
			
		||||
#define ATT_UUID_BATTERY_LEVEL_STATE        0x2A1B    /*! Battery Level State */
 | 
			
		||||
#define ATT_UUID_TEMP_MEAS                  0x2A1C    /*! Temperature Measurement */
 | 
			
		||||
#define ATT_UUID_TEMP_TYPE                  0x2A1D    /*! Temperature Type */
 | 
			
		||||
#define ATT_UUID_INTERMEDIATE_TEMP          0x2A1E    /*! Intermediate Temperature */
 | 
			
		||||
#define ATT_UUID_TEMP_C                     0x2A1F    /*! Temperature Celsius */
 | 
			
		||||
#define ATT_UUID_TEMP_F                     0x2A20    /*! Temperature Fahrenheit */
 | 
			
		||||
#define ATT_UUID_MEAS_INTERVAL              0x2A21    /*! Measurement Interval */
 | 
			
		||||
#define ATT_UUID_HID_BOOT_KEYBOARD_IN       0x2A22    /*! HID Boot Keyboard In */
 | 
			
		||||
#define ATT_UUID_SYSTEM_ID                  0x2A23    /*! System ID */
 | 
			
		||||
#define ATT_UUID_MODEL_NUMBER               0x2A24    /*! Model Number String */
 | 
			
		||||
#define ATT_UUID_SERIAL_NUMBER              0x2A25    /*! Serial Number String */
 | 
			
		||||
#define ATT_UUID_FIRMWARE_REV               0x2A26    /*! Firmware Revision String */
 | 
			
		||||
#define ATT_UUID_HARDWARE_REV               0x2A27    /*! Hardware Revision String */
 | 
			
		||||
#define ATT_UUID_SOFTWARE_REV               0x2A28    /*! Software Revision String */
 | 
			
		||||
#define ATT_UUID_MANUFACTURER_NAME          0x2A29    /*! Manufacturer Name String */
 | 
			
		||||
#define ATT_UUID_11073_CERT_DATA            0x2A2A    /*! IEEE 11073-20601 Regulatory Certification Data List */
 | 
			
		||||
#define ATT_UUID_CURRENT_TIME               0x2A2B    /*! Current Time */
 | 
			
		||||
#define ATT_UUID_ELEVATION                  0x2A2C    /*! Elevation */
 | 
			
		||||
#define ATT_UUID_LATITUDE                   0x2A2D    /*! Latitude */
 | 
			
		||||
#define ATT_UUID_LONGITUDE                  0x2A2E    /*! Longitude */
 | 
			
		||||
#define ATT_UUID_POSITION_2D                0x2A2F    /*! Position 2D */
 | 
			
		||||
#define ATT_UUID_POSITION_3D                0x2A30    /*! Position 3D */
 | 
			
		||||
#define ATT_UUID_VENDOR_ID                  0x2A31    /*! Vendor ID */
 | 
			
		||||
#define ATT_UUID_HID_BOOT_KEYBOARD_OUT      0x2A32    /*! HID Boot Keyboard Out */
 | 
			
		||||
#define ATT_UUID_HID_BOOT_MOUSE_IN          0x2A33    /*! HID Boot Mouse In */
 | 
			
		||||
#define ATT_UUID_GLUCOSE_MEAS_CONTEXT       0x2A34    /*! Glucose Measurement Context */
 | 
			
		||||
#define ATT_UUID_BP_MEAS                    0x2A35    /*! Blood Pressure Measurement */
 | 
			
		||||
#define ATT_UUID_INTERMEDIATE_BP            0x2A36    /*! Intermediate Cuff Pressure */
 | 
			
		||||
#define ATT_UUID_HR_MEAS                    0x2A37    /*! Heart Rate Measurement */
 | 
			
		||||
#define ATT_UUID_HR_SENSOR_LOC              0x2A38    /*! Body Sensor Location */
 | 
			
		||||
#define ATT_UUID_HR_CP                      0x2A39    /*! Heart Rate Control Point */
 | 
			
		||||
#define ATT_UUID_REMOVABLE                  0x2A3A    /*! Removable */
 | 
			
		||||
#define ATT_UUID_SERVICE_REQ                0x2A3B    /*! Service Required */
 | 
			
		||||
#define ATT_UUID_SCI_TEMP_C                 0x2A3C    /*! Scientific Temperature in Celsius */
 | 
			
		||||
#define ATT_UUID_STRING                     0x2A3D    /*! String */
 | 
			
		||||
#define ATT_UUID_NETWORK_AVAIL              0x2A3E    /*! Network Availability */
 | 
			
		||||
#define ATT_UUID_ALERT_STATUS               0x2A3F    /*! Alert Status */
 | 
			
		||||
#define ATT_UUID_RINGER_CP                  0x2A40    /*! Ringer Control Point */
 | 
			
		||||
#define ATT_UUID_RINGER_SETTING             0x2A41    /*! Ringer Setting */
 | 
			
		||||
#define ATT_UUID_ALERT_CAT_ID_MASK          0x2A42    /*! Alert Category ID Bit Mask */
 | 
			
		||||
#define ATT_UUID_ALERT_CAT_ID               0x2A43    /*! Alert Category ID */
 | 
			
		||||
#define ATT_UUID_ALERT_NOTIF_CP             0x2A44    /*! Alert Notification Control Point */
 | 
			
		||||
#define ATT_UUID_UNREAD_ALERT_STATUS        0x2A45    /*! Unread Alert Status */
 | 
			
		||||
#define ATT_UUID_NEW_ALERT                  0x2A46    /*! New Alert */
 | 
			
		||||
#define ATT_UUID_SUP_NEW_ALERT_CAT          0x2A47    /*! Supported New Alert Category */
 | 
			
		||||
#define ATT_UUID_SUP_UNREAD_ALERT_CAT       0x2A48    /*! Supported Unread Alert Category */
 | 
			
		||||
#define ATT_UUID_BP_FEATURE                 0x2A49    /*! Blood Pressure Feature */
 | 
			
		||||
#define ATT_UUID_HID_INFORMATION            0x2A4A    /*! HID Information */            
 | 
			
		||||
#define ATT_UUID_HID_REPORT_MAP             0x2A4B    /*! HID Report Map */                
 | 
			
		||||
#define ATT_UUID_HID_CONTROL_POINT          0x2A4C    /*! HID Control Point */          
 | 
			
		||||
#define ATT_UUID_HID_REPORT                 0x2A4D    /*! HID Report */                    
 | 
			
		||||
#define ATT_UUID_HID_PROTOCOL_MODE          0x2A4E    /*! HID Protocol Mode */              
 | 
			
		||||
#define ATT_UUID_SCAN_INT_WIND              0x2A4F    /*! Scan Interval Window */       
 | 
			
		||||
#define ATT_UUID_PNP_ID                     0x2A50    /*! PnP ID */                     
 | 
			
		||||
#define ATT_UUID_GLUCOSE_FEATURE            0x2A51    /*! Glucose Feature */            
 | 
			
		||||
#define ATT_UUID_RACP                       0x2A52    /*! Record Access Control Point */
 | 
			
		||||
#define ATT_UUID_CAR                        0x2AA6    /*! Central Address Resolution */
 | 
			
		||||
 | 
			
		||||
/* remove when adopted */
 | 
			
		||||
#define ATT_UUID_GENERIC_CTRL_SERVICE       0xF011
 | 
			
		||||
#define ATT_UUID_COMMAND_ENUM               0xE010    /*! Command Enumeration */
 | 
			
		||||
#define ATT_UUID_GENERIC_COMMAND_CP         0xE011    /*! Generic Command Control Point */
 | 
			
		||||
#define ATT_UUID_WEIGHT_SCALE_SERVICE       0x181D    /*! Weight Scale Service */
 | 
			
		||||
#define ATT_UUID_WEIGHT_MEAS                0x2A9D    /*! Weight Measurement */
 | 
			
		||||
#define ATT_UUID_WEIGHT_SCALE_FEATURE       0x2A9E    /*! Weight Scale Feature */
 | 
			
		||||
 | 
			
		||||
/*! Unit UUIDs */
 | 
			
		||||
#define ATT_UUID_UNITLESS                   0x2700    /*! unitless */
 | 
			
		||||
#define ATT_UUID_LENGTH_M                   0x2701    /*! length metre */
 | 
			
		||||
#define ATT_UUID_MASS_KG                    0x2702    /*! mass kilogram */
 | 
			
		||||
#define ATT_UUID_TIME_SEC                   0x2703    /*! time second */
 | 
			
		||||
#define ATT_UUID_ELECTRIC_CURRENT_AMP       0x2704    /*! electric current ampere */
 | 
			
		||||
#define ATT_UUID_THERMO_TEMP_K              0x2705    /*! thermodynamic temperature kelvin */
 | 
			
		||||
#define ATT_UUID_AMOUNT_OF_SUBSTANCE_MOLE   0x2706    /*! amount of substance mole */
 | 
			
		||||
#define ATT_UUID_LUMINOUS_INTENSITY_CAND    0x2707    /*! luminous intensity candela */
 | 
			
		||||
#define ATT_UUID_AREA_SQ_M                  0x2710    /*! area square metres */
 | 
			
		||||
#define ATT_UUID_VOLUME_CU_M                0x2711    /*! volume cubic metres */
 | 
			
		||||
#define ATT_UUID_VELOCITY_MPS               0x2712    /*! velocity metres per second */
 | 
			
		||||
#define ATT_UUID_ACCELERATION_MPS_SQ        0x2713    /*! acceleration metres per second squared */
 | 
			
		||||
#define ATT_UUID_WAVENUMBER_RECIPROCAL_M    0x2714    /*! wavenumber reciprocal metre */
 | 
			
		||||
#define ATT_UUID_DENSITY_KG_PER_CU_M        0x2715    /*! density kilogram per cubic metre */
 | 
			
		||||
#define ATT_UUID_SURFACE_DENS_KG_PER_SQ_M   0x2716    /*! surface density kilogram per square metre */
 | 
			
		||||
#define ATT_UUID_SPECIFIC_VOL_CU_M_PER_KG   0x2717    /*! specific volume cubic metre per kilogram */
 | 
			
		||||
#define ATT_UUID_CURRENT_DENS_AMP_PER_SQ_M  0x2718    /*! current density ampere per square metre */
 | 
			
		||||
#define ATT_UUID_MAG_FIELD_STR_AMP_PER_M    0x2719    /*! magnetic field strength ampere per metre */
 | 
			
		||||
#define ATT_UUID_AMOUNT_CONC_MOLE_PER_CU_M  0x271A    /*! amount concentration mole per cubic metre */
 | 
			
		||||
#define ATT_UUID_MASS_CONC_KG_PER_CU_M      0x271B    /*! mass concentration kilogram per cubic metre */
 | 
			
		||||
#define ATT_UUID_LUM_CAND_PER_SQ_M          0x271C    /*! luminance candela per square metre */
 | 
			
		||||
#define ATT_UUID_REFRACTIVE_INDEX           0x271D    /*! refractive index */
 | 
			
		||||
#define ATT_UUID_RELATIVE_PERMEABILITY      0x271E    /*! relative permeability */
 | 
			
		||||
#define ATT_UUID_PLANE_ANGLE_R              0x2720    /*! plane angle radian */
 | 
			
		||||
#define ATT_UUID_SOLID_ANGLE_STER           0x2721    /*! solid angle steradian */
 | 
			
		||||
#define ATT_UUID_FREQUENCY_HERTZ            0x2722    /*! frequency hertz */
 | 
			
		||||
#define ATT_UUID_FORCE_NEWT                 0x2723    /*! force newton */
 | 
			
		||||
#define ATT_UUID_PRESSURE_PASCAL            0x2724    /*! pressure pascal */
 | 
			
		||||
#define ATT_UUID_ENERGY_J                   0x2725    /*! energy joule */
 | 
			
		||||
#define ATT_UUID_POWER_W                    0x2726    /*! power watt */
 | 
			
		||||
#define ATT_UUID_ELECTRIC_CHG_C             0x2727    /*! electric charge coulomb */
 | 
			
		||||
#define ATT_UUID_ELECTRIC_POTENTIAL_VOLT    0x2728    /*! electric potential difference volt */
 | 
			
		||||
#define ATT_UUID_CAPACITANCE_F              0x2729    /*! capacitance farad */
 | 
			
		||||
#define ATT_UUID_ELECTRIC_RESISTANCE_OHM    0x272A    /*! electric resistance ohm */
 | 
			
		||||
#define ATT_UUID_ELECTRIC_COND_SIEMENS      0x272B    /*! electric conductance siemens */
 | 
			
		||||
#define ATT_UUID_MAGNETIC_FLEX_WEBER        0x272C    /*! magnetic flex weber */
 | 
			
		||||
#define ATT_UUID_MAGNETIC_FLEX_DENS_TESLA   0x272D    /*! magnetic flex density tesla */
 | 
			
		||||
#define ATT_UUID_INDUCTANCE_H               0x272E    /*! inductance henry */
 | 
			
		||||
#define ATT_UUID_C_TEMP_DEG_C               0x272F    /*! Celsius temperature degree Celsius */
 | 
			
		||||
#define ATT_UUID_LUMINOUS_FLUX_LUMEN        0x2730    /*! luminous flux lumen */
 | 
			
		||||
#define ATT_UUID_ILLUMINANCE_LUX            0x2731    /*! illuminance lux */
 | 
			
		||||
#define ATT_UUID_RADIONUCLIDE_BECQUEREL     0x2732    /*! activity referred to a radionuclide becquerel */
 | 
			
		||||
#define ATT_UUID_ABSORBED_DOSE_GRAY         0x2733    /*! absorbed dose gray */
 | 
			
		||||
#define ATT_UUID_DOSE_EQUIVALENT_SIEVERT    0x2734    /*! dose equivalent sievert */
 | 
			
		||||
#define ATT_UUID_CATALYTIC_ACTIVITY_KATAL   0x2735    /*! catalytic activity katal */
 | 
			
		||||
#define ATT_UUID_DYNAMIC_VISC_PASCAL_SEC    0x2740    /*! dynamic viscosity pascal second */
 | 
			
		||||
#define ATT_UUID_MOMENT_OF_FORCE_NEWT_M     0x2741    /*! moment of force newton metre */
 | 
			
		||||
#define ATT_UUID_SURFACE_TENSION_NEWT_PER_M 0x2742    /*! surface tension newton per metre */
 | 
			
		||||
#define ATT_UUID_ANG_VELOCITY_R_PER_SEC     0x2743    /*! angular velocity radian per second */
 | 
			
		||||
#define ATT_UUID_ANG_ACCEL_R_PER_SEC_SQD    0x2744    /*! angular acceleration radian per second squared */
 | 
			
		||||
#define ATT_UUID_HEAT_FLUX_DEN_W_PER_SQ_M   0x2745    /*! heat flux density watt per square metre */
 | 
			
		||||
#define ATT_UUID_HEAT_CAP_J_PER_K           0x2746    /*! heat capacity joule per kelvin */
 | 
			
		||||
#define ATT_UUID_SPEC_HEAT_CAP_J_PER_KG_K   0x2747    /*! specific heat capacity joule per kilogram kelvin */
 | 
			
		||||
#define ATT_UUID_SPEC_ENERGY_J_PER_KG       0x2748    /*! specific energy joule per kilogram */
 | 
			
		||||
#define ATT_UUID_THERMAL_COND_W_PER_M_K     0x2749    /*! thermal conductivity watt per metre kelvin */
 | 
			
		||||
#define ATT_UUID_ENERGY_DENSITY_J_PER_CU_M  0x274A    /*! energy density joule per cubic metre */
 | 
			
		||||
#define ATT_UUID_ELEC_FIELD_STR_VOLT_PER_M  0x274B    /*! electric field strength volt per metre */
 | 
			
		||||
#define ATT_UUID_ELEC_CHG_DENS_C_PER_CU_M   0x274C    /*! electric charge density coulomb per cubic metre */
 | 
			
		||||
#define ATT_UUID_SURF_CHG_DENS_C_PER_SQ_M   0x274D    /*! surface charge density coulomb per square metre */
 | 
			
		||||
#define ATT_UUID_ELEC_FLUX_DENS_C_PER_SQ_M  0x274E    /*! electric flux density coulomb per square metre */
 | 
			
		||||
#define ATT_UUID_PERMITTIVITY_F_PER_M       0x274F    /*! permittivity farad per metre */
 | 
			
		||||
#define ATT_UUID_PERMEABILITY_H_PER_M       0x2750    /*! permeability henry per metre */
 | 
			
		||||
#define ATT_UUID_MOLAR_ENERGY_J_PER_MOLE    0x2751    /*! molar energy joule per mole */
 | 
			
		||||
#define ATT_UUID_MOLAR_ENTROPY_J_PER_MOLE_K 0x2752    /*! molar entropy joule per mole kelvin */
 | 
			
		||||
#define ATT_UUID_EXPOSURE_C_PER_KG          0x2753    /*! exposure coulomb per kilogram */
 | 
			
		||||
#define ATT_UUID_DOSE_RATE_GRAY_PER_SEC     0x2754    /*! absorbed dose rate gray per second */
 | 
			
		||||
#define ATT_UUID_RT_INTENSITY_W_PER_STER    0x2755    /*! radiant intensity watt per steradian */
 | 
			
		||||
#define ATT_UUID_RCE_W_PER_SQ_METER_STER    0x2756    /*! radiance watt per square meter steradian */
 | 
			
		||||
#define ATT_UUID_CATALYTIC_KATAL_PER_CU_M   0x2757    /*! catalytic activity concentration katal per cubic metre */
 | 
			
		||||
#define ATT_UUID_TIME_MIN                   0x2760    /*! time minute */
 | 
			
		||||
#define ATT_UUID_TIME_HR                    0x2761    /*! time hour */
 | 
			
		||||
#define ATT_UUID_TIME_DAY                   0x2762    /*! time day */
 | 
			
		||||
#define ATT_UUID_PLANE_ANGLE_DEG            0x2763    /*! plane angle degree */
 | 
			
		||||
#define ATT_UUID_PLANE_ANGLE_MIN            0x2764    /*! plane angle minute */
 | 
			
		||||
#define ATT_UUID_PLANE_ANGLE_SEC            0x2765    /*! plane angle second */
 | 
			
		||||
#define ATT_UUID_AREA_HECTARE               0x2766    /*! area hectare */
 | 
			
		||||
#define ATT_UUID_VOLUME_L                   0x2767    /*! volume litre */
 | 
			
		||||
#define ATT_UUID_MASS_TONNE                 0x2768    /*! mass tonne */
 | 
			
		||||
#define ATT_UUID_PRESSURE_BAR               0x2780    /*! pressure bar */
 | 
			
		||||
#define ATT_UUID_PRESSURE_MM                0x2781    /*! pressure millimetre of mercury */
 | 
			
		||||
#define ATT_UUID_LENGTH_ANGSTROM            0x2782    /*! length angstrom */
 | 
			
		||||
#define ATT_UUID_LENGTH_NAUTICAL_MILE       0x2783    /*! length nautical mile */
 | 
			
		||||
#define ATT_UUID_AREA_BARN                  0x2784    /*! area barn */
 | 
			
		||||
#define ATT_UUID_VELOCITY_KNOT              0x2785    /*! velocity knot */
 | 
			
		||||
#define ATT_UUID_LOG_RADIO_QUANT_NEPER      0x2786    /*! logarithmic radio quantity neper */
 | 
			
		||||
#define ATT_UUID_LOG_RADIO_QUANT_BEL        0x2787    /*! logarithmic radio quantity bel */
 | 
			
		||||
#define ATT_UUID_LOG_RADIO_QUANT_DB         0x2788    /*! logarithmic radio quantity decibel */
 | 
			
		||||
#define ATT_UUID_LENGTH_YARD                0x27A0    /*! length yard */
 | 
			
		||||
#define ATT_UUID_LENGTH_PARSEC              0x27A1    /*! length parsec */
 | 
			
		||||
#define ATT_UUID_LENGTH_IN                  0x27A2    /*! length inch */
 | 
			
		||||
#define ATT_UUID_LENGTH_FOOT                0x27A3    /*! length foot */
 | 
			
		||||
#define ATT_UUID_LENGTH_MILE                0x27A4    /*! length mile */
 | 
			
		||||
#define ATT_UUID_PRESSURE_POUND_PER_SQ_IN   0x27A5    /*! pressure pound-force per square inch */
 | 
			
		||||
#define ATT_UUID_VELOCITY_KPH               0x27A6    /*! velocity kilometre per hour */
 | 
			
		||||
#define ATT_UUID_VELOCITY_MPH               0x27A7    /*! velocity mile per hour */
 | 
			
		||||
#define ATT_UUID_ANG_VELOCITY_RPM           0x27A8    /*! angular velocity revolution per minute */
 | 
			
		||||
#define ATT_UUID_ENERGY_GRAM_CALORIE        0x27A9    /*! energy gram calorie */
 | 
			
		||||
#define ATT_UUID_ENERGY_KG_CALORIE          0x27AA    /*! energy kilogram calorie */
 | 
			
		||||
#define ATT_UUID_ENERGY_KILOWATT_HR         0x27AB    /*! energy kilowatt hour */
 | 
			
		||||
#define ATT_UUID_THERM_TEMP_F               0x27AC    /*! thermodynamic temperature degree Fahrenheit */
 | 
			
		||||
#define ATT_UUID_PERCENTAGE                 0x27AD    /*! percentage */
 | 
			
		||||
#define ATT_UUID_PER_MILLE                  0x27AE    /*! per mille */
 | 
			
		||||
#define ATT_UUID_PERIOD_BEATS_PER_MIN       0x27AF    /*! period beats per minute */
 | 
			
		||||
#define ATT_UUID_ELECTRIC_CHG_AMP_HRS       0x27B0    /*! electric charge ampere hours */
 | 
			
		||||
#define ATT_UUID_MASS_DENSITY_MG_PER_DL     0x27B1    /*! mass density milligram per decilitre */
 | 
			
		||||
#define ATT_UUID_MASS_DENSITY_MMOLE_PER_L   0x27B2    /*! mass density millimole per litre */
 | 
			
		||||
#define ATT_UUID_TIME_YEAR                  0x27B3    /*! time year */
 | 
			
		||||
#define ATT_UUID_TIME_MONTH                 0x27B4    /*! time month */
 | 
			
		||||
 | 
			
		||||
/*! Wicentric proprietary UUIDs */
 | 
			
		||||
 | 
			
		||||
/*! Base UUID:  E0262760-08C2-11E1-9073-0E8AC72EXXXX */
 | 
			
		||||
#define ATT_UUID_WICENTRIC_BASE             0x2E, 0xC7, 0x8A, 0x0E, 0x73, 0x90, \
 | 
			
		||||
                                            0xE1, 0x11, 0xC2, 0x08, 0x60, 0x27, 0x26, 0xE0
 | 
			
		||||
 | 
			
		||||
/*! Macro for building Wicentric UUIDs */
 | 
			
		||||
#define ATT_UUID_WICENTRIC_BUILD(part)      UINT16_TO_BYTES(part), ATT_UUID_WICENTRIC_BASE
 | 
			
		||||
 | 
			
		||||
/*! Partial proprietary service UUIDs */
 | 
			
		||||
#define ATT_UUID_P1_SERVICE_PART            0x1001   /*! Proprietary service P1 */
 | 
			
		||||
 | 
			
		||||
/*! Partial proprietary characteristic UUIDs */
 | 
			
		||||
#define ATT_UUID_D1_DATA_PART               0x0001    /*! Proprietary data D1 */
 | 
			
		||||
 | 
			
		||||
/* Proprietary services */
 | 
			
		||||
#define ATT_UUID_P1_SERVICE                 ATT_UUID_WICENTRIC_BUILD(ATT_UUID_P1_SERVICE_PART)
 | 
			
		||||
 | 
			
		||||
/* Proprietary characteristics */
 | 
			
		||||
#define ATT_UUID_D1_DATA                    ATT_UUID_WICENTRIC_BUILD(ATT_UUID_D1_DATA_PART)
 | 
			
		||||
 | 
			
		||||
/**************************************************************************************************
 | 
			
		||||
  Global Variables
 | 
			
		||||
**************************************************************************************************/
 | 
			
		||||
 | 
			
		||||
/*! Service UUIDs */
 | 
			
		||||
extern const uint8_t attGapSvcUuid[ATT_16_UUID_LEN];     /*! Generic Access Profile Service */
 | 
			
		||||
extern const uint8_t attGattSvcUuid[ATT_16_UUID_LEN];    /*! Generic Attribute Profile Service */
 | 
			
		||||
extern const uint8_t attIasSvcUuid[ATT_16_UUID_LEN];     /*! Immediate Alert Service */
 | 
			
		||||
extern const uint8_t attLlsSvcUuid[ATT_16_UUID_LEN];     /*! Link Loss Service */
 | 
			
		||||
extern const uint8_t attTpsSvcUuid[ATT_16_UUID_LEN];     /*! Tx Power Service */
 | 
			
		||||
extern const uint8_t attCtsSvcUuid[ATT_16_UUID_LEN];     /*! Current Time Service */
 | 
			
		||||
extern const uint8_t attRtusSvcUuid[ATT_16_UUID_LEN];    /*! Reference Time Update Service */
 | 
			
		||||
extern const uint8_t attNdcsSvcUuid[ATT_16_UUID_LEN];    /*! Next DST Change Service */
 | 
			
		||||
extern const uint8_t attGlsSvcUuid[ATT_16_UUID_LEN];     /*! Glucose Service */
 | 
			
		||||
extern const uint8_t attHtsSvcUuid[ATT_16_UUID_LEN];     /*! Health Thermometer Service */
 | 
			
		||||
extern const uint8_t attDisSvcUuid[ATT_16_UUID_LEN];     /*! Device Information Service */
 | 
			
		||||
extern const uint8_t attNwaSvcUuid[ATT_16_UUID_LEN];     /*! Network Availability Service */
 | 
			
		||||
extern const uint8_t attWdsSvcUuid[ATT_16_UUID_LEN];     /*! Watchdog Service */
 | 
			
		||||
extern const uint8_t attHrsSvcUuid[ATT_16_UUID_LEN];     /*! Heart Rate Service */
 | 
			
		||||
extern const uint8_t attPassSvcUuid[ATT_16_UUID_LEN];    /*! Phone Alert Status Service */
 | 
			
		||||
extern const uint8_t attBasSvcUuid[ATT_16_UUID_LEN];     /*! Battery Service */
 | 
			
		||||
extern const uint8_t attBpsSvcUuid[ATT_16_UUID_LEN];     /*! Blood Pressure Service */
 | 
			
		||||
extern const uint8_t attAnsSvcUuid[ATT_16_UUID_LEN];     /*! Alert Notification Service */
 | 
			
		||||
extern const uint8_t attHidSvcUuid[ATT_16_UUID_LEN];     /*! Human Interface Device Service */
 | 
			
		||||
extern const uint8_t attSpsSvcUuid[ATT_16_UUID_LEN];     /*! Scan Parameter Service */
 | 
			
		||||
 | 
			
		||||
/*! GATT UUIDs */
 | 
			
		||||
extern const uint8_t attPrimSvcUuid[ATT_16_UUID_LEN];    /*! Primary Service */
 | 
			
		||||
extern const uint8_t attSecSvcUuid[ATT_16_UUID_LEN];     /*! Secondary Service */
 | 
			
		||||
extern const uint8_t attIncUuid[ATT_16_UUID_LEN];        /*! Include */
 | 
			
		||||
extern const uint8_t attChUuid[ATT_16_UUID_LEN];         /*! Characteristic */
 | 
			
		||||
                                                         
 | 
			
		||||
/*! Descriptor UUIDs */                                  
 | 
			
		||||
extern const uint8_t attChExtUuid[ATT_16_UUID_LEN];      /*! Characteristic Extended Properties */
 | 
			
		||||
extern const uint8_t attChUserDescUuid[ATT_16_UUID_LEN]; /*! Characteristic User Description */
 | 
			
		||||
extern const uint8_t attCliChCfgUuid[ATT_16_UUID_LEN];   /*! Client Characteristic Configuration */
 | 
			
		||||
extern const uint8_t attSrvChCfgUuid[ATT_16_UUID_LEN];   /*! Server Characteristic Configuration */
 | 
			
		||||
extern const uint8_t attChPresFmtUuid[ATT_16_UUID_LEN];  /*! Characteristic Presentation Format */
 | 
			
		||||
extern const uint8_t attAggFmtUuid[ATT_16_UUID_LEN];     /*! Characteristic Aggregate Format */
 | 
			
		||||
extern const uint8_t attHidErmUuid[ATT_16_UUID_LEN];     /*! HID External Report Reference */
 | 
			
		||||
extern const uint8_t attHidRimUuid[ATT_16_UUID_LEN];     /*! HID Report ID Mapping */
 | 
			
		||||
extern const uint8_t attValRangeUuid[ATT_16_UUID_LEN];   /*! Valid Range */
 | 
			
		||||
 | 
			
		||||
/*! Characteristic UUIDs */
 | 
			
		||||
extern const uint8_t attDnChUuid[ATT_16_UUID_LEN];       /*! Device Name */
 | 
			
		||||
extern const uint8_t attApChUuid[ATT_16_UUID_LEN];       /*! Appearance */
 | 
			
		||||
extern const uint8_t attPpfChUuid[ATT_16_UUID_LEN];      /*! Peripheral Privacy Flag */
 | 
			
		||||
extern const uint8_t attRaChUuid[ATT_16_UUID_LEN];	     /*! Reconnection Address */
 | 
			
		||||
extern const uint8_t attPpcpChUuid[ATT_16_UUID_LEN];     /*! Peripheral Preferred Connection Parameters */
 | 
			
		||||
extern const uint8_t attScChUuid[ATT_16_UUID_LEN];       /*! Service Changed */
 | 
			
		||||
extern const uint8_t attAlChUuid[ATT_16_UUID_LEN];       /*! Alert Level */
 | 
			
		||||
extern const uint8_t attTxpChUuid[ATT_16_UUID_LEN];      /*! Tx Power Level */
 | 
			
		||||
extern const uint8_t attDtChUuid[ATT_16_UUID_LEN];       /*! Date Time */
 | 
			
		||||
extern const uint8_t attDwChUuid[ATT_16_UUID_LEN];       /*! Day of Week */
 | 
			
		||||
extern const uint8_t attDdtChUuid[ATT_16_UUID_LEN];      /*! Day Date Time */
 | 
			
		||||
extern const uint8_t attEt100ChUuid[ATT_16_UUID_LEN];    /*! Exact Time 100 */
 | 
			
		||||
extern const uint8_t attEt256ChUuid[ATT_16_UUID_LEN];    /*! Exact Time 256 */
 | 
			
		||||
extern const uint8_t attDstoChUuid[ATT_16_UUID_LEN];     /*! DST Offset */
 | 
			
		||||
extern const uint8_t attTzChUuid[ATT_16_UUID_LEN];       /*! Time Zone */
 | 
			
		||||
extern const uint8_t attLtiChUuid[ATT_16_UUID_LEN];      /*! Local Time Information */
 | 
			
		||||
extern const uint8_t attStzChUuid[ATT_16_UUID_LEN];      /*! Secondary Time Zone */
 | 
			
		||||
extern const uint8_t attTdstChUuid[ATT_16_UUID_LEN];     /*! Time with DST */
 | 
			
		||||
extern const uint8_t attTaChUuid[ATT_16_UUID_LEN];       /*! Time Accuracy */
 | 
			
		||||
extern const uint8_t attTsChUuid[ATT_16_UUID_LEN];       /*! Time Source */
 | 
			
		||||
extern const uint8_t attRtiChUuid[ATT_16_UUID_LEN];      /*! Reference Time Information */
 | 
			
		||||
extern const uint8_t attTbChUuid[ATT_16_UUID_LEN];       /*! Time Broadcast */
 | 
			
		||||
extern const uint8_t attTucpChUuid[ATT_16_UUID_LEN];     /*! Time Update Control Point */
 | 
			
		||||
extern const uint8_t attTusChUuid[ATT_16_UUID_LEN];      /*! Time Update State */
 | 
			
		||||
extern const uint8_t attGlmChUuid[ATT_16_UUID_LEN];      /*! Glucose Measurement */
 | 
			
		||||
extern const uint8_t attBlChUuid[ATT_16_UUID_LEN];       /*! Battery Level */
 | 
			
		||||
extern const uint8_t attBpsChUuid[ATT_16_UUID_LEN];      /*! Battery Power State */
 | 
			
		||||
extern const uint8_t attBlsChUuid[ATT_16_UUID_LEN];      /*! Battery Level State */
 | 
			
		||||
extern const uint8_t attTmChUuid[ATT_16_UUID_LEN];       /*! Temperature Measurement */
 | 
			
		||||
extern const uint8_t attTtChUuid[ATT_16_UUID_LEN];       /*! Temperature Type */
 | 
			
		||||
extern const uint8_t attItChUuid[ATT_16_UUID_LEN];       /*! Intermediate Temperature */
 | 
			
		||||
extern const uint8_t attTcelChUuid[ATT_16_UUID_LEN];     /*! Temperature Celsius */
 | 
			
		||||
extern const uint8_t attTfahChUuid[ATT_16_UUID_LEN];     /*! Temperature Fahrenheit */
 | 
			
		||||
extern const uint8_t attSidChUuid[ATT_16_UUID_LEN];      /*! System ID */
 | 
			
		||||
extern const uint8_t attMnsChUuid[ATT_16_UUID_LEN];      /*! Model Number String */
 | 
			
		||||
extern const uint8_t attSnsChUuid[ATT_16_UUID_LEN];      /*! Serial Number String */
 | 
			
		||||
extern const uint8_t attFrsChUuid[ATT_16_UUID_LEN];      /*! Firmware Revision String */
 | 
			
		||||
extern const uint8_t attHrsChUuid[ATT_16_UUID_LEN];      /*! Hardware Revision String */
 | 
			
		||||
extern const uint8_t attSrsChUuid[ATT_16_UUID_LEN];      /*! Software Revision String */
 | 
			
		||||
extern const uint8_t attMfnsChUuid[ATT_16_UUID_LEN];     /*! Manufacturer Name String */
 | 
			
		||||
extern const uint8_t attIeeeChUuid[ATT_16_UUID_LEN];     /*! IEEE 11073-20601 Regulatory Certification Data List */
 | 
			
		||||
extern const uint8_t attCtChUuid[ATT_16_UUID_LEN];       /*! Current Time */
 | 
			
		||||
extern const uint8_t attElChUuid[ATT_16_UUID_LEN];       /*! Elevation */
 | 
			
		||||
extern const uint8_t attLatChUuid[ATT_16_UUID_LEN];      /*! Latitude */
 | 
			
		||||
extern const uint8_t attLongChUuid[ATT_16_UUID_LEN];     /*! Longitude */
 | 
			
		||||
extern const uint8_t attP2dChUuid[ATT_16_UUID_LEN];      /*! Position 2D */
 | 
			
		||||
extern const uint8_t attP3dChUuid[ATT_16_UUID_LEN];      /*! Position 3D */
 | 
			
		||||
extern const uint8_t attVidChUuid[ATT_16_UUID_LEN];      /*! Vendor ID */
 | 
			
		||||
extern const uint8_t attGlmcChUuid[ATT_16_UUID_LEN];     /*! Glucose Measurement Context */
 | 
			
		||||
extern const uint8_t attBpmChUuid[ATT_16_UUID_LEN];      /*! Blood Pressure Measurement */
 | 
			
		||||
extern const uint8_t attIcpChUuid[ATT_16_UUID_LEN];      /*! Intermediate Cuff Pressure */
 | 
			
		||||
extern const uint8_t attHrmChUuid[ATT_16_UUID_LEN];      /*! Heart Rate Measurement */
 | 
			
		||||
extern const uint8_t attBslChUuid[ATT_16_UUID_LEN];      /*! Body Sensor Location */
 | 
			
		||||
extern const uint8_t attHrcpChUuid[ATT_16_UUID_LEN];     /*! Heart Rate Control Point */
 | 
			
		||||
extern const uint8_t attRemChUuid[ATT_16_UUID_LEN];      /*! Removable */
 | 
			
		||||
extern const uint8_t attSrChUuid[ATT_16_UUID_LEN];       /*! Service Required */
 | 
			
		||||
extern const uint8_t attStcChUuid[ATT_16_UUID_LEN];      /*! Scientific Temperature in Celsius */
 | 
			
		||||
extern const uint8_t attStrChUuid[ATT_16_UUID_LEN];      /*! String */
 | 
			
		||||
extern const uint8_t attNwaChUuid[ATT_16_UUID_LEN];      /*! Network Availability */
 | 
			
		||||
extern const uint8_t attAsChUuid[ATT_16_UUID_LEN];       /*! Alert Status */
 | 
			
		||||
extern const uint8_t attRcpChUuid[ATT_16_UUID_LEN];      /*! Ringer Control Point */
 | 
			
		||||
extern const uint8_t attRsChUuid[ATT_16_UUID_LEN];       /*! Ringer Setting */
 | 
			
		||||
extern const uint8_t attAcbmChUuid[ATT_16_UUID_LEN];     /*! Alert Category ID Bit Mask */
 | 
			
		||||
extern const uint8_t attAcChUuid[ATT_16_UUID_LEN];       /*! Alert Category ID */
 | 
			
		||||
extern const uint8_t attAncpChUuid[ATT_16_UUID_LEN];     /*! Alert Notification Control Point */
 | 
			
		||||
extern const uint8_t attUasChUuid[ATT_16_UUID_LEN];      /*! Unread Alert Status */
 | 
			
		||||
extern const uint8_t attNaChUuid[ATT_16_UUID_LEN];       /*! New Alert */
 | 
			
		||||
extern const uint8_t attSnacChUuid[ATT_16_UUID_LEN];     /*! Supported New Alert Category */
 | 
			
		||||
extern const uint8_t attSuacChUuid[ATT_16_UUID_LEN];     /*! Supported Unread Alert Category */
 | 
			
		||||
extern const uint8_t attBpfChUuid[ATT_16_UUID_LEN];      /*! Blood Pressure Feature */
 | 
			
		||||
extern const uint8_t attHidBmiChUuid[ATT_16_UUID_LEN];   /*! HID Information */            
 | 
			
		||||
extern const uint8_t attHidBkiChUuid[ATT_16_UUID_LEN];   /*! HID Information */            
 | 
			
		||||
extern const uint8_t attHidBkoChUuid[ATT_16_UUID_LEN];   /*! HID Information */            
 | 
			
		||||
extern const uint8_t attHidiChUuid[ATT_16_UUID_LEN];     /*! HID Information */            
 | 
			
		||||
extern const uint8_t attHidRmChUuid[ATT_16_UUID_LEN];    /*! Report Map */                
 | 
			
		||||
extern const uint8_t attHidcpChUuid[ATT_16_UUID_LEN];    /*! HID Control Point */          
 | 
			
		||||
extern const uint8_t attHidRepChUuid[ATT_16_UUID_LEN];   /*! Report */                    
 | 
			
		||||
extern const uint8_t attHidPmChUuid[ATT_16_UUID_LEN];    /*! Protocol Mode */              
 | 
			
		||||
extern const uint8_t attSiwChUuid[ATT_16_UUID_LEN];      /*! Scan Interval Window */       
 | 
			
		||||
extern const uint8_t attPnpChUuid[ATT_16_UUID_LEN];      /*! PnP ID */                     
 | 
			
		||||
extern const uint8_t attGlfChUuid[ATT_16_UUID_LEN];      /*! Glucose Feature */            
 | 
			
		||||
extern const uint8_t attRacpChUuid[ATT_16_UUID_LEN];     /*! Record Access Control Point */
 | 
			
		||||
extern const uint8_t attCarChUuid[ATT_16_UUID_LEN];      /*! Central Address Resolution */
 | 
			
		||||
 | 
			
		||||
/* remove when adopted */
 | 
			
		||||
extern const uint8_t attWssSvcUuid[ATT_16_UUID_LEN];      /*! Weight scale service */
 | 
			
		||||
extern const uint8_t attWmChUuid[ATT_16_UUID_LEN];        /*! Weight measurement */
 | 
			
		||||
extern const uint8_t attWsfChUuid[ATT_16_UUID_LEN];       /*! Weight scale feature */
 | 
			
		||||
 | 
			
		||||
#ifdef __cplusplus
 | 
			
		||||
};
 | 
			
		||||
#endif
 | 
			
		||||
 | 
			
		||||
#endif /* ATT_UUID_H */
 | 
			
		||||
										
											
												File diff suppressed because it is too large
												Load Diff
											
										
									
								
							| 
						 | 
				
			
			@ -1,67 +0,0 @@
 | 
			
		|||
/*************************************************************************************************/
 | 
			
		||||
/*!
 | 
			
		||||
 *  \file   dm_handler.h
 | 
			
		||||
 *
 | 
			
		||||
 *  \brief  Interface to DM event handler.
 | 
			
		||||
 *
 | 
			
		||||
 *          $Date: 2012-03-29 13:24:04 -0700 (Thu, 29 Mar 2012) $
 | 
			
		||||
 *          $Revision: 287 $
 | 
			
		||||
 *
 | 
			
		||||
 *  Copyright (c) 2009 Wicentric, Inc., all rights reserved.
 | 
			
		||||
 *  Wicentric confidential and proprietary.
 | 
			
		||||
 *
 | 
			
		||||
 *  IMPORTANT.  Your use of this file is governed by a Software License Agreement
 | 
			
		||||
 *  ("Agreement") that must be accepted in order to download or otherwise receive a
 | 
			
		||||
 *  copy of this file.  You may not use or copy this file for any purpose other than
 | 
			
		||||
 *  as described in the Agreement.  If you do not agree to all of the terms of the
 | 
			
		||||
 *  Agreement do not use this file and delete all copies in your possession or control;
 | 
			
		||||
 *  if you do not have a copy of the Agreement, you must contact Wicentric, Inc. prior
 | 
			
		||||
 *  to any use, copying or further distribution of this software.
 | 
			
		||||
 */
 | 
			
		||||
/*************************************************************************************************/
 | 
			
		||||
#ifndef DM_HANDLER_H
 | 
			
		||||
#define DM_HANDLER_H
 | 
			
		||||
 | 
			
		||||
#include "wsf_os.h"
 | 
			
		||||
 | 
			
		||||
#ifdef __cplusplus
 | 
			
		||||
extern "C" {
 | 
			
		||||
#endif
 | 
			
		||||
 | 
			
		||||
/**************************************************************************************************
 | 
			
		||||
  Function Declarations
 | 
			
		||||
**************************************************************************************************/
 | 
			
		||||
 | 
			
		||||
/*************************************************************************************************/
 | 
			
		||||
/*!
 | 
			
		||||
 *  \fn     DmHandlerInit
 | 
			
		||||
 *        
 | 
			
		||||
 *  \brief  DM handler init function called during system initialization.
 | 
			
		||||
 *
 | 
			
		||||
 *  \param  handlerID  WSF handler ID for DM.
 | 
			
		||||
 *
 | 
			
		||||
 *  \return None.
 | 
			
		||||
 */
 | 
			
		||||
/*************************************************************************************************/
 | 
			
		||||
void DmHandlerInit(wsfHandlerId_t handlerId);
 | 
			
		||||
 | 
			
		||||
 | 
			
		||||
/*************************************************************************************************/
 | 
			
		||||
/*!
 | 
			
		||||
 *  \fn     DmHandler
 | 
			
		||||
 *        
 | 
			
		||||
 *  \brief  WSF event handler for DM.
 | 
			
		||||
 *
 | 
			
		||||
 *  \param  event   WSF event mask.
 | 
			
		||||
 *  \param  pMsg    WSF message.
 | 
			
		||||
 *
 | 
			
		||||
 *  \return None.
 | 
			
		||||
 */
 | 
			
		||||
/*************************************************************************************************/
 | 
			
		||||
void DmHandler(wsfEventMask_t event, wsfMsgHdr_t *pMsg);
 | 
			
		||||
 | 
			
		||||
#ifdef __cplusplus
 | 
			
		||||
};
 | 
			
		||||
#endif
 | 
			
		||||
 | 
			
		||||
#endif /* DM_HANDLER_H */
 | 
			
		||||
| 
						 | 
				
			
			@ -1,596 +0,0 @@
 | 
			
		|||
/*************************************************************************************************/
 | 
			
		||||
/*!
 | 
			
		||||
 *  \file   hci_api.h
 | 
			
		||||
 *
 | 
			
		||||
 *  \brief  HCI subsystem API.
 | 
			
		||||
 *
 | 
			
		||||
 *          $Date: 2016-04-05 14:14:53 -0700 (Tue, 05 Apr 2016) $
 | 
			
		||||
 *          $Revision: 6646 $
 | 
			
		||||
 *
 | 
			
		||||
 *  Copyright (c) 2009 Wicentric, Inc., all rights reserved.
 | 
			
		||||
 *  Wicentric confidential and proprietary.
 | 
			
		||||
 *
 | 
			
		||||
 *  IMPORTANT.  Your use of this file is governed by a Software License Agreement
 | 
			
		||||
 *  ("Agreement") that must be accepted in order to download or otherwise receive a
 | 
			
		||||
 *  copy of this file.  You may not use or copy this file for any purpose other than
 | 
			
		||||
 *  as described in the Agreement.  If you do not agree to all of the terms of the
 | 
			
		||||
 *  Agreement do not use this file and delete all copies in your possession or control;
 | 
			
		||||
 *  if you do not have a copy of the Agreement, you must contact Wicentric, Inc. prior
 | 
			
		||||
 *  to any use, copying or further distribution of this software.
 | 
			
		||||
 */
 | 
			
		||||
/*************************************************************************************************/
 | 
			
		||||
#ifndef HCI_API_H
 | 
			
		||||
#define HCI_API_H
 | 
			
		||||
 | 
			
		||||
#include "wsf_types.h"
 | 
			
		||||
#include "hci_defs.h"
 | 
			
		||||
#include "wsf_os.h"
 | 
			
		||||
#include "bda.h"
 | 
			
		||||
 | 
			
		||||
#ifdef __cplusplus
 | 
			
		||||
extern "C" {
 | 
			
		||||
#endif
 | 
			
		||||
 | 
			
		||||
/**************************************************************************************************
 | 
			
		||||
  Macros
 | 
			
		||||
**************************************************************************************************/
 | 
			
		||||
 | 
			
		||||
/*! Internal event values for the HCI event and sec callbacks */
 | 
			
		||||
#define HCI_RESET_SEQ_CMPL_CBACK_EVT                     0   /*! Reset sequence complete */
 | 
			
		||||
#define HCI_LE_CONN_CMPL_CBACK_EVT                       1   /*! LE connection complete */
 | 
			
		||||
#define HCI_LE_ENHANCED_CONN_CMPL_CBACK_EVT              2   /*! LE enhanced connection complete */
 | 
			
		||||
#define HCI_DISCONNECT_CMPL_CBACK_EVT                    3   /*! LE disconnect complete */
 | 
			
		||||
#define HCI_LE_CONN_UPDATE_CMPL_CBACK_EVT                4   /*! LE connection update complete */
 | 
			
		||||
#define HCI_LE_CREATE_CONN_CANCEL_CMD_CMPL_CBACK_EVT     5   /*! LE create connection cancel command complete */
 | 
			
		||||
#define HCI_LE_ADV_REPORT_CBACK_EVT                      6   /*! LE advertising report */
 | 
			
		||||
#define HCI_READ_RSSI_CMD_CMPL_CBACK_EVT                 7   /*! Read RSSI command complete */
 | 
			
		||||
#define HCI_LE_READ_CHAN_MAP_CMD_CMPL_CBACK_EVT          8   /*! LE Read channel map command complete */
 | 
			
		||||
#define HCI_READ_TX_PWR_LVL_CMD_CMPL_CBACK_EVT           9   /*! Read transmit power level command complete */
 | 
			
		||||
#define HCI_READ_REMOTE_VER_INFO_CMPL_CBACK_EVT          10  /*! Read remote version information complete */
 | 
			
		||||
#define HCI_LE_READ_REMOTE_FEAT_CMPL_CBACK_EVT           11  /*! LE read remote features complete */
 | 
			
		||||
#define HCI_LE_LTK_REQ_REPL_CMD_CMPL_CBACK_EVT           12  /*! LE LTK request reply command complete */
 | 
			
		||||
#define HCI_LE_LTK_REQ_NEG_REPL_CMD_CMPL_CBACK_EVT       13  /*! LE LTK request negative reply command complete */
 | 
			
		||||
#define HCI_ENC_KEY_REFRESH_CMPL_CBACK_EVT               14  /*! Encryption key refresh complete */
 | 
			
		||||
#define HCI_ENC_CHANGE_CBACK_EVT                         15  /*! Encryption change */
 | 
			
		||||
#define HCI_LE_LTK_REQ_CBACK_EVT                         16  /*! LE LTK request */
 | 
			
		||||
#define HCI_VENDOR_SPEC_CMD_STATUS_CBACK_EVT             17  /*! Vendor specific command status */
 | 
			
		||||
#define HCI_VENDOR_SPEC_CMD_CMPL_CBACK_EVT               18  /*! Vendor specific command complete */
 | 
			
		||||
#define HCI_VENDOR_SPEC_CBACK_EVT                        19  /*! Vendor specific */
 | 
			
		||||
#define HCI_HW_ERROR_CBACK_EVT                           20  /*! Hardware error */
 | 
			
		||||
#define HCI_LE_ADD_DEV_TO_RES_LIST_CMD_CMPL_CBACK_EVT    21  /*! LE add device to resolving list command complete */
 | 
			
		||||
#define HCI_LE_REM_DEV_FROM_RES_LIST_CMD_CMPL_CBACK_EVT  22  /*! LE remove device from resolving command complete */
 | 
			
		||||
#define HCI_LE_CLEAR_RES_LIST_CMD_CMPL_CBACK_EVT         23  /*! LE clear resolving list command complete */
 | 
			
		||||
#define HCI_LE_READ_PEER_RES_ADDR_CMD_CMPL_CBACK_EVT     24  /*! LE read peer resolving address command complete */
 | 
			
		||||
#define HCI_LE_READ_LOCAL_RES_ADDR_CMD_CMPL_CBACK_EVT    25  /*! LE read local resolving address command complete */
 | 
			
		||||
#define HCI_LE_SET_ADDR_RES_ENABLE_CMD_CMPL_CBACK_EVT    26  /*! LE set address resolving enable command complete */
 | 
			
		||||
#define HCI_LE_ENCRYPT_CMD_CMPL_CBACK_EVT                27  /*! LE encrypt command complete */
 | 
			
		||||
#define HCI_LE_RAND_CMD_CMPL_CBACK_EVT                   28  /*! LE rand command complete */
 | 
			
		||||
#define HCI_LE_REM_CONN_PARAM_REP_CMD_CMPL_CBACK_EVT     29  /*! LE remote connection parameter request reply complete */
 | 
			
		||||
#define HCI_LE_REM_CONN_PARAM_NEG_REP_CMD_CMPL_CBACK_EVT 30  /*! LE remote connection parameter request negative reply complete */
 | 
			
		||||
#define HCI_LE_READ_DEF_DATA_LEN_CMD_CMPL_CBACK_EVT      31  /*! LE read suggested default data length command complete */
 | 
			
		||||
#define HCI_LE_WRITE_DEF_DATA_LEN_CMD_CMPL_CBACK_EVT     32  /*! LE write suggested default data length command complete */
 | 
			
		||||
#define HCI_LE_SET_DATA_LEN_CMD_CMPL_CBACK_EVT           33  /*! LE set data length command complete */
 | 
			
		||||
#define HCI_LE_READ_MAX_DATA_LEN_CMD_CMPL_CBACK_EVT      34  /*! LE read maximum data length command complete */
 | 
			
		||||
#define HCI_LE_REM_CONN_PARAM_REQ_CBACK_EVT              35  /*! LE remote connection parameter request */
 | 
			
		||||
#define HCI_LE_DATA_LEN_CHANGE_CBACK_EVT                 36  /*! LE data length change */
 | 
			
		||||
#define HCI_LE_READ_LOCAL_P256_PUB_KEY_CMPL_CBACK_EVT    37  /*! LE read local P-256 public key */
 | 
			
		||||
#define HCI_LE_GENERATE_DHKEY_CMPL_CBACK_EVT             38  /*! LE generate DHKey complete */
 | 
			
		||||
#define HCI_WRITE_AUTH_PAYLOAD_TO_CMD_CMPL_CBACK_EVT     39  /*! Write authenticated payload timeout command complete */
 | 
			
		||||
#define HCI_AUTH_PAYLOAD_TO_EXPIRED_CBACK_EVT            40  /*! Authenticated payload timeout expired event */
 | 
			
		||||
 | 
			
		||||
/**************************************************************************************************
 | 
			
		||||
  Data Types
 | 
			
		||||
**************************************************************************************************/
 | 
			
		||||
 | 
			
		||||
/*! Connection specification type */
 | 
			
		||||
typedef struct
 | 
			
		||||
{
 | 
			
		||||
  uint16_t            connIntervalMin;
 | 
			
		||||
  uint16_t            connIntervalMax;
 | 
			
		||||
  uint16_t            connLatency;
 | 
			
		||||
  uint16_t            supTimeout;
 | 
			
		||||
  uint16_t            minCeLen;
 | 
			
		||||
  uint16_t            maxCeLen;
 | 
			
		||||
} hciConnSpec_t;
 | 
			
		||||
 | 
			
		||||
/*! LE connection complete event */
 | 
			
		||||
typedef struct
 | 
			
		||||
{
 | 
			
		||||
  wsfMsgHdr_t         hdr;
 | 
			
		||||
  uint8_t             status;
 | 
			
		||||
  uint16_t            handle;
 | 
			
		||||
  uint8_t             role;
 | 
			
		||||
  uint8_t             addrType;
 | 
			
		||||
  bdAddr_t            peerAddr;
 | 
			
		||||
  uint16_t            connInterval;
 | 
			
		||||
  uint16_t            connLatency;
 | 
			
		||||
  uint16_t            supTimeout;
 | 
			
		||||
  uint8_t             clockAccuracy;
 | 
			
		||||
 | 
			
		||||
  /* enhanced fields */
 | 
			
		||||
  bdAddr_t            localRpa;
 | 
			
		||||
  bdAddr_t            peerRpa;
 | 
			
		||||
} hciLeConnCmplEvt_t;
 | 
			
		||||
 | 
			
		||||
/*! Disconnect complete event */
 | 
			
		||||
typedef struct
 | 
			
		||||
{
 | 
			
		||||
  wsfMsgHdr_t         hdr;
 | 
			
		||||
  uint8_t             status;
 | 
			
		||||
  uint16_t            handle;
 | 
			
		||||
  uint8_t             reason;
 | 
			
		||||
} hciDisconnectCmplEvt_t;
 | 
			
		||||
 | 
			
		||||
/*! LE connection update complete event */
 | 
			
		||||
typedef struct
 | 
			
		||||
{
 | 
			
		||||
  wsfMsgHdr_t         hdr;
 | 
			
		||||
  uint8_t             status;
 | 
			
		||||
  uint16_t            handle;
 | 
			
		||||
  uint16_t            connInterval;
 | 
			
		||||
  uint16_t            connLatency;
 | 
			
		||||
  uint16_t            supTimeout;
 | 
			
		||||
} hciLeConnUpdateCmplEvt_t;
 | 
			
		||||
 | 
			
		||||
/*! LE create connection cancel command complete event */
 | 
			
		||||
typedef struct
 | 
			
		||||
{
 | 
			
		||||
  wsfMsgHdr_t         hdr;
 | 
			
		||||
  uint8_t             status;
 | 
			
		||||
} hciLeCreateConnCancelCmdCmplEvt_t;
 | 
			
		||||
 | 
			
		||||
/*! LE advertising report event */
 | 
			
		||||
typedef struct
 | 
			
		||||
{
 | 
			
		||||
  wsfMsgHdr_t         hdr;
 | 
			
		||||
  uint8_t             *pData;
 | 
			
		||||
  uint8_t             len;
 | 
			
		||||
  int8_t              rssi;
 | 
			
		||||
  uint8_t             eventType;
 | 
			
		||||
  uint8_t             addrType;
 | 
			
		||||
  bdAddr_t            addr;
 | 
			
		||||
 | 
			
		||||
  /* direct fields */
 | 
			
		||||
  uint8_t             directAddrType;
 | 
			
		||||
  bdAddr_t            directAddr;
 | 
			
		||||
} hciLeAdvReportEvt_t;
 | 
			
		||||
 | 
			
		||||
/*! Read RSSI command complete event */
 | 
			
		||||
typedef struct
 | 
			
		||||
{
 | 
			
		||||
  wsfMsgHdr_t         hdr;
 | 
			
		||||
  uint8_t             status;
 | 
			
		||||
  uint16_t            handle;
 | 
			
		||||
  int8_t              rssi;
 | 
			
		||||
} hciReadRssiCmdCmplEvt_t;
 | 
			
		||||
 | 
			
		||||
/*! LE Read channel map command complete event */
 | 
			
		||||
typedef struct
 | 
			
		||||
{
 | 
			
		||||
  wsfMsgHdr_t         hdr;
 | 
			
		||||
  uint8_t             status;
 | 
			
		||||
  uint16_t            handle;
 | 
			
		||||
  uint8_t             chanMap[HCI_CHAN_MAP_LEN];
 | 
			
		||||
} hciReadChanMapCmdCmplEvt_t;
 | 
			
		||||
 | 
			
		||||
/*! Read transmit power level command complete event */
 | 
			
		||||
typedef struct
 | 
			
		||||
{
 | 
			
		||||
  wsfMsgHdr_t         hdr;
 | 
			
		||||
  uint8_t             status;
 | 
			
		||||
  uint8_t             handle;
 | 
			
		||||
  int8_t              pwrLvl;
 | 
			
		||||
} hciReadTxPwrLvlCmdCmplEvt_t;
 | 
			
		||||
 | 
			
		||||
/*! Read remote version information complete event */
 | 
			
		||||
typedef struct
 | 
			
		||||
{
 | 
			
		||||
  wsfMsgHdr_t         hdr;
 | 
			
		||||
  uint8_t             status;
 | 
			
		||||
  uint16_t            handle;
 | 
			
		||||
  uint8_t             version;
 | 
			
		||||
  uint16_t            mfrName;
 | 
			
		||||
  uint16_t            subversion;
 | 
			
		||||
} hciReadRemoteVerInfoCmplEvt_t;
 | 
			
		||||
 | 
			
		||||
/*! LE read remote features complete event */
 | 
			
		||||
typedef struct
 | 
			
		||||
{
 | 
			
		||||
  wsfMsgHdr_t         hdr;
 | 
			
		||||
  uint8_t             status;
 | 
			
		||||
  uint16_t            handle;
 | 
			
		||||
  uint8_t             features[HCI_FEAT_LEN];
 | 
			
		||||
} hciLeReadRemoteFeatCmplEvt_t;
 | 
			
		||||
 | 
			
		||||
/*! LE LTK request reply command complete event */
 | 
			
		||||
typedef struct
 | 
			
		||||
{
 | 
			
		||||
  wsfMsgHdr_t         hdr;
 | 
			
		||||
  uint8_t             status;
 | 
			
		||||
  uint16_t            handle;
 | 
			
		||||
} hciLeLtkReqReplCmdCmplEvt_t;
 | 
			
		||||
 | 
			
		||||
/*! LE LTK request negative reply command complete event */
 | 
			
		||||
typedef struct
 | 
			
		||||
{
 | 
			
		||||
  wsfMsgHdr_t         hdr;
 | 
			
		||||
  uint8_t             status;
 | 
			
		||||
  uint16_t            handle;
 | 
			
		||||
} hciLeLtkReqNegReplCmdCmplEvt_t;
 | 
			
		||||
 | 
			
		||||
/*! Encryption key refresh complete event */
 | 
			
		||||
typedef struct
 | 
			
		||||
{
 | 
			
		||||
  wsfMsgHdr_t         hdr;
 | 
			
		||||
  uint8_t             status;
 | 
			
		||||
  uint16_t            handle;
 | 
			
		||||
} hciEncKeyRefreshCmpl_t;
 | 
			
		||||
 | 
			
		||||
/*! Encryption change event */
 | 
			
		||||
typedef struct
 | 
			
		||||
{
 | 
			
		||||
  wsfMsgHdr_t         hdr;
 | 
			
		||||
  uint8_t             status;
 | 
			
		||||
  uint16_t            handle;
 | 
			
		||||
  uint8_t             enabled;
 | 
			
		||||
} hciEncChangeEvt_t;
 | 
			
		||||
 | 
			
		||||
/*! LE LTK request event */
 | 
			
		||||
typedef struct
 | 
			
		||||
{
 | 
			
		||||
  wsfMsgHdr_t         hdr;
 | 
			
		||||
  uint16_t            handle;
 | 
			
		||||
  uint8_t             randNum[HCI_RAND_LEN];
 | 
			
		||||
  uint16_t            encDiversifier;
 | 
			
		||||
} hciLeLtkReqEvt_t;
 | 
			
		||||
 | 
			
		||||
/*! Vendor specific command status event */
 | 
			
		||||
typedef struct
 | 
			
		||||
{
 | 
			
		||||
  wsfMsgHdr_t        hdr;
 | 
			
		||||
  uint16_t           opcode;
 | 
			
		||||
} hciVendorSpecCmdStatusEvt_t;
 | 
			
		||||
 | 
			
		||||
/*! Vendor specific command complete event */
 | 
			
		||||
typedef struct
 | 
			
		||||
{
 | 
			
		||||
  wsfMsgHdr_t        hdr;
 | 
			
		||||
  uint16_t           opcode;
 | 
			
		||||
  uint8_t            param[1];
 | 
			
		||||
} hciVendorSpecCmdCmplEvt_t;
 | 
			
		||||
 | 
			
		||||
/*! Vendor specific event */
 | 
			
		||||
typedef struct
 | 
			
		||||
{
 | 
			
		||||
  wsfMsgHdr_t        hdr;
 | 
			
		||||
  uint8_t            param[1];
 | 
			
		||||
} hciVendorSpecEvt_t;
 | 
			
		||||
 | 
			
		||||
/*! Hardware error event */
 | 
			
		||||
typedef struct
 | 
			
		||||
{
 | 
			
		||||
  wsfMsgHdr_t        hdr;
 | 
			
		||||
  uint8_t            code;
 | 
			
		||||
} hciHwErrorEvt_t;
 | 
			
		||||
 | 
			
		||||
/*! LE encrypt command complete event */
 | 
			
		||||
typedef struct
 | 
			
		||||
{
 | 
			
		||||
  wsfMsgHdr_t        hdr;
 | 
			
		||||
  uint8_t            status;
 | 
			
		||||
  uint8_t            data[HCI_ENCRYPT_DATA_LEN];
 | 
			
		||||
} hciLeEncryptCmdCmplEvt_t;
 | 
			
		||||
 | 
			
		||||
/*! LE rand command complete event */
 | 
			
		||||
typedef struct
 | 
			
		||||
{
 | 
			
		||||
  wsfMsgHdr_t        hdr;
 | 
			
		||||
  uint8_t            status;
 | 
			
		||||
  uint8_t            randNum[HCI_RAND_LEN];
 | 
			
		||||
} hciLeRandCmdCmplEvt_t;
 | 
			
		||||
 | 
			
		||||
/*! LE remote connection parameter request reply command complete event */
 | 
			
		||||
typedef struct
 | 
			
		||||
{
 | 
			
		||||
  wsfMsgHdr_t         hdr;
 | 
			
		||||
  uint8_t             status;
 | 
			
		||||
  uint16_t            handle;
 | 
			
		||||
} hciLeRemConnParamRepEvt_t;
 | 
			
		||||
 | 
			
		||||
/*! LE remote connection parameter request negative reply command complete event */
 | 
			
		||||
typedef struct
 | 
			
		||||
{
 | 
			
		||||
  wsfMsgHdr_t         hdr;
 | 
			
		||||
  uint8_t             status;
 | 
			
		||||
  uint16_t            handle;
 | 
			
		||||
} hciLeRemConnParamNegRepEvt_t;
 | 
			
		||||
 | 
			
		||||
/*! LE read suggested default data len command complete event */
 | 
			
		||||
typedef struct
 | 
			
		||||
{
 | 
			
		||||
  wsfMsgHdr_t         hdr;
 | 
			
		||||
  uint8_t             status;
 | 
			
		||||
  uint16_t            suggestedMaxTxOctets;
 | 
			
		||||
  uint16_t            suggestedMaxTxTime;
 | 
			
		||||
} hciLeReadDefDataLenEvt_t;
 | 
			
		||||
 | 
			
		||||
/*! LE write suggested default data len command complete event */
 | 
			
		||||
typedef struct
 | 
			
		||||
{
 | 
			
		||||
  wsfMsgHdr_t         hdr;
 | 
			
		||||
  uint8_t             status;
 | 
			
		||||
} hciLeWriteDefDataLenEvt_t;
 | 
			
		||||
 | 
			
		||||
/*! LE set data len command complete event */
 | 
			
		||||
typedef struct
 | 
			
		||||
{
 | 
			
		||||
  wsfMsgHdr_t         hdr;
 | 
			
		||||
  uint8_t             status;
 | 
			
		||||
  uint16_t            handle;
 | 
			
		||||
} hciLeSetDataLenEvt_t;
 | 
			
		||||
 | 
			
		||||
/*! LE read maximum data len command complete event */
 | 
			
		||||
typedef struct
 | 
			
		||||
{
 | 
			
		||||
  wsfMsgHdr_t         hdr;
 | 
			
		||||
  uint8_t             status;
 | 
			
		||||
  uint16_t            supportedMaxTxOctets;
 | 
			
		||||
  uint16_t            supportedMaxTxTime;
 | 
			
		||||
  uint16_t            supportedMaxRxOctets;
 | 
			
		||||
  uint16_t            supportedMaxRxTime;
 | 
			
		||||
} hciLeReadMaxDataLenEvt_t;
 | 
			
		||||
 | 
			
		||||
/*! LE remote connetion parameter request event */
 | 
			
		||||
typedef struct
 | 
			
		||||
{
 | 
			
		||||
  wsfMsgHdr_t         hdr;
 | 
			
		||||
  uint16_t            handle;
 | 
			
		||||
  uint16_t            intervalMin;
 | 
			
		||||
  uint16_t            intervalMax;
 | 
			
		||||
  uint16_t            latency;
 | 
			
		||||
  uint16_t            timeout;
 | 
			
		||||
} hciLeRemConnParamReqEvt_t;
 | 
			
		||||
 | 
			
		||||
/*! LE data length change event */
 | 
			
		||||
typedef struct
 | 
			
		||||
{
 | 
			
		||||
  wsfMsgHdr_t        hdr;
 | 
			
		||||
  uint16_t           handle;
 | 
			
		||||
  uint16_t           maxTxOctets;
 | 
			
		||||
  uint16_t           maxTxTime;
 | 
			
		||||
  uint16_t           maxRxOctets;
 | 
			
		||||
  uint16_t           maxRxTime;
 | 
			
		||||
} hciLeDataLenChangeEvt_t;
 | 
			
		||||
 | 
			
		||||
/*! LE local  p256 ecc key command complete event */
 | 
			
		||||
typedef struct
 | 
			
		||||
{
 | 
			
		||||
  wsfMsgHdr_t        hdr;
 | 
			
		||||
  uint8_t            status;
 | 
			
		||||
  uint8_t            key[HCI_P256_KEY_LEN];
 | 
			
		||||
} hciLeP256CmplEvt_t;
 | 
			
		||||
 | 
			
		||||
/*! LE generate DH key command complete event */
 | 
			
		||||
typedef struct
 | 
			
		||||
{
 | 
			
		||||
  wsfMsgHdr_t        hdr;
 | 
			
		||||
  uint8_t            status;
 | 
			
		||||
  uint8_t            key[HCI_DH_KEY_LEN];
 | 
			
		||||
} hciLeGenDhKeyEvt_t;
 | 
			
		||||
 | 
			
		||||
/*! LE read peer resolving address command complete event */
 | 
			
		||||
typedef struct
 | 
			
		||||
{
 | 
			
		||||
  wsfMsgHdr_t         hdr;
 | 
			
		||||
  uint8_t             status;
 | 
			
		||||
  uint8_t             peerRpa[BDA_ADDR_LEN];
 | 
			
		||||
} hciLeReadPeerResAddrCmdCmplEvt_t;
 | 
			
		||||
 | 
			
		||||
/*! LE read local resolving address command complete event */
 | 
			
		||||
typedef struct
 | 
			
		||||
{
 | 
			
		||||
  wsfMsgHdr_t         hdr;
 | 
			
		||||
  uint8_t             status;
 | 
			
		||||
  uint8_t             localRpa[BDA_ADDR_LEN];
 | 
			
		||||
} hciLeReadLocalResAddrCmdCmplEvt_t;
 | 
			
		||||
 | 
			
		||||
/*! LE set address resolving enable command complete event */
 | 
			
		||||
typedef struct
 | 
			
		||||
{
 | 
			
		||||
  wsfMsgHdr_t         hdr;
 | 
			
		||||
  uint8_t             status;
 | 
			
		||||
} hciLeSetAddrResEnableCmdCmplEvt_t;
 | 
			
		||||
 | 
			
		||||
/*! LE add device to resolving list command complete event */
 | 
			
		||||
typedef struct
 | 
			
		||||
{
 | 
			
		||||
  wsfMsgHdr_t         hdr;
 | 
			
		||||
  uint8_t             status;
 | 
			
		||||
} hciLeAddDevToResListCmdCmplEvt_t;
 | 
			
		||||
 | 
			
		||||
/*! LE remove device from resolving list command complete event */
 | 
			
		||||
typedef struct
 | 
			
		||||
{
 | 
			
		||||
  wsfMsgHdr_t         hdr;
 | 
			
		||||
  uint8_t             status;
 | 
			
		||||
} hciLeRemDevFromResListCmdCmplEvt_t;
 | 
			
		||||
 | 
			
		||||
/*! LE clear resolving list command complete event */
 | 
			
		||||
typedef struct
 | 
			
		||||
{
 | 
			
		||||
  wsfMsgHdr_t         hdr;
 | 
			
		||||
  uint8_t             status;
 | 
			
		||||
} hciLeClearResListCmdCmplEvt_t;
 | 
			
		||||
 | 
			
		||||
typedef struct
 | 
			
		||||
{
 | 
			
		||||
  wsfMsgHdr_t         hdr;
 | 
			
		||||
  uint8_t             status;
 | 
			
		||||
  uint16_t            handle;
 | 
			
		||||
} hciWriteAuthPayloadToCmdCmplEvt_t;
 | 
			
		||||
 | 
			
		||||
typedef struct
 | 
			
		||||
{
 | 
			
		||||
  wsfMsgHdr_t         hdr;
 | 
			
		||||
  uint16_t            handle;
 | 
			
		||||
} hciAuthPayloadToExpiredEvt_t;
 | 
			
		||||
 | 
			
		||||
/*! Union of all event types */
 | 
			
		||||
typedef union
 | 
			
		||||
{
 | 
			
		||||
  wsfMsgHdr_t                        hdr;
 | 
			
		||||
  wsfMsgHdr_t                        resetSeqCmpl;
 | 
			
		||||
  hciLeConnCmplEvt_t                 leConnCmpl;
 | 
			
		||||
  hciDisconnectCmplEvt_t             disconnectCmpl;
 | 
			
		||||
  hciLeConnUpdateCmplEvt_t           leConnUpdateCmpl;
 | 
			
		||||
  hciLeCreateConnCancelCmdCmplEvt_t  leCreateConnCancelCmdCmpl;
 | 
			
		||||
  hciLeAdvReportEvt_t                leAdvReport;
 | 
			
		||||
  hciReadRssiCmdCmplEvt_t            readRssiCmdCmpl;
 | 
			
		||||
  hciReadChanMapCmdCmplEvt_t         readChanMapCmdCmpl;
 | 
			
		||||
  hciReadTxPwrLvlCmdCmplEvt_t        readTxPwrLvlCmdCmpl;
 | 
			
		||||
  hciReadRemoteVerInfoCmplEvt_t      readRemoteVerInfoCmpl;
 | 
			
		||||
  hciLeReadRemoteFeatCmplEvt_t       leReadRemoteFeatCmpl;
 | 
			
		||||
  hciLeLtkReqReplCmdCmplEvt_t        leLtkReqReplCmdCmpl;
 | 
			
		||||
  hciLeLtkReqNegReplCmdCmplEvt_t     leLtkReqNegReplCmdCmpl;
 | 
			
		||||
  hciEncKeyRefreshCmpl_t             encKeyRefreshCmpl;
 | 
			
		||||
  hciEncChangeEvt_t                  encChange;
 | 
			
		||||
  hciLeLtkReqEvt_t                   leLtkReq;
 | 
			
		||||
  hciVendorSpecCmdStatusEvt_t        vendorSpecCmdStatus;
 | 
			
		||||
  hciVendorSpecCmdCmplEvt_t          vendorSpecCmdCmpl;
 | 
			
		||||
  hciVendorSpecEvt_t                 vendorSpec;
 | 
			
		||||
  hciHwErrorEvt_t                    hwError;
 | 
			
		||||
  hciLeEncryptCmdCmplEvt_t           leEncryptCmdCmpl;
 | 
			
		||||
  hciLeRandCmdCmplEvt_t              leRandCmdCmpl;
 | 
			
		||||
  hciLeReadPeerResAddrCmdCmplEvt_t   leReadPeerResAddrCmdCmpl;
 | 
			
		||||
  hciLeReadLocalResAddrCmdCmplEvt_t  leReadLocalResAddrCmdCmpl;
 | 
			
		||||
  hciLeSetAddrResEnableCmdCmplEvt_t  leSetAddrResEnableCmdCmpl;
 | 
			
		||||
  hciLeAddDevToResListCmdCmplEvt_t   leAddDevToResListCmdCmpl;
 | 
			
		||||
  hciLeRemDevFromResListCmdCmplEvt_t leRemDevFromResListCmdCmpl;
 | 
			
		||||
  hciLeClearResListCmdCmplEvt_t      leClearResListCmdCmpl;
 | 
			
		||||
  hciLeRemConnParamRepEvt_t          leRemConnParamRepCmdCmpl;
 | 
			
		||||
  hciLeRemConnParamNegRepEvt_t       leRemConnParamNegRepCmdCmpl;
 | 
			
		||||
  hciLeReadDefDataLenEvt_t           leReadDefDataLenCmdCmpl;
 | 
			
		||||
  hciLeWriteDefDataLenEvt_t          leWriteDefDataLenCmdCmpl;
 | 
			
		||||
  hciLeSetDataLenEvt_t               leSetDataLenCmdCmpl;
 | 
			
		||||
  hciLeReadMaxDataLenEvt_t           leReadMaxDataLenCmdCmpl;
 | 
			
		||||
  hciLeRemConnParamReqEvt_t          leRemConnParamReq;
 | 
			
		||||
  hciLeDataLenChangeEvt_t            leDataLenChange;
 | 
			
		||||
  hciLeP256CmplEvt_t                 leP256;
 | 
			
		||||
  hciLeGenDhKeyEvt_t                 leGenDHKey;
 | 
			
		||||
  hciWriteAuthPayloadToCmdCmplEvt_t  writeAuthPayloadToCmdCmpl;
 | 
			
		||||
  hciAuthPayloadToExpiredEvt_t       authPayloadToExpired;
 | 
			
		||||
} hciEvt_t;
 | 
			
		||||
 | 
			
		||||
/**************************************************************************************************
 | 
			
		||||
  Callback Function Types
 | 
			
		||||
**************************************************************************************************/
 | 
			
		||||
 | 
			
		||||
typedef void (*hciEvtCback_t)(hciEvt_t *pEvent);
 | 
			
		||||
typedef void (*hciSecCback_t)(hciEvt_t *pEvent);
 | 
			
		||||
typedef void (*hciAclCback_t)(uint8_t *pData);
 | 
			
		||||
typedef void (*hciFlowCback_t)(uint16_t handle, bool_t flowDisabled);
 | 
			
		||||
 | 
			
		||||
/**************************************************************************************************
 | 
			
		||||
  Function Declarations
 | 
			
		||||
**************************************************************************************************/
 | 
			
		||||
 | 
			
		||||
/*! Initialization, registration, and reset */
 | 
			
		||||
void HciEvtRegister(hciEvtCback_t evtCback);
 | 
			
		||||
void HciSecRegister(hciSecCback_t secCback);
 | 
			
		||||
void HciAclRegister(hciAclCback_t aclCback, hciFlowCback_t flowCback);
 | 
			
		||||
void HciResetSequence(void);
 | 
			
		||||
void HciVsInit(uint8_t param);
 | 
			
		||||
void HciCoreInit(void);
 | 
			
		||||
void HciCoreHandler(wsfEventMask_t event, wsfMsgHdr_t *pMsg);
 | 
			
		||||
void HciSetMaxRxAclLen(uint16_t len);
 | 
			
		||||
void HciSetAclQueueWatermarks(uint8_t queueHi, uint8_t queueLo);
 | 
			
		||||
void HciSetLeSupFeat(uint8_t feat, bool_t flag);
 | 
			
		||||
 | 
			
		||||
/*! Optimization interface */
 | 
			
		||||
uint8_t *HciGetBdAddr(void);
 | 
			
		||||
uint8_t HciGetWhiteListSize(void);
 | 
			
		||||
int8_t HciGetAdvTxPwr(void);
 | 
			
		||||
uint16_t HciGetBufSize(void);
 | 
			
		||||
uint8_t HciGetNumBufs(void);
 | 
			
		||||
uint8_t *HciGetSupStates(void);
 | 
			
		||||
uint8_t HciGetLeSupFeat(void);
 | 
			
		||||
uint16_t HciGetMaxRxAclLen(void);
 | 
			
		||||
uint8_t HciGetResolvingListSize(void);
 | 
			
		||||
bool_t HciLlPrivacySupported(void);
 | 
			
		||||
 | 
			
		||||
/*! ACL data interface */
 | 
			
		||||
void HciSendAclData(uint8_t *pAclData);
 | 
			
		||||
 | 
			
		||||
/*! Command interface */
 | 
			
		||||
void HciDisconnectCmd(uint16_t handle, uint8_t reason);
 | 
			
		||||
void HciLeAddDevWhiteListCmd(uint8_t addrType, uint8_t *pAddr);
 | 
			
		||||
void HciLeClearWhiteListCmd(void);
 | 
			
		||||
void HciLeConnUpdateCmd(uint16_t handle, hciConnSpec_t *pConnSpec);
 | 
			
		||||
void HciLeCreateConnCmd(uint16_t scanInterval, uint16_t scanWindow, uint8_t filterPolicy,
 | 
			
		||||
                        uint8_t peerAddrType, uint8_t *pPeerAddr, uint8_t ownAddrType,
 | 
			
		||||
                        hciConnSpec_t *pConnSpec);
 | 
			
		||||
void HciLeCreateConnCancelCmd(void);
 | 
			
		||||
void HciLeEncryptCmd(uint8_t *pKey, uint8_t *pData);
 | 
			
		||||
void HciLeLtkReqNegReplCmd(uint16_t handle);
 | 
			
		||||
void HciLeLtkReqReplCmd(uint16_t handle, uint8_t *pKey);
 | 
			
		||||
void HciLeRandCmd(void);
 | 
			
		||||
void HciLeReadAdvTXPowerCmd(void);
 | 
			
		||||
void HciLeReadBufSizeCmd(void);
 | 
			
		||||
void HciLeReadChanMapCmd(uint16_t handle);
 | 
			
		||||
void HciLeReadLocalSupFeatCmd(void);
 | 
			
		||||
void HciLeReadRemoteFeatCmd(uint16_t handle);
 | 
			
		||||
void HciLeReadSupStatesCmd(void);
 | 
			
		||||
void HciLeReadWhiteListSizeCmd(void);
 | 
			
		||||
void HciLeRemoveDevWhiteListCmd(uint8_t addrType, uint8_t *pAddr);
 | 
			
		||||
void HciLeSetAdvEnableCmd(uint8_t enable);
 | 
			
		||||
void HciLeSetAdvDataCmd(uint8_t len, uint8_t *pData);
 | 
			
		||||
void HciLeSetAdvParamCmd(uint16_t advIntervalMin, uint16_t advIntervalMax, uint8_t advType,
 | 
			
		||||
                         uint8_t ownAddrType, uint8_t peerAddrType, uint8_t *pPeerAddr,
 | 
			
		||||
                         uint8_t advChanMap, uint8_t advFiltPolicy);
 | 
			
		||||
void HciLeSetEventMaskCmd(uint8_t *pLeEventMask);
 | 
			
		||||
void HciLeSetHostChanClassCmd(uint8_t *pChanMap);
 | 
			
		||||
void HciLeSetRandAddrCmd(uint8_t *pAddr);
 | 
			
		||||
void HciLeSetScanEnableCmd(uint8_t enable, uint8_t filterDup);
 | 
			
		||||
void HciLeSetScanParamCmd(uint8_t scanType, uint16_t scanInterval, uint16_t scanWindow,
 | 
			
		||||
                          uint8_t ownAddrType, uint8_t scanFiltPolicy);
 | 
			
		||||
void HciLeSetScanRespDataCmd(uint8_t len, uint8_t *pData);
 | 
			
		||||
void HciLeStartEncryptionCmd(uint16_t handle, uint8_t *pRand, uint16_t diversifier, uint8_t *pKey);
 | 
			
		||||
void HciReadBdAddrCmd(void);
 | 
			
		||||
void HciReadBufSizeCmd(void);
 | 
			
		||||
void HciReadLocalSupFeatCmd(void);
 | 
			
		||||
void HciReadLocalVerInfoCmd(void);
 | 
			
		||||
void HciReadRemoteVerInfoCmd(uint16_t handle);
 | 
			
		||||
void HciReadRssiCmd(uint16_t handle);
 | 
			
		||||
void HciReadTxPwrLvlCmd(uint16_t handle, uint8_t type);
 | 
			
		||||
void HciResetCmd(void);
 | 
			
		||||
void HciSetEventMaskCmd(uint8_t *pEventMask);
 | 
			
		||||
void HciSetEventMaskPage2Cmd(uint8_t *pEventMask);
 | 
			
		||||
void HciReadAuthPayloadTimeout(uint16_t handle);
 | 
			
		||||
void HciWriteAuthPayloadTimeout(uint16_t handle, uint16_t timeout);
 | 
			
		||||
void HciLeAddDeviceToResolvingListCmd(uint8_t peerAddrType, const uint8_t *pPeerIdentityAddr,
 | 
			
		||||
                                      const uint8_t *pPeerIrk, const uint8_t *pLocalIrk);
 | 
			
		||||
void HciLeRemoveDeviceFromResolvingList(uint8_t peerAddrType, const uint8_t *pPeerIdentityAddr);
 | 
			
		||||
void HciLeClearResolvingList(void);
 | 
			
		||||
void HciLeReadResolvingListSize(void);
 | 
			
		||||
void HciLeReadPeerResolvableAddr(uint8_t addrType, const uint8_t *pIdentityAddr);
 | 
			
		||||
void HciLeReadLocalResolvableAddr(uint8_t addrType, const uint8_t *pIdentityAddr);
 | 
			
		||||
void HciLeSetAddrResolutionEnable(uint8_t enable);
 | 
			
		||||
void HciLeSetResolvablePrivateAddrTimeout(uint16_t rpaTimeout);
 | 
			
		||||
void HciVendorSpecificCmd(uint16_t opcode, uint8_t len, uint8_t *pData);
 | 
			
		||||
 | 
			
		||||
void HciLeRemoteConnParamReqReply(uint16_t handle, uint16_t intervalMin, uint16_t intervalMax, uint16_t latency,
 | 
			
		||||
                                  uint16_t timeout, uint16_t minCeLen, uint16_t maxCeLen);
 | 
			
		||||
void HciLeRemoteConnParamReqNegReply(uint16_t handle, uint8_t reason);
 | 
			
		||||
void HciLeSetDataLen(uint16_t handle, uint16_t txOctets, uint16_t txTime);
 | 
			
		||||
void HciLeReadDefDataLen(void);
 | 
			
		||||
void HciLeWriteDefDataLen(uint16_t suggestedMaxTxOctets, uint16_t suggestedMaxTxTime);
 | 
			
		||||
void HciLeReadLocalP256PubKey(void);
 | 
			
		||||
void HciLeGenerateDHKey(uint8_t *pPubKeyX, uint8_t *pPubKeyY);
 | 
			
		||||
void HciLeReadMaxDataLen(void);
 | 
			
		||||
void HciWriteAuthPayloadTimeout(uint16_t handle, uint16_t timeout);
 | 
			
		||||
 | 
			
		||||
#ifdef __cplusplus
 | 
			
		||||
};
 | 
			
		||||
#endif
 | 
			
		||||
 | 
			
		||||
#endif /* HCI_API_H */
 | 
			
		||||
| 
						 | 
				
			
			@ -1,67 +0,0 @@
 | 
			
		|||
/*************************************************************************************************/
 | 
			
		||||
/*!
 | 
			
		||||
 *  \file   hci_handler.h
 | 
			
		||||
 *
 | 
			
		||||
 *  \brief  Interface to HCI event handler.
 | 
			
		||||
 *
 | 
			
		||||
 *          $Date: 2012-03-29 13:24:04 -0700 (Thu, 29 Mar 2012) $
 | 
			
		||||
 *          $Revision: 287 $
 | 
			
		||||
 *
 | 
			
		||||
 *  Copyright (c) 2009 Wicentric, Inc., all rights reserved.
 | 
			
		||||
 *  Wicentric confidential and proprietary.
 | 
			
		||||
 *
 | 
			
		||||
 *  IMPORTANT.  Your use of this file is governed by a Software License Agreement
 | 
			
		||||
 *  ("Agreement") that must be accepted in order to download or otherwise receive a
 | 
			
		||||
 *  copy of this file.  You may not use or copy this file for any purpose other than
 | 
			
		||||
 *  as described in the Agreement.  If you do not agree to all of the terms of the
 | 
			
		||||
 *  Agreement do not use this file and delete all copies in your possession or control;
 | 
			
		||||
 *  if you do not have a copy of the Agreement, you must contact Wicentric, Inc. prior
 | 
			
		||||
 *  to any use, copying or further distribution of this software.
 | 
			
		||||
 */
 | 
			
		||||
/*************************************************************************************************/
 | 
			
		||||
#ifndef HCI_HANDLER_H
 | 
			
		||||
#define HCI_HANDLER_H
 | 
			
		||||
 | 
			
		||||
#include "wsf_os.h"
 | 
			
		||||
 | 
			
		||||
#ifdef __cplusplus
 | 
			
		||||
extern "C" {
 | 
			
		||||
#endif
 | 
			
		||||
 | 
			
		||||
/**************************************************************************************************
 | 
			
		||||
  Function Declarations
 | 
			
		||||
**************************************************************************************************/
 | 
			
		||||
 | 
			
		||||
/*************************************************************************************************/
 | 
			
		||||
/*!
 | 
			
		||||
 *  \fn     HciHandlerInit
 | 
			
		||||
 *        
 | 
			
		||||
 *  \brief  HCI handler init function called during system initialization.
 | 
			
		||||
 *
 | 
			
		||||
 *  \param  handlerID  WSF handler ID for HCI.
 | 
			
		||||
 *
 | 
			
		||||
 *  \return None.
 | 
			
		||||
 */
 | 
			
		||||
/*************************************************************************************************/
 | 
			
		||||
void HciHandlerInit(wsfHandlerId_t handlerId);
 | 
			
		||||
 | 
			
		||||
 | 
			
		||||
/*************************************************************************************************/
 | 
			
		||||
/*!
 | 
			
		||||
 *  \fn     HciHandler
 | 
			
		||||
 *        
 | 
			
		||||
 *  \brief  WSF event handler for HCI.
 | 
			
		||||
 *
 | 
			
		||||
 *  \param  event   WSF event mask.
 | 
			
		||||
 *  \param  pMsg    WSF message.
 | 
			
		||||
 *
 | 
			
		||||
 *  \return None.
 | 
			
		||||
 */
 | 
			
		||||
/*************************************************************************************************/
 | 
			
		||||
void HciHandler(wsfEventMask_t event, wsfMsgHdr_t *pMsg);
 | 
			
		||||
 | 
			
		||||
#ifdef __cplusplus
 | 
			
		||||
};
 | 
			
		||||
#endif
 | 
			
		||||
 | 
			
		||||
#endif /* HCI_HANDLER_H */
 | 
			
		||||
| 
						 | 
				
			
			@ -1,439 +0,0 @@
 | 
			
		|||
/*************************************************************************************************/
 | 
			
		||||
/*!
 | 
			
		||||
 *  \file   l2c_api.h
 | 
			
		||||
 *        
 | 
			
		||||
 *  \brief  L2CAP subsystem API.
 | 
			
		||||
 *
 | 
			
		||||
 *          $Date: 2015-10-09 09:08:23 -0700 (Fri, 09 Oct 2015) $
 | 
			
		||||
 *          $Revision: 4164 $
 | 
			
		||||
 *  
 | 
			
		||||
 *  Copyright (c) 2009 Wicentric, Inc., all rights reserved.
 | 
			
		||||
 *  Wicentric confidential and proprietary.
 | 
			
		||||
 *
 | 
			
		||||
 *  IMPORTANT.  Your use of this file is governed by a Software License Agreement
 | 
			
		||||
 *  ("Agreement") that must be accepted in order to download or otherwise receive a
 | 
			
		||||
 *  copy of this file.  You may not use or copy this file for any purpose other than
 | 
			
		||||
 *  as described in the Agreement.  If you do not agree to all of the terms of the
 | 
			
		||||
 *  Agreement do not use this file and delete all copies in your possession or control;
 | 
			
		||||
 *  if you do not have a copy of the Agreement, you must contact Wicentric, Inc. prior
 | 
			
		||||
 *  to any use, copying or further distribution of this software.
 | 
			
		||||
 */
 | 
			
		||||
/*************************************************************************************************/
 | 
			
		||||
#ifndef L2C_API_H
 | 
			
		||||
#define L2C_API_H
 | 
			
		||||
 | 
			
		||||
#include "dm_api.h"
 | 
			
		||||
#include "l2c_defs.h"
 | 
			
		||||
 | 
			
		||||
#ifdef __cplusplus
 | 
			
		||||
extern "C" {
 | 
			
		||||
#endif
 | 
			
		||||
 | 
			
		||||
/**************************************************************************************************
 | 
			
		||||
  Macros
 | 
			
		||||
**************************************************************************************************/
 | 
			
		||||
 | 
			
		||||
/*! Control callback message events */
 | 
			
		||||
#define L2C_CTRL_FLOW_ENABLE_IND          0         /*! Data flow enabled */
 | 
			
		||||
#define L2C_CTRL_FLOW_DISABLE_IND         1         /*! Data flow disabled */
 | 
			
		||||
 | 
			
		||||
/*! Invalid channel registration ID for connection oriented channels */
 | 
			
		||||
#define L2C_COC_REG_ID_NONE               0
 | 
			
		||||
 | 
			
		||||
/*! Invalid channel ID for connection oriented channels */
 | 
			
		||||
#define L2C_COC_CID_NONE                  0
 | 
			
		||||
 | 
			
		||||
/*! Connection oriented channel initiator/acceptor role */
 | 
			
		||||
#define L2C_COC_ROLE_NONE                 0x00      /*! No role (unallocated) */
 | 
			
		||||
#define L2C_COC_ROLE_INITIATOR            0x01      /*! Channel initiator */
 | 
			
		||||
#define L2C_COC_ROLE_ACCEPTOR             0x02      /*! Channel acceptor */
 | 
			
		||||
 | 
			
		||||
/*! Connection oriented channel data confirm status values */
 | 
			
		||||
#define L2C_COC_DATA_SUCCESS              0         /*! Data request successful */
 | 
			
		||||
#define L2C_COC_DATA_ERR_MEMORY           1         /*! Out of memory */
 | 
			
		||||
#define L2C_COC_DATA_ERR_OVERFLOW         2         /*! Transaction overflow */
 | 
			
		||||
 | 
			
		||||
/*! Connection oriented channel callback events */
 | 
			
		||||
#define L2C_COC_CBACK_START               0x40      /*! L2C callback event starting value */
 | 
			
		||||
enum
 | 
			
		||||
{
 | 
			
		||||
  L2C_COC_CONNECT_IND = L2C_COC_CBACK_START,        /*! Channel connect indication */
 | 
			
		||||
  L2C_COC_DISCONNECT_IND,                           /*! Channel disconnect indication */
 | 
			
		||||
  L2C_COC_DATA_IND,                                 /*! Received data indication */
 | 
			
		||||
  L2C_COC_DATA_CNF                                  /*! Transmit data confirm */
 | 
			
		||||
};
 | 
			
		||||
 | 
			
		||||
#define L2C_COC_CBACK_CBACK_END           L2C_COC_DATA_CNF  /*! L2C callback event ending value */
 | 
			
		||||
 | 
			
		||||
/**************************************************************************************************
 | 
			
		||||
  Data Types
 | 
			
		||||
**************************************************************************************************/
 | 
			
		||||
 | 
			
		||||
/*! Connection oriented channel registration ID */
 | 
			
		||||
typedef uint16_t l2cCocRegId_t;
 | 
			
		||||
 | 
			
		||||
/*! Connection oriented channel registration structure */
 | 
			
		||||
typedef struct
 | 
			
		||||
{
 | 
			
		||||
  uint16_t        psm;                    /*! Protocol service multiplexer */
 | 
			
		||||
  uint16_t        mps;                    /*! Maximum receive PDU fragment size */
 | 
			
		||||
  uint16_t        mtu;                    /*! Maximum receive data packet size */
 | 
			
		||||
  uint16_t        credits;                /*! Data packet receive credits for this channel */
 | 
			
		||||
  bool_t          authoriz;               /*! TRUE if authorization is required */
 | 
			
		||||
  uint8_t         secLevel;               /*! Channel minimum security level requirements */
 | 
			
		||||
  uint8_t         role;                   /*! Channel initiator/acceptor role */
 | 
			
		||||
} l2cCocReg_t;
 | 
			
		||||
 | 
			
		||||
/* Connection oriented channel connect indication structure */
 | 
			
		||||
typedef struct
 | 
			
		||||
{
 | 
			
		||||
  wsfMsgHdr_t           hdr;              /*! Header structure */
 | 
			
		||||
  uint16_t              cid;              /*! Local channel ID */  
 | 
			
		||||
  uint16_t              peerMtu;          /*! Data packet MTU peer can receive */
 | 
			
		||||
  uint16_t              psm;              /*! Connected PSM */
 | 
			
		||||
} l2cCocConnectInd_t;
 | 
			
		||||
 | 
			
		||||
/* Connection oriented channel disconnect indication structure */
 | 
			
		||||
typedef struct
 | 
			
		||||
{
 | 
			
		||||
  wsfMsgHdr_t           hdr;              /*! Header structure */
 | 
			
		||||
  uint16_t              cid;              /*! Local channel ID */  
 | 
			
		||||
  uint16_t              result;           /*! Connection failure result code */
 | 
			
		||||
} l2cCocDisconnectInd_t;
 | 
			
		||||
 | 
			
		||||
/* Connection oriented channel data indication structure */
 | 
			
		||||
typedef struct
 | 
			
		||||
{
 | 
			
		||||
  wsfMsgHdr_t           hdr;              /*! Header structure */
 | 
			
		||||
  uint16_t              cid;              /*! Local channel ID */  
 | 
			
		||||
  uint8_t               *pData;           /*! Pointer to packet data */
 | 
			
		||||
  uint16_t              dataLen;          /*! packet data length */  
 | 
			
		||||
} l2cCocDataInd_t;
 | 
			
		||||
 | 
			
		||||
/* Connection oriented channel disconnect indication structure */
 | 
			
		||||
typedef struct
 | 
			
		||||
{
 | 
			
		||||
  wsfMsgHdr_t           hdr;              /*! Header structure */
 | 
			
		||||
  uint16_t              cid;              /*! Local channel ID */  
 | 
			
		||||
} l2cCocDataCnf_t;
 | 
			
		||||
 | 
			
		||||
/*! 
 | 
			
		||||
 * Connection oriented channel event structure
 | 
			
		||||
 * 
 | 
			
		||||
 * Connection oriented channel callback header parameters:
 | 
			
		||||
 *
 | 
			
		||||
 * \param hdr.event     Callback event
 | 
			
		||||
 * \param hdr.param     DM connection ID
 | 
			
		||||
 * \param hdr.status    Event status (L2C_COC_DATA_CNF only)
 | 
			
		||||
 */
 | 
			
		||||
typedef union
 | 
			
		||||
{
 | 
			
		||||
  wsfMsgHdr_t           hdr;              /*! Header structure */
 | 
			
		||||
  l2cCocConnectInd_t    connectInd;       /*! Channel connect indication */ 
 | 
			
		||||
  l2cCocDisconnectInd_t disconnectInd;    /*! Channel disconnect indication */
 | 
			
		||||
  l2cCocDataInd_t       dataInd;          /*! Received data indication */
 | 
			
		||||
  l2cCocDataCnf_t       dataCnf;          /*! Transmit data confirm */
 | 
			
		||||
} l2cCocEvt_t;
 | 
			
		||||
 | 
			
		||||
/*! Configurable parameters */
 | 
			
		||||
typedef struct
 | 
			
		||||
{
 | 
			
		||||
  uint16_t            reqTimeout;         /*! Request timeout in seconds */
 | 
			
		||||
} l2cCfg_t;
 | 
			
		||||
 | 
			
		||||
/**************************************************************************************************
 | 
			
		||||
  Global Variables;
 | 
			
		||||
**************************************************************************************************/
 | 
			
		||||
 | 
			
		||||
/*! Configuration pointer */
 | 
			
		||||
extern l2cCfg_t *pL2cCfg;
 | 
			
		||||
 | 
			
		||||
/**************************************************************************************************
 | 
			
		||||
  Callback Function Types
 | 
			
		||||
**************************************************************************************************/
 | 
			
		||||
 | 
			
		||||
/*************************************************************************************************/
 | 
			
		||||
/*!
 | 
			
		||||
 *  \fn     l2cDataCback_t
 | 
			
		||||
 *        
 | 
			
		||||
 *  \brief  This callback function sends a received L2CAP packet to the client.
 | 
			
		||||
 *
 | 
			
		||||
 *  \param  handle    The connection handle.
 | 
			
		||||
 *  \param  len       The length of the L2CAP payload data in pPacket.
 | 
			
		||||
 *  \param  pPacket   A buffer containing the packet.
 | 
			
		||||
 *
 | 
			
		||||
 *  \return None.
 | 
			
		||||
 */
 | 
			
		||||
/*************************************************************************************************/
 | 
			
		||||
typedef void (*l2cDataCback_t)(uint16_t handle, uint16_t len, uint8_t *pPacket);
 | 
			
		||||
 | 
			
		||||
/*************************************************************************************************/
 | 
			
		||||
/*!
 | 
			
		||||
 *  \fn     l2cCtrlCback_t
 | 
			
		||||
 *        
 | 
			
		||||
 *  \brief  This callback function sends control messages to the client.
 | 
			
		||||
 *
 | 
			
		||||
 *  \param  pMsg    Pointer to message structure.
 | 
			
		||||
 *
 | 
			
		||||
 *  \return None.
 | 
			
		||||
 */
 | 
			
		||||
/*************************************************************************************************/
 | 
			
		||||
typedef void (*l2cCtrlCback_t)(wsfMsgHdr_t *pMsg);
 | 
			
		||||
 | 
			
		||||
/*************************************************************************************************/
 | 
			
		||||
/*!
 | 
			
		||||
 *  \fn     l2cCocCback_t
 | 
			
		||||
 *        
 | 
			
		||||
 *  \brief  This callback function sends data and other events to connection oriented
 | 
			
		||||
 *          channels clients.
 | 
			
		||||
 *
 | 
			
		||||
 *  \param  pMsg    Pointer to message structure.
 | 
			
		||||
 *
 | 
			
		||||
 *  \return None.
 | 
			
		||||
 */
 | 
			
		||||
/*************************************************************************************************/
 | 
			
		||||
typedef void (*l2cCocCback_t)(l2cCocEvt_t *pMsg);
 | 
			
		||||
 | 
			
		||||
/*************************************************************************************************/
 | 
			
		||||
/*!
 | 
			
		||||
 *  \fn     l2cCocAuthorCback_t
 | 
			
		||||
 *        
 | 
			
		||||
 *  \brief  This callback function is used for authoriztion of connection oriented channels.
 | 
			
		||||
 *
 | 
			
		||||
 *  \param  connId    DM connection ID.
 | 
			
		||||
 *  \param  regId     The registration instance requiring authorization.
 | 
			
		||||
 *  \param  psm       The PSM of the registration instance.
 | 
			
		||||
 *
 | 
			
		||||
 *  \return L2C_CONN_SUCCESS if authorization is successful, any other value for failure.
 | 
			
		||||
 */
 | 
			
		||||
/*************************************************************************************************/
 | 
			
		||||
typedef uint16_t (*l2cCocAuthorCback_t)(dmConnId_t connId, l2cCocRegId_t regId, uint16_t psm);
 | 
			
		||||
 | 
			
		||||
/**************************************************************************************************
 | 
			
		||||
  Function Declarations
 | 
			
		||||
**************************************************************************************************/
 | 
			
		||||
 | 
			
		||||
/*************************************************************************************************/
 | 
			
		||||
/*!
 | 
			
		||||
 *  \fn     L2cInit
 | 
			
		||||
 *        
 | 
			
		||||
 *  \brief  Initialize L2C subsystem.
 | 
			
		||||
 *
 | 
			
		||||
 *  \return None.
 | 
			
		||||
 */
 | 
			
		||||
/*************************************************************************************************/
 | 
			
		||||
void L2cInit(void);
 | 
			
		||||
 | 
			
		||||
/*************************************************************************************************/
 | 
			
		||||
/*!
 | 
			
		||||
 *  \fn     L2cMasterInit
 | 
			
		||||
 *        
 | 
			
		||||
 *  \brief  Initialize L2C for operation as a Bluetooth LE master.
 | 
			
		||||
 *
 | 
			
		||||
 *  \return None.
 | 
			
		||||
 */
 | 
			
		||||
/*************************************************************************************************/
 | 
			
		||||
void L2cMasterInit(void);
 | 
			
		||||
 | 
			
		||||
/*************************************************************************************************/
 | 
			
		||||
/*!
 | 
			
		||||
 *  \fn     L2cSlaveInit
 | 
			
		||||
 *        
 | 
			
		||||
 *  \brief  Initialize L2C for operation as a Bluetooth LE slave.
 | 
			
		||||
 *
 | 
			
		||||
 *  \return None.
 | 
			
		||||
 */
 | 
			
		||||
/*************************************************************************************************/
 | 
			
		||||
void L2cSlaveInit(void);
 | 
			
		||||
 | 
			
		||||
/*************************************************************************************************/
 | 
			
		||||
/*!
 | 
			
		||||
 *  \fn     L2cSlaveInit
 | 
			
		||||
 *        
 | 
			
		||||
 *  \brief  Initialize L2C for operation with connection-oriented channels.
 | 
			
		||||
 *
 | 
			
		||||
 *  \return None.
 | 
			
		||||
 */
 | 
			
		||||
/*************************************************************************************************/
 | 
			
		||||
void L2cCocInit(void);
 | 
			
		||||
 | 
			
		||||
/*************************************************************************************************/
 | 
			
		||||
/*!
 | 
			
		||||
 *  \fn     L2cRegister
 | 
			
		||||
 *        
 | 
			
		||||
 *  \brief  called by the L2C client, such as ATT or SMP, to register for the given CID.
 | 
			
		||||
 *
 | 
			
		||||
 *  \param  cid       channel identifier.
 | 
			
		||||
 *  \param  dataCback Callback function for L2CAP data received for this CID.
 | 
			
		||||
 *  \param  ctrlCback Callback function for control events for this CID.
 | 
			
		||||
 *
 | 
			
		||||
 *  \return None.
 | 
			
		||||
 */
 | 
			
		||||
/*************************************************************************************************/
 | 
			
		||||
void L2cRegister(uint16_t cid, l2cDataCback_t dataCback, l2cCtrlCback_t ctrlCback);
 | 
			
		||||
 | 
			
		||||
/*************************************************************************************************/
 | 
			
		||||
/*!
 | 
			
		||||
 *  \fn     L2cDataReq
 | 
			
		||||
 *        
 | 
			
		||||
 *  \brief  Send an L2CAP data packet on the given CID.
 | 
			
		||||
 *
 | 
			
		||||
 *  \param  cid       The channel identifier.
 | 
			
		||||
 *  \param  handle    The connection handle.  The client receives this handle from DM.
 | 
			
		||||
 *  \param  len       The length of the payload data in pPacket.
 | 
			
		||||
 *  \param  pPacket   A buffer containing the packet. 
 | 
			
		||||
 *
 | 
			
		||||
 *  \return None.
 | 
			
		||||
 */
 | 
			
		||||
/*************************************************************************************************/
 | 
			
		||||
void L2cDataReq(uint16_t cid, uint16_t handle, uint16_t len, uint8_t *pL2cPacket);
 | 
			
		||||
 | 
			
		||||
/*************************************************************************************************/
 | 
			
		||||
/*!
 | 
			
		||||
 *  \fn     L2cCocInit
 | 
			
		||||
 *        
 | 
			
		||||
 *  \brief  Initialize L2C connection oriented channel subsystem.
 | 
			
		||||
 *
 | 
			
		||||
 *  \return None.
 | 
			
		||||
 */
 | 
			
		||||
/*************************************************************************************************/
 | 
			
		||||
void L2cCocInit(void);
 | 
			
		||||
 | 
			
		||||
/*************************************************************************************************/
 | 
			
		||||
/*!
 | 
			
		||||
 *  \fn     L2cCocRegister
 | 
			
		||||
 *        
 | 
			
		||||
 *  \brief  Register to use a connection oriented channel, as either a channel acceptor,
 | 
			
		||||
 *          initiator, or both.  If registering as channel acceptor then the PSM is specified.
 | 
			
		||||
 *          After registering a connection can be established by the client using this
 | 
			
		||||
 *          registration instance.
 | 
			
		||||
 *
 | 
			
		||||
 *  \param  cback   Client callback function.
 | 
			
		||||
 *  \param  pReg    Registration parameter structure.
 | 
			
		||||
 *
 | 
			
		||||
 *  \return Registration instance ID or L2C_COC_REG_ID_NONE if registration failed.
 | 
			
		||||
 */
 | 
			
		||||
/*************************************************************************************************/
 | 
			
		||||
l2cCocRegId_t L2cCocRegister(l2cCocCback_t cback, l2cCocReg_t *pReg);
 | 
			
		||||
 | 
			
		||||
/*************************************************************************************************/
 | 
			
		||||
/*!
 | 
			
		||||
 *  \fn     L2cCocDeregister
 | 
			
		||||
 *        
 | 
			
		||||
 *  \brief  Deregister and deallocate a connection oriented channel registration instance.
 | 
			
		||||
 *          This function should only be called if there are no active channels using this
 | 
			
		||||
 *          registration instance.
 | 
			
		||||
 *
 | 
			
		||||
 *  \param  regId   Registration instance ID.
 | 
			
		||||
 *
 | 
			
		||||
 *  \return None.
 | 
			
		||||
 */
 | 
			
		||||
/*************************************************************************************************/
 | 
			
		||||
void L2cCocDeregister(l2cCocRegId_t regId);
 | 
			
		||||
 | 
			
		||||
/*************************************************************************************************/
 | 
			
		||||
/*!
 | 
			
		||||
 *  \fn     L2cCocConnectReq
 | 
			
		||||
 *        
 | 
			
		||||
 *  \brief  Initiate a connection to the given peer PSM.
 | 
			
		||||
 *
 | 
			
		||||
 *  \param  connId    DM connection ID.
 | 
			
		||||
 *  \param  regId     The associated registration instance.
 | 
			
		||||
 *  \param  psm       Peer PSM.
 | 
			
		||||
 *
 | 
			
		||||
 *  \return Local CID or L2C_COC_CID_NONE none if failure.
 | 
			
		||||
 */
 | 
			
		||||
/*************************************************************************************************/
 | 
			
		||||
uint16_t L2cCocConnectReq(dmConnId_t connId, l2cCocRegId_t regId, uint16_t psm);
 | 
			
		||||
 | 
			
		||||
/*************************************************************************************************/
 | 
			
		||||
/*!
 | 
			
		||||
 *  \fn     L2cCocDisconnectReq
 | 
			
		||||
 *        
 | 
			
		||||
 *  \brief  Disconnect the channel for the given CID.
 | 
			
		||||
 *
 | 
			
		||||
 *  \param  cid       Channel ID.
 | 
			
		||||
 *
 | 
			
		||||
 *  \return None.
 | 
			
		||||
 */
 | 
			
		||||
/*************************************************************************************************/
 | 
			
		||||
void L2cCocDisconnectReq(uint16_t cid);
 | 
			
		||||
 | 
			
		||||
/*************************************************************************************************/
 | 
			
		||||
/*!
 | 
			
		||||
 *  \fn     L2cCocDataReq
 | 
			
		||||
 *        
 | 
			
		||||
 *  \brief  Send an L2CAP data packet on the given connection oriented CID.
 | 
			
		||||
 *
 | 
			
		||||
 *  \param  cid       The local channel identifier.
 | 
			
		||||
 *  \param  len       The length of the payload data in pPacket.
 | 
			
		||||
 *  \param  pPacket   Packet payload data. 
 | 
			
		||||
 *
 | 
			
		||||
 *  \return None.
 | 
			
		||||
 */
 | 
			
		||||
/*************************************************************************************************/
 | 
			
		||||
void L2cCocDataReq(uint16_t cid, uint16_t len, uint8_t *pPayload);
 | 
			
		||||
 | 
			
		||||
/*************************************************************************************************/
 | 
			
		||||
/*!
 | 
			
		||||
 *  \fn     L2cCocErrorTest
 | 
			
		||||
 *        
 | 
			
		||||
 *  \brief  For testing purposes only.
 | 
			
		||||
 *
 | 
			
		||||
 *  \param  result    Result code
 | 
			
		||||
 *
 | 
			
		||||
 *  \return None.
 | 
			
		||||
 */
 | 
			
		||||
/*************************************************************************************************/
 | 
			
		||||
void L2cCocErrorTest(uint16_t result);
 | 
			
		||||
 | 
			
		||||
/*************************************************************************************************/
 | 
			
		||||
/*!
 | 
			
		||||
 *  \fn     L2cCocCreditSendTest
 | 
			
		||||
 *        
 | 
			
		||||
 *  \brief  For testing purposes only.
 | 
			
		||||
 *
 | 
			
		||||
 *  \param  cid       The local channel identifier.
 | 
			
		||||
 *  \param  credits   Credits to send.
 | 
			
		||||
 *
 | 
			
		||||
 *  \return None.
 | 
			
		||||
 */
 | 
			
		||||
/*************************************************************************************************/
 | 
			
		||||
void L2cCocCreditSendTest(uint16_t cid, uint16_t credits);
 | 
			
		||||
 | 
			
		||||
/*************************************************************************************************/
 | 
			
		||||
/*!
 | 
			
		||||
 *  \fn     L2cDmConnUpdateReq
 | 
			
		||||
 *        
 | 
			
		||||
 *  \brief  For internal use only.  This function is called by DM to send an L2CAP
 | 
			
		||||
 *          connection update request.
 | 
			
		||||
 *
 | 
			
		||||
 *  \param  handle      The connection handle.
 | 
			
		||||
 *  \param  pConnSpec   Pointer to the connection specification structure.
 | 
			
		||||
 *
 | 
			
		||||
 *  \return None.
 | 
			
		||||
 */
 | 
			
		||||
/*************************************************************************************************/
 | 
			
		||||
void L2cDmConnUpdateReq(uint16_t handle, hciConnSpec_t *pConnSpec);
 | 
			
		||||
 | 
			
		||||
/*************************************************************************************************/
 | 
			
		||||
/*!
 | 
			
		||||
 *  \fn     L2cDmConnUpdateRsp
 | 
			
		||||
 *        
 | 
			
		||||
 *  \brief  For internal use only.  This function is called by DM to send an L2CAP
 | 
			
		||||
 *          connection update response.
 | 
			
		||||
 *
 | 
			
		||||
 *  \param  identifier  Identifier value previously passed from L2C to DM.
 | 
			
		||||
 *  \param  handle      The connection handle.
 | 
			
		||||
 *  \param  result      Connection update response result.
 | 
			
		||||
 *
 | 
			
		||||
 *  \return None.
 | 
			
		||||
 */
 | 
			
		||||
/*************************************************************************************************/
 | 
			
		||||
void L2cDmConnUpdateRsp(uint8_t identifier, uint16_t handle, uint16_t result);
 | 
			
		||||
 | 
			
		||||
#ifdef __cplusplus
 | 
			
		||||
};
 | 
			
		||||
#endif
 | 
			
		||||
 | 
			
		||||
#endif /* L2C_API_H */
 | 
			
		||||
| 
						 | 
				
			
			@ -1,112 +0,0 @@
 | 
			
		|||
/*************************************************************************************************/
 | 
			
		||||
/*!
 | 
			
		||||
 *  \file   l2c_defs.h
 | 
			
		||||
 *        
 | 
			
		||||
 *  \brief  L2CAP constants and definitions from the Bluetooth specification.
 | 
			
		||||
 *
 | 
			
		||||
 *          $Date: 2015-06-12 04:19:18 -0700 (Fri, 12 Jun 2015) $
 | 
			
		||||
 *          $Revision: 3061 $
 | 
			
		||||
 *  
 | 
			
		||||
 *  Copyright (c) 2009 Wicentric, Inc., all rights reserved.
 | 
			
		||||
 *  Wicentric confidential and proprietary.
 | 
			
		||||
 *
 | 
			
		||||
 *  IMPORTANT.  Your use of this file is governed by a Software License Agreement
 | 
			
		||||
 *  ("Agreement") that must be accepted in order to download or otherwise receive a
 | 
			
		||||
 *  copy of this file.  You may not use or copy this file for any purpose other than
 | 
			
		||||
 *  as described in the Agreement.  If you do not agree to all of the terms of the
 | 
			
		||||
 *  Agreement do not use this file and delete all copies in your possession or control;
 | 
			
		||||
 *  if you do not have a copy of the Agreement, you must contact Wicentric, Inc. prior
 | 
			
		||||
 *  to any use, copying or further distribution of this software.
 | 
			
		||||
 */
 | 
			
		||||
/*************************************************************************************************/
 | 
			
		||||
#ifndef L2C_DEFS_H
 | 
			
		||||
#define L2C_DEFS_H
 | 
			
		||||
 | 
			
		||||
#ifdef __cplusplus
 | 
			
		||||
extern "C" {
 | 
			
		||||
#endif
 | 
			
		||||
 | 
			
		||||
/**************************************************************************************************
 | 
			
		||||
  Macros
 | 
			
		||||
**************************************************************************************************/
 | 
			
		||||
 | 
			
		||||
/*! Packet definitions */
 | 
			
		||||
#define L2C_HDR_LEN                   4         /*! L2CAP packet header length */
 | 
			
		||||
#define L2C_MIN_MTU                   23        /*! Minimum packet payload MTU for LE */
 | 
			
		||||
#define L2C_SIG_HDR_LEN               4         /*! L2CAP signaling command header length */
 | 
			
		||||
#define L2C_LE_SDU_HDR_LEN            2         /*! L2CAP LE SDU data header length */
 | 
			
		||||
 | 
			
		||||
/*! Start of L2CAP payload in an HCI ACL packet buffer */
 | 
			
		||||
#define L2C_PAYLOAD_START             (HCI_ACL_HDR_LEN + L2C_HDR_LEN)
 | 
			
		||||
 | 
			
		||||
/*! L2CAP signaling packet base length, including HCI header */
 | 
			
		||||
#define L2C_SIG_PKT_BASE_LEN          (HCI_ACL_HDR_LEN + L2C_HDR_LEN + L2C_SIG_HDR_LEN)
 | 
			
		||||
 | 
			
		||||
/*! L2CAP LE SDU packet base length, including HCI header */
 | 
			
		||||
#define L2C_LE_SDU_PKT_BASE_LEN       (HCI_ACL_HDR_LEN + L2C_HDR_LEN + L2C_LE_SDU_HDR_LEN)
 | 
			
		||||
 | 
			
		||||
/*! Signaling packet parameter lengths */
 | 
			
		||||
#define L2C_SIG_CONN_UPDATE_REQ_LEN   8
 | 
			
		||||
#define L2C_SIG_CONN_UPDATE_RSP_LEN   2
 | 
			
		||||
#define L2C_SIG_CMD_REJ_LEN           2
 | 
			
		||||
#define L2C_SIG_DISCONN_REQ_LEN       4
 | 
			
		||||
#define L2C_SIG_DISCONN_RSP_LEN       4
 | 
			
		||||
#define L2C_SIG_LE_CONN_REQ_LEN       10
 | 
			
		||||
#define L2C_SIG_LE_CONN_RSP_LEN       10
 | 
			
		||||
#define L2C_SIG_FLOW_CTRL_CREDIT_LEN  4
 | 
			
		||||
 | 
			
		||||
/*! Connection identifiers */
 | 
			
		||||
#define L2C_CID_ATT                   0x0004    /*! CID for attribute protocol */
 | 
			
		||||
#define L2C_CID_LE_SIGNALING          0x0005    /*! CID for LE signaling */
 | 
			
		||||
#define L2C_CID_SMP                   0x0006    /*! CID for security manager protocol */
 | 
			
		||||
 | 
			
		||||
/*! Signaling codes */
 | 
			
		||||
#define L2C_SIG_CMD_REJ               0x01      /*! Comand reject */
 | 
			
		||||
#define L2C_SIG_DISCONNECT_REQ        0x06      /*! Disconnect request */
 | 
			
		||||
#define L2C_SIG_DISCONNECT_RSP        0x07      /*! Disconnect response */
 | 
			
		||||
#define L2C_SIG_CONN_UPDATE_REQ       0x12      /*! Connection parameter update request */
 | 
			
		||||
#define L2C_SIG_CONN_UPDATE_RSP       0x13      /*! Connection parameter update response */
 | 
			
		||||
#define L2C_SIG_LE_CONNECT_REQ        0x14      /*! LE credit based connection request */
 | 
			
		||||
#define L2C_SIG_LE_CONNECT_RSP        0x15      /*! LE credit based connection response */
 | 
			
		||||
#define L2C_SIG_FLOW_CTRL_CREDIT      0x16      /*! LE flow control credit */
 | 
			
		||||
 | 
			
		||||
/*! Signaling response code flag */
 | 
			
		||||
#define L2C_SIG_RSP_FLAG              0x01
 | 
			
		||||
 | 
			
		||||
/*! Command reject reason codes */
 | 
			
		||||
#define L2C_REJ_NOT_UNDERSTOOD        0x0000    /*! Command not understood */
 | 
			
		||||
#define L2C_REJ_MTU_EXCEEDED          0x0001    /*! Signaling MTU exceeded */
 | 
			
		||||
#define L2C_REJ_INVALID_CID           0x0002    /*! Invalid CID in request */
 | 
			
		||||
 | 
			
		||||
/*! Connection parameter update result */
 | 
			
		||||
#define L2C_CONN_PARAM_ACCEPTED       0x0000    /*! Connection parameters accepted */
 | 
			
		||||
#define L2C_CONN_PARAM_REJECTED       0x0001    /*! Connection parameters rejected */
 | 
			
		||||
 | 
			
		||||
/*! LE connection result */
 | 
			
		||||
#define L2C_CONN_SUCCESS              0x0000    /*! Connection successful */
 | 
			
		||||
#define L2C_CONN_NONE                 0x0001    /*! No connection result value available */
 | 
			
		||||
#define L2C_CONN_FAIL_PSM             0x0002    /*! Connection refused LE_PSM not supported */
 | 
			
		||||
#define L2C_CONN_FAIL_RES             0x0004    /*! Connection refused no resources available */
 | 
			
		||||
#define L2C_CONN_FAIL_AUTH            0x0005    /*! Connection refused insufficient authentication */
 | 
			
		||||
#define L2C_CONN_FAIL_AUTHORIZ        0x0006    /*! Connection refused insufficient authorization */
 | 
			
		||||
#define L2C_CONN_FAIL_KEY_SIZE        0x0007    /*! Connection refused insufficient encryption key size */
 | 
			
		||||
#define L2C_CONN_FAIL_ENC             0x0008    /*! Connection Refused insufficient encryption */
 | 
			
		||||
 | 
			
		||||
/*! LE connection result proprietary codes */
 | 
			
		||||
#define L2C_CONN_FAIL_TIMEOUT         0xF000    /*! Request timeout */
 | 
			
		||||
 | 
			
		||||
/*! Signaling parameter value ranges */
 | 
			
		||||
#define L2C_PSM_MIN                   0x0001
 | 
			
		||||
#define L2C_PSM_MAX                   0x00FF
 | 
			
		||||
#define L2C_CID_DYN_MIN               0x0040
 | 
			
		||||
#define L2C_CID_DYN_MAX               0x007F
 | 
			
		||||
#define L2C_MTU_MIN                   0x0017
 | 
			
		||||
#define L2C_MPS_MIN                   0x0017
 | 
			
		||||
#define L2C_MPS_MAX                   0xFFFD
 | 
			
		||||
#define L2C_CREDITS_MAX               0xFFFF
 | 
			
		||||
 | 
			
		||||
#ifdef __cplusplus
 | 
			
		||||
};
 | 
			
		||||
#endif
 | 
			
		||||
 | 
			
		||||
#endif /* L2C_DEFS_H */
 | 
			
		||||
| 
						 | 
				
			
			@ -1,93 +0,0 @@
 | 
			
		|||
/*************************************************************************************************/
 | 
			
		||||
/*!
 | 
			
		||||
 *  \file   l2c_handler.h
 | 
			
		||||
 *        
 | 
			
		||||
 *  \brief  L2CAP handler interface.
 | 
			
		||||
 *
 | 
			
		||||
 *          $Date $
 | 
			
		||||
 *          $Revision $
 | 
			
		||||
 *  
 | 
			
		||||
 *  Copyright (c) 2009 Wicentric, Inc., all rights reserved.
 | 
			
		||||
 *  Wicentric confidential and proprietary.
 | 
			
		||||
 *
 | 
			
		||||
 *  IMPORTANT.  Your use of this file is governed by a Software License Agreement
 | 
			
		||||
 *  ("Agreement") that must be accepted in order to download or otherwise receive a
 | 
			
		||||
 *  copy of this file.  You may not use or copy this file for any purpose other than
 | 
			
		||||
 *  as described in the Agreement.  If you do not agree to all of the terms of the
 | 
			
		||||
 *  Agreement do not use this file and delete all copies in your possession or control;
 | 
			
		||||
 *  if you do not have a copy of the Agreement, you must contact Wicentric, Inc. prior
 | 
			
		||||
 *  to any use, copying or further distribution of this software.
 | 
			
		||||
 */
 | 
			
		||||
/*************************************************************************************************/
 | 
			
		||||
#ifndef L2C_HANDLER_H
 | 
			
		||||
#define L2C_HANDLER_H
 | 
			
		||||
 | 
			
		||||
#include "wsf_os.h"
 | 
			
		||||
 | 
			
		||||
#ifdef __cplusplus
 | 
			
		||||
extern "C" {
 | 
			
		||||
#endif
 | 
			
		||||
 | 
			
		||||
/**************************************************************************************************
 | 
			
		||||
  Function Declarations
 | 
			
		||||
**************************************************************************************************/
 | 
			
		||||
 | 
			
		||||
/*************************************************************************************************/
 | 
			
		||||
/*!
 | 
			
		||||
 *  \fn     L2cSlaveHandlerInit
 | 
			
		||||
 *        
 | 
			
		||||
 *  \brief  Event handler initialization function for L2C when operating as a slave.
 | 
			
		||||
 *
 | 
			
		||||
 *  \param  handlerId  ID for this event handler.
 | 
			
		||||
 *
 | 
			
		||||
 *  \return None.
 | 
			
		||||
 */
 | 
			
		||||
/*************************************************************************************************/
 | 
			
		||||
void L2cSlaveHandlerInit(wsfHandlerId_t handlerId);
 | 
			
		||||
 | 
			
		||||
/*************************************************************************************************/
 | 
			
		||||
/*!
 | 
			
		||||
 *  \fn     L2cSlaveHandler
 | 
			
		||||
 *        
 | 
			
		||||
 *  \brief  The WSF event handler for L2C when operating as a slave.
 | 
			
		||||
 *
 | 
			
		||||
 *  \param  event   Event mask.
 | 
			
		||||
 *  \param  pMsg    Pointer to message.
 | 
			
		||||
 *
 | 
			
		||||
 *  \return None.
 | 
			
		||||
 */
 | 
			
		||||
/*************************************************************************************************/
 | 
			
		||||
void L2cSlaveHandler(wsfEventMask_t event, wsfMsgHdr_t *pMsg);
 | 
			
		||||
 | 
			
		||||
/*************************************************************************************************/
 | 
			
		||||
/*!
 | 
			
		||||
 *  \fn     L2cCocHandlerInit
 | 
			
		||||
 *        
 | 
			
		||||
 *  \brief  Event handler initialization function for L2C with connection oriented channels.
 | 
			
		||||
 *
 | 
			
		||||
 *  \param  handlerId  ID for this event handler.
 | 
			
		||||
 *
 | 
			
		||||
 *  \return None.
 | 
			
		||||
 */
 | 
			
		||||
/*************************************************************************************************/
 | 
			
		||||
void L2cCocHandlerInit(wsfHandlerId_t handlerId);
 | 
			
		||||
 | 
			
		||||
/*************************************************************************************************/
 | 
			
		||||
/*!
 | 
			
		||||
 *  \fn     L2cCocHandler
 | 
			
		||||
 *        
 | 
			
		||||
 *  \brief  The WSF event handler for L2C with connection oriented channels.
 | 
			
		||||
 *
 | 
			
		||||
 *  \param  event   Event mask.
 | 
			
		||||
 *  \param  pMsg    Pointer to message.
 | 
			
		||||
 *
 | 
			
		||||
 *  \return None.
 | 
			
		||||
 */
 | 
			
		||||
/*************************************************************************************************/
 | 
			
		||||
void L2cCocHandler(wsfEventMask_t event, wsfMsgHdr_t *pMsg);
 | 
			
		||||
 | 
			
		||||
#ifdef __cplusplus
 | 
			
		||||
};
 | 
			
		||||
#endif
 | 
			
		||||
 | 
			
		||||
#endif /* L2C_HANDLER_H */
 | 
			
		||||
| 
						 | 
				
			
			@ -1,238 +0,0 @@
 | 
			
		|||
/*************************************************************************************************/
 | 
			
		||||
/*!
 | 
			
		||||
 *  \file   smp_api.h
 | 
			
		||||
 *        
 | 
			
		||||
 *  \brief  SMP subsystem API.
 | 
			
		||||
 *
 | 
			
		||||
 *          $Date: 2015-06-12 04:19:18 -0700 (Fri, 12 Jun 2015) $
 | 
			
		||||
 *          $Revision: 3061 $
 | 
			
		||||
 *  
 | 
			
		||||
 *  Copyright (c) 2010 Wicentric, Inc., all rights reserved.
 | 
			
		||||
 *  Wicentric confidential and proprietary.
 | 
			
		||||
 *
 | 
			
		||||
 *  IMPORTANT.  Your use of this file is governed by a Software License Agreement
 | 
			
		||||
 *  ("Agreement") that must be accepted in order to download or otherwise receive a
 | 
			
		||||
 *  copy of this file.  You may not use or copy this file for any purpose other than
 | 
			
		||||
 *  as described in the Agreement.  If you do not agree to all of the terms of the
 | 
			
		||||
 *  Agreement do not use this file and delete all copies in your possession or control;
 | 
			
		||||
 *  if you do not have a copy of the Agreement, you must contact Wicentric, Inc. prior
 | 
			
		||||
 *  to any use, copying or further distribution of this software.
 | 
			
		||||
 */
 | 
			
		||||
/*************************************************************************************************/
 | 
			
		||||
#ifndef SMP_API_H
 | 
			
		||||
#define SMP_API_H
 | 
			
		||||
 | 
			
		||||
#include "wsf_os.h"
 | 
			
		||||
#include "smp_defs.h"
 | 
			
		||||
#include "dm_api.h"
 | 
			
		||||
 | 
			
		||||
#ifdef __cplusplus
 | 
			
		||||
extern "C" {
 | 
			
		||||
#endif
 | 
			
		||||
 | 
			
		||||
/**************************************************************************************************
 | 
			
		||||
  Macros
 | 
			
		||||
**************************************************************************************************/
 | 
			
		||||
 | 
			
		||||
/*! Event handler messages for SMP state machines */
 | 
			
		||||
enum
 | 
			
		||||
{
 | 
			
		||||
  SMP_MSG_API_PAIR_REQ = 1,               /*! API pairing request */
 | 
			
		||||
  SMP_MSG_API_PAIR_RSP,                   /*! API pairing response */
 | 
			
		||||
  SMP_MSG_API_CANCEL_REQ,                 /*! API cancel request */
 | 
			
		||||
  SMP_MSG_API_AUTH_RSP,                   /*! API pin response */
 | 
			
		||||
  SMP_MSG_API_SECURITY_REQ,               /*! API security request */
 | 
			
		||||
  SMP_MSG_CMD_PKT,                        /*! SMP command packet received */
 | 
			
		||||
  SMP_MSG_CMD_PAIRING_FAILED,             /*! SMP pairing failed packet received */
 | 
			
		||||
  SMP_MSG_DM_ENCRYPT_CMPL,                /*! Link encrypted */
 | 
			
		||||
  SMP_MSG_DM_ENCRYPT_FAILED,              /*! Link encryption failed */
 | 
			
		||||
  SMP_MSG_DM_CONN_CLOSE,                  /*! Connection closed */
 | 
			
		||||
  SMP_MSG_WSF_AES_CMPL,                   /*! AES calculation complete */
 | 
			
		||||
  SMP_MSG_INT_SEND_NEXT_KEY,              /*! Send next key to be distributed */
 | 
			
		||||
  SMP_MSG_INT_MAX_ATTEMPTS,               /*! Maximum pairing attempts reached */
 | 
			
		||||
  SMP_MSG_INT_PAIRING_CMPL,               /*! Pairing complete */
 | 
			
		||||
  SMP_MSG_INT_TIMEOUT,                    /*! Pairing protocol timeout */
 | 
			
		||||
  SMP_MSG_INT_LESC,                       /*! Pair with Secure Connections */
 | 
			
		||||
  SMP_MSG_INT_LEGACY,                     /*! Pair with Legacy Security */
 | 
			
		||||
  SMP_MSG_INT_JW_NC,                      /*! LESC Just-Works/Numeric Comparison pairing */
 | 
			
		||||
  SMP_MSG_INT_PASSKEY,                    /*! LESC Passkey pairing */
 | 
			
		||||
  SMP_MSG_INT_OOB,                        /*! LESC Out-of-Band Pairing */
 | 
			
		||||
  SMP_MSG_API_USER_CONFIRM,               /*! User confirms valid numeric comparison */
 | 
			
		||||
  SMP_MSG_API_USER_KEYPRESS,              /*! User keypress in passkey pairing */
 | 
			
		||||
  SMP_MSG_API_KEYPRESS_CMPL,              /*! User keypress complete in passkey pairing */
 | 
			
		||||
  SMP_MSG_WSF_ECC_CMPL,                   /*! WSF ECC operation complete */
 | 
			
		||||
  SMP_MSG_INT_PK_NEXT,                    /*! Continue to next passkey bit */
 | 
			
		||||
  SMP_MSG_INT_PK_CMPL,                    /*! Passkey operation complete */
 | 
			
		||||
  SMP_MSG_WSF_CMAC_CMPL,                  /*! WSF CMAC operation complete */
 | 
			
		||||
  SMP_MSG_DH_CHECK_FAILURE,               /*! WSF CMAC operation complete */
 | 
			
		||||
  SMP_NUM_MSGS
 | 
			
		||||
};
 | 
			
		||||
 | 
			
		||||
/**************************************************************************************************
 | 
			
		||||
  Data Types
 | 
			
		||||
**************************************************************************************************/
 | 
			
		||||
 | 
			
		||||
/*! Configurable parameters */
 | 
			
		||||
typedef struct
 | 
			
		||||
{
 | 
			
		||||
  uint16_t            attemptTimeout;     /*! 'Repeated attempts' timeout in msec */
 | 
			
		||||
  uint8_t             ioCap;              /*! I/O Capability */
 | 
			
		||||
  uint8_t             minKeyLen;          /*! Minimum encryption key length */
 | 
			
		||||
  uint8_t             maxKeyLen;          /*! Maximum encryption key length */
 | 
			
		||||
  uint8_t             maxAttempts;        /*! Attempts to trigger 'repeated attempts' timeout */
 | 
			
		||||
  uint8_t             auth;               /*! Device authentication requirements */
 | 
			
		||||
} smpCfg_t;
 | 
			
		||||
 | 
			
		||||
/*! Data type for SMP_MSG_API_PAIR_REQ and SMP_MSG_API_PAIR_RSP */
 | 
			
		||||
typedef struct
 | 
			
		||||
{
 | 
			
		||||
  wsfMsgHdr_t         hdr;
 | 
			
		||||
  uint8_t             oob;
 | 
			
		||||
  uint8_t             auth;
 | 
			
		||||
  uint8_t             iKeyDist;
 | 
			
		||||
  uint8_t             rKeyDist;
 | 
			
		||||
} smpDmPair_t;
 | 
			
		||||
 | 
			
		||||
/*! Data type for SMP_MSG_API_AUTH_RSP */
 | 
			
		||||
typedef struct
 | 
			
		||||
{
 | 
			
		||||
  wsfMsgHdr_t         hdr;
 | 
			
		||||
  uint8_t             authData[SMP_OOB_LEN];
 | 
			
		||||
  uint8_t             authDataLen;
 | 
			
		||||
} smpDmAuthRsp_t;
 | 
			
		||||
 | 
			
		||||
/*! Data type for SMP_MSG_API_USER_KEYPRESS */
 | 
			
		||||
typedef struct
 | 
			
		||||
{
 | 
			
		||||
  wsfMsgHdr_t         hdr;
 | 
			
		||||
  uint8_t             keypress;
 | 
			
		||||
} smpDmKeypress_t;
 | 
			
		||||
 | 
			
		||||
/*! Data type for SMP_MSG_API_SECURITY_REQ */
 | 
			
		||||
typedef struct
 | 
			
		||||
{
 | 
			
		||||
  wsfMsgHdr_t         hdr;
 | 
			
		||||
  uint8_t             auth;
 | 
			
		||||
} smpDmSecurityReq_t;
 | 
			
		||||
 | 
			
		||||
/*! Union SMP DM message data types */
 | 
			
		||||
typedef union
 | 
			
		||||
{
 | 
			
		||||
  wsfMsgHdr_t         hdr;
 | 
			
		||||
  smpDmPair_t         pair;
 | 
			
		||||
  smpDmAuthRsp_t      authRsp;
 | 
			
		||||
  smpDmSecurityReq_t  securityReq;
 | 
			
		||||
  smpDmKeypress_t     keypress;
 | 
			
		||||
} smpDmMsg_t;
 | 
			
		||||
 | 
			
		||||
/**************************************************************************************************
 | 
			
		||||
  Global Variables;
 | 
			
		||||
**************************************************************************************************/
 | 
			
		||||
 | 
			
		||||
/*! Configuration pointer */
 | 
			
		||||
extern smpCfg_t *pSmpCfg;
 | 
			
		||||
 | 
			
		||||
/**************************************************************************************************
 | 
			
		||||
  Function Declarations
 | 
			
		||||
**************************************************************************************************/
 | 
			
		||||
 | 
			
		||||
/*************************************************************************************************/
 | 
			
		||||
/*!
 | 
			
		||||
 *  \fn     SmpiInit
 | 
			
		||||
 *        
 | 
			
		||||
 *  \brief  Initialize SMP initiator role.
 | 
			
		||||
 *
 | 
			
		||||
 *  \return None.
 | 
			
		||||
 */
 | 
			
		||||
/*************************************************************************************************/
 | 
			
		||||
void SmpiInit(void);
 | 
			
		||||
 | 
			
		||||
/*************************************************************************************************/
 | 
			
		||||
/*!
 | 
			
		||||
 *  \fn     SmprInit
 | 
			
		||||
 *        
 | 
			
		||||
 *  \brief  Initialize SMP responder role.
 | 
			
		||||
 *
 | 
			
		||||
 *  \return None.
 | 
			
		||||
 */
 | 
			
		||||
/*************************************************************************************************/
 | 
			
		||||
void SmprInit(void);
 | 
			
		||||
 | 
			
		||||
/*************************************************************************************************/
 | 
			
		||||
/*!
 | 
			
		||||
 *  \fn     SmpiScInit
 | 
			
		||||
 *        
 | 
			
		||||
 *  \brief  Initialize SMP initiator role utilizing BTLE Secure Connections.
 | 
			
		||||
 *
 | 
			
		||||
 *  \return None.
 | 
			
		||||
 */
 | 
			
		||||
/*************************************************************************************************/
 | 
			
		||||
void SmpiScInit(void);
 | 
			
		||||
 | 
			
		||||
/*************************************************************************************************/
 | 
			
		||||
/*!
 | 
			
		||||
 *  \fn     SmprScInit
 | 
			
		||||
 *        
 | 
			
		||||
 *  \brief  Initialize SMP responder role utilizing BTLE Secure Connections.
 | 
			
		||||
 *
 | 
			
		||||
 *  \return None.
 | 
			
		||||
 */
 | 
			
		||||
/*************************************************************************************************/
 | 
			
		||||
void SmprScInit(void);
 | 
			
		||||
 | 
			
		||||
/*************************************************************************************************/
 | 
			
		||||
/*!
 | 
			
		||||
 *  \fn     SmpNonInit
 | 
			
		||||
 *        
 | 
			
		||||
 *  \brief  Use this SMP init function when SMP is not supported.
 | 
			
		||||
 *
 | 
			
		||||
 *  \return None.
 | 
			
		||||
 */
 | 
			
		||||
/*************************************************************************************************/
 | 
			
		||||
void SmpNonInit(void);
 | 
			
		||||
 | 
			
		||||
/*************************************************************************************************/
 | 
			
		||||
/*!
 | 
			
		||||
 *  \fn     SmpDmMsgSend
 | 
			
		||||
 *        
 | 
			
		||||
 *  \brief  This function is called by DM to send a message to SMP.
 | 
			
		||||
 *
 | 
			
		||||
 *  \param  pMsg      Pointer to message structure.
 | 
			
		||||
 *
 | 
			
		||||
 *  \return None.
 | 
			
		||||
 */
 | 
			
		||||
/*************************************************************************************************/
 | 
			
		||||
void SmpDmMsgSend(smpDmMsg_t *pMsg);
 | 
			
		||||
 | 
			
		||||
/*************************************************************************************************/
 | 
			
		||||
/*!
 | 
			
		||||
 *  \fn     SmpDmEncryptInd
 | 
			
		||||
 *        
 | 
			
		||||
 *  \brief  This function is called by DM to notify SMP of encrypted link status.
 | 
			
		||||
 *
 | 
			
		||||
 *  \param  pMsg    Pointer to HCI message structure.
 | 
			
		||||
 *
 | 
			
		||||
 *  \return None.
 | 
			
		||||
 */
 | 
			
		||||
/*************************************************************************************************/
 | 
			
		||||
void SmpDmEncryptInd(wsfMsgHdr_t *pMsg);
 | 
			
		||||
 | 
			
		||||
/*************************************************************************************************/
 | 
			
		||||
/*!
 | 
			
		||||
 *  \fn     SmpDmGetStk
 | 
			
		||||
 *        
 | 
			
		||||
 *  \brief  Return the STK for the given connection.
 | 
			
		||||
 *
 | 
			
		||||
 *  \param  connId    Connection identifier.
 | 
			
		||||
 *  \param  pSecLevel Returns the security level of pairing when STK was created.
 | 
			
		||||
 *
 | 
			
		||||
 *  \return Pointer to STK or NULL if not available.
 | 
			
		||||
 */
 | 
			
		||||
/*************************************************************************************************/
 | 
			
		||||
uint8_t *SmpDmGetStk(dmConnId_t connId, uint8_t *pSecLevel);
 | 
			
		||||
 | 
			
		||||
#ifdef __cplusplus
 | 
			
		||||
};
 | 
			
		||||
#endif
 | 
			
		||||
 | 
			
		||||
#endif /* SMP_API_H */
 | 
			
		||||
| 
						 | 
				
			
			@ -1,152 +0,0 @@
 | 
			
		|||
/*************************************************************************************************/
 | 
			
		||||
/*!
 | 
			
		||||
 *  \file   smp_defs.h
 | 
			
		||||
 *        
 | 
			
		||||
 *  \brief  Security manager constants and definitions from the Bluetooth specification.
 | 
			
		||||
 *
 | 
			
		||||
 *          $Date: 2015-10-15 10:06:43 -0700 (Thu, 15 Oct 2015) $
 | 
			
		||||
 *          $Revision: 4216 $
 | 
			
		||||
 *  
 | 
			
		||||
 *  Copyright (c) 2010 Wicentric, Inc., all rights reserved.
 | 
			
		||||
 *  Wicentric confidential and proprietary.
 | 
			
		||||
 *
 | 
			
		||||
 *  IMPORTANT.  Your use of this file is governed by a Software License Agreement
 | 
			
		||||
 *  ("Agreement") that must be accepted in order to download or otherwise receive a
 | 
			
		||||
 *  copy of this file.  You may not use or copy this file for any purpose other than
 | 
			
		||||
 *  as described in the Agreement.  If you do not agree to all of the terms of the
 | 
			
		||||
 *  Agreement do not use this file and delete all copies in your possession or control;
 | 
			
		||||
 *  if you do not have a copy of the Agreement, you must contact Wicentric, Inc. prior
 | 
			
		||||
 *  to any use, copying or further distribution of this software.
 | 
			
		||||
 */
 | 
			
		||||
/*************************************************************************************************/
 | 
			
		||||
#ifndef SMP_DEFS_H
 | 
			
		||||
#define SMP_DEFS_H
 | 
			
		||||
 | 
			
		||||
#ifdef __cplusplus
 | 
			
		||||
extern "C" {
 | 
			
		||||
#endif
 | 
			
		||||
 | 
			
		||||
/**************************************************************************************************
 | 
			
		||||
  Macros
 | 
			
		||||
**************************************************************************************************/
 | 
			
		||||
 | 
			
		||||
/*! PDU format */
 | 
			
		||||
#define SMP_HDR_LEN                   1         /*! Attribute PDU header length */
 | 
			
		||||
 | 
			
		||||
/*! Protocol timeout */
 | 
			
		||||
#define SMP_TIMEOUT                   30        /*! Protocol timeout in seconds */
 | 
			
		||||
 | 
			
		||||
/*! Encryption key size */
 | 
			
		||||
#define SMP_KEY_SIZE_MAX              16        /*! Maximum encryption key size */
 | 
			
		||||
#define SMP_KEY_SIZE_MIN              7         /*! Minimum encryption key size */
 | 
			
		||||
 | 
			
		||||
/*! OOB and PIN data lengths in bytes */
 | 
			
		||||
#define SMP_OOB_LEN                   16
 | 
			
		||||
#define SMP_PIN_LEN                   3
 | 
			
		||||
 | 
			
		||||
/*! Error codes */
 | 
			
		||||
#define SMP_ERR_PASSKEY_ENTRY         0x01      /*! User input of passkey failed */
 | 
			
		||||
#define SMP_ERR_OOB                   0x02      /*! OOB data is not available */
 | 
			
		||||
#define SMP_ERR_AUTH_REQ              0x03      /*! Authentication requirements cannot be met */
 | 
			
		||||
#define SMP_ERR_CONFIRM_VALUE         0x04      /*! Confirm value does not match */
 | 
			
		||||
#define SMP_ERR_PAIRING_NOT_SUP       0x05      /*! Pairing is not supported by the device */
 | 
			
		||||
#define SMP_ERR_ENC_KEY_SIZE          0x06      /*! Insufficient encryption key size */
 | 
			
		||||
#define SMP_ERR_COMMAND_NOT_SUP       0x07      /*! Command not supported */
 | 
			
		||||
#define SMP_ERR_UNSPECIFIED           0x08      /*! Unspecified reason */
 | 
			
		||||
#define SMP_ERR_ATTEMPTS              0x09      /*! Repeated attempts */
 | 
			
		||||
#define SMP_ERR_INVALID_PARAM         0x0A      /*! Invalid parameter or command length */
 | 
			
		||||
#define SMP_ERR_DH_KEY_CHECK          0x0B      /*! DH Key check did not match */
 | 
			
		||||
#define SMP_ERR_NUMERIC_COMPARISON    0x0C      /*! Numeric comparison did not match */
 | 
			
		||||
#define SMP_ERR_BR_EDR_IN_PROGRESS    0x0D      /*! BR/EDR in progress */
 | 
			
		||||
#define SMP_ERR_CROSS_TRANSPORT       0x0E      /*! BR/EDR Cross transport key generation not allowed */
 | 
			
		||||
 | 
			
		||||
/*! Proprietary internal error codes */
 | 
			
		||||
#define SMP_ERR_MEMORY                0xE0      /*! Out of memory */
 | 
			
		||||
#define SMP_ERR_TIMEOUT               0xE1      /*! Transaction timeout */
 | 
			
		||||
 | 
			
		||||
/*! Command codes */
 | 
			
		||||
#define SMP_CMD_PAIR_REQ              0x01      /*! Pairing Request */
 | 
			
		||||
#define SMP_CMD_PAIR_RSP              0x02      /*! Pairing Response */
 | 
			
		||||
#define SMP_CMD_PAIR_CNF              0x03      /*! Pairing Confirm */
 | 
			
		||||
#define SMP_CMD_PAIR_RAND             0x04      /*! Pairing Random */
 | 
			
		||||
#define SMP_CMD_PAIR_FAIL             0x05      /*! Pairing Failed */
 | 
			
		||||
#define SMP_CMD_ENC_INFO              0x06      /*! Encryption Information */
 | 
			
		||||
#define SMP_CMD_MASTER_ID             0x07      /*! Master Identification */
 | 
			
		||||
#define SMP_CMD_ID_INFO               0x08      /*! Identity Information */
 | 
			
		||||
#define SMP_CMD_ID_ADDR_INFO          0x09      /*! Identity Address Information */
 | 
			
		||||
#define SMP_CMD_SIGN_INFO             0x0A      /*! Signing Information */
 | 
			
		||||
#define SMP_CMD_SECURITY_REQ          0x0B      /*! Security Request */
 | 
			
		||||
#define SMP_CMD_PUBLIC_KEY            0x0C      /*! Public Key */
 | 
			
		||||
#define SMP_CMD_DHKEY_CHECK           0x0D      /*! DH Key Check */
 | 
			
		||||
#define SMP_CMD_KEYPRESS              0x0E      /*! User Key Press */
 | 
			
		||||
#define SMP_CMD_MAX                   0x0F      /*! Command code maximum */
 | 
			
		||||
 | 
			
		||||
/*! Command packet lengths */
 | 
			
		||||
#define SMP_PAIR_REQ_LEN              7
 | 
			
		||||
#define SMP_PAIR_RSP_LEN              7
 | 
			
		||||
#define SMP_PAIR_CNF_LEN              17
 | 
			
		||||
#define SMP_PAIR_RAND_LEN             17
 | 
			
		||||
#define SMP_PAIR_FAIL_LEN             2
 | 
			
		||||
#define SMP_ENC_INFO_LEN              17
 | 
			
		||||
#define SMP_MASTER_ID_LEN             11
 | 
			
		||||
#define SMP_ID_INFO_LEN               17
 | 
			
		||||
#define SMP_ID_ADDR_INFO_LEN          8
 | 
			
		||||
#define SMP_SIGN_INFO_LEN             17
 | 
			
		||||
#define SMP_SECURITY_REQ_LEN          2
 | 
			
		||||
#define SMP_PUB_KEY_MSG_LEN           (1 + 2*SMP_PUB_KEY_LEN)
 | 
			
		||||
#define SMP_DHKEY_CHECK_MSG_LEN       (1 + SMP_DHKEY_CHECK_LEN)
 | 
			
		||||
#define SMP_KEYPRESS_MSG_LEN          2
 | 
			
		||||
 | 
			
		||||
/*! I/O capabilities */
 | 
			
		||||
#define SMP_IO_DISP_ONLY              0x00      /*! DisplayOnly */
 | 
			
		||||
#define SMP_IO_DISP_YES_NO            0x01      /*! DisplayYesNo */
 | 
			
		||||
#define SMP_IO_KEY_ONLY               0x02      /*! KeyboardOnly */
 | 
			
		||||
#define SMP_IO_NO_IN_NO_OUT           0x03      /*! NoInputNoOutput */
 | 
			
		||||
#define SMP_IO_KEY_DISP               0x04      /*! KeyboardDisplay */
 | 
			
		||||
 | 
			
		||||
/*! OOB data present */
 | 
			
		||||
#define SMP_OOB_DATA_NONE             0x00
 | 
			
		||||
#define SMP_OOB_DATA_PRESENT          0x01
 | 
			
		||||
 | 
			
		||||
/*! Authentication/security properties bit mask */
 | 
			
		||||
#define SMP_AUTH_BOND_MASK            0x03      /*! Mask for bonding bits */
 | 
			
		||||
#define SMP_AUTH_BOND_FLAG            0x01      /*! Bonding requested */
 | 
			
		||||
#define SMP_AUTH_MITM_FLAG            0x04      /*! MITM (authenticated pairing) requested */
 | 
			
		||||
#define SMP_AUTH_SC_FLAG              0x08      /*! LE Secure Connections requested */
 | 
			
		||||
#define SMP_AUTH_KP_FLAG              0x10      /*! Keypress notifications requested */
 | 
			
		||||
 | 
			
		||||
/*! Key distribution bit mask */
 | 
			
		||||
#define SMP_KEY_DIST_ENC              0x01      /*! Distribute LTK */
 | 
			
		||||
#define SMP_KEY_DIST_ID               0x02      /*! Distribute IRK */
 | 
			
		||||
#define SMP_KEY_DIST_SIGN             0x04      /*! Distribute CSRK */
 | 
			
		||||
#define SMP_KEY_DIST_MASK             (SMP_KEY_DIST_ENC | SMP_KEY_DIST_ID | SMP_KEY_DIST_SIGN)
 | 
			
		||||
 | 
			
		||||
/*! LESC Passkey keypress types */
 | 
			
		||||
#define SMP_PASSKEY_ENTRY_STARTED     0x00      /*! Passkey entry started keypress type */
 | 
			
		||||
#define SMP_PASSKEY_DIGIT_ENTERED     0x01      /*! Passkey digit entered keypress type */
 | 
			
		||||
#define SMP_PASSKEY_DIGIT_ERASED      0x02      /*! Passkey digit erased keypress type */
 | 
			
		||||
#define SMP_PASSKEY_CLEARED           0x03      /*! Passkey cleared keypress type */
 | 
			
		||||
#define SMP_PASSKEY_ENTRY_COMPLETED   0x04      /*! Passkey entry complete keypress type */
 | 
			
		||||
 | 
			
		||||
/*! Various parameter lengths */
 | 
			
		||||
#define SMP_RAND_LEN                  16
 | 
			
		||||
#define SMP_CONFIRM_LEN               16
 | 
			
		||||
#define SMP_KEY_LEN                   16
 | 
			
		||||
#define SMP_RAND8_LEN                 8
 | 
			
		||||
#define SMP_PRIVATE_KEY_LEN           32
 | 
			
		||||
#define SMP_PUB_KEY_LEN               32
 | 
			
		||||
#define SMP_DHKEY_LEN                 32
 | 
			
		||||
#define SMP_DHKEY_CHECK_LEN           16
 | 
			
		||||
 | 
			
		||||
/* CMAC Input Lengths */
 | 
			
		||||
#define SMP_F4_TEXT_LEN               (SMP_PUB_KEY_LEN * 2 + 1)
 | 
			
		||||
#define SMP_G2_TEXT_LEN               (SMP_PUB_KEY_LEN * 2 + SMP_RAND_LEN)
 | 
			
		||||
#define SMP_F5_TKEY_TEXT_LEN          (SMP_DHKEY_LEN)
 | 
			
		||||
#define SMP_F5_TEXT_LEN               (9 + 2*BDA_ADDR_LEN + 2*SMP_RAND_LEN)
 | 
			
		||||
#define SMP_F6_TEXT_LEN               (2*BDA_ADDR_LEN + 3*SMP_RAND_LEN + 5)
 | 
			
		||||
 | 
			
		||||
#ifdef __cplusplus
 | 
			
		||||
};
 | 
			
		||||
#endif
 | 
			
		||||
 | 
			
		||||
#endif /* SMP_DEFS_H */
 | 
			
		||||
| 
						 | 
				
			
			@ -1,67 +0,0 @@
 | 
			
		|||
/*************************************************************************************************/
 | 
			
		||||
/*!
 | 
			
		||||
 *  \file   smp_handler.h
 | 
			
		||||
 *
 | 
			
		||||
 *  \brief  Interface to SMP event handler.
 | 
			
		||||
 *
 | 
			
		||||
 *          $Date: 2012-03-29 13:24:04 -0700 (Thu, 29 Mar 2012) $
 | 
			
		||||
 *          $Revision: 287 $
 | 
			
		||||
 *
 | 
			
		||||
 *  Copyright (c) 2010 Wicentric, Inc., all rights reserved.
 | 
			
		||||
 *  Wicentric confidential and proprietary.
 | 
			
		||||
 *
 | 
			
		||||
 *  IMPORTANT.  Your use of this file is governed by a Software License Agreement
 | 
			
		||||
 *  ("Agreement") that must be accepted in order to download or otherwise receive a
 | 
			
		||||
 *  copy of this file.  You may not use or copy this file for any purpose other than
 | 
			
		||||
 *  as described in the Agreement.  If you do not agree to all of the terms of the
 | 
			
		||||
 *  Agreement do not use this file and delete all copies in your possession or control;
 | 
			
		||||
 *  if you do not have a copy of the Agreement, you must contact Wicentric, Inc. prior
 | 
			
		||||
 *  to any use, copying or further distribution of this software.
 | 
			
		||||
 */
 | 
			
		||||
/*************************************************************************************************/
 | 
			
		||||
#ifndef SMP_HANDLER_H
 | 
			
		||||
#define SMP_HANDLER_H
 | 
			
		||||
 | 
			
		||||
#include "wsf_os.h"
 | 
			
		||||
 | 
			
		||||
#ifdef __cplusplus
 | 
			
		||||
extern "C" {
 | 
			
		||||
#endif
 | 
			
		||||
 | 
			
		||||
/**************************************************************************************************
 | 
			
		||||
  Function Declarations
 | 
			
		||||
**************************************************************************************************/
 | 
			
		||||
 | 
			
		||||
/*************************************************************************************************/
 | 
			
		||||
/*!
 | 
			
		||||
 *  \fn     SmpHandlerInit
 | 
			
		||||
 *        
 | 
			
		||||
 *  \brief  SMP handler init function called during system initialization.
 | 
			
		||||
 *
 | 
			
		||||
 *  \param  handlerID  WSF handler ID for SMP.
 | 
			
		||||
 *
 | 
			
		||||
 *  \return None.
 | 
			
		||||
 */
 | 
			
		||||
/*************************************************************************************************/
 | 
			
		||||
void SmpHandlerInit(wsfHandlerId_t handlerId);
 | 
			
		||||
 | 
			
		||||
 | 
			
		||||
/*************************************************************************************************/
 | 
			
		||||
/*!
 | 
			
		||||
 *  \fn     SmpHandler
 | 
			
		||||
 *        
 | 
			
		||||
 *  \brief  WSF event handler for SMP.
 | 
			
		||||
 *
 | 
			
		||||
 *  \param  event   WSF event mask.
 | 
			
		||||
 *  \param  pMsg    WSF message.
 | 
			
		||||
 *
 | 
			
		||||
 *  \return None.
 | 
			
		||||
 */
 | 
			
		||||
/*************************************************************************************************/
 | 
			
		||||
void SmpHandler(wsfEventMask_t event, wsfMsgHdr_t *pMsg);
 | 
			
		||||
 | 
			
		||||
#ifdef __cplusplus
 | 
			
		||||
};
 | 
			
		||||
#endif
 | 
			
		||||
 | 
			
		||||
#endif /* SMP_HANDLER_H */
 | 
			
		||||
| 
						 | 
				
			
			@ -1,122 +0,0 @@
 | 
			
		|||
/*************************************************************************************************/
 | 
			
		||||
/*!
 | 
			
		||||
 *  \file   bda.h
 | 
			
		||||
 *
 | 
			
		||||
 *  \brief  Bluetooth device address utilities.
 | 
			
		||||
 *
 | 
			
		||||
 *          $Date: 2016-02-18 16:07:11 -0800 (Thu, 18 Feb 2016) $
 | 
			
		||||
 *          $Revision: 5910 $
 | 
			
		||||
 *
 | 
			
		||||
 *  Copyright (c) 2009 Wicentric, Inc., all rights reserved.
 | 
			
		||||
 *  Wicentric confidential and proprietary.
 | 
			
		||||
 *
 | 
			
		||||
 *  IMPORTANT.  Your use of this file is governed by a Software License Agreement
 | 
			
		||||
 *  ("Agreement") that must be accepted in order to download or otherwise receive a
 | 
			
		||||
 *  copy of this file.  You may not use or copy this file for any purpose other than
 | 
			
		||||
 *  as described in the Agreement.  If you do not agree to all of the terms of the
 | 
			
		||||
 *  Agreement do not use this file and delete all copies in your possession or control;
 | 
			
		||||
 *  if you do not have a copy of the Agreement, you must contact Wicentric, Inc. prior
 | 
			
		||||
 *  to any use, copying or further distribution of this software.
 | 
			
		||||
 */
 | 
			
		||||
/*************************************************************************************************/
 | 
			
		||||
#ifndef BDA_H
 | 
			
		||||
#define BDA_H
 | 
			
		||||
 | 
			
		||||
#ifdef __cplusplus
 | 
			
		||||
extern "C" {
 | 
			
		||||
#endif
 | 
			
		||||
 | 
			
		||||
/**************************************************************************************************
 | 
			
		||||
  Macros
 | 
			
		||||
**************************************************************************************************/
 | 
			
		||||
 | 
			
		||||
/*! BD address length */
 | 
			
		||||
#define BDA_ADDR_LEN         6
 | 
			
		||||
 | 
			
		||||
/*! BD address string length */
 | 
			
		||||
#define BDA_ADDR_STR_LEN    (BDA_ADDR_LEN * 2)
 | 
			
		||||
 | 
			
		||||
/**************************************************************************************************
 | 
			
		||||
  Data Types
 | 
			
		||||
**************************************************************************************************/
 | 
			
		||||
 | 
			
		||||
/*! BD address data type */
 | 
			
		||||
typedef uint8_t bdAddr_t[BDA_ADDR_LEN];
 | 
			
		||||
 | 
			
		||||
/**************************************************************************************************
 | 
			
		||||
  Function Declarations
 | 
			
		||||
**************************************************************************************************/
 | 
			
		||||
 | 
			
		||||
/*************************************************************************************************/
 | 
			
		||||
/*!
 | 
			
		||||
 *  \fn     BdaCpy
 | 
			
		||||
 *
 | 
			
		||||
 *  \brief  Copy a BD address from source to destination.
 | 
			
		||||
 *
 | 
			
		||||
 *  \param  pDst    Pointer to destination.
 | 
			
		||||
 *  \param  pSrc    Pointer to source.
 | 
			
		||||
 *
 | 
			
		||||
 *  \return None.
 | 
			
		||||
 */
 | 
			
		||||
/*************************************************************************************************/
 | 
			
		||||
void BdaCpy(uint8_t *pDst, const uint8_t *pSrc);
 | 
			
		||||
 | 
			
		||||
 | 
			
		||||
/*************************************************************************************************/
 | 
			
		||||
/*!
 | 
			
		||||
 *  \fn     BdaCmp
 | 
			
		||||
 *
 | 
			
		||||
 *  \brief  Compare two BD addresses.
 | 
			
		||||
 *
 | 
			
		||||
 *  \param  pAddr1  First address.
 | 
			
		||||
 *  \param  pAddr2  Second address.
 | 
			
		||||
 *
 | 
			
		||||
 *  \return TRUE if addresses match, FALSE otherwise.
 | 
			
		||||
 */
 | 
			
		||||
/*************************************************************************************************/
 | 
			
		||||
bool_t BdaCmp(const uint8_t *pAddr1, const uint8_t *pAddr2);
 | 
			
		||||
 | 
			
		||||
/*************************************************************************************************/
 | 
			
		||||
/*!
 | 
			
		||||
 *  \fn     BdaClr
 | 
			
		||||
 *
 | 
			
		||||
 *  \brief  Set a BD address to all zeros.
 | 
			
		||||
 *
 | 
			
		||||
 *  \param  pDst    Pointer to destination.
 | 
			
		||||
 *
 | 
			
		||||
 *  \return pDst + BDA_ADDR_LEN
 | 
			
		||||
 */
 | 
			
		||||
/*************************************************************************************************/
 | 
			
		||||
uint8_t *BdaClr(uint8_t *pDst);
 | 
			
		||||
 | 
			
		||||
/*************************************************************************************************/
 | 
			
		||||
/*!
 | 
			
		||||
*  \fn     BdaIsZeros
 | 
			
		||||
*
 | 
			
		||||
*  \brief  Check if a BD address is all zeros.
 | 
			
		||||
*
 | 
			
		||||
*  \param  pAddr    Pointer to address.
 | 
			
		||||
*
 | 
			
		||||
*  \return TRUE if address is all zeros, FALSE otherwise.
 | 
			
		||||
*/
 | 
			
		||||
/*************************************************************************************************/
 | 
			
		||||
bool_t BdaIsZeros(const uint8_t *pAddr);
 | 
			
		||||
 | 
			
		||||
/*************************************************************************************************/
 | 
			
		||||
/*!
 | 
			
		||||
 *  \fn     Bda2Str
 | 
			
		||||
 *
 | 
			
		||||
 *  \brief  Convert a BD address to a string.
 | 
			
		||||
 *
 | 
			
		||||
 *  \param  pAddr    Pointer to BD address.
 | 
			
		||||
 *
 | 
			
		||||
 *  \return Pointer to string.
 | 
			
		||||
 */
 | 
			
		||||
/*************************************************************************************************/
 | 
			
		||||
char *Bda2Str(const uint8_t *pAddr);
 | 
			
		||||
 | 
			
		||||
#ifdef __cplusplus
 | 
			
		||||
};
 | 
			
		||||
#endif
 | 
			
		||||
 | 
			
		||||
#endif /* BDA_H */
 | 
			
		||||
| 
						 | 
				
			
			@ -1,143 +0,0 @@
 | 
			
		|||
/*************************************************************************************************/
 | 
			
		||||
/*!
 | 
			
		||||
 *  \file   bstream.h
 | 
			
		||||
 *
 | 
			
		||||
 *  \brief  Byte stream to integer conversion macros.
 | 
			
		||||
 *
 | 
			
		||||
 *          $Date: 2015-10-25 12:07:49 -0700 (Sun, 25 Oct 2015) $
 | 
			
		||||
 *          $Revision: 4298 $
 | 
			
		||||
 *
 | 
			
		||||
 *  Copyright (c) 2009 Wicentric, Inc., all rights reserved.
 | 
			
		||||
 *  Wicentric confidential and proprietary.
 | 
			
		||||
 *
 | 
			
		||||
 *  IMPORTANT.  Your use of this file is governed by a Software License Agreement
 | 
			
		||||
 *  ("Agreement") that must be accepted in order to download or otherwise receive a
 | 
			
		||||
 *  copy of this file.  You may not use or copy this file for any purpose other than
 | 
			
		||||
 *  as described in the Agreement.  If you do not agree to all of the terms of the
 | 
			
		||||
 *  Agreement do not use this file and delete all copies in your possession or control;
 | 
			
		||||
 *  if you do not have a copy of the Agreement, you must contact Wicentric, Inc. prior
 | 
			
		||||
 *  to any use, copying or further distribution of this software.
 | 
			
		||||
 */
 | 
			
		||||
/*************************************************************************************************/
 | 
			
		||||
#ifndef BSTREAM_H
 | 
			
		||||
#define BSTREAM_H
 | 
			
		||||
 | 
			
		||||
#include "bda.h"
 | 
			
		||||
 | 
			
		||||
#ifdef __cplusplus
 | 
			
		||||
extern "C" {
 | 
			
		||||
#endif
 | 
			
		||||
 | 
			
		||||
/**************************************************************************************************
 | 
			
		||||
  Macros
 | 
			
		||||
**************************************************************************************************/
 | 
			
		||||
 | 
			
		||||
/*!
 | 
			
		||||
 * Macros for converting a little endian byte buffer to integers.
 | 
			
		||||
 */
 | 
			
		||||
#define BYTES_TO_UINT16(n, p)     {n = ((uint16_t)(p)[0] + ((uint16_t)(p)[1] << 8));}
 | 
			
		||||
 | 
			
		||||
#define BYTES_TO_UINT24(n, p)     {n = ((uint16_t)(p)[0] + ((uint16_t)(p)[1] << 8) + \
 | 
			
		||||
                                        ((uint16_t)(p)[2] << 16));}
 | 
			
		||||
 | 
			
		||||
#define BYTES_TO_UINT32(n, p)     {n = ((uint32_t)(p)[0] + ((uint32_t)(p)[1] << 8) + \
 | 
			
		||||
                                        ((uint32_t)(p)[2] << 16) + ((uint32_t)(p)[3] << 24));}
 | 
			
		||||
 | 
			
		||||
#define BYTES_TO_UINT40(n, p)     {n = ((uint64_t)(p)[0] + ((uint64_t)(p)[1] << 8) + \
 | 
			
		||||
                                        ((uint64_t)(p)[2] << 16) + ((uint64_t)(p)[3] << 24) + \
 | 
			
		||||
                                        ((uint64_t)(p)[4] << 32));}
 | 
			
		||||
 | 
			
		||||
#define BYTES_TO_UINT64(n, p)     {n = ((uint64_t)(p)[0] + ((uint64_t)(p)[1] << 8) + \
 | 
			
		||||
                                        ((uint64_t)(p)[2] << 16) + ((uint64_t)(p)[3] << 24) + \
 | 
			
		||||
                                        ((uint64_t)(p)[4] << 32) + ((uint64_t)(p)[5] << 40) + \
 | 
			
		||||
                                        ((uint64_t)(p)[6] << 48) + ((uint64_t)(p)[7] << 56));}
 | 
			
		||||
 | 
			
		||||
/*!
 | 
			
		||||
 * Macros for converting little endian integers to array of bytes
 | 
			
		||||
 */
 | 
			
		||||
#define UINT16_TO_BYTES(n)        ((uint8_t) (n)), ((uint8_t)((n) >> 8))
 | 
			
		||||
 | 
			
		||||
/*!
 | 
			
		||||
 * Macros for converting little endian integers to single bytes
 | 
			
		||||
 */
 | 
			
		||||
#define UINT16_TO_BYTE0(n)        ((uint8_t) (n))
 | 
			
		||||
#define UINT16_TO_BYTE1(n)        ((uint8_t) ((n) >> 8))
 | 
			
		||||
 | 
			
		||||
#define UINT32_TO_BYTE0(n)        ((uint8_t) (n))
 | 
			
		||||
#define UINT32_TO_BYTE1(n)        ((uint8_t) ((n) >> 8))
 | 
			
		||||
#define UINT32_TO_BYTE2(n)        ((uint8_t) ((n) >> 16))
 | 
			
		||||
#define UINT32_TO_BYTE3(n)        ((uint8_t) ((n) >> 24))
 | 
			
		||||
 | 
			
		||||
/*!
 | 
			
		||||
 * Macros for converting a little endian byte stream to integers, with increment.
 | 
			
		||||
 */
 | 
			
		||||
#define BSTREAM_TO_INT8(n, p)     {n = (int8_t)(*(p)++);}
 | 
			
		||||
#define BSTREAM_TO_UINT8(n, p)    {n = (uint8_t)(*(p)++);}
 | 
			
		||||
#define BSTREAM_TO_UINT16(n, p)   {BYTES_TO_UINT16(n, p); p += 2;}
 | 
			
		||||
#define BSTREAM_TO_UINT24(n, p)   {BYTES_TO_UINT24(n, p); p += 3;}
 | 
			
		||||
#define BSTREAM_TO_UINT32(n, p)   {BYTES_TO_UINT32(n, p); p += 4;}
 | 
			
		||||
#define BSTREAM_TO_UINT40(n, p)   {BYTES_TO_UINT40(n, p); p += 5;}
 | 
			
		||||
#define BSTREAM_TO_UINT64(n, p)   {n = BstreamToUint64(p); p += 8;}
 | 
			
		||||
#define BSTREAM_TO_BDA(bda, p)    {BdaCpy(bda, p); p += BDA_ADDR_LEN;}
 | 
			
		||||
#define BSTREAM_TO_BDA64(bda, p)  {bda = BstreamToBda64(p); p += BDA_ADDR_LEN;}
 | 
			
		||||
 | 
			
		||||
/*!
 | 
			
		||||
 * Macros for converting integers to a little endian byte stream, with increment.
 | 
			
		||||
 */
 | 
			
		||||
#define UINT8_TO_BSTREAM(p, n)    {*(p)++ = (uint8_t)(n);}
 | 
			
		||||
#define UINT16_TO_BSTREAM(p, n)   {*(p)++ = (uint8_t)(n); *(p)++ = (uint8_t)((n) >> 8);}
 | 
			
		||||
#define UINT24_TO_BSTREAM(p, n)   {*(p)++ = (uint8_t)(n); *(p)++ = (uint8_t)((n) >> 8); \
 | 
			
		||||
                                  *(p)++ = (uint8_t)((n) >> 16);}
 | 
			
		||||
#define UINT32_TO_BSTREAM(p, n)   {*(p)++ = (uint8_t)(n); *(p)++ = (uint8_t)((n) >> 8); \
 | 
			
		||||
                                  *(p)++ = (uint8_t)((n) >> 16); *(p)++ = (uint8_t)((n) >> 24);}
 | 
			
		||||
#define UINT40_TO_BSTREAM(p, n)   {*(p)++ = (uint8_t)(n); *(p)++ = (uint8_t)((n) >> 8); \
 | 
			
		||||
                                  *(p)++ = (uint8_t)((n) >> 16); *(p)++ = (uint8_t)((n) >> 24); \
 | 
			
		||||
                                  *(p)++ = (uint8_t)((n) >> 32);}
 | 
			
		||||
#define UINT64_TO_BSTREAM(p, n)   {Uint64ToBstream(p, n); p += sizeof(uint64_t);}
 | 
			
		||||
#define BDA_TO_BSTREAM(p, bda)    {BdaCpy(p, bda); p += BDA_ADDR_LEN;}
 | 
			
		||||
#define BDA64_TO_BSTREAM(p, bda)  {Bda64ToBstream(p, bda); p += BDA_ADDR_LEN;}
 | 
			
		||||
 | 
			
		||||
/*!
 | 
			
		||||
 * Macros for converting integers to a little endian byte stream, without increment.
 | 
			
		||||
 */
 | 
			
		||||
#define UINT16_TO_BUF(p, n)       {(p)[0] = (uint8_t)(n); (p)[1] = (uint8_t)((n) >> 8);}
 | 
			
		||||
#define UINT32_TO_BUF(p, n)       {(p)[0] = (uint8_t)(n); (p)[1] = (uint8_t)((n) >> 8); \
 | 
			
		||||
                                  (p)[2] = (uint8_t)((n) >> 16); (p)[3] = (uint8_t)((n) >> 24);}
 | 
			
		||||
 | 
			
		||||
/*!
 | 
			
		||||
 * Macros for comparing a little endian byte buffer to integers.
 | 
			
		||||
 */
 | 
			
		||||
#define BYTES_UINT16_CMP(p, n)    ((p)[1] == UINT16_TO_BYTE1(n) && (p)[0] == UINT16_TO_BYTE0(n))
 | 
			
		||||
 | 
			
		||||
/*!
 | 
			
		||||
 * Macros for IEEE FLOAT type:  exponent = byte 3, mantissa = bytes 2-0
 | 
			
		||||
 */
 | 
			
		||||
#define FLT_TO_UINT32(m, e)       ((m) | ((int32_t)(e) << 24))
 | 
			
		||||
#define UINT32_TO_FLT(m, e, n)    {m = UINT32_TO_FLT_M(n); e = UINT32_TO_FLT_E(n);}
 | 
			
		||||
#define UINT32_TO_FLT_M(n)        ((((n) & 0x00FFFFFF) >= 0x00800000) ? \
 | 
			
		||||
                                   ((int32_t)(((n) | 0xFF000000))) : ((int32_t)((n) & 0x00FFFFFF)))
 | 
			
		||||
#define UINT32_TO_FLT_E(n)        ((int8_t)(n >> 24))
 | 
			
		||||
/*!
 | 
			
		||||
 * Macros for IEEE SFLOAT type:  exponent = bits 15-12, mantissa = bits 11-0
 | 
			
		||||
 */
 | 
			
		||||
#define SFLT_TO_UINT16(m, e)      ((m) | ((int16_t)(e) << 12))
 | 
			
		||||
#define UINT16_TO_SFLT(m, e, n)   {m = UINT16_TO_SFLT_M(n); e = UINT16_TO_SFLT_E(n);}
 | 
			
		||||
#define UINT16_TO_SFLT_M(n)       ((((n) & 0x0FFF) >= 0x0800) ? \
 | 
			
		||||
                                   ((int16_t)(((n) | 0xF000))) : ((int16_t)((n) & 0x0FFF)))
 | 
			
		||||
#define UINT16_TO_SFLT_E(n)       (((n >> 12) >= 0x0008) ? \
 | 
			
		||||
                                   ((int8_t)(((n >> 12) | 0xF0))) : ((int8_t)(n >> 12)))
 | 
			
		||||
 | 
			
		||||
/**************************************************************************************************
 | 
			
		||||
  Function Declarations
 | 
			
		||||
**************************************************************************************************/
 | 
			
		||||
 | 
			
		||||
uint64_t BstreamToBda64(const uint8_t *p);
 | 
			
		||||
uint64_t BstreamToUint64(const uint8_t *p);
 | 
			
		||||
void Bda64ToBstream(uint8_t *p, uint64_t bda);
 | 
			
		||||
void Uint64ToBstream(uint8_t *p, uint64_t n);
 | 
			
		||||
 | 
			
		||||
#ifdef __cplusplus
 | 
			
		||||
};
 | 
			
		||||
#endif
 | 
			
		||||
 | 
			
		||||
#endif /* BSTREAM_H */
 | 
			
		||||
| 
						 | 
				
			
			@ -1,122 +0,0 @@
 | 
			
		|||
/*************************************************************************************************/
 | 
			
		||||
/*!
 | 
			
		||||
 *  \file   utils.h
 | 
			
		||||
 *
 | 
			
		||||
 *  \brief  Utility functions.
 | 
			
		||||
 *
 | 
			
		||||
 *  Copyright (c) 2015 ARM, Ltd., all rights reserved.
 | 
			
		||||
 *  ARM confidential and proprietary.
 | 
			
		||||
 *
 | 
			
		||||
 *  IMPORTANT.  Your use of this file is governed by a Software License Agreement
 | 
			
		||||
 *  ("Agreement") that must be accepted in order to download or otherwise receive a
 | 
			
		||||
 *  copy of this file.  You may not use or copy this file for any purpose other than
 | 
			
		||||
 *  as described in the Agreement.  If you do not agree to all of the terms of the
 | 
			
		||||
 *  Agreement do not use this file and delete all copies in your possession or control;
 | 
			
		||||
 *  if you do not have a copy of the Agreement, you must contact ARM, Ltd. prior
 | 
			
		||||
 *  to any use, copying or further distribution of this software.
 | 
			
		||||
 */
 | 
			
		||||
/*************************************************************************************************/
 | 
			
		||||
 | 
			
		||||
#ifndef __UTILS_H
 | 
			
		||||
#define __UTILS_H
 | 
			
		||||
 | 
			
		||||
/***************************************************************************************************
 | 
			
		||||
** INCLUDES
 | 
			
		||||
***************************************************************************************************/
 | 
			
		||||
 | 
			
		||||
#include <stdarg.h>
 | 
			
		||||
#include <stddef.h>
 | 
			
		||||
 | 
			
		||||
#include "wsf_types.h"
 | 
			
		||||
 | 
			
		||||
#if defined(__GNUC__) || defined(__CC_ARM)
 | 
			
		||||
#define PRINTF_ATTRIBUTE(a, b) __attribute__((format(printf, a, b)))
 | 
			
		||||
#else
 | 
			
		||||
#define PRINTF_ATTRIBUTE(a, b)
 | 
			
		||||
#endif
 | 
			
		||||
 | 
			
		||||
#ifdef __cplusplus
 | 
			
		||||
extern "C" {
 | 
			
		||||
#endif
 | 
			
		||||
 | 
			
		||||
/***************************************************************************************************
 | 
			
		||||
** DEFINES
 | 
			
		||||
***************************************************************************************************/
 | 
			
		||||
 | 
			
		||||
#define UTIL_MAC_ADDR_LEN 6
 | 
			
		||||
 | 
			
		||||
/*------------------------------------------------------------------------------------------------*/
 | 
			
		||||
 | 
			
		||||
#define UTIL_IS_DIGIT(c)        ((c >= '0') && (c <= '9'))
 | 
			
		||||
#define UTIL_IS_XDIGIT(c)      (((c >= '0') && (c <= '9')) || ((c >= 'a') && (c <= 'f')) || \
 | 
			
		||||
                                ((c >= 'A') && (c <= 'F')))
 | 
			
		||||
 | 
			
		||||
/*------------------------------------------------------------------------------------------------*/
 | 
			
		||||
 | 
			
		||||
#define UTIL_DIGIT_TO_INT(c)   (((c >= '0') && (c <= '9')) ? (uint8_t)(c - '0') : 0u)
 | 
			
		||||
#define UTIL_XDIGIT_TO_INT(c)  (((c >= '0') && (c <= '9')) ? (uint8_t)(c - '0') : \
 | 
			
		||||
                                ((c >= 'a') && (c <= 'f')) ? (uint8_t)(c - 'a' + 10u) : \
 | 
			
		||||
                                ((c >= 'A') && (c <= 'F')) ? (uint8_t)(c - 'A' + 10u) : 0u)
 | 
			
		||||
 | 
			
		||||
/***************************************************************************************************
 | 
			
		||||
** FUNCTIONS
 | 
			
		||||
***************************************************************************************************/
 | 
			
		||||
 | 
			
		||||
/*--------------------------------------------------------------------------------------------------
 | 
			
		||||
** Util_VSNPrintf()
 | 
			
		||||
**
 | 
			
		||||
** DESCRIPTION: Print formatted output to string.
 | 
			
		||||
**
 | 
			
		||||
** PARAMETERS:  s       Pointer to string that will receive outoput
 | 
			
		||||
**              size    Maximum number of characters to store in s
 | 
			
		||||
**              format  Pointer to format string
 | 
			
		||||
**              ap      Variable arguments
 | 
			
		||||
**
 | 
			
		||||
** RETURNS:     Number of characters stored in s
 | 
			
		||||
**------------------------------------------------------------------------------------------------*/
 | 
			
		||||
int Util_VSNPrintf(char *s, size_t size, const char *format, va_list ap) PRINTF_ATTRIBUTE(3, 0);
 | 
			
		||||
 | 
			
		||||
/*--------------------------------------------------------------------------------------------------
 | 
			
		||||
** Util_SNPrintf()
 | 
			
		||||
**
 | 
			
		||||
** DESCRIPTION: Print formatted output to string.
 | 
			
		||||
**
 | 
			
		||||
** PARAMETERS:  s       Pointer to string that will receive outoput
 | 
			
		||||
**              size    Maximum number of characters to store in s
 | 
			
		||||
**              format  Pointer to format string
 | 
			
		||||
**              ap      Variable arguments
 | 
			
		||||
**
 | 
			
		||||
** RETURNS:     Number of characters stored in s
 | 
			
		||||
**------------------------------------------------------------------------------------------------*/
 | 
			
		||||
int Util_SNPrintf (char *s, size_t size, const char *format, ...) PRINTF_ATTRIBUTE(3, 4);
 | 
			
		||||
 | 
			
		||||
/*--------------------------------------------------------------------------------------------------
 | 
			
		||||
** Util_ParseMacAddr()
 | 
			
		||||
**
 | 
			
		||||
** DESCRIPTION: Parse MAC address from string.
 | 
			
		||||
**
 | 
			
		||||
** PARAMETERS:  s     Pointer to string to parse
 | 
			
		||||
**              addr  Pointer to buffer that will receive MAC address
 | 
			
		||||
**
 | 
			
		||||
** RETURNS:     Number of characters consumed from string
 | 
			
		||||
**------------------------------------------------------------------------------------------------*/
 | 
			
		||||
int32_t Util_ParseMacAddr(const char *s, uint8_t (*addr)[UTIL_MAC_ADDR_LEN]);
 | 
			
		||||
 | 
			
		||||
/*--------------------------------------------------------------------------------------------------
 | 
			
		||||
** Util_ParseUInt()
 | 
			
		||||
**
 | 
			
		||||
** DESCRIPTION: Parse unsigned integer from string.
 | 
			
		||||
**
 | 
			
		||||
** PARAMETERS:  s     Pointer to string to parse
 | 
			
		||||
**              u     Pointer to variable that will receive integer
 | 
			
		||||
**              base  Base of integer (between 2 and 36, inclusive) or 0, for automatic detection
 | 
			
		||||
**
 | 
			
		||||
** RETURNS:     Number of characters consumed from string
 | 
			
		||||
**------------------------------------------------------------------------------------------------*/
 | 
			
		||||
int32_t Util_ParseUInt(const char *s, uint32_t *u, uint32_t base);
 | 
			
		||||
 | 
			
		||||
#ifdef __cplusplus
 | 
			
		||||
}
 | 
			
		||||
#endif
 | 
			
		||||
 | 
			
		||||
#endif /* __UTILS_H */
 | 
			
		||||
| 
						 | 
				
			
			@ -1,79 +0,0 @@
 | 
			
		|||
/*************************************************************************************************/
 | 
			
		||||
/*!
 | 
			
		||||
 *  \file   wsf_assert.h
 | 
			
		||||
 *
 | 
			
		||||
 *  \brief  Assert macro.
 | 
			
		||||
 *
 | 
			
		||||
 *          $Date: 2015-10-05 09:54:16 -0700 (Mon, 05 Oct 2015) $
 | 
			
		||||
 *          $Revision: 4112 $
 | 
			
		||||
 *
 | 
			
		||||
 *  Copyright (c) 2009 Wicentric, Inc., all rights reserved.
 | 
			
		||||
 *  Wicentric confidential and proprietary.
 | 
			
		||||
 *
 | 
			
		||||
 *  IMPORTANT.  Your use of this file is governed by a Software License Agreement
 | 
			
		||||
 *  ("Agreement") that must be accepted in order to download or otherwise receive a
 | 
			
		||||
 *  copy of this file.  You may not use or copy this file for any purpose other than
 | 
			
		||||
 *  as described in the Agreement.  If you do not agree to all of the terms of the
 | 
			
		||||
 *  Agreement do not use this file and delete all copies in your possession or control;
 | 
			
		||||
 *  if you do not have a copy of the Agreement, you must contact Wicentric, Inc. prior
 | 
			
		||||
 *  to any use, copying or further distribution of this software.
 | 
			
		||||
 */
 | 
			
		||||
/*************************************************************************************************/
 | 
			
		||||
#ifndef WSF_ASSERT_H
 | 
			
		||||
#define WSF_ASSERT_H
 | 
			
		||||
 | 
			
		||||
#ifdef __cplusplus
 | 
			
		||||
extern "C" {
 | 
			
		||||
#endif
 | 
			
		||||
 | 
			
		||||
/**************************************************************************************************
 | 
			
		||||
  Function Prototypes
 | 
			
		||||
**************************************************************************************************/
 | 
			
		||||
 | 
			
		||||
#if WSF_TOKEN_ENABLED == TRUE
 | 
			
		||||
void WsfAssert(uint16_t modId, uint16_t line);
 | 
			
		||||
#else
 | 
			
		||||
void WsfAssert(const char *pFile, uint16_t line);
 | 
			
		||||
#endif
 | 
			
		||||
 | 
			
		||||
/**************************************************************************************************
 | 
			
		||||
  Macros
 | 
			
		||||
**************************************************************************************************/
 | 
			
		||||
 | 
			
		||||
/*************************************************************************************************/
 | 
			
		||||
/*!
 | 
			
		||||
 *  \def    WSF_ASSERT
 | 
			
		||||
 *
 | 
			
		||||
 *  \brief  Run-time assert macro.  The assert executes when the expression is FALSE.
 | 
			
		||||
 *
 | 
			
		||||
 *  \param  expr    Boolean expression to be tested.
 | 
			
		||||
 */
 | 
			
		||||
/*************************************************************************************************/
 | 
			
		||||
#if WSF_ASSERT_ENABLED == TRUE
 | 
			
		||||
#if WSF_TOKEN_ENABLED == TRUE
 | 
			
		||||
#define WSF_ASSERT(expr)      if (!(expr)) {WsfAssert(MODULE_ID, (uint16_t) __LINE__);}
 | 
			
		||||
#else
 | 
			
		||||
#define WSF_ASSERT(expr)      if (!(expr)) {WsfAssert(__FILE__, (uint16_t) __LINE__);}
 | 
			
		||||
#endif
 | 
			
		||||
#else
 | 
			
		||||
#define WSF_ASSERT(expr)
 | 
			
		||||
#endif
 | 
			
		||||
 | 
			
		||||
/*************************************************************************************************/
 | 
			
		||||
/*!
 | 
			
		||||
 *  \def    WSF_CT_ASSERT
 | 
			
		||||
 *
 | 
			
		||||
 *  \brief  Compile-time assert macro.  This macro causes a compiler error when the
 | 
			
		||||
 *          expression is FALSE.  Note that this macro is generally used at file scope to
 | 
			
		||||
 *          test constant expressions.  Errors may result of it is used in executing code.
 | 
			
		||||
 *
 | 
			
		||||
 *  \param  expr    Boolean expression to be tested.
 | 
			
		||||
 */
 | 
			
		||||
/*************************************************************************************************/
 | 
			
		||||
#define WSF_CT_ASSERT(expr)     extern char wsf_ct_assert[(expr) ? 1 : -1]
 | 
			
		||||
 | 
			
		||||
#ifdef __cplusplus
 | 
			
		||||
};
 | 
			
		||||
#endif
 | 
			
		||||
 | 
			
		||||
#endif /* WSF_ASSERT_H */
 | 
			
		||||
| 
						 | 
				
			
			@ -1,105 +0,0 @@
 | 
			
		|||
/*************************************************************************************************/
 | 
			
		||||
/*!
 | 
			
		||||
 *  \file   wsf_os_int.h
 | 
			
		||||
 *        
 | 
			
		||||
 *  \brief  Software foundation OS platform-specific interface file.
 | 
			
		||||
 *
 | 
			
		||||
 *          $Date: 2012-10-01 13:53:07 -0700 (Mon, 01 Oct 2012) $
 | 
			
		||||
 *          $Revision: 357 $
 | 
			
		||||
 *  
 | 
			
		||||
 *  Copyright (c) 2009 Wicentric, Inc., all rights reserved.
 | 
			
		||||
 *  Wicentric confidential and proprietary.
 | 
			
		||||
 *
 | 
			
		||||
 *  IMPORTANT.  Your use of this file is governed by a Software License Agreement
 | 
			
		||||
 *  ("Agreement") that must be accepted in order to download or otherwise receive a
 | 
			
		||||
 *  copy of this file.  You may not use or copy this file for any purpose other than
 | 
			
		||||
 *  as described in the Agreement.  If you do not agree to all of the terms of the
 | 
			
		||||
 *  Agreement do not use this file and delete all copies in your possession or control;
 | 
			
		||||
 *  if you do not have a copy of the Agreement, you must contact Wicentric, Inc. prior
 | 
			
		||||
 *  to any use, copying or further distribution of this software.
 | 
			
		||||
 */
 | 
			
		||||
/*************************************************************************************************/
 | 
			
		||||
#ifndef WSF_OS_INT_H
 | 
			
		||||
#define WSF_OS_INT_H
 | 
			
		||||
 | 
			
		||||
#ifdef __cplusplus
 | 
			
		||||
extern "C" {
 | 
			
		||||
#endif
 | 
			
		||||
 | 
			
		||||
/**************************************************************************************************
 | 
			
		||||
  Macros
 | 
			
		||||
**************************************************************************************************/
 | 
			
		||||
 | 
			
		||||
/* Task events */
 | 
			
		||||
#define WSF_MSG_QUEUE_EVENT   0x01        /* Message queued for event handler */
 | 
			
		||||
#define WSF_TIMER_EVENT       0x02        /* Timer expired for event handler */
 | 
			
		||||
#define WSF_HANDLER_EVENT     0x04        /* Event set for event handler */
 | 
			
		||||
 | 
			
		||||
/* Derive task from handler ID */
 | 
			
		||||
#define WSF_TASK_FROM_ID(handlerID)       (((handlerID) >> 4) & 0x0F)
 | 
			
		||||
 | 
			
		||||
/* Derive handler from handler ID */
 | 
			
		||||
#define WSF_HANDLER_FROM_ID(handlerID)    ((handlerID) & 0x0F)
 | 
			
		||||
 | 
			
		||||
/**************************************************************************************************
 | 
			
		||||
  Data Types
 | 
			
		||||
**************************************************************************************************/
 | 
			
		||||
 | 
			
		||||
/* Event handler ID data type */
 | 
			
		||||
typedef uint8_t  wsfHandlerId_t;
 | 
			
		||||
 | 
			
		||||
/* Event handler event mask data type */
 | 
			
		||||
typedef uint8_t  wsfEventMask_t;
 | 
			
		||||
 | 
			
		||||
/* Task ID data type */
 | 
			
		||||
typedef wsfHandlerId_t  wsfTaskId_t;
 | 
			
		||||
 | 
			
		||||
/* Task event mask data type */
 | 
			
		||||
typedef uint8_t wsfTaskEvent_t;
 | 
			
		||||
 | 
			
		||||
/**************************************************************************************************
 | 
			
		||||
  Function Declarations
 | 
			
		||||
**************************************************************************************************/
 | 
			
		||||
 | 
			
		||||
/*************************************************************************************************/
 | 
			
		||||
/*!
 | 
			
		||||
 *  \fn     wsfOsReadyToSleep
 | 
			
		||||
 *        
 | 
			
		||||
 *  \brief  Check if WSF is ready to sleep.
 | 
			
		||||
 *
 | 
			
		||||
 *  \param  None.
 | 
			
		||||
 *
 | 
			
		||||
 *  \return Return TRUE if there are no pending WSF task events set, FALSE otherwise.
 | 
			
		||||
 */
 | 
			
		||||
/*************************************************************************************************/
 | 
			
		||||
bool_t wsfOsReadyToSleep(void);
 | 
			
		||||
 | 
			
		||||
/*************************************************************************************************/
 | 
			
		||||
/*!
 | 
			
		||||
 *  \fn     wsfOsDispatcher
 | 
			
		||||
 *        
 | 
			
		||||
 *  \brief  Event dispatched.  Designed to be called repeatedly from infinite loop.
 | 
			
		||||
 *
 | 
			
		||||
 *  \param  None.
 | 
			
		||||
 *
 | 
			
		||||
 *  \return None.
 | 
			
		||||
 */
 | 
			
		||||
/*************************************************************************************************/
 | 
			
		||||
void wsfOsDispatcher(void);
 | 
			
		||||
 | 
			
		||||
/*************************************************************************************************/
 | 
			
		||||
/*!
 | 
			
		||||
 *  \fn     WsfOsShutdown
 | 
			
		||||
 *        
 | 
			
		||||
 *  \brief  Shutdown OS.
 | 
			
		||||
 *
 | 
			
		||||
 *  \return None.
 | 
			
		||||
 */
 | 
			
		||||
/*************************************************************************************************/
 | 
			
		||||
void WsfOsShutdown(void);
 | 
			
		||||
 | 
			
		||||
#ifdef __cplusplus
 | 
			
		||||
};
 | 
			
		||||
#endif
 | 
			
		||||
 | 
			
		||||
#endif /* WSF_OS_INT_H */
 | 
			
		||||
| 
						 | 
				
			
			@ -1,223 +0,0 @@
 | 
			
		|||
/*************************************************************************************************/
 | 
			
		||||
/*!
 | 
			
		||||
 *  \file   wsf_trace.h
 | 
			
		||||
 *
 | 
			
		||||
 *  \brief  Trace message interface.
 | 
			
		||||
 *
 | 
			
		||||
 *          $Date: 2016-02-27 09:05:32 -0800 (Sat, 27 Feb 2016) $
 | 
			
		||||
 *          $Revision: 6074 $
 | 
			
		||||
 *
 | 
			
		||||
 *  Copyright (c) 2009 Wicentric, Inc., all rights reserved.
 | 
			
		||||
 *  Wicentric confidential and proprietary.
 | 
			
		||||
 *
 | 
			
		||||
 *  IMPORTANT.  Your use of this file is governed by a Software License Agreement
 | 
			
		||||
 *  ("Agreement") that must be accepted in order to download or otherwise receive a
 | 
			
		||||
 *  copy of this file.  You may not use or copy this file for any purpose other than
 | 
			
		||||
 *  as described in the Agreement.  If you do not agree to all of the terms of the
 | 
			
		||||
 *  Agreement do not use this file and delete all copies in your possession or control;
 | 
			
		||||
 *  if you do not have a copy of the Agreement, you must contact Wicentric, Inc. prior
 | 
			
		||||
 *  to any use, copying or further distribution of this software.
 | 
			
		||||
 */
 | 
			
		||||
/*************************************************************************************************/
 | 
			
		||||
#ifndef WSF_TRACE_H
 | 
			
		||||
#define WSF_TRACE_H
 | 
			
		||||
 | 
			
		||||
/**************************************************************************************************
 | 
			
		||||
  Data Types
 | 
			
		||||
**************************************************************************************************/
 | 
			
		||||
 | 
			
		||||
/*! \brief      Token event handler. */
 | 
			
		||||
typedef void (*WsfTokenHandler_t)(void);
 | 
			
		||||
 | 
			
		||||
/**************************************************************************************************
 | 
			
		||||
  Function Prototypes
 | 
			
		||||
**************************************************************************************************/
 | 
			
		||||
 | 
			
		||||
void WsfTrace(const char *pStr, ...);
 | 
			
		||||
void WsfToken(uint32_t tok, uint32_t var);
 | 
			
		||||
void WsfTraceEnable(bool_t enable);
 | 
			
		||||
 | 
			
		||||
/* Token management. */
 | 
			
		||||
bool_t WsfTokenService(void);
 | 
			
		||||
uint8_t WsfTokenIOWrite(uint8_t *pBuf, uint8_t len);
 | 
			
		||||
 | 
			
		||||
/**************************************************************************************************
 | 
			
		||||
  Macros
 | 
			
		||||
**************************************************************************************************/
 | 
			
		||||
 | 
			
		||||
#ifdef TOKEN_GENERATION
 | 
			
		||||
 | 
			
		||||
#define WSF_TOKEN(subsys, stat, msg)                    \
 | 
			
		||||
  __WSF_TOKEN_DEFINE__(                                 \
 | 
			
		||||
    /* token:   */     MODULE_ID, __LINE__,             \
 | 
			
		||||
    /* origin:  */     __FILE__, subsys,                \
 | 
			
		||||
    /* message: */     stat, msg)
 | 
			
		||||
 | 
			
		||||
#define WSF_TRACE0(subsys, stat, msg)                   WSF_TOKEN(subsys, stat, msg)
 | 
			
		||||
#define WSF_TRACE1(subsys, stat, msg, var1)             WSF_TOKEN(subsys, stat, msg)
 | 
			
		||||
#define WSF_TRACE2(subsys, stat, msg, var1, var2)       WSF_TOKEN(subsys, stat, msg)
 | 
			
		||||
#define WSF_TRACE3(subsys, stat, msg, var1, var2, var3) WSF_TOKEN(subsys, stat, msg)
 | 
			
		||||
 | 
			
		||||
#elif WSF_TRACE_ENABLED == TRUE
 | 
			
		||||
 | 
			
		||||
#define WSF_TRACE0(subsys, stat, msg)                   WsfTrace(msg)
 | 
			
		||||
#define WSF_TRACE1(subsys, stat, msg, var1)             WsfTrace(msg, var1)
 | 
			
		||||
#define WSF_TRACE2(subsys, stat, msg, var1, var2)       WsfTrace(msg, var1, var2)
 | 
			
		||||
#define WSF_TRACE3(subsys, stat, msg, var1, var2, var3) WsfTrace(msg, var1, var2, var3)
 | 
			
		||||
 | 
			
		||||
#elif WSF_TOKEN_ENABLED == TRUE
 | 
			
		||||
 | 
			
		||||
#define WSF_TRACE0(subsys, stat, msg)                   \
 | 
			
		||||
  WsfToken(((__LINE__ & 0xFFF) << 16) | MODULE_ID, 0)
 | 
			
		||||
#define WSF_TRACE1(subsys, stat, msg, var1)             \
 | 
			
		||||
  WsfToken(((__LINE__ & 0xFFF) << 16) | MODULE_ID, (uint32_t)(var1))
 | 
			
		||||
#define WSF_TRACE2(subsys, stat, msg, var1, var2)       \
 | 
			
		||||
  WsfToken(((__LINE__ & 0xFFF) << 16) | MODULE_ID, (uint32_t)(((var2) << 16) | ((var1) & 0xFFFF)))
 | 
			
		||||
#define WSF_TRACE3(subsys, stat, msg, var1, var2, var3) \
 | 
			
		||||
  WsfToken(((__LINE__ & 0xFFF) << 16) | MODULE_ID, (uint32_t)((((var3) & 0xFFFF) << 16) | (((var2) & 0xFF) << 8) | ((var1) & 0xFF)))
 | 
			
		||||
 | 
			
		||||
#else
 | 
			
		||||
 | 
			
		||||
#define WSF_TRACE0(subsys, stat, msg)
 | 
			
		||||
#define WSF_TRACE1(subsys, stat, msg, var1)
 | 
			
		||||
#define WSF_TRACE2(subsys, stat, msg, var1, var2)
 | 
			
		||||
#define WSF_TRACE3(subsys, stat, msg, var1, var2, var3)
 | 
			
		||||
 | 
			
		||||
#endif
 | 
			
		||||
 | 
			
		||||
#define WSF_TRACE_INFO0(msg)
 | 
			
		||||
#define WSF_TRACE_INFO1(msg, var1)
 | 
			
		||||
#define WSF_TRACE_INFO2(msg, var1, var2)
 | 
			
		||||
#define WSF_TRACE_INFO3(msg, var1, var2, var3)
 | 
			
		||||
#define WSF_TRACE_WARN0(msg)                        WSF_TRACE0("WSF", "WARN", msg)
 | 
			
		||||
#define WSF_TRACE_WARN1(msg, var1)                  WSF_TRACE1("WSF", "WARN", msg, var1)
 | 
			
		||||
#define WSF_TRACE_WARN2(msg, var1, var2)            WSF_TRACE2("WSF", "WARN", msg, var1, var2)
 | 
			
		||||
#define WSF_TRACE_WARN3(msg, var1, var2, var3)      WSF_TRACE3("WSF", "WARN", msg, var1, var2, var3)
 | 
			
		||||
#define WSF_TRACE_ERR0(msg)                         WSF_TRACE0("WSF", "ERR",  msg)
 | 
			
		||||
#define WSF_TRACE_ERR1(msg, var1)                   WSF_TRACE1("WSF", "ERR",  msg, var1)
 | 
			
		||||
#define WSF_TRACE_ERR2(msg, var1, var2)             WSF_TRACE2("WSF", "ERR",  msg, var1, var2)
 | 
			
		||||
#define WSF_TRACE_ERR3(msg, var1, var2, var3)       WSF_TRACE3("WSF", "ERR",  msg, var1, var2, var3)
 | 
			
		||||
#define WSF_TRACE_ALLOC0(msg)
 | 
			
		||||
#define WSF_TRACE_ALLOC1(msg, var1)
 | 
			
		||||
#define WSF_TRACE_ALLOC2(msg, var1, var2)
 | 
			
		||||
#define WSF_TRACE_ALLOC3(msg, var1, var2, var3)
 | 
			
		||||
#define WSF_TRACE_FREE0(msg)
 | 
			
		||||
#define WSF_TRACE_FREE1(msg, var1)
 | 
			
		||||
#define WSF_TRACE_FREE2(msg, var1, var2)
 | 
			
		||||
#define WSF_TRACE_FREE3(msg, var1, var2, var3)
 | 
			
		||||
#define WSF_TRACE_MSG0(msg)
 | 
			
		||||
#define WSF_TRACE_MSG1(msg, var1)
 | 
			
		||||
#define WSF_TRACE_MSG2(msg, var1, var2)
 | 
			
		||||
#define WSF_TRACE_MSG3(msg, var1, var2, var3)
 | 
			
		||||
 | 
			
		||||
#define HCI_TRACE_INFO0(msg)                        WSF_TRACE0("HCI", "INFO", msg)
 | 
			
		||||
#define HCI_TRACE_INFO1(msg, var1)                  WSF_TRACE1("HCI", "INFO", msg, var1)
 | 
			
		||||
#define HCI_TRACE_INFO2(msg, var1, var2)            WSF_TRACE2("HCI", "INFO", msg, var1, var2)
 | 
			
		||||
#define HCI_TRACE_INFO3(msg, var1, var2, var3)      WSF_TRACE3("HCI", "INFO", msg, var1, var2, var3)
 | 
			
		||||
#define HCI_TRACE_WARN0(msg)                        WSF_TRACE0("HCI", "WARN", msg)
 | 
			
		||||
#define HCI_TRACE_WARN1(msg, var1)                  WSF_TRACE1("HCI", "WARN", msg, var1)
 | 
			
		||||
#define HCI_TRACE_WARN2(msg, var1, var2)            WSF_TRACE2("HCI", "WARN", msg, var1, var2)
 | 
			
		||||
#define HCI_TRACE_WARN3(msg, var1, var2, var3)      WSF_TRACE3("HCI", "WARN", msg, var1, var2, var3)
 | 
			
		||||
#define HCI_TRACE_ERR0(msg)                         WSF_TRACE0("HCI", "ERR",  msg)
 | 
			
		||||
#define HCI_TRACE_ERR1(msg, var1)                   WSF_TRACE1("HCI", "ERR",  msg, var1)
 | 
			
		||||
#define HCI_TRACE_ERR2(msg, var1, var2)             WSF_TRACE2("HCI", "ERR",  msg, var1, var2)
 | 
			
		||||
#define HCI_TRACE_ERR3(msg, var1, var2, var3)       WSF_TRACE3("HCI", "ERR",  msg, var1, var2, var3)
 | 
			
		||||
 | 
			
		||||
#define HCI_PDUMP_CMD(len, pBuf)
 | 
			
		||||
#define HCI_PDUMP_EVT(len, pBuf)
 | 
			
		||||
#define HCI_PDUMP_TX_ACL(len, pBuf)
 | 
			
		||||
#define HCI_PDUMP_RX_ACL(len, pBuf)
 | 
			
		||||
 | 
			
		||||
#define DM_TRACE_INFO0(msg)                         WSF_TRACE0("DM", "INFO", msg)
 | 
			
		||||
#define DM_TRACE_INFO1(msg, var1)                   WSF_TRACE1("DM", "INFO", msg, var1)
 | 
			
		||||
#define DM_TRACE_INFO2(msg, var1, var2)             WSF_TRACE2("DM", "INFO", msg, var1, var2)
 | 
			
		||||
#define DM_TRACE_INFO3(msg, var1, var2, var3)       WSF_TRACE3("DM", "INFO", msg, var1, var2, var3)
 | 
			
		||||
#define DM_TRACE_WARN0(msg)                         WSF_TRACE0("DM", "WARN", msg)
 | 
			
		||||
#define DM_TRACE_WARN1(msg, var1)                   WSF_TRACE1("DM", "WARN", msg, var1)
 | 
			
		||||
#define DM_TRACE_WARN2(msg, var1, var2)             WSF_TRACE2("DM", "WARN", msg, var1, var2)
 | 
			
		||||
#define DM_TRACE_WARN3(msg, var1, var2, var3)       WSF_TRACE3("DM", "WARN", msg, var1, var2, var3)
 | 
			
		||||
#define DM_TRACE_ERR0(msg)                          WSF_TRACE0("DM", "ERR",  msg)
 | 
			
		||||
#define DM_TRACE_ERR1(msg, var1)                    WSF_TRACE1("DM", "ERR",  msg, var1)
 | 
			
		||||
#define DM_TRACE_ERR2(msg, var1, var2)              WSF_TRACE2("DM", "ERR",  msg, var1, var2)
 | 
			
		||||
#define DM_TRACE_ERR3(msg, var1, var2, var3)        WSF_TRACE3("DM", "ERR",  msg, var1, var2, var3)
 | 
			
		||||
#define DM_TRACE_ALLOC0(msg)                        WSF_TRACE0("DM", "ALLOC", msg)
 | 
			
		||||
#define DM_TRACE_ALLOC1(msg, var1)                  WSF_TRACE1("DM", "ALLOC", msg, var1)
 | 
			
		||||
#define DM_TRACE_ALLOC2(msg, var1, var2)            WSF_TRACE2("DM", "ALLOC", msg, var1, var2)
 | 
			
		||||
#define DM_TRACE_ALLOC3(msg, var1, var2, var3)      WSF_TRACE3("DM", "ALLOC", msg, var1, var2, var3)
 | 
			
		||||
#define DM_TRACE_FREE0(msg)                         WSF_TRACE0("DM", "FREE", msg)
 | 
			
		||||
#define DM_TRACE_FREE1(msg, var1)                   WSF_TRACE1("DM", "FREE", msg, var1)
 | 
			
		||||
#define DM_TRACE_FREE2(msg, var1, var2)             WSF_TRACE2("DM", "FREE", msg, var1, var2)
 | 
			
		||||
#define DM_TRACE_FREE3(msg, var1, var2, var3)       WSF_TRACE3("DM", "FREE", msg, var1, var2, var3)
 | 
			
		||||
 | 
			
		||||
#define L2C_TRACE_INFO0(msg)                        WSF_TRACE0("L2C", "INFO", msg)
 | 
			
		||||
#define L2C_TRACE_INFO1(msg, var1)                  WSF_TRACE1("L2C", "INFO", msg, var1)
 | 
			
		||||
#define L2C_TRACE_INFO2(msg, var1, var2)            WSF_TRACE2("L2C", "INFO", msg, var1, var2)
 | 
			
		||||
#define L2C_TRACE_INFO3(msg, var1, var2, var3)      WSF_TRACE3("L2C", "INFO", msg, var1, var2, var3)
 | 
			
		||||
#define L2C_TRACE_WARN0(msg)                        WSF_TRACE0("L2C", "WARN", msg)
 | 
			
		||||
#define L2C_TRACE_WARN1(msg, var1)                  WSF_TRACE1("L2C", "WARN", msg, var1)
 | 
			
		||||
#define L2C_TRACE_WARN2(msg, var1, var2)            WSF_TRACE2("L2C", "WARN", msg, var1, var2)
 | 
			
		||||
#define L2C_TRACE_WARN3(msg, var1, var2, var3)      WSF_TRACE3("L2C", "WARN", msg, var1, var2, var3)
 | 
			
		||||
#define L2C_TRACE_ERR0(msg)                         WSF_TRACE0("L2C", "ERR",  msg)
 | 
			
		||||
#define L2C_TRACE_ERR1(msg, var1)                   WSF_TRACE1("L2C", "ERR",  msg, var1)
 | 
			
		||||
#define L2C_TRACE_ERR2(msg, var1, var2)             WSF_TRACE2("L2C", "ERR",  msg, var1, var2)
 | 
			
		||||
#define L2C_TRACE_ERR3(msg, var1, var2, var3)       WSF_TRACE3("L2C", "ERR",  msg, var1, var2, var3)
 | 
			
		||||
 | 
			
		||||
#define ATT_TRACE_INFO0(msg)                        WSF_TRACE0("ATT", "INFO", msg)
 | 
			
		||||
#define ATT_TRACE_INFO1(msg, var1)                  WSF_TRACE1("ATT", "INFO", msg, var1)
 | 
			
		||||
#define ATT_TRACE_INFO2(msg, var1, var2)            WSF_TRACE2("ATT", "INFO", msg, var1, var2)
 | 
			
		||||
#define ATT_TRACE_INFO3(msg, var1, var2, var3)      WSF_TRACE3("ATT", "INFO", msg, var1, var2, var3)
 | 
			
		||||
#define ATT_TRACE_WARN0(msg)                        WSF_TRACE0("ATT", "WARN", msg)
 | 
			
		||||
#define ATT_TRACE_WARN1(msg, var1)                  WSF_TRACE1("ATT", "WARN", msg, var1)
 | 
			
		||||
#define ATT_TRACE_WARN2(msg, var1, var2)            WSF_TRACE2("ATT", "WARN", msg, var1, var2)
 | 
			
		||||
#define ATT_TRACE_WARN3(msg, var1, var2, var3)      WSF_TRACE3("ATT", "WARN", msg, var1, var2, var3)
 | 
			
		||||
#define ATT_TRACE_ERR0(msg)                         WSF_TRACE0("ATT", "ERR",  msg)
 | 
			
		||||
#define ATT_TRACE_ERR1(msg, var1)                   WSF_TRACE1("ATT", "ERR",  msg, var1)
 | 
			
		||||
#define ATT_TRACE_ERR2(msg, var1, var2)             WSF_TRACE2("ATT", "ERR",  msg, var1, var2)
 | 
			
		||||
#define ATT_TRACE_ERR3(msg, var1, var2, var3)       WSF_TRACE3("ATT", "ERR",  msg, var1, var2, var3)
 | 
			
		||||
 | 
			
		||||
#define SMP_TRACE_INFO0(msg)                        WSF_TRACE0("SMP", "INFO", msg)
 | 
			
		||||
#define SMP_TRACE_INFO1(msg, var1)                  WSF_TRACE1("SMP", "INFO", msg, var1)
 | 
			
		||||
#define SMP_TRACE_INFO2(msg, var1, var2)            WSF_TRACE2("SMP", "INFO", msg, var1, var2)
 | 
			
		||||
#define SMP_TRACE_INFO3(msg, var1, var2, var3)      WSF_TRACE3("SMP", "INFO", msg, var1, var2, var3)
 | 
			
		||||
#define SMP_TRACE_WARN0(msg)                        WSF_TRACE0("SMP", "WARN", msg)
 | 
			
		||||
#define SMP_TRACE_WARN1(msg, var1)                  WSF_TRACE1("SMP", "WARN", msg, var1)
 | 
			
		||||
#define SMP_TRACE_WARN2(msg, var1, var2)            WSF_TRACE2("SMP", "WARN", msg, var1, var2)
 | 
			
		||||
#define SMP_TRACE_WARN3(msg, var1, var2, var3)      WSF_TRACE3("SMP", "WARN", msg, var1, var2, var3)
 | 
			
		||||
#define SMP_TRACE_ERR0(msg)                         WSF_TRACE0("SMP", "ERR",  msg)
 | 
			
		||||
#define SMP_TRACE_ERR1(msg, var1)                   WSF_TRACE1("SMP", "ERR",  msg, var1)
 | 
			
		||||
#define SMP_TRACE_ERR2(msg, var1, var2)             WSF_TRACE2("SMP", "ERR",  msg, var1, var2)
 | 
			
		||||
#define SMP_TRACE_ERR3(msg, var1, var2, var3)       WSF_TRACE3("SMP", "ERR",  msg, var1, var2, var3)
 | 
			
		||||
 | 
			
		||||
#define APP_TRACE_INFO0(msg)                        WSF_TRACE0("APP", "INFO", msg)
 | 
			
		||||
#define APP_TRACE_INFO1(msg, var1)                  WSF_TRACE1("APP", "INFO", msg, var1)
 | 
			
		||||
#define APP_TRACE_INFO2(msg, var1, var2)            WSF_TRACE2("APP", "INFO", msg, var1, var2)
 | 
			
		||||
#define APP_TRACE_INFO3(msg, var1, var2, var3)      WSF_TRACE3("APP", "INFO", msg, var1, var2, var3)
 | 
			
		||||
#define APP_TRACE_WARN0(msg)                        WSF_TRACE0("APP", "WARN", msg)
 | 
			
		||||
#define APP_TRACE_WARN1(msg, var1)                  WSF_TRACE1("APP", "WARN", msg, var1)
 | 
			
		||||
#define APP_TRACE_WARN2(msg, var1, var2)            WSF_TRACE2("APP", "WARN", msg, var1, var2)
 | 
			
		||||
#define APP_TRACE_WARN3(msg, var1, var2, var3)      WSF_TRACE3("APP", "WARN", msg, var1, var2, var3)
 | 
			
		||||
#define APP_TRACE_ERR0(msg)                         WSF_TRACE0("APP", "ERR",  msg)
 | 
			
		||||
#define APP_TRACE_ERR1(msg, var1)                   WSF_TRACE1("APP", "ERR",   msg, var1)
 | 
			
		||||
#define APP_TRACE_ERR2(msg, var1, var2)             WSF_TRACE2("APP", "ERR",   msg, var1, var2)
 | 
			
		||||
#define APP_TRACE_ERR3(msg, var1, var2, var3)       WSF_TRACE3("APP", "ERR",   msg, var1, var2, var3)
 | 
			
		||||
 | 
			
		||||
#define LL_TRACE_INFO0(msg)                         WSF_TRACE0("LL", "INFO", msg)
 | 
			
		||||
#define LL_TRACE_INFO1(msg, var1)                   WSF_TRACE1("LL", "INFO", msg, var1)
 | 
			
		||||
#define LL_TRACE_INFO2(msg, var1, var2)             WSF_TRACE2("LL", "INFO", msg, var1, var2)
 | 
			
		||||
#define LL_TRACE_INFO3(msg, var1, var2, var3)       WSF_TRACE3("LL", "INFO", msg, var1, var2, var3)
 | 
			
		||||
#define LL_TRACE_WARN0(msg)                         WSF_TRACE0("LL", "WARN", msg)
 | 
			
		||||
#define LL_TRACE_WARN1(msg, var1)                   WSF_TRACE1("LL", "WARN", msg, var1)
 | 
			
		||||
#define LL_TRACE_WARN2(msg, var1, var2)             WSF_TRACE2("LL", "WARN", msg, var1, var2)
 | 
			
		||||
#define LL_TRACE_WARN3(msg, var1, var2, var3)       WSF_TRACE3("LL", "WARN", msg, var1, var2, var3)
 | 
			
		||||
#define LL_TRACE_ERR0(msg)                          WSF_TRACE0("LL", "ERR",  msg)
 | 
			
		||||
#define LL_TRACE_ERR1(msg, var1)                    WSF_TRACE1("LL", "ERR",  msg, var1)
 | 
			
		||||
#define LL_TRACE_ERR2(msg, var1, var2)              WSF_TRACE2("LL", "ERR",  msg, var1, var2)
 | 
			
		||||
#define LL_TRACE_ERR3(msg, var1, var2, var3)        WSF_TRACE3("LL", "ERR",  msg, var1, var2, var3)
 | 
			
		||||
 | 
			
		||||
#if (WSF_TRACE_ENABLED == TRUE) || (WSF_TOKEN_ENABLED == TRUE)
 | 
			
		||||
#define LL_TRACE_ENABLE(ena)                        WsfTraceEnable(ena)
 | 
			
		||||
#else
 | 
			
		||||
#define LL_TRACE_ENABLE(ena)
 | 
			
		||||
#endif
 | 
			
		||||
 | 
			
		||||
#endif /* WSF_TRACE_H */
 | 
			
		||||
| 
						 | 
				
			
			@ -1,28 +0,0 @@
 | 
			
		|||
/*************************************************************************************************/
 | 
			
		||||
/*!
 | 
			
		||||
 *  \file   wsf_types.h
 | 
			
		||||
 *
 | 
			
		||||
 *  \brief  Platform-independent data types.
 | 
			
		||||
 *
 | 
			
		||||
 *          $Date: 2015-05-14 14:58:23 -0700 (Thu, 14 May 2015) $
 | 
			
		||||
 *          $Revision: 2837 $
 | 
			
		||||
 *
 | 
			
		||||
 *  Copyright (c) 2009 Wicentric, Inc., all rights reserved.
 | 
			
		||||
 *  Wicentric confidential and proprietary.
 | 
			
		||||
 *
 | 
			
		||||
 *  IMPORTANT.  Your use of this file is governed by a Software License Agreement
 | 
			
		||||
 *  ("Agreement") that must be accepted in order to download or otherwise receive a
 | 
			
		||||
 *  copy of this file.  You may not use or copy this file for any purpose other than
 | 
			
		||||
 *  as described in the Agreement.  If you do not agree to all of the terms of the
 | 
			
		||||
 *  Agreement do not use this file and delete all copies in your possession or control;
 | 
			
		||||
 *  if you do not have a copy of the Agreement, you must contact Wicentric, Inc. prior
 | 
			
		||||
 *  to any use, copying or further distribution of this software.
 | 
			
		||||
 */
 | 
			
		||||
/*************************************************************************************************/
 | 
			
		||||
#ifndef WSF_TYPES_H
 | 
			
		||||
#define WSF_TYPES_H
 | 
			
		||||
 | 
			
		||||
#include <stdint.h>
 | 
			
		||||
#include <rtx_core_cm.h>
 | 
			
		||||
 | 
			
		||||
#endif /* WSF_TYPES_H */
 | 
			
		||||
| 
						 | 
				
			
			@ -1,171 +0,0 @@
 | 
			
		|||
/*************************************************************************************************/
 | 
			
		||||
/*!
 | 
			
		||||
 *  \file   wsf_buf.h
 | 
			
		||||
 *
 | 
			
		||||
 *  \brief  Buffer pool service.
 | 
			
		||||
 *
 | 
			
		||||
 *          $Date: 2015-12-20 15:10:41 -0800 (Sun, 20 Dec 2015) $
 | 
			
		||||
 *          $Revision: 4927 $
 | 
			
		||||
 *
 | 
			
		||||
 *  Copyright (c) 2009 Wicentric, Inc., all rights reserved.
 | 
			
		||||
 *  Wicentric confidential and proprietary.
 | 
			
		||||
 *
 | 
			
		||||
 *  IMPORTANT.  Your use of this file is governed by a Software License Agreement
 | 
			
		||||
 *  ("Agreement") that must be accepted in order to download or otherwise receive a
 | 
			
		||||
 *  copy of this file.  You may not use or copy this file for any purpose other than
 | 
			
		||||
 *  as described in the Agreement.  If you do not agree to all of the terms of the
 | 
			
		||||
 *  Agreement do not use this file and delete all copies in your possession or control;
 | 
			
		||||
 *  if you do not have a copy of the Agreement, you must contact Wicentric, Inc. prior
 | 
			
		||||
 *  to any use, copying or further distribution of this software.
 | 
			
		||||
 */
 | 
			
		||||
/*************************************************************************************************/
 | 
			
		||||
#ifndef WSF_BUF_H
 | 
			
		||||
#define WSF_BUF_H
 | 
			
		||||
 | 
			
		||||
#ifdef __cplusplus
 | 
			
		||||
extern "C" {
 | 
			
		||||
#endif
 | 
			
		||||
 | 
			
		||||
/**************************************************************************************************
 | 
			
		||||
  Macros
 | 
			
		||||
**************************************************************************************************/
 | 
			
		||||
 | 
			
		||||
/*! Length of the buffer statistics array */
 | 
			
		||||
#define WSF_BUF_STATS_MAX_LEN       128
 | 
			
		||||
 | 
			
		||||
/**************************************************************************************************
 | 
			
		||||
  Data Types
 | 
			
		||||
**************************************************************************************************/
 | 
			
		||||
 | 
			
		||||
/*! Buffer pool descriptor structure */
 | 
			
		||||
typedef struct
 | 
			
		||||
{
 | 
			
		||||
  uint16_t   len;                  /*! length of buffers in pool */
 | 
			
		||||
  uint8_t    num;                  /*! number of buffers in pool */
 | 
			
		||||
} wsfBufPoolDesc_t;
 | 
			
		||||
 | 
			
		||||
/*! Pool statistics */
 | 
			
		||||
typedef struct
 | 
			
		||||
{
 | 
			
		||||
  uint16_t   bufSize;              /*!< Pool buffer size. */
 | 
			
		||||
  uint8_t    numBuf;               /*!< Total number of buffers. */
 | 
			
		||||
  uint8_t    numAlloc;             /*!< Number of outstanding allocations. */
 | 
			
		||||
  uint8_t    maxAlloc;             /*!< High allocation watermark. */
 | 
			
		||||
} WsfBufPoolStat_t;
 | 
			
		||||
 | 
			
		||||
 | 
			
		||||
/**************************************************************************************************
 | 
			
		||||
  Function Declarations
 | 
			
		||||
**************************************************************************************************/
 | 
			
		||||
 | 
			
		||||
/*************************************************************************************************/
 | 
			
		||||
/*!
 | 
			
		||||
 *  \fn     WsfBufInit
 | 
			
		||||
 *
 | 
			
		||||
 *  \brief  Initialize the buffer pool service.  This function should only be called once
 | 
			
		||||
 *          upon system initialization.
 | 
			
		||||
 *
 | 
			
		||||
 *  \param  bufMemLen Length in bytes of memory pointed to by pBufMem.
 | 
			
		||||
 *  \param  pBufMem   Memory in which to store the pools used by the buffer pool service.
 | 
			
		||||
 *  \param  numPools  Number of buffer pools.
 | 
			
		||||
 *  \param  pDesc     Array of buffer pool descriptors, one for each pool.
 | 
			
		||||
 *
 | 
			
		||||
 *  \return Amount of pBufMem used or 0 for failures.
 | 
			
		||||
 */
 | 
			
		||||
/*************************************************************************************************/
 | 
			
		||||
uint16_t WsfBufInit(uint16_t bufMemLen, uint8_t *pBufMem, uint8_t numPools, wsfBufPoolDesc_t *pDesc);
 | 
			
		||||
 | 
			
		||||
/*************************************************************************************************/
 | 
			
		||||
/*!
 | 
			
		||||
 *  \fn     WsfBufAlloc
 | 
			
		||||
 *
 | 
			
		||||
 *  \brief  Allocate a buffer.
 | 
			
		||||
 *
 | 
			
		||||
 *  \param  len     Length of buffer to allocate.
 | 
			
		||||
 *
 | 
			
		||||
 *  \return Pointer to allocated buffer or NULL if allocation fails.
 | 
			
		||||
 */
 | 
			
		||||
/*************************************************************************************************/
 | 
			
		||||
void *WsfBufAlloc(uint16_t len);
 | 
			
		||||
 | 
			
		||||
/*************************************************************************************************/
 | 
			
		||||
/*!
 | 
			
		||||
 *  \fn     WsfBufFree
 | 
			
		||||
 *
 | 
			
		||||
 *  \brief  Free a buffer.
 | 
			
		||||
 *
 | 
			
		||||
 *  \param  pBuf    Buffer to free.
 | 
			
		||||
 *
 | 
			
		||||
 *  \return None.
 | 
			
		||||
 */
 | 
			
		||||
/*************************************************************************************************/
 | 
			
		||||
void WsfBufFree(void *pBuf);
 | 
			
		||||
 | 
			
		||||
/*************************************************************************************************/
 | 
			
		||||
/*!
 | 
			
		||||
 *  \fn     WsfBufGetMaxAlloc
 | 
			
		||||
 *
 | 
			
		||||
 *  \brief  Diagnostic function to get maximum allocated buffers from a pool.
 | 
			
		||||
 *
 | 
			
		||||
 *  \param  pool    Buffer pool number.
 | 
			
		||||
 *
 | 
			
		||||
 *  \return Number of allocated buffers.
 | 
			
		||||
 */
 | 
			
		||||
/*************************************************************************************************/
 | 
			
		||||
uint8_t WsfBufGetMaxAlloc(uint8_t pool);
 | 
			
		||||
 | 
			
		||||
/*************************************************************************************************/
 | 
			
		||||
/*!
 | 
			
		||||
 *  \fn     WsfBufGetNumAlloc
 | 
			
		||||
 *
 | 
			
		||||
 *  \brief  Diagnostic function to get the number of currently allocated buffers in a pool.
 | 
			
		||||
 *
 | 
			
		||||
 *  \param  pool    Buffer pool number.
 | 
			
		||||
 *
 | 
			
		||||
 *  \return Number of allocated buffers.
 | 
			
		||||
 */
 | 
			
		||||
/*************************************************************************************************/
 | 
			
		||||
uint8_t WsfBufGetNumAlloc(uint8_t pool);
 | 
			
		||||
 | 
			
		||||
/*************************************************************************************************/
 | 
			
		||||
/*!
 | 
			
		||||
 *  \fn     WsfBufGetAllocStats
 | 
			
		||||
 *
 | 
			
		||||
 *  \brief  Diagnostic function to get the buffer allocation statistics.
 | 
			
		||||
 *
 | 
			
		||||
 *  \return Buffer allocation statistics array.
 | 
			
		||||
 */
 | 
			
		||||
/*************************************************************************************************/
 | 
			
		||||
uint8_t *WsfBufGetAllocStats(void);
 | 
			
		||||
 | 
			
		||||
/*************************************************************************************************/
 | 
			
		||||
/*!
 | 
			
		||||
 *  \fn     WsfBufGetNumPool
 | 
			
		||||
 *
 | 
			
		||||
 *  \brief  Get number of pools.
 | 
			
		||||
 *
 | 
			
		||||
 *  \return Number of pools.
 | 
			
		||||
 */
 | 
			
		||||
/*************************************************************************************************/
 | 
			
		||||
uint8_t WsfBufGetNumPool(void);
 | 
			
		||||
 | 
			
		||||
/*************************************************************************************************/
 | 
			
		||||
/*!
 | 
			
		||||
 *  \fn     WsfBufGetPoolStats
 | 
			
		||||
 *
 | 
			
		||||
 *  \brief  Get statistics for each pool.
 | 
			
		||||
 *
 | 
			
		||||
 *  \param  pStat   Buffer to store the statistics.
 | 
			
		||||
 *  \param  numPool Number of pool elements.
 | 
			
		||||
 *
 | 
			
		||||
 *  \return Pool statistics.
 | 
			
		||||
 */
 | 
			
		||||
/*************************************************************************************************/
 | 
			
		||||
void WsfBufGetPoolStats(WsfBufPoolStat_t *pStat, uint8_t numPool);
 | 
			
		||||
 | 
			
		||||
 | 
			
		||||
#ifdef __cplusplus
 | 
			
		||||
};
 | 
			
		||||
#endif
 | 
			
		||||
 | 
			
		||||
#endif /* WSF_BUF_H */
 | 
			
		||||
| 
						 | 
				
			
			@ -1,188 +0,0 @@
 | 
			
		|||
/*************************************************************************************************/
 | 
			
		||||
/*!
 | 
			
		||||
 *  \file   wsf_math.h
 | 
			
		||||
 *
 | 
			
		||||
 *  \brief  Common math utilities.
 | 
			
		||||
 *
 | 
			
		||||
 *          $Date: 2016-04-05 14:14:53 -0700 (Tue, 05 Apr 2016) $
 | 
			
		||||
 *          $Revision: 6646 $
 | 
			
		||||
 *
 | 
			
		||||
 *  Copyright (c) 2013 Wicentric, Inc., all rights reserved.
 | 
			
		||||
 *  Wicentric confidential and proprietary.
 | 
			
		||||
 *
 | 
			
		||||
 *  IMPORTANT.  Your use of this file is governed by a Software License Agreement
 | 
			
		||||
 *  ("Agreement") that must be accepted in order to download or otherwise receive a
 | 
			
		||||
 *  copy of this file.  You may not use or copy this file for any purpose other than
 | 
			
		||||
 *  as described in the Agreement.  If you do not agree to all of the terms of the
 | 
			
		||||
 *  Agreement do not use this file and delete all copies in your possession or control;
 | 
			
		||||
 *  if you do not have a copy of the Agreement, you must contact Wicentric, Inc. prior
 | 
			
		||||
 *  to any use, copying or further distribution of this software.
 | 
			
		||||
 */
 | 
			
		||||
/*************************************************************************************************/
 | 
			
		||||
#ifndef WSF_MATH_H
 | 
			
		||||
#define WSF_MATH_H
 | 
			
		||||
 | 
			
		||||
#include "wsf_types.h"
 | 
			
		||||
 | 
			
		||||
#ifdef __cplusplus
 | 
			
		||||
extern "C" {
 | 
			
		||||
#endif
 | 
			
		||||
 | 
			
		||||
/**************************************************************************************************
 | 
			
		||||
  Macros
 | 
			
		||||
**************************************************************************************************/
 | 
			
		||||
 | 
			
		||||
/*! \brief      Returns the minimum of two values. */
 | 
			
		||||
#define WSF_MIN(a,b)        ((a) < (b) ? (a) : (b))
 | 
			
		||||
 | 
			
		||||
/*! \brief      Returns the maximum of two values. */
 | 
			
		||||
#define WSF_MAX(a,b)        ((a) > (b) ? (a) : (b))
 | 
			
		||||
 | 
			
		||||
/*! \brief      ECC key length. */
 | 
			
		||||
#define WSF_MATH_ECC_KEY_LEN    32
 | 
			
		||||
 | 
			
		||||
/**************************************************************************************************
 | 
			
		||||
  Data Types
 | 
			
		||||
**************************************************************************************************/
 | 
			
		||||
 | 
			
		||||
/*! \brief      ECC service callback. */
 | 
			
		||||
typedef void (*WsfMathEccServiceCback_t)(uint8_t op);
 | 
			
		||||
 | 
			
		||||
/*! \brief      ECC operations. */
 | 
			
		||||
enum
 | 
			
		||||
{
 | 
			
		||||
  WSF_MATH_ECC_OP_GENERATE_P256_KEY_PAIR,   /*!< Generate P-256 key pair. */
 | 
			
		||||
  WSF_MATH_ECC_OP_GENERATE_DH_KEY           /*!< Generate Diffie-Hellman key. */
 | 
			
		||||
};
 | 
			
		||||
 | 
			
		||||
 | 
			
		||||
/**************************************************************************************************
 | 
			
		||||
  Function Declarations
 | 
			
		||||
**************************************************************************************************/
 | 
			
		||||
 | 
			
		||||
/*************************************************************************************************/
 | 
			
		||||
/*!
 | 
			
		||||
 *  \fn     WsfMathInit
 | 
			
		||||
 *
 | 
			
		||||
 *  \brief  Initialize math routines.
 | 
			
		||||
 *
 | 
			
		||||
 *  \return None.
 | 
			
		||||
 */
 | 
			
		||||
/*************************************************************************************************/
 | 
			
		||||
void WsfMathInit(void);
 | 
			
		||||
 | 
			
		||||
/*************************************************************************************************/
 | 
			
		||||
/*!
 | 
			
		||||
 *  \fn     WsfRandNum
 | 
			
		||||
 *
 | 
			
		||||
 *  \brief  Generate random number.
 | 
			
		||||
 *
 | 
			
		||||
 *  \return 32-bit random number.
 | 
			
		||||
 */
 | 
			
		||||
/*************************************************************************************************/
 | 
			
		||||
uint32_t WsfRandNum(void);
 | 
			
		||||
 | 
			
		||||
/*************************************************************************************************/
 | 
			
		||||
/*!
 | 
			
		||||
 *  \fn     WsfAesEcb
 | 
			
		||||
 *
 | 
			
		||||
 *  \brief  Calculate AES ECB.
 | 
			
		||||
 *
 | 
			
		||||
 *  \param  pKey        Encryption key.
 | 
			
		||||
 *  \param  pOut        Output data.
 | 
			
		||||
 *  \param  pIn         Input data.
 | 
			
		||||
 *
 | 
			
		||||
 *  \return None.
 | 
			
		||||
 */
 | 
			
		||||
/*************************************************************************************************/
 | 
			
		||||
void WsfAesEcb(const uint8_t *pKey, uint8_t *pOut, const uint8_t *pIn);
 | 
			
		||||
 | 
			
		||||
/*************************************************************************************************/
 | 
			
		||||
/*!
 | 
			
		||||
 *  \brief  Set service callback for ECC generation.
 | 
			
		||||
 *
 | 
			
		||||
 *  \param  cback   Callback to invoke when driver needs servicing.
 | 
			
		||||
 *
 | 
			
		||||
 *  \return None.
 | 
			
		||||
 */
 | 
			
		||||
/*************************************************************************************************/
 | 
			
		||||
void WsfMathEccSetServiceCback(WsfMathEccServiceCback_t cback);
 | 
			
		||||
 | 
			
		||||
/*************************************************************************************************/
 | 
			
		||||
/*!
 | 
			
		||||
 *  \brief  Start generating P-256 key pair.
 | 
			
		||||
 *
 | 
			
		||||
 *  \return None.
 | 
			
		||||
 */
 | 
			
		||||
/*************************************************************************************************/
 | 
			
		||||
void WsfMathEccGenerateP256KeyPairStart(void);
 | 
			
		||||
 | 
			
		||||
/*************************************************************************************************/
 | 
			
		||||
/*!
 | 
			
		||||
 *  \brief  Start generating P-256 public key with a specified private key.
 | 
			
		||||
 *
 | 
			
		||||
 *  \param  pPrivKey      Private key.
 | 
			
		||||
 *
 | 
			
		||||
 *  \return None.
 | 
			
		||||
 */
 | 
			
		||||
/*************************************************************************************************/
 | 
			
		||||
void WsfMathEccGenerateP256PublicKeyStart(const uint8_t *pPrivKey);
 | 
			
		||||
 | 
			
		||||
/*************************************************************************************************/
 | 
			
		||||
/*!
 | 
			
		||||
 *  \brief  Continue generating P-256 key pair.
 | 
			
		||||
 *
 | 
			
		||||
 *  \return TRUE if key generation complete.
 | 
			
		||||
 */
 | 
			
		||||
/*************************************************************************************************/
 | 
			
		||||
bool_t WsfMathEccGenerateP256KeyPairContinue(void);
 | 
			
		||||
 | 
			
		||||
/*************************************************************************************************/
 | 
			
		||||
/*!
 | 
			
		||||
 *  \brief  Get results from generating P-256 key pair.
 | 
			
		||||
 *
 | 
			
		||||
 *  \param  pPubKey     Storage for public key.
 | 
			
		||||
 *  \param  pPrivKey    Storage for private key.
 | 
			
		||||
 *
 | 
			
		||||
 *  \return None.
 | 
			
		||||
 */
 | 
			
		||||
/*************************************************************************************************/
 | 
			
		||||
void WsfMathEccGenerateP256KeyPairComplete(uint8_t *pPubKey, uint8_t *pPrivKey);
 | 
			
		||||
 | 
			
		||||
/*************************************************************************************************/
 | 
			
		||||
/*!
 | 
			
		||||
 *  \brief  Start generating Diffie-Hellman key.
 | 
			
		||||
 *
 | 
			
		||||
 *  \param  pPublicKey    Public key.
 | 
			
		||||
 *  \param  pPrivateKey   Private key.
 | 
			
		||||
 *
 | 
			
		||||
 *  \return None.
 | 
			
		||||
 */
 | 
			
		||||
/*************************************************************************************************/
 | 
			
		||||
void WsfMathEccGenerateDhKeyStart(const uint8_t *pPubKey, const uint8_t *pPrivKey);
 | 
			
		||||
 | 
			
		||||
/*************************************************************************************************/
 | 
			
		||||
/*!
 | 
			
		||||
 *  \brief  Continue generating Diffie-Hellman key.
 | 
			
		||||
 *
 | 
			
		||||
 *  \return TRUE if Diffie-Hellman key generation complete.
 | 
			
		||||
 */
 | 
			
		||||
/*************************************************************************************************/
 | 
			
		||||
bool_t WsfMathEccGenerateDhKeyContinue(void);
 | 
			
		||||
 | 
			
		||||
/*************************************************************************************************/
 | 
			
		||||
/*!
 | 
			
		||||
 *  \brief  Get results from generating Diffie-Hellman key.
 | 
			
		||||
 *
 | 
			
		||||
 *  \param  pDhKey      Storage for Diffie-Hellman key.
 | 
			
		||||
 *
 | 
			
		||||
 *  \return None.
 | 
			
		||||
 */
 | 
			
		||||
/*************************************************************************************************/
 | 
			
		||||
void WsfMathEccGenerateDhKeyComplete(uint8_t *pDhKey);
 | 
			
		||||
 | 
			
		||||
#ifdef __cplusplus
 | 
			
		||||
};
 | 
			
		||||
#endif
 | 
			
		||||
 | 
			
		||||
#endif /* WSF_MATH_H */
 | 
			
		||||
| 
						 | 
				
			
			@ -1,123 +0,0 @@
 | 
			
		|||
/*************************************************************************************************/
 | 
			
		||||
/*!
 | 
			
		||||
 *  \file   wsf_msg.h
 | 
			
		||||
 *
 | 
			
		||||
 *  \brief  Message passing service.
 | 
			
		||||
 *
 | 
			
		||||
 *          $Date: 2013-07-02 15:08:09 -0700 (Tue, 02 Jul 2013) $
 | 
			
		||||
 *          $Revision: 779 $
 | 
			
		||||
 *
 | 
			
		||||
 *  Copyright (c) 2009 Wicentric, Inc., all rights reserved.
 | 
			
		||||
 *  Wicentric confidential and proprietary.
 | 
			
		||||
 *
 | 
			
		||||
 *  IMPORTANT.  Your use of this file is governed by a Software License Agreement
 | 
			
		||||
 *  ("Agreement") that must be accepted in order to download or otherwise receive a
 | 
			
		||||
 *  copy of this file.  You may not use or copy this file for any purpose other than
 | 
			
		||||
 *  as described in the Agreement.  If you do not agree to all of the terms of the
 | 
			
		||||
 *  Agreement do not use this file and delete all copies in your possession or control;
 | 
			
		||||
 *  if you do not have a copy of the Agreement, you must contact Wicentric, Inc. prior
 | 
			
		||||
 *  to any use, copying or further distribution of this software.
 | 
			
		||||
 */
 | 
			
		||||
/*************************************************************************************************/
 | 
			
		||||
#ifndef WSF_MSG_H
 | 
			
		||||
#define WSF_MSG_H
 | 
			
		||||
 | 
			
		||||
#include "wsf_queue.h"
 | 
			
		||||
#include "wsf_os.h"
 | 
			
		||||
 | 
			
		||||
#ifdef __cplusplus
 | 
			
		||||
extern "C" {
 | 
			
		||||
#endif
 | 
			
		||||
 | 
			
		||||
/**************************************************************************************************
 | 
			
		||||
  Function Declarations
 | 
			
		||||
**************************************************************************************************/
 | 
			
		||||
 | 
			
		||||
/*************************************************************************************************/
 | 
			
		||||
/*!
 | 
			
		||||
 *  \fn     WsfMsgAlloc
 | 
			
		||||
 *
 | 
			
		||||
 *  \brief  Allocate a message buffer to be sent with WsfMsgSend().
 | 
			
		||||
 *
 | 
			
		||||
 *  \param  len   Message length in bytes.
 | 
			
		||||
 *
 | 
			
		||||
 *  \return Pointer to message buffer or NULL if allocation failed.
 | 
			
		||||
 */
 | 
			
		||||
/*************************************************************************************************/
 | 
			
		||||
void *WsfMsgAlloc(uint16_t len);
 | 
			
		||||
 | 
			
		||||
/*************************************************************************************************/
 | 
			
		||||
/*!
 | 
			
		||||
 *  \fn     WsfMsgFree
 | 
			
		||||
 *
 | 
			
		||||
 *  \brief  Free a message buffer allocated with WsfMsgAlloc().
 | 
			
		||||
 *
 | 
			
		||||
 *  \param  pMsg  Pointer to message buffer.
 | 
			
		||||
 *
 | 
			
		||||
 *  \return None.
 | 
			
		||||
 */
 | 
			
		||||
/*************************************************************************************************/
 | 
			
		||||
void WsfMsgFree(void *pMsg);
 | 
			
		||||
 | 
			
		||||
/*************************************************************************************************/
 | 
			
		||||
/*!
 | 
			
		||||
 *  \fn     WsfMsgSend
 | 
			
		||||
 *
 | 
			
		||||
 *  \brief  Send a message to an event handler.
 | 
			
		||||
 *
 | 
			
		||||
 *  \param  handlerId   Event handler ID.
 | 
			
		||||
 *  \param  pMsg        Pointer to message buffer.
 | 
			
		||||
 *
 | 
			
		||||
 *  \return None.
 | 
			
		||||
 */
 | 
			
		||||
/*************************************************************************************************/
 | 
			
		||||
void WsfMsgSend(wsfHandlerId_t handlerId, void *pMsg);
 | 
			
		||||
 | 
			
		||||
/*************************************************************************************************/
 | 
			
		||||
/*!
 | 
			
		||||
 *  \fn     WsfMsgEnq
 | 
			
		||||
 *
 | 
			
		||||
 *  \brief  Enqueue a message.
 | 
			
		||||
 *
 | 
			
		||||
 *  \param  pQueue    Pointer to queue.
 | 
			
		||||
 *  \param  handerId  Set message handler ID to this value.
 | 
			
		||||
 *  \param  pElem     Pointer to message buffer.
 | 
			
		||||
 *
 | 
			
		||||
 *  \return None.
 | 
			
		||||
 */
 | 
			
		||||
/*************************************************************************************************/
 | 
			
		||||
void WsfMsgEnq(wsfQueue_t *pQueue, wsfHandlerId_t handlerId, void *pMsg);
 | 
			
		||||
 | 
			
		||||
/*************************************************************************************************/
 | 
			
		||||
/*!
 | 
			
		||||
 *  \fn     WsfMsgDeq
 | 
			
		||||
 *
 | 
			
		||||
 *  \brief  Dequeue a message.
 | 
			
		||||
 *
 | 
			
		||||
 *  \param  pQueue      Pointer to queue.
 | 
			
		||||
 *  \param  pHandlerId  Handler ID of returned message; this is a return parameter.
 | 
			
		||||
 *
 | 
			
		||||
 *  \return Pointer to message that has been dequeued or NULL if queue is empty.
 | 
			
		||||
 */
 | 
			
		||||
/*************************************************************************************************/
 | 
			
		||||
void *WsfMsgDeq(wsfQueue_t *pQueue, wsfHandlerId_t *pHandlerId);
 | 
			
		||||
 | 
			
		||||
/*************************************************************************************************/
 | 
			
		||||
/*!
 | 
			
		||||
 *  \fn     WsfMsgPeek
 | 
			
		||||
 *
 | 
			
		||||
 *  \brief  Get the next message without removing it from the queue.
 | 
			
		||||
 *
 | 
			
		||||
 *  \param  pQueue      Pointer to queue.
 | 
			
		||||
 *  \param  pHandlerId  Handler ID of returned message; this is a return parameter.
 | 
			
		||||
 *
 | 
			
		||||
 *  \return Pointer to the next message on the queue or NULL if queue is empty.
 | 
			
		||||
 */
 | 
			
		||||
/*************************************************************************************************/
 | 
			
		||||
void *WsfMsgPeek(wsfQueue_t *pQueue, wsfHandlerId_t *pHandlerId);
 | 
			
		||||
 | 
			
		||||
#ifdef __cplusplus
 | 
			
		||||
};
 | 
			
		||||
#endif
 | 
			
		||||
 | 
			
		||||
#endif /* WSF_MSG_H */
 | 
			
		||||
| 
						 | 
				
			
			@ -1,147 +0,0 @@
 | 
			
		|||
/*************************************************************************************************/
 | 
			
		||||
/*!
 | 
			
		||||
 *  \file   wsf_os.h
 | 
			
		||||
 *        
 | 
			
		||||
 *  \brief  Software foundation OS API.
 | 
			
		||||
 *
 | 
			
		||||
 *          $Date: 2014-08-08 06:30:50 -0700 (Fri, 08 Aug 2014) $
 | 
			
		||||
 *          $Revision: 1725 $
 | 
			
		||||
 *  
 | 
			
		||||
 *  Copyright (c) 2009 Wicentric, Inc., all rights reserved.
 | 
			
		||||
 *  Wicentric confidential and proprietary.
 | 
			
		||||
 *
 | 
			
		||||
 *  IMPORTANT.  Your use of this file is governed by a Software License Agreement
 | 
			
		||||
 *  ("Agreement") that must be accepted in order to download or otherwise receive a
 | 
			
		||||
 *  copy of this file.  You may not use or copy this file for any purpose other than
 | 
			
		||||
 *  as described in the Agreement.  If you do not agree to all of the terms of the
 | 
			
		||||
 *  Agreement do not use this file and delete all copies in your possession or control;
 | 
			
		||||
 *  if you do not have a copy of the Agreement, you must contact Wicentric, Inc. prior
 | 
			
		||||
 *  to any use, copying or further distribution of this software.
 | 
			
		||||
 */
 | 
			
		||||
/*************************************************************************************************/
 | 
			
		||||
#ifndef WSF_OS_H
 | 
			
		||||
#define WSF_OS_H
 | 
			
		||||
 | 
			
		||||
#include "wsf_os_int.h"
 | 
			
		||||
#include "wsf_queue.h"
 | 
			
		||||
 | 
			
		||||
#ifdef __cplusplus
 | 
			
		||||
extern "C" {
 | 
			
		||||
#endif
 | 
			
		||||
 | 
			
		||||
/**************************************************************************************************
 | 
			
		||||
  Data Types
 | 
			
		||||
**************************************************************************************************/
 | 
			
		||||
 | 
			
		||||
/*! Common message structure passed to event handler */
 | 
			
		||||
typedef struct
 | 
			
		||||
{
 | 
			
		||||
  uint16_t        param;          /*! General purpose parameter passed to event handler */
 | 
			
		||||
  uint8_t         event;          /*! General purpose event value passed to event handler */
 | 
			
		||||
  uint8_t         status;         /*! General purpose status value passed to event handler */
 | 
			
		||||
} wsfMsgHdr_t;
 | 
			
		||||
 | 
			
		||||
/**************************************************************************************************
 | 
			
		||||
  Callback Function Types
 | 
			
		||||
**************************************************************************************************/
 | 
			
		||||
 | 
			
		||||
/*************************************************************************************************/
 | 
			
		||||
/*!
 | 
			
		||||
 *  \fn     wsfEventHandler_t
 | 
			
		||||
 *        
 | 
			
		||||
 *  \brief  Event handler callback function.
 | 
			
		||||
 *
 | 
			
		||||
 *  \param  event    Mask of events set for the event handler.
 | 
			
		||||
 *  \param  pMsg     Pointer to message for the event handler.
 | 
			
		||||
 *
 | 
			
		||||
 *  \return None.
 | 
			
		||||
 */
 | 
			
		||||
/*************************************************************************************************/
 | 
			
		||||
typedef void (*wsfEventHandler_t)(wsfEventMask_t event, wsfMsgHdr_t *pMsg);
 | 
			
		||||
 | 
			
		||||
/**************************************************************************************************
 | 
			
		||||
  Function Declarations
 | 
			
		||||
**************************************************************************************************/
 | 
			
		||||
 | 
			
		||||
/*************************************************************************************************/
 | 
			
		||||
/*!
 | 
			
		||||
 *  \fn     WsfSetEvent
 | 
			
		||||
 *        
 | 
			
		||||
 *  \brief  Set an event for an event handler.
 | 
			
		||||
 *
 | 
			
		||||
 *  \param  handlerId   Handler ID.
 | 
			
		||||
 *  \param  event       Event or events to set.
 | 
			
		||||
 *
 | 
			
		||||
 *  \return None.
 | 
			
		||||
 */
 | 
			
		||||
/*************************************************************************************************/
 | 
			
		||||
void WsfSetEvent(wsfHandlerId_t handlerId, wsfEventMask_t event);
 | 
			
		||||
 | 
			
		||||
/*************************************************************************************************/
 | 
			
		||||
/*!
 | 
			
		||||
 *  \fn     WsfTaskLock
 | 
			
		||||
 *        
 | 
			
		||||
 *  \brief  Lock task scheduling.
 | 
			
		||||
 *
 | 
			
		||||
 *  \return None.
 | 
			
		||||
 */
 | 
			
		||||
/*************************************************************************************************/
 | 
			
		||||
void WsfTaskLock(void);
 | 
			
		||||
 | 
			
		||||
/*************************************************************************************************/
 | 
			
		||||
/*!
 | 
			
		||||
 *  \fn     WsfTaskUnlock
 | 
			
		||||
 *        
 | 
			
		||||
 *  \brief  Unlock task scheduling.
 | 
			
		||||
 *
 | 
			
		||||
 *  \return None.
 | 
			
		||||
 */
 | 
			
		||||
/*************************************************************************************************/
 | 
			
		||||
void WsfTaskUnlock(void);
 | 
			
		||||
 | 
			
		||||
/*************************************************************************************************/
 | 
			
		||||
/*!
 | 
			
		||||
 *  \fn     WsfTaskSetReady
 | 
			
		||||
 *        
 | 
			
		||||
 *  \brief  Set the task used by the given handler as ready to run.
 | 
			
		||||
 *
 | 
			
		||||
 *  \param  handlerId   Event handler ID.
 | 
			
		||||
 *  \param  event       Task event mask.
 | 
			
		||||
 *
 | 
			
		||||
 *  \return None.
 | 
			
		||||
 */
 | 
			
		||||
/*************************************************************************************************/
 | 
			
		||||
void WsfTaskSetReady(wsfHandlerId_t handlerId, wsfTaskEvent_t event);
 | 
			
		||||
 | 
			
		||||
/*************************************************************************************************/
 | 
			
		||||
/*!
 | 
			
		||||
 *  \fn     WsfTaskMsgQueue
 | 
			
		||||
 *        
 | 
			
		||||
 *  \brief  Return the task message queue used by the given handler.
 | 
			
		||||
 *
 | 
			
		||||
 *  \param  handlerId   Event handler ID.
 | 
			
		||||
 *
 | 
			
		||||
 *  \return Task message queue.
 | 
			
		||||
 */
 | 
			
		||||
/*************************************************************************************************/
 | 
			
		||||
wsfQueue_t *WsfTaskMsgQueue(wsfHandlerId_t handlerId);
 | 
			
		||||
 | 
			
		||||
/*************************************************************************************************/
 | 
			
		||||
/*!
 | 
			
		||||
 *  \fn     WsfOsSetNextHandler
 | 
			
		||||
 *        
 | 
			
		||||
 *  \brief  Set the next WSF handler function in the WSF OS handler array.  This function
 | 
			
		||||
 *          should only be called as part of the OS initialization procedure.
 | 
			
		||||
 *
 | 
			
		||||
 *  \param  handler    WSF handler function.
 | 
			
		||||
 *
 | 
			
		||||
 *  \return WSF handler ID for this handler.
 | 
			
		||||
 */
 | 
			
		||||
/*************************************************************************************************/
 | 
			
		||||
wsfHandlerId_t WsfOsSetNextHandler(wsfEventHandler_t handler);
 | 
			
		||||
 | 
			
		||||
#ifdef __cplusplus
 | 
			
		||||
};
 | 
			
		||||
#endif
 | 
			
		||||
 | 
			
		||||
#endif /* WSF_OS_H */
 | 
			
		||||
| 
						 | 
				
			
			@ -1,155 +0,0 @@
 | 
			
		|||
/*************************************************************************************************/
 | 
			
		||||
/*!
 | 
			
		||||
 *  \file   wsf_queue.h
 | 
			
		||||
 *        
 | 
			
		||||
 *  \brief  General purpose queue service.
 | 
			
		||||
 *
 | 
			
		||||
 *          $Date: 2011-10-14 21:35:03 -0700 (Fri, 14 Oct 2011) $
 | 
			
		||||
 *          $Revision: 191 $
 | 
			
		||||
 *  
 | 
			
		||||
 *  Copyright (c) 2009 Wicentric, Inc., all rights reserved.
 | 
			
		||||
 *  Wicentric confidential and proprietary.
 | 
			
		||||
 *
 | 
			
		||||
 *  IMPORTANT.  Your use of this file is governed by a Software License Agreement
 | 
			
		||||
 *  ("Agreement") that must be accepted in order to download or otherwise receive a
 | 
			
		||||
 *  copy of this file.  You may not use or copy this file for any purpose other than
 | 
			
		||||
 *  as described in the Agreement.  If you do not agree to all of the terms of the
 | 
			
		||||
 *  Agreement do not use this file and delete all copies in your possession or control;
 | 
			
		||||
 *  if you do not have a copy of the Agreement, you must contact Wicentric, Inc. prior
 | 
			
		||||
 *  to any use, copying or further distribution of this software.
 | 
			
		||||
 */
 | 
			
		||||
/*************************************************************************************************/
 | 
			
		||||
#ifndef WSF_QUEUE_H
 | 
			
		||||
#define WSF_QUEUE_H
 | 
			
		||||
 | 
			
		||||
#ifdef __cplusplus
 | 
			
		||||
extern "C" {
 | 
			
		||||
#endif
 | 
			
		||||
 | 
			
		||||
/**************************************************************************************************
 | 
			
		||||
  Macros
 | 
			
		||||
**************************************************************************************************/
 | 
			
		||||
 | 
			
		||||
/*! Initialize a queue */
 | 
			
		||||
#define WSF_QUEUE_INIT(pQueue)          {(pQueue)->pHead = NULL; (pQueue)->pTail = NULL;}
 | 
			
		||||
 | 
			
		||||
/**************************************************************************************************
 | 
			
		||||
  Data Types
 | 
			
		||||
**************************************************************************************************/
 | 
			
		||||
 | 
			
		||||
/*! Queue structure */
 | 
			
		||||
typedef struct
 | 
			
		||||
{
 | 
			
		||||
  void      *pHead;         /*! head of queue */
 | 
			
		||||
  void      *pTail;         /*! tail of queue */
 | 
			
		||||
} wsfQueue_t;
 | 
			
		||||
 | 
			
		||||
/**************************************************************************************************
 | 
			
		||||
  Function Declarations
 | 
			
		||||
**************************************************************************************************/
 | 
			
		||||
 | 
			
		||||
/*************************************************************************************************/
 | 
			
		||||
/*!
 | 
			
		||||
 *  \fn     WsfQueueEnq
 | 
			
		||||
 *        
 | 
			
		||||
 *  \brief  Enqueue an element to the tail of a queue.
 | 
			
		||||
 *
 | 
			
		||||
 *  \param  pQueue    Pointer to queue.
 | 
			
		||||
 *  \param  pElem     Pointer to element.
 | 
			
		||||
 *
 | 
			
		||||
 *  \return None.
 | 
			
		||||
 */
 | 
			
		||||
/*************************************************************************************************/
 | 
			
		||||
void WsfQueueEnq(wsfQueue_t *pQueue, void *pElem);
 | 
			
		||||
 | 
			
		||||
/*************************************************************************************************/
 | 
			
		||||
/*!
 | 
			
		||||
 *  \fn     WsfQueueDeq
 | 
			
		||||
 *        
 | 
			
		||||
 *  \brief  Dequeue an element from the head of a queue.
 | 
			
		||||
 *
 | 
			
		||||
 *  \param  pQueue    Pointer to queue.
 | 
			
		||||
 *
 | 
			
		||||
 *  \return Pointer to element that has been dequeued or NULL if queue is empty.
 | 
			
		||||
 */
 | 
			
		||||
/*************************************************************************************************/
 | 
			
		||||
void *WsfQueueDeq(wsfQueue_t *pQueue);
 | 
			
		||||
 | 
			
		||||
/*************************************************************************************************/
 | 
			
		||||
/*!
 | 
			
		||||
 *  \fn     WsfQueuePush
 | 
			
		||||
 *        
 | 
			
		||||
 *  \brief  Push an element to the head of a queue.
 | 
			
		||||
 *
 | 
			
		||||
 *  \param  pQueue    Pointer to queue.
 | 
			
		||||
 *  \param  pElem     Pointer to element.
 | 
			
		||||
 *
 | 
			
		||||
 *  \return None.
 | 
			
		||||
 */
 | 
			
		||||
/*************************************************************************************************/
 | 
			
		||||
void WsfQueuePush(wsfQueue_t *pQueue, void *pElem);
 | 
			
		||||
 | 
			
		||||
/*************************************************************************************************/
 | 
			
		||||
/*!
 | 
			
		||||
 *  \fn     WsfQueueInsert
 | 
			
		||||
 *        
 | 
			
		||||
 *  \brief  Insert an element into a queue.  This function is typically used when iterating
 | 
			
		||||
 *          over a queue.
 | 
			
		||||
 *
 | 
			
		||||
 *  \param  pQueue    Pointer to queue.
 | 
			
		||||
 *  \param  pElem     Pointer to element to be inserted.
 | 
			
		||||
 *  \param  pPrev     Pointer to previous element in the queue before element to be inserted.
 | 
			
		||||
 *                    Note:  set pPrev to NULL if pElem is first element in queue.
 | 
			
		||||
 *  \return None.
 | 
			
		||||
 */
 | 
			
		||||
/*************************************************************************************************/
 | 
			
		||||
void WsfQueueInsert(wsfQueue_t *pQueue, void *pElem, void *pPrev);
 | 
			
		||||
 | 
			
		||||
/*************************************************************************************************/
 | 
			
		||||
/*!
 | 
			
		||||
 *  \fn     WsfQueueRemove
 | 
			
		||||
 *        
 | 
			
		||||
 *  \brief  Remove an element from a queue.  This function is typically used when iterating
 | 
			
		||||
 *          over a queue.
 | 
			
		||||
 *
 | 
			
		||||
 *  \param  pQueue    Pointer to queue.
 | 
			
		||||
 *  \param  pElem     Pointer to element to be removed.
 | 
			
		||||
 *  \param  pPrev     Pointer to previous element in the queue before element to be removed.
 | 
			
		||||
 *
 | 
			
		||||
 *  \return None.
 | 
			
		||||
 */
 | 
			
		||||
/*************************************************************************************************/
 | 
			
		||||
void WsfQueueRemove(wsfQueue_t *pQueue, void *pElem, void *pPrev);
 | 
			
		||||
 | 
			
		||||
/*************************************************************************************************/
 | 
			
		||||
/*!
 | 
			
		||||
 *  \fn     WsfQueueCount
 | 
			
		||||
 *        
 | 
			
		||||
 *  \brief  Count the number of elements in a queue.
 | 
			
		||||
 *
 | 
			
		||||
 *  \param  pQueue    Pointer to queue.
 | 
			
		||||
 *
 | 
			
		||||
 *  \return Number of elements in queue.
 | 
			
		||||
 */
 | 
			
		||||
/*************************************************************************************************/
 | 
			
		||||
uint16_t WsfQueueCount(wsfQueue_t *pQueue);
 | 
			
		||||
 | 
			
		||||
/*************************************************************************************************/
 | 
			
		||||
/*!
 | 
			
		||||
 *  \fn     WsfQueueEmpty
 | 
			
		||||
 *        
 | 
			
		||||
 *  \brief  Return TRUE if queue is empty.
 | 
			
		||||
 *
 | 
			
		||||
 *  \param  pQueue    Pointer to queue.
 | 
			
		||||
 *
 | 
			
		||||
 *  \return TRUE if queue is empty, FALSE otherwise.
 | 
			
		||||
 */
 | 
			
		||||
/*************************************************************************************************/
 | 
			
		||||
bool_t WsfQueueEmpty(wsfQueue_t *pQueue);
 | 
			
		||||
 | 
			
		||||
 | 
			
		||||
#ifdef __cplusplus
 | 
			
		||||
};
 | 
			
		||||
#endif
 | 
			
		||||
 | 
			
		||||
#endif /* WSF_QUEUE_H */
 | 
			
		||||
| 
						 | 
				
			
			@ -1,243 +0,0 @@
 | 
			
		|||
/*************************************************************************************************/
 | 
			
		||||
/*!
 | 
			
		||||
 *  \file   wsf_sec.h
 | 
			
		||||
 *        
 | 
			
		||||
 *  \brief  AES and random number security service API.
 | 
			
		||||
 *
 | 
			
		||||
 *          $Date: 2015-10-15 11:57:57 -0700 (Thu, 15 Oct 2015) $
 | 
			
		||||
 *          $Revision: 4218 $
 | 
			
		||||
 *  
 | 
			
		||||
 *  Copyright (c) 2010 Wicentric, Inc., all rights reserved.
 | 
			
		||||
 *  Wicentric confidential and proprietary.
 | 
			
		||||
 *
 | 
			
		||||
 *  IMPORTANT.  Your use of this file is governed by a Software License Agreement
 | 
			
		||||
 *  ("Agreement") that must be accepted in order to download or otherwise receive a
 | 
			
		||||
 *  copy of this file.  You may not use or copy this file for any purpose other than
 | 
			
		||||
 *  as described in the Agreement.  If you do not agree to all of the terms of the
 | 
			
		||||
 *  Agreement do not use this file and delete all copies in your possession or control;
 | 
			
		||||
 *  if you do not have a copy of the Agreement, you must contact Wicentric, Inc. prior
 | 
			
		||||
 *  to any use, copying or further distribution of this software.
 | 
			
		||||
 */
 | 
			
		||||
/*************************************************************************************************/
 | 
			
		||||
#ifndef WSF_SEC_H
 | 
			
		||||
#define WSF_SEC_H
 | 
			
		||||
 | 
			
		||||
#include "wsf_types.h"
 | 
			
		||||
 | 
			
		||||
#ifdef __cplusplus
 | 
			
		||||
extern "C" {
 | 
			
		||||
#endif
 | 
			
		||||
  
 | 
			
		||||
/**************************************************************************************************
 | 
			
		||||
  Macros
 | 
			
		||||
**************************************************************************************************/
 | 
			
		||||
 | 
			
		||||
/*! CMAC algorithm key length */
 | 
			
		||||
#define WSF_CMAC_KEY_LEN              16
 | 
			
		||||
 | 
			
		||||
/*! CMAC algorithm result length */
 | 
			
		||||
#define WSF_CMAC_HASH_LEN             16
 | 
			
		||||
 | 
			
		||||
/*! ECC algorithm key length */
 | 
			
		||||
#define WSF_ECC_KEY_LEN               32
 | 
			
		||||
 | 
			
		||||
/*! Invalid AES Token */
 | 
			
		||||
#define WSF_TOKEN_INVALID             0xFF
 | 
			
		||||
 | 
			
		||||
/**************************************************************************************************
 | 
			
		||||
  Data Types
 | 
			
		||||
**************************************************************************************************/
 | 
			
		||||
/*! AES Security callback parameters structure */
 | 
			
		||||
typedef struct
 | 
			
		||||
{
 | 
			
		||||
  wsfMsgHdr_t   hdr;              /*! header */
 | 
			
		||||
  uint8_t       *pCiphertext;     /*! pointer to 16 bytes of ciphertext data */
 | 
			
		||||
} wsfSecMsg_t;
 | 
			
		||||
 | 
			
		||||
/*! AES Security callback are the same as wsfSecMsg_t */
 | 
			
		||||
typedef wsfSecMsg_t wsfSecAes_t;
 | 
			
		||||
 | 
			
		||||
/*! CMAC Security callback are the same as wsfSecMsg_t */
 | 
			
		||||
typedef wsfSecMsg_t wsfSecCmacMsg_t;
 | 
			
		||||
 | 
			
		||||
/*! ECC Security public/private key pair */
 | 
			
		||||
typedef struct
 | 
			
		||||
{
 | 
			
		||||
  uint8_t pubKey_x[WSF_ECC_KEY_LEN]; /*! x component of ecc public key */
 | 
			
		||||
  uint8_t pubKey_y[WSF_ECC_KEY_LEN]; /*! y component of ecc public key */
 | 
			
		||||
  uint8_t privKey[WSF_ECC_KEY_LEN];  /*! ecc private key */
 | 
			
		||||
} wsfSecEccKey_t;
 | 
			
		||||
 | 
			
		||||
/*! ECC security DH Key shared secret */
 | 
			
		||||
typedef struct
 | 
			
		||||
{
 | 
			
		||||
  uint8_t secret[WSF_ECC_KEY_LEN];  /*! DH Key Shared secret */
 | 
			
		||||
} wsfSecEccSharedSec_t;
 | 
			
		||||
 | 
			
		||||
 | 
			
		||||
/*! ECC Security callback parameters structure */
 | 
			
		||||
typedef struct
 | 
			
		||||
{
 | 
			
		||||
  wsfMsgHdr_t   hdr;                    /*! header */
 | 
			
		||||
  union
 | 
			
		||||
  {
 | 
			
		||||
    wsfSecEccSharedSec_t sharedSecret;  /*! shared secret */
 | 
			
		||||
    wsfSecEccKey_t key;                 /*! ecc public/private key pair */
 | 
			
		||||
  } data;
 | 
			
		||||
} wsfSecEccMsg_t;
 | 
			
		||||
 | 
			
		||||
 | 
			
		||||
/**************************************************************************************************
 | 
			
		||||
  Function Declarations
 | 
			
		||||
**************************************************************************************************/
 | 
			
		||||
 | 
			
		||||
/*************************************************************************************************/
 | 
			
		||||
/*!
 | 
			
		||||
 *  \fn     WsfSecInit
 | 
			
		||||
 *        
 | 
			
		||||
 *  \brief  Initialize the security service.  This function should only be called once
 | 
			
		||||
 *          upon system initialization.
 | 
			
		||||
 *
 | 
			
		||||
 *  \return None.
 | 
			
		||||
 */
 | 
			
		||||
/*************************************************************************************************/
 | 
			
		||||
void WsfSecInit(void);
 | 
			
		||||
 | 
			
		||||
/*************************************************************************************************/
 | 
			
		||||
/*!
 | 
			
		||||
 *  \fn     WsfSecRandInit
 | 
			
		||||
 *        
 | 
			
		||||
 *  \brief  Initialize the random number service.  This function should only be called once
 | 
			
		||||
 *          upon system initialization.
 | 
			
		||||
 *
 | 
			
		||||
 *  \return None.
 | 
			
		||||
 */
 | 
			
		||||
/*************************************************************************************************/
 | 
			
		||||
void WsfSecRandInit(void);
 | 
			
		||||
 | 
			
		||||
/*************************************************************************************************/
 | 
			
		||||
/*!
 | 
			
		||||
 *  \fn     WsfSecAesInit
 | 
			
		||||
 *        
 | 
			
		||||
 *  \brief  Initialize the AES service.  This function should only be called once
 | 
			
		||||
 *          upon system initialization.
 | 
			
		||||
 *
 | 
			
		||||
 *  \return None.
 | 
			
		||||
 */
 | 
			
		||||
/*************************************************************************************************/
 | 
			
		||||
void WsfSecAesInit(void);
 | 
			
		||||
 | 
			
		||||
/*************************************************************************************************/
 | 
			
		||||
/*!
 | 
			
		||||
 *  \fn     WsfSecCmacInit
 | 
			
		||||
 *        
 | 
			
		||||
 *  \brief  Called to initialize CMAC security.  This function should only be called once
 | 
			
		||||
 *          upon system initialization.
 | 
			
		||||
 *
 | 
			
		||||
 *  \return None.
 | 
			
		||||
 */
 | 
			
		||||
/*************************************************************************************************/
 | 
			
		||||
void WsfSecCmacInit(void);
 | 
			
		||||
 | 
			
		||||
/*************************************************************************************************/
 | 
			
		||||
/*!
 | 
			
		||||
 *  \fn     WsfSecEccInit
 | 
			
		||||
 *        
 | 
			
		||||
 *  \brief  Called to initialize ECC security.  This function should only be called once
 | 
			
		||||
 *          upon system initialization.
 | 
			
		||||
 *
 | 
			
		||||
 *  \return None.
 | 
			
		||||
 */
 | 
			
		||||
/*************************************************************************************************/
 | 
			
		||||
void WsfSecEccInit(void);
 | 
			
		||||
 | 
			
		||||
/*************************************************************************************************/
 | 
			
		||||
/*!
 | 
			
		||||
 *  \fn     WsfSecAes
 | 
			
		||||
 *        
 | 
			
		||||
 *  \brief  Execute an AES calculation.  When the calculation completes, a WSF message will be
 | 
			
		||||
 *          sent to the specified handler.  This function returns a token value that
 | 
			
		||||
 *          the client can use to match calls to this function with messages.
 | 
			
		||||
 *
 | 
			
		||||
 *  \param  pKey        Pointer to 16 byte key.
 | 
			
		||||
 *  \param  pPlaintext  Pointer to 16 byte plaintext.
 | 
			
		||||
 *  \param  handlerId   WSF handler ID.
 | 
			
		||||
 *  \param  param       Client-defined parameter returned in message.
 | 
			
		||||
 *  \param  event       Event for client's WSF handler.
 | 
			
		||||
 *
 | 
			
		||||
 *  \return Token value.
 | 
			
		||||
 */
 | 
			
		||||
/*************************************************************************************************/
 | 
			
		||||
uint8_t WsfSecAes(uint8_t *pKey, uint8_t *pPlaintext, wsfHandlerId_t handlerId,
 | 
			
		||||
                  uint16_t param, uint8_t event);
 | 
			
		||||
 | 
			
		||||
/*************************************************************************************************/
 | 
			
		||||
/*!
 | 
			
		||||
 *  \fn     WsfSecAesCmac
 | 
			
		||||
 *        
 | 
			
		||||
 *  \brief  Execute the CMAC algorithm.
 | 
			
		||||
 *
 | 
			
		||||
 *  \param  pKey        Key used in CMAC operation.
 | 
			
		||||
 *  \param  pPlaintext  Data to perform CMAC operation over
 | 
			
		||||
 *  \param  len         Size of pPlaintext in bytes.
 | 
			
		||||
 *  \param  handlerId   WSF handler ID for client.
 | 
			
		||||
 *  \param  param       Optional parameter sent to client's WSF handler.
 | 
			
		||||
 *  \param  event       Event for client's WSF handler.
 | 
			
		||||
 *
 | 
			
		||||
 *  \return TRUE if successful, else FALSE.
 | 
			
		||||
 */
 | 
			
		||||
/*************************************************************************************************/
 | 
			
		||||
bool_t WsfSecCmac(const uint8_t *pKey, uint8_t *pPlaintext, uint8_t textLen, wsfHandlerId_t handlerId, 
 | 
			
		||||
                   uint16_t param, uint8_t event);
 | 
			
		||||
 | 
			
		||||
/*************************************************************************************************/
 | 
			
		||||
/*!
 | 
			
		||||
 *  \fn     WsfSecEccGenKey
 | 
			
		||||
 *        
 | 
			
		||||
 *  \brief  Generate an ECC key.
 | 
			
		||||
 *
 | 
			
		||||
 *  \param  handlerId   WSF handler ID for client.
 | 
			
		||||
 *  \param  param       Optional parameter sent to client's WSF handler.
 | 
			
		||||
 *  \param  event       Event for client's WSF handler.
 | 
			
		||||
 *
 | 
			
		||||
 *  \return TRUE if successful, else FALSE.
 | 
			
		||||
 */
 | 
			
		||||
/*************************************************************************************************/
 | 
			
		||||
bool_t WsfSecEccGenKey(wsfHandlerId_t handlerId, uint16_t param, uint8_t event);
 | 
			
		||||
 | 
			
		||||
/*************************************************************************************************/
 | 
			
		||||
/*!
 | 
			
		||||
 *  \fn     WsfSecEccGenSharedSecret
 | 
			
		||||
 *        
 | 
			
		||||
 *  \brief  Generate an ECC key.
 | 
			
		||||
 *
 | 
			
		||||
 *  \param  pKey        ECC Key structure.
 | 
			
		||||
 *  \param  handlerId   WSF handler ID for client.
 | 
			
		||||
 *  \param  param       Optional parameter sent to client's WSF handler.
 | 
			
		||||
 *  \param  event       Event for client's WSF handler.
 | 
			
		||||
 *
 | 
			
		||||
 *  \return TRUE if successful, else FALSE.
 | 
			
		||||
 */
 | 
			
		||||
/*************************************************************************************************/
 | 
			
		||||
bool_t WsfSecEccGenSharedSecret(wsfSecEccKey_t *pKey, wsfHandlerId_t handlerId, uint16_t param, uint8_t event);
 | 
			
		||||
 | 
			
		||||
/*************************************************************************************************/
 | 
			
		||||
/*!
 | 
			
		||||
 *  \fn     WsfSecRand
 | 
			
		||||
 *        
 | 
			
		||||
 *  \brief  This function returns up to 16 bytes of random data to a buffer provided by the
 | 
			
		||||
 *          client.
 | 
			
		||||
 *
 | 
			
		||||
 *  \param  pRand       Pointer to returned random data.
 | 
			
		||||
 *  \param  randLen     Length of random data.
 | 
			
		||||
 *
 | 
			
		||||
 *  \return None.
 | 
			
		||||
 */
 | 
			
		||||
/*************************************************************************************************/
 | 
			
		||||
void WsfSecRand(uint8_t *pRand, uint8_t randLen);
 | 
			
		||||
 | 
			
		||||
#ifdef __cplusplus
 | 
			
		||||
};
 | 
			
		||||
#endif
 | 
			
		||||
 | 
			
		||||
#endif /* WSF_SEC_H */
 | 
			
		||||
| 
						 | 
				
			
			@ -1,105 +0,0 @@
 | 
			
		|||
/*************************************************************************************************/
 | 
			
		||||
/*!
 | 
			
		||||
 *  \file   wsf_sec_int.h
 | 
			
		||||
 *
 | 
			
		||||
 *  \brief  Internal security service structures.
 | 
			
		||||
 *
 | 
			
		||||
 *          $Date: 2015-12-10 09:40:54 -0800 (Thu, 10 Dec 2015) $
 | 
			
		||||
 *          $Revision: 4754 $
 | 
			
		||||
 *
 | 
			
		||||
 *  Copyright (c) 2010 Wicentric, Inc., all rights reserved.
 | 
			
		||||
 *  Wicentric confidential and proprietary.
 | 
			
		||||
 *
 | 
			
		||||
 *  IMPORTANT.  Your use of this file is governed by a Software License Agreement
 | 
			
		||||
 *  ("Agreement") that must be accepted in order to download or otherwise receive a
 | 
			
		||||
 *  copy of this file.  You may not use or copy this file for any purpose other than
 | 
			
		||||
 *  as described in the Agreement.  If you do not agree to all of the terms of the
 | 
			
		||||
 *  Agreement do not use this file and delete all copies in your possession or control;
 | 
			
		||||
 *  if you do not have a copy of the Agreement, you must contact Wicentric, Inc. prior
 | 
			
		||||
 *  to any use, copying or further distribution of this software.
 | 
			
		||||
 */
 | 
			
		||||
/*************************************************************************************************/
 | 
			
		||||
#ifndef WSF_SEC_INT_H
 | 
			
		||||
#define WSF_SEC_INT_H
 | 
			
		||||
 | 
			
		||||
#include "hci_api.h"
 | 
			
		||||
 | 
			
		||||
#ifdef __cplusplus
 | 
			
		||||
extern "C" {
 | 
			
		||||
#endif
 | 
			
		||||
 | 
			
		||||
/**************************************************************************************************
 | 
			
		||||
  Macros
 | 
			
		||||
**************************************************************************************************/
 | 
			
		||||
 | 
			
		||||
 | 
			
		||||
/*! AES, CMAC and HCI algorithm block length */
 | 
			
		||||
#define WSF_SEC_BLOCK_LEN             16
 | 
			
		||||
 | 
			
		||||
/* CMAC constant Rb */
 | 
			
		||||
#define WSF_SEC_CMAC_RB               0x87
 | 
			
		||||
 | 
			
		||||
/*! Multiple of HCI_RAND_LEN to keep in the wsfSecCb_t rand data buffer */
 | 
			
		||||
#define WSF_HCI_RAND_MULT            (32 / HCI_RAND_LEN)
 | 
			
		||||
 | 
			
		||||
/*! Compile time ECC configuration */
 | 
			
		||||
#define WSF_SEC_ECC_CFG_DEBUG        0
 | 
			
		||||
#define WSF_SEC_ECC_CFG_UECC         1
 | 
			
		||||
#define WSF_SEC_ECC_CFG_HCI          2
 | 
			
		||||
 | 
			
		||||
/**************************************************************************************************
 | 
			
		||||
  Data Types
 | 
			
		||||
**************************************************************************************************/
 | 
			
		||||
 | 
			
		||||
/*! Enumeration of security operation types */
 | 
			
		||||
enum
 | 
			
		||||
{
 | 
			
		||||
  WSF_SEC_TYPE_AES,
 | 
			
		||||
  WSF_SEC_TYPE_CMAC,
 | 
			
		||||
  WSF_SEC_TYPE_DH,
 | 
			
		||||
  WSF_SEC_NUM_TYPES
 | 
			
		||||
};
 | 
			
		||||
 | 
			
		||||
/*! Security queue element for CMAC operations */
 | 
			
		||||
typedef struct
 | 
			
		||||
{
 | 
			
		||||
  uint8_t           *pPlainText;
 | 
			
		||||
  uint8_t           key[WSF_CMAC_KEY_LEN];
 | 
			
		||||
  uint8_t           subkey[WSF_CMAC_KEY_LEN];
 | 
			
		||||
  uint16_t          position;
 | 
			
		||||
  uint16_t          len;
 | 
			
		||||
  wsfHandlerId_t    handlerId;
 | 
			
		||||
  uint8_t           state;
 | 
			
		||||
} wsfSecCmacSecCb_t;
 | 
			
		||||
 | 
			
		||||
/*! Security queue element */
 | 
			
		||||
typedef struct
 | 
			
		||||
{
 | 
			
		||||
  wsfSecMsg_t   msg;
 | 
			
		||||
  uint8_t       ciphertext[WSF_SEC_BLOCK_LEN];
 | 
			
		||||
  uint8_t       reserved[WSF_SEC_BLOCK_LEN];
 | 
			
		||||
  void          *pCb;
 | 
			
		||||
  uint8_t       type;
 | 
			
		||||
} wsfSecQueueBuf_t;
 | 
			
		||||
 | 
			
		||||
typedef void wsfSecHciCback_t(wsfSecQueueBuf_t *pBuf, hciEvt_t *pEvent, wsfHandlerId_t handlerId);
 | 
			
		||||
typedef wsfSecHciCback_t *pWsfSecHciCback_t;
 | 
			
		||||
 | 
			
		||||
/* Control block */
 | 
			
		||||
typedef struct
 | 
			
		||||
{
 | 
			
		||||
  uint8_t           rand[HCI_RAND_LEN*WSF_HCI_RAND_MULT]; /* Random data buffer */
 | 
			
		||||
  wsfQueue_t        queue;                /* Queue for AES requests */
 | 
			
		||||
  uint8_t           token;                /* Token value */
 | 
			
		||||
  pWsfSecHciCback_t hciCbackTbl[WSF_SEC_NUM_TYPES];
 | 
			
		||||
} wsfSecCb_t;
 | 
			
		||||
 | 
			
		||||
/**************************************************************************************************
 | 
			
		||||
  Function Declarations
 | 
			
		||||
**************************************************************************************************/
 | 
			
		||||
 | 
			
		||||
#ifdef __cplusplus
 | 
			
		||||
};
 | 
			
		||||
#endif
 | 
			
		||||
 | 
			
		||||
#endif /* WSF_SEC_H */
 | 
			
		||||
| 
						 | 
				
			
			@ -1,164 +0,0 @@
 | 
			
		|||
/*************************************************************************************************/
 | 
			
		||||
/*!
 | 
			
		||||
 *  \file   wsf_timer.h
 | 
			
		||||
 *
 | 
			
		||||
 *  \brief  Timer service.
 | 
			
		||||
 *
 | 
			
		||||
 *          $Date: 2015-09-11 14:14:44 -0700 (Fri, 11 Sep 2015) $
 | 
			
		||||
 *          $Revision: 3856 $
 | 
			
		||||
 *
 | 
			
		||||
 *  Copyright (c) 2009 Wicentric, Inc., all rights reserved.
 | 
			
		||||
 *  Wicentric confidential and proprietary.
 | 
			
		||||
 *
 | 
			
		||||
 *  IMPORTANT.  Your use of this file is governed by a Software License Agreement
 | 
			
		||||
 *  ("Agreement") that must be accepted in order to download or otherwise receive a
 | 
			
		||||
 *  copy of this file.  You may not use or copy this file for any purpose other than
 | 
			
		||||
 *  as described in the Agreement.  If you do not agree to all of the terms of the
 | 
			
		||||
 *  Agreement do not use this file and delete all copies in your possession or control;
 | 
			
		||||
 *  if you do not have a copy of the Agreement, you must contact Wicentric, Inc. prior
 | 
			
		||||
 *  to any use, copying or further distribution of this software.
 | 
			
		||||
 */
 | 
			
		||||
/*************************************************************************************************/
 | 
			
		||||
#ifndef WSF_TIMER_H
 | 
			
		||||
#define WSF_TIMER_H
 | 
			
		||||
 | 
			
		||||
#include "wsf_os.h"
 | 
			
		||||
 | 
			
		||||
#ifdef __cplusplus
 | 
			
		||||
extern "C" {
 | 
			
		||||
#endif
 | 
			
		||||
 | 
			
		||||
/**************************************************************************************************
 | 
			
		||||
  Macros
 | 
			
		||||
**************************************************************************************************/
 | 
			
		||||
 | 
			
		||||
#ifndef WSF_MS_PER_TICK
 | 
			
		||||
/*! Default milliseconds per tick rate */
 | 
			
		||||
#define WSF_MS_PER_TICK   10
 | 
			
		||||
#endif
 | 
			
		||||
 | 
			
		||||
/**************************************************************************************************
 | 
			
		||||
  Data Types
 | 
			
		||||
**************************************************************************************************/
 | 
			
		||||
 | 
			
		||||
/*! Timer ticks data type */
 | 
			
		||||
typedef uint32_t wsfTimerTicks_t;
 | 
			
		||||
 | 
			
		||||
/*! Timer structure */
 | 
			
		||||
typedef struct wsfTimer_tag
 | 
			
		||||
{
 | 
			
		||||
  struct wsfTimer_tag *pNext;             /*! pointer to next timer in queue */
 | 
			
		||||
  wsfTimerTicks_t     ticks;              /*! number of ticks until expiration */
 | 
			
		||||
  wsfHandlerId_t      handlerId;          /*! event handler for this timer */
 | 
			
		||||
  bool_t              isStarted;          /*! TRUE if timer has been started */
 | 
			
		||||
  wsfMsgHdr_t         msg;                /*! application-defined timer event parameters */
 | 
			
		||||
} wsfTimer_t;
 | 
			
		||||
 | 
			
		||||
 | 
			
		||||
/**************************************************************************************************
 | 
			
		||||
  Function Declarations
 | 
			
		||||
**************************************************************************************************/
 | 
			
		||||
 | 
			
		||||
/*************************************************************************************************/
 | 
			
		||||
/*!
 | 
			
		||||
 *  \fn     WsfTimerInit
 | 
			
		||||
 *
 | 
			
		||||
 *  \brief  Initialize the timer service.  This function should only be called once
 | 
			
		||||
 *          upon system initialization.
 | 
			
		||||
 *
 | 
			
		||||
 *  \return None.
 | 
			
		||||
 */
 | 
			
		||||
/*************************************************************************************************/
 | 
			
		||||
void WsfTimerInit(void);
 | 
			
		||||
 | 
			
		||||
/*************************************************************************************************/
 | 
			
		||||
/*!
 | 
			
		||||
 *  \fn     WsfTimerStartSec
 | 
			
		||||
 *
 | 
			
		||||
 *  \brief  Start a timer in units of seconds.  Before this function is called parameter
 | 
			
		||||
 *          pTimer->handlerId must be set to the event handler for this timer and parameter
 | 
			
		||||
 *          pTimer->msg must be set to any application-defined timer event parameters.
 | 
			
		||||
 *
 | 
			
		||||
 *  \param  pTimer  Pointer to timer.
 | 
			
		||||
 *  \param  sec     Seconds until expiration.
 | 
			
		||||
 *
 | 
			
		||||
 *  \return None.
 | 
			
		||||
 */
 | 
			
		||||
/*************************************************************************************************/
 | 
			
		||||
void WsfTimerStartSec(wsfTimer_t *pTimer, wsfTimerTicks_t sec);
 | 
			
		||||
 | 
			
		||||
/*************************************************************************************************/
 | 
			
		||||
/*!
 | 
			
		||||
 *  \fn     WsfTimerStartMs
 | 
			
		||||
 *
 | 
			
		||||
 *  \brief  Start a timer in units of milliseconds.
 | 
			
		||||
 *
 | 
			
		||||
 *  \param  pTimer  Pointer to timer.
 | 
			
		||||
 *  \param  ms      Milliseconds until expiration.
 | 
			
		||||
 *
 | 
			
		||||
 *  \return None.
 | 
			
		||||
 */
 | 
			
		||||
/*************************************************************************************************/
 | 
			
		||||
void WsfTimerStartMs(wsfTimer_t *pTimer, wsfTimerTicks_t ms);
 | 
			
		||||
 | 
			
		||||
/*************************************************************************************************/
 | 
			
		||||
/*!
 | 
			
		||||
 *  \fn     WsfTimerStop
 | 
			
		||||
 *
 | 
			
		||||
 *  \brief  Stop a timer.
 | 
			
		||||
 *
 | 
			
		||||
 *  \param  pTimer  Pointer to timer.
 | 
			
		||||
 *
 | 
			
		||||
 *  \return None.
 | 
			
		||||
 */
 | 
			
		||||
/*************************************************************************************************/
 | 
			
		||||
void WsfTimerStop(wsfTimer_t *pTimer);
 | 
			
		||||
 | 
			
		||||
/*************************************************************************************************/
 | 
			
		||||
/*!
 | 
			
		||||
 *  \fn     WsfTimerUpdate
 | 
			
		||||
 *
 | 
			
		||||
 *  \brief  Update the timer service with the number of elapsed ticks.  This function is
 | 
			
		||||
 *          typically called only from timer porting code.
 | 
			
		||||
 *
 | 
			
		||||
 *  \param  ticks  Number of ticks since last update.
 | 
			
		||||
 *
 | 
			
		||||
 *  \return None.
 | 
			
		||||
 */
 | 
			
		||||
/*************************************************************************************************/
 | 
			
		||||
void WsfTimerUpdate(wsfTimerTicks_t ticks);
 | 
			
		||||
 | 
			
		||||
/*************************************************************************************************/
 | 
			
		||||
/*!
 | 
			
		||||
 *  \fn     WsfTimerNextExpiration
 | 
			
		||||
 *
 | 
			
		||||
 *  \brief  Return the number of ticks until the next timer expiration.  Note that this
 | 
			
		||||
 *          function can return zero even if a timer is running, indicating the timer
 | 
			
		||||
 *          has expired but has not yet been serviced.
 | 
			
		||||
 *
 | 
			
		||||
 *  \param  pTimerRunning   Returns TRUE if a timer is running, FALSE if no timers running.
 | 
			
		||||
 *
 | 
			
		||||
 *  \return The number of ticks until the next timer expiration.
 | 
			
		||||
 */
 | 
			
		||||
/*************************************************************************************************/
 | 
			
		||||
wsfTimerTicks_t WsfTimerNextExpiration(bool_t *pTimerRunning);
 | 
			
		||||
 | 
			
		||||
/*************************************************************************************************/
 | 
			
		||||
/*!
 | 
			
		||||
 *  \fn     WsfTimerServiceExpired
 | 
			
		||||
 *
 | 
			
		||||
 *  \brief  Service expired timers for the given task.  This function is typically called only
 | 
			
		||||
 *          WSF OS porting code.
 | 
			
		||||
 *
 | 
			
		||||
 *  \param  taskId      OS Task ID of task servicing timers.
 | 
			
		||||
 *
 | 
			
		||||
 *  \return Pointer to next expired timer or NULL if there are no expired timers.
 | 
			
		||||
 */
 | 
			
		||||
/*************************************************************************************************/
 | 
			
		||||
wsfTimer_t *WsfTimerServiceExpired(wsfTaskId_t taskId);
 | 
			
		||||
 | 
			
		||||
#ifdef __cplusplus
 | 
			
		||||
};
 | 
			
		||||
#endif
 | 
			
		||||
 | 
			
		||||
#endif /* WSF_TIMER_H */
 | 
			
		||||
| 
						 | 
				
			
			@ -1,39 +0,0 @@
 | 
			
		|||
/*************************************************************************************************/
 | 
			
		||||
/*!
 | 
			
		||||
 *  \file   wsf_mbed_os.h
 | 
			
		||||
 *
 | 
			
		||||
 *  \brief  Mbed OS specific callback.
 | 
			
		||||
 *
 | 
			
		||||
 *  Copyright (c) 2016 ARM, Ltd., all rights reserved.
 | 
			
		||||
 *  ARM confidential and proprietary.
 | 
			
		||||
 *
 | 
			
		||||
 *  IMPORTANT.  Your use of this file is governed by a Software License Agreement
 | 
			
		||||
 *  ("Agreement") that must be accepted in order to download or otherwise receive a
 | 
			
		||||
 *  copy of this file.  You may not use or copy this file for any purpose other than
 | 
			
		||||
 *  as described in the Agreement.  If you do not agree to all of the terms of the
 | 
			
		||||
 *  Agreement do not use this file and delete all copies in your possession or control;
 | 
			
		||||
 *  if you do not have a copy of the Agreement, you must contact Wicentric, Inc. prior
 | 
			
		||||
 *  to any use, copying or further distribution of this software.
 | 
			
		||||
 */
 | 
			
		||||
/*************************************************************************************************/
 | 
			
		||||
#ifndef WSF_MBED_OS_H
 | 
			
		||||
#define WSF_MBED_OS_H
 | 
			
		||||
 | 
			
		||||
#ifdef __cplusplus
 | 
			
		||||
extern "C" {
 | 
			
		||||
#endif
 | 
			
		||||
 | 
			
		||||
/* Register MBED OS SignalEvent */
 | 
			
		||||
void mbedOSRegisterSignalEventCallback(uint32_t (*fnSignalEventInput)(void));
 | 
			
		||||
 | 
			
		||||
/*
 | 
			
		||||
 * Call Mbed OS SignalEvent
 | 
			
		||||
 * This function is called to signal to the user code when a wsf task is ready
 | 
			
		||||
 */
 | 
			
		||||
void mbedOSSignalEventCallback(void);
 | 
			
		||||
 | 
			
		||||
#ifdef __cplusplus
 | 
			
		||||
};
 | 
			
		||||
#endif
 | 
			
		||||
 | 
			
		||||
#endif /* WSF_MBED_OS_H */
 | 
			
		||||
| 
						 | 
				
			
			@ -1,21 +0,0 @@
 | 
			
		|||
/* mbed Microcontroller Library
 | 
			
		||||
 * Copyright (c) 2015 ARM Limited
 | 
			
		||||
 *
 | 
			
		||||
 * Licensed under the Apache License, Version 2.0 (the "License");
 | 
			
		||||
 * you may not use this file except in compliance with the License.
 | 
			
		||||
 * You may obtain a copy of the License at
 | 
			
		||||
 *
 | 
			
		||||
 *     http://www.apache.org/licenses/LICENSE-2.0
 | 
			
		||||
 *
 | 
			
		||||
 * Unless required by applicable law or agreed to in writing, software
 | 
			
		||||
 * distributed under the License is distributed on an "AS IS" BASIS,
 | 
			
		||||
 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
 | 
			
		||||
 * See the License for the specific language governing permissions and
 | 
			
		||||
 * limitations under the License.
 | 
			
		||||
 */
 | 
			
		||||
#ifndef MBED_DEVICE_H
 | 
			
		||||
#define MBED_DEVICE_H
 | 
			
		||||
 | 
			
		||||
#include "objects.h"
 | 
			
		||||
 | 
			
		||||
#endif
 | 
			
		||||
										
											
												File diff suppressed because it is too large
												Load Diff
											
										
									
								
							| 
						 | 
				
			
			@ -1,46 +0,0 @@
 | 
			
		|||
#! armcc -E;
 | 
			
		||||
/*
 | 
			
		||||
; * BEETLE CMSIS Library
 | 
			
		||||
; */
 | 
			
		||||
;/*
 | 
			
		||||
; * Copyright (c) 2009-2016 ARM Limited. All rights reserved.
 | 
			
		||||
; *
 | 
			
		||||
; * SPDX-License-Identifier: Apache-2.0
 | 
			
		||||
; *
 | 
			
		||||
; * Licensed under the Apache License, Version 2.0 (the License); you may
 | 
			
		||||
; * not use this file except in compliance with the License.
 | 
			
		||||
; * You may obtain a copy of the License at
 | 
			
		||||
; *
 | 
			
		||||
; * http://www.apache.org/licenses/LICENSE-2.0
 | 
			
		||||
; *
 | 
			
		||||
; * Unless required by applicable law or agreed to in writing, software
 | 
			
		||||
; * distributed under the License is distributed on an AS IS BASIS, WITHOUT
 | 
			
		||||
; * WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
 | 
			
		||||
; * See the License for the specific language governing permissions and
 | 
			
		||||
; * limitations under the License.
 | 
			
		||||
; */
 | 
			
		||||
; *************************************************************
 | 
			
		||||
; *** Scatter-Loading Description File                      ***
 | 
			
		||||
; *************************************************************
 | 
			
		||||
 | 
			
		||||
#if !defined(MBED_BOOT_STACK_SIZE)
 | 
			
		||||
  #define MBED_BOOT_STACK_SIZE 0x400
 | 
			
		||||
#endif
 | 
			
		||||
 | 
			
		||||
#define Stack_Size MBED_BOOT_STACK_SIZE
 | 
			
		||||
 | 
			
		||||
LR_IROM1 0x00000000 0x00040000  {    ; load region size_region
 | 
			
		||||
  ER_IROM1 0x00000000 0x00040000  {  ; load address = execution address
 | 
			
		||||
   *.o (RESET, +FIRST)
 | 
			
		||||
   *(InRoot$$Sections)
 | 
			
		||||
   .ANY (+RO)
 | 
			
		||||
   CORDIO_RO_2.1.o (*)
 | 
			
		||||
  }
 | 
			
		||||
  ; Total: 80 vectors = 320 bytes (0x140) to be reserved in RAM
 | 
			
		||||
  RW_IRAM1 (0x20000000+0x140) (0x20000-0x140-Stack_Size)  {  ; RW data
 | 
			
		||||
   .ANY (+RW +ZI)
 | 
			
		||||
  }
 | 
			
		||||
  
 | 
			
		||||
  ARM_LIB_STACK (0x20000000+0x20000) EMPTY -Stack_Size { ; stack
 | 
			
		||||
  }
 | 
			
		||||
}
 | 
			
		||||
| 
						 | 
				
			
			@ -1,268 +0,0 @@
 | 
			
		|||
;/*
 | 
			
		||||
; * BEETLE CMSIS Library
 | 
			
		||||
; */
 | 
			
		||||
;/*
 | 
			
		||||
; * Copyright (c) 2009-2016 ARM Limited. All rights reserved.
 | 
			
		||||
; *
 | 
			
		||||
; * SPDX-License-Identifier: Apache-2.0
 | 
			
		||||
; *
 | 
			
		||||
; * Licensed under the Apache License, Version 2.0 (the License); you may
 | 
			
		||||
; * not use this file except in compliance with the License.
 | 
			
		||||
; * You may obtain a copy of the License at
 | 
			
		||||
; *
 | 
			
		||||
; * http://www.apache.org/licenses/LICENSE-2.0
 | 
			
		||||
; *
 | 
			
		||||
; * Unless required by applicable law or agreed to in writing, software
 | 
			
		||||
; * distributed under the License is distributed on an AS IS BASIS, WITHOUT
 | 
			
		||||
; * WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
 | 
			
		||||
; * See the License for the specific language governing permissions and
 | 
			
		||||
; * limitations under the License.
 | 
			
		||||
; */
 | 
			
		||||
;
 | 
			
		||||
; This file is derivative of CMSIS V5.00 startup_ARMCM3.s
 | 
			
		||||
;
 | 
			
		||||
;/*
 | 
			
		||||
;//-------- <<< Use Configuration Wizard in Context Menu >>> ------------------
 | 
			
		||||
;*/
 | 
			
		||||
 | 
			
		||||
 | 
			
		||||
__initial_sp        EQU     0x20020000  ; Top of RAM
 | 
			
		||||
 | 
			
		||||
                PRESERVE8
 | 
			
		||||
                THUMB
 | 
			
		||||
 | 
			
		||||
 | 
			
		||||
; Vector Table Mapped to Address 0 at Reset
 | 
			
		||||
 | 
			
		||||
                AREA    RESET, DATA, READONLY
 | 
			
		||||
                EXPORT  __Vectors
 | 
			
		||||
                EXPORT  __Vectors_End
 | 
			
		||||
                EXPORT  __Vectors_Size
 | 
			
		||||
 | 
			
		||||
__Vectors       DCD     __initial_sp              ; Top of Stack
 | 
			
		||||
                DCD     Reset_Handler             ; Reset Handler
 | 
			
		||||
                DCD     NMI_Handler               ; NMI Handler
 | 
			
		||||
                DCD     HardFault_Handler         ; Hard Fault Handler
 | 
			
		||||
                DCD     MemManage_Handler         ; MPU Fault Handler
 | 
			
		||||
                DCD     BusFault_Handler          ; Bus Fault Handler
 | 
			
		||||
                DCD     UsageFault_Handler        ; Usage Fault Handler
 | 
			
		||||
                DCD     0                         ; Reserved
 | 
			
		||||
                DCD     0                         ; Reserved
 | 
			
		||||
                DCD     0                         ; Reserved
 | 
			
		||||
                DCD     0                         ; Reserved
 | 
			
		||||
                DCD     SVC_Handler               ; SVCall Handler
 | 
			
		||||
                DCD     DebugMon_Handler          ; Debug Monitor Handler
 | 
			
		||||
                DCD     0                         ; Reserved
 | 
			
		||||
                DCD     PendSV_Handler            ; PendSV Handler
 | 
			
		||||
                DCD     SysTick_Handler           ; SysTick Handler
 | 
			
		||||
 | 
			
		||||
                ; External Interrupts
 | 
			
		||||
                DCD     UART0_Handler             ; UART 0 RX and TX Handler
 | 
			
		||||
                DCD     Spare_IRQ_Handler         ; Undefined
 | 
			
		||||
                DCD     UART1_Handler             ; UART 1 RX and TX Handler
 | 
			
		||||
                DCD     I2C0_Handler              ; I2C 0 Handler
 | 
			
		||||
                DCD     I2C1_Handler              ; I2C 1 Handler
 | 
			
		||||
                DCD     RTC_Handler               ; RTC Handler
 | 
			
		||||
                DCD     PORT0_COMB_Handler        ; GPIO Port 0 Combined Handler
 | 
			
		||||
                DCD     PORT1_COMB_Handler        ; GPIO Port 1 Combined Handler
 | 
			
		||||
                DCD     TIMER0_Handler            ; TIMER 0 handler
 | 
			
		||||
                DCD     TIMER1_Handler            ; TIMER 1 handler
 | 
			
		||||
                DCD     DUALTIMER_HANDLER         ; Dual timer handler
 | 
			
		||||
                DCD     SPI0_Handler              ; SPI 0 Handler
 | 
			
		||||
                DCD     UARTOVF_Handler           ; UART 0,1 Overflow Handler
 | 
			
		||||
                DCD     SPI1_Handler              ; SPI 1 Handler
 | 
			
		||||
                DCD     QSPI_Handler              ; QSPI Handler
 | 
			
		||||
                DCD     DMA_Handler               ; DMA handler
 | 
			
		||||
                DCD     PORT0_0_Handler           ; GPIO Port 0 pin 0 Handler
 | 
			
		||||
                DCD     PORT0_1_Handler           ; GPIO Port 0 pin 1 Handler
 | 
			
		||||
                DCD     PORT0_2_Handler           ; GPIO Port 0 pin 2 Handler
 | 
			
		||||
                DCD     PORT0_3_Handler           ; GPIO Port 0 pin 3 Handler
 | 
			
		||||
                DCD     PORT0_4_Handler           ; GPIO Port 0 pin 4 Handler
 | 
			
		||||
                DCD     PORT0_5_Handler           ; GPIO Port 0 pin 5 Handler
 | 
			
		||||
                DCD     PORT0_6_Handler           ; GPIO Port 0 pin 6 Handler
 | 
			
		||||
                DCD     PORT0_7_Handler           ; GPIO Port 0 pin 7 Handler
 | 
			
		||||
                DCD     PORT0_8_Handler           ; GPIO Port 0 pin 8 Handler
 | 
			
		||||
                DCD     PORT0_9_Handler           ; GPIO Port 0 pin 9 Handler
 | 
			
		||||
                DCD     PORT0_10_Handler          ; GPIO Port 0 pin 10 Handler
 | 
			
		||||
                DCD     PORT0_11_Handler          ; GPIO Port 0 pin 11 Handler
 | 
			
		||||
                DCD     PORT0_12_Handler          ; GPIO Port 0 pin 12 Handler
 | 
			
		||||
                DCD     PORT0_13_Handler          ; GPIO Port 0 pin 13 Handler
 | 
			
		||||
                DCD     PORT0_14_Handler          ; GPIO Port 0 pin 14 Handler
 | 
			
		||||
                DCD     PORT0_15_Handler          ; GPIO Port 0 pin 15 Handler
 | 
			
		||||
                DCD     SysError_Handler          ; System Error (Flash Cache)
 | 
			
		||||
                DCD     EFLASH_Handler            ; Embedded Flash
 | 
			
		||||
                DCD     LLCC_TXCMD_EMPTY_Handler  ; LLCC_TXCMDIRQ
 | 
			
		||||
                DCD     LLCC_TXEVT_EMPTY_Handler  ; LLCC_TXEVTIRQ
 | 
			
		||||
                DCD     LLCC_TXDMAH_DONE_Handler  ; LLCC_TXDMA0IRQ
 | 
			
		||||
                DCD     LLCC_TXDMAL_DONE_Handler  ; LLCC_TXDMA1IRQ
 | 
			
		||||
                DCD     LLCC_RXCMD_VALID_Handler  ; LLCC_RXCMDIRQ
 | 
			
		||||
                DCD     LLCC_RXEVT_VALID_Handler  ; LLCC_RXEVTIRQ
 | 
			
		||||
                DCD     LLCC_RXDMAH_DONE_Handler  ; LLCC_RXDMA0IRQ
 | 
			
		||||
                DCD     LLCC_RXDMAL_DONE_Handler  ; LLCC_RXDMA1IRQ
 | 
			
		||||
                DCD     PORT2_COMB_Handler        ; GPIO 2
 | 
			
		||||
                DCD     PORT3_COMB_Handler        ; GPIO 3
 | 
			
		||||
                DCD     TRNG_Handler              ; TRNG
 | 
			
		||||
__Vectors_End
 | 
			
		||||
 | 
			
		||||
__Vectors_Size  EQU     __Vectors_End - __Vectors
 | 
			
		||||
 | 
			
		||||
                AREA    |.text|, CODE, READONLY
 | 
			
		||||
 | 
			
		||||
 | 
			
		||||
; Reset Handler
 | 
			
		||||
 | 
			
		||||
Reset_Handler   PROC
 | 
			
		||||
                EXPORT  Reset_Handler             [WEAK]
 | 
			
		||||
                IMPORT  SystemInit
 | 
			
		||||
                IMPORT  __main
 | 
			
		||||
                LDR     R0, =SystemInit
 | 
			
		||||
                BLX     R0
 | 
			
		||||
                LDR     R0, =__main
 | 
			
		||||
                BX      R0
 | 
			
		||||
                ENDP
 | 
			
		||||
 | 
			
		||||
 | 
			
		||||
; Dummy Exception Handlers (infinite loops which can be modified)
 | 
			
		||||
 | 
			
		||||
NMI_Handler     PROC
 | 
			
		||||
                EXPORT  NMI_Handler               [WEAK]
 | 
			
		||||
                B       .
 | 
			
		||||
                ENDP
 | 
			
		||||
HardFault_Handler\
 | 
			
		||||
                PROC
 | 
			
		||||
                EXPORT  HardFault_Handler         [WEAK]
 | 
			
		||||
                B       .
 | 
			
		||||
                ENDP
 | 
			
		||||
MemManage_Handler\
 | 
			
		||||
                PROC
 | 
			
		||||
                EXPORT  MemManage_Handler         [WEAK]
 | 
			
		||||
                B       .
 | 
			
		||||
                ENDP
 | 
			
		||||
BusFault_Handler\
 | 
			
		||||
                PROC
 | 
			
		||||
                EXPORT  BusFault_Handler          [WEAK]
 | 
			
		||||
                B       .
 | 
			
		||||
                ENDP
 | 
			
		||||
UsageFault_Handler\
 | 
			
		||||
                PROC
 | 
			
		||||
                EXPORT  UsageFault_Handler        [WEAK]
 | 
			
		||||
                B       .
 | 
			
		||||
                ENDP
 | 
			
		||||
SVC_Handler     PROC
 | 
			
		||||
                EXPORT  SVC_Handler               [WEAK]
 | 
			
		||||
                B       .
 | 
			
		||||
                ENDP
 | 
			
		||||
DebugMon_Handler\
 | 
			
		||||
                PROC
 | 
			
		||||
                EXPORT  DebugMon_Handler          [WEAK]
 | 
			
		||||
                B       .
 | 
			
		||||
                ENDP
 | 
			
		||||
PendSV_Handler  PROC
 | 
			
		||||
                EXPORT  PendSV_Handler            [WEAK]
 | 
			
		||||
                B       .
 | 
			
		||||
                ENDP
 | 
			
		||||
SysTick_Handler PROC
 | 
			
		||||
                EXPORT  SysTick_Handler           [WEAK]
 | 
			
		||||
                B       .
 | 
			
		||||
                ENDP
 | 
			
		||||
 | 
			
		||||
Default_Handler PROC
 | 
			
		||||
                EXPORT UART0_Handler              [WEAK]
 | 
			
		||||
                EXPORT Spare_IRQ_Handler          [WEAK]
 | 
			
		||||
                EXPORT UART1_Handler              [WEAK]
 | 
			
		||||
                EXPORT I2C0_Handler               [WEAK]
 | 
			
		||||
                EXPORT I2C1_Handler               [WEAK]
 | 
			
		||||
                EXPORT RTC_Handler                [WEAK]
 | 
			
		||||
                EXPORT PORT0_COMB_Handler         [WEAK]
 | 
			
		||||
                EXPORT PORT1_COMB_Handler         [WEAK]
 | 
			
		||||
                EXPORT TIMER0_Handler             [WEAK]
 | 
			
		||||
                EXPORT TIMER1_Handler             [WEAK]
 | 
			
		||||
                EXPORT DUALTIMER_HANDLER          [WEAK]
 | 
			
		||||
                EXPORT SPI0_Handler               [WEAK]
 | 
			
		||||
                EXPORT UARTOVF_Handler            [WEAK]
 | 
			
		||||
                EXPORT SPI1_Handler               [WEAK]
 | 
			
		||||
                EXPORT QSPI_Handler               [WEAK]
 | 
			
		||||
                EXPORT DMA_Handler                [WEAK]
 | 
			
		||||
                EXPORT PORT0_0_Handler            [WEAK]
 | 
			
		||||
                EXPORT PORT0_1_Handler            [WEAK]
 | 
			
		||||
                EXPORT PORT0_2_Handler            [WEAK]
 | 
			
		||||
                EXPORT PORT0_3_Handler            [WEAK]
 | 
			
		||||
                EXPORT PORT0_4_Handler            [WEAK]
 | 
			
		||||
                EXPORT PORT0_5_Handler            [WEAK]
 | 
			
		||||
                EXPORT PORT0_6_Handler            [WEAK]
 | 
			
		||||
                EXPORT PORT0_7_Handler            [WEAK]
 | 
			
		||||
                EXPORT PORT0_8_Handler            [WEAK]
 | 
			
		||||
                EXPORT PORT0_9_Handler            [WEAK]
 | 
			
		||||
                EXPORT PORT0_10_Handler           [WEAK]
 | 
			
		||||
                EXPORT PORT0_11_Handler           [WEAK]
 | 
			
		||||
                EXPORT PORT0_12_Handler           [WEAK]
 | 
			
		||||
                EXPORT PORT0_13_Handler           [WEAK]
 | 
			
		||||
                EXPORT PORT0_14_Handler           [WEAK]
 | 
			
		||||
                EXPORT PORT0_15_Handler           [WEAK]
 | 
			
		||||
                EXPORT SysError_Handler           [WEAK]
 | 
			
		||||
                EXPORT EFLASH_Handler             [WEAK]
 | 
			
		||||
                EXPORT LLCC_TXEVT_EMPTY_Handler   [WEAK]
 | 
			
		||||
                EXPORT LLCC_TXCMD_EMPTY_Handler   [WEAK]
 | 
			
		||||
                EXPORT LLCC_RXEVT_VALID_Handler   [WEAK]
 | 
			
		||||
                EXPORT LLCC_RXCMD_VALID_Handler   [WEAK]
 | 
			
		||||
                EXPORT LLCC_TXDMAL_DONE_Handler   [WEAK]
 | 
			
		||||
                EXPORT LLCC_RXDMAL_DONE_Handler   [WEAK]
 | 
			
		||||
                EXPORT LLCC_TXDMAH_DONE_Handler   [WEAK]
 | 
			
		||||
                EXPORT LLCC_RXDMAH_DONE_Handler   [WEAK]
 | 
			
		||||
                EXPORT PORT2_COMB_Handler         [WEAK]
 | 
			
		||||
                EXPORT PORT3_COMB_Handler         [WEAK]
 | 
			
		||||
                EXPORT TRNG_Handler               [WEAK]
 | 
			
		||||
 | 
			
		||||
UART0_Handler
 | 
			
		||||
Spare_IRQ_Handler
 | 
			
		||||
UART1_Handler
 | 
			
		||||
I2C0_Handler
 | 
			
		||||
I2C1_Handler
 | 
			
		||||
RTC_Handler
 | 
			
		||||
PORT0_COMB_Handler
 | 
			
		||||
PORT1_COMB_Handler
 | 
			
		||||
TIMER0_Handler
 | 
			
		||||
TIMER1_Handler
 | 
			
		||||
DUALTIMER_HANDLER
 | 
			
		||||
SPI0_Handler
 | 
			
		||||
UARTOVF_Handler
 | 
			
		||||
SPI1_Handler
 | 
			
		||||
QSPI_Handler
 | 
			
		||||
DMA_Handler
 | 
			
		||||
PORT0_0_Handler
 | 
			
		||||
PORT0_1_Handler
 | 
			
		||||
PORT0_2_Handler
 | 
			
		||||
PORT0_3_Handler
 | 
			
		||||
PORT0_4_Handler
 | 
			
		||||
PORT0_5_Handler
 | 
			
		||||
PORT0_6_Handler
 | 
			
		||||
PORT0_7_Handler
 | 
			
		||||
PORT0_8_Handler
 | 
			
		||||
PORT0_9_Handler
 | 
			
		||||
PORT0_10_Handler
 | 
			
		||||
PORT0_11_Handler
 | 
			
		||||
PORT0_12_Handler
 | 
			
		||||
PORT0_13_Handler
 | 
			
		||||
PORT0_14_Handler
 | 
			
		||||
PORT0_15_Handler
 | 
			
		||||
SysError_Handler
 | 
			
		||||
EFLASH_Handler
 | 
			
		||||
LLCC_TXEVT_EMPTY_Handler
 | 
			
		||||
LLCC_TXCMD_EMPTY_Handler
 | 
			
		||||
LLCC_RXEVT_VALID_Handler
 | 
			
		||||
LLCC_RXCMD_VALID_Handler
 | 
			
		||||
LLCC_TXDMAL_DONE_Handler
 | 
			
		||||
LLCC_RXDMAL_DONE_Handler
 | 
			
		||||
LLCC_TXDMAH_DONE_Handler
 | 
			
		||||
LLCC_RXDMAH_DONE_Handler
 | 
			
		||||
PORT2_COMB_Handler
 | 
			
		||||
PORT3_COMB_Handler
 | 
			
		||||
TRNG_Handler
 | 
			
		||||
                B       .
 | 
			
		||||
 | 
			
		||||
                ENDP
 | 
			
		||||
 | 
			
		||||
 | 
			
		||||
                ALIGN
 | 
			
		||||
 | 
			
		||||
                END
 | 
			
		||||
| 
						 | 
				
			
			@ -1,222 +0,0 @@
 | 
			
		|||
/*
 | 
			
		||||
 * BEETLE CMSIS Library
 | 
			
		||||
 */
 | 
			
		||||
/*
 | 
			
		||||
 * Copyright (c) 2009-2016 ARM Limited. All rights reserved.
 | 
			
		||||
 *
 | 
			
		||||
 * SPDX-License-Identifier: Apache-2.0
 | 
			
		||||
 *
 | 
			
		||||
 * Licensed under the Apache License, Version 2.0 (the License); you may
 | 
			
		||||
 * not use this file except in compliance with the License.
 | 
			
		||||
 * You may obtain a copy of the License at
 | 
			
		||||
 *
 | 
			
		||||
 * http://www.apache.org/licenses/LICENSE-2.0
 | 
			
		||||
 *
 | 
			
		||||
 * Unless required by applicable law or agreed to in writing, software
 | 
			
		||||
 * distributed under the License is distributed on an AS IS BASIS, WITHOUT
 | 
			
		||||
 * WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
 | 
			
		||||
 * See the License for the specific language governing permissions and
 | 
			
		||||
 * limitations under the License.
 | 
			
		||||
 */
 | 
			
		||||
/*
 | 
			
		||||
 * This file is derivative of CMSIS V5.00 gcc_arm.ld
 | 
			
		||||
 */
 | 
			
		||||
/* Linker script for mbed BEETLE SoC */
 | 
			
		||||
 | 
			
		||||
/* Linker script to configure memory regions. */
 | 
			
		||||
MEMORY
 | 
			
		||||
{
 | 
			
		||||
  VECTORS (rx)          : ORIGIN = 0x00000000, LENGTH = 0x00000400
 | 
			
		||||
  FLASH (rx)            : ORIGIN = 0x00000400, LENGTH = 0x00040000 - 0x00000400
 | 
			
		||||
  RAM (rwx)             : ORIGIN = 0x20000000, LENGTH = 0x00020000
 | 
			
		||||
}
 | 
			
		||||
 | 
			
		||||
/* Linker script to place sections and symbol values. Should be used together
 | 
			
		||||
 * with other linker script that defines memory regions FLASH and RAM.
 | 
			
		||||
 * It references following symbols, which must be defined in code:
 | 
			
		||||
 *   Reset_Handler : Entry of reset handler
 | 
			
		||||
 *
 | 
			
		||||
 * It defines following symbols, which code can use without definition:
 | 
			
		||||
 *   __exidx_start
 | 
			
		||||
 *   __exidx_end
 | 
			
		||||
 *   __etext
 | 
			
		||||
 *   __data_start__
 | 
			
		||||
 *   __preinit_array_start
 | 
			
		||||
 *   __preinit_array_end
 | 
			
		||||
 *   __init_array_start
 | 
			
		||||
 *   __init_array_end
 | 
			
		||||
 *   __fini_array_start
 | 
			
		||||
 *   __fini_array_end
 | 
			
		||||
 *   __data_end__
 | 
			
		||||
 *   __bss_start__
 | 
			
		||||
 *   __bss_end__
 | 
			
		||||
 *   __end__
 | 
			
		||||
 *   end
 | 
			
		||||
 *   __HeapLimit
 | 
			
		||||
 *   __StackLimit
 | 
			
		||||
 *   __StackTop
 | 
			
		||||
 *   __stack
 | 
			
		||||
 */
 | 
			
		||||
ENTRY(Reset_Handler)
 | 
			
		||||
 | 
			
		||||
#if !defined(MBED_BOOT_STACK_SIZE)
 | 
			
		||||
    #define MBED_BOOT_STACK_SIZE 0x400
 | 
			
		||||
#endif
 | 
			
		||||
 | 
			
		||||
__stack_size__ = MBED_BOOT_STACK_SIZE;
 | 
			
		||||
__heap_size__ = 0x8000;
 | 
			
		||||
 | 
			
		||||
HEAP_SIZE  = DEFINED(__heap_size__)  ? __heap_size__  : 0x0400;
 | 
			
		||||
STACK_SIZE = DEFINED(__stack_size__) ? __stack_size__ : 0x0400;
 | 
			
		||||
 | 
			
		||||
/* Size of the vector table in SRAM */
 | 
			
		||||
M_VECTOR_RAM_SIZE = 0x140;
 | 
			
		||||
 | 
			
		||||
SECTIONS
 | 
			
		||||
{
 | 
			
		||||
    .isr_vector :
 | 
			
		||||
    {
 | 
			
		||||
        __vector_table = .;
 | 
			
		||||
        KEEP(*(.vector_table))
 | 
			
		||||
         . = ALIGN(8);
 | 
			
		||||
    } > VECTORS
 | 
			
		||||
 | 
			
		||||
    .text :
 | 
			
		||||
    {
 | 
			
		||||
        *(.text*)
 | 
			
		||||
 | 
			
		||||
        KEEP(*(.init))
 | 
			
		||||
        KEEP(*(.fini))
 | 
			
		||||
 | 
			
		||||
        /* .ctors */
 | 
			
		||||
        *crtbegin.o(.ctors)
 | 
			
		||||
        *crtbegin?.o(.ctors)
 | 
			
		||||
        *(EXCLUDE_FILE(*crtend?.o *crtend.o) .ctors)
 | 
			
		||||
        *(SORT(.ctors.*))
 | 
			
		||||
        *(.ctors)
 | 
			
		||||
 | 
			
		||||
        /* .dtors */
 | 
			
		||||
        *crtbegin.o(.dtors)
 | 
			
		||||
        *crtbegin?.o(.dtors)
 | 
			
		||||
        *(EXCLUDE_FILE(*crtend?.o *crtend.o) .dtors)
 | 
			
		||||
        *(SORT(.dtors.*))
 | 
			
		||||
        *(.dtors)
 | 
			
		||||
 | 
			
		||||
        *(.rodata*)
 | 
			
		||||
 | 
			
		||||
        KEEP(*(.eh_frame*))
 | 
			
		||||
    } > FLASH
 | 
			
		||||
 | 
			
		||||
    .ARM.extab :
 | 
			
		||||
    {
 | 
			
		||||
        *(.ARM.extab* .gnu.linkonce.armextab.*)
 | 
			
		||||
    } > FLASH
 | 
			
		||||
 | 
			
		||||
    __exidx_start = .;
 | 
			
		||||
    .ARM.exidx :
 | 
			
		||||
    {
 | 
			
		||||
        *(.ARM.exidx* .gnu.linkonce.armexidx.*)
 | 
			
		||||
    } > FLASH
 | 
			
		||||
    __exidx_end = .;
 | 
			
		||||
 | 
			
		||||
    .cordio :
 | 
			
		||||
    {
 | 
			
		||||
        *CORDIO_RO_2.1.o
 | 
			
		||||
        *TRIM_2.1.o
 | 
			
		||||
    } > FLASH
 | 
			
		||||
 | 
			
		||||
    .interrupts_ram :
 | 
			
		||||
    {
 | 
			
		||||
        . = ALIGN(8);
 | 
			
		||||
        __VECTOR_RAM__ = .;
 | 
			
		||||
        __interrupts_ram_start__ = .;   /* Create a global symbol at data start */
 | 
			
		||||
        . += M_VECTOR_RAM_SIZE;
 | 
			
		||||
        . = ALIGN(8);
 | 
			
		||||
        __interrupts_ram_end__ = .;     /* Define a global symbol at data end */
 | 
			
		||||
    } > RAM
 | 
			
		||||
 | 
			
		||||
    .data :
 | 
			
		||||
    {
 | 
			
		||||
        PROVIDE(__etext = LOADADDR(.data));
 | 
			
		||||
        . = ALIGN(8);
 | 
			
		||||
        __data_start__ = .;
 | 
			
		||||
        *(vtable)
 | 
			
		||||
        *(.data)
 | 
			
		||||
        *(.data*)
 | 
			
		||||
 | 
			
		||||
        . = ALIGN(8);
 | 
			
		||||
        /* preinit data */
 | 
			
		||||
        PROVIDE (__preinit_array_start = .);
 | 
			
		||||
        KEEP(*(.preinit_array))
 | 
			
		||||
        PROVIDE (__preinit_array_end = .);
 | 
			
		||||
 | 
			
		||||
        . = ALIGN(8);
 | 
			
		||||
        /* init data */
 | 
			
		||||
        PROVIDE (__init_array_start = .);
 | 
			
		||||
        KEEP(*(SORT(.init_array.*)))
 | 
			
		||||
        KEEP(*(.init_array))
 | 
			
		||||
        PROVIDE (__init_array_end = .);
 | 
			
		||||
 | 
			
		||||
 | 
			
		||||
        . = ALIGN(8);
 | 
			
		||||
        /* finit data */
 | 
			
		||||
        PROVIDE (__fini_array_start = .);
 | 
			
		||||
        KEEP(*(SORT(.fini_array.*)))
 | 
			
		||||
        KEEP(*(.fini_array))
 | 
			
		||||
        PROVIDE (__fini_array_end = .);
 | 
			
		||||
 | 
			
		||||
        . = ALIGN(8);
 | 
			
		||||
        /* All data end */
 | 
			
		||||
        __data_end__ = .;
 | 
			
		||||
 | 
			
		||||
    } > RAM AT > FLASH
 | 
			
		||||
 | 
			
		||||
    /* From now on you can insert any other SRAM region. */
 | 
			
		||||
 | 
			
		||||
    .uninitialized (NOLOAD):
 | 
			
		||||
    {
 | 
			
		||||
        . = ALIGN(32);
 | 
			
		||||
        __uninitialized_start = .;
 | 
			
		||||
        *(.uninitialized)
 | 
			
		||||
        KEEP(*(.keep.uninitialized))
 | 
			
		||||
        . = ALIGN(32);
 | 
			
		||||
        __uninitialized_end = .;
 | 
			
		||||
    } > RAM
 | 
			
		||||
 | 
			
		||||
    .bss :
 | 
			
		||||
    {
 | 
			
		||||
        . = ALIGN(8);
 | 
			
		||||
        __START_BSS = .;
 | 
			
		||||
        __bss_start__ = .;
 | 
			
		||||
        *(.bss)
 | 
			
		||||
        *(.bss*)
 | 
			
		||||
        *(COMMON)
 | 
			
		||||
        . = ALIGN(8);
 | 
			
		||||
        __bss_end__ = .;
 | 
			
		||||
        __END_BSS = .;
 | 
			
		||||
 | 
			
		||||
    } > RAM
 | 
			
		||||
 | 
			
		||||
    bss_size = __bss_end__ - __bss_start__;
 | 
			
		||||
 | 
			
		||||
    .heap :
 | 
			
		||||
    {
 | 
			
		||||
        . = ALIGN(8);
 | 
			
		||||
        __end__ = .;
 | 
			
		||||
        PROVIDE(end = .);
 | 
			
		||||
        __HeapBase = .;
 | 
			
		||||
        . = ORIGIN(RAM) + LENGTH(RAM) - STACK_SIZE;
 | 
			
		||||
        __HeapLimit = .;
 | 
			
		||||
        __heap_limit = .; /* Add for _sbrk */
 | 
			
		||||
    } > RAM
 | 
			
		||||
 | 
			
		||||
    /* Set stack top to end of RAM, and stack limit move down by
 | 
			
		||||
     * size of stack_dummy section */
 | 
			
		||||
    __StackTop = ORIGIN(RAM) + LENGTH(RAM);
 | 
			
		||||
    __StackLimit = __StackTop - STACK_SIZE;
 | 
			
		||||
    PROVIDE(__stack = __StackTop);
 | 
			
		||||
 | 
			
		||||
    /* Check if data + heap + stack exceeds RAM limit */
 | 
			
		||||
    ASSERT(__StackLimit >= __HeapLimit, "region RAM overflowed with stack")
 | 
			
		||||
 | 
			
		||||
}   /* End of sections */
 | 
			
		||||
| 
						 | 
				
			
			@ -1,233 +0,0 @@
 | 
			
		|||
/*
 | 
			
		||||
 * BEETLE CMSIS Library
 | 
			
		||||
 */
 | 
			
		||||
/*
 | 
			
		||||
 * Copyright (c) 2009-2016 ARM Limited. All rights reserved.
 | 
			
		||||
 *
 | 
			
		||||
 * SPDX-License-Identifier: Apache-2.0
 | 
			
		||||
 *
 | 
			
		||||
 * Licensed under the Apache License, Version 2.0 (the License); you may
 | 
			
		||||
 * not use this file except in compliance with the License.
 | 
			
		||||
 * You may obtain a copy of the License at
 | 
			
		||||
 *
 | 
			
		||||
 * http://www.apache.org/licenses/LICENSE-2.0
 | 
			
		||||
 *
 | 
			
		||||
 * Unless required by applicable law or agreed to in writing, software
 | 
			
		||||
 * distributed under the License is distributed on an AS IS BASIS, WITHOUT
 | 
			
		||||
 * WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
 | 
			
		||||
 * See the License for the specific language governing permissions and
 | 
			
		||||
 * limitations under the License.
 | 
			
		||||
 */
 | 
			
		||||
/*
 | 
			
		||||
 * This file is derivative of CMSIS V5.00 startup_ARMCM3.S
 | 
			
		||||
 */
 | 
			
		||||
    .syntax unified
 | 
			
		||||
    .arch armv7-m
 | 
			
		||||
 | 
			
		||||
    .section .vector_table,"a",%progbits
 | 
			
		||||
    .align 2
 | 
			
		||||
    .globl __isr_vector
 | 
			
		||||
__isr_vector:
 | 
			
		||||
    .long    __StackTop            /* Top of Stack */
 | 
			
		||||
    .long    Reset_Handler         /* Reset Handler */
 | 
			
		||||
    .long    NMI_Handler           /* NMI Handler */
 | 
			
		||||
    .long    HardFault_Handler     /* Hard Fault Handler */
 | 
			
		||||
    .long    MemManage_Handler     /* MPU Fault Handler */
 | 
			
		||||
    .long    BusFault_Handler      /* Bus Fault Handler */
 | 
			
		||||
    .long    UsageFault_Handler    /* Usage Fault Handler */
 | 
			
		||||
    .long    0                     /* Reserved */
 | 
			
		||||
    .long    0                     /* Reserved */
 | 
			
		||||
    .long    0                     /* Reserved */
 | 
			
		||||
    .long    0                     /* Reserved */
 | 
			
		||||
    .long    SVC_Handler           /* SVCall Handler */
 | 
			
		||||
    .long    DebugMon_Handler      /* Debug Monitor Handler */
 | 
			
		||||
    .long    0                     /* Reserved */
 | 
			
		||||
    .long    PendSV_Handler        /* PendSV Handler */
 | 
			
		||||
    .long    SysTick_Handler       /* SysTick Handler */
 | 
			
		||||
 | 
			
		||||
    /* External interrupts */
 | 
			
		||||
    .long    UART0_Handler       /* 0:UART 0 RX and TX Combined Interrupt        */
 | 
			
		||||
    .long    Spare_Handler       /* 1:Undefined                                  */
 | 
			
		||||
    .long    UART1_Handler       /* 2:UART 1 RX and TX Combined Interrupt        */
 | 
			
		||||
    .long    I2C0_Handler        /* 3:I2C 0 Interrupt                            */
 | 
			
		||||
    .long    I2C1_Handler        /* 4:I2C 1 Interrupt                            */
 | 
			
		||||
    .long    RTC_Handler         /* 5:RTC Interrupt                              */
 | 
			
		||||
    .long    PORT0_Handler       /* 6:GPIO Port 0 combined Interrupt             */
 | 
			
		||||
    .long    PORT1_ALL_Handler   /* 7:GPIO Port 1 combined Interrupt             */
 | 
			
		||||
    .long    TIMER0_Handler      /* 8:TIMER 0 Interrupt                          */
 | 
			
		||||
    .long    TIMER1_Handler      /* 9:TIMER 1 Interrupt                          */
 | 
			
		||||
    .long    DUALTIMER_Handler   /* 10:Dual Timer Interrupt                      */
 | 
			
		||||
    .long    SPI0_Handler        /* 11:SPI 0 Interrupt                           */
 | 
			
		||||
    .long    UARTOVF_Handler     /* 12:UART 0,1,2 Overflow Interrupt             */
 | 
			
		||||
    .long    SPI1_Handler        /* 13:SPI 1 Interrupt                           */
 | 
			
		||||
    .long    QSPI_Handler        /* 14:QUAD SPI Interrupt                        */
 | 
			
		||||
    .long    DMA_Handler         /* 15:Touch Screen Interrupt                    */
 | 
			
		||||
    .long    PORT0_0_Handler     /* 16:All P0 and P1I/O pins used as irq source  */
 | 
			
		||||
    .long    PORT0_1_Handler     /* 17:There are 16 pins in total                */
 | 
			
		||||
    .long    PORT0_2_Handler     /* 18:                                          */
 | 
			
		||||
    .long    PORT0_3_Handler     /* 19:                                          */
 | 
			
		||||
    .long    PORT0_4_Handler     /* 20:                                          */
 | 
			
		||||
    .long    PORT0_5_Handler     /* 21:                                          */
 | 
			
		||||
    .long    PORT0_6_Handler     /* 22:                                          */
 | 
			
		||||
    .long    PORT0_7_Handler     /* 23:                                          */
 | 
			
		||||
    .long    PORT0_8_Handler     /* 24:                                          */
 | 
			
		||||
    .long    PORT0_9_Handler     /* 25:                                          */
 | 
			
		||||
    .long    PORT0_10_Handler    /* 26:                                          */
 | 
			
		||||
    .long    PORT0_11_Handler    /* 27:                                          */
 | 
			
		||||
    .long    PORT0_12_Handler    /* 28:                                          */
 | 
			
		||||
    .long    PORT0_13_Handler    /* 29:                                          */
 | 
			
		||||
    .long    PORT0_14_Handler    /* 30:                                          */
 | 
			
		||||
    .long    PORT0_15_Handler    /* 31:                                          */
 | 
			
		||||
    .long    SysError_Handler    /* 32: System Error (Flash Cache)               */
 | 
			
		||||
    .long    EFLASH_Handler      /* 33: Embedded Flash                           */
 | 
			
		||||
    .long    LLCC_TXCMD_EMPTY_Handler        /* 34: LLCC_TXCMDIRQ                */
 | 
			
		||||
    .long    LLCC_TXEVT_EMPTY_Handler        /* 35: LLCC_TXEVTIRQ                */
 | 
			
		||||
    .long    LLCC_TXDMAH_DONE_Handler        /* 36: LLCC_TXDMA0IRQ               */
 | 
			
		||||
    .long    LLCC_TXDMAL_DONE_Handler        /* 37: LLCC_TXDMA1IRQ               */
 | 
			
		||||
    .long    LLCC_RXCMD_VALID_Handler        /* 38: LLCC_RXCMDIRQ                */
 | 
			
		||||
    .long    LLCC_RXEVT_VALID_Handler        /* 39: LLCC_RXEVTIRQ                */
 | 
			
		||||
    .long    LLCC_RXDMAH_DONE_Handler        /* 40: LLCC_RXDMA0IRQ               */
 | 
			
		||||
    .long    LLCC_RXDMAL_DONE_Handler        /* 41: LLCC_RXDMA1IRQ               */
 | 
			
		||||
    .long    PORT2_COMB_Handler              /* 42: GPIO 2                       */
 | 
			
		||||
    .long    PORT3_COMB_Handler              /* 43: GPIO 3                       */
 | 
			
		||||
    .long    TRNG_Handler                    /* 44: TRNG                         */
 | 
			
		||||
 | 
			
		||||
    .size    __isr_vector, . - __isr_vector
 | 
			
		||||
 | 
			
		||||
    .section .text.Reset_Handler
 | 
			
		||||
    .thumb
 | 
			
		||||
    .thumb_func
 | 
			
		||||
    .align  2
 | 
			
		||||
    .globl   Reset_Handler
 | 
			
		||||
    .type    Reset_Handler, %function
 | 
			
		||||
Reset_Handler:
 | 
			
		||||
    ldr    r0, =SystemInit
 | 
			
		||||
    blx    r0
 | 
			
		||||
/*
 | 
			
		||||
 * Loop to copy data from read only memory to RAM. The ranges
 | 
			
		||||
 * of copy from/to are specified by following symbols evaluated in
 | 
			
		||||
 * linker script.
 | 
			
		||||
 * _etext: End of code section, i.e., begin of data sections to copy from.
 | 
			
		||||
 * __data_start__/__data_end__: RAM address range that data should be
 | 
			
		||||
 * copied to. Both must be aligned to 4 bytes boundary.
 | 
			
		||||
 */
 | 
			
		||||
 | 
			
		||||
    ldr    r1, =__etext
 | 
			
		||||
    ldr    r2, =__data_start__
 | 
			
		||||
    ldr    r3, =__data_end__
 | 
			
		||||
 | 
			
		||||
    subs   r3, r2
 | 
			
		||||
    ble    .Lflash_to_ram_loop_end
 | 
			
		||||
 | 
			
		||||
    movs    r4, 0
 | 
			
		||||
.Lflash_to_ram_loop:
 | 
			
		||||
    ldr    r0, [r1,r4]
 | 
			
		||||
    str    r0, [r2,r4]
 | 
			
		||||
    adds   r4, 4
 | 
			
		||||
    cmp    r4, r3
 | 
			
		||||
    blt    .Lflash_to_ram_loop
 | 
			
		||||
.Lflash_to_ram_loop_end:
 | 
			
		||||
 | 
			
		||||
/* Initialize .bss */
 | 
			
		||||
init_bss:
 | 
			
		||||
        ldr   r1, =__bss_start__
 | 
			
		||||
        ldr   r2, =__bss_end__
 | 
			
		||||
        ldr   r3, =bss_size
 | 
			
		||||
 | 
			
		||||
        cmp   r3, #0
 | 
			
		||||
        beq   system_startup
 | 
			
		||||
 | 
			
		||||
        mov   r4, #0
 | 
			
		||||
zero:
 | 
			
		||||
        strb  r4, [r1], #1
 | 
			
		||||
        subs  r3, r3, #1
 | 
			
		||||
        bne   zero
 | 
			
		||||
 | 
			
		||||
system_startup:
 | 
			
		||||
    ldr    r0, =SystemInit
 | 
			
		||||
    blx    r0
 | 
			
		||||
    ldr    r0, =_start
 | 
			
		||||
    bx    r0
 | 
			
		||||
    .pool
 | 
			
		||||
    .size Reset_Handler, . - Reset_Handler
 | 
			
		||||
 | 
			
		||||
    .text
 | 
			
		||||
/*
 | 
			
		||||
 * Macro to define default handlers. Default handler
 | 
			
		||||
 * will be weak symbol and just dead loops. They can be
 | 
			
		||||
 * overwritten by other handlers
 | 
			
		||||
 */
 | 
			
		||||
    .macro    def_default_handler    handler_name
 | 
			
		||||
    .align 1
 | 
			
		||||
    .thumb_func
 | 
			
		||||
    .weak    \handler_name
 | 
			
		||||
    .type    \handler_name, %function
 | 
			
		||||
\handler_name :
 | 
			
		||||
    b    .
 | 
			
		||||
    .size    \handler_name, . - \handler_name
 | 
			
		||||
    .endm
 | 
			
		||||
 | 
			
		||||
    def_default_handler    NMI_Handler
 | 
			
		||||
    def_default_handler    HardFault_Handler
 | 
			
		||||
    def_default_handler    MemManage_Handler
 | 
			
		||||
    def_default_handler    BusFault_Handler
 | 
			
		||||
    def_default_handler    UsageFault_Handler
 | 
			
		||||
    def_default_handler    SVC_Handler
 | 
			
		||||
    def_default_handler    DebugMon_Handler
 | 
			
		||||
    def_default_handler    PendSV_Handler
 | 
			
		||||
    def_default_handler    SysTick_Handler
 | 
			
		||||
    def_default_handler    Default_Handler
 | 
			
		||||
 | 
			
		||||
    .macro    def_irq_default_handler    handler_name
 | 
			
		||||
    .weak     \handler_name
 | 
			
		||||
    .set      \handler_name, Default_Handler
 | 
			
		||||
    .endm
 | 
			
		||||
 | 
			
		||||
    /* External interrupts */
 | 
			
		||||
    def_irq_default_handler     UART0_Handler       /* 0:UART 0 RX and TX Combined Interrupt        */
 | 
			
		||||
    def_irq_default_handler     Spare_Handler       /* 1:Undefined                                  */
 | 
			
		||||
    def_irq_default_handler     UART1_Handler       /* 2:UART 1 RX and TX Combined Interrupt        */
 | 
			
		||||
    def_irq_default_handler     I2C0_Handler        /* 3:I2C 0 Interrupt                            */
 | 
			
		||||
    def_irq_default_handler     I2C1_Handler        /* 4:I2C 1 Interrupt                            */
 | 
			
		||||
    def_irq_default_handler     RTC_Handler         /* 5:RTC Interrupt                              */
 | 
			
		||||
    def_irq_default_handler     PORT0_Handler       /* 6:GPIO Port 0 combined Interrupt             */
 | 
			
		||||
    def_irq_default_handler     PORT1_ALL_Handler   /* 7:GPIO Port 1 combined Interrupt             */
 | 
			
		||||
    def_irq_default_handler     TIMER0_Handler      /* 8:TIMER 0 Interrupt                          */
 | 
			
		||||
    def_irq_default_handler     TIMER1_Handler      /* 9:TIMER 1 Interrupt                          */
 | 
			
		||||
    def_irq_default_handler     DUALTIMER_Handler   /* 10:Dual Timer Interrupt                      */
 | 
			
		||||
    def_irq_default_handler     SPI0_Handler        /* 11:SPI 0 Interrupt                           */
 | 
			
		||||
    def_irq_default_handler     UARTOVF_Handler     /* 12:UART 0,1,2 Overflow Interrupt             */
 | 
			
		||||
    def_irq_default_handler     SPI1_Handler        /* 13:SPI 1 Interrupt                           */
 | 
			
		||||
    def_irq_default_handler     QSPI_Handler        /* 14:QUAD SPI Interrupt                        */
 | 
			
		||||
    def_irq_default_handler     DMA_Handler         /* 15:Touch Screen Interrupt                    */
 | 
			
		||||
    def_irq_default_handler     PORT0_0_Handler     /* 16:All P0 and P1I/O pins used as irq source  */
 | 
			
		||||
    def_irq_default_handler     PORT0_1_Handler     /* 17:There are 16 pins in total                */
 | 
			
		||||
    def_irq_default_handler     PORT0_2_Handler     /* 18:                                          */
 | 
			
		||||
    def_irq_default_handler     PORT0_3_Handler     /* 19:                                          */
 | 
			
		||||
    def_irq_default_handler     PORT0_4_Handler     /* 20:                                          */
 | 
			
		||||
    def_irq_default_handler     PORT0_5_Handler     /* 21:                                          */
 | 
			
		||||
    def_irq_default_handler     PORT0_6_Handler     /* 22:                                          */
 | 
			
		||||
    def_irq_default_handler     PORT0_7_Handler     /* 23:                                          */
 | 
			
		||||
    def_irq_default_handler     PORT0_8_Handler     /* 24:                                          */
 | 
			
		||||
    def_irq_default_handler     PORT0_9_Handler     /* 25:                                          */
 | 
			
		||||
    def_irq_default_handler     PORT0_10_Handler    /* 26:                                          */
 | 
			
		||||
    def_irq_default_handler     PORT0_11_Handler    /* 27:                                          */
 | 
			
		||||
    def_irq_default_handler     PORT0_12_Handler    /* 28:                                          */
 | 
			
		||||
    def_irq_default_handler     PORT0_13_Handler    /* 29:                                          */
 | 
			
		||||
    def_irq_default_handler     PORT0_14_Handler    /* 30:                                          */
 | 
			
		||||
    def_irq_default_handler     PORT0_15_Handler    /* 31:                                          */
 | 
			
		||||
    def_irq_default_handler     SysError_Handler    /* 32: System Error (Flash Cache)               */
 | 
			
		||||
    def_irq_default_handler     EFLASH_Handler      /* 33: Embedded Flash                           */
 | 
			
		||||
    def_irq_default_handler     LLCC_TXCMD_EMPTY_Handler        /* 34: LLCC_TXCMDIRQ                */
 | 
			
		||||
    def_irq_default_handler     LLCC_TXEVT_EMPTY_Handler	       /* 35: LLCC_TXEVTIRQ                */
 | 
			
		||||
    def_irq_default_handler     LLCC_TXDMAH_DONE_Handler        /* 36: LLCC_TXDMA0IRQ               */
 | 
			
		||||
    def_irq_default_handler     LLCC_TXDMAL_DONE_Handler        /* 37: LLCC_TXDMA1IRQ               */
 | 
			
		||||
    def_irq_default_handler     LLCC_RXCMD_VALID_Handler        /* 38: LLCC_RXCMDIRQ                */
 | 
			
		||||
    def_irq_default_handler     LLCC_RXEVT_VALID_Handler        /* 39: LLCC_RXEVTIRQ                */
 | 
			
		||||
    def_irq_default_handler     LLCC_RXDMAH_DONE_Handler        /* 40: LLCC_RXDMA0IRQ               */
 | 
			
		||||
    def_irq_default_handler     LLCC_RXDMAL_DONE_Handler        /* 41: LLCC_RXDMA1IRQ               */
 | 
			
		||||
    def_irq_default_handler     PORT2_COMB_Handler              /* 42: GPIO 2                       */
 | 
			
		||||
    def_irq_default_handler     PORT3_COMB_Handler              /* 43: GPIO 3                       */
 | 
			
		||||
    def_irq_default_handler     TRNG_Handler                    /* 44: TRNG                         */
 | 
			
		||||
 | 
			
		||||
    .end
 | 
			
		||||
| 
						 | 
				
			
			@ -1,55 +0,0 @@
 | 
			
		|||
/*
 | 
			
		||||
 * BEETLE CMSIS Library
 | 
			
		||||
 */
 | 
			
		||||
/*
 | 
			
		||||
 * Copyright (c) 2009-2016 ARM Limited. All rights reserved.
 | 
			
		||||
 *
 | 
			
		||||
 * SPDX-License-Identifier: Apache-2.0
 | 
			
		||||
 *
 | 
			
		||||
 * Licensed under the Apache License, Version 2.0 (the License) you may
 | 
			
		||||
 * not use this file except in compliance with the License.
 | 
			
		||||
 * You may obtain a copy of the License at
 | 
			
		||||
 *
 | 
			
		||||
 * http://www.apache.org/licenses/LICENSE-2.0
 | 
			
		||||
 *
 | 
			
		||||
 * Unless required by applicable law or agreed to in writing, software
 | 
			
		||||
 * distributed under the License is distributed on an AS IS BASIS, WITHOUT
 | 
			
		||||
 * WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
 | 
			
		||||
 * See the License for the specific language governing permissions and
 | 
			
		||||
 * limitations under the License.
 | 
			
		||||
 */
 | 
			
		||||
/*###ICF### Section handled by ICF editor, don't touch! ****/
 | 
			
		||||
/*-Editor annotation file-*/
 | 
			
		||||
/* IcfEditorFile="$TOOLKIT_DIR$\config\ide\IcfEditor\cortex_v1_0.xml" */
 | 
			
		||||
/*-Specials-*/
 | 
			
		||||
define symbol __ICFEDIT_intvec_start__ = 0x00000000;
 | 
			
		||||
/*-Memory Regions-*/
 | 
			
		||||
define symbol __ICFEDIT_region_ROM_start__    = 0x00000000;
 | 
			
		||||
define symbol __ICFEDIT_region_ROM_end__      = 0x0003FFFF;
 | 
			
		||||
define symbol __ICFEDIT_region_RAM_start__    = 0x20000140;
 | 
			
		||||
define symbol __ICFEDIT_region_RAM_end__      = 0x2001FFFF;
 | 
			
		||||
/*-Sizes-*/
 | 
			
		||||
 | 
			
		||||
if (!isdefinedsymbol(MBED_BOOT_STACK_SIZE)) {
 | 
			
		||||
    define symbol MBED_BOOT_STACK_SIZE = 0x400;
 | 
			
		||||
}
 | 
			
		||||
 | 
			
		||||
/* Heap and Stack size */
 | 
			
		||||
define symbol __ICFEDIT_size_cstack__ = MBED_BOOT_STACK_SIZE;
 | 
			
		||||
define symbol __ICFEDIT_size_heap__   = 0x4000;
 | 
			
		||||
/**** End of ICF editor section. ###ICF###*/
 | 
			
		||||
 | 
			
		||||
define memory mem with size = 4G;
 | 
			
		||||
define region ROM_region      = mem:[from __ICFEDIT_region_ROM_start__   to __ICFEDIT_region_ROM_end__];
 | 
			
		||||
define region RAM_region      = mem:[from __ICFEDIT_region_RAM_start__   to __ICFEDIT_region_RAM_end__];
 | 
			
		||||
 | 
			
		||||
initialize by copy { readwrite };
 | 
			
		||||
do not initialize  { section .noinit };
 | 
			
		||||
 | 
			
		||||
define block CSTACK    with alignment = 8, size = __ICFEDIT_size_cstack__   { };
 | 
			
		||||
define block HEAP      with alignment = 8, size = __ICFEDIT_size_heap__     { };
 | 
			
		||||
 | 
			
		||||
place at address mem:__ICFEDIT_intvec_start__ { readonly section .intvec };
 | 
			
		||||
place in ROM_region   { readonly };
 | 
			
		||||
place in RAM_region   { readwrite,
 | 
			
		||||
                        block CSTACK, block HEAP };
 | 
			
		||||
| 
						 | 
				
			
			@ -1,421 +0,0 @@
 | 
			
		|||
;/*
 | 
			
		||||
; * BEETLE CMSIS Library
 | 
			
		||||
; */
 | 
			
		||||
;/*
 | 
			
		||||
; * Copyright (c) 2009-2016 ARM Limited. All rights reserved.
 | 
			
		||||
; *
 | 
			
		||||
; * SPDX-License-Identifier: Apache-2.0
 | 
			
		||||
; *
 | 
			
		||||
; * Licensed under the Apache License, Version 2.0 (the License); you may
 | 
			
		||||
; * not use this file except in compliance with the License.
 | 
			
		||||
; * You may obtain a copy of the License at
 | 
			
		||||
; *
 | 
			
		||||
; * http://www.apache.org/licenses/LICENSE-2.0
 | 
			
		||||
; *
 | 
			
		||||
; * Unless required by applicable law or agreed to in writing, software
 | 
			
		||||
; * distributed under the License is distributed on an AS IS BASIS, WITHOUT
 | 
			
		||||
; * WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
 | 
			
		||||
; * See the License for the specific language governing permissions and
 | 
			
		||||
; * limitations under the License.
 | 
			
		||||
; */
 | 
			
		||||
;/*
 | 
			
		||||
; * This file is derivative of CMSIS V5.00 startup_Device.s
 | 
			
		||||
; */
 | 
			
		||||
 | 
			
		||||
 | 
			
		||||
;
 | 
			
		||||
; The modules in this file are included in the libraries, and may be replaced
 | 
			
		||||
; by any user-defined modules that define the PUBLIC symbol _program_start or
 | 
			
		||||
; a user defined start symbol.
 | 
			
		||||
; To override the cstartup defined in the library, simply add your modified
 | 
			
		||||
; version to the workbench project.
 | 
			
		||||
;
 | 
			
		||||
; The vector table is normally located at address 0.
 | 
			
		||||
; When debugging in RAM, it can be located in RAM, aligned to at least 2^6.
 | 
			
		||||
; The name "__vector_table" has special meaning for C-SPY:
 | 
			
		||||
; it is where the SP start value is found, and the NVIC vector
 | 
			
		||||
; table register (VTOR) is initialized to this address if != 0.
 | 
			
		||||
;
 | 
			
		||||
; Cortex-M version
 | 
			
		||||
;
 | 
			
		||||
 | 
			
		||||
        MODULE  ?cstartup
 | 
			
		||||
 | 
			
		||||
        ;; Forward declaration of sections.
 | 
			
		||||
        SECTION CSTACK:DATA:NOROOT(3)
 | 
			
		||||
 | 
			
		||||
        SECTION .intvec:CODE:NOROOT(2)
 | 
			
		||||
 | 
			
		||||
        EXTERN  __iar_program_start
 | 
			
		||||
        EXTERN  SystemInit
 | 
			
		||||
        PUBLIC  __vector_table
 | 
			
		||||
        PUBLIC  __vector_table_0x1c
 | 
			
		||||
        PUBLIC  __Vectors
 | 
			
		||||
        PUBLIC  __Vectors_End
 | 
			
		||||
        PUBLIC  __Vectors_Size
 | 
			
		||||
 | 
			
		||||
        DATA
 | 
			
		||||
 | 
			
		||||
__vector_table
 | 
			
		||||
        DCD     sfe(CSTACK)
 | 
			
		||||
        DCD     Reset_Handler
 | 
			
		||||
 | 
			
		||||
        DCD     NMI_Handler
 | 
			
		||||
        DCD     HardFault_Handler
 | 
			
		||||
        DCD     MemManage_Handler
 | 
			
		||||
        DCD     BusFault_Handler
 | 
			
		||||
        DCD     UsageFault_Handler
 | 
			
		||||
__vector_table_0x1c
 | 
			
		||||
        DCD     0
 | 
			
		||||
        DCD     0
 | 
			
		||||
        DCD     0
 | 
			
		||||
        DCD     0
 | 
			
		||||
        DCD     SVC_Handler
 | 
			
		||||
        DCD     DebugMon_Handler
 | 
			
		||||
        DCD     0
 | 
			
		||||
        DCD     PendSV_Handler
 | 
			
		||||
        DCD     SysTick_Handler
 | 
			
		||||
 | 
			
		||||
        ; External Interrupts
 | 
			
		||||
        DCD     UART0_Handler             ;  0: UART 0 RX and TX Handler
 | 
			
		||||
        DCD     Spare_IRQ_Handler         ;  1: Undefined
 | 
			
		||||
        DCD     UART1_Handler             ;  2: UART 1 RX and TX Handler
 | 
			
		||||
        DCD     I2C0_Handler              ;  3: I2C 0 Handler
 | 
			
		||||
        DCD     I2C1_Handler              ;  4: I2C 1 Handler
 | 
			
		||||
        DCD     RTC_Handler               ;  5: RTC Handler
 | 
			
		||||
        DCD     PORT0_COMB_Handler        ;  6: GPIO Port 0 Combined Handler
 | 
			
		||||
        DCD     PORT1_COMB_Handler        ;  7: GPIO Port 1 Combined Handler
 | 
			
		||||
        DCD     TIMER0_Handler            ;  8: TIMER 0 handler
 | 
			
		||||
        DCD     TIMER1_Handler            ;  9: TIMER 1 handler
 | 
			
		||||
        DCD     DUALTIMER_HANDLER         ; 10: Dual timer handler
 | 
			
		||||
        DCD     SPI0_Handler              ; 11: SPI 0 Handler
 | 
			
		||||
        DCD     UARTOVF_Handler           ; 12: UART 0,1 Overflow Handler
 | 
			
		||||
        DCD     SPI1_Handler              ; 13: SPI 1 Handler
 | 
			
		||||
        DCD     QSPI_Handler              ; 14: QSPI Handler
 | 
			
		||||
        DCD     DMA_Handler               ; 15: DMA handler
 | 
			
		||||
        DCD     PORT0_0_Handler           ; 16: GPIO Port 0 pin 0 Handler
 | 
			
		||||
        DCD     PORT0_1_Handler           ; 17: GPIO Port 0 pin 1 Handler
 | 
			
		||||
        DCD     PORT0_2_Handler           ; 18: GPIO Port 0 pin 2 Handler
 | 
			
		||||
        DCD     PORT0_3_Handler           ; 19: GPIO Port 0 pin 3 Handler
 | 
			
		||||
        DCD     PORT0_4_Handler           ; 20: GPIO Port 0 pin 4 Handler
 | 
			
		||||
        DCD     PORT0_5_Handler           ; 21: GPIO Port 0 pin 5 Handler
 | 
			
		||||
        DCD     PORT0_6_Handler           ; 22: GPIO Port 0 pin 6 Handler
 | 
			
		||||
        DCD     PORT0_7_Handler           ; 23: GPIO Port 0 pin 7 Handler
 | 
			
		||||
        DCD     PORT0_8_Handler           ; 24: GPIO Port 0 pin 8 Handler
 | 
			
		||||
        DCD     PORT0_9_Handler           ; 25: GPIO Port 0 pin 9 Handler
 | 
			
		||||
        DCD     PORT0_10_Handler          ; 26: GPIO Port 0 pin 10 Handler
 | 
			
		||||
        DCD     PORT0_11_Handler          ; 27: GPIO Port 0 pin 11 Handler
 | 
			
		||||
        DCD     PORT0_12_Handler          ; 28: GPIO Port 0 pin 12 Handler
 | 
			
		||||
        DCD     PORT0_13_Handler          ; 29: GPIO Port 0 pin 13 Handler
 | 
			
		||||
        DCD     PORT0_14_Handler          ; 30: GPIO Port 0 pin 14 Handler
 | 
			
		||||
        DCD     PORT0_15_Handler          ; 31: GPIO Port 0 pin 15 Handler
 | 
			
		||||
        DCD     SysError_Handler          ; 32: System Error (Flash Cache)
 | 
			
		||||
        DCD     EFLASH_Handler            ; 33: Embedded Flash
 | 
			
		||||
        DCD     LLCC_TXCMD_EMPTY_Handler  ; 34: LLCC_TXCMDIRQ
 | 
			
		||||
        DCD     LLCC_TXEVT_EMPTY_Handler  ; 35: LLCC_TXEVTIRQ
 | 
			
		||||
        DCD     LLCC_TXDMAH_DONE_Handler  ; 36: LLCC_TXDMA0IRQ
 | 
			
		||||
        DCD     LLCC_TXDMAL_DONE_Handler  ; 37: LLCC_TXDMA1IRQ
 | 
			
		||||
        DCD     LLCC_RXCMD_VALID_Handler  ; 38: LLCC_RXCMDIRQ
 | 
			
		||||
        DCD     LLCC_RXEVT_VALID_Handler  ; 39: LLCC_RXEVTIRQ
 | 
			
		||||
        DCD     LLCC_RXDMAH_DONE_Handler  ; 40: LLCC_RXDMA0IRQ
 | 
			
		||||
        DCD     LLCC_RXDMAL_DONE_Handler  ; 41: LLCC_RXDMA1IRQ
 | 
			
		||||
        DCD     PORT2_COMB_Handler        ; 42: GPIO 2
 | 
			
		||||
        DCD     PORT3_COMB_Handler        ; 43: GPIO 3
 | 
			
		||||
        DCD     TRNG_Handler              ; 44: TRNG
 | 
			
		||||
__Vectors_End
 | 
			
		||||
 | 
			
		||||
__Vectors       EQU   __vector_table
 | 
			
		||||
__Vectors_Size  EQU   __Vectors_End - __Vectors
 | 
			
		||||
 | 
			
		||||
 | 
			
		||||
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
 | 
			
		||||
;;
 | 
			
		||||
;; Default interrupt handlers.
 | 
			
		||||
;;
 | 
			
		||||
        THUMB
 | 
			
		||||
 | 
			
		||||
        PUBWEAK Reset_Handler
 | 
			
		||||
        SECTION .text:CODE:REORDER:NOROOT(2)
 | 
			
		||||
Reset_Handler
 | 
			
		||||
        LDR     R0, =SystemInit
 | 
			
		||||
        BLX     R0
 | 
			
		||||
        LDR     R0, =__iar_program_start
 | 
			
		||||
        BX      R0
 | 
			
		||||
 | 
			
		||||
        PUBWEAK NMI_Handler
 | 
			
		||||
        SECTION .text:CODE:REORDER:NOROOT(1)
 | 
			
		||||
NMI_Handler
 | 
			
		||||
        B NMI_Handler
 | 
			
		||||
 | 
			
		||||
        PUBWEAK HardFault_Handler
 | 
			
		||||
        SECTION .text:CODE:REORDER:NOROOT(1)
 | 
			
		||||
HardFault_Handler
 | 
			
		||||
        B HardFault_Handler
 | 
			
		||||
 | 
			
		||||
        PUBWEAK MemManage_Handler
 | 
			
		||||
        SECTION .text:CODE:REORDER:NOROOT(1)
 | 
			
		||||
MemManage_Handler
 | 
			
		||||
        B MemManage_Handler
 | 
			
		||||
 | 
			
		||||
        PUBWEAK BusFault_Handler
 | 
			
		||||
        SECTION .text:CODE:REORDER:NOROOT(1)
 | 
			
		||||
BusFault_Handler
 | 
			
		||||
        B BusFault_Handler
 | 
			
		||||
 | 
			
		||||
        PUBWEAK UsageFault_Handler
 | 
			
		||||
        SECTION .text:CODE:REORDER:NOROOT(1)
 | 
			
		||||
UsageFault_Handler
 | 
			
		||||
        B UsageFault_Handler
 | 
			
		||||
 | 
			
		||||
        PUBWEAK SecureFault_Handler
 | 
			
		||||
        SECTION .text:CODE:REORDER:NOROOT(1)
 | 
			
		||||
SecureFault_Handler
 | 
			
		||||
        B SecureFault_Handler
 | 
			
		||||
 | 
			
		||||
        PUBWEAK SVC_Handler
 | 
			
		||||
        SECTION .text:CODE:REORDER:NOROOT(1)
 | 
			
		||||
SVC_Handler
 | 
			
		||||
        B SVC_Handler
 | 
			
		||||
 | 
			
		||||
        PUBWEAK DebugMon_Handler
 | 
			
		||||
        SECTION .text:CODE:REORDER:NOROOT(1)
 | 
			
		||||
DebugMon_Handler
 | 
			
		||||
        B DebugMon_Handler
 | 
			
		||||
 | 
			
		||||
        PUBWEAK PendSV_Handler
 | 
			
		||||
        SECTION .text:CODE:REORDER:NOROOT(1)
 | 
			
		||||
PendSV_Handler
 | 
			
		||||
        B PendSV_Handler
 | 
			
		||||
 | 
			
		||||
        PUBWEAK SysTick_Handler
 | 
			
		||||
        SECTION .text:CODE:REORDER:NOROOT(1)
 | 
			
		||||
SysTick_Handler
 | 
			
		||||
        B SysTick_Handler
 | 
			
		||||
 | 
			
		||||
 | 
			
		||||
        PUBWEAK UART0_Handler
 | 
			
		||||
        SECTION .text:CODE:REORDER:NOROOT(1)
 | 
			
		||||
UART0_Handler
 | 
			
		||||
        B UART0_Handler
 | 
			
		||||
 | 
			
		||||
        PUBWEAK Spare_IRQ_Handler
 | 
			
		||||
        SECTION .text:CODE:REORDER:NOROOT(1)
 | 
			
		||||
Spare_IRQ_Handler
 | 
			
		||||
        B Spare_IRQ_Handler
 | 
			
		||||
 | 
			
		||||
        PUBWEAK UART1_Handler
 | 
			
		||||
        SECTION .text:CODE:REORDER:NOROOT(1)
 | 
			
		||||
UART1_Handler
 | 
			
		||||
        B UART1_Handler
 | 
			
		||||
 | 
			
		||||
        PUBWEAK I2C0_Handler
 | 
			
		||||
        SECTION .text:CODE:REORDER:NOROOT(1)
 | 
			
		||||
I2C0_Handler
 | 
			
		||||
        B I2C0_Handler
 | 
			
		||||
 | 
			
		||||
        PUBWEAK I2C1_Handler
 | 
			
		||||
        SECTION .text:CODE:REORDER:NOROOT(1)
 | 
			
		||||
I2C1_Handler
 | 
			
		||||
        B I2C1_Handler
 | 
			
		||||
 | 
			
		||||
        PUBWEAK RTC_Handler
 | 
			
		||||
        SECTION .text:CODE:REORDER:NOROOT(1)
 | 
			
		||||
RTC_Handler
 | 
			
		||||
        B RTC_Handler
 | 
			
		||||
 | 
			
		||||
        PUBWEAK PORT0_COMB_Handler
 | 
			
		||||
        SECTION .text:CODE:REORDER:NOROOT(1)
 | 
			
		||||
PORT0_COMB_Handler
 | 
			
		||||
        B PORT0_COMB_Handler
 | 
			
		||||
 | 
			
		||||
        PUBWEAK PORT1_COMB_Handler
 | 
			
		||||
        SECTION .text:CODE:REORDER:NOROOT(1)
 | 
			
		||||
PORT1_COMB_Handler
 | 
			
		||||
        B PORT1_COMB_Handler
 | 
			
		||||
 | 
			
		||||
        PUBWEAK TIMER0_Handler
 | 
			
		||||
        SECTION .text:CODE:REORDER:NOROOT(1)
 | 
			
		||||
TIMER0_Handler
 | 
			
		||||
        B TIMER0_Handler
 | 
			
		||||
 | 
			
		||||
        PUBWEAK TIMER1_Handler
 | 
			
		||||
        SECTION .text:CODE:REORDER:NOROOT(1)
 | 
			
		||||
TIMER1_Handler
 | 
			
		||||
        B TIMER1_Handler
 | 
			
		||||
 | 
			
		||||
        PUBWEAK DUALTIMER_HANDLER
 | 
			
		||||
        SECTION .text:CODE:REORDER:NOROOT(1)
 | 
			
		||||
DUALTIMER_HANDLER
 | 
			
		||||
        B DUALTIMER_HANDLER
 | 
			
		||||
 | 
			
		||||
        PUBWEAK SPI0_Handler
 | 
			
		||||
        SECTION .text:CODE:REORDER:NOROOT(1)
 | 
			
		||||
SPI0_Handler
 | 
			
		||||
        B SPI0_Handler
 | 
			
		||||
 | 
			
		||||
        PUBWEAK UARTOVF_Handler
 | 
			
		||||
        SECTION .text:CODE:REORDER:NOROOT(1)
 | 
			
		||||
UARTOVF_Handler
 | 
			
		||||
        B UARTOVF_Handler
 | 
			
		||||
 | 
			
		||||
        PUBWEAK SPI1_Handler
 | 
			
		||||
        SECTION .text:CODE:REORDER:NOROOT(1)
 | 
			
		||||
SPI1_Handler
 | 
			
		||||
        B SPI1_Handler
 | 
			
		||||
 | 
			
		||||
        PUBWEAK QSPI_Handler
 | 
			
		||||
        SECTION .text:CODE:REORDER:NOROOT(1)
 | 
			
		||||
QSPI_Handler
 | 
			
		||||
        B QSPI_Handler
 | 
			
		||||
 | 
			
		||||
        PUBWEAK DMA_Handler
 | 
			
		||||
        SECTION .text:CODE:REORDER:NOROOT(1)
 | 
			
		||||
DMA_Handler
 | 
			
		||||
        B DMA_Handler
 | 
			
		||||
 | 
			
		||||
        PUBWEAK PORT0_0_Handler
 | 
			
		||||
        SECTION .text:CODE:REORDER:NOROOT(1)
 | 
			
		||||
PORT0_0_Handler
 | 
			
		||||
        B PORT0_0_Handler
 | 
			
		||||
 | 
			
		||||
        PUBWEAK PORT0_1_Handler
 | 
			
		||||
        SECTION .text:CODE:REORDER:NOROOT(1)
 | 
			
		||||
PORT0_1_Handler
 | 
			
		||||
        B PORT0_1_Handler
 | 
			
		||||
 | 
			
		||||
        PUBWEAK PORT0_2_Handler
 | 
			
		||||
        SECTION .text:CODE:REORDER:NOROOT(1)
 | 
			
		||||
PORT0_2_Handler
 | 
			
		||||
        B PORT0_2_Handler
 | 
			
		||||
 | 
			
		||||
        PUBWEAK PORT0_3_Handler
 | 
			
		||||
        SECTION .text:CODE:REORDER:NOROOT(1)
 | 
			
		||||
PORT0_3_Handler
 | 
			
		||||
        B PORT0_3_Handler
 | 
			
		||||
 | 
			
		||||
        PUBWEAK PORT0_4_Handler
 | 
			
		||||
        SECTION .text:CODE:REORDER:NOROOT(1)
 | 
			
		||||
PORT0_4_Handler
 | 
			
		||||
        B PORT0_4_Handler
 | 
			
		||||
 | 
			
		||||
        PUBWEAK PORT0_5_Handler
 | 
			
		||||
        SECTION .text:CODE:REORDER:NOROOT(1)
 | 
			
		||||
PORT0_5_Handler
 | 
			
		||||
        B PORT0_5_Handler
 | 
			
		||||
 | 
			
		||||
        PUBWEAK PORT0_6_Handler
 | 
			
		||||
        SECTION .text:CODE:REORDER:NOROOT(1)
 | 
			
		||||
PORT0_6_Handler
 | 
			
		||||
        B PORT0_6_Handler
 | 
			
		||||
 | 
			
		||||
        PUBWEAK PORT0_7_Handler
 | 
			
		||||
        SECTION .text:CODE:REORDER:NOROOT(1)
 | 
			
		||||
PORT0_7_Handler
 | 
			
		||||
        B PORT0_7_Handler
 | 
			
		||||
 | 
			
		||||
        PUBWEAK PORT0_8_Handler
 | 
			
		||||
        SECTION .text:CODE:REORDER:NOROOT(1)
 | 
			
		||||
PORT0_8_Handler
 | 
			
		||||
        B PORT0_8_Handler
 | 
			
		||||
 | 
			
		||||
        PUBWEAK PORT0_9_Handler
 | 
			
		||||
        SECTION .text:CODE:REORDER:NOROOT(1)
 | 
			
		||||
PORT0_9_Handler
 | 
			
		||||
        B PORT0_9_Handler
 | 
			
		||||
 | 
			
		||||
        PUBWEAK PORT0_10_Handler
 | 
			
		||||
        SECTION .text:CODE:REORDER:NOROOT(1)
 | 
			
		||||
PORT0_10_Handler
 | 
			
		||||
        B PORT0_10_Handler
 | 
			
		||||
 | 
			
		||||
        PUBWEAK PORT0_11_Handler
 | 
			
		||||
        SECTION .text:CODE:REORDER:NOROOT(1)
 | 
			
		||||
PORT0_11_Handler
 | 
			
		||||
        B PORT0_11_Handler
 | 
			
		||||
 | 
			
		||||
        PUBWEAK PORT0_12_Handler
 | 
			
		||||
        SECTION .text:CODE:REORDER:NOROOT(1)
 | 
			
		||||
PORT0_12_Handler
 | 
			
		||||
        B PORT0_12_Handler
 | 
			
		||||
 | 
			
		||||
        PUBWEAK PORT0_13_Handler
 | 
			
		||||
        SECTION .text:CODE:REORDER:NOROOT(1)
 | 
			
		||||
PORT0_13_Handler
 | 
			
		||||
        B PORT0_13_Handler
 | 
			
		||||
 | 
			
		||||
        PUBWEAK PORT0_14_Handler
 | 
			
		||||
        SECTION .text:CODE:REORDER:NOROOT(1)
 | 
			
		||||
PORT0_14_Handler
 | 
			
		||||
        B PORT0_14_Handler
 | 
			
		||||
 | 
			
		||||
        PUBWEAK PORT0_15_Handler
 | 
			
		||||
        SECTION .text:CODE:REORDER:NOROOT(1)
 | 
			
		||||
PORT0_15_Handler
 | 
			
		||||
        B PORT0_15_Handler
 | 
			
		||||
 | 
			
		||||
        PUBWEAK SysError_Handler
 | 
			
		||||
        SECTION .text:CODE:REORDER:NOROOT(1)
 | 
			
		||||
SysError_Handler
 | 
			
		||||
        B SysError_Handler
 | 
			
		||||
 | 
			
		||||
        PUBWEAK EFLASH_Handler
 | 
			
		||||
        SECTION .text:CODE:REORDER:NOROOT(1)
 | 
			
		||||
EFLASH_Handler
 | 
			
		||||
        B EFLASH_Handler
 | 
			
		||||
 | 
			
		||||
        PUBWEAK LLCC_TXCMD_EMPTY_Handler
 | 
			
		||||
        SECTION .text:CODE:REORDER:NOROOT(1)
 | 
			
		||||
LLCC_TXCMD_EMPTY_Handler
 | 
			
		||||
        B LLCC_TXCMD_EMPTY_Handler
 | 
			
		||||
 | 
			
		||||
        PUBWEAK LLCC_TXEVT_EMPTY_Handler
 | 
			
		||||
        SECTION .text:CODE:REORDER:NOROOT(1)
 | 
			
		||||
LLCC_TXEVT_EMPTY_Handler
 | 
			
		||||
        B LLCC_TXEVT_EMPTY_Handler
 | 
			
		||||
 | 
			
		||||
        PUBWEAK LLCC_TXDMAH_DONE_Handler
 | 
			
		||||
        SECTION .text:CODE:REORDER:NOROOT(1)
 | 
			
		||||
LLCC_TXDMAH_DONE_Handler
 | 
			
		||||
        B LLCC_TXDMAH_DONE_Handler
 | 
			
		||||
 | 
			
		||||
        PUBWEAK LLCC_TXDMAL_DONE_Handler
 | 
			
		||||
        SECTION .text:CODE:REORDER:NOROOT(1)
 | 
			
		||||
LLCC_TXDMAL_DONE_Handler
 | 
			
		||||
        B LLCC_TXDMAL_DONE_Handler
 | 
			
		||||
 | 
			
		||||
        PUBWEAK LLCC_RXCMD_VALID_Handler
 | 
			
		||||
        SECTION .text:CODE:REORDER:NOROOT(1)
 | 
			
		||||
LLCC_RXCMD_VALID_Handler
 | 
			
		||||
        B LLCC_RXCMD_VALID_Handler
 | 
			
		||||
 | 
			
		||||
        PUBWEAK LLCC_RXEVT_VALID_Handler
 | 
			
		||||
        SECTION .text:CODE:REORDER:NOROOT(1)
 | 
			
		||||
LLCC_RXEVT_VALID_Handler
 | 
			
		||||
        B LLCC_RXEVT_VALID_Handler
 | 
			
		||||
 | 
			
		||||
        PUBWEAK LLCC_RXDMAH_DONE_Handler
 | 
			
		||||
        SECTION .text:CODE:REORDER:NOROOT(1)
 | 
			
		||||
LLCC_RXDMAH_DONE_Handler
 | 
			
		||||
        B LLCC_RXDMAH_DONE_Handler
 | 
			
		||||
 | 
			
		||||
        PUBWEAK LLCC_RXDMAL_DONE_Handler
 | 
			
		||||
        SECTION .text:CODE:REORDER:NOROOT(1)
 | 
			
		||||
LLCC_RXDMAL_DONE_Handler
 | 
			
		||||
        B LLCC_RXDMAL_DONE_Handler
 | 
			
		||||
 | 
			
		||||
        PUBWEAK PORT2_COMB_Handler
 | 
			
		||||
        SECTION .text:CODE:REORDER:NOROOT(1)
 | 
			
		||||
PORT2_COMB_Handler
 | 
			
		||||
        B PORT2_COMB_Handler
 | 
			
		||||
 | 
			
		||||
        PUBWEAK PORT3_COMB_Handler
 | 
			
		||||
        SECTION .text:CODE:REORDER:NOROOT(1)
 | 
			
		||||
PORT3_COMB_Handler
 | 
			
		||||
        B PORT3_COMB_Handler
 | 
			
		||||
 | 
			
		||||
        PUBWEAK TRNG_Handler
 | 
			
		||||
        SECTION .text:CODE:REORDER:NOROOT(1)
 | 
			
		||||
TRNG_Handler
 | 
			
		||||
        B TRNG_Handler
 | 
			
		||||
 | 
			
		||||
        END
 | 
			
		||||
| 
						 | 
				
			
			@ -1,413 +0,0 @@
 | 
			
		|||
/* mbed Microcontroller Library
 | 
			
		||||
 * Copyright (c) 2016 ARM Limited
 | 
			
		||||
 *
 | 
			
		||||
 * Licensed under the Apache License, Version 2.0 (the "License");
 | 
			
		||||
 * you may not use this file except in compliance with the License.
 | 
			
		||||
 * You may obtain a copy of the License at
 | 
			
		||||
 *
 | 
			
		||||
 *     http://www.apache.org/licenses/LICENSE-2.0
 | 
			
		||||
 *
 | 
			
		||||
 * Unless required by applicable law or agreed to in writing, software
 | 
			
		||||
 * distributed under the License is distributed on an "AS IS" BASIS,
 | 
			
		||||
 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
 | 
			
		||||
 * See the License for the specific language governing permissions and
 | 
			
		||||
 * limitations under the License.
 | 
			
		||||
 */
 | 
			
		||||
#include "cmsis.h"
 | 
			
		||||
#include "apb_dualtimer.h"
 | 
			
		||||
 | 
			
		||||
/* DualTimer Private Data */
 | 
			
		||||
typedef struct {
 | 
			
		||||
    /* DualTimer 1 Definition */
 | 
			
		||||
    CMSDK_DUALTIMER_SINGLE_TypeDef *dualtimer1;
 | 
			
		||||
    /* DualTimer 2 Definition */
 | 
			
		||||
    CMSDK_DUALTIMER_SINGLE_TypeDef *dualtimer2;
 | 
			
		||||
    /* Dual Timer IRQn */
 | 
			
		||||
    uint32_t dualtimerIRQn;
 | 
			
		||||
    /* DualTimer 1 Reload Value */
 | 
			
		||||
    uint32_t dualtimer1Reload;
 | 
			
		||||
    /* DualTimer 2 Reload Value */
 | 
			
		||||
    uint32_t dualtimer2Reload;
 | 
			
		||||
    /* Timer state */
 | 
			
		||||
    uint32_t state;
 | 
			
		||||
} apb_dualtimer_t;
 | 
			
		||||
 | 
			
		||||
/* Timer state definitions */
 | 
			
		||||
#define DUALTIMER_INITIALIZED   (1)
 | 
			
		||||
#define DUALTIMER_ENABLED       (1 << 1)
 | 
			
		||||
 | 
			
		||||
/*
 | 
			
		||||
 * This Timer is written for MBED OS and keeps count
 | 
			
		||||
 * of the ticks. All the elaboration logic is demanded
 | 
			
		||||
 * to the upper layers.
 | 
			
		||||
 */
 | 
			
		||||
#define DUALTIMER_MAX_VALUE     0xFFFFFFFF
 | 
			
		||||
#define DUALTIMER_TICKS_US      (SystemCoreClock/1000000)
 | 
			
		||||
 | 
			
		||||
/* Dual Timers Array */
 | 
			
		||||
static apb_dualtimer_t DualTimers[NUM_DUALTIMERS];
 | 
			
		||||
 | 
			
		||||
/*
 | 
			
		||||
 * DualTimer_Initialize(): Initializes a hardware timer
 | 
			
		||||
 * timer: timer to be Initialized
 | 
			
		||||
 * time_us: timer reload value in us - 0 to reload to timer max value
 | 
			
		||||
 *          time_us = ticks_value / TIMER_TICK_US
 | 
			
		||||
 */
 | 
			
		||||
void DualTimer_Initialize(uint32_t timer, uint32_t time_us)
 | 
			
		||||
{
 | 
			
		||||
    uint32_t reload = 0;
 | 
			
		||||
 | 
			
		||||
    if (timer < NUM_DUALTIMERS)
 | 
			
		||||
    {
 | 
			
		||||
        if (time_us == 0)
 | 
			
		||||
            reload = DUALTIMER_MAX_VALUE;
 | 
			
		||||
        else
 | 
			
		||||
            reload = (time_us) * DUALTIMER_TICKS_US;
 | 
			
		||||
 | 
			
		||||
        switch(timer) {
 | 
			
		||||
            case 0: DualTimers[timer].dualtimer1 = CMSDK_DUALTIMER1;
 | 
			
		||||
                    DualTimers[timer].dualtimer2 = CMSDK_DUALTIMER2;
 | 
			
		||||
                    DualTimers[timer].dualtimerIRQn = DUALTIMER_IRQn;
 | 
			
		||||
                    DualTimers[timer].dualtimer1Reload = reload;
 | 
			
		||||
                    DualTimers[timer].dualtimer2Reload = reload;
 | 
			
		||||
                    DualTimers[timer].state = DUALTIMER_INITIALIZED;
 | 
			
		||||
            default: break;
 | 
			
		||||
        }
 | 
			
		||||
    }
 | 
			
		||||
}
 | 
			
		||||
 | 
			
		||||
/*
 | 
			
		||||
 * DualTimer_ReturnMode(): returns the correct mode for Dual Timer Control
 | 
			
		||||
 * mode: mode set by user
 | 
			
		||||
 * @return: mode for TimeControl register
 | 
			
		||||
 */
 | 
			
		||||
uint32_t DualTimer_ReturnMode(timerenable_t mode)
 | 
			
		||||
{
 | 
			
		||||
    uint32_t return_mode = 0;
 | 
			
		||||
    /* Check Interrupt Enable */
 | 
			
		||||
    if (((mode & DUALTIMER_INT) >> DUALTIMER_INT_MASK) == 1)
 | 
			
		||||
        return_mode |= CMSDK_DUALTIMER_CTRL_INTEN_Msk;
 | 
			
		||||
    /* Check 32 bit Counter */
 | 
			
		||||
    if (((mode & DUALTIMER_COUNT_32) >> DUALTIMER_COUNT_32_MASK) == 1)
 | 
			
		||||
        return_mode |= CMSDK_DUALTIMER_CTRL_SIZE_Msk;
 | 
			
		||||
    /* Check Periodic Mode */
 | 
			
		||||
    if (((mode & DUALTIMER_PERIODIC) >> DUALTIMER_PERIODIC_MASK) == 1)
 | 
			
		||||
        return_mode |= CMSDK_DUALTIMER_CTRL_MODE_Msk;
 | 
			
		||||
    /* Check OneShot Mode */
 | 
			
		||||
    if (((mode & DUALTIMER_ONESHOT) >> DUALTIMER_ONESHOT_MASK) == 1)
 | 
			
		||||
        return_mode |= CMSDK_DUALTIMER_CTRL_ONESHOOT_Msk;
 | 
			
		||||
 | 
			
		||||
    return return_mode;
 | 
			
		||||
}
 | 
			
		||||
 | 
			
		||||
/*
 | 
			
		||||
 * DualTimer_Enable(): Enables a hardware timer
 | 
			
		||||
 * timer: timer to be enabled
 | 
			
		||||
 * mode: enable mode
 | 
			
		||||
 */
 | 
			
		||||
void DualTimer_Enable(uint32_t timer, timerenable_t mode)
 | 
			
		||||
{
 | 
			
		||||
    uint32_t dualtimerControl = 0;
 | 
			
		||||
    /* The timer has to be contained in a valid range */
 | 
			
		||||
    if (timer < NUM_DUALTIMERS) {
 | 
			
		||||
        /* Timer has to be already initialized */
 | 
			
		||||
        if (DualTimers[timer].state == DUALTIMER_INITIALIZED) {
 | 
			
		||||
            /* Disable Timer */
 | 
			
		||||
            (DualTimers[timer].dualtimer1)->TimerControl = 0x0;
 | 
			
		||||
            (DualTimers[timer].dualtimer2)->TimerControl = 0x0;
 | 
			
		||||
            /* Reload Value */
 | 
			
		||||
            (DualTimers[timer].dualtimer1)->TimerLoad =
 | 
			
		||||
                                            DualTimers[timer].dualtimer1Reload;
 | 
			
		||||
            (DualTimers[timer].dualtimer2)->TimerLoad =
 | 
			
		||||
                                            DualTimers[timer].dualtimer2Reload;
 | 
			
		||||
            /* Set up Dual Timer Control */
 | 
			
		||||
            dualtimerControl = DualTimer_ReturnMode(mode);
 | 
			
		||||
            (DualTimers[timer].dualtimer1)->TimerControl = dualtimerControl;
 | 
			
		||||
            (DualTimers[timer].dualtimer2)->TimerControl = dualtimerControl;
 | 
			
		||||
            /* Enable Counter */
 | 
			
		||||
            (DualTimers[timer].dualtimer1)->TimerControl |=
 | 
			
		||||
                                    CMSDK_DUALTIMER_CTRL_EN_Msk;
 | 
			
		||||
            (DualTimers[timer].dualtimer2)->TimerControl |=
 | 
			
		||||
                                    CMSDK_DUALTIMER_CTRL_EN_Msk;
 | 
			
		||||
            /* Change timer state */
 | 
			
		||||
            DualTimers[timer].state |= DUALTIMER_ENABLED;
 | 
			
		||||
        }
 | 
			
		||||
    }
 | 
			
		||||
}
 | 
			
		||||
 | 
			
		||||
/*
 | 
			
		||||
 * DualTimer_Disable(): Disables a hardware timer
 | 
			
		||||
 * timer: timer to be disabled
 | 
			
		||||
 * dis_timer: 0 both - 1 dual timer 1 - 2 dual timer 2
 | 
			
		||||
 */
 | 
			
		||||
void DualTimer_Disable(uint32_t timer, uint32_t dis_timer)
 | 
			
		||||
{
 | 
			
		||||
    /* The timer has to be contained in a valid range */
 | 
			
		||||
    if (timer < NUM_DUALTIMERS) {
 | 
			
		||||
        /* Timer has to be already initialized and enabled */
 | 
			
		||||
        if (DualTimers[timer].state == (DUALTIMER_INITIALIZED | DUALTIMER_ENABLED)) {
 | 
			
		||||
            /* Disable Timer */
 | 
			
		||||
            switch (dis_timer)
 | 
			
		||||
            {
 | 
			
		||||
                case 0: (DualTimers[timer].dualtimer1)->TimerControl = 0x0;
 | 
			
		||||
                        (DualTimers[timer].dualtimer2)->TimerControl = 0x0;
 | 
			
		||||
                        break;
 | 
			
		||||
                case 1: (DualTimers[timer].dualtimer1)->TimerControl = 0x0;
 | 
			
		||||
                        break;
 | 
			
		||||
                case 2: (DualTimers[timer].dualtimer2)->TimerControl = 0x0;
 | 
			
		||||
                        break;
 | 
			
		||||
                default: break;
 | 
			
		||||
            }
 | 
			
		||||
            /* Change timer state */
 | 
			
		||||
            DualTimers[timer].state = DUALTIMER_INITIALIZED;
 | 
			
		||||
        }
 | 
			
		||||
    }
 | 
			
		||||
}
 | 
			
		||||
 | 
			
		||||
/*
 | 
			
		||||
 * DualTimer_isEnabled(): verifies if a timer is enabled
 | 
			
		||||
 * timer: timer to be verified
 | 
			
		||||
 * @return: 0 disabled - 1 enabled
 | 
			
		||||
 */
 | 
			
		||||
uint32_t DualTimer_isEnabled(uint32_t timer)
 | 
			
		||||
{
 | 
			
		||||
    /* The timer has to be contained in a valid range */
 | 
			
		||||
    if (timer < NUM_DUALTIMERS) {
 | 
			
		||||
        /* Timer has to be already initialized and enabled */
 | 
			
		||||
        if (DualTimers[timer].state == (DUALTIMER_INITIALIZED | DUALTIMER_ENABLED))
 | 
			
		||||
            return 1;
 | 
			
		||||
    } else {
 | 
			
		||||
        return 0;
 | 
			
		||||
    }
 | 
			
		||||
    return 0;
 | 
			
		||||
}
 | 
			
		||||
 | 
			
		||||
/*
 | 
			
		||||
 * DualTimer_Read_1(): provides single timer 1 VALUE
 | 
			
		||||
 * timer: timer to be read
 | 
			
		||||
 * @return: timer VALUE
 | 
			
		||||
 */
 | 
			
		||||
uint32_t DualTimer_Read_1(uint32_t timer)
 | 
			
		||||
{
 | 
			
		||||
    uint32_t return_value = 0;
 | 
			
		||||
    /* Verify if the Timer is enabled */
 | 
			
		||||
    if (DualTimer_isEnabled(timer) == 1) {
 | 
			
		||||
        return_value = (DualTimers[timer].dualtimer1Reload
 | 
			
		||||
                    - (DualTimers[timer].dualtimer1)->TimerValue)
 | 
			
		||||
                    / DUALTIMER_TICKS_US;
 | 
			
		||||
    }
 | 
			
		||||
 | 
			
		||||
    return return_value;
 | 
			
		||||
}
 | 
			
		||||
 | 
			
		||||
/*
 | 
			
		||||
 * DualTimer_Read_2(): provides single timer 2 VALUE
 | 
			
		||||
 * timer: timer to be read
 | 
			
		||||
 * @return: timer VALUE
 | 
			
		||||
 */
 | 
			
		||||
uint32_t DualTimer_Read_2(uint32_t timer)
 | 
			
		||||
{
 | 
			
		||||
    uint32_t return_value = 0;
 | 
			
		||||
    /* Verify if the Timer is enabled */
 | 
			
		||||
    if (DualTimer_isEnabled(timer) == 1) {
 | 
			
		||||
        return_value = (DualTimers[timer].dualtimer2Reload
 | 
			
		||||
                    - (DualTimers[timer].dualtimer2)->TimerValue)
 | 
			
		||||
                    / DUALTIMER_TICKS_US;
 | 
			
		||||
    }
 | 
			
		||||
 | 
			
		||||
    return return_value;
 | 
			
		||||
}
 | 
			
		||||
 | 
			
		||||
/*
 | 
			
		||||
 * DualTimer_SetInterrupt_1(): sets timer 1 Interrupt
 | 
			
		||||
 * timer: timer on which interrupt is set
 | 
			
		||||
 * time_us: reloading value us
 | 
			
		||||
 * mode: enable mode
 | 
			
		||||
 */
 | 
			
		||||
void DualTimer_SetInterrupt_1(uint32_t timer, uint32_t time_us,
 | 
			
		||||
            timerenable_t mode)
 | 
			
		||||
{
 | 
			
		||||
    uint32_t dualtimerControl = 0;
 | 
			
		||||
    uint32_t load_time_us = 0;
 | 
			
		||||
    /* Verify if the Timer is enabled */
 | 
			
		||||
    if (DualTimer_isEnabled(timer) == 1) {
 | 
			
		||||
        /* Disable Timer */
 | 
			
		||||
        DualTimer_Disable(timer, SINGLETIMER1);
 | 
			
		||||
        /* Set up Dual Timer Control */
 | 
			
		||||
        dualtimerControl = DualTimer_ReturnMode(mode);
 | 
			
		||||
        (DualTimers[timer].dualtimer1)->TimerControl =
 | 
			
		||||
                                CMSDK_DUALTIMER_CTRL_INTEN_Msk
 | 
			
		||||
                                | dualtimerControl;
 | 
			
		||||
 | 
			
		||||
        /* Check time us condition */
 | 
			
		||||
        if(time_us == DUALTIMER_DEFAULT_RELOAD)
 | 
			
		||||
            load_time_us = DUALTIMER_MAX_VALUE;
 | 
			
		||||
        else
 | 
			
		||||
            load_time_us = time_us * DUALTIMER_TICKS_US;
 | 
			
		||||
 | 
			
		||||
        /* Reload Value */
 | 
			
		||||
        DualTimers[timer].dualtimer1Reload = load_time_us;
 | 
			
		||||
        (DualTimers[timer].dualtimer1)->TimerLoad =
 | 
			
		||||
                                DualTimers[timer].dualtimer1Reload;
 | 
			
		||||
        /* Enable Counter */
 | 
			
		||||
        (DualTimers[timer].dualtimer1)->TimerControl |=
 | 
			
		||||
                                CMSDK_DUALTIMER_CTRL_EN_Msk;
 | 
			
		||||
        /* Change timer state */
 | 
			
		||||
        DualTimers[timer].state |= DUALTIMER_ENABLED;
 | 
			
		||||
    }
 | 
			
		||||
}
 | 
			
		||||
 | 
			
		||||
/*
 | 
			
		||||
 * DualTimer_SetInterrupt_2(): sets timer 2 Interrupt
 | 
			
		||||
 * timer: timer on which interrupt is set
 | 
			
		||||
 * time_us: reloading value us
 | 
			
		||||
 * mode: enable mode
 | 
			
		||||
 */
 | 
			
		||||
void DualTimer_SetInterrupt_2(uint32_t timer, uint32_t time_us,
 | 
			
		||||
            timerenable_t mode)
 | 
			
		||||
{
 | 
			
		||||
    uint32_t dualtimerControl = 0;
 | 
			
		||||
    uint32_t load_time_us = 0;
 | 
			
		||||
    /* Verify if the Timer is enabled */
 | 
			
		||||
    if (DualTimer_isEnabled(timer) == 1) {
 | 
			
		||||
        /* Disable Timer */
 | 
			
		||||
        DualTimer_Disable(timer, SINGLETIMER2);
 | 
			
		||||
        /* Set up Dual Timer Control */
 | 
			
		||||
        dualtimerControl = DualTimer_ReturnMode(mode);
 | 
			
		||||
        (DualTimers[timer].dualtimer2)->TimerControl =
 | 
			
		||||
                                CMSDK_DUALTIMER_CTRL_INTEN_Msk
 | 
			
		||||
                                | dualtimerControl;
 | 
			
		||||
 | 
			
		||||
        /* Check time us condition */
 | 
			
		||||
        if(time_us == DUALTIMER_DEFAULT_RELOAD)
 | 
			
		||||
            load_time_us = DUALTIMER_MAX_VALUE;
 | 
			
		||||
        else
 | 
			
		||||
            load_time_us = time_us * DUALTIMER_TICKS_US;
 | 
			
		||||
 | 
			
		||||
        /* Reload Value */
 | 
			
		||||
        DualTimers[timer].dualtimer2Reload = load_time_us;
 | 
			
		||||
        (DualTimers[timer].dualtimer2)->TimerLoad =
 | 
			
		||||
                                DualTimers[timer].dualtimer2Reload;
 | 
			
		||||
        /* Enable Counter */
 | 
			
		||||
        (DualTimers[timer].dualtimer2)->TimerControl |=
 | 
			
		||||
                                CMSDK_DUALTIMER_CTRL_EN_Msk;
 | 
			
		||||
        /* Change timer state */
 | 
			
		||||
        DualTimers[timer].state |= DUALTIMER_ENABLED;
 | 
			
		||||
    }
 | 
			
		||||
}
 | 
			
		||||
 | 
			
		||||
/*
 | 
			
		||||
 * DualTimer_DisableInterrupt(): disables timer interrupts
 | 
			
		||||
 * dualimer: dualtimer on which interrupt is disabled
 | 
			
		||||
 * single_timer: single timer in the dualtimer on which
 | 
			
		||||
 *               interrupt is disabled
 | 
			
		||||
 */
 | 
			
		||||
void DualTimer_DisableInterrupt(uint32_t dualtimer,
 | 
			
		||||
                                uint32_t single_timer)
 | 
			
		||||
{
 | 
			
		||||
    /* Verify if the Timer is enabled */
 | 
			
		||||
    if (DualTimer_isEnabled(dualtimer) == 1) {
 | 
			
		||||
        switch(single_timer) {
 | 
			
		||||
            case SINGLETIMER1:
 | 
			
		||||
                /* Disable Interrupt for single timer 1 */
 | 
			
		||||
                (DualTimers[dualtimer].dualtimer1)->TimerControl &=
 | 
			
		||||
                                       CMSDK_DUALTIMER_CTRL_EN_Msk;
 | 
			
		||||
                break;
 | 
			
		||||
            case SINGLETIMER2:
 | 
			
		||||
                /* Disable Interrupt for single timer 2 */
 | 
			
		||||
                (DualTimers[dualtimer].dualtimer2)->TimerControl &=
 | 
			
		||||
                                       CMSDK_DUALTIMER_CTRL_EN_Msk;
 | 
			
		||||
                break;
 | 
			
		||||
            case ALL_SINGLETIMERS:
 | 
			
		||||
                /* Disable Interrupt for single timer 1 */
 | 
			
		||||
                (DualTimers[dualtimer].dualtimer1)->TimerControl &=
 | 
			
		||||
                                       CMSDK_DUALTIMER_CTRL_EN_Msk;
 | 
			
		||||
                /* Disable Interrupt for single timer 2 */
 | 
			
		||||
                (DualTimers[dualtimer].dualtimer2)->TimerControl &=
 | 
			
		||||
                                       CMSDK_DUALTIMER_CTRL_EN_Msk;
 | 
			
		||||
                break;
 | 
			
		||||
            default:
 | 
			
		||||
                break;
 | 
			
		||||
        }
 | 
			
		||||
    }
 | 
			
		||||
}
 | 
			
		||||
 | 
			
		||||
/*
 | 
			
		||||
 * DualTimer_ClearInterrupt(): clear timer interrupt
 | 
			
		||||
 * timer: timer on which interrupt needs to be cleared
 | 
			
		||||
 */
 | 
			
		||||
void DualTimer_ClearInterrupt(uint32_t timer)
 | 
			
		||||
{
 | 
			
		||||
    /* Verify if the Timer is enabled */
 | 
			
		||||
    if (DualTimer_isEnabled(timer) == 1) {
 | 
			
		||||
        /* Clear Interrupt */
 | 
			
		||||
        (DualTimers[timer].dualtimer1)->TimerIntClr =
 | 
			
		||||
                                CMSDK_DUALTIMER_INTCLR_Msk;
 | 
			
		||||
        (DualTimers[timer].dualtimer2)->TimerIntClr =
 | 
			
		||||
                                CMSDK_DUALTIMER_INTCLR_Msk;
 | 
			
		||||
    }
 | 
			
		||||
}
 | 
			
		||||
 | 
			
		||||
/*
 | 
			
		||||
 * DualTimer_GetIRQn(): returns IRQn of a DualTimer
 | 
			
		||||
 * timer: timer on which IRQn is defined - 0 if it is not defined
 | 
			
		||||
 */
 | 
			
		||||
uint32_t DualTimer_GetIRQn(uint32_t timer)
 | 
			
		||||
{
 | 
			
		||||
    /* Verify if the Timer is enabled */
 | 
			
		||||
    if (DualTimer_isEnabled(timer) == 1) {
 | 
			
		||||
        return DualTimers[timer].dualtimerIRQn;
 | 
			
		||||
    }
 | 
			
		||||
    return 0;
 | 
			
		||||
}
 | 
			
		||||
 | 
			
		||||
/*
 | 
			
		||||
 * DualTimer_GetIRQInfo(): provides the single timer who caused
 | 
			
		||||
 * the interrupt.
 | 
			
		||||
 * dualtimer: dualtimer that triggered the IRQ
 | 
			
		||||
 * @return: a single timer - 0 if it is not defined
 | 
			
		||||
 */
 | 
			
		||||
uint32_t DualTimer_GetIRQInfo(uint32_t timer)
 | 
			
		||||
{
 | 
			
		||||
    /* Verify if the Timer is enabled */
 | 
			
		||||
    if (DualTimer_isEnabled(timer) == 1) {
 | 
			
		||||
        if((DualTimers[timer].dualtimer1)->TimerRIS)
 | 
			
		||||
            return SINGLETIMER1;
 | 
			
		||||
        else
 | 
			
		||||
            return SINGLETIMER2;
 | 
			
		||||
    }
 | 
			
		||||
    return 0;
 | 
			
		||||
}
 | 
			
		||||
 | 
			
		||||
/*
 | 
			
		||||
 * DualTimer_GetTicksUS(): returns the Ticks per us
 | 
			
		||||
 * timer: timer associated with the Ticks per us
 | 
			
		||||
 * @return: Ticks per us - 0 if the timer is disables
 | 
			
		||||
 */
 | 
			
		||||
uint32_t DualTimer_GetTicksUS(uint32_t timer)
 | 
			
		||||
{
 | 
			
		||||
    /* Verify if the Timer is enabled */
 | 
			
		||||
    if (DualTimer_isEnabled(timer) == 1) {
 | 
			
		||||
        return DUALTIMER_TICKS_US;
 | 
			
		||||
    }
 | 
			
		||||
    return 0;
 | 
			
		||||
}
 | 
			
		||||
 | 
			
		||||
/*
 | 
			
		||||
 * DualTimer_GetReloadValue(): returns the load value of the selected
 | 
			
		||||
 * singletimer.
 | 
			
		||||
 * timer: timer associated with the Ticks per us
 | 
			
		||||
 * singletimer: selected singletimer
 | 
			
		||||
 * @return: reload value of the selected singletimer - 0 if timer is disabled
 | 
			
		||||
 */
 | 
			
		||||
uint32_t DualTimer_GetReloadValue(uint32_t timer, uint32_t singletimer)
 | 
			
		||||
{
 | 
			
		||||
    /* Verify if the Timer is enabled */
 | 
			
		||||
    if (DualTimer_isEnabled(timer) == 1) {
 | 
			
		||||
        if (singletimer == SINGLETIMER1)
 | 
			
		||||
            return DualTimers[timer].dualtimer1Reload / DUALTIMER_TICKS_US;
 | 
			
		||||
        else
 | 
			
		||||
            return DualTimers[timer].dualtimer2Reload / DUALTIMER_TICKS_US;
 | 
			
		||||
    }
 | 
			
		||||
    return 0;
 | 
			
		||||
}
 | 
			
		||||
| 
						 | 
				
			
			@ -1,158 +0,0 @@
 | 
			
		|||
/* mbed Microcontroller Library
 | 
			
		||||
 * Copyright (c) 2016 ARM Limited
 | 
			
		||||
 *
 | 
			
		||||
 * Licensed under the Apache License, Version 2.0 (the "License");
 | 
			
		||||
 * you may not use this file except in compliance with the License.
 | 
			
		||||
 * You may obtain a copy of the License at
 | 
			
		||||
 *
 | 
			
		||||
 *     http://www.apache.org/licenses/LICENSE-2.0
 | 
			
		||||
 *
 | 
			
		||||
 * Unless required by applicable law or agreed to in writing, software
 | 
			
		||||
 * distributed under the License is distributed on an "AS IS" BASIS,
 | 
			
		||||
 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
 | 
			
		||||
 * See the License for the specific language governing permissions and
 | 
			
		||||
 * limitations under the License.
 | 
			
		||||
 */
 | 
			
		||||
 | 
			
		||||
#ifndef _APB_DUAL_TIMER_DRV_H
 | 
			
		||||
#define _APB_DUAL_TIMER_DRV_H
 | 
			
		||||
 | 
			
		||||
#ifdef __cplusplus
 | 
			
		||||
extern "C" {
 | 
			
		||||
#endif
 | 
			
		||||
 | 
			
		||||
/* Supported Number of Dual Timers */
 | 
			
		||||
#define NUM_DUALTIMERS   1
 | 
			
		||||
#define DUALTIMER0       0
 | 
			
		||||
#define SINGLETIMER1     1
 | 
			
		||||
#define SINGLETIMER2     2
 | 
			
		||||
#define ALL_SINGLETIMERS 3
 | 
			
		||||
 | 
			
		||||
/*
 | 
			
		||||
 * DualTimer_Initialize(): Initializes a hardware timer
 | 
			
		||||
 * timer: timer to be Initialized
 | 
			
		||||
 * time_us: timer reload value in us - 0 to reload to timer max value
 | 
			
		||||
 *          time_us = tick_value / TIMER_TICK_US
 | 
			
		||||
 */
 | 
			
		||||
void DualTimer_Initialize(uint32_t timer, uint32_t time_us);
 | 
			
		||||
 | 
			
		||||
/* Enable Mode */
 | 
			
		||||
typedef uint8_t timerenable_t;
 | 
			
		||||
/* Interrupt */
 | 
			
		||||
#define DUALTIMER_INT_MASK      (0)
 | 
			
		||||
#define DUALTIMER_INT           (1 << DUALTIMER_INT_MASK)
 | 
			
		||||
/* 32 bit Counter */
 | 
			
		||||
#define DUALTIMER_COUNT_32_MASK (1)
 | 
			
		||||
#define DUALTIMER_COUNT_32      (1 << DUALTIMER_COUNT_32_MASK)
 | 
			
		||||
/* Periodic mode */
 | 
			
		||||
#define DUALTIMER_PERIODIC_MASK (2)
 | 
			
		||||
#define DUALTIMER_PERIODIC      (1 << DUALTIMER_PERIODIC_MASK)
 | 
			
		||||
/* OneShot mode */
 | 
			
		||||
#define DUALTIMER_ONESHOT_MASK  (3)
 | 
			
		||||
#define DUALTIMER_ONESHOT       (1 << DUALTIMER_ONESHOT_MASK)
 | 
			
		||||
 | 
			
		||||
/* Default reload */
 | 
			
		||||
#define DUALTIMER_DEFAULT_RELOAD    0xFFFFFFFF
 | 
			
		||||
 | 
			
		||||
/*
 | 
			
		||||
 * DualTimer_Enable(): Enables a hardware timer
 | 
			
		||||
 * timer: timer to be enabled
 | 
			
		||||
 * mode: enable mode
 | 
			
		||||
 */
 | 
			
		||||
void DualTimer_Enable(uint32_t timer, timerenable_t mode);
 | 
			
		||||
 | 
			
		||||
/*
 | 
			
		||||
 * DualTimer_Disable(): Disables a hardware timer
 | 
			
		||||
 * timer: timer to be disabled
 | 
			
		||||
 * dis_timer: 0 both - 1 dual timer 1 - 2 dual timer 2
 | 
			
		||||
 */
 | 
			
		||||
void DualTimer_Disable(uint32_t timer, uint32_t dis_timer);
 | 
			
		||||
 | 
			
		||||
/*
 | 
			
		||||
 * DualTimer_isEnabled(): verifies if a timer is enabled
 | 
			
		||||
 * timer: timer to be verified
 | 
			
		||||
 * @return: 0 disabled - 1 enabled
 | 
			
		||||
 */
 | 
			
		||||
uint32_t DualTimer_isEnabled(uint32_t timer);
 | 
			
		||||
 | 
			
		||||
/*
 | 
			
		||||
 * DualTimer_Read_1(): provides single timer 1 VALUE
 | 
			
		||||
 * timer: timer to be read
 | 
			
		||||
 * @return: timer VALUE us
 | 
			
		||||
 */
 | 
			
		||||
uint32_t DualTimer_Read_1(uint32_t timer);
 | 
			
		||||
 | 
			
		||||
/*
 | 
			
		||||
 * DualTimer_Read_2(): provides single timer 2 VALUE
 | 
			
		||||
 * timer: timer to be read
 | 
			
		||||
 * @return: timer VALUE us
 | 
			
		||||
 */
 | 
			
		||||
uint32_t DualTimer_Read_2(uint32_t timer);
 | 
			
		||||
 | 
			
		||||
/*
 | 
			
		||||
 * DualTimer_SetInterrupt_1(): sets timer 1 Interrupt
 | 
			
		||||
 * timer: timer on which interrupt is set
 | 
			
		||||
 * time_us: reloading value us
 | 
			
		||||
 * mode: enable mode
 | 
			
		||||
 */
 | 
			
		||||
void DualTimer_SetInterrupt_1(uint32_t timer, uint32_t time_us,
 | 
			
		||||
            timerenable_t mode);
 | 
			
		||||
 | 
			
		||||
/*
 | 
			
		||||
 * DualTimer_SetInterrupt_2(): sets timer 2 Interrupt
 | 
			
		||||
 * timer: timer on which interrupt is set
 | 
			
		||||
 * time_us: reloading value us
 | 
			
		||||
 * mode: enable mode
 | 
			
		||||
 */
 | 
			
		||||
void DualTimer_SetInterrupt_2(uint32_t timer, uint32_t time_us,
 | 
			
		||||
            timerenable_t mode);
 | 
			
		||||
 | 
			
		||||
/*
 | 
			
		||||
 * DualTimer_DisableInterrupt(): disables timer interrupts
 | 
			
		||||
 * dualimer: dualtimer on which interrupt is disabled
 | 
			
		||||
 * single_timer: single timer in the dualtimer on which
 | 
			
		||||
 *               interrupt is disabled
 | 
			
		||||
 */
 | 
			
		||||
void DualTimer_DisableInterrupt(uint32_t dualtimer,
 | 
			
		||||
                                uint32_t single_timer);
 | 
			
		||||
 | 
			
		||||
/*
 | 
			
		||||
 * DualTimer_ClearInterrupt(): clear timer interrupt
 | 
			
		||||
 * timer: timer on which interrupt needs to be cleared
 | 
			
		||||
 */
 | 
			
		||||
void DualTimer_ClearInterrupt(uint32_t timer);
 | 
			
		||||
 | 
			
		||||
/*
 | 
			
		||||
 * DualTimer_GetIRQn(): returns IRQn of a DualTimer
 | 
			
		||||
 * timer: timer on which IRQn is defined - 0 if it is not defined
 | 
			
		||||
 */
 | 
			
		||||
uint32_t DualTimer_GetIRQn(uint32_t timer);
 | 
			
		||||
 | 
			
		||||
/*
 | 
			
		||||
 * DualTimer_GetIRQInfo(): provides the single timer who caused
 | 
			
		||||
 * the interrupt.
 | 
			
		||||
 * timer: dualtimer that triggered the IRQ
 | 
			
		||||
 * @return: a single timer
 | 
			
		||||
 */
 | 
			
		||||
uint32_t DualTimer_GetIRQInfo(uint32_t dualtimer);
 | 
			
		||||
 | 
			
		||||
/*
 | 
			
		||||
 * DualTimer_GetTicksUS(): returns the Ticks per us
 | 
			
		||||
 * timer: timer associated with the Ticks per us
 | 
			
		||||
 * @return: Ticks per us - 0 if the timer is disables
 | 
			
		||||
 */
 | 
			
		||||
uint32_t DualTimer_GetTicksUS(uint32_t timer);
 | 
			
		||||
 | 
			
		||||
/*
 | 
			
		||||
 * DualTimer_GetReloadValue(): returns the load value of the selected
 | 
			
		||||
 * singletimer.
 | 
			
		||||
 * timer: timer associated with the Ticks per us
 | 
			
		||||
 * singletimer: selected singletimer
 | 
			
		||||
 * @return: reload value of the selected singletimer
 | 
			
		||||
 */
 | 
			
		||||
uint32_t DualTimer_GetReloadValue(uint32_t timer, uint32_t singletimer);
 | 
			
		||||
 | 
			
		||||
#ifdef __cplusplus
 | 
			
		||||
}
 | 
			
		||||
#endif
 | 
			
		||||
#endif /* _APB_DUAL_TIMER_DRV_H */
 | 
			
		||||
| 
						 | 
				
			
			@ -1,262 +0,0 @@
 | 
			
		|||
/* mbed Microcontroller Library
 | 
			
		||||
 * Copyright (c) 2016 ARM Limited
 | 
			
		||||
 *
 | 
			
		||||
 * Licensed under the Apache License, Version 2.0 (the "License");
 | 
			
		||||
 * you may not use this file except in compliance with the License.
 | 
			
		||||
 * You may obtain a copy of the License at
 | 
			
		||||
 *
 | 
			
		||||
 *     http://www.apache.org/licenses/LICENSE-2.0
 | 
			
		||||
 *
 | 
			
		||||
 * Unless required by applicable law or agreed to in writing, software
 | 
			
		||||
 * distributed under the License is distributed on an "AS IS" BASIS,
 | 
			
		||||
 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
 | 
			
		||||
 * See the License for the specific language governing permissions and
 | 
			
		||||
 * limitations under the License.
 | 
			
		||||
 */
 | 
			
		||||
#include "cmsis.h"
 | 
			
		||||
#include "apb_timer.h"
 | 
			
		||||
 | 
			
		||||
/* Timer Private Data */
 | 
			
		||||
typedef struct {
 | 
			
		||||
    /* Timer Definition */
 | 
			
		||||
    CMSDK_TIMER_TypeDef *timerN;
 | 
			
		||||
    /* Timer IRQn */
 | 
			
		||||
    uint32_t timerIRQn;
 | 
			
		||||
    /* Timer Reload Value */
 | 
			
		||||
    uint32_t timerReload;
 | 
			
		||||
    /* Timer state */
 | 
			
		||||
    uint32_t state;
 | 
			
		||||
} apb_timer_t;
 | 
			
		||||
 | 
			
		||||
/* Timer state definitions */
 | 
			
		||||
#define TIMER_INITIALIZED   (1)
 | 
			
		||||
#define TIMER_ENABLED       (1 << 1)
 | 
			
		||||
 | 
			
		||||
/*
 | 
			
		||||
 * This Timer is written for MBED OS and keeps count
 | 
			
		||||
 * of the ticks. All the elaboration logic is demanded
 | 
			
		||||
 * to the upper layers.
 | 
			
		||||
 */
 | 
			
		||||
#define TIMER_MAX_VALUE     0xFFFFFFFF
 | 
			
		||||
#define TIMER_TICKS_US      (SystemCoreClock/1000000)
 | 
			
		||||
 | 
			
		||||
/* Timers Array */
 | 
			
		||||
static apb_timer_t Timers[NUM_TIMERS];
 | 
			
		||||
 | 
			
		||||
void Timer_Index_Init(uint32_t timer, uint32_t reload,
 | 
			
		||||
    CMSDK_TIMER_TypeDef *TimerN, uint32_t IRQn)
 | 
			
		||||
{
 | 
			
		||||
    Timers[timer].timerN = TimerN;
 | 
			
		||||
    Timers[timer].timerIRQn = IRQn;
 | 
			
		||||
    Timers[timer].timerReload = reload;
 | 
			
		||||
    Timers[timer].state = TIMER_INITIALIZED;
 | 
			
		||||
}
 | 
			
		||||
 | 
			
		||||
/*
 | 
			
		||||
 * Timer_Initialize(): Initializes an hardware timer
 | 
			
		||||
 * timer: timer to be Initialized
 | 
			
		||||
 * time_us: timer reload value in us - 0 to reload to timer max value
 | 
			
		||||
 *          time_us = tick_value / TIMER_TICKS_US
 | 
			
		||||
 */
 | 
			
		||||
#define TIMER_INIT(index, reload) Timer_Index_Init(index, reload, CMSDK_TIMER##index, TIMER##index##_IRQn)
 | 
			
		||||
void Timer_Initialize(uint32_t timer, uint32_t time_us)
 | 
			
		||||
{
 | 
			
		||||
    uint32_t reload = 0;
 | 
			
		||||
 | 
			
		||||
    if (timer < NUM_TIMERS)
 | 
			
		||||
    {
 | 
			
		||||
        if (time_us == 0)
 | 
			
		||||
            reload = TIMER_MAX_VALUE;
 | 
			
		||||
        else
 | 
			
		||||
            reload = (time_us) * TIMER_TICKS_US;
 | 
			
		||||
 | 
			
		||||
        switch(timer) {
 | 
			
		||||
            case 0: TIMER_INIT(0, reload);
 | 
			
		||||
                    break;
 | 
			
		||||
            case 1: TIMER_INIT(1, reload);
 | 
			
		||||
                    break;
 | 
			
		||||
            default: break;
 | 
			
		||||
        }
 | 
			
		||||
    }
 | 
			
		||||
}
 | 
			
		||||
 | 
			
		||||
/*
 | 
			
		||||
 * Timer_Enable(): Enables a hardware timer
 | 
			
		||||
 * timer: timer to be enabled
 | 
			
		||||
 */
 | 
			
		||||
void Timer_Enable(uint32_t timer)
 | 
			
		||||
{
 | 
			
		||||
    /* The timer has to be contained in a valid range */
 | 
			
		||||
    if (timer < NUM_TIMERS) {
 | 
			
		||||
        /* Timer has to be already initialized */
 | 
			
		||||
        if (Timers[timer].state == TIMER_INITIALIZED) {
 | 
			
		||||
            /* Disable Timer */
 | 
			
		||||
            (Timers[timer].timerN)->CTRL = 0x0;
 | 
			
		||||
            /* Reload Value */
 | 
			
		||||
            (Timers[timer].timerN)->RELOAD = Timers[timer].timerReload;
 | 
			
		||||
            /* Enable Interrupt */
 | 
			
		||||
            (Timers[timer].timerN)->CTRL = CMSDK_TIMER_CTRL_IRQEN_Msk;
 | 
			
		||||
            /* Enable Counter */
 | 
			
		||||
            (Timers[timer].timerN)->CTRL |= CMSDK_TIMER_CTRL_EN_Msk;
 | 
			
		||||
            /* Change timer state */
 | 
			
		||||
            Timers[timer].state |= TIMER_ENABLED;
 | 
			
		||||
        }
 | 
			
		||||
    }
 | 
			
		||||
}
 | 
			
		||||
 | 
			
		||||
/*
 | 
			
		||||
 * Timer_Disable(): Disables a hardware timer
 | 
			
		||||
 * timer: timer to be disabled
 | 
			
		||||
 */
 | 
			
		||||
void Timer_Disable(uint32_t timer)
 | 
			
		||||
{
 | 
			
		||||
    /* The timer has to be contained in a valid range */
 | 
			
		||||
    if (timer < NUM_TIMERS) {
 | 
			
		||||
        /* Timer has to be already initialized and enabled */
 | 
			
		||||
        if (Timers[timer].state == (TIMER_INITIALIZED | TIMER_ENABLED)) {
 | 
			
		||||
            /* Disable Timer */
 | 
			
		||||
            (Timers[timer].timerN)->CTRL = 0x0;
 | 
			
		||||
            /* Change timer state */
 | 
			
		||||
            Timers[timer].state = TIMER_INITIALIZED;
 | 
			
		||||
        }
 | 
			
		||||
    }
 | 
			
		||||
}
 | 
			
		||||
 | 
			
		||||
/*
 | 
			
		||||
 * Timer_isEnabled(): verifies if a timer is enabled
 | 
			
		||||
 * timer: timer to be verified
 | 
			
		||||
 * @return: 0 disabled - 1 enabled
 | 
			
		||||
 */
 | 
			
		||||
uint32_t Timer_isEnabled(uint32_t timer)
 | 
			
		||||
{
 | 
			
		||||
    /* The timer has to be contained in a valid range */
 | 
			
		||||
    if (timer < NUM_TIMERS) {
 | 
			
		||||
        /* Timer has to be already initialized and enabled */
 | 
			
		||||
        if (Timers[timer].state == (TIMER_INITIALIZED | TIMER_ENABLED))
 | 
			
		||||
            return 1;
 | 
			
		||||
    } else {
 | 
			
		||||
        return 0;
 | 
			
		||||
    }
 | 
			
		||||
    return 0;
 | 
			
		||||
}
 | 
			
		||||
 | 
			
		||||
/*
 | 
			
		||||
 * Timer_Read(): provides timer VALUE
 | 
			
		||||
 * timer: timer to be read
 | 
			
		||||
 * @return: timer VALUE us
 | 
			
		||||
 */
 | 
			
		||||
uint32_t Timer_Read(uint32_t timer)
 | 
			
		||||
{
 | 
			
		||||
    uint32_t return_value = 0;
 | 
			
		||||
    /* Verify if the Timer is enabled */
 | 
			
		||||
    if (Timer_isEnabled(timer) == 1) {
 | 
			
		||||
        return_value = (Timers[timer].timerReload
 | 
			
		||||
                    - (Timers[timer].timerN)->VALUE)
 | 
			
		||||
                    / TIMER_TICKS_US;
 | 
			
		||||
    }
 | 
			
		||||
 | 
			
		||||
    return return_value;
 | 
			
		||||
}
 | 
			
		||||
 | 
			
		||||
/*
 | 
			
		||||
 * Timer_SetInterrupt(): sets timer Interrupt
 | 
			
		||||
 * timer: timer on which interrupt is set
 | 
			
		||||
 * time_us: reloading time in us
 | 
			
		||||
 */
 | 
			
		||||
void Timer_SetInterrupt(uint32_t timer, uint32_t time_us)
 | 
			
		||||
{
 | 
			
		||||
    uint32_t load_time_us = 0;
 | 
			
		||||
    /* Verify if the Timer is enabled */
 | 
			
		||||
    if (Timer_isEnabled(timer) == 1) {
 | 
			
		||||
        /* Disable Timer */
 | 
			
		||||
        Timer_Disable(timer);
 | 
			
		||||
        /* Enable Interrupt */
 | 
			
		||||
        (Timers[timer].timerN)->CTRL = CMSDK_TIMER_CTRL_IRQEN_Msk;
 | 
			
		||||
 | 
			
		||||
        /* Check time us condition */
 | 
			
		||||
        if(time_us == TIMER_DEFAULT_RELOAD)
 | 
			
		||||
            load_time_us = TIMER_MAX_VALUE;
 | 
			
		||||
        else
 | 
			
		||||
            load_time_us = time_us * TIMER_TICKS_US;
 | 
			
		||||
 | 
			
		||||
        /* Initialize Timer Value */
 | 
			
		||||
        Timers[timer].timerReload = load_time_us;
 | 
			
		||||
        (Timers[timer].timerN)->RELOAD = Timers[timer].timerReload;
 | 
			
		||||
        (Timers[timer].timerN)->VALUE = Timers[timer].timerReload;
 | 
			
		||||
        /* Enable Counter */
 | 
			
		||||
        (Timers[timer].timerN)->CTRL |= CMSDK_TIMER_CTRL_EN_Msk;
 | 
			
		||||
        /* Change timer state */
 | 
			
		||||
        Timers[timer].state |= TIMER_ENABLED;
 | 
			
		||||
    }
 | 
			
		||||
}
 | 
			
		||||
 | 
			
		||||
/*
 | 
			
		||||
 * Timer_DisableInterrupt(): disables timer interrupt
 | 
			
		||||
 * timer: timer on which interrupt is disabled
 | 
			
		||||
 */
 | 
			
		||||
void Timer_DisableInterrupt(uint32_t timer)
 | 
			
		||||
{
 | 
			
		||||
    /* Verify if the Timer is enabled */
 | 
			
		||||
    if (Timer_isEnabled(timer) == 1) {
 | 
			
		||||
        /* Disable Interrupt */
 | 
			
		||||
        (Timers[timer].timerN)->CTRL &= CMSDK_TIMER_CTRL_EN_Msk;
 | 
			
		||||
    }
 | 
			
		||||
}
 | 
			
		||||
 | 
			
		||||
/*
 | 
			
		||||
 * Timer_ClearInterrupt(): clear timer interrupt
 | 
			
		||||
 * timer: timer on which interrupt needs to be cleared
 | 
			
		||||
 */
 | 
			
		||||
void Timer_ClearInterrupt(uint32_t timer)
 | 
			
		||||
{
 | 
			
		||||
    /* Verify if the Timer is enabled */
 | 
			
		||||
    if (Timer_isEnabled(timer) == 1) {
 | 
			
		||||
        /* Clear Interrupt */
 | 
			
		||||
        (Timers[timer].timerN)->INTCLEAR = CMSDK_TIMER_INTCLEAR_Msk;
 | 
			
		||||
    }
 | 
			
		||||
}
 | 
			
		||||
 | 
			
		||||
/*
 | 
			
		||||
 * Timer_GetIRQn(): returns IRQn of a Timer
 | 
			
		||||
 * timer: timer on which IRQn is defined - 0 if it is not defined
 | 
			
		||||
 */
 | 
			
		||||
uint32_t Timer_GetIRQn(uint32_t timer)
 | 
			
		||||
{
 | 
			
		||||
    /* Verify if the Timer is enabled */
 | 
			
		||||
    if (Timer_isEnabled(timer) == 1) {
 | 
			
		||||
        return Timers[timer].timerIRQn;
 | 
			
		||||
    }
 | 
			
		||||
    return 0;
 | 
			
		||||
}
 | 
			
		||||
 | 
			
		||||
/*
 | 
			
		||||
 * Timer_GetTicksUS(): returns the number of Ticks per us
 | 
			
		||||
 * timer: timer associated with the Ticks per us
 | 
			
		||||
 * @return: Ticks per us - 0 if the timer is disables
 | 
			
		||||
 */
 | 
			
		||||
uint32_t Timer_GetTicksUS(uint32_t timer)
 | 
			
		||||
{
 | 
			
		||||
    /* Verify if the Timer is enabled */
 | 
			
		||||
    if (Timer_isEnabled(timer) == 1) {
 | 
			
		||||
        return TIMER_TICKS_US;
 | 
			
		||||
    }
 | 
			
		||||
    return 0;
 | 
			
		||||
}
 | 
			
		||||
 | 
			
		||||
/*
 | 
			
		||||
 * Timer_GetReloadValue(): returns the load value of the selected
 | 
			
		||||
 * timer.
 | 
			
		||||
 * timer: timer associated with the Ticks per us
 | 
			
		||||
 * @return: reload value of the selected singletimer
 | 
			
		||||
 */
 | 
			
		||||
uint32_t Timer_GetReloadValue(uint32_t timer)
 | 
			
		||||
{
 | 
			
		||||
    /* Verify if the Timer is enabled */
 | 
			
		||||
    if (Timer_isEnabled(timer) == 1) {
 | 
			
		||||
        if (timer == TIMER1)
 | 
			
		||||
            return Timers[timer].timerReload / TIMER_TICKS_US;
 | 
			
		||||
        else
 | 
			
		||||
            return Timers[timer].timerReload / TIMER_TICKS_US;
 | 
			
		||||
    }
 | 
			
		||||
    return 0;
 | 
			
		||||
}
 | 
			
		||||
| 
						 | 
				
			
			@ -1,109 +0,0 @@
 | 
			
		|||
/* mbed Microcontroller Library
 | 
			
		||||
 * Copyright (c) 2016 ARM Limited
 | 
			
		||||
 *
 | 
			
		||||
 * Licensed under the Apache License, Version 2.0 (the "License");
 | 
			
		||||
 * you may not use this file except in compliance with the License.
 | 
			
		||||
 * You may obtain a copy of the License at
 | 
			
		||||
 *
 | 
			
		||||
 *     http://www.apache.org/licenses/LICENSE-2.0
 | 
			
		||||
 *
 | 
			
		||||
 * Unless required by applicable law or agreed to in writing, software
 | 
			
		||||
 * distributed under the License is distributed on an "AS IS" BASIS,
 | 
			
		||||
 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
 | 
			
		||||
 * See the License for the specific language governing permissions and
 | 
			
		||||
 * limitations under the License.
 | 
			
		||||
 */
 | 
			
		||||
 | 
			
		||||
#ifndef _APB_TIMER_DRV_H
 | 
			
		||||
#define _APB_TIMER_DRV_H
 | 
			
		||||
 | 
			
		||||
#ifdef __cplusplus
 | 
			
		||||
extern "C" {
 | 
			
		||||
#endif
 | 
			
		||||
 | 
			
		||||
/* Supported Number of Timers */
 | 
			
		||||
#define NUM_TIMERS  2
 | 
			
		||||
#define TIMER0  0
 | 
			
		||||
#define TIMER1  1
 | 
			
		||||
 | 
			
		||||
/* Default reload */
 | 
			
		||||
#define TIMER_DEFAULT_RELOAD    0xFFFFFFFF
 | 
			
		||||
 | 
			
		||||
/*
 | 
			
		||||
 * Timer_Initialize(): Initializes an hardware timer
 | 
			
		||||
 * timer: timer to be Initialized
 | 
			
		||||
 * time_us: timer reload value in us - 0 to reload to timer max value
 | 
			
		||||
 *          time_us = tick_value / TIMER_TICK_US
 | 
			
		||||
 */
 | 
			
		||||
void Timer_Initialize(uint32_t timer, uint32_t time_us);
 | 
			
		||||
 | 
			
		||||
/*
 | 
			
		||||
 * Timer_Enable(): Enables an hardware timer
 | 
			
		||||
 * timer: timer to be enabled
 | 
			
		||||
 */
 | 
			
		||||
void Timer_Enable(uint32_t timer);
 | 
			
		||||
 | 
			
		||||
/*
 | 
			
		||||
 * Timer_Disable(): Disables an hardware timer
 | 
			
		||||
 * timer: timer to be disabled
 | 
			
		||||
 */
 | 
			
		||||
void Timer_Disable(uint32_t timer);
 | 
			
		||||
 | 
			
		||||
/*
 | 
			
		||||
 * Timer_isEnabled(): verifies if a timer is enabled
 | 
			
		||||
 * timer: timer to be verified
 | 
			
		||||
 * @return: 0 disabled - 1 enabled
 | 
			
		||||
 */
 | 
			
		||||
uint32_t Timer_isEnabled(uint32_t timer);
 | 
			
		||||
 | 
			
		||||
/*
 | 
			
		||||
 * Timer_Read(): provides timer VALUE
 | 
			
		||||
 * timer: timer to be read
 | 
			
		||||
 * @return: timer VALUE
 | 
			
		||||
 */
 | 
			
		||||
uint32_t Timer_Read(uint32_t timer);
 | 
			
		||||
 | 
			
		||||
/*
 | 
			
		||||
 * Timer_SetInterrupt(): sets timer Interrupt
 | 
			
		||||
 * timer: timer on which interrupt is set
 | 
			
		||||
 * time_us: reloading time in us
 | 
			
		||||
 */
 | 
			
		||||
void Timer_SetInterrupt(uint32_t timer, uint32_t time_us);
 | 
			
		||||
 | 
			
		||||
/*
 | 
			
		||||
 * Timer_DisableInterrupt(): disables timer interrupt
 | 
			
		||||
 * timer: timer on which interrupt is disabled
 | 
			
		||||
 */
 | 
			
		||||
void Timer_DisableInterrupt(uint32_t timer);
 | 
			
		||||
 | 
			
		||||
/*
 | 
			
		||||
 * Timer_ClearInterrupt(): clear timer interrupt
 | 
			
		||||
 * timer: timer on which interrupt needs to be cleared
 | 
			
		||||
 */
 | 
			
		||||
void Timer_ClearInterrupt(uint32_t timer);
 | 
			
		||||
 | 
			
		||||
/*
 | 
			
		||||
 * Timer_GetIRQn(): returns IRQn of a Timer
 | 
			
		||||
 * timer: timer on which IRQn is defined - 0 if it is not defined
 | 
			
		||||
 */
 | 
			
		||||
uint32_t Timer_GetIRQn(uint32_t timer);
 | 
			
		||||
 | 
			
		||||
/*
 | 
			
		||||
 * Timer_GetTicksUS(): returns the number of Ticks per us
 | 
			
		||||
 * timer: timer associated with the Ticks per us
 | 
			
		||||
 * @return: Ticks per us - 0 if the timer is disables
 | 
			
		||||
 */
 | 
			
		||||
uint32_t Timer_GetTicksUS(uint32_t timer);
 | 
			
		||||
 | 
			
		||||
/*
 | 
			
		||||
 * Timer_GetReloadValue(): returns the load value of the selected
 | 
			
		||||
 * timer.
 | 
			
		||||
 * timer: timer associated with the Ticks per us
 | 
			
		||||
 * @return: reload value of the selected singletimer
 | 
			
		||||
 */
 | 
			
		||||
uint32_t Timer_GetReloadValue(uint32_t timer);
 | 
			
		||||
 | 
			
		||||
#ifdef __cplusplus
 | 
			
		||||
}
 | 
			
		||||
#endif
 | 
			
		||||
#endif /* _APB_TIMER_DRV_H */
 | 
			
		||||
| 
						 | 
				
			
			@ -1,42 +0,0 @@
 | 
			
		|||
/* mbed Microcontroller Library
 | 
			
		||||
 * Copyright (c) 2015-2016 ARM Limited
 | 
			
		||||
 *
 | 
			
		||||
 * Licensed under the Apache License, Version 2.0 (the "License");
 | 
			
		||||
 * you may not use this file except in compliance with the License.
 | 
			
		||||
 * You may obtain a copy of the License at
 | 
			
		||||
 *
 | 
			
		||||
 *     http://www.apache.org/licenses/LICENSE-2.0
 | 
			
		||||
 *
 | 
			
		||||
 * Unless required by applicable law or agreed to in writing, software
 | 
			
		||||
 * distributed under the License is distributed on an "AS IS" BASIS,
 | 
			
		||||
 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
 | 
			
		||||
 * See the License for the specific language governing permissions and
 | 
			
		||||
 * limitations under the License.
 | 
			
		||||
 */
 | 
			
		||||
/*
 | 
			
		||||
 * A generic CMSIS include header, pulling in BEETLE SoC specifics
 | 
			
		||||
 */
 | 
			
		||||
 | 
			
		||||
#ifndef MBED_CMSIS_H
 | 
			
		||||
#define MBED_CMSIS_H
 | 
			
		||||
 | 
			
		||||
/* Beetle Core */
 | 
			
		||||
#include "CMSDK_BEETLE.h"
 | 
			
		||||
/* Beetle System Core */
 | 
			
		||||
#include "system_CMSDK_BEETLE.h"
 | 
			
		||||
/* Beetle Core Config */
 | 
			
		||||
#include "system_core_beetle.h"
 | 
			
		||||
/* APB Dual Timer */
 | 
			
		||||
#include "apb_dualtimer.h"
 | 
			
		||||
/* APB Timer */
 | 
			
		||||
#include "apb_timer.h"
 | 
			
		||||
/* Flash Cache Driver */
 | 
			
		||||
#include "fcache_api.h"
 | 
			
		||||
/* Embedded Flash Driver */
 | 
			
		||||
#include "eflash_api.h"
 | 
			
		||||
/* NVIC Driver */
 | 
			
		||||
#include "cmsis_nvic.h"
 | 
			
		||||
/* System Core Version */
 | 
			
		||||
#include "system_core_version.h"
 | 
			
		||||
 | 
			
		||||
#endif
 | 
			
		||||
| 
						 | 
				
			
			@ -1,23 +0,0 @@
 | 
			
		|||
/* mbed Microcontroller Library
 | 
			
		||||
 * Copyright (c) 2015-2016 ARM Limited
 | 
			
		||||
 *
 | 
			
		||||
 * Licensed under the Apache License, Version 2.0 (the "License");
 | 
			
		||||
 * you may not use this file except in compliance with the License.
 | 
			
		||||
 * You may obtain a copy of the License at
 | 
			
		||||
 *
 | 
			
		||||
 *     http://www.apache.org/licenses/LICENSE-2.0
 | 
			
		||||
 *
 | 
			
		||||
 * Unless required by applicable law or agreed to in writing, software
 | 
			
		||||
 * distributed under the License is distributed on an "AS IS" BASIS,
 | 
			
		||||
 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
 | 
			
		||||
 * See the License for the specific language governing permissions and
 | 
			
		||||
 * limitations under the License.
 | 
			
		||||
 */
 | 
			
		||||
 | 
			
		||||
#ifndef MBED_CMSIS_NVIC_H
 | 
			
		||||
#define MBED_CMSIS_NVIC_H
 | 
			
		||||
 | 
			
		||||
#define NVIC_NUM_VECTORS        (16 + 48)
 | 
			
		||||
#define NVIC_RAM_VECTOR_ADDRESS 0x20000000   //Location of vectors in RAM
 | 
			
		||||
 | 
			
		||||
#endif
 | 
			
		||||
| 
						 | 
				
			
			@ -1,361 +0,0 @@
 | 
			
		|||
/* mbed Microcontroller Library
 | 
			
		||||
 * Copyright (c) 2015 ARM Limited
 | 
			
		||||
 *
 | 
			
		||||
 * Licensed under the Apache License, Version 2.0 (the "License");
 | 
			
		||||
 * you may not use this file except in compliance with the License.
 | 
			
		||||
 * You may obtain a copy of the License at
 | 
			
		||||
 *
 | 
			
		||||
 *     http://www.apache.org/licenses/LICENSE-2.0
 | 
			
		||||
 *
 | 
			
		||||
 * Unless required by applicable law or agreed to in writing, software
 | 
			
		||||
 * distributed under the License is distributed on an "AS IS" BASIS,
 | 
			
		||||
 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
 | 
			
		||||
 * See the License for the specific language governing permissions and
 | 
			
		||||
 * limitations under the License.
 | 
			
		||||
 */
 | 
			
		||||
 | 
			
		||||
#include "eflash_api.h"
 | 
			
		||||
 | 
			
		||||
/* EFlash Private Data */
 | 
			
		||||
typedef struct {
 | 
			
		||||
    /* basebank0 start address */
 | 
			
		||||
    unsigned int basebank0;
 | 
			
		||||
    /* basebank0 mass erase + info pages address */
 | 
			
		||||
    unsigned int basebank0_me;
 | 
			
		||||
    /* basebank1 start address */
 | 
			
		||||
    unsigned int basebank1;
 | 
			
		||||
    /* basebank1 mass erase + info pages address */
 | 
			
		||||
    unsigned int basebank1_me;
 | 
			
		||||
} eflash_t;
 | 
			
		||||
 | 
			
		||||
static eflash_t eflash;
 | 
			
		||||
 | 
			
		||||
/* EFlash_IdCheck: Detect the part number to see if device is present */
 | 
			
		||||
int EFlash_IdCheck()
 | 
			
		||||
{
 | 
			
		||||
    unsigned int eflash_id;
 | 
			
		||||
 | 
			
		||||
    eflash_id = EFlash_Readl(SYS_EFLASH_PIDR2) & (EFLASH_DES_1 | EFLASH_JEDEC);
 | 
			
		||||
 | 
			
		||||
    if (EFlash_Readl(SYS_EFLASH_PIDR0) != FLS_PID0
 | 
			
		||||
            || EFlash_Readl(SYS_EFLASH_PIDR1) != FLS_PID1
 | 
			
		||||
            || eflash_id != FLS_PID2)
 | 
			
		||||
        /* port ID and ARM ID does not match */
 | 
			
		||||
        return 1;
 | 
			
		||||
    else
 | 
			
		||||
        return 0;
 | 
			
		||||
}
 | 
			
		||||
 | 
			
		||||
/* EFlash_ReturnBank1BaseAddress: Returns start address of bank 1 */
 | 
			
		||||
int EFlash_ReturnBank1BaseAddress()
 | 
			
		||||
{
 | 
			
		||||
    unsigned int hwparams0;
 | 
			
		||||
    int baseaddr;
 | 
			
		||||
 | 
			
		||||
    hwparams0 = EFlash_Readl(SYS_EFLASH_HWPARAMS0) & EFLASH_FLASHSIZE;
 | 
			
		||||
 | 
			
		||||
    switch(hwparams0)
 | 
			
		||||
    {
 | 
			
		||||
        case 0x11:
 | 
			
		||||
            /* 128kb flash size - first page of bank 1 is 0x20000 */
 | 
			
		||||
            baseaddr = 0x20000;
 | 
			
		||||
            break;
 | 
			
		||||
        case 0x12:
 | 
			
		||||
            /* 256kb flash size - first page of bank 1 is 0x40000 */
 | 
			
		||||
            baseaddr = 0x40000;
 | 
			
		||||
            break;
 | 
			
		||||
        default:
 | 
			
		||||
            /* unsupported flash size */
 | 
			
		||||
            baseaddr = -1;
 | 
			
		||||
            break;
 | 
			
		||||
    }
 | 
			
		||||
 | 
			
		||||
    return baseaddr;
 | 
			
		||||
}
 | 
			
		||||
 | 
			
		||||
/* EFlash_DriverInitialize: eFlash Driver Initialize function */
 | 
			
		||||
void EFlash_DriverInitialize()
 | 
			
		||||
{
 | 
			
		||||
    /* Find the start address of banks */
 | 
			
		||||
    eflash.basebank0 = 0x0;
 | 
			
		||||
    eflash.basebank0_me = 0x40000000;
 | 
			
		||||
    eflash.basebank1 = EFlash_ReturnBank1BaseAddress();
 | 
			
		||||
    eflash.basebank1_me = 0x80000000;
 | 
			
		||||
}
 | 
			
		||||
 | 
			
		||||
/* EFlash_ClockConfig: eFlash Clock Configuration */
 | 
			
		||||
void EFlash_ClockConfig()
 | 
			
		||||
{
 | 
			
		||||
    /* Wait until eFlash controller gets unlocked */
 | 
			
		||||
    while ((EFlash_Readl(SYS_EFLASH_STATUS) & EFLASH_LOCK_MASK) == EFLASH_LOCK);
 | 
			
		||||
 | 
			
		||||
    /*
 | 
			
		||||
    * Configure to use external clock
 | 
			
		||||
    * EXTCL = 31250 ns ->
 | 
			
		||||
    *   1 ms = 32 clock count 32khz ext_clk -> ER_CLK_COUNT = 32
 | 
			
		||||
    *   1 us = 84 clock count system_clk -> WR_CLK_COUNT = 84
 | 
			
		||||
    *   EXT_CLK_CONF = 0x1 [Erase] External clock used for erase counters (>1ms)
 | 
			
		||||
    *   HCLK used for write counters
 | 
			
		||||
    *   RD_CLK_COUNT = 0x3
 | 
			
		||||
    */
 | 
			
		||||
    EFlash_Writel(SYS_EFLASH_CONFIG0, 0x00200B43);
 | 
			
		||||
 | 
			
		||||
    /* Wait until eFlash controller gets unlocked */
 | 
			
		||||
    while ((EFlash_Readl(SYS_EFLASH_STATUS) & EFLASH_BUSY_MASK) == EFLASH_BUSY);
 | 
			
		||||
}
 | 
			
		||||
 | 
			
		||||
/*
 | 
			
		||||
 * EFlash_Erase: Erases flash banks
 | 
			
		||||
 * Mode:
 | 
			
		||||
 *  0 - erases bank 0
 | 
			
		||||
 *  1 - erases bank 1
 | 
			
		||||
 *  2 - erases bank 0 + info pages
 | 
			
		||||
 *  3 - erases bank 1 + info pages
 | 
			
		||||
 *  4 - erases bank 0 + 1
 | 
			
		||||
 *  5 - erases bank 0 + 1 with info pages
 | 
			
		||||
 */
 | 
			
		||||
void EFlash_Erase(int mode)
 | 
			
		||||
{
 | 
			
		||||
    switch (mode)
 | 
			
		||||
    {
 | 
			
		||||
        case 0:
 | 
			
		||||
            /* Wait until eFlash controller gets unlocked */
 | 
			
		||||
            while ((EFlash_Readl(SYS_EFLASH_STATUS)
 | 
			
		||||
                        & EFLASH_LOCK_MASK) == EFLASH_LOCK);
 | 
			
		||||
            /* Erase Block #0 */
 | 
			
		||||
            EFlash_Writel(SYS_EFLASH_WADDR, eflash.basebank0);
 | 
			
		||||
            EFlash_Writel(SYS_EFLASH_CTRL, EFLASH_MASS_ERASE);
 | 
			
		||||
            /* Wait until eFlash controller is not busy */
 | 
			
		||||
            while ((EFlash_Readl(SYS_EFLASH_STATUS)
 | 
			
		||||
                        & EFLASH_BUSY_MASK) == EFLASH_BUSY);
 | 
			
		||||
            break;
 | 
			
		||||
        case 1:
 | 
			
		||||
            /* Wait until eFlash controller gets unlocked */
 | 
			
		||||
            while ((EFlash_Readl(SYS_EFLASH_STATUS)
 | 
			
		||||
                        & EFLASH_LOCK_MASK) == EFLASH_LOCK);
 | 
			
		||||
            /* Erase Block #1 */
 | 
			
		||||
            EFlash_Writel(SYS_EFLASH_WADDR, eflash.basebank1);
 | 
			
		||||
            EFlash_Writel(SYS_EFLASH_CTRL, EFLASH_MASS_ERASE);
 | 
			
		||||
            /* Wait until eFlash controller is not busy */
 | 
			
		||||
            while ((EFlash_Readl(SYS_EFLASH_STATUS)
 | 
			
		||||
                        & EFLASH_BUSY_MASK) == EFLASH_BUSY);
 | 
			
		||||
            break;
 | 
			
		||||
        case 2:
 | 
			
		||||
            /* Wait until eFlash controller gets unlocked */
 | 
			
		||||
            while ((EFlash_Readl(SYS_EFLASH_STATUS)
 | 
			
		||||
                        & EFLASH_LOCK_MASK) == EFLASH_LOCK);
 | 
			
		||||
            /* Erase Block #0 + info pages */
 | 
			
		||||
            EFlash_Writel(SYS_EFLASH_WADDR, eflash.basebank0_me);
 | 
			
		||||
            EFlash_Writel(SYS_EFLASH_CTRL, EFLASH_MASS_ERASE);
 | 
			
		||||
            /* Wait until eFlash controller is not busy */
 | 
			
		||||
            while ((EFlash_Readl(SYS_EFLASH_STATUS)
 | 
			
		||||
                        & EFLASH_BUSY_MASK) == EFLASH_BUSY);
 | 
			
		||||
            break;
 | 
			
		||||
        case 3:
 | 
			
		||||
            /* Wait until eFlash controller gets unlocked */
 | 
			
		||||
            while ((EFlash_Readl(SYS_EFLASH_STATUS)
 | 
			
		||||
                        & EFLASH_LOCK_MASK) == EFLASH_LOCK);
 | 
			
		||||
            /* Erase Block #1 + info pages */
 | 
			
		||||
            EFlash_Writel(SYS_EFLASH_WADDR, eflash.basebank1_me);
 | 
			
		||||
            EFlash_Writel(SYS_EFLASH_CTRL, EFLASH_MASS_ERASE);
 | 
			
		||||
            /* Wait until eFlash controller is not busy */
 | 
			
		||||
            while ((EFlash_Readl(SYS_EFLASH_STATUS)
 | 
			
		||||
                        & EFLASH_BUSY_MASK) == EFLASH_BUSY);
 | 
			
		||||
            break;
 | 
			
		||||
        case 4:
 | 
			
		||||
            /* Wait until eFlash controller gets unlocked */
 | 
			
		||||
            while ((EFlash_Readl(SYS_EFLASH_STATUS)
 | 
			
		||||
                        & EFLASH_LOCK_MASK) == EFLASH_LOCK);
 | 
			
		||||
            /* Erase Block #0 */
 | 
			
		||||
            EFlash_Writel(SYS_EFLASH_WADDR, eflash.basebank0);
 | 
			
		||||
            EFlash_Writel(SYS_EFLASH_CTRL, EFLASH_MASS_ERASE);
 | 
			
		||||
            /* Wait until eFlash controller is not busy */
 | 
			
		||||
            while ((EFlash_Readl(SYS_EFLASH_STATUS)
 | 
			
		||||
                        & EFLASH_BUSY_MASK) == EFLASH_BUSY);
 | 
			
		||||
            /* Wait until eFlash controller gets unlocked */
 | 
			
		||||
            while ((EFlash_Readl(SYS_EFLASH_STATUS)
 | 
			
		||||
                        & EFLASH_LOCK_MASK) == EFLASH_LOCK);
 | 
			
		||||
            /* Erase Block #1 */
 | 
			
		||||
            EFlash_Writel(SYS_EFLASH_WADDR, eflash.basebank1);
 | 
			
		||||
            EFlash_Writel(SYS_EFLASH_CTRL, EFLASH_MASS_ERASE);
 | 
			
		||||
            /* Wait until eFlash controller gets unlocked */
 | 
			
		||||
            /* Wait until eFlash controller is not busy */
 | 
			
		||||
            while ((EFlash_Readl(SYS_EFLASH_STATUS)
 | 
			
		||||
                        & EFLASH_BUSY_MASK) == EFLASH_BUSY);
 | 
			
		||||
            break;
 | 
			
		||||
        case 5:
 | 
			
		||||
            /* Wait until eFlash controller gets unlocked */
 | 
			
		||||
            while ((EFlash_Readl(SYS_EFLASH_STATUS)
 | 
			
		||||
                        & EFLASH_LOCK_MASK) == EFLASH_LOCK);
 | 
			
		||||
            /* Erase Block #0 + info pages */
 | 
			
		||||
            EFlash_Writel(SYS_EFLASH_WADDR, eflash.basebank0_me);
 | 
			
		||||
            EFlash_Writel(SYS_EFLASH_CTRL, EFLASH_MASS_ERASE);
 | 
			
		||||
            /* Wait until eFlash controller is not busy */
 | 
			
		||||
            while ((EFlash_Readl(SYS_EFLASH_STATUS)
 | 
			
		||||
                        & EFLASH_BUSY_MASK) == EFLASH_BUSY);
 | 
			
		||||
            /* Wait until eFlash controller gets unlocked */
 | 
			
		||||
            while ((EFlash_Readl(SYS_EFLASH_STATUS)
 | 
			
		||||
                        & EFLASH_LOCK_MASK) == EFLASH_LOCK);
 | 
			
		||||
            /* Erase Block #1 + info pages */
 | 
			
		||||
            EFlash_Writel(SYS_EFLASH_WADDR, eflash.basebank1_me);
 | 
			
		||||
            EFlash_Writel(SYS_EFLASH_CTRL, EFLASH_MASS_ERASE);
 | 
			
		||||
            /* Wait until eFlash controller is not busy */
 | 
			
		||||
            while ((EFlash_Readl(SYS_EFLASH_STATUS)
 | 
			
		||||
                        & EFLASH_BUSY_MASK) == EFLASH_BUSY);
 | 
			
		||||
            break;
 | 
			
		||||
        default:
 | 
			
		||||
            break;
 | 
			
		||||
    }
 | 
			
		||||
}
 | 
			
		||||
 | 
			
		||||
/* EFlash_ErasePage: Erase a Page */
 | 
			
		||||
void EFlash_ErasePage(unsigned int waddr)
 | 
			
		||||
{
 | 
			
		||||
    /* Erase the page starting a waddr */
 | 
			
		||||
    EFlash_Writel(SYS_EFLASH_WADDR, waddr);
 | 
			
		||||
    EFlash_Writel(SYS_EFLASH_CTRL, EFLASH_ERASE);
 | 
			
		||||
    /* Wait until eFlash controller gets unlocked */
 | 
			
		||||
    while ((EFlash_Readl(SYS_EFLASH_STATUS)
 | 
			
		||||
                & EFLASH_BUSY_MASK) == EFLASH_BUSY);
 | 
			
		||||
}
 | 
			
		||||
 | 
			
		||||
/*
 | 
			
		||||
 * EFlash_Write: Write function
 | 
			
		||||
 * Parameters:
 | 
			
		||||
 *  waddr - address in flash
 | 
			
		||||
 *  data - data to be written
 | 
			
		||||
 */
 | 
			
		||||
void EFlash_Write(unsigned int waddr, unsigned int data)
 | 
			
		||||
{
 | 
			
		||||
    /* Set Write Data Register */
 | 
			
		||||
    EFlash_Writel(SYS_EFLASH_WDATA, data);
 | 
			
		||||
    /* Set Write Address Register */
 | 
			
		||||
    EFlash_Writel(SYS_EFLASH_WADDR, waddr);
 | 
			
		||||
    /* Start Write Operation through CTRL register */
 | 
			
		||||
    EFlash_Writel(SYS_EFLASH_CTRL, EFLASH_WRITE);
 | 
			
		||||
    /* Wait until eFlash controller gets unlocked */
 | 
			
		||||
    while ((EFlash_Readl(SYS_EFLASH_STATUS)
 | 
			
		||||
                & EFLASH_BUSY_MASK) == EFLASH_BUSY);
 | 
			
		||||
 | 
			
		||||
    /* Flash Cache invalidate if FCache enabled */
 | 
			
		||||
    if (FCache_isEnabled() == 1)
 | 
			
		||||
        FCache_Invalidate();
 | 
			
		||||
}
 | 
			
		||||
 | 
			
		||||
/*
 | 
			
		||||
 * EFlash_WritePage: Write Page function
 | 
			
		||||
 * Parameters:
 | 
			
		||||
 *  waddr - address in flash
 | 
			
		||||
 *  page_size - data to be written
 | 
			
		||||
 *  buf - buffer containing the data
 | 
			
		||||
 */
 | 
			
		||||
int EFlash_WritePage(unsigned int waddr, unsigned int page_size,
 | 
			
		||||
        unsigned char *buf)
 | 
			
		||||
{
 | 
			
		||||
    unsigned int page_index;
 | 
			
		||||
    unsigned int data;
 | 
			
		||||
 | 
			
		||||
    /* To be verified */
 | 
			
		||||
    for(page_index = 0; page_index < page_size; page_index = page_index + 4) {
 | 
			
		||||
        /* Recreate the 32 bit word */
 | 
			
		||||
        data = ((unsigned int) buf[page_index + 3]) << 24 |
 | 
			
		||||
            ((unsigned int) buf[page_index + 2]) << 16 |
 | 
			
		||||
            ((unsigned int) buf[page_index + 1]) << 8 |
 | 
			
		||||
            ((unsigned int) buf[page_index]);
 | 
			
		||||
        /* Write the word in memory */
 | 
			
		||||
        EFlash_Write(waddr, data);
 | 
			
		||||
        waddr += 4;
 | 
			
		||||
    }
 | 
			
		||||
 | 
			
		||||
    return 0;
 | 
			
		||||
}
 | 
			
		||||
 | 
			
		||||
/*
 | 
			
		||||
 * EFlash_Read: Read function
 | 
			
		||||
 * Parameters:
 | 
			
		||||
 *  waddr - address in flash
 | 
			
		||||
 * Returns:
 | 
			
		||||
 *  the vaule read at address waddr
 | 
			
		||||
 */
 | 
			
		||||
unsigned int EFlash_Read(unsigned int waddr)
 | 
			
		||||
{
 | 
			
		||||
    unsigned int eflash_read = EFlash_Readl(waddr);
 | 
			
		||||
    return eflash_read;
 | 
			
		||||
}
 | 
			
		||||
 | 
			
		||||
/*
 | 
			
		||||
 * EFlash_Verify: Verifies if the eFlash has been written correctly.
 | 
			
		||||
 * Parameters:
 | 
			
		||||
 *  waddr - address in flash
 | 
			
		||||
 *  page_size - data to be written
 | 
			
		||||
 *  buf - buffer containing the data
 | 
			
		||||
 * Returns:
 | 
			
		||||
 *  (waddr+page_size) - OK or Failed Address
 | 
			
		||||
 */
 | 
			
		||||
unsigned int EFlash_Verify(unsigned int waddr, unsigned int page_size,
 | 
			
		||||
        unsigned char *buf)
 | 
			
		||||
{
 | 
			
		||||
    unsigned int page_index;
 | 
			
		||||
    unsigned int eflash_data, buf_data;
 | 
			
		||||
 | 
			
		||||
    /* To be verified */
 | 
			
		||||
    for(page_index = 0; page_index < page_size; page_index = page_index + 4) {
 | 
			
		||||
        /* Recreate the 32 bit word */
 | 
			
		||||
        buf_data = ((unsigned int) buf[page_index + 3]) << 24 |
 | 
			
		||||
            ((unsigned int) buf[page_index + 2]) << 16 |
 | 
			
		||||
            ((unsigned int) buf[page_index + 1]) << 8 |
 | 
			
		||||
            ((unsigned int) buf[page_index]);
 | 
			
		||||
        /* Read the word in memory */
 | 
			
		||||
        eflash_data = EFlash_Read(waddr);
 | 
			
		||||
        if (eflash_data != buf_data)
 | 
			
		||||
            break;
 | 
			
		||||
        waddr += 4;
 | 
			
		||||
    }
 | 
			
		||||
 | 
			
		||||
    /* Allign the address before return */
 | 
			
		||||
    return (waddr);
 | 
			
		||||
}
 | 
			
		||||
 | 
			
		||||
/*
 | 
			
		||||
 * EFlash_BlankCheck: Verifies if there is any Blank Block in eFlash
 | 
			
		||||
 * Parameters:
 | 
			
		||||
 *  waddr - address in flash
 | 
			
		||||
 *  page_size - data to be written
 | 
			
		||||
 *  pat - pattern of a blank block
 | 
			
		||||
 * Returns:
 | 
			
		||||
 *  0 - OK or 1- Failed
 | 
			
		||||
 */
 | 
			
		||||
int EFlash_BlankCheck(unsigned int waddr, unsigned int page_size,
 | 
			
		||||
        unsigned char pat)
 | 
			
		||||
{
 | 
			
		||||
    unsigned int page_index;
 | 
			
		||||
    unsigned int eflash_data, buf_data;
 | 
			
		||||
 | 
			
		||||
    /* Page size div by 4 */
 | 
			
		||||
    page_size = page_size >> 2;
 | 
			
		||||
 | 
			
		||||
    /* To be verified */
 | 
			
		||||
    for(page_index = 0; page_index < page_size; page_index = page_index + 4) {
 | 
			
		||||
        /* Recreate the 32 bit word */
 | 
			
		||||
        buf_data = ((unsigned int) pat) << 24 |
 | 
			
		||||
            ((unsigned int) pat) << 16 |
 | 
			
		||||
            ((unsigned int) pat) << 8 |
 | 
			
		||||
            ((unsigned int) pat);
 | 
			
		||||
        /* Read the word in memory */
 | 
			
		||||
        eflash_data = EFlash_Read(waddr);
 | 
			
		||||
        if (eflash_data != buf_data)
 | 
			
		||||
            return 1;
 | 
			
		||||
        waddr += 4;
 | 
			
		||||
    }
 | 
			
		||||
 | 
			
		||||
    return 0;
 | 
			
		||||
}
 | 
			
		||||
 | 
			
		||||
/*
 | 
			
		||||
 * Delay ns (uncalibrated delay)
 | 
			
		||||
 */
 | 
			
		||||
void EFlash_Delay(unsigned int period) {
 | 
			
		||||
    int loop;
 | 
			
		||||
    for (loop = 0; loop < period; loop++)
 | 
			
		||||
        continue;
 | 
			
		||||
}
 | 
			
		||||
| 
						 | 
				
			
			@ -1,158 +0,0 @@
 | 
			
		|||
/* mbed Microcontroller Library
 | 
			
		||||
 * Copyright (c) 2015 ARM Limited
 | 
			
		||||
 *
 | 
			
		||||
 * Licensed under the Apache License, Version 2.0 (the "License");
 | 
			
		||||
 * you may not use this file except in compliance with the License.
 | 
			
		||||
 * You may obtain a copy of the License at
 | 
			
		||||
 *
 | 
			
		||||
 *     http://www.apache.org/licenses/LICENSE-2.0
 | 
			
		||||
 *
 | 
			
		||||
 * Unless required by applicable law or agreed to in writing, software
 | 
			
		||||
 * distributed under the License is distributed on an "AS IS" BASIS,
 | 
			
		||||
 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
 | 
			
		||||
 * See the License for the specific language governing permissions and
 | 
			
		||||
 * limitations under the License.
 | 
			
		||||
 */
 | 
			
		||||
 | 
			
		||||
#ifndef _EFLASH_DRV_H
 | 
			
		||||
#define _EFLASH_DRV_H
 | 
			
		||||
 | 
			
		||||
#include "fcache_api.h"
 | 
			
		||||
 | 
			
		||||
#ifdef __cplusplus
 | 
			
		||||
 | 
			
		||||
extern "C" {
 | 
			
		||||
#else
 | 
			
		||||
#include <stdio.h>
 | 
			
		||||
#endif
 | 
			
		||||
 | 
			
		||||
    /* eFLASH Address Map */
 | 
			
		||||
#define SYS_EFLASH_BASE 0x40009000
 | 
			
		||||
#define SYS_EFLASH_IRQ_SET_STATUS (SYS_EFLASH_BASE + 0x008)
 | 
			
		||||
#define SYS_EFLASH_IRQ_CLR_STATUS (SYS_EFLASH_BASE + 0x008)
 | 
			
		||||
#define SYS_EFLASH_CTRL (SYS_EFLASH_BASE + 0x014)
 | 
			
		||||
#define SYS_EFLASH_STATUS (SYS_EFLASH_BASE + 0x018)
 | 
			
		||||
#define SYS_EFLASH_CONFIG0 (SYS_EFLASH_BASE + 0x01C)
 | 
			
		||||
#define SYS_EFLASH_WADDR (SYS_EFLASH_BASE + 0x028)
 | 
			
		||||
#define SYS_EFLASH_WDATA (SYS_EFLASH_BASE + 0x02C)
 | 
			
		||||
#define SYS_EFLASH_HWPARAMS0 (SYS_EFLASH_BASE + 0x034)
 | 
			
		||||
#define SYS_EFLASH_PIDR0 (SYS_EFLASH_BASE + 0xFE0)
 | 
			
		||||
#define SYS_EFLASH_PIDR1 (SYS_EFLASH_BASE + 0xFE4)
 | 
			
		||||
#define SYS_EFLASH_PIDR2 (SYS_EFLASH_BASE + 0xFE8)
 | 
			
		||||
 | 
			
		||||
    /* SYS_EFLASH_CTRL (RW): Flash Control Register */
 | 
			
		||||
#define EFLASH_WRITE        1           /* Write one word on eFlash */
 | 
			
		||||
#define EFLASH_ROW_WRITE    (1 << 1)    /* Write a row of eFlash */
 | 
			
		||||
#define EFLASH_ERASE        (1 << 2)    /* Erase one page of eFlash */
 | 
			
		||||
#define EFLASH_MASS_ERASE   (1 << 3)    /* Erases all pages of the eFlash*/
 | 
			
		||||
#define EFLASH_STOP         (1 << 4)    /* Stop any write erase operation */
 | 
			
		||||
 | 
			
		||||
    /* SYS_EFLASH_STATUS (RO): Status Register */
 | 
			
		||||
#define EFLASH_BUSY_MASK    1           /* EFlash Busy Mask */
 | 
			
		||||
#define EFLASH_BUSY         1           /* EFlash Busy */
 | 
			
		||||
#define EFLASH_LOCK_MASK    (1 << 1)    /* EFlash Lock Mask */
 | 
			
		||||
#define EFLASH_LOCK         (1 << 1)    /* EFlash Lock */
 | 
			
		||||
 | 
			
		||||
    /* SYS_EFLASH_HWPARAMS0 (RO): HW parameters */
 | 
			
		||||
#define EFLASH_FLASHSIZE    0x1F    /* Flash Size */
 | 
			
		||||
 | 
			
		||||
    /* SYS_EFLASH_PIDR2 (RO): Flash Memory Information */
 | 
			
		||||
#define EFLASH_DES_1    0x7     /* JEP106 Id Mask */
 | 
			
		||||
#define EFLASH_JEDEC    0x8     /* JEDEC assigned val Mask */
 | 
			
		||||
#define EFLASH_REVISION 0xF0    /* Revision number */
 | 
			
		||||
 | 
			
		||||
    /* Macros */
 | 
			
		||||
#define EFlash_Readl(reg) *(volatile unsigned int *)reg
 | 
			
		||||
#define EFlash_Writel(reg, val)  *(volatile unsigned int *)reg = val;
 | 
			
		||||
 | 
			
		||||
    /* peripheral and component ID values */
 | 
			
		||||
#define FLS_PID4  0x14
 | 
			
		||||
#define FLS_PID5  0x00
 | 
			
		||||
#define FLS_PID6  0x00
 | 
			
		||||
#define FLS_PID7  0x00
 | 
			
		||||
#define FLS_PID0  0x30
 | 
			
		||||
#define FLS_PID1  0xB8
 | 
			
		||||
#define FLS_PID2  0x0B
 | 
			
		||||
#define FLS_PID3  0x00
 | 
			
		||||
#define FLS_CID0  0x0D
 | 
			
		||||
#define FLS_CID1  0xF0
 | 
			
		||||
#define FLS_CID2  0x05
 | 
			
		||||
#define FLS_CID3  0xB1
 | 
			
		||||
 | 
			
		||||
/* Functions */
 | 
			
		||||
/* EFlash_DriverInitialize: eFlash Driver Initialize function */
 | 
			
		||||
void EFlash_DriverInitialize(void);
 | 
			
		||||
 | 
			
		||||
/* EFlash_ClockConfig: eFlash Clock Configuration */
 | 
			
		||||
void EFlash_ClockConfig(void);
 | 
			
		||||
 | 
			
		||||
/*
 | 
			
		||||
 * EFlash_Erase: Erases flash banks
 | 
			
		||||
 * Mode:
 | 
			
		||||
 *  0 - erases bank 0
 | 
			
		||||
 *  1 - erases bank 1
 | 
			
		||||
 *  2 - erases bank 0 + info pages
 | 
			
		||||
 *  3 - erases bank 1 + info pages
 | 
			
		||||
 *  4 - erases bank 0 + 1
 | 
			
		||||
 *  5 - erases bank 0 + 1 with info pages
 | 
			
		||||
 */
 | 
			
		||||
void EFlash_Erase(int mode);
 | 
			
		||||
/* EFlash_ErasePage: Erase a Page */
 | 
			
		||||
void EFlash_ErasePage(unsigned int waddr);
 | 
			
		||||
/*
 | 
			
		||||
 * EFlash_Write: Write function
 | 
			
		||||
 * Parameters:
 | 
			
		||||
 *  waddr - address in flash
 | 
			
		||||
 *  data - data to be written
 | 
			
		||||
 */
 | 
			
		||||
void EFlash_Write(unsigned int waddr, unsigned int data);
 | 
			
		||||
/*
 | 
			
		||||
 * EFlash_WritePage: Write Page function
 | 
			
		||||
 * Parameters:
 | 
			
		||||
 *	waddr - address in flash
 | 
			
		||||
 *	page_size - data to be written
 | 
			
		||||
 *	buf - buffer containing the data
 | 
			
		||||
 */
 | 
			
		||||
int EFlash_WritePage(unsigned int waddr,
 | 
			
		||||
        unsigned int page_size, unsigned char *buf);
 | 
			
		||||
/*
 | 
			
		||||
 * EFlash_Read: Read function
 | 
			
		||||
 * Parameters:
 | 
			
		||||
 *  waddr - address in flash
 | 
			
		||||
 * Returns:
 | 
			
		||||
 *  the vaule read at address waddr
 | 
			
		||||
 */
 | 
			
		||||
unsigned int EFlash_Read(unsigned int waddr);
 | 
			
		||||
/*
 | 
			
		||||
 * EFlash_Verify: Verifies if the eFlash has been written correctly.
 | 
			
		||||
 * Parameters:
 | 
			
		||||
 *  waddr - address in flash
 | 
			
		||||
 *  page_size - data to be written
 | 
			
		||||
 *  buf - buffer containing the data
 | 
			
		||||
 * Returns:
 | 
			
		||||
 *  (waddr+page_size) - OK or Failed Address
 | 
			
		||||
 */
 | 
			
		||||
unsigned int EFlash_Verify(unsigned int waddr,
 | 
			
		||||
        unsigned int page_size, unsigned char *buf);
 | 
			
		||||
/*
 | 
			
		||||
 * EFlash_BlankCheck: Verifies if there is any Blank Block in eFlash
 | 
			
		||||
 * Parameters:
 | 
			
		||||
 *  waddr - address in flash
 | 
			
		||||
 *  page_size - data to be written
 | 
			
		||||
 *  pat - pattern of a blank block
 | 
			
		||||
 * Returns:
 | 
			
		||||
 *  0 - OK or 1- Failed
 | 
			
		||||
 */
 | 
			
		||||
int EFlash_BlankCheck(unsigned int waddr,
 | 
			
		||||
        unsigned int page_size, unsigned char pat);
 | 
			
		||||
 | 
			
		||||
/* EFlash_Delay function */
 | 
			
		||||
void EFlash_Delay(unsigned int period);
 | 
			
		||||
 | 
			
		||||
/* EFlash_ReturnBank1BaseAddress: Returns start address of bank 1 */
 | 
			
		||||
int EFlash_ReturnBank1BaseAddress(void);
 | 
			
		||||
 | 
			
		||||
#ifdef __cplusplus
 | 
			
		||||
}
 | 
			
		||||
#endif
 | 
			
		||||
#endif /* _FCACHE_DRV_H */
 | 
			
		||||
| 
						 | 
				
			
			@ -1,199 +0,0 @@
 | 
			
		|||
/* mbed Microcontroller Library
 | 
			
		||||
 * Copyright (c) 2015 ARM Limited
 | 
			
		||||
 *
 | 
			
		||||
 * Licensed under the Apache License, Version 2.0 (the "License");
 | 
			
		||||
 * you may not use this file except in compliance with the License.
 | 
			
		||||
 * You may obtain a copy of the License at
 | 
			
		||||
 *
 | 
			
		||||
 *     http://www.apache.org/licenses/LICENSE-2.0
 | 
			
		||||
 *
 | 
			
		||||
 * Unless required by applicable law or agreed to in writing, software
 | 
			
		||||
 * distributed under the License is distributed on an "AS IS" BASIS,
 | 
			
		||||
 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
 | 
			
		||||
 * See the License for the specific language governing permissions and
 | 
			
		||||
 * limitations under the License.
 | 
			
		||||
 */
 | 
			
		||||
 | 
			
		||||
#include "fcache_api.h"
 | 
			
		||||
 | 
			
		||||
static unsigned int enabled;
 | 
			
		||||
static unsigned int fcache_mode;
 | 
			
		||||
/* Functions */
 | 
			
		||||
 | 
			
		||||
/*
 | 
			
		||||
 * FCache_DriverInitialize: flash cache driver initialize funtion
 | 
			
		||||
 */
 | 
			
		||||
void FCache_DriverInitialize()
 | 
			
		||||
{
 | 
			
		||||
    unsigned int irqstat;
 | 
			
		||||
 | 
			
		||||
    /* Clear interrupt status register */
 | 
			
		||||
    irqstat = FCache_Readl(SYS_FCACHE_IRQSTAT) & (FCACHE_POW_ERR | FCACHE_MAN_INV_ERR);
 | 
			
		||||
    FCache_Writel(SYS_FCACHE_IRQSTAT, irqstat);
 | 
			
		||||
 | 
			
		||||
    /* Cache Disabled: Set enabled to 0 */
 | 
			
		||||
    enabled = 0;
 | 
			
		||||
}
 | 
			
		||||
 | 
			
		||||
/*
 | 
			
		||||
 * FCache_Enable: Enables the flash cache mode
 | 
			
		||||
 * mode: supported modes:
 | 
			
		||||
 * 0 - auto-power auto-invalidate
 | 
			
		||||
 * 1 - manual-power, manual-invalidate
 | 
			
		||||
 */
 | 
			
		||||
void FCache_Enable(int mode)
 | 
			
		||||
{
 | 
			
		||||
    /* Save Enable Mode */
 | 
			
		||||
    fcache_mode = mode;
 | 
			
		||||
 | 
			
		||||
    /* Enable the FCache */
 | 
			
		||||
    switch (fcache_mode) {
 | 
			
		||||
        case 0:
 | 
			
		||||
            /* Statistic counters enabled, Cache enable,
 | 
			
		||||
             * auto-inval, auto-power control
 | 
			
		||||
             */
 | 
			
		||||
            FCache_Writel(SYS_FCACHE_CCR, (FCACHE_EN | FCACHE_STATISTIC_EN));
 | 
			
		||||
            /* Wait until the cache is enabled */
 | 
			
		||||
            while ((FCache_Readl(SYS_FCACHE_SR) & FCACHE_CS) != FCACHE_CS_ENABLED);
 | 
			
		||||
            /* Cache Enabled: Set enabled to 1 */
 | 
			
		||||
            enabled = 1;
 | 
			
		||||
            break;
 | 
			
		||||
        case 1:
 | 
			
		||||
            /*
 | 
			
		||||
             * Statistic counters enabled, Cache disabled,
 | 
			
		||||
             * Manual power request (Setting: Power CTRL:
 | 
			
		||||
             * Manual, Invalidate: Manual)
 | 
			
		||||
             */
 | 
			
		||||
            FCache_Writel(SYS_FCACHE_CCR, (FCACHE_POW_REQ
 | 
			
		||||
                        | FCACHE_SET_MAN_POW
 | 
			
		||||
                        | FCACHE_SET_MAN_INV
 | 
			
		||||
                        | FCACHE_STATISTIC_EN));
 | 
			
		||||
            /* Wait until the cache rams are powered */
 | 
			
		||||
            while ((FCache_Readl(SYS_FCACHE_SR) & FCACHE_POW_STAT) != FCACHE_POW_STAT);
 | 
			
		||||
            /* Statistic counters enabled, Cache enabled
 | 
			
		||||
             * Manual invalidate request (Setting: Power CTRL:
 | 
			
		||||
             * Manual, Invalidate: Manual)
 | 
			
		||||
             */
 | 
			
		||||
            FCache_Writel(SYS_FCACHE_CCR, (FCACHE_INV_REQ
 | 
			
		||||
                        | FCACHE_POW_REQ
 | 
			
		||||
                        | FCACHE_SET_MAN_POW
 | 
			
		||||
                        | FCACHE_SET_MAN_INV
 | 
			
		||||
                        | FCACHE_STATISTIC_EN));
 | 
			
		||||
            /* Wait until the cache is invalidated */
 | 
			
		||||
            while ((FCache_Readl(SYS_FCACHE_SR) & FCACHE_INV_STAT) == FCACHE_INV_STAT);
 | 
			
		||||
            /* Statistic counters enabled, Cache enable,
 | 
			
		||||
             * manual-inval, manual-power control
 | 
			
		||||
             */
 | 
			
		||||
            FCache_Writel(SYS_FCACHE_CCR, (FCACHE_EN
 | 
			
		||||
                        | FCACHE_POW_REQ
 | 
			
		||||
                        | FCACHE_SET_MAN_POW
 | 
			
		||||
                        | FCACHE_SET_MAN_INV
 | 
			
		||||
                        | FCACHE_STATISTIC_EN));
 | 
			
		||||
            /* Wait until the cache is enabled */
 | 
			
		||||
            while ((FCache_Readl(SYS_FCACHE_SR) & FCACHE_CS) != FCACHE_CS_ENABLED);
 | 
			
		||||
            /* Cache Enabled: Set enabled to 1 */
 | 
			
		||||
            enabled = 1;
 | 
			
		||||
            break;
 | 
			
		||||
        default:
 | 
			
		||||
            break;
 | 
			
		||||
    }
 | 
			
		||||
}
 | 
			
		||||
 | 
			
		||||
/*
 | 
			
		||||
 * FCache_Disable: Disables the flash cache mode previously enabled
 | 
			
		||||
 */
 | 
			
		||||
void FCache_Disable()
 | 
			
		||||
{
 | 
			
		||||
    /* Disable the FCache */
 | 
			
		||||
    switch (fcache_mode) {
 | 
			
		||||
        case 0:
 | 
			
		||||
            /* Statistic counters enabled, Cache disable,
 | 
			
		||||
             * auto-inval, auto-power control
 | 
			
		||||
             */
 | 
			
		||||
            FCache_Writel(SYS_FCACHE_CCR, FCACHE_STATISTIC_EN);
 | 
			
		||||
            /* Wait until the cache is disabled */
 | 
			
		||||
            while ((FCache_Readl(SYS_FCACHE_SR) & FCACHE_CS) != FCACHE_CS_DISABLED);
 | 
			
		||||
            /* Cache Enabled: Set enabled to 0 */
 | 
			
		||||
            enabled = 0;
 | 
			
		||||
            break;
 | 
			
		||||
        case 1:
 | 
			
		||||
            /* Statistic counters enabled, Cache disable,
 | 
			
		||||
             * manual-inval, manual-power control
 | 
			
		||||
             */
 | 
			
		||||
            FCache_Writel(SYS_FCACHE_CCR, (FCACHE_POW_REQ
 | 
			
		||||
                        | FCACHE_SET_MAN_POW
 | 
			
		||||
                        | FCACHE_SET_MAN_INV
 | 
			
		||||
                        | FCACHE_STATISTIC_EN));
 | 
			
		||||
            /* Wait until the cache is disabled */
 | 
			
		||||
            while ((FCache_Readl(SYS_FCACHE_SR) & FCACHE_CS) != FCACHE_CS_DISABLED);
 | 
			
		||||
            /* Cache Enabled: Set enabled to 0 */
 | 
			
		||||
            enabled = 0;
 | 
			
		||||
            break;
 | 
			
		||||
        default:
 | 
			
		||||
            break;
 | 
			
		||||
    }
 | 
			
		||||
}
 | 
			
		||||
 | 
			
		||||
/*
 | 
			
		||||
 * FCache_Invalidate: to be invalidated the cache needs to be disabled.
 | 
			
		||||
 * return -1: flash cannot be disabled
 | 
			
		||||
 *        -2: flash cannot be enabled
 | 
			
		||||
 */
 | 
			
		||||
int FCache_Invalidate()
 | 
			
		||||
{
 | 
			
		||||
    /* Manual cache invalidate */
 | 
			
		||||
    if (fcache_mode == 1)
 | 
			
		||||
    {
 | 
			
		||||
        /* Disable Flash Cache */
 | 
			
		||||
        if (enabled == 1)
 | 
			
		||||
            FCache_Disable();
 | 
			
		||||
        else
 | 
			
		||||
            goto error;
 | 
			
		||||
 | 
			
		||||
        /* Trigger INV_REQ */
 | 
			
		||||
        FCache_Writel(SYS_FCACHE_CCR, (FCACHE_INV_REQ
 | 
			
		||||
                    | FCACHE_POW_REQ
 | 
			
		||||
                    | FCACHE_SET_MAN_POW
 | 
			
		||||
                    | FCACHE_SET_MAN_INV
 | 
			
		||||
                    | FCACHE_STATISTIC_EN));
 | 
			
		||||
 | 
			
		||||
        /* Wait until INV_REQ is finished */
 | 
			
		||||
        while ((FCache_Readl(SYS_FCACHE_SR) & FCACHE_CS) != FCACHE_CS_DISABLED);
 | 
			
		||||
 | 
			
		||||
        /* Clear Stats */
 | 
			
		||||
        FCache_Writel(SYS_FCACHE_CSHR, 0);
 | 
			
		||||
        FCache_Writel(SYS_FCACHE_CSMR, 0);
 | 
			
		||||
 | 
			
		||||
        /* Enable Flash Cache */
 | 
			
		||||
        if (enabled == 0)
 | 
			
		||||
            FCache_Enable(1);
 | 
			
		||||
 | 
			
		||||
error:
 | 
			
		||||
        if (enabled == 0)
 | 
			
		||||
            return -1;
 | 
			
		||||
        else
 | 
			
		||||
            return -2;
 | 
			
		||||
    }
 | 
			
		||||
 | 
			
		||||
    return 0;
 | 
			
		||||
}
 | 
			
		||||
 | 
			
		||||
unsigned int * FCache_GetStats()
 | 
			
		||||
{
 | 
			
		||||
    static unsigned int stats[2];
 | 
			
		||||
 | 
			
		||||
    /* Cache Statistics HIT Register */
 | 
			
		||||
    stats[0] = FCache_Readl(SYS_FCACHE_CSHR);
 | 
			
		||||
    /* Cache Statistics MISS Register */
 | 
			
		||||
    stats[1] = FCache_Readl(SYS_FCACHE_CSMR);
 | 
			
		||||
 | 
			
		||||
    return stats;
 | 
			
		||||
}
 | 
			
		||||
 | 
			
		||||
/*
 | 
			
		||||
 * FCache_isEnabled: returns 1 if FCache is enabled
 | 
			
		||||
 */
 | 
			
		||||
unsigned int FCache_isEnabled()
 | 
			
		||||
{
 | 
			
		||||
    return enabled;
 | 
			
		||||
}
 | 
			
		||||
| 
						 | 
				
			
			@ -1,106 +0,0 @@
 | 
			
		|||
/* mbed Microcontroller Library
 | 
			
		||||
 * Copyright (c) 2015 ARM Limited
 | 
			
		||||
 *
 | 
			
		||||
 * Licensed under the Apache License, Version 2.0 (the "License");
 | 
			
		||||
 * you may not use this file except in compliance with the License.
 | 
			
		||||
 * You may obtain a copy of the License at
 | 
			
		||||
 *
 | 
			
		||||
 *     http://www.apache.org/licenses/LICENSE-2.0
 | 
			
		||||
 *
 | 
			
		||||
 * Unless required by applicable law or agreed to in writing, software
 | 
			
		||||
 * distributed under the License is distributed on an "AS IS" BASIS,
 | 
			
		||||
 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
 | 
			
		||||
 * See the License for the specific language governing permissions and
 | 
			
		||||
 * limitations under the License.
 | 
			
		||||
 */
 | 
			
		||||
 | 
			
		||||
#ifndef _FCACHE_DRV_H
 | 
			
		||||
#define _FCACHE_DRV_H
 | 
			
		||||
 | 
			
		||||
#ifdef __cplusplus
 | 
			
		||||
 | 
			
		||||
extern "C" {
 | 
			
		||||
#else
 | 
			
		||||
#include <stdio.h>
 | 
			
		||||
#endif
 | 
			
		||||
 | 
			
		||||
    /* Flash Cache Address Map */
 | 
			
		||||
#define SYS_FCACHE_BASE 0x40003000
 | 
			
		||||
/* Configuration and Control Register */
 | 
			
		||||
#define SYS_FCACHE_CCR  (SYS_FCACHE_BASE)
 | 
			
		||||
/* Status Register */
 | 
			
		||||
#define SYS_FCACHE_SR   (SYS_FCACHE_BASE + 0x4)
 | 
			
		||||
/* Interrupt Req Status Register */
 | 
			
		||||
#define SYS_FCACHE_IRQSTAT  (SYS_FCACHE_BASE + 0x8)
 | 
			
		||||
/* Cache Statistic Hit Register */
 | 
			
		||||
#define SYS_FCACHE_CSHR (SYS_FCACHE_BASE + 0x14)
 | 
			
		||||
/* Cache Statistic Miss Register */
 | 
			
		||||
#define SYS_FCACHE_CSMR (SYS_FCACHE_BASE + 0x18)
 | 
			
		||||
 | 
			
		||||
    /* SYS_FCACHE_CCR (RW): Configuration and Control Register */
 | 
			
		||||
#define FCACHE_EN           1           /* FCache Enable */
 | 
			
		||||
#define FCACHE_INV_REQ      (1 << 1)    /* Manual Invalidate Request */
 | 
			
		||||
#define FCACHE_POW_REQ      (1 << 2)    /* Manual SRAM Power Request */
 | 
			
		||||
#define FCACHE_SET_MAN_POW  (1 << 3)    /* Power Control Setting */
 | 
			
		||||
#define FCACHE_SET_MAN_INV  (1 << 4)    /* Invalidate Control Setting */
 | 
			
		||||
#define FCACHE_SET_PREFETCH (1 << 5)    /* Cache Prefetch Setting */
 | 
			
		||||
#define FCACHE_STATISTIC_EN (1 << 6)    /* Enable Statistics Logic */
 | 
			
		||||
 | 
			
		||||
   /* SYS_FCACHE_SR (RO): Status Register */
 | 
			
		||||
#define FCACHE_CS           0x3     /* Cache Status Mask */
 | 
			
		||||
#define FCACHE_CS_DISABLED  0x0
 | 
			
		||||
#define FCACHE_CS_ENABLING  0x1
 | 
			
		||||
#define FCACHE_CS_ENABLED   0x2
 | 
			
		||||
#define FCACHE_CS_DISABLING 0x3
 | 
			
		||||
#define FCACHE_INV_STAT     0x4     /* Invalidating Status */
 | 
			
		||||
#define FCACHE_POW_STAT     0x10    /* SRAM Power Ack */
 | 
			
		||||
 | 
			
		||||
    /* SYS_FCACHE_IRQSTAT (RW): Interrupt Req Status Register */
 | 
			
		||||
#define FCACHE_POW_ERR      1           /* SRAM Power Error */
 | 
			
		||||
#define FCACHE_MAN_INV_ERR  (1 << 1)    /* Manual Invalidation error status */
 | 
			
		||||
 | 
			
		||||
    /* Macros */
 | 
			
		||||
#define FCache_Readl(reg) *(volatile unsigned int *)reg
 | 
			
		||||
#define FCache_Writel(reg, val)  *(volatile unsigned int *)reg = val;
 | 
			
		||||
 | 
			
		||||
/* Functions */
 | 
			
		||||
 | 
			
		||||
/*
 | 
			
		||||
 * FCache_DriverInitialize: flash cache driver initialize funtion
 | 
			
		||||
 */
 | 
			
		||||
void FCache_DriverInitialize(void);
 | 
			
		||||
 | 
			
		||||
/*
 | 
			
		||||
 * FCache_Enable: Enables the flash cache mode
 | 
			
		||||
 * mode: supported modes:
 | 
			
		||||
 * 0 - auto-power auto-invalidate
 | 
			
		||||
 * 1 - manual-power, manual-invalidate
 | 
			
		||||
 */
 | 
			
		||||
void FCache_Enable(int mode);
 | 
			
		||||
 | 
			
		||||
/*
 | 
			
		||||
 * FCache_Disable: Disables the flash cache mode previously enabled
 | 
			
		||||
 */
 | 
			
		||||
void FCache_Disable(void);
 | 
			
		||||
 | 
			
		||||
/*
 | 
			
		||||
 * FCache_Invalidate: to be invalidated the cache needs to be disabled.
 | 
			
		||||
 * return -1: flash cannot be disabled
 | 
			
		||||
 *        -2: flash cannot be enabled
 | 
			
		||||
 */
 | 
			
		||||
int FCache_Invalidate(void);
 | 
			
		||||
 | 
			
		||||
/*
 | 
			
		||||
 * FCache_GetStats: provides cache stats
 | 
			
		||||
 */
 | 
			
		||||
unsigned int * FCache_GetStats(void);
 | 
			
		||||
 | 
			
		||||
/*
 | 
			
		||||
 * FCache_isEnabled: returns 1 if FCache is enabled
 | 
			
		||||
 */
 | 
			
		||||
unsigned int FCache_isEnabled(void);
 | 
			
		||||
 | 
			
		||||
#ifdef __cplusplus
 | 
			
		||||
}
 | 
			
		||||
#endif
 | 
			
		||||
#endif /* _FCACHE_DRV_H */
 | 
			
		||||
| 
						 | 
				
			
			@ -1,95 +0,0 @@
 | 
			
		|||
/*
 | 
			
		||||
 * Copyright (c) 2009-2016 ARM Limited. All rights reserved.
 | 
			
		||||
 *
 | 
			
		||||
 * SPDX-License-Identifier: Apache-2.0
 | 
			
		||||
 *
 | 
			
		||||
 * Licensed under the Apache License, Version 2.0 (the License); you may
 | 
			
		||||
 * not use this file except in compliance with the License.
 | 
			
		||||
 * You may obtain a copy of the License at
 | 
			
		||||
 *
 | 
			
		||||
 * http://www.apache.org/licenses/LICENSE-2.0
 | 
			
		||||
 *
 | 
			
		||||
 * Unless required by applicable law or agreed to in writing, software
 | 
			
		||||
 * distributed under the License is distributed on an AS IS BASIS, WITHOUT
 | 
			
		||||
 * WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
 | 
			
		||||
 * See the License for the specific language governing permissions and
 | 
			
		||||
 * limitations under the License.
 | 
			
		||||
 */
 | 
			
		||||
/*
 | 
			
		||||
 * This file is derivative of CMSIS V5.00 system_ARMCM3.c
 | 
			
		||||
 */
 | 
			
		||||
 | 
			
		||||
#include "cmsis.h"
 | 
			
		||||
 | 
			
		||||
/*----------------------------------------------------------------------------
 | 
			
		||||
 * Define clocks
 | 
			
		||||
 *----------------------------------------------------------------------------*/
 | 
			
		||||
#define __XTAL (48000000UL) /* Oscillator frequency */
 | 
			
		||||
 | 
			
		||||
#define __SYSTEM_CLOCK (__XTAL / 2)
 | 
			
		||||
 | 
			
		||||
/*----------------------------------------------------------------------------
 | 
			
		||||
 * Clock Variable definitions
 | 
			
		||||
 *----------------------------------------------------------------------------*/
 | 
			
		||||
/* !< System Clock Frequency (Core Clock) */
 | 
			
		||||
uint32_t SystemCoreClock = __SYSTEM_CLOCK;
 | 
			
		||||
 | 
			
		||||
/*----------------------------------------------------------------------------
 | 
			
		||||
 * Clock functions
 | 
			
		||||
 *----------------------------------------------------------------------------*/
 | 
			
		||||
/**
 | 
			
		||||
 * Update SystemCoreClock variable
 | 
			
		||||
 *
 | 
			
		||||
 * @param  none
 | 
			
		||||
 * @return none
 | 
			
		||||
 *
 | 
			
		||||
 * @brief   Updates the SystemCoreClock with current core Clock
 | 
			
		||||
 *          retrieved from cpu registers.
 | 
			
		||||
 */
 | 
			
		||||
void SystemCoreClockUpdate (void)
 | 
			
		||||
{
 | 
			
		||||
 | 
			
		||||
    SystemCoreClock = __SYSTEM_CLOCK;
 | 
			
		||||
 | 
			
		||||
}
 | 
			
		||||
 | 
			
		||||
/**
 | 
			
		||||
 * Initialize the system
 | 
			
		||||
 *
 | 
			
		||||
 * @param  none
 | 
			
		||||
 * @return none
 | 
			
		||||
 *
 | 
			
		||||
 * @brief  Setup the microcontroller system.
 | 
			
		||||
 *         Initialize the System.
 | 
			
		||||
 */
 | 
			
		||||
void SystemInit (void)
 | 
			
		||||
{
 | 
			
		||||
 | 
			
		||||
#ifdef UNALIGNED_SUPPORT_DISABLE
 | 
			
		||||
    SCB->CCR |= SCB_CCR_UNALIGN_TRP_Msk;
 | 
			
		||||
#endif
 | 
			
		||||
 | 
			
		||||
    SystemCoreClock = __SYSTEM_CLOCK;
 | 
			
		||||
 | 
			
		||||
    // Enable AHB and APB clock
 | 
			
		||||
    /* GPIO */
 | 
			
		||||
    CMSDK_SYSCON->AHBCLKCFG0SET = 0xF;
 | 
			
		||||
    /*
 | 
			
		||||
     * Activate clock for: I2C1, SPI1, SPIO, QUADSPI, WDOG,
 | 
			
		||||
     * I2C0, UART0, UART1, TIMER0, TIMER1, DUAL TIMER, TRNG
 | 
			
		||||
     */
 | 
			
		||||
    CMSDK_SYSCON->APBCLKCFG0SET = SYSTEM_CORE_TIMER0
 | 
			
		||||
                            | SYSTEM_CORE_TIMER1
 | 
			
		||||
                            | SYSTEM_CORE_DUALTIMER0
 | 
			
		||||
                            | SYSTEM_CORE_UART0
 | 
			
		||||
                            | SYSTEM_CORE_UART1
 | 
			
		||||
                            | SYSTEM_CORE_I2C0
 | 
			
		||||
                            | SYSTEM_CORE_WDOG
 | 
			
		||||
                            | SYSTEM_CORE_QSPI
 | 
			
		||||
                            | SYSTEM_CORE_SPI0
 | 
			
		||||
                            | SYSTEM_CORE_SPI1
 | 
			
		||||
                            | SYSTEM_CORE_I2C1
 | 
			
		||||
                            | SYSTEM_CORE_TRNG;
 | 
			
		||||
    /* Beetle System Core Config */
 | 
			
		||||
    SystemCoreConfig();
 | 
			
		||||
}
 | 
			
		||||
Some files were not shown because too many files have changed in this diff Show More
		Loading…
	
		Reference in New Issue