Skip to content

Commit ba6f9fb

Browse files
nxp-wei-fengmmahadevan108
authored andcommitted
Added new SVC trim equation for new samples
Signed-off-by: Feng Wei <[email protected]>
1 parent 111f568 commit ba6f9fb

File tree

6 files changed

+64
-28
lines changed

6 files changed

+64
-28
lines changed

mcux/mcux-sdk-ng/devices/Wireless/RW/RW610/drivers/CMakeLists.txt

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -46,7 +46,7 @@ if (CONFIG_MCUX_COMPONENT_driver.ocotp_rw61x)
4646
endif()
4747

4848
if (CONFIG_MCUX_COMPONENT_driver.power)
49-
mcux_component_version(2.5.0)
49+
mcux_component_version(2.5.1)
5050
mcux_add_source( SOURCES fsl_power.c fsl_power.h )
5151
mcux_add_include( INCLUDES . )
5252
endif()

mcux/mcux-sdk-ng/devices/Wireless/RW/RW610/drivers/fsl_power.c

Lines changed: 29 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -52,6 +52,10 @@
5252
*((volatile uint32_t *)(addr)) = (val); \
5353
} while (false)
5454

55+
#define POWER_SAVED_GDET_CLOCK_SOURCE (s_gdetCfgData.TRIM0 & CLKCTL0_ELS_GDET_CLK_SEL_SEL_MASK)
56+
#define POWER_GDET_CLOCK_SOURCE_64MHZ (CLKCTL0_ELS_GDET_CLK_SEL_SEL(2U))
57+
#define POWER_GDET_CLOCK_SOURCE_32MHZ (CLKCTL0_ELS_GDET_CLK_SEL_SEL(3U))
58+
5559
typedef struct _power_nvic_context
5660
{
5761
uint32_t PriorityGroup;
@@ -1229,6 +1233,8 @@ void Power_InitLoadGdetCfg(power_load_gdet_cfg loadFunc, const power_gdet_data_t
12291233

12301234
s_gdetCfgloadFunc = loadFunc;
12311235
(void)memcpy(&s_gdetCfgData, data, sizeof(power_gdet_data_t));
1236+
/* Save GDET clock source on startup */
1237+
s_gdetCfgData.TRIM0 = CLKCTL0->ELS_GDET_CLK_SEL;
12321238
s_gdetCfgData.CFG[3] = POWER_TrimSvc(data->CFG[3], pack);
12331239
}
12341240

@@ -1426,24 +1432,36 @@ uint32_t POWER_TrimSvc(uint32_t gdetTrim, uint32_t pack)
14261432
/* A2 */
14271433
/* Autotrim value at [7:0] */
14281434
x = (int32_t)(uint32_t)(gdetTrim & 0xFFUL);
1429-
if (pack == 0U)
1435+
if (POWER_SAVED_GDET_CLOCK_SOURCE == POWER_GDET_CLOCK_SOURCE_64MHZ)
14301436
{
1431-
/* QFN */
1432-
y1 = (18 * x * x) + (801 * x) + 437290;
1433-
y3 = y1 / 10000;
1437+
if (pack == 0U)
1438+
{
1439+
/* QFN */
1440+
y1 = (18 * x * x) + (801 * x) + 437290;
1441+
y3 = y1 / 10000;
1442+
}
1443+
else if (pack == 1U)
1444+
{
1445+
/* CSP */
1446+
y1 = (82 * x * x) - (5171 * x) + 559320;
1447+
y3 = y1 / 10000;
1448+
}
1449+
else
1450+
{
1451+
/* BGA */
1452+
assert(pack == 2U);
1453+
y1 = (25 * x * x) + (1337 * x) + 381140;
1454+
y3 = y1 / 10000;
1455+
}
14341456
}
1435-
else if (pack == 1U)
1457+
else if (POWER_SAVED_GDET_CLOCK_SOURCE == POWER_GDET_CLOCK_SOURCE_32MHZ)
14361458
{
1437-
/* CSP */
1438-
y1 = (82 * x * x) - (5171 * x) + 559320;
1459+
y1 = (-63 * x * x) + (10961 * x) + 265000;
14391460
y3 = y1 / 10000;
14401461
}
14411462
else
14421463
{
1443-
/* BGA */
1444-
assert(pack == 2U);
1445-
y1 = (25 * x * x) + (1337 * x) + 381140;
1446-
y3 = y1 / 10000;
1464+
assert(false);
14471465
}
14481466

14491467
trimSvc = ((uint32_t)y3) << 24;

mcux/mcux-sdk-ng/devices/Wireless/RW/RW610/drivers/fsl_power.h

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -23,8 +23,8 @@
2323

2424
/*! @name Driver version */
2525
/*@{*/
26-
/*! @brief POWER driver version 2.5.0. */
27-
#define FSL_POWER_DRIVER_VERSION (MAKE_VERSION(2, 5, 0))
26+
/*! @brief POWER driver version 2.5.1. */
27+
#define FSL_POWER_DRIVER_VERSION (MAKE_VERSION(2, 5, 1))
2828
/*@}*/
2929

3030
/*!

mcux/mcux-sdk-ng/devices/Wireless/RW/RW612/drivers/CMakeLists.txt

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -46,7 +46,7 @@ if (CONFIG_MCUX_COMPONENT_driver.ocotp_rw61x)
4646
endif()
4747

4848
if (CONFIG_MCUX_COMPONENT_driver.power)
49-
mcux_component_version(2.5.0)
49+
mcux_component_version(2.5.1)
5050
mcux_add_source( SOURCES fsl_power.c fsl_power.h )
5151
mcux_add_include( INCLUDES . )
5252
endif()

mcux/mcux-sdk-ng/devices/Wireless/RW/RW612/drivers/fsl_power.c

Lines changed: 29 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -52,6 +52,10 @@
5252
*((volatile uint32_t *)(addr)) = (val); \
5353
} while (false)
5454

55+
#define POWER_SAVED_GDET_CLOCK_SOURCE (s_gdetCfgData.TRIM0 & CLKCTL0_ELS_GDET_CLK_SEL_SEL_MASK)
56+
#define POWER_GDET_CLOCK_SOURCE_64MHZ (CLKCTL0_ELS_GDET_CLK_SEL_SEL(2U))
57+
#define POWER_GDET_CLOCK_SOURCE_32MHZ (CLKCTL0_ELS_GDET_CLK_SEL_SEL(3U))
58+
5559
typedef struct _power_nvic_context
5660
{
5761
uint32_t PriorityGroup;
@@ -1229,6 +1233,8 @@ void Power_InitLoadGdetCfg(power_load_gdet_cfg loadFunc, const power_gdet_data_t
12291233

12301234
s_gdetCfgloadFunc = loadFunc;
12311235
(void)memcpy(&s_gdetCfgData, data, sizeof(power_gdet_data_t));
1236+
/* Save GDET clock source on startup */
1237+
s_gdetCfgData.TRIM0 = CLKCTL0->ELS_GDET_CLK_SEL;
12321238
s_gdetCfgData.CFG[3] = POWER_TrimSvc(data->CFG[3], pack);
12331239
}
12341240

@@ -1426,24 +1432,36 @@ uint32_t POWER_TrimSvc(uint32_t gdetTrim, uint32_t pack)
14261432
/* A2 */
14271433
/* Autotrim value at [7:0] */
14281434
x = (int32_t)(uint32_t)(gdetTrim & 0xFFUL);
1429-
if (pack == 0U)
1435+
if (POWER_SAVED_GDET_CLOCK_SOURCE == POWER_GDET_CLOCK_SOURCE_64MHZ)
14301436
{
1431-
/* QFN */
1432-
y1 = (18 * x * x) + (801 * x) + 437290;
1433-
y3 = y1 / 10000;
1437+
if (pack == 0U)
1438+
{
1439+
/* QFN */
1440+
y1 = (18 * x * x) + (801 * x) + 437290;
1441+
y3 = y1 / 10000;
1442+
}
1443+
else if (pack == 1U)
1444+
{
1445+
/* CSP */
1446+
y1 = (82 * x * x) - (5171 * x) + 559320;
1447+
y3 = y1 / 10000;
1448+
}
1449+
else
1450+
{
1451+
/* BGA */
1452+
assert(pack == 2U);
1453+
y1 = (25 * x * x) + (1337 * x) + 381140;
1454+
y3 = y1 / 10000;
1455+
}
14341456
}
1435-
else if (pack == 1U)
1457+
else if (POWER_SAVED_GDET_CLOCK_SOURCE == POWER_GDET_CLOCK_SOURCE_32MHZ)
14361458
{
1437-
/* CSP */
1438-
y1 = (82 * x * x) - (5171 * x) + 559320;
1459+
y1 = (-63 * x * x) + (10961 * x) + 265000;
14391460
y3 = y1 / 10000;
14401461
}
14411462
else
14421463
{
1443-
/* BGA */
1444-
assert(pack == 2U);
1445-
y1 = (25 * x * x) + (1337 * x) + 381140;
1446-
y3 = y1 / 10000;
1464+
assert(false);
14471465
}
14481466

14491467
trimSvc = ((uint32_t)y3) << 24;

mcux/mcux-sdk-ng/devices/Wireless/RW/RW612/drivers/fsl_power.h

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -23,8 +23,8 @@
2323

2424
/*! @name Driver version */
2525
/*@{*/
26-
/*! @brief POWER driver version 2.5.0. */
27-
#define FSL_POWER_DRIVER_VERSION (MAKE_VERSION(2, 5, 0))
26+
/*! @brief POWER driver version 2.5.1. */
27+
#define FSL_POWER_DRIVER_VERSION (MAKE_VERSION(2, 5, 1))
2828
/*@}*/
2929

3030
/*!

0 commit comments

Comments
 (0)