Skip to content

Commit fbb60ef

Browse files
committed
update(port/kinetis): update mcx glue for mcxa153/mcxc444
1 parent 83b5d84 commit fbb60ef

File tree

2 files changed

+33
-9
lines changed

2 files changed

+33
-9
lines changed

port/kinetis/README.md

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -10,8 +10,8 @@ Modify USB_NOCACHE_RAM_SECTION
1010
#define USB_NOCACHE_RAM_SECTION __attribute__((section(".NonCacheable")))
1111
```
1212

13-
- MCXC/MCXA (device only)
14-
- MCXN
13+
- MCXC444/MCXA153 (device only)
14+
- MCXN947
1515

1616
### MM32
1717

port/kinetis/usb_glue_mcx.c

Lines changed: 31 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -9,26 +9,51 @@
99

1010
#define USB_OTG_DEV ((KINETIS_MCX_TypeDef *)g_usbdev_bus[busid].reg_base)
1111

12-
void USB0_FS_IRQHandler(void)
12+
#if defined(MCXC444_H_)
13+
#define USBD_IRQHandler USB0_IRQHandler
14+
void USB_ClockInit(void)
1315
{
14-
extern void USBD_IRQHandler(uint8_t busid);
15-
USBD_IRQHandler(0);
16+
SystemCoreClockUpdate();
17+
CLOCK_EnableUsbfs0Clock(kCLOCK_UsbSrcIrc48M, 48000000U);
1618
}
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
1828
void USB_ClockInit(void)
1929
{
2030
CLOCK_AttachClk(kCLK_48M_to_USB0);
2131
CLOCK_EnableClock(kCLOCK_Usb0Ram);
2232
CLOCK_EnableClock(kCLOCK_Usb0Fs);
2333
CLOCK_EnableUsbfsClock();
2434
}
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+
}
2544

2645
void usb_dc_low_level_init(uint8_t busid)
2746
{
2847
USB_ClockInit();
48+
49+
uint8_t irqNumber;
50+
51+
uint8_t usbDeviceKhciIrq[] = USB_IRQS;
52+
irqNumber = usbDeviceKhciIrq[0];
53+
2954
/* 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);
3257

3358
USB_OTG_DEV->USBTRC0 |= USB_USBTRC0_USBRESET_MASK;
3459
while (USB_OTG_DEV->USBTRC0 & USB_USBTRC0_USBRESET_MASK)
@@ -47,5 +72,4 @@ void usb_dc_low_level_deinit(uint8_t busid)
4772

4873
void usbd_kinetis_delay_ms(uint8_t ms)
4974
{
50-
5175
}

0 commit comments

Comments
 (0)