|
1 | 1 | /* mbed Microcontroller Library
|
2 |
| - * Copyright (c) 2006-2013 ARM Limited |
| 2 | + * Copyright (c) 2006-2020 ARM Limited |
| 3 | + * SPDX-License-Identifier: Apache-2.0 |
3 | 4 | *
|
4 | 5 | * Licensed under the Apache License, Version 2.0 (the "License");
|
5 | 6 | * you may not use this file except in compliance with the License.
|
|
20 | 21 | #include "fsl_iomuxc.h"
|
21 | 22 | #include "fsl_gpio.h"
|
22 | 23 | #include "lpm.h"
|
| 24 | +#include "usb_phy.h" |
| 25 | +#include "usb_device_config.h" |
23 | 26 |
|
24 | 27 | #define LPSPI_CLOCK_SOURCE_DIVIDER (7U)
|
25 | 28 | #define LPI2C_CLOCK_SOURCE_DIVIDER (5U)
|
| 29 | + |
| 30 | +/* USB PHY condfiguration */ |
| 31 | +#define BOARD_USB_PHY_D_CAL (0x0CU) |
| 32 | +#define BOARD_USB_PHY_TXCAL45DP (0x06U) |
| 33 | +#define BOARD_USB_PHY_TXCAL45DM (0x06U) |
| 34 | + |
26 | 35 | uint8_t mbed_otp_mac_address(char *mac);
|
27 | 36 | void mbed_default_mac_address(char *mac);
|
28 | 37 |
|
@@ -311,3 +320,28 @@ void mbed_default_mac_address(char *mac) {
|
311 | 320 |
|
312 | 321 | return;
|
313 | 322 | }
|
| 323 | + |
| 324 | +void USB_DeviceClockInit(void) |
| 325 | +{ |
| 326 | + usb_phy_config_struct_t phyConfig = { |
| 327 | + BOARD_USB_PHY_D_CAL, |
| 328 | + BOARD_USB_PHY_TXCAL45DP, |
| 329 | + BOARD_USB_PHY_TXCAL45DM, |
| 330 | + }; |
| 331 | + |
| 332 | + CLOCK_EnableUsbhs0PhyPllClock(kCLOCK_Usbphy480M, 480000000U); |
| 333 | + CLOCK_EnableUsbhs0Clock(kCLOCK_Usb480M, 480000000U); |
| 334 | + |
| 335 | + USB_EhciPhyInit(CONTROLLER_ID, BOARD_XTAL0_CLK_HZ, &phyConfig); |
| 336 | +} |
| 337 | + |
| 338 | +uint32_t USB_DeviceGetIrqNumber(void) |
| 339 | +{ |
| 340 | + uint8_t irqNumber; |
| 341 | + |
| 342 | + uint8_t usbDeviceEhciIrq[] = USBHS_IRQS; |
| 343 | + irqNumber = usbDeviceEhciIrq[CONTROLLER_ID - kUSB_ControllerEhci0]; |
| 344 | + |
| 345 | + return irqNumber; |
| 346 | +} |
| 347 | + |
0 commit comments