summaryrefslogtreecommitdiff
path: root/port/fsdev/usb_glue_st.c
blob: 70a98acb7a1d9a24dd735460d2373cc50cecb48d (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
/*
 * Copyright (c) 2025, sakumisu
 *
 * SPDX-License-Identifier: Apache-2.0
 */
#include "usbd_core.h"

#if __has_include("stm32f0xx_hal.h")
#include "stm32f0xx_hal.h"
#elif __has_include("stm32f1xx_hal.h")
#include "stm32f1xx_hal.h"
#elif __has_include("stm32f3xx_hal.h")
#include "stm32f3xx_hal.h"
#elif __has_include("stm32g0xx_hal.h")
#include "stm32g0xx_hal.h"
#elif __has_include("stm32g4xx_hal.h")
#include "stm32g4xx_hal.h"
#elif __has_include("stm32l0xx_hal.h")
#include "stm32l0xx_hal.h"
#elif __has_include("stm32l1xx_hal.h")
#include "stm32l1xx_hal.h"
#elif __has_include("stm32l4xx_hal.h")
#include "stm32l4xx_hal.h"
#elif __has_include("stm32l5xx_hal.h")
#include "stm32l5xx_hal.h"
#endif

#if !defined(HAL_PCD_MODULE_ENABLED)
#error please define HAL_PCD_MODULE_ENABLED in stm32xxx_hal_conf.h
#endif

#ifndef CONFIG_USBDEV_FSDEV_PMA_ACCESS
#error "please define CONFIG_USBDEV_FSDEV_PMA_ACCESS in usb_config.h"
#endif

#if CONFIG_USBDEV_FSDEV_PMA_ACCESS != PMA_ACCESS
#error "CONFIG_USBDEV_FSDEV_PMA_ACCESS must be equal PMA_ACCESS"
#endif

struct fsdev_instance {
    USB_TypeDef *Instance;
};

static struct fsdev_instance g_fsdev_instance;

void usb_dc_low_level_init(uint8_t busid)
{
    g_fsdev_instance.Instance = (USB_TypeDef *)g_usbdev_bus[busid].reg_base;
    HAL_PCD_MspInit((PCD_HandleTypeDef *)&g_fsdev_instance);
}

void usb_dc_low_level_deinit(uint8_t busid)
{
    g_fsdev_instance.Instance = (USB_TypeDef *)g_usbdev_bus[busid].reg_base;
    HAL_PCD_MspDeInit((PCD_HandleTypeDef *)&g_fsdev_instance);
}

void USB_IRQHandler(void)
{
    USBD_IRQHandler(0);
}

void USB_LP_IRQHandler(void)
{
    USBD_IRQHandler(0);
}