Fork of https://developer.mbed.org/users/bscott/code/STM32_USBDevice/
Fork of STM32_USBDevice by
Diff: USBDevice/USBHAL_STM32L1.cpp
- Revision:
- 67:6099ce7e71c9
- Parent:
- 66:b129e98ab7a0
- Child:
- 68:f8305faf7917
--- a/USBDevice/USBHAL_STM32L1.cpp Wed Sep 21 20:28:24 2016 +0100 +++ b/USBDevice/USBHAL_STM32L1.cpp Mon Oct 24 17:40:10 2016 +0100 @@ -80,12 +80,11 @@ void HAL_PCD_MspInit(PCD_HandleTypeDef* hpcd) { __USB_CLK_ENABLE(); HAL_NVIC_SetPriority(USB_LP_IRQn, 0, 0); - HAL_NVIC_EnableIRQ(USB_LP_IRQn); } void HAL_PCD_MspDeInit(PCD_HandleTypeDef* hpcd) { + HAL_NVIC_DisableIRQ(USB_LP_IRQn); // Peripheral interrupt Deinit __USB_CLK_DISABLE(); // Peripheral clock disable - HAL_NVIC_DisableIRQ(USB_LP_IRQn); // Peripheral interrupt Deinit } USBHAL::~USBHAL(void) { @@ -93,11 +92,13 @@ } void USBHAL::connect(void) { + HAL_NVIC_EnableIRQ(USB_LP_IRQn); HAL_PCD_DevConnect(&hpcd_USB_FS); } void USBHAL::disconnect(void) { HAL_PCD_DevDisconnect(&hpcd_USB_FS); + HAL_NVIC_DisableIRQ(USB_LP_IRQn); } void USBHAL::configureDevice(void) { @@ -254,8 +255,10 @@ } EP_STATUS USBHAL::endpointRead(uint8_t endpoint, uint32_t maximumSize) { + core_util_critical_section_enter(); HAL_PCD_EP_Receive(&hpcd_USB_FS, endpoint>>1, rxtmp.ptr(endpoint, maximumSize), maximumSize); epComplete &= ~(1 << endpoint); + core_util_critical_section_exit(); return EP_PENDING; } @@ -270,14 +273,18 @@ } EP_STATUS USBHAL::endpointWrite(uint8_t endpoint, uint8_t *data, uint32_t size) { + core_util_critical_section_enter(); HAL_PCD_EP_Transmit(&hpcd_USB_FS, endpoint>>1, data, size); epComplete &= ~(1 << endpoint); + core_util_critical_section_exit(); return EP_PENDING; } EP_STATUS USBHAL::endpointWriteResult(uint8_t endpoint) { if (epComplete & (1 << endpoint)) { + core_util_critical_section_enter(); epComplete &= ~(1 << endpoint); + core_util_critical_section_exit(); return EP_COMPLETED; } return EP_PENDING;