usb_glue_st.c 1.6 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566
  1. /*
  2. * Copyright (c) 2025, sakumisu
  3. *
  4. * SPDX-License-Identifier: Apache-2.0
  5. */
  6. #include "usbd_core.h"
  7. #if __has_include("stm32f0xx_hal.h")
  8. #include "stm32f0xx_hal.h"
  9. #elif __has_include("stm32f1xx_hal.h")
  10. #include "stm32f1xx_hal.h"
  11. #elif __has_include("stm32f3xx_hal.h")
  12. #include "stm32f3xx_hal.h"
  13. #elif __has_include("stm32g0xx_hal.h")
  14. #include "stm32g0xx_hal.h"
  15. #elif __has_include("stm32g4xx_hal.h")
  16. #include "stm32g4xx_hal.h"
  17. #elif __has_include("stm32l0xx_hal.h")
  18. #include "stm32l0xx_hal.h"
  19. #elif __has_include("stm32l1xx_hal.h")
  20. #include "stm32l1xx_hal.h"
  21. #elif __has_include("stm32l4xx_hal.h")
  22. #include "stm32l4xx_hal.h"
  23. #elif __has_include("stm32l5xx_hal.h")
  24. #include "stm32l5xx_hal.h"
  25. #endif
  26. #if !defined(HAL_PCD_MODULE_ENABLED)
  27. #error please define HAL_PCD_MODULE_ENABLED in stm32xxx_hal_conf.h
  28. #endif
  29. #ifndef CONFIG_USBDEV_FSDEV_PMA_ACCESS
  30. #error "please define CONFIG_USBDEV_FSDEV_PMA_ACCESS in usb_config.h"
  31. #endif
  32. #if CONFIG_USBDEV_FSDEV_PMA_ACCESS != PMA_ACCESS
  33. #error "CONFIG_USBDEV_FSDEV_PMA_ACCESS must be equal PMA_ACCESS"
  34. #endif
  35. struct fsdev_instance {
  36. USB_TypeDef *Instance;
  37. };
  38. static struct fsdev_instance g_fsdev_instance;
  39. void usb_dc_low_level_init(uint8_t busid)
  40. {
  41. g_fsdev_instance.Instance = (USB_TypeDef *)g_usbdev_bus[busid].reg_base;
  42. HAL_PCD_MspInit((PCD_HandleTypeDef *)&g_fsdev_instance);
  43. }
  44. void usb_dc_low_level_deinit(uint8_t busid)
  45. {
  46. g_fsdev_instance.Instance = (USB_TypeDef *)g_usbdev_bus[busid].reg_base;
  47. HAL_PCD_MspDeInit((PCD_HandleTypeDef *)&g_fsdev_instance);
  48. }
  49. void USB_IRQHandler(void)
  50. {
  51. USBD_IRQHandler(0);
  52. }
  53. void USB_LP_IRQHandler(void)
  54. {
  55. USBD_IRQHandler(0);
  56. }