diff --git a/card10-cross.ini b/card10-cross.ini index 04f103378b276ac7e8b8a47567781c2e75a72190..7208481c68e98f6253bbd8038b8188257b488257 100644 --- a/card10-cross.ini +++ b/card10-cross.ini @@ -4,11 +4,11 @@ ar = 'arm-none-eabi-ar' strip = 'arm-none-eabi-strip' [properties] -c_args = ['-mthumb', '-mcpu=cortex-m4', '-mfloat-abi=softfp', '-mfpu=fpv4-sp-d16', '-Wa,-mimplicit-it=thumb', '-ffunction-sections', '-fdata-sections', '-fsingle-precision-constant', '-fno-isolate-erroneous-paths-dereference', '-DWSF_TRACE_ENABLED=TRUE', '-DWSF_ASSERT_ENABLED=TRUE', '-DWSF_MS_PER_TICK=1', '-DINIT_BROADCASTER', '-DINIT_PERIPHERAL', '-DINIT_ENCRYPTED'] +c_args = ['-mthumb', '-mcpu=cortex-m4', '-mfloat-abi=softfp', '-mfpu=fpv4-sp-d16', '-Wa,-mimplicit-it=thumb', '-ffunction-sections', '-fdata-sections', '-fsingle-precision-constant', '-fno-isolate-erroneous-paths-dereference'] c_link_args = ['-mthumb', '-mcpu=cortex-m4', '-mfloat-abi=softfp', '-mfpu=fpv4-sp-d16', '-Wl,--start-group', '-lc', '-lnosys', '-Wl,--end-group', '--specs=nano.specs', '../lib/sdk/Libraries/BTLE/cordio-phy.a'] -target_defs = ['-DTARGET=32665', '-DTARGET_REV=0x4131', '-DBOARD_CARD10=1'] +target_defs = ['-DTARGET=32665', '-DTARGET_REV=0x4131', '-DBOARD_CARD10=1', '-DWSF_TRACE_ENABLED=TRUE', '-DWSF_ASSERT_ENABLED=TRUE', '-DWSF_MS_PER_TICK=1', '-DINIT_BROADCASTER', '-DINIT_PERIPHERAL', '-DINIT_ENCRYPTED'] [host_machine] system = 'none' diff --git a/epicardium/meson.build b/epicardium/meson.build index a3b06df61483023593f109c11c51d6abccdceb23..bf727f0715673fdf9e430ddd8685a777ac1c3b10 100644 --- a/epicardium/meson.build +++ b/epicardium/meson.build @@ -73,7 +73,6 @@ elf = executable( 'cdcacm.c', 'main.c', 'support.c', - 'stack_fit.c', module_sources, l0der_sources, dependencies: [libcard10, max32665_startup_core0, maxusb, libff13, ble], diff --git a/epicardium/modules/ble_stack_fit.c b/epicardium/modules/ble_stack_fit.c new file mode 100644 index 0000000000000000000000000000000000000000..cdbfe1217aeebe1f60a3cfb5111186c1c0aca053 --- /dev/null +++ b/epicardium/modules/ble_stack_fit.c @@ -0,0 +1,167 @@ +/*************************************************************************************************/ +/*! + * \file + * + * \brief Stack initialization for fit. + * + * Copyright (c) 2016-2017 ARM Ltd. All Rights Reserved. + * ARM Ltd. confidential and proprietary. + * + * IMPORTANT. Your use of this file is governed by a Software License Agreement + * ("Agreement") that must be accepted in order to download or otherwise receive a + * copy of this file. You may not use or copy this file for any purpose other than + * as described in the Agreement. If you do not agree to all of the terms of the + * Agreement do not use this file and delete all copies in your possession or control; + * if you do not have a copy of the Agreement, you must contact ARM Ltd. prior + * to any use, copying or further distribution of this software. + */ +/*************************************************************************************************/ + +#include <stdio.h> +#include <string.h> +#include "wsf_types.h" +#include "wsf_os.h" +#include "util/bstream.h" +#include "fit/fit_api.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 "app_api.h" +#include "svc_dis.h" +#include "svc_core.h" +#include "sec_api.h" +#include "ll_init_api.h" + +#define LL_IMPL_REV 0x2303 + +#define LL_MEMORY_FOOTPRINT 0xC152 + +uint8_t LlMem[LL_MEMORY_FOOTPRINT]; + +const LlRtCfg_t _ll_cfg = { + /* Device */ + /*compId*/ LL_COMP_ID_ARM, + /*implRev*/ LL_IMPL_REV, + /*btVer*/ LL_VER_BT_CORE_SPEC_5_0, + /*_align32 */ 0, // padding for alignment + + /* Advertiser */ + /*maxAdvSets*/ 4, // 4 Extended Advertising Sets + /*maxAdvReports*/ 8, + /*maxExtAdvDataLen*/ LL_MAX_ADV_DATA_LEN, + /*defExtAdvDataFrag*/ 64, + /*auxDelayUsec*/ 0, + + /* Scanner */ + /*maxScanReqRcvdEvt*/ 4, + /*maxExtScanDataLen*/ LL_MAX_ADV_DATA_LEN, + + /* Connection */ + /*maxConn*/ 2, + /*numTxBufs*/ 16, + /*numRxBufs*/ 16, + /*maxAclLen*/ 512, + /*defTxPwrLvl*/ 0, + /*ceJitterUsec*/ 0, + + /* DTM */ + /*dtmRxSyncMs*/ 10000, + + /* PHY */ + /*phy2mSup*/ TRUE, + /*phyCodedSup*/ TRUE, + /*stableModIdxTxSup*/ FALSE, + /*stableModIdxRxSup*/ FALSE +}; + +const BbRtCfg_t _bb_cfg = { + /*clkPpm*/ 20, + /*rfSetupDelayUsec*/ BB_RF_SETUP_DELAY_US, + /*maxScanPeriodMsec*/ BB_MAX_SCAN_PERIOD_MS, + /*schSetupDelayUsec*/ BB_SCH_SETUP_DELAY_US +}; + +/*************************************************************************************************/ +/*! + * \brief Initialize stack. + * + * \return None. + */ +/*************************************************************************************************/ +void StackInitFit(void) +{ + wsfHandlerId_t handlerId; + +#ifndef ENABLE_SDMA + uint32_t memUsed; + + /* Initialize link layer. */ + LlInitRtCfg_t ll_init_cfg = + { + .pBbRtCfg = &_bb_cfg, + .wlSizeCfg = 4, + .rlSizeCfg = 4, + .plSizeCfg = 4, + .pLlRtCfg = &_ll_cfg, + .pFreeMem = LlMem, + .freeMemAvail = LL_MEMORY_FOOTPRINT + }; + +#ifdef DATS_APP_USE_LEGACY_API + memUsed = LlInitControllerExtInit(&ll_init_cfg); +#else /* DATS_APP_USE_LEGACY_API */ + memUsed = LlInitControllerExtInit(&ll_init_cfg); +#endif /* DATS_APP_USE_LEGACY_API */ + if(memUsed != LL_MEMORY_FOOTPRINT) + { + printf("Controller memory mismatch 0x%x != 0x%x\n", memUsed, + LL_MEMORY_FOOTPRINT); + } +#endif + + handlerId = WsfOsSetNextHandler(HciHandler); + HciHandlerInit(handlerId); + + SecInit(); + SecAesInit(); + SecCmacInit(); + SecEccInit(); + + handlerId = WsfOsSetNextHandler(DmHandler); + DmDevVsInit(0); + DmAdvInit(); + DmConnInit(); + DmConnSlaveInit(); + DmSecInit(); + DmSecLescInit(); + DmPrivInit(); + DmPhyInit(); + DmHandlerInit(handlerId); + + handlerId = WsfOsSetNextHandler(L2cSlaveHandler); + L2cSlaveHandlerInit(handlerId); + L2cInit(); + L2cSlaveInit(); + + handlerId = WsfOsSetNextHandler(AttHandler); + AttHandlerInit(handlerId); + AttsInit(); + AttsIndInit(); + + handlerId = WsfOsSetNextHandler(SmpHandler); + SmpHandlerInit(handlerId); + SmprInit(); + SmprScInit(); + HciSetMaxRxAclLen(100); + + handlerId = WsfOsSetNextHandler(AppHandler); + AppHandlerInit(handlerId); + + handlerId = WsfOsSetNextHandler(FitHandler); + FitHandlerInit(handlerId); +} diff --git a/epicardium/modules/meson.build b/epicardium/modules/meson.build index 677d3f1e1c633bce74b28dda37a4e434d670d7a0..416ec428cb6e031569ad768d1eb05ea3b57a0045 100644 --- a/epicardium/modules/meson.build +++ b/epicardium/modules/meson.build @@ -10,5 +10,6 @@ module_sources = files( 'vibra.c', 'light_sensor.c', 'rtc.c', - 'ble.c' + 'ble.c', + 'ble_stack_fit.c' )