Other Parts Discussed in Thread: SYSCONFIG
Tool/software:
I'm trying to shut down the MCU after 3 blinks each time I wake it up. but the wake-up pin acts as a gate and shutdown immediately, without the blink. Here's the attached code:
#include <stdbool.h>
#include <ti/drivers/GPIO.h>
#include <ti/drivers/Power.h>
#include <ti/drivers/power/PowerCC26X2.h>
#include <ti/drivers/apps/LED.h>
#include <ti/drivers/dpl/SemaphoreP.h>
#include <ti/devices/DeviceFamily.h>
#include DeviceFamily_constructPath(driverlib/sys_ctrl.h)
#include DeviceFamily_constructPath(driverlib/pwr_ctrl.h)
#include "ti_drivers_config.h"
// Semaphore used to gate for shutdown
SemaphoreP_Struct semStruct;
SemaphoreP_Handle semHandle;
void *mainThread(void *arg0) {
// Initialize LEDs
//LED_Handle led0Handle = LED_open(CONFIG_LED_0, NULL);
LED_Handle led1Handle = LED_open(CONFIG_LED_1, NULL);
PowerCC26X2_ResetReason resetReason = PowerCC26X2_getResetReason();
/* If waking up from shutdown, execute blink sequence */
if (resetReason == PowerCC26X2_RESET_SHUTDOWN_IO) {
PowerCC26X2_releaseLatches(); // Disable IO latches after shutdown
// Blink LED1 three times to indicate wake-up
LED_startBlinking(led1Handle, 500, 3);
// Delay to allow LED blink sequence to complete
usleep(2000000); // 2 seconds delay
}
// Configure GPIO wake-up pin and initiate automatic shutdown
GPIO_setConfig(CONFIG_GPIO_WAKEUP, GPIO_CFG_IN_PD | GPIO_CFG_SHUTDOWN_WAKE_HIGH);
// Enter shutdown mode directly after wake-up actions
Power_shutdown(0, 0);
// Failsafe: this loop should not be reached, as shutdown resets the device
while (1) {}
}