summaryrefslogtreecommitdiff
path: root/port/kinetis/usb_glue_mm32.c
blob: 75e722c495df763205c7934e51a99c72dc6212d2 (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
#include <stdio.h>
#include <string.h>

#include "mm32_device.h"
#include "hal_rcc.h"
#include "usbd_core.h"

void usb_dc_low_level_init(uint8_t busid)
{
    /* Select USBCLK source */
    //  RCC_USBCLKConfig(RCC_USBCLKSource_PLLCLK_Div1);
    RCC->CFGR &= ~(0x3 << 22);
    RCC->CFGR |= (0x1 << 22);

    /* Enable USB clock */
    RCC->AHB2ENR |= 0x1 << 7;

#define USB_DEVICE_INTERRUPT_PRIORITY (7U)
    NVIC_SetPriority((IRQn_Type)USB_OTGFS_IRQn, USB_DEVICE_INTERRUPT_PRIORITY);
    NVIC_EnableIRQ(USB_OTGFS_IRQn);
}

void usb_dc_low_level_deinit(uint8_t busid)
{
    RCC->AHB2ENR &= ~(0x1 << 7);
}

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

void usbd_kinetis_delay_ms(uint8_t ms)
{
    //delay_ms(ms);
}