Skip to content

Commit dab09f3

Browse files
committed
STM32 USB redesign step 1
No more need to explicitly configure each targets. Pins are now defined in the PeripheralPin.c file which is build by a script.
1 parent 3950fd0 commit dab09f3

File tree

3 files changed

+112
-233
lines changed

3 files changed

+112
-233
lines changed

targets/TARGET_STM/USBEndpoints_STM32.h

Lines changed: 0 additions & 65 deletions
This file was deleted.

targets/TARGET_STM/USBPhyHw.h

Lines changed: 26 additions & 18 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,6 @@
11
/* mbed Microcontroller Library
2-
* Copyright (c) 2018-2018 ARM Limited
2+
* Copyright (c) 2018-2019 ARM Limited
3+
* Copyright (c) 2018-2019 STMicroelectronics
34
*
45
* Licensed under the Apache License, Version 2.0 (the "License");
56
* you may not use this file except in compliance with the License.
@@ -19,34 +20,41 @@
1920

2021
#include "mbed.h"
2122
#include "USBPhy.h"
23+
#include "PeripheralPins.h"
2224

23-
#if defined(TARGET_DISCO_F746NG)
24-
#if (MBED_CONF_TARGET_USB_SPEED == 1) // Defined in json configuration file
25-
#define TARGET_DISCO_F746NG_OTG_HS
25+
#if !defined(MBED_CONF_TARGET_USB_SPEED)
26+
27+
#if defined (USB)
28+
#define MBED_CONF_TARGET_USB_SPEED USE_USB_NO_OTG
29+
#elif defined(USB_OTG_FS)
30+
#define MBED_CONF_TARGET_USB_SPEED USE_USB_OTG_FS
2631
#else
27-
#define TARGET_DISCO_F746NG_OTG_FS
28-
#endif
32+
#define MBED_CONF_TARGET_USB_SPEED USE_USB_OTG_HS
2933
#endif
3034

31-
#if defined(TARGET_DISCO_F429ZI) || \
32-
defined(TARGET_DISCO_F769NI) || \
33-
defined(TARGET_DISCO_F746NG_OTG_HS)
34-
#define USBHAL_IRQn OTG_HS_IRQn
35+
#endif /* !defined(MBED_CONF_TARGET_USB_SPEED) */
36+
37+
#if MBED_CONF_TARGET_USB_SPEED == USE_USB_NO_OTG
38+
39+
#if defined(TARGET_STM32F3) || defined(TARGET_STM32WB)
40+
#define USBHAL_IRQn USB_HP_IRQn
3541
#else
36-
#define USBHAL_IRQn OTG_FS_IRQn
42+
#define USBHAL_IRQn USB_IRQn
3743
#endif
3844

39-
#include "USBEndpoints_STM32.h"
45+
#elif (MBED_CONF_TARGET_USB_SPEED == USE_USB_OTG_FS)
46+
#define USBHAL_IRQn OTG_FS_IRQn
4047

41-
#define NB_ENDPOINT 4 // Must be a multiple of 4 bytes
48+
#else
49+
#define USBHAL_IRQn OTG_HS_IRQn
4250

43-
#define MAXTRANSFER_SIZE 0x200
51+
#endif
4452

45-
#define FIFO_USB_RAM_SIZE (MAXTRANSFER_SIZE + MAX_PACKET_SIZE_EP0 + MAX_PACKET_SIZE_EP1 + MAX_PACKET_SIZE_EP2 + MAX_PACKET_SIZE_EP3)
53+
#define NB_ENDPOINT 16
4654

47-
#if (FIFO_USB_RAM_SIZE > 0x500)
48-
#error "FIFO dimensioning incorrect"
49-
#endif
55+
// #define MAXTRANSFER_SIZE 0x200
56+
#define MAX_PACKET_SIZE_SETUP (48)
57+
#define MAX_PACKET_SIZE_EP0 (64)
5058

5159
class USBPhyHw : public USBPhy {
5260
public:

0 commit comments

Comments
 (0)