Hello,
There is existing code GPIO wakeup code available with the toolchain which you can use for reference.
This is specifically taken from D2XX Example 1 (see
AN_360 FT900 Example Applications).
The code can be found at the following location as part of the IDE:
C:\Users\
Username\Documents\Bridgetek\FT9xx\
Version\Examples\D2XX Example 1
#ifdef GPIO_REMOTE_WAKEUP
SetRemoteWakeup = 0;
if (RemoteWakeupEnable)
{
tfp_printf("d2xx_loopback_test1: Configuring GPIO pin to wakeup \r\n");
#if 1
/* Set up the pin */
gpio_dir(GPIO_PIN, pad_dir_input);
gpio_pull(GPIO_PIN, pad_pull_pullup);
/* Attach an interrupt */
gpio_interrupt_enable(GPIO_PIN, gpio_int_edge_falling);
interrupt_attach(interrupt_gpio, (uint8_t)interrupt_gpio, ISR_gpio);
tfp_printf("d2xx_loopback_test1: GPIO pin setup for interrupt\r\n");
#endif
}
#endif
D2XXTEST__Sleep = 1;
D2XXTEST__Wakeup = 0;
/* Power down Mode */
SYS->PMCFG_L |= MASK_SYS_PMCFG_PM_PWRDN_MODE;
SYS->PMCFG_L |= MASK_SYS_PMCFG_PM_PWRDN;
asm volatile ("nop");
asm volatile ("nop");
asm volatile ("nop");
asm volatile ("nop");
asm volatile ("nop");
//wait for wakeup
while(!D2XXTEST__Wakeup);
interrupt_disable_globally();
#ifdef GPIO_REMOTE_WAKEUP
gpio_interrupt_disable(GPIO_PIN);
interrupt_detach(interrupt_gpio);
gpio_is_interrupted(GPIO_PIN);
#endif
SYS->PMCFG_L &= ~MASK_SYS_PMCFG_PM_PWRDN_MODE;
SYS->PMCFG_L &= ~MASK_SYS_PMCFG_PM_PWRDN;
The contents in RAM should not be lost, as this is a standby mode and not POWER ON RESET.
The datalogger feature uses the on-chip flash in the FT9XX for storage.
More information can be found in
AN 365 FT9xx API Programmers Manual section 2.34 Datalogger Feature.
Example datalogger code can also be found in the Toolchain examples.
Best Regards,
BRT Community