Important changes to repositories hosted on mbed.com
Mbed hosted mercurial repositories are deprecated and are due to be permanently deleted in July 2026.
To keep a copy of this software download the repository Zip archive or clone locally using Mercurial.
It is also possible to export all your personal repositories from the account settings page.
Fork of F042K6_USBDevice by
Revision 75:a394ea726048, committed 2018-10-11
- Comitter:
- Bradley Scott
- Date:
- Thu Oct 11 11:12:35 2018 -0400
- Parent:
- 74:f9c09a6c750f
- Commit message:
- Add USB suspend support for STM32L1 (and other STM32 devices with same USB peripheral)
Changed in this revision
| USBDevice/USBHAL.h | Show annotated file Show diff for this revision Revisions of this file |
| USBDevice/USBHAL_STM32L1.cpp | Show annotated file Show diff for this revision Revisions of this file |
--- a/USBDevice/USBHAL.h Wed Oct 03 21:41:29 2018 +0000
+++ b/USBDevice/USBHAL.h Thu Oct 11 11:12:35 2018 -0400
@@ -124,6 +124,7 @@
void DataOutStageCallback(uint8_t epnum);
void ResetCallback();
void SOFCallback();
+ void SuspendCallback();
private:
class PacketBufferAreaManager {
--- a/USBDevice/USBHAL_STM32L1.cpp Wed Oct 03 21:41:29 2018 +0000
+++ b/USBDevice/USBHAL_STM32L1.cpp Thu Oct 11 11:12:35 2018 -0400
@@ -83,13 +83,13 @@
}
void HAL_PCD_MspInit(PCD_HandleTypeDef* hpcd) {
- __USB_CLK_ENABLE();
+ __HAL_RCC_USB_CLK_ENABLE();
HAL_NVIC_SetPriority(USB_LP_IRQn, 0, 0);
}
void HAL_PCD_MspDeInit(PCD_HandleTypeDef* hpcd) {
HAL_NVIC_DisableIRQ(USB_LP_IRQn); // Peripheral interrupt Deinit
- __USB_CLK_DISABLE(); // Peripheral clock disable
+ __HAL_RCC_USB_CLK_DISABLE(); // Peripheral clock disable
}
USBHAL::~USBHAL(void) {
@@ -367,11 +367,16 @@
}
void USBHAL::ResetCallback() {
+ suspendStateChanged(0);
PktBufArea.reset();
realiseEndpoint(EP0IN, MAX_PACKET_SIZE_EP0, 0);
realiseEndpoint(EP0OUT, MAX_PACKET_SIZE_EP0, 0);
}
+void USBHAL::SuspendCallback() {
+ suspendStateChanged(1);
+}
+
void USBHAL::SOFCallback() {
SOF(hpcd_USB_FS.Instance->FNR & USB_FNR_FN);
}
@@ -397,6 +402,7 @@
}
void HAL_PCD_SuspendCallback(PCD_HandleTypeDef *hpcd) {
+ reinterpret_cast<USBHAL*>(hpcd->pData)->SuspendCallback();
if (hpcd->Init.low_power_enable) {
SCB->SCR |= (uint32_t)((uint32_t)(SCB_SCR_SLEEPDEEP_Msk | SCB_SCR_SLEEPONEXIT_Msk));
}
