Important changes to repositories hosted on mbed.com
Mbed hosted mercurial repositories are deprecated and are due to be permanently deleted in July 2026.
To keep a copy of this software download the repository Zip archive or clone locally using Mercurial.
It is also possible to export all your personal repositories from the account settings page.
hw_config.c
00001 /******************** (C) COPYRIGHT 2011 STMicroelectronics ******************** 00002 * File Name : hw_config.c 00003 * Author : MCD Application Team 00004 * Version : V3.3.0 00005 * Date : 21-March-2011 00006 * Description : Hardware Configuration & Setup 00007 ******************************************************************************** 00008 * THE PRESENT FIRMWARE WHICH IS FOR GUIDANCE ONLY AIMS AT PROVIDING CUSTOMERS 00009 * WITH CODING INFORMATION REGARDING THEIR PRODUCTS IN ORDER FOR THEM TO SAVE TIME. 00010 * AS A RESULT, STMICROELECTRONICS SHALL NOT BE HELD LIABLE FOR ANY DIRECT, 00011 * INDIRECT OR CONSEQUENTIAL DAMAGES WITH RESPECT TO ANY CLAIMS ARISING FROM THE 00012 * CONTENT OF SUCH FIRMWARE AND/OR THE USE MADE BY CUSTOMERS OF THE CODING 00013 * INFORMATION CONTAINED HEREIN IN CONNECTION WITH THEIR PRODUCTS. 00014 *******************************************************************************/ 00015 00016 #include "stm32f10x_it.h" 00017 00018 #include "usb_lib.h" 00019 #include "usb_prop.h" 00020 #include "usb_desc.h" 00021 #include "hw_config.h" 00022 #include "platform_config.h" 00023 #include "usb_pwr.h" 00024 #include "stm32f10x_rcc.h" 00025 #include "misc.h" 00026 00027 ErrorStatus HSEStartUpStatus; 00028 00029 static void IntToUnicode(uint32_t value, uint8_t *pbuf, uint8_t len); 00030 00031 /******************************************************************************* 00032 * Description : Configures Main system clocks & power 00033 *******************************************************************************/ 00034 void Set_System(void) 00035 { 00036 } 00037 00038 /******************************************************************************* 00039 * Description : Configures USB Clock input (48MHz) 00040 *******************************************************************************/ 00041 void Set_USBClock(void) 00042 { 00043 /* Select USBCLK source */ 00044 RCC_USBCLKConfig(RCC_USBCLKSource_PLLCLK_1Div5); 00045 00046 /* Enable the USB clock */ 00047 RCC_APB1PeriphClockCmd(RCC_APB1Periph_USB, ENABLE); 00048 } 00049 00050 /******************************************************************************* 00051 * Description : Power-off system clocks and power while entering suspend mode 00052 *******************************************************************************/ 00053 void Enter_LowPowerMode(void) 00054 { 00055 /* Set the device state to suspend */ 00056 bDeviceState = SUSPENDED; 00057 } 00058 00059 /******************************************************************************* 00060 * Description : Restores system clocks and power while exiting suspend mode 00061 *******************************************************************************/ 00062 void Leave_LowPowerMode(void) 00063 { 00064 DEVICE_INFO *pInfo = &Device_Info; 00065 00066 /* Set the device state to the correct state */ 00067 if (pInfo->Current_Configuration != 0) 00068 { 00069 /* Device configured */ 00070 bDeviceState = CONFIGURED; 00071 } 00072 else 00073 { 00074 bDeviceState = ATTACHED; 00075 } 00076 } 00077 00078 /******************************************************************************* 00079 * Description : Configures the USB interrupts 00080 *******************************************************************************/ 00081 void USB_Interrupts_Config(void) 00082 { 00083 NVIC_InitTypeDef NVIC_InitStructure; 00084 00085 NVIC_PriorityGroupConfig(NVIC_PriorityGroup_1); 00086 00087 NVIC_InitStructure.NVIC_IRQChannel = USB_LP_CAN1_RX0_IRQn; 00088 NVIC_InitStructure.NVIC_IRQChannelPreemptionPriority = 1; 00089 NVIC_InitStructure.NVIC_IRQChannelSubPriority = 0; 00090 NVIC_InitStructure.NVIC_IRQChannelCmd = ENABLE; 00091 NVIC_Init(&NVIC_InitStructure); 00092 } 00093 00094 /******************************************************************************* 00095 * Description : Software Connection/Disconnection of USB Cable 00096 *******************************************************************************/ 00097 void USB_Cable_Config(FunctionalState NewState) 00098 { 00099 } 00100 00101 /******************************************************************************* 00102 * Description : Create the serial number string descriptor. 00103 *******************************************************************************/ 00104 void Get_SerialNum(void) 00105 { 00106 uint32_t Device_Serial0, Device_Serial1, Device_Serial2; 00107 00108 Device_Serial0 = *(__IO uint32_t*) (0x1FFFF7E8); 00109 Device_Serial1 = *(__IO uint32_t*) (0x1FFFF7EC); 00110 Device_Serial2 = *(__IO uint32_t*) (0x1FFFF7F0); 00111 00112 Device_Serial0 += Device_Serial2; 00113 00114 if (Device_Serial0 != 0) 00115 { 00116 IntToUnicode(Device_Serial0, &Virtual_Com_Port_StringSerial[2], 8); 00117 IntToUnicode(Device_Serial1, &Virtual_Com_Port_StringSerial[18], 4); 00118 } 00119 } 00120 00121 /******************************************************************************* 00122 * Description : Convert Hex 32Bits value into char. 00123 *******************************************************************************/ 00124 static void IntToUnicode(uint32_t value, uint8_t *pbuf, uint8_t len) 00125 { 00126 uint8_t idx = 0; 00127 00128 for (idx = 0; idx < len; idx++) 00129 { 00130 if (((value >> 28)) < 0xA) 00131 { 00132 pbuf[2 * idx] = (value >> 28) + '0'; 00133 } 00134 else 00135 { 00136 pbuf[2 * idx] = (value >> 28) + 'A' - 10; 00137 } 00138 00139 value = value << 4; 00140 00141 pbuf[2 * idx + 1] = 0; 00142 } 00143 }
Generated on Tue Jul 12 2022 20:45:31 by
1.7.2