stm32/usb: Guard USB device code with #if for whether USB is enabled.
With this change, all the USB source code can now be passed through the compiler even if the MCU does not have a USB peripheral.
This commit is contained in:
parent
ef4c8e6e97
commit
aa4a7a8732
@ -84,8 +84,12 @@
|
||||
#include "usb.h"
|
||||
|
||||
extern void __fatal_error(const char*);
|
||||
#if defined(MICROPY_HW_USB_FS)
|
||||
extern PCD_HandleTypeDef pcd_fs_handle;
|
||||
#endif
|
||||
#if defined(MICROPY_HW_USB_HS)
|
||||
extern PCD_HandleTypeDef pcd_hs_handle;
|
||||
#endif
|
||||
|
||||
/******************************************************************************/
|
||||
/* Cortex-M4 Processor Exceptions Handlers */
|
||||
|
@ -45,6 +45,8 @@
|
||||
#include "lib/utils/interrupt_char.h"
|
||||
#include "irq.h"
|
||||
|
||||
#if MICROPY_HW_ENABLE_USB
|
||||
|
||||
// CDC control commands
|
||||
#define CDC_SEND_ENCAPSULATED_COMMAND 0x00
|
||||
#define CDC_GET_ENCAPSULATED_RESPONSE 0x01
|
||||
@ -360,3 +362,5 @@ int usbd_cdc_rx(usbd_cdc_itf_t *cdc, uint8_t *buf, uint32_t len, uint32_t timeou
|
||||
// Success, return number of bytes read
|
||||
return len;
|
||||
}
|
||||
|
||||
#endif
|
||||
|
@ -35,6 +35,8 @@
|
||||
#include "irq.h"
|
||||
#include "usb.h"
|
||||
|
||||
#if MICROPY_HW_USB_FS || MICROPY_HW_USB_HS
|
||||
|
||||
#if MICROPY_HW_USB_FS
|
||||
PCD_HandleTypeDef pcd_fs_handle;
|
||||
#endif
|
||||
@ -663,4 +665,6 @@ void USBD_LL_Delay(uint32_t Delay) {
|
||||
HAL_Delay(Delay);
|
||||
}
|
||||
|
||||
#endif // MICROPY_HW_USB_FS || MICROPY_HW_USB_HS
|
||||
|
||||
/************************ (C) COPYRIGHT STMicroelectronics *****END OF FILE****/
|
||||
|
@ -28,6 +28,8 @@
|
||||
#include "usbd_ioreq.h"
|
||||
#include "usbd_cdc_msc_hid.h"
|
||||
|
||||
#if MICROPY_HW_ENABLE_USB
|
||||
|
||||
#define MSC_TEMPLATE_CONFIG_DESC_SIZE (32)
|
||||
#define MSC_TEMPLATE_MSC_DESC_OFFSET (9)
|
||||
#define CDC_TEMPLATE_CONFIG_DESC_SIZE (67)
|
||||
@ -1312,3 +1314,5 @@ const USBD_ClassTypeDef USBD_CDC_MSC_HID = {
|
||||
USBD_CDC_MSC_HID_GetCfgDesc,
|
||||
USBD_CDC_MSC_HID_GetDeviceQualifierDescriptor,
|
||||
};
|
||||
|
||||
#endif
|
||||
|
Loading…
Reference in New Issue
Block a user