Fork of https://developer.mbed.org/users/bscott/code/STM32_USBDevice/
Fork of STM32_USBDevice by
Diff: USBDevice/USBHAL_STM32L1.cpp
- Revision:
- 61:5f4f01a06669
- Parent:
- 60:04a69c36260e
- Child:
- 62:23cb405e1ee5
diff -r 04a69c36260e -r 5f4f01a06669 USBDevice/USBHAL_STM32L1.cpp --- a/USBDevice/USBHAL_STM32L1.cpp Wed Jun 17 15:16:26 2015 +0900 +++ b/USBDevice/USBHAL_STM32L1.cpp Sat Jun 20 11:54:36 2015 +0900 @@ -386,58 +386,4 @@ } } - -void L152RE_SystemClock_Config(void) { - RCC_OscInitTypeDef RCC_OscInitStruct; - RCC_ClkInitTypeDef RCC_ClkInitStruct; - - __PWR_CLK_ENABLE(); - - __HAL_PWR_VOLTAGESCALING_CONFIG(PWR_REGULATOR_VOLTAGE_SCALE1); - - RCC_OscInitStruct.OscillatorType = RCC_OSCILLATORTYPE_HSI; - RCC_OscInitStruct.HSIState = RCC_HSI_ON; - RCC_OscInitStruct.HSICalibrationValue = 16; - RCC_OscInitStruct.PLL.PLLState = RCC_PLL_ON; - RCC_OscInitStruct.PLL.PLLSource = RCC_PLLSOURCE_HSI; - RCC_OscInitStruct.PLL.PLLMUL = RCC_PLL_MUL6; - RCC_OscInitStruct.PLL.PLLDIV = RCC_PLL_DIV3; - HAL_RCC_OscConfig(&RCC_OscInitStruct); - - RCC_ClkInitStruct.ClockType = RCC_CLOCKTYPE_SYSCLK; - RCC_ClkInitStruct.SYSCLKSource = RCC_SYSCLKSOURCE_PLLCLK; - RCC_ClkInitStruct.AHBCLKDivider = RCC_SYSCLK_DIV1; - RCC_ClkInitStruct.APB1CLKDivider = RCC_HCLK_DIV1; - RCC_ClkInitStruct.APB2CLKDivider = RCC_HCLK_DIV1; - HAL_RCC_ClockConfig(&RCC_ClkInitStruct, FLASH_LATENCY_1); -} - -uint32_t L152RE_getUSBclock() { - RCC_OscInitTypeDef cfg; - HAL_RCC_GetOscConfig(&cfg); - MBED_ASSERT(cfg.PLL.PLLState == RCC_PLL_ON); - uint32_t src = (cfg.PLL.PLLSource == RCC_PLLSOURCE_HSI) ? HSI_VALUE : HSE_VALUE; - MBED_ASSERT(src == 16000000 || src == 8000000); - switch(cfg.PLL.PLLMUL) { - case RCC_PLL_MUL3: src *= 3; break; - case RCC_PLL_MUL4: src *= 4; break; - case RCC_PLL_MUL6: src *= 6; break; - case RCC_PLL_MUL8: src *= 8; break; - case RCC_PLL_MUL12: src *= 12; break; - case RCC_PLL_MUL16: src *= 16; break; - case RCC_PLL_MUL24: src *= 24; break; - case RCC_PLL_MUL32: src *= 32; break; - case RCC_PLL_MUL48: src *= 48; break; - } - return src / 2; -} - -void L152RE_USBclock_setup() { - if (L152RE_getUSBclock() != 48000000) { - HAL_RCC_DeInit(); - L152RE_SystemClock_Config(); - } -} - #endif -