summaryrefslogtreecommitdiffstatshomepage
diff options
context:
space:
mode:
authorDamien George <damien.p.george@gmail.com>2015-01-12 16:13:29 +0000
committerDamien George <damien.p.george@gmail.com>2015-01-12 16:13:29 +0000
commit131185a2b84de5432c33b2aa46bff8c2354297ca (patch)
tree1aff757cd5d22d338bc06323dc5acd0cce285264
parent7630d9ca0e7ed9dcea675b85923503f5d922f6ce (diff)
downloadmicropython-131185a2b84de5432c33b2aa46bff8c2354297ca.tar.gz
micropython-131185a2b84de5432c33b2aa46bff8c2354297ca.zip
stmhal: Add MICROPY_HW_USB_OTG_ID_PIN config, set for relevant boards.
This config option is for the USB OTG pin, pin A10. This is used on some boards but not others. Eg PYBv3 uses PA10 for LED(2), so it shouldn't be used for OTG ID (actually PA10 is multiplexed on this board, but defaults to LED(2)). Partially addresses issue #1059.
-rw-r--r--stmhal/boards/HYDRABUS/mpconfigboard.h3
-rw-r--r--stmhal/boards/NETDUINO_PLUS_2/stm32f4xx_hal_conf.h1
-rw-r--r--stmhal/boards/PYBV10/mpconfigboard.h3
-rw-r--r--stmhal/boards/PYBV4/mpconfigboard.h3
-rw-r--r--stmhal/boards/STM32F4DISC/mpconfigboard.h3
-rw-r--r--stmhal/usbd_conf.c7
6 files changed, 11 insertions, 9 deletions
diff --git a/stmhal/boards/HYDRABUS/mpconfigboard.h b/stmhal/boards/HYDRABUS/mpconfigboard.h
index 9a3f054520..0109930cad 100644
--- a/stmhal/boards/HYDRABUS/mpconfigboard.h
+++ b/stmhal/boards/HYDRABUS/mpconfigboard.h
@@ -37,3 +37,6 @@
#define MICROPY_HW_SDCARD_DETECT_PIN (pin_A8)
#define MICROPY_HW_SDCARD_DETECT_PULL (GPIO_PULLUP)
#define MICROPY_HW_SDCARD_DETECT_PRESENT (1)
+
+// USB config
+#define MICROPY_HW_USB_OTG_ID_PIN (pin_A10)
diff --git a/stmhal/boards/NETDUINO_PLUS_2/stm32f4xx_hal_conf.h b/stmhal/boards/NETDUINO_PLUS_2/stm32f4xx_hal_conf.h
index 8d15635664..f266732d5c 100644
--- a/stmhal/boards/NETDUINO_PLUS_2/stm32f4xx_hal_conf.h
+++ b/stmhal/boards/NETDUINO_PLUS_2/stm32f4xx_hal_conf.h
@@ -48,7 +48,6 @@
#define STM32F405xx
#define USE_USB_FS
-#define USE_USB_OTG_ID 0
/* ########################## Module Selection ############################## */
/**
diff --git a/stmhal/boards/PYBV10/mpconfigboard.h b/stmhal/boards/PYBV10/mpconfigboard.h
index 48c40e9936..25472ba696 100644
--- a/stmhal/boards/PYBV10/mpconfigboard.h
+++ b/stmhal/boards/PYBV10/mpconfigboard.h
@@ -39,5 +39,6 @@
#define MICROPY_HW_SDCARD_DETECT_PULL (GPIO_PULLUP)
#define MICROPY_HW_SDCARD_DETECT_PRESENT (GPIO_PIN_RESET)
-// USB VBUS detect pin
+// USB config
#define MICROPY_HW_USB_VBUS_DETECT_PIN (pin_A9)
+#define MICROPY_HW_USB_OTG_ID_PIN (pin_A10)
diff --git a/stmhal/boards/PYBV4/mpconfigboard.h b/stmhal/boards/PYBV4/mpconfigboard.h
index a72da6f528..6663175f7a 100644
--- a/stmhal/boards/PYBV4/mpconfigboard.h
+++ b/stmhal/boards/PYBV4/mpconfigboard.h
@@ -38,5 +38,6 @@
#define MICROPY_HW_SDCARD_DETECT_PULL (GPIO_PULLUP)
#define MICROPY_HW_SDCARD_DETECT_PRESENT (GPIO_PIN_RESET)
-// USB VBUS detect pin
+// USB config
#define MICROPY_HW_USB_VBUS_DETECT_PIN (pin_A9)
+#define MICROPY_HW_USB_OTG_ID_PIN (pin_A10)
diff --git a/stmhal/boards/STM32F4DISC/mpconfigboard.h b/stmhal/boards/STM32F4DISC/mpconfigboard.h
index b2ccefda5f..bf26f641db 100644
--- a/stmhal/boards/STM32F4DISC/mpconfigboard.h
+++ b/stmhal/boards/STM32F4DISC/mpconfigboard.h
@@ -33,5 +33,6 @@
#define MICROPY_HW_LED_ON(pin) (pin->gpio->BSRRL = pin->pin_mask)
#define MICROPY_HW_LED_OFF(pin) (pin->gpio->BSRRH = pin->pin_mask)
-// USB VBUS detect pin
+// USB config
#define MICROPY_HW_USB_VBUS_DETECT_PIN (pin_A9)
+#define MICROPY_HW_USB_OTG_ID_PIN (pin_A10)
diff --git a/stmhal/usbd_conf.c b/stmhal/usbd_conf.c
index 2ff31c9892..eddf1d6264 100644
--- a/stmhal/usbd_conf.c
+++ b/stmhal/usbd_conf.c
@@ -33,10 +33,6 @@
#include "stm32f4xx_hal.h"
#include "usbd_core.h"
-#if !defined(USE_USB_OTG_ID)
-#define USE_USB_OTG_ID 1
-#endif
-
/* Private typedef -----------------------------------------------------------*/
/* Private define ------------------------------------------------------------*/
/* Private macro -------------------------------------------------------------*/
@@ -79,7 +75,8 @@ void HAL_PCD_MspInit(PCD_HandleTypeDef *hpcd)
HAL_GPIO_Init(GPIOA, &GPIO_InitStruct);
#endif
-#if USE_USB_OTG_ID
+#if defined(MICROPY_HW_USB_OTG_ID_PIN)
+ // USB ID pin is always A10
GPIO_InitStruct.Pin = GPIO_PIN_10;
GPIO_InitStruct.Mode = GPIO_MODE_AF_OD;
GPIO_InitStruct.Pull = GPIO_PULLUP;