Commit 938f4a88 authored by schneider's avatar schneider
Browse files

fix(max32666): Update SDK to 0.2.1-7

parent b6832e3f
build/
/build/
/Documentation/output/
__pycache__/
*.pyc
......
......@@ -29,14 +29,15 @@
* property whatsoever. Maxim Integrated Products, Inc. retains all
* ownership rights.
*
* $Date: 2019-07-12 10:56:57 -0500 (Fri, 12 Jul 2019) $
* $Revision: 44598 $
* $Date: 2019-08-22 20:18:08 -0500 (Thu, 22 Aug 2019) $
* $Revision: 45615 $
*
******************************************************************************/
#include <stdio.h>
#include <string.h>
#include "mxc_config.h"
#include "mxc_sys.h"
#include "wsf_types.h"
#include "wsf_os.h"
#include "wsf_buf.h"
......@@ -47,6 +48,7 @@
#include "app_ui.h"
#include "hci_vs.h"
#include "hci_core.h"
#include "dm_api.h"
/**************************************************************************************************
Macros
......@@ -150,12 +152,40 @@ static void WsfInit(void)
*/
void SetAddress(uint8_t event)
{
uint8_t bdAddr[6] = {0x02, 0x00, 0x44, 0x8B, 0x05, 0x00};
uint8_t usn[SYS_USN_CHECKSUM_LEN];
uint8_t checksum[SYS_USN_CHECKSUM_LEN];
uint8_t bdAddr[6];
uint8_t bdAddrRand[6];
if(SYS_GetUSN(usn, checksum) != E_NO_ERROR) {
printf("Error getting Checksum\n");
}
// MA-L assigend by IEEE to Maxim Integrated Products
bdAddr[5] = 0x00;
bdAddr[4] = 0x18;
bdAddr[3] = 0x80;
// USN checksum
bdAddr[2] = checksum[2];
bdAddr[1] = checksum[1];
bdAddr[0] = checksum[0];
bdAddrRand[0] = checksum[3];
bdAddrRand[1] = checksum[4];
bdAddrRand[2] = checksum[5];
bdAddrRand[3] = checksum[6];
bdAddrRand[4] = checksum[7];
bdAddrRand[5] = checksum[8];
switch (event) {
case APP_UI_RESET_CMPL:
printf("Setting address -- MAC %02X:%02X:%02X:%02X:%02X:%02X\n", bdAddr[5], bdAddr[4], bdAddr[3], bdAddr[2], bdAddr[1], bdAddr[0]);
HciVsSetBdAddr(bdAddr);
DM_RAND_ADDR_SET(bdAddrRand, DM_RAND_ADDR_STATIC);
DmDevSetRandAddr(bdAddrRand);
DmAdvSetAddrType(DM_ADDR_RANDOM);
printf("Setting random address -- MAC %02X:%02X:%02X:%02X:%02X:%02X\n",
bdAddrRand[5], bdAddrRand[4], bdAddrRand[3], bdAddrRand[2], bdAddrRand[1], bdAddrRand[0]);
break;
default:
break;
......
......@@ -20,6 +20,7 @@
#include <stdio.h>
#include <string.h>
#include <ctype.h>
#include "mxc_device.h"
#include "wsf_types.h"
#include "util/bstream.h"
#include "wsf_msg.h"
......@@ -41,6 +42,7 @@
#include "wpc/wpc_api.h"
#include "datc/datc_api.h"
#include "util/calc128.h"
#include "gcr_regs.h"
/**************************************************************************************************
Macros
......@@ -983,7 +985,13 @@ static void datcSetup(dmEvt_t *pMsg)
DmDevSetFilterPolicy(DM_FILT_POLICY_MODE_INIT, HCI_FILT_WHITE_LIST);
#endif /* BTLE_APP_USE_WHITELIST */
DmSetDefaultPhy(0, HCI_PHY_LE_1M_BIT | HCI_PHY_LE_2M_BIT, HCI_PHY_LE_1M_BIT | HCI_PHY_LE_2M_BIT);
/* Enable coded PHY */
if(MXC_GCR->revision != 0xA1) {
DmSetDefaultPhy(0, HCI_PHY_LE_1M_BIT | HCI_PHY_LE_2M_BIT | HCI_PHY_LE_CODED_BIT,
HCI_PHY_LE_1M_BIT | HCI_PHY_LE_2M_BIT | HCI_PHY_LE_CODED_BIT);
} else {
DmSetDefaultPhy(0, HCI_PHY_LE_1M_BIT | HCI_PHY_LE_2M_BIT, HCI_PHY_LE_1M_BIT | HCI_PHY_LE_2M_BIT);
}
testCb.phy = HCI_PHY_LE_1M_BIT;
DmConnSetConnSpec((hciConnSpec_t *) &datcConnCfg);
......@@ -1153,12 +1161,21 @@ static void testTimerHandler(void)
(testCb.connId != DM_CONN_ID_NONE) &&
(datcCb.discState[testCb.connId-1] == DATC_DISC_SVC_MAX))
{
if(testCb.phy == HCI_PHY_LE_1M_BIT) {
if(testCb.phy == HCI_PHY_LE_2M_BIT) {
/* Change from 1M to 2M PHY */
testCb.phy = HCI_PHY_LE_2M_BIT;
} else {
/* Change from Coded to 1M PHY */
testCb.phy = HCI_PHY_LE_1M_BIT;
} else if (testCb.phy == HCI_PHY_LE_1M_BIT) {
/* Change to the coded PHY if we're not using A1 */
if(MXC_GCR->revision != 0xA1) {
testCb.phy = HCI_PHY_LE_CODED_BIT;
} else {
testCb.phy = HCI_PHY_LE_2M_BIT;
}
} else {
/* Change to 2M PHY */
testCb.phy = HCI_PHY_LE_2M_BIT;
}
DmSetPhy(testCb.connId, 0, testCb.phy, testCb.phy, 0);
......
......@@ -19,6 +19,7 @@
#include <stdio.h>
#include <string.h>
#include "mxc_device.h"
#include "wsf_types.h"
#include "wsf_os.h"
#include "util/bstream.h"
......@@ -36,7 +37,7 @@
#include "svc_core.h"
#include "sec_api.h"
#include "ll_init_api.h"
#include "gcr_regs.h"
#define LL_IMPL_REV 0x2303
......@@ -44,7 +45,7 @@
uint8_t LlMem[LL_MEMORY_FOOTPRINT];
const LlRtCfg_t _ll_cfg = {
LlRtCfg_t _ll_cfg = {
/* Device */
/*compId*/ LL_COMP_ID_ARM,
/*implRev*/ LL_IMPL_REV,
......@@ -101,6 +102,11 @@ void StackInitDatc(void)
#ifndef ENABLE_SDMA
uint32_t memUsed;
/* Enable coded PHY */
if(MXC_GCR->revision != 0xA1) {
_ll_cfg.phyCodedSup = TRUE;
}
/* Initialize link layer. */
LlInitRtCfg_t ll_init_cfg =
......
......@@ -19,6 +19,7 @@
#include <stdio.h>
#include <string.h>
#include "mxc_device.h"
#include "wsf_types.h"
#include "util/bstream.h"
#include "wsf_msg.h"
......@@ -40,6 +41,7 @@
#include "svc_wp.h"
#include "util/calc128.h"
#include "dats/dats_api.h"
#include "gcr_regs.h"
/**************************************************************************************************
Macros
......@@ -505,7 +507,13 @@ static void datsSetup(dmEvt_t *pMsg)
AppExtAdvSetData(DM_ADV_HANDLE_DEFAULT, APP_SCAN_DATA_CONNECTABLE, sizeof(datsExtScanDataDisc), (uint8_t *) datsExtScanDataDisc, HCI_EXT_ADV_DATA_LEN);
#endif /* BTLE_APP_USE_LEGACY_API */
DmSetDefaultPhy(0, HCI_PHY_LE_1M_BIT | HCI_PHY_LE_2M_BIT, HCI_PHY_LE_1M_BIT | HCI_PHY_LE_2M_BIT);
/* Enable coded PHY */
if(MXC_GCR->revision != 0xA1) {
DmSetDefaultPhy(0, HCI_PHY_LE_1M_BIT | HCI_PHY_LE_2M_BIT | HCI_PHY_LE_CODED_BIT,
HCI_PHY_LE_1M_BIT | HCI_PHY_LE_2M_BIT | HCI_PHY_LE_CODED_BIT);
} else {
DmSetDefaultPhy(0, HCI_PHY_LE_1M_BIT | HCI_PHY_LE_2M_BIT, HCI_PHY_LE_1M_BIT | HCI_PHY_LE_2M_BIT);
}
/* start advertising; automatically set connectable/discoverable mode and bondable mode */
#ifndef BTLE_APP_USE_LEGACY_API
......
......@@ -19,6 +19,7 @@
#include <stdio.h>
#include <string.h>
#include "mxc_device.h"
#include "wsf_types.h"
#include "wsf_os.h"
#include "util/bstream.h"
......@@ -37,6 +38,7 @@
#include "svc_core.h"
#include "sec_api.h"
#include "ll_init_api.h"
#include "gcr_regs.h"
#define LL_IMPL_REV 0x2303
......@@ -44,7 +46,7 @@
uint8_t LlMem[LL_MEMORY_FOOTPRINT];
const LlRtCfg_t _ll_cfg = {
LlRtCfg_t _ll_cfg = {
/* Device */
/*compId*/ LL_COMP_ID_ARM,
/*implRev*/ LL_IMPL_REV,
......@@ -102,6 +104,11 @@ void StackInitDats(void)
#ifndef ENABLE_SDMA
uint32_t memUsed;
/* Enable coded PHY */
if(MXC_GCR->revision != 0xA1) {
_ll_cfg.phyCodedSup = TRUE;
}
/* Initialize link layer. */
LlInitRtCfg_t ll_init_cfg =
{
......
......@@ -29,7 +29,7 @@
# property whatsoever. Maxim Integrated Products, Inc. retains all
# ownership rights.
#
# $Id: Makefile 45395 2019-08-13 21:04:28Z kevin.gillespie $
# $Id: Makefile 48012 2019-10-23 18:41:06Z kevin.gillespie $
#
################################################################################
......@@ -65,15 +65,20 @@ ifneq "$(BLE_ADDR_LSB)" ""
PROJ_CFLAGS+=-DBLE_ADDR_LSB=$(BLE_ADDR_LSB)
endif
## Subsitute WSF critical section entry for default MAXUSB
# Suppress compiler warnings on undefined names (define as zeros)
PROJ_CFLAGS+=-DIAR_PRAGMAS=0
# Subsitute WSF critical section entry for default MAXUSB
#PROJ_CFLAGS+=-DMAXUSB_ENTER_CRITICAL=WsfCsEnter
#PROJ_CFLAGS+=-DMAXUSB_EXIT_CRITICAL=WsfCsExit
# This is the path to the CMSIS root directory
ifeq "$(MAXIM_PATH)" ""
LIBS_DIR=../../../Libraries
NDALIBS_DIR=../../../NDALibraries
else
LIBS_DIR=/$(subst \,/,$(subst :,,$(MAXIM_PATH))/Firmware/$(TARGET_UC)/Libraries)
NDALIBS_DIR=/$(subst \,/,$(subst :,,$(MAXIM_PATH))/Firmware/$(TARGET_UC)/NDALibraries)
endif
CMSIS_ROOT=$(LIBS_DIR)/CMSIS
......@@ -150,7 +155,7 @@ PROJ_CFLAGS+=-DINIT_BROADCASTER
PROJ_CFLAGS+=-DINIT_PERIPHERAL
PROJ_CFLAGS+=-DINIT_ENCRYPTED
ENABLE_LL_TESTER?=#1
# ENABLE_LL_TESTER?=#1
# Use this variable to override default compilier optimization.
#MXC_OPTIMIZE_CFLAGS=-Os
......@@ -174,10 +179,6 @@ include ${PERIPH_DRIVER_DIR}/periphdriver.mk
CORDIO_DIR=$(LIBS_DIR)/BTLE
include ${CORDIO_DIR}/btle.mk
# Include MAXUSB library
MAXUSB_DIR=$(LIBS_DIR)/MAXUSB
include $(MAXUSB_DIR)/maxusb.mk
################################################################################
# Include the rules for building for this target. All other makefiles should be
# included before this one.
......
......@@ -84,7 +84,7 @@ typedef union
static const appAdvCfg_t fitAdvCfg =
{
{ 1000, 0, 0}, /*! Advertising durations in ms */
{ 96, 200, 0} /*! Advertising intervals in 0.625 ms units */
{ 200, 200, 0} /*! Advertising intervals in 0.625 ms units */
};
/*! configurable parameters for slave */
......
/*******************************************************************************
* Copyright (C) 2018 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.
*
* $Date: 2019-07-11 16:47:07 -0500 (Thu, 11 Jul 2019) $
* $Revision: 44577 $
*
******************************************************************************/
#include <stdio.h>
#include <string.h>
#include "mxc_config.h"
#include "wsf_types.h"
#include "wsf_os.h"
#include "wsf_buf.h"
#include "wsf_timer.h"
#include "wsf_trace.h"
#include "app_ui.h"
#include "fit/fit_api.h"
#include "app_ui.h"
#include "hci_vs.h"
#include "hci_core.h"
#include "pb.h"
#include "tmr.h"
/**************************************************************************************************
Macros
**************************************************************************************************/
/* Size of buffer for stdio functions */
#define WSF_BUF_POOLS 6
#define WSF_BUF_SIZE 0x1048
/* Size of buffer for stdio functions */
#define PRINTF_BUF_SIZE 128
/* Definitions for push button handling */
#define BUTTON0_TMR MXC_TMR0
#define BUTTON1_TMR MXC_TMR1
#define BUTTON_SHORT_MS 200
#define BUTTON_MED_MS 500
#define BUTTON_LONG_MS 1000
/**************************************************************************************************
Local Variables
**************************************************************************************************/
uint32_t SystemHeapSize=WSF_BUF_SIZE;
uint32_t SystemHeap[WSF_BUF_SIZE/4];
uint32_t SystemHeapStart;
/*! Buffer for stdio functions */
char printf_buffer[PRINTF_BUF_SIZE];
/*! Default pool descriptor. */
static wsfBufPoolDesc_t mainPoolDesc[WSF_BUF_POOLS] =
{
{ 16, 8 },
{ 32, 4 },
{ 64, 4 },
{ 128, 4 },
{ 256, 4 },
{ 512, 4 }
};
/**************************************************************************************************
Functions
**************************************************************************************************/
/*! \brief Stack initialization for app. */
extern void StackInitFit(void);
/*************************************************************************************************/
void PalSysAssertTrap(void)
{
while(1) {}
}
/*************************************************************************************************/
void SysTick_Handler(void)
{
WsfTimerUpdate(1);
}
/*************************************************************************************************/
static bool_t myTrace(const uint8_t *pBuf, uint32_t len)
{
extern uint8_t wsfCsNesting;
if (wsfCsNesting == 0)
{
fwrite(pBuf, len, 1, stdout);
return TRUE;
}
return FALSE;
}
/*************************************************************************************************/
/*!
* \brief Initialize WSF.
*
* \return None.
*/
/*************************************************************************************************/
static void WsfInit(void)
{
uint32_t bytesUsed;
/* setup the systick for 1MS timer*/
SysTick->LOAD = (SystemCoreClock / 1000) * WSF_MS_PER_TICK;
SysTick->VAL = 0;
SysTick->CTRL |= (SysTick_CTRL_CLKSOURCE_Msk | SysTick_CTRL_ENABLE_Msk | SysTick_CTRL_TICKINT_Msk);
WsfTimerInit();
SystemHeapStart = (uint32_t)&SystemHeap;
memset(SystemHeap, 0, sizeof(SystemHeap));
printf("SystemHeapStart = 0x%x\n", SystemHeapStart);
printf("SystemHeapSize = 0x%x\n", SystemHeapSize);
bytesUsed = WsfBufInit(WSF_BUF_POOLS, mainPoolDesc);
printf("bytesUsed = 0x%x\n", bytesUsed);
WsfTraceRegisterHandler(myTrace);
WsfTraceEnable(TRUE);
}
/*
* In two-chip solutions, setting the address must wait until the HCI interface is initialized.
* This handler can also catch other Application events, but none are currently implemented.
* See ble-profiles/sources/apps/app/common/app_ui.c for further details.
*
*/
void SetAddress(uint8_t event)
{
uint8_t bdAddr[6] = {0x02, 0x02, 0x44, 0x8B, 0x05, 0x00};
switch (event) {
case APP_UI_RESET_CMPL:
printf("Setting address -- MAC %02X:%02X:%02X:%02X:%02X:%02X\n", bdAddr[5], bdAddr[4], bdAddr[3], bdAddr[2], bdAddr[1], bdAddr[0]);
HciVsSetBdAddr(bdAddr);
break;
default:
break;
}
}
/*************************************************************************************************/
void HandleButton(int button)
{
mxc_tmr_regs_t* button_tmr = MXC_TMR_GET_TMR(button);
// Check if rising or falling
if(PB_Get(button)) {
// Start timer
TMR_Enable(button_tmr);
} else {
uint32_t time;
tmr_unit_t unit;
// Get the elapsed time since the button was pressed
TMR_GetTime(button_tmr, TMR_GetCount(button_tmr), &time, &unit);
TMR_Disable(button_tmr);
TMR_SetCount(button_tmr, 0);
if(unit == TMR_UNIT_NANOSEC) {
time /= 1000000;
} else if(unit == TMR_UNIT_MICROSEC) {
time /= 1000;
}
if(time < BUTTON_SHORT_MS) {
AppUiBtnTest(button ? APP_UI_BTN_2_SHORT : APP_UI_BTN_1_SHORT);
} else if (time < BUTTON_MED_MS) {
AppUiBtnTest(button ? APP_UI_BTN_2_MED : APP_UI_BTN_1_MED);
} else if (time < BUTTON_LONG_MS) {
AppUiBtnTest(button ? APP_UI_BTN_2_LONG : APP_UI_BTN_1_LONG);
} else {
AppUiBtnTest(button ? APP_UI_BTN_2_EX_LONG : APP_UI_BTN_1_EX_LONG);
}
}
}
/*************************************************************************************************/
void Button0Pressed(void* arg)
{
HandleButton(0);
}
/*************************************************************************************************/
void Button1Pressed(void* arg)
{
HandleButton(1);
}
/*************************************************************************************************/
/*!
* \fn main
*
* \brief Entry point for demo software.
*
* \param None.
*
* \return None.
*/
/*************************************************************************************************/
int main(void)
{
#ifndef __IAR_SYSTEMS_ICC__
setvbuf(stdout, printf_buffer, _IOLBF, PRINTF_BUF_SIZE);
#endif
printf("\n\n***** MAX32665 BLE Fitness Profile *****\n");
/* Initialize Radio */
WsfInit();
StackInitFit();
FitStart();
/* Setup pushbuttons and timers */
PB_RegisterRiseFallCallback(0, Button0Pressed);
PB_RegisterRiseFallCallback(1, Button1Pressed);
PB_IntEnable(0);
TMR_Init(BUTTON0_TMR, TMR_PRES_16, NULL);
TMR_Init(BUTTON1_TMR, TMR_PRES_16, NULL);
tmr_cfg_t button_config;
button_config.mode = TMR_MODE_CONTINUOUS;
TMR_Config(BUTTON0_TMR, &button_config);
TMR_Config(BUTTON1_TMR, &button_config);
/* Register a handler for Application events */
AppUiActionRegister(SetAddress);
printf("Setup Complete\n");
while (1)
{
wsfOsDispatcher();
}
}
/*****************************************************************/
void HardFault_Handler(void)
{
printf("\nFaultISR: CFSR %08X, BFAR %08x\n", (unsigned int)SCB->CFSR, (unsigned int)SCB->BFAR);
// Loop forever
while(1);
}
/*******************************************************************************
* Copyright (C) 2018 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.
*