9
9
10
10
#define USB_OTG_DEV ((KINETIS_MCX_TypeDef *)g_usbdev_bus[busid].reg_base)
11
11
12
- void USB0_FS_IRQHandler (void )
12
+ #if defined(MCXC444_H_ )
13
+ #define USBD_IRQHandler USB0_IRQHandler
14
+ void USB_ClockInit (void )
13
15
{
14
- extern void USBD_IRQHandler ( uint8_t busid );
15
- USBD_IRQHandler ( 0 );
16
+ SystemCoreClockUpdate ( );
17
+ CLOCK_EnableUsbfs0Clock ( kCLOCK_UsbSrcIrc48M , 48000000U );
16
18
}
17
-
19
+ #elif defined(MCXA153_H_ )
20
+ #define USBD_IRQHandler USB0_IRQHandler
21
+ void USB_ClockInit (void )
22
+ {
23
+ RESET_PeripheralReset (kUSB0_RST_SHIFT_RSTn );
24
+ CLOCK_EnableUsbfsClock ();
25
+ }
26
+ #elif defined(MCXN947_CM33_CORE0_H_ )
27
+ #define USBD_IRQHandler USB0_FS_IRQHandler
18
28
void USB_ClockInit (void )
19
29
{
20
30
CLOCK_AttachClk (kCLK_48M_to_USB0 );
21
31
CLOCK_EnableClock (kCLOCK_Usb0Ram );
22
32
CLOCK_EnableClock (kCLOCK_Usb0Fs );
23
33
CLOCK_EnableUsbfsClock ();
24
34
}
35
+ #else
36
+ #error "Unsupported MCU with Kinetis IP"
37
+ #endif
38
+
39
+ void USBD_IRQHandler (void )
40
+ {
41
+ extern void USBD_IRQHandler (uint8_t busid );
42
+ USBD_IRQHandler (0 );
43
+ }
25
44
26
45
void usb_dc_low_level_init (uint8_t busid )
27
46
{
28
47
USB_ClockInit ();
48
+
49
+ uint8_t irqNumber ;
50
+
51
+ uint8_t usbDeviceKhciIrq [] = USB_IRQS ;
52
+ irqNumber = usbDeviceKhciIrq [0 ];
53
+
29
54
/* Install isr, set priority, and enable IRQ. */
30
- NVIC_SetPriority ((IRQn_Type )USB0_FS_IRQn , 3 );
31
- EnableIRQ ((IRQn_Type )USB0_FS_IRQn );
55
+ NVIC_SetPriority ((IRQn_Type )irqNumber , 3 );
56
+ EnableIRQ ((IRQn_Type )irqNumber );
32
57
33
58
USB_OTG_DEV -> USBTRC0 |= USB_USBTRC0_USBRESET_MASK ;
34
59
while (USB_OTG_DEV -> USBTRC0 & USB_USBTRC0_USBRESET_MASK )
@@ -47,5 +72,4 @@ void usb_dc_low_level_deinit(uint8_t busid)
47
72
48
73
void usbd_kinetis_delay_ms (uint8_t ms )
49
74
{
50
-
51
75
}
0 commit comments