stmhal: Add MICROPY_HW_USB_VBUS_DETECT_PIN option, for boards without it

Since all currently supported boards use pin A9 for this function, the
value of the macro MICROPY_HW_USB_VBUS_DETECT_PIN is not actually used,
just the fact that it is defined.

Addresses issue #1048.
This commit is contained in:
Damien George 2015-01-07 23:54:57 +00:00
parent c223df5113
commit 181bfb6db2
6 changed files with 20 additions and 2 deletions

View File

@ -36,3 +36,6 @@
#define MICROPY_HW_LED_OTYPE (GPIO_MODE_OUTPUT_PP) #define MICROPY_HW_LED_OTYPE (GPIO_MODE_OUTPUT_PP)
#define MICROPY_HW_LED_ON(pin) (pin->gpio->BSRRL = pin->pin_mask) #define MICROPY_HW_LED_ON(pin) (pin->gpio->BSRRL = pin->pin_mask)
#define MICROPY_HW_LED_OFF(pin) (pin->gpio->BSRRH = pin->pin_mask) #define MICROPY_HW_LED_OFF(pin) (pin->gpio->BSRRH = pin->pin_mask)
// USB VBUS detect pin
#define MICROPY_HW_USB_VBUS_DETECT_PIN (pin_A9)

View File

@ -38,3 +38,6 @@
#define MICROPY_HW_SDCARD_DETECT_PIN (pin_A8) #define MICROPY_HW_SDCARD_DETECT_PIN (pin_A8)
#define MICROPY_HW_SDCARD_DETECT_PULL (GPIO_PULLUP) #define MICROPY_HW_SDCARD_DETECT_PULL (GPIO_PULLUP)
#define MICROPY_HW_SDCARD_DETECT_PRESENT (GPIO_PIN_RESET) #define MICROPY_HW_SDCARD_DETECT_PRESENT (GPIO_PIN_RESET)
// USB VBUS detect pin
#define MICROPY_HW_USB_VBUS_DETECT_PIN (pin_A9)

View File

@ -37,3 +37,6 @@
#define MICROPY_HW_SDCARD_DETECT_PIN (pin_C13) #define MICROPY_HW_SDCARD_DETECT_PIN (pin_C13)
#define MICROPY_HW_SDCARD_DETECT_PULL (GPIO_PULLDOWN) #define MICROPY_HW_SDCARD_DETECT_PULL (GPIO_PULLDOWN)
#define MICROPY_HW_SDCARD_DETECT_PRESENT (GPIO_PIN_SET) #define MICROPY_HW_SDCARD_DETECT_PRESENT (GPIO_PIN_SET)
// USB VBUS detect pin
#define MICROPY_HW_USB_VBUS_DETECT_PIN (pin_A9)

View File

@ -37,3 +37,6 @@
#define MICROPY_HW_SDCARD_DETECT_PIN (pin_A8) #define MICROPY_HW_SDCARD_DETECT_PIN (pin_A8)
#define MICROPY_HW_SDCARD_DETECT_PULL (GPIO_PULLUP) #define MICROPY_HW_SDCARD_DETECT_PULL (GPIO_PULLUP)
#define MICROPY_HW_SDCARD_DETECT_PRESENT (GPIO_PIN_RESET) #define MICROPY_HW_SDCARD_DETECT_PRESENT (GPIO_PIN_RESET)
// USB VBUS detect pin
#define MICROPY_HW_USB_VBUS_DETECT_PIN (pin_A9)

View File

@ -32,3 +32,6 @@
#define MICROPY_HW_LED_OTYPE (GPIO_MODE_OUTPUT_PP) #define MICROPY_HW_LED_OTYPE (GPIO_MODE_OUTPUT_PP)
#define MICROPY_HW_LED_ON(pin) (pin->gpio->BSRRL = pin->pin_mask) #define MICROPY_HW_LED_ON(pin) (pin->gpio->BSRRL = pin->pin_mask)
#define MICROPY_HW_LED_OFF(pin) (pin->gpio->BSRRH = pin->pin_mask) #define MICROPY_HW_LED_OFF(pin) (pin->gpio->BSRRH = pin->pin_mask)
// USB VBUS detect pin
#define MICROPY_HW_USB_VBUS_DETECT_PIN (pin_A9)

View File

@ -71,10 +71,13 @@ void HAL_PCD_MspInit(PCD_HandleTypeDef *hpcd)
HAL_GPIO_Init(GPIOA, &GPIO_InitStruct); HAL_GPIO_Init(GPIOA, &GPIO_InitStruct);
/* Configure VBUS Pin */ /* Configure VBUS Pin */
#if defined(MICROPY_HW_USB_VBUS_DETECT_PIN)
// USB VBUS detect pin is always A9
GPIO_InitStruct.Pin = GPIO_PIN_9; GPIO_InitStruct.Pin = GPIO_PIN_9;
GPIO_InitStruct.Mode = GPIO_MODE_INPUT; GPIO_InitStruct.Mode = GPIO_MODE_INPUT;
GPIO_InitStruct.Pull = GPIO_NOPULL; GPIO_InitStruct.Pull = GPIO_NOPULL;
HAL_GPIO_Init(GPIOA, &GPIO_InitStruct); HAL_GPIO_Init(GPIOA, &GPIO_InitStruct);
#endif
#if USE_USB_OTG_ID #if USE_USB_OTG_ID
GPIO_InitStruct.Pin = GPIO_PIN_10; GPIO_InitStruct.Pin = GPIO_PIN_10;
@ -340,8 +343,8 @@ USBD_StatusTypeDef USBD_LL_Init (USBD_HandleTypeDef *pdev)
hpcd.Init.phy_itface = PCD_PHY_EMBEDDED; hpcd.Init.phy_itface = PCD_PHY_EMBEDDED;
hpcd.Init.Sof_enable = 0; hpcd.Init.Sof_enable = 0;
hpcd.Init.speed = PCD_SPEED_FULL; hpcd.Init.speed = PCD_SPEED_FULL;
#if defined(HYDRABUSV10) #if !defined(MICROPY_HW_USB_VBUS_DETECT_PIN)
hpcd.Init.vbus_sensing_enable = 0; /* No VBUS Sensing on USB0 for HydraBus (VBUS is not connected on GPIOA9) */ hpcd.Init.vbus_sensing_enable = 0; // No VBUS Sensing on USB0
#else #else
hpcd.Init.vbus_sensing_enable = 1; hpcd.Init.vbus_sensing_enable = 1;
#endif #endif