Merge pull request #2832 from jeremybrodt/max326xx_updates

Updates to Maxim Integrated targets.
pull/3004/head
Sam Grove 2016-10-12 17:08:24 -05:00 committed by GitHub
commit fefde9d1db
80 changed files with 7845 additions and 365 deletions

View File

@ -0,0 +1,326 @@
/*******************************************************************************
* Copyright (C) 2016 Maxim Integrated Products, Inc., All Rights Reserved.
*
* Permission is hereby granted, free of charge, to any person obtaining a
* copy of this software and associated documentation files (the "Software"),
* to deal in the Software without restriction, including without limitation
* the rights to use, copy, modify, merge, publish, distribute, sublicense,
* and/or sell copies of the Software, and to permit persons to whom the
* Software is furnished to do so, subject to the following conditions:
*
* The above copyright notice and this permission notice shall be included
* in all copies or substantial portions of the Software.
*
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS
* OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
* MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT.
* IN NO EVENT SHALL MAXIM INTEGRATED BE LIABLE FOR ANY CLAIM, DAMAGES
* OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE,
* ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR
* OTHER DEALINGS IN THE SOFTWARE.
*
* Except as contained in this notice, the name of Maxim Integrated
* Products, Inc. shall not be used except as stated in the Maxim Integrated
* Products, Inc. Branding Policy.
*
* The mere transfer of this software does not imply any licenses
* of trade secrets, proprietary technology, copyrights, patents,
* trademarks, maskwork rights, or any other form of intellectual
* property whatsoever. Maxim Integrated Products, Inc. retains all
* ownership rights.
*******************************************************************************
*/
#include "mbed.h"
#include "us_ticker_api.h"
#include "MaximBLE.h"
#include "wsf_types.h"
#include "wsf_msg.h"
#include "wsf_os.h"
#include "wsf_buf.h"
#include "wsf_sec.h"
#include "wsf_timer.h"
#include "hci_handler.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_drv.h"
#include "hci_vs.h"
/* Number of WSF buffer pools */
#define WSF_BUF_POOLS 4
/*! Free memory for pool buffers. */
static uint8_t mainBufMem[768];
/*! Default pool descriptor. */
static wsfBufPoolDesc_t mainPoolDesc[WSF_BUF_POOLS] =
{
{ 16, 8 },
{ 32, 4 },
{ 64, 2 },
{ 128, 2 }
};
/*! WSF handler ID */
wsfHandlerId_t maximHandlerId;
static volatile int reset_complete;
/* Current mbed SPI API does not support HW slave selects. Configured in HCI driver. */
static DigitalOut _csn(HCI_CSN, 1);
static SPI _spi(HCI_MOSI, HCI_MISO, HCI_SCK, HCI_CSN);
static DigitalOut _rst(HCI_RST, 0);
static InterruptIn _irq(HCI_IRQ);
/**
* The singleton which represents the MaximBLE transport for the BLE.
*/
static MaximBLE deviceInstance;
/**
* BLE-API requires an implementation of the following function in order to
* obtain its transport handle.
*/
BLEInstanceBase *createBLEInstance(void)
{
return (&deviceInstance);
}
MaximBLE::MaximBLE(void) : initialized(false), instanceID(BLE::DEFAULT_INSTANCE)
{
}
MaximBLE::~MaximBLE(void)
{
}
const char *MaximBLE::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(maximHandlerId, pMsg);
}
}
static void maximHandler(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:
MaximGap::getInstance().advertisingStopped();
break;
case DM_SCAN_REPORT_IND:
{
hciLeAdvReportEvt_t *scanReport = (hciLeAdvReportEvt_t*)pMsg;
MaximGap::getInstance().processAdvertisementReport( scanReport->addr,
scanReport->rssi,
(scanReport->eventType == DM_ADV_SCAN_RESPONSE) ? true : false,
(GapAdvertisingParams::AdvertisingType_t)scanReport->eventType,
scanReport->len,
scanReport->pData);
}
break;
case DM_CONN_OPEN_IND:
{
hciLeConnCmplEvt_t *connOpen = (hciLeConnCmplEvt_t*)pMsg;
MaximGap::getInstance().setConnectionHandle(connOpen->handle);
Gap::ConnectionParams_t params = { connOpen->connInterval, connOpen->connInterval, connOpen->connLatency, connOpen->supTimeout };
Gap::AddressType_t ownAddrType;
Gap::Address_t ownAddr;
MaximGap::getInstance().getAddress(&ownAddrType, ownAddr);
MaximGap::getInstance().processConnectionEvent(connOpen->handle,
Gap::PERIPHERAL,
(Gap::AddressType_t)connOpen->addrType,
connOpen->peerAddr,
ownAddrType,
ownAddr,
&params);
}
break;
case DM_CONN_CLOSE_IND:
{
hciDisconnectCmplEvt_t *connClose = (hciDisconnectCmplEvt_t*)pMsg;
MaximGap::getInstance().setConnectionHandle(DM_CONN_ID_NONE);
MaximGap::getInstance().processDisconnectionEvent(connClose->handle, (Gap::DisconnectionReason_t)connClose->reason);
}
break;
case DM_HW_ERROR_IND:
{
hciHwErrorEvt_t *error = (hciHwErrorEvt_t*)pMsg;
printf("HCI Hardware Error 0x%02x occurred\n", error->code);
}
break;
default:
break;
}
}
}
static void AppServerConnCback(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;
}
}
ble_error_t MaximBLE::init(BLE::InstanceID_t instanceID, FunctionPointerWithContext<BLE::InitializationCompleteCallbackContext *> initCallback)
{
wsfHandlerId_t handlerId;
/* init OS subsystems */
WsfTimerInit(1);
WsfBufInit(sizeof(mainBufMem), mainBufMem, WSF_BUF_POOLS, mainPoolDesc);
WsfSecInit();
/* init stack */
handlerId = WsfOsSetNextHandler(HciHandler);
HciHandlerInit(handlerId);
handlerId = WsfOsSetNextHandler(DmHandler);
DmAdvInit();
DmScanInit();
DmConnInit();
DmConnSlaveInit();
DmSecInit();
DmHandlerInit(handlerId);
handlerId = WsfOsSetNextHandler(L2cSlaveHandler);
L2cSlaveHandlerInit(handlerId);
L2cInit();
L2cMasterInit();
L2cSlaveInit();
handlerId = WsfOsSetNextHandler(AttHandler);
AttHandlerInit(handlerId);
AttsInit();
AttsIndInit();
AttcInit();
handlerId = WsfOsSetNextHandler(SmpHandler);
SmpHandlerInit(handlerId);
SmpiInit();
SmprInit();
/* store handler ID */
maximHandlerId = WsfOsSetNextHandler(maximHandler);
/* init HCI */
_irq.disable_irq();
_irq.rise(hciDrvIsr);
_irq.fall(NULL);
hciDrvInit(HCI_CSN, HCI_RST, HCI_IRQ);
/* Register for stack callbacks */
DmRegister(DmCback);
DmConnRegister(DM_CLIENT_ID_APP, DmCback);
AttConnRegister(AppServerConnCback);
/* Reset the device */
reset_complete = 0;
DmDevReset();
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 MaximBLE::shutdown(void)
{
return BLE_ERROR_NOT_IMPLEMENTED;
}
void MaximBLE::waitForEvent(void)
{
static LowPowerTimeout nextTimeout;
timestamp_t nextTimestamp;
bool_t pTimerRunning;
callDispatcher();
if (wsfOsReadyToSleep()) {
// setup an mbed timer for the next Wicentric timeout
nextTimestamp = (timestamp_t)WsfTimerNextExpiration(&pTimerRunning) * 1000;
if (pTimerRunning) {
nextTimeout.attach_us(timeoutCallback, nextTimestamp);
}
// go to sleep
if (hciDrvReadyToSleep()) {
// go to deep sleep
deepsleep();
hciDrvResume();
}
else {
sleep();
}
}
}
void MaximBLE::processEvents()
{
callDispatcher();
}
void MaximBLE::timeoutCallback(void)
{
// do nothing. just an interrupt for wake up.
}
void MaximBLE::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();
}

View File

@ -0,0 +1,92 @@
/*******************************************************************************
* Copyright (C) 2016 Maxim Integrated Products, Inc., All Rights Reserved.
*
* Permission is hereby granted, free of charge, to any person obtaining a
* copy of this software and associated documentation files (the "Software"),
* to deal in the Software without restriction, including without limitation
* the rights to use, copy, modify, merge, publish, distribute, sublicense,
* and/or sell copies of the Software, and to permit persons to whom the
* Software is furnished to do so, subject to the following conditions:
*
* The above copyright notice and this permission notice shall be included
* in all copies or substantial portions of the Software.
*
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS
* OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
* MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT.
* IN NO EVENT SHALL MAXIM INTEGRATED BE LIABLE FOR ANY CLAIM, DAMAGES
* OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE,
* ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR
* OTHER DEALINGS IN THE SOFTWARE.
*
* Except as contained in this notice, the name of Maxim Integrated
* Products, Inc. shall not be used except as stated in the Maxim Integrated
* Products, Inc. Branding Policy.
*
* The mere transfer of this software does not imply any licenses
* of trade secrets, proprietary technology, copyrights, patents,
* trademarks, maskwork rights, or any other form of intellectual
* property whatsoever. Maxim Integrated Products, Inc. retains all
* ownership rights.
*******************************************************************************
*/
#ifndef _MAXIMBLE_H_
#define _MAXIMBLE_H_
#include "ble/BLE.h"
#include "ble/blecommon.h"
#include "ble/BLEInstanceBase.h"
#include "MaximGap.h"
#include "MaximGattServer.h"
#include "MaximGattClient.h"
#include "MaximSecurityManager.h"
class MaximBLE : public BLEInstanceBase
{
public:
MaximBLE(void);
virtual ~MaximBLE(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 MaximGap::getInstance();
};
virtual const Gap &getGap() const {
return MaximGap::getInstance();
};
virtual GattServer &getGattServer() {
return MaximGattServer::getInstance();
};
virtual const GattServer &getGattServer() const {
return MaximGattServer::getInstance();
};
virtual GattClient &getGattClient() {
return MaximGattClient::getInstance();
};
virtual SecurityManager &getSecurityManager() {
return MaximSecurityManager::getInstance();
};
virtual const SecurityManager &getSecurityManager() const {
return MaximSecurityManager::getInstance();
};
virtual void waitForEvent(void);
virtual void processEvents(void);
private:
bool initialized;
BLE::InstanceID_t instanceID;
static void timeoutCallback(void);
void callDispatcher(void);
};
#endif /* _MAXIMBLE_H_ */

View File

@ -0,0 +1,261 @@
/*******************************************************************************
* Copyright (C) 2016 Maxim Integrated Products, Inc., All Rights Reserved.
*
* Permission is hereby granted, free of charge, to any person obtaining a
* copy of this software and associated documentation files (the "Software"),
* to deal in the Software without restriction, including without limitation
* the rights to use, copy, modify, merge, publish, distribute, sublicense,
* and/or sell copies of the Software, and to permit persons to whom the
* Software is furnished to do so, subject to the following conditions:
*
* The above copyright notice and this permission notice shall be included
* in all copies or substantial portions of the Software.
*
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS
* OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
* MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT.
* IN NO EVENT SHALL MAXIM INTEGRATED BE LIABLE FOR ANY CLAIM, DAMAGES
* OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE,
* ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR
* OTHER DEALINGS IN THE SOFTWARE.
*
* Except as contained in this notice, the name of Maxim Integrated
* Products, Inc. shall not be used except as stated in the Maxim Integrated
* Products, Inc. Branding Policy.
*
* The mere transfer of this software does not imply any licenses
* of trade secrets, proprietary technology, copyrights, patents,
* trademarks, maskwork rights, or any other form of intellectual
* property whatsoever. Maxim Integrated Products, Inc. retains all
* ownership rights.
*******************************************************************************
*/
#include "MaximGap.h"
#include "mbed.h"
#include "hci_vs.h"
MaximGap &MaximGap::getInstance() {
static MaximGap m_instance;
return m_instance;
}
ble_error_t MaximGap::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;
}
/* save advertising and scan response data */
advDataLen = advData.getPayloadLen();
scanResponseLen = scanResponse.getPayloadLen();
memcpy((void*)advDataCache, (void*)advData.getPayload(), advDataLen);
memcpy((void*)advDataCache, (void*)advData.getPayload(), scanResponseLen);
return BLE_ERROR_NONE;
}
ble_error_t MaximGap::startAdvertising(const GapAdvertisingParams &params)
{
/* 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;
}
/* set advertising and scan response data for discoverable mode */
DmAdvSetData(DM_DATA_LOC_ADV, advDataLen, advDataCache);
DmAdvSetData(DM_DATA_LOC_SCAN, scanResponseLen, scanResponseCache);
DmAdvSetInterval(params.getInterval(), params.getInterval());
DmAdvStart(params.getAdvertisingType(), params.getTimeout());
state.advertising = 1;
return BLE_ERROR_NONE;
}
ble_error_t MaximGap::stopAdvertising(void)
{
DmAdvStop();
state.advertising = 0;
return BLE_ERROR_NONE;
}
void MaximGap::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 MaximGap::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 MaximGap::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 MaximGap::getPreferredConnectionParams(ConnectionParams_t *params)
{
return BLE_ERROR_NOT_IMPLEMENTED;
}
ble_error_t MaximGap::setPreferredConnectionParams(const ConnectionParams_t *params)
{
return BLE_ERROR_NOT_IMPLEMENTED;
}
ble_error_t MaximGap::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 MaximGap::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 MaximGap::stopScan(void)
{
DmScanStop();
return BLE_ERROR_NONE;
}
void MaximGap::setConnectionHandle(uint16_t connectionHandle)
{
m_connectionHandle = connectionHandle;
}
uint16_t MaximGap::getConnectionHandle(void)
{
return m_connectionHandle;
}
ble_error_t MaximGap::setAddress(AddressType_t type, const Address_t address)
{
if ((type != BLEProtocol::AddressType::PUBLIC) && (type != BLEProtocol::AddressType::RANDOM_STATIC)) {
return BLE_ERROR_PARAM_OUT_OF_RANGE;
}
m_type = type;
HciVsSetPublicAddr((uint8_t*)address);
return BLE_ERROR_NONE;
}
ble_error_t MaximGap::getAddress(AddressType_t *typeP, Address_t address)
{
*typeP = m_type;
BdaCpy(address, HciGetBdAddr());
return BLE_ERROR_NONE;
}
ble_error_t MaximGap::setDeviceName(const uint8_t *deviceName)
{
return BLE_ERROR_NOT_IMPLEMENTED;
}
ble_error_t MaximGap::getDeviceName(uint8_t *deviceName, unsigned *lengthP)
{
return BLE_ERROR_NOT_IMPLEMENTED;
}
ble_error_t MaximGap::setAppearance(GapAdvertisingData::Appearance appearance)
{
return BLE_ERROR_NOT_IMPLEMENTED;
}
ble_error_t MaximGap::getAppearance(GapAdvertisingData::Appearance *appearanceP)
{
return BLE_ERROR_NOT_IMPLEMENTED;
}
ble_error_t MaximGap::setTxPower(int8_t txPower)
{
HciVsSetTxPower(txPower);
return BLE_ERROR_NONE;
}
void MaximGap::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);
}

View File

@ -0,0 +1,112 @@
/*******************************************************************************
* Copyright (C) 2016 Maxim Integrated Products, Inc., All Rights Reserved.
*
* Permission is hereby granted, free of charge, to any person obtaining a
* copy of this software and associated documentation files (the "Software"),
* to deal in the Software without restriction, including without limitation
* the rights to use, copy, modify, merge, publish, distribute, sublicense,
* and/or sell copies of the Software, and to permit persons to whom the
* Software is furnished to do so, subject to the following conditions:
*
* The above copyright notice and this permission notice shall be included
* in all copies or substantial portions of the Software.
*
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS
* OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
* MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT.
* IN NO EVENT SHALL MAXIM INTEGRATED BE LIABLE FOR ANY CLAIM, DAMAGES
* OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE,
* ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR
* OTHER DEALINGS IN THE SOFTWARE.
*
* Except as contained in this notice, the name of Maxim Integrated
* Products, Inc. shall not be used except as stated in the Maxim Integrated
* Products, Inc. Branding Policy.
*
* The mere transfer of this software does not imply any licenses
* of trade secrets, proprietary technology, copyrights, patents,
* trademarks, maskwork rights, or any other form of intellectual
* property whatsoever. Maxim Integrated Products, Inc. retains all
* ownership rights.
*******************************************************************************
*/
#ifndef _MAXIM_GAP_H_
#define _MAXIM_GAP_H_
#include "mbed.h"
#include "ble/blecommon.h"
#include "ble/GapAdvertisingParams.h"
#include "ble/GapAdvertisingData.h"
#include "ble/Gap.h"
#include "ble/GapScanningParams.h"
#include "dm_api.h"
#include "att_api.h"
/**************************************************************************/
/*!
\brief
*/
/**************************************************************************/
class MaximGap : public Gap
{
public:
static MaximGap &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 /**< Maximum 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;
MaximGap() {
m_connectionHandle = DM_CONN_ID_NONE;
m_type = BLEProtocol::AddressType::RANDOM_STATIC;
}
MaximGap(MaximGap const &);
void operator=(MaximGap const &);
uint8_t advDataCache[HCI_LEN_LE_SET_ADV_DATA];
uint8_t scanResponseCache[HCI_LEN_LE_SET_SCAN_RESP_DATA];
int advDataLen;
int scanResponseLen;
};
#endif /* _MAXIM_GAP_H_ */

View File

@ -0,0 +1,58 @@
/*******************************************************************************
* Copyright (C) 2016 Maxim Integrated Products, Inc., All Rights Reserved.
*
* Permission is hereby granted, free of charge, to any person obtaining a
* copy of this software and associated documentation files (the "Software"),
* to deal in the Software without restriction, including without limitation
* the rights to use, copy, modify, merge, publish, distribute, sublicense,
* and/or sell copies of the Software, and to permit persons to whom the
* Software is furnished to do so, subject to the following conditions:
*
* The above copyright notice and this permission notice shall be included
* in all copies or substantial portions of the Software.
*
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS
* OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
* MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT.
* IN NO EVENT SHALL MAXIM INTEGRATED BE LIABLE FOR ANY CLAIM, DAMAGES
* OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE,
* ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR
* OTHER DEALINGS IN THE SOFTWARE.
*
* Except as contained in this notice, the name of Maxim Integrated
* Products, Inc. shall not be used except as stated in the Maxim Integrated
* Products, Inc. Branding Policy.
*
* The mere transfer of this software does not imply any licenses
* of trade secrets, proprietary technology, copyrights, patents,
* trademarks, maskwork rights, or any other form of intellectual
* property whatsoever. Maxim Integrated Products, Inc. retains all
* ownership rights.
*******************************************************************************
*/
#ifndef _MAXIM_GATT_CLIENT_H_
#define _MAXIM_GATT_CLIENT_H_
#include <stddef.h>
#include "ble/GattClient.h"
class MaximGattClient : public GattClient
{
public:
static MaximGattClient &getInstance() {
static MaximGattClient m_instance;
return m_instance;
}
public:
MaximGattClient() {
/* empty */
}
private:
};
#endif /* _MAXIM_GATT_CLIENT_H_ */

View File

@ -0,0 +1,439 @@
/*******************************************************************************
* Copyright (C) 2016 Maxim Integrated Products, Inc., All Rights Reserved.
*
* Permission is hereby granted, free of charge, to any person obtaining a
* copy of this software and associated documentation files (the "Software"),
* to deal in the Software without restriction, including without limitation
* the rights to use, copy, modify, merge, publish, distribute, sublicense,
* and/or sell copies of the Software, and to permit persons to whom the
* Software is furnished to do so, subject to the following conditions:
*
* The above copyright notice and this permission notice shall be included
* in all copies or substantial portions of the Software.
*
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS
* OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
* MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT.
* IN NO EVENT SHALL MAXIM INTEGRATED BE LIABLE FOR ANY CLAIM, DAMAGES
* OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE,
* ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR
* OTHER DEALINGS IN THE SOFTWARE.
*
* Except as contained in this notice, the name of Maxim Integrated
* Products, Inc. shall not be used except as stated in the Maxim Integrated
* Products, Inc. Branding Policy.
*
* The mere transfer of this software does not imply any licenses
* of trade secrets, proprietary technology, copyrights, patents,
* trademarks, maskwork rights, or any other form of intellectual
* property whatsoever. Maxim Integrated Products, Inc. retains all
* ownership rights.
*******************************************************************************
*/
#include "MaximGattServer.h"
#include "mbed.h"
#include "MaximGap.h"
#include "wsf_types.h"
#include "att_api.h"
typedef struct mxmChar_s {
uint16_t descLen;
mxmChar_s() {}
} mxmChar_t;
typedef struct mxmService_s mxmService_t;
struct mxmService_s {
uint16_t uuidLen;
mxmChar_t *chars;
attsGroup_t *attGroup;
mxmService_t *next;
mxmService_s() {}
};
static uint16_t currentHandle = 0x20;
static UUID cccUUID(BLE_UUID_DESCRIPTOR_CLIENT_CHAR_CONFIG);
static const uint16_t cccSize = sizeof(uint16_t);
MaximGattServer &MaximGattServer::getInstance() {
static MaximGattServer m_instance;
return m_instance;
}
ble_error_t MaximGattServer::addService(GattService &service)
{
currentHandle = (currentHandle + 0xF) & ~0xF;
uint16_t startHandle = currentHandle;
mxmService_t *mxmSvc = new mxmService_t;
// Create WiCentric attribute group
mxmSvc->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
mxmSvc->attGroup->pAttr = (attsAttr_t*)malloc(attListLen * sizeof(attsAttr_t));;
if (mxmSvc->attGroup->pAttr == NULL) {
return BLE_ERROR_BUFFER_OVERFLOW;
}
// Create characteristics
mxmSvc->chars = new mxmChar_t [service.getCharacteristicCount()];
attsAttr_t *currAtt = mxmSvc->attGroup->pAttr;
/* Service */
currAtt->pUuid = attPrimSvcUuid;
if (service.getUUID().shortOrLong() == UUID::UUID_TYPE_LONG) {
mxmSvc->uuidLen = UUID::LENGTH_OF_LONG_UUID;
} else {
mxmSvc->uuidLen = sizeof(UUID::ShortUUIDBytes_t);
}
currAtt->pValue = (uint8_t*)malloc(mxmSvc->uuidLen);
memcpy(currAtt->pValue, service.getUUID().getBaseUUID(), mxmSvc->uuidLen);
currAtt->maxLen = mxmSvc->uuidLen;
currAtt->pLen = &mxmSvc->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);
mxmSvc->chars[i].descLen = 1 + sizeof(currentHandle) + p_char->getValueAttribute().getUUID().getLen();
currAtt->pValue = (uint8_t*)malloc(mxmSvc->chars[i].descLen);
uint8_t *pValue = currAtt->pValue;
*pValue++ = p_char->getProperties();
memcpy(pValue, &currentHandle, sizeof(currentHandle));
pValue += sizeof(currentHandle);
memcpy(pValue, p_char->getValueAttribute().getUUID().getBaseUUID(), p_char->getValueAttribute().getUUID().getLen());
currAtt->pLen = &mxmSvc->chars[i].descLen;
currAtt->maxLen = mxmSvc->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().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++;
}
}
mxmSvc->attGroup->pNext = NULL;
mxmSvc->attGroup->readCback = attsReadCback;
mxmSvc->attGroup->writeCback = attsWriteCback;
mxmSvc->attGroup->startHandle = startHandle;
mxmSvc->attGroup->endHandle = currentHandle;
AttsAddGroup(mxmSvc->attGroup);
AttRegister(attCback);
AttsCccRegister(cccCnt, (attsCccSet_t*)cccSet, cccCback);
return BLE_ERROR_NONE;
}
ble_error_t MaximGattServer::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 MaximGattServer::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 MaximGattServer::write(GattAttribute::Handle_t attributeHandle, const uint8_t buffer[], uint16_t len, bool localOnly)
{
uint16_t connectionHandle = MaximGap::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 MaximGattServer::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 MaximGattServer::areUpdatesEnabled(const GattCharacteristic &characteristic, bool *enabledP)
{
uint16_t connectionHandle = MaximGap::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 MaximGattServer::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 MaximGattServer::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 MaximGattServer::attCback(attEvt_t *pEvt)
{
if (pEvt->hdr.status == ATT_SUCCESS) {
getInstance().handleEvent(GattServerEvents::GATT_EVENT_DATA_SENT, pEvt->handle);
}
}
uint8_t MaximGattServer::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 MaximGattServer::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;
}

View File

@ -0,0 +1,84 @@
/*******************************************************************************
* Copyright (C) 2016 Maxim Integrated Products, Inc., All Rights Reserved.
*
* Permission is hereby granted, free of charge, to any person obtaining a
* copy of this software and associated documentation files (the "Software"),
* to deal in the Software without restriction, including without limitation
* the rights to use, copy, modify, merge, publish, distribute, sublicense,
* and/or sell copies of the Software, and to permit persons to whom the
* Software is furnished to do so, subject to the following conditions:
*
* The above copyright notice and this permission notice shall be included
* in all copies or substantial portions of the Software.
*
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS
* OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
* MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT.
* IN NO EVENT SHALL MAXIM INTEGRATED BE LIABLE FOR ANY CLAIM, DAMAGES
* OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE,
* ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR
* OTHER DEALINGS IN THE SOFTWARE.
*
* Except as contained in this notice, the name of Maxim Integrated
* Products, Inc. shall not be used except as stated in the Maxim Integrated
* Products, Inc. Branding Policy.
*
* The mere transfer of this software does not imply any licenses
* of trade secrets, proprietary technology, copyrights, patents,
* trademarks, maskwork rights, or any other form of intellectual
* property whatsoever. Maxim Integrated Products, Inc. retains all
* ownership rights.
*******************************************************************************
*/
#ifndef _MAXIM_GATT_SERVER_H_
#define _MAXIM_GATT_SERVER_H_
#include <stddef.h>
#include "ble/blecommon.h"
#include "ble/GattServer.h"
#include "wsf_types.h"
#include "att_api.h"
class MaximGattServer : public GattServer
{
public:
static MaximGattServer &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:
MaximGattServer() : GattServer(), cccSet(), cccValues(), cccHandles(), cccCnt(0) {
/* empty */
}
MaximGattServer(const MaximGattServer &);
const MaximGattServer& operator=(const MaximGattServer &);
};
#endif /* _MAXIM_GATT_SERVER_H_ */

View File

@ -0,0 +1,55 @@
/*******************************************************************************
* Copyright (C) 2016 Maxim Integrated Products, Inc., All Rights Reserved.
*
* Permission is hereby granted, free of charge, to any person obtaining a
* copy of this software and associated documentation files (the "Software"),
* to deal in the Software without restriction, including without limitation
* the rights to use, copy, modify, merge, publish, distribute, sublicense,
* and/or sell copies of the Software, and to permit persons to whom the
* Software is furnished to do so, subject to the following conditions:
*
* The above copyright notice and this permission notice shall be included
* in all copies or substantial portions of the Software.
*
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS
* OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
* MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT.
* IN NO EVENT SHALL MAXIM INTEGRATED BE LIABLE FOR ANY CLAIM, DAMAGES
* OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE,
* ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR
* OTHER DEALINGS IN THE SOFTWARE.
*
* Except as contained in this notice, the name of Maxim Integrated
* Products, Inc. shall not be used except as stated in the Maxim Integrated
* Products, Inc. Branding Policy.
*
* The mere transfer of this software does not imply any licenses
* of trade secrets, proprietary technology, copyrights, patents,
* trademarks, maskwork rights, or any other form of intellectual
* property whatsoever. Maxim Integrated Products, Inc. retains all
* ownership rights.
*******************************************************************************
*/
#ifndef _MAXIM_SECURITY_MANAGER_H_
#define _MAXIM_SECURITY_MANAGER_H_
#include <stddef.h>
#include "ble/SecurityManager.h"
class MaximSecurityManager : public SecurityManager
{
public:
static MaximSecurityManager &getInstance() {
static MaximSecurityManager m_instance;
return m_instance;
}
public:
MaximSecurityManager() {
/* empty */
}
};
#endif /* _MAXIM_SECURITY_MANAGER_H_ */

View File

@ -0,0 +1,49 @@
Permissive Binary License
Copyright (c) 2016, ARM, Ltd. All rights reserved.
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.

View File

@ -0,0 +1,114 @@
/*************************************************************************************************/
/*!
* \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-2016 ARM Limited. All rights reserved.
*
* SPDX-License-Identifier: LicenseRef-PBL
*
* Licensed under the Permissive Binary License, Version 1.0 (the "License"); you may not use
* this file except in compliance with the License. You may obtain a copy of the License at
*
* https://www.mbed.com/licenses/PBL-1.0
*
* See the License for the specific language governing permissions and limitations under the License.
*/
/*************************************************************************************************/
#ifndef HCI_DRV_H
#define HCI_DRV_H
#ifdef __cplusplus
extern "C" {
#endif
#include "PinNames.h"
/**************************************************************************************************
Function Declarations
**************************************************************************************************/
/*************************************************************************************************/
/*!
* \fn hciDrvInit
*
* \brief Initialize the driver.
*
* \param csn name of the pin connected to CSN
* \param irq name of the pin conntected to IRQ
*/
/*************************************************************************************************/
void hciDrvInit(PinName csn, PinName rst, PinName irq);
/*************************************************************************************************/
/*!
* \fn hciDrvWrite
*
* \brief Write data to 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, bool_t last);
/*************************************************************************************************/
/*!
* \fn hciDrvIsr
*
* \brief Interrupt service routine for IRQ
*/
/*************************************************************************************************/
void hciDrvIsr(void);
/*************************************************************************************************/
/*!
* \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);
void hciDrvResume(void);
/*************************************************************************************************/
/*!
* \fn hciDrvReset
*
* \brief Resets the controller
*/
/*************************************************************************************************/
void hciDrvReset(void);
#ifdef __cplusplus
};
#endif
#endif /* HCI_DRV_H */

View File

@ -0,0 +1,59 @@
/*************************************************************************************************/
/*!
* \file hci_drv.h
*
* \brief HCI vendor specific functions for EM Microelectronic.
*
* $Date: 2013-01-02 22:19:17 -0800 (Wed, 02 Jan 2013) $
* $Revision: 405 $
*
* Copyright (c) 2012-2016 ARM Limited. All rights reserved.
*
* SPDX-License-Identifier: LicenseRef-PBL
*
* Licensed under the Permissive Binary License, Version 1.0 (the "License"); you may not use
* this file except in compliance with the License. You may obtain a copy of the License at
*
* https://www.mbed.com/licenses/PBL-1.0
*
* See the License for the specific language governing permissions and limitations under the License.
*/
/*************************************************************************************************/
#ifndef HCI_VS_H
#define HCI_VS_H
#ifdef __cplusplus
extern "C" {
#endif
/*************************************************************************************************/
/*!
* \fn HciVsSetPublicAddr
*
* \brief Vendor-specific set public address function.
*
* \param param public address
*
* \return None.
*/
/*************************************************************************************************/
void HciVsSetPublicAddr(uint8_t *bdAddr);
/*************************************************************************************************/
/*!
* \fn HciVsSetTxPower
*
* \brief Vendor-specific set RF output power function
*
* \param param output power in dB
*
* \return None.
*/
/*************************************************************************************************/
void HciVsSetTxPower(int txPower);
#ifdef __cplusplus
};
#endif
#endif /* HCI_VS_H */

View File

@ -0,0 +1,71 @@
/*************************************************************************************************/
/*!
* \file cfg_stack.h
*
* \brief Stack configuration.
*
* $Date: 2011-10-14 21:35:03 -0700 (Fri, 14 Oct 2011) $
* $Revision: 191 $
*
* Copyright (c) 2009-2016 ARM Limited. All rights reserved.
*
* SPDX-License-Identifier: LicenseRef-PBL
*
* Licensed under the Permissive Binary License, Version 1.0 (the "License"); you may not use
* this file except in compliance with the License. You may obtain a copy of the License at
*
* https://www.mbed.com/licenses/PBL-1.0
*
* See the License for the specific language governing permissions and limitations under the License.
*/
/*************************************************************************************************/
#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
**************************************************************************************************/
/**************************************************************************************************
ATT
**************************************************************************************************/
/**************************************************************************************************
SMP
**************************************************************************************************/
#ifdef __cplusplus
};
#endif
#endif /* CFG_STACK_H */

View File

@ -0,0 +1,942 @@
/*************************************************************************************************/
/*!
* \file att_api.h
*
* \brief Attribute protocol client and server API.
*
* $Date: 2012-05-07 19:54:28 -0700 (Mon, 07 May 2012) $
* $Revision: 315 $
*
* Copyright (c) 2009-2016 ARM Limited. All rights reserved.
*
* SPDX-License-Identifier: LicenseRef-PBL
*
* Licensed under the Permissive Binary License, Version 1.0 (the "License"); you may not use
* this file except in compliance with the License. You may obtain a copy of the License at
*
* https://www.mbed.com/licenses/PBL-1.0
*
* See the License for the specific language governing permissions and limitations under the License.
*/
/*************************************************************************************************/
#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 attributes UUID */
uint8_t *pValue; /*! Pointer to the attributes value */
uint16_t *pLen; /*! Pointer to the length of the attributes value */
uint16_t maxLen; /*! Maximum length of attributes 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 */

View File

@ -0,0 +1,221 @@
/*************************************************************************************************/
/*!
* \file att_defs.h
*
* \brief Attribute protocol constants and definitions from the Bluetooth specification.
*
* $Date: 2012-09-11 16:18:57 -0700 (Tue, 11 Sep 2012) $
* $Revision: 349 $
*
* Copyright (c) 2009-2016 ARM Limited. All rights reserved.
*
* SPDX-License-Identifier: LicenseRef-PBL
*
* Licensed under the Permissive Binary License, Version 1.0 (the "License"); you may not use
* this file except in compliance with the License. You may obtain a copy of the License at
*
* https://www.mbed.com/licenses/PBL-1.0
*
* See the License for the specific language governing permissions and limitations under the License.
*/
/*************************************************************************************************/
#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_CONTINUING 0x77 /*! 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 */

View File

@ -0,0 +1,67 @@
/*************************************************************************************************/
/*!
* \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-2016 ARM Limited. All rights reserved.
*
* SPDX-License-Identifier: LicenseRef-PBL
*
* Licensed under the Permissive Binary License, Version 1.0 (the "License"); you may not use
* this file except in compliance with the License. You may obtain a copy of the License at
*
* https://www.mbed.com/licenses/PBL-1.0
*
* See the License for the specific language governing permissions and limitations under the License.
*/
/*************************************************************************************************/
#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 */

View File

@ -0,0 +1,431 @@
/*************************************************************************************************/
/*!
* \file att_uuid.h
*
* \brief Attribute protocol UUIDs from the Bluetooth specification.
*
* $Date: 2014-08-11 17:41:56 -0500 (Mon, 11 Aug 2014) $
* $Revision: 14613 $
*
* Copyright (c) 2011-2016 ARM Limited. All rights reserved.
*
* SPDX-License-Identifier: LicenseRef-PBL
*
* Licensed under the Permissive Binary License, Version 1.0 (the "License"); you may not use
* this file except in compliance with the License. You may obtain a copy of the License at
*
* https://www.mbed.com/licenses/PBL-1.0
*
* See the License for the specific language governing permissions and limitations under the License.
*/
/*************************************************************************************************/
#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 */
#define ATT_UUID_WEIGHT_SCALE_SERVICE 0x181D /*! Weight Scale 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_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_REPORT_MAP 0x2A22 /*! HID Boot Report Mapping */
#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_PRODUCT_ID 0x2A32 /*! Product ID */
#define ATT_UUID_HID_VERSION 0x2A33 /*! HID Version */
#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_INFO 0x2A4A /*! HID Information */
#define ATT_UUID_REPORT_MAP 0x2A4B /*! Report Map */
#define ATT_UUID_HID_CP 0x2A4C /*! HID Control Point */
#define ATT_UUID_REPORT 0x2A4D /*! Report */
#define ATT_UUID_PROTOCOL_MODE 0x2A4E /*! 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_WEIGHT_MEAS 0x2A9D /*! Weight Measurement */
#define ATT_UUID_WEIGHT_SCALE_FEATURE 0x2A9E /*! Weight Scale Feature */
/* 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 */
/*! 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 */
extern const uint8_t attWssSvcUuid[ATT_16_UUID_LEN]; /*! Weight scale 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 attValRangeUuid[ATT_16_UUID_LEN]; /*! Valid Range */
extern const uint8_t attHidRimUuid[ATT_16_UUID_LEN]; /*! HID Report ID Mapping */
/*! 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 attMiChUuid[ATT_16_UUID_LEN]; /*! Measurement Interval */
extern const uint8_t attHbrpChUuid[ATT_16_UUID_LEN]; /*! HID Boot Report Mapping */
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 attPidChUuid[ATT_16_UUID_LEN]; /*! Product ID */
extern const uint8_t attHidvChUuid[ATT_16_UUID_LEN]; /*! HID Version */
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 attHidiChUuid[ATT_16_UUID_LEN]; /*! HID Information */
extern const uint8_t attRmChUuid[ATT_16_UUID_LEN]; /*! Report Map */
extern const uint8_t attHidcpChUuid[ATT_16_UUID_LEN]; /*! HID Control Point */
extern const uint8_t attRepChUuid[ATT_16_UUID_LEN]; /*! Report */
extern const uint8_t attPmChUuid[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 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

View File

@ -0,0 +1,67 @@
/*************************************************************************************************/
/*!
* \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-2016 ARM Limited. All rights reserved.
*
* SPDX-License-Identifier: LicenseRef-PBL
*
* Licensed under the Permissive Binary License, Version 1.0 (the "License"); you may not use
* this file except in compliance with the License. You may obtain a copy of the License at
*
* https://www.mbed.com/licenses/PBL-1.0
*
* See the License for the specific language governing permissions and limitations under the License.
*/
/*************************************************************************************************/
#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 */

View File

@ -0,0 +1,375 @@
/*************************************************************************************************/
/*!
* \file hci_api.h
*
* \brief HCI subsystem API.
*
* $Date: 2011-10-14 21:35:03 -0700 (Fri, 14 Oct 2011) $
* $Revision: 191 $
*
* Copyright (c) 2009-2016 ARM Limited. All rights reserved.
*
* SPDX-License-Identifier: LicenseRef-PBL
*
* Licensed under the Permissive Binary License, Version 1.0 (the "License"); you may not use
* this file except in compliance with the License. You may obtain a copy of the License at
*
* https://www.mbed.com/licenses/PBL-1.0
*
* See the License for the specific language governing permissions and limitations under the License.
*/
/*************************************************************************************************/
#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_DISCONNECT_CMPL_CBACK_EVT 2 /*! LE disconnect complete */
#define HCI_LE_CONN_UPDATE_CMPL_CBACK_EVT 3 /*! LE connection update complete */
#define HCI_LE_CREATE_CONN_CANCEL_CMD_CMPL_CBACK_EVT 4 /*! LE create connection cancel command complete */
#define HCI_LE_ADV_REPORT_CBACK_EVT 5 /*! LE advertising report */
#define HCI_READ_RSSI_CMD_CMPL_CBACK_EVT 6 /*! Read RSSI command complete */
#define HCI_LE_READ_CHAN_MAP_CMD_CMPL_CBACK_EVT 7 /*! LE Read channel map command complete */
#define HCI_READ_TX_PWR_LVL_CMD_CMPL_CBACK_EVT 8 /*! Read transmit power level command complete */
#define HCI_READ_REMOTE_VER_INFO_CMPL_CBACK_EVT 9 /*! Read remote version information complete */
#define HCI_LE_READ_REMOTE_FEAT_CMPL_CBACK_EVT 10 /*! LE read remote features complete */
#define HCI_LE_LTK_REQ_REPL_CMD_CMPL_CBACK_EVT 11 /*! LE LTK request reply command complete */
#define HCI_LE_LTK_REQ_NEG_REPL_CMD_CMPL_CBACK_EVT 12 /*! LE LTK request negative reply command complete */
#define HCI_ENC_KEY_REFRESH_CMPL_CBACK_EVT 13 /*! Encryption key refresh complete */
#define HCI_ENC_CHANGE_CBACK_EVT 14 /*! Encryption change */
#define HCI_LE_LTK_REQ_CBACK_EVT 15 /*! LE LTK request */
#define HCI_VENDOR_SPEC_CMD_STATUS_CBACK_EVT 16 /*! Vendor specific command status */
#define HCI_VENDOR_SPEC_CMD_CMPL_CBACK_EVT 17 /*! Vendor specific command complete */
#define HCI_VENDOR_SPEC_CBACK_EVT 18 /*! Vendor specific */
#define HCI_HW_ERROR_CBACK_EVT 19 /*! Hardware error */
#define HCI_LE_ENCRYPT_CMD_CMPL_CBACK_EVT 20 /*! LE encrypt command complete */
#define HCI_LE_RAND_CMD_CMPL_CBACK_EVT 21 /*! LE rand command complete */
/**************************************************************************************************
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;
} 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;
} hciLeAdvReportEvt_t;
/*! Read RSSI command complete event */
typedef struct
{
wsfMsgHdr_t hdr;
uint8_t status;
uint8_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;
/*! 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;
} 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);
/*! 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);
/*! 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 directAddrType, uint8_t *pDirectAddr,
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 HciVendorSpecificCmd(uint16_t opcode, uint8_t len, uint8_t *pData);
#ifdef __cplusplus
};
#endif
#endif /* HCI_API_H */

View File

@ -0,0 +1,462 @@
/*************************************************************************************************/
/*!
* \file hci_defs.h
*
* \brief HCI constants and definitions from the Bluetooth specification.
*
* $Date: 2012-06-26 21:53:53 -0700 (Tue, 26 Jun 2012) $
* $Revision: 337 $
*
* Copyright (c) 2009-2016 ARM Limited. All rights reserved.
*
* SPDX-License-Identifier: LicenseRef-PBL
*
* Licensed under the Permissive Binary License, Version 1.0 (the "License"); you may not use
* this file except in compliance with the License. You may obtain a copy of the License at
*
* https://www.mbed.com/licenses/PBL-1.0
*
* See the License for the specific language governing permissions and limitations under the License.
*/
/*************************************************************************************************/
#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_PB_FLAG_MASK 0x1000 /*! ACL packet boundary flag mask */
#define HCI_PB_START 0x0000 /*! Packet boundary flag, start */
#define HCI_PB_CONTINUE 0x1000 /*! Packet boundary flag, continue */
#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
/*! 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
/*! 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_CONTROLLER_TO_HOST_FC HCI_OPCODE(HCI_OGF_CONTROLLER, HCI_OCF_SET_CONTROLLER_TO_HOST_FC)
#define HCI_OPCODE_HOST_BUFFER_SIZE HCI_OPCODE(HCI_OGF_CONTROLLER, HCI_OCF_HOST_BUFFER_SIZE)
#define HCI_OPCODE_HOST_NUM_CMPL_PKTS HCI_OPCODE(HCI_OGF_CONTROLLER, HCI_OCF_HOST_NUM_CMPL_PKTS)
#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)
/*! 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_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_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
/*! 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_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
/*! Event parameter lengths */
#define HCI_LEN_DISCONNECT_CMPL 4
#define HCI_LEN_ENC_CHANGE 5
#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_SET_CONTROLLER_TO_HOST_FC 0x20 /*! Byte 10 */
#define HCI_SUP_HOST_BUFFER_SIZE 0x40 /*! Byte 10 */
#define HCI_SUP_HOST_NUM_CMPL_PKTS 0x80 /*! 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_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 */
/*! 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 */
/*! 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 */
/*! LE supported features */
#define HCI_LE_SUP_FEAT_ENCRYPTION 0x01
/*! 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 advertising */
#define HCI_ADV_TYPE_DISC_UNDIRECT 0x02 /*! Discoverable undirected advertising */
#define HCI_ADV_TYPE_NONCONN_UNDIRECT 0x03 /*! Nonconnectable undirected 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_FILT_NONE 0 /*! No white list filtering */
#define HCI_FILT_WHITE_LIST 1 /*! White list filtering */
#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_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 */
/*! Wicentric company ID */
#define HCI_ID_WICENTRIC 0x005F
#ifdef __cplusplus
};
#endif
#endif /* HCI_DEFS_H */

View File

@ -0,0 +1,67 @@
/*************************************************************************************************/
/*!
* \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-2016 ARM Limited. All rights reserved.
*
* SPDX-License-Identifier: LicenseRef-PBL
*
* Licensed under the Permissive Binary License, Version 1.0 (the "License"); you may not use
* this file except in compliance with the License. You may obtain a copy of the License at
*
* https://www.mbed.com/licenses/PBL-1.0
*
* See the License for the specific language governing permissions and limitations under the License.
*/
/*************************************************************************************************/
#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 */

View File

@ -0,0 +1,173 @@
/*************************************************************************************************/
/*!
* \file l2c_api.h
*
* \brief L2CAP subsystem API.
*
* $Date: 2012-03-07 22:32:20 -0800 (Wed, 07 Mar 2012) $
* $Revision: 268 $
*
* Copyright (c) 2009-2016 ARM Limited. All rights reserved.
*
* SPDX-License-Identifier: LicenseRef-PBL
*
* Licensed under the Permissive Binary License, Version 1.0 (the "License"); you may not use
* this file except in compliance with the License. You may obtain a copy of the License at
*
* https://www.mbed.com/licenses/PBL-1.0
*
* See the License for the specific language governing permissions and limitations under the License.
*/
/*************************************************************************************************/
#ifndef L2C_API_H
#define L2C_API_H
#include "hci_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 */
/**************************************************************************************************
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);
/**************************************************************************************************
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 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 L2cDmConnUpdateReq
*
* \brief 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 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 */

View File

@ -0,0 +1,76 @@
/*************************************************************************************************/
/*!
* \file l2c_defs.h
*
* \brief L2CAP constants and definitions from the Bluetooth specification.
*
* $Date: 2011-10-14 21:35:03 -0700 (Fri, 14 Oct 2011) $
* $Revision: 191 $
*
* Copyright (c) 2009-2016 ARM Limited. All rights reserved.
*
* SPDX-License-Identifier: LicenseRef-PBL
*
* Licensed under the Permissive Binary License, Version 1.0 (the "License"); you may not use
* this file except in compliance with the License. You may obtain a copy of the License at
*
* https://www.mbed.com/licenses/PBL-1.0
*
* See the License for the specific language governing permissions and limitations under the License.
*/
/*************************************************************************************************/
#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 */
/*! 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)
/*! 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
/*! 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_CONN_UPDATE_REQ 0x12 /*! Connection parameter update request */
#define L2C_SIG_CONN_UPDATE_RSP 0x13 /*! Connection parameter update response */
/*! 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 */
#ifdef __cplusplus
};
#endif
#endif /* L2C_DEFS_H */

View File

@ -0,0 +1,66 @@
/*************************************************************************************************/
/*!
* \file l2c_handler.h
*
* \brief L2CAP handler interface.
*
* $Date $
* $Revision $
*
* Copyright (c) 2009-2016 ARM Limited. All rights reserved.
*
* SPDX-License-Identifier: LicenseRef-PBL
*
* Licensed under the Permissive Binary License, Version 1.0 (the "License"); you may not use
* this file except in compliance with the License. You may obtain a copy of the License at
*
* https://www.mbed.com/licenses/PBL-1.0
*
* See the License for the specific language governing permissions and limitations under the License.
*/
/*************************************************************************************************/
#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);
#ifdef __cplusplus
};
#endif
#endif /* L2C_HANDLER_H */

View File

@ -0,0 +1,195 @@
/*************************************************************************************************/
/*!
* \file smp_api.h
*
* \brief SMP subsystem API.
*
* $Date: 2011-10-14 21:35:03 -0700 (Fri, 14 Oct 2011) $
* $Revision: 191 $
*
* Copyright (c) 2010-2016 ARM Limited. All rights reserved.
*
* SPDX-License-Identifier: LicenseRef-PBL
*
* Licensed under the Permissive Binary License, Version 1.0 (the "License"); you may not use
* this file except in compliance with the License. You may obtain a copy of the License at
*
* https://www.mbed.com/licenses/PBL-1.0
*
* See the License for the specific language governing permissions and limitations under the License.
*/
/*************************************************************************************************/
#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_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_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;
} 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 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 */

View File

@ -0,0 +1,122 @@
/*************************************************************************************************/
/*!
* \file smp_defs.h
*
* \brief Security manager constants and definitions from the Bluetooth specification.
*
* $Date: 2011-10-14 21:35:03 -0700 (Fri, 14 Oct 2011) $
* $Revision: 191 $
*
* Copyright (c) 2010-2016 ARM Limited. All rights reserved.
*
* SPDX-License-Identifier: LicenseRef-PBL
*
* Licensed under the Permissive Binary License, Version 1.0 (the "License"); you may not use
* this file except in compliance with the License. You may obtain a copy of the License at
*
* https://www.mbed.com/licenses/PBL-1.0
*
* See the License for the specific language governing permissions and limitations under the License.
*/
/*************************************************************************************************/
#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 */
/*! 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_MAX 0x0C /*! 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
/*! 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 */
/*! 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)
/*! Various parameter lengths */
#define SMP_RAND_LEN 16
#define SMP_CONFIRM_LEN 16
#define SMP_KEY_LEN 16
#define SMP_RAND8_LEN 8
#ifdef __cplusplus
};
#endif
#endif /* SMP_DEFS_H */

View File

@ -0,0 +1,67 @@
/*************************************************************************************************/
/*!
* \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-2016 ARM Limited. All rights reserved.
*
* SPDX-License-Identifier: LicenseRef-PBL
*
* Licensed under the Permissive Binary License, Version 1.0 (the "License"); you may not use
* this file except in compliance with the License. You may obtain a copy of the License at
*
* https://www.mbed.com/licenses/PBL-1.0
*
* See the License for the specific language governing permissions and limitations under the License.
*/
/*************************************************************************************************/
#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 */

View File

@ -0,0 +1,109 @@
/*************************************************************************************************/
/*!
* \file bda.h
*
* \brief Bluetooth device address utilities.
*
* $Date: 2012-05-08 10:58:07 -0700 (Tue, 08 May 2012) $
* $Revision: 316 $
*
* Copyright (c) 2009-2016 ARM Limited. All rights reserved.
*
* SPDX-License-Identifier: LicenseRef-PBL
*
* Licensed under the Permissive Binary License, Version 1.0 (the "License"); you may not use
* this file except in compliance with the License. You may obtain a copy of the License at
*
* https://www.mbed.com/licenses/PBL-1.0
*
* See the License for the specific language governing permissions and limitations under the License.
*/
/*************************************************************************************************/
#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, 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(uint8_t *pAddr1, 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 Bda2Str
*
* \brief Convert a BD address to a string.
*
* \param pAddr Pointer to BD address.
*
* \return Pointer to string.
*/
/*************************************************************************************************/
char *Bda2Str(uint8_t *pAddr);
#ifdef __cplusplus
};
#endif
#endif /* BDA_H */

View File

@ -0,0 +1,105 @@
/*************************************************************************************************/
/*!
* \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-2016 ARM Limited. All rights reserved.
*
* SPDX-License-Identifier: LicenseRef-PBL
*
* Licensed under the Permissive Binary License, Version 1.0 (the "License"); you may not use
* this file except in compliance with the License. You may obtain a copy of the License at
*
* https://www.mbed.com/licenses/PBL-1.0
*
* See the License for the specific language governing permissions and limitations under the License.
*/
/*************************************************************************************************/
#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 */

View File

@ -0,0 +1,61 @@
/*************************************************************************************************/
/*!
* \file wsf_types.h
*
* \brief Platform-independent data types.
*
* $Date: 2012-04-28 22:02:14 -0700 (Sat, 28 Apr 2012) $
* $Revision: 306 $
*
* Copyright (c) 2009-2016 ARM Limited. All rights reserved.
*
* SPDX-License-Identifier: LicenseRef-PBL
*
* Licensed under the Permissive Binary License, Version 1.0 (the "License"); you may not use
* this file except in compliance with the License. You may obtain a copy of the License at
*
* https://www.mbed.com/licenses/PBL-1.0
*
* See the License for the specific language governing permissions and limitations under the License.
*/
/*************************************************************************************************/
#ifndef WSF_TYPES_H
#define WSF_TYPES_H
/**************************************************************************************************
Macros
**************************************************************************************************/
#ifndef NULL
#define NULL 0
#endif
#ifndef TRUE
#define TRUE 1
#endif
#ifndef FALSE
#define FALSE 0
#endif
/**************************************************************************************************
Data Types
**************************************************************************************************/
/* Integer data types */
#if ((defined(__STDC_VERSION__) && (__STDC_VERSION__ >= 199901L)) && \
(__ICC8051__ == 0)) || defined(__CC_ARM) || defined(__IAR_SYSTEMS_ICC__)
#include <stdint.h>
#else
typedef signed char int8_t;
typedef unsigned char uint8_t;
typedef signed short int16_t;
typedef unsigned short uint16_t;
typedef signed long int32_t;
typedef unsigned long uint32_t;
#endif
/* Boolean data type */
typedef uint8_t bool_t;
#endif /* WSF_TYPES_H */

View File

@ -0,0 +1,137 @@
/*************************************************************************************************/
/*!
* \file wsf_buf.h
*
* \brief Buffer pool service.
*
* $Date: 2013-05-13 15:20:24 -0700 (Mon, 13 May 2013) $
* $Revision: 612 $
*
* Copyright (c) 2009-2016 ARM Limited. All rights reserved.
*
* SPDX-License-Identifier: LicenseRef-PBL
*
* Licensed under the Permissive Binary License, Version 1.0 (the "License"); you may not use
* this file except in compliance with the License. You may obtain a copy of the License at
*
* https://www.mbed.com/licenses/PBL-1.0
*
* See the License for the specific language governing permissions and limitations under the License.
*/
/*************************************************************************************************/
#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;
/**************************************************************************************************
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 TRUE if initialization was successful, FALSE otherwise.
*/
/*************************************************************************************************/
bool_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);
#ifdef __cplusplus
};
#endif
#endif /* WSF_BUF_H */

View File

@ -0,0 +1,123 @@
/*************************************************************************************************/
/*!
* \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-2016 ARM Limited. All rights reserved.
*
* SPDX-License-Identifier: LicenseRef-PBL
*
* Licensed under the Permissive Binary License, Version 1.0 (the "License"); you may not use
* this file except in compliance with the License. You may obtain a copy of the License at
*
* https://www.mbed.com/licenses/PBL-1.0
*
* See the License for the specific language governing permissions and limitations under the License.
*/
/*************************************************************************************************/
#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 */

View File

@ -0,0 +1,147 @@
/*************************************************************************************************/
/*!
* \file wsf_os.h
*
* \brief Software foundation OS API.
*
* $Date: 2012-10-22 14:09:36 -0700 (Mon, 22 Oct 2012) $
* $Revision: 359 $
*
* Copyright (c) 2009-2016 ARM Limited. All rights reserved.
*
* SPDX-License-Identifier: LicenseRef-PBL
*
* Licensed under the Permissive Binary License, Version 1.0 (the "License"); you may not use
* this file except in compliance with the License. You may obtain a copy of the License at
*
* https://www.mbed.com/licenses/PBL-1.0
*
* See the License for the specific language governing permissions and limitations under the License.
*/
/*************************************************************************************************/
#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 */

View File

@ -0,0 +1,155 @@
/*************************************************************************************************/
/*!
* \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-2016 ARM Limited. All rights reserved.
*
* SPDX-License-Identifier: LicenseRef-PBL
*
* Licensed under the Permissive Binary License, Version 1.0 (the "License"); you may not use
* this file except in compliance with the License. You may obtain a copy of the License at
*
* https://www.mbed.com/licenses/PBL-1.0
*
* See the License for the specific language governing permissions and limitations under the License.
*/
/*************************************************************************************************/
#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 */

View File

@ -0,0 +1,111 @@
/*************************************************************************************************/
/*!
* \file wsf_sec.h
*
* \brief AES and random number security service API.
*
* $Date: 2011-10-14 21:35:03 -0700 (Fri, 14 Oct 2011) $
* $Revision: 191 $
*
* Copyright (c) 2010-2016 ARM Limited. All rights reserved.
*
* SPDX-License-Identifier: LicenseRef-PBL
*
* Licensed under the Permissive Binary License, Version 1.0 (the "License"); you may not use
* this file except in compliance with the License. You may obtain a copy of the License at
*
* https://www.mbed.com/licenses/PBL-1.0
*
* See the License for the specific language governing permissions and limitations under the License.
*/
/*************************************************************************************************/
#ifndef WSF_SEC_H
#define WSF_SEC_H
#ifdef __cplusplus
extern "C" {
#endif
/**************************************************************************************************
Data Types
**************************************************************************************************/
/*! AES callback parameters structure */
typedef struct
{
wsfMsgHdr_t hdr; /*! header */
uint8_t *pCiphertext; /*! pointer to 16 bytes of ciphertext data */
} wsfSecAes_t;
/*! AES callback function type */
typedef void (*wsfSecAesCback_t)(wsfSecAes_t *pMsg);
/**************************************************************************************************
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 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 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 */

View File

@ -0,0 +1,161 @@
/*************************************************************************************************/
/*!
* \file wsf_timer.h
*
* \brief Timer service.
*
* $Date: 2013-07-19 17:17:05 -0700 (Fri, 19 Jul 2013) $
* $Revision: 843 $
*
* Copyright (c) 2009-2016 ARM Limited. All rights reserved.
*
* SPDX-License-Identifier: LicenseRef-PBL
*
* Licensed under the Permissive Binary License, Version 1.0 (the "License"); you may not use
* this file except in compliance with the License. You may obtain a copy of the License at
*
* https://www.mbed.com/licenses/PBL-1.0
*
* See the License for the specific language governing permissions and limitations under the License.
*/
/*************************************************************************************************/
#ifndef WSF_TIMER_H
#define WSF_TIMER_H
#include "wsf_os.h"
#ifdef __cplusplus
extern "C" {
#endif
/**************************************************************************************************
Macros
**************************************************************************************************/
/**************************************************************************************************
Data Types
**************************************************************************************************/
/*! Timer ticks data type */
typedef uint16_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.
*
* \param msPerTick Sets the number of milliseconds per timer tick.
*
* \return None.
*/
/*************************************************************************************************/
void WsfTimerInit(uint8_t msPerTick);
/*************************************************************************************************/
/*!
* \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 */

View File

@ -47,18 +47,18 @@ __Vectors DCD __initial_sp ; Top of Stack
DCD Reset_Handler ; Reset Handler
DCD NMI_Handler ; NMI Handler
DCD HardFault_Handler ; Hard Fault Handler
DCD DefaultIRQ_Handler ; MPU Fault Handler
DCD DefaultIRQ_Handler ; Bus Fault Handler
DCD DefaultIRQ_Handler ; Usage 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 DefaultIRQ_Handler ; SVCall Handler
DCD SVC_Handler ; SVCall Handler
DCD DebugMon_Handler ; Debug Monitor Handler
DCD 0 ; Reserved
DCD DefaultIRQ_Handler ; PendSV Handler
DCD SysTick_IRQHandler ; SysTick Handler
DCD PendSV_Handler ; PendSV Handler
DCD SysTick_Handler ; SysTick Handler
; Maxim 32600 Externals interrupts
DCD UART0_IRQHandler ; 16: 1 UART0
@ -136,9 +136,24 @@ HardFault_Handler PROC
B HardFault_Handler
ENDP
DefaultIRQ_Handler PROC
EXPORT DefaultIRQ_Handler [WEAK]
B DefaultIRQ_Handler
MemManage_Handler PROC
EXPORT MemManage_Handler [WEAK]
B MemManage_Handler
ENDP
BusFault_Handler PROC
EXPORT BusFault_Handler [WEAK]
B BusFault_Handler
ENDP
UsageFault_Handler PROC
EXPORT UsageFault_Handler [WEAK]
B UsageFault_Handler
ENDP
SVC_Handler PROC
EXPORT SVC_Handler [WEAK]
B SVC_Handler
ENDP
DebugMon_Handler PROC
@ -146,9 +161,14 @@ DebugMon_Handler PROC
B DebugMon_Handler
ENDP
SysTick_IRQHandler PROC
EXPORT SysTick_IRQHandler [WEAK]
B SysTick_IRQHandler
PendSV_Handler PROC
EXPORT PendSV_Handler [WEAK]
B PendSV_Handler
ENDP
SysTick_Handler PROC
EXPORT SysTick_Handler [WEAK]
B SysTick_Handler
ENDP
Default_Handler PROC

View File

@ -51,7 +51,7 @@
#ifdef __STACK_SIZE
.equ Stack_Size, __STACK_SIZE
#else
.equ Stack_Size, 0x00001000
.equ Stack_Size, 0x00000800
#endif
.globl __StackTop
.globl __StackLimit
@ -66,7 +66,7 @@ __StackTop:
#ifdef __HEAP_SIZE
.equ Heap_Size, __HEAP_SIZE
#else
.equ Heap_Size, 0x00000C00
.equ Heap_Size, 0x00003000
#endif
.globl __HeapBase
.globl __HeapLimit

View File

@ -15,8 +15,8 @@ define region ROM_region = mem:[from __region_ROM_start__ to __region_ROM
define region RAM_region = mem:[from __region_RAM_start__ to __region_RAM_end__];
/* Stack and Heap */
define symbol __size_cstack__ = 0x800;
define symbol __size_heap__ = 0x800;
define symbol __size_cstack__ = 0x0800;
define symbol __size_heap__ = 0x3000;
define block CSTACK with alignment = 8, size = __size_cstack__ { };
define block HEAP with alignment = 8, size = __size_heap__ { };

View File

@ -47,18 +47,18 @@ __vector_table DCD sfe(CSTACK) /* Top of Stack */
DCD Reset_Handler /* Reset Handler */
DCD NMI_Handler /* NMI Handler */
DCD HardFault_Handler /* Hard Fault Handler */
DCD DefaultIRQ_Handler /* MPU Fault Handler */
DCD DefaultIRQ_Handler /* Bus Fault Handler */
DCD DefaultIRQ_Handler /* Usage 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 DefaultIRQ_Handler /* SVCall Handler */
DCD SVC_Handler /* SVCall Handler */
DCD DebugMon_Handler /* Debug Monitor Handler */
DCD 0 /* Reserved */
DCD DefaultIRQ_Handler /* PendSV Handler */
DCD SysTick_IRQHandler /* SysTick Handler */
DCD PendSV_Handler /* PendSV Handler */
DCD SysTick_Handler /* SysTick Handler */
/* Maxim 32600 Externals interrupts */
DCD UART0_IRQHandler /* 16: 1 UART0 */
@ -130,20 +130,40 @@ NMI_Handler
HardFault_Handler
B HardFault_Handler
PUBWEAK DefaultIRQ_Handler
PUBWEAK MemManage_Handler
SECTION .text:CODE:REORDER:NOROOT(1)
DefaultIRQ_Handler
B DefaultIRQ_Handler
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 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 SysTick_IRQHandler
PUBWEAK PendSV_Handler
SECTION .text:CODE:REORDER:NOROOT(1)
SysTick_IRQHandler
B SysTick_IRQHandler
PendSV_Handler
B PendSV_Handler
PUBWEAK SysTick_Handler
SECTION .text:CODE:REORDER:NOROOT(1)
SysTick_Handler
B SysTick_Handler
PUBWEAK UART0_IRQHandler
SECTION .text:CODE:REORDER:NOROOT(1)

View File

@ -43,71 +43,71 @@ __initial_sp EQU 0x20008000 ; Top of RAM
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 DefaultIRQ_Handler ; MPU Fault Handler
DCD DefaultIRQ_Handler ; Bus Fault Handler
DCD DefaultIRQ_Handler ; Usage Fault Handler
DCD 0 ; Reserved
DCD 0 ; Reserved
DCD 0 ; Reserved
DCD 0 ; Reserved
DCD DefaultIRQ_Handler ; SVCall Handler
DCD DebugMon_Handler ; Debug Monitor Handler
DCD 0 ; Reserved
DCD DefaultIRQ_Handler ; PendSV Handler
DCD SysTick_IRQHandler ; SysTick Handler
__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
; Maxim 32610 Externals interrupts
DCD UART0_IRQHandler ; 16: 1 UART0
DCD UART1_IRQHandler ; 17: 2 UART1
DCD I2CM0_IRQHandler ; 18: 3 I2C Master 0
DCD I2CS_IRQHandler ; 19: 4 I2C Slave
DCD USB_IRQHandler ; 20: 5 USB
DCD PMU_IRQHandler ; 21: 6 DMA
DCD AFE_IRQHandler ; 22: 7 AFE
DCD MAA_IRQHandler ; 23: 8 MAA
DCD AES_IRQHandler ; 24: 9 AES
DCD SPI0_IRQHandler ; 25:10 SPI0
DCD SPI1_IRQHandler ; 26:11 SPI1
DCD SPI2_IRQHandler ; 27:12 SPI2
DCD TMR0_IRQHandler ; 28:13 Timer32-0
DCD TMR1_IRQHandler ; 29:14 Timer32-1
DCD TMR2_IRQHandler ; 30:15 Timer32-1
DCD TMR3_IRQHandler ; 31:16 Timer32-2
DCD RSVD0_IRQHandler ; 32:17 RSVD
DCD RSVD1_IRQHandler ; 33:18 RSVD
DCD DAC0_IRQHandler ; 34:19 DAC0 (12-bit DAC)
DCD DAC1_IRQHandler ; 35:20 DAC1 (12-bit DAC)
DCD DAC2_IRQHandler ; 36:21 DAC2 (8-bit DAC)
DCD DAC3_IRQHandler ; 37:22 DAC3 (8-bit DAC)
DCD ADC_IRQHandler ; 38:23 ADC
DCD FLC_IRQHandler ; 39:24 Flash Controller
DCD PWRMAN_IRQHandler ; 40:25 PWRMAN
DCD CLKMAN_IRQHandler ; 41:26 CLKMAN
DCD RTC0_IRQHandler ; 42:27 RTC INT0
DCD RTC1_IRQHandler ; 43:28 RTC INT1
DCD RTC2_IRQHandler ; 44:29 RTC INT2
DCD RTC3_IRQHandler ; 45:30 RTC INT3
DCD WDT0_IRQHandler ; 46:31 WATCHDOG0
DCD WDT0_P_IRQHandler ; 47:32 WATCHDOG0 PRE-WINDOW
DCD WDT1_IRQHandler ; 48:33 WATCHDOG1
DCD WDT1_P_IRQHandler ; 49:34 WATCHDOG1 PRE-WINDOW
DCD GPIO_P0_IRQHandler ; 50:35 GPIO Port 0
DCD GPIO_P1_IRQHandler ; 51:36 GPIO Port 1
DCD GPIO_P2_IRQHandler ; 52:37 GPIO Port 2
DCD GPIO_P3_IRQHandler ; 53:38 GPIO Port 3
DCD GPIO_P4_IRQHandler ; 54:39 GPIO Port 4
DCD GPIO_P5_IRQHandler ; 55:40 GPIO Port 5
DCD GPIO_P6_IRQHandler ; 56:41 GPIO Port 6
DCD GPIO_P7_IRQHandler ; 57:42 GPIO Port 7
DCD TMR16_0_IRQHandler ; 58:43 Timer16-s0
DCD TMR16_1_IRQHandler ; 59:44 Timer16-s1
DCD TMR16_2_IRQHandler ; 60:45 Timer16-s2
DCD TMR16_3_IRQHandler ; 61:46 Timer16-s3
DCD I2CM1_IRQHandler ; 62:47 I2C Master 1
; Maxim 32610 Externals interrupts
DCD UART0_IRQHandler ; 16: 1 UART0
DCD UART1_IRQHandler ; 17: 2 UART1
DCD I2CM0_IRQHandler ; 18: 3 I2C Master 0
DCD I2CS_IRQHandler ; 19: 4 I2C Slave
DCD USB_IRQHandler ; 20: 5 USB
DCD PMU_IRQHandler ; 21: 6 DMA
DCD AFE_IRQHandler ; 22: 7 AFE
DCD MAA_IRQHandler ; 23: 8 MAA
DCD AES_IRQHandler ; 24: 9 AES
DCD SPI0_IRQHandler ; 25:10 SPI0
DCD SPI1_IRQHandler ; 26:11 SPI1
DCD SPI2_IRQHandler ; 27:12 SPI2
DCD TMR0_IRQHandler ; 28:13 Timer32-0
DCD TMR1_IRQHandler ; 29:14 Timer32-1
DCD TMR2_IRQHandler ; 30:15 Timer32-1
DCD TMR3_IRQHandler ; 31:16 Timer32-2
DCD RSVD0_IRQHandler ; 32:17 RSVD
DCD RSVD1_IRQHandler ; 33:18 RSVD
DCD DAC0_IRQHandler ; 34:19 DAC0 (12-bit DAC)
DCD DAC1_IRQHandler ; 35:20 DAC1 (12-bit DAC)
DCD DAC2_IRQHandler ; 36:21 DAC2 (8-bit DAC)
DCD DAC3_IRQHandler ; 37:22 DAC3 (8-bit DAC)
DCD ADC_IRQHandler ; 38:23 ADC
DCD FLC_IRQHandler ; 39:24 Flash Controller
DCD PWRMAN_IRQHandler ; 40:25 PWRMAN
DCD CLKMAN_IRQHandler ; 41:26 CLKMAN
DCD RTC0_IRQHandler ; 42:27 RTC INT0
DCD RTC1_IRQHandler ; 43:28 RTC INT1
DCD RTC2_IRQHandler ; 44:29 RTC INT2
DCD RTC3_IRQHandler ; 45:30 RTC INT3
DCD WDT0_IRQHandler ; 46:31 WATCHDOG0
DCD WDT0_P_IRQHandler ; 47:32 WATCHDOG0 PRE-WINDOW
DCD WDT1_IRQHandler ; 48:33 WATCHDOG1
DCD WDT1_P_IRQHandler ; 49:34 WATCHDOG1 PRE-WINDOW
DCD GPIO_P0_IRQHandler ; 50:35 GPIO Port 0
DCD GPIO_P1_IRQHandler ; 51:36 GPIO Port 1
DCD GPIO_P2_IRQHandler ; 52:37 GPIO Port 2
DCD GPIO_P3_IRQHandler ; 53:38 GPIO Port 3
DCD GPIO_P4_IRQHandler ; 54:39 GPIO Port 4
DCD GPIO_P5_IRQHandler ; 55:40 GPIO Port 5
DCD GPIO_P6_IRQHandler ; 56:41 GPIO Port 6
DCD GPIO_P7_IRQHandler ; 57:42 GPIO Port 7
DCD TMR16_0_IRQHandler ; 58:43 Timer16-s0
DCD TMR16_1_IRQHandler ; 59:44 Timer16-s1
DCD TMR16_2_IRQHandler ; 60:45 Timer16-s2
DCD TMR16_3_IRQHandler ; 61:46 Timer16-s3
DCD I2CM1_IRQHandler ; 62:47 I2C Master 1
__Vectors_End
__Vectors_Size EQU __Vectors_End - __Vectors
@ -136,9 +136,24 @@ HardFault_Handler PROC
B HardFault_Handler
ENDP
DefaultIRQ_Handler PROC
EXPORT DefaultIRQ_Handler [WEAK]
B DefaultIRQ_Handler
MemManage_Handler PROC
EXPORT MemManage_Handler [WEAK]
B MemManage_Handler
ENDP
BusFault_Handler PROC
EXPORT BusFault_Handler [WEAK]
B BusFault_Handler
ENDP
UsageFault_Handler PROC
EXPORT UsageFault_Handler [WEAK]
B UsageFault_Handler
ENDP
SVC_Handler PROC
EXPORT SVC_Handler [WEAK]
B SVC_Handler
ENDP
DebugMon_Handler PROC
@ -146,9 +161,14 @@ DebugMon_Handler PROC
B DebugMon_Handler
ENDP
SysTick_IRQHandler PROC
EXPORT SysTick_IRQHandler [WEAK]
B SysTick_IRQHandler
PendSV_Handler PROC
EXPORT PendSV_Handler [WEAK]
B PendSV_Handler
ENDP
SysTick_Handler PROC
EXPORT SysTick_Handler [WEAK]
B SysTick_Handler
ENDP
Default_Handler PROC

View File

@ -51,7 +51,7 @@
#ifdef __STACK_SIZE
.equ Stack_Size, __STACK_SIZE
#else
.equ Stack_Size, 0x00001000
.equ Stack_Size, 0x00000800
#endif
.globl __StackTop
.globl __StackLimit
@ -66,7 +66,7 @@ __StackTop:
#ifdef __HEAP_SIZE
.equ Heap_Size, __HEAP_SIZE
#else
.equ Heap_Size, 0x00000C00
.equ Heap_Size, 0x00003000
#endif
.globl __HeapBase
.globl __HeapLimit

View File

@ -15,8 +15,8 @@ define region ROM_region = mem:[from __region_ROM_start__ to __region_ROM
define region RAM_region = mem:[from __region_RAM_start__ to __region_RAM_end__];
/* Stack and Heap */
define symbol __size_cstack__ = 0x800;
define symbol __size_heap__ = 0x800;
define symbol __size_cstack__ = 0x0800;
define symbol __size_heap__ = 0x3000;
define block CSTACK with alignment = 8, size = __size_cstack__ { };
define block HEAP with alignment = 8, size = __size_heap__ { };

View File

@ -47,18 +47,18 @@ __vector_table DCD sfe(CSTACK) /* Top of Stack */
DCD Reset_Handler /* Reset Handler */
DCD NMI_Handler /* NMI Handler */
DCD HardFault_Handler /* Hard Fault Handler */
DCD DefaultIRQ_Handler /* MPU Fault Handler */
DCD DefaultIRQ_Handler /* Bus Fault Handler */
DCD DefaultIRQ_Handler /* Usage 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 DefaultIRQ_Handler /* SVCall Handler */
DCD SVC_Handler /* SVCall Handler */
DCD DebugMon_Handler /* Debug Monitor Handler */
DCD 0 /* Reserved */
DCD DefaultIRQ_Handler /* PendSV Handler */
DCD SysTick_IRQHandler /* SysTick Handler */
DCD PendSV_Handler /* PendSV Handler */
DCD SysTick_Handler /* SysTick Handler */
/* Maxim 32610 Externals interrupts */
DCD UART0_IRQHandler /* 16: 1 UART0 */
@ -130,20 +130,40 @@ NMI_Handler
HardFault_Handler
B HardFault_Handler
PUBWEAK DefaultIRQ_Handler
PUBWEAK MemManage_Handler
SECTION .text:CODE:REORDER:NOROOT(1)
DefaultIRQ_Handler
B DefaultIRQ_Handler
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 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 SysTick_IRQHandler
PUBWEAK PendSV_Handler
SECTION .text:CODE:REORDER:NOROOT(1)
SysTick_IRQHandler
B SysTick_IRQHandler
PendSV_Handler
B PendSV_Handler
PUBWEAK SysTick_Handler
SECTION .text:CODE:REORDER:NOROOT(1)
SysTick_Handler
B SysTick_Handler
PUBWEAK UART0_IRQHandler
SECTION .text:CODE:REORDER:NOROOT(1)

View File

@ -68,14 +68,14 @@ const PinMap PinMap_I2C_SCL[] = {
/*
*/
const PinMap PinMap_UART_TX[] = {
{ P0_1, UART_0, (int)&((pin_function_t){&MXC_IOMAN->uart0_req, &MXC_IOMAN->uart0_ack, ((uint32_t)MXC_E_IOMAN_MAPPING_A | MXC_F_IOMAN_UART_REQ_IO_REQ), (MXC_F_IOMAN_UART_ACK_IO_MAP | MXC_F_IOMAN_UART_ACK_IO_ACK)}) },
{ P2_1, UART_1, (int)&((pin_function_t){&MXC_IOMAN->uart1_req, &MXC_IOMAN->uart1_ack, ((uint32_t)MXC_E_IOMAN_MAPPING_A | MXC_F_IOMAN_UART_REQ_IO_REQ), (MXC_F_IOMAN_UART_ACK_IO_MAP | MXC_F_IOMAN_UART_ACK_IO_ACK)}) },
{ P3_1, UART_2, (int)&((pin_function_t){&MXC_IOMAN->uart2_req, &MXC_IOMAN->uart2_ack, ((uint32_t)MXC_E_IOMAN_MAPPING_A | MXC_F_IOMAN_UART_REQ_IO_REQ), (MXC_F_IOMAN_UART_ACK_IO_MAP | MXC_F_IOMAN_UART_ACK_IO_ACK)}) },
{ P5_4, UART_3, (int)&((pin_function_t){&MXC_IOMAN->uart3_req, &MXC_IOMAN->uart3_ack, ((uint32_t)MXC_E_IOMAN_MAPPING_A | MXC_F_IOMAN_UART_REQ_IO_REQ), (MXC_F_IOMAN_UART_ACK_IO_MAP | MXC_F_IOMAN_UART_ACK_IO_ACK)}) },
{ P0_0, UART_0, (int)&((pin_function_t){&MXC_IOMAN->uart0_req, &MXC_IOMAN->uart0_ack, ((uint32_t)MXC_E_IOMAN_MAPPING_B | MXC_F_IOMAN_UART_REQ_IO_REQ), (MXC_F_IOMAN_UART_ACK_IO_MAP | MXC_F_IOMAN_UART_ACK_IO_ACK)}) },
{ P2_0, UART_1, (int)&((pin_function_t){&MXC_IOMAN->uart1_req, &MXC_IOMAN->uart1_ack, ((uint32_t)MXC_E_IOMAN_MAPPING_B | MXC_F_IOMAN_UART_REQ_IO_REQ), (MXC_F_IOMAN_UART_ACK_IO_MAP | MXC_F_IOMAN_UART_ACK_IO_ACK)}) },
{ P3_0, UART_2, (int)&((pin_function_t){&MXC_IOMAN->uart2_req, &MXC_IOMAN->uart2_ack, ((uint32_t)MXC_E_IOMAN_MAPPING_B | MXC_F_IOMAN_UART_REQ_IO_REQ), (MXC_F_IOMAN_UART_ACK_IO_MAP | MXC_F_IOMAN_UART_ACK_IO_ACK)}) },
{ P5_3, UART_3, (int)&((pin_function_t){&MXC_IOMAN->uart3_req, &MXC_IOMAN->uart3_ack, ((uint32_t)MXC_E_IOMAN_MAPPING_B | MXC_F_IOMAN_UART_REQ_IO_REQ), (MXC_F_IOMAN_UART_ACK_IO_MAP | MXC_F_IOMAN_UART_ACK_IO_ACK)}) },
{ P0_1, UART_0, (int)&((pin_function_t){&MXC_IOMAN->uart0_req, &MXC_IOMAN->uart0_ack, ((uint32_t)MXC_E_IOMAN_MAPPING_A | MXC_F_IOMAN_UART_REQ_IO_REQ), (MXC_F_IOMAN_UART_ACK_IO_MAP | MXC_F_IOMAN_UART_ACK_IO_ACK)}) },
{ P2_1, UART_1, (int)&((pin_function_t){&MXC_IOMAN->uart1_req, &MXC_IOMAN->uart1_ack, ((uint32_t)MXC_E_IOMAN_MAPPING_A | MXC_F_IOMAN_UART_REQ_IO_REQ), (MXC_F_IOMAN_UART_ACK_IO_MAP | MXC_F_IOMAN_UART_ACK_IO_ACK)}) },
{ P3_1, UART_2, (int)&((pin_function_t){&MXC_IOMAN->uart2_req, &MXC_IOMAN->uart2_ack, ((uint32_t)MXC_E_IOMAN_MAPPING_A | MXC_F_IOMAN_UART_REQ_IO_REQ), (MXC_F_IOMAN_UART_ACK_IO_MAP | MXC_F_IOMAN_UART_ACK_IO_ACK)}) },
{ P5_4, UART_3, (int)&((pin_function_t){&MXC_IOMAN->uart3_req, &MXC_IOMAN->uart3_ack, ((uint32_t)MXC_E_IOMAN_MAPPING_A | MXC_F_IOMAN_UART_REQ_IO_REQ), (MXC_F_IOMAN_UART_ACK_IO_MAP | MXC_F_IOMAN_UART_ACK_IO_ACK)}) },
{ P0_0, UART_0, (int)&((pin_function_t){&MXC_IOMAN->uart0_req, &MXC_IOMAN->uart0_ack, ((uint32_t)MXC_E_IOMAN_MAPPING_B | MXC_F_IOMAN_UART_REQ_IO_REQ), (MXC_F_IOMAN_UART_ACK_IO_MAP | MXC_F_IOMAN_UART_ACK_IO_ACK)}) },
{ P2_0, UART_1, (int)&((pin_function_t){&MXC_IOMAN->uart1_req, &MXC_IOMAN->uart1_ack, ((uint32_t)MXC_E_IOMAN_MAPPING_B | MXC_F_IOMAN_UART_REQ_IO_REQ), (MXC_F_IOMAN_UART_ACK_IO_MAP | MXC_F_IOMAN_UART_ACK_IO_ACK)}) },
{ P3_0, UART_2, (int)&((pin_function_t){&MXC_IOMAN->uart2_req, &MXC_IOMAN->uart2_ack, ((uint32_t)MXC_E_IOMAN_MAPPING_B | MXC_F_IOMAN_UART_REQ_IO_REQ), (MXC_F_IOMAN_UART_ACK_IO_MAP | MXC_F_IOMAN_UART_ACK_IO_ACK)}) },
{ P5_3, UART_3, (int)&((pin_function_t){&MXC_IOMAN->uart3_req, &MXC_IOMAN->uart3_ack, ((uint32_t)MXC_E_IOMAN_MAPPING_B | MXC_F_IOMAN_UART_REQ_IO_REQ), (MXC_F_IOMAN_UART_ACK_IO_MAP | MXC_F_IOMAN_UART_ACK_IO_ACK)}) },
{ NC, NC, 0 }
};
@ -157,30 +157,30 @@ const PinMap PinMap_SPI_QUAD[] = {
/************PWM***************/
const PinMap PinMap_PWM[] = {
{ P0_0, PWM_0, 1 }, { P2_0, PWM_0, 1 }, { P4_0, PWM_0, 1 }, {P6_0, PWM_0, 1},
{ P0_1, PWM_1, 1 }, { P2_1, PWM_1, 1 }, { P4_1, PWM_1, 1 },
{ P0_2, PWM_2, 1 }, { P2_2, PWM_2, 1 }, { P4_2, PWM_2, 1 },
{ P0_3, PWM_3, 1 }, { P2_3, PWM_3, 1 }, { P4_3, PWM_3, 1 },
{ P0_4, PWM_4, 1 }, { P2_4, PWM_4, 1 }, { P4_4, PWM_4, 1 },
{ P0_5, PWM_5, 1 }, { P2_5, PWM_5, 1 }, { P4_5, PWM_5, 1 },
{ P0_6, PWM_6, 1 }, { P2_6, PWM_6, 1 }, { P4_6, PWM_6, 1 },
{ P0_7, PWM_7, 1 }, { P2_7, PWM_7, 1 }, { P4_7, PWM_7, 1 },
{ P1_0, PWM_8, 1 }, { P3_0, PWM_8, 1 }, { P5_0, PWM_8, 1 },
{ P1_1, PWM_9, 1 }, { P3_1, PWM_9, 1 }, { P5_1, PWM_9, 1 },
{ P1_2, PWM_10, 1 }, { P3_2, PWM_10, 1 }, { P5_2, PWM_10, 1 },
{ P1_3, PWM_11, 1 }, { P3_3, PWM_11, 1 }, { P5_3, PWM_11, 1 },
{ P1_4, PWM_12, 1 }, { P3_4, PWM_12, 1 }, { P5_4, PWM_12, 1 },
{ P1_5, PWM_13, 1 }, { P3_5, PWM_13, 1 }, { P5_5, PWM_13, 1 },
{ P1_6, PWM_14, 1 }, { P3_6, PWM_14, 1 }, { P5_6, PWM_14, 1 },
{ P1_7, PWM_15, 1 }, { P3_7, PWM_15, 1 }, { P5_7, PWM_15, 1 },
{ NC, NC, 0 }
{ P0_0, PWM_0, 1 }, { P2_0, PWM_0, 1 }, { P4_0, PWM_0, 1 }, {P6_0, PWM_0, 1},
{ P0_1, PWM_1, 1 }, { P2_1, PWM_1, 1 }, { P4_1, PWM_1, 1 },
{ P0_2, PWM_2, 1 }, { P2_2, PWM_2, 1 }, { P4_2, PWM_2, 1 },
{ P0_3, PWM_3, 1 }, { P2_3, PWM_3, 1 }, { P4_3, PWM_3, 1 },
{ P0_4, PWM_4, 1 }, { P2_4, PWM_4, 1 }, { P4_4, PWM_4, 1 },
{ P0_5, PWM_5, 1 }, { P2_5, PWM_5, 1 }, { P4_5, PWM_5, 1 },
{ P0_6, PWM_6, 1 }, { P2_6, PWM_6, 1 }, { P4_6, PWM_6, 1 },
{ P0_7, PWM_7, 1 }, { P2_7, PWM_7, 1 }, { P4_7, PWM_7, 1 },
{ P1_0, PWM_8, 1 }, { P3_0, PWM_8, 1 }, { P5_0, PWM_8, 1 },
{ P1_1, PWM_9, 1 }, { P3_1, PWM_9, 1 }, { P5_1, PWM_9, 1 },
{ P1_2, PWM_10, 1 }, { P3_2, PWM_10, 1 }, { P5_2, PWM_10, 1 },
{ P1_3, PWM_11, 1 }, { P3_3, PWM_11, 1 }, { P5_3, PWM_11, 1 },
{ P1_4, PWM_12, 1 }, { P3_4, PWM_12, 1 }, { P5_4, PWM_12, 1 },
{ P1_5, PWM_13, 1 }, { P3_5, PWM_13, 1 }, { P5_5, PWM_13, 1 },
{ P1_6, PWM_14, 1 }, { P3_6, PWM_14, 1 }, { P5_6, PWM_14, 1 },
{ P1_7, PWM_15, 1 }, { P3_7, PWM_15, 1 }, { P5_7, PWM_15, 1 },
{ NC, NC, 0 }
};
/************ADC***************/
const PinMap PinMap_ADC[] = {
{ AIN_0, ADC, 0 },
{ AIN_1, ADC, 0 },
{ AIN_2, ADC, 0 },
{ AIN_3, ADC, 0 },
{ NC, NC, 0 }
{ AIN_0, ADC, 0 },
{ AIN_1, ADC, 0 },
{ AIN_2, ADC, 0 },
{ AIN_3, ADC, 0 },
{ NC, NC, 0 }
};

View File

@ -30,7 +30,7 @@
* ownership rights.
*******************************************************************************
*/
#ifndef MBED_PORTNAMES_H
#define MBED_PORTNAMES_H

View File

@ -116,7 +116,7 @@ typedef enum {
AIN_3 = (0xA << PORT_SHIFT) | 3,
// LEDs
LED_RED = P2_0,
LED_RED = P2_0,
LED1 = LED_RED,
LED2 = NOT_CONNECTED,
LED3 = NOT_CONNECTED,

View File

@ -49,7 +49,7 @@
// Only allow initialization once
static int initialized = 0;
//******************************************************************************
void analogin_init(analogin_t *obj, PinName pin)
{
@ -86,7 +86,7 @@ void analogin_init(analogin_t *obj, PinName pin)
// Enable ADC power bypass the buffer
obj->adc->ctrl |= (MXC_F_ADC_CTRL_ADC_PU | MXC_F_ADC_CTRL_ADC_REFBUF_PU |
MXC_F_ADC_CTRL_ADC_CHGPUMP_PU | MXC_F_ADC_CTRL_BUF_BYPASS);
MXC_F_ADC_CTRL_ADC_CHGPUMP_PU | MXC_F_ADC_CTRL_BUF_BYPASS);
// Wait for ADC ready
while (!(obj->adc->intr & MXC_F_ADC_INTR_ADC_REF_READY_IF));

View File

@ -32,7 +32,7 @@
* ownership rights.
*******************************************************************************
*/
#ifndef MBED_DEVICE_H
#define MBED_DEVICE_H
#include "objects.h"

View File

@ -14,7 +14,7 @@ LR_IROM1 0x00000000 0x200000 { ; load region size_region
}
; [RAM] Vector table dynamic copy: 65 vectors * 4 bytes = 260 (0x104) + 4
; for 8 byte alignment
; for 8 byte alignment
RW_IRAM1 (0x20000000+0x108) (0x40000-0x108) { ; RW data
.ANY (+RW +ZI)
}

View File

@ -47,18 +47,18 @@ __Vectors DCD __initial_sp ; Top of Stack
DCD Reset_Handler ; Reset Handler
DCD NMI_Handler ; NMI Handler
DCD HardFault_Handler ; Hard Fault Handler
DCD DefaultIRQ_Handler ; MPU Fault Handler
DCD DefaultIRQ_Handler ; Bus Fault Handler
DCD DefaultIRQ_Handler ; Usage 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 DefaultIRQ_Handler ; SVCall Handler
DCD SVC_Handler ; SVCall Handler
DCD DebugMon_Handler ; Debug Monitor Handler
DCD 0 ; Reserved
DCD DefaultIRQ_Handler ; PendSV Handler
DCD SysTick_IRQHandler ; SysTick Handler
DCD PendSV_Handler ; PendSV Handler
DCD SysTick_Handler ; SysTick Handler
; Maxim 32620 Externals interrupts
DCD CLKMAN_IRQHandler /* 16:01 CLKMAN */
@ -139,9 +139,24 @@ HardFault_Handler PROC
B HardFault_Handler
ENDP
DefaultIRQ_Handler PROC
EXPORT DefaultIRQ_Handler [WEAK]
B DefaultIRQ_Handler
MemManage_Handler PROC
EXPORT MemManage_Handler [WEAK]
B MemManage_Handler
ENDP
BusFault_Handler PROC
EXPORT BusFault_Handler [WEAK]
B BusFault_Handler
ENDP
UsageFault_Handler PROC
EXPORT UsageFault_Handler [WEAK]
B UsageFault_Handler
ENDP
SVC_Handler PROC
EXPORT SVC_Handler [WEAK]
B SVC_Handler
ENDP
DebugMon_Handler PROC
@ -149,9 +164,14 @@ DebugMon_Handler PROC
B DebugMon_Handler
ENDP
SysTick_IRQHandler PROC
EXPORT SysTick_IRQHandler [WEAK]
B SysTick_IRQHandler
PendSV_Handler PROC
EXPORT PendSV_Handler [WEAK]
B PendSV_Handler
ENDP
SysTick_Handler PROC
EXPORT SysTick_Handler [WEAK]
B SysTick_Handler
ENDP
Default_Handler PROC

View File

@ -36,11 +36,12 @@
#ifdef __cplusplus
extern "C" {
#endif
#endif
extern char Image$$RW_IRAM1$$ZI$$Limit[];
extern __value_in_regs struct __initial_stackheap __user_setup_stackheap(uint32_t R0, uint32_t R1, uint32_t R2, uint32_t R3) {
extern __value_in_regs struct __initial_stackheap __user_setup_stackheap(uint32_t R0, uint32_t R1, uint32_t R2, uint32_t R3)
{
uint32_t zi_limit = (uint32_t)Image$$RW_IRAM1$$ZI$$Limit;
uint32_t sp_limit = __current_sp();
@ -54,4 +55,4 @@ extern __value_in_regs struct __initial_stackheap __user_setup_stackheap(uint32_
#ifdef __cplusplus
}
#endif
#endif

View File

@ -66,7 +66,7 @@ __StackTop:
#ifdef __HEAP_SIZE
.equ Heap_Size, __HEAP_SIZE
#else
.equ Heap_Size, 0x00000C00
.equ Heap_Size, 0x00004000
#endif
.globl __HeapBase
.globl __HeapLimit

View File

@ -15,8 +15,8 @@ define region ROM_region = mem:[from __region_ROM_start__ to __region_ROM
define region RAM_region = mem:[from __region_RAM_start__ to __region_RAM_end__];
/* Stack and Heap */
define symbol __size_cstack__ = 0x800;
define symbol __size_heap__ = 0x800;
define symbol __size_cstack__ = 0x1000;
define symbol __size_heap__ = 0x4000;
define block CSTACK with alignment = 8, size = __size_cstack__ { };
define block HEAP with alignment = 8, size = __size_heap__ { };

View File

@ -47,18 +47,18 @@ __vector_table DCD sfe(CSTACK) /* Top of Stack */
DCD Reset_Handler /* Reset Handler */
DCD NMI_Handler /* NMI Handler */
DCD HardFault_Handler /* Hard Fault Handler */
DCD DefaultIRQ_Handler /* MPU Fault Handler */
DCD DefaultIRQ_Handler /* Bus Fault Handler */
DCD DefaultIRQ_Handler /* Usage 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 DefaultIRQ_Handler /* SVCall Handler */
DCD SVC_Handler /* SVCall Handler */
DCD DebugMon_Handler /* Debug Monitor Handler */
DCD 0 /* Reserved */
DCD DefaultIRQ_Handler /* PendSV Handler */
DCD SysTick_IRQHandler /* SysTick Handler */
DCD PendSV_Handler /* PendSV Handler */
DCD SysTick_Handler /* SysTick Handler */
/* Maxim 32620 NVIC Index */
DCD CLKMAN_IRQHandler /* 16:01 CLKMAN */
@ -137,20 +137,40 @@ NMI_Handler
HardFault_Handler
B HardFault_Handler
PUBWEAK DefaultIRQ_Handler
PUBWEAK MemManage_Handler
SECTION .text:CODE:REORDER:NOROOT(1)
DefaultIRQ_Handler
B DefaultIRQ_Handler
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 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 SysTick_IRQHandler
PUBWEAK PendSV_Handler
SECTION .text:CODE:REORDER:NOROOT(1)
SysTick_IRQHandler
B SysTick_IRQHandler
PendSV_Handler
B PendSV_Handler
PUBWEAK SysTick_Handler
SECTION .text:CODE:REORDER:NOROOT(1)
SysTick_Handler
B SysTick_Handler
PUBWEAK CLKMAN_IRQHandler
SECTION .text:CODE:REORDER:NOROOT(1)

View File

@ -30,7 +30,7 @@
* ownership rights.
*******************************************************************************
*/
#ifndef MBED_CMSIS_H
#define MBED_CMSIS_H

View File

@ -30,7 +30,7 @@
* ownership rights.
*******************************************************************************
*/
#include "cmsis_nvic.h"
#if defined(TOOLCHAIN_GCC_ARM) || defined(TOOLCHAIN_ARM_STD)

View File

@ -72,72 +72,63 @@ typedef enum {
Bitfield structs for registers in this module
*/
typedef struct
{
typedef struct {
uint32_t wud_req_p0 : 8;
uint32_t wud_req_p1 : 8;
uint32_t wud_req_p2 : 8;
uint32_t wud_req_p3 : 8;
} mxc_ioman_wud_req0_t;
typedef struct
{
typedef struct {
uint32_t wud_req_p4 : 8;
uint32_t wud_req_p5 : 8;
uint32_t wud_req_p6 : 1;
uint32_t : 15;
} mxc_ioman_wud_req1_t;
typedef struct
{
typedef struct {
uint32_t wud_ack_p0 : 8;
uint32_t wud_ack_p1 : 8;
uint32_t wud_ack_p2 : 8;
uint32_t wud_ack_p3 : 8;
} mxc_ioman_wud_ack0_t;
typedef struct
{
typedef struct {
uint32_t wud_ack_p4 : 8;
uint32_t wud_ack_p5 : 8;
uint32_t wud_ack_p6 : 1;
uint32_t : 15;
} mxc_ioman_wud_ack1_t;
typedef struct
{
typedef struct {
uint32_t ali_req_p0 : 8;
uint32_t ali_req_p1 : 8;
uint32_t ali_req_p2 : 8;
uint32_t ali_req_p3 : 8;
} mxc_ioman_ali_req0_t;
typedef struct
{
typedef struct {
uint32_t ali_req_p4 : 8;
uint32_t ali_req_p5 : 8;
uint32_t ali_req_p6 : 1;
uint32_t : 15;
} mxc_ioman_ali_req1_t;
typedef struct
{
typedef struct {
uint32_t ali_ack_p0 : 8;
uint32_t ali_ack_p1 : 8;
uint32_t ali_ack_p2 : 8;
uint32_t ali_ack_p3 : 8;
} mxc_ioman_ali_ack0_t;
typedef struct
{
typedef struct {
uint32_t ali_ack_p4 : 8;
uint32_t ali_ack_p5 : 8;
uint32_t ali_ack_p6 : 1;
uint32_t : 15;
} mxc_ioman_ali_ack1_t;
typedef struct
{
typedef struct {
uint32_t : 4;
uint32_t core_io_req : 1;
uint32_t : 3;
@ -151,8 +142,7 @@ typedef struct
uint32_t : 15;
} mxc_ioman_spix_req_t;
typedef struct
{
typedef struct {
uint32_t : 4;
uint32_t core_io_ack : 1;
uint32_t : 3;
@ -166,8 +156,7 @@ typedef struct
uint32_t : 15;
} mxc_ioman_spix_ack_t;
typedef struct
{
typedef struct {
uint32_t io_map : 1;
uint32_t cts_map : 1;
uint32_t rts_map : 1;
@ -178,8 +167,7 @@ typedef struct
uint32_t : 25;
} mxc_ioman_uart0_req_t;
typedef struct
{
typedef struct {
uint32_t io_map : 1;
uint32_t cts_map : 1;
uint32_t rts_map : 1;
@ -190,8 +178,7 @@ typedef struct
uint32_t : 25;
} mxc_ioman_uart0_ack_t;
typedef struct
{
typedef struct {
uint32_t io_map : 1;
uint32_t cts_map : 1;
uint32_t rts_map : 1;
@ -202,8 +189,7 @@ typedef struct
uint32_t : 25;
} mxc_ioman_uart1_req_t;
typedef struct
{
typedef struct {
uint32_t io_map : 1;
uint32_t cts_map : 1;
uint32_t rts_map : 1;
@ -214,8 +200,7 @@ typedef struct
uint32_t : 25;
} mxc_ioman_uart1_ack_t;
typedef struct
{
typedef struct {
uint32_t io_map : 1;
uint32_t cts_map : 1;
uint32_t rts_map : 1;
@ -226,8 +211,7 @@ typedef struct
uint32_t : 25;
} mxc_ioman_uart2_req_t;
typedef struct
{
typedef struct {
uint32_t io_map : 1;
uint32_t cts_map : 1;
uint32_t rts_map : 1;
@ -238,8 +222,7 @@ typedef struct
uint32_t : 25;
} mxc_ioman_uart2_ack_t;
typedef struct
{
typedef struct {
uint32_t io_map : 1;
uint32_t cts_map : 1;
uint32_t rts_map : 1;
@ -250,8 +233,7 @@ typedef struct
uint32_t : 25;
} mxc_ioman_uart3_req_t;
typedef struct
{
typedef struct {
uint32_t io_map : 1;
uint32_t cts_map : 1;
uint32_t rts_map : 1;
@ -262,66 +244,57 @@ typedef struct
uint32_t : 25;
} mxc_ioman_uart3_ack_t;
typedef struct
{
typedef struct {
uint32_t : 4;
uint32_t mapping_req : 1;
uint32_t : 27;
} mxc_ioman_i2cm0_req_t;
typedef struct
{
typedef struct {
uint32_t : 4;
uint32_t mapping_ack : 1;
uint32_t : 27;
} mxc_ioman_i2cm0_ack_t;
typedef struct
{
typedef struct {
uint32_t : 4;
uint32_t mapping_req : 1;
uint32_t : 27;
} mxc_ioman_i2cm1_req_t;
typedef struct
{
typedef struct {
uint32_t : 4;
uint32_t mapping_ack : 1;
uint32_t : 27;
} mxc_ioman_i2cm1_ack_t;
typedef struct
{
typedef struct {
uint32_t : 4;
uint32_t mapping_req : 1;
uint32_t : 27;
} mxc_ioman_i2cm2_req_t;
typedef struct
{
typedef struct {
uint32_t : 4;
uint32_t mapping_ack : 1;
uint32_t : 27;
} mxc_ioman_i2cm2_ack_t;
typedef struct
{
typedef struct {
uint32_t io_sel : 2;
uint32_t : 2;
uint32_t mapping_req : 1;
uint32_t : 27;
} mxc_ioman_i2cs_req_t;
typedef struct
{
typedef struct {
uint32_t io_sel : 2;
uint32_t : 2;
uint32_t mapping_ack : 1;
uint32_t : 27;
} mxc_ioman_i2cs_ack_t;
typedef struct
{
typedef struct {
uint32_t : 4;
uint32_t core_io_req : 1;
uint32_t : 3;
@ -337,8 +310,7 @@ typedef struct
uint32_t : 7;
} mxc_ioman_spim0_req_t;
typedef struct
{
typedef struct {
uint32_t : 4;
uint32_t core_io_ack : 1;
uint32_t : 3;
@ -354,8 +326,7 @@ typedef struct
uint32_t : 7;
} mxc_ioman_spim0_ack_t;
typedef struct
{
typedef struct {
uint32_t : 4;
uint32_t core_io_req : 1;
uint32_t : 3;
@ -369,8 +340,7 @@ typedef struct
uint32_t : 7;
} mxc_ioman_spim1_req_t;
typedef struct
{
typedef struct {
uint32_t : 4;
uint32_t core_io_ack : 1;
uint32_t : 3;
@ -384,8 +354,7 @@ typedef struct
uint32_t : 7;
} mxc_ioman_spim1_ack_t;
typedef struct
{
typedef struct {
uint32_t mapping_req : 1;
uint32_t : 3;
uint32_t core_io_req : 1;
@ -403,8 +372,7 @@ typedef struct
uint32_t : 7;
} mxc_ioman_spim2_req_t;
typedef struct
{
typedef struct {
uint32_t mapping_ack : 1;
uint32_t : 3;
uint32_t core_io_ack : 1;
@ -422,8 +390,7 @@ typedef struct
uint32_t : 7;
} mxc_ioman_spim2_ack_t;
typedef struct
{
typedef struct {
uint32_t : 4;
uint32_t core_io_req : 1;
uint32_t : 3;
@ -433,8 +400,7 @@ typedef struct
uint32_t : 19;
} mxc_ioman_spib_req_t;
typedef struct
{
typedef struct {
uint32_t : 4;
uint32_t core_io_ack : 1;
uint32_t : 3;
@ -444,16 +410,14 @@ typedef struct
uint32_t : 19;
} mxc_ioman_spib_ack_t;
typedef struct
{
typedef struct {
uint32_t : 4;
uint32_t mapping_req : 1;
uint32_t epu_io_req : 1;
uint32_t : 26;
} mxc_ioman_owm_req_t;
typedef struct
{
typedef struct {
uint32_t : 4;
uint32_t mapping_ack : 1;
uint32_t epu_io_ack : 1;

View File

@ -57,20 +57,20 @@ extern "C" {
typedef struct {
__IO uint32_t start_opcode[32];
__IO uint32_t enable;
__IO uint32_t rsvd0;
__IO uint32_t rsvd0;
__IO uint32_t ll_stopped;
__IO uint32_t manual;
__IO uint32_t bus_error;
__IO uint32_t rsvd1;
__IO uint32_t to_stat;
__IO uint32_t rsvd2[4];
__IO uint32_t to_sel[3];
__IO uint32_t manual;
__IO uint32_t bus_error;
__IO uint32_t rsvd1;
__IO uint32_t to_stat;
__IO uint32_t rsvd2[4];
__IO uint32_t to_sel[3];
__IO uint32_t ps_sel[2];
__IO uint32_t interrupt;
__IO uint32_t interrupt;
__IO uint32_t int_enable;
__IO uint32_t rsvd3[6];
__IO uint32_t rsvd3[6];
__IO uint32_t burst_size[5];
__IO uint32_t rsvd4[3];
__IO uint32_t rsvd4[3];
__IO uint32_t padding[192]; /* Offset to next channel */
} mxc_pmu_bits_t;

View File

@ -53,12 +53,12 @@ static uint8_t running;
// NOTE: Setting the CMSIS SystemCoreClock value to the actual value it will
// be AFTER SystemInit() runs. This is required so the hal drivers will have
// the correct value when the DATA sections are initialized.
uint32_t SystemCoreClock = RO_FREQ;
uint32_t SystemCoreClock = RO_FREQ / 2;
void SystemCoreClockUpdate(void)
{
switch ((MXC_CLKMAN->clk_ctrl & MXC_F_CLKMAN_CLK_CTRL_SYSTEM_SOURCE_SELECT) >> MXC_F_CLKMAN_CLK_CTRL_SYSTEM_SOURCE_SELECT_POS) {
case MXC_V_CLKMAN_CLK_CTRL_SYSTEM_SOURCE_SELECT_96MHZ_RO_DIV_2:
default:
SystemCoreClock = RO_FREQ / 2;
@ -147,10 +147,9 @@ void SystemInit(void)
low_level_init();
// Select 96MHz ring oscillator as clock source
// Select 48MHz ring oscillator as clock source
uint32_t reg = MXC_CLKMAN->clk_ctrl;
reg &= ~MXC_F_CLKMAN_CLK_CTRL_SYSTEM_SOURCE_SELECT;
reg |= 1 << MXC_F_CLKMAN_CLK_CTRL_SYSTEM_SOURCE_SELECT_POS;
MXC_CLKMAN->clk_ctrl = reg;
// Copy trim information from shadow registers into power manager registers
@ -187,11 +186,11 @@ void SystemInit(void)
// Clear all unused wakeup sources
// Beware! Do not change any flag not mentioned here, as they will gate important power sequencer signals
MXC_PWRSEQ->msk_flags &= ~(MXC_F_PWRSEQ_MSK_FLAGS_PWR_USB_PLUG_WAKEUP |
MXC_F_PWRSEQ_MSK_FLAGS_PWR_USB_REMOVE_WAKEUP);
MXC_F_PWRSEQ_MSK_FLAGS_PWR_USB_REMOVE_WAKEUP);
// RTC sources are inverted, so a 1 will disable them
MXC_PWRSEQ->msk_flags |= (MXC_F_PWRSEQ_MSK_FLAGS_RTC_CMPR1 |
MXC_F_PWRSEQ_MSK_FLAGS_RTC_PRESCALE_CMP);
MXC_F_PWRSEQ_MSK_FLAGS_RTC_PRESCALE_CMP);
/* Enable RTOS Mode: Enable 32kHz clock synchronizer to SysTick external clock input */
MXC_CLKMAN->clk_ctrl |= MXC_F_CLKMAN_CLK_CTRL_RTOS_MODE;
@ -206,7 +205,7 @@ void SystemInit(void)
SCB->CPACR |= SCB_CPACR_CP10_Msk | SCB_CPACR_CP11_Msk;
__DSB();
__ISB();
#endif
#endif
// Trim ring oscillator
Trim_ROAtomic();

View File

@ -85,11 +85,10 @@ void pin_dir(PinName name, PinDirection direction)
if (direction == PIN_INPUT) {
/* Set requested output mode */
MXC_GPIO->out_mode[port] = (MXC_GPIO->out_mode[port] & ~(0xF << (4 * pin))) | (MXC_V_GPIO_OUT_MODE_HIGH_Z_WEAK_PULLUP << (4 * pin));
/* Enable default input weak pull-up by setting corresponding output */
MXC_GPIO->out_val[port] |= 1 << pin;
}
else {
} else {
/* Set requested output mode */
MXC_GPIO->out_mode[port] = (MXC_GPIO->out_mode[port] & ~(0xF << (4 * pin))) | (MXC_V_GPIO_OUT_MODE_NORMAL << (4 * pin));
}
@ -97,5 +96,5 @@ void pin_dir(PinName name, PinDirection direction)
void gpio_dir(gpio_t *obj, PinDirection direction)
{
pin_dir(obj->name, direction);
pin_dir(obj->name, direction);
}

View File

@ -233,7 +233,7 @@ int gpio_irq_init(gpio_irq_t *obj, PinName name, gpio_irq_handler handler, uint3
void gpio_irq_free(gpio_irq_t *obj)
{
/* disable interrupt */
/* disable interrupt */
MXC_GPIO->inten[obj->port] &= ~(1 << obj->pin);
MXC_GPIO->int_mode[obj->port] &= ~(MXC_V_GPIO_INT_MODE_ANY_EDGE << (obj->pin*4));
objs[obj->port][obj->pin] = NULL;

View File

@ -30,7 +30,7 @@
* ownership rights.
*******************************************************************************
*/
#ifndef MBED_GPIO_OBJECT_H
#define MBED_GPIO_OBJECT_H
@ -60,7 +60,8 @@ static inline int gpio_read(gpio_t *obj)
void pin_dir(PinName name, PinDirection direction);
static inline int gpio_is_connected(const gpio_t *obj) {
static inline int gpio_is_connected(const gpio_t *obj)
{
return obj->name != (PinName)NC;
}

View File

@ -60,42 +60,42 @@ typedef enum {
static const uint32_t clk_div_table[2][8] = {
/* MXC_E_I2CM_SPEED_100KHZ */
{
/* 0: 12MHz */ ((6 << MXC_F_I2CM_FS_CLK_DIV_FS_FILTER_CLK_DIV_POS) |
(17 << MXC_F_I2CM_FS_CLK_DIV_FS_SCL_HI_CNT_POS) |
(72 << MXC_F_I2CM_FS_CLK_DIV_FS_SCL_LO_CNT_POS)),
/* 1: 24MHz */ ((12 << MXC_F_I2CM_FS_CLK_DIV_FS_FILTER_CLK_DIV_POS) |
(38 << MXC_F_I2CM_FS_CLK_DIV_FS_SCL_HI_CNT_POS) |
(144 << MXC_F_I2CM_FS_CLK_DIV_FS_SCL_LO_CNT_POS)),
/* 2: */ 0, /* not supported */
/* 3: 48MHz */ ((24 << MXC_F_I2CM_FS_CLK_DIV_FS_FILTER_CLK_DIV_POS) |
(80 << MXC_F_I2CM_FS_CLK_DIV_FS_SCL_HI_CNT_POS) |
(288 << MXC_F_I2CM_FS_CLK_DIV_FS_SCL_LO_CNT_POS)),
/* 4: */ 0, /* not supported */
/* 5: */ 0, /* not supported */
/* 6: */ 0, /* not supported */
/* 7: 96MHz */ ((48 << MXC_F_I2CM_FS_CLK_DIV_FS_FILTER_CLK_DIV_POS) |
(164 << MXC_F_I2CM_FS_CLK_DIV_FS_SCL_HI_CNT_POS) |
(576 << MXC_F_I2CM_FS_CLK_DIV_FS_SCL_LO_CNT_POS)),
},
/* MXC_E_I2CM_SPEED_400KHZ */
{
/* 0: 12MHz */ ((2 << MXC_F_I2CM_FS_CLK_DIV_FS_FILTER_CLK_DIV_POS) |
(1 << MXC_F_I2CM_FS_CLK_DIV_FS_SCL_HI_CNT_POS) |
(18 << MXC_F_I2CM_FS_CLK_DIV_FS_SCL_LO_CNT_POS)),
/* 1: 24MHz */ ((3 << MXC_F_I2CM_FS_CLK_DIV_FS_FILTER_CLK_DIV_POS) |
(5 << MXC_F_I2CM_FS_CLK_DIV_FS_SCL_HI_CNT_POS) |
(36 << MXC_F_I2CM_FS_CLK_DIV_FS_SCL_LO_CNT_POS)),
/* 2: */ 0, /* not supported */
/* 3: 48MHz */ ((6 << MXC_F_I2CM_FS_CLK_DIV_FS_FILTER_CLK_DIV_POS) |
(15 << MXC_F_I2CM_FS_CLK_DIV_FS_SCL_HI_CNT_POS) |
(72 << MXC_F_I2CM_FS_CLK_DIV_FS_SCL_LO_CNT_POS)),
/* 4: */ 0, /* not supported */
/* 5: */ 0, /* not supported */
/* 6: */ 0, /* not supported */
/* 7: 96MHz */ ((12 << MXC_F_I2CM_FS_CLK_DIV_FS_FILTER_CLK_DIV_POS) |
(33 << MXC_F_I2CM_FS_CLK_DIV_FS_SCL_HI_CNT_POS) |
(144 << MXC_F_I2CM_FS_CLK_DIV_FS_SCL_LO_CNT_POS)),
},
/* 0: 12MHz */ ((6 << MXC_F_I2CM_FS_CLK_DIV_FS_FILTER_CLK_DIV_POS) |
(17 << MXC_F_I2CM_FS_CLK_DIV_FS_SCL_HI_CNT_POS) |
(72 << MXC_F_I2CM_FS_CLK_DIV_FS_SCL_LO_CNT_POS)),
/* 1: 24MHz */ ((12 << MXC_F_I2CM_FS_CLK_DIV_FS_FILTER_CLK_DIV_POS) |
(38 << MXC_F_I2CM_FS_CLK_DIV_FS_SCL_HI_CNT_POS) |
(144 << MXC_F_I2CM_FS_CLK_DIV_FS_SCL_LO_CNT_POS)),
/* 2: */ 0, /* not supported */
/* 3: 48MHz */ ((24 << MXC_F_I2CM_FS_CLK_DIV_FS_FILTER_CLK_DIV_POS) |
(80 << MXC_F_I2CM_FS_CLK_DIV_FS_SCL_HI_CNT_POS) |
(288 << MXC_F_I2CM_FS_CLK_DIV_FS_SCL_LO_CNT_POS)),
/* 4: */ 0, /* not supported */
/* 5: */ 0, /* not supported */
/* 6: */ 0, /* not supported */
/* 7: 96MHz */ ((48 << MXC_F_I2CM_FS_CLK_DIV_FS_FILTER_CLK_DIV_POS) |
(164 << MXC_F_I2CM_FS_CLK_DIV_FS_SCL_HI_CNT_POS) |
(576 << MXC_F_I2CM_FS_CLK_DIV_FS_SCL_LO_CNT_POS)),
},
/* MXC_E_I2CM_SPEED_400KHZ */
{
/* 0: 12MHz */ ((2 << MXC_F_I2CM_FS_CLK_DIV_FS_FILTER_CLK_DIV_POS) |
(1 << MXC_F_I2CM_FS_CLK_DIV_FS_SCL_HI_CNT_POS) |
(18 << MXC_F_I2CM_FS_CLK_DIV_FS_SCL_LO_CNT_POS)),
/* 1: 24MHz */ ((3 << MXC_F_I2CM_FS_CLK_DIV_FS_FILTER_CLK_DIV_POS) |
(5 << MXC_F_I2CM_FS_CLK_DIV_FS_SCL_HI_CNT_POS) |
(36 << MXC_F_I2CM_FS_CLK_DIV_FS_SCL_LO_CNT_POS)),
/* 2: */ 0, /* not supported */
/* 3: 48MHz */ ((6 << MXC_F_I2CM_FS_CLK_DIV_FS_FILTER_CLK_DIV_POS) |
(15 << MXC_F_I2CM_FS_CLK_DIV_FS_SCL_HI_CNT_POS) |
(72 << MXC_F_I2CM_FS_CLK_DIV_FS_SCL_LO_CNT_POS)),
/* 4: */ 0, /* not supported */
/* 5: */ 0, /* not supported */
/* 6: */ 0, /* not supported */
/* 7: 96MHz */ ((12 << MXC_F_I2CM_FS_CLK_DIV_FS_FILTER_CLK_DIV_POS) |
(33 << MXC_F_I2CM_FS_CLK_DIV_FS_SCL_HI_CNT_POS) |
(144 << MXC_F_I2CM_FS_CLK_DIV_FS_SCL_LO_CNT_POS)),
},
};
void i2c_init(i2c_t *obj, PinName sda, PinName scl)
@ -109,7 +109,7 @@ void i2c_init(i2c_t *obj, PinName sda, PinName scl)
obj->i2c = i2c;
obj->fifos = (mxc_i2cm_fifo_regs_t*)MXC_I2CM_GET_BASE_FIFO(MXC_I2CM_GET_IDX(i2c));
obj->start_pending = 0;
obj->stop_pending = 0;
obj->stop_pending = 0;
// configure the pins
pinmap_pinout(sda, PinMap_I2C_SDA);
@ -135,10 +135,10 @@ void i2c_init(i2c_t *obj, PinName sda, PinName scl)
void i2c_frequency(i2c_t *obj, int hz)
{
// compute clock array index
// (96Mhz/12M) -1 = 7
// (48Mhz/12M) -1 = 3
// (24Mhz/12M) -1 = 1
// (12Mhz/12M) -1 = 0
// (96Mhz/12M) -1 = 7
// (48Mhz/12M) -1 = 3
// (24Mhz/12M) -1 = 1
// (12Mhz/12M) -1 = 0
int clki = (SystemCoreClock / 12000000) - 1;
// get clock divider settings from lookup table
@ -318,7 +318,7 @@ int i2c_write(i2c_t *obj, int address, const char *data, int length, int stop)
}
if (stop) {
obj->stop_pending = 0;
obj->stop_pending = 0;
if ((err = write_tx_fifo(obj, MXC_S_I2CM_TRANS_TAG_STOP)) != 0) { // stop condition
retval = (retval ? retval : err);
}

View File

@ -30,7 +30,7 @@
* ownership rights.
*******************************************************************************
*/
#include "mbed_assert.h"
#include "pinmap.h"
#include "objects.h"

View File

@ -30,7 +30,7 @@
* ownership rights.
*******************************************************************************
*/
#include "port_api.h"
#include "pinmap.h"
#include "gpio_api.h"
@ -50,7 +50,7 @@ void port_init(port_t *obj, PortName port, int mask, PinDirection dir)
obj->reg_in = &MXC_GPIO->in_val[port];
/* Ensure that the GPIO clock is enabled */
MXC_CLKMAN->sys_clk_ctrl_6_gpio = MXC_S_CLKMAN_CLK_SCALE_DIV_1;
MXC_CLKMAN->sys_clk_ctrl_6_gpio = MXC_S_CLKMAN_CLK_SCALE_DIV_1;
uint32_t i;
// The function is set per pin: reuse gpio logic

View File

@ -79,7 +79,7 @@ void pwmout_init(pwmout_t* obj, PinName pin)
obj->pwm = (mxc_pt_regs_t*)pwm.peripheral;
// Initialize object period and pulse width
obj->period = -1;
obj->period = -1;
obj->pulse_width = -1;
// Disable the output
@ -114,7 +114,7 @@ static void pwmout_update(pwmout_t* obj)
{
// Calculate and set the divider ratio
int div = (obj->period * (SystemCoreClock/1000000))/32;
if (div < 2){
if (div < 2) {
div = 2;
}
MXC_SET_FIELD(&obj->pwm->rate_length, MXC_F_PT_RATE_LENGTH_RATE_CONTROL, div);
@ -142,7 +142,7 @@ void pwmout_write(pwmout_t* obj, float percent)
float pwmout_read(pwmout_t* obj)
{
// Check for when pulsewidth or period equals 0
if ((obj->pulse_width == 0) || (obj->period == 0)){
if ((obj->pulse_width == 0) || (obj->period == 0)) {
return 0;
}

View File

@ -83,7 +83,7 @@ static uint64_t rtc_read64(void);
//******************************************************************************
static void overflow_handler(void)
{
MXC_RTCTMR->flags |= MXC_F_RTC_FLAGS_ASYNC_CLR_FLAGS;
MXC_RTCTMR->flags |= MXC_F_RTC_FLAGS_ASYNC_CLR_FLAGS;
overflow_cnt++;
// Wait for pending transactions
@ -271,7 +271,7 @@ void lp_ticker_set_interrupt(timestamp_t timestamp)
}
MXC_RTCTMR->comp[0] = comp_value;
MXC_RTCTMR->flags |= MXC_F_RTC_FLAGS_ASYNC_CLR_FLAGS;
MXC_RTCTMR->flags |= MXC_F_RTC_FLAGS_ASYNC_CLR_FLAGS;
MXC_RTCTMR->inten |= MXC_F_RTC_INTEN_COMP0; // enable the interrupt
// Enable wakeup from RTC
@ -290,7 +290,7 @@ inline void lp_ticker_disable_interrupt(void)
//******************************************************************************
inline void lp_ticker_clear_interrupt(void)
{
MXC_RTCTMR->flags |= MXC_F_RTC_FLAGS_ASYNC_CLR_FLAGS;
MXC_RTCTMR->flags |= MXC_F_RTC_FLAGS_ASYNC_CLR_FLAGS;
// Wait for pending transactions
while (MXC_RTCTMR->ctrl & MXC_F_RTC_CTRL_PENDING);

View File

@ -92,7 +92,7 @@ void serial_init(serial_t *obj, PinName tx, PinName rx)
// To support the most common baud rates, 9600 and 115200, we need to
// scale down the uart input clock.
if (!(MXC_CLKMAN->sys_clk_ctrl_8_uart & MXC_F_CLKMAN_SYS_CLK_CTRL_8_UART_UART_CLK_SCALE)) {
switch (SystemCoreClock) {
case RO_FREQ:
MXC_CLKMAN->sys_clk_ctrl_8_uart = MXC_S_CLKMAN_CLK_SCALE_DIV_4;
@ -134,7 +134,7 @@ void serial_init(serial_t *obj, PinName tx, PinName rx)
stdio_uart_inited = 1;
memcpy(&stdio_uart, obj, sizeof(serial_t));
}
// Enable UART
obj->uart->ctrl |= MXC_F_UART_CTRL_UART_EN;
}
@ -311,7 +311,7 @@ void serial_putc(serial_t *obj, int c)
{
// Wait for TXFIFO to not be full
while ( ((obj->uart->tx_fifo_ctrl & MXC_F_UART_TX_FIFO_CTRL_FIFO_ENTRY)
>> MXC_F_UART_TX_FIFO_CTRL_FIFO_ENTRY_POS)
>> MXC_F_UART_TX_FIFO_CTRL_FIFO_ENTRY_POS)
>= MXC_UART_FIFO_DEPTH );
// Must clear before every write to the buffer to know that the fifo
@ -330,8 +330,8 @@ int serial_readable(serial_t *obj)
int serial_writable(serial_t *obj)
{
return ( ((obj->uart->tx_fifo_ctrl & MXC_F_UART_TX_FIFO_CTRL_FIFO_ENTRY)
>> MXC_F_UART_TX_FIFO_CTRL_FIFO_ENTRY_POS)
< MXC_UART_FIFO_DEPTH );
>> MXC_F_UART_TX_FIFO_CTRL_FIFO_ENTRY_POS)
< MXC_UART_FIFO_DEPTH );
}
//******************************************************************************
@ -348,7 +348,7 @@ void serial_break_set(serial_t *obj)
{
// Make sure that nothing is being sent
while ( ((obj->uart->tx_fifo_ctrl & MXC_F_UART_TX_FIFO_CTRL_FIFO_ENTRY)
>> MXC_F_UART_TX_FIFO_CTRL_FIFO_ENTRY_POS) > 0);
>> MXC_F_UART_TX_FIFO_CTRL_FIFO_ENTRY_POS) > 0);
while (!(obj->uart->intfl & MXC_F_UART_INTFL_TX_DONE));
// Configure the GPIO to output 0

View File

@ -32,14 +32,12 @@
*/
#include "sleep_api.h"
#include "cmsis.h"
#include "pwrman_regs.h"
#include "pwrseq_regs.h"
#include "clkman_regs.h"
#include "ioman_regs.h"
#include "rtc_regs.h"
#include "usb_regs.h"
#include "wait_api.h"
#define REVISION_A3 2
#define REVISION_A4 3
@ -86,8 +84,7 @@ static void usb_sleep(void)
MXC_USB->dev_cn = 0;
MXC_USB->cn = 0;
restore_usb = 1; // USB should be restored upon wakeup
}
else {
} else {
restore_usb = 0;
}
}
@ -124,7 +121,7 @@ void deepsleep(void)
// Wait for all STDIO characters to be sent. The UART clock will stop.
while ((stdio_uart->tx_fifo_ctrl & MXC_F_UART_TX_FIFO_CTRL_FIFO_ENTRY) ||
!(stdio_uart->intfl & MXC_F_UART_INTFL_TX_DONE));
!(stdio_uart->intfl & MXC_F_UART_INTFL_TX_DONE));
__disable_irq();
@ -179,7 +176,7 @@ void deepsleep(void)
MXC_PWRSEQ->reg1 |= MXC_F_PWRSEQ_REG1_PWR_MBUS_GATE;
// Dummy read to make sure SSB writes are complete
MXC_PWRSEQ->reg0;
MXC_PWRSEQ->reg0 = MXC_PWRSEQ->reg0;
if (part_rev == REVISION_A4) {
// Note: ARM deep-sleep requires a specific sequence to clear event latches,
@ -187,8 +184,7 @@ void deepsleep(void)
__SEV();
__WFE();
__WFI();
}
else {
} else {
// Note: ARM deep-sleep requires a specific sequence to clear event latches,
// otherwise the CPU will not enter sleep.
__SEV();

View File

@ -69,7 +69,7 @@ void spi_init(spi_t *obj, PinName mosi, PinName miso, PinName sclk, PinName ssel
// Give the application the option to manually control Slave Select
if ((SPIName)spi_ssel != (SPIName)NC) {
spi_cntl = (SPIName)pinmap_merge(spi_sclk, spi_ssel);
// Slave select is currently limited to slave select zero. If others are
// Slave select is currently limited to slave select zero. If others are
// to be supported a function to map PinName to a value suitable for use
// in mstr_cfg.slave_sel will be required.
obj->spi.ssel = 0;
@ -352,7 +352,7 @@ static uint32_t spi_master_transfer_handler(spi_t *obj)
// Set the transaction configuration in the header
header = ((write | (read << 1)) << MXC_F_SPI_FIFO_DIR_POS) | (req->width << MXC_F_SPI_FIFO_WIDTH_POS);
if (remain >= SPI_MAX_BYTE_LEN) {
// Send a 32 byte header
@ -367,7 +367,7 @@ static uint32_t spi_master_transfer_handler(spi_t *obj)
// Send in increments of 32 byte pages
header |= MXC_S_SPI_FIFO_UNIT_PAGES;
pages = remain / SPI_MAX_PAGE_LEN;
if (pages >= 32) {
// 0 maps to 32 in the header
bytes = 32 * SPI_MAX_PAGE_LEN;
@ -380,7 +380,7 @@ static uint32_t spi_master_transfer_handler(spi_t *obj)
if ((remain - bytes) == 0) {
header |= MXC_F_SPI_FIFO_DASS;
}
}
}
fifo->trans_16[0] = header;
@ -414,7 +414,7 @@ static uint32_t spi_master_transfer_handler(spi_t *obj)
}
// Only memcpy even numbers
length = ((length / 2) * 2);
length = ((length / 2) * 2);
memcpy((void*)fifo->trans_32, &(req->tx_data[req->write_num]), length);
@ -450,8 +450,8 @@ static uint32_t spi_master_transfer_handler(spi_t *obj)
}
// Check to see if we've finished reading and writing
if (((read && (req->read_num == req->len)) || !read) &&
((req->write_num == req->len) || !write)) {
if (((read && (req->read_num == req->len)) || !read) &&
((req->write_num == req->len) || !write)) {
// Disable interrupts
spim->inten = 0;
@ -469,7 +469,7 @@ void spi_master_transfer(spi_t *obj, const void *tx, size_t tx_length, void *rx,
// Save object reference for callback
state[obj->spi.index] = &obj->spi;
// Initialize request info
obj->spi.tx_data = tx;
obj->spi.rx_data = rx;
@ -491,7 +491,7 @@ uint32_t spi_irq_handler_asynch(spi_t *obj)
{
mxc_spi_regs_t *spim = obj->spi.spi;
uint32_t flags;
// Clear the interrupt flags
spim->inten = 0;
flags = spim->intfl;
@ -503,7 +503,7 @@ uint32_t spi_irq_handler_asynch(spi_t *obj)
return 0;
}
}
state[obj->spi.index] = NULL;
return SPI_EVENT_COMPLETE;
@ -516,7 +516,7 @@ uint8_t spi_active(spi_t *obj)
// Check to see if there are any ongoing transactions
if ((state[obj->spi.index] == NULL) &&
!(spim->fifo_ctrl & MXC_F_SPI_FIFO_CTRL_TX_FIFO_USED)) {
!(spim->fifo_ctrl & MXC_F_SPI_FIFO_CTRL_TX_FIFO_USED)) {
return 0;
}

View File

@ -72,7 +72,8 @@ static volatile uint64_t event_cnt; // Holds the value of the next event
#define MAX_TICK_VAL ((uint64_t)0xFFFFFFFF * ticks_per_us)
//******************************************************************************
static inline void inc_current_cnt(uint32_t inc) {
static inline void inc_current_cnt(uint32_t inc)
{
// Overflow the ticker when the us ticker overflows
current_cnt += inc;
@ -82,14 +83,15 @@ static inline void inc_current_cnt(uint32_t inc) {
}
//******************************************************************************
static inline int event_passed(uint64_t current, uint64_t event) {
static inline int event_passed(uint64_t current, uint64_t event)
{
// Determine if the event has already happened.
// If the event is behind the current ticker, within a window,
// then the event has already happened.
if (((current < tick_win) && ((event < current) ||
(event > (MAX_TICK_VAL - (tick_win - current))))) ||
((event < current) && (event > (current - tick_win)))) {
if (((current < tick_win) && ((event < current) ||
(event > (MAX_TICK_VAL - (tick_win - current))))) ||
((event < current) && (event > (current - tick_win)))) {
return 1;
}
@ -97,7 +99,8 @@ static inline int event_passed(uint64_t current, uint64_t event) {
}
//******************************************************************************
static inline uint64_t event_diff(uint64_t current, uint64_t event) {
static inline uint64_t event_diff(uint64_t current, uint64_t event)
{
// Check to see if the ticker will overflow before the event
if(current <= event) {
@ -129,7 +132,7 @@ static void tmr_handler(void)
US_TIMER->term_cnt32 = diff;
// Since the timer keeps counting after the terminal value is reached, it is possible that the new
// terminal value is in the past.
// terminal value is in the past.
if (US_TIMER->term_cnt32 < US_TIMER->count32) {
// the timestamp has expired
US_TIMER->term_cnt32 = 0xFFFFFFFF; // reset to max value to prevent further interrupts
@ -239,7 +242,7 @@ void us_ticker_set_interrupt(timestamp_t timestamp)
inc_current_cnt(US_TIMER->count32);
US_TIMER->count32 = 0;
// add the number of cycles that the timer is disabled here for
// add the number of cycles that the timer is disabled here for
inc_current_cnt(200);
event_cnt = (uint64_t)timestamp * ticks_per_us;
@ -251,7 +254,7 @@ void us_ticker_set_interrupt(timestamp_t timestamp)
// the event occurs before the next overflow
US_TIMER->term_cnt32 = diff;
} else {
// the event occurs after the next overflow
// the event occurs after the next overflow
US_TIMER->term_cnt32 = 0xFFFFFFFF; // set to max
}
} else {

View File

@ -50,7 +50,7 @@
#elif defined(TARGET_MAX32620)
#ifndef INITIAL_SP
#define INITIAL_SP (0x20008000UL)
#define INITIAL_SP (0x20040000UL)
#endif
#ifndef OS_TASKCNT
#define OS_TASKCNT 14
@ -59,7 +59,7 @@
#define OS_MAINSTKSIZE 256
#endif
#ifndef OS_CLOCK
#define OS_CLOCK 96000000
#define OS_CLOCK 48000000
#endif
#endif

View File

@ -1705,6 +1705,7 @@
"extra_labels": ["Maxim", "MAX32610"],
"supported_toolchains": ["GCC_ARM", "IAR", "ARM"],
"device_has": ["ANALOGIN", "ANALOGOUT", "ERROR_PATTERN", "I2C", "INTERRUPTIN", "LOWPOWERTIMER", "PORTIN", "PORTINOUT", "PORTOUT", "PWMOUT", "RTC", "SERIAL", "SERIAL_FC", "SLEEP", "SPI", "STDIO_MESSAGES"],
"features": ["BLE"],
"release_versions": ["2", "5"]
},
"MAX32600MBED": {
@ -1723,6 +1724,7 @@
"extra_labels": ["Maxim", "MAX32620"],
"supported_toolchains": ["GCC_ARM", "IAR", "ARM"],
"device_has": ["ANALOGIN", "ERROR_PATTERN", "I2C", "INTERRUPTIN", "LOWPOWERTIMER", "PORTIN", "PORTINOUT", "PORTOUT", "PWMOUT", "RTC", "SERIAL", "SERIAL_FC", "SLEEP", "SPI", "SPI_ASYNCH", "STDIO_MESSAGES"],
"features": ["BLE"],
"release_versions": ["2", "5"]
},
"EFM32GG_STK3700": {