Only sleep mode can be used for USB suspend on STM32F103.
This commit is contained in:
@@ -709,6 +709,7 @@ svc (void)
|
|||||||
}
|
}
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
|
#ifdef MCU_STM32F0
|
||||||
struct SCB
|
struct SCB
|
||||||
{
|
{
|
||||||
volatile uint32_t CPUID;
|
volatile uint32_t CPUID;
|
||||||
@@ -748,27 +749,27 @@ static struct PWR *const PWR = ((struct PWR *)0x40007000);
|
|||||||
void
|
void
|
||||||
chx_sleep_mode (int how)
|
chx_sleep_mode (int how)
|
||||||
{
|
{
|
||||||
if (how == 0)
|
PWR->CR |= PWR_CR_CWUF;
|
||||||
;
|
PWR->CR &= ~(PWR_CR_PDDS|PWR_CR_LPDS);
|
||||||
|
|
||||||
|
if (how == 0 || how == 1 /* Sleep only (not deepsleep) */)
|
||||||
|
SCB->SCR &= ~SCB_SCR_SLEEPDEEP;
|
||||||
else
|
else
|
||||||
{
|
{ /* Deepsleep */
|
||||||
if (how == 1)
|
/* how == 2: deepsleep but regulator ON */
|
||||||
/* sleep only */
|
if (how == 3)
|
||||||
SCB->SCR &= ~SCB_SCR_SLEEPDEEP;
|
PWR->CR |= PWR_CR_LPDS; /* regulator low-power mode */
|
||||||
else
|
else if (how == 4)
|
||||||
{
|
PWR->CR |= PWR_CR_PDDS; /* Power down: All OFF */
|
||||||
PWR->CR |= PWR_CR_CWUF;
|
|
||||||
|
|
||||||
if (how == 2 || how == 3)
|
SCB->SCR |= SCB_SCR_SLEEPDEEP;
|
||||||
{
|
|
||||||
PWR->CR &= ~PWR_CR_PDDS;
|
|
||||||
if (how == 3)
|
|
||||||
PWR->CR |= PWR_CR_LPDS;
|
|
||||||
}
|
|
||||||
else /* how == 4 */
|
|
||||||
PWR->CR |= PWR_CR_PDDS;
|
|
||||||
|
|
||||||
SCB->SCR |= SCB_SCR_SLEEPDEEP;
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
#else
|
||||||
|
/* Deepsleep is only useful with RTC, Watch Dog, or WKUP pin. */
|
||||||
|
void
|
||||||
|
chx_sleep_mode (int how)
|
||||||
|
{
|
||||||
|
(void)how;
|
||||||
|
}
|
||||||
|
#endif
|
||||||
|
|||||||
@@ -29,7 +29,6 @@
|
|||||||
#include <stdint.h>
|
#include <stdint.h>
|
||||||
#include <stdlib.h>
|
#include <stdlib.h>
|
||||||
|
|
||||||
#include "mcu/stm32f103.h"
|
|
||||||
#include "sys-stm32f103.h"
|
#include "sys-stm32f103.h"
|
||||||
#include "usb_lld.h"
|
#include "usb_lld.h"
|
||||||
#include "usb_lld_driver.h"
|
#include "usb_lld_driver.h"
|
||||||
@@ -343,9 +342,19 @@ void usb_lld_init (struct usb_dev *dev, uint8_t feature)
|
|||||||
st103_set_cntr (CNTR_CTRM | CNTR_OVRM | CNTR_ERRM
|
st103_set_cntr (CNTR_CTRM | CNTR_OVRM | CNTR_ERRM
|
||||||
| CNTR_WKUPM | CNTR_SUSPM | CNTR_RESETM);
|
| CNTR_WKUPM | CNTR_SUSPM | CNTR_RESETM);
|
||||||
|
|
||||||
/* Setting of EXTI wakeup event to break sleep on WFE. */
|
#if 0
|
||||||
EXTI->RTSR |= (1 << 18); /* Rising trigger selection */
|
/*
|
||||||
|
* Since stop mode makes PLL, HSI & HES oscillators stop, USB clock is
|
||||||
|
* not supplied in stop mode. Thus, USB wakeup can't occur.
|
||||||
|
*
|
||||||
|
* So, only sleep mode can be supported with USB, which doesn't
|
||||||
|
* require use of EXTI.
|
||||||
|
*/
|
||||||
|
#include "mcu/stm32f103.h"
|
||||||
|
/* Setting of EXTI wakeup event to break stop mode. */
|
||||||
EXTI->EMR |= (1 << 18); /* Event mask cleared */
|
EXTI->EMR |= (1 << 18); /* Event mask cleared */
|
||||||
|
EXTI->RTSR |= (1 << 18); /* Rising trigger selection */
|
||||||
|
#endif
|
||||||
}
|
}
|
||||||
|
|
||||||
void usb_lld_prepare_shutdown (void)
|
void usb_lld_prepare_shutdown (void)
|
||||||
|
|||||||
Reference in New Issue
Block a user