Skip to content

Commit

Permalink
Selected MXC_WUT0 in more ME18 examples
Browse files Browse the repository at this point in the history
  • Loading branch information
crsz20 committed Dec 11, 2024
1 parent b31661b commit 274b02e
Show file tree
Hide file tree
Showing 13 changed files with 36 additions and 36 deletions.
2 changes: 1 addition & 1 deletion Examples/MAX32690/Bluetooth/BLE_FreeRTOS/dats_main.c
Original file line number Diff line number Diff line change
Expand Up @@ -342,7 +342,7 @@ static void trimStart(void)
extern void wutTrimCb(int err);

/* Start the 32 kHz crystal trim procedure */
err = MXC_WUT_TrimCrystalAsync(wutTrimCb);
err = MXC_WUT_TrimCrystalAsync(MXC_WUT0, wutTrimCb);
if (err != E_NO_ERROR) {
APP_TRACE_INFO1("Error starting 32kHz crystal trim %d", err);
}
Expand Down
16 changes: 8 additions & 8 deletions Examples/MAX32690/Bluetooth/BLE_FreeRTOS/freertos_tickless.c
Original file line number Diff line number Diff line change
Expand Up @@ -60,7 +60,7 @@
int freertos_permit_tickless(void)
{
/* Can not disable BLE DBB and 32 MHz clock while trim procedure is ongoing */
if (MXC_WUT_TrimPending() != E_NO_ERROR) {
if (MXC_WUT_TrimPending(MXC_WUT0) != E_NO_ERROR) {
return E_BUSY;
}

Expand Down Expand Up @@ -160,8 +160,8 @@ void vPortSuppressTicksAndSleep(TickType_t xExpectedIdleTime)
/* Determine if we need to snapshot the PalBb clock */
if (schTimerActive) {
/* Snapshot the current WUT value with the PalBb clock */
MXC_WUT_Store();
preCapture = MXC_WUT_GetCount();
MXC_WUT_Store(MXC_WUT0);
preCapture = MXC_WUT_GetCount(MXC_WUT0);
schUsec = PalTimerGetExpTime();

/* Adjust idleTicks for the time it takes to restart the BLE hardware */
Expand All @@ -176,8 +176,8 @@ void vPortSuppressTicksAndSleep(TickType_t xExpectedIdleTime)
}
} else {
/* Snapshot the current WUT value */
MXC_WUT_Edge();
preCapture = MXC_WUT_GetCount();
MXC_WUT_Edge(MXC_WUT0);
preCapture = MXC_WUT_GetCount(MXC_WUT0);
bleSleepTicks = 0;
schUsec = 0;
}
Expand Down Expand Up @@ -221,7 +221,7 @@ void vPortSuppressTicksAndSleep(TickType_t xExpectedIdleTime)

if (schTimerActive) {
/* Restore the BB counter */
MXC_WUT_RestoreBBClock(BB_CLK_RATE_HZ);
MXC_WUT_RestoreBBClock(MXC_WUT0, BB_CLK_RATE_HZ);

/* Restart the BLE scheduler timer */
dsWutTicks = MXC_WUT->cnt - preCapture;
Expand All @@ -237,8 +237,8 @@ void vPortSuppressTicksAndSleep(TickType_t xExpectedIdleTime)
}

/* Recalculate dsWutTicks for the FreeRTOS tick counter update */
MXC_WUT_Edge();
postCapture = MXC_WUT_GetCount();
MXC_WUT_Edge(MXC_WUT0);
postCapture = MXC_WUT_GetCount(MXC_WUT0);
dsWutTicks = postCapture - preCapture;

/*
Expand Down
2 changes: 1 addition & 1 deletion Examples/MAX32690/Bluetooth/BLE_FreeRTOS/stack_dats.c
Original file line number Diff line number Diff line change
Expand Up @@ -279,7 +279,7 @@ void trim32k(void)

/* Execute the trim procedure */
wutTrimComplete = 0;
if (MXC_WUT_TrimCrystalAsync(wutTrimCb) != E_NO_ERROR) {
if (MXC_WUT_TrimCrystalAsync(MXC_WUT0, wutTrimCb) != E_NO_ERROR) {
APP_TRACE_INFO0("Error with 32k trim");
} else {
while (!wutTrimComplete) {}
Expand Down
2 changes: 1 addition & 1 deletion Examples/MAX32690/Bluetooth/BLE_datc/main.c
Original file line number Diff line number Diff line change
Expand Up @@ -277,7 +277,7 @@ int main(void)

/* Execute the trim procedure */
wutTrimComplete = 0;
MXC_WUT_TrimCrystalAsync(wutTrimCb);
MXC_WUT_TrimCrystalAsync(MXC_WUT0, wutTrimCb);
while (!wutTrimComplete) {}

/* Shutdown the 32 MHz crystal and the BLE DBB */
Expand Down
2 changes: 1 addition & 1 deletion Examples/MAX32690/Bluetooth/BLE_dats/dats_main.c
Original file line number Diff line number Diff line change
Expand Up @@ -403,7 +403,7 @@ static void trimStart(void)
extern void wutTrimCb(int err);

/* Start the 32 kHz crystal trim procedure */
err = MXC_WUT_TrimCrystalAsync(wutTrimCb);
err = MXC_WUT_TrimCrystalAsync(MXC_WUT0, wutTrimCb);
if (err != E_NO_ERROR) {
APP_TRACE_INFO1("Error starting 32kHz crystal trim %d", err);
}
Expand Down
2 changes: 1 addition & 1 deletion Examples/MAX32690/Bluetooth/BLE_dats/main.c
Original file line number Diff line number Diff line change
Expand Up @@ -272,7 +272,7 @@ int main(void)

/* Execute the trim procedure */
wutTrimComplete = 0;
MXC_WUT_TrimCrystalAsync(wutTrimCb);
MXC_WUT_TrimCrystalAsync(MXC_WUT0, wutTrimCb);
while (!wutTrimComplete) {}

/* Shutdown the 32 MHz crystal and the BLE DBB */
Expand Down
2 changes: 1 addition & 1 deletion Examples/MAX32690/Bluetooth/BLE_fit/main.c
Original file line number Diff line number Diff line change
Expand Up @@ -272,7 +272,7 @@ int main(void)

/* Execute the trim procedure */
wutTrimComplete = 0;
MXC_WUT_TrimCrystalAsync(wutTrimCb);
MXC_WUT_TrimCrystalAsync(MXC_WUT0, wutTrimCb);
while (!wutTrimComplete) {}

/* Shutdown the 32 MHz crystal and the BLE DBB */
Expand Down
2 changes: 1 addition & 1 deletion Examples/MAX32690/Bluetooth/BLE_otac/main.c
Original file line number Diff line number Diff line change
Expand Up @@ -273,7 +273,7 @@ int main(void)

/* Execute the trim procedure */
wutTrimComplete = 0;
MXC_WUT_TrimCrystalAsync(wutTrimCb);
MXC_WUT_TrimCrystalAsync(MXC_WUT0, wutTrimCb);
while (!wutTrimComplete) {}

/* Shutdown the 32 MHz crystal and the BLE DBB */
Expand Down
2 changes: 1 addition & 1 deletion Examples/MAX32690/Bluetooth/BLE_otas/dats_main.c
Original file line number Diff line number Diff line change
Expand Up @@ -349,7 +349,7 @@ static void trimStart(void)
extern void wutTrimCb(int err);

/* Start the 32 kHz crystal trim procedure */
err = MXC_WUT_TrimCrystalAsync(wutTrimCb);
err = MXC_WUT_TrimCrystalAsync(MXC_WUT0, wutTrimCb);
if (err != E_NO_ERROR) {
APP_TRACE_INFO1("Error starting 32kHz crystal trim %d", err);
}
Expand Down
2 changes: 1 addition & 1 deletion Examples/MAX32690/Bluetooth/BLE_otas/main.c
Original file line number Diff line number Diff line change
Expand Up @@ -276,7 +276,7 @@ int main(void)

/* Execute the trim procedure */
wutTrimComplete = 0;
MXC_WUT_TrimCrystalAsync(wutTrimCb);
MXC_WUT_TrimCrystalAsync(MXC_WUT0, wutTrimCb);
while (!wutTrimComplete) {}

/* Stop here to measure the 32 kHz clock */
Expand Down
16 changes: 8 additions & 8 deletions Examples/MAX32690/Bluetooth/RF_Test/freertos_tickless.c
Original file line number Diff line number Diff line change
Expand Up @@ -60,7 +60,7 @@
int freertos_permit_tickless(void)
{
/* Can not disable BLE DBB and 32 MHz clock while trim procedure is ongoing */
if (MXC_WUT_TrimPending() != E_NO_ERROR) {
if (MXC_WUT_TrimPending(MXC_WUT0) != E_NO_ERROR) {
return E_BUSY;
}

Expand Down Expand Up @@ -160,8 +160,8 @@ void vPortSuppressTicksAndSleep(TickType_t xExpectedIdleTime)
/* Determine if we need to snapshot the PalBb clock */
if (schTimerActive) {
/* Snapshot the current WUT value with the PalBb clock */
MXC_WUT_Store();
preCapture = MXC_WUT_GetCount();
MXC_WUT_Store(MXC_WUT0);
preCapture = MXC_WUT_GetCount(MXC_WUT0);
schUsec = PalTimerGetExpTime();

/* Adjust idleTicks for the time it takes to restart the BLE hardware */
Expand All @@ -176,8 +176,8 @@ void vPortSuppressTicksAndSleep(TickType_t xExpectedIdleTime)
}
} else {
/* Snapshot the current WUT value */
MXC_WUT_Edge();
preCapture = MXC_WUT_GetCount();
MXC_WUT_Edge(MXC_WUT0);
preCapture = MXC_WUT_GetCount(MXC_WUT0);
bleSleepTicks = 0;
schUsec = 0;
}
Expand Down Expand Up @@ -222,7 +222,7 @@ void vPortSuppressTicksAndSleep(TickType_t xExpectedIdleTime)
PalBbRestore();

/* Restore the BB counter */
MXC_WUT_RestoreBBClock(BB_CLK_RATE_HZ);
MXC_WUT_RestoreBBClock(MXC_WUT0, BB_CLK_RATE_HZ);

/* Restart the BLE scheduler timer */
dsWutTicks = MXC_WUT->cnt - preCapture;
Expand All @@ -238,8 +238,8 @@ void vPortSuppressTicksAndSleep(TickType_t xExpectedIdleTime)
}

/* Recalculate dsWutTicks for the FreeRTOS tick counter update */
MXC_WUT_Edge();
postCapture = MXC_WUT_GetCount();
MXC_WUT_Edge(MXC_WUT0);
postCapture = MXC_WUT_GetCount(MXC_WUT0);
dsWutTicks = postCapture - preCapture;

/*
Expand Down
14 changes: 7 additions & 7 deletions Examples/MAX32690/FreeRTOSDemo/freertos_tickless.c
Original file line number Diff line number Diff line change
Expand Up @@ -67,7 +67,7 @@ __attribute__((weak)) int freertos_permit_tickless(void)
*/
void wutHitSnooze(void)
{
wutSnooze = MXC_WUT_GetCount() + MAX_WUT_SNOOZE;
wutSnooze = MXC_WUT_GetCount(MXC_WUT0) + MAX_WUT_SNOOZE;
wutSnoozeValid = 1;
}

Expand Down Expand Up @@ -108,7 +108,7 @@ void vPortSuppressTicksAndSleep(TickType_t xExpectedIdleTime)
}

/* Check the WUT snooze */
if (wutSnoozeValid && (MXC_WUT_GetCount() < wutSnooze)) {
if (wutSnoozeValid && (MXC_WUT_GetCount(MXC_WUT0) < wutSnooze)) {
/* Finish out the rest of this tick with normal sleep */
MXC_LP_EnterSleepMode();
return;
Expand All @@ -134,16 +134,16 @@ void vPortSuppressTicksAndSleep(TickType_t xExpectedIdleTime)
MXC_GPIO_OutSet(uart_rts.port, uart_rts.mask);

/* Snapshot the current WUT value */
MXC_WUT_Edge();
pre_capture = MXC_WUT_GetCount();
MXC_WUT_SetCompare(pre_capture + wut_ticks);
MXC_WUT_Edge();
MXC_WUT_Edge(MXC_WUT0);
pre_capture = MXC_WUT_GetCount(MXC_WUT0);
MXC_WUT_SetCompare(MXC_WUT0, pre_capture + wut_ticks);
MXC_WUT_Edge(MXC_WUT0);

LED_Off(1);

MXC_LP_EnterStandbyMode();

post_capture = MXC_WUT_GetCount();
post_capture = MXC_WUT_GetCount(MXC_WUT0);
actual_ticks = post_capture - pre_capture;

LED_On(1);
Expand Down
8 changes: 4 additions & 4 deletions Examples/MAX32690/FreeRTOSDemo/main.c
Original file line number Diff line number Diff line change
Expand Up @@ -345,7 +345,7 @@ int freertos_permit_tickless(void)
*/
void WUT_IRQHandler(void)
{
MXC_WUT_ClearFlags();
MXC_WUT_ClearFlags(MXC_WUT0);
NVIC_ClearPendingIRQ(WUT0_IRQn);
}

Expand Down Expand Up @@ -374,7 +374,7 @@ int main(void)
#if configUSE_TICKLESS_IDLE

/* Initialize Wakeup timer */
MXC_WUT_Init(MXC_WUT_PRES_1);
MXC_WUT_Init(MXC_WUT0, MXC_WUT_PRES_1);
mxc_wut_cfg_t wut_cfg;
wut_cfg.mode = MXC_WUT_MODE_COMPARE;
wut_cfg.cmp_cnt = 0xFFFFFFFF;
Expand All @@ -386,8 +386,8 @@ int main(void)
NVIC_EnableIRQ(WUT_IRQn);

/* Configure and start the WUT */
MXC_WUT_Config(&wut_cfg);
MXC_WUT_Enable();
MXC_WUT_Config(MXC_WUT0, &wut_cfg);
MXC_WUT_Enable(MXC_WUT0);

/* Setup CTS interrupt */
MXC_GPIO_IntConfig(&uart_cts, MXC_GPIO_INT_FALLING);
Expand Down

0 comments on commit 274b02e

Please sign in to comment.