Commit 357a3f0a authored by schneider's avatar schneider
Browse files

Merge branch 'schneider/sdk-0.2.1-12' into 'master'

Update SDK to 0.2.1-12

See merge request card10/firmware!397
parents 64ea6680 4f1f5d0a
build/
/build/
/Documentation/output/
__pycache__/
*.pyc
......
......@@ -71,12 +71,6 @@ extern void bleFileTransfer_init(void);
extern void bleCard10_init(void);
extern void BbBleDrvSetTxPower(int8_t power);
/*************************************************************************************************/
void PalSysAssertTrap(void)
{
while (1) {
}
}
/*************************************************************************************************/
static bool_t myTrace(const uint8_t *pBuf, uint32_t len)
{
......
......@@ -84,13 +84,8 @@ int hardware_early_init(void)
PB_Init();
/* Enable 32 kHz output */
while (RTC_SquareWave(
MXC_RTC,
SQUARE_WAVE_ENABLED,
F_32KHZ,
NOISE_IMMUNE_MODE,
NULL) == E_BUSY
)
while (RTC_SquareWave(MXC_RTC, SQUARE_WAVE_ENABLED, F_32KHZ, NULL) ==
E_BUSY)
;
/* If we don't have a valid time yet, set it to 2019-01-01 */
......@@ -101,12 +96,11 @@ int hardware_early_init(void)
/*
* SPI for ECG
*/
const sys_cfg_spi_t spi17y_master_cfg = {
.map = MAP_A,
.ss0 = Enable,
.ss1 = Disable,
.ss2 = Disable,
};
const sys_cfg_spi_t spi17y_master_cfg = { .map = MAP_A,
.ss0 = Enable,
.ss1 = Disable,
.ss2 = Disable,
.num_io = 2 };
if (SPI_Init(SPI0, 0, SPI_SPEED, spi17y_master_cfg) != 0) {
LOG_ERR("init", "Error configuring SPI");
......
......@@ -8,6 +8,8 @@
#include "max86150.h"
#include "MAX77650-Arduino-Library.h"
#include "bb_drv.h"
#include "max32665.h"
#include "mxc_sys.h"
#include "mxc_pins.h"
......@@ -188,6 +190,7 @@ void sleep_deepsleep(void)
core1_stop();
MAX77650_getINT_GLBL();
gpio_low_power();
BbDrvDisable();
turnOffClocks();
old_clkcn = MXC_GCR->clkcn;
switchToHIRC();
......
......@@ -60,13 +60,8 @@ void card10_init(void)
TMR_Delay(MXC_TMR0, MSEC(1000), 0);
// Enable 32 kHz output
while (RTC_SquareWave(
MXC_RTC,
SQUARE_WAVE_ENABLED,
F_32KHZ,
NOISE_IMMUNE_MODE,
NULL) == E_BUSY
)
while (RTC_SquareWave(MXC_RTC, SQUARE_WAVE_ENABLED, F_32KHZ, NULL) ==
E_BUSY)
;
/* If we don't have a valid time yet, set it to 2019-01-01 */
if (RTC_GetSecond() < 1546300800L) {
......@@ -80,10 +75,11 @@ void card10_init(void)
// Enable SPI
sys_cfg_spi_t spi17y_master_cfg;
spi17y_master_cfg.map = MAP_A;
spi17y_master_cfg.ss0 = Enable;
spi17y_master_cfg.ss1 = Disable;
spi17y_master_cfg.ss2 = Disable;
spi17y_master_cfg.map = MAP_A;
spi17y_master_cfg.ss0 = Enable;
spi17y_master_cfg.ss1 = Disable;
spi17y_master_cfg.ss2 = Disable;
spi17y_master_cfg.num_io = 2;
if (SPI_Init(SPI0, 0, SPI_SPEED, spi17y_master_cfg) != 0) {
printf("Error configuring SPI\n");
while (1)
......
......@@ -51,10 +51,11 @@ void lcd_write(uint8_t *data, int size)
{
sys_cfg_spi_t spi17y_master_cfg;
spi17y_master_cfg.map = MAP_A;
spi17y_master_cfg.ss0 = Enable;
spi17y_master_cfg.ss1 = Disable;
spi17y_master_cfg.ss2 = Disable;
spi17y_master_cfg.map = MAP_A;
spi17y_master_cfg.ss0 = Enable;
spi17y_master_cfg.ss1 = Disable;
spi17y_master_cfg.ss2 = Disable;
spi17y_master_cfg.num_io = 2;
if (SPI_Init(SPI2, 0, SPI_SPEED, spi17y_master_cfg) != 0) {
printf("Error configuring SPI\n");
while (1)
......
......@@ -188,6 +188,26 @@ $(error SDMA currently requires BTLE_APP_USE_LEGACY_API)
endif
endif
ifdef ENABLE_SDMA_UNIFIED_CONFIG
ifneq "$(ENABLE_SDMA_UNIFIED_CONFIG)" ""
ifeq "$(ENABLE_SDMA_UNIFIED_CONFIG)" "0"
ENABLE_SDMA_UNIFIED_CONFIG=
else
ifeq "$(ENABLE_SDMA_UNIFIED_CONFIG)" "FALSE"
ENABLE_SDMA_UNIFIED_CONFIG=
else
ENABLE_SDMA_UNIFIED_CONFIG=1
endif
endif
endif
endif
ifdef ENABLE_SDMA_UNIFIED_CONFIG
ifneq "$(ENABLE_SDMA_UNIFIED_CONFIG)" "0"
PROJ_CFLAGS+=-DENABLE_SDMA_UNIFIED_CONFIG=1
endif
endif
#-------------------------------------------------------------------------------
# Configuration specified here.
......@@ -199,7 +219,6 @@ PROJ_CFLAGS+=-DMXC_ASSERT_ENABLE=TRUE
PROJ_CFLAGS+=-DWSF_ASSERT_ENABLED=TRUE
# PROJ_CFLAGS+=-DLL_TRACE_ENABLED=TRUE
# PROJ_CFLAGS+=-DLL_DBG_PIN_ENABLED=TRUE
PROJ_CFLAGS+=-DWSF_MS_PER_TICK=1
#--------------------
......@@ -213,6 +232,7 @@ PROJ_CFLAGS+=-DINIT_BROADCASTER
# PROJ_CFLAGS+=-DINIT_CENTRAL
PROJ_CFLAGS+=-DINIT_PERIPHERAL
PROJ_CFLAGS+=-DINIT_ENCRYPTED
PROJ_CFLAGS+=-DINIT_PHY
ENABLE_LL_TESTER?=#1
......@@ -239,10 +259,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.
......
## Application description
The BLE\_beacon application demonstrates a BLE beacon device that can not accept connections.
......@@ -11,9 +11,14 @@ BTLE_APP_ENABLE_PERIODIC?=0
# Unspecified -> Use default (connectable).
# DM_ADV_SCAN_UNDIRECT -> Non-connectable scannable
# DM_ADV_NONCONN_UNDIRECT -> Non-connectable non-scannable
BTLE_APP_ADV_TYPE?=
#BTLE_APP_ADV_TYPE?=
#BTLE_APP_ADV_TYPE?=DM_ADV_NONCONN_UNDIRECT
#BTLE_APP_ADV_TYPE?=DM_ADV_SCAN_UNDIRECT
BTLE_APP_ADV_TYPE?=DM_ADV_SCAN_UNDIRECT
# Run link layer using SDMA.
ENABLE_SDMA?=0
# Copy sdma config from application.
ENABLE_SDMA_UNIFIED_CONFIG?=1
......@@ -29,14 +29,16 @@
* 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: 2020-09-01 12:32:30 -0500 (Tue, 01 Sep 2020) $
* $Revision: 55172 $
*
******************************************************************************/
#include <stdio.h>
#include <string.h>
#include <ctype.h>
#include "mxc_config.h"
#include "mxc_sys.h"
#include "wsf_types.h"
#include "wsf_os.h"
#include "wsf_buf.h"
......@@ -47,6 +49,9 @@
#include "app_ui.h"
#include "hci_vs.h"
#include "hci_core.h"
#include "hci_drv_sdma.h"
#include "ipc_defs.h"
#include "dm_api.h"
/**************************************************************************************************
Macros
......@@ -88,16 +93,10 @@ static wsfBufPoolDesc_t mainPoolDesc[WSF_BUF_POOLS] =
/*! \brief Stack initialization for app. */
extern void StackInitBeacon(void);
/*************************************************************************************************/
void PalSysAssertTrap(void)
{
while(1) {}
}
/*************************************************************************************************/
void SysTick_Handler(void)
{
WsfTimerUpdate(1);
WsfTimerUpdate(WSF_MS_PER_TICK);
}
/*************************************************************************************************/
......@@ -150,12 +149,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;
......@@ -175,6 +202,9 @@ void SetAddress(uint8_t event)
/*************************************************************************************************/
int main(void)
{
#ifdef ENABLE_SDMA
uint8_t sdmaFlag;
#endif /* ENABLE_SDMA */
#ifndef __IAR_SYSTEMS_ICC__
setvbuf(stdout, printf_buffer, _IOLBF, PRINTF_BUF_SIZE);
......@@ -192,9 +222,22 @@ int main(void)
printf("Setup Complete\n");
#ifdef ENABLE_SDMA
sdmaFlag = SDMA_FLAG_INIT;
#endif /* ENABLE_SDMA */
while (1)
{
wsfOsDispatcher();
#ifdef ENABLE_SDMA
if (sdmaFlag == SDMA_FLAG_INIT) {
sdmaFlag = SDMAGetSDMAFlag();
}
if (sdmaFlag == SDMA_FLAG_ENOMEM) {
printf ("SDMA core ran out of allocatable memory.");
while(1);
}
#endif /* ENABLE_SDMA */
}
}
......
......@@ -37,6 +37,7 @@
#include "svc_core.h"
#include "sec_api.h"
#include "ll_init_api.h"
#include "hci_drv_sdma.h"
#define LL_IMPL_REV 0x2303
......@@ -51,9 +52,13 @@ const LlRtCfg_t _ll_cfg = {
/*btVer*/ LL_VER_BT_CORE_SPEC_5_0,
/*_align32 */ 0, // padding for alignment
/* Advertiser */
#ifdef ENABLE_SDMA
/*maxAdvSets*/ 2, // 1 Extended Advertising Set
/*maxAdvReports*/ 2,
#else /* ENABLE_SDMA */
/*maxAdvSets*/ 4, // 4 Extended Advertising Sets
/*maxAdvReports*/ 8,
#endif /* ENABLE_SDMA */
/*maxExtAdvDataLen*/ LL_MAX_ADV_DATA_LEN,
/*defExtAdvDataFrag*/ 64,
/*auxDelayUsec*/ 0,
......@@ -63,10 +68,17 @@ const LlRtCfg_t _ll_cfg = {
/*maxExtScanDataLen*/ LL_MAX_ADV_DATA_LEN,
/* Connection */
#ifdef ENABLE_SDMA
/*maxConn*/ 4,
/*numTxBufs*/ 4,
/*numRxBufs*/ 4,
/*maxAclLen*/ 150,
#else /* ENABLE_SDMA */
/*maxConn*/ 2,
/*numTxBufs*/ 16,
/*numRxBufs*/ 16,
/*maxAclLen*/ 512,
#endif /* ENABLE_SDMA */
/*defTxPwrLvl*/ 0,
/*ceJitterUsec*/ 0,
......@@ -75,7 +87,11 @@ const LlRtCfg_t _ll_cfg = {
/* PHY */
/*phy2mSup*/ TRUE,
#ifdef ENABLE_SDMA
/*phyCodedSup*/ FALSE,
#else /* ENABLE_SDMA */
/*phyCodedSup*/ TRUE,
#endif /* ENABLE_SDMA */
/*stableModIdxTxSup*/ FALSE,
/*stableModIdxRxSup*/ FALSE
};
......@@ -120,7 +136,13 @@ void StackInitBeacon(void)
printf("mem_used: 0x%x LL_MEMORY_FOOTPRINT: 0x%x\n", memUsed,
LL_MEMORY_FOOTPRINT);
}
#endif
#endif /* ENABLE_SDMA */
#ifdef ENABLE_SDMA
/* Copy link layer configuration to sdma memory space. */
SDMASetBBCfg(&_bb_cfg);
SDMASetLLCfg(&_ll_cfg);
#endif /* ENABLE_SDMA */
handlerId = WsfOsSetNextHandler(HciHandler);
HciHandlerInit(handlerId);
......
......@@ -43,6 +43,12 @@ ifeq "$(PROJECT)" ""
PROJECT=max32665
endif
# Build directory for image that peer will be udpated with
FW_UPDATE_DIR=../BLE_dats
# Firmware update files, do not rename
FW_UPDATE_BIN=fw_update.bin
# Specify the target processor
ifeq "$(TARGET)" ""
TARGET=MAX32665
......@@ -72,6 +78,7 @@ endif
# 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)
endif
......@@ -176,6 +183,30 @@ PROJ_CFLAGS+=-DCONSOLE_UART=$(CONSOLE_UART)
endif
endif
ifdef ENABLE_WDX
ifneq "$(ENABLE_WDX)" ""
ifneq "$(ENABLE_WDX)" "0"
PROJ_CFLAGS+=-DWDXC_INCLUDED=TRUE
PROJ_CFLAGS+=-DWDXS_INCLUDED=TRUE
# PROJ_CFLAGS+=-DWSF_TRACE_ENABLED=TRUE
# Include bin file for firmware update image
BINS+=${FW_UPDATE_BIN}
# Target for creating the fw_update bin file
${FW_UPDATE_BIN}:
$(MAKE) -C ${FW_UPDATE_DIR}
$(MAKE) -C ${FW_UPDATE_DIR} build/${PROJECT}.bin
@cp ${FW_UPDATE_DIR}/build/${PROJECT}.bin ${FW_UPDATE_BIN}
myclean:
@rm -f ${FW_UPDATE_BIN}
clean: myclean
endif
endif
endif
ifdef ENABLE_SDMA
ifneq "$(ENABLE_SDMA)" ""
ifeq "$(ENABLE_SDMA)" "0"
......@@ -203,6 +234,26 @@ endif
endif
endif
ifdef ENABLE_SDMA_UNIFIED_CONFIG
ifneq "$(ENABLE_SDMA_UNIFIED_CONFIG)" ""
ifeq "$(ENABLE_SDMA_UNIFIED_CONFIG)" "0"
ENABLE_SDMA_UNIFIED_CONFIG=
else
ifeq "$(ENABLE_SDMA_UNIFIED_CONFIG)" "FALSE"
ENABLE_SDMA_UNIFIED_CONFIG=
else
ENABLE_SDMA_UNIFIED_CONFIG=1
endif
endif
endif
endif
ifdef ENABLE_SDMA_UNIFIED_CONFIG
ifneq "$(ENABLE_SDMA_UNIFIED_CONFIG)" "0"
PROJ_CFLAGS+=-DENABLE_SDMA_UNIFIED_CONFIG=1
endif
endif
#-------------------------------------------------------------------------------
# Configuration specified here.
......@@ -214,7 +265,6 @@ PROJ_CFLAGS+=-DMXC_ASSERT_ENABLE=TRUE
PROJ_CFLAGS+=-DWSF_ASSERT_ENABLED=TRUE
# PROJ_CFLAGS+=-DLL_TRACE_ENABLED=TRUE
# PROJ_CFLAGS+=-DLL_DBG_PIN_ENABLED=TRUE
PROJ_CFLAGS+=-DWSF_MS_PER_TICK=1
#--------------------
......@@ -228,6 +278,7 @@ PROJ_CFLAGS+=-DINIT_OBSERVER
PROJ_CFLAGS+=-DINIT_CENTRAL
# PROJ_CFLAGS+=-DINIT_PERIPHERAL
PROJ_CFLAGS+=-DINIT_ENCRYPTED
PROJ_CFLAGS+=-DINIT_PHY
ENABLE_LL_TESTER?=#1
......@@ -254,10 +305,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.
......
## Application description
The BLE\_datc application demonstrates a BLE central device that can connect to another device running the BLE\_dats application.
......@@ -15,3 +15,9 @@ BTLE_APP_ENABLE_WHITELIST?=0
# Run link layer using SDMA.
ENABLE_SDMA?=0
# Copy sdma config from application.
ENABLE_SDMA_UNIFIED_CONFIG?=1
# Enable file transfer profile
ENABLE_WDX?=0
......@@ -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"
......@@ -37,10 +38,20 @@
#include "app_ui.h"
#include "svc_core.h"
#include "svc_ch.h"
#include "hci_vs.h"
#include "gatt/gatt_api.h"
#include "wpc/wpc_api.h"
#include "datc/datc_api.h"
#include "util/calc128.h"
#include "gcr_regs.h"
#include "ll_defs.h"
#include "tmr_utils.h"
#if WDXC_INCLUDED == TRUE
#include "wsf_efs.h"
#include "wdxc/wdxc_api.h"
#include "wdx_defs.h"
#include "hash.h"
#endif /* WDXC_INCLUDED */
/**************************************************************************************************
Macros
......@@ -48,6 +59,37 @@ Macros
#define TEST_TIMER_IND 0x99
#if WDXC_INCLUDED == TRUE
/* Size of WDXC file discovery dataset */
#define DATC_WDXC_MAX_FILES 4
/*! WSF message event starting value */
#define DATC_MSG_START 0xA0
/*! Data rate timer period in seconds */
#define DATC_WDXS_DATA_RATE_TIMEOUT 4
/* Pointer for accessing the fw_update image*/
uint8_t *fileData;
extern uint32_t _binary_fw_update_bin_start;
extern uint32_t _binary_fw_update_bin_end;
extern uint32_t _binary_fw_update_bin_size;
#define FILE_SIZE (uint32_t)&_binary_fw_update_bin_size
#define BLOCK_OFFSET_INIT 0x0
#define BLOCK_SIZE 224
#define SHA256_BYTES (256/8)
char fileHashDigest[SHA256_BYTES];
/*! WSF message event enumeration */
enum
{
DATC_WDXS_DATA_RATE_TIMER_IND = DATC_MSG_START, /*! Data rate timer expired */
};
#endif /* WDXC_INCLUDED */
/**************************************************************************************************
Local Variables
**************************************************************************************************/
......@@ -61,6 +103,13 @@ struct
bool_t autoConnectSync; /*! TRUE if auto-connecting */
uint8_t discState[DM_CONN_MAX]; /*! Service discovery state */
uint8_t hdlListLen; /*! Cached handle list length */
uint8_t btnConnId; /*! The index of the connection ID for button presses */
#if WDXC_INCLUDED == TRUE
bool_t sendingFile[DM_CONN_MAX];
bool_t fileVerified[DM_CONN_MAX];
uint32_t blockOffset[DM_CONN_MAX];
wsfEfsFileInfo_t fileList[DM_CONN_MAX][DATC_WDXC_MAX_FILES]; /* Buffer to hold WDXC file list */
#endif /* WDXC_INCLUDED */
} datcCb;
/*! connection control block */
......@@ -204,7 +253,7 @@ static const hciConnSpec_t datcConnCfg =
0, /*! Connection latency */
600, /*! Supervision timeout in 10ms units */
0, /*! Minimum CE length, in 0.625 ms units */
16 /*! Maximum CE length, in 0.625 ms units */
0 /*! Maximum CE length, in 0.625 ms units */
};
/*! Configurable parameters for service and characteristic discovery */
......@@ -223,8 +272,12 @@ static const appCfg_t datcAppCfg =
static const attCfg_t datcAttCfg =
{
15, /* ATT server service discovery connection idle timeout in seconds */
300, /* desired ATT MTU */
ATT_MAX_TRANS_TIMEOUT, /* transaction timeout in seconds */
#if WDXC_INCLUDED == TRUE
241, /* desired ATT MTU */
#else
23, /* desired ATT MTU */
#endif /* WDXC_INCLUDED */
ATT_MAX_TRANS_TIMEOUT, /* transcation timeout in seconds */
4 /* number of queued prepare writes supported by server */
};
......@@ -244,6 +297,9 @@ enum
DATC_DISC_GATT_SVC, /*! GATT service */
DATC_DISC_GAP_SVC, /*! GAP service */
DATC_DISC_WP_SVC, /*! ARM Ltd. proprietary service */
#if WDXC_INCLUDED == TRUE
DATC_DISC_WDXC_SCV, /*! ARM Ltd. Wireless Data Exchange service */