|
| 1 | +/** |
| 2 | + * @file hic_init.c |
| 3 | + * @brief |
| 4 | + * |
| 5 | + * DAPLink Interface Firmware |
| 6 | + * Copyright (c) 2009-2016, ARM Limited, All Rights Reserved |
| 7 | + * Copyright (c) 2016-2017 NXP |
| 8 | + * SPDX-License-Identifier: Apache-2.0 |
| 9 | + * |
| 10 | + * Licensed under the Apache License, Version 2.0 (the "License"); you may |
| 11 | + * not use this file except in compliance with the License. |
| 12 | + * You may obtain a copy of the License at |
| 13 | + * |
| 14 | + * http://www.apache.org/licenses/LICENSE-2.0 |
| 15 | + * |
| 16 | + * Unless required by applicable law or agreed to in writing, software |
| 17 | + * distributed under the License is distributed on an "AS IS" BASIS, WITHOUT |
| 18 | + * WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. |
| 19 | + * See the License for the specific language governing permissions and |
| 20 | + * limitations under the License. |
| 21 | + */ |
| 22 | + |
| 23 | +#include "fsl_device_registers.h" |
| 24 | + |
| 25 | +/* Enable all clocks needed for USB to function */ |
| 26 | +void hic_enable_usb_clocks(void) |
| 27 | +{ |
| 28 | + /* Set USB clock to 48 MHz */ |
| 29 | + SIM->SOPT2 |= SIM_SOPT2_USBSRC_MASK | /* MCGPLLCLK used as src */ |
| 30 | + SIM_SOPT2_PLLFLLSEL_MASK ; /* Select MCGPLLCLK as clock */ |
| 31 | + SIM->CLKDIV2 &= ~(SIM_CLKDIV2_USBFRAC_MASK | /* Clear CLKDIV2 FS values */ |
| 32 | + SIM_CLKDIV2_USBDIV_MASK); |
| 33 | + SIM->CLKDIV2 = SIM_CLKDIV2_USBDIV(0) ; /* USB clk = (PLL*1/2) */ |
| 34 | + /* = ( 48*1/1)=48 */ |
| 35 | + SIM->SCGC4 |= SIM_SCGC4_USBOTG_MASK; /* Enable USBOTG clock */ |
| 36 | +} |
| 37 | + |
0 commit comments