summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorsakumisu <[email protected]>2024-10-11 18:48:32 +0800
committersakumisu <[email protected]>2024-10-11 20:02:39 +0800
commita20e312b556c34bf096410b755bf9edc2c580065 (patch)
treed00fb3ea001ef50d7270abf08cf15cbcc1a2a650
parent83b5d842c79b446ad1ca2d869db295350f7c1334 (diff)
update(port/kinetis): update mcx glue for mcxa153/mcxc444
-rw-r--r--port/kinetis/README.md4
-rw-r--r--port/kinetis/usb_glue_mcx.c38
2 files changed, 33 insertions, 9 deletions
diff --git a/port/kinetis/README.md b/port/kinetis/README.md
index 23598736..f51c9a67 100644
--- a/port/kinetis/README.md
+++ b/port/kinetis/README.md
@@ -10,8 +10,8 @@ Modify USB_NOCACHE_RAM_SECTION
#define USB_NOCACHE_RAM_SECTION __attribute__((section(".NonCacheable")))
```
-- MCXC/MCXA (device only)
-- MCXN
+- MCXC444/MCXA153 (device only)
+- MCXN947
### MM32
diff --git a/port/kinetis/usb_glue_mcx.c b/port/kinetis/usb_glue_mcx.c
index 40710adf..44607794 100644
--- a/port/kinetis/usb_glue_mcx.c
+++ b/port/kinetis/usb_glue_mcx.c
@@ -9,12 +9,22 @@
#define USB_OTG_DEV ((KINETIS_MCX_TypeDef *)g_usbdev_bus[busid].reg_base)
-void USB0_FS_IRQHandler(void)
+#if defined(MCXC444_H_)
+#define USBD_IRQ USB0_IRQHandler
+void USB_ClockInit(void)
{
- extern void USBD_IRQHandler(uint8_t busid);
- USBD_IRQHandler(0);
+ SystemCoreClockUpdate();
+ CLOCK_EnableUsbfs0Clock(kCLOCK_UsbSrcIrc48M, 48000000U);
}
-
+#elif defined(MCXA153_H_)
+#define USBD_IRQ USB0_IRQHandler
+void USB_ClockInit(void)
+{
+ RESET_PeripheralReset(kUSB0_RST_SHIFT_RSTn);
+ CLOCK_EnableUsbfsClock();
+}
+#elif defined(MCXN947_CM33_CORE0_H_)
+#define USBD_IRQ USB0_FS_IRQHandler
void USB_ClockInit(void)
{
CLOCK_AttachClk(kCLK_48M_to_USB0);
@@ -22,13 +32,28 @@ void USB_ClockInit(void)
CLOCK_EnableClock(kCLOCK_Usb0Fs);
CLOCK_EnableUsbfsClock();
}
+#else
+#error "Unsupported MCU with Kinetis IP"
+#endif
+
+void USBD_IRQ(void)
+{
+ extern void USBD_IRQHandler(uint8_t busid);
+ USBD_IRQHandler(0);
+}
void usb_dc_low_level_init(uint8_t busid)
{
USB_ClockInit();
+
+ uint8_t irqNumber;
+
+ uint8_t usbDeviceKhciIrq[] = USB_IRQS;
+ irqNumber = usbDeviceKhciIrq[0];
+
/* Install isr, set priority, and enable IRQ. */
- NVIC_SetPriority((IRQn_Type)USB0_FS_IRQn, 3);
- EnableIRQ((IRQn_Type)USB0_FS_IRQn);
+ NVIC_SetPriority((IRQn_Type)irqNumber, 3);
+ EnableIRQ((IRQn_Type)irqNumber);
USB_OTG_DEV->USBTRC0 |= USB_USBTRC0_USBRESET_MASK;
while (USB_OTG_DEV->USBTRC0 & USB_USBTRC0_USBRESET_MASK)
@@ -47,5 +72,4 @@ void usb_dc_low_level_deinit(uint8_t busid)
void usbd_kinetis_delay_ms(uint8_t ms)
{
-
} \ No newline at end of file