SN32F24xB: Add remote wakeup and examples of suspend handling
This commit is contained in:
parent
8f693258a3
commit
52acdb5527
|
@ -213,6 +213,12 @@ static void usb_lld_serve_interrupt(USBDriver *usbp)
|
||||||
/* Suspend */
|
/* Suspend */
|
||||||
__USB_CLRINSTS(mskBUS_SUSPEND);
|
__USB_CLRINSTS(mskBUS_SUSPEND);
|
||||||
_usb_suspend(usbp);
|
_usb_suspend(usbp);
|
||||||
|
//USB suspend will put MCU in sleep mode with lower clock
|
||||||
|
//and disable execution of user code allowing only interrupt to execute
|
||||||
|
//keeping it here just for reference on how to could be done
|
||||||
|
//not necessary for remote wakeup to work
|
||||||
|
//uncomment if want to experiment with suspend mode
|
||||||
|
//USB_SuspendEvent();
|
||||||
}
|
}
|
||||||
else if(iwIntFlag & mskBUS_RESUME)
|
else if(iwIntFlag & mskBUS_RESUME)
|
||||||
{
|
{
|
||||||
|
|
|
@ -28,6 +28,7 @@
|
||||||
#if (HAL_USE_USB == TRUE) || defined(__DOXYGEN__)
|
#if (HAL_USE_USB == TRUE) || defined(__DOXYGEN__)
|
||||||
|
|
||||||
#include "sn32_usb.h"
|
#include "sn32_usb.h"
|
||||||
|
#include "usbhw.h"
|
||||||
|
|
||||||
/*===========================================================================*/
|
/*===========================================================================*/
|
||||||
/* Driver constants. */
|
/* Driver constants. */
|
||||||
|
@ -362,7 +363,9 @@ struct USBDriver {
|
||||||
*
|
*
|
||||||
* @notapi
|
* @notapi
|
||||||
*/
|
*/
|
||||||
#define usb_lld_wakeup_host(usbp)
|
#define usb_lld_wakeup_host(usbp) { \
|
||||||
|
USB_RemoteWakeUp(); \
|
||||||
|
}
|
||||||
|
|
||||||
/*===========================================================================*/
|
/*===========================================================================*/
|
||||||
/* External declarations. */
|
/* External declarations. */
|
||||||
|
|
|
@ -362,3 +362,31 @@ void USB_WakeupEvent(void)
|
||||||
__USB_CLRINSTS(mskBUS_WAKEUP); //** Clear BUS_WAKEUP
|
__USB_CLRINSTS(mskBUS_WAKEUP); //** Clear BUS_WAKEUP
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/*****************************************************************************
|
||||||
|
* Function : USB_SuspendEvent
|
||||||
|
* Description : puts MCU in sleep mode
|
||||||
|
* Input : None
|
||||||
|
* Output : None
|
||||||
|
* Return : None
|
||||||
|
* Note : None
|
||||||
|
*****************************************************************************/
|
||||||
|
void USB_SuspendEvent(void)
|
||||||
|
{
|
||||||
|
__USB_PHY_DISABLE;
|
||||||
|
SN_USB->INTEN = 0;
|
||||||
|
//** switch ILRC
|
||||||
|
SN_SYS0->CLKCFG = 0x01;
|
||||||
|
//** check ILRC status
|
||||||
|
while((SN_SYS0->CLKCFG & 0x10) != 0x10);
|
||||||
|
//** switch SYSCLK / 4 DO NOT set SYSCLK / 1 or SYSCLK / 2!!!!
|
||||||
|
SN_SYS0->AHBCP = 2;
|
||||||
|
//** disable IHRC
|
||||||
|
SN_SYS0->ANBCTRL = 0;
|
||||||
|
SN_USB->INTEN = (mskBUS_IE|mskUSB_IE|mskEPnACK_EN|mskBUSWK_IE);
|
||||||
|
SN_USB->INTEN |= mskEP1_NAK_EN;
|
||||||
|
SN_USB->INTEN |= mskEP2_NAK_EN;
|
||||||
|
SN_USB->INTEN |= mskEP3_NAK_EN;
|
||||||
|
SN_USB->INTEN |= mskEP4_NAK_EN;
|
||||||
|
SN_USB->INTEN |= mskUSB_SOF_IE;
|
||||||
|
SN_PMU->CTRL = 0x04;
|
||||||
|
}
|
|
@ -222,5 +222,6 @@ extern void USB_EPnBufferOffset(uint32_t wEPNum, uint32_t wAddr);
|
||||||
extern void USB_ReturntoNormal(void);
|
extern void USB_ReturntoNormal(void);
|
||||||
extern void USB_ResetEvent(void);
|
extern void USB_ResetEvent(void);
|
||||||
extern void USB_WakeupEvent(void);
|
extern void USB_WakeupEvent(void);
|
||||||
|
extern void USB_SuspendEvent(void);
|
||||||
|
|
||||||
#endif /* __USBHW_H__ */
|
#endif /* __USBHW_H__ */
|
||||||
|
|
Loading…
Reference in New Issue