Skip to content

Commit

Permalink
Modified ME14 examples with WsfHeap updates
Browse files Browse the repository at this point in the history
  • Loading branch information
crsz20 committed Sep 27, 2024
1 parent d34b408 commit 6605515
Show file tree
Hide file tree
Showing 12 changed files with 394 additions and 149 deletions.
8 changes: 1 addition & 7 deletions Examples/MAX32665/Bluetooth/BLE4_ctr/main.c
Original file line number Diff line number Diff line change
Expand Up @@ -124,13 +124,7 @@ static void mainWsfInit(void)
.freeMemAvail = WsfHeapCountAvailable()
};

llmemUsed = LlInitSetBbRtCfg(llCfg.pBbRtCfg, llCfg.wlSizeCfg, llCfg.rlSizeCfg, llCfg.plSizeCfg,
llCfg.pFreeMem, llCfg.freeMemAvail);

llCfg.pFreeMem += llmemUsed;
llCfg.freeMemAvail -= llmemUsed;

llmemUsed += LlInitSetLlRtCfg(llCfg.pLlRtCfg, llCfg.pFreeMem, llCfg.freeMemAvail);
llmemUsed = LlInitSetRtCfg(&llCfg);

WsfCsExit();

Expand Down
8 changes: 1 addition & 7 deletions Examples/MAX32665/Bluetooth/BLE5_ctr/main.c
Original file line number Diff line number Diff line change
Expand Up @@ -156,13 +156,7 @@ static void mainWsfInit(void)
.freeMemAvail = WsfHeapCountAvailable()
};

llmemUsed = LlInitSetBbRtCfg(llCfg.pBbRtCfg, llCfg.wlSizeCfg, llCfg.rlSizeCfg, llCfg.plSizeCfg,
llCfg.pFreeMem, llCfg.freeMemAvail);

llCfg.pFreeMem += llmemUsed;
llCfg.freeMemAvail -= llmemUsed;

llmemUsed += LlInitSetLlRtCfg(llCfg.pLlRtCfg, llCfg.pFreeMem, llCfg.freeMemAvail);
llmemUsed = LlInitSetRtCfg(&llCfg);

WsfCsExit();

Expand Down
55 changes: 41 additions & 14 deletions Examples/MAX32665/Bluetooth/BLE_FreeRTOS/stack_dats.c
Original file line number Diff line number Diff line change
Expand Up @@ -176,9 +176,11 @@ static void mainWsfInit(void)
const uint8_t numPools = sizeof(mainPoolDesc) / sizeof(mainPoolDesc[0]);

uint16_t memUsed;
/* Initial buffer configuration. */
WsfCsEnter();
memUsed = WsfBufInit(numPools, mainPoolDesc);
memUsed = WsfBufCalcSize(numPools, mainPoolDesc);
WsfHeapAlloc(memUsed);
WsfBufInit(numPools, mainPoolDesc);
WsfCsExit();

WsfOsInit();
Expand Down Expand Up @@ -360,27 +362,52 @@ void bleStartup(void)
mainLlRtCfg.defTxPwrLvl = DEFAULT_TX_POWER;
#endif

uint32_t memUsed;
WsfCsEnter();
memUsed = WsfBufIoUartInit(WsfHeapGetFreeStartAddress(), PLATFORM_UART_TERMINAL_BUFFER_SIZE);
WsfHeapAlloc(memUsed);
WsfHeapAlloc(PLATFORM_UART_TERMINAL_BUFFER_SIZE);
WsfBufIoUartInit(WsfHeapGetFreeStartAddress(), PLATFORM_UART_TERMINAL_BUFFER_SIZE);
WsfCsExit();

mainWsfInit();
AppTerminalInit();

#if defined(HCI_TR_EXACTLE) && (HCI_TR_EXACTLE == 1)
uint32_t llmemUsed;

/* Calculate how much memory we will need for the LL initialization */
WsfCsEnter();
LlInitRtCfg_t llCfg = { .pBbRtCfg = &mainBbRtCfg,
.wlSizeCfg = 4,
.rlSizeCfg = 4,
.plSizeCfg = 4,
.pLlRtCfg = &mainLlRtCfg,
.pFreeMem = WsfHeapGetFreeStartAddress(),
.freeMemAvail = WsfHeapCountAvailable() };

memUsed = LlInit(&llCfg);
WsfHeapAlloc(memUsed);

WsfTraceEnable(FALSE);

LlInitRtCfg_t llCfg = {
.pBbRtCfg = &mainBbRtCfg,
.wlSizeCfg = 4,
.rlSizeCfg = 4,
.plSizeCfg = 4,
.pLlRtCfg = &mainLlRtCfg,
/* Not significant yet, only being used for memory size requirement calculation. */
.pFreeMem = WsfHeapGetFreeStartAddress(),
/* Not significant yet, only being used for memory size requirement calculation. */
.freeMemAvail = WsfHeapCountAvailable()
};

llmemUsed = LlInitSetRtCfg(&llCfg);

/* Allocate the memory */
WsfHeapAlloc(llmemUsed);

/* Set the free memory pointers */
llCfg.pFreeMem = WsfHeapGetFreeStartAddress();
llCfg.freeMemAvail = WsfHeapCountAvailable();

#if (WSF_TOKEN_ENABLED == TRUE) || (WSF_TRACE_ENABLED == TRUE)
WsfTraceEnable(TRUE);
#endif

/* Run the initialization with properly set the free memory pointers */
if (llmemUsed != LlInitControllerInit(&llCfg)) {
WSF_ASSERT(0);
}

WsfCsExit();

bdAddr_t bdAddr;
Expand Down
58 changes: 44 additions & 14 deletions Examples/MAX32665/Bluetooth/BLE_datc/main.c
Original file line number Diff line number Diff line change
Expand Up @@ -117,9 +117,11 @@ static void mainWsfInit(void)
const uint8_t numPools = sizeof(mainPoolDesc) / sizeof(mainPoolDesc[0]);

uint16_t memUsed;
/* Initial buffer configuration. */
WsfCsEnter();
memUsed = WsfBufInit(numPools, mainPoolDesc);
memUsed = WsfBufCalcSize(numPools, mainPoolDesc);
WsfHeapAlloc(memUsed);
WsfBufInit(numPools, mainPoolDesc);
WsfCsExit();

WsfOsInit();
Expand Down Expand Up @@ -230,27 +232,55 @@ int main(void)
mainLlRtCfg.defTxPwrLvl = DEFAULT_TX_POWER;
#endif

uint32_t memUsed;
WsfCsEnter();
memUsed = WsfBufIoUartInit(WsfHeapGetFreeStartAddress(), PLATFORM_UART_TERMINAL_BUFFER_SIZE);
WsfHeapAlloc(memUsed);
WsfHeapAlloc(PLATFORM_UART_TERMINAL_BUFFER_SIZE);
WsfBufIoUartInit(WsfHeapGetFreeStartAddress(), PLATFORM_UART_TERMINAL_BUFFER_SIZE);
WsfCsExit();

mainWsfInit();
AppTerminalInit();

#if defined(HCI_TR_EXACTLE) && (HCI_TR_EXACTLE == 1)

uint32_t llmemUsed;

/* Calculate how much memory we will need for the LL initialization */
WsfCsEnter();
LlInitRtCfg_t llCfg = { .pBbRtCfg = &mainBbRtCfg,
.wlSizeCfg = 4,
.rlSizeCfg = 4,
.plSizeCfg = 4,
.pLlRtCfg = &mainLlRtCfg,
.pFreeMem = WsfHeapGetFreeStartAddress(),
.freeMemAvail = WsfHeapCountAvailable() };

memUsed = LlInit(&llCfg);
WsfHeapAlloc(memUsed);

WsfTraceEnable(FALSE);

LlInitRtCfg_t llCfg = {
.pBbRtCfg = &mainBbRtCfg,
.wlSizeCfg = 4,
.rlSizeCfg = 4,
.plSizeCfg = 4,
.pLlRtCfg = &mainLlRtCfg,
/* Not significant yet, only being used for memory size requirement calculation. */
.pFreeMem = WsfHeapGetFreeStartAddress(),
/* Not significant yet, only being used for memory size requirement calculation. */
.freeMemAvail = WsfHeapCountAvailable()
};

llmemUsed = LlInitSetRtCfg(&llCfg);


#if (WSF_TOKEN_ENABLED == TRUE) || (WSF_TRACE_ENABLED == TRUE)
WsfTraceEnable(TRUE);
#endif

/* Complete the LL initialization */
/* Allocate the memory */
WsfHeapAlloc(llmemUsed);

/* Set the free memory pointers */
llCfg.pFreeMem = WsfHeapGetFreeStartAddress();
llCfg.freeMemAvail = WsfHeapCountAvailable();

/* Run the initialization with properly set the free memory pointers */
if (llmemUsed != LlInit(&llCfg)) {
WSF_ASSERT(0);
}

WsfCsExit();

bdAddr_t bdAddr;
Expand Down
56 changes: 42 additions & 14 deletions Examples/MAX32665/Bluetooth/BLE_dats/main.c
Original file line number Diff line number Diff line change
Expand Up @@ -117,9 +117,11 @@ static void mainWsfInit(void)
const uint8_t numPools = sizeof(mainPoolDesc) / sizeof(mainPoolDesc[0]);

uint16_t memUsed;
/* Initial buffer configuration. */
WsfCsEnter();
memUsed = WsfBufInit(numPools, mainPoolDesc);
memUsed = WsfBufCalcSize(numPools, mainPoolDesc);
WsfHeapAlloc(memUsed);
WsfBufInit(numPools, mainPoolDesc);
WsfCsExit();

WsfOsInit();
Expand Down Expand Up @@ -226,28 +228,54 @@ int main(void)
mainLlRtCfg.defTxPwrLvl = DEFAULT_TX_POWER;
#endif

uint32_t memUsed;
WsfCsEnter();
memUsed = WsfBufIoUartInit(WsfHeapGetFreeStartAddress(), PLATFORM_UART_TERMINAL_BUFFER_SIZE);
WsfHeapAlloc(memUsed);
WsfHeapAlloc(PLATFORM_UART_TERMINAL_BUFFER_SIZE);
WsfBufIoUartInit(WsfHeapGetFreeStartAddress(), PLATFORM_UART_TERMINAL_BUFFER_SIZE);
WsfCsExit();

mainWsfInit();
AppTerminalInit();

#if defined(HCI_TR_EXACTLE) && (HCI_TR_EXACTLE == 1)

uint32_t llmemUsed;

/* Calculate how much memory we will need for the LL initialization */
WsfCsEnter();
LlInitRtCfg_t llCfg = { .pBbRtCfg = &mainBbRtCfg,
.wlSizeCfg = 4,
.rlSizeCfg = 4,
.plSizeCfg = 4,
.pLlRtCfg = &mainLlRtCfg,
.pFreeMem = WsfHeapGetFreeStartAddress(),
.freeMemAvail = WsfHeapCountAvailable() };

memUsed = LlInit(&llCfg);
WsfHeapAlloc(memUsed);

WsfTraceEnable(FALSE);

LlInitRtCfg_t llCfg = {
.pBbRtCfg = &mainBbRtCfg,
.wlSizeCfg = 4,
.rlSizeCfg = 4,
.plSizeCfg = 4,
.pLlRtCfg = &mainLlRtCfg,
/* Not significant yet, only being used for memory size requirement calculation. */
.pFreeMem = WsfHeapGetFreeStartAddress(),
/* Not significant yet, only being used for memory size requirement calculation. */
.freeMemAvail = WsfHeapCountAvailable()
};

llmemUsed = LlInitSetRtCfg(&llCfg);

#if (WSF_TOKEN_ENABLED == TRUE) || (WSF_TRACE_ENABLED == TRUE)
WsfTraceEnable(TRUE);
#endif

/* Complete the LL initialization */
/* Allocate the memory */
WsfHeapAlloc(llmemUsed);

/* Set the free memory pointers */
llCfg.pFreeMem = WsfHeapGetFreeStartAddress();
llCfg.freeMemAvail = WsfHeapCountAvailable();

/* Run the initialization with properly set the free memory pointers */
if (llmemUsed != LlInit(&llCfg)) {
WSF_ASSERT(0);
}

WsfCsExit();

bdAddr_t bdAddr;
Expand Down
59 changes: 44 additions & 15 deletions Examples/MAX32665/Bluetooth/BLE_fit/main.c
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
Expand Down Expand Up @@ -117,9 +117,11 @@ static void mainWsfInit(void)
const uint8_t numPools = sizeof(mainPoolDesc) / sizeof(mainPoolDesc[0]);

uint16_t memUsed;
/* Initial buffer configuration. */
WsfCsEnter();
memUsed = WsfBufInit(numPools, mainPoolDesc);
memUsed = WsfBufCalcSize(numPools, mainPoolDesc);
WsfHeapAlloc(memUsed);
WsfBufInit(numPools, mainPoolDesc);
WsfCsExit();

WsfOsInit();
Expand Down Expand Up @@ -225,27 +227,54 @@ int main(void)
mainLlRtCfg.defTxPwrLvl = DEFAULT_TX_POWER;
#endif

uint32_t memUsed;
WsfCsEnter();
memUsed = WsfBufIoUartInit(WsfHeapGetFreeStartAddress(), PLATFORM_UART_TERMINAL_BUFFER_SIZE);
WsfHeapAlloc(memUsed);
WsfHeapAlloc(PLATFORM_UART_TERMINAL_BUFFER_SIZE);
WsfBufIoUartInit(WsfHeapGetFreeStartAddress(), PLATFORM_UART_TERMINAL_BUFFER_SIZE);
WsfCsExit();

mainWsfInit();
AppTerminalInit();

#if defined(HCI_TR_EXACTLE) && (HCI_TR_EXACTLE == 1)

uint32_t llmemUsed;

/* Calculate how much memory we will need for the LL initialization */
WsfCsEnter();
LlInitRtCfg_t llCfg = { .pBbRtCfg = &mainBbRtCfg,
.wlSizeCfg = 4,
.rlSizeCfg = 4,
.plSizeCfg = 4,
.pLlRtCfg = &mainLlRtCfg,
.pFreeMem = WsfHeapGetFreeStartAddress(),
.freeMemAvail = WsfHeapCountAvailable() };

memUsed = LlInit(&llCfg);
WsfHeapAlloc(memUsed);

WsfTraceEnable(FALSE);

LlInitRtCfg_t llCfg = {
.pBbRtCfg = &mainBbRtCfg,
.wlSizeCfg = 4,
.rlSizeCfg = 4,
.plSizeCfg = 4,
.pLlRtCfg = &mainLlRtCfg,
/* Not significant yet, only being used for memory size requirement calculation. */
.pFreeMem = WsfHeapGetFreeStartAddress(),
/* Not significant yet, only being used for memory size requirement calculation. */
.freeMemAvail = WsfHeapCountAvailable()
};

llmemUsed = LlInitSetRtCfg(&llCfg);

#if (WSF_TOKEN_ENABLED == TRUE) || (WSF_TRACE_ENABLED == TRUE)
WsfTraceEnable(TRUE);
#endif

/* Complete the LL initialization */
/* Allocate the memory */
WsfHeapAlloc(llmemUsed);

/* Set the free memory pointers */
llCfg.pFreeMem = WsfHeapGetFreeStartAddress();
llCfg.freeMemAvail = WsfHeapCountAvailable();

/* Run the initialization with properly set the free memory pointers */
if (llmemUsed != LlInit(&llCfg)) {
WSF_ASSERT(0);
}

WsfCsExit();

bdAddr_t bdAddr;
Expand Down
Loading

0 comments on commit 6605515

Please sign in to comment.