summaryrefslogtreecommitdiffstatshomepage
path: root/stmhal/stm32_it.c
diff options
context:
space:
mode:
authorneilh10 <neilh20@wLLw.net>2015-12-08 14:02:34 -0800
committerDamien George <damien.p.george@gmail.com>2015-12-09 09:56:36 +0000
commit1be0fde45c8d84eaf04851af96f06aad8171b2b2 (patch)
tree6dd5ee8b27c3d6493bf1718775f766d7e96e0743 /stmhal/stm32_it.c
parent0891cf7d2d6bfe1d3daf625213ddc99b78102f1e (diff)
downloadmicropython-1be0fde45c8d84eaf04851af96f06aad8171b2b2.tar.gz
micropython-1be0fde45c8d84eaf04851af96f06aad8171b2b2.zip
stmhal: Enable two USB phys to be supported together.
This is refactoring to enable support for the two USB PHYs available on some STM32F4 processors to be used at the same time. The F405/7 & F429 have two USB PHYs, others such as the F411 only have one PHY. This has been tested separately on a pyb10 (USB_FS PHY) and F429DISC (USB_HS PHY) to be able to invoke a REPL/USB. I have modified a PYBV10 to support two PHYs. The long term objective is to support a 2nd USB PHY to be brought up as a USB HOST, and possibly a single USB PHY to be OTG.
Diffstat (limited to 'stmhal/stm32_it.c')
-rw-r--r--stmhal/stm32_it.c64
1 files changed, 43 insertions, 21 deletions
diff --git a/stmhal/stm32_it.c b/stmhal/stm32_it.c
index 371d20dd7c..fec663ea74 100644
--- a/stmhal/stm32_it.c
+++ b/stmhal/stm32_it.c
@@ -80,8 +80,8 @@
#include "dma.h"
extern void __fatal_error(const char*);
-extern PCD_HandleTypeDef pcd_handle;
-
+extern PCD_HandleTypeDef pcd_fs_handle;
+extern PCD_HandleTypeDef pcd_hs_handle;
/******************************************************************************/
/* Cortex-M4 Processor Exceptions Handlers */
/******************************************************************************/
@@ -305,28 +305,25 @@ void SysTick_Handler(void) {
* @retval None
*/
#if defined(USE_USB_FS)
-#define OTG_XX_IRQHandler OTG_FS_IRQHandler
-#define OTG_XX_WKUP_IRQHandler OTG_FS_WKUP_IRQHandler
-#elif defined(USE_USB_HS)
-#define OTG_XX_IRQHandler OTG_HS_IRQHandler
-#define OTG_XX_WKUP_IRQHandler OTG_HS_WKUP_IRQHandler
+void OTG_FS_IRQHandler(void) {
+ HAL_PCD_IRQHandler(&pcd_fs_handle);
+}
#endif
-
-#if defined(OTG_XX_IRQHandler)
-void OTG_XX_IRQHandler(void) {
- HAL_PCD_IRQHandler(&pcd_handle);
+#if defined(USE_USB_HS)
+void OTG_HS_IRQHandler(void) {
+ HAL_PCD_IRQHandler(&pcd_hs_handle);
}
#endif
+#if defined(USE_USB_FS) || defined(USE_USB_HS)
/**
- * @brief This function handles USB OTG FS or HS Wakeup IRQ Handler.
- * @param None
+ * @brief This function handles USB OTG Common FS/HS Wakeup functions.
+ * @param *pcd_handle for FS or HS
* @retval None
*/
-#if defined(OTG_XX_WKUP_IRQHandler)
-void OTG_XX_WKUP_IRQHandler(void) {
+STATIC void OTG_CMD_WKUP_Handler(PCD_HandleTypeDef *pcd_handle) {
- if ((&pcd_handle)->Init.low_power_enable) {
+ if (pcd_handle->Init.low_power_enable) {
/* Reset SLEEPDEEP bit of Cortex System Control Register */
SCB->SCR &= (uint32_t)~((uint32_t)(SCB_SCR_SLEEPDEEP_Msk | SCB_SCR_SLEEPONEXIT_Msk));
@@ -353,16 +350,41 @@ void OTG_XX_WKUP_IRQHandler(void) {
{}
/* ungate PHY clock */
- __HAL_PCD_UNGATE_PHYCLOCK((&pcd_handle));
+ __HAL_PCD_UNGATE_PHYCLOCK(pcd_handle);
}
-#ifdef USE_USB_FS
+
+}
+#endif
+
+#if defined(USE_USB_FS)
+/**
+ * @brief This function handles USB OTG FS Wakeup IRQ Handler.
+ * @param None
+ * @retval None
+ */
+void OTG_FS_WKUP_IRQHandler(void) {
+
+ OTG_CMD_WKUP_Handler(&pcd_fs_handle);
+
/* Clear EXTI pending Bit*/
__HAL_USB_FS_EXTI_CLEAR_FLAG();
-#elif defined(USE_USB_HS)
- /* Clear EXTI pending Bit*/
- __HAL_USB_HS_EXTI_CLEAR_FLAG();
+
+}
#endif
+#if defined(USE_USB_HS)
+/**
+ * @brief This function handles USB OTG HS Wakeup IRQ Handler.
+ * @param None
+ * @retval None
+ */
+void OTG_HS_WKUP_IRQHandler(void) {
+
+ OTG_CMD_WKUP_Handler(&pcd_hs_handle);
+
+ /* Clear EXTI pending Bit*/
+ __HAL_USB_HS_EXTI_CLEAR_FLAG();
+
}
#endif