Skip to content

Commit ecb6c27

Browse files
committed
connectivity_framework: adapt wireless_mcu code for zephyr support
Remove unnecessary dependencies and not applicable features. Signed-off-by: Axel Le Bourhis <axel.lebourhis@nxp.com>
1 parent 31275d7 commit ecb6c27

File tree

9 files changed

+32
-661
lines changed

9 files changed

+32
-661
lines changed

mcux/middleware/mcux-sdk-middleware-connectivity-framework/platform/kw45_k32w1_mcxw71/configs/fwk_config.h

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -166,7 +166,7 @@
166166
* in non secure mode.
167167
* */
168168
#if !defined(gPlatformNbuDebugGpioDAccessEnabled_d)
169-
#define gPlatformNbuDebugGpioDAccessEnabled_d 1
169+
#define gPlatformNbuDebugGpioDAccessEnabled_d 0
170170
#endif
171171

172172
/*********************************************************************
@@ -179,7 +179,7 @@
179179
* thread stack (this can be configured).
180180
*/
181181
#ifndef gPlatformIcsUseWorkqueueRxProcessing_d
182-
#define gPlatformIcsUseWorkqueueRxProcessing_d 1
182+
#define gPlatformIcsUseWorkqueueRxProcessing_d 0
183183
#endif
184184

185185
#endif /* _FWK_CONFIG_H_ */

mcux/middleware/mcux-sdk-middleware-connectivity-framework/platform/kw47_mcxw72/configs/fwk_config.h

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -167,7 +167,7 @@
167167
* in non secure mode.
168168
* */
169169
#if !defined(gPlatformNbuDebugGpioDAccessEnabled_d)
170-
#define gPlatformNbuDebugGpioDAccessEnabled_d 1
170+
#define gPlatformNbuDebugGpioDAccessEnabled_d 0
171171
#endif
172172

173173
/*********************************************************************
@@ -180,7 +180,7 @@
180180
* thread stack (this can be configured).
181181
*/
182182
#ifndef gPlatformIcsUseWorkqueueRxProcessing_d
183-
#define gPlatformIcsUseWorkqueueRxProcessing_d 1
183+
#define gPlatformIcsUseWorkqueueRxProcessing_d 0
184184
#endif
185185

186186
#endif /* _FWK_CONFIG_H_ */

mcux/middleware/mcux-sdk-middleware-connectivity-framework/platform/wireless_mcu/fwk_platform.c

Lines changed: 4 additions & 169 deletions
Original file line numberDiff line numberDiff line change
@@ -7,9 +7,7 @@
77
/* -------------------------------------------------------------------------- */
88
/* Includes */
99
/* -------------------------------------------------------------------------- */
10-
11-
/* Get some BOARD_***_DEFAULT macro values if defined in board.h for 32kHz settings */
12-
#include "board_platform.h"
10+
#include "fsl_os_abstraction.h"
1311

1412
#include "fwk_platform.h"
1513
#include "fwk_config.h"
@@ -19,23 +17,16 @@
1917
#endif
2018

2119
#include "FunctionLib.h"
22-
#include "fsl_adapter_flash.h"
23-
#include "HWParameter.h"
24-
#include "fsl_component_timer_manager.h"
25-
#include "fsl_os_abstraction.h"
2620
#include "fsl_adapter_rpmsg.h"
2721
#include "fsl_ccm32k.h"
2822
#include "fsl_spc.h"
29-
#include "fsl_trdc.h"
3023

3124
#include "rpmsg_platform.h"
3225

3326
#if defined(gMWS_Enabled_d) && (gMWS_Enabled_d > 0)
3427
#include "fwk_platform_mws.h"
3528
#endif
3629

37-
#include "fwk_debug.h"
38-
3930
#include "mcmgr_imu_internal.h"
4031

4132
/* -------------------------------------------------------------------------- */
@@ -142,20 +133,6 @@ int PLATFORM_IsNbuStarted(void)
142133
return nbu_started;
143134
}
144135

145-
void PLATFORM_SetLowPowerFlag(bool PwrDownOngoing)
146-
{
147-
uint32_t val = 0UL;
148-
extern uint32_t m_lowpower_flag_start[]; /* defined by linker */
149-
volatile uint32_t *p_lp_flag = (volatile uint32_t *)(uint32_t)m_lowpower_flag_start;
150-
151-
/* if called with */
152-
if (PwrDownOngoing)
153-
{
154-
val = PLATFORM_HOST_USE_POWER_DOWN;
155-
}
156-
*p_lp_flag = val;
157-
}
158-
159136
int PLATFORM_InitNbu(void)
160137
{
161138
int status = 0;
@@ -174,9 +151,6 @@ int PLATFORM_InitNbu(void)
174151
TRDC_SetNonProcessorDomainAssignment(TRDC, (uint8_t)kTRDC_MasterRadioNBU, &domainAssignment);
175152
#endif
176153

177-
/* Initialize a memory zone of the shared memory that will be used to transmit a message later */
178-
PLATFORM_SetLowPowerFlag(false);
179-
180154
rfmc_ctrl = RFMC->RF2P4GHZ_CTRL;
181155

182156
/* Enables BLE Power Controller on NBU side AND sets LP mode to DeepSleep */
@@ -200,23 +174,17 @@ int PLATFORM_InitNbu(void)
200174
* Here, we make sure the XTAL is ready before releasing the CM3 from reset
201175
* it will prevent any access issue when the CM3 is starting up.
202176
* CM3 is released in HAL_RpmsgMcmgrInit */
203-
BOARD_DBGLPIOSET(2, 1);
204177
while ((cnt++ < FWK_PLATFORM_XTAL32M_STARTUP_TIMEOUT) && ((RFMC->XO_STAT & RFMC_XO_STAT_XTAL_RDY_MASK) == 0U))
205178
{
206-
BOARD_DBGLPIOSET(2, 0);
207179
__ASM("NOP");
208-
BOARD_DBGLPIOSET(2, 1);
209180
}
210-
BOARD_DBGLPIOSET(2, 0);
211181

212182
if (cnt > FWK_PLATFORM_XTAL32M_STARTUP_TIMEOUT)
213183
{
214184
status = RAISE_ERROR(0, 1);
215185
}
216186
else
217187
{
218-
DBG_NBU_GPIOD_ACCESS();
219-
220188
/* nbu initialization completed */
221189
nbu_init = 1;
222190
}
@@ -262,19 +230,6 @@ int PLATFORM_InitMulticore(void)
262230

263231
void PLATFORM_LoadHwParams(void)
264232
{
265-
uint8_t xtal_32m_trim;
266-
hardwareParameters_t *pHWParams = NULL;
267-
uint32_t status;
268-
269-
/* Load the HW parameters from Flash to RAM */
270-
status = NV_ReadHWParameters(&pHWParams);
271-
if ((status == 0U) && (pHWParams->xtalTrim != 0xFFU))
272-
{
273-
/* There is an existing trim value */
274-
xtal_32m_trim = pHWParams->xtalTrim;
275-
/* Set value to RFMC */
276-
PLATFORM_SetXtal32MhzTrim(xtal_32m_trim, FALSE);
277-
}
278233
}
279234

280235
/* get 4 words of information that uniquely identifies the MCU */
@@ -350,63 +305,12 @@ int PLATFORM_InitOsc32K(void)
350305

351306
int PLATFORM_GetOscCap32KValue(uint8_t *xtalCap32K)
352307
{
353-
hardwareParameters_t *pHWParams = NULL;
354-
int status;
355-
356-
status = (int)NV_ReadHWParameters(&pHWParams);
357-
358-
if ((status == 0) && (pHWParams->xtalCap32K != 0xFFU))
359-
{
360-
uint32_t regPrimask;
361-
regPrimask = DisableGlobalIRQ();
362-
*xtalCap32K = pHWParams->xtalCap32K;
363-
EnableGlobalIRQ(regPrimask);
364-
}
365-
else
366-
{
367-
*xtalCap32K = BOARD_32KHZ_XTAL_CLOAD_DEFAULT;
368-
}
369-
/* If the HWParameter are not set it will keep the value chosen by default so do nothing here */
370-
return status;
308+
return -1;
371309
}
372310

373311
int PLATFORM_SetOscCap32KValue(uint8_t xtalCap32K)
374312
{
375-
hardwareParameters_t *pHWParams = NULL;
376-
int status;
377-
ccm32k_osc_config_t osc32k_config;
378-
379-
do
380-
{
381-
uint32_t regPrimask;
382-
if (xtalCap32K > BOARD_32KHZ_XTAL_CAPACITANCE_MAX_VALUE)
383-
{
384-
status = -1;
385-
break;
386-
}
387-
388-
status = (int)NV_ReadHWParameters(&pHWParams);
389-
if (status != 0)
390-
{
391-
break;
392-
}
393-
394-
regPrimask = DisableGlobalIRQ();
395-
pHWParams->xtalCap32K = xtalCap32K;
396-
(void)NV_WriteHWParameters();
397-
EnableGlobalIRQ(regPrimask);
398-
399-
osc32k_config.enableInternalCapBank = true;
400-
osc32k_config.coarseAdjustment = (ccm32k_osc_coarse_adjustment_value_t)BOARD_32KHZ_XTAL_COARSE_ADJ_DEFAULT;
401-
402-
osc32k_config.extalCap = (ccm32k_osc_extal_cap_t)xtalCap32K;
403-
osc32k_config.xtalCap = (ccm32k_osc_xtal_cap_t)xtalCap32K;
404-
405-
CCM32K_Set32kOscConfig(CCM32K, kCCM32K_Enable32kHzCrystalOsc, &osc32k_config);
406-
407-
} while (false);
408-
409-
return status;
313+
return -1;
410314
}
411315

412316
int PLATFORM_SwitchToOsc32k(void)
@@ -467,72 +371,15 @@ uint8_t PLATFORM_GetXtal32MhzTrim(bool_t regRead)
467371
/* Calling this function assumes HWParameters in flash have been read */
468372
void PLATFORM_SetXtal32MhzTrim(uint8_t trimValue, bool_t saveToHwParams)
469373
{
470-
uint32_t status;
471-
uint32_t rfmc_xo;
472-
hardwareParameters_t *pHWParams = NULL;
473-
status = NV_ReadHWParameters(&pHWParams);
474-
if ((TRUE == saveToHwParams) && (status == 0U))
475-
{
476-
/* update value only if it changed */
477-
pHWParams->xtalTrim = trimValue;
478-
(void)NV_WriteHWParameters();
479-
}
480-
481-
/* Apply a trim value to the crystal oscillator */
482-
rfmc_xo = RFMC->XO_TEST;
483-
484-
rfmc_xo &= ~(RFMC_XO_TEST_CDAC_MASK);
485-
rfmc_xo |= RFMC_XO_TEST_CDAC(pHWParams->xtalTrim);
486-
487-
RFMC->XO_TEST = rfmc_xo;
488374
}
489375

490376
int PLATFORM_InitTimerManager(void)
491377
{
492-
int status = 0;
493-
494-
if (timer_manager_initialized == 0)
495-
{
496-
timer_status_t tm_st;
497-
timer_config_t timerConfig;
498-
499-
timerConfig.instance = PLATFORM_TM_INSTANCE;
500-
timerConfig.srcClock_Hz = PLATFORM_TM_CLK_FREQ;
501-
timerConfig.clockSrcSelect = PLATFORM_TM_CLK_SELECT;
502-
503-
#if (defined(TM_ENABLE_TIME_STAMP) && (TM_ENABLE_TIME_STAMP > 0U))
504-
timerConfig.timeStampSrcClock_Hz = PLATFORM_TM_STAMP_CLK_FREQ;
505-
timerConfig.timeStampInstance = PLATFORM_TM_STAMP_INSTANCE;
506-
timerConfig.timeStampClockSrcSelect = PLATFORM_TM_STAMP_CLK_SELECT;
507-
#endif
508-
509-
tm_st = TM_Init(&timerConfig);
510-
if (tm_st != kStatus_TimerSuccess)
511-
{
512-
status = RAISE_ERROR(tm_st, 1);
513-
assert(0);
514-
}
515-
else
516-
{
517-
/* Timer Manager initialization completed */
518-
timer_manager_initialized = 1;
519-
}
520-
}
521-
else
522-
{
523-
/* Timer Manager already initialized */
524-
status = 1;
525-
}
526-
return status;
378+
return -1;
527379
}
528380

529381
void PLATFORM_DeinitTimerManager(void)
530382
{
531-
if (timer_manager_initialized == 1)
532-
{
533-
TM_Deinit();
534-
timer_manager_initialized = 0;
535-
}
536383
}
537384

538385
uint64_t PLATFORM_GetTimeStamp(void)
@@ -601,9 +448,6 @@ void PLATFORM_DisableControllerLowPower(void)
601448

602449
void PLATFORM_RemoteActiveReq(void)
603450
{
604-
BOARD_DBGLPIOSET(1, 1);
605-
BOARD_DBGLPIOSET(0, 1);
606-
607451
OSA_InterruptDisable();
608452

609453
if (active_request_nb == 0)
@@ -667,9 +511,7 @@ void PLATFORM_RemoteActiveReq(void)
667511
/* Wait for the NBU to become active */
668512
while ((RFMC->RF2P4GHZ_STAT & RFMC_RF2P4GHZ_STAT_BLE_STATE_MASK) != RFMC_RF2P4GHZ_STAT_BLE_STATE(0x1U))
669513
{
670-
BOARD_DBGLPIOSET(0, 1);
671514
__ASM("NOP");
672-
BOARD_DBGLPIOSET(0, 0);
673515
/* Error callback set by PLATFORM_RegisterBleErrorCallback() */
674516
if (PLATFORM_IsTimeoutExpired(timestamp, FWK_PLATFORM_ACTIVE_REQ_TIMEOUT_US) &&
675517
(pfPlatformErrorCallback != NULL))
@@ -689,14 +531,10 @@ void PLATFORM_RemoteActiveReq(void)
689531
active_request_nb++;
690532

691533
OSA_InterruptEnable();
692-
693-
BOARD_DBGLPIOSET(0, 0);
694534
}
695535

696536
void PLATFORM_RemoteActiveRel(void)
697537
{
698-
BOARD_DBGLPIOSET(0, 1);
699-
700538
OSA_InterruptDisable();
701539

702540
assert(active_request_nb > 0);
@@ -708,12 +546,9 @@ void PLATFORM_RemoteActiveRel(void)
708546
rfmc_ctrl = RFMC->RF2P4GHZ_CTRL;
709547
rfmc_ctrl &= ~RFMC_RF2P4GHZ_CTRL_BLE_WKUP_MASK;
710548
RFMC->RF2P4GHZ_CTRL = rfmc_ctrl;
711-
BOARD_DBGLPIOSET(1, 0);
712549
}
713550

714551
OSA_InterruptEnable();
715-
716-
BOARD_DBGLPIOSET(0, 0);
717552
}
718553

719554
void PLATFORM_GetResetCause(PLATFORM_ResetStatus_t *reset_status)

mcux/middleware/mcux-sdk-middleware-connectivity-framework/platform/wireless_mcu/fwk_platform.h

Lines changed: 0 additions & 29 deletions
Original file line numberDiff line numberDiff line change
@@ -33,35 +33,6 @@
3333
/* Definitions */
3434
/* -------------------------------------------------------------------------- */
3535

36-
/*! @brief The configuration of timer. */
37-
#ifndef PLATFORM_TM_INSTANCE
38-
#define PLATFORM_TM_INSTANCE 0U
39-
#endif
40-
#ifndef PLATFORM_TM_CLK_FREQ
41-
#define PLATFORM_TM_CLK_FREQ 32768U
42-
#endif
43-
44-
#ifndef PLATFORM_TM_CLK_SELECT
45-
#define PLATFORM_TM_CLK_SELECT 2U /*Lptmr timer use (kLPTMR_PrescalerClock_2) 32k clock*/
46-
#endif
47-
48-
/*! @brief The configuration of timer stamp. */
49-
#ifndef PLATFORM_TM_STAMP_INSTANCE
50-
#define PLATFORM_TM_STAMP_INSTANCE 1U
51-
#endif
52-
#ifndef PLATFORM_TM_STAMP_CLK_FREQ
53-
#define PLATFORM_TM_STAMP_CLK_FREQ 32768U
54-
#endif
55-
56-
#ifndef PLATFORM_TM_STAMP_CLK_SELECT
57-
#define PLATFORM_TM_STAMP_CLK_SELECT 2U /*Lptmr timer use (kLPTMR_PrescalerClock_2) 32k clock*/
58-
#endif
59-
60-
#define PLATFORM_TM_STAMP_MAX_US COUNT_TO_USEC(LPTMR_CNR_COUNTER_MASK, PLATFORM_TM_STAMP_CLK_FREQ)
61-
62-
/* Value of LowPower flag word to notify NBU core that Host core has initiated PowerDown */
63-
#define PLATFORM_HOST_USE_POWER_DOWN (0xA5A5A5A5U)
64-
6536
/*!
6637
* \brief type definition for the list of reset status
6738
*

0 commit comments

Comments
 (0)