Use deep sleep API for example-fsm-55.
This commit is contained in:
@@ -355,8 +355,6 @@ text_display (uint8_t kind)
|
|||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
static void setup_scr_sleepdeep (void);
|
|
||||||
|
|
||||||
int
|
int
|
||||||
main (int argc, const char *argv[])
|
main (int argc, const char *argv[])
|
||||||
{
|
{
|
||||||
@@ -366,7 +364,7 @@ main (int argc, const char *argv[])
|
|||||||
(void)argc;
|
(void)argc;
|
||||||
(void)argv;
|
(void)argv;
|
||||||
|
|
||||||
chopstx_conf_idle (1);
|
chopstx_conf_idle (4);
|
||||||
|
|
||||||
chopstx_mutex_init (&mtx);
|
chopstx_mutex_init (&mtx);
|
||||||
chopstx_cond_init (&cnd0);
|
chopstx_cond_init (&cnd0);
|
||||||
@@ -408,56 +406,8 @@ main (int argc, const char *argv[])
|
|||||||
chopstx_join (button_thd, NULL);
|
chopstx_join (button_thd, NULL);
|
||||||
chopstx_join (led_thd, NULL);
|
chopstx_join (led_thd, NULL);
|
||||||
|
|
||||||
setup_scr_sleepdeep ();
|
|
||||||
for (;;)
|
for (;;)
|
||||||
asm volatile ("wfi" : : : "memory");
|
asm volatile ("wfi" : : : "memory");
|
||||||
|
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
struct SCB
|
|
||||||
{
|
|
||||||
volatile uint32_t CPUID;
|
|
||||||
volatile uint32_t ICSR;
|
|
||||||
volatile uint32_t VTOR;
|
|
||||||
volatile uint32_t AIRCR;
|
|
||||||
volatile uint32_t SCR;
|
|
||||||
volatile uint32_t CCR;
|
|
||||||
volatile uint8_t SHP[12];
|
|
||||||
volatile uint32_t SHCSR;
|
|
||||||
volatile uint32_t CFSR;
|
|
||||||
volatile uint32_t HFSR;
|
|
||||||
volatile uint32_t DFSR;
|
|
||||||
volatile uint32_t MMFAR;
|
|
||||||
volatile uint32_t BFAR;
|
|
||||||
volatile uint32_t AFSR;
|
|
||||||
volatile uint32_t PFR[2];
|
|
||||||
volatile uint32_t DFR;
|
|
||||||
volatile uint32_t ADR;
|
|
||||||
volatile uint32_t MMFR[4];
|
|
||||||
volatile uint32_t ISAR[5];
|
|
||||||
};
|
|
||||||
|
|
||||||
#define SCS_BASE (0xE000E000)
|
|
||||||
#define SCB_BASE (SCS_BASE + 0x0D00)
|
|
||||||
static struct SCB *const SCB = ((struct SCB *)SCB_BASE);
|
|
||||||
|
|
||||||
#define SCB_SCR_SLEEPDEEP (1 << 2)
|
|
||||||
|
|
||||||
struct PWR
|
|
||||||
{
|
|
||||||
volatile uint32_t CR;
|
|
||||||
volatile uint32_t CSR;
|
|
||||||
};
|
|
||||||
#define PWR_CR_PDDS 0x0002
|
|
||||||
#define PWR_CR_CWUF 0x0004
|
|
||||||
|
|
||||||
#define PWR_BASE (APBPERIPH_BASE + 0x00007000)
|
|
||||||
#define PWR ((struct PWR *) PWR_BASE)
|
|
||||||
|
|
||||||
static void setup_scr_sleepdeep (void)
|
|
||||||
{
|
|
||||||
PWR->CR |= PWR_CR_CWUF;
|
|
||||||
PWR->CR |= PWR_CR_PDDS;
|
|
||||||
SCB->SCR |= SCB_SCR_SLEEPDEEP;
|
|
||||||
}
|
|
||||||
|
|||||||
Reference in New Issue
Block a user