repo_id
stringlengths
27
162
file_path
stringlengths
42
195
content
stringlengths
4
5.16M
__index_level_0__
int64
0
0
D://workCode//uploadProject\STM32CubeF1\Projects\STM3210E_EVAL\Applications\USB_Device\CustomHID_Standalone
D://workCode//uploadProject\STM32CubeF1\Projects\STM3210E_EVAL\Applications\USB_Device\CustomHID_Standalone\Inc\usbd_customhid_if.h
/** ****************************************************************************** * @file USB_Device/CustomHID_Standalone/Inc/usbd_customhid_if.h * @author MCD Application Team * @brief Header for usbd_customhid_if.c file. ****************************************************************************** * @attention * * Copyright (c) 2015 STMicroelectronics. * All rights reserved. * * This software is licensed under terms that can be found in the LICENSE file * in the root directory of this software component. * If no LICENSE file comes with this software, it is provided AS-IS. * ****************************************************************************** */ /* Define to prevent recursive inclusion -------------------------------------*/ #ifndef __USBD_CUSTOMHID_IF_H #define __USBD_CUSTOMHID_IF_H /* Includes ------------------------------------------------------------------*/ #include "usbd_customhid.h" /* Exported types ------------------------------------------------------------*/ /* Exported constants --------------------------------------------------------*/ #define LED1_REPORT_ID 0x01 #define LED1_REPORT_COUNT 0x01 #define LED2_REPORT_ID 0x02 #define LED2_REPORT_COUNT 0x01 #define LED3_REPORT_ID 0x03 #define LED3_REPORT_COUNT 0x01 #define LED4_REPORT_ID 0x04 #define LED4_REPORT_COUNT 0x01 #define KEY_REPORT_ID 0x05 #define TAMPER_REPORT_ID 0x06 #define ADC_REPORT_ID 0x07 /* User can use this section to tailor ADCx instance used and associated resources */ /* Definition for ADCx clock resources */ #define ADCx ADC1 #define ADCx_CLK_ENABLE() __HAL_RCC_ADC1_CLK_ENABLE() #define ADCx_CHANNEL_GPIO_CLK_ENABLE() __HAL_RCC_GPIOC_CLK_ENABLE() #define ADCx_FORCE_RESET() __HAL_RCC_ADC1_FORCE_RESET() #define ADCx_RELEASE_RESET() __HAL_RCC_ADC1_RELEASE_RESET() /* Definition for ADCx Channel Pin */ #define ADCx_CHANNEL_PIN GPIO_PIN_4 #define ADCx_CHANNEL_GPIO_PORT GPIOC /* Definition for ADCx's Channel */ #define ADCx_CHANNEL ADC_CHANNEL_14 /* Definition for ADCx's DMA */ #define ADCx_DMA_CHANNEL DMA1_Channel1 /* Definition for ADCx's NVIC */ #define ADCx_DMA_IRQn DMA1_Channel1_IRQn /* Exported macro ------------------------------------------------------------*/ /* Exported functions ------------------------------------------------------- */ extern USBD_CUSTOM_HID_ItfTypeDef USBD_CustomHID_fops; #endif /* __USBD_CUSTOMHID_IF_H */
0
D://workCode//uploadProject\STM32CubeF1\Projects\STM3210E_EVAL\Applications\USB_Device\CustomHID_Standalone
D://workCode//uploadProject\STM32CubeF1\Projects\STM3210E_EVAL\Applications\USB_Device\CustomHID_Standalone\Inc\usbd_desc.h
/** ****************************************************************************** * @file USB_Device/CustomHID_Standalone/Inc/usbd_desc.h * @author MCD Application Team * @brief Header for usbd_desc.c module ****************************************************************************** * @attention * * Copyright (c) 2015 STMicroelectronics. * All rights reserved. * * This software is licensed under terms that can be found in the LICENSE file * in the root directory of this software component. * If no LICENSE file comes with this software, it is provided AS-IS. * ****************************************************************************** */ /* Define to prevent recursive inclusion -------------------------------------*/ #ifndef __USBD_DESC_H #define __USBD_DESC_H /* Includes ------------------------------------------------------------------*/ #include "usbd_def.h" /* Exported types ------------------------------------------------------------*/ /* Exported constants --------------------------------------------------------*/ #define DEVICE_ID1 (0x1FFFF7E8) #define DEVICE_ID2 (0x1FFFF7EC) #define DEVICE_ID3 (0x1FFFF7F0) #define USB_SIZ_STRING_SERIAL 0x1A /* Exported macro ------------------------------------------------------------*/ /* Exported functions ------------------------------------------------------- */ extern USBD_DescriptorsTypeDef HID_Desc; #endif /* __USBD_DESC_H */
0
D://workCode//uploadProject\STM32CubeF1\Projects\STM3210E_EVAL\Applications\USB_Device\CustomHID_Standalone
D://workCode//uploadProject\STM32CubeF1\Projects\STM3210E_EVAL\Applications\USB_Device\CustomHID_Standalone\Src\main.c
/** ****************************************************************************** * @file USB_Device/CustomHID_Standalone/Src/main.c * @author MCD Application Team * @brief USB device CustomHID application main file. ****************************************************************************** * @attention * * Copyright (c) 2016 STMicroelectronics. * All rights reserved. * * This software is licensed under terms that can be found in the LICENSE file * in the root directory of this software component. * If no LICENSE file comes with this software, it is provided AS-IS. * ****************************************************************************** */ /* Includes ------------------------------------------------------------------ */ #include "main.h" /** @addtogroup STM32F1xx_HAL_Validation * @{ */ /** @addtogroup STANDARD_CHECK * @{ */ /* Private typedef ----------------------------------------------------------- */ /* Private define ------------------------------------------------------------ */ /* Private macro ------------------------------------------------------------- */ /* Private variables --------------------------------------------------------- */ USBD_HandleTypeDef USBD_Device; /* Private function prototypes ----------------------------------------------- */ void SystemClock_Config(void); static void Error_Handler(void); /* Private functions --------------------------------------------------------- */ /** * @brief Main program. * @param None * @retval None */ int main(void) { /* Reset of all peripherals, Initializes the Flash interface and the Systick. */ HAL_Init(); /* Initialize LEDs */ BSP_LED_Init(LED1); BSP_LED_Init(LED2); BSP_LED_Init(LED3); BSP_LED_Init(LED4); /* Configure the system clock to 72 MHz */ SystemClock_Config(); /* Init Device Library */ USBD_Init(&USBD_Device, &HID_Desc, 0); /* Add Supported Class */ USBD_RegisterClass(&USBD_Device, &USBD_CUSTOM_HID); /* Add Custom HID callbacks */ USBD_CUSTOM_HID_RegisterInterface(&USBD_Device, &USBD_CustomHID_fops); /* Start Device Process */ USBD_Start(&USBD_Device); /* Infinite loop */ while (1) { } } /** * @brief System Clock Configuration * The system Clock is configured as follow : * System Clock source = PLL (HSE) * SYSCLK(Hz) = 72000000 * HCLK(Hz) = 72000000 * AHB Prescaler = 1 * APB1 Prescaler = 2 * APB2 Prescaler = 1 * HSE Frequency(Hz) = 8000000 * HSE PREDIV1 = 1 * PLLMUL = 9 * Flash Latency(WS) = 2 * @param None * @retval None */ void SystemClock_Config(void) { RCC_ClkInitTypeDef clkinitstruct = { 0 }; RCC_OscInitTypeDef oscinitstruct = { 0 }; RCC_PeriphCLKInitTypeDef rccperiphclkinit = { 0 }; /* Enable HSE Oscillator and activate PLL with HSE as source */ oscinitstruct.OscillatorType = RCC_OSCILLATORTYPE_HSE; oscinitstruct.HSEState = RCC_HSE_ON; oscinitstruct.HSEPredivValue = RCC_HSE_PREDIV_DIV1; oscinitstruct.PLL.PLLMUL = RCC_PLL_MUL9; oscinitstruct.PLL.PLLState = RCC_PLL_ON; oscinitstruct.PLL.PLLSource = RCC_PLLSOURCE_HSE; if (HAL_RCC_OscConfig(&oscinitstruct) != HAL_OK) { /* Start Conversation Error */ Error_Handler(); } /* USB clock selection */ rccperiphclkinit.PeriphClockSelection = RCC_PERIPHCLK_USB; rccperiphclkinit.UsbClockSelection = RCC_USBCLKSOURCE_PLL_DIV1_5; HAL_RCCEx_PeriphCLKConfig(&rccperiphclkinit); /* Select PLL as system clock source and configure the HCLK, PCLK1 and PCLK2 * clocks dividers */ clkinitstruct.ClockType = RCC_CLOCKTYPE_SYSCLK | RCC_CLOCKTYPE_HCLK | RCC_CLOCKTYPE_PCLK1 | RCC_CLOCKTYPE_PCLK2; clkinitstruct.SYSCLKSource = RCC_SYSCLKSOURCE_PLLCLK; clkinitstruct.AHBCLKDivider = RCC_SYSCLK_DIV1; clkinitstruct.APB1CLKDivider = RCC_HCLK_DIV2; clkinitstruct.APB2CLKDivider = RCC_HCLK_DIV1; if (HAL_RCC_ClockConfig(&clkinitstruct, FLASH_LATENCY_2) != HAL_OK) { /* Start Conversation Error */ Error_Handler(); } } /** * @brief This function is executed in case of error occurrence. * @param None * @retval None */ static void Error_Handler(void) { /* Turn LED3 on */ BSP_LED_On(LED3); while (1) { } } #ifdef USE_FULL_ASSERT /** * @brief Reports the name of the source file and the source line number * where the assert_param error has occurred. * @param file: pointer to the source file name * @param line: assert_param error line source number * @retval None */ void assert_failed(uint8_t * file, uint32_t line) { /* User can add his own implementation to report the file name and line * number, ex: printf("Wrong parameters value: file %s on line %d\r\n", file, * line) */ /* Infinite loop */ while (1) { } } #endif /** * @} */ /** * @} */
0
D://workCode//uploadProject\STM32CubeF1\Projects\STM3210E_EVAL\Applications\USB_Device\CustomHID_Standalone
D://workCode//uploadProject\STM32CubeF1\Projects\STM3210E_EVAL\Applications\USB_Device\CustomHID_Standalone\Src\stm32f1xx_hal_msp.c
/** ****************************************************************************** * @file USB_Device/CustomHID_Standalone/Src/stm32f1xx_hal_msp.c * @author MCD Application Team * @brief HAL MSP module. ****************************************************************************** * @attention * * Copyright (c) 2016 STMicroelectronics. * All rights reserved. * * This software is licensed under terms that can be found in the LICENSE file * in the root directory of this software component. * If no LICENSE file comes with this software, it is provided AS-IS. * ****************************************************************************** */ /* Includes ------------------------------------------------------------------ */ #include "main.h" /* Private typedef ----------------------------------------------------------- */ /* Private define ------------------------------------------------------------ */ /* Private macro ------------------------------------------------------------- */ /* Private variables --------------------------------------------------------- */ /* Private function prototypes ----------------------------------------------- */ /* Private functions --------------------------------------------------------- */ /** * @brief ADC MSP initialization * This function configures the hardware resources used in this example: * - Enable clock of ADC peripheral * - Configure the GPIO associated to the peripheral channels * - Configure the DMA associated to the peripheral * - Configure the NVIC associated to the peripheral interruptions * @param hadc: ADC handle pointer * @retval None */ void HAL_ADC_MspInit(ADC_HandleTypeDef * hadc) { GPIO_InitTypeDef GPIO_InitStruct; static DMA_HandleTypeDef DmaHandle; /* ##-1- Enable peripherals and GPIO Clocks ################################# */ /* Enable clock of GPIO associated to the peripheral channels */ ADCx_CHANNEL_GPIO_CLK_ENABLE(); /* Enable clock of ADCx peripheral */ ADCx_CLK_ENABLE(); /* Enable clock of DMA associated to the peripheral */ __HAL_RCC_DMA1_CLK_ENABLE(); /* ##-2- Configure peripheral GPIO ########################################## */ /* Configure GPIO pin of the selected ADC channel */ GPIO_InitStruct.Pin = ADCx_CHANNEL_PIN; GPIO_InitStruct.Mode = GPIO_MODE_ANALOG; GPIO_InitStruct.Pull = GPIO_NOPULL; HAL_GPIO_Init(ADCx_CHANNEL_GPIO_PORT, &GPIO_InitStruct); /* ##- 3- Configure DMA ##################################################### */ /* Configure DMA parameters */ DmaHandle.Instance = DMA1_Channel1; DmaHandle.Init.Direction = DMA_PERIPH_TO_MEMORY; DmaHandle.Init.PeriphInc = DMA_PINC_DISABLE; DmaHandle.Init.MemInc = DMA_MINC_ENABLE; DmaHandle.Init.PeriphDataAlignment = DMA_PDATAALIGN_WORD; DmaHandle.Init.MemDataAlignment = DMA_MDATAALIGN_WORD; DmaHandle.Init.Mode = DMA_CIRCULAR; DmaHandle.Init.Priority = DMA_PRIORITY_HIGH; /* Deinitialize & Initialize the DMA for new transfer */ HAL_DMA_DeInit(&DmaHandle); HAL_DMA_Init(&DmaHandle); /* Associate the initialized DMA handle to the the ADC handle */ __HAL_LINKDMA(hadc, DMA_Handle, DmaHandle); /* ##-4- Configure the NVIC for DMA ######################################### */ /* NVIC configuration for DMA transfer complete interrupt */ HAL_NVIC_SetPriority(ADCx_DMA_IRQn, 5, 0); HAL_NVIC_EnableIRQ(ADCx_DMA_IRQn); } /** * @brief ADC MSP De-Initialization * This function frees the hardware resources used in this example: * - Disable the Peripheral's clock * - Revert GPIO to their default state * @param hadc: ADC handle pointer * @retval None */ void HAL_ADC_MspDeInit(ADC_HandleTypeDef * hadc) { /* ##-1- Reset peripherals ################################################## */ ADCx_FORCE_RESET(); ADCx_RELEASE_RESET(); /* ##-2- Disable peripherals and GPIO Clocks ################################ */ /* De-initialize the ADC3 Channel8 GPIO pin */ HAL_GPIO_DeInit(ADCx_CHANNEL_GPIO_PORT, ADCx_CHANNEL_PIN); /* ##-3- Disable the DMA Streams ############################################ */ /* De-Initialize the DMA associated to the peripheral */ if (hadc->DMA_Handle != NULL) { HAL_DMA_DeInit(hadc->DMA_Handle); } /* ##-4- Disable the NVIC ################################################### */ /* Disable the NVIC configuration for DMA interrupt */ HAL_NVIC_DisableIRQ(ADCx_DMA_IRQn); }
0
D://workCode//uploadProject\STM32CubeF1\Projects\STM3210E_EVAL\Applications\USB_Device\CustomHID_Standalone
D://workCode//uploadProject\STM32CubeF1\Projects\STM3210E_EVAL\Applications\USB_Device\CustomHID_Standalone\Src\stm32f1xx_it.c
/** ****************************************************************************** * @file USB_Device/CustomHID_Standalone/Src/stm32f1xx_it.c * @author MCD Application Team * @brief Main Interrupt Service Routines. * This file provides template for all exceptions handler and * peripherals interrupt service routine. ****************************************************************************** * @attention * * Copyright (c) 2016 STMicroelectronics. * All rights reserved. * * This software is licensed under terms that can be found in the LICENSE file * in the root directory of this software component. * If no LICENSE file comes with this software, it is provided AS-IS. * ****************************************************************************** */ /* Includes ------------------------------------------------------------------ */ #include "stm32f1xx_it.h" /** @addtogroup Validation_Project * @{ */ /* Private typedef ----------------------------------------------------------- */ /* Private define ------------------------------------------------------------ */ /* Private macro ------------------------------------------------------------- */ /* Private variables --------------------------------------------------------- */ extern PCD_HandleTypeDef hpcd; extern USBD_HandleTypeDef USBD_Device; extern ADC_HandleTypeDef AdcHandle; extern uint32_t ADCConvertedValue; extern uint32_t ADC_Prev_ConvertedValue; extern uint8_t SendBuffer[2]; /* Private function prototypes ----------------------------------------------- */ /* Private functions --------------------------------------------------------- */ /******************************************************************************/ /* Cortex-M3 Processor Exceptions Handlers */ /******************************************************************************/ /** * @brief This function handles NMI exception. * @param None * @retval None */ void NMI_Handler(void) { } /** * @brief This function handles Hard Fault exception. * @param None * @retval None */ void HardFault_Handler(void) { /* Go to infinite loop when Hard Fault exception occurs */ while (1) { } } /** * @brief This function handles Memory Manage exception. * @param None * @retval None */ void MemManage_Handler(void) { /* Go to infinite loop when Memory Manage exception occurs */ while (1) { } } /** * @brief This function handles Bus Fault exception. * @param None * @retval None */ void BusFault_Handler(void) { /* Go to infinite loop when Bus Fault exception occurs */ while (1) { } } /** * @brief This function handles Usage Fault exception. * @param None * @retval None */ void UsageFault_Handler(void) { /* Go to infinite loop when Usage Fault exception occurs */ while (1) { } } /** * @brief This function handles SVCall exception. * @param None * @retval None */ void SVC_Handler(void) { } /** * @brief This function handles Debug Monitor exception. * @param None * @retval None */ void DebugMon_Handler(void) { } /** * @brief This function handles PendSVC exception. * @param None * @retval None */ void PendSV_Handler(void) { } /** * @brief This function handles SysTick Handler. * @param None * @retval None */ void SysTick_Handler(void) { HAL_IncTick(); } /******************************************************************************/ /* STM32F1xx Peripherals Interrupt Handlers */ /* Add here the Interrupt Handler for the used peripheral(s) (PPP), for the */ /* available peripheral interrupt handler's name please refer to the startup */ /* file (startup_stm32f1xx.s). */ /******************************************************************************/ /** * @brief This function handles USB Handler. * @param None * @retval None */ void USB_LP_CAN1_RX0_IRQHandler(void) { HAL_PCD_IRQHandler(&hpcd); } /** * @brief This function handles External lines 10-15 interrupt request. * @param None * @retval None */ void EXTI9_5_IRQHandler(void) { HAL_GPIO_EXTI_IRQHandler(KEY_BUTTON_PIN); } /** * @brief This function handles DMA interrupt request. * @param None * @retval None */ void DMA1_Channel1_IRQHandler(void) { HAL_DMA_IRQHandler(AdcHandle.DMA_Handle); SendBuffer[0] = ADC_REPORT_ID; if (abs((ADCConvertedValue >> 4) - (ADC_Prev_ConvertedValue >> 4)) > 4) { SendBuffer[1] = (uint8_t) (ADCConvertedValue >> 4); USBD_CUSTOM_HID_SendReport(&USBD_Device, SendBuffer, 2); ADC_Prev_ConvertedValue = ADCConvertedValue; } } /** * @} */
0
D://workCode//uploadProject\STM32CubeF1\Projects\STM3210E_EVAL\Applications\USB_Device\CustomHID_Standalone
D://workCode//uploadProject\STM32CubeF1\Projects\STM3210E_EVAL\Applications\USB_Device\CustomHID_Standalone\Src\system_stm32f1xx.c
/** ****************************************************************************** * @file system_stm32f1xx.c * @author MCD Application Team * @brief CMSIS Cortex-M3 Device Peripheral Access Layer System Source File. * * 1. This file provides two functions and one global variable to be called from * user application: * - SystemInit(): Setups the system clock (System clock source, PLL Multiplier * factors, AHB/APBx prescalers and Flash settings). * This function is called at startup just after reset and * before branch to main program. This call is made inside * the "startup_stm32f1xx_xx.s" file. * * - SystemCoreClock variable: Contains the core clock (HCLK), it can be used * by the user application to setup the SysTick * timer or configure other parameters. * * - SystemCoreClockUpdate(): Updates the variable SystemCoreClock and must * be called whenever the core clock is changed * during program execution. * * 2. After each device reset the HSI (8 MHz) is used as system clock source. * Then SystemInit() function is called, in "startup_stm32f1xx_xx.s" file, to * configure the system clock before to branch to main program. * * 4. The default value of HSE crystal is set to 8 MHz (or 25 MHz, depending on * the product used), refer to "HSE_VALUE". * When HSE is used as system clock source, directly or through PLL, and you * are using different crystal you have to adapt the HSE value to your own * configuration. * ****************************************************************************** * @attention * * Copyright (c) 2016 STMicroelectronics. * All rights reserved. * * This software is licensed under terms that can be found in the LICENSE file * in the root directory of this software component. * If no LICENSE file comes with this software, it is provided AS-IS. * ****************************************************************************** */ /** @addtogroup CMSIS * @{ */ /** @addtogroup stm32f1xx_system * @{ */ /** @addtogroup STM32F1xx_System_Private_Includes * @{ */ #include "stm32f1xx.h" /** * @} */ /** @addtogroup STM32F1xx_System_Private_TypesDefinitions * @{ */ /** * @} */ /** @addtogroup STM32F1xx_System_Private_Defines * @{ */ #if !defined (HSE_VALUE) #define HSE_VALUE ((uint32_t)8000000) /*!< Default value of the External oscillator in Hz. This value can be provided and adapted by the user application. */ #endif /* HSE_VALUE */ #if !defined (HSI_VALUE) #define HSI_VALUE ((uint32_t)8000000) /*!< Default value of the Internal oscillator in Hz. This value can be provided and adapted by the user application. */ #endif /* HSI_VALUE */ /*!< Uncomment the following line if you need to use external SRAM */ #if defined(STM32F100xE) || defined(STM32F101xE) || defined(STM32F101xG) || defined(STM32F103xE) || defined(STM32F103xG) /* #define DATA_IN_ExtSRAM */ #endif /* STM32F100xE || STM32F101xE || STM32F101xG || STM32F103xE || STM32F103xG */ /*!< Uncomment the following line if you need to relocate your vector Table in Internal SRAM. */ /* #define VECT_TAB_SRAM */ #define VECT_TAB_OFFSET 0x0 /*!< Vector Table base offset field. This value must be a multiple of 0x200. */ /** * @} */ /** @addtogroup STM32F1xx_System_Private_Macros * @{ */ /** * @} */ /** @addtogroup STM32F1xx_System_Private_Variables * @{ */ /* This variable is updated in three ways: 1) by calling CMSIS function SystemCoreClockUpdate() 2) by calling HAL API function HAL_RCC_GetHCLKFreq() 3) each time HAL_RCC_ClockConfig() is called to configure the system clock frequency Note: If you use this function to configure the system clock; then there is no need to call the 2 first functions listed above, since SystemCoreClock variable is updated automatically. */ uint32_t SystemCoreClock = 16000000; const uint8_t AHBPrescTable[16] = {0, 0, 0, 0, 0, 0, 0, 0, 1, 2, 3, 4, 6, 7, 8, 9}; const uint8_t APBPrescTable[8] = {0, 0, 0, 0, 1, 2, 3, 4}; /** * @} */ /** @addtogroup STM32F1xx_System_Private_FunctionPrototypes * @{ */ #if defined(STM32F100xE) || defined(STM32F101xE) || defined(STM32F101xG) || defined(STM32F103xE) || defined(STM32F103xG) #ifdef DATA_IN_ExtSRAM static void SystemInit_ExtMemCtl(void); #endif /* DATA_IN_ExtSRAM */ #endif /* STM32F100xE || STM32F101xE || STM32F101xG || STM32F103xE || STM32F103xG */ /** * @} */ /** @addtogroup STM32F1xx_System_Private_Functions * @{ */ /** * @brief Setup the microcontroller system * Initialize the Embedded Flash Interface, the PLL and update the * SystemCoreClock variable. * @note This function should be used only after reset. * @param None * @retval None */ void SystemInit (void) { /* Reset the RCC clock configuration to the default reset state(for debug purpose) */ /* Set HSION bit */ RCC->CR |= (uint32_t)0x00000001; /* Reset SW, HPRE, PPRE1, PPRE2, ADCPRE and MCO bits */ #if !defined(STM32F105xC) && !defined(STM32F107xC) RCC->CFGR &= (uint32_t)0xF8FF0000; #else RCC->CFGR &= (uint32_t)0xF0FF0000; #endif /* STM32F105xC */ /* Reset HSEON, CSSON and PLLON bits */ RCC->CR &= (uint32_t)0xFEF6FFFF; /* Reset HSEBYP bit */ RCC->CR &= (uint32_t)0xFFFBFFFF; /* Reset PLLSRC, PLLXTPRE, PLLMUL and USBPRE/OTGFSPRE bits */ RCC->CFGR &= (uint32_t)0xFF80FFFF; #if defined(STM32F105xC) || defined(STM32F107xC) /* Reset PLL2ON and PLL3ON bits */ RCC->CR &= (uint32_t)0xEBFFFFFF; /* Disable all interrupts and clear pending bits */ RCC->CIR = 0x00FF0000; /* Reset CFGR2 register */ RCC->CFGR2 = 0x00000000; #elif defined(STM32F100xB) || defined(STM32F100xE) /* Disable all interrupts and clear pending bits */ RCC->CIR = 0x009F0000; /* Reset CFGR2 register */ RCC->CFGR2 = 0x00000000; #else /* Disable all interrupts and clear pending bits */ RCC->CIR = 0x009F0000; #endif /* STM32F105xC */ #if defined(STM32F100xE) || defined(STM32F101xE) || defined(STM32F101xG) || defined(STM32F103xE) || defined(STM32F103xG) #ifdef DATA_IN_ExtSRAM SystemInit_ExtMemCtl(); #endif /* DATA_IN_ExtSRAM */ #endif #ifdef VECT_TAB_SRAM SCB->VTOR = SRAM_BASE | VECT_TAB_OFFSET; /* Vector Table Relocation in Internal SRAM. */ #else SCB->VTOR = FLASH_BASE | VECT_TAB_OFFSET; /* Vector Table Relocation in Internal FLASH. */ #endif } /** * @brief Update SystemCoreClock variable according to Clock Register Values. * The SystemCoreClock variable contains the core clock (HCLK), it can * be used by the user application to setup the SysTick timer or configure * other parameters. * * @note Each time the core clock (HCLK) changes, this function must be called * to update SystemCoreClock variable value. Otherwise, any configuration * based on this variable will be incorrect. * * @note - The system frequency computed by this function is not the real * frequency in the chip. It is calculated based on the predefined * constant and the selected clock source: * * - If SYSCLK source is HSI, SystemCoreClock will contain the HSI_VALUE(*) * * - If SYSCLK source is HSE, SystemCoreClock will contain the HSE_VALUE(**) * * - If SYSCLK source is PLL, SystemCoreClock will contain the HSE_VALUE(**) * or HSI_VALUE(*) multiplied by the PLL factors. * * (*) HSI_VALUE is a constant defined in stm32f1xx.h file (default value * 8 MHz) but the real value may vary depending on the variations * in voltage and temperature. * * (**) HSE_VALUE is a constant defined in stm32f1xx.h file (default value * 8 MHz or 25 MHz, depending on the product used), user has to ensure * that HSE_VALUE is same as the real frequency of the crystal used. * Otherwise, this function may have wrong result. * * - The result of this function could be not correct when using fractional * value for HSE crystal. * @param None * @retval None */ void SystemCoreClockUpdate (void) { uint32_t tmp = 0, pllmull = 0, pllsource = 0; #if defined(STM32F105xC) || defined(STM32F107xC) uint32_t prediv1source = 0, prediv1factor = 0, prediv2factor = 0, pll2mull = 0; #endif /* STM32F105xC */ #if defined(STM32F100xB) || defined(STM32F100xE) uint32_t prediv1factor = 0; #endif /* STM32F100xB or STM32F100xE */ /* Get SYSCLK source -------------------------------------------------------*/ tmp = RCC->CFGR & RCC_CFGR_SWS; switch (tmp) { case 0x00: /* HSI used as system clock */ SystemCoreClock = HSI_VALUE; break; case 0x04: /* HSE used as system clock */ SystemCoreClock = HSE_VALUE; break; case 0x08: /* PLL used as system clock */ /* Get PLL clock source and multiplication factor ----------------------*/ pllmull = RCC->CFGR & RCC_CFGR_PLLMULL; pllsource = RCC->CFGR & RCC_CFGR_PLLSRC; #if !defined(STM32F105xC) && !defined(STM32F107xC) pllmull = ( pllmull >> 18) + 2; if (pllsource == 0x00) { /* HSI oscillator clock divided by 2 selected as PLL clock entry */ SystemCoreClock = (HSI_VALUE >> 1) * pllmull; } else { #if defined(STM32F100xB) || defined(STM32F100xE) prediv1factor = (RCC->CFGR2 & RCC_CFGR2_PREDIV1) + 1; /* HSE oscillator clock selected as PREDIV1 clock entry */ SystemCoreClock = (HSE_VALUE / prediv1factor) * pllmull; #else /* HSE selected as PLL clock entry */ if ((RCC->CFGR & RCC_CFGR_PLLXTPRE) != (uint32_t)RESET) {/* HSE oscillator clock divided by 2 */ SystemCoreClock = (HSE_VALUE >> 1) * pllmull; } else { SystemCoreClock = HSE_VALUE * pllmull; } #endif } #else pllmull = pllmull >> 18; if (pllmull != 0x0D) { pllmull += 2; } else { /* PLL multiplication factor = PLL input clock * 6.5 */ pllmull = 13 / 2; } if (pllsource == 0x00) { /* HSI oscillator clock divided by 2 selected as PLL clock entry */ SystemCoreClock = (HSI_VALUE >> 1) * pllmull; } else {/* PREDIV1 selected as PLL clock entry */ /* Get PREDIV1 clock source and division factor */ prediv1source = RCC->CFGR2 & RCC_CFGR2_PREDIV1SRC; prediv1factor = (RCC->CFGR2 & RCC_CFGR2_PREDIV1) + 1; if (prediv1source == 0) { /* HSE oscillator clock selected as PREDIV1 clock entry */ SystemCoreClock = (HSE_VALUE / prediv1factor) * pllmull; } else {/* PLL2 clock selected as PREDIV1 clock entry */ /* Get PREDIV2 division factor and PLL2 multiplication factor */ prediv2factor = ((RCC->CFGR2 & RCC_CFGR2_PREDIV2) >> 4) + 1; pll2mull = ((RCC->CFGR2 & RCC_CFGR2_PLL2MUL) >> 8 ) + 2; SystemCoreClock = (((HSE_VALUE / prediv2factor) * pll2mull) / prediv1factor) * pllmull; } } #endif /* STM32F105xC */ break; default: SystemCoreClock = HSI_VALUE; break; } /* Compute HCLK clock frequency ----------------*/ /* Get HCLK prescaler */ tmp = AHBPrescTable[((RCC->CFGR & RCC_CFGR_HPRE) >> 4)]; /* HCLK clock frequency */ SystemCoreClock >>= tmp; } #if defined(STM32F100xE) || defined(STM32F101xE) || defined(STM32F101xG) || defined(STM32F103xE) || defined(STM32F103xG) /** * @brief Setup the external memory controller. Called in startup_stm32f1xx.s * before jump to __main * @param None * @retval None */ #ifdef DATA_IN_ExtSRAM /** * @brief Setup the external memory controller. * Called in startup_stm32f1xx_xx.s/.c before jump to main. * This function configures the external SRAM mounted on STM3210E-EVAL * board (STM32 High density devices). This SRAM will be used as program * data memory (including heap and stack). * @param None * @retval None */ void SystemInit_ExtMemCtl(void) { /*!< FSMC Bank1 NOR/SRAM3 is used for the STM3210E-EVAL, if another Bank is required, then adjust the Register Addresses */ /* Enable FSMC clock */ RCC->AHBENR = 0x00000114; /* Enable GPIOD, GPIOE, GPIOF and GPIOG clocks */ RCC->APB2ENR = 0x000001E0; /* --------------- SRAM Data lines, NOE and NWE configuration ---------------*/ /*---------------- SRAM Address lines configuration -------------------------*/ /*---------------- NOE and NWE configuration --------------------------------*/ /*---------------- NE3 configuration ----------------------------------------*/ /*---------------- NBL0, NBL1 configuration ---------------------------------*/ GPIOD->CRL = 0x44BB44BB; GPIOD->CRH = 0xBBBBBBBB; GPIOE->CRL = 0xB44444BB; GPIOE->CRH = 0xBBBBBBBB; GPIOF->CRL = 0x44BBBBBB; GPIOF->CRH = 0xBBBB4444; GPIOG->CRL = 0x44BBBBBB; GPIOG->CRH = 0x44444B44; /*---------------- FSMC Configuration ---------------------------------------*/ /*---------------- Enable FSMC Bank1_SRAM Bank ------------------------------*/ FSMC_Bank1->BTCR[4] = 0x00001011; FSMC_Bank1->BTCR[5] = 0x00000200; } #endif /* DATA_IN_ExtSRAM */ #endif /* STM32F100xE || STM32F101xE || STM32F101xG || STM32F103xE || STM32F103xG */ /** * @} */ /** * @} */ /** * @} */
0
D://workCode//uploadProject\STM32CubeF1\Projects\STM3210E_EVAL\Applications\USB_Device\CustomHID_Standalone
D://workCode//uploadProject\STM32CubeF1\Projects\STM3210E_EVAL\Applications\USB_Device\CustomHID_Standalone\Src\usbd_conf.c
/** ****************************************************************************** * @file USB_Device/CustomHID_Standalone/Src/usbd_conf.c * @author MCD Application Team * @brief This file implements the USB Device library callbacks and MSP ****************************************************************************** * @attention * * Copyright (c) 2015 STMicroelectronics. * All rights reserved. * * This software is licensed under terms that can be found in the LICENSE file * in the root directory of this software component. * If no LICENSE file comes with this software, it is provided AS-IS. * ****************************************************************************** */ /* Includes ------------------------------------------------------------------ */ #include "main.h" /* Private typedef ----------------------------------------------------------- */ /* Private define ------------------------------------------------------------ */ #define USB_DISCONNECT_PORT GPIOB #define USB_DISCONNECT_PIN GPIO_PIN_14 /* Private macro ------------------------------------------------------------- */ /* Private variables --------------------------------------------------------- */ PCD_HandleTypeDef hpcd; /* Private function prototypes ----------------------------------------------- */ /* Private functions --------------------------------------------------------- */ /******************************************************************************* PCD BSP Routines *******************************************************************************/ /** * @brief Initializes the PCD MSP. * @param hpcd: PCD handle * @retval None */ void HAL_PCD_MspInit(PCD_HandleTypeDef * hpcd) { GPIO_InitTypeDef GPIO_InitStruct; /* Enable the GPIOA clock */ __HAL_RCC_GPIOA_CLK_ENABLE(); /* Configure USB DM/DP pins */ GPIO_InitStruct.Pin = (GPIO_PIN_11 | GPIO_PIN_12); GPIO_InitStruct.Mode = GPIO_MODE_AF_INPUT; GPIO_InitStruct.Pull = GPIO_PULLUP; GPIO_InitStruct.Speed = GPIO_SPEED_FREQ_HIGH; HAL_GPIO_Init(GPIOA, &GPIO_InitStruct); /* Enable the USB disconnect GPIO clock */ __HAL_RCC_GPIOB_CLK_ENABLE(); /* USB_DISCONNECT used as USB pull-up */ GPIO_InitStruct.Pin = USB_DISCONNECT_PIN; GPIO_InitStruct.Mode = GPIO_MODE_OUTPUT_OD; HAL_GPIO_Init(USB_DISCONNECT_PORT, &GPIO_InitStruct); /* Enable USB Clock */ __HAL_RCC_USB_CLK_ENABLE(); /* Set USB Interrupt priority */ HAL_NVIC_SetPriority(USB_LP_CAN1_RX0_IRQn, 3, 0); /* Enable USB Interrupt */ HAL_NVIC_EnableIRQ(USB_LP_CAN1_RX0_IRQn); } /** * @brief De-Initializes the PCD MSP. * @param hpcd: PCD handle * @retval None */ void HAL_PCD_MspDeInit(PCD_HandleTypeDef * hpcd) { /* Disable USB FS Clock */ __HAL_RCC_USB_CLK_DISABLE(); } /******************************************************************************* LL Driver Callbacks (PCD -> USB Device Library) *******************************************************************************/ /** * @brief SetupStage callback. * @param hpcd: PCD handle * @retval None */ void HAL_PCD_SetupStageCallback(PCD_HandleTypeDef * hpcd) { USBD_LL_SetupStage((USBD_HandleTypeDef *) hpcd->pData, (uint8_t *) hpcd->Setup); } /** * @brief DataOut Stage callback. * @param hpcd: PCD handle * @param epnum: Endpoint Number * @retval None */ void HAL_PCD_DataOutStageCallback(PCD_HandleTypeDef * hpcd, uint8_t epnum) { USBD_LL_DataOutStage((USBD_HandleTypeDef *) hpcd->pData, epnum, hpcd->OUT_ep[epnum].xfer_buff); } /** * @brief DataIn Stage callback. * @param hpcd: PCD handle * @param epnum: Endpoint Number * @retval None */ void HAL_PCD_DataInStageCallback(PCD_HandleTypeDef * hpcd, uint8_t epnum) { USBD_LL_DataInStage((USBD_HandleTypeDef *) hpcd->pData, epnum, hpcd->IN_ep[epnum].xfer_buff); } /** * @brief SOF callback. * @param hpcd: PCD handle * @retval None */ void HAL_PCD_SOFCallback(PCD_HandleTypeDef * hpcd) { USBD_LL_SOF((USBD_HandleTypeDef *) hpcd->pData); } /** * @brief Reset callback. * @param hpcd: PCD handle * @retval None */ void HAL_PCD_ResetCallback(PCD_HandleTypeDef * hpcd) { USBD_LL_SetSpeed((USBD_HandleTypeDef *) hpcd->pData, USBD_SPEED_FULL); /* Reset Device */ USBD_LL_Reset((USBD_HandleTypeDef *) hpcd->pData); } /** * @brief Suspend callback. * @param hpcd: PCD handle * @retval None */ void HAL_PCD_SuspendCallback(PCD_HandleTypeDef * hpcd) { } /** * @brief Resume callback. * @param hpcd: PCD handle * @retval None */ void HAL_PCD_ResumeCallback(PCD_HandleTypeDef * hpcd) { } /** * @brief ISOOUTIncomplete callback. * @param hpcd: PCD handle * @param epnum: Endpoint Number * @retval None */ void HAL_PCD_ISOOUTIncompleteCallback(PCD_HandleTypeDef * hpcd, uint8_t epnum) { USBD_LL_IsoOUTIncomplete((USBD_HandleTypeDef *) hpcd->pData, epnum); } /** * @brief ISOINIncomplete callback. * @param hpcd: PCD handle * @param epnum: Endpoint Number * @retval None */ void HAL_PCD_ISOINIncompleteCallback(PCD_HandleTypeDef * hpcd, uint8_t epnum) { USBD_LL_IsoINIncomplete((USBD_HandleTypeDef *) hpcd->pData, epnum); } /** * @brief ConnectCallback callback. * @param hpcd: PCD handle * @retval None */ void HAL_PCD_ConnectCallback(PCD_HandleTypeDef * hpcd) { USBD_LL_DevConnected((USBD_HandleTypeDef *) hpcd->pData); } /** * @brief Disconnect callback. * @param hpcd: PCD handle * @retval None */ void HAL_PCD_DisconnectCallback(PCD_HandleTypeDef * hpcd) { USBD_LL_DevDisconnected((USBD_HandleTypeDef *) hpcd->pData); } /******************************************************************************* LL Driver Interface (USB Device Library --> PCD) *******************************************************************************/ /** * @brief Initializes the Low Level portion of the Device driver. * @param pdev: Device handle * @retval USBD Status */ USBD_StatusTypeDef USBD_LL_Init(USBD_HandleTypeDef * pdev) { /* Set LL Driver parameters */ hpcd.Instance = USB; hpcd.Init.dev_endpoints = 8; hpcd.Init.phy_itface = PCD_PHY_EMBEDDED; hpcd.Init.speed = PCD_SPEED_FULL; hpcd.Init.low_power_enable = 0; /* Link The driver to the stack */ hpcd.pData = pdev; pdev->pData = &hpcd; /* Initialize LL Driver */ HAL_PCD_Init((PCD_HandleTypeDef *) pdev->pData); HAL_PCDEx_PMAConfig(pdev->pData, 0x00, PCD_SNG_BUF, 0x18); HAL_PCDEx_PMAConfig(pdev->pData, 0x80, PCD_SNG_BUF, 0x58); HAL_PCDEx_PMAConfig(pdev->pData, CUSTOM_HID_EPIN_ADDR, PCD_SNG_BUF, 0x98); HAL_PCDEx_PMAConfig(pdev->pData, CUSTOM_HID_EPOUT_ADDR, PCD_SNG_BUF, 0xD8); return USBD_OK; } /** * @brief De-Initializes the Low Level portion of the Device driver. * @param pdev: Device handle * @retval USBD Status */ USBD_StatusTypeDef USBD_LL_DeInit(USBD_HandleTypeDef * pdev) { HAL_PCD_DeInit((PCD_HandleTypeDef *) pdev->pData); return USBD_OK; } /** * @brief Starts the Low Level portion of the Device driver. * @param pdev: Device handle * @retval USBD Status */ USBD_StatusTypeDef USBD_LL_Start(USBD_HandleTypeDef * pdev) { HAL_PCD_Start((PCD_HandleTypeDef *) pdev->pData); return USBD_OK; } /** * @brief Stops the Low Level portion of the Device driver. * @param pdev: Device handle * @retval USBD Status */ USBD_StatusTypeDef USBD_LL_Stop(USBD_HandleTypeDef * pdev) { HAL_PCD_Stop((PCD_HandleTypeDef *) pdev->pData); return USBD_OK; } /** * @brief Opens an endpoint of the Low Level Driver. * @param pdev: Device handle * @param ep_addr: Endpoint Number * @param ep_type: Endpoint Type * @param ep_mps: Endpoint Max Packet Size * @retval USBD Status */ USBD_StatusTypeDef USBD_LL_OpenEP(USBD_HandleTypeDef * pdev, uint8_t ep_addr, uint8_t ep_type, uint16_t ep_mps) { HAL_PCD_EP_Open((PCD_HandleTypeDef *) pdev->pData, ep_addr, ep_mps, ep_type); return USBD_OK; } /** * @brief Closes an endpoint of the Low Level Driver. * @param pdev: Device handle * @param ep_addr: Endpoint Number * @retval USBD Status */ USBD_StatusTypeDef USBD_LL_CloseEP(USBD_HandleTypeDef * pdev, uint8_t ep_addr) { HAL_PCD_EP_Close((PCD_HandleTypeDef *) pdev->pData, ep_addr); return USBD_OK; } /** * @brief Flushes an endpoint of the Low Level Driver. * @param pdev: Device handle * @param ep_addr: Endpoint Number * @retval USBD Status */ USBD_StatusTypeDef USBD_LL_FlushEP(USBD_HandleTypeDef * pdev, uint8_t ep_addr) { HAL_PCD_EP_Flush((PCD_HandleTypeDef *) pdev->pData, ep_addr); return USBD_OK; } /** * @brief Sets a Stall condition on an endpoint of the Low Level Driver. * @param pdev: Device handle * @param ep_addr: Endpoint Number * @retval USBD Status */ USBD_StatusTypeDef USBD_LL_StallEP(USBD_HandleTypeDef * pdev, uint8_t ep_addr) { HAL_PCD_EP_SetStall((PCD_HandleTypeDef *) pdev->pData, ep_addr); return USBD_OK; } /** * @brief Clears a Stall condition on an endpoint of the Low Level Driver. * @param pdev: Device handle * @param ep_addr: Endpoint Number * @retval USBD Status */ USBD_StatusTypeDef USBD_LL_ClearStallEP(USBD_HandleTypeDef * pdev, uint8_t ep_addr) { HAL_PCD_EP_ClrStall((PCD_HandleTypeDef *) pdev->pData, ep_addr); return USBD_OK; } /** * @brief Returns Stall condition. * @param pdev: Device handle * @param ep_addr: Endpoint Number * @retval Stall (1: Yes, 0: No) */ uint8_t USBD_LL_IsStallEP(USBD_HandleTypeDef * pdev, uint8_t ep_addr) { PCD_HandleTypeDef *hpcd = (PCD_HandleTypeDef *) pdev->pData; if ((ep_addr & 0x80) == 0x80) { return hpcd->IN_ep[ep_addr & 0x7F].is_stall; } else { return hpcd->OUT_ep[ep_addr & 0x7F].is_stall; } } /** * @brief Assigns a USB address to the device. * @param pdev: Device handle * @param ep_addr: Endpoint Number * @retval USBD Status */ USBD_StatusTypeDef USBD_LL_SetUSBAddress(USBD_HandleTypeDef * pdev, uint8_t dev_addr) { HAL_PCD_SetAddress((PCD_HandleTypeDef *) pdev->pData, dev_addr); return USBD_OK; } /** * @brief Transmits data over an endpoint. * @param pdev: Device handle * @param ep_addr: Endpoint Number * @param pbuf: Pointer to data to be sent * @param size: Data size * @retval USBD Status */ USBD_StatusTypeDef USBD_LL_Transmit(USBD_HandleTypeDef * pdev, uint8_t ep_addr, uint8_t * pbuf, uint16_t size) { HAL_PCD_EP_Transmit((PCD_HandleTypeDef *) pdev->pData, ep_addr, pbuf, size); return USBD_OK; } /** * @brief Prepares an endpoint for reception. * @param pdev: Device handle * @param ep_addr: Endpoint Number * @param pbuf: Pointer to data to be received * @param size: Data size * @retval USBD Status */ USBD_StatusTypeDef USBD_LL_PrepareReceive(USBD_HandleTypeDef * pdev, uint8_t ep_addr, uint8_t * pbuf, uint16_t size) { HAL_PCD_EP_Receive((PCD_HandleTypeDef *) pdev->pData, ep_addr, pbuf, size); return USBD_OK; } /** * @brief Returns the last transferred packet size. * @param pdev: Device handle * @param ep_addr: Endpoint Number * @retval Received Data Size */ uint32_t USBD_LL_GetRxDataSize(USBD_HandleTypeDef * pdev, uint8_t ep_addr) { return HAL_PCD_EP_GetRxCount((PCD_HandleTypeDef *) pdev->pData, ep_addr); } /** * @brief Delays routine for the USB Device Library. * @param Delay: Delay in ms * @retval None */ void USBD_LL_Delay(uint32_t Delay) { HAL_Delay(Delay); } /** * @brief static single allocation. * @param size: size of allocated memory * @retval None */ void *USBD_static_malloc(uint32_t size) { static uint32_t mem[MAX_STATIC_ALLOC_SIZE]; return mem; } /** * @brief Dummy memory free * @param *p pointer to allocated memory address * @retval None */ void USBD_static_free(void *p) { } /** * @brief Software Device Connection * @param hpcd: PCD handle * @param state: connection state (0 : disconnected / 1: connected) * @retval None */ void HAL_PCDEx_SetConnectionState(PCD_HandleTypeDef * hpcd, uint8_t state) { if (state != 0) { /* Enabling DP Pull-Down bit to Connect internal pull-up on USB DP line */ HAL_GPIO_WritePin(GPIOB, GPIO_PIN_14, GPIO_PIN_RESET); } else { /* Disable DP Pull-Down bit */ HAL_GPIO_WritePin(GPIOB, GPIO_PIN_14, GPIO_PIN_SET); } }
0
D://workCode//uploadProject\STM32CubeF1\Projects\STM3210E_EVAL\Applications\USB_Device\CustomHID_Standalone
D://workCode//uploadProject\STM32CubeF1\Projects\STM3210E_EVAL\Applications\USB_Device\CustomHID_Standalone\Src\usbd_customhid_if.c
/** ****************************************************************************** * @file USB_Device/CustomHID_Standalone/Src/usbd_customhid_if.c * @author MCD Application Team * @brief USB Device Custom HID interface file. ****************************************************************************** * @attention * * Copyright (c) 2015 STMicroelectronics. * All rights reserved. * * This software is licensed under terms that can be found in the LICENSE file * in the root directory of this software component. * If no LICENSE file comes with this software, it is provided AS-IS. * ****************************************************************************** */ /* Includes ------------------------------------------------------------------ */ #include "usbd_customhid_if.h" /* Private typedef ----------------------------------------------------------- */ /* Private define ------------------------------------------------------------ */ /* Private macro ------------------------------------------------------------- */ /* Private function prototypes ----------------------------------------------- */ static int8_t CustomHID_Init(void); static int8_t CustomHID_DeInit(void); static int8_t CustomHID_OutEvent(uint8_t event_idx, uint8_t state); /* Private variables --------------------------------------------------------- */ ADC_HandleTypeDef AdcHandle; uint32_t ADCConvertedValue = 0; uint32_t ADC_Prev_ConvertedValue = 0; uint8_t SendBuffer[2]; extern USBD_HandleTypeDef USBD_Device; __ALIGN_BEGIN static uint8_t CustomHID_ReportDesc[USBD_CUSTOM_HID_REPORT_DESC_SIZE] __ALIGN_END = { 0x06, 0xFF, 0x00, /* USAGE_PAGE (Vendor Page: 0xFF00) */ 0x09, 0x01, /* USAGE (Demo Kit) */ 0xa1, 0x01, /* COLLECTION (Application) */ /* 6 */ /* Led 1 */ 0x85, LED1_REPORT_ID, /* REPORT_ID (1) */ 0x09, 0x01, /* USAGE (LED 1) */ 0x15, 0x00, /* LOGICAL_MINIMUM (0) */ 0x25, 0x01, /* LOGICAL_MAXIMUM (1) */ 0x75, 0x08, /* REPORT_SIZE (8) */ 0x95, LED1_REPORT_COUNT, /* REPORT_COUNT (1) */ 0xB1, 0x82, /* FEATURE (Data,Var,Abs,Vol) */ 0x85, LED1_REPORT_ID, /* REPORT_ID (1) */ 0x09, 0x01, /* USAGE (LED 1) */ 0x91, 0x82, /* OUTPUT (Data,Var,Abs,Vol) */ /* 26 */ /* Led 2 */ 0x85, LED2_REPORT_ID, /* REPORT_ID 2 */ 0x09, 0x02, /* USAGE (LED 2) */ 0x15, 0x00, /* LOGICAL_MINIMUM (0) */ 0x25, 0x01, /* LOGICAL_MAXIMUM (1) */ 0x75, 0x08, /* REPORT_SIZE (8) */ 0x95, LED2_REPORT_COUNT, /* REPORT_COUNT (1) */ 0xB1, 0x82, /* FEATURE (Data,Var,Abs,Vol) */ 0x85, LED2_REPORT_ID, /* REPORT_ID (2) */ 0x09, 0x02, /* USAGE (LED 2) */ 0x91, 0x82, /* OUTPUT (Data,Var,Abs,Vol) */ /* 46 */ /* Led 3 */ 0x85, LED3_REPORT_ID, /* REPORT_ID (3) */ 0x09, 0x03, /* USAGE (LED 3) */ 0x15, 0x00, /* LOGICAL_MINIMUM (0) */ 0x25, 0x01, /* LOGICAL_MAXIMUM (1) */ 0x75, 0x08, /* REPORT_SIZE (8) */ 0x95, LED3_REPORT_COUNT, /* REPORT_COUNT (1) */ 0xB1, 0x82, /* FEATURE (Data,Var,Abs,Vol) */ 0x85, LED3_REPORT_ID, /* REPORT_ID (3) */ 0x09, 0x03, /* USAGE (LED 3) */ 0x91, 0x82, /* OUTPUT (Data,Var,Abs,Vol) */ /* 66 */ /* Led 4 */ 0x85, LED4_REPORT_ID, /* REPORT_ID 4) */ 0x09, 0x04, /* USAGE (LED 4) */ 0x15, 0x00, /* LOGICAL_MINIMUM (0) */ 0x25, 0x01, /* LOGICAL_MAXIMUM (1) */ 0x75, 0x08, /* REPORT_SIZE (8) */ 0x95, LED4_REPORT_COUNT, /* REPORT_COUNT (1) */ 0xB1, 0x82, /* FEATURE (Data,Var,Abs,Vol) */ 0x85, LED4_REPORT_ID, /* REPORT_ID (4) */ 0x09, 0x04, /* USAGE (LED 4) */ 0x91, 0x82, /* OUTPUT (Data,Var,Abs,Vol) */ /* 86 */ /* key Push Button */ 0x85, KEY_REPORT_ID, /* REPORT_ID (5) */ 0x09, 0x05, /* USAGE (Push Button) */ 0x15, 0x00, /* LOGICAL_MINIMUM (0) */ 0x25, 0x01, /* LOGICAL_MAXIMUM (1) */ 0x75, 0x01, /* REPORT_SIZE (1) */ 0x81, 0x82, /* INPUT (Data,Var,Abs,Vol) */ 0x09, 0x05, /* USAGE (Push Button) */ 0x75, 0x01, /* REPORT_SIZE (1) */ 0xb1, 0x82, /* FEATURE (Data,Var,Abs,Vol) */ 0x75, 0x07, /* REPORT_SIZE (7) */ 0x81, 0x83, /* INPUT (Cnst,Var,Abs,Vol) */ 0x85, KEY_REPORT_ID, /* REPORT_ID (2) */ 0x75, 0x07, /* REPORT_SIZE (7) */ 0xb1, 0x83, /* FEATURE (Cnst,Var,Abs,Vol) */ /* 114 */ /* Tamper Push Button */ 0x85, TAMPER_REPORT_ID, /* REPORT_ID (6) */ 0x09, 0x06, /* USAGE (Tamper Push Button) */ 0x15, 0x00, /* LOGICAL_MINIMUM (0) */ 0x25, 0x01, /* LOGICAL_MAXIMUM (1) */ 0x75, 0x01, /* REPORT_SIZE (1) */ 0x81, 0x82, /* INPUT (Data,Var,Abs,Vol) */ 0x09, 0x06, /* USAGE (Tamper Push Button) */ 0x75, 0x01, /* REPORT_SIZE (1) */ 0xb1, 0x82, /* FEATURE (Data,Var,Abs,Vol) */ 0x75, 0x07, /* REPORT_SIZE (7) */ 0x81, 0x83, /* INPUT (Cnst,Var,Abs,Vol) */ 0x85, TAMPER_REPORT_ID, /* REPORT_ID (6) */ 0x75, 0x07, /* REPORT_SIZE (7) */ 0xb1, 0x83, /* FEATURE (Cnst,Var,Abs,Vol) */ /* 142 */ /* ADC IN */ 0x85, ADC_REPORT_ID, /* REPORT_ID */ 0x09, 0x07, /* USAGE (ADC IN) */ 0x15, 0x00, /* LOGICAL_MINIMUM (0) */ 0x26, 0xff, 0x00, /* LOGICAL_MAXIMUM (255) */ 0x75, 0x08, /* REPORT_SIZE (8) */ 0x81, 0x82, /* INPUT (Data,Var,Abs,Vol) */ 0x85, ADC_REPORT_ID, /* REPORT_ID (7) */ 0x09, 0x07, /* USAGE (ADC in) */ 0xb1, 0x82, /* FEATURE (Data,Var,Abs,Vol) */ /* 161 */ 0xc0 /* END_COLLECTION */ }; USBD_CUSTOM_HID_ItfTypeDef USBD_CustomHID_fops = { CustomHID_ReportDesc, CustomHID_Init, CustomHID_DeInit, CustomHID_OutEvent, }; /* Private functions --------------------------------------------------------- */ /** * @brief CustomHID_Init * Initializes the CUSTOM HID media low layer * @param None * @retval Result of the operation: USBD_OK if all operations are OK else USBD_FAIL */ static int8_t CustomHID_Init(void) { GPIO_InitTypeDef GPIO_InitStructure; ADC_ChannelConfTypeDef sConfig; /* Configure the ADC peripheral */ AdcHandle.Instance = ADCx; __HAL_RCC_ADC1_CLK_ENABLE(); AdcHandle.Init.ScanConvMode = DISABLE; AdcHandle.Init.ContinuousConvMode = ENABLE; AdcHandle.Init.DiscontinuousConvMode = DISABLE; AdcHandle.Init.NbrOfDiscConversion = 0; AdcHandle.Init.ExternalTrigConv = ADC_SOFTWARE_START; AdcHandle.Init.DataAlign = ADC_DATAALIGN_RIGHT; AdcHandle.Init.NbrOfConversion = 1; HAL_ADC_Init(&AdcHandle); /* Configure ADC regular channel */ sConfig.Channel = ADCx_CHANNEL; sConfig.Rank = 1; sConfig.SamplingTime = ADC_SAMPLETIME_55CYCLES_5; HAL_ADC_ConfigChannel(&AdcHandle, &sConfig); /* Start the conversion process and enable interrupt */ HAL_ADC_Start_DMA(&AdcHandle, (uint32_t *) & ADCConvertedValue, 1); /* Configure LED1, LED2, LED3 and LED4 */ BSP_LED_Init(LED1); BSP_LED_Init(LED2); BSP_LED_Init(LED3); BSP_LED_Init(LED4); /* Enable GPIOG clock */ __HAL_RCC_GPIOG_CLK_ENABLE(); /* Configure PG8 pin as input floating for key Button */ GPIO_InitStructure.Mode = GPIO_MODE_IT_RISING_FALLING; GPIO_InitStructure.Pull = GPIO_NOPULL; GPIO_InitStructure.Pin = GPIO_PIN_8; HAL_GPIO_Init(GPIOG, &GPIO_InitStructure); /* Enable and set EXTI2_TSC Interrupt to the lowest priority */ HAL_NVIC_SetPriority(EXTI9_5_IRQn, 3, 0); HAL_NVIC_EnableIRQ(EXTI9_5_IRQn); return (0); } /** * @brief CustomHID_DeInit * DeInitializes the CUSTOM HID media low layer * @param None * @retval Result of the operation: USBD_OK if all operations are OK else USBD_FAIL */ static int8_t CustomHID_DeInit(void) { /* * Add your deinitialization code here */ return (0); } /** * @brief CustomHID_OutEvent * Manage the CUSTOM HID class Out Event * @param event_idx: LED Report Number * @param state: LED states (ON/OFF) */ static int8_t CustomHID_OutEvent(uint8_t event_idx, uint8_t state) { switch (event_idx) { case 1: /* LED1 */ (state == 1) ? BSP_LED_On(LED1) : BSP_LED_Off(LED1); break; case 2: /* LED2 */ (state == 1) ? BSP_LED_On(LED2) : BSP_LED_Off(LED2); break; case 3: /* LED3 */ (state == 1) ? BSP_LED_On(LED3) : BSP_LED_Off(LED3); break; case 4: /* LED4 */ (state == 1) ? BSP_LED_On(LED4) : BSP_LED_Off(LED4); break; default: BSP_LED_Off(LED1); BSP_LED_Off(LED2); BSP_LED_Off(LED3); BSP_LED_Off(LED4); break; } return (0); } /** * @brief EXTI line detection callbacks * @param GPIO_Pin: Specifies the pins connected EXTI line * @retval None */ void HAL_GPIO_EXTI_Callback(uint16_t GPIO_Pin) { if (GPIO_Pin == KEY_BUTTON_PIN) { SendBuffer[0] = KEY_REPORT_ID; if (BSP_PB_GetState(BUTTON_KEY) == GPIO_PIN_RESET) { SendBuffer[1] = 0x01; } else { SendBuffer[1] = 0x00; } USBD_CUSTOM_HID_SendReport(&USBD_Device, SendBuffer, 2); } }
0
D://workCode//uploadProject\STM32CubeF1\Projects\STM3210E_EVAL\Applications\USB_Device\CustomHID_Standalone
D://workCode//uploadProject\STM32CubeF1\Projects\STM3210E_EVAL\Applications\USB_Device\CustomHID_Standalone\Src\usbd_desc.c
/** ****************************************************************************** * @file USB_Device/CustomHID_Standalone/Src/usbd_desc.c * @author MCD Application Team * @brief This file provides the USBD descriptors and string formatting method. ****************************************************************************** * @attention * * Copyright (c) 2015 STMicroelectronics. * All rights reserved. * * This software is licensed under terms that can be found in the LICENSE file * in the root directory of this software component. * If no LICENSE file comes with this software, it is provided AS-IS. * ****************************************************************************** */ /* Includes ------------------------------------------------------------------ */ #include "usbd_core.h" #include "usbd_desc.h" #include "usbd_conf.h" /* Private typedef ----------------------------------------------------------- */ /* Private define ------------------------------------------------------------ */ #define USBD_VID 0x0483 #define USBD_PID 0x5750 #define USBD_LANGID_STRING 0x409 #define USBD_MANUFACTURER_STRING "STMicroelectronics" #define USBD_PRODUCT_FS_STRING "Custome HID in FS Mode" #define USBD_CONFIGURATION_FS_STRING "HID Config" #define USBD_INTERFACE_FS_STRING "HID Interface" /* Private macro ------------------------------------------------------------- */ /* Private function prototypes ----------------------------------------------- */ uint8_t *USBD_HID_DeviceDescriptor(USBD_SpeedTypeDef speed, uint16_t * length); uint8_t *USBD_HID_LangIDStrDescriptor(USBD_SpeedTypeDef speed, uint16_t * length); uint8_t *USBD_HID_ManufacturerStrDescriptor(USBD_SpeedTypeDef speed, uint16_t * length); uint8_t *USBD_HID_ProductStrDescriptor(USBD_SpeedTypeDef speed, uint16_t * length); uint8_t *USBD_HID_SerialStrDescriptor(USBD_SpeedTypeDef speed, uint16_t * length); uint8_t *USBD_HID_ConfigStrDescriptor(USBD_SpeedTypeDef speed, uint16_t * length); uint8_t *USBD_HID_InterfaceStrDescriptor(USBD_SpeedTypeDef speed, uint16_t * length); /* Private variables --------------------------------------------------------- */ USBD_DescriptorsTypeDef HID_Desc = { USBD_HID_DeviceDescriptor, USBD_HID_LangIDStrDescriptor, USBD_HID_ManufacturerStrDescriptor, USBD_HID_ProductStrDescriptor, USBD_HID_SerialStrDescriptor, USBD_HID_ConfigStrDescriptor, USBD_HID_InterfaceStrDescriptor, }; /* USB Standard Device Descriptor */ #if defined ( __ICCARM__ ) /*!< IAR Compiler */ #pragma data_alignment=4 #endif __ALIGN_BEGIN uint8_t USBD_DeviceDesc[USB_LEN_DEV_DESC] __ALIGN_END = { 0x12, /* bLength */ USB_DESC_TYPE_DEVICE, /* bDescriptorType */ 0x00, /* bcdUSB */ 0x02, 0x00, /* bDeviceClass */ 0x00, /* bDeviceSubClass */ 0x00, /* bDeviceProtocol */ USB_MAX_EP0_SIZE, /* bMaxPacketSize */ LOBYTE(USBD_VID), /* idVendor */ HIBYTE(USBD_VID), /* idVendor */ LOBYTE(USBD_PID), /* idVendor */ HIBYTE(USBD_PID), /* idVendor */ 0x00, /* bcdDevice rel. 2.00 */ 0x02, USBD_IDX_MFC_STR, /* Index of manufacturer string */ USBD_IDX_PRODUCT_STR, /* Index of product string */ USBD_IDX_SERIAL_STR, /* Index of serial number string */ USBD_MAX_NUM_CONFIGURATION /* bNumConfigurations */ }; /* USB_DeviceDescriptor */ /* USB Standard Device Descriptor */ #if defined ( __ICCARM__ ) /*!< IAR Compiler */ #pragma data_alignment=4 #endif __ALIGN_BEGIN uint8_t USBD_LangIDDesc[USB_LEN_LANGID_STR_DESC] __ALIGN_END = { USB_LEN_LANGID_STR_DESC, USB_DESC_TYPE_STRING, LOBYTE(USBD_LANGID_STRING), HIBYTE(USBD_LANGID_STRING), }; #if defined ( __ICCARM__ ) /*!< IAR Compiler */ #pragma data_alignment=4 #endif __ALIGN_BEGIN uint8_t USBD_StringSerial[USB_SIZ_STRING_SERIAL] __ALIGN_END = { USB_SIZ_STRING_SERIAL, USB_DESC_TYPE_STRING, }; #if defined ( __ICCARM__ ) /*!< IAR Compiler */ #pragma data_alignment=4 #endif __ALIGN_BEGIN uint8_t USBD_StrDesc[USBD_MAX_STR_DESC_SIZ] __ALIGN_END; /* Private functions --------------------------------------------------------- */ static void IntToUnicode(uint32_t value, uint8_t * pbuf, uint8_t len); static void Get_SerialNum(void); /** * @brief Returns the device descriptor. * @param speed: Current device speed * @param length: Pointer to data length variable * @retval Pointer to descriptor buffer */ uint8_t *USBD_HID_DeviceDescriptor(USBD_SpeedTypeDef speed, uint16_t * length) { *length = sizeof(USBD_DeviceDesc); return (uint8_t *) USBD_DeviceDesc; } /** * @brief Returns the LangID string descriptor. * @param speed: Current device speed * @param length: Pointer to data length variable * @retval Pointer to descriptor buffer */ uint8_t *USBD_HID_LangIDStrDescriptor(USBD_SpeedTypeDef speed, uint16_t * length) { *length = sizeof(USBD_LangIDDesc); return (uint8_t *) USBD_LangIDDesc; } /** * @brief Returns the product string descriptor. * @param speed: Current device speed * @param length: Pointer to data length variable * @retval Pointer to descriptor buffer */ uint8_t *USBD_HID_ProductStrDescriptor(USBD_SpeedTypeDef speed, uint16_t * length) { USBD_GetString((uint8_t *) USBD_PRODUCT_FS_STRING, USBD_StrDesc, length); return USBD_StrDesc; } /** * @brief Returns the manufacturer string descriptor. * @param speed: Current device speed * @param length: Pointer to data length variable * @retval Pointer to descriptor buffer */ uint8_t *USBD_HID_ManufacturerStrDescriptor(USBD_SpeedTypeDef speed, uint16_t * length) { USBD_GetString((uint8_t *) USBD_MANUFACTURER_STRING, USBD_StrDesc, length); return USBD_StrDesc; } /** * @brief Returns the serial number string descriptor. * @param speed: Current device speed * @param length: Pointer to data length variable * @retval Pointer to descriptor buffer */ uint8_t *USBD_HID_SerialStrDescriptor(USBD_SpeedTypeDef speed, uint16_t * length) { *length = USB_SIZ_STRING_SERIAL; /* Update the serial number string descriptor with the data from the unique * ID */ Get_SerialNum(); return USBD_StringSerial; } /** * @brief Returns the configuration string descriptor. * @param speed: Current device speed * @param length: Pointer to data length variable * @retval Pointer to descriptor buffer */ uint8_t *USBD_HID_ConfigStrDescriptor(USBD_SpeedTypeDef speed, uint16_t * length) { USBD_GetString((uint8_t *) USBD_CONFIGURATION_FS_STRING, USBD_StrDesc, length); return USBD_StrDesc; } /** * @brief Returns the interface string descriptor. * @param speed: Current device speed * @param length: Pointer to data length variable * @retval Pointer to descriptor buffer */ uint8_t *USBD_HID_InterfaceStrDescriptor(USBD_SpeedTypeDef speed, uint16_t * length) { USBD_GetString((uint8_t *) USBD_INTERFACE_FS_STRING, USBD_StrDesc, length); return USBD_StrDesc; } /** * @brief Create the serial number string descriptor * @param None * @retval None */ static void Get_SerialNum(void) { uint32_t deviceserial0, deviceserial1, deviceserial2; deviceserial0 = *(uint32_t *) DEVICE_ID1; deviceserial1 = *(uint32_t *) DEVICE_ID2; deviceserial2 = *(uint32_t *) DEVICE_ID3; deviceserial0 += deviceserial2; if (deviceserial0 != 0) { IntToUnicode(deviceserial0, &USBD_StringSerial[2], 8); IntToUnicode(deviceserial1, &USBD_StringSerial[18], 4); } } /** * @brief Convert Hex 32Bits value into char * @param value: value to convert * @param pbuf: pointer to the buffer * @param len: buffer length * @retval None */ static void IntToUnicode(uint32_t value, uint8_t * pbuf, uint8_t len) { uint8_t idx = 0; for (idx = 0; idx < len; idx++) { if (((value >> 28)) < 0xA) { pbuf[2 * idx] = (value >> 28) + '0'; } else { pbuf[2 * idx] = (value >> 28) + 'A' - 10; } value = value << 4; pbuf[2 * idx + 1] = 0; } }
0
D://workCode//uploadProject\STM32CubeF1\Projects\STM3210E_EVAL\Applications\USB_Device\DFU_Standalone
D://workCode//uploadProject\STM32CubeF1\Projects\STM3210E_EVAL\Applications\USB_Device\DFU_Standalone\Inc\main.h
/** ****************************************************************************** * @file USB_Device/DFU_Standalone/Inc/main.h * @author MCD Application Team * @brief Header for main.c module ****************************************************************************** * @attention * * Copyright (c) 2016 STMicroelectronics. * All rights reserved. * * This software is licensed under terms that can be found in the LICENSE file * in the root directory of this software component. * If no LICENSE file comes with this software, it is provided AS-IS. * ****************************************************************************** */ /* Define to prevent recursive inclusion -------------------------------------*/ #ifndef __MAIN_H #define __MAIN_H /* Includes ------------------------------------------------------------------*/ #include "stm32f1xx_hal.h" #include "stm3210e_eval.h" #include "usbd_core.h" #include "stm32f1xx_hal_pcd.h" #include "usbd_desc.h" #include "usbd_dfu.h" #include "usbd_dfu_flash.h" /* Exported types ------------------------------------------------------------*/ /* Exported constants --------------------------------------------------------*/ /* Exported macro ------------------------------------------------------------*/ /* Exported functions ------------------------------------------------------- */ #endif /* __MAIN_H */
0
D://workCode//uploadProject\STM32CubeF1\Projects\STM3210E_EVAL\Applications\USB_Device\DFU_Standalone
D://workCode//uploadProject\STM32CubeF1\Projects\STM3210E_EVAL\Applications\USB_Device\DFU_Standalone\Inc\stm32f1xx_hal_conf.h
/** ****************************************************************************** * @file USB_Device/DFU_Standalone/Inc/stm32f1xx_hal_conf.h * @author MCD Application Team * @brief HAL configuration template file. * This file should be copied to the application folder and renamed * to stm32f1xx_hal_conf.h. ****************************************************************************** * @attention * * Copyright (c) 2016 STMicroelectronics. * All rights reserved. * * This software is licensed under terms that can be found in the LICENSE file * in the root directory of this software component. * If no LICENSE file comes with this software, it is provided AS-IS. * ****************************************************************************** */ /* Define to prevent recursive inclusion -------------------------------------*/ #ifndef __STM32F1xx_HAL_CONF_H #define __STM32F1xx_HAL_CONF_H #ifdef __cplusplus extern "C" { #endif /* Exported types ------------------------------------------------------------*/ /* Exported constants --------------------------------------------------------*/ /* ########################## Module Selection ############################## */ /** * @brief This is the list of modules to be used in the HAL driver */ #define HAL_MODULE_ENABLED /* #define HAL_ADC_MODULE_ENABLED */ /* #define HAL_CAN_MODULE_ENABLED */ /* #define HAL_CAN_LEGACY_MODULE_ENABLED */ #define HAL_CORTEX_MODULE_ENABLED */ /* #define HAL_CRC_MODULE_ENABLED */ /* #define HAL_DAC_MODULE_ENABLED */ #define HAL_DMA_MODULE_ENABLED #define HAL_EXTI_MODULE_ENABLED #define HAL_FLASH_MODULE_ENABLED #define HAL_GPIO_MODULE_ENABLED /* #define HAL_I2C_MODULE_ENABLED */ /* #define HAL_I2S_MODULE_ENABLED */ /* #define HAL_IRDA_MODULE_ENABLED */ /* #define HAL_IWDG_MODULE_ENABLED */ /* #define HAL_NOR_MODULE_ENABLED */ /* #define HAL_PCCARD_MODULE_ENABLED */ #define HAL_PCD_MODULE_ENABLED #define HAL_PWR_MODULE_ENABLED #define HAL_RCC_MODULE_ENABLED /* #define HAL_RTC_MODULE_ENABLED */ /* #define HAL_SD_MODULE_ENABLED */ /* #define HAL_SDRAM_MODULE_ENABLED */ /* #define HAL_SMARTCARD_MODULE_ENABLED */ /* #define HAL_SPI_MODULE_ENABLED */ /* #define HAL_SRAM_MODULE_ENABLED */ /* #define HAL_TIM_MODULE_ENABLED */ #define HAL_UART_MODULE_ENABLED /* #define HAL_USART_MODULE_ENABLED */ /* #define HAL_WWDG_MODULE_ENABLED */ /* #define HAL_MMC_MODULE_ENABLED */ /* ########################## Oscillator Values adaptation ####################*/ /** * @brief Adjust the value of External High Speed oscillator (HSE) used in your application. * This value is used by the RCC HAL module to compute the system frequency * (when HSE is used as system clock source, directly or through the PLL). */ #if !defined (HSE_VALUE) #if defined(USE_STM3210C_EVAL) #define HSE_VALUE 25000000U /*!< Value of the External oscillator in Hz */ #else #define HSE_VALUE 8000000U /*!< Value of the External oscillator in Hz */ #endif #endif /* HSE_VALUE */ #if !defined (HSE_STARTUP_TIMEOUT) #define HSE_STARTUP_TIMEOUT 100U /*!< Time out for HSE start up, in ms */ #endif /* HSE_STARTUP_TIMEOUT */ /** * @brief Internal High Speed oscillator (HSI) value. * This value is used by the RCC HAL module to compute the system frequency * (when HSI is used as system clock source, directly or through the PLL). */ #if !defined (HSI_VALUE) #define HSI_VALUE 8000000U /*!< Value of the Internal oscillator in Hz */ #endif /* HSI_VALUE */ /** * @brief Internal Low Speed oscillator (LSI) value. */ #if !defined (LSI_VALUE) #define LSI_VALUE 40000U /*!< LSI Typical Value in Hz */ #endif /* LSI_VALUE */ /*!< Value of the Internal Low Speed oscillator in Hz The real value may vary depending on the variations in voltage and temperature. */ /** * @brief External Low Speed oscillator (LSE) value. * This value is used by the UART, RTC HAL module to compute the system frequency */ #if !defined (LSE_VALUE) #define LSE_VALUE 32768U /*!< Value of the External oscillator in Hz*/ #endif /* LSE_VALUE */ #if !defined (LSE_STARTUP_TIMEOUT) #define LSE_STARTUP_TIMEOUT 5000U /*!< Time out for LSE start up, in ms */ #endif /* LSE_STARTUP_TIMEOUT */ /* Tip: To avoid modifying this file each time you need to use different HSE, === you can define the HSE value in your toolchain compiler preprocessor. */ /* ########################### System Configuration ######################### */ /** * @brief This is the HAL system configuration section */ #define VDD_VALUE 3300U /*!< Value of VDD in mv */ #define TICK_INT_PRIORITY 0x00U /*!< tick interrupt priority */ #define USE_RTOS 0U #define PREFETCH_ENABLE 1U #define USE_HAL_ADC_REGISTER_CALLBACKS 0U /* ADC register callback disabled */ #define USE_HAL_CAN_REGISTER_CALLBACKS 0U /* CAN register callback disabled */ #define USE_HAL_CEC_REGISTER_CALLBACKS 0U /* CEC register callback disabled */ #define USE_HAL_DAC_REGISTER_CALLBACKS 0U /* DAC register callback disabled */ #define USE_HAL_ETH_REGISTER_CALLBACKS 0U /* ETH register callback disabled */ #define USE_HAL_HCD_REGISTER_CALLBACKS 0U /* HCD register callback disabled */ #define USE_HAL_I2C_REGISTER_CALLBACKS 0U /* I2C register callback disabled */ #define USE_HAL_I2S_REGISTER_CALLBACKS 0U /* I2S register callback disabled */ #define USE_HAL_MMC_REGISTER_CALLBACKS 0U /* MMC register callback disabled */ #define USE_HAL_NAND_REGISTER_CALLBACKS 0U /* NAND register callback disabled */ #define USE_HAL_NOR_REGISTER_CALLBACKS 0U /* NOR register callback disabled */ #define USE_HAL_PCCARD_REGISTER_CALLBACKS 0U /* PCCARD register callback disabled */ #define USE_HAL_PCD_REGISTER_CALLBACKS 0U /* PCD register callback disabled */ #define USE_HAL_RTC_REGISTER_CALLBACKS 0U /* RTC register callback disabled */ #define USE_HAL_SD_REGISTER_CALLBACKS 0U /* SD register callback disabled */ #define USE_HAL_SMARTCARD_REGISTER_CALLBACKS 0U /* SMARTCARD register callback disabled */ #define USE_HAL_IRDA_REGISTER_CALLBACKS 0U /* IRDA register callback disabled */ #define USE_HAL_SRAM_REGISTER_CALLBACKS 0U /* SRAM register callback disabled */ #define USE_HAL_SPI_REGISTER_CALLBACKS 0U /* SPI register callback disabled */ #define USE_HAL_TIM_REGISTER_CALLBACKS 0U /* TIM register callback disabled */ #define USE_HAL_UART_REGISTER_CALLBACKS 0U /* UART register callback disabled */ #define USE_HAL_USART_REGISTER_CALLBACKS 0U /* USART register callback disabled */ #define USE_HAL_WWDG_REGISTER_CALLBACKS 0U /* WWDG register callback disabled */ /* ########################## Assert Selection ############################## */ /** * @brief Uncomment the line below to expanse the "assert_param" macro in the * HAL drivers code */ /* #define USE_FULL_ASSERT 1U */ /* ################## Ethernet peripheral configuration ##################### */ /* Section 1 : Ethernet peripheral configuration */ /* MAC ADDRESS: MAC_ADDR0:MAC_ADDR1:MAC_ADDR2:MAC_ADDR3:MAC_ADDR4:MAC_ADDR5 */ #define MAC_ADDR0 2U #define MAC_ADDR1 0U #define MAC_ADDR2 0U #define MAC_ADDR3 0U #define MAC_ADDR4 0U #define MAC_ADDR5 0U /* Definition of the Ethernet driver buffers size and count */ #define ETH_RX_BUF_SIZE ETH_MAX_PACKET_SIZE /* buffer size for receive */ #define ETH_TX_BUF_SIZE ETH_MAX_PACKET_SIZE /* buffer size for transmit */ #define ETH_RXBUFNB 8U /* 8 Rx buffers of size ETH_RX_BUF_SIZE */ #define ETH_TXBUFNB 4U /* 4 Tx buffers of size ETH_TX_BUF_SIZE */ /* Section 2: PHY configuration section */ /* DP83848 PHY Address*/ #define DP83848_PHY_ADDRESS 0x01U /* PHY Reset delay these values are based on a 1 ms Systick interrupt*/ #define PHY_RESET_DELAY 0x000000FFU /* PHY Configuration delay */ #define PHY_CONFIG_DELAY 0x00000FFFU #define PHY_READ_TO 0x0000FFFFU #define PHY_WRITE_TO 0x0000FFFFU /* Section 3: Common PHY Registers */ #define PHY_BCR ((uint16_t)0x0000) /*!< Transceiver Basic Control Register */ #define PHY_BSR ((uint16_t)0x0001) /*!< Transceiver Basic Status Register */ #define PHY_RESET ((uint16_t)0x8000) /*!< PHY Reset */ #define PHY_LOOPBACK ((uint16_t)0x4000) /*!< Select loop-back mode */ #define PHY_FULLDUPLEX_100M ((uint16_t)0x2100) /*!< Set the full-duplex mode at 100 Mb/s */ #define PHY_HALFDUPLEX_100M ((uint16_t)0x2000) /*!< Set the half-duplex mode at 100 Mb/s */ #define PHY_FULLDUPLEX_10M ((uint16_t)0x0100) /*!< Set the full-duplex mode at 10 Mb/s */ #define PHY_HALFDUPLEX_10M ((uint16_t)0x0000) /*!< Set the half-duplex mode at 10 Mb/s */ #define PHY_AUTONEGOTIATION ((uint16_t)0x1000) /*!< Enable auto-negotiation function */ #define PHY_RESTART_AUTONEGOTIATION ((uint16_t)0x0200) /*!< Restart auto-negotiation function */ #define PHY_POWERDOWN ((uint16_t)0x0800) /*!< Select the power down mode */ #define PHY_ISOLATE ((uint16_t)0x0400) /*!< Isolate PHY from MII */ #define PHY_AUTONEGO_COMPLETE ((uint16_t)0x0020) /*!< Auto-Negotiation process completed */ #define PHY_LINKED_STATUS ((uint16_t)0x0004) /*!< Valid link established */ #define PHY_JABBER_DETECTION ((uint16_t)0x0002) /*!< Jabber condition detected */ /* Section 4: Extended PHY Registers */ #define PHY_SR ((uint16_t)0x0010) /*!< PHY status register Offset */ #define PHY_MICR ((uint16_t)0x0011) /*!< MII Interrupt Control Register */ #define PHY_MISR ((uint16_t)0x0012) /*!< MII Interrupt Status and Misc. Control Register */ #define PHY_LINK_STATUS ((uint16_t)0x0001) /*!< PHY Link mask */ #define PHY_SPEED_STATUS ((uint16_t)0x0002) /*!< PHY Speed mask */ #define PHY_DUPLEX_STATUS ((uint16_t)0x0004) /*!< PHY Duplex mask */ #define PHY_MICR_INT_EN ((uint16_t)0x0002) /*!< PHY Enable interrupts */ #define PHY_MICR_INT_OE ((uint16_t)0x0001) /*!< PHY Enable output interrupt events */ #define PHY_MISR_LINK_INT_EN ((uint16_t)0x0020) /*!< Enable Interrupt on change of link status */ #define PHY_LINK_INTERRUPT ((uint16_t)0x2000) /*!< PHY link status interrupt mask */ /* ################## SPI peripheral configuration ########################## */ /* CRC FEATURE: Use to activate CRC feature inside HAL SPI Driver * Activated: CRC code is present inside driver * Deactivated: CRC code cleaned from driver */ #define USE_SPI_CRC 1U /* Includes ------------------------------------------------------------------*/ /** * @brief Include module's header file */ #ifdef HAL_RCC_MODULE_ENABLED #include "stm32f1xx_hal_rcc.h" #endif /* HAL_RCC_MODULE_ENABLED */ #ifdef HAL_GPIO_MODULE_ENABLED #include "stm32f1xx_hal_gpio.h" #endif /* HAL_GPIO_MODULE_ENABLED */ #ifdef HAL_EXTI_MODULE_ENABLED #include "stm32f1xx_hal_exti.h" #endif /* HAL_EXTI_MODULE_ENABLED */ #ifdef HAL_DMA_MODULE_ENABLED #include "stm32f1xx_hal_dma.h" #endif /* HAL_DMA_MODULE_ENABLED */ #ifdef HAL_CAN_MODULE_ENABLED #include "stm32f1xx_hal_can.h" #endif /* HAL_CAN_MODULE_ENABLED */ #ifdef HAL_CAN_LEGACY_MODULE_ENABLED #include "Legacy/stm32f1xx_hal_can_legacy.h" #endif /* HAL_CAN_LEGACY_MODULE_ENABLED */ #ifdef HAL_CORTEX_MODULE_ENABLED #include "stm32f1xx_hal_cortex.h" #endif /* HAL_CORTEX_MODULE_ENABLED */ #ifdef HAL_ADC_MODULE_ENABLED #include "stm32f1xx_hal_adc.h" #endif /* HAL_ADC_MODULE_ENABLED */ #ifdef HAL_CRC_MODULE_ENABLED #include "stm32f1xx_hal_crc.h" #endif /* HAL_CRC_MODULE_ENABLED */ #ifdef HAL_DAC_MODULE_ENABLED #include "stm32f1xx_hal_dac.h" #endif /* HAL_DAC_MODULE_ENABLED */ #ifdef HAL_FLASH_MODULE_ENABLED #include "stm32f1xx_hal_flash.h" #endif /* HAL_FLASH_MODULE_ENABLED */ #ifdef HAL_SRAM_MODULE_ENABLED #include "stm32f1xx_hal_sram.h" #endif /* HAL_SRAM_MODULE_ENABLED */ #ifdef HAL_NOR_MODULE_ENABLED #include "stm32f1xx_hal_nor.h" #endif /* HAL_NOR_MODULE_ENABLED */ #ifdef HAL_I2C_MODULE_ENABLED #include "stm32f1xx_hal_i2c.h" #endif /* HAL_I2C_MODULE_ENABLED */ #ifdef HAL_I2S_MODULE_ENABLED #include "stm32f1xx_hal_i2s.h" #endif /* HAL_I2S_MODULE_ENABLED */ #ifdef HAL_IWDG_MODULE_ENABLED #include "stm32f1xx_hal_iwdg.h" #endif /* HAL_IWDG_MODULE_ENABLED */ #ifdef HAL_PWR_MODULE_ENABLED #include "stm32f1xx_hal_pwr.h" #endif /* HAL_PWR_MODULE_ENABLED */ #ifdef HAL_RTC_MODULE_ENABLED #include "stm32f1xx_hal_rtc.h" #endif /* HAL_RTC_MODULE_ENABLED */ #ifdef HAL_PCCARD_MODULE_ENABLED #include "stm32f1xx_hal_pccard.h" #endif /* HAL_PCCARD_MODULE_ENABLED */ #ifdef HAL_SD_MODULE_ENABLED #include "stm32f1xx_hal_sd.h" #endif /* HAL_SD_MODULE_ENABLED */ #ifdef HAL_SDRAM_MODULE_ENABLED #include "stm32f1xx_hal_sdram.h" #endif /* HAL_SDRAM_MODULE_ENABLED */ #ifdef HAL_SPI_MODULE_ENABLED #include "stm32f1xx_hal_spi.h" #endif /* HAL_SPI_MODULE_ENABLED */ #ifdef HAL_TIM_MODULE_ENABLED #include "stm32f1xx_hal_tim.h" #endif /* HAL_TIM_MODULE_ENABLED */ #ifdef HAL_UART_MODULE_ENABLED #include "stm32f1xx_hal_uart.h" #endif /* HAL_UART_MODULE_ENABLED */ #ifdef HAL_USART_MODULE_ENABLED #include "stm32f1xx_hal_usart.h" #endif /* HAL_USART_MODULE_ENABLED */ #ifdef HAL_IRDA_MODULE_ENABLED #include "stm32f1xx_hal_irda.h" #endif /* HAL_IRDA_MODULE_ENABLED */ #ifdef HAL_SMARTCARD_MODULE_ENABLED #include "stm32f1xx_hal_smartcard.h" #endif /* HAL_SMARTCARD_MODULE_ENABLED */ #ifdef HAL_WWDG_MODULE_ENABLED #include "stm32f1xx_hal_wwdg.h" #endif /* HAL_WWDG_MODULE_ENABLED */ #ifdef HAL_PCD_MODULE_ENABLED #include "stm32f1xx_hal_pcd.h" #endif /* HAL_PCD_MODULE_ENABLED */ #ifdef HAL_MMC_MODULE_ENABLED #include "stm32f1xx_hal_mmc.h" #endif /* HAL_MMC_MODULE_ENABLED */ /* Exported macro ------------------------------------------------------------*/ #ifdef USE_FULL_ASSERT /** * @brief The assert_param macro is used for function's parameters check. * @param expr: If expr is false, it calls assert_failed function * which reports the name of the source file and the source * line number of the call that failed. * If expr is true, it returns no value. * @retval None */ #define assert_param(expr) ((expr) ? (void)0U : assert_failed((uint8_t *)__FILE__, __LINE__)) /* Exported functions ------------------------------------------------------- */ void assert_failed(uint8_t* file, uint32_t line); #else #define assert_param(expr) ((void)0U) #endif /* USE_FULL_ASSERT */ #ifdef __cplusplus } #endif #endif /* __STM32F1xx_HAL_CONF_H */
0
D://workCode//uploadProject\STM32CubeF1\Projects\STM3210E_EVAL\Applications\USB_Device\DFU_Standalone
D://workCode//uploadProject\STM32CubeF1\Projects\STM3210E_EVAL\Applications\USB_Device\DFU_Standalone\Inc\stm32f1xx_it.h
/** ****************************************************************************** * @file USB_Device/DFU_Standalone/Inc/stm32f1xx_it.h * @author MCD Application Team * @brief This file contains the headers of the interrupt handlers. ****************************************************************************** * @attention * * Copyright (c) 2016 STMicroelectronics. * All rights reserved. * * This software is licensed under terms that can be found in the LICENSE file * in the root directory of this software component. * If no LICENSE file comes with this software, it is provided AS-IS. * ****************************************************************************** */ /* Define to prevent recursive inclusion -------------------------------------*/ #ifndef __STM32F1xx_IT_H #define __STM32F1xx_IT_H #ifdef __cplusplus extern "C" { #endif /* Includes ------------------------------------------------------------------*/ #include "main.h" /* Exported types ------------------------------------------------------------*/ /* Exported constants --------------------------------------------------------*/ /* Exported macro ------------------------------------------------------------*/ /* Exported functions ------------------------------------------------------- */ void NMI_Handler(void); void HardFault_Handler(void); void MemManage_Handler(void); void BusFault_Handler(void); void UsageFault_Handler(void); void SVC_Handler(void); void DebugMon_Handler(void); void PendSV_Handler(void); void SysTick_Handler(void); void USB_LP_CAN1_RX0_IRQHandler(void); #ifdef __cplusplus } #endif #endif /* __STM32F1xx_IT_H */
0
D://workCode//uploadProject\STM32CubeF1\Projects\STM3210E_EVAL\Applications\USB_Device\DFU_Standalone
D://workCode//uploadProject\STM32CubeF1\Projects\STM3210E_EVAL\Applications\USB_Device\DFU_Standalone\Inc\usbd_conf.h
/** ****************************************************************************** * @file USB_Device/DFU_Standalone/Inc/usbd_conf.h * @author MCD Application Team * @brief General low level driver configuration ****************************************************************************** * @attention * * Copyright (c) 2015 STMicroelectronics. * All rights reserved. * * This software is licensed under terms that can be found in the LICENSE file * in the root directory of this software component. * If no LICENSE file comes with this software, it is provided AS-IS. * ****************************************************************************** */ /* Define to prevent recursive inclusion -------------------------------------*/ #ifndef __USBD_CONF_H #define __USBD_CONF_H /* Includes ------------------------------------------------------------------*/ #include "stm32f1xx_hal.h" #include <stdio.h> #include <stdlib.h> #include <string.h> /* Exported types ------------------------------------------------------------*/ /* Exported constants --------------------------------------------------------*/ /* Common Config */ /* Maximum number of supported media : Flash */ #define USBD_MAX_NUM_INTERFACES 1 #define USBD_MAX_NUM_CONFIGURATION 1 #define USBD_MAX_STR_DESC_SIZ 0x100 #define USBD_SUPPORT_USER_STRING_DESC 1 #define USBD_SELF_POWERED 1 #define USBD_DEBUG_LEVEL 0 /* DFU Class Config */ #define USBD_DFU_MAX_ITF_NUM 1 #define USBD_DFU_XFER_SIZE 1024 /* Max DFU Packet Size = 1024 bytes */ #define USBD_DFU_APP_DEFAULT_ADD 0x08005000 /* Start user code address: ADDR_FLASH_PAGE_10 */ #define USBD_DFU_APP_END_ADD 0x080FF800 /* Start address of latest flash page: ADDR_FLASH_PAGE_511 */ /* Exported macro ------------------------------------------------------------*/ /* Memory management macros */ /* For footprint reasons and since only one allocation is handled in the DFU class driver, the malloc/free is changed into a static allocation method */ void *USBD_static_malloc(uint32_t size); void USBD_static_free(void *p); #define MAX_STATIC_ALLOC_SIZE 265 /*DFU Class Driver Structure size*/ #define USBD_malloc (uint32_t *)USBD_static_malloc #define USBD_free USBD_static_free #define USBD_memset /* Not used */ #define USBD_memcpy /* Not used */ #define USBD_Delay HAL_Delay /* DEBUG macros */ #if (USBD_DEBUG_LEVEL > 0) #define USBD_UsrLog(...) printf(__VA_ARGS__);\ printf("\n"); #else #define USBD_UsrLog(...) #endif #if (USBD_DEBUG_LEVEL > 1) #define USBD_ErrLog(...) printf("ERROR: ") ;\ printf(__VA_ARGS__);\ printf("\n"); #else #define USBD_ErrLog(...) #endif #if (USBD_DEBUG_LEVEL > 2) #define USBD_DbgLog(...) printf("DEBUG : ") ;\ printf(__VA_ARGS__);\ printf("\n"); #else #define USBD_DbgLog(...) #endif /* Exported functions ------------------------------------------------------- */ #endif /* __USBD_CONF_H */
0
D://workCode//uploadProject\STM32CubeF1\Projects\STM3210E_EVAL\Applications\USB_Device\DFU_Standalone
D://workCode//uploadProject\STM32CubeF1\Projects\STM3210E_EVAL\Applications\USB_Device\DFU_Standalone\Inc\usbd_desc.h
/** ****************************************************************************** * @file USB_Device/DFU_Standalone/Inc/usbd_desc.h * @author MCD Application Team * @brief Header for usbd_desc.c module ****************************************************************************** * @attention * * Copyright (c) 2015 STMicroelectronics. * All rights reserved. * * This software is licensed under terms that can be found in the LICENSE file * in the root directory of this software component. * If no LICENSE file comes with this software, it is provided AS-IS. * ****************************************************************************** */ /* Define to prevent recursive inclusion -------------------------------------*/ #ifndef __USBD_DESC_H #define __USBD_DESC_H /* Includes ------------------------------------------------------------------*/ #include "usbd_def.h" /* Exported types ------------------------------------------------------------*/ /* Exported constants --------------------------------------------------------*/ #define DEVICE_ID1 (0x1FFFF7E8) #define DEVICE_ID2 (0x1FFFF7EC) #define DEVICE_ID3 (0x1FFFF7F0) #define USB_SIZ_STRING_SERIAL 0x1A /* Exported macro ------------------------------------------------------------*/ /* Exported functions ------------------------------------------------------- */ extern USBD_DescriptorsTypeDef DFU_Desc; #endif /* __USBD_DESC_H */
0
D://workCode//uploadProject\STM32CubeF1\Projects\STM3210E_EVAL\Applications\USB_Device\DFU_Standalone
D://workCode//uploadProject\STM32CubeF1\Projects\STM3210E_EVAL\Applications\USB_Device\DFU_Standalone\Inc\usbd_dfu_flash.h
/** ****************************************************************************** * @file USB_Device/DFU_Standalone/Inc/usbd_dfu_flash.h * @author MCD Application Team * @brief Header for usbd_dfu_flash.c file. ****************************************************************************** * @attention * * Copyright (c) 2015 STMicroelectronics. * All rights reserved. * * This software is licensed under terms that can be found in the LICENSE file * in the root directory of this software component. * If no LICENSE file comes with this software, it is provided AS-IS. * ****************************************************************************** */ /* Define to prevent recursive inclusion -------------------------------------*/ #ifndef __USBD_DFU_FLASH_H_ #define __USBD_DFU_FLASH_H_ /* Includes ------------------------------------------------------------------*/ #include "usbd_dfu.h" /* Exported types ------------------------------------------------------------*/ /* Exported constants --------------------------------------------------------*/ /* Exported macro ------------------------------------------------------------*/ extern USBD_DFU_MediaTypeDef USBD_DFU_Flash_fops; /* Exported functions ------------------------------------------------------- */ #endif /* __USBD_DFU_FLASH_H_ */
0
D://workCode//uploadProject\STM32CubeF1\Projects\STM3210E_EVAL\Applications\USB_Device\DFU_Standalone
D://workCode//uploadProject\STM32CubeF1\Projects\STM3210E_EVAL\Applications\USB_Device\DFU_Standalone\Src\main.c
/** ****************************************************************************** * @file USB_Device/DFU_Standalone/Src/main.c * @author MCD Application Team * @brief USB device DFU application main file. ****************************************************************************** * @attention * * Copyright (c) 2016 STMicroelectronics. * All rights reserved. * * This software is licensed under terms that can be found in the LICENSE file * in the root directory of this software component. * If no LICENSE file comes with this software, it is provided AS-IS. * ****************************************************************************** */ /* Includes ------------------------------------------------------------------ */ #include "main.h" /** @addtogroup STM32F1xx_HAL_Validation * @{ */ /** @addtogroup STANDARD_CHECK * @{ */ /* Private typedef ----------------------------------------------------------- */ /* Private define ------------------------------------------------------------ */ /* Private macro ------------------------------------------------------------- */ /* Private variables --------------------------------------------------------- */ USBD_HandleTypeDef USBD_Device; /* Private function prototypes ----------------------------------------------- */ void SystemClock_Config(void); static void Error_Handler(void); /* Private functions --------------------------------------------------------- */ /** * @brief Main program. * @param None * @retval None */ int main(void) { pFunction JumpToApplication; uint32_t JumpAddress; /* Reset of all peripherals, Initializes the Flash interface and the Systick */ HAL_Init(); /* Configure the system clock to 72 MHz */ SystemClock_Config(); /* Configure Key push-button */ BSP_PB_Init(BUTTON_KEY, BUTTON_MODE_GPIO); /* Check if the Key push-button is pressed */ if (BSP_PB_GetState(BUTTON_KEY) != GPIO_PIN_RESET) { /* Test if user code is programmed starting from address 0x08007000 */ if (((*(__IO uint32_t *) USBD_DFU_APP_DEFAULT_ADD) & 0x2FFE0000) == 0x20000000) { /* Jump to user application */ JumpAddress = *(__IO uint32_t *) (USBD_DFU_APP_DEFAULT_ADD + 4); JumpToApplication = (pFunction) JumpAddress; /* Initialize user application's Stack Pointer */ __set_MSP(*(__IO uint32_t *) USBD_DFU_APP_DEFAULT_ADD); JumpToApplication(); } } /* Otherwise enters DFU mode to allow user to program his application */ /* Init Device Library */ USBD_Init(&USBD_Device, &DFU_Desc, 0); /* Register the DFU class */ USBD_RegisterClass(&USBD_Device, &USBD_DFU); /* Add DFU Media interface */ USBD_DFU_RegisterMedia(&USBD_Device, &USBD_DFU_Flash_fops); /* Start Device Process */ USBD_Start(&USBD_Device); /* In an infinite loop */ while (1) { } } /** * @brief System Clock Configuration * The system Clock is configured as follow : * System Clock source = PLL (HSE) * SYSCLK(Hz) = 72000000 * HCLK(Hz) = 72000000 * AHB Prescaler = 1 * APB1 Prescaler = 2 * APB2 Prescaler = 1 * HSE Frequency(Hz) = 8000000 * HSE PREDIV1 = 1 * PLLMUL = 9 * Flash Latency(WS) = 2 * @param None * @retval None */ void SystemClock_Config(void) { RCC_ClkInitTypeDef clkinitstruct = { 0 }; RCC_OscInitTypeDef oscinitstruct = { 0 }; RCC_PeriphCLKInitTypeDef rccperiphclkinit = { 0 }; /* Enable HSE Oscillator and activate PLL with HSE as source */ oscinitstruct.OscillatorType = RCC_OSCILLATORTYPE_HSE; oscinitstruct.HSEState = RCC_HSE_ON; oscinitstruct.HSEPredivValue = RCC_HSE_PREDIV_DIV1; oscinitstruct.PLL.PLLMUL = RCC_PLL_MUL9; oscinitstruct.PLL.PLLState = RCC_PLL_ON; oscinitstruct.PLL.PLLSource = RCC_PLLSOURCE_HSE; if (HAL_RCC_OscConfig(&oscinitstruct) != HAL_OK) { /* Start Conversation Error */ Error_Handler(); } /* USB clock selection */ rccperiphclkinit.PeriphClockSelection = RCC_PERIPHCLK_USB; rccperiphclkinit.UsbClockSelection = RCC_USBCLKSOURCE_PLL_DIV1_5; HAL_RCCEx_PeriphCLKConfig(&rccperiphclkinit); /* Select PLL as system clock source and configure the HCLK, PCLK1 and PCLK2 * clocks dividers */ clkinitstruct.ClockType = RCC_CLOCKTYPE_SYSCLK | RCC_CLOCKTYPE_HCLK | RCC_CLOCKTYPE_PCLK1 | RCC_CLOCKTYPE_PCLK2; clkinitstruct.SYSCLKSource = RCC_SYSCLKSOURCE_PLLCLK; clkinitstruct.AHBCLKDivider = RCC_SYSCLK_DIV1; clkinitstruct.APB1CLKDivider = RCC_HCLK_DIV2; clkinitstruct.APB2CLKDivider = RCC_HCLK_DIV1; if (HAL_RCC_ClockConfig(&clkinitstruct, FLASH_LATENCY_2) != HAL_OK) { /* Start Conversation Error */ Error_Handler(); } } /** * @brief This function is executed in case of error occurrence. * @param None * @retval None */ static void Error_Handler(void) { /* Turn LED3 on */ BSP_LED_On(LED3); while (1) { } } #ifdef USE_FULL_ASSERT /** * @brief Reports the name of the source file and the source line number * where the assert_param error has occurred. * @param file: pointer to the source file name * @param line: assert_param error line source number * @retval None */ void assert_failed(uint8_t * file, uint32_t line) { /* User can add his own implementation to report the file name and line * number, ex: printf("Wrong parameters value: file %s on line %d\r\n", file, * line) */ /* Infinite loop */ while (1) { } } #endif /** * @} */ /** * @} */
0
D://workCode//uploadProject\STM32CubeF1\Projects\STM3210E_EVAL\Applications\USB_Device\DFU_Standalone
D://workCode//uploadProject\STM32CubeF1\Projects\STM3210E_EVAL\Applications\USB_Device\DFU_Standalone\Src\stm32f1xx_it.c
/** ****************************************************************************** * @file USB_Device/DFU_Standalone/Src/stm32f1xx_it.c * @author MCD Application Team * @brief Main Interrupt Service Routines. * This file provides template for all exceptions handler and * peripherals interrupt service routine. ****************************************************************************** * @attention * * Copyright (c) 2016 STMicroelectronics. * All rights reserved. * * This software is licensed under terms that can be found in the LICENSE file * in the root directory of this software component. * If no LICENSE file comes with this software, it is provided AS-IS. * ****************************************************************************** */ /* Includes ------------------------------------------------------------------ */ #include "stm32f1xx_it.h" /** @addtogroup Validation_Project * @{ */ /* Private typedef ----------------------------------------------------------- */ /* Private define ------------------------------------------------------------ */ /* Private macro ------------------------------------------------------------- */ /* Private variables --------------------------------------------------------- */ extern PCD_HandleTypeDef hpcd; /* Private function prototypes ----------------------------------------------- */ /* Private functions --------------------------------------------------------- */ /******************************************************************************/ /* Cortex-M3 Processor Exceptions Handlers */ /******************************************************************************/ /** * @brief This function handles NMI exception. * @param None * @retval None */ void NMI_Handler(void) { } /** * @brief This function handles Hard Fault exception. * @param None * @retval None */ void HardFault_Handler(void) { /* Go to infinite loop when Hard Fault exception occurs */ while (1) { } } /** * @brief This function handles Memory Manage exception. * @param None * @retval None */ void MemManage_Handler(void) { /* Go to infinite loop when Memory Manage exception occurs */ while (1) { } } /** * @brief This function handles Bus Fault exception. * @param None * @retval None */ void BusFault_Handler(void) { /* Go to infinite loop when Bus Fault exception occurs */ while (1) { } } /** * @brief This function handles Usage Fault exception. * @param None * @retval None */ void UsageFault_Handler(void) { /* Go to infinite loop when Usage Fault exception occurs */ while (1) { } } /** * @brief This function handles SVCall exception. * @param None * @retval None */ void SVC_Handler(void) { } /** * @brief This function handles Debug Monitor exception. * @param None * @retval None */ void DebugMon_Handler(void) { } /** * @brief This function handles PendSVC exception. * @param None * @retval None */ void PendSV_Handler(void) { } /** * @brief This function handles SysTick Handler. * @param None * @retval None */ void SysTick_Handler(void) { HAL_IncTick(); } /******************************************************************************/ /* STM32F1xx Peripherals Interrupt Handlers */ /* Add here the Interrupt Handler for the used peripheral(s) (PPP), for the */ /* available peripheral interrupt handler's name please refer to the startup */ /* file (startup_stm32f1xx.s). */ /******************************************************************************/ /** * @brief This function handles USB Handler. * @param None * @retval None */ void USB_LP_CAN1_RX0_IRQHandler(void) { HAL_PCD_IRQHandler(&hpcd); } /** * @} */
0
D://workCode//uploadProject\STM32CubeF1\Projects\STM3210E_EVAL\Applications\USB_Device\DFU_Standalone
D://workCode//uploadProject\STM32CubeF1\Projects\STM3210E_EVAL\Applications\USB_Device\DFU_Standalone\Src\system_stm32f1xx.c
/** ****************************************************************************** * @file system_stm32f1xx.c * @author MCD Application Team * @brief CMSIS Cortex-M3 Device Peripheral Access Layer System Source File. * * 1. This file provides two functions and one global variable to be called from * user application: * - SystemInit(): Setups the system clock (System clock source, PLL Multiplier * factors, AHB/APBx prescalers and Flash settings). * This function is called at startup just after reset and * before branch to main program. This call is made inside * the "startup_stm32f1xx_xx.s" file. * * - SystemCoreClock variable: Contains the core clock (HCLK), it can be used * by the user application to setup the SysTick * timer or configure other parameters. * * - SystemCoreClockUpdate(): Updates the variable SystemCoreClock and must * be called whenever the core clock is changed * during program execution. * * 2. After each device reset the HSI (8 MHz) is used as system clock source. * Then SystemInit() function is called, in "startup_stm32f1xx_xx.s" file, to * configure the system clock before to branch to main program. * * 4. The default value of HSE crystal is set to 8 MHz (or 25 MHz, depending on * the product used), refer to "HSE_VALUE". * When HSE is used as system clock source, directly or through PLL, and you * are using different crystal you have to adapt the HSE value to your own * configuration. * ****************************************************************************** * @attention * * Copyright (c) 2016 STMicroelectronics. * All rights reserved. * * This software is licensed under terms that can be found in the LICENSE file * in the root directory of this software component. * If no LICENSE file comes with this software, it is provided AS-IS. * ****************************************************************************** */ /** @addtogroup CMSIS * @{ */ /** @addtogroup stm32f1xx_system * @{ */ /** @addtogroup STM32F1xx_System_Private_Includes * @{ */ #include "stm32f1xx.h" /** * @} */ /** @addtogroup STM32F1xx_System_Private_TypesDefinitions * @{ */ /** * @} */ /** @addtogroup STM32F1xx_System_Private_Defines * @{ */ #if !defined (HSE_VALUE) #define HSE_VALUE ((uint32_t)8000000) /*!< Default value of the External oscillator in Hz. This value can be provided and adapted by the user application. */ #endif /* HSE_VALUE */ #if !defined (HSI_VALUE) #define HSI_VALUE ((uint32_t)8000000) /*!< Default value of the Internal oscillator in Hz. This value can be provided and adapted by the user application. */ #endif /* HSI_VALUE */ /*!< Uncomment the following line if you need to use external SRAM */ #if defined(STM32F100xE) || defined(STM32F101xE) || defined(STM32F101xG) || defined(STM32F103xE) || defined(STM32F103xG) /* #define DATA_IN_ExtSRAM */ #endif /* STM32F100xE || STM32F101xE || STM32F101xG || STM32F103xE || STM32F103xG */ /*!< Uncomment the following line if you need to relocate your vector Table in Internal SRAM. */ /* #define VECT_TAB_SRAM */ #define VECT_TAB_OFFSET 0x0 /*!< Vector Table base offset field. This value must be a multiple of 0x200. */ /** * @} */ /** @addtogroup STM32F1xx_System_Private_Macros * @{ */ /** * @} */ /** @addtogroup STM32F1xx_System_Private_Variables * @{ */ /* This variable is updated in three ways: 1) by calling CMSIS function SystemCoreClockUpdate() 2) by calling HAL API function HAL_RCC_GetHCLKFreq() 3) each time HAL_RCC_ClockConfig() is called to configure the system clock frequency Note: If you use this function to configure the system clock; then there is no need to call the 2 first functions listed above, since SystemCoreClock variable is updated automatically. */ uint32_t SystemCoreClock = 16000000; const uint8_t AHBPrescTable[16] = {0, 0, 0, 0, 0, 0, 0, 0, 1, 2, 3, 4, 6, 7, 8, 9}; const uint8_t APBPrescTable[8] = {0, 0, 0, 0, 1, 2, 3, 4}; /** * @} */ /** @addtogroup STM32F1xx_System_Private_FunctionPrototypes * @{ */ #if defined(STM32F100xE) || defined(STM32F101xE) || defined(STM32F101xG) || defined(STM32F103xE) || defined(STM32F103xG) #ifdef DATA_IN_ExtSRAM static void SystemInit_ExtMemCtl(void); #endif /* DATA_IN_ExtSRAM */ #endif /* STM32F100xE || STM32F101xE || STM32F101xG || STM32F103xE || STM32F103xG */ /** * @} */ /** @addtogroup STM32F1xx_System_Private_Functions * @{ */ /** * @brief Setup the microcontroller system * Initialize the Embedded Flash Interface, the PLL and update the * SystemCoreClock variable. * @note This function should be used only after reset. * @param None * @retval None */ void SystemInit (void) { /* Reset the RCC clock configuration to the default reset state(for debug purpose) */ /* Set HSION bit */ RCC->CR |= (uint32_t)0x00000001; /* Reset SW, HPRE, PPRE1, PPRE2, ADCPRE and MCO bits */ #if !defined(STM32F105xC) && !defined(STM32F107xC) RCC->CFGR &= (uint32_t)0xF8FF0000; #else RCC->CFGR &= (uint32_t)0xF0FF0000; #endif /* STM32F105xC */ /* Reset HSEON, CSSON and PLLON bits */ RCC->CR &= (uint32_t)0xFEF6FFFF; /* Reset HSEBYP bit */ RCC->CR &= (uint32_t)0xFFFBFFFF; /* Reset PLLSRC, PLLXTPRE, PLLMUL and USBPRE/OTGFSPRE bits */ RCC->CFGR &= (uint32_t)0xFF80FFFF; #if defined(STM32F105xC) || defined(STM32F107xC) /* Reset PLL2ON and PLL3ON bits */ RCC->CR &= (uint32_t)0xEBFFFFFF; /* Disable all interrupts and clear pending bits */ RCC->CIR = 0x00FF0000; /* Reset CFGR2 register */ RCC->CFGR2 = 0x00000000; #elif defined(STM32F100xB) || defined(STM32F100xE) /* Disable all interrupts and clear pending bits */ RCC->CIR = 0x009F0000; /* Reset CFGR2 register */ RCC->CFGR2 = 0x00000000; #else /* Disable all interrupts and clear pending bits */ RCC->CIR = 0x009F0000; #endif /* STM32F105xC */ #if defined(STM32F100xE) || defined(STM32F101xE) || defined(STM32F101xG) || defined(STM32F103xE) || defined(STM32F103xG) #ifdef DATA_IN_ExtSRAM SystemInit_ExtMemCtl(); #endif /* DATA_IN_ExtSRAM */ #endif #ifdef VECT_TAB_SRAM SCB->VTOR = SRAM_BASE | VECT_TAB_OFFSET; /* Vector Table Relocation in Internal SRAM. */ #else SCB->VTOR = FLASH_BASE | VECT_TAB_OFFSET; /* Vector Table Relocation in Internal FLASH. */ #endif } /** * @brief Update SystemCoreClock variable according to Clock Register Values. * The SystemCoreClock variable contains the core clock (HCLK), it can * be used by the user application to setup the SysTick timer or configure * other parameters. * * @note Each time the core clock (HCLK) changes, this function must be called * to update SystemCoreClock variable value. Otherwise, any configuration * based on this variable will be incorrect. * * @note - The system frequency computed by this function is not the real * frequency in the chip. It is calculated based on the predefined * constant and the selected clock source: * * - If SYSCLK source is HSI, SystemCoreClock will contain the HSI_VALUE(*) * * - If SYSCLK source is HSE, SystemCoreClock will contain the HSE_VALUE(**) * * - If SYSCLK source is PLL, SystemCoreClock will contain the HSE_VALUE(**) * or HSI_VALUE(*) multiplied by the PLL factors. * * (*) HSI_VALUE is a constant defined in stm32f1xx.h file (default value * 8 MHz) but the real value may vary depending on the variations * in voltage and temperature. * * (**) HSE_VALUE is a constant defined in stm32f1xx.h file (default value * 8 MHz or 25 MHz, depending on the product used), user has to ensure * that HSE_VALUE is same as the real frequency of the crystal used. * Otherwise, this function may have wrong result. * * - The result of this function could be not correct when using fractional * value for HSE crystal. * @param None * @retval None */ void SystemCoreClockUpdate (void) { uint32_t tmp = 0, pllmull = 0, pllsource = 0; #if defined(STM32F105xC) || defined(STM32F107xC) uint32_t prediv1source = 0, prediv1factor = 0, prediv2factor = 0, pll2mull = 0; #endif /* STM32F105xC */ #if defined(STM32F100xB) || defined(STM32F100xE) uint32_t prediv1factor = 0; #endif /* STM32F100xB or STM32F100xE */ /* Get SYSCLK source -------------------------------------------------------*/ tmp = RCC->CFGR & RCC_CFGR_SWS; switch (tmp) { case 0x00: /* HSI used as system clock */ SystemCoreClock = HSI_VALUE; break; case 0x04: /* HSE used as system clock */ SystemCoreClock = HSE_VALUE; break; case 0x08: /* PLL used as system clock */ /* Get PLL clock source and multiplication factor ----------------------*/ pllmull = RCC->CFGR & RCC_CFGR_PLLMULL; pllsource = RCC->CFGR & RCC_CFGR_PLLSRC; #if !defined(STM32F105xC) && !defined(STM32F107xC) pllmull = ( pllmull >> 18) + 2; if (pllsource == 0x00) { /* HSI oscillator clock divided by 2 selected as PLL clock entry */ SystemCoreClock = (HSI_VALUE >> 1) * pllmull; } else { #if defined(STM32F100xB) || defined(STM32F100xE) prediv1factor = (RCC->CFGR2 & RCC_CFGR2_PREDIV1) + 1; /* HSE oscillator clock selected as PREDIV1 clock entry */ SystemCoreClock = (HSE_VALUE / prediv1factor) * pllmull; #else /* HSE selected as PLL clock entry */ if ((RCC->CFGR & RCC_CFGR_PLLXTPRE) != (uint32_t)RESET) {/* HSE oscillator clock divided by 2 */ SystemCoreClock = (HSE_VALUE >> 1) * pllmull; } else { SystemCoreClock = HSE_VALUE * pllmull; } #endif } #else pllmull = pllmull >> 18; if (pllmull != 0x0D) { pllmull += 2; } else { /* PLL multiplication factor = PLL input clock * 6.5 */ pllmull = 13 / 2; } if (pllsource == 0x00) { /* HSI oscillator clock divided by 2 selected as PLL clock entry */ SystemCoreClock = (HSI_VALUE >> 1) * pllmull; } else {/* PREDIV1 selected as PLL clock entry */ /* Get PREDIV1 clock source and division factor */ prediv1source = RCC->CFGR2 & RCC_CFGR2_PREDIV1SRC; prediv1factor = (RCC->CFGR2 & RCC_CFGR2_PREDIV1) + 1; if (prediv1source == 0) { /* HSE oscillator clock selected as PREDIV1 clock entry */ SystemCoreClock = (HSE_VALUE / prediv1factor) * pllmull; } else {/* PLL2 clock selected as PREDIV1 clock entry */ /* Get PREDIV2 division factor and PLL2 multiplication factor */ prediv2factor = ((RCC->CFGR2 & RCC_CFGR2_PREDIV2) >> 4) + 1; pll2mull = ((RCC->CFGR2 & RCC_CFGR2_PLL2MUL) >> 8 ) + 2; SystemCoreClock = (((HSE_VALUE / prediv2factor) * pll2mull) / prediv1factor) * pllmull; } } #endif /* STM32F105xC */ break; default: SystemCoreClock = HSI_VALUE; break; } /* Compute HCLK clock frequency ----------------*/ /* Get HCLK prescaler */ tmp = AHBPrescTable[((RCC->CFGR & RCC_CFGR_HPRE) >> 4)]; /* HCLK clock frequency */ SystemCoreClock >>= tmp; } #if defined(STM32F100xE) || defined(STM32F101xE) || defined(STM32F101xG) || defined(STM32F103xE) || defined(STM32F103xG) /** * @brief Setup the external memory controller. Called in startup_stm32f1xx.s * before jump to __main * @param None * @retval None */ #ifdef DATA_IN_ExtSRAM /** * @brief Setup the external memory controller. * Called in startup_stm32f1xx_xx.s/.c before jump to main. * This function configures the external SRAM mounted on STM3210E-EVAL * board (STM32 High density devices). This SRAM will be used as program * data memory (including heap and stack). * @param None * @retval None */ void SystemInit_ExtMemCtl(void) { /*!< FSMC Bank1 NOR/SRAM3 is used for the STM3210E-EVAL, if another Bank is required, then adjust the Register Addresses */ /* Enable FSMC clock */ RCC->AHBENR = 0x00000114; /* Enable GPIOD, GPIOE, GPIOF and GPIOG clocks */ RCC->APB2ENR = 0x000001E0; /* --------------- SRAM Data lines, NOE and NWE configuration ---------------*/ /*---------------- SRAM Address lines configuration -------------------------*/ /*---------------- NOE and NWE configuration --------------------------------*/ /*---------------- NE3 configuration ----------------------------------------*/ /*---------------- NBL0, NBL1 configuration ---------------------------------*/ GPIOD->CRL = 0x44BB44BB; GPIOD->CRH = 0xBBBBBBBB; GPIOE->CRL = 0xB44444BB; GPIOE->CRH = 0xBBBBBBBB; GPIOF->CRL = 0x44BBBBBB; GPIOF->CRH = 0xBBBB4444; GPIOG->CRL = 0x44BBBBBB; GPIOG->CRH = 0x44444B44; /*---------------- FSMC Configuration ---------------------------------------*/ /*---------------- Enable FSMC Bank1_SRAM Bank ------------------------------*/ FSMC_Bank1->BTCR[4] = 0x00001011; FSMC_Bank1->BTCR[5] = 0x00000200; } #endif /* DATA_IN_ExtSRAM */ #endif /* STM32F100xE || STM32F101xE || STM32F101xG || STM32F103xE || STM32F103xG */ /** * @} */ /** * @} */ /** * @} */
0
D://workCode//uploadProject\STM32CubeF1\Projects\STM3210E_EVAL\Applications\USB_Device\DFU_Standalone
D://workCode//uploadProject\STM32CubeF1\Projects\STM3210E_EVAL\Applications\USB_Device\DFU_Standalone\Src\usbd_conf.c
/** ****************************************************************************** * @file USB_Device/DFU_Standalone/Src/usbd_conf.c * @author MCD Application Team * @brief This file implements the USB Device library callbacks and MSP ****************************************************************************** * @attention * * Copyright (c) 2015 STMicroelectronics. * All rights reserved. * * This software is licensed under terms that can be found in the LICENSE file * in the root directory of this software component. * If no LICENSE file comes with this software, it is provided AS-IS. * ****************************************************************************** */ /* Includes ------------------------------------------------------------------ */ #include "main.h" /* Private typedef ----------------------------------------------------------- */ /* Private define ------------------------------------------------------------ */ #define USB_DISCONNECT_PORT GPIOB #define USB_DISCONNECT_PIN GPIO_PIN_14 /* Private macro ------------------------------------------------------------- */ /* Private variables --------------------------------------------------------- */ PCD_HandleTypeDef hpcd; /* Private function prototypes ----------------------------------------------- */ /* Private functions --------------------------------------------------------- */ /******************************************************************************* PCD BSP Routines *******************************************************************************/ /** * @brief Initializes the PCD MSP. * @param hpcd: PCD handle * @retval None */ void HAL_PCD_MspInit(PCD_HandleTypeDef * hpcd) { GPIO_InitTypeDef GPIO_InitStruct; /* Enable the GPIOA clock */ __HAL_RCC_GPIOA_CLK_ENABLE(); /* Configure USB DM/DP pins */ GPIO_InitStruct.Pin = (GPIO_PIN_11 | GPIO_PIN_12); GPIO_InitStruct.Mode = GPIO_MODE_AF_INPUT; GPIO_InitStruct.Pull = GPIO_PULLUP; GPIO_InitStruct.Speed = GPIO_SPEED_FREQ_HIGH; HAL_GPIO_Init(GPIOA, &GPIO_InitStruct); /* Enable the USB disconnect GPIO clock */ __HAL_RCC_GPIOB_CLK_ENABLE(); /* USB_DISCONNECT used as USB pull-up */ GPIO_InitStruct.Pin = USB_DISCONNECT_PIN; GPIO_InitStruct.Mode = GPIO_MODE_OUTPUT_OD; HAL_GPIO_Init(USB_DISCONNECT_PORT, &GPIO_InitStruct); /* Enable USB Clock */ __HAL_RCC_USB_CLK_ENABLE(); /* Set USB Interrupt priority */ HAL_NVIC_SetPriority(USB_LP_CAN1_RX0_IRQn, 5, 0); /* Enable USB Interrupt */ HAL_NVIC_EnableIRQ(USB_LP_CAN1_RX0_IRQn); } /** * @brief De-Initializes the PCD MSP. * @param hpcd: PCD handle * @retval None */ void HAL_PCD_MspDeInit(PCD_HandleTypeDef * hpcd) { /* Disable USB FS Clock */ __HAL_RCC_USB_CLK_DISABLE(); } /******************************************************************************* LL Driver Callbacks (PCD -> USB Device Library) *******************************************************************************/ /** * @brief SetupStage callback. * @param hpcd: PCD handle * @retval None */ void HAL_PCD_SetupStageCallback(PCD_HandleTypeDef * hpcd) { USBD_LL_SetupStage((USBD_HandleTypeDef *) hpcd->pData, (uint8_t *) hpcd->Setup); } /** * @brief DataOut Stage callback. * @param hpcd: PCD handle * @param epnum: Endpoint Number * @retval None */ void HAL_PCD_DataOutStageCallback(PCD_HandleTypeDef * hpcd, uint8_t epnum) { USBD_LL_DataOutStage((USBD_HandleTypeDef *) hpcd->pData, epnum, hpcd->OUT_ep[epnum].xfer_buff); } /** * @brief DataIn Stage callback. * @param hpcd: PCD handle * @param epnum: Endpoint Number * @retval None */ void HAL_PCD_DataInStageCallback(PCD_HandleTypeDef * hpcd, uint8_t epnum) { USBD_LL_DataInStage((USBD_HandleTypeDef *) hpcd->pData, epnum, hpcd->IN_ep[epnum].xfer_buff); } /** * @brief SOF callback. * @param hpcd: PCD handle * @retval None */ void HAL_PCD_SOFCallback(PCD_HandleTypeDef * hpcd) { USBD_LL_SOF((USBD_HandleTypeDef *) hpcd->pData); } /** * @brief Reset callback. * @param hpcd: PCD handle * @retval None */ void HAL_PCD_ResetCallback(PCD_HandleTypeDef * hpcd) { USBD_LL_SetSpeed((USBD_HandleTypeDef *) hpcd->pData, USBD_SPEED_FULL); /* Reset Device */ USBD_LL_Reset((USBD_HandleTypeDef *) hpcd->pData); } /** * @brief Suspend callback. * @param hpcd: PCD handle * @retval None */ void HAL_PCD_SuspendCallback(PCD_HandleTypeDef * hpcd) { /* Inform USB library that core enters in suspend Mode */ USBD_LL_Suspend((USBD_HandleTypeDef *) hpcd->pData); } /** * @brief Resume callback. * @param hpcd: PCD handle * @retval None */ void HAL_PCD_ResumeCallback(PCD_HandleTypeDef * hpcd) { USBD_LL_Resume((USBD_HandleTypeDef *) hpcd->pData); } /** * @brief ISOOUTIncomplete callback. * @param hpcd: PCD handle * @param epnum: Endpoint Number * @retval None */ void HAL_PCD_ISOOUTIncompleteCallback(PCD_HandleTypeDef * hpcd, uint8_t epnum) { USBD_LL_IsoOUTIncomplete((USBD_HandleTypeDef *) hpcd->pData, epnum); } /** * @brief ISOINIncomplete callback. * @param hpcd: PCD handle * @param epnum: Endpoint Number * @retval None */ void HAL_PCD_ISOINIncompleteCallback(PCD_HandleTypeDef * hpcd, uint8_t epnum) { USBD_LL_IsoINIncomplete((USBD_HandleTypeDef *) hpcd->pData, epnum); } /** * @brief ConnectCallback callback. * @param hpcd: PCD handle * @retval None */ void HAL_PCD_ConnectCallback(PCD_HandleTypeDef * hpcd) { USBD_LL_DevConnected((USBD_HandleTypeDef *) hpcd->pData); } /** * @brief Disconnect callback. * @param hpcd: PCD handle * @retval None */ void HAL_PCD_DisconnectCallback(PCD_HandleTypeDef * hpcd) { USBD_LL_DevDisconnected((USBD_HandleTypeDef *) hpcd->pData); } /******************************************************************************* LL Driver Interface (USB Device Library --> PCD) *******************************************************************************/ /** * @brief Initializes the Low Level portion of the Device driver. * @param pdev: Device handle * @retval USBD Status */ USBD_StatusTypeDef USBD_LL_Init(USBD_HandleTypeDef * pdev) { /* Set LL Driver parameters */ hpcd.Instance = USB; hpcd.Init.dev_endpoints = 8; hpcd.Init.phy_itface = PCD_PHY_EMBEDDED; hpcd.Init.speed = PCD_SPEED_FULL; hpcd.Init.low_power_enable = 0; /* Link The driver to the stack */ hpcd.pData = pdev; pdev->pData = &hpcd; /* Initialize LL Driver */ HAL_PCD_Init((PCD_HandleTypeDef *) pdev->pData); HAL_PCDEx_PMAConfig(pdev->pData, 0x00, PCD_SNG_BUF, 0x18); HAL_PCDEx_PMAConfig(pdev->pData, 0x80, PCD_SNG_BUF, 0x58); return USBD_OK; } /** * @brief De-Initializes the Low Level portion of the Device driver. * @param pdev: Device handle * @retval USBD Status */ USBD_StatusTypeDef USBD_LL_DeInit(USBD_HandleTypeDef * pdev) { HAL_PCD_DeInit((PCD_HandleTypeDef *) pdev->pData); return USBD_OK; } /** * @brief Starts the Low Level portion of the Device driver. * @param pdev: Device handle * @retval USBD Status */ USBD_StatusTypeDef USBD_LL_Start(USBD_HandleTypeDef * pdev) { HAL_PCD_Start((PCD_HandleTypeDef *) pdev->pData); return USBD_OK; } /** * @brief Stops the Low Level portion of the Device driver. * @param pdev: Device handle * @retval USBD Status */ USBD_StatusTypeDef USBD_LL_Stop(USBD_HandleTypeDef * pdev) { HAL_PCD_Stop((PCD_HandleTypeDef *) pdev->pData); return USBD_OK; } /** * @brief Opens an endpoint of the Low Level Driver. * @param pdev: Device handle * @param ep_addr: Endpoint Number * @param ep_type: Endpoint Type * @param ep_mps: Endpoint Max Packet Size * @retval USBD Status */ USBD_StatusTypeDef USBD_LL_OpenEP(USBD_HandleTypeDef * pdev, uint8_t ep_addr, uint8_t ep_type, uint16_t ep_mps) { HAL_PCD_EP_Open((PCD_HandleTypeDef *) pdev->pData, ep_addr, ep_mps, ep_type); return USBD_OK; } /** * @brief Closes an endpoint of the Low Level Driver. * @param pdev: Device handle * @param ep_addr: Endpoint Number * @retval USBD Status */ USBD_StatusTypeDef USBD_LL_CloseEP(USBD_HandleTypeDef * pdev, uint8_t ep_addr) { HAL_PCD_EP_Close((PCD_HandleTypeDef *) pdev->pData, ep_addr); return USBD_OK; } /** * @brief Flushes an endpoint of the Low Level Driver. * @param pdev: Device handle * @param ep_addr: Endpoint Number * @retval USBD Status */ USBD_StatusTypeDef USBD_LL_FlushEP(USBD_HandleTypeDef * pdev, uint8_t ep_addr) { HAL_PCD_EP_Flush((PCD_HandleTypeDef *) pdev->pData, ep_addr); return USBD_OK; } /** * @brief Sets a Stall condition on an endpoint of the Low Level Driver. * @param pdev: Device handle * @param ep_addr: Endpoint Number * @retval USBD Status */ USBD_StatusTypeDef USBD_LL_StallEP(USBD_HandleTypeDef * pdev, uint8_t ep_addr) { HAL_PCD_EP_SetStall((PCD_HandleTypeDef *) pdev->pData, ep_addr); return USBD_OK; } /** * @brief Clears a Stall condition on an endpoint of the Low Level Driver. * @param pdev: Device handle * @param ep_addr: Endpoint Number * @retval USBD Status */ USBD_StatusTypeDef USBD_LL_ClearStallEP(USBD_HandleTypeDef * pdev, uint8_t ep_addr) { HAL_PCD_EP_ClrStall((PCD_HandleTypeDef *) pdev->pData, ep_addr); return USBD_OK; } /** * @brief Returns Stall condition. * @param pdev: Device handle * @param ep_addr: Endpoint Number * @retval Stall (1: Yes, 0: No) */ uint8_t USBD_LL_IsStallEP(USBD_HandleTypeDef * pdev, uint8_t ep_addr) { PCD_HandleTypeDef *hpcd = (PCD_HandleTypeDef *) pdev->pData; if ((ep_addr & 0x80) == 0x80) { return hpcd->IN_ep[ep_addr & 0x7F].is_stall; } else { return hpcd->OUT_ep[ep_addr & 0x7F].is_stall; } } /** * @brief Assigns a USB address to the device. * @param pdev: Device handle * @param ep_addr: Endpoint Number * @retval USBD Status */ USBD_StatusTypeDef USBD_LL_SetUSBAddress(USBD_HandleTypeDef * pdev, uint8_t dev_addr) { HAL_PCD_SetAddress((PCD_HandleTypeDef *) pdev->pData, dev_addr); return USBD_OK; } /** * @brief Transmits data over an endpoint. * @param pdev: Device handle * @param ep_addr: Endpoint Number * @param pbuf: Pointer to data to be sent * @param size: Data size * @retval USBD Status */ USBD_StatusTypeDef USBD_LL_Transmit(USBD_HandleTypeDef * pdev, uint8_t ep_addr, uint8_t * pbuf, uint16_t size) { HAL_PCD_EP_Transmit((PCD_HandleTypeDef *) pdev->pData, ep_addr, pbuf, size); return USBD_OK; } /** * @brief Prepares an endpoint for reception. * @param pdev: Device handle * @param ep_addr: Endpoint Number * @param pbuf: Pointer to data to be received * @param size: Data size * @retval USBD Status */ USBD_StatusTypeDef USBD_LL_PrepareReceive(USBD_HandleTypeDef * pdev, uint8_t ep_addr, uint8_t * pbuf, uint16_t size) { HAL_PCD_EP_Receive((PCD_HandleTypeDef *) pdev->pData, ep_addr, pbuf, size); return USBD_OK; } /** * @brief Returns the last transferred packet size. * @param pdev: Device handle * @param ep_addr: Endpoint Number * @retval Received Data Size */ uint32_t USBD_LL_GetRxDataSize(USBD_HandleTypeDef * pdev, uint8_t ep_addr) { return HAL_PCD_EP_GetRxCount((PCD_HandleTypeDef *) pdev->pData, ep_addr); } /** * @brief Delays routine for the USB Device Library. * @param Delay: Delay in ms * @retval None */ void USBD_LL_Delay(uint32_t Delay) { HAL_Delay(Delay); } /** * @brief static single allocation. * @param size: size of allocated memory * @retval None */ void *USBD_static_malloc(uint32_t size) { static uint32_t mem[MAX_STATIC_ALLOC_SIZE]; return mem; } /** * @brief Dummy memory free * @param *p pointer to allocated memory address * @retval None */ void USBD_static_free(void *p) { } /** * @brief Software Device Connection * @param hpcd: PCD handle * @param state: connection state (0 : disconnected / 1: connected) * @retval None */ void HAL_PCDEx_SetConnectionState(PCD_HandleTypeDef * hpcd, uint8_t state) { if (state != 0) { /* Enabling DP Pull-Down bit to Connect internal pull-up on USB DP line */ HAL_GPIO_WritePin(GPIOB, GPIO_PIN_14, GPIO_PIN_RESET); } else { /* Disable DP Pull-Down bit */ HAL_GPIO_WritePin(GPIOB, GPIO_PIN_14, GPIO_PIN_SET); } }
0
D://workCode//uploadProject\STM32CubeF1\Projects\STM3210E_EVAL\Applications\USB_Device\DFU_Standalone
D://workCode//uploadProject\STM32CubeF1\Projects\STM3210E_EVAL\Applications\USB_Device\DFU_Standalone\Src\usbd_desc.c
/** ****************************************************************************** * @file USB_Device/DFU_Standalone/Src/usbd_desc.c * @author MCD Application Team * @brief This file provides the USBD descriptors and string formatting method. ****************************************************************************** * @attention * * Copyright (c) 2015 STMicroelectronics. * All rights reserved. * * This software is licensed under terms that can be found in the LICENSE file * in the root directory of this software component. * If no LICENSE file comes with this software, it is provided AS-IS. * ****************************************************************************** */ /* Includes ------------------------------------------------------------------ */ #include "usbd_core.h" #include "usbd_desc.h" #include "usbd_conf.h" /* Private typedef ----------------------------------------------------------- */ /* Private define ------------------------------------------------------------ */ #define USBD_VID 0x0483 #define USBD_PID 0xDF11 #define USBD_LANGID_STRING 0x409 #define USBD_MANUFACTURER_STRING "STMicroelectronics" #define USBD_PRODUCT_FS_STRING "DFU in FS Mode" #define USBD_CONFIGURATION_FS_STRING "DFU Config" #define USBD_INTERFACE_FS_STRING "DFU Interface" /* Private macro ------------------------------------------------------------- */ /* Private function prototypes ----------------------------------------------- */ uint8_t *USBD_DFU_DeviceDescriptor(USBD_SpeedTypeDef speed, uint16_t * length); uint8_t *USBD_DFU_LangIDStrDescriptor(USBD_SpeedTypeDef speed, uint16_t * length); uint8_t *USBD_DFU_ManufacturerStrDescriptor(USBD_SpeedTypeDef speed, uint16_t * length); uint8_t *USBD_DFU_ProductStrDescriptor(USBD_SpeedTypeDef speed, uint16_t * length); uint8_t *USBD_DFU_SerialStrDescriptor(USBD_SpeedTypeDef speed, uint16_t * length); uint8_t *USBD_DFU_ConfigStrDescriptor(USBD_SpeedTypeDef speed, uint16_t * length); uint8_t *USBD_DFU_InterfaceStrDescriptor(USBD_SpeedTypeDef speed, uint16_t * length); /* Private variables --------------------------------------------------------- */ USBD_DescriptorsTypeDef DFU_Desc = { USBD_DFU_DeviceDescriptor, USBD_DFU_LangIDStrDescriptor, USBD_DFU_ManufacturerStrDescriptor, USBD_DFU_ProductStrDescriptor, USBD_DFU_SerialStrDescriptor, USBD_DFU_ConfigStrDescriptor, USBD_DFU_InterfaceStrDescriptor, }; /* USB Standard Device Descriptor */ #if defined ( __ICCARM__ ) /*!< IAR Compiler */ #pragma data_alignment=4 #endif __ALIGN_BEGIN uint8_t USBD_DeviceDesc[USB_LEN_DEV_DESC] __ALIGN_END = { 0x12, /* bLength */ USB_DESC_TYPE_DEVICE, /* bDescriptorType */ 0x00, /* bcdUSB */ 0x02, 0x00, /* bDeviceClass */ 0x00, /* bDeviceSubClass */ 0x00, /* bDeviceProtocol */ USB_MAX_EP0_SIZE, /* bMaxPacketSize */ LOBYTE(USBD_VID), /* idVendor */ HIBYTE(USBD_VID), /* idVendor */ LOBYTE(USBD_PID), /* idVendor */ HIBYTE(USBD_PID), /* idVendor */ 0x00, /* bcdDevice rel. 2.00 */ 0x02, USBD_IDX_MFC_STR, /* Index of manufacturer string */ USBD_IDX_PRODUCT_STR, /* Index of product string */ USBD_IDX_SERIAL_STR, /* Index of serial number string */ USBD_MAX_NUM_CONFIGURATION /* bNumConfigurations */ }; /* USB_DeviceDescriptor */ /* USB Standard Device Descriptor */ #if defined ( __ICCARM__ ) /*!< IAR Compiler */ #pragma data_alignment=4 #endif __ALIGN_BEGIN uint8_t USBD_LangIDDesc[USB_LEN_LANGID_STR_DESC] __ALIGN_END = { USB_LEN_LANGID_STR_DESC, USB_DESC_TYPE_STRING, LOBYTE(USBD_LANGID_STRING), HIBYTE(USBD_LANGID_STRING), }; #if defined ( __ICCARM__ ) /*!< IAR Compiler */ #pragma data_alignment=4 #endif __ALIGN_BEGIN uint8_t USBD_StringSerial[USB_SIZ_STRING_SERIAL] __ALIGN_END = { USB_SIZ_STRING_SERIAL, USB_DESC_TYPE_STRING, }; #if defined ( __ICCARM__ ) /*!< IAR Compiler */ #pragma data_alignment=4 #endif __ALIGN_BEGIN uint8_t USBD_StrDesc[USBD_MAX_STR_DESC_SIZ] __ALIGN_END; /* Private functions --------------------------------------------------------- */ static void IntToUnicode(uint32_t value, uint8_t * pbuf, uint8_t len); static void Get_SerialNum(void); /** * @brief Returns the device descriptor. * @param speed: Current device speed * @param length: Pointer to data length variable * @retval Pointer to descriptor buffer */ uint8_t *USBD_DFU_DeviceDescriptor(USBD_SpeedTypeDef speed, uint16_t * length) { *length = sizeof(USBD_DeviceDesc); return (uint8_t *) USBD_DeviceDesc; } /** * @brief Returns the LangID string descriptor. * @param speed: Current device speed * @param length: Pointer to data length variable * @retval Pointer to descriptor buffer */ uint8_t *USBD_DFU_LangIDStrDescriptor(USBD_SpeedTypeDef speed, uint16_t * length) { *length = sizeof(USBD_LangIDDesc); return (uint8_t *) USBD_LangIDDesc; } /** * @brief Returns the product string descriptor. * @param speed: Current device speed * @param length: Pointer to data length variable * @retval Pointer to descriptor buffer */ uint8_t *USBD_DFU_ProductStrDescriptor(USBD_SpeedTypeDef speed, uint16_t * length) { USBD_GetString((uint8_t *) USBD_PRODUCT_FS_STRING, USBD_StrDesc, length); return USBD_StrDesc; } /** * @brief Returns the manufacturer string descriptor. * @param speed: Current device speed * @param length: Pointer to data length variable * @retval Pointer to descriptor buffer */ uint8_t *USBD_DFU_ManufacturerStrDescriptor(USBD_SpeedTypeDef speed, uint16_t * length) { USBD_GetString((uint8_t *) USBD_MANUFACTURER_STRING, USBD_StrDesc, length); return USBD_StrDesc; } /** * @brief Returns the serial number string descriptor. * @param speed: Current device speed * @param length: Pointer to data length variable * @retval Pointer to descriptor buffer */ uint8_t *USBD_DFU_SerialStrDescriptor(USBD_SpeedTypeDef speed, uint16_t * length) { *length = USB_SIZ_STRING_SERIAL; /* Update the serial number string descriptor with the data from the unique * ID */ Get_SerialNum(); return USBD_StringSerial; } /** * @brief Returns the configuration string descriptor. * @param speed: Current device speed * @param length: Pointer to data length variable * @retval Pointer to descriptor buffer */ uint8_t *USBD_DFU_ConfigStrDescriptor(USBD_SpeedTypeDef speed, uint16_t * length) { USBD_GetString((uint8_t *) USBD_CONFIGURATION_FS_STRING, USBD_StrDesc, length); return USBD_StrDesc; } /** * @brief Returns the interface string descriptor. * @param speed: Current device speed * @param length: Pointer to data length variable * @retval Pointer to descriptor buffer */ uint8_t *USBD_DFU_InterfaceStrDescriptor(USBD_SpeedTypeDef speed, uint16_t * length) { USBD_GetString((uint8_t *) USBD_INTERFACE_FS_STRING, USBD_StrDesc, length); return USBD_StrDesc; } /** * @brief Create the serial number string descriptor * @param None * @retval None */ static void Get_SerialNum(void) { uint32_t deviceserial0, deviceserial1, deviceserial2; deviceserial0 = *(uint32_t *) DEVICE_ID1; deviceserial1 = *(uint32_t *) DEVICE_ID2; deviceserial2 = *(uint32_t *) DEVICE_ID3; deviceserial0 += deviceserial2; if (deviceserial0 != 0) { IntToUnicode(deviceserial0, &USBD_StringSerial[2], 8); IntToUnicode(deviceserial1, &USBD_StringSerial[18], 4); } } /** * @brief Convert Hex 32Bits value into char * @param value: value to convert * @param pbuf: pointer to the buffer * @param len: buffer length * @retval None */ static void IntToUnicode(uint32_t value, uint8_t * pbuf, uint8_t len) { uint8_t idx = 0; for (idx = 0; idx < len; idx++) { if (((value >> 28)) < 0xA) { pbuf[2 * idx] = (value >> 28) + '0'; } else { pbuf[2 * idx] = (value >> 28) + 'A' - 10; } value = value << 4; pbuf[2 * idx + 1] = 0; } }
0
D://workCode//uploadProject\STM32CubeF1\Projects\STM3210E_EVAL\Applications\USB_Device\DFU_Standalone
D://workCode//uploadProject\STM32CubeF1\Projects\STM3210E_EVAL\Applications\USB_Device\DFU_Standalone\Src\usbd_dfu_flash.c
/** ****************************************************************************** * @file USB_Device/DFU_Standalone/Src/usbd_dfu_flash.c * @author MCD Application Team * @brief Memory management layer ****************************************************************************** * @attention * * Copyright (c) 2015 STMicroelectronics. * All rights reserved. * * This software is licensed under terms that can be found in the LICENSE file * in the root directory of this software component. * If no LICENSE file comes with this software, it is provided AS-IS. * ****************************************************************************** */ /* Includes ------------------------------------------------------------------ */ #include "usbd_dfu_flash.h" #include "stm32f1xx_hal_conf.h" /* Private typedef ----------------------------------------------------------- */ /* Private define ------------------------------------------------------------ */ /* 256 pages of 2 Kbytes */ #define FLASH_DESC_STR "@Internal Flash /0x08000000/10*02Ka,502*02Kg" #define FLASH_ERASE_TIME (uint16_t)50 #define FLASH_PROGRAM_TIME (uint16_t)50 /* Private macro ------------------------------------------------------------- */ /* Private variables --------------------------------------------------------- */ /* Private function prototypes ----------------------------------------------- */ /* Extern function prototypes ------------------------------------------------ */ uint16_t Flash_If_Init(void); uint16_t Flash_If_Erase(uint32_t Add); uint16_t Flash_If_Write(uint8_t * src, uint8_t * dest, uint32_t Len); uint8_t *Flash_If_Read(uint8_t * src, uint8_t * dest, uint32_t Len); uint16_t Flash_If_DeInit(void); uint16_t Flash_If_GetStatus(uint32_t Add, uint8_t Cmd, uint8_t * buffer); USBD_DFU_MediaTypeDef USBD_DFU_Flash_fops = { (uint8_t *) FLASH_DESC_STR, Flash_If_Init, Flash_If_DeInit, Flash_If_Erase, Flash_If_Write, Flash_If_Read, Flash_If_GetStatus, }; /* Private functions --------------------------------------------------------- */ /** * @brief Initializes Memory. * @param None * @retval 0 if operation is successeful, MAL_FAIL else. */ uint16_t Flash_If_Init(void) { /* Unlock the internal flash */ HAL_FLASH_Unlock(); return 0; } /** * @brief De-Initializes Memory. * @param None * @retval 0 if operation is successeful, MAL_FAIL else. */ uint16_t Flash_If_DeInit(void) { /* Lock the internal flash */ HAL_FLASH_Lock(); return 0; } /** * @brief Erases sector. * @param Add: Address of sector to be erased. * @retval 0 if operation is successeful, MAL_FAIL else. */ uint16_t Flash_If_Erase(uint32_t Add) { uint32_t PageError; /* Variable contains Flash operation status */ HAL_StatusTypeDef status; FLASH_EraseInitTypeDef eraseinitstruct; eraseinitstruct.TypeErase = FLASH_TYPEERASE_PAGES; eraseinitstruct.PageAddress = Add; eraseinitstruct.NbPages = 1U; status = HAL_FLASHEx_Erase(&eraseinitstruct, &PageError); if (status != HAL_OK) { return 1U; } return 0U; } /** * @brief Writes Data into Memory. * @param src: Pointer to the source buffer. Address to be written to. * @param dest: Pointer to the destination buffer. * @param Len: Number of data to be written (in bytes). * @retval 0 if operation is successeful, MAL_FAIL else. */ uint16_t Flash_If_Write(uint8_t * src, uint8_t * dest, uint32_t Len) { uint32_t i = 0; for (i = 0; i < Len; i += 4) { /* Device voltage range supposed to be [2.7V to 3.6V], the operation will * be done by byte */ if (HAL_FLASH_Program (FLASH_TYPEPROGRAM_WORD, (uint32_t) (dest + i), *(uint32_t *) (src + i)) == HAL_OK) { /* Check the written value */ if (*(uint32_t *) (src + i) != *(uint32_t *) (dest + i)) { /* Flash content doesn't match SRAM content */ return 2; } } else { /* Error occurred while writing data in Flash memory */ return 1; } } return 0; } /** * @brief Reads Data into Memory. * @param src: Pointer to the source buffer. Address to be written to. * @param dest: Pointer to the destination buffer. * @param Len: Number of data to be read (in bytes). * @retval Pointer to the physical address where data should be read. */ uint8_t *Flash_If_Read(uint8_t * src, uint8_t * dest, uint32_t Len) { uint32_t i = 0; uint8_t *psrc = src; for (i = 0; i < Len; i++) { dest[i] = *psrc++; } /* Return a valid address to avoid HardFault */ return (uint8_t *) (dest); } /** * @brief Gets Memory Status. * @param Add: Address to be read from. * @param Cmd: Number of data to be read (in bytes). * @retval 0 if operation is successeful */ uint16_t Flash_If_GetStatus(uint32_t Add, uint8_t Cmd, uint8_t * buffer) { switch (Cmd) { case DFU_MEDIA_PROGRAM: buffer[1] = (uint8_t) FLASH_PROGRAM_TIME; buffer[2] = (uint8_t) (FLASH_PROGRAM_TIME << 8); buffer[3] = 0; break; case DFU_MEDIA_ERASE: default: buffer[1] = (uint8_t) FLASH_ERASE_TIME; buffer[2] = (uint8_t) (FLASH_ERASE_TIME << 8); buffer[3] = 0; break; } return 0; }
0
D://workCode//uploadProject\STM32CubeF1\Projects\STM3210E_EVAL\Applications\USB_Device\HID_Standalone
D://workCode//uploadProject\STM32CubeF1\Projects\STM3210E_EVAL\Applications\USB_Device\HID_Standalone\Inc\main.h
/** ****************************************************************************** * @file USB_Device/HID_Standalone/Inc/main.h * @author MCD Application Team * @brief Header for main.c module ****************************************************************************** * @attention * * Copyright (c) 2016 STMicroelectronics. * All rights reserved. * * This software is licensed under terms that can be found in the LICENSE file * in the root directory of this software component. * If no LICENSE file comes with this software, it is provided AS-IS. * ****************************************************************************** */ /* Define to prevent recursive inclusion -------------------------------------*/ #ifndef __MAIN_H #define __MAIN_H /* Includes ------------------------------------------------------------------*/ #include "stm32f1xx_hal.h" #include "stm3210e_eval.h" #include "usbd_core.h" #include "stm32f1xx_hal_pcd.h" #include "usbd_desc.h" #include "usbd_hid.h" /* Exported types ------------------------------------------------------------*/ /* Exported constants --------------------------------------------------------*/ /* Exported macro ------------------------------------------------------------*/ /* Exported functions ------------------------------------------------------- */ void Toggle_Leds(void); #endif /* __MAIN_H */
0
D://workCode//uploadProject\STM32CubeF1\Projects\STM3210E_EVAL\Applications\USB_Device\HID_Standalone
D://workCode//uploadProject\STM32CubeF1\Projects\STM3210E_EVAL\Applications\USB_Device\HID_Standalone\Inc\stm32f1xx_hal_conf.h
/** ****************************************************************************** * @file USB_Device/HID_Standalone/Inc/stm32f1xx_hal_conf.h * @author MCD Application Team * @brief HAL configuration template file. * This file should be copied to the application folder and renamed * to stm32f1xx_hal_conf.h. ****************************************************************************** * @attention * * Copyright (c) 2016 STMicroelectronics. * All rights reserved. * * This software is licensed under terms that can be found in the LICENSE file * in the root directory of this software component. * If no LICENSE file comes with this software, it is provided AS-IS. * ****************************************************************************** */ /* Define to prevent recursive inclusion -------------------------------------*/ #ifndef __STM32F1xx_HAL_CONF_H #define __STM32F1xx_HAL_CONF_H #ifdef __cplusplus extern "C" { #endif /* Exported types ------------------------------------------------------------*/ /* Exported constants --------------------------------------------------------*/ /* ########################## Module Selection ############################## */ /** * @brief This is the list of modules to be used in the HAL driver */ #define HAL_MODULE_ENABLED /* #define HAL_ADC_MODULE_ENABLED */ /* #define HAL_CAN_MODULE_ENABLED */ /* #define HAL_CAN_LEGACY_MODULE_ENABLED */ #define HAL_CORTEX_MODULE_ENABLED */ /* #define HAL_CRC_MODULE_ENABLED */ /* #define HAL_DAC_MODULE_ENABLED */ #define HAL_DMA_MODULE_ENABLED #define HAL_EXTI_MODULE_ENABLED #define HAL_FLASH_MODULE_ENABLED #define HAL_GPIO_MODULE_ENABLED /* #define HAL_I2C_MODULE_ENABLED */ /* #define HAL_I2S_MODULE_ENABLED */ /* #define HAL_IRDA_MODULE_ENABLED */ /* #define HAL_IWDG_MODULE_ENABLED */ /* #define HAL_NOR_MODULE_ENABLED */ /* #define HAL_PCCARD_MODULE_ENABLED */ #define HAL_PCD_MODULE_ENABLED #define HAL_PWR_MODULE_ENABLED #define HAL_RCC_MODULE_ENABLED /* #define HAL_RTC_MODULE_ENABLED */ /* #define HAL_SD_MODULE_ENABLED */ /* #define HAL_SDRAM_MODULE_ENABLED */ /* #define HAL_SMARTCARD_MODULE_ENABLED */ /* #define HAL_SPI_MODULE_ENABLED */ /* #define HAL_SRAM_MODULE_ENABLED */ /* #define HAL_TIM_MODULE_ENABLED */ #define HAL_UART_MODULE_ENABLED /* #define HAL_USART_MODULE_ENABLED */ /* #define HAL_WWDG_MODULE_ENABLED */ /* #define HAL_MMC_MODULE_ENABLED */ /* ########################## Oscillator Values adaptation ####################*/ /** * @brief Adjust the value of External High Speed oscillator (HSE) used in your application. * This value is used by the RCC HAL module to compute the system frequency * (when HSE is used as system clock source, directly or through the PLL). */ #if !defined (HSE_VALUE) #if defined(USE_STM3210C_EVAL) #define HSE_VALUE 25000000U /*!< Value of the External oscillator in Hz */ #else #define HSE_VALUE 8000000U /*!< Value of the External oscillator in Hz */ #endif #endif /* HSE_VALUE */ #if !defined (HSE_STARTUP_TIMEOUT) #define HSE_STARTUP_TIMEOUT 100U /*!< Time out for HSE start up, in ms */ #endif /* HSE_STARTUP_TIMEOUT */ /** * @brief Internal High Speed oscillator (HSI) value. * This value is used by the RCC HAL module to compute the system frequency * (when HSI is used as system clock source, directly or through the PLL). */ #if !defined (HSI_VALUE) #define HSI_VALUE 8000000U /*!< Value of the Internal oscillator in Hz */ #endif /* HSI_VALUE */ /** * @brief Internal Low Speed oscillator (LSI) value. */ #if !defined (LSI_VALUE) #define LSI_VALUE 40000U /*!< LSI Typical Value in Hz */ #endif /* LSI_VALUE */ /*!< Value of the Internal Low Speed oscillator in Hz The real value may vary depending on the variations in voltage and temperature. */ /** * @brief External Low Speed oscillator (LSE) value. * This value is used by the UART, RTC HAL module to compute the system frequency */ #if !defined (LSE_VALUE) #define LSE_VALUE 32768U /*!< Value of the External oscillator in Hz*/ #endif /* LSE_VALUE */ #if !defined (LSE_STARTUP_TIMEOUT) #define LSE_STARTUP_TIMEOUT 5000U /*!< Time out for LSE start up, in ms */ #endif /* LSE_STARTUP_TIMEOUT */ /* Tip: To avoid modifying this file each time you need to use different HSE, === you can define the HSE value in your toolchain compiler preprocessor. */ /* ########################### System Configuration ######################### */ /** * @brief This is the HAL system configuration section */ #define VDD_VALUE 3300U /*!< Value of VDD in mv */ #define TICK_INT_PRIORITY 0x00U /*!< tick interrupt priority */ #define USE_RTOS 0U #define PREFETCH_ENABLE 1U #define USE_HAL_ADC_REGISTER_CALLBACKS 0U /* ADC register callback disabled */ #define USE_HAL_CAN_REGISTER_CALLBACKS 0U /* CAN register callback disabled */ #define USE_HAL_CEC_REGISTER_CALLBACKS 0U /* CEC register callback disabled */ #define USE_HAL_DAC_REGISTER_CALLBACKS 0U /* DAC register callback disabled */ #define USE_HAL_ETH_REGISTER_CALLBACKS 0U /* ETH register callback disabled */ #define USE_HAL_HCD_REGISTER_CALLBACKS 0U /* HCD register callback disabled */ #define USE_HAL_I2C_REGISTER_CALLBACKS 0U /* I2C register callback disabled */ #define USE_HAL_I2S_REGISTER_CALLBACKS 0U /* I2S register callback disabled */ #define USE_HAL_MMC_REGISTER_CALLBACKS 0U /* MMC register callback disabled */ #define USE_HAL_NAND_REGISTER_CALLBACKS 0U /* NAND register callback disabled */ #define USE_HAL_NOR_REGISTER_CALLBACKS 0U /* NOR register callback disabled */ #define USE_HAL_PCCARD_REGISTER_CALLBACKS 0U /* PCCARD register callback disabled */ #define USE_HAL_PCD_REGISTER_CALLBACKS 0U /* PCD register callback disabled */ #define USE_HAL_RTC_REGISTER_CALLBACKS 0U /* RTC register callback disabled */ #define USE_HAL_SD_REGISTER_CALLBACKS 0U /* SD register callback disabled */ #define USE_HAL_SMARTCARD_REGISTER_CALLBACKS 0U /* SMARTCARD register callback disabled */ #define USE_HAL_IRDA_REGISTER_CALLBACKS 0U /* IRDA register callback disabled */ #define USE_HAL_SRAM_REGISTER_CALLBACKS 0U /* SRAM register callback disabled */ #define USE_HAL_SPI_REGISTER_CALLBACKS 0U /* SPI register callback disabled */ #define USE_HAL_TIM_REGISTER_CALLBACKS 0U /* TIM register callback disabled */ #define USE_HAL_UART_REGISTER_CALLBACKS 0U /* UART register callback disabled */ #define USE_HAL_USART_REGISTER_CALLBACKS 0U /* USART register callback disabled */ #define USE_HAL_WWDG_REGISTER_CALLBACKS 0U /* WWDG register callback disabled */ /* ########################## Assert Selection ############################## */ /** * @brief Uncomment the line below to expanse the "assert_param" macro in the * HAL drivers code */ /* #define USE_FULL_ASSERT 1U */ /* ################## Ethernet peripheral configuration ##################### */ /* Section 1 : Ethernet peripheral configuration */ /* MAC ADDRESS: MAC_ADDR0:MAC_ADDR1:MAC_ADDR2:MAC_ADDR3:MAC_ADDR4:MAC_ADDR5 */ #define MAC_ADDR0 2U #define MAC_ADDR1 0U #define MAC_ADDR2 0U #define MAC_ADDR3 0U #define MAC_ADDR4 0U #define MAC_ADDR5 0U /* Definition of the Ethernet driver buffers size and count */ #define ETH_RX_BUF_SIZE ETH_MAX_PACKET_SIZE /* buffer size for receive */ #define ETH_TX_BUF_SIZE ETH_MAX_PACKET_SIZE /* buffer size for transmit */ #define ETH_RXBUFNB 8U /* 8 Rx buffers of size ETH_RX_BUF_SIZE */ #define ETH_TXBUFNB 4U /* 4 Tx buffers of size ETH_TX_BUF_SIZE */ /* Section 2: PHY configuration section */ /* DP83848 PHY Address*/ #define DP83848_PHY_ADDRESS 0x01U /* PHY Reset delay these values are based on a 1 ms Systick interrupt*/ #define PHY_RESET_DELAY 0x000000FFU /* PHY Configuration delay */ #define PHY_CONFIG_DELAY 0x00000FFFU #define PHY_READ_TO 0x0000FFFFU #define PHY_WRITE_TO 0x0000FFFFU /* Section 3: Common PHY Registers */ #define PHY_BCR ((uint16_t)0x0000) /*!< Transceiver Basic Control Register */ #define PHY_BSR ((uint16_t)0x0001) /*!< Transceiver Basic Status Register */ #define PHY_RESET ((uint16_t)0x8000) /*!< PHY Reset */ #define PHY_LOOPBACK ((uint16_t)0x4000) /*!< Select loop-back mode */ #define PHY_FULLDUPLEX_100M ((uint16_t)0x2100) /*!< Set the full-duplex mode at 100 Mb/s */ #define PHY_HALFDUPLEX_100M ((uint16_t)0x2000) /*!< Set the half-duplex mode at 100 Mb/s */ #define PHY_FULLDUPLEX_10M ((uint16_t)0x0100) /*!< Set the full-duplex mode at 10 Mb/s */ #define PHY_HALFDUPLEX_10M ((uint16_t)0x0000) /*!< Set the half-duplex mode at 10 Mb/s */ #define PHY_AUTONEGOTIATION ((uint16_t)0x1000) /*!< Enable auto-negotiation function */ #define PHY_RESTART_AUTONEGOTIATION ((uint16_t)0x0200) /*!< Restart auto-negotiation function */ #define PHY_POWERDOWN ((uint16_t)0x0800) /*!< Select the power down mode */ #define PHY_ISOLATE ((uint16_t)0x0400) /*!< Isolate PHY from MII */ #define PHY_AUTONEGO_COMPLETE ((uint16_t)0x0020) /*!< Auto-Negotiation process completed */ #define PHY_LINKED_STATUS ((uint16_t)0x0004) /*!< Valid link established */ #define PHY_JABBER_DETECTION ((uint16_t)0x0002) /*!< Jabber condition detected */ /* Section 4: Extended PHY Registers */ #define PHY_SR ((uint16_t)0x0010) /*!< PHY status register Offset */ #define PHY_MICR ((uint16_t)0x0011) /*!< MII Interrupt Control Register */ #define PHY_MISR ((uint16_t)0x0012) /*!< MII Interrupt Status and Misc. Control Register */ #define PHY_LINK_STATUS ((uint16_t)0x0001) /*!< PHY Link mask */ #define PHY_SPEED_STATUS ((uint16_t)0x0002) /*!< PHY Speed mask */ #define PHY_DUPLEX_STATUS ((uint16_t)0x0004) /*!< PHY Duplex mask */ #define PHY_MICR_INT_EN ((uint16_t)0x0002) /*!< PHY Enable interrupts */ #define PHY_MICR_INT_OE ((uint16_t)0x0001) /*!< PHY Enable output interrupt events */ #define PHY_MISR_LINK_INT_EN ((uint16_t)0x0020) /*!< Enable Interrupt on change of link status */ #define PHY_LINK_INTERRUPT ((uint16_t)0x2000) /*!< PHY link status interrupt mask */ /* ################## SPI peripheral configuration ########################## */ /* CRC FEATURE: Use to activate CRC feature inside HAL SPI Driver * Activated: CRC code is present inside driver * Deactivated: CRC code cleaned from driver */ #define USE_SPI_CRC 1U /* Includes ------------------------------------------------------------------*/ /** * @brief Include module's header file */ #ifdef HAL_RCC_MODULE_ENABLED #include "stm32f1xx_hal_rcc.h" #endif /* HAL_RCC_MODULE_ENABLED */ #ifdef HAL_GPIO_MODULE_ENABLED #include "stm32f1xx_hal_gpio.h" #endif /* HAL_GPIO_MODULE_ENABLED */ #ifdef HAL_EXTI_MODULE_ENABLED #include "stm32f1xx_hal_exti.h" #endif /* HAL_EXTI_MODULE_ENABLED */ #ifdef HAL_DMA_MODULE_ENABLED #include "stm32f1xx_hal_dma.h" #endif /* HAL_DMA_MODULE_ENABLED */ #ifdef HAL_CAN_MODULE_ENABLED #include "stm32f1xx_hal_can.h" #endif /* HAL_CAN_MODULE_ENABLED */ #ifdef HAL_CAN_LEGACY_MODULE_ENABLED #include "Legacy/stm32f1xx_hal_can_legacy.h" #endif /* HAL_CAN_LEGACY_MODULE_ENABLED */ #ifdef HAL_CORTEX_MODULE_ENABLED #include "stm32f1xx_hal_cortex.h" #endif /* HAL_CORTEX_MODULE_ENABLED */ #ifdef HAL_ADC_MODULE_ENABLED #include "stm32f1xx_hal_adc.h" #endif /* HAL_ADC_MODULE_ENABLED */ #ifdef HAL_CRC_MODULE_ENABLED #include "stm32f1xx_hal_crc.h" #endif /* HAL_CRC_MODULE_ENABLED */ #ifdef HAL_DAC_MODULE_ENABLED #include "stm32f1xx_hal_dac.h" #endif /* HAL_DAC_MODULE_ENABLED */ #ifdef HAL_FLASH_MODULE_ENABLED #include "stm32f1xx_hal_flash.h" #endif /* HAL_FLASH_MODULE_ENABLED */ #ifdef HAL_SRAM_MODULE_ENABLED #include "stm32f1xx_hal_sram.h" #endif /* HAL_SRAM_MODULE_ENABLED */ #ifdef HAL_NOR_MODULE_ENABLED #include "stm32f1xx_hal_nor.h" #endif /* HAL_NOR_MODULE_ENABLED */ #ifdef HAL_I2C_MODULE_ENABLED #include "stm32f1xx_hal_i2c.h" #endif /* HAL_I2C_MODULE_ENABLED */ #ifdef HAL_I2S_MODULE_ENABLED #include "stm32f1xx_hal_i2s.h" #endif /* HAL_I2S_MODULE_ENABLED */ #ifdef HAL_IWDG_MODULE_ENABLED #include "stm32f1xx_hal_iwdg.h" #endif /* HAL_IWDG_MODULE_ENABLED */ #ifdef HAL_PWR_MODULE_ENABLED #include "stm32f1xx_hal_pwr.h" #endif /* HAL_PWR_MODULE_ENABLED */ #ifdef HAL_RTC_MODULE_ENABLED #include "stm32f1xx_hal_rtc.h" #endif /* HAL_RTC_MODULE_ENABLED */ #ifdef HAL_PCCARD_MODULE_ENABLED #include "stm32f1xx_hal_pccard.h" #endif /* HAL_PCCARD_MODULE_ENABLED */ #ifdef HAL_SD_MODULE_ENABLED #include "stm32f1xx_hal_sd.h" #endif /* HAL_SD_MODULE_ENABLED */ #ifdef HAL_SDRAM_MODULE_ENABLED #include "stm32f1xx_hal_sdram.h" #endif /* HAL_SDRAM_MODULE_ENABLED */ #ifdef HAL_SPI_MODULE_ENABLED #include "stm32f1xx_hal_spi.h" #endif /* HAL_SPI_MODULE_ENABLED */ #ifdef HAL_TIM_MODULE_ENABLED #include "stm32f1xx_hal_tim.h" #endif /* HAL_TIM_MODULE_ENABLED */ #ifdef HAL_UART_MODULE_ENABLED #include "stm32f1xx_hal_uart.h" #endif /* HAL_UART_MODULE_ENABLED */ #ifdef HAL_USART_MODULE_ENABLED #include "stm32f1xx_hal_usart.h" #endif /* HAL_USART_MODULE_ENABLED */ #ifdef HAL_IRDA_MODULE_ENABLED #include "stm32f1xx_hal_irda.h" #endif /* HAL_IRDA_MODULE_ENABLED */ #ifdef HAL_SMARTCARD_MODULE_ENABLED #include "stm32f1xx_hal_smartcard.h" #endif /* HAL_SMARTCARD_MODULE_ENABLED */ #ifdef HAL_WWDG_MODULE_ENABLED #include "stm32f1xx_hal_wwdg.h" #endif /* HAL_WWDG_MODULE_ENABLED */ #ifdef HAL_PCD_MODULE_ENABLED #include "stm32f1xx_hal_pcd.h" #endif /* HAL_PCD_MODULE_ENABLED */ #ifdef HAL_MMC_MODULE_ENABLED #include "stm32f1xx_hal_mmc.h" #endif /* HAL_MMC_MODULE_ENABLED */ /* Exported macro ------------------------------------------------------------*/ #ifdef USE_FULL_ASSERT /** * @brief The assert_param macro is used for function's parameters check. * @param expr: If expr is false, it calls assert_failed function * which reports the name of the source file and the source * line number of the call that failed. * If expr is true, it returns no value. * @retval None */ #define assert_param(expr) ((expr) ? (void)0U : assert_failed((uint8_t *)__FILE__, __LINE__)) /* Exported functions ------------------------------------------------------- */ void assert_failed(uint8_t* file, uint32_t line); #else #define assert_param(expr) ((void)0U) #endif /* USE_FULL_ASSERT */ #ifdef __cplusplus } #endif #endif /* __STM32F1xx_HAL_CONF_H */
0
D://workCode//uploadProject\STM32CubeF1\Projects\STM3210E_EVAL\Applications\USB_Device\HID_Standalone
D://workCode//uploadProject\STM32CubeF1\Projects\STM3210E_EVAL\Applications\USB_Device\HID_Standalone\Inc\stm32f1xx_it.h
/** ****************************************************************************** * @file USB_Device/HID_Standalone/Inc/stm32f1xx_it.h * @author MCD Application Team * @brief This file contains the headers of the interrupt handlers. ****************************************************************************** * @attention * * Copyright (c) 2016 STMicroelectronics. * All rights reserved. * * This software is licensed under terms that can be found in the LICENSE file * in the root directory of this software component. * If no LICENSE file comes with this software, it is provided AS-IS. * ****************************************************************************** */ /* Define to prevent recursive inclusion -------------------------------------*/ #ifndef __STM32F1xx_IT_H #define __STM32F1xx_IT_H #ifdef __cplusplus extern "C" { #endif /* Includes ------------------------------------------------------------------*/ #include "main.h" /* Exported types ------------------------------------------------------------*/ /* Exported constants --------------------------------------------------------*/ /* Exported macro ------------------------------------------------------------*/ /* Exported functions ------------------------------------------------------- */ void NMI_Handler(void); void HardFault_Handler(void); void MemManage_Handler(void); void BusFault_Handler(void); void UsageFault_Handler(void); void SVC_Handler(void); void DebugMon_Handler(void); void PendSV_Handler(void); void SysTick_Handler(void); void USB_LP_CAN1_RX0_IRQHandler(void); void USBWakeUp_IRQHandler(void); void EXTI9_5_IRQHandler(void); #ifdef __cplusplus } #endif #endif /* __STM32F1xx_IT_H */
0
D://workCode//uploadProject\STM32CubeF1\Projects\STM3210E_EVAL\Applications\USB_Device\HID_Standalone
D://workCode//uploadProject\STM32CubeF1\Projects\STM3210E_EVAL\Applications\USB_Device\HID_Standalone\Inc\usbd_conf.h
/** ****************************************************************************** * @file USB_Device/HID_Standalone/Inc/usbd_conf.h * @author MCD Application Team * @brief General low level driver configuration ****************************************************************************** * @attention * * Copyright (c) 2015 STMicroelectronics. * All rights reserved. * * This software is licensed under terms that can be found in the LICENSE file * in the root directory of this software component. * If no LICENSE file comes with this software, it is provided AS-IS. * ****************************************************************************** */ /* Define to prevent recursive inclusion -------------------------------------*/ #ifndef __USBD_CONF_H #define __USBD_CONF_H /* Includes ------------------------------------------------------------------*/ #include "stm32f1xx_hal.h" #include <stdio.h> #include <stdlib.h> #include <string.h> /* Exported types ------------------------------------------------------------*/ /* Exported constants --------------------------------------------------------*/ /* Common Config */ #define USBD_MAX_NUM_INTERFACES 1 #define USBD_MAX_NUM_CONFIGURATION 1 #define USBD_MAX_STR_DESC_SIZ 0x100 #define USBD_SUPPORT_USER_STRING_DESC 0 #define USBD_SELF_POWERED 1 #define USBD_DEBUG_LEVEL 0 /* Exported macro ------------------------------------------------------------*/ /* Memory management macros */ /* For footprint reasons and since only one allocation is handled in the HID class driver, the malloc/free is changed into a static allocation method */ void *USBD_static_malloc(uint32_t size); void USBD_static_free(void *p); #define MAX_STATIC_ALLOC_SIZE 4 /*HID Class Driver Structure size*/ #define USBD_malloc (uint32_t *)USBD_static_malloc #define USBD_free USBD_static_free #define USBD_memset /* Not used */ #define USBD_memcpy /* Not used */ /* DEBUG macros */ #if (USBD_DEBUG_LEVEL > 0) #define USBD_UsrLog(...) printf(__VA_ARGS__);\ printf("\n"); #else #define USBD_UsrLog(...) #endif #if (USBD_DEBUG_LEVEL > 1) #define USBD_ErrLog(...) printf("ERROR: ") ;\ printf(__VA_ARGS__);\ printf("\n"); #else #define USBD_ErrLog(...) #endif #if (USBD_DEBUG_LEVEL > 2) #define USBD_DbgLog(...) printf("DEBUG : ") ;\ printf(__VA_ARGS__);\ printf("\n"); #else #define USBD_DbgLog(...) #endif /* Exported functions ------------------------------------------------------- */ #endif /* __USBD_CONF_H */
0
D://workCode//uploadProject\STM32CubeF1\Projects\STM3210E_EVAL\Applications\USB_Device\HID_Standalone
D://workCode//uploadProject\STM32CubeF1\Projects\STM3210E_EVAL\Applications\USB_Device\HID_Standalone\Inc\usbd_desc.h
/** ****************************************************************************** * @file USB_Device/HID_Standalone/Inc/usbd_desc.h * @author MCD Application Team * @brief Header for usbd_desc.c module ****************************************************************************** * @attention * * Copyright (c) 2015 STMicroelectronics. * All rights reserved. * * This software is licensed under terms that can be found in the LICENSE file * in the root directory of this software component. * If no LICENSE file comes with this software, it is provided AS-IS. * ****************************************************************************** */ /* Define to prevent recursive inclusion -------------------------------------*/ #ifndef __USBD_DESC_H #define __USBD_DESC_H /* Includes ------------------------------------------------------------------*/ #include "usbd_def.h" /* Exported types ------------------------------------------------------------*/ /* Exported constants --------------------------------------------------------*/ #define DEVICE_ID1 (0x1FFFF7E8) #define DEVICE_ID2 (0x1FFFF7EC) #define DEVICE_ID3 (0x1FFFF7F0) #define USB_SIZ_STRING_SERIAL 0x1A /* Exported macro ------------------------------------------------------------*/ /* Exported functions ------------------------------------------------------- */ extern USBD_DescriptorsTypeDef HID_Desc; #endif /* __USBD_DESC_H */
0
D://workCode//uploadProject\STM32CubeF1\Projects\STM3210E_EVAL\Applications\USB_Device\HID_Standalone
D://workCode//uploadProject\STM32CubeF1\Projects\STM3210E_EVAL\Applications\USB_Device\HID_Standalone\Src\main.c
/** ****************************************************************************** * @file USB_Device/HID_Standalone/Src/main.c * @author MCD Application Team * @brief USB device HID application main file. ****************************************************************************** * @attention * * Copyright (c) 2016 STMicroelectronics. * All rights reserved. * * This software is licensed under terms that can be found in the LICENSE file * in the root directory of this software component. * If no LICENSE file comes with this software, it is provided AS-IS. * ****************************************************************************** */ /* Includes ------------------------------------------------------------------ */ #include "main.h" /** @addtogroup STM32F1xx_HAL_Validation * @{ */ /** @addtogroup STANDARD_CHECK * @{ */ /* Private typedef ----------------------------------------------------------- */ /* Private define ------------------------------------------------------------ */ /* Private macro ------------------------------------------------------------- */ /* Private variables --------------------------------------------------------- */ USBD_HandleTypeDef USBD_Device; /* Private function prototypes ----------------------------------------------- */ void SystemClock_Config(void); static void Error_Handler(void); /* Private functions --------------------------------------------------------- */ /** * @brief Main program. * @param None * @retval None */ int main(void) { /* Reset of all peripherals, Initializes the Flash interface and the Systick. */ HAL_Init(); /* Initialize LEDs */ BSP_LED_Init(LED1); BSP_LED_Init(LED2); BSP_LED_Init(LED3); BSP_LED_Init(LED4); /* Configure the system clock to 72 MHz */ SystemClock_Config(); /* Initialize Joystick */ BSP_JOY_Init(JOY_MODE_GPIO); /* Configure Key push-button for remote wakeup */ BSP_PB_Init(BUTTON_KEY, BUTTON_MODE_EXTI); /* Init Device Library */ USBD_Init(&USBD_Device, &HID_Desc, 0); /* Register the HID class */ USBD_RegisterClass(&USBD_Device, &USBD_HID); /* Start Device Process */ USBD_Start(&USBD_Device); /* Infinite loop */ while (1) { } } /** * @brief System Clock Configuration * The system Clock is configured as follow : * System Clock source = PLL (HSE) * SYSCLK(Hz) = 72000000 * HCLK(Hz) = 72000000 * AHB Prescaler = 1 * APB1 Prescaler = 2 * APB2 Prescaler = 1 * HSE Frequency(Hz) = 8000000 * HSE PREDIV1 = 1 * PLLMUL = 9 * Flash Latency(WS) = 2 * @param None * @retval None */ void SystemClock_Config(void) { RCC_ClkInitTypeDef clkinitstruct = { 0 }; RCC_OscInitTypeDef oscinitstruct = { 0 }; RCC_PeriphCLKInitTypeDef rccperiphclkinit = { 0 }; /* Enable HSE Oscillator and activate PLL with HSE as source */ oscinitstruct.OscillatorType = RCC_OSCILLATORTYPE_HSE; oscinitstruct.HSEState = RCC_HSE_ON; oscinitstruct.HSEPredivValue = RCC_HSE_PREDIV_DIV1; oscinitstruct.PLL.PLLMUL = RCC_PLL_MUL9; oscinitstruct.PLL.PLLState = RCC_PLL_ON; oscinitstruct.PLL.PLLSource = RCC_PLLSOURCE_HSE; if (HAL_RCC_OscConfig(&oscinitstruct) != HAL_OK) { /* Start Conversation Error */ Error_Handler(); } /* USB clock selection */ rccperiphclkinit.PeriphClockSelection = RCC_PERIPHCLK_USB; rccperiphclkinit.UsbClockSelection = RCC_USBCLKSOURCE_PLL_DIV1_5; HAL_RCCEx_PeriphCLKConfig(&rccperiphclkinit); /* Select PLL as system clock source and configure the HCLK, PCLK1 and PCLK2 * clocks dividers */ clkinitstruct.ClockType = RCC_CLOCKTYPE_SYSCLK | RCC_CLOCKTYPE_HCLK | RCC_CLOCKTYPE_PCLK1 | RCC_CLOCKTYPE_PCLK2; clkinitstruct.SYSCLKSource = RCC_SYSCLKSOURCE_PLLCLK; clkinitstruct.AHBCLKDivider = RCC_SYSCLK_DIV1; clkinitstruct.APB1CLKDivider = RCC_HCLK_DIV2; clkinitstruct.APB2CLKDivider = RCC_HCLK_DIV1; if (HAL_RCC_ClockConfig(&clkinitstruct, FLASH_LATENCY_2) != HAL_OK) { /* Start Conversation Error */ Error_Handler(); } } /** * @brief This function is executed in case of error occurrence. * @param None * @retval None */ static void Error_Handler(void) { /* Turn LED3 on */ BSP_LED_On(LED3); while (1) { } } /** * @brief Toggle LEDs to shows user input state. * @param None * @retval None */ void Toggle_Leds(void) { static uint32_t ticks; if (ticks++ == 0xFFFFF) { BSP_LED_Toggle(LED1); BSP_LED_Toggle(LED2); BSP_LED_Toggle(LED3); BSP_LED_Toggle(LED4); ticks = 0; } } #ifdef USE_FULL_ASSERT /** * @brief Reports the name of the source file and the source line number * where the assert_param error has occurred. * @param file: pointer to the source file name * @param line: assert_param error line source number * @retval None */ void assert_failed(uint8_t * file, uint32_t line) { /* User can add his own implementation to report the file name and line * number, ex: printf("Wrong parameters value: file %s on line %d\r\n", file, * line) */ /* Infinite loop */ while (1) { } } #endif /** * @} */ /** * @} */
0
D://workCode//uploadProject\STM32CubeF1\Projects\STM3210E_EVAL\Applications\USB_Device\HID_Standalone
D://workCode//uploadProject\STM32CubeF1\Projects\STM3210E_EVAL\Applications\USB_Device\HID_Standalone\Src\stm32f1xx_it.c
/** ****************************************************************************** * @file USB_Device/HID_Standalone/Src/stm32f1xx_it.c * @author MCD Application Team * @brief Main Interrupt Service Routines. * This file provides template for all exceptions handler and * peripherals interrupt service routine. ****************************************************************************** * @attention * * Copyright (c) 2016 STMicroelectronics. * All rights reserved. * * This software is licensed under terms that can be found in the LICENSE file * in the root directory of this software component. * If no LICENSE file comes with this software, it is provided AS-IS. * ****************************************************************************** */ /* Includes ------------------------------------------------------------------ */ #include "stm32f1xx_it.h" /** @addtogroup Validation_Project * @{ */ /* Private typedef ----------------------------------------------------------- */ /* Private define ------------------------------------------------------------ */ #define CURSOR_STEP 5 /* Private macro ------------------------------------------------------------- */ /* Private variables --------------------------------------------------------- */ extern PCD_HandleTypeDef hpcd; extern USBD_HandleTypeDef USBD_Device; /* Private function prototypes ----------------------------------------------- */ static void GetPointerData(uint8_t * pbuf); /* Private functions --------------------------------------------------------- */ /******************************************************************************/ /* Cortex-M3 Processor Exceptions Handlers */ /******************************************************************************/ /** * @brief This function handles NMI exception. * @param None * @retval None */ void NMI_Handler(void) { } /** * @brief This function handles Hard Fault exception. * @param None * @retval None */ void HardFault_Handler(void) { /* Go to infinite loop when Hard Fault exception occurs */ while (1) { } } /** * @brief This function handles Memory Manage exception. * @param None * @retval None */ void MemManage_Handler(void) { /* Go to infinite loop when Memory Manage exception occurs */ while (1) { } } /** * @brief This function handles Bus Fault exception. * @param None * @retval None */ void BusFault_Handler(void) { /* Go to infinite loop when Bus Fault exception occurs */ while (1) { } } /** * @brief This function handles Usage Fault exception. * @param None * @retval None */ void UsageFault_Handler(void) { /* Go to infinite loop when Usage Fault exception occurs */ while (1) { } } /** * @brief This function handles SVCall exception. * @param None * @retval None */ void SVC_Handler(void) { } /** * @brief This function handles Debug Monitor exception. * @param None * @retval None */ void DebugMon_Handler(void) { } /** * @brief This function handles PendSVC exception. * @param None * @retval None */ void PendSV_Handler(void) { } /** * @brief This function handles SysTick Handler. * @param None * @retval None */ void SysTick_Handler(void) { uint8_t HID_Buffer[4]; static __IO uint32_t counter = 0; HAL_IncTick(); /* check Joystick state every 10ms */ if (counter++ == 10) { GetPointerData(HID_Buffer); /* send data though IN endpoint */ if ((HID_Buffer[1] != 0) || (HID_Buffer[2] != 0)) { USBD_HID_SendReport(&USBD_Device, HID_Buffer, 4); } counter = 0; } } /******************************************************************************/ /* STM32F1xx Peripherals Interrupt Handlers */ /* Add here the Interrupt Handler for the used peripheral(s) (PPP), for the */ /* available peripheral interrupt handler's name please refer to the startup */ /* file (startup_stm32f1xx.s). */ /******************************************************************************/ /** * @brief This function handles USB Handler. * @param None * @retval None */ void USB_LP_CAN1_RX0_IRQHandler(void) { HAL_PCD_IRQHandler(&hpcd); } /** * @brief This function handles USB WakeUp interrupt request. * @param None * @retval None */ void USBWakeUp_IRQHandler(void) { __HAL_USB_WAKEUP_EXTI_CLEAR_FLAG(); } /** * @brief This function handles external lines interrupt request. * @param None * @retval None */ void EXTI9_5_IRQHandler(void) { HAL_GPIO_EXTI_IRQHandler(KEY_BUTTON_PIN); } /** * @brief Gets Pointer Data. * @param pbuf: Pointer to report * @retval None */ static void GetPointerData(uint8_t * pbuf) { int8_t x = 0, y = 0; switch (BSP_JOY_GetState()) { case JOY_LEFT: x -= CURSOR_STEP; break; case JOY_RIGHT: x += CURSOR_STEP; break; case JOY_UP: y -= CURSOR_STEP; break; case JOY_DOWN: y += CURSOR_STEP; break; default: break; } pbuf[0] = 0; pbuf[1] = x; pbuf[2] = y; pbuf[3] = 0; } /** * @} */
0
D://workCode//uploadProject\STM32CubeF1\Projects\STM3210E_EVAL\Applications\USB_Device\HID_Standalone
D://workCode//uploadProject\STM32CubeF1\Projects\STM3210E_EVAL\Applications\USB_Device\HID_Standalone\Src\system_stm32f1xx.c
/** ****************************************************************************** * @file system_stm32f1xx.c * @author MCD Application Team * @brief CMSIS Cortex-M3 Device Peripheral Access Layer System Source File. * * 1. This file provides two functions and one global variable to be called from * user application: * - SystemInit(): Setups the system clock (System clock source, PLL Multiplier * factors, AHB/APBx prescalers and Flash settings). * This function is called at startup just after reset and * before branch to main program. This call is made inside * the "startup_stm32f1xx_xx.s" file. * * - SystemCoreClock variable: Contains the core clock (HCLK), it can be used * by the user application to setup the SysTick * timer or configure other parameters. * * - SystemCoreClockUpdate(): Updates the variable SystemCoreClock and must * be called whenever the core clock is changed * during program execution. * * 2. After each device reset the HSI (8 MHz) is used as system clock source. * Then SystemInit() function is called, in "startup_stm32f1xx_xx.s" file, to * configure the system clock before to branch to main program. * * 4. The default value of HSE crystal is set to 8 MHz (or 25 MHz, depending on * the product used), refer to "HSE_VALUE". * When HSE is used as system clock source, directly or through PLL, and you * are using different crystal you have to adapt the HSE value to your own * configuration. * ****************************************************************************** * @attention * * Copyright (c) 2016 STMicroelectronics. * All rights reserved. * * This software is licensed under terms that can be found in the LICENSE file * in the root directory of this software component. * If no LICENSE file comes with this software, it is provided AS-IS. * ****************************************************************************** */ /** @addtogroup CMSIS * @{ */ /** @addtogroup stm32f1xx_system * @{ */ /** @addtogroup STM32F1xx_System_Private_Includes * @{ */ #include "stm32f1xx.h" /** * @} */ /** @addtogroup STM32F1xx_System_Private_TypesDefinitions * @{ */ /** * @} */ /** @addtogroup STM32F1xx_System_Private_Defines * @{ */ #if !defined (HSE_VALUE) #define HSE_VALUE ((uint32_t)8000000) /*!< Default value of the External oscillator in Hz. This value can be provided and adapted by the user application. */ #endif /* HSE_VALUE */ #if !defined (HSI_VALUE) #define HSI_VALUE ((uint32_t)8000000) /*!< Default value of the Internal oscillator in Hz. This value can be provided and adapted by the user application. */ #endif /* HSI_VALUE */ /*!< Uncomment the following line if you need to use external SRAM */ #if defined(STM32F100xE) || defined(STM32F101xE) || defined(STM32F101xG) || defined(STM32F103xE) || defined(STM32F103xG) /* #define DATA_IN_ExtSRAM */ #endif /* STM32F100xE || STM32F101xE || STM32F101xG || STM32F103xE || STM32F103xG */ /*!< Uncomment the following line if you need to relocate your vector Table in Internal SRAM. */ /* #define VECT_TAB_SRAM */ #define VECT_TAB_OFFSET 0x0 /*!< Vector Table base offset field. This value must be a multiple of 0x200. */ /** * @} */ /** @addtogroup STM32F1xx_System_Private_Macros * @{ */ /** * @} */ /** @addtogroup STM32F1xx_System_Private_Variables * @{ */ /* This variable is updated in three ways: 1) by calling CMSIS function SystemCoreClockUpdate() 2) by calling HAL API function HAL_RCC_GetHCLKFreq() 3) each time HAL_RCC_ClockConfig() is called to configure the system clock frequency Note: If you use this function to configure the system clock; then there is no need to call the 2 first functions listed above, since SystemCoreClock variable is updated automatically. */ uint32_t SystemCoreClock = 16000000; const uint8_t AHBPrescTable[16] = {0, 0, 0, 0, 0, 0, 0, 0, 1, 2, 3, 4, 6, 7, 8, 9}; const uint8_t APBPrescTable[8] = {0, 0, 0, 0, 1, 2, 3, 4}; /** * @} */ /** @addtogroup STM32F1xx_System_Private_FunctionPrototypes * @{ */ #if defined(STM32F100xE) || defined(STM32F101xE) || defined(STM32F101xG) || defined(STM32F103xE) || defined(STM32F103xG) #ifdef DATA_IN_ExtSRAM static void SystemInit_ExtMemCtl(void); #endif /* DATA_IN_ExtSRAM */ #endif /* STM32F100xE || STM32F101xE || STM32F101xG || STM32F103xE || STM32F103xG */ /** * @} */ /** @addtogroup STM32F1xx_System_Private_Functions * @{ */ /** * @brief Setup the microcontroller system * Initialize the Embedded Flash Interface, the PLL and update the * SystemCoreClock variable. * @note This function should be used only after reset. * @param None * @retval None */ void SystemInit (void) { /* Reset the RCC clock configuration to the default reset state(for debug purpose) */ /* Set HSION bit */ RCC->CR |= (uint32_t)0x00000001; /* Reset SW, HPRE, PPRE1, PPRE2, ADCPRE and MCO bits */ #if !defined(STM32F105xC) && !defined(STM32F107xC) RCC->CFGR &= (uint32_t)0xF8FF0000; #else RCC->CFGR &= (uint32_t)0xF0FF0000; #endif /* STM32F105xC */ /* Reset HSEON, CSSON and PLLON bits */ RCC->CR &= (uint32_t)0xFEF6FFFF; /* Reset HSEBYP bit */ RCC->CR &= (uint32_t)0xFFFBFFFF; /* Reset PLLSRC, PLLXTPRE, PLLMUL and USBPRE/OTGFSPRE bits */ RCC->CFGR &= (uint32_t)0xFF80FFFF; #if defined(STM32F105xC) || defined(STM32F107xC) /* Reset PLL2ON and PLL3ON bits */ RCC->CR &= (uint32_t)0xEBFFFFFF; /* Disable all interrupts and clear pending bits */ RCC->CIR = 0x00FF0000; /* Reset CFGR2 register */ RCC->CFGR2 = 0x00000000; #elif defined(STM32F100xB) || defined(STM32F100xE) /* Disable all interrupts and clear pending bits */ RCC->CIR = 0x009F0000; /* Reset CFGR2 register */ RCC->CFGR2 = 0x00000000; #else /* Disable all interrupts and clear pending bits */ RCC->CIR = 0x009F0000; #endif /* STM32F105xC */ #if defined(STM32F100xE) || defined(STM32F101xE) || defined(STM32F101xG) || defined(STM32F103xE) || defined(STM32F103xG) #ifdef DATA_IN_ExtSRAM SystemInit_ExtMemCtl(); #endif /* DATA_IN_ExtSRAM */ #endif #ifdef VECT_TAB_SRAM SCB->VTOR = SRAM_BASE | VECT_TAB_OFFSET; /* Vector Table Relocation in Internal SRAM. */ #else SCB->VTOR = FLASH_BASE | VECT_TAB_OFFSET; /* Vector Table Relocation in Internal FLASH. */ #endif } /** * @brief Update SystemCoreClock variable according to Clock Register Values. * The SystemCoreClock variable contains the core clock (HCLK), it can * be used by the user application to setup the SysTick timer or configure * other parameters. * * @note Each time the core clock (HCLK) changes, this function must be called * to update SystemCoreClock variable value. Otherwise, any configuration * based on this variable will be incorrect. * * @note - The system frequency computed by this function is not the real * frequency in the chip. It is calculated based on the predefined * constant and the selected clock source: * * - If SYSCLK source is HSI, SystemCoreClock will contain the HSI_VALUE(*) * * - If SYSCLK source is HSE, SystemCoreClock will contain the HSE_VALUE(**) * * - If SYSCLK source is PLL, SystemCoreClock will contain the HSE_VALUE(**) * or HSI_VALUE(*) multiplied by the PLL factors. * * (*) HSI_VALUE is a constant defined in stm32f1xx.h file (default value * 8 MHz) but the real value may vary depending on the variations * in voltage and temperature. * * (**) HSE_VALUE is a constant defined in stm32f1xx.h file (default value * 8 MHz or 25 MHz, depending on the product used), user has to ensure * that HSE_VALUE is same as the real frequency of the crystal used. * Otherwise, this function may have wrong result. * * - The result of this function could be not correct when using fractional * value for HSE crystal. * @param None * @retval None */ void SystemCoreClockUpdate (void) { uint32_t tmp = 0, pllmull = 0, pllsource = 0; #if defined(STM32F105xC) || defined(STM32F107xC) uint32_t prediv1source = 0, prediv1factor = 0, prediv2factor = 0, pll2mull = 0; #endif /* STM32F105xC */ #if defined(STM32F100xB) || defined(STM32F100xE) uint32_t prediv1factor = 0; #endif /* STM32F100xB or STM32F100xE */ /* Get SYSCLK source -------------------------------------------------------*/ tmp = RCC->CFGR & RCC_CFGR_SWS; switch (tmp) { case 0x00: /* HSI used as system clock */ SystemCoreClock = HSI_VALUE; break; case 0x04: /* HSE used as system clock */ SystemCoreClock = HSE_VALUE; break; case 0x08: /* PLL used as system clock */ /* Get PLL clock source and multiplication factor ----------------------*/ pllmull = RCC->CFGR & RCC_CFGR_PLLMULL; pllsource = RCC->CFGR & RCC_CFGR_PLLSRC; #if !defined(STM32F105xC) && !defined(STM32F107xC) pllmull = ( pllmull >> 18) + 2; if (pllsource == 0x00) { /* HSI oscillator clock divided by 2 selected as PLL clock entry */ SystemCoreClock = (HSI_VALUE >> 1) * pllmull; } else { #if defined(STM32F100xB) || defined(STM32F100xE) prediv1factor = (RCC->CFGR2 & RCC_CFGR2_PREDIV1) + 1; /* HSE oscillator clock selected as PREDIV1 clock entry */ SystemCoreClock = (HSE_VALUE / prediv1factor) * pllmull; #else /* HSE selected as PLL clock entry */ if ((RCC->CFGR & RCC_CFGR_PLLXTPRE) != (uint32_t)RESET) {/* HSE oscillator clock divided by 2 */ SystemCoreClock = (HSE_VALUE >> 1) * pllmull; } else { SystemCoreClock = HSE_VALUE * pllmull; } #endif } #else pllmull = pllmull >> 18; if (pllmull != 0x0D) { pllmull += 2; } else { /* PLL multiplication factor = PLL input clock * 6.5 */ pllmull = 13 / 2; } if (pllsource == 0x00) { /* HSI oscillator clock divided by 2 selected as PLL clock entry */ SystemCoreClock = (HSI_VALUE >> 1) * pllmull; } else {/* PREDIV1 selected as PLL clock entry */ /* Get PREDIV1 clock source and division factor */ prediv1source = RCC->CFGR2 & RCC_CFGR2_PREDIV1SRC; prediv1factor = (RCC->CFGR2 & RCC_CFGR2_PREDIV1) + 1; if (prediv1source == 0) { /* HSE oscillator clock selected as PREDIV1 clock entry */ SystemCoreClock = (HSE_VALUE / prediv1factor) * pllmull; } else {/* PLL2 clock selected as PREDIV1 clock entry */ /* Get PREDIV2 division factor and PLL2 multiplication factor */ prediv2factor = ((RCC->CFGR2 & RCC_CFGR2_PREDIV2) >> 4) + 1; pll2mull = ((RCC->CFGR2 & RCC_CFGR2_PLL2MUL) >> 8 ) + 2; SystemCoreClock = (((HSE_VALUE / prediv2factor) * pll2mull) / prediv1factor) * pllmull; } } #endif /* STM32F105xC */ break; default: SystemCoreClock = HSI_VALUE; break; } /* Compute HCLK clock frequency ----------------*/ /* Get HCLK prescaler */ tmp = AHBPrescTable[((RCC->CFGR & RCC_CFGR_HPRE) >> 4)]; /* HCLK clock frequency */ SystemCoreClock >>= tmp; } #if defined(STM32F100xE) || defined(STM32F101xE) || defined(STM32F101xG) || defined(STM32F103xE) || defined(STM32F103xG) /** * @brief Setup the external memory controller. Called in startup_stm32f1xx.s * before jump to __main * @param None * @retval None */ #ifdef DATA_IN_ExtSRAM /** * @brief Setup the external memory controller. * Called in startup_stm32f1xx_xx.s/.c before jump to main. * This function configures the external SRAM mounted on STM3210E-EVAL * board (STM32 High density devices). This SRAM will be used as program * data memory (including heap and stack). * @param None * @retval None */ void SystemInit_ExtMemCtl(void) { /*!< FSMC Bank1 NOR/SRAM3 is used for the STM3210E-EVAL, if another Bank is required, then adjust the Register Addresses */ /* Enable FSMC clock */ RCC->AHBENR = 0x00000114; /* Enable GPIOD, GPIOE, GPIOF and GPIOG clocks */ RCC->APB2ENR = 0x000001E0; /* --------------- SRAM Data lines, NOE and NWE configuration ---------------*/ /*---------------- SRAM Address lines configuration -------------------------*/ /*---------------- NOE and NWE configuration --------------------------------*/ /*---------------- NE3 configuration ----------------------------------------*/ /*---------------- NBL0, NBL1 configuration ---------------------------------*/ GPIOD->CRL = 0x44BB44BB; GPIOD->CRH = 0xBBBBBBBB; GPIOE->CRL = 0xB44444BB; GPIOE->CRH = 0xBBBBBBBB; GPIOF->CRL = 0x44BBBBBB; GPIOF->CRH = 0xBBBB4444; GPIOG->CRL = 0x44BBBBBB; GPIOG->CRH = 0x44444B44; /*---------------- FSMC Configuration ---------------------------------------*/ /*---------------- Enable FSMC Bank1_SRAM Bank ------------------------------*/ FSMC_Bank1->BTCR[4] = 0x00001011; FSMC_Bank1->BTCR[5] = 0x00000200; } #endif /* DATA_IN_ExtSRAM */ #endif /* STM32F100xE || STM32F101xE || STM32F101xG || STM32F103xE || STM32F103xG */ /** * @} */ /** * @} */ /** * @} */
0
D://workCode//uploadProject\STM32CubeF1\Projects\STM3210E_EVAL\Applications\USB_Device\HID_Standalone
D://workCode//uploadProject\STM32CubeF1\Projects\STM3210E_EVAL\Applications\USB_Device\HID_Standalone\Src\usbd_conf.c
/** ****************************************************************************** * @file USB_Device/HID_Standalone/Src/usbd_conf.c * @author MCD Application Team * @brief This file implements the USB Device library callbacks and MSP ****************************************************************************** * @attention * * Copyright (c) 2015 STMicroelectronics. * All rights reserved. * * This software is licensed under terms that can be found in the LICENSE file * in the root directory of this software component. * If no LICENSE file comes with this software, it is provided AS-IS. * ****************************************************************************** */ /* Includes ------------------------------------------------------------------ */ #include "main.h" /* Private typedef ----------------------------------------------------------- */ /* Private define ------------------------------------------------------------ */ #define USB_DISCONNECT_PORT GPIOB #define USB_DISCONNECT_PIN GPIO_PIN_14 /* Private macro ------------------------------------------------------------- */ /* Private variables --------------------------------------------------------- */ PCD_HandleTypeDef hpcd; __IO uint32_t remotewakeupon = 0; /* Private function prototypes ----------------------------------------------- */ /* Private functions --------------------------------------------------------- */ static void SystemClockConfig_STOP(void); /******************************************************************************* PCD BSP Routines *******************************************************************************/ /** * @brief Initializes the PCD MSP. * @param hpcd: PCD handle * @retval None */ void HAL_PCD_MspInit(PCD_HandleTypeDef * hpcd) { GPIO_InitTypeDef GPIO_InitStruct; /* Enable the GPIOA clock */ __HAL_RCC_GPIOA_CLK_ENABLE(); /* Configure USB DM/DP pins */ GPIO_InitStruct.Pin = (GPIO_PIN_11 | GPIO_PIN_12); GPIO_InitStruct.Mode = GPIO_MODE_AF_INPUT; GPIO_InitStruct.Pull = GPIO_PULLUP; GPIO_InitStruct.Speed = GPIO_SPEED_FREQ_HIGH; HAL_GPIO_Init(GPIOA, &GPIO_InitStruct); /* Enable the USB disconnect GPIO clock */ __HAL_RCC_GPIOB_CLK_ENABLE(); /* USB_DISCONNECT used as USB pull-up */ GPIO_InitStruct.Pin = USB_DISCONNECT_PIN; GPIO_InitStruct.Mode = GPIO_MODE_OUTPUT_OD; HAL_GPIO_Init(USB_DISCONNECT_PORT, &GPIO_InitStruct); /* Enable USB Clock */ __HAL_RCC_USB_CLK_ENABLE(); if (hpcd->Init.low_power_enable == 1) { /* Enable EXTI for USB wakeup */ __HAL_USB_WAKEUP_EXTI_CLEAR_FLAG(); __HAL_USB_WAKEUP_EXTI_ENABLE_RISING_EDGE(); __HAL_USB_WAKEUP_EXTI_ENABLE_IT(); /* USB Wakeup Interrupt */ HAL_NVIC_EnableIRQ(USBWakeUp_IRQn); /* Enable USB Wake-up interrupt */ HAL_NVIC_SetPriority(USBWakeUp_IRQn, 0, 0); } /* Set USB Interrupt priority */ HAL_NVIC_SetPriority(USB_LP_CAN1_RX0_IRQn, 5, 0); /* Enable USB Interrupt */ HAL_NVIC_EnableIRQ(USB_LP_CAN1_RX0_IRQn); } /** * @brief De-Initializes the PCD MSP. * @param hpcd: PCD handle * @retval None */ void HAL_PCD_MspDeInit(PCD_HandleTypeDef * hpcd) { /* Disable USB FS Clock */ __HAL_RCC_USB_CLK_DISABLE(); } /******************************************************************************* LL Driver Callbacks (PCD -> USB Device Library) *******************************************************************************/ /** * @brief SetupStage callback. * @param hpcd: PCD handle * @retval None */ void HAL_PCD_SetupStageCallback(PCD_HandleTypeDef * hpcd) { USBD_LL_SetupStage((USBD_HandleTypeDef *) hpcd->pData, (uint8_t *) hpcd->Setup); } /** * @brief DataOut Stage callback. * @param hpcd: PCD handle * @param epnum: Endpoint Number * @retval None */ void HAL_PCD_DataOutStageCallback(PCD_HandleTypeDef * hpcd, uint8_t epnum) { USBD_LL_DataOutStage((USBD_HandleTypeDef *) hpcd->pData, epnum, hpcd->OUT_ep[epnum].xfer_buff); } /** * @brief DataIn Stage callback. * @param hpcd: PCD handle * @param epnum: Endpoint Number * @retval None */ void HAL_PCD_DataInStageCallback(PCD_HandleTypeDef * hpcd, uint8_t epnum) { USBD_LL_DataInStage((USBD_HandleTypeDef *) hpcd->pData, epnum, hpcd->IN_ep[epnum].xfer_buff); } /** * @brief SOF callback. * @param hpcd: PCD handle * @retval None */ void HAL_PCD_SOFCallback(PCD_HandleTypeDef * hpcd) { USBD_LL_SOF((USBD_HandleTypeDef *) hpcd->pData); } /** * @brief Reset callback. * @param hpcd: PCD handle * @retval None */ void HAL_PCD_ResetCallback(PCD_HandleTypeDef * hpcd) { USBD_LL_SetSpeed((USBD_HandleTypeDef *) hpcd->pData, USBD_SPEED_FULL); /* Reset Device */ USBD_LL_Reset((USBD_HandleTypeDef *) hpcd->pData); } /** * @brief Suspend callback. * @param hpcd: PCD handle * @retval None */ void HAL_PCD_SuspendCallback(PCD_HandleTypeDef * hpcd) { /* Inform USB library that core enters in suspend Mode */ USBD_LL_Suspend((USBD_HandleTypeDef *) hpcd->pData); /* Enter in STOP mode */ if (hpcd->Init.low_power_enable) { /* Set SLEEPDEEP bit and SleepOnExit of Cortex System Control Register */ SCB->SCR |= (uint32_t) ((uint32_t) (SCB_SCR_SLEEPDEEP_Msk | SCB_SCR_SLEEPONEXIT_Msk)); } USBD_LL_Delay(50); } /** * @brief Resume callback. * @param hpcd: PCD handle * @retval None */ void HAL_PCD_ResumeCallback(PCD_HandleTypeDef * hpcd) { if ((hpcd->Init.low_power_enable) && (remotewakeupon == 0)) { SystemClockConfig_STOP(); /* Reset SLEEPDEEP bit of Cortex System Control Register */ SCB->SCR &= (uint32_t) ~ ((uint32_t) (SCB_SCR_SLEEPDEEP_Msk | SCB_SCR_SLEEPONEXIT_Msk)); } USBD_LL_Resume((USBD_HandleTypeDef *) hpcd->pData); remotewakeupon = 0; } /** * @brief ISOOUTIncomplete callback. * @param hpcd: PCD handle * @param epnum: Endpoint Number * @retval None */ void HAL_PCD_ISOOUTIncompleteCallback(PCD_HandleTypeDef * hpcd, uint8_t epnum) { USBD_LL_IsoOUTIncomplete((USBD_HandleTypeDef *) hpcd->pData, epnum); } /** * @brief ISOINIncomplete callback. * @param hpcd: PCD handle * @param epnum: Endpoint Number * @retval None */ void HAL_PCD_ISOINIncompleteCallback(PCD_HandleTypeDef * hpcd, uint8_t epnum) { USBD_LL_IsoINIncomplete((USBD_HandleTypeDef *) hpcd->pData, epnum); } /** * @brief ConnectCallback callback. * @param hpcd: PCD handle * @retval None */ void HAL_PCD_ConnectCallback(PCD_HandleTypeDef * hpcd) { USBD_LL_DevConnected((USBD_HandleTypeDef *) hpcd->pData); } /** * @brief Disconnect callback. * @param hpcd: PCD handle * @retval None */ void HAL_PCD_DisconnectCallback(PCD_HandleTypeDef * hpcd) { USBD_LL_DevDisconnected((USBD_HandleTypeDef *) hpcd->pData); } /******************************************************************************* LL Driver Interface (USB Device Library --> PCD) *******************************************************************************/ /** * @brief Initializes the Low Level portion of the Device driver. * @param pdev: Device handle * @retval USBD Status */ USBD_StatusTypeDef USBD_LL_Init(USBD_HandleTypeDef * pdev) { /* Set LL Driver parameters */ hpcd.Instance = USB; hpcd.Init.dev_endpoints = 8; hpcd.Init.phy_itface = PCD_PHY_EMBEDDED; hpcd.Init.speed = PCD_SPEED_FULL; hpcd.Init.low_power_enable = 0; /* Link The driver to the stack */ hpcd.pData = pdev; pdev->pData = &hpcd; /* Initialize LL Driver */ HAL_PCD_Init((PCD_HandleTypeDef *) pdev->pData); HAL_PCDEx_PMAConfig((PCD_HandleTypeDef *) pdev->pData, 0x00, PCD_SNG_BUF, 0x18); HAL_PCDEx_PMAConfig((PCD_HandleTypeDef *) pdev->pData, 0x80, PCD_SNG_BUF, 0x58); HAL_PCDEx_PMAConfig((PCD_HandleTypeDef *) pdev->pData, 0x81, PCD_SNG_BUF, 0x100); return USBD_OK; } /** * @brief De-Initializes the Low Level portion of the Device driver. * @param pdev: Device handle * @retval USBD Status */ USBD_StatusTypeDef USBD_LL_DeInit(USBD_HandleTypeDef * pdev) { HAL_PCD_DeInit((PCD_HandleTypeDef *) pdev->pData); return USBD_OK; } /** * @brief Starts the Low Level portion of the Device driver. * @param pdev: Device handle * @retval USBD Status */ USBD_StatusTypeDef USBD_LL_Start(USBD_HandleTypeDef * pdev) { HAL_PCD_Start((PCD_HandleTypeDef *) pdev->pData); return USBD_OK; } /** * @brief Stops the Low Level portion of the Device driver. * @param pdev: Device handle * @retval USBD Status */ USBD_StatusTypeDef USBD_LL_Stop(USBD_HandleTypeDef * pdev) { HAL_PCD_Stop((PCD_HandleTypeDef *) pdev->pData); return USBD_OK; } /** * @brief Opens an endpoint of the Low Level Driver. * @param pdev: Device handle * @param ep_addr: Endpoint Number * @param ep_type: Endpoint Type * @param ep_mps: Endpoint Max Packet Size * @retval USBD Status */ USBD_StatusTypeDef USBD_LL_OpenEP(USBD_HandleTypeDef * pdev, uint8_t ep_addr, uint8_t ep_type, uint16_t ep_mps) { HAL_PCD_EP_Open((PCD_HandleTypeDef *) pdev->pData, ep_addr, ep_mps, ep_type); return USBD_OK; } /** * @brief Closes an endpoint of the Low Level Driver. * @param pdev: Device handle * @param ep_addr: Endpoint Number * @retval USBD Status */ USBD_StatusTypeDef USBD_LL_CloseEP(USBD_HandleTypeDef * pdev, uint8_t ep_addr) { HAL_PCD_EP_Close((PCD_HandleTypeDef *) pdev->pData, ep_addr); return USBD_OK; } /** * @brief Flushes an endpoint of the Low Level Driver. * @param pdev: Device handle * @param ep_addr: Endpoint Number * @retval USBD Status */ USBD_StatusTypeDef USBD_LL_FlushEP(USBD_HandleTypeDef * pdev, uint8_t ep_addr) { HAL_PCD_EP_Flush((PCD_HandleTypeDef *) pdev->pData, ep_addr); return USBD_OK; } /** * @brief Sets a Stall condition on an endpoint of the Low Level Driver. * @param pdev: Device handle * @param ep_addr: Endpoint Number * @retval USBD Status */ USBD_StatusTypeDef USBD_LL_StallEP(USBD_HandleTypeDef * pdev, uint8_t ep_addr) { HAL_PCD_EP_SetStall((PCD_HandleTypeDef *) pdev->pData, ep_addr); return USBD_OK; } /** * @brief Clears a Stall condition on an endpoint of the Low Level Driver. * @param pdev: Device handle * @param ep_addr: Endpoint Number * @retval USBD Status */ USBD_StatusTypeDef USBD_LL_ClearStallEP(USBD_HandleTypeDef * pdev, uint8_t ep_addr) { HAL_PCD_EP_ClrStall((PCD_HandleTypeDef *) pdev->pData, ep_addr); return USBD_OK; } /** * @brief Returns Stall condition. * @param pdev: Device handle * @param ep_addr: Endpoint Number * @retval Stall (1: Yes, 0: No) */ uint8_t USBD_LL_IsStallEP(USBD_HandleTypeDef * pdev, uint8_t ep_addr) { PCD_HandleTypeDef *hpcd = (PCD_HandleTypeDef *) pdev->pData; if ((ep_addr & 0x80) == 0x80) { return hpcd->IN_ep[ep_addr & 0x7F].is_stall; } else { return hpcd->OUT_ep[ep_addr & 0x7F].is_stall; } } /** * @brief Assigns a USB address to the device. * @param pdev: Device handle * @param ep_addr: Endpoint Number * @retval USBD Status */ USBD_StatusTypeDef USBD_LL_SetUSBAddress(USBD_HandleTypeDef * pdev, uint8_t dev_addr) { HAL_PCD_SetAddress((PCD_HandleTypeDef *) pdev->pData, dev_addr); return USBD_OK; } /** * @brief Transmits data over an endpoint. * @param pdev: Device handle * @param ep_addr: Endpoint Number * @param pbuf: Pointer to data to be sent * @param size: Data size * @retval USBD Status */ USBD_StatusTypeDef USBD_LL_Transmit(USBD_HandleTypeDef * pdev, uint8_t ep_addr, uint8_t * pbuf, uint16_t size) { HAL_PCD_EP_Transmit((PCD_HandleTypeDef *) pdev->pData, ep_addr, pbuf, size); return USBD_OK; } /** * @brief Prepares an endpoint for reception. * @param pdev: Device handle * @param ep_addr: Endpoint Number * @param pbuf: Pointer to data to be received * @param size: Data size * @retval USBD Status */ USBD_StatusTypeDef USBD_LL_PrepareReceive(USBD_HandleTypeDef * pdev, uint8_t ep_addr, uint8_t * pbuf, uint16_t size) { HAL_PCD_EP_Receive((PCD_HandleTypeDef *) pdev->pData, ep_addr, pbuf, size); return USBD_OK; } /** * @brief Returns the last transferred packet size. * @param pdev: Device handle * @param ep_addr: Endpoint Number * @retval Received Data Size */ uint32_t USBD_LL_GetRxDataSize(USBD_HandleTypeDef * pdev, uint8_t ep_addr) { return HAL_PCD_EP_GetRxCount((PCD_HandleTypeDef *) pdev->pData, ep_addr); } /** * @brief Delays routine for the USB Device Library. * @param Delay: Delay in ms * @retval None */ void USBD_LL_Delay(uint32_t Delay) { HAL_Delay(Delay); } /** * @brief static single allocation. * @param size: size of allocated memory * @retval None */ void *USBD_static_malloc(uint32_t size) { static uint32_t mem[MAX_STATIC_ALLOC_SIZE]; return mem; } /** * @brief Dummy memory free * @param *p pointer to allocated memory address * @retval None */ void USBD_static_free(void *p) { } /** * @brief Software Device Connection * @param hpcd: PCD handle * @param state: connection state (0 : disconnected / 1: connected) * @retval None */ void HAL_PCDEx_SetConnectionState(PCD_HandleTypeDef * hpcd, uint8_t state) { if (state != 0) { /* Enabling DP Pull-Down bit to Connect internal pull-up on USB DP line */ HAL_GPIO_WritePin(GPIOB, GPIO_PIN_14, GPIO_PIN_RESET); } else { /* Disable DP Pull-Down bit */ HAL_GPIO_WritePin(GPIOB, GPIO_PIN_14, GPIO_PIN_SET); } } /** * @brief Configures system clock after wakeup from STOP mode. * @param None * @retval None */ static void SystemClockConfig_STOP(void) { RCC_ClkInitTypeDef clkinitstruct = { 0 }; RCC_OscInitTypeDef oscinitstruct = { 0 }; /* Enable HSE Oscillator and activate PLL with HSE as source */ oscinitstruct.OscillatorType = RCC_OSCILLATORTYPE_HSE; oscinitstruct.HSEState = RCC_HSE_ON; oscinitstruct.HSEPredivValue = RCC_HSE_PREDIV_DIV1; oscinitstruct.PLL.PLLMUL = RCC_PLL_MUL9; oscinitstruct.PLL.PLLState = RCC_PLL_ON; oscinitstruct.PLL.PLLSource = RCC_PLLSOURCE_HSE; HAL_RCC_OscConfig(&oscinitstruct); /* Select PLL as system clock source and configure the HCLK, PCLK1 and PCLK2 * clocks dividers */ clkinitstruct.ClockType = (RCC_CLOCKTYPE_SYSCLK | RCC_CLOCKTYPE_HCLK | RCC_CLOCKTYPE_PCLK1 | RCC_CLOCKTYPE_PCLK2); clkinitstruct.SYSCLKSource = RCC_SYSCLKSOURCE_PLLCLK; clkinitstruct.AHBCLKDivider = RCC_SYSCLK_DIV1; clkinitstruct.APB1CLKDivider = RCC_HCLK_DIV2; clkinitstruct.APB2CLKDivider = RCC_HCLK_DIV1; HAL_RCC_ClockConfig(&clkinitstruct, FLASH_LATENCY_2); } /** * @brief GPIO EXTI Callback function * Handle remote-wakeup through key button * @param GPIO_Pin * @retval None */ void HAL_GPIO_EXTI_Callback(uint16_t GPIO_Pin) { if (GPIO_Pin == KEY_BUTTON_PIN) { if ((((USBD_HandleTypeDef *) hpcd.pData)->dev_remote_wakeup == 1) && (((USBD_HandleTypeDef *) hpcd.pData)->dev_state == USBD_STATE_SUSPENDED)) { if ((&hpcd)->Init.low_power_enable) { /* Reset SLEEPDEEP bit of Cortex System Control Register */ SCB->SCR &= (uint32_t) ~ ((uint32_t) (SCB_SCR_SLEEPDEEP_Msk | SCB_SCR_SLEEPONEXIT_Msk)); SystemClockConfig_STOP(); } /* Activate Remote wakeup */ HAL_PCD_ActivateRemoteWakeup((&hpcd)); /* remote wakeup delay */ HAL_Delay(10); /* Disable Remote wakeup */ HAL_PCD_DeActivateRemoteWakeup((&hpcd)); /* change remote_wakeup feature to 0 */ ((USBD_HandleTypeDef *) hpcd.pData)->dev_remote_wakeup = 0; remotewakeupon = 1; } } }
0
D://workCode//uploadProject\STM32CubeF1\Projects\STM3210E_EVAL\Applications\USB_Device\HID_Standalone
D://workCode//uploadProject\STM32CubeF1\Projects\STM3210E_EVAL\Applications\USB_Device\HID_Standalone\Src\usbd_desc.c
/** ****************************************************************************** * @file USB_Device/HID_Standalone/Src/usbd_desc.c * @author MCD Application Team * @brief This file provides the USBD descriptors and string formatting method. ****************************************************************************** * @attention * * Copyright (c) 2015 STMicroelectronics. * All rights reserved. * * This software is licensed under terms that can be found in the LICENSE file * in the root directory of this software component. * If no LICENSE file comes with this software, it is provided AS-IS. * ****************************************************************************** */ /* Includes ------------------------------------------------------------------ */ #include "usbd_core.h" #include "usbd_desc.h" #include "usbd_conf.h" /* Private typedef ----------------------------------------------------------- */ /* Private define ------------------------------------------------------------ */ #define USBD_VID 0x0483 #define USBD_PID 0x5710 #define USBD_LANGID_STRING 0x409 #define USBD_MANUFACTURER_STRING "STMicroelectronics" #define USBD_PRODUCT_FS_STRING "HID Joystick in FS Mode" #define USBD_CONFIGURATION_FS_STRING "HID Config" #define USBD_INTERFACE_FS_STRING "HID Interface" /* Private macro ------------------------------------------------------------- */ /* Private function prototypes ----------------------------------------------- */ uint8_t *USBD_HID_DeviceDescriptor(USBD_SpeedTypeDef speed, uint16_t * length); uint8_t *USBD_HID_LangIDStrDescriptor(USBD_SpeedTypeDef speed, uint16_t * length); uint8_t *USBD_HID_ManufacturerStrDescriptor(USBD_SpeedTypeDef speed, uint16_t * length); uint8_t *USBD_HID_ProductStrDescriptor(USBD_SpeedTypeDef speed, uint16_t * length); uint8_t *USBD_HID_SerialStrDescriptor(USBD_SpeedTypeDef speed, uint16_t * length); uint8_t *USBD_HID_ConfigStrDescriptor(USBD_SpeedTypeDef speed, uint16_t * length); uint8_t *USBD_HID_InterfaceStrDescriptor(USBD_SpeedTypeDef speed, uint16_t * length); /* Private variables --------------------------------------------------------- */ USBD_DescriptorsTypeDef HID_Desc = { USBD_HID_DeviceDescriptor, USBD_HID_LangIDStrDescriptor, USBD_HID_ManufacturerStrDescriptor, USBD_HID_ProductStrDescriptor, USBD_HID_SerialStrDescriptor, USBD_HID_ConfigStrDescriptor, USBD_HID_InterfaceStrDescriptor, }; /* USB Standard Device Descriptor */ #if defined ( __ICCARM__ ) /*!< IAR Compiler */ #pragma data_alignment=4 #endif __ALIGN_BEGIN uint8_t USBD_DeviceDesc[USB_LEN_DEV_DESC] __ALIGN_END = { 0x12, /* bLength */ USB_DESC_TYPE_DEVICE, /* bDescriptorType */ 0x00, /* bcdUSB */ 0x02, 0x00, /* bDeviceClass */ 0x00, /* bDeviceSubClass */ 0x00, /* bDeviceProtocol */ USB_MAX_EP0_SIZE, /* bMaxPacketSize */ LOBYTE(USBD_VID), /* idVendor */ HIBYTE(USBD_VID), /* idVendor */ LOBYTE(USBD_PID), /* idVendor */ HIBYTE(USBD_PID), /* idVendor */ 0x00, /* bcdDevice rel. 2.00 */ 0x02, USBD_IDX_MFC_STR, /* Index of manufacturer string */ USBD_IDX_PRODUCT_STR, /* Index of product string */ USBD_IDX_SERIAL_STR, /* Index of serial number string */ USBD_MAX_NUM_CONFIGURATION /* bNumConfigurations */ }; /* USB_DeviceDescriptor */ /* USB Standard Device Descriptor */ #if defined ( __ICCARM__ ) /*!< IAR Compiler */ #pragma data_alignment=4 #endif __ALIGN_BEGIN uint8_t USBD_LangIDDesc[USB_LEN_LANGID_STR_DESC] __ALIGN_END = { USB_LEN_LANGID_STR_DESC, USB_DESC_TYPE_STRING, LOBYTE(USBD_LANGID_STRING), HIBYTE(USBD_LANGID_STRING), }; #if defined ( __ICCARM__ ) /*!< IAR Compiler */ #pragma data_alignment=4 #endif __ALIGN_BEGIN uint8_t USBD_StringSerial[USB_SIZ_STRING_SERIAL] __ALIGN_END = { USB_SIZ_STRING_SERIAL, USB_DESC_TYPE_STRING, }; #if defined ( __ICCARM__ ) /*!< IAR Compiler */ #pragma data_alignment=4 #endif __ALIGN_BEGIN uint8_t USBD_StrDesc[USBD_MAX_STR_DESC_SIZ] __ALIGN_END; /* Private functions --------------------------------------------------------- */ static void IntToUnicode(uint32_t value, uint8_t *pbuf, uint8_t len); static void Get_SerialNum(void); /** * @brief Returns the device descriptor. * @param speed: Current device speed * @param length: Pointer to data length variable * @retval Pointer to descriptor buffer */ uint8_t *USBD_HID_DeviceDescriptor(USBD_SpeedTypeDef speed, uint16_t * length) { *length = sizeof(USBD_DeviceDesc); return (uint8_t *) USBD_DeviceDesc; } /** * @brief Returns the LangID string descriptor. * @param speed: Current device speed * @param length: Pointer to data length variable * @retval Pointer to descriptor buffer */ uint8_t *USBD_HID_LangIDStrDescriptor(USBD_SpeedTypeDef speed, uint16_t * length) { *length = sizeof(USBD_LangIDDesc); return (uint8_t *) USBD_LangIDDesc; } /** * @brief Returns the product string descriptor. * @param speed: Current device speed * @param length: Pointer to data length variable * @retval Pointer to descriptor buffer */ uint8_t *USBD_HID_ProductStrDescriptor(USBD_SpeedTypeDef speed, uint16_t * length) { USBD_GetString((uint8_t *) USBD_PRODUCT_FS_STRING, USBD_StrDesc, length); return USBD_StrDesc; } /** * @brief Returns the manufacturer string descriptor. * @param speed: Current device speed * @param length: Pointer to data length variable * @retval Pointer to descriptor buffer */ uint8_t *USBD_HID_ManufacturerStrDescriptor(USBD_SpeedTypeDef speed, uint16_t * length) { USBD_GetString((uint8_t *) USBD_MANUFACTURER_STRING, USBD_StrDesc, length); return USBD_StrDesc; } /** * @brief Returns the serial number string descriptor. * @param speed: Current device speed * @param length: Pointer to data length variable * @retval Pointer to descriptor buffer */ uint8_t *USBD_HID_SerialStrDescriptor(USBD_SpeedTypeDef speed, uint16_t * length) { *length = USB_SIZ_STRING_SERIAL; /* Update the serial number string descriptor with the data from the unique * ID */ Get_SerialNum(); return USBD_StringSerial; } /** * @brief Returns the configuration string descriptor. * @param speed: Current device speed * @param length: Pointer to data length variable * @retval Pointer to descriptor buffer */ uint8_t *USBD_HID_ConfigStrDescriptor(USBD_SpeedTypeDef speed, uint16_t * length) { USBD_GetString((uint8_t *) USBD_CONFIGURATION_FS_STRING, USBD_StrDesc, length); return USBD_StrDesc; } /** * @brief Returns the interface string descriptor. * @param speed: Current device speed * @param length: Pointer to data length variable * @retval Pointer to descriptor buffer */ uint8_t *USBD_HID_InterfaceStrDescriptor(USBD_SpeedTypeDef speed, uint16_t * length) { USBD_GetString((uint8_t *) USBD_INTERFACE_FS_STRING, USBD_StrDesc, length); return USBD_StrDesc; } /** * @brief Create the serial number string descriptor * @param None * @retval None */ static void Get_SerialNum(void) { uint32_t deviceserial0, deviceserial1, deviceserial2; deviceserial0 = *(uint32_t *) DEVICE_ID1; deviceserial1 = *(uint32_t *) DEVICE_ID2; deviceserial2 = *(uint32_t *) DEVICE_ID3; deviceserial0 += deviceserial2; if (deviceserial0 != 0) { IntToUnicode(deviceserial0, &USBD_StringSerial[2], 8); IntToUnicode(deviceserial1, &USBD_StringSerial[18], 4); } } /** * @brief Convert Hex 32Bits value into char * @param value: value to convert * @param pbuf: pointer to the buffer * @param len: buffer length * @retval None */ static void IntToUnicode(uint32_t value, uint8_t * pbuf, uint8_t len) { uint8_t idx = 0; for (idx = 0; idx < len; idx++) { if (((value >> 28)) < 0xA) { pbuf[2 * idx] = (value >> 28) + '0'; } else { pbuf[2 * idx] = (value >> 28) + 'A' - 10; } value = value << 4; pbuf[2 * idx + 1] = 0; } }
0
D://workCode//uploadProject\STM32CubeF1\Projects\STM3210E_EVAL\Applications\USB_Device\MSC_Standalone
D://workCode//uploadProject\STM32CubeF1\Projects\STM3210E_EVAL\Applications\USB_Device\MSC_Standalone\Inc\main.h
/** ****************************************************************************** * @file USB_Device/MSC_Standalone/Inc/main.h * @author MCD Application Team * @brief Header for main.c module ****************************************************************************** * @attention * * Copyright (c) 2016 STMicroelectronics. * All rights reserved. * * This software is licensed under terms that can be found in the LICENSE file * in the root directory of this software component. * If no LICENSE file comes with this software, it is provided AS-IS. * ****************************************************************************** */ /* Define to prevent recursive inclusion -------------------------------------*/ #ifndef __MAIN_H #define __MAIN_H /* Includes ------------------------------------------------------------------*/ #include "stm32f1xx_hal.h" #include "stm3210e_eval.h" #include "stm3210e_eval_sd.h" #include "usbd_core.h" #include "stm32f1xx_hal_pcd.h" #include "usbd_desc.h" #include "usbd_msc.h" #include "usbd_storage.h" /* Exported types ------------------------------------------------------------*/ /* Exported constants --------------------------------------------------------*/ /* Exported macro ------------------------------------------------------------*/ /* Exported functions ------------------------------------------------------- */ void Toggle_Leds(void); #endif /* __MAIN_H */
0
D://workCode//uploadProject\STM32CubeF1\Projects\STM3210E_EVAL\Applications\USB_Device\MSC_Standalone
D://workCode//uploadProject\STM32CubeF1\Projects\STM3210E_EVAL\Applications\USB_Device\MSC_Standalone\Inc\stm32f1xx_hal_conf.h
/** ****************************************************************************** * @file USB_Device/MSC_Standalone/Inc/stm32f1xx_hal_conf.h * @author MCD Application Team * @brief HAL configuration template file. * This file should be copied to the application folder and renamed * to stm32f1xx_hal_conf.h. ****************************************************************************** * @attention * * Copyright (c) 2016 STMicroelectronics. * All rights reserved. * * This software is licensed under terms that can be found in the LICENSE file * in the root directory of this software component. * If no LICENSE file comes with this software, it is provided AS-IS. * ****************************************************************************** */ /* Define to prevent recursive inclusion -------------------------------------*/ #ifndef __STM32F1xx_HAL_CONF_H #define __STM32F1xx_HAL_CONF_H #ifdef __cplusplus extern "C" { #endif /* Exported types ------------------------------------------------------------*/ /* Exported constants --------------------------------------------------------*/ /* ########################## Module Selection ############################## */ /** * @brief This is the list of modules to be used in the HAL driver */ #define HAL_MODULE_ENABLED /* #define HAL_ADC_MODULE_ENABLED */ /* #define HAL_CAN_MODULE_ENABLED */ /* #define HAL_CAN_LEGACY_MODULE_ENABLED */ #define HAL_CORTEX_MODULE_ENABLED */ /* #define HAL_CRC_MODULE_ENABLED */ /* #define HAL_DAC_MODULE_ENABLED */ #define HAL_DMA_MODULE_ENABLED #define HAL_EXTI_MODULE_ENABLED #define HAL_FLASH_MODULE_ENABLED #define HAL_GPIO_MODULE_ENABLED /* #define HAL_I2C_MODULE_ENABLED */ /* #define HAL_I2S_MODULE_ENABLED */ /* #define HAL_IRDA_MODULE_ENABLED */ /* #define HAL_IWDG_MODULE_ENABLED */ /* #define HAL_NOR_MODULE_ENABLED */ /* #define HAL_PCCARD_MODULE_ENABLED */ #define HAL_PCD_MODULE_ENABLED #define HAL_PWR_MODULE_ENABLED #define HAL_RCC_MODULE_ENABLED /* #define HAL_RTC_MODULE_ENABLED */ #define HAL_SD_MODULE_ENABLED /* #define HAL_SDRAM_MODULE_ENABLED */ /* #define HAL_SMARTCARD_MODULE_ENABLED */ /* #define HAL_SPI_MODULE_ENABLED */ /* #define HAL_SRAM_MODULE_ENABLED */ /* #define HAL_TIM_MODULE_ENABLED */ #define HAL_UART_MODULE_ENABLED /* #define HAL_USART_MODULE_ENABLED */ /* #define HAL_WWDG_MODULE_ENABLED */ /* #define HAL_MMC_MODULE_ENABLED */ /* ########################## Oscillator Values adaptation ####################*/ /** * @brief Adjust the value of External High Speed oscillator (HSE) used in your application. * This value is used by the RCC HAL module to compute the system frequency * (when HSE is used as system clock source, directly or through the PLL). */ #if !defined (HSE_VALUE) #if defined(USE_STM3210C_EVAL) #define HSE_VALUE 25000000U /*!< Value of the External oscillator in Hz */ #else #define HSE_VALUE 8000000U /*!< Value of the External oscillator in Hz */ #endif #endif /* HSE_VALUE */ #if !defined (HSE_STARTUP_TIMEOUT) #define HSE_STARTUP_TIMEOUT 100U /*!< Time out for HSE start up, in ms */ #endif /* HSE_STARTUP_TIMEOUT */ /** * @brief Internal High Speed oscillator (HSI) value. * This value is used by the RCC HAL module to compute the system frequency * (when HSI is used as system clock source, directly or through the PLL). */ #if !defined (HSI_VALUE) #define HSI_VALUE 8000000U /*!< Value of the Internal oscillator in Hz */ #endif /* HSI_VALUE */ /** * @brief Internal Low Speed oscillator (LSI) value. */ #if !defined (LSI_VALUE) #define LSI_VALUE 40000U /*!< LSI Typical Value in Hz */ #endif /* LSI_VALUE */ /*!< Value of the Internal Low Speed oscillator in Hz The real value may vary depending on the variations in voltage and temperature. */ /** * @brief External Low Speed oscillator (LSE) value. * This value is used by the UART, RTC HAL module to compute the system frequency */ #if !defined (LSE_VALUE) #define LSE_VALUE 32768U /*!< Value of the External oscillator in Hz*/ #endif /* LSE_VALUE */ #if !defined (LSE_STARTUP_TIMEOUT) #define LSE_STARTUP_TIMEOUT 5000U /*!< Time out for LSE start up, in ms */ #endif /* LSE_STARTUP_TIMEOUT */ /* Tip: To avoid modifying this file each time you need to use different HSE, === you can define the HSE value in your toolchain compiler preprocessor. */ /* ########################### System Configuration ######################### */ /** * @brief This is the HAL system configuration section */ #define VDD_VALUE 3300U /*!< Value of VDD in mv */ #define TICK_INT_PRIORITY 0x00U /*!< tick interrupt priority */ #define USE_RTOS 0U #define PREFETCH_ENABLE 1U #define USE_HAL_ADC_REGISTER_CALLBACKS 0U /* ADC register callback disabled */ #define USE_HAL_CAN_REGISTER_CALLBACKS 0U /* CAN register callback disabled */ #define USE_HAL_CEC_REGISTER_CALLBACKS 0U /* CEC register callback disabled */ #define USE_HAL_DAC_REGISTER_CALLBACKS 0U /* DAC register callback disabled */ #define USE_HAL_ETH_REGISTER_CALLBACKS 0U /* ETH register callback disabled */ #define USE_HAL_HCD_REGISTER_CALLBACKS 0U /* HCD register callback disabled */ #define USE_HAL_I2C_REGISTER_CALLBACKS 0U /* I2C register callback disabled */ #define USE_HAL_I2S_REGISTER_CALLBACKS 0U /* I2S register callback disabled */ #define USE_HAL_MMC_REGISTER_CALLBACKS 0U /* MMC register callback disabled */ #define USE_HAL_NAND_REGISTER_CALLBACKS 0U /* NAND register callback disabled */ #define USE_HAL_NOR_REGISTER_CALLBACKS 0U /* NOR register callback disabled */ #define USE_HAL_PCCARD_REGISTER_CALLBACKS 0U /* PCCARD register callback disabled */ #define USE_HAL_PCD_REGISTER_CALLBACKS 0U /* PCD register callback disabled */ #define USE_HAL_RTC_REGISTER_CALLBACKS 0U /* RTC register callback disabled */ #define USE_HAL_SD_REGISTER_CALLBACKS 0U /* SD register callback disabled */ #define USE_HAL_SMARTCARD_REGISTER_CALLBACKS 0U /* SMARTCARD register callback disabled */ #define USE_HAL_IRDA_REGISTER_CALLBACKS 0U /* IRDA register callback disabled */ #define USE_HAL_SRAM_REGISTER_CALLBACKS 0U /* SRAM register callback disabled */ #define USE_HAL_SPI_REGISTER_CALLBACKS 0U /* SPI register callback disabled */ #define USE_HAL_TIM_REGISTER_CALLBACKS 0U /* TIM register callback disabled */ #define USE_HAL_UART_REGISTER_CALLBACKS 0U /* UART register callback disabled */ #define USE_HAL_USART_REGISTER_CALLBACKS 0U /* USART register callback disabled */ #define USE_HAL_WWDG_REGISTER_CALLBACKS 0U /* WWDG register callback disabled */ /* ########################## Assert Selection ############################## */ /** * @brief Uncomment the line below to expanse the "assert_param" macro in the * HAL drivers code */ /* #define USE_FULL_ASSERT 1U */ /* ################## Ethernet peripheral configuration ##################### */ /* Section 1 : Ethernet peripheral configuration */ /* MAC ADDRESS: MAC_ADDR0:MAC_ADDR1:MAC_ADDR2:MAC_ADDR3:MAC_ADDR4:MAC_ADDR5 */ #define MAC_ADDR0 2U #define MAC_ADDR1 0U #define MAC_ADDR2 0U #define MAC_ADDR3 0U #define MAC_ADDR4 0U #define MAC_ADDR5 0U /* Definition of the Ethernet driver buffers size and count */ #define ETH_RX_BUF_SIZE ETH_MAX_PACKET_SIZE /* buffer size for receive */ #define ETH_TX_BUF_SIZE ETH_MAX_PACKET_SIZE /* buffer size for transmit */ #define ETH_RXBUFNB 8U /* 8 Rx buffers of size ETH_RX_BUF_SIZE */ #define ETH_TXBUFNB 4U /* 4 Tx buffers of size ETH_TX_BUF_SIZE */ /* Section 2: PHY configuration section */ /* DP83848 PHY Address*/ #define DP83848_PHY_ADDRESS 0x01U /* PHY Reset delay these values are based on a 1 ms Systick interrupt*/ #define PHY_RESET_DELAY 0x000000FFU /* PHY Configuration delay */ #define PHY_CONFIG_DELAY 0x00000FFFU #define PHY_READ_TO 0x0000FFFFU #define PHY_WRITE_TO 0x0000FFFFU /* Section 3: Common PHY Registers */ #define PHY_BCR ((uint16_t)0x0000) /*!< Transceiver Basic Control Register */ #define PHY_BSR ((uint16_t)0x0001) /*!< Transceiver Basic Status Register */ #define PHY_RESET ((uint16_t)0x8000) /*!< PHY Reset */ #define PHY_LOOPBACK ((uint16_t)0x4000) /*!< Select loop-back mode */ #define PHY_FULLDUPLEX_100M ((uint16_t)0x2100) /*!< Set the full-duplex mode at 100 Mb/s */ #define PHY_HALFDUPLEX_100M ((uint16_t)0x2000) /*!< Set the half-duplex mode at 100 Mb/s */ #define PHY_FULLDUPLEX_10M ((uint16_t)0x0100) /*!< Set the full-duplex mode at 10 Mb/s */ #define PHY_HALFDUPLEX_10M ((uint16_t)0x0000) /*!< Set the half-duplex mode at 10 Mb/s */ #define PHY_AUTONEGOTIATION ((uint16_t)0x1000) /*!< Enable auto-negotiation function */ #define PHY_RESTART_AUTONEGOTIATION ((uint16_t)0x0200) /*!< Restart auto-negotiation function */ #define PHY_POWERDOWN ((uint16_t)0x0800) /*!< Select the power down mode */ #define PHY_ISOLATE ((uint16_t)0x0400) /*!< Isolate PHY from MII */ #define PHY_AUTONEGO_COMPLETE ((uint16_t)0x0020) /*!< Auto-Negotiation process completed */ #define PHY_LINKED_STATUS ((uint16_t)0x0004) /*!< Valid link established */ #define PHY_JABBER_DETECTION ((uint16_t)0x0002) /*!< Jabber condition detected */ /* Section 4: Extended PHY Registers */ #define PHY_SR ((uint16_t)0x0010) /*!< PHY status register Offset */ #define PHY_MICR ((uint16_t)0x0011) /*!< MII Interrupt Control Register */ #define PHY_MISR ((uint16_t)0x0012) /*!< MII Interrupt Status and Misc. Control Register */ #define PHY_LINK_STATUS ((uint16_t)0x0001) /*!< PHY Link mask */ #define PHY_SPEED_STATUS ((uint16_t)0x0002) /*!< PHY Speed mask */ #define PHY_DUPLEX_STATUS ((uint16_t)0x0004) /*!< PHY Duplex mask */ #define PHY_MICR_INT_EN ((uint16_t)0x0002) /*!< PHY Enable interrupts */ #define PHY_MICR_INT_OE ((uint16_t)0x0001) /*!< PHY Enable output interrupt events */ #define PHY_MISR_LINK_INT_EN ((uint16_t)0x0020) /*!< Enable Interrupt on change of link status */ #define PHY_LINK_INTERRUPT ((uint16_t)0x2000) /*!< PHY link status interrupt mask */ /* ################## SPI peripheral configuration ########################## */ /* CRC FEATURE: Use to activate CRC feature inside HAL SPI Driver * Activated: CRC code is present inside driver * Deactivated: CRC code cleaned from driver */ #define USE_SPI_CRC 1U /* Includes ------------------------------------------------------------------*/ /** * @brief Include module's header file */ #ifdef HAL_RCC_MODULE_ENABLED #include "stm32f1xx_hal_rcc.h" #endif /* HAL_RCC_MODULE_ENABLED */ #ifdef HAL_GPIO_MODULE_ENABLED #include "stm32f1xx_hal_gpio.h" #endif /* HAL_GPIO_MODULE_ENABLED */ #ifdef HAL_EXTI_MODULE_ENABLED #include "stm32f1xx_hal_exti.h" #endif /* HAL_EXTI_MODULE_ENABLED */ #ifdef HAL_DMA_MODULE_ENABLED #include "stm32f1xx_hal_dma.h" #endif /* HAL_DMA_MODULE_ENABLED */ #ifdef HAL_CAN_MODULE_ENABLED #include "stm32f1xx_hal_can.h" #endif /* HAL_CAN_MODULE_ENABLED */ #ifdef HAL_CAN_LEGACY_MODULE_ENABLED #include "Legacy/stm32f1xx_hal_can_legacy.h" #endif /* HAL_CAN_LEGACY_MODULE_ENABLED */ #ifdef HAL_CORTEX_MODULE_ENABLED #include "stm32f1xx_hal_cortex.h" #endif /* HAL_CORTEX_MODULE_ENABLED */ #ifdef HAL_ADC_MODULE_ENABLED #include "stm32f1xx_hal_adc.h" #endif /* HAL_ADC_MODULE_ENABLED */ #ifdef HAL_CRC_MODULE_ENABLED #include "stm32f1xx_hal_crc.h" #endif /* HAL_CRC_MODULE_ENABLED */ #ifdef HAL_DAC_MODULE_ENABLED #include "stm32f1xx_hal_dac.h" #endif /* HAL_DAC_MODULE_ENABLED */ #ifdef HAL_FLASH_MODULE_ENABLED #include "stm32f1xx_hal_flash.h" #endif /* HAL_FLASH_MODULE_ENABLED */ #ifdef HAL_SRAM_MODULE_ENABLED #include "stm32f1xx_hal_sram.h" #endif /* HAL_SRAM_MODULE_ENABLED */ #ifdef HAL_NOR_MODULE_ENABLED #include "stm32f1xx_hal_nor.h" #endif /* HAL_NOR_MODULE_ENABLED */ #ifdef HAL_I2C_MODULE_ENABLED #include "stm32f1xx_hal_i2c.h" #endif /* HAL_I2C_MODULE_ENABLED */ #ifdef HAL_I2S_MODULE_ENABLED #include "stm32f1xx_hal_i2s.h" #endif /* HAL_I2S_MODULE_ENABLED */ #ifdef HAL_IWDG_MODULE_ENABLED #include "stm32f1xx_hal_iwdg.h" #endif /* HAL_IWDG_MODULE_ENABLED */ #ifdef HAL_PWR_MODULE_ENABLED #include "stm32f1xx_hal_pwr.h" #endif /* HAL_PWR_MODULE_ENABLED */ #ifdef HAL_RTC_MODULE_ENABLED #include "stm32f1xx_hal_rtc.h" #endif /* HAL_RTC_MODULE_ENABLED */ #ifdef HAL_PCCARD_MODULE_ENABLED #include "stm32f1xx_hal_pccard.h" #endif /* HAL_PCCARD_MODULE_ENABLED */ #ifdef HAL_SD_MODULE_ENABLED #include "stm32f1xx_hal_sd.h" #endif /* HAL_SD_MODULE_ENABLED */ #ifdef HAL_SDRAM_MODULE_ENABLED #include "stm32f1xx_hal_sdram.h" #endif /* HAL_SDRAM_MODULE_ENABLED */ #ifdef HAL_SPI_MODULE_ENABLED #include "stm32f1xx_hal_spi.h" #endif /* HAL_SPI_MODULE_ENABLED */ #ifdef HAL_TIM_MODULE_ENABLED #include "stm32f1xx_hal_tim.h" #endif /* HAL_TIM_MODULE_ENABLED */ #ifdef HAL_UART_MODULE_ENABLED #include "stm32f1xx_hal_uart.h" #endif /* HAL_UART_MODULE_ENABLED */ #ifdef HAL_USART_MODULE_ENABLED #include "stm32f1xx_hal_usart.h" #endif /* HAL_USART_MODULE_ENABLED */ #ifdef HAL_IRDA_MODULE_ENABLED #include "stm32f1xx_hal_irda.h" #endif /* HAL_IRDA_MODULE_ENABLED */ #ifdef HAL_SMARTCARD_MODULE_ENABLED #include "stm32f1xx_hal_smartcard.h" #endif /* HAL_SMARTCARD_MODULE_ENABLED */ #ifdef HAL_WWDG_MODULE_ENABLED #include "stm32f1xx_hal_wwdg.h" #endif /* HAL_WWDG_MODULE_ENABLED */ #ifdef HAL_PCD_MODULE_ENABLED #include "stm32f1xx_hal_pcd.h" #endif /* HAL_PCD_MODULE_ENABLED */ #ifdef HAL_MMC_MODULE_ENABLED #include "stm32f1xx_hal_mmc.h" #endif /* HAL_MMC_MODULE_ENABLED */ /* Exported macro ------------------------------------------------------------*/ #ifdef USE_FULL_ASSERT /** * @brief The assert_param macro is used for function's parameters check. * @param expr: If expr is false, it calls assert_failed function * which reports the name of the source file and the source * line number of the call that failed. * If expr is true, it returns no value. * @retval None */ #define assert_param(expr) ((expr) ? (void)0U : assert_failed((uint8_t *)__FILE__, __LINE__)) /* Exported functions ------------------------------------------------------- */ void assert_failed(uint8_t* file, uint32_t line); #else #define assert_param(expr) ((void)0U) #endif /* USE_FULL_ASSERT */ #ifdef __cplusplus } #endif #endif /* __STM32F1xx_HAL_CONF_H */
0
D://workCode//uploadProject\STM32CubeF1\Projects\STM3210E_EVAL\Applications\USB_Device\MSC_Standalone
D://workCode//uploadProject\STM32CubeF1\Projects\STM3210E_EVAL\Applications\USB_Device\MSC_Standalone\Inc\stm32f1xx_it.h
/** ****************************************************************************** * @file USB_Device/MSC_Standalone/Inc/stm32f1xx_it.h * @author MCD Application Team * @brief This file contains the headers of the interrupt handlers. ****************************************************************************** * @attention * * Copyright (c) 2016 STMicroelectronics. * All rights reserved. * * This software is licensed under terms that can be found in the LICENSE file * in the root directory of this software component. * If no LICENSE file comes with this software, it is provided AS-IS. * ****************************************************************************** */ /* Define to prevent recursive inclusion -------------------------------------*/ #ifndef __STM32F1xx_IT_H #define __STM32F1xx_IT_H #ifdef __cplusplus extern "C" { #endif /* Includes ------------------------------------------------------------------*/ #include "main.h" /* Exported types ------------------------------------------------------------*/ /* Exported constants --------------------------------------------------------*/ /* Exported macro ------------------------------------------------------------*/ /* Exported functions ------------------------------------------------------- */ void NMI_Handler(void); void HardFault_Handler(void); void MemManage_Handler(void); void BusFault_Handler(void); void UsageFault_Handler(void); void SVC_Handler(void); void DebugMon_Handler(void); void PendSV_Handler(void); void SysTick_Handler(void); void USB_LP_CAN1_RX0_IRQHandler(void); void SDIO_IRQHandler(void); void SD_DMAx_Rx_IRQHandler(void); #ifdef __cplusplus } #endif #endif /* __STM32F1xx_IT_H */
0
D://workCode//uploadProject\STM32CubeF1\Projects\STM3210E_EVAL\Applications\USB_Device\MSC_Standalone
D://workCode//uploadProject\STM32CubeF1\Projects\STM3210E_EVAL\Applications\USB_Device\MSC_Standalone\Inc\usbd_conf.h
/** ****************************************************************************** * @file USB_Device/MSC_Standalone/Inc/usbd_conf.h * @author MCD Application Team * @brief General low level driver configuration ****************************************************************************** * @attention * * Copyright (c) 2015 STMicroelectronics. * All rights reserved. * * This software is licensed under terms that can be found in the LICENSE file * in the root directory of this software component. * If no LICENSE file comes with this software, it is provided AS-IS. * ****************************************************************************** */ /* Define to prevent recursive inclusion -------------------------------------*/ #ifndef __USBD_CONF_H #define __USBD_CONF_H /* Includes ------------------------------------------------------------------*/ #include "stm32f1xx_hal.h" #include <stdio.h> #include <stdlib.h> #include <string.h> /* Exported types ------------------------------------------------------------*/ /* Exported constants --------------------------------------------------------*/ /* Common Config */ #define USBD_MAX_NUM_INTERFACES 1 #define USBD_MAX_NUM_CONFIGURATION 1 #define USBD_MAX_STR_DESC_SIZ 0x100 #define USBD_SUPPORT_USER_STRING_DESC 0 #define USBD_SELF_POWERED 1 #define USBD_DEBUG_LEVEL 0 /* MSC Class Config */ #define MSC_MEDIA_PACKET 512 /* Exported macro ------------------------------------------------------------*/ /* Memory management macros */ /* For footprint reasons and since only one allocation is handled in the HID class driver, the malloc/free is changed into a static allocation method */ void *USBD_static_malloc(uint32_t size); void USBD_static_free(void *p); #define USBD_malloc (uint32_t *)USBD_static_malloc #define USBD_free USBD_static_free #define USBD_memset /* Not used */ #define USBD_memcpy /* Not used */ /* DEBUG macros */ #if (USBD_DEBUG_LEVEL > 0) #define USBD_UsrLog(...) printf(__VA_ARGS__);\ printf("\n"); #else #define USBD_UsrLog(...) #endif #if (USBD_DEBUG_LEVEL > 1) #define USBD_ErrLog(...) printf("ERROR: ") ;\ printf(__VA_ARGS__);\ printf("\n"); #else #define USBD_ErrLog(...) #endif #if (USBD_DEBUG_LEVEL > 2) #define USBD_DbgLog(...) printf("DEBUG : ") ;\ printf(__VA_ARGS__);\ printf("\n"); #else #define USBD_DbgLog(...) #endif /* Exported functions ------------------------------------------------------- */ #endif /* __USBD_CONF_H */
0
D://workCode//uploadProject\STM32CubeF1\Projects\STM3210E_EVAL\Applications\USB_Device\MSC_Standalone
D://workCode//uploadProject\STM32CubeF1\Projects\STM3210E_EVAL\Applications\USB_Device\MSC_Standalone\Inc\usbd_desc.h
/** ****************************************************************************** * @file USB_Device/MSC_Standalone/Inc/usbd_desc.h * @author MCD Application Team * @brief Header for usbd_desc.c module ****************************************************************************** * @attention * * Copyright (c) 2015 STMicroelectronics. * All rights reserved. * * This software is licensed under terms that can be found in the LICENSE file * in the root directory of this software component. * If no LICENSE file comes with this software, it is provided AS-IS. * ****************************************************************************** */ /* Define to prevent recursive inclusion -------------------------------------*/ #ifndef __USBD_DESC_H #define __USBD_DESC_H /* Includes ------------------------------------------------------------------*/ #include "usbd_def.h" /* Exported types ------------------------------------------------------------*/ /* Exported constants --------------------------------------------------------*/ #define DEVICE_ID1 (0x1FFFF7E8) #define DEVICE_ID2 (0x1FFFF7EC) #define DEVICE_ID3 (0x1FFFF7F0) #define USB_SIZ_STRING_SERIAL 0x1A /* Exported macro ------------------------------------------------------------*/ /* Exported functions ------------------------------------------------------- */ extern USBD_DescriptorsTypeDef MSC_Desc; #endif /* __USBD_DESC_H */
0
D://workCode//uploadProject\STM32CubeF1\Projects\STM3210E_EVAL\Applications\USB_Device\MSC_Standalone
D://workCode//uploadProject\STM32CubeF1\Projects\STM3210E_EVAL\Applications\USB_Device\MSC_Standalone\Inc\usbd_storage.h
/** ****************************************************************************** * @file USB_Device/MSC_Standalone/Inc/usbd_storage.h * @author MCD Application Team * @brief Header for usbd_storage.c module ****************************************************************************** * @attention * * Copyright (c) 2015 STMicroelectronics. * All rights reserved. * * This software is licensed under terms that can be found in the LICENSE file * in the root directory of this software component. * If no LICENSE file comes with this software, it is provided AS-IS. * ****************************************************************************** */ /* Define to prevent recursive inclusion -------------------------------------*/ #ifndef __USBD_STORAGE_H_ #define __USBD_STORAGE_H_ /* Includes ------------------------------------------------------------------*/ #include "usbd_msc.h" /* Exported types ------------------------------------------------------------*/ /* Exported constants --------------------------------------------------------*/ /* Exported macro ------------------------------------------------------------*/ /* Exported functions ------------------------------------------------------- */ extern USBD_StorageTypeDef USBD_DISK_fops; #endif /* __USBD_STORAGE_H_ */
0
D://workCode//uploadProject\STM32CubeF1\Projects\STM3210E_EVAL\Applications\USB_Device\MSC_Standalone
D://workCode//uploadProject\STM32CubeF1\Projects\STM3210E_EVAL\Applications\USB_Device\MSC_Standalone\Src\main.c
/** ****************************************************************************** * @file USB_Device/MSC_Standalone/Src/main.c * @author MCD Application Team * @brief USB device MSC application main file. ****************************************************************************** * @attention * * Copyright (c) 2016 STMicroelectronics. * All rights reserved. * * This software is licensed under terms that can be found in the LICENSE file * in the root directory of this software component. * If no LICENSE file comes with this software, it is provided AS-IS. * ****************************************************************************** */ /* Includes ------------------------------------------------------------------ */ #include "main.h" /** @addtogroup STM32F1xx_HAL_Validation * @{ */ /** @addtogroup STANDARD_CHECK * @{ */ /* Private typedef ----------------------------------------------------------- */ /* Private define ------------------------------------------------------------ */ /* Private macro ------------------------------------------------------------- */ /* Private variables --------------------------------------------------------- */ USBD_HandleTypeDef USBD_Device; /* Private function prototypes ----------------------------------------------- */ void SystemClock_Config(void); static void Error_Handler(void); /* Private functions --------------------------------------------------------- */ /** * @brief Main program. * @param None * @retval None */ int main(void) { /* Reset of all peripherals, Initializes the Flash interface and the Systick. */ HAL_Init(); /* Initialize LEDs */ BSP_LED_Init(LED1); BSP_LED_Init(LED2); BSP_LED_Init(LED3); BSP_LED_Init(LED4); /* Configure the system clock to 72 MHz */ SystemClock_Config(); /* Init MSC Application */ USBD_Init(&USBD_Device, &MSC_Desc, 0); /* Add Supported Class */ USBD_RegisterClass(&USBD_Device, USBD_MSC_CLASS); /* Add Storage callbacks for MSC Class */ USBD_MSC_RegisterStorage(&USBD_Device, &USBD_DISK_fops); /* Start Device Process */ USBD_Start(&USBD_Device); /* Infinite loop */ while (1) { } } /** * @brief System Clock Configuration * The system Clock is configured as follow : * System Clock source = PLL (HSE) * SYSCLK(Hz) = 72000000 * HCLK(Hz) = 72000000 * AHB Prescaler = 1 * APB1 Prescaler = 2 * APB2 Prescaler = 1 * HSE Frequency(Hz) = 8000000 * HSE PREDIV1 = 1 * PLLMUL = 9 * Flash Latency(WS) = 2 * @param None * @retval None */ void SystemClock_Config(void) { RCC_ClkInitTypeDef clkinitstruct = { 0 }; RCC_OscInitTypeDef oscinitstruct = { 0 }; RCC_PeriphCLKInitTypeDef rccperiphclkinit = { 0 }; /* Enable HSE Oscillator and activate PLL with HSE as source */ oscinitstruct.OscillatorType = RCC_OSCILLATORTYPE_HSE; oscinitstruct.HSEState = RCC_HSE_ON; oscinitstruct.HSEPredivValue = RCC_HSE_PREDIV_DIV1; oscinitstruct.PLL.PLLMUL = RCC_PLL_MUL9; oscinitstruct.PLL.PLLState = RCC_PLL_ON; oscinitstruct.PLL.PLLSource = RCC_PLLSOURCE_HSE; if (HAL_RCC_OscConfig(&oscinitstruct) != HAL_OK) { /* Start Conversation Error */ Error_Handler(); } /* USB clock selection */ rccperiphclkinit.PeriphClockSelection = RCC_PERIPHCLK_USB; rccperiphclkinit.UsbClockSelection = RCC_USBCLKSOURCE_PLL_DIV1_5; HAL_RCCEx_PeriphCLKConfig(&rccperiphclkinit); /* Select PLL as system clock source and configure the HCLK, PCLK1 and PCLK2 * clocks dividers */ clkinitstruct.ClockType = (RCC_CLOCKTYPE_SYSCLK | RCC_CLOCKTYPE_HCLK | RCC_CLOCKTYPE_PCLK1 | RCC_CLOCKTYPE_PCLK2); clkinitstruct.SYSCLKSource = RCC_SYSCLKSOURCE_PLLCLK; clkinitstruct.AHBCLKDivider = RCC_SYSCLK_DIV1; clkinitstruct.APB1CLKDivider = RCC_HCLK_DIV2; clkinitstruct.APB2CLKDivider = RCC_HCLK_DIV1; if (HAL_RCC_ClockConfig(&clkinitstruct, FLASH_LATENCY_2) != HAL_OK) { /* Start Conversation Error */ Error_Handler(); } } /** * @brief This function is executed in case of error occurrence. * @param None * @retval None */ static void Error_Handler(void) { /* Turn LED3 on */ BSP_LED_On(LED3); while (1) { } } /** * @brief Toggle LEDs to shows user input state. * @param None * @retval None */ void Toggle_Leds(void) { static uint32_t ticks; if (ticks++ == 100) { BSP_LED_Toggle(LED1); BSP_LED_Toggle(LED2); BSP_LED_Toggle(LED3); BSP_LED_Toggle(LED4); ticks = 0; } } #ifdef USE_FULL_ASSERT /** * @brief Reports the name of the source file and the source line number * where the assert_param error has occurred. * @param file: pointer to the source file name * @param line: assert_param error line source number * @retval None */ void assert_failed(uint8_t * file, uint32_t line) { /* User can add his own implementation to report the file name and line * number, ex: printf("Wrong parameters value: file %s on line %d\r\n", file, * line) */ /* Infinite loop */ while (1) { } } #endif /** * @} */ /** * @} */
0
D://workCode//uploadProject\STM32CubeF1\Projects\STM3210E_EVAL\Applications\USB_Device\MSC_Standalone
D://workCode//uploadProject\STM32CubeF1\Projects\STM3210E_EVAL\Applications\USB_Device\MSC_Standalone\Src\stm32f1xx_it.c
/** ****************************************************************************** * @file USB_Device/MSC_Standalone/Src/stm32f1xx_it.c * @author MCD Application Team * @brief Main Interrupt Service Routines. * This file provides template for all exceptions handler and * peripherals interrupt service routine. ****************************************************************************** * @attention * * Copyright (c) 2016 STMicroelectronics. * All rights reserved. * * This software is licensed under terms that can be found in the LICENSE file * in the root directory of this software component. * If no LICENSE file comes with this software, it is provided AS-IS. * ****************************************************************************** */ /* Includes ------------------------------------------------------------------ */ #include "stm32f1xx_it.h" /** @addtogroup Validation_Project * @{ */ /* Private typedef ----------------------------------------------------------- */ /* Private define ------------------------------------------------------------ */ /* Private macro ------------------------------------------------------------- */ /* Private variables --------------------------------------------------------- */ extern PCD_HandleTypeDef hpcd; extern SD_HandleTypeDef uSdHandle; /* Private function prototypes ----------------------------------------------- */ /* Private functions --------------------------------------------------------- */ /******************************************************************************/ /* Cortex-M3 Processor Exceptions Handlers */ /******************************************************************************/ /** * @brief This function handles NMI exception. * @param None * @retval None */ void NMI_Handler(void) { } /** * @brief This function handles Hard Fault exception. * @param None * @retval None */ void HardFault_Handler(void) { /* Go to infinite loop when Hard Fault exception occurs */ while (1) { } } /** * @brief This function handles Memory Manage exception. * @param None * @retval None */ void MemManage_Handler(void) { /* Go to infinite loop when Memory Manage exception occurs */ while (1) { } } /** * @brief This function handles Bus Fault exception. * @param None * @retval None */ void BusFault_Handler(void) { /* Go to infinite loop when Bus Fault exception occurs */ while (1) { } } /** * @brief This function handles Usage Fault exception. * @param None * @retval None */ void UsageFault_Handler(void) { /* Go to infinite loop when Usage Fault exception occurs */ while (1) { } } /** * @brief This function handles SVCall exception. * @param None * @retval None */ void SVC_Handler(void) { } /** * @brief This function handles Debug Monitor exception. * @param None * @retval None */ void DebugMon_Handler(void) { } /** * @brief This function handles PendSVC exception. * @param None * @retval None */ void PendSV_Handler(void) { } /** * @brief This function handles SysTick Handler. * @param None * @retval None */ void SysTick_Handler(void) { HAL_IncTick(); } /******************************************************************************/ /* STM32F1xx Peripherals Interrupt Handlers */ /* Add here the Interrupt Handler for the used peripheral(s) (PPP), for the */ /* available peripheral interrupt handler's name please refer to the startup */ /* file (startup_stm32f1xx.s). */ /******************************************************************************/ /** * @brief This function handles USB Handler. * @param None * @retval None */ void USB_LP_CAN1_RX0_IRQHandler(void) { HAL_PCD_IRQHandler(&hpcd); } /** * @brief This function handles SDIO interrupt request. * @param None * @retval None */ void SDIO_IRQHandler(void) { HAL_SD_IRQHandler(&uSdHandle); } /** * @brief This function handles DMA interrupt request. * @param None * @retval None */ void SD_DMAx_Rx_IRQHandler(void) { HAL_DMA_IRQHandler(uSdHandle.hdmarx); } ///** // * @brief This function handles DMA2 Stream 6 interrupt request. // * @param None // * @retval None // */ //void SD_DMAx_Tx_IRQHandler(void) //{ // HAL_DMA_IRQHandler(uSdHandle.hdmatx); //} /** * @brief This function handles PPP interrupt request. * @param None * @retval None */
0
D://workCode//uploadProject\STM32CubeF1\Projects\STM3210E_EVAL\Applications\USB_Device\MSC_Standalone
D://workCode//uploadProject\STM32CubeF1\Projects\STM3210E_EVAL\Applications\USB_Device\MSC_Standalone\Src\system_stm32f1xx.c
/** ****************************************************************************** * @file system_stm32f1xx.c * @author MCD Application Team * @brief CMSIS Cortex-M3 Device Peripheral Access Layer System Source File. * * 1. This file provides two functions and one global variable to be called from * user application: * - SystemInit(): Setups the system clock (System clock source, PLL Multiplier * factors, AHB/APBx prescalers and Flash settings). * This function is called at startup just after reset and * before branch to main program. This call is made inside * the "startup_stm32f1xx_xx.s" file. * * - SystemCoreClock variable: Contains the core clock (HCLK), it can be used * by the user application to setup the SysTick * timer or configure other parameters. * * - SystemCoreClockUpdate(): Updates the variable SystemCoreClock and must * be called whenever the core clock is changed * during program execution. * * 2. After each device reset the HSI (8 MHz) is used as system clock source. * Then SystemInit() function is called, in "startup_stm32f1xx_xx.s" file, to * configure the system clock before to branch to main program. * * 4. The default value of HSE crystal is set to 8 MHz (or 25 MHz, depending on * the product used), refer to "HSE_VALUE". * When HSE is used as system clock source, directly or through PLL, and you * are using different crystal you have to adapt the HSE value to your own * configuration. * ****************************************************************************** * @attention * * Copyright (c) 2016 STMicroelectronics. * All rights reserved. * * This software is licensed under terms that can be found in the LICENSE file * in the root directory of this software component. * If no LICENSE file comes with this software, it is provided AS-IS. * ****************************************************************************** */ /** @addtogroup CMSIS * @{ */ /** @addtogroup stm32f1xx_system * @{ */ /** @addtogroup STM32F1xx_System_Private_Includes * @{ */ #include "stm32f1xx.h" /** * @} */ /** @addtogroup STM32F1xx_System_Private_TypesDefinitions * @{ */ /** * @} */ /** @addtogroup STM32F1xx_System_Private_Defines * @{ */ #if !defined (HSE_VALUE) #define HSE_VALUE ((uint32_t)8000000) /*!< Default value of the External oscillator in Hz. This value can be provided and adapted by the user application. */ #endif /* HSE_VALUE */ #if !defined (HSI_VALUE) #define HSI_VALUE ((uint32_t)8000000) /*!< Default value of the Internal oscillator in Hz. This value can be provided and adapted by the user application. */ #endif /* HSI_VALUE */ /*!< Uncomment the following line if you need to use external SRAM */ #if defined(STM32F100xE) || defined(STM32F101xE) || defined(STM32F101xG) || defined(STM32F103xE) || defined(STM32F103xG) /* #define DATA_IN_ExtSRAM */ #endif /* STM32F100xE || STM32F101xE || STM32F101xG || STM32F103xE || STM32F103xG */ /*!< Uncomment the following line if you need to relocate your vector Table in Internal SRAM. */ /* #define VECT_TAB_SRAM */ #define VECT_TAB_OFFSET 0x0 /*!< Vector Table base offset field. This value must be a multiple of 0x200. */ /** * @} */ /** @addtogroup STM32F1xx_System_Private_Macros * @{ */ /** * @} */ /** @addtogroup STM32F1xx_System_Private_Variables * @{ */ /* This variable is updated in three ways: 1) by calling CMSIS function SystemCoreClockUpdate() 2) by calling HAL API function HAL_RCC_GetHCLKFreq() 3) each time HAL_RCC_ClockConfig() is called to configure the system clock frequency Note: If you use this function to configure the system clock; then there is no need to call the 2 first functions listed above, since SystemCoreClock variable is updated automatically. */ uint32_t SystemCoreClock = 16000000; const uint8_t AHBPrescTable[16] = {0, 0, 0, 0, 0, 0, 0, 0, 1, 2, 3, 4, 6, 7, 8, 9}; const uint8_t APBPrescTable[8] = {0, 0, 0, 0, 1, 2, 3, 4}; /** * @} */ /** @addtogroup STM32F1xx_System_Private_FunctionPrototypes * @{ */ #if defined(STM32F100xE) || defined(STM32F101xE) || defined(STM32F101xG) || defined(STM32F103xE) || defined(STM32F103xG) #ifdef DATA_IN_ExtSRAM static void SystemInit_ExtMemCtl(void); #endif /* DATA_IN_ExtSRAM */ #endif /* STM32F100xE || STM32F101xE || STM32F101xG || STM32F103xE || STM32F103xG */ /** * @} */ /** @addtogroup STM32F1xx_System_Private_Functions * @{ */ /** * @brief Setup the microcontroller system * Initialize the Embedded Flash Interface, the PLL and update the * SystemCoreClock variable. * @note This function should be used only after reset. * @param None * @retval None */ void SystemInit (void) { /* Reset the RCC clock configuration to the default reset state(for debug purpose) */ /* Set HSION bit */ RCC->CR |= (uint32_t)0x00000001; /* Reset SW, HPRE, PPRE1, PPRE2, ADCPRE and MCO bits */ #if !defined(STM32F105xC) && !defined(STM32F107xC) RCC->CFGR &= (uint32_t)0xF8FF0000; #else RCC->CFGR &= (uint32_t)0xF0FF0000; #endif /* STM32F105xC */ /* Reset HSEON, CSSON and PLLON bits */ RCC->CR &= (uint32_t)0xFEF6FFFF; /* Reset HSEBYP bit */ RCC->CR &= (uint32_t)0xFFFBFFFF; /* Reset PLLSRC, PLLXTPRE, PLLMUL and USBPRE/OTGFSPRE bits */ RCC->CFGR &= (uint32_t)0xFF80FFFF; #if defined(STM32F105xC) || defined(STM32F107xC) /* Reset PLL2ON and PLL3ON bits */ RCC->CR &= (uint32_t)0xEBFFFFFF; /* Disable all interrupts and clear pending bits */ RCC->CIR = 0x00FF0000; /* Reset CFGR2 register */ RCC->CFGR2 = 0x00000000; #elif defined(STM32F100xB) || defined(STM32F100xE) /* Disable all interrupts and clear pending bits */ RCC->CIR = 0x009F0000; /* Reset CFGR2 register */ RCC->CFGR2 = 0x00000000; #else /* Disable all interrupts and clear pending bits */ RCC->CIR = 0x009F0000; #endif /* STM32F105xC */ #if defined(STM32F100xE) || defined(STM32F101xE) || defined(STM32F101xG) || defined(STM32F103xE) || defined(STM32F103xG) #ifdef DATA_IN_ExtSRAM SystemInit_ExtMemCtl(); #endif /* DATA_IN_ExtSRAM */ #endif #ifdef VECT_TAB_SRAM SCB->VTOR = SRAM_BASE | VECT_TAB_OFFSET; /* Vector Table Relocation in Internal SRAM. */ #else SCB->VTOR = FLASH_BASE | VECT_TAB_OFFSET; /* Vector Table Relocation in Internal FLASH. */ #endif } /** * @brief Update SystemCoreClock variable according to Clock Register Values. * The SystemCoreClock variable contains the core clock (HCLK), it can * be used by the user application to setup the SysTick timer or configure * other parameters. * * @note Each time the core clock (HCLK) changes, this function must be called * to update SystemCoreClock variable value. Otherwise, any configuration * based on this variable will be incorrect. * * @note - The system frequency computed by this function is not the real * frequency in the chip. It is calculated based on the predefined * constant and the selected clock source: * * - If SYSCLK source is HSI, SystemCoreClock will contain the HSI_VALUE(*) * * - If SYSCLK source is HSE, SystemCoreClock will contain the HSE_VALUE(**) * * - If SYSCLK source is PLL, SystemCoreClock will contain the HSE_VALUE(**) * or HSI_VALUE(*) multiplied by the PLL factors. * * (*) HSI_VALUE is a constant defined in stm32f1xx.h file (default value * 8 MHz) but the real value may vary depending on the variations * in voltage and temperature. * * (**) HSE_VALUE is a constant defined in stm32f1xx.h file (default value * 8 MHz or 25 MHz, depending on the product used), user has to ensure * that HSE_VALUE is same as the real frequency of the crystal used. * Otherwise, this function may have wrong result. * * - The result of this function could be not correct when using fractional * value for HSE crystal. * @param None * @retval None */ void SystemCoreClockUpdate (void) { uint32_t tmp = 0, pllmull = 0, pllsource = 0; #if defined(STM32F105xC) || defined(STM32F107xC) uint32_t prediv1source = 0, prediv1factor = 0, prediv2factor = 0, pll2mull = 0; #endif /* STM32F105xC */ #if defined(STM32F100xB) || defined(STM32F100xE) uint32_t prediv1factor = 0; #endif /* STM32F100xB or STM32F100xE */ /* Get SYSCLK source -------------------------------------------------------*/ tmp = RCC->CFGR & RCC_CFGR_SWS; switch (tmp) { case 0x00: /* HSI used as system clock */ SystemCoreClock = HSI_VALUE; break; case 0x04: /* HSE used as system clock */ SystemCoreClock = HSE_VALUE; break; case 0x08: /* PLL used as system clock */ /* Get PLL clock source and multiplication factor ----------------------*/ pllmull = RCC->CFGR & RCC_CFGR_PLLMULL; pllsource = RCC->CFGR & RCC_CFGR_PLLSRC; #if !defined(STM32F105xC) && !defined(STM32F107xC) pllmull = ( pllmull >> 18) + 2; if (pllsource == 0x00) { /* HSI oscillator clock divided by 2 selected as PLL clock entry */ SystemCoreClock = (HSI_VALUE >> 1) * pllmull; } else { #if defined(STM32F100xB) || defined(STM32F100xE) prediv1factor = (RCC->CFGR2 & RCC_CFGR2_PREDIV1) + 1; /* HSE oscillator clock selected as PREDIV1 clock entry */ SystemCoreClock = (HSE_VALUE / prediv1factor) * pllmull; #else /* HSE selected as PLL clock entry */ if ((RCC->CFGR & RCC_CFGR_PLLXTPRE) != (uint32_t)RESET) {/* HSE oscillator clock divided by 2 */ SystemCoreClock = (HSE_VALUE >> 1) * pllmull; } else { SystemCoreClock = HSE_VALUE * pllmull; } #endif } #else pllmull = pllmull >> 18; if (pllmull != 0x0D) { pllmull += 2; } else { /* PLL multiplication factor = PLL input clock * 6.5 */ pllmull = 13 / 2; } if (pllsource == 0x00) { /* HSI oscillator clock divided by 2 selected as PLL clock entry */ SystemCoreClock = (HSI_VALUE >> 1) * pllmull; } else {/* PREDIV1 selected as PLL clock entry */ /* Get PREDIV1 clock source and division factor */ prediv1source = RCC->CFGR2 & RCC_CFGR2_PREDIV1SRC; prediv1factor = (RCC->CFGR2 & RCC_CFGR2_PREDIV1) + 1; if (prediv1source == 0) { /* HSE oscillator clock selected as PREDIV1 clock entry */ SystemCoreClock = (HSE_VALUE / prediv1factor) * pllmull; } else {/* PLL2 clock selected as PREDIV1 clock entry */ /* Get PREDIV2 division factor and PLL2 multiplication factor */ prediv2factor = ((RCC->CFGR2 & RCC_CFGR2_PREDIV2) >> 4) + 1; pll2mull = ((RCC->CFGR2 & RCC_CFGR2_PLL2MUL) >> 8 ) + 2; SystemCoreClock = (((HSE_VALUE / prediv2factor) * pll2mull) / prediv1factor) * pllmull; } } #endif /* STM32F105xC */ break; default: SystemCoreClock = HSI_VALUE; break; } /* Compute HCLK clock frequency ----------------*/ /* Get HCLK prescaler */ tmp = AHBPrescTable[((RCC->CFGR & RCC_CFGR_HPRE) >> 4)]; /* HCLK clock frequency */ SystemCoreClock >>= tmp; } #if defined(STM32F100xE) || defined(STM32F101xE) || defined(STM32F101xG) || defined(STM32F103xE) || defined(STM32F103xG) /** * @brief Setup the external memory controller. Called in startup_stm32f1xx.s * before jump to __main * @param None * @retval None */ #ifdef DATA_IN_ExtSRAM /** * @brief Setup the external memory controller. * Called in startup_stm32f1xx_xx.s/.c before jump to main. * This function configures the external SRAM mounted on STM3210E-EVAL * board (STM32 High density devices). This SRAM will be used as program * data memory (including heap and stack). * @param None * @retval None */ void SystemInit_ExtMemCtl(void) { __IO uint32_t tmpreg; /*!< FSMC Bank1 NOR/SRAM3 is used for the STM3210E-EVAL, if another Bank is required, then adjust the Register Addresses */ /* Enable FSMC clock */ RCC->AHBENR = 0x00000114; /* Delay after an RCC peripheral clock enabling */ tmpreg = READ_BIT(RCC->AHBENR, RCC_AHBENR_FSMCEN); /* Enable GPIOD, GPIOE, GPIOF and GPIOG clocks */ RCC->APB2ENR = 0x000001E0; /* Delay after an RCC peripheral clock enabling */ tmpreg = READ_BIT(RCC->APB2ENR, RCC_APB2ENR_IOPDEN); (void)(tmpreg); /* --------------- SRAM Data lines, NOE and NWE configuration ---------------*/ /*---------------- SRAM Address lines configuration -------------------------*/ /*---------------- NOE and NWE configuration --------------------------------*/ /*---------------- NE3 configuration ----------------------------------------*/ /*---------------- NBL0, NBL1 configuration ---------------------------------*/ GPIOD->CRL = 0x44BB44BB; GPIOD->CRH = 0xBBBBBBBB; GPIOE->CRL = 0xB44444BB; GPIOE->CRH = 0xBBBBBBBB; GPIOF->CRL = 0x44BBBBBB; GPIOF->CRH = 0xBBBB4444; GPIOG->CRL = 0x44BBBBBB; GPIOG->CRH = 0x444B4B44; /*---------------- FSMC Configuration ---------------------------------------*/ /*---------------- Enable FSMC Bank1_SRAM Bank ------------------------------*/ FSMC_Bank1->BTCR[4] = 0x00001091; FSMC_Bank1->BTCR[5] = 0x00110212; } #endif /* DATA_IN_ExtSRAM */ #endif /* STM32F100xE || STM32F101xE || STM32F101xG || STM32F103xE || STM32F103xG */ /** * @} */ /** * @} */ /** * @} */
0
D://workCode//uploadProject\STM32CubeF1\Projects\STM3210E_EVAL\Applications\USB_Device\MSC_Standalone
D://workCode//uploadProject\STM32CubeF1\Projects\STM3210E_EVAL\Applications\USB_Device\MSC_Standalone\Src\usbd_conf.c
/** ****************************************************************************** * @file USB_Device/MSC_Standalone/Src/usbd_conf.c * @author MCD Application Team * @brief This file implements the USB Device library callbacks and MSP ****************************************************************************** * @attention * * Copyright (c) 2015 STMicroelectronics. * All rights reserved. * * This software is licensed under terms that can be found in the LICENSE file * in the root directory of this software component. * If no LICENSE file comes with this software, it is provided AS-IS. * ****************************************************************************** */ /* Includes ------------------------------------------------------------------ */ #include "main.h" #include "usbd_msc.h" /* Private typedef ----------------------------------------------------------- */ /* Private define ------------------------------------------------------------ */ #define USB_DISCONNECT_PORT GPIOB #define USB_DISCONNECT_PIN GPIO_PIN_14 /* Private macro ------------------------------------------------------------- */ /* Private variables --------------------------------------------------------- */ PCD_HandleTypeDef hpcd; /* Private function prototypes ----------------------------------------------- */ /* Private functions --------------------------------------------------------- */ /******************************************************************************* PCD BSP Routines *******************************************************************************/ /** * @brief Initializes the PCD MSP. * @param hpcd: PCD handle * @retval None */ void HAL_PCD_MspInit(PCD_HandleTypeDef * hpcd) { GPIO_InitTypeDef GPIO_InitStruct; /* Enable the GPIOA clock */ __HAL_RCC_GPIOA_CLK_ENABLE(); /* Configure USB DM/DP pins */ GPIO_InitStruct.Pin = (GPIO_PIN_11 | GPIO_PIN_12); GPIO_InitStruct.Mode = GPIO_MODE_AF_INPUT; GPIO_InitStruct.Pull = GPIO_PULLUP; GPIO_InitStruct.Speed = GPIO_SPEED_FREQ_HIGH; HAL_GPIO_Init(GPIOA, &GPIO_InitStruct); /* Enable the USB disconnect GPIO clock */ __HAL_RCC_GPIOB_CLK_ENABLE(); /* USB_DISCONNECT used as USB pull-up */ GPIO_InitStruct.Pin = USB_DISCONNECT_PIN; GPIO_InitStruct.Mode = GPIO_MODE_OUTPUT_OD; HAL_GPIO_Init(USB_DISCONNECT_PORT, &GPIO_InitStruct); /* Enable USB Clock */ __HAL_RCC_USB_CLK_ENABLE(); /* Set USB Interrupt priority */ HAL_NVIC_SetPriority(USB_LP_CAN1_RX0_IRQn, 7, 0); /* Enable USB Interrupt */ HAL_NVIC_EnableIRQ(USB_LP_CAN1_RX0_IRQn); } /** * @brief De-Initializes the PCD MSP. * @param hpcd: PCD handle * @retval None */ void HAL_PCD_MspDeInit(PCD_HandleTypeDef * hpcd) { /* Disable USB FS Clock */ __HAL_RCC_USB_CLK_DISABLE(); } /******************************************************************************* LL Driver Callbacks (PCD -> USB Device Library) *******************************************************************************/ /** * @brief SetupStage callback. * @param hpcd: PCD handle * @retval None */ void HAL_PCD_SetupStageCallback(PCD_HandleTypeDef * hpcd) { USBD_LL_SetupStage((USBD_HandleTypeDef *) hpcd->pData, (uint8_t *) hpcd->Setup); } /** * @brief DataOut Stage callback. * @param hpcd: PCD handle * @param epnum: Endpoint Number * @retval None */ void HAL_PCD_DataOutStageCallback(PCD_HandleTypeDef * hpcd, uint8_t epnum) { USBD_LL_DataOutStage((USBD_HandleTypeDef *) hpcd->pData, epnum, hpcd->OUT_ep[epnum].xfer_buff); } /** * @brief DataIn Stage callback. * @param hpcd: PCD handle * @param epnum: Endpoint Number * @retval None */ void HAL_PCD_DataInStageCallback(PCD_HandleTypeDef * hpcd, uint8_t epnum) { USBD_LL_DataInStage((USBD_HandleTypeDef *) hpcd->pData, epnum, hpcd->IN_ep[epnum].xfer_buff); } /** * @brief SOF callback. * @param hpcd: PCD handle * @retval None */ void HAL_PCD_SOFCallback(PCD_HandleTypeDef * hpcd) { USBD_LL_SOF((USBD_HandleTypeDef *) hpcd->pData); } /** * @brief Reset callback. * @param hpcd: PCD handle * @retval None */ void HAL_PCD_ResetCallback(PCD_HandleTypeDef * hpcd) { USBD_LL_SetSpeed((USBD_HandleTypeDef *) hpcd->pData, USBD_SPEED_FULL); /* Reset Device */ USBD_LL_Reset((USBD_HandleTypeDef *) hpcd->pData); } /** * @brief Suspend callback. * @param hpcd: PCD handle * @retval None */ void HAL_PCD_SuspendCallback(PCD_HandleTypeDef * hpcd) { } /** * @brief Resume callback. * @param hpcd: PCD handle * @retval None */ void HAL_PCD_ResumeCallback(PCD_HandleTypeDef * hpcd) { } /** * @brief ISOOUTIncomplete callback. * @param hpcd: PCD handle * @param epnum: Endpoint Number * @retval None */ void HAL_PCD_ISOOUTIncompleteCallback(PCD_HandleTypeDef * hpcd, uint8_t epnum) { USBD_LL_IsoOUTIncomplete((USBD_HandleTypeDef *) hpcd->pData, epnum); } /** * @brief ISOINIncomplete callback. * @param hpcd: PCD handle * @param epnum: Endpoint Number * @retval None */ void HAL_PCD_ISOINIncompleteCallback(PCD_HandleTypeDef * hpcd, uint8_t epnum) { USBD_LL_IsoINIncomplete((USBD_HandleTypeDef *) hpcd->pData, epnum); } /** * @brief ConnectCallback callback. * @param hpcd: PCD handle * @retval None */ void HAL_PCD_ConnectCallback(PCD_HandleTypeDef * hpcd) { USBD_LL_DevConnected((USBD_HandleTypeDef *) hpcd->pData); } /** * @brief Disconnect callback. * @param hpcd: PCD handle * @retval None */ void HAL_PCD_DisconnectCallback(PCD_HandleTypeDef * hpcd) { USBD_LL_DevDisconnected((USBD_HandleTypeDef *) hpcd->pData); } /******************************************************************************* LL Driver Interface (USB Device Library --> PCD) *******************************************************************************/ /** * @brief Initializes the Low Level portion of the Device driver. * @param pdev: Device handle * @retval USBD Status */ USBD_StatusTypeDef USBD_LL_Init(USBD_HandleTypeDef * pdev) { /* Set LL Driver parameters */ hpcd.Instance = USB; hpcd.Init.dev_endpoints = 8; hpcd.Init.phy_itface = PCD_PHY_EMBEDDED; hpcd.Init.speed = PCD_SPEED_FULL; hpcd.Init.low_power_enable = 0; /* Link The driver to the stack */ hpcd.pData = pdev; pdev->pData = &hpcd; /* Initialize LL Driver */ HAL_PCD_Init((PCD_HandleTypeDef *) pdev->pData); HAL_PCDEx_PMAConfig(pdev->pData, 0x00, PCD_SNG_BUF, 0x18); HAL_PCDEx_PMAConfig(pdev->pData, 0x80, PCD_SNG_BUF, 0x58); HAL_PCDEx_PMAConfig(pdev->pData, MSC_EPIN_ADDR, PCD_SNG_BUF, 0x98); HAL_PCDEx_PMAConfig(pdev->pData, MSC_EPOUT_ADDR, PCD_SNG_BUF, 0xD8); return USBD_OK; } /** * @brief De-Initializes the Low Level portion of the Device driver. * @param pdev: Device handle * @retval USBD Status */ USBD_StatusTypeDef USBD_LL_DeInit(USBD_HandleTypeDef * pdev) { HAL_PCD_DeInit((PCD_HandleTypeDef *) pdev->pData); return USBD_OK; } /** * @brief Starts the Low Level portion of the Device driver. * @param pdev: Device handle * @retval USBD Status */ USBD_StatusTypeDef USBD_LL_Start(USBD_HandleTypeDef * pdev) { HAL_PCD_Start((PCD_HandleTypeDef *) pdev->pData); return USBD_OK; } /** * @brief Stops the Low Level portion of the Device driver. * @param pdev: Device handle * @retval USBD Status */ USBD_StatusTypeDef USBD_LL_Stop(USBD_HandleTypeDef * pdev) { HAL_PCD_Stop((PCD_HandleTypeDef *) pdev->pData); return USBD_OK; } /** * @brief Opens an endpoint of the Low Level Driver. * @param pdev: Device handle * @param ep_addr: Endpoint Number * @param ep_type: Endpoint Type * @param ep_mps: Endpoint Max Packet Size * @retval USBD Status */ USBD_StatusTypeDef USBD_LL_OpenEP(USBD_HandleTypeDef * pdev, uint8_t ep_addr, uint8_t ep_type, uint16_t ep_mps) { HAL_PCD_EP_Open((PCD_HandleTypeDef *) pdev->pData, ep_addr, ep_mps, ep_type); return USBD_OK; } /** * @brief Closes an endpoint of the Low Level Driver. * @param pdev: Device handle * @param ep_addr: Endpoint Number * @retval USBD Status */ USBD_StatusTypeDef USBD_LL_CloseEP(USBD_HandleTypeDef * pdev, uint8_t ep_addr) { HAL_PCD_EP_Close((PCD_HandleTypeDef *) pdev->pData, ep_addr); return USBD_OK; } /** * @brief Flushes an endpoint of the Low Level Driver. * @param pdev: Device handle * @param ep_addr: Endpoint Number * @retval USBD Status */ USBD_StatusTypeDef USBD_LL_FlushEP(USBD_HandleTypeDef * pdev, uint8_t ep_addr) { HAL_PCD_EP_Flush((PCD_HandleTypeDef *) pdev->pData, ep_addr); return USBD_OK; } /** * @brief Sets a Stall condition on an endpoint of the Low Level Driver. * @param pdev: Device handle * @param ep_addr: Endpoint Number * @retval USBD Status */ USBD_StatusTypeDef USBD_LL_StallEP(USBD_HandleTypeDef * pdev, uint8_t ep_addr) { HAL_PCD_EP_SetStall((PCD_HandleTypeDef *) pdev->pData, ep_addr); return USBD_OK; } /** * @brief Clears a Stall condition on an endpoint of the Low Level Driver. * @param pdev: Device handle * @param ep_addr: Endpoint Number * @retval USBD Status */ USBD_StatusTypeDef USBD_LL_ClearStallEP(USBD_HandleTypeDef * pdev, uint8_t ep_addr) { HAL_PCD_EP_ClrStall((PCD_HandleTypeDef *) pdev->pData, ep_addr); return USBD_OK; } /** * @brief Returns Stall condition. * @param pdev: Device handle * @param ep_addr: Endpoint Number * @retval Stall (1: Yes, 0: No) */ uint8_t USBD_LL_IsStallEP(USBD_HandleTypeDef * pdev, uint8_t ep_addr) { PCD_HandleTypeDef *hpcd = (PCD_HandleTypeDef *) pdev->pData; if ((ep_addr & 0x80) == 0x80) { return hpcd->IN_ep[ep_addr & 0x7F].is_stall; } else { return hpcd->OUT_ep[ep_addr & 0x7F].is_stall; } } /** * @brief Assigns a USB address to the device. * @param pdev: Device handle * @param ep_addr: Endpoint Number * @retval USBD Status */ USBD_StatusTypeDef USBD_LL_SetUSBAddress(USBD_HandleTypeDef * pdev, uint8_t dev_addr) { HAL_PCD_SetAddress((PCD_HandleTypeDef *) pdev->pData, dev_addr); return USBD_OK; } /** * @brief Transmits data over an endpoint. * @param pdev: Device handle * @param ep_addr: Endpoint Number * @param pbuf: Pointer to data to be sent * @param size: Data size * @retval USBD Status */ USBD_StatusTypeDef USBD_LL_Transmit(USBD_HandleTypeDef * pdev, uint8_t ep_addr, uint8_t * pbuf, uint16_t size) { HAL_PCD_EP_Transmit((PCD_HandleTypeDef *) pdev->pData, ep_addr, pbuf, size); return USBD_OK; } /** * @brief Prepares an endpoint for reception. * @param pdev: Device handle * @param ep_addr: Endpoint Number * @param pbuf: Pointer to data to be received * @param size: Data size * @retval USBD Status */ USBD_StatusTypeDef USBD_LL_PrepareReceive(USBD_HandleTypeDef * pdev, uint8_t ep_addr, uint8_t * pbuf, uint16_t size) { HAL_PCD_EP_Receive((PCD_HandleTypeDef *) pdev->pData, ep_addr, pbuf, size); return USBD_OK; } /** * @brief Returns the last transferred packet size. * @param pdev: Device handle * @param ep_addr: Endpoint Number * @retval Received Data Size */ uint32_t USBD_LL_GetRxDataSize(USBD_HandleTypeDef * pdev, uint8_t ep_addr) { return HAL_PCD_EP_GetRxCount((PCD_HandleTypeDef *) pdev->pData, ep_addr); } /** * @brief Delays routine for the USB Device Library. * @param Delay: Delay in ms * @retval None */ void USBD_LL_Delay(uint32_t Delay) { HAL_Delay(Delay); } /** * @brief static single allocation. * @param size: size of allocated memory * @retval None */ void *USBD_static_malloc(uint32_t size) { static uint32_t mem[(sizeof(USBD_MSC_BOT_HandleTypeDef) / 4U) + 1U];/* On 32-bit boundary */ return mem; } /** * @brief Dummy memory free * @param *p pointer to allocated memory address * @retval None */ void USBD_static_free(void *p) { } /** * @brief Software Device Connection * @param hpcd: PCD handle * @param state: connection state (0 : disconnected / 1: connected) * @retval None */ void HAL_PCDEx_SetConnectionState(PCD_HandleTypeDef * hpcd, uint8_t state) { if (state != 0) { /* Enabling DP Pull-Down bit to Connect internal pull-up on USB DP line */ HAL_GPIO_WritePin(GPIOB, GPIO_PIN_14, GPIO_PIN_RESET); } else { /* Disable DP Pull-Down bit */ HAL_GPIO_WritePin(GPIOB, GPIO_PIN_14, GPIO_PIN_SET); } }
0
D://workCode//uploadProject\STM32CubeF1\Projects\STM3210E_EVAL\Applications\USB_Device\MSC_Standalone
D://workCode//uploadProject\STM32CubeF1\Projects\STM3210E_EVAL\Applications\USB_Device\MSC_Standalone\Src\usbd_desc.c
/** ****************************************************************************** * @file USB_Device/MSC_Standalone/Src/usbd_desc.c * @author MCD Application Team * @brief This file provides the USBD descriptors and string formatting method. ****************************************************************************** * @attention * * Copyright (c) 2015 STMicroelectronics. * All rights reserved. * * This software is licensed under terms that can be found in the LICENSE file * in the root directory of this software component. * If no LICENSE file comes with this software, it is provided AS-IS. * ****************************************************************************** */ /* Includes ------------------------------------------------------------------ */ #include "usbd_core.h" #include "usbd_desc.h" #include "usbd_conf.h" /* Private typedef ----------------------------------------------------------- */ /* Private define ------------------------------------------------------------ */ #define USBD_VID 0x0483 #define USBD_PID 0x5720 #define USBD_LANGID_STRING 0x409 #define USBD_MANUFACTURER_STRING "STMicroelectronics" #define USBD_PRODUCT_FS_STRING "Mass Storage in FS Mode" #define USBD_CONFIGURATION_FS_STRING "MSC Config" #define USBD_INTERFACE_FS_STRING "MSC Interface" /* Private macro ------------------------------------------------------------- */ /* Private function prototypes ----------------------------------------------- */ uint8_t *USBD_MSC_DeviceDescriptor(USBD_SpeedTypeDef speed, uint16_t * length); uint8_t *USBD_MSC_LangIDStrDescriptor(USBD_SpeedTypeDef speed, uint16_t * length); uint8_t *USBD_MSC_ManufacturerStrDescriptor(USBD_SpeedTypeDef speed, uint16_t * length); uint8_t *USBD_MSC_ProductStrDescriptor(USBD_SpeedTypeDef speed, uint16_t * length); uint8_t *USBD_MSC_SerialStrDescriptor(USBD_SpeedTypeDef speed, uint16_t * length); uint8_t *USBD_MSC_ConfigStrDescriptor(USBD_SpeedTypeDef speed, uint16_t * length); uint8_t *USBD_MSC_InterfaceStrDescriptor(USBD_SpeedTypeDef speed, uint16_t * length); /* Private variables --------------------------------------------------------- */ USBD_DescriptorsTypeDef MSC_Desc = { USBD_MSC_DeviceDescriptor, USBD_MSC_LangIDStrDescriptor, USBD_MSC_ManufacturerStrDescriptor, USBD_MSC_ProductStrDescriptor, USBD_MSC_SerialStrDescriptor, USBD_MSC_ConfigStrDescriptor, USBD_MSC_InterfaceStrDescriptor, }; /* USB Standard Device Descriptor */ #if defined ( __ICCARM__ ) /*!< IAR Compiler */ #pragma data_alignment=4 #endif __ALIGN_BEGIN uint8_t USBD_DeviceDesc[USB_LEN_DEV_DESC] __ALIGN_END = { 0x12, /* bLength */ USB_DESC_TYPE_DEVICE, /* bDescriptorType */ 0x00, /* bcdUSB */ 0x02, 0x00, /* bDeviceClass */ 0x00, /* bDeviceSubClass */ 0x00, /* bDeviceProtocol */ USB_MAX_EP0_SIZE, /* bMaxPacketSize */ LOBYTE(USBD_VID), /* idVendor */ HIBYTE(USBD_VID), /* idVendor */ LOBYTE(USBD_PID), /* idVendor */ HIBYTE(USBD_PID), /* idVendor */ 0x00, /* bcdDevice rel. 2.00 */ 0x02, USBD_IDX_MFC_STR, /* Index of manufacturer string */ USBD_IDX_PRODUCT_STR, /* Index of product string */ USBD_IDX_SERIAL_STR, /* Index of serial number string */ USBD_MAX_NUM_CONFIGURATION /* bNumConfigurations */ }; /* USB_DeviceDescriptor */ /* USB Standard Device Descriptor */ #if defined ( __ICCARM__ ) /*!< IAR Compiler */ #pragma data_alignment=4 #endif __ALIGN_BEGIN uint8_t USBD_LangIDDesc[USB_LEN_LANGID_STR_DESC] __ALIGN_END = { USB_LEN_LANGID_STR_DESC, USB_DESC_TYPE_STRING, LOBYTE(USBD_LANGID_STRING), HIBYTE(USBD_LANGID_STRING), }; #if defined ( __ICCARM__ ) /*!< IAR Compiler */ #pragma data_alignment=4 #endif __ALIGN_BEGIN uint8_t USBD_StringSerial[USB_SIZ_STRING_SERIAL] __ALIGN_END = { USB_SIZ_STRING_SERIAL, USB_DESC_TYPE_STRING, }; #if defined ( __ICCARM__ ) /*!< IAR Compiler */ #pragma data_alignment=4 #endif __ALIGN_BEGIN uint8_t USBD_StrDesc[USBD_MAX_STR_DESC_SIZ] __ALIGN_END; /* Private functions --------------------------------------------------------- */ static void IntToUnicode(uint32_t value, uint8_t * pbuf, uint8_t len); static void Get_SerialNum(void); /** * @brief Returns the device descriptor. * @param speed: Current device speed * @param length: Pointer to data length variable * @retval Pointer to descriptor buffer */ uint8_t *USBD_MSC_DeviceDescriptor(USBD_SpeedTypeDef speed, uint16_t * length) { *length = sizeof(USBD_DeviceDesc); return (uint8_t *) USBD_DeviceDesc; } /** * @brief Returns the LangID string descriptor. * @param speed: Current device speed * @param length: Pointer to data length variable * @retval Pointer to descriptor buffer */ uint8_t *USBD_MSC_LangIDStrDescriptor(USBD_SpeedTypeDef speed, uint16_t * length) { *length = sizeof(USBD_LangIDDesc); return (uint8_t *) USBD_LangIDDesc; } /** * @brief Returns the product string descriptor. * @param speed: Current device speed * @param length: Pointer to data length variable * @retval Pointer to descriptor buffer */ uint8_t *USBD_MSC_ProductStrDescriptor(USBD_SpeedTypeDef speed, uint16_t * length) { USBD_GetString((uint8_t *) USBD_PRODUCT_FS_STRING, USBD_StrDesc, length); return USBD_StrDesc; } /** * @brief Returns the manufacturer string descriptor. * @param speed: Current device speed * @param length: Pointer to data length variable * @retval Pointer to descriptor buffer */ uint8_t *USBD_MSC_ManufacturerStrDescriptor(USBD_SpeedTypeDef speed, uint16_t * length) { USBD_GetString((uint8_t *) USBD_MANUFACTURER_STRING, USBD_StrDesc, length); return USBD_StrDesc; } /** * @brief Returns the serial number string descriptor. * @param speed: Current device speed * @param length: Pointer to data length variable * @retval Pointer to descriptor buffer */ uint8_t *USBD_MSC_SerialStrDescriptor(USBD_SpeedTypeDef speed, uint16_t * length) { *length = USB_SIZ_STRING_SERIAL; /* Update the serial number string descriptor with the data from the unique * ID */ Get_SerialNum(); return USBD_StringSerial; } /** * @brief Returns the configuration string descriptor. * @param speed: Current device speed * @param length: Pointer to data length variable * @retval Pointer to descriptor buffer */ uint8_t *USBD_MSC_ConfigStrDescriptor(USBD_SpeedTypeDef speed, uint16_t * length) { USBD_GetString((uint8_t *) USBD_CONFIGURATION_FS_STRING, USBD_StrDesc, length); return USBD_StrDesc; } /** * @brief Returns the interface string descriptor. * @param speed: Current device speed * @param length: Pointer to data length variable * @retval Pointer to descriptor buffer */ uint8_t *USBD_MSC_InterfaceStrDescriptor(USBD_SpeedTypeDef speed, uint16_t * length) { USBD_GetString((uint8_t *) USBD_INTERFACE_FS_STRING, USBD_StrDesc, length); return USBD_StrDesc; } /** * @brief Create the serial number string descriptor * @param None * @retval None */ static void Get_SerialNum(void) { uint32_t deviceserial0, deviceserial1, deviceserial2; deviceserial0 = *(uint32_t *) DEVICE_ID1; deviceserial1 = *(uint32_t *) DEVICE_ID2; deviceserial2 = *(uint32_t *) DEVICE_ID3; deviceserial0 += deviceserial2; if (deviceserial0 != 0) { IntToUnicode(deviceserial0, &USBD_StringSerial[2], 8); IntToUnicode(deviceserial1, &USBD_StringSerial[18], 4); } } /** * @brief Convert Hex 32Bits value into char * @param value: value to convert * @param pbuf: pointer to the buffer * @param len: buffer length * @retval None */ static void IntToUnicode(uint32_t value, uint8_t * pbuf, uint8_t len) { uint8_t idx = 0; for (idx = 0; idx < len; idx++) { if (((value >> 28)) < 0xA) { pbuf[2 * idx] = (value >> 28) + '0'; } else { pbuf[2 * idx] = (value >> 28) + 'A' - 10; } value = value << 4; pbuf[2 * idx + 1] = 0; } }
0
D://workCode//uploadProject\STM32CubeF1\Projects\STM3210E_EVAL\Applications\USB_Device\MSC_Standalone
D://workCode//uploadProject\STM32CubeF1\Projects\STM3210E_EVAL\Applications\USB_Device\MSC_Standalone\Src\usbd_storage.c
/** ****************************************************************************** * @file USB_Device/MSC_Standalone/Src/usbd_storage.c * @author MCD Application Team * @brief Memory management layer ****************************************************************************** * @attention * * Copyright (c) 2015 STMicroelectronics. * All rights reserved. * * This software is licensed under terms that can be found in the LICENSE file * in the root directory of this software component. * If no LICENSE file comes with this software, it is provided AS-IS. * ****************************************************************************** */ /* Includes ------------------------------------------------------------------ */ #include "usbd_storage.h" #include "stm3210e_eval_sd.h" /* Private typedef ----------------------------------------------------------- */ /* Private define ------------------------------------------------------------ */ #define STORAGE_LUN_NBR 1 #define STORAGE_BLK_NBR 0x10000 #define STORAGE_BLK_SIZ 0x200 /* Private macro ------------------------------------------------------------- */ /* Private variables --------------------------------------------------------- */ __IO uint32_t writestatus, readstatus = 0; /* USB Mass storage Standard Inquiry Data */ int8_t STORAGE_Inquirydata[] = { /* 36 */ /* LUN 0 */ 0x00, 0x80, 0x02, 0x02, (STANDARD_INQUIRY_DATA_LEN - 5), 0x00, 0x00, 0x00, 'S', 'T', 'M', ' ', ' ', ' ', ' ', ' ', /* Manufacturer: 8 bytes */ 'P', 'r', 'o', 'd', 'u', 'c', 't', ' ', /* Product : 16 Bytes */ ' ', ' ', ' ', ' ', ' ', ' ', ' ', ' ', '0', '.', '0', '1', /* Version : 4 Bytes */ }; /* Private function prototypes ----------------------------------------------- */ int8_t STORAGE_Init(uint8_t lun); int8_t STORAGE_GetCapacity(uint8_t lun, uint32_t * block_num, uint16_t * block_size); int8_t STORAGE_IsReady(uint8_t lun); int8_t STORAGE_IsWriteProtected(uint8_t lun); int8_t STORAGE_Read(uint8_t lun, uint8_t * buf, uint32_t blk_addr, uint16_t blk_len); int8_t STORAGE_Write(uint8_t lun, uint8_t * buf, uint32_t blk_addr, uint16_t blk_len); int8_t STORAGE_GetMaxLun(void); USBD_StorageTypeDef USBD_DISK_fops = { STORAGE_Init, STORAGE_GetCapacity, STORAGE_IsReady, STORAGE_IsWriteProtected, STORAGE_Read, STORAGE_Write, STORAGE_GetMaxLun, STORAGE_Inquirydata, }; /* Private functions --------------------------------------------------------- */ /** * @brief Initializes the storage unit (medium) * @param lun: Logical unit number * @retval Status (0 : Ok / -1 : Error) */ int8_t STORAGE_Init(uint8_t lun) { BSP_SD_Init(); return 0; } /** * @brief Returns the medium capacity. * @param lun: Logical unit number * @param block_num: Number of total block number * @param block_size: Block size * @retval Status (0: Ok / -1: Error) */ int8_t STORAGE_GetCapacity(uint8_t lun, uint32_t * block_num, uint16_t * block_size) { HAL_SD_CardInfoTypeDef info; int8_t ret = -1; if (BSP_SD_IsDetected() != SD_NOT_PRESENT) { BSP_SD_GetCardInfo(&info); *block_num = info.LogBlockNbr - 1; *block_size = info.LogBlockSize; ret = 0; } return ret; } /** * @brief Checks whether the medium is ready. * @param lun: Logical unit number * @retval Status (0: Ok / -1: Error) */ int8_t STORAGE_IsReady(uint8_t lun) { static int8_t prev_status = 0; int8_t ret = -1; if (BSP_SD_IsDetected() != SD_NOT_PRESENT) { if (prev_status < 0) { BSP_SD_Init(); prev_status = 0; } if (BSP_SD_GetCardState() == SD_TRANSFER_OK) { ret = 0; } } else if (prev_status == 0) { prev_status = -1; } return ret; } /** * @brief Checks whether the medium is write protected. * @param lun: Logical unit number * @retval Status (0: write enabled / -1: otherwise) */ int8_t STORAGE_IsWriteProtected(uint8_t lun) { return 0; } /** * @brief Reads data from the medium. * @param lun: Logical unit number * @param blk_addr: Logical block address * @param blk_len: Blocks number * @retval Status (0: Ok / -1: Error) */ int8_t STORAGE_Read(uint8_t lun, uint8_t * buf, uint32_t blk_addr, uint16_t blk_len) { int8_t ret = -1; if (BSP_SD_IsDetected() != SD_NOT_PRESENT) { BSP_SD_ReadBlocks((uint32_t *) buf, blk_addr, blk_len, 1000); /* Wait until SD card is ready to use for new operation */ while (BSP_SD_GetCardState() != SD_TRANSFER_OK) { } ret = 0; } return ret; } /** * @brief Writes data into the medium. * @param lun: Logical unit number * @param blk_addr: Logical block address * @param blk_len: Blocks number * @retval Status (0 : Ok / -1 : Error) */ int8_t STORAGE_Write(uint8_t lun, uint8_t * buf, uint32_t blk_addr, uint16_t blk_len) { int8_t ret = -1; if (BSP_SD_IsDetected() != SD_NOT_PRESENT) { BSP_SD_WriteBlocks((uint32_t *) buf, blk_addr, blk_len, 1000); /* Wait until SD card is ready to use for new operation */ while (BSP_SD_GetCardState() != SD_TRANSFER_OK) { } ret = 0; } return ret; } /** * @brief Returns the Max Supported LUNs. * @param None * @retval Lun(s) number */ int8_t STORAGE_GetMaxLun(void) { return (STORAGE_LUN_NBR - 1); } /** * @brief BSP Tx Transfer completed callbacks * @param None * @retval None */ void BSP_SD_WriteCpltCallback(void) { writestatus = 1; } /** * @brief BSP Rx Transfer completed callbacks * @param None * @retval None */ void BSP_SD_ReadCpltCallback(void) { readstatus = 1; }
0
D://workCode//uploadProject\STM32CubeF1\Projects\STM3210E_EVAL\Examples\ADC\ADC_Sequencer
D://workCode//uploadProject\STM32CubeF1\Projects\STM3210E_EVAL\Examples\ADC\ADC_Sequencer\Inc\main.h
/** ****************************************************************************** * @file ADC/ADC_Sequencer/Inc/main.h * @author MCD Application Team * @brief Header for main.c module ****************************************************************************** * @attention * * Copyright (c) 2016 STMicroelectronics. * All rights reserved. * * This software is licensed under terms that can be found in the LICENSE file * in the root directory of this software component. * If no LICENSE file comes with this software, it is provided AS-IS. * ****************************************************************************** */ /* Define to prevent recursive inclusion -------------------------------------*/ #ifndef __MAIN_H #define __MAIN_H /* Includes ------------------------------------------------------------------*/ #include "stm32f1xx_hal.h" #include "stm3210e_eval.h" /* Exported types ------------------------------------------------------------*/ /* Exported constants --------------------------------------------------------*/ /* Waveform voltage generation for test: */ /* - If this literal is defined: For this example purpose, generates a */ /* waveform voltage on a spare DAC channel, so user has just to connect */ /* a wire between DAC channel output and ADC input to run this example. */ /* (this avoid to user the need of an external signal generator). */ /* - If this literal is not defined: User has to connect an external signal */ /* generator on the selected ADC input to run this example. */ #define WAVEFORM_VOLTAGE_GENERATION_FOR_TEST /* User can use this section to tailor ADCx instance under use and associated resources */ /* ## Definition of ADC related resources ################################### */ /* Definition of ADCx clock resources */ #define ADCx ADC1 #define ADCx_CLK_ENABLE() __HAL_RCC_ADC1_CLK_ENABLE() #define ADCx_FORCE_RESET() __HAL_RCC_ADC1_FORCE_RESET() #define ADCx_RELEASE_RESET() __HAL_RCC_ADC1_RELEASE_RESET() /* Definition of ADCx channels */ #define ADCx_CHANNELa ADC_CHANNEL_4 /* Definition of ADCx channels pins */ #define ADCx_CHANNELa_GPIO_CLK_ENABLE() __HAL_RCC_GPIOA_CLK_ENABLE() #define ADCx_CHANNELa_GPIO_PORT GPIOA #define ADCx_CHANNELa_PIN GPIO_PIN_4 /* Definition of ADCx DMA resources */ #define ADCx_DMA_CLK_ENABLE() __HAL_RCC_DMA1_CLK_ENABLE() #define ADCx_DMA DMA1_Channel1 #define ADCx_DMA_IRQn DMA1_Channel1_IRQn #define ADCx_DMA_IRQHandler DMA1_Channel1_IRQHandler /* Definition of ADCx NVIC resources */ #define ADCx_IRQn ADC1_2_IRQn #define ADCx_IRQHandler ADC1_2_IRQHandler #if defined(WAVEFORM_VOLTAGE_GENERATION_FOR_TEST) /* ## Definition of DAC related resources ################################### */ /* Definition of DACx clock resources */ #define DACx DAC #define DACx_CLK_ENABLE() __HAL_RCC_DAC_CLK_ENABLE() #define DACx_CHANNEL_GPIO_CLK_ENABLE() __HAL_RCC_GPIOA_CLK_ENABLE() #define DACx_FORCE_RESET() __HAL_RCC_DAC_FORCE_RESET() #define DACx_RELEASE_RESET() __HAL_RCC_DAC_RELEASE_RESET() /* Definition of DACx channels */ #define DACx_CHANNEL_TO_ADCx_CHANNELa DAC_CHANNEL_1 /* Definition of DACx channels pins */ #define DACx_CHANNEL_TO_ADCx_CHANNELa_PIN GPIO_PIN_4 #define DACx_CHANNEL_TO_ADCx_CHANNELa_GPIO_PORT GPIOA #endif /* WAVEFORM_VOLTAGE_GENERATION_FOR_TEST */ /* Exported macro ------------------------------------------------------------*/ /* Exported functions ------------------------------------------------------- */ #endif /* __MAIN_H */
0
D://workCode//uploadProject\STM32CubeF1\Projects\STM3210E_EVAL\Examples\ADC\ADC_Sequencer
D://workCode//uploadProject\STM32CubeF1\Projects\STM3210E_EVAL\Examples\ADC\ADC_Sequencer\Inc\stm32f1xx_hal_conf.h
/** ****************************************************************************** * @file stm32f1xx_hal_conf.h * @author MCD Application Team * @brief HAL configuration file. ****************************************************************************** * @attention * * Copyright (c) 2016 STMicroelectronics. * All rights reserved. * * This software is licensed under terms that can be found in the LICENSE file * in the root directory of this software component. * If no LICENSE file comes with this software, it is provided AS-IS. * ****************************************************************************** */ /* Define to prevent recursive inclusion -------------------------------------*/ #ifndef __STM32F1xx_HAL_CONF_H #define __STM32F1xx_HAL_CONF_H #ifdef __cplusplus extern "C" { #endif /* Exported types ------------------------------------------------------------*/ /* Exported constants --------------------------------------------------------*/ /* ########################## Module Selection ############################## */ /** * @brief This is the list of modules to be used in the HAL driver */ #define HAL_MODULE_ENABLED #define HAL_ADC_MODULE_ENABLED /* #define HAL_CAN_MODULE_ENABLED */ /* #define HAL_CAN_LEGACY_MODULE_ENABLED */ /* #define HAL_CEC_MODULE_ENABLED */ #define HAL_CORTEX_MODULE_ENABLED /* #define HAL_CRC_MODULE_ENABLED */ #define HAL_DAC_MODULE_ENABLED #define HAL_DMA_MODULE_ENABLED /* #define HAL_ETH_MODULE_ENABLED */ /* #define HAL_EXTI_MODULE_ENABLED */ #define HAL_FLASH_MODULE_ENABLED #define HAL_GPIO_MODULE_ENABLED /* #define HAL_HCD_MODULE_ENABLED */ /* #define HAL_I2C_MODULE_ENABLED */ /* #define HAL_I2S_MODULE_ENABLED */ /* #define HAL_IRDA_MODULE_ENABLED */ /* #define HAL_IWDG_MODULE_ENABLED */ /* #define HAL_NAND_MODULE_ENABLED */ /* #define HAL_NOR_MODULE_ENABLED */ /* #define HAL_PCCARD_MODULE_ENABLED */ /* #define HAL_PCD_MODULE_ENABLED */ /* #define HAL_PWR_MODULE_ENABLED */ #define HAL_RCC_MODULE_ENABLED /* #define HAL_RTC_MODULE_ENABLED */ /* #define HAL_SD_MODULE_ENABLED */ /* #define HAL_SMARTCARD_MODULE_ENABLED */ /* #define HAL_SPI_MODULE_ENABLED */ /* #define HAL_SRAM_MODULE_ENABLED */ #define HAL_TIM_MODULE_ENABLED /* #define HAL_UART_MODULE_ENABLED */ /* #define HAL_USART_MODULE_ENABLED */ /* #define HAL_WWDG_MODULE_ENABLED */ /* #define HAL_MMC_MODULE_ENABLED */ /* ########################## Oscillator Values adaptation ####################*/ /** * @brief Adjust the value of External High Speed oscillator (HSE) used in your application. * This value is used by the RCC HAL module to compute the system frequency * (when HSE is used as system clock source, directly or through the PLL). */ #if !defined (HSE_VALUE) #if defined(USE_STM3210C_EVAL) #define HSE_VALUE 25000000U /*!< Value of the External oscillator in Hz */ #else #define HSE_VALUE 8000000U /*!< Value of the External oscillator in Hz */ #endif #endif /* HSE_VALUE */ #if !defined (HSE_STARTUP_TIMEOUT) #define HSE_STARTUP_TIMEOUT 100U /*!< Time out for HSE start up, in ms */ #endif /* HSE_STARTUP_TIMEOUT */ /** * @brief Internal High Speed oscillator (HSI) value. * This value is used by the RCC HAL module to compute the system frequency * (when HSI is used as system clock source, directly or through the PLL). */ #if !defined (HSI_VALUE) #define HSI_VALUE 8000000U /*!< Value of the Internal oscillator in Hz */ #endif /* HSI_VALUE */ /** * @brief Internal Low Speed oscillator (LSI) value. */ #if !defined (LSI_VALUE) #define LSI_VALUE 40000U /*!< LSI Typical Value in Hz */ #endif /* LSI_VALUE */ /*!< Value of the Internal Low Speed oscillator in Hz The real value may vary depending on the variations in voltage and temperature. */ /** * @brief External Low Speed oscillator (LSE) value. * This value is used by the UART, RTC HAL module to compute the system frequency */ #if !defined (LSE_VALUE) #define LSE_VALUE 32768U /*!< Value of the External oscillator in Hz*/ #endif /* LSE_VALUE */ #if !defined (LSE_STARTUP_TIMEOUT) #define LSE_STARTUP_TIMEOUT 5000U /*!< Time out for LSE start up, in ms */ #endif /* LSE_STARTUP_TIMEOUT */ /* Tip: To avoid modifying this file each time you need to use different HSE, === you can define the HSE value in your toolchain compiler preprocessor. */ /* ########################### System Configuration ######################### */ /** * @brief This is the HAL system configuration section */ #define VDD_VALUE 3300U /*!< Value of VDD in mv */ #define TICK_INT_PRIORITY 0x0FU /*!< tick interrupt priority */ #define USE_RTOS 0U #define PREFETCH_ENABLE 1U #define USE_HAL_ADC_REGISTER_CALLBACKS 0U /* ADC register callback disabled */ #define USE_HAL_CAN_REGISTER_CALLBACKS 0U /* CAN register callback disabled */ #define USE_HAL_CEC_REGISTER_CALLBACKS 0U /* CEC register callback disabled */ #define USE_HAL_DAC_REGISTER_CALLBACKS 0U /* DAC register callback disabled */ #define USE_HAL_ETH_REGISTER_CALLBACKS 0U /* ETH register callback disabled */ #define USE_HAL_HCD_REGISTER_CALLBACKS 0U /* HCD register callback disabled */ #define USE_HAL_I2C_REGISTER_CALLBACKS 0U /* I2C register callback disabled */ #define USE_HAL_I2S_REGISTER_CALLBACKS 0U /* I2S register callback disabled */ #define USE_HAL_MMC_REGISTER_CALLBACKS 0U /* MMC register callback disabled */ #define USE_HAL_NAND_REGISTER_CALLBACKS 0U /* NAND register callback disabled */ #define USE_HAL_NOR_REGISTER_CALLBACKS 0U /* NOR register callback disabled */ #define USE_HAL_PCCARD_REGISTER_CALLBACKS 0U /* PCCARD register callback disabled */ #define USE_HAL_PCD_REGISTER_CALLBACKS 0U /* PCD register callback disabled */ #define USE_HAL_RTC_REGISTER_CALLBACKS 0U /* RTC register callback disabled */ #define USE_HAL_SD_REGISTER_CALLBACKS 0U /* SD register callback disabled */ #define USE_HAL_SMARTCARD_REGISTER_CALLBACKS 0U /* SMARTCARD register callback disabled */ #define USE_HAL_IRDA_REGISTER_CALLBACKS 0U /* IRDA register callback disabled */ #define USE_HAL_SRAM_REGISTER_CALLBACKS 0U /* SRAM register callback disabled */ #define USE_HAL_SPI_REGISTER_CALLBACKS 0U /* SPI register callback disabled */ #define USE_HAL_TIM_REGISTER_CALLBACKS 0U /* TIM register callback disabled */ #define USE_HAL_UART_REGISTER_CALLBACKS 0U /* UART register callback disabled */ #define USE_HAL_USART_REGISTER_CALLBACKS 0U /* USART register callback disabled */ #define USE_HAL_WWDG_REGISTER_CALLBACKS 0U /* WWDG register callback disabled */ /* ########################## Assert Selection ############################## */ /** * @brief Uncomment the line below to expanse the "assert_param" macro in the * HAL drivers code */ /* #define USE_FULL_ASSERT 1U */ /* ################## Ethernet peripheral configuration ##################### */ /* Section 1 : Ethernet peripheral configuration */ /* MAC ADDRESS: MAC_ADDR0:MAC_ADDR1:MAC_ADDR2:MAC_ADDR3:MAC_ADDR4:MAC_ADDR5 */ #define MAC_ADDR0 2U #define MAC_ADDR1 0U #define MAC_ADDR2 0U #define MAC_ADDR3 0U #define MAC_ADDR4 0U #define MAC_ADDR5 0U /* Definition of the Ethernet driver buffers size and count */ #define ETH_RX_BUF_SIZE ETH_MAX_PACKET_SIZE /* buffer size for receive */ #define ETH_TX_BUF_SIZE ETH_MAX_PACKET_SIZE /* buffer size for transmit */ #define ETH_RXBUFNB 8U /* 8 Rx buffers of size ETH_RX_BUF_SIZE */ #define ETH_TXBUFNB 4U /* 4 Tx buffers of size ETH_TX_BUF_SIZE */ /* Section 2: PHY configuration section */ /* DP83848 PHY Address*/ #define DP83848_PHY_ADDRESS 0x01U /* PHY Reset delay these values are based on a 1 ms Systick interrupt*/ #define PHY_RESET_DELAY 0x000000FFU /* PHY Configuration delay */ #define PHY_CONFIG_DELAY 0x00000FFFU #define PHY_READ_TO 0x0000FFFFU #define PHY_WRITE_TO 0x0000FFFFU /* Section 3: Common PHY Registers */ #define PHY_BCR ((uint16_t)0x0000) /*!< Transceiver Basic Control Register */ #define PHY_BSR ((uint16_t)0x0001) /*!< Transceiver Basic Status Register */ #define PHY_RESET ((uint16_t)0x8000) /*!< PHY Reset */ #define PHY_LOOPBACK ((uint16_t)0x4000) /*!< Select loop-back mode */ #define PHY_FULLDUPLEX_100M ((uint16_t)0x2100) /*!< Set the full-duplex mode at 100 Mb/s */ #define PHY_HALFDUPLEX_100M ((uint16_t)0x2000) /*!< Set the half-duplex mode at 100 Mb/s */ #define PHY_FULLDUPLEX_10M ((uint16_t)0x0100) /*!< Set the full-duplex mode at 10 Mb/s */ #define PHY_HALFDUPLEX_10M ((uint16_t)0x0000) /*!< Set the half-duplex mode at 10 Mb/s */ #define PHY_AUTONEGOTIATION ((uint16_t)0x1000) /*!< Enable auto-negotiation function */ #define PHY_RESTART_AUTONEGOTIATION ((uint16_t)0x0200) /*!< Restart auto-negotiation function */ #define PHY_POWERDOWN ((uint16_t)0x0800) /*!< Select the power down mode */ #define PHY_ISOLATE ((uint16_t)0x0400) /*!< Isolate PHY from MII */ #define PHY_AUTONEGO_COMPLETE ((uint16_t)0x0020) /*!< Auto-Negotiation process completed */ #define PHY_LINKED_STATUS ((uint16_t)0x0004) /*!< Valid link established */ #define PHY_JABBER_DETECTION ((uint16_t)0x0002) /*!< Jabber condition detected */ /* Section 4: Extended PHY Registers */ #define PHY_SR ((uint16_t)0x0010) /*!< PHY status register Offset */ #define PHY_MICR ((uint16_t)0x0011) /*!< MII Interrupt Control Register */ #define PHY_MISR ((uint16_t)0x0012) /*!< MII Interrupt Status and Misc. Control Register */ #define PHY_LINK_STATUS ((uint16_t)0x0001) /*!< PHY Link mask */ #define PHY_SPEED_STATUS ((uint16_t)0x0002) /*!< PHY Speed mask */ #define PHY_DUPLEX_STATUS ((uint16_t)0x0004) /*!< PHY Duplex mask */ #define PHY_MICR_INT_EN ((uint16_t)0x0002) /*!< PHY Enable interrupts */ #define PHY_MICR_INT_OE ((uint16_t)0x0001) /*!< PHY Enable output interrupt events */ #define PHY_MISR_LINK_INT_EN ((uint16_t)0x0020) /*!< Enable Interrupt on change of link status */ #define PHY_LINK_INTERRUPT ((uint16_t)0x2000) /*!< PHY link status interrupt mask */ /* ################## SPI peripheral configuration ########################## */ /* CRC FEATURE: Use to activate CRC feature inside HAL SPI Driver * Activated: CRC code is present inside driver * Deactivated: CRC code cleaned from driver */ #define USE_SPI_CRC 1U /* Includes ------------------------------------------------------------------*/ /** * @brief Include module's header file */ #ifdef HAL_RCC_MODULE_ENABLED #include "stm32f1xx_hal_rcc.h" #endif /* HAL_RCC_MODULE_ENABLED */ #ifdef HAL_GPIO_MODULE_ENABLED #include "stm32f1xx_hal_gpio.h" #endif /* HAL_GPIO_MODULE_ENABLED */ #ifdef HAL_EXTI_MODULE_ENABLED #include "stm32f1xx_hal_exti.h" #endif /* HAL_EXTI_MODULE_ENABLED */ #ifdef HAL_DMA_MODULE_ENABLED #include "stm32f1xx_hal_dma.h" #endif /* HAL_DMA_MODULE_ENABLED */ #ifdef HAL_ETH_MODULE_ENABLED #include "stm32f1xx_hal_eth.h" #endif /* HAL_ETH_MODULE_ENABLED */ #ifdef HAL_CAN_MODULE_ENABLED #include "stm32f1xx_hal_can.h" #endif /* HAL_CAN_MODULE_ENABLED */ #ifdef HAL_CAN_LEGACY_MODULE_ENABLED #include "Legacy/stm32f1xx_hal_can_legacy.h" #endif /* HAL_CAN_LEGACY_MODULE_ENABLED */ #ifdef HAL_CEC_MODULE_ENABLED #include "stm32f1xx_hal_cec.h" #endif /* HAL_CEC_MODULE_ENABLED */ #ifdef HAL_CORTEX_MODULE_ENABLED #include "stm32f1xx_hal_cortex.h" #endif /* HAL_CORTEX_MODULE_ENABLED */ #ifdef HAL_ADC_MODULE_ENABLED #include "stm32f1xx_hal_adc.h" #endif /* HAL_ADC_MODULE_ENABLED */ #ifdef HAL_CRC_MODULE_ENABLED #include "stm32f1xx_hal_crc.h" #endif /* HAL_CRC_MODULE_ENABLED */ #ifdef HAL_DAC_MODULE_ENABLED #include "stm32f1xx_hal_dac.h" #endif /* HAL_DAC_MODULE_ENABLED */ #ifdef HAL_FLASH_MODULE_ENABLED #include "stm32f1xx_hal_flash.h" #endif /* HAL_FLASH_MODULE_ENABLED */ #ifdef HAL_SRAM_MODULE_ENABLED #include "stm32f1xx_hal_sram.h" #endif /* HAL_SRAM_MODULE_ENABLED */ #ifdef HAL_NOR_MODULE_ENABLED #include "stm32f1xx_hal_nor.h" #endif /* HAL_NOR_MODULE_ENABLED */ #ifdef HAL_I2C_MODULE_ENABLED #include "stm32f1xx_hal_i2c.h" #endif /* HAL_I2C_MODULE_ENABLED */ #ifdef HAL_I2S_MODULE_ENABLED #include "stm32f1xx_hal_i2s.h" #endif /* HAL_I2S_MODULE_ENABLED */ #ifdef HAL_IWDG_MODULE_ENABLED #include "stm32f1xx_hal_iwdg.h" #endif /* HAL_IWDG_MODULE_ENABLED */ #ifdef HAL_PWR_MODULE_ENABLED #include "stm32f1xx_hal_pwr.h" #endif /* HAL_PWR_MODULE_ENABLED */ #ifdef HAL_RTC_MODULE_ENABLED #include "stm32f1xx_hal_rtc.h" #endif /* HAL_RTC_MODULE_ENABLED */ #ifdef HAL_PCCARD_MODULE_ENABLED #include "stm32f1xx_hal_pccard.h" #endif /* HAL_PCCARD_MODULE_ENABLED */ #ifdef HAL_SD_MODULE_ENABLED #include "stm32f1xx_hal_sd.h" #endif /* HAL_SD_MODULE_ENABLED */ #ifdef HAL_NAND_MODULE_ENABLED #include "stm32f1xx_hal_nand.h" #endif /* HAL_NAND_MODULE_ENABLED */ #ifdef HAL_SPI_MODULE_ENABLED #include "stm32f1xx_hal_spi.h" #endif /* HAL_SPI_MODULE_ENABLED */ #ifdef HAL_TIM_MODULE_ENABLED #include "stm32f1xx_hal_tim.h" #endif /* HAL_TIM_MODULE_ENABLED */ #ifdef HAL_UART_MODULE_ENABLED #include "stm32f1xx_hal_uart.h" #endif /* HAL_UART_MODULE_ENABLED */ #ifdef HAL_USART_MODULE_ENABLED #include "stm32f1xx_hal_usart.h" #endif /* HAL_USART_MODULE_ENABLED */ #ifdef HAL_IRDA_MODULE_ENABLED #include "stm32f1xx_hal_irda.h" #endif /* HAL_IRDA_MODULE_ENABLED */ #ifdef HAL_SMARTCARD_MODULE_ENABLED #include "stm32f1xx_hal_smartcard.h" #endif /* HAL_SMARTCARD_MODULE_ENABLED */ #ifdef HAL_WWDG_MODULE_ENABLED #include "stm32f1xx_hal_wwdg.h" #endif /* HAL_WWDG_MODULE_ENABLED */ #ifdef HAL_PCD_MODULE_ENABLED #include "stm32f1xx_hal_pcd.h" #endif /* HAL_PCD_MODULE_ENABLED */ #ifdef HAL_HCD_MODULE_ENABLED #include "stm32f1xx_hal_hcd.h" #endif /* HAL_HCD_MODULE_ENABLED */ #ifdef HAL_MMC_MODULE_ENABLED #include "stm32f1xx_hal_mmc.h" #endif /* HAL_MMC_MODULE_ENABLED */ /* Exported macro ------------------------------------------------------------*/ #ifdef USE_FULL_ASSERT /** * @brief The assert_param macro is used for function's parameters check. * @param expr: If expr is false, it calls assert_failed function * which reports the name of the source file and the source * line number of the call that failed. * If expr is true, it returns no value. * @retval None */ #define assert_param(expr) ((expr) ? (void)0U : assert_failed((uint8_t *)__FILE__, __LINE__)) /* Exported functions ------------------------------------------------------- */ void assert_failed(uint8_t* file, uint32_t line); #else #define assert_param(expr) ((void)0U) #endif /* USE_FULL_ASSERT */ #ifdef __cplusplus } #endif #endif /* __STM32F1xx_HAL_CONF_H */
0
D://workCode//uploadProject\STM32CubeF1\Projects\STM3210E_EVAL\Examples\ADC\ADC_Sequencer
D://workCode//uploadProject\STM32CubeF1\Projects\STM3210E_EVAL\Examples\ADC\ADC_Sequencer\Inc\stm32f1xx_it.h
/** ****************************************************************************** * @file ADC/ADC_Sequencer/Inc/stm32f1xx_it.h * @author MCD Application Team * @brief This file contains the headers of the interrupt handlers. ****************************************************************************** * @attention * * Copyright (c) 2016 STMicroelectronics. * All rights reserved. * * This software is licensed under terms that can be found in the LICENSE file * in the root directory of this software component. * If no LICENSE file comes with this software, it is provided AS-IS. * ****************************************************************************** */ /* Define to prevent recursive inclusion -------------------------------------*/ #ifndef __STM32F1xx_IT_H #define __STM32F1xx_IT_H #ifdef __cplusplus extern "C" { #endif /* Includes ------------------------------------------------------------------*/ /* Exported types ------------------------------------------------------------*/ /* Exported constants --------------------------------------------------------*/ /* Exported macro ------------------------------------------------------------*/ /* Exported functions ------------------------------------------------------- */ void NMI_Handler(void); void HardFault_Handler(void); void MemManage_Handler(void); void BusFault_Handler(void); void UsageFault_Handler(void); void SVC_Handler(void); void DebugMon_Handler(void); void PendSV_Handler(void); void SysTick_Handler(void); void EXTI9_5_IRQHandler(void); void ADCx_IRQHandler(void); void ADCx_DMA_IRQHandler(void); #ifdef __cplusplus } #endif #endif /* __STM32F1xx_IT_H */
0
D://workCode//uploadProject\STM32CubeF1\Projects\STM3210E_EVAL\Examples\ADC\ADC_Sequencer
D://workCode//uploadProject\STM32CubeF1\Projects\STM3210E_EVAL\Examples\ADC\ADC_Sequencer\Src\main.c
/** ****************************************************************************** * @file ADC/ADC_Sequencer/Src/main.c * @author MCD Application Team * @brief This example provides a short description of how to use the ADC * peripheral with sequencer, to convert several channels. * Channels converted are 1 channel on external pin and 2 internal * channels (VrefInt and temperature sensor). * Moreover, voltage and temperature are then computed. ****************************************************************************** * @attention * * Copyright (c) 2016 STMicroelectronics. * All rights reserved. * * This software is licensed under terms that can be found in the LICENSE file * in the root directory of this software component. * If no LICENSE file comes with this software, it is provided AS-IS. * ****************************************************************************** */ /* Includes ------------------------------------------------------------------*/ #include "main.h" /** @addtogroup STM32F1xx_HAL_Examples * @{ */ /** @addtogroup ADC_Sequencer * @{ */ /* Private typedef -----------------------------------------------------------*/ /* Private define ------------------------------------------------------------*/ #define VDD_APPLI ((uint32_t) 3300) /* Value of analog voltage supply Vdda (unit: mV) */ #define RANGE_12BITS ((uint32_t) 4095) /* Max value with a full range of 12 bits */ #define USERBUTTON_CLICK_COUNT_MAX ((uint32_t) 4) /* Maximum value of variable "UserButtonClickCount" */ #define ADCCONVERTEDVALUES_BUFFER_SIZE ((uint32_t) 3) /* Size of array containing ADC converted values: set to ADC sequencer number of ranks converted, to have a rank in each address */ /* Internal temperature sensor: constants data used for indicative values in */ /* this example. Refer to device datasheet for min/typ/max values. */ /* For more accurate values, device should be calibrated on offset and slope */ /* for application temperature range. */ #define INTERNAL_TEMPSENSOR_V25 ((int32_t)1430) /* Internal temperature sensor, parameter V25 (unit: mV). Refer to device datasheet for min/typ/max values. */ #define INTERNAL_TEMPSENSOR_AVGSLOPE ((int32_t)4300) /* Internal temperature sensor, parameter Avg_Slope (unit: uV/DegCelsius). Refer to device datasheet for min/typ/max values. */ /* This calibration parameter is intended to calculate the actual VDDA from Vrefint ADC measurement. */ /* Private macro -------------------------------------------------------------*/ /** * @brief Computation of temperature (unit: degree Celsius) from the internal * temperature sensor measurement by ADC. * Computation is using temperature sensor standard parameters (refer * to device datasheet). * Computation formula: * Temperature = (VTS - V25)/Avg_Slope + 25 * with VTS = temperature sensor voltage * Avg_Slope = temperature sensor slope (unit: uV/DegCelsius) * V25 = temperature sensor @25degC and Vdda 3.3V (unit: mV) * Calculation validity conditioned to settings: * - ADC resolution 12 bits (need to scale value if using a different * resolution). * - Power supply of analog voltage Vdda 3.3V (need to scale value * if using a different analog voltage supply value). * @param TS_ADC_DATA: Temperature sensor digital value measured by ADC * @retval None */ #define COMPUTATION_TEMPERATURE_STD_PARAMS(TS_ADC_DATA) \ ((((int32_t)(INTERNAL_TEMPSENSOR_V25 - (((TS_ADC_DATA) * VDD_APPLI) / RANGE_12BITS) \ ) * 1000 \ ) / INTERNAL_TEMPSENSOR_AVGSLOPE \ ) + 25 \ ) /** * @brief Computation of voltage (unit: mV) from ADC measurement digital * value on range 12 bits. * Calculation validity conditioned to settings: * - ADC resolution 12 bits (need to scale value if using a different * resolution). * - Power supply of analog voltage Vdda 3.3V (need to scale value * if using a different analog voltage supply value). * @param ADC_DATA: Digital value measured by ADC * @retval None */ #define COMPUTATION_DIGITAL_12BITS_TO_VOLTAGE(ADC_DATA) \ ( (ADC_DATA) * VDD_APPLI / RANGE_12BITS) /* Private variables ---------------------------------------------------------*/ /* ADC handler declaration */ ADC_HandleTypeDef AdcHandle; #if defined(WAVEFORM_VOLTAGE_GENERATION_FOR_TEST) /* DAC handler declaration */ DAC_HandleTypeDef DacHandle; #endif /* WAVEFORM_VOLTAGE_GENERATION_FOR_TEST */ /* Variable containing ADC conversions results */ __IO uint16_t aADCxConvertedValues[ADCCONVERTEDVALUES_BUFFER_SIZE]; /* Variables for ADC conversions results computation to physical values */ uint16_t uhADCChannelToDAC_mVolt = 0; uint16_t uhVrefInt_mVolt = 0; int32_t wTemperature_DegreeCelsius = 0; /* Variables to manage push button on board: interface between ExtLine interruption and main program */ uint8_t ubUserButtonClickCount = 0; /* Count number of clicks: Incremented after User Button interrupt */ __IO uint8_t ubUserButtonClickEvent = RESET; /* Event detection: Set after User Button interrupt */ /* Variable to report ADC sequencer status */ uint8_t ubSequenceCompleted = RESET; /* Set when all ranks of the sequence have been converted */ /* Private function prototypes -----------------------------------------------*/ void SystemClock_Config(void); static void Error_Handler(void); static void ADC_Config(void); #if defined(WAVEFORM_VOLTAGE_GENERATION_FOR_TEST) static void DAC_Config(void); #endif /* WAVEFORM_VOLTAGE_GENERATION_FOR_TEST */ /* Private functions ---------------------------------------------------------*/ /** * @brief Main program. * @param None * @retval None */ int main(void) { /* STM32F103xG HAL library initialization: - Configure the Flash prefetch - Systick timer is configured by default as source of time base, but user can eventually implement his proper time base source (a general purpose timer for example or other time source), keeping in mind that Time base duration should be kept 1ms since PPP_TIMEOUT_VALUEs are defined and handled in milliseconds basis. - Set NVIC Group Priority to 4 - Low Level Initialization */ HAL_Init(); /* Configure the system clock to 72 MHz */ SystemClock_Config(); /*## Configure peripherals #################################################*/ /* Initialize LEDs on board */ BSP_LED_Init(LED3); BSP_LED_Init(LED1); /* Configure Key push-button in Interrupt mode */ BSP_PB_Init(BUTTON_KEY, BUTTON_MODE_EXTI); /* Configure the ADC peripheral */ ADC_Config(); /* Run the ADC calibration */ if (HAL_ADCEx_Calibration_Start(&AdcHandle) != HAL_OK) { /* Calibration Error */ Error_Handler(); } #if defined(WAVEFORM_VOLTAGE_GENERATION_FOR_TEST) /* Configure the DAC peripheral */ DAC_Config(); #endif /* WAVEFORM_VOLTAGE_GENERATION_FOR_TEST */ /*## Enable peripherals ####################################################*/ #if defined(WAVEFORM_VOLTAGE_GENERATION_FOR_TEST) /* Set DAC Channel data register: channel corresponding to ADC channel CHANNELa */ /* Set DAC output to 1/2 of full range (4095 <=> Vdda=3.3V): 2048 <=> 1.65V */ if (HAL_DAC_SetValue(&DacHandle, DACx_CHANNEL_TO_ADCx_CHANNELa, DAC_ALIGN_12B_R, RANGE_12BITS/2) != HAL_OK) { /* Setting value Error */ Error_Handler(); } /* Enable DAC Channel: channel corresponding to ADC channel CHANNELa */ if (HAL_DAC_Start(&DacHandle, DACx_CHANNEL_TO_ADCx_CHANNELa) != HAL_OK) { /* Start Error */ Error_Handler(); } #endif /* WAVEFORM_VOLTAGE_GENERATION_FOR_TEST */ /*## Start ADC conversions #################################################*/ /* Start ADC conversion on regular group with transfer by DMA */ if (HAL_ADC_Start_DMA(&AdcHandle, (uint32_t *)aADCxConvertedValues, ADCCONVERTEDVALUES_BUFFER_SIZE ) != HAL_OK) { /* Start Error */ Error_Handler(); } /* Infinite loop */ while (1) { /* Wait for event on push button to perform following actions */ while ((ubUserButtonClickEvent) == RESET) { } /* Reset variable for next loop iteration */ ubUserButtonClickEvent = RESET; #if defined(WAVEFORM_VOLTAGE_GENERATION_FOR_TEST) /* Set DAC voltage on channel corresponding to ADCx_CHANNELa */ /* in function of user button clicks count. */ /* Set DAC output successively to: */ /* - minimum of full range (0 <=> ground 0V) */ /* - 1/4 of full range (4095 <=> Vdda=3.3V): 1023 <=> 0.825V */ /* - 1/2 of full range (4095 <=> Vdda=3.3V): 2048 <=> 1.65V */ /* - 3/4 of full range (4095 <=> Vdda=3.3V): 3071 <=> 2.475V */ /* - maximum of full range (4095 <=> Vdda=3.3V) */ if (HAL_DAC_SetValue(&DacHandle, DACx_CHANNEL_TO_ADCx_CHANNELa, DAC_ALIGN_12B_R, (RANGE_12BITS * ubUserButtonClickCount / USERBUTTON_CLICK_COUNT_MAX) ) != HAL_OK) { /* Start Error */ Error_Handler(); } #endif /* WAVEFORM_VOLTAGE_GENERATION_FOR_TEST */ /* Wait for DAC settling time */ HAL_Delay(1); /* Start ADC conversion */ /* Since sequencer is enabled in discontinuous mode, this will perform */ /* the conversion of the next rank in sequencer. */ /* Note: For this example, conversion is triggered by software start, */ /* therefore "HAL_ADC_Start()" must be called for each conversion. */ /* Since DMA transfer has been initiated previously by function */ /* "HAL_ADC_Start_DMA()", this function will keep DMA transfer */ /* active. */ HAL_ADC_Start(&AdcHandle); /* Wait for conversion completion before conditional check hereafter */ HAL_ADC_PollForConversion(&AdcHandle, 1); /* Turn-on/off LED1 in function of ADC sequencer status */ /* - Turn-off if sequencer has not yet converted all ranks */ /* - Turn-on if sequencer has converted all ranks */ if (ubSequenceCompleted == RESET) { BSP_LED_Off(LED1); } else { BSP_LED_On(LED1); /* Computation of ADC conversions raw data to physical values */ /* Note: ADC results are transferred into array "aADCxConvertedValues" */ /* in the order of their rank in ADC sequencer. */ uhADCChannelToDAC_mVolt = COMPUTATION_DIGITAL_12BITS_TO_VOLTAGE(aADCxConvertedValues[0]); uhVrefInt_mVolt = COMPUTATION_DIGITAL_12BITS_TO_VOLTAGE(aADCxConvertedValues[2]); wTemperature_DegreeCelsius = COMPUTATION_TEMPERATURE_STD_PARAMS(aADCxConvertedValues[1]); /* Reset variable for next loop iteration */ ubSequenceCompleted = RESET; } } } /** * @brief System Clock Configuration * The system Clock is configured as follow : * System Clock source = PLL (HSE) * SYSCLK(Hz) = 72000000 * HCLK(Hz) = 72000000 * AHB Prescaler = 1 * APB1 Prescaler = 2 * APB2 Prescaler = 1 * HSE Frequency(Hz) = 8000000 * HSE PREDIV1 = 1 * PLLMUL = 9 * Flash Latency(WS) = 2 * @param None * @retval None */ void SystemClock_Config(void) { RCC_ClkInitTypeDef clkinitstruct = {0}; RCC_OscInitTypeDef oscinitstruct = {0}; /* Enable HSE Oscillator and activate PLL with HSE as source */ oscinitstruct.OscillatorType = RCC_OSCILLATORTYPE_HSE; oscinitstruct.HSEState = RCC_HSE_ON; oscinitstruct.HSEPredivValue = RCC_HSE_PREDIV_DIV1; oscinitstruct.PLL.PLLState = RCC_PLL_ON; oscinitstruct.PLL.PLLSource = RCC_PLLSOURCE_HSE; oscinitstruct.PLL.PLLMUL = RCC_PLL_MUL9; if (HAL_RCC_OscConfig(&oscinitstruct)!= HAL_OK) { /* Initialization Error */ while(1); } /* Select PLL as system clock source and configure the HCLK, PCLK1 and PCLK2 clocks dividers */ clkinitstruct.ClockType = (RCC_CLOCKTYPE_SYSCLK | RCC_CLOCKTYPE_HCLK | RCC_CLOCKTYPE_PCLK1 | RCC_CLOCKTYPE_PCLK2); clkinitstruct.SYSCLKSource = RCC_SYSCLKSOURCE_PLLCLK; clkinitstruct.AHBCLKDivider = RCC_SYSCLK_DIV1; clkinitstruct.APB2CLKDivider = RCC_HCLK_DIV1; clkinitstruct.APB1CLKDivider = RCC_HCLK_DIV2; if (HAL_RCC_ClockConfig(&clkinitstruct, FLASH_LATENCY_2)!= HAL_OK) { /* Initialization Error */ while(1); } } /** * @brief ADC configuration * @param None * @retval None */ static void ADC_Config(void) { ADC_ChannelConfTypeDef sConfig; /* Configuration of ADCx init structure: ADC parameters and regular group */ AdcHandle.Instance = ADCx; AdcHandle.Init.DataAlign = ADC_DATAALIGN_RIGHT; AdcHandle.Init.ScanConvMode = ADC_SCAN_ENABLE; /* Sequencer disabled (ADC conversion on only 1 channel: channel set on rank 1) */ AdcHandle.Init.ContinuousConvMode = DISABLE; /* Continuous mode disabled to have only 1 rank converted at each conversion trig, and because discontinuous mode is enabled */ AdcHandle.Init.NbrOfConversion = 3; /* Sequencer of regular group will convert the 3 first ranks: rank1, rank2, rank3 */ AdcHandle.Init.DiscontinuousConvMode = ENABLE; /* Sequencer of regular group will convert the sequence in several sub-divided sequences */ AdcHandle.Init.NbrOfDiscConversion = 1; /* Sequencer of regular group will convert ranks one by one, at each conversion trig */ AdcHandle.Init.ExternalTrigConv = ADC_SOFTWARE_START; /* Trig of conversion start done manually by software, without external event */ if (HAL_ADC_Init(&AdcHandle) != HAL_OK) { /* ADC initialization error */ Error_Handler(); } /* Configuration of channel on ADCx regular group on sequencer rank 1 */ /* Note: Considering IT occurring after each ADC conversion (IT by DMA end */ /* of transfer), select sampling time and ADC clock with sufficient */ /* duration to not create an overhead situation in IRQHandler. */ /* Note: Set long sampling time due to internal channels (VrefInt, */ /* temperature sensor) constraints. Refer to device datasheet for */ /* min/typ/max values. */ sConfig.Channel = ADCx_CHANNELa; sConfig.Rank = ADC_REGULAR_RANK_1; sConfig.SamplingTime = ADC_SAMPLETIME_71CYCLES_5; if (HAL_ADC_ConfigChannel(&AdcHandle, &sConfig) != HAL_OK) { /* Channel Configuration Error */ Error_Handler(); } /* Configuration of channel on ADCx regular group on sequencer rank 2 */ /* Replicate previous rank settings, change only channel and rank */ sConfig.Channel = ADC_CHANNEL_TEMPSENSOR; sConfig.Rank = ADC_REGULAR_RANK_2; if (HAL_ADC_ConfigChannel(&AdcHandle, &sConfig) != HAL_OK) { /* Channel Configuration Error */ Error_Handler(); } /* Configuration of channel on ADCx regular group on sequencer rank 3 */ /* Replicate previous rank settings, change only channel and rank */ sConfig.Channel = ADC_CHANNEL_VREFINT; sConfig.Rank = ADC_REGULAR_RANK_3; if (HAL_ADC_ConfigChannel(&AdcHandle, &sConfig) != HAL_OK) { /* Channel Configuration Error */ Error_Handler(); } } #if defined(WAVEFORM_VOLTAGE_GENERATION_FOR_TEST) /** * @brief DAC configuration * @param None * @retval None */ static void DAC_Config(void) { static DAC_ChannelConfTypeDef sConfig; /* Configuration of DACx peripheral */ DacHandle.Instance = DACx; if (HAL_DAC_Init(&DacHandle) != HAL_OK) { /* DAC initialization error */ Error_Handler(); } /* Configuration of DAC channel */ sConfig.DAC_Trigger = DAC_TRIGGER_NONE; sConfig.DAC_OutputBuffer = DAC_OUTPUTBUFFER_ENABLE; if (HAL_DAC_ConfigChannel(&DacHandle, &sConfig, DACx_CHANNEL_TO_ADCx_CHANNELa) != HAL_OK) { /* Channel configuration error */ Error_Handler(); } } #endif /* WAVEFORM_VOLTAGE_GENERATION_FOR_TEST */ /** * @brief EXTI line detection callbacks * @param GPIO_Pin: Specifies the pins connected EXTI line * @retval None */ void HAL_GPIO_EXTI_Callback(uint16_t GPIO_Pin) { if (GPIO_Pin == KEY_BUTTON_PIN) { /* Set variable to report push button event to main program */ ubUserButtonClickEvent = SET; /* Manage ubUserButtonClickCount to increment it circularly from 0 to */ /* maximum value defined */ if (ubUserButtonClickCount < USERBUTTON_CLICK_COUNT_MAX) { ubUserButtonClickCount++; } else { ubUserButtonClickCount=0; } } } /** * @brief Conversion complete callback in non blocking mode * @param AdcHandle : AdcHandle handle * @note This example shows a simple way to report end of conversion * and get conversion result. You can add your own implementation. * @retval None */ void HAL_ADC_ConvCpltCallback(ADC_HandleTypeDef *AdcHandle) { /* Report to main program that ADC sequencer has reached its end */ ubSequenceCompleted = SET; } /** * @brief Conversion DMA half-transfer callback in non blocking mode * @param hadc: ADC handle * @retval None */ void HAL_ADC_ConvHalfCpltCallback(ADC_HandleTypeDef* hadc) { } /** * @brief ADC error callback in non blocking mode * (ADC conversion with interruption or transfer by DMA) * @param hadc: ADC handle * @retval None */ void HAL_ADC_ErrorCallback(ADC_HandleTypeDef *hadc) { /* In case of ADC error, call main error handler */ Error_Handler(); } /** * @brief This function is executed in case of error occurrence. * @param None * @retval None */ static void Error_Handler(void) { /* User may add here some code to deal with a potential error */ /* In case of error, LED3 is toggling at a frequency of 1Hz */ while(1) { /* Toggle LED3 */ BSP_LED_Toggle(LED3); HAL_Delay(500); } } #ifdef USE_FULL_ASSERT /** * @brief Reports the name of the source file and the source line number * where the assert_param error has occurred. * @param file: pointer to the source file name * @param line: assert_param error line source number * @retval None */ void assert_failed(uint8_t *file, uint32_t line) { /* User can add his own implementation to report the file name and line number, ex: printf("Wrong parameters value: file %s on line %d\r\n", file, line) */ /* Infinite loop */ while (1) { } } #endif /** * @} */ /** * @} */
0
D://workCode//uploadProject\STM32CubeF1\Projects\STM3210E_EVAL\Examples\ADC\ADC_Sequencer
D://workCode//uploadProject\STM32CubeF1\Projects\STM3210E_EVAL\Examples\ADC\ADC_Sequencer\Src\stm32f1xx_hal_msp.c
/** ****************************************************************************** * @file ADC/ADC_Sequencer/Src/stm32f1xx_hal_msp.c * @author MCD Application Team * @brief HAL MSP module. ****************************************************************************** * @attention * * Copyright (c) 2016 STMicroelectronics. * All rights reserved. * * This software is licensed under terms that can be found in the LICENSE file * in the root directory of this software component. * If no LICENSE file comes with this software, it is provided AS-IS. * ****************************************************************************** */ /* Includes ------------------------------------------------------------------*/ #include "main.h" /** @addtogroup STM32F1xx_HAL_Examples * @{ */ /** @defgroup ADC_Sequencer * @{ */ /* Private typedef -----------------------------------------------------------*/ /* Private define ------------------------------------------------------------*/ /* Private macro -------------------------------------------------------------*/ /* Private variables ---------------------------------------------------------*/ /* Private function prototypes -----------------------------------------------*/ /* Private functions ---------------------------------------------------------*/ /** @defgroup HAL_MSP_Private_Functions * @{ */ /** * @brief ADC MSP initialization * This function configures the hardware resources used in this example: * - Enable clock of ADC peripheral * - Configure the GPIO associated to the peripheral channels * - Configure the DMA associated to the peripheral * - Configure the NVIC associated to the peripheral interruptions * @param hadc: ADC handle pointer * @retval None */ void HAL_ADC_MspInit(ADC_HandleTypeDef *hadc) { GPIO_InitTypeDef GPIO_InitStruct; static DMA_HandleTypeDef DmaHandle; RCC_PeriphCLKInitTypeDef PeriphClkInit; /*##-1- Enable peripherals and GPIO Clocks #################################*/ /* Enable clock of GPIO associated to the peripheral channels */ ADCx_CHANNELa_GPIO_CLK_ENABLE(); /* Enable clock of ADCx peripheral */ ADCx_CLK_ENABLE(); /* Configure ADCx clock prescaler */ /* Caution: On STM32F1, ADC clock frequency max is 14MHz (refer to device */ /* datasheet). */ /* Therefore, ADC clock prescaler must be configured in function */ /* of ADC clock source frequency to remain below this maximum */ /* frequency. */ PeriphClkInit.PeriphClockSelection = RCC_PERIPHCLK_ADC; PeriphClkInit.AdcClockSelection = RCC_ADCPCLK2_DIV6; HAL_RCCEx_PeriphCLKConfig(&PeriphClkInit); /* Enable clock of DMA associated to the peripheral */ ADCx_DMA_CLK_ENABLE(); /*##-2- Configure peripheral GPIO ##########################################*/ /* Configure GPIO pin of the selected ADC channel */ GPIO_InitStruct.Pin = ADCx_CHANNELa_PIN; GPIO_InitStruct.Mode = GPIO_MODE_ANALOG; GPIO_InitStruct.Pull = GPIO_NOPULL; HAL_GPIO_Init(ADCx_CHANNELa_GPIO_PORT, &GPIO_InitStruct); /*##-3- Configure the DMA ##################################################*/ /* Configure DMA parameters */ DmaHandle.Instance = ADCx_DMA; DmaHandle.Init.Direction = DMA_PERIPH_TO_MEMORY; DmaHandle.Init.PeriphInc = DMA_PINC_DISABLE; DmaHandle.Init.MemInc = DMA_MINC_ENABLE; DmaHandle.Init.PeriphDataAlignment = DMA_PDATAALIGN_HALFWORD; /* Transfer from ADC by half-word to match with ADC configuration: ADC resolution 10 or 12 bits */ DmaHandle.Init.MemDataAlignment = DMA_MDATAALIGN_HALFWORD; /* Transfer to memory by half-word to match with buffer variable type: half-word */ DmaHandle.Init.Mode = DMA_CIRCULAR; /* DMA in circular mode to match with ADC configuration: DMA continuous requests */ DmaHandle.Init.Priority = DMA_PRIORITY_HIGH; /* Deinitialize & Initialize the DMA for new transfer */ HAL_DMA_DeInit(&DmaHandle); HAL_DMA_Init(&DmaHandle); /* Associate the initialized DMA handle to the ADC handle */ __HAL_LINKDMA(hadc, DMA_Handle, DmaHandle); /*##-4- Configure the NVIC #################################################*/ /* NVIC configuration for DMA interrupt (transfer completion or error) */ /* Priority: high-priority */ HAL_NVIC_SetPriority(ADCx_DMA_IRQn, 1, 0); HAL_NVIC_EnableIRQ(ADCx_DMA_IRQn); /* NVIC configuration for ADC interrupt */ /* Priority: high-priority */ HAL_NVIC_SetPriority(ADCx_IRQn, 0, 0); HAL_NVIC_EnableIRQ(ADCx_IRQn); } /** * @brief ADC MSP de-initialization * This function frees the hardware resources used in this example: * - Disable clock of ADC peripheral * - Revert GPIO associated to the peripheral channels to their default state * - Revert DMA associated to the peripheral to its default state * - Revert NVIC associated to the peripheral interruptions to its default state * @param hadc: ADC handle pointer * @retval None */ void HAL_ADC_MspDeInit(ADC_HandleTypeDef *hadc) { /*##-1- Reset peripherals ##################################################*/ ADCx_FORCE_RESET(); ADCx_RELEASE_RESET(); /*##-2- Disable peripherals and GPIO Clocks ################################*/ /* De-initialize GPIO pin of the selected ADC channel */ HAL_GPIO_DeInit(ADCx_CHANNELa_GPIO_PORT, ADCx_CHANNELa_PIN); /*##-3- Disable the DMA ####################################################*/ /* De-Initialize the DMA associated to the peripheral */ if(hadc->DMA_Handle != NULL) { HAL_DMA_DeInit(hadc->DMA_Handle); } /*##-4- Disable the NVIC ###################################################*/ /* Disable the NVIC configuration for DMA interrupt */ HAL_NVIC_DisableIRQ(ADCx_DMA_IRQn); /* Disable the NVIC configuration for ADC interrupt */ HAL_NVIC_DisableIRQ(ADCx_IRQn); } #if defined(WAVEFORM_VOLTAGE_GENERATION_FOR_TEST) /** * @brief DAC MSP initialization * This function configures the hardware resources used in this example: * - Enable clock of peripheral * - Configure the GPIO associated to the peripheral channels * - Configure the NVIC associated to the peripheral interruptions * @param hdac: DAC handle pointer * @retval None */ void HAL_DAC_MspInit(DAC_HandleTypeDef *hdac) { GPIO_InitTypeDef GPIO_InitStruct; /*##-1- Enable peripherals and GPIO Clocks #################################*/ /* Enable GPIO clock */ DACx_CHANNEL_GPIO_CLK_ENABLE(); /* DAC peripheral clock enable */ DACx_CLK_ENABLE(); /*##-2- Configure peripheral GPIO ##########################################*/ /* Configure GPIO pin of the selected DAC channel */ GPIO_InitStruct.Pin = DACx_CHANNEL_TO_ADCx_CHANNELa_PIN; GPIO_InitStruct.Mode = GPIO_MODE_ANALOG; GPIO_InitStruct.Pull = GPIO_NOPULL; HAL_GPIO_Init(DACx_CHANNEL_TO_ADCx_CHANNELa_GPIO_PORT, &GPIO_InitStruct); /*##-3- Configure the NVIC #################################################*/ /* Note: On this device, DAC has no interruption (no underrun IT) */ } /** * @brief DAC MSP de-initialization * This function frees the hardware resources used in this example: * - Disable clock of peripheral * - Revert GPIO associated to the peripheral channels to their default state * - Revert NVIC associated to the peripheral interruptions to its default state * @param hadc: DAC handle pointer * @retval None */ void HAL_DAC_MspDeInit(DAC_HandleTypeDef *hdac) { /*##-1- Reset peripherals ##################################################*/ DACx_FORCE_RESET(); DACx_RELEASE_RESET(); /*##-2- Disable peripherals and GPIO Clocks ################################*/ /* De-initialize GPIO pin of the selected DAC channel */ HAL_GPIO_DeInit(DACx_CHANNEL_TO_ADCx_CHANNELa_GPIO_PORT, DACx_CHANNEL_TO_ADCx_CHANNELa_PIN); /*##-3- Disable the NVIC for DAC ###########################################*/ /* Note: On this device, DAC has no interruption (no underrun IT) */ } #endif /* WAVEFORM_VOLTAGE_GENERATION_FOR_TEST */ /** * @} */ /** * @} */ /** * @} */
0
D://workCode//uploadProject\STM32CubeF1\Projects\STM3210E_EVAL\Examples\ADC\ADC_Sequencer
D://workCode//uploadProject\STM32CubeF1\Projects\STM3210E_EVAL\Examples\ADC\ADC_Sequencer\Src\stm32f1xx_it.c
/** ****************************************************************************** * @file ADC/ADC_Sequencer/Src/stm32f1xx_it.c * @author MCD Application Team * @brief Main Interrupt Service Routines. * This file provides template for all exceptions handler and * peripherals interrupt service routine. ****************************************************************************** * @attention * * Copyright (c) 2016 STMicroelectronics. * All rights reserved. * * This software is licensed under terms that can be found in the LICENSE file * in the root directory of this software component. * If no LICENSE file comes with this software, it is provided AS-IS. * ****************************************************************************** */ /* Includes ------------------------------------------------------------------*/ #include "main.h" #include "stm32f1xx_it.h" /** @addtogroup STM32F1xx_HAL_Examples * @{ */ /** @addtogroup ADC_Sequencer * @{ */ /* Private typedef -----------------------------------------------------------*/ /* Private define ------------------------------------------------------------*/ /* Private macro -------------------------------------------------------------*/ /* Private variables ---------------------------------------------------------*/ extern ADC_HandleTypeDef AdcHandle; /* Private function prototypes -----------------------------------------------*/ /* Private functions ---------------------------------------------------------*/ /******************************************************************************/ /* Cortex-M3 Processor Exceptions Handlers */ /******************************************************************************/ /** * @brief This function handles NMI exception. * @param None * @retval None */ void NMI_Handler(void) { } /** * @brief This function handles Hard Fault exception. * @param None * @retval None */ void HardFault_Handler(void) { /* Go to infinite loop when Hard Fault exception occurs */ while (1) { } } /** * @brief This function handles Memory Manage exception. * @param None * @retval None */ void MemManage_Handler(void) { /* Go to infinite loop when Memory Manage exception occurs */ while (1) { } } /** * @brief This function handles Bus Fault exception. * @param None * @retval None */ void BusFault_Handler(void) { /* Go to infinite loop when Bus Fault exception occurs */ while (1) { } } /** * @brief This function handles Usage Fault exception. * @param None * @retval None */ void UsageFault_Handler(void) { /* Go to infinite loop when Usage Fault exception occurs */ while (1) { } } /** * @brief This function handles SVCall exception. * @param None * @retval None */ void SVC_Handler(void) { } /** * @brief This function handles Debug Monitor exception. * @param None * @retval None */ void DebugMon_Handler(void) { } /** * @brief This function handles PendSVC exception. * @param None * @retval None */ void PendSV_Handler(void) { } /** * @brief This function handles SysTick Handler. * @param None * @retval None */ void SysTick_Handler(void) { HAL_IncTick(); } /******************************************************************************/ /* STM32F1xx Peripherals Interrupt Handlers */ /* Add here the Interrupt Handler for the used peripheral(s) (PPP), for the */ /* available peripheral interrupt handler's name please refer to the startup */ /* file (startup_stm32f1xx.s). */ /******************************************************************************/ /** * @brief This function handles external lines 9 to 5 interrupt request. * @param None * @retval None */ void EXTI9_5_IRQHandler(void) { HAL_GPIO_EXTI_IRQHandler(KEY_BUTTON_PIN); } /** * @brief This function handles ADC interrupt request. * @param None * @retval None */ void ADCx_IRQHandler(void) { HAL_ADC_IRQHandler(&AdcHandle); } /** * @brief This function handles DMA interrupt request. * @param None * @retval None */ void ADCx_DMA_IRQHandler(void) { HAL_DMA_IRQHandler(AdcHandle.DMA_Handle); } /** * @brief This function handles PPP interrupt request. * @param None * @retval None */ /*void PPP_IRQHandler(void) { }*/ /** * @} */ /** * @} */
0
D://workCode//uploadProject\STM32CubeF1\Projects\STM3210E_EVAL\Examples\ADC\ADC_Sequencer
D://workCode//uploadProject\STM32CubeF1\Projects\STM3210E_EVAL\Examples\ADC\ADC_Sequencer\Src\system_stm32f1xx.c
/** ****************************************************************************** * @file system_stm32f1xx.c * @author MCD Application Team * @brief CMSIS Cortex-M3 Device Peripheral Access Layer System Source File. * * 1. This file provides two functions and one global variable to be called from * user application: * - SystemInit(): Setups the system clock (System clock source, PLL Multiplier * factors, AHB/APBx prescalers and Flash settings). * This function is called at startup just after reset and * before branch to main program. This call is made inside * the "startup_stm32f1xx_xx.s" file. * * - SystemCoreClock variable: Contains the core clock (HCLK), it can be used * by the user application to setup the SysTick * timer or configure other parameters. * * - SystemCoreClockUpdate(): Updates the variable SystemCoreClock and must * be called whenever the core clock is changed * during program execution. * * 2. After each device reset the HSI (8 MHz) is used as system clock source. * Then SystemInit() function is called, in "startup_stm32f1xx_xx.s" file, to * configure the system clock before to branch to main program. * * 4. The default value of HSE crystal is set to 8 MHz (or 25 MHz, depending on * the product used), refer to "HSE_VALUE". * When HSE is used as system clock source, directly or through PLL, and you * are using different crystal you have to adapt the HSE value to your own * configuration. * ****************************************************************************** * @attention * * Copyright (c) 2016 STMicroelectronics. * All rights reserved. * * This software is licensed under terms that can be found in the LICENSE file * in the root directory of this software component. * If no LICENSE file comes with this software, it is provided AS-IS. * ****************************************************************************** */ /** @addtogroup CMSIS * @{ */ /** @addtogroup stm32f1xx_system * @{ */ /** @addtogroup STM32F1xx_System_Private_Includes * @{ */ #include "stm32f1xx.h" /** * @} */ /** @addtogroup STM32F1xx_System_Private_TypesDefinitions * @{ */ /** * @} */ /** @addtogroup STM32F1xx_System_Private_Defines * @{ */ #if !defined (HSE_VALUE) #define HSE_VALUE ((uint32_t)8000000) /*!< Default value of the External oscillator in Hz. This value can be provided and adapted by the user application. */ #endif /* HSE_VALUE */ #if !defined (HSI_VALUE) #define HSI_VALUE ((uint32_t)8000000) /*!< Default value of the Internal oscillator in Hz. This value can be provided and adapted by the user application. */ #endif /* HSI_VALUE */ /*!< Uncomment the following line if you need to use external SRAM */ #if defined(STM32F100xE) || defined(STM32F101xE) || defined(STM32F101xG) || defined(STM32F103xE) || defined(STM32F103xG) /* #define DATA_IN_ExtSRAM */ #endif /* STM32F100xE || STM32F101xE || STM32F101xG || STM32F103xE || STM32F103xG */ /*!< Uncomment the following line if you need to relocate your vector Table in Internal SRAM. */ /* #define VECT_TAB_SRAM */ #define VECT_TAB_OFFSET 0x0 /*!< Vector Table base offset field. This value must be a multiple of 0x200. */ /** * @} */ /** @addtogroup STM32F1xx_System_Private_Macros * @{ */ /** * @} */ /** @addtogroup STM32F1xx_System_Private_Variables * @{ */ /* This variable is updated in three ways: 1) by calling CMSIS function SystemCoreClockUpdate() 2) by calling HAL API function HAL_RCC_GetHCLKFreq() 3) each time HAL_RCC_ClockConfig() is called to configure the system clock frequency Note: If you use this function to configure the system clock; then there is no need to call the 2 first functions listed above, since SystemCoreClock variable is updated automatically. */ uint32_t SystemCoreClock = 16000000; const uint8_t AHBPrescTable[16] = {0, 0, 0, 0, 0, 0, 0, 0, 1, 2, 3, 4, 6, 7, 8, 9}; const uint8_t APBPrescTable[8] = {0, 0, 0, 0, 1, 2, 3, 4}; /** * @} */ /** @addtogroup STM32F1xx_System_Private_FunctionPrototypes * @{ */ #if defined(STM32F100xE) || defined(STM32F101xE) || defined(STM32F101xG) || defined(STM32F103xE) || defined(STM32F103xG) #ifdef DATA_IN_ExtSRAM static void SystemInit_ExtMemCtl(void); #endif /* DATA_IN_ExtSRAM */ #endif /* STM32F100xE || STM32F101xE || STM32F101xG || STM32F103xE || STM32F103xG */ /** * @} */ /** @addtogroup STM32F1xx_System_Private_Functions * @{ */ /** * @brief Setup the microcontroller system * Initialize the Embedded Flash Interface, the PLL and update the * SystemCoreClock variable. * @note This function should be used only after reset. * @param None * @retval None */ void SystemInit (void) { /* Reset the RCC clock configuration to the default reset state(for debug purpose) */ /* Set HSION bit */ RCC->CR |= (uint32_t)0x00000001; /* Reset SW, HPRE, PPRE1, PPRE2, ADCPRE and MCO bits */ #if !defined(STM32F105xC) && !defined(STM32F107xC) RCC->CFGR &= (uint32_t)0xF8FF0000; #else RCC->CFGR &= (uint32_t)0xF0FF0000; #endif /* STM32F105xC */ /* Reset HSEON, CSSON and PLLON bits */ RCC->CR &= (uint32_t)0xFEF6FFFF; /* Reset HSEBYP bit */ RCC->CR &= (uint32_t)0xFFFBFFFF; /* Reset PLLSRC, PLLXTPRE, PLLMUL and USBPRE/OTGFSPRE bits */ RCC->CFGR &= (uint32_t)0xFF80FFFF; #if defined(STM32F105xC) || defined(STM32F107xC) /* Reset PLL2ON and PLL3ON bits */ RCC->CR &= (uint32_t)0xEBFFFFFF; /* Disable all interrupts and clear pending bits */ RCC->CIR = 0x00FF0000; /* Reset CFGR2 register */ RCC->CFGR2 = 0x00000000; #elif defined(STM32F100xB) || defined(STM32F100xE) /* Disable all interrupts and clear pending bits */ RCC->CIR = 0x009F0000; /* Reset CFGR2 register */ RCC->CFGR2 = 0x00000000; #else /* Disable all interrupts and clear pending bits */ RCC->CIR = 0x009F0000; #endif /* STM32F105xC */ #if defined(STM32F100xE) || defined(STM32F101xE) || defined(STM32F101xG) || defined(STM32F103xE) || defined(STM32F103xG) #ifdef DATA_IN_ExtSRAM SystemInit_ExtMemCtl(); #endif /* DATA_IN_ExtSRAM */ #endif #ifdef VECT_TAB_SRAM SCB->VTOR = SRAM_BASE | VECT_TAB_OFFSET; /* Vector Table Relocation in Internal SRAM. */ #else SCB->VTOR = FLASH_BASE | VECT_TAB_OFFSET; /* Vector Table Relocation in Internal FLASH. */ #endif } /** * @brief Update SystemCoreClock variable according to Clock Register Values. * The SystemCoreClock variable contains the core clock (HCLK), it can * be used by the user application to setup the SysTick timer or configure * other parameters. * * @note Each time the core clock (HCLK) changes, this function must be called * to update SystemCoreClock variable value. Otherwise, any configuration * based on this variable will be incorrect. * * @note - The system frequency computed by this function is not the real * frequency in the chip. It is calculated based on the predefined * constant and the selected clock source: * * - If SYSCLK source is HSI, SystemCoreClock will contain the HSI_VALUE(*) * * - If SYSCLK source is HSE, SystemCoreClock will contain the HSE_VALUE(**) * * - If SYSCLK source is PLL, SystemCoreClock will contain the HSE_VALUE(**) * or HSI_VALUE(*) multiplied by the PLL factors. * * (*) HSI_VALUE is a constant defined in stm32f1xx.h file (default value * 8 MHz) but the real value may vary depending on the variations * in voltage and temperature. * * (**) HSE_VALUE is a constant defined in stm32f1xx.h file (default value * 8 MHz or 25 MHz, depending on the product used), user has to ensure * that HSE_VALUE is same as the real frequency of the crystal used. * Otherwise, this function may have wrong result. * * - The result of this function could be not correct when using fractional * value for HSE crystal. * @param None * @retval None */ void SystemCoreClockUpdate (void) { uint32_t tmp = 0, pllmull = 0, pllsource = 0; #if defined(STM32F105xC) || defined(STM32F107xC) uint32_t prediv1source = 0, prediv1factor = 0, prediv2factor = 0, pll2mull = 0; #endif /* STM32F105xC */ #if defined(STM32F100xB) || defined(STM32F100xE) uint32_t prediv1factor = 0; #endif /* STM32F100xB or STM32F100xE */ /* Get SYSCLK source -------------------------------------------------------*/ tmp = RCC->CFGR & RCC_CFGR_SWS; switch (tmp) { case 0x00: /* HSI used as system clock */ SystemCoreClock = HSI_VALUE; break; case 0x04: /* HSE used as system clock */ SystemCoreClock = HSE_VALUE; break; case 0x08: /* PLL used as system clock */ /* Get PLL clock source and multiplication factor ----------------------*/ pllmull = RCC->CFGR & RCC_CFGR_PLLMULL; pllsource = RCC->CFGR & RCC_CFGR_PLLSRC; #if !defined(STM32F105xC) && !defined(STM32F107xC) pllmull = ( pllmull >> 18) + 2; if (pllsource == 0x00) { /* HSI oscillator clock divided by 2 selected as PLL clock entry */ SystemCoreClock = (HSI_VALUE >> 1) * pllmull; } else { #if defined(STM32F100xB) || defined(STM32F100xE) prediv1factor = (RCC->CFGR2 & RCC_CFGR2_PREDIV1) + 1; /* HSE oscillator clock selected as PREDIV1 clock entry */ SystemCoreClock = (HSE_VALUE / prediv1factor) * pllmull; #else /* HSE selected as PLL clock entry */ if ((RCC->CFGR & RCC_CFGR_PLLXTPRE) != (uint32_t)RESET) {/* HSE oscillator clock divided by 2 */ SystemCoreClock = (HSE_VALUE >> 1) * pllmull; } else { SystemCoreClock = HSE_VALUE * pllmull; } #endif } #else pllmull = pllmull >> 18; if (pllmull != 0x0D) { pllmull += 2; } else { /* PLL multiplication factor = PLL input clock * 6.5 */ pllmull = 13 / 2; } if (pllsource == 0x00) { /* HSI oscillator clock divided by 2 selected as PLL clock entry */ SystemCoreClock = (HSI_VALUE >> 1) * pllmull; } else {/* PREDIV1 selected as PLL clock entry */ /* Get PREDIV1 clock source and division factor */ prediv1source = RCC->CFGR2 & RCC_CFGR2_PREDIV1SRC; prediv1factor = (RCC->CFGR2 & RCC_CFGR2_PREDIV1) + 1; if (prediv1source == 0) { /* HSE oscillator clock selected as PREDIV1 clock entry */ SystemCoreClock = (HSE_VALUE / prediv1factor) * pllmull; } else {/* PLL2 clock selected as PREDIV1 clock entry */ /* Get PREDIV2 division factor and PLL2 multiplication factor */ prediv2factor = ((RCC->CFGR2 & RCC_CFGR2_PREDIV2) >> 4) + 1; pll2mull = ((RCC->CFGR2 & RCC_CFGR2_PLL2MUL) >> 8 ) + 2; SystemCoreClock = (((HSE_VALUE / prediv2factor) * pll2mull) / prediv1factor) * pllmull; } } #endif /* STM32F105xC */ break; default: SystemCoreClock = HSI_VALUE; break; } /* Compute HCLK clock frequency ----------------*/ /* Get HCLK prescaler */ tmp = AHBPrescTable[((RCC->CFGR & RCC_CFGR_HPRE) >> 4)]; /* HCLK clock frequency */ SystemCoreClock >>= tmp; } #if defined(STM32F100xE) || defined(STM32F101xE) || defined(STM32F101xG) || defined(STM32F103xE) || defined(STM32F103xG) /** * @brief Setup the external memory controller. Called in startup_stm32f1xx.s * before jump to __main * @param None * @retval None */ #ifdef DATA_IN_ExtSRAM /** * @brief Setup the external memory controller. * Called in startup_stm32f1xx_xx.s/.c before jump to main. * This function configures the external SRAM mounted on STM3210E-EVAL * board (STM32 High density devices). This SRAM will be used as program * data memory (including heap and stack). * @param None * @retval None */ void SystemInit_ExtMemCtl(void) { __IO uint32_t tmpreg; /*!< FSMC Bank1 NOR/SRAM3 is used for the STM3210E-EVAL, if another Bank is required, then adjust the Register Addresses */ /* Enable FSMC clock */ RCC->AHBENR = 0x00000114; /* Delay after an RCC peripheral clock enabling */ tmpreg = READ_BIT(RCC->AHBENR, RCC_AHBENR_FSMCEN); /* Enable GPIOD, GPIOE, GPIOF and GPIOG clocks */ RCC->APB2ENR = 0x000001E0; /* Delay after an RCC peripheral clock enabling */ tmpreg = READ_BIT(RCC->APB2ENR, RCC_APB2ENR_IOPDEN); (void)(tmpreg); /* --------------- SRAM Data lines, NOE and NWE configuration ---------------*/ /*---------------- SRAM Address lines configuration -------------------------*/ /*---------------- NOE and NWE configuration --------------------------------*/ /*---------------- NE3 configuration ----------------------------------------*/ /*---------------- NBL0, NBL1 configuration ---------------------------------*/ GPIOD->CRL = 0x44BB44BB; GPIOD->CRH = 0xBBBBBBBB; GPIOE->CRL = 0xB44444BB; GPIOE->CRH = 0xBBBBBBBB; GPIOF->CRL = 0x44BBBBBB; GPIOF->CRH = 0xBBBB4444; GPIOG->CRL = 0x44BBBBBB; GPIOG->CRH = 0x44444B44; /*---------------- FSMC Configuration ---------------------------------------*/ /*---------------- Enable FSMC Bank1_SRAM Bank ------------------------------*/ FSMC_Bank1->BTCR[4] = 0x00001091; FSMC_Bank1->BTCR[5] = 0x00110212; } #endif /* DATA_IN_ExtSRAM */ #endif /* STM32F100xE || STM32F101xE || STM32F101xG || STM32F103xE || STM32F103xG */ /** * @} */ /** * @} */ /** * @} */
0
D://workCode//uploadProject\STM32CubeF1\Projects\STM3210E_EVAL\Examples\BSP
D://workCode//uploadProject\STM32CubeF1\Projects\STM3210E_EVAL\Examples\BSP\Inc\lcd_log_conf.h
/** ****************************************************************************** * @file lcd_log_conf.h * @author MCD Application Team * @brief lcd_log configuration template file. * This file should be copied to the application folder and modified * as follows: * - Rename it to 'lcd_log_conf.h'. * - Update the name of the LCD driver's header file, depending on * the EVAL board you are using, see line40 below (be default this * file will generate compile error unless you do this modification). ****************************************************************************** * @attention * * Copyright (c) 2016 STMicroelectronics. * All rights reserved. * * This software is licensed under terms that can be found in the LICENSE file * in the root directory of this software component. * If no LICENSE file comes with this software, it is provided AS-IS. * ****************************************************************************** */ /* Define to prevent recursive inclusion -------------------------------------*/ #ifndef __LCD_LOG_CONF_H__ #define __LCD_LOG_CONF_H__ /* Includes ------------------------------------------------------------------*/ #include "stm3210e_eval_lcd.h" #include <stdio.h> /** @addtogroup LCD_LOG * @{ */ /** @defgroup LCD_LOG * @brief This file is the * @{ */ /** @defgroup LCD_LOG_CONF_Exported_Defines * @{ */ /* Comment the line below to disable the scroll back and forward features */ #define LCD_SCROLL_ENABLED 1 /* Define the Fonts */ #define LCD_LOG_HEADER_FONT Font16 #define LCD_LOG_FOOTER_FONT Font12 #define LCD_LOG_TEXT_FONT Font12 /* Define the LCD LOG Color */ #define LCD_LOG_BACKGROUND_COLOR LCD_COLOR_WHITE #define LCD_LOG_TEXT_COLOR LCD_COLOR_DARKBLUE #define LCD_LOG_SOLID_BACKGROUND_COLOR LCD_COLOR_BLUE #define LCD_LOG_SOLID_TEXT_COLOR LCD_COLOR_WHITE /* Define the cache depth */ #define CACHE_SIZE 100 #define YWINDOW_SIZE 14 #if (YWINDOW_SIZE > 14) #error "Wrong YWINDOW SIZE" #endif /* Redirect the printf to the LCD */ #ifdef __GNUC__ /* With GCC, small printf (option LD Linker->Libraries->Small printf set to 'Yes') calls __io_putchar() */ #define LCD_LOG_PUTCHAR int __io_putchar(int ch) #else #define LCD_LOG_PUTCHAR int fputc(int ch, FILE *f) #endif /* __GNUC__ */ /** @defgroup LCD_LOG_CONF_Exported_TypesDefinitions * @{ */ /** * @} */ /** @defgroup LCD_LOG_Exported_Macros * @{ */ /** * @} */ /** @defgroup LCD_LOG_CONF_Exported_Variables * @{ */ /** * @} */ /** @defgroup LCD_LOG_CONF_Exported_FunctionsPrototype * @{ */ /** * @} */ #endif //__LCD_LOG_CONF_H__ /** * @} */ /** * @} */
0
D://workCode//uploadProject\STM32CubeF1\Projects\STM3210E_EVAL\Examples\BSP
D://workCode//uploadProject\STM32CubeF1\Projects\STM3210E_EVAL\Examples\BSP\Inc\main.h
/** ****************************************************************************** * @file main.h * @author MCD Application Team * @brief Header for main.c module ****************************************************************************** * @attention * * Copyright (c) 2016 STMicroelectronics. * All rights reserved. * * This software is licensed under terms that can be found in the LICENSE file * in the root directory of this software component. * If no LICENSE file comes with this software, it is provided AS-IS. * ****************************************************************************** */ /* Define to prevent recursive inclusion -------------------------------------*/ #ifndef __MAIN_H #define __MAIN_H /* Includes ------------------------------------------------------------------*/ #include "stdio.h" #include "string.h" #include "stm32f1xx_hal.h" #include "stm3210e_eval.h" #include "stm3210e_eval_lcd.h" #include "stm3210e_eval_sd.h" #include "stm3210e_eval_audio.h" #include "stm3210e_eval_nor.h" #include "stm3210e_eval_sram.h" #include "stm3210e_eval_nand.h" #include "stm3210e_eval_serialflash.h" #include "stm3210e_eval_tsensor.h" /* Exported types ------------------------------------------------------------*/ typedef struct { void (*DemoFunc)(void); uint8_t DemoName[50]; uint32_t DemoIndex; }BSP_DemoTypedef; /* Exported variables --------------------------------------------------------*/ extern const unsigned char stlogo[]; /* Exported constants --------------------------------------------------------*/ /* Defines for the Audio playing process */ #define PAUSE_STATUS ((uint32_t)0x00) /* Audio Player in Pause Status */ #define RESUME_STATUS ((uint32_t)0x01) /* Audio Player in Resume Status */ #define IDLE_STATUS ((uint32_t)0x02) /* Audio Player in Idle Status */ /* Exported macro ------------------------------------------------------------*/ #define COUNT_OF_EXAMPLE(x) (sizeof(x)/sizeof(BSP_DemoTypedef)) /* Exported functions ------------------------------------------------------- */ void LCD_demo (void); void Log_demo(void); void Joystick_demo (void); void SD_demo (void); void TSENSOR_demo (void); void AudioPlay_demo(void); void NOR_demo(void); void SRAM_demo(void); void NAND_demo(void); void FLASH_demo(void); uint8_t CheckForUserInput(void); void Toggle_Leds(void); void Error_Handler(void); #endif /* __MAIN_H */
0
D://workCode//uploadProject\STM32CubeF1\Projects\STM3210E_EVAL\Examples\BSP
D://workCode//uploadProject\STM32CubeF1\Projects\STM3210E_EVAL\Examples\BSP\Inc\stlogo.h
__ALIGN_END const unsigned char stlogo[9174]= { 0x42,0x4d,0xd6,0x23,0x00,0x00,0x00,0x00,0x00,0x00,0x36,0x00,0x00,0x00,0x28,0x00, 0x00,0x00,0x50,0x00,0x00,0x00,0x39,0x00,0x00,0x00,0x01,0x00,0x10,0x00,0x03,0x00, 0x00,0x00,0xa0,0x23,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00, 0x00,0x00,0x00,0x00,0x00,0x00,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff, 0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff, 0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff, 0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff, 0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff, 0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff, 0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff, 0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff, 0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff, 0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff, 0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff, 0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff, 0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff, 0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff, 0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff, 0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff, 0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff, 0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff, 0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff, 0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff, 0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff, 0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff, 0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff, 0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff, 0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff, 0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff, 0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff, 0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff, 0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff, 0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff, 0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff, 0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff, 0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff, 0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff, 0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff, 0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff, 0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff, 0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff, 0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff, 0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff, 0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff, 0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff, 0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff, 0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff, 0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0x98,0xb5,0xa9,0x08, 0x4b,0x29,0x27,0x00,0xd2,0x7b,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff, 0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff, 0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff, 0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff, 0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff, 0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff, 0x7f,0xd7,0x5f,0xc7,0x1e,0xb7,0x9f,0xdf,0x3f,0xc7,0x5f,0xc7,0x3e,0xc7,0x3f,0xc7, 0x5f,0xc7,0xff,0xff,0xdf,0xf7,0xbe,0x9e,0xbe,0xa6,0xff,0xff,0xff,0xff,0xff,0xf7, 0x9e,0x96,0xff,0xff,0xff,0xff,0xff,0xff,0xd6,0x9c,0x14,0x84,0xdc,0xde,0xfa,0xc5, 0xff,0xff,0xff,0xff,0xb5,0x9c,0x34,0x8c,0x3a,0xce,0x3d,0xef,0xa9,0x08,0x34,0x8c, 0xd6,0x9c,0x1a,0xce,0x04,0x00,0xff,0xff,0xb8,0xbd,0xff,0xff,0xff,0xff,0xf9,0xc5, 0xff,0xff,0xff,0xff,0x98,0xb5,0xbf,0xff,0xff,0xff,0x37,0xad,0xf3,0x7b,0xfd,0xe6, 0xff,0xff,0xdc,0xde,0xdc,0xde,0xff,0xff,0xff,0xff,0x99,0xb5,0xff,0xff,0x9c,0xd6, 0xdc,0xde,0xff,0xff,0xff,0xff,0x57,0xad,0xf3,0x7b,0xdc,0xde,0xff,0xff,0xff,0xff, 0xdf,0xff,0x14,0x84,0x95,0x94,0xfd,0xe6,0x1a,0xc6,0xff,0xff,0xff,0xff,0xff,0xff, 0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff, 0xde,0xae,0xdb,0x14,0xdd,0x5d,0x1e,0xbf,0xfb,0x1c,0x5d,0x7e,0x9e,0x96,0xdb,0x14, 0x9e,0x96,0xdf,0xf7,0xbb,0x04,0x7d,0x8e,0x3d,0x76,0xbb,0x04,0xff,0xff,0x3d,0x7e, 0xbb,0x04,0x3d,0x7e,0xff,0xff,0xc9,0x10,0xcd,0x31,0xf3,0x73,0x07,0x00,0x06,0x00, 0xff,0xff,0xc9,0x10,0x2d,0x3a,0x51,0x63,0x04,0x00,0x54,0x84,0x13,0x84,0x89,0x00, 0xf3,0x7b,0x0a,0x11,0x06,0x00,0xd8,0xbd,0x06,0x00,0xff,0xff,0xff,0xff,0x06,0x00, 0xff,0xff,0xff,0xff,0x05,0x00,0xbc,0xde,0x0d,0x3a,0x2a,0x19,0xd3,0x73,0x05,0x00, 0x78,0xb5,0xb2,0x6b,0x51,0x6b,0xff,0xff,0xff,0xff,0x03,0x00,0xdf,0xff,0x0e,0x3a, 0xb2,0x73,0xff,0xff,0x0d,0x3a,0x0a,0x11,0x14,0x7c,0x05,0x00,0x77,0xad,0xff,0xff, 0x06,0x00,0x10,0x5b,0xf0,0x5a,0x04,0x00,0x4b,0x21,0xff,0xff,0xff,0xff,0xff,0xff, 0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff, 0xff,0xff,0x1c,0x25,0x5f,0xdf,0xff,0xff,0x3a,0x2d,0xdf,0xff,0xff,0xff,0x1c,0x25, 0xff,0xff,0x1d,0x76,0x9e,0x96,0xff,0xff,0xff,0xff,0xff,0xae,0x5f,0xd7,0xff,0xff, 0x7e,0x86,0xff,0xff,0x98,0xb5,0x88,0x08,0xff,0xff,0xff,0xff,0x5d,0xef,0x07,0x00, 0x7e,0xef,0x06,0x00,0xff,0xff,0xff,0xff,0x11,0x5b,0x51,0x6b,0x06,0x00,0xff,0xff, 0xff,0xff,0xff,0xff,0x05,0x00,0x1a,0xc6,0x27,0x00,0xff,0xff,0xff,0xff,0x69,0x08, 0xff,0xff,0xff,0xff,0x27,0x00,0x37,0xa5,0x07,0x00,0xff,0xff,0xdf,0xff,0x3a,0xce, 0xab,0x31,0x14,0x84,0xb2,0x73,0xff,0xff,0xff,0xff,0x06,0x00,0xff,0xff,0xaf,0x52, 0x34,0x84,0x3a,0xce,0x06,0x00,0xff,0xff,0xdf,0xff,0xf9,0xc5,0x8b,0x31,0x12,0x5b, 0x10,0x5b,0xff,0xff,0xff,0xff,0x95,0x94,0x4b,0x21,0xff,0xff,0xff,0xff,0xff,0xff, 0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff, 0xff,0xff,0xfc,0x1c,0x5f,0xd7,0xff,0xff,0x3b,0x2d,0xbf,0xef,0xff,0xff,0xfb,0x1c, 0xff,0xff,0xfc,0x6d,0xbd,0x4d,0xfd,0x5d,0x1e,0x66,0x5c,0x2d,0xfd,0x65,0xff,0xff, 0xff,0xff,0xff,0xff,0xd6,0x9c,0x4e,0x3a,0xff,0xff,0xff,0xff,0xff,0xff,0x07,0x00, 0x5e,0xef,0x48,0x00,0xff,0xff,0xff,0xff,0x13,0x84,0x6e,0x4a,0x28,0x00,0xff,0xff, 0xff,0xff,0xff,0xff,0x68,0x08,0xf9,0xbd,0x48,0x00,0xff,0xff,0xff,0xff,0x68,0x08, 0xff,0xff,0xff,0xff,0x48,0x00,0x53,0x84,0x28,0x00,0x0a,0x11,0xca,0x10,0x0a,0x11, 0x06,0x00,0x92,0x6b,0x14,0x84,0xff,0xff,0xff,0xff,0x05,0x00,0xff,0xff,0xaf,0x52, 0x75,0x8c,0xb9,0xbd,0x07,0x00,0x2a,0x19,0xca,0x10,0x0a,0x11,0xa9,0x08,0x8b,0x29, 0x74,0x8c,0xff,0xff,0xff,0xff,0x57,0xa5,0x4b,0x19,0xff,0xff,0xff,0xff,0xff,0xff, 0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff, 0xff,0xff,0x1c,0x25,0x5f,0xd7,0x7f,0xdf,0xfb,0x1c,0xdf,0xf7,0x1e,0xb7,0x1c,0x25, 0x3f,0xc7,0x7f,0xd7,0x1c,0x25,0x3f,0xcf,0xde,0xae,0xfc,0x1c,0xbf,0xef,0xff,0xff, 0xff,0xff,0xff,0xff,0xbf,0xff,0x05,0x00,0xd6,0x94,0xdc,0xde,0xed,0x31,0x07,0x00, 0x5e,0xef,0x07,0x00,0xff,0xff,0xff,0xff,0xb2,0x73,0x14,0x7c,0x6b,0x21,0xf0,0x5a, 0xbb,0xde,0xf3,0x7b,0x04,0x00,0x1a,0xc6,0x06,0x00,0x98,0xb5,0xf6,0x9c,0x05,0x00, 0xb5,0x94,0x19,0xc6,0x04,0x00,0xff,0xff,0x47,0x00,0x37,0xa5,0x5e,0xef,0x4e,0x42, 0xef,0x5a,0x74,0x8c,0x27,0x00,0x9b,0xd6,0xb5,0x94,0x07,0x00,0x5d,0xef,0xcd,0x31, 0xaf,0x52,0x7b,0xd6,0x68,0x00,0xf6,0x9c,0x5d,0xef,0x2e,0x42,0x11,0x5b,0xfc,0xe6, 0x06,0x00,0x1a,0xc6,0xf9,0xc5,0xa9,0x08,0xac,0x29,0xff,0xff,0xff,0xff,0xff,0xff, 0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff, 0xff,0xff,0xfb,0x1c,0x7f,0xdf,0x7d,0x8e,0xfd,0x65,0xdf,0xff,0xdd,0x5d,0x1b,0x25, 0x5e,0x86,0xff,0xff,0x5f,0xcf,0x9c,0x45,0xfd,0x6d,0xbf,0xe7,0xff,0xff,0xff,0xff, 0xff,0xff,0xff,0xff,0xff,0xff,0x3d,0xe7,0x2b,0x19,0x48,0x00,0xb2,0x73,0x2e,0x42, 0x7e,0xf7,0xec,0x39,0xff,0xff,0xff,0xff,0xb5,0x9c,0xb5,0x94,0xff,0xff,0x8e,0x4a, 0x48,0x00,0xef,0x52,0x0d,0x3a,0x7a,0xd6,0x0d,0x3a,0x4a,0x19,0x2b,0x19,0x5a,0xce, 0x2b,0x21,0x68,0x00,0x19,0xc6,0xff,0xff,0x9e,0xf7,0x4a,0x19,0x68,0x00,0xb2,0x73, 0xff,0xff,0xd5,0x9c,0xf0,0x5a,0x89,0x00,0x2b,0x21,0xde,0xf7,0x77,0xb5,0x89,0x00, 0xea,0x10,0xd3,0x7b,0xff,0xff,0xed,0x31,0x68,0x00,0x91,0x6b,0xff,0xff,0xff,0xff, 0xd9,0xbd,0x89,0x00,0xc9,0x10,0x51,0x63,0x6c,0x29,0xff,0xff,0xff,0xff,0xff,0xff, 0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff, 0x9e,0x96,0xdc,0x0c,0x3f,0xcf,0xff,0xff,0x1c,0x1d,0xff,0xff,0xff,0xff,0x3c,0x25, 0x1c,0x6e,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff, 0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff, 0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff, 0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff, 0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff, 0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0x4f,0x42, 0xf3,0x7b,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff, 0xff,0xff,0xff,0xff,0xff,0xff,0x37,0xa5,0xa9,0x08,0xff,0xff,0xff,0xff,0xff,0xff, 0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff, 0x3f,0xcf,0xde,0xa6,0xdf,0xf7,0xff,0xff,0x1e,0x76,0xff,0xff,0xff,0xff,0xdf,0xf7, 0xbd,0x9e,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff, 0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff, 0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff, 0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff, 0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff, 0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0x39,0xce, 0xbb,0xd6,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff, 0xff,0xff,0xff,0xff,0xff,0xff,0xfc,0xde,0xd8,0xbd,0xff,0xff,0xff,0xff,0xff,0xff, 0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff, 0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff, 0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff, 0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff, 0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff, 0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff, 0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff, 0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff, 0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff, 0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff, 0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff, 0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff, 0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff, 0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff, 0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff, 0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff, 0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff, 0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff, 0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff, 0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff, 0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff, 0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff, 0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff, 0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff, 0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff, 0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff, 0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff, 0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff, 0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff, 0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff, 0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff, 0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff, 0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff, 0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff, 0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff, 0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff, 0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff, 0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff, 0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff, 0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff, 0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff, 0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff, 0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff, 0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff, 0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0x14,0x54,0xf0,0x22,0x72,0x3b, 0x72,0x33,0x72,0x3b,0x71,0x33,0x72,0x3b,0x72,0x33,0x51,0x2b,0x7b,0xbe,0xff,0xff, 0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0x92,0x3b,0x51,0x33,0x72,0x3b, 0x71,0x33,0xd3,0x43,0x37,0x85,0x3e,0xdf,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff, 0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff, 0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff, 0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff, 0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff, 0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff, 0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff, 0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xb9,0x9d,0x0d,0x02, 0x6d,0x12,0x6d,0x0a,0x8e,0x12,0x6e,0x0a,0x8e,0x0a,0x6e,0x02,0xf0,0x1a,0xff,0xff, 0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0x95,0x64,0x6e,0x02,0x8f,0x0a, 0xaf,0x12,0x8e,0x0a,0x8e,0x0a,0x2e,0x02,0x92,0x3b,0x5d,0xe7,0xff,0xff,0xff,0xff, 0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff, 0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff, 0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff, 0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff, 0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff, 0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff, 0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xfa,0xa5, 0x4e,0x02,0xaf,0x12,0xaf,0x12,0xd0,0x12,0xaf,0x12,0xd0,0x12,0x4e,0x02,0x7b,0xbe, 0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0x5e,0xe7,0x4e,0x02,0xf0,0x12, 0xf0,0x12,0xf0,0x1a,0xd0,0x12,0xf0,0x12,0xaf,0x0a,0x0d,0x02,0xf9,0xb5,0xff,0xff, 0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff, 0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff, 0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff, 0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff, 0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff, 0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff, 0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff, 0x54,0x5c,0x6e,0x02,0xcf,0x12,0xcf,0x12,0xd0,0x12,0xcf,0x12,0xaf,0x12,0xd2,0x43, 0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0x92,0x3b,0xcf,0x0a, 0xf0,0x1a,0xf0,0x12,0xf0,0x1a,0xf0,0x12,0xf0,0x12,0xf0,0x12,0xab,0x01,0x9b,0xc6, 0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff, 0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff, 0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff, 0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff, 0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff, 0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff, 0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff, 0xff,0xff,0x8f,0x0a,0xcf,0x12,0xf0,0x1a,0xf0,0x12,0xf0,0x1a,0xf0,0x12,0x6f,0x02, 0x5e,0xe7,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0x5b,0xbe,0xb0,0x0a, 0x11,0x1b,0x11,0x1b,0x11,0x13,0x11,0x1b,0x10,0x13,0x11,0x1b,0xf0,0x12,0xd0,0x0a, 0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff, 0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff, 0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff, 0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff, 0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff, 0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff, 0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff, 0xff,0xff,0xb2,0x3b,0xd0,0x0a,0xf0,0x12,0xf0,0x1a,0xf0,0x12,0x11,0x1b,0xd0,0x0a, 0xd6,0x74,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xaf,0x12, 0x31,0x1b,0x11,0x13,0x11,0x1b,0x11,0x13,0x31,0x1b,0x10,0x13,0x11,0x1b,0xb0,0x02, 0xfb,0x95,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff, 0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff, 0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff, 0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0x3a,0xb6,0x51,0x2b,0x92,0x3b,0xb2,0x3b, 0x92,0x3b,0xb2,0x3b,0x92,0x3b,0xb2,0x3b,0x92,0x3b,0xb3,0x3b,0x92,0x3b,0xb2,0x3b, 0x92,0x3b,0xb2,0x3b,0x92,0x3b,0xb2,0x3b,0x92,0x3b,0xb2,0x3b,0x92,0x3b,0xb2,0x3b, 0x92,0x3b,0x92,0x3b,0x34,0x5c,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff, 0xff,0xff,0x98,0x95,0xaf,0x02,0x11,0x1b,0x11,0x13,0x31,0x1b,0x11,0x1b,0x32,0x1b, 0x0c,0x02,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xf5,0x84, 0xaf,0x0a,0x52,0x1b,0x31,0x1b,0x32,0x1b,0x31,0x1b,0x32,0x1b,0x11,0x1b,0xf1,0x12, 0x57,0x24,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff, 0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff, 0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff, 0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0x7e,0xef,0xcc,0x01,0x0c,0x1a,0x0b,0x12, 0x0c,0x1a,0x0b,0x12,0x0c,0x1a,0x0c,0x12,0x2c,0x1a,0x2c,0x12,0x4d,0x12,0x4d,0x12, 0x6d,0x12,0x6d,0x0a,0x8e,0x12,0x8e,0x0a,0x8f,0x0a,0x8f,0x0a,0xaf,0x12,0xaf,0x0a, 0xd0,0x12,0xd0,0x0a,0x6f,0x02,0xd9,0x9d,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff, 0xff,0xff,0x19,0xb6,0x6f,0x02,0x11,0x13,0x31,0x1b,0x31,0x13,0x32,0x1b,0x31,0x13, 0x8f,0x02,0x57,0x95,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0x9e,0xf7, 0x4e,0x02,0x52,0x13,0x52,0x1b,0x31,0x13,0x52,0x1b,0x31,0x13,0x32,0x1b,0x11,0x13, 0x53,0x0b,0x1e,0xcf,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff, 0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff, 0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff, 0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0x92,0x3b,0x0c,0x1a,0x4d,0x22, 0x2c,0x1a,0x4d,0x22,0x4c,0x1a,0x6d,0x22,0x6d,0x1a,0x8e,0x1a,0x6d,0x1a,0x8f,0x1a, 0x8e,0x12,0xaf,0x1a,0xaf,0x12,0xcf,0x12,0xcf,0x12,0xd0,0x12,0xf0,0x12,0x10,0x1b, 0xf0,0x12,0x11,0x13,0x2d,0x02,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff, 0xff,0xff,0x1a,0xae,0xaf,0x02,0x32,0x1b,0x32,0x1b,0x52,0x1b,0x32,0x13,0x53,0x1b, 0x52,0x13,0xf1,0x0a,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff, 0x54,0x4c,0x32,0x13,0x52,0x1b,0x73,0x1b,0x52,0x1b,0x52,0x1b,0x52,0x13,0x52,0x1b, 0x11,0x13,0xdb,0x85,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff, 0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff, 0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff, 0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xbb,0xc6,0xcb,0x01,0x2c,0x1a, 0x4d,0x22,0x4c,0x1a,0x4d,0x1a,0x4d,0x1a,0x6e,0x1a,0x6d,0x12,0x8e,0x1a,0x8e,0x12, 0xaf,0x1a,0xae,0x12,0xcf,0x12,0xaf,0x12,0xd0,0x12,0xcf,0x12,0xf0,0x1a,0xf0,0x12, 0xd0,0x0a,0x4d,0x12,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff, 0xff,0xff,0xd7,0x54,0x11,0x13,0x31,0x13,0x52,0x1b,0x52,0x13,0x52,0x1b,0x52,0x1b, 0x53,0x1b,0x12,0x03,0x1e,0xcf,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff, 0x1d,0xd7,0x12,0x03,0x73,0x1b,0x52,0x1b,0x73,0x1b,0x52,0x1b,0x53,0x1b,0x52,0x13, 0x32,0x13,0xd4,0x1b,0xdf,0xf7,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff, 0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff, 0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff, 0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0x0c,0x0a,0x2c,0x22, 0x4c,0x1a,0x4d,0x22,0x4d,0x1a,0x6d,0x1a,0x6d,0x1a,0x8e,0x1a,0x8e,0x1a,0xaf,0x1a, 0xae,0x12,0xcf,0x12,0xcf,0x12,0xd0,0x12,0xd0,0x12,0xf1,0x1a,0x10,0x1b,0xb0,0x0a, 0xae,0x2a,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff, 0xff,0xff,0xf6,0x13,0x11,0x13,0x52,0x1b,0x52,0x13,0x73,0x1b,0x53,0x1b,0x73,0x1b, 0x73,0x1b,0x53,0x1b,0x19,0x55,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff, 0xff,0xff,0x98,0x34,0x53,0x13,0x93,0x23,0x73,0x1b,0x73,0x23,0x73,0x1b,0x73,0x1b, 0x52,0x1b,0x53,0x13,0xfb,0x8d,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff, 0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff, 0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff, 0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0x57,0x8d,0xcb,0x09, 0x4d,0x22,0x4d,0x1a,0x6d,0x1a,0x6d,0x12,0x8e,0x1a,0x8e,0x12,0xaf,0x1a,0x8e,0x12, 0xaf,0x12,0xaf,0x12,0xd0,0x12,0xcf,0x12,0xf0,0x12,0xf0,0x12,0x8f,0x02,0x71,0x3b, 0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff, 0x7c,0xae,0x73,0x23,0x73,0x2b,0x73,0x23,0x93,0x2b,0x93,0x23,0x94,0x2b,0x93,0x23, 0x94,0x23,0x73,0x13,0xf5,0x23,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff, 0xff,0xff,0x7c,0xae,0x94,0x13,0x73,0x13,0x94,0x1b,0x73,0x1b,0x93,0x1b,0x73,0x1b, 0x73,0x1b,0x32,0x13,0x74,0x03,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff, 0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff, 0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff, 0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0x4e,0x02, 0x2c,0x1a,0x6d,0x1a,0x6d,0x1a,0x8e,0x1a,0x8e,0x1a,0xae,0x1a,0x8e,0x12,0xaf,0x12, 0xaf,0x12,0xd0,0x12,0xf0,0x1a,0x11,0x23,0x11,0x23,0xf1,0x1a,0x96,0x64,0xff,0xff, 0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0x9f,0xef, 0x76,0x4c,0xb3,0x33,0xd4,0x3b,0xf5,0x3b,0xd4,0x3b,0xf5,0x3b,0xf5,0x3b,0x15,0x3c, 0xf5,0x3b,0x16,0x3c,0xf5,0x33,0x3c,0xa6,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff, 0xff,0xff,0xff,0xff,0x76,0x3c,0x74,0x13,0x94,0x13,0xb4,0x1b,0x93,0x1b,0x94,0x23, 0x73,0x1b,0x73,0x23,0x12,0x03,0x5b,0xae,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff, 0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff, 0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff, 0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xd7,0x5c, 0x2c,0x12,0x4d,0x1a,0x6e,0x1a,0x6d,0x12,0x8e,0x12,0x8e,0x12,0xcf,0x1a,0xef,0x22, 0x31,0x33,0x51,0x33,0x71,0x3b,0x51,0x33,0x32,0x23,0x79,0x7d,0xff,0xff,0xff,0xff, 0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0x5e,0xdf,0x36,0x3c, 0x93,0x33,0xb4,0x33,0xd4,0x3b,0xd4,0x33,0xf5,0x3b,0xf4,0x33,0xf5,0x3b,0xf5,0x3b, 0x16,0x3c,0x15,0x3c,0xf5,0x3b,0xf6,0x2b,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff, 0xff,0xff,0xff,0xff,0x5c,0xa6,0xd5,0x2b,0xd5,0x2b,0xb4,0x1b,0xb4,0x1b,0x93,0x13, 0x94,0x1b,0x73,0x1b,0x73,0x1b,0xf0,0x12,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff, 0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff, 0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff, 0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0x7f,0xdf, 0xb0,0x02,0x4d,0x1a,0x8e,0x1a,0xcf,0x2a,0xef,0x32,0x31,0x3b,0x30,0x33,0x51,0x3b, 0x31,0x33,0x52,0x3b,0x31,0x33,0x53,0x23,0x3c,0x9e,0xff,0xff,0xff,0xff,0xff,0xff, 0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xfe,0xce,0xb5,0x23,0xb4,0x33, 0xd4,0x33,0xf5,0x3b,0xd4,0x3b,0xf5,0x3b,0xf5,0x3b,0x16,0x3c,0x15,0x3c,0x36,0x3c, 0x16,0x3c,0x36,0x44,0x36,0x3c,0xd5,0x2b,0x3b,0xae,0xff,0xff,0xff,0xff,0xff,0xff, 0xff,0xff,0xff,0xff,0xff,0xff,0xf6,0x2b,0x16,0x3c,0x36,0x44,0x16,0x3c,0x16,0x3c, 0xd4,0x2b,0xb4,0x23,0x94,0x13,0x4f,0x02,0xdc,0xd6,0xff,0xff,0xff,0xff,0xff,0xff, 0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff, 0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff, 0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff, 0xf8,0x5c,0x8e,0x2a,0xf0,0x32,0xef,0x32,0x10,0x33,0x10,0x33,0x31,0x33,0x30,0x33, 0x51,0x33,0x10,0x33,0xb4,0x2b,0xbd,0xb6,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff, 0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0x5b,0xae,0x53,0x1b,0xb4,0x3b,0xd4,0x33, 0xf4,0x3b,0xd4,0x33,0xf5,0x3b,0xf5,0x3b,0x15,0x3c,0x15,0x3c,0x16,0x3c,0x16,0x3c, 0x36,0x3c,0x36,0x3c,0x37,0x3c,0x36,0x34,0xd4,0x3b,0xff,0xff,0xff,0xff,0xff,0xff, 0xff,0xff,0xff,0xff,0xff,0xff,0xb7,0x54,0x16,0x34,0x16,0x3c,0x36,0x3c,0x15,0x3c, 0x16,0x3c,0x15,0x3c,0x15,0x3c,0x94,0x1b,0xb1,0x5b,0xff,0xff,0xff,0xff,0xff,0xff, 0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff, 0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff, 0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff, 0x1e,0xcf,0x52,0x33,0xcf,0x32,0x10,0x3b,0x10,0x33,0x31,0x33,0x30,0x33,0x51,0x3b, 0x31,0x33,0x93,0x33,0xbd,0xb6,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff, 0xff,0xff,0xff,0xff,0xff,0xff,0x99,0x95,0x11,0x13,0xd4,0x3b,0xd4,0x33,0xf5,0x3b, 0xf5,0x3b,0x15,0x3c,0x15,0x3c,0x16,0x3c,0x16,0x3c,0x36,0x3c,0x36,0x3c,0x57,0x3c, 0x37,0x3c,0x57,0x3c,0x57,0x3c,0x78,0x44,0x73,0x23,0xdc,0xce,0xff,0xff,0xff,0xff, 0xff,0xff,0xff,0xff,0xff,0xff,0x1d,0xdf,0x94,0x23,0x57,0x44,0x36,0x3c,0x37,0x3c, 0x16,0x3c,0x36,0x3c,0x15,0x3c,0x36,0x44,0xaf,0x1a,0xdf,0xff,0xff,0xff,0xff,0xff, 0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff, 0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff, 0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff, 0xff,0xff,0xb6,0x5c,0xae,0x2a,0x10,0x33,0x30,0x33,0x10,0x33,0x51,0x33,0x31,0x33, 0x11,0x33,0x59,0x75,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff, 0xff,0xff,0xff,0xff,0xd6,0x7c,0xf1,0x12,0xd4,0x3b,0xd4,0x33,0xf4,0x3b,0xd4,0x33, 0xf5,0x3b,0xf5,0x33,0x16,0x3c,0x16,0x3c,0x36,0x3c,0x36,0x3c,0x57,0x3c,0x37,0x3c, 0x57,0x3c,0x57,0x3c,0x77,0x3c,0x57,0x3c,0x57,0x3c,0xd2,0x53,0xff,0xff,0xff,0xff, 0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0x51,0x33,0x57,0x3c,0x57,0x3c,0x36,0x3c, 0x37,0x3c,0x16,0x3c,0x36,0x3c,0x15,0x3c,0xb4,0x2b,0x77,0x95,0xff,0xff,0xff,0xff, 0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff, 0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff, 0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff, 0xff,0xff,0xdd,0xbe,0x10,0x33,0x10,0x33,0x10,0x33,0x31,0x3b,0x31,0x33,0x51,0x3b, 0x72,0x33,0xfe,0xc6,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff, 0xff,0xff,0x13,0x64,0xf1,0x22,0xd4,0x3b,0xd4,0x33,0xf5,0x3b,0xd5,0x3b,0x15,0x3c, 0xf5,0x3b,0x16,0x3c,0x16,0x3c,0x36,0x3c,0x36,0x3c,0x57,0x44,0x57,0x3c,0x78,0x3c, 0x57,0x3c,0x78,0x44,0x77,0x44,0x78,0x44,0x98,0x44,0xf0,0x22,0xbf,0xff,0xff,0xff, 0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0x97,0xa5,0xb5,0x2b,0x77,0x3c,0x57,0x3c, 0x37,0x3c,0x57,0x44,0x36,0x3c,0x36,0x3c,0x16,0x34,0xb3,0x43,0xff,0xff,0xff,0xff, 0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff, 0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff, 0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff, 0xff,0xff,0xff,0xff,0xd4,0x3b,0xcf,0x2a,0x30,0x33,0x30,0x33,0x51,0x33,0x31,0x33, 0xb4,0x33,0xdf,0xf7,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff, 0x2f,0x3b,0x11,0x23,0xd4,0x3b,0xb3,0x33,0xd4,0x3b,0xd4,0x33,0xf5,0x3b,0xf5,0x33, 0x16,0x3c,0x15,0x3c,0x36,0x3c,0x36,0x3c,0x57,0x3c,0x57,0x3c,0x77,0x3c,0x57,0x3c, 0x77,0x44,0x77,0x44,0x98,0x44,0x77,0x44,0x98,0x4c,0x15,0x34,0xd5,0x84,0xff,0xff, 0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0x8e,0x1a,0x98,0x44,0x57,0x3c, 0x57,0x3c,0x36,0x3c,0x57,0x3c,0x16,0x3c,0x36,0x3c,0xb4,0x33,0xdc,0xce,0xff,0xff, 0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff, 0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff, 0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff, 0xff,0xff,0xff,0xff,0x9a,0x75,0xf0,0x32,0x30,0x33,0x51,0x33,0x51,0x33,0x52,0x3b, 0xb4,0x2b,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0x95,0x74, 0x11,0x23,0xb4,0x3b,0xb4,0x33,0xd4,0x3b,0xd4,0x33,0xf5,0x3b,0xf5,0x3b,0x16,0x3c, 0x16,0x3c,0x36,0x3c,0x36,0x3c,0x57,0x3c,0x57,0x3c,0x78,0x3c,0x77,0x3c,0x78,0x44, 0x77,0x44,0x98,0x4c,0x97,0x44,0x98,0x4c,0x98,0x4c,0xb8,0x4c,0xf3,0x43,0xff,0xff, 0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0x74,0x74,0x57,0x3c,0x78,0x44, 0x77,0x3c,0x77,0x3c,0x37,0x3c,0x37,0x3c,0x36,0x3c,0x16,0x34,0xf7,0x6c,0xff,0xff, 0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff, 0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff, 0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff, 0xff,0xff,0xff,0xff,0x5e,0xdf,0x12,0x1b,0x30,0x33,0x31,0x33,0x51,0x33,0x51,0x33, 0x94,0x2b,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0x98,0x95, 0x32,0x23,0x72,0x2b,0x93,0x2b,0x93,0x2b,0xb4,0x33,0xb4,0x2b,0xd5,0x33,0xd5,0x2b, 0xf5,0x33,0xf5,0x2b,0x16,0x34,0x16,0x34,0x37,0x3c,0x36,0x34,0x57,0x3c,0x56,0x3c, 0x57,0x44,0x56,0x3c,0x77,0x44,0x77,0x44,0x97,0x4c,0x77,0x44,0x56,0x44,0x9b,0xb6, 0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0x9e,0xf7,0x11,0x1b,0x16,0x34, 0x16,0x34,0x16,0x2c,0x16,0x34,0x16,0x34,0x16,0x34,0xf5,0x2b,0x36,0x3c,0x7e,0xe7, 0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff, 0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff, 0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff, 0xff,0xff,0xff,0xff,0xff,0xff,0x57,0x44,0x10,0x33,0x51,0x3b,0x51,0x33,0x72,0x3b, 0x32,0x23,0x9f,0xef,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff, 0x1d,0xd7,0xdd,0xc6,0xdc,0xc6,0xdd,0xc6,0xdc,0xc6,0xdd,0xce,0xdc,0xc6,0xfd,0xce, 0xdc,0xc6,0xfd,0xce,0xdd,0xce,0xfd,0xce,0xfd,0xc6,0xfd,0xce,0xfd,0xce,0xfd,0xce, 0xfd,0xce,0xfd,0xce,0xfd,0xce,0xfd,0xce,0xfd,0xce,0xfd,0xce,0xdd,0xc6,0xbf,0xef, 0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0x3d,0xe7,0x3a,0xb6, 0x5a,0xbe,0x9b,0xc6,0x9b,0xc6,0xbc,0xc6,0xdc,0xc6,0xfd,0xce,0xdd,0xc6,0xff,0xff, 0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff, 0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff, 0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff, 0xff,0xff,0xff,0xff,0xff,0xff,0x3b,0xa6,0x11,0x23,0x31,0x33,0x52,0x3b,0x52,0x33, 0x52,0x2b,0xb9,0x95,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff, 0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff, 0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff, 0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff, 0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff, 0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff, 0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff, 0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff, 0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff, 0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0x52,0x23,0x51,0x33,0x51,0x33,0x72,0x3b, 0x72,0x33,0x93,0x33,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff, 0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff, 0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff, 0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff, 0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff, 0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff, 0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff, 0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff, 0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff, 0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0x37,0x85,0x10,0x23,0x72,0x3b,0x72,0x33, 0x93,0x3b,0x31,0x23,0xf7,0x7c,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff, 0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff, 0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff, 0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff, 0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff, 0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff, 0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff, 0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff, 0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff, 0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xdf,0xff,0xd0,0x1a,0x72,0x33,0x73,0x3b, 0x92,0x33,0xb3,0x3b,0xd0,0x1a,0x78,0x95,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff, 0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff, 0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff, 0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff, 0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff, 0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff, 0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff, 0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff, 0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff, 0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xd2,0x4b,0x52,0x33,0x72,0x33, 0x93,0x3b,0x93,0x33,0xd4,0x3b,0xf0,0x1a,0x91,0x4b,0x7e,0xef,0xff,0xff,0xff,0xff, 0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff, 0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff, 0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff, 0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff, 0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff, 0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff, 0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff, 0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff, 0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xfc,0xd6,0x6e,0x12,0x93,0x3b, 0x93,0x33,0xb3,0x3b,0xb3,0x33,0xd4,0x3b,0xb4,0x33,0x8f,0x12,0xef,0x2a,0x94,0x74, 0x36,0x95,0x57,0x9d,0x36,0x95,0x57,0x9d,0x36,0x95,0x56,0x95,0x36,0x95,0x36,0x95, 0x36,0x95,0x36,0x95,0x36,0x95,0x36,0x95,0x16,0x95,0x36,0x95,0x16,0x8d,0x36,0x95, 0x16,0x95,0x36,0x95,0x16,0x95,0x36,0x95,0x16,0x95,0x36,0x95,0x36,0x95,0x36,0x95, 0x36,0x95,0x36,0x95,0x36,0x95,0x57,0x9d,0x36,0x95,0x57,0x9d,0x56,0x95,0x57,0x9d, 0x56,0x95,0x57,0x9d,0x56,0x95,0x57,0x9d,0x57,0x9d,0x77,0x9d,0x57,0x9d,0x77,0x9d, 0x77,0x9d,0x57,0x95,0xbe,0xf7,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff, 0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff, 0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff, 0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xb1,0x53,0x11,0x2b, 0x93,0x3b,0x92,0x33,0xb3,0x3b,0xb3,0x33,0xd4,0x3b,0xf5,0x33,0x16,0x3c,0xd4,0x2b, 0x94,0x2b,0x93,0x23,0xb4,0x2b,0xb4,0x2b,0xb5,0x2b,0xb4,0x2b,0xd5,0x33,0xd5,0x33, 0xf5,0x3b,0xf5,0x33,0x15,0x3c,0x15,0x3c,0x35,0x44,0x35,0x44,0x56,0x4c,0x55,0x4c, 0x76,0x4c,0x75,0x4c,0x96,0x54,0x76,0x54,0x96,0x54,0x76,0x54,0x76,0x54,0x56,0x4c, 0x76,0x4c,0x55,0x44,0x56,0x4c,0x35,0x44,0x36,0x44,0x15,0x3c,0x15,0x3c,0xf5,0x33, 0xf5,0x3b,0xf5,0x33,0xf5,0x33,0xd5,0x2b,0xd5,0x2b,0xb4,0x2b,0xb4,0x2b,0x93,0x2b, 0x94,0x2b,0x32,0x1b,0xf6,0x84,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff, 0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff, 0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff, 0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0x30,0x33, 0x52,0x2b,0x93,0x3b,0xb3,0x33,0xd4,0x3b,0xd4,0x33,0xf5,0x3b,0xf5,0x3b,0x16,0x3c, 0x16,0x3c,0x57,0x3c,0x57,0x3c,0x78,0x44,0x77,0x3c,0x98,0x44,0x98,0x44,0xb8,0x4c, 0xb8,0x4c,0xd9,0x54,0xd8,0x54,0xf9,0x5c,0xf8,0x5c,0x19,0x65,0x19,0x65,0x39,0x65, 0x39,0x65,0x59,0x6d,0x59,0x6d,0x7a,0x75,0x59,0x6d,0x59,0x75,0x39,0x6d,0x39,0x6d, 0x19,0x65,0x19,0x65,0xf8,0x5c,0xf9,0x5c,0xd8,0x54,0xd9,0x54,0xb8,0x54,0xb8,0x4c, 0x98,0x4c,0x98,0x4c,0x77,0x44,0x78,0x44,0x57,0x3c,0x57,0x44,0x36,0x3c,0x36,0x3c, 0x15,0x3c,0xf6,0x3b,0x72,0x33,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff, 0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff, 0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff, 0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff, 0x74,0x64,0x11,0x23,0x93,0x33,0xb3,0x33,0xd4,0x3b,0xd4,0x33,0xf5,0x3b,0xf5,0x33, 0x16,0x3c,0x16,0x34,0x37,0x3c,0x57,0x3c,0x77,0x3c,0x57,0x3c,0x98,0x44,0x97,0x44, 0x98,0x4c,0x98,0x4c,0xd8,0x54,0xd8,0x54,0xf8,0x5c,0xf8,0x5c,0x19,0x65,0x18,0x5d, 0x39,0x65,0x39,0x6d,0x59,0x6d,0x59,0x6d,0x59,0x6d,0x39,0x6d,0x39,0x6d,0x18,0x65, 0x19,0x65,0xf8,0x5c,0xf9,0x5c,0xd8,0x54,0xd8,0x54,0xb8,0x54,0xb8,0x4c,0x97,0x44, 0x98,0x4c,0x77,0x44,0x78,0x44,0x57,0x3c,0x57,0x3c,0x16,0x3c,0x36,0x3c,0x15,0x34, 0xf5,0x3b,0xd4,0x33,0xb4,0x33,0x7b,0xb6,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff, 0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff, 0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff, 0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff, 0xff,0xff,0xdc,0xce,0xb6,0x64,0x93,0x33,0x93,0x2b,0xb4,0x33,0xb4,0x33,0xd5,0x33, 0xd4,0x33,0xf5,0x33,0xf5,0x33,0x16,0x34,0x16,0x34,0x36,0x3c,0x16,0x3c,0x36,0x3c, 0x36,0x3c,0x56,0x44,0x56,0x44,0x77,0x4c,0x76,0x4c,0x97,0x4c,0x96,0x4c,0x97,0x54, 0x97,0x54,0xb7,0x54,0xb7,0x54,0xd8,0x5c,0xb7,0x54,0xd7,0x5c,0xb7,0x54,0xb8,0x54, 0x97,0x54,0x97,0x54,0x97,0x4c,0x97,0x4c,0x77,0x4c,0x97,0x4c,0x77,0x44,0x77,0x44, 0x56,0x44,0x77,0x44,0x56,0x3c,0x57,0x3c,0x36,0x3c,0x36,0x3c,0x16,0x3c,0x36,0x3c, 0x15,0x3c,0x15,0x3c,0xd4,0x33,0x18,0x6d,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff, 0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff, 0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff, 0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff, 0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0x7e,0xef,0x3d,0xdf,0x5e,0xdf,0x3d,0xdf, 0x5e,0xe7,0x3d,0xdf,0x5d,0xdf,0x3d,0xdf,0x3e,0xe7,0x3d,0xdf,0x3d,0xdf,0x3d,0xdf, 0x5e,0xdf,0x3d,0xdf,0x5e,0xdf,0x3d,0xdf,0x5e,0xdf,0x3d,0xdf,0x5e,0xdf,0x3d,0xdf, 0x5e,0xdf,0x3d,0xdf,0x5e,0xdf,0x3d,0xdf,0x5e,0xdf,0x3d,0xdf,0x5e,0xdf,0x3d,0xdf, 0x5e,0xe7,0x5d,0xdf,0x5e,0xe7,0x5e,0xdf,0x5e,0xe7,0x5d,0xdf,0x5e,0xe7,0x5e,0xdf, 0x7e,0xe7,0x5e,0xdf,0x7e,0xe7,0x5e,0xe7,0x7e,0xe7,0x7e,0xe7,0x7e,0xe7,0x7e,0xe7, 0x7f,0xe7,0x7e,0xe7,0x7e,0xe7,0x7e,0xe7,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff, 0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff, 0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff, 0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff, 0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff, 0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff, 0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff, 0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff, 0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff, 0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff, 0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff, 0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff, 0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff, 0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff, 0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff, 0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff, 0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff, 0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff, 0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff, 0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff, 0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff, 0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff, 0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff, 0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff, 0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff, 0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff, 0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff, 0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff, 0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff, 0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff, 0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff, 0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff, 0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff, 0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff, 0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff, 0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff, 0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff, 0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff, 0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff, 0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff, 0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff, 0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff, 0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff, 0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff, 0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff, 0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff, 0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff, 0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff, 0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff, 0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff, 0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff, 0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff, 0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff, 0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff, 0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff, 0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff, 0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff, 0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff, 0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff, 0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff, 0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff, 0xff,0xff,0xff,0xff,0xff,0xff };
0
D://workCode//uploadProject\STM32CubeF1\Projects\STM3210E_EVAL\Examples\BSP
D://workCode//uploadProject\STM32CubeF1\Projects\STM3210E_EVAL\Examples\BSP\Inc\stm32f1xx_hal_conf.h
/** ****************************************************************************** * @file stm32f1xx_hal_conf.h * @author MCD Application Team * @brief HAL configuration file. ****************************************************************************** * @attention * * Copyright (c) 2016 STMicroelectronics. * All rights reserved. * * This software is licensed under terms that can be found in the LICENSE file * in the root directory of this software component. * If no LICENSE file comes with this software, it is provided AS-IS. * ****************************************************************************** */ /* Define to prevent recursive inclusion -------------------------------------*/ #ifndef __STM32F1xx_HAL_CONF_H #define __STM32F1xx_HAL_CONF_H #ifdef __cplusplus extern "C" { #endif /* Exported types ------------------------------------------------------------*/ /* Exported constants --------------------------------------------------------*/ /* ########################## Module Selection ############################## */ /** * @brief This is the list of modules to be used in the HAL driver */ #define HAL_MODULE_ENABLED #define HAL_ADC_MODULE_ENABLED /* #define HAL_CAN_MODULE_ENABLED */ /* #define HAL_CAN_LEGACY_MODULE_ENABLED */ /* #define HAL_CEC_MODULE_ENABLED */ #define HAL_CORTEX_MODULE_ENABLED /* #define HAL_CRC_MODULE_ENABLED */ /* #define HAL_DAC_MODULE_ENABLED */ #define HAL_DMA_MODULE_ENABLED /* #define HAL_ETH_MODULE_ENABLED */ /* #define HAL_EXTI_MODULE_ENABLED */ #define HAL_FLASH_MODULE_ENABLED #define HAL_GPIO_MODULE_ENABLED /* #define HAL_HCD_MODULE_ENABLED */ #define HAL_I2C_MODULE_ENABLED #define HAL_I2S_MODULE_ENABLED /* #define HAL_IRDA_MODULE_ENABLED */ /* #define HAL_IWDG_MODULE_ENABLED */ #define HAL_NAND_MODULE_ENABLED #define HAL_NOR_MODULE_ENABLED /* #define HAL_PCCARD_MODULE_ENABLED */ /* #define HAL_PCD_MODULE_ENABLED */ #define HAL_PWR_MODULE_ENABLED #define HAL_RCC_MODULE_ENABLED /* #define HAL_RTC_MODULE_ENABLED */ #define HAL_SD_MODULE_ENABLED /* #define HAL_SMARTCARD_MODULE_ENABLED */ #define HAL_SPI_MODULE_ENABLED #define HAL_SRAM_MODULE_ENABLED #define HAL_TIM_MODULE_ENABLED /* #define HAL_UART_MODULE_ENABLED */ /* #define HAL_USART_MODULE_ENABLED */ /* #define HAL_WWDG_MODULE_ENABLED */ /* #define HAL_MMC_MODULE_ENABLED */ /* ########################## Oscillator Values adaptation ####################*/ /** * @brief Adjust the value of External High Speed oscillator (HSE) used in your application. * This value is used by the RCC HAL module to compute the system frequency * (when HSE is used as system clock source, directly or through the PLL). */ #if !defined (HSE_VALUE) #if defined(USE_STM3210C_EVAL) #define HSE_VALUE 25000000U /*!< Value of the External oscillator in Hz */ #else #define HSE_VALUE 8000000U /*!< Value of the External oscillator in Hz */ #endif #endif /* HSE_VALUE */ #if !defined (HSE_STARTUP_TIMEOUT) #define HSE_STARTUP_TIMEOUT 100U /*!< Time out for HSE start up, in ms */ #endif /* HSE_STARTUP_TIMEOUT */ /** * @brief Internal High Speed oscillator (HSI) value. * This value is used by the RCC HAL module to compute the system frequency * (when HSI is used as system clock source, directly or through the PLL). */ #if !defined (HSI_VALUE) #define HSI_VALUE 8000000U /*!< Value of the Internal oscillator in Hz */ #endif /* HSI_VALUE */ /** * @brief Internal Low Speed oscillator (LSI) value. */ #if !defined (LSI_VALUE) #define LSI_VALUE 40000U /*!< LSI Typical Value in Hz */ #endif /* LSI_VALUE */ /*!< Value of the Internal Low Speed oscillator in Hz The real value may vary depending on the variations in voltage and temperature. */ /** * @brief External Low Speed oscillator (LSE) value. * This value is used by the UART, RTC HAL module to compute the system frequency */ #if !defined (LSE_VALUE) #define LSE_VALUE 32768U /*!< Value of the External oscillator in Hz*/ #endif /* LSE_VALUE */ #if !defined (LSE_STARTUP_TIMEOUT) #define LSE_STARTUP_TIMEOUT 5000U /*!< Time out for LSE start up, in ms */ #endif /* LSE_STARTUP_TIMEOUT */ /* Tip: To avoid modifying this file each time you need to use different HSE, === you can define the HSE value in your toolchain compiler preprocessor. */ /* ########################### System Configuration ######################### */ /** * @brief This is the HAL system configuration section */ #define VDD_VALUE 3300U /*!< Value of VDD in mv */ #define TICK_INT_PRIORITY 0x0FU /*!< tick interrupt priority */ #define USE_RTOS 0U #define PREFETCH_ENABLE 1U #define USE_HAL_ADC_REGISTER_CALLBACKS 0U /* ADC register callback disabled */ #define USE_HAL_CAN_REGISTER_CALLBACKS 0U /* CAN register callback disabled */ #define USE_HAL_CEC_REGISTER_CALLBACKS 0U /* CEC register callback disabled */ #define USE_HAL_DAC_REGISTER_CALLBACKS 0U /* DAC register callback disabled */ #define USE_HAL_ETH_REGISTER_CALLBACKS 0U /* ETH register callback disabled */ #define USE_HAL_HCD_REGISTER_CALLBACKS 0U /* HCD register callback disabled */ #define USE_HAL_I2C_REGISTER_CALLBACKS 0U /* I2C register callback disabled */ #define USE_HAL_I2S_REGISTER_CALLBACKS 0U /* I2S register callback disabled */ #define USE_HAL_MMC_REGISTER_CALLBACKS 0U /* MMC register callback disabled */ #define USE_HAL_NAND_REGISTER_CALLBACKS 0U /* NAND register callback disabled */ #define USE_HAL_NOR_REGISTER_CALLBACKS 0U /* NOR register callback disabled */ #define USE_HAL_PCCARD_REGISTER_CALLBACKS 0U /* PCCARD register callback disabled */ #define USE_HAL_PCD_REGISTER_CALLBACKS 0U /* PCD register callback disabled */ #define USE_HAL_RTC_REGISTER_CALLBACKS 0U /* RTC register callback disabled */ #define USE_HAL_SD_REGISTER_CALLBACKS 0U /* SD register callback disabled */ #define USE_HAL_SMARTCARD_REGISTER_CALLBACKS 0U /* SMARTCARD register callback disabled */ #define USE_HAL_IRDA_REGISTER_CALLBACKS 0U /* IRDA register callback disabled */ #define USE_HAL_SRAM_REGISTER_CALLBACKS 0U /* SRAM register callback disabled */ #define USE_HAL_SPI_REGISTER_CALLBACKS 0U /* SPI register callback disabled */ #define USE_HAL_TIM_REGISTER_CALLBACKS 0U /* TIM register callback disabled */ #define USE_HAL_UART_REGISTER_CALLBACKS 0U /* UART register callback disabled */ #define USE_HAL_USART_REGISTER_CALLBACKS 0U /* USART register callback disabled */ #define USE_HAL_WWDG_REGISTER_CALLBACKS 0U /* WWDG register callback disabled */ /* ########################## Assert Selection ############################## */ /** * @brief Uncomment the line below to expanse the "assert_param" macro in the * HAL drivers code */ /* #define USE_FULL_ASSERT 1U */ /* ################## Ethernet peripheral configuration ##################### */ /* Section 1 : Ethernet peripheral configuration */ /* MAC ADDRESS: MAC_ADDR0:MAC_ADDR1:MAC_ADDR2:MAC_ADDR3:MAC_ADDR4:MAC_ADDR5 */ #define MAC_ADDR0 2U #define MAC_ADDR1 0U #define MAC_ADDR2 0U #define MAC_ADDR3 0U #define MAC_ADDR4 0U #define MAC_ADDR5 0U /* Definition of the Ethernet driver buffers size and count */ #define ETH_RX_BUF_SIZE ETH_MAX_PACKET_SIZE /* buffer size for receive */ #define ETH_TX_BUF_SIZE ETH_MAX_PACKET_SIZE /* buffer size for transmit */ #define ETH_RXBUFNB 8U /* 8 Rx buffers of size ETH_RX_BUF_SIZE */ #define ETH_TXBUFNB 4U /* 4 Tx buffers of size ETH_TX_BUF_SIZE */ /* Section 2: PHY configuration section */ /* DP83848 PHY Address*/ #define DP83848_PHY_ADDRESS 0x01U /* PHY Reset delay these values are based on a 1 ms Systick interrupt*/ #define PHY_RESET_DELAY 0x000000FFU /* PHY Configuration delay */ #define PHY_CONFIG_DELAY 0x00000FFFU #define PHY_READ_TO 0x0000FFFFU #define PHY_WRITE_TO 0x0000FFFFU /* Section 3: Common PHY Registers */ #define PHY_BCR ((uint16_t)0x0000) /*!< Transceiver Basic Control Register */ #define PHY_BSR ((uint16_t)0x0001) /*!< Transceiver Basic Status Register */ #define PHY_RESET ((uint16_t)0x8000) /*!< PHY Reset */ #define PHY_LOOPBACK ((uint16_t)0x4000) /*!< Select loop-back mode */ #define PHY_FULLDUPLEX_100M ((uint16_t)0x2100) /*!< Set the full-duplex mode at 100 Mb/s */ #define PHY_HALFDUPLEX_100M ((uint16_t)0x2000) /*!< Set the half-duplex mode at 100 Mb/s */ #define PHY_FULLDUPLEX_10M ((uint16_t)0x0100) /*!< Set the full-duplex mode at 10 Mb/s */ #define PHY_HALFDUPLEX_10M ((uint16_t)0x0000) /*!< Set the half-duplex mode at 10 Mb/s */ #define PHY_AUTONEGOTIATION ((uint16_t)0x1000) /*!< Enable auto-negotiation function */ #define PHY_RESTART_AUTONEGOTIATION ((uint16_t)0x0200) /*!< Restart auto-negotiation function */ #define PHY_POWERDOWN ((uint16_t)0x0800) /*!< Select the power down mode */ #define PHY_ISOLATE ((uint16_t)0x0400) /*!< Isolate PHY from MII */ #define PHY_AUTONEGO_COMPLETE ((uint16_t)0x0020) /*!< Auto-Negotiation process completed */ #define PHY_LINKED_STATUS ((uint16_t)0x0004) /*!< Valid link established */ #define PHY_JABBER_DETECTION ((uint16_t)0x0002) /*!< Jabber condition detected */ /* Section 4: Extended PHY Registers */ #define PHY_SR ((uint16_t)0x0010) /*!< PHY status register Offset */ #define PHY_MICR ((uint16_t)0x0011) /*!< MII Interrupt Control Register */ #define PHY_MISR ((uint16_t)0x0012) /*!< MII Interrupt Status and Misc. Control Register */ #define PHY_LINK_STATUS ((uint16_t)0x0001) /*!< PHY Link mask */ #define PHY_SPEED_STATUS ((uint16_t)0x0002) /*!< PHY Speed mask */ #define PHY_DUPLEX_STATUS ((uint16_t)0x0004) /*!< PHY Duplex mask */ #define PHY_MICR_INT_EN ((uint16_t)0x0002) /*!< PHY Enable interrupts */ #define PHY_MICR_INT_OE ((uint16_t)0x0001) /*!< PHY Enable output interrupt events */ #define PHY_MISR_LINK_INT_EN ((uint16_t)0x0020) /*!< Enable Interrupt on change of link status */ #define PHY_LINK_INTERRUPT ((uint16_t)0x2000) /*!< PHY link status interrupt mask */ /* ################## SPI peripheral configuration ########################## */ /* CRC FEATURE: Use to activate CRC feature inside HAL SPI Driver * Activated: CRC code is present inside driver * Deactivated: CRC code cleaned from driver */ #define USE_SPI_CRC 1U /* Includes ------------------------------------------------------------------*/ /** * @brief Include module's header file */ #ifdef HAL_RCC_MODULE_ENABLED #include "stm32f1xx_hal_rcc.h" #endif /* HAL_RCC_MODULE_ENABLED */ #ifdef HAL_GPIO_MODULE_ENABLED #include "stm32f1xx_hal_gpio.h" #endif /* HAL_GPIO_MODULE_ENABLED */ #ifdef HAL_EXTI_MODULE_ENABLED #include "stm32f1xx_hal_exti.h" #endif /* HAL_EXTI_MODULE_ENABLED */ #ifdef HAL_DMA_MODULE_ENABLED #include "stm32f1xx_hal_dma.h" #endif /* HAL_DMA_MODULE_ENABLED */ #ifdef HAL_ETH_MODULE_ENABLED #include "stm32f1xx_hal_eth.h" #endif /* HAL_ETH_MODULE_ENABLED */ #ifdef HAL_CAN_MODULE_ENABLED #include "stm32f1xx_hal_can.h" #endif /* HAL_CAN_MODULE_ENABLED */ #ifdef HAL_CAN_LEGACY_MODULE_ENABLED #include "Legacy/stm32f1xx_hal_can_legacy.h" #endif /* HAL_CAN_LEGACY_MODULE_ENABLED */ #ifdef HAL_CEC_MODULE_ENABLED #include "stm32f1xx_hal_cec.h" #endif /* HAL_CEC_MODULE_ENABLED */ #ifdef HAL_CORTEX_MODULE_ENABLED #include "stm32f1xx_hal_cortex.h" #endif /* HAL_CORTEX_MODULE_ENABLED */ #ifdef HAL_ADC_MODULE_ENABLED #include "stm32f1xx_hal_adc.h" #endif /* HAL_ADC_MODULE_ENABLED */ #ifdef HAL_CRC_MODULE_ENABLED #include "stm32f1xx_hal_crc.h" #endif /* HAL_CRC_MODULE_ENABLED */ #ifdef HAL_DAC_MODULE_ENABLED #include "stm32f1xx_hal_dac.h" #endif /* HAL_DAC_MODULE_ENABLED */ #ifdef HAL_FLASH_MODULE_ENABLED #include "stm32f1xx_hal_flash.h" #endif /* HAL_FLASH_MODULE_ENABLED */ #ifdef HAL_SRAM_MODULE_ENABLED #include "stm32f1xx_hal_sram.h" #endif /* HAL_SRAM_MODULE_ENABLED */ #ifdef HAL_NOR_MODULE_ENABLED #include "stm32f1xx_hal_nor.h" #endif /* HAL_NOR_MODULE_ENABLED */ #ifdef HAL_I2C_MODULE_ENABLED #include "stm32f1xx_hal_i2c.h" #endif /* HAL_I2C_MODULE_ENABLED */ #ifdef HAL_I2S_MODULE_ENABLED #include "stm32f1xx_hal_i2s.h" #endif /* HAL_I2S_MODULE_ENABLED */ #ifdef HAL_IWDG_MODULE_ENABLED #include "stm32f1xx_hal_iwdg.h" #endif /* HAL_IWDG_MODULE_ENABLED */ #ifdef HAL_PWR_MODULE_ENABLED #include "stm32f1xx_hal_pwr.h" #endif /* HAL_PWR_MODULE_ENABLED */ #ifdef HAL_RTC_MODULE_ENABLED #include "stm32f1xx_hal_rtc.h" #endif /* HAL_RTC_MODULE_ENABLED */ #ifdef HAL_PCCARD_MODULE_ENABLED #include "stm32f1xx_hal_pccard.h" #endif /* HAL_PCCARD_MODULE_ENABLED */ #ifdef HAL_SD_MODULE_ENABLED #include "stm32f1xx_hal_sd.h" #endif /* HAL_SD_MODULE_ENABLED */ #ifdef HAL_NAND_MODULE_ENABLED #include "stm32f1xx_hal_nand.h" #endif /* HAL_NAND_MODULE_ENABLED */ #ifdef HAL_SPI_MODULE_ENABLED #include "stm32f1xx_hal_spi.h" #endif /* HAL_SPI_MODULE_ENABLED */ #ifdef HAL_TIM_MODULE_ENABLED #include "stm32f1xx_hal_tim.h" #endif /* HAL_TIM_MODULE_ENABLED */ #ifdef HAL_UART_MODULE_ENABLED #include "stm32f1xx_hal_uart.h" #endif /* HAL_UART_MODULE_ENABLED */ #ifdef HAL_USART_MODULE_ENABLED #include "stm32f1xx_hal_usart.h" #endif /* HAL_USART_MODULE_ENABLED */ #ifdef HAL_IRDA_MODULE_ENABLED #include "stm32f1xx_hal_irda.h" #endif /* HAL_IRDA_MODULE_ENABLED */ #ifdef HAL_SMARTCARD_MODULE_ENABLED #include "stm32f1xx_hal_smartcard.h" #endif /* HAL_SMARTCARD_MODULE_ENABLED */ #ifdef HAL_WWDG_MODULE_ENABLED #include "stm32f1xx_hal_wwdg.h" #endif /* HAL_WWDG_MODULE_ENABLED */ #ifdef HAL_PCD_MODULE_ENABLED #include "stm32f1xx_hal_pcd.h" #endif /* HAL_PCD_MODULE_ENABLED */ #ifdef HAL_HCD_MODULE_ENABLED #include "stm32f1xx_hal_hcd.h" #endif /* HAL_HCD_MODULE_ENABLED */ #ifdef HAL_MMC_MODULE_ENABLED #include "stm32f1xx_hal_mmc.h" #endif /* HAL_MMC_MODULE_ENABLED */ /* Exported macro ------------------------------------------------------------*/ #ifdef USE_FULL_ASSERT /** * @brief The assert_param macro is used for function's parameters check. * @param expr: If expr is false, it calls assert_failed function * which reports the name of the source file and the source * line number of the call that failed. * If expr is true, it returns no value. * @retval None */ #define assert_param(expr) ((expr) ? (void)0U : assert_failed((uint8_t *)__FILE__, __LINE__)) /* Exported functions ------------------------------------------------------- */ void assert_failed(uint8_t* file, uint32_t line); #else #define assert_param(expr) ((void)0U) #endif /* USE_FULL_ASSERT */ #ifdef __cplusplus } #endif #endif /* __STM32F1xx_HAL_CONF_H */
0
D://workCode//uploadProject\STM32CubeF1\Projects\STM3210E_EVAL\Examples\BSP
D://workCode//uploadProject\STM32CubeF1\Projects\STM3210E_EVAL\Examples\BSP\Inc\stm32f1xx_it.h
/** ****************************************************************************** * @file stm32f1xx_it.h * @author MCD Application Team * @brief This file contains the headers of the interrupt handlers. ****************************************************************************** * @attention * * Copyright (c) 2016 STMicroelectronics. * All rights reserved. * * This software is licensed under terms that can be found in the LICENSE file * in the root directory of this software component. * If no LICENSE file comes with this software, it is provided AS-IS. * ****************************************************************************** */ /* Define to prevent recursive inclusion -------------------------------------*/ #ifndef __STM32F1xx_IT_H #define __STM32F1xx_IT_H #ifdef __cplusplus extern "C" { #endif /* Includes ------------------------------------------------------------------*/ /* Exported types ------------------------------------------------------------*/ /* Exported constants --------------------------------------------------------*/ /* Exported macro ------------------------------------------------------------*/ /* Exported functions ------------------------------------------------------- */ void NMI_Handler(void); void HardFault_Handler(void); void MemManage_Handler(void); void BusFault_Handler(void); void UsageFault_Handler(void); void SVC_Handler(void); void DebugMon_Handler(void); void PendSV_Handler(void); void SysTick_Handler(void); void EXTI3_IRQHandler(void); void EXTI9_5_IRQHandler(void); void EXTI15_10_IRQHandler(void); void I2SOUT_IRQHandler(void); #ifdef __cplusplus } #endif #endif /* __STM32F1xx_IT_H */
0
D://workCode//uploadProject\STM32CubeF1\Projects\STM3210E_EVAL\Examples\BSP
D://workCode//uploadProject\STM32CubeF1\Projects\STM3210E_EVAL\Examples\BSP\Src\audio_play.c
/** ****************************************************************************** * @file BSP/Src/audio_play.c * @author MCD Application Team * @brief This example code shows how to use AUDIO features for the play. ****************************************************************************** * @attention * * Copyright (c) 2016 STMicroelectronics. * All rights reserved. * * This software is licensed under terms that can be found in the LICENSE file * in the root directory of this software component. * If no LICENSE file comes with this software, it is provided AS-IS. * ****************************************************************************** */ /* Includes ------------------------------------------------------------------*/ #include "main.h" /** @addtogroup STM32F1xx_HAL_Examples * @{ */ /** @addtogroup BSP * @{ */ /* Private typedef -----------------------------------------------------------*/ typedef struct { uint32_t ChunkID; /* 0 */ uint32_t FileSize; /* 4 */ uint32_t FileFormat; /* 8 */ uint32_t SubChunk1ID; /* 12 */ uint32_t SubChunk1Size; /* 16*/ uint16_t AudioFormat; /* 20 */ uint16_t NbrChannels; /* 22 */ uint32_t SampleRate; /* 24 */ uint32_t ByteRate; /* 28 */ uint16_t BlockAlign; /* 32 */ uint16_t BitPerSample; /* 34 */ uint32_t SubChunk2ID; /* 36 */ uint32_t SubChunk2Size; /* 40 */ }WAVE_FormatTypeDef; /* Private define ------------------------------------------------------------*/ /* Audio file size and start address are defined here since the Audio file is stored in Flash memory as a constant table of 16-bit data */ #define AUDIO_FILE_ADDRESS 0x08016800 /* Audio file address */ #define AUDIO_FILE_SIZE 0x2D000 /* Offset relative to Audio file header size (wave format) */ #define AUDIO_START_ADDRESS 58 /* Audio sampling frequency range to check integrity of audio file Wave data */ /* (unit: Hz). */ #define SAMPLE_RATE_MIN 8000 #define SAMPLE_RATE_MAX 96000 /* Private macro -------------------------------------------------------------*/ /* Private variables ---------------------------------------------------------*/ extern __IO uint8_t UserPressButton; extern __IO uint32_t PauseResumeStatus; extern __IO uint8_t UserOutputMode; uint8_t UserOutputModePreviousState = OUTPUT_DEVICE_BOTH; /* Variables used in normal mode to manage audio file during DMA transfer*/ uint32_t AudioTotalSize = 0xFFFF; /* This variable holds the total size of the audio file */ uint32_t AudioRemSize = 0xFFFF; /* This variable holds the remaining data in audio file */ uint16_t *CurrentPos ; /* This variable holds the current position of audio pointer */ extern __IO uint8_t volume; extern __IO uint8_t VolumeChange; /* Private function prototypes -----------------------------------------------*/ static void AudioPlay_SetHint(void); static void AudioPlay_DisplayInfos(WAVE_FormatTypeDef * format); /* Private functions ---------------------------------------------------------*/ /** * @brief Test Audio Hardware. * The main objective of this test is to check the hardware connection of the * Audio peripheral. * @param None * @retval None */ void AudioPlay_demo(void) { WAVE_FormatTypeDef *waveformat = NULL; uint8_t Volume_string[20] = {0}; AudioPlay_SetHint(); /* Configuration of the EXTI for the joystick SEL push button for pause/resume */ /* UP/DOWN push buttons for change the volume */ BSP_JOY_Init(JOY_MODE_EXTI); /* Retrieve Wave Sample rate */ waveformat = (WAVE_FormatTypeDef*) AUDIO_FILE_ADDRESS; /* Check waveformat validity */ /* In case of audio file pre-loaded into Flash memory, to check audio data */ /* integrity. */ if ((waveformat->SampleRate < SAMPLE_RATE_MIN) || (waveformat->SampleRate > SAMPLE_RATE_MAX)) { BSP_LCD_SetTextColor(LCD_COLOR_RED); BSP_LCD_DisplayStringAt(0, 130, (uint8_t*)"Audio file not valid", CENTER_MODE); BSP_LCD_DisplayStringAt(0, 145, (uint8_t*)"Check audio data integrity", CENTER_MODE); Error_Handler(); } /* Display audio file Wave parameters */ AudioPlay_DisplayInfos(waveformat); /* Initialize Audio Device */ if(BSP_AUDIO_OUT_Init(OUTPUT_DEVICE_BOTH, volume, waveformat->SampleRate) != 0) { BSP_LCD_SetTextColor(LCD_COLOR_RED); BSP_LCD_DisplayStringAt(0, 130, (uint8_t*)"Initialization problem", CENTER_MODE); BSP_LCD_DisplayStringAt(0, 145, (uint8_t*)"Audio Codec not detected", CENTER_MODE); Error_Handler(); } /* Set the total number of data to be played */ AudioTotalSize = (AUDIO_FILE_SIZE - AUDIO_START_ADDRESS) / 2; /* Set the current audio pointer position */ CurrentPos = (uint16_t *)(AUDIO_FILE_ADDRESS); /* Initialize Volume */ if(BSP_AUDIO_OUT_SetVolume(volume) != 0) { Error_Handler(); } /* Start the audio player */ if(BSP_AUDIO_OUT_Play(CurrentPos, DMA_MAX(AudioTotalSize)) != 0) { Error_Handler(); } /* Turn ON LED green: start of Audio file play */ BSP_LED_On(LED_GREEN); /* Update the remaining number of data to be played */ AudioRemSize = AudioTotalSize - DMA_MAX(AudioTotalSize); /* Update the current audio pointer position */ CurrentPos += DMA_MAX(AudioTotalSize); BSP_LCD_DisplayStringAt(20, BSP_LCD_GetYSize()-30, (uint8_t *)"Playback on-going", LEFT_MODE); sprintf((char *) Volume_string, " Volume : %d%% ", volume); BSP_LCD_DisplayStringAt(20, BSP_LCD_GetYSize()-30, Volume_string, RIGHT_MODE); /* Infinite loop */ while(!CheckForUserInput()) { if (PauseResumeStatus == PAUSE_STATUS) { /* Turn ON LED orange: Audio play in pause */ BSP_LED_On(LED_ORANGE); /* Pause playing */ if(BSP_AUDIO_OUT_Pause() != 0) { Error_Handler(); } BSP_LCD_DisplayStringAt(20, BSP_LCD_GetYSize()-30, (uint8_t *)"Playback paused ", LEFT_MODE); PauseResumeStatus = IDLE_STATUS; } else if (PauseResumeStatus == RESUME_STATUS) { /* Turn OFF LED orange: Audio play running */ BSP_LED_Off(LED_ORANGE); /* Resume playing */ if(BSP_AUDIO_OUT_Resume() != 0) { Error_Handler(); } BSP_LCD_DisplayStringAt(20, BSP_LCD_GetYSize()-30, (uint8_t *)"Playback on-going", LEFT_MODE); PauseResumeStatus = IDLE_STATUS; } if (VolumeChange != 0) { VolumeChange = 0; if(BSP_AUDIO_OUT_SetVolume(volume) != 0) { Error_Handler(); } sprintf((char *) Volume_string, " Volume : %d%% ", volume); BSP_LCD_DisplayStringAt(20, BSP_LCD_GetYSize()-30, Volume_string, RIGHT_MODE); } if (UserOutputMode != UserOutputModePreviousState) { /* Change audio output */ BSP_AUDIO_OUT_SetOutputMode(UserOutputMode); UserOutputModePreviousState = UserOutputMode; } } /* Reset the EXTI configuration for Joystick SEL, UP and DOWN push buttons */ /* Configuration of the joystick in GPIO mode and no more EXTI */ BSP_PB_Init(BUTTON_SEL, BUTTON_MODE_GPIO); BSP_PB_Init(BUTTON_UP, BUTTON_MODE_GPIO); BSP_PB_Init(BUTTON_DOWN, BUTTON_MODE_GPIO); /* Stop Player before close Test */ if (BSP_AUDIO_OUT_Stop(CODEC_PDWN_SW) != AUDIO_OK) { /* Audio Stop error */ Error_Handler(); } else { /* Turn OFF LED green: stop of Audio file play */ BSP_LED_Off(LED_GREEN); BSP_LED_Off(LED_ORANGE); } } /** * @brief Display audio play demo hint * @param None * @retval None */ static void AudioPlay_SetHint(void) { /* Clear the LCD */ BSP_LCD_Clear(LCD_COLOR_WHITE); /* Set Audio Demo description */ BSP_LCD_SetTextColor(LCD_COLOR_BLUE); BSP_LCD_FillRect(0, 0, BSP_LCD_GetXSize(), 80); BSP_LCD_SetTextColor(LCD_COLOR_WHITE); BSP_LCD_SetBackColor(LCD_COLOR_BLUE); BSP_LCD_SetFont(&Font24); BSP_LCD_DisplayStringAt(0, 0, (uint8_t *)"Audio Play", CENTER_MODE); BSP_LCD_SetFont(&Font12); BSP_LCD_DisplayStringAt(0, 30, (uint8_t *)"Press Key push-button to stop play", CENTER_MODE); BSP_LCD_DisplayStringAt(0, 45, (uint8_t *)"Press SEL to pause/resume playback", CENTER_MODE); BSP_LCD_DisplayStringAt(0, 60, (uint8_t *)"Press UP/DOWN to change Volume", CENTER_MODE); /* Set the LCD Text Color */ BSP_LCD_SetTextColor(LCD_COLOR_BLUE); BSP_LCD_DrawRect(10, 90, BSP_LCD_GetXSize() - 20, BSP_LCD_GetYSize()- 100); BSP_LCD_DrawRect(11, 91, BSP_LCD_GetXSize() - 22, BSP_LCD_GetYSize()- 102); BSP_LCD_SetTextColor(LCD_COLOR_BLACK); BSP_LCD_SetBackColor(LCD_COLOR_WHITE); } /** * @brief Display audio play demo hint * @param format : structure containing information of the file * @retval None */ static void AudioPlay_DisplayInfos(WAVE_FormatTypeDef * format) { uint8_t string[50] = {0}; sprintf((char *) string, "Sampling frequency : %ld Hz", format->SampleRate); BSP_LCD_DisplayStringAt(20, 100, string, CENTER_MODE); if (format->NbrChannels == 2) { sprintf((char *) string, "Format : %d bits stereo", format->BitPerSample); BSP_LCD_DisplayStringAt(20, 115, string, CENTER_MODE); } else if (format->NbrChannels == 1) { sprintf((char *) string, "Format : %d bits mono", format->BitPerSample); BSP_LCD_DisplayStringAt(20, 115, string, CENTER_MODE); } /* How to use Joystick for change speaker */ sprintf((char *) string, "Joystick Right for speaker only"); BSP_LCD_DisplayStringAt(20, 145, string, CENTER_MODE); sprintf((char *) string, "Joystick Left for headset only"); BSP_LCD_DisplayStringAt(20, 160, string, CENTER_MODE); } /*-------------------------------- Callbacks implementation: The callbacks prototypes are defined in the stm3210e_eval_audio.h file and their implementation should be done in the user code if they are needed. Below some examples of callback implementations. --------------------------------------------------------*/ /** * @brief Calculates the remaining file size and new position of the pointer. * @param None * @retval None */ void BSP_AUDIO_OUT_TransferComplete_CallBack() { uint32_t replay = 0; if (AudioRemSize > 0) { /* Replay from the current position */ BSP_AUDIO_OUT_ChangeBuffer((uint16_t*)CurrentPos, DMA_MAX(AudioRemSize)); /* Update the current pointer position */ CurrentPos += DMA_MAX(AudioRemSize); /* Update the remaining number of data to be played */ AudioRemSize -= DMA_MAX(AudioRemSize); } else { /* Request to replay audio file from beginning */ replay = 1; } /* Audio sample used for play */ if(replay == 1) { /* Replay from the beginning */ /* Set the current audio pointer position */ CurrentPos = (uint16_t *)(AUDIO_FILE_ADDRESS); /* Replay from the beginning */ if (BSP_AUDIO_OUT_Play(CurrentPos,DMA_MAX(AudioTotalSize)) != 0) { Error_Handler(); } /* Toggle Green Led, each time a replay is requested */ BSP_LED_Toggle(LED_GREEN); /* Update the remaining number of data to be played */ AudioRemSize = AudioTotalSize - DMA_MAX(AudioTotalSize); /* Update the current audio pointer position */ CurrentPos += DMA_MAX(AudioTotalSize); } } /** * @brief Manages the DMA FIFO error interrupt. * @param None * @retval None */ void BSP_AUDIO_OUT_Error_CallBack(void) { /* Stop the program with an infinite loop */ Error_Handler(); } /** * @} */ /** * @} */
0
D://workCode//uploadProject\STM32CubeF1\Projects\STM3210E_EVAL\Examples\BSP
D://workCode//uploadProject\STM32CubeF1\Projects\STM3210E_EVAL\Examples\BSP\Src\flash.c
/** ****************************************************************************** * @file BSP/Src/flash.c * @author MCD Application Team * @brief This example code shows how to use Flash SPI features. ****************************************************************************** * @attention * * Copyright (c) 2016 STMicroelectronics. * All rights reserved. * * This software is licensed under terms that can be found in the LICENSE file * in the root directory of this software component. * If no LICENSE file comes with this software, it is provided AS-IS. * ****************************************************************************** */ /* Includes ------------------------------------------------------------------*/ #include "main.h" /** @addtogroup STM32F1xx_HAL_Examples * @{ */ /** @addtogroup BSP * @{ */ /* Private typedef -----------------------------------------------------------*/ typedef enum {FAILED = 0, PASSED = !FAILED} TestStatus; /* Private define ------------------------------------------------------------*/ #define FLASH_WriteSector127 0x7F0000 /* End of Sector 0x7FFFFF */ #define FLASH_WriteSector126 0x7E0000 /* End of Sector 0x7EFFFF */ #define FLASH_WriteSector125 0x7D0000 /* End of Sector 0x7DFFFF */ #define FLASH_WriteSector124 0x7C0000 /* End of Sector 0x7CFFFF */ #define FLASH_WriteSector123 0x7B0000 /* End of Sector 0x7BFFFF */ #define FLASH_WriteSector122 0x7A0000 /* End of Sector 0x7AFFFF */ #define FLASH_WriteSector121 0x790000 /* End of Sector 0x79FFFF */ #define FLASH_WriteSector120 0x780000 /* End of Sector 0x78FFFF */ #define FLASH_WriteSector119 0x770000 /* End of Sector 0x77FFFF */ #define FLASH_WriteSector118 0x760000 /* End of Sector 0x76FFFF */ #define FLASH_WriteSector117 0x750000 /* End of Sector 0x75FFFF */ #define FLASH_WriteSector116 0x740000 /* End of Sector 0x74FFFF */ #define FLASH_WriteSector115 0x730000 /* End of Sector 0x73FFFF */ #define FLASH_WriteSector114 0x720000 /* End of Sector 0x72FFFF */ #define FLASH_WriteSector113 0x710000 /* End of Sector 0x71FFFF */ #define FLASH_WriteSector112 0x700000 /* End of Sector 0x70FFFF */ #define FLASH_WriteSector111 0x6F0000 /* End of Sector 0x6FFFFF */ #define FLASH_WriteSector110 0x6E0000 /* End of Sector 0x6EFFFF */ #define FLASH_WriteSector109 0x6D0000 /* End of Sector 0x6DFFFF */ #define FLASH_WriteSector108 0x6C0000 /* End of Sector 0x6CFFFF */ #define FLASH_WriteSector107 0x6B0000 /* End of Sector 0x6BFFFF */ #define FLASH_WriteSector106 0x6A0000 /* End of Sector 0x6AFFFF */ #define FLASH_WriteSector105 0x690000 /* End of Sector 0x69FFFF */ #define FLASH_WriteSector104 0x680000 /* End of Sector 0x68FFFF */ #define FLASH_WriteSector103 0x670000 /* End of Sector 0x67FFFF */ #define FLASH_WriteSector102 0x660000 /* End of Sector 0x66FFFF */ #define FLASH_WriteSector101 0x650000 /* End of Sector 0x65FFFF */ #define FLASH_WriteSector100 0x640000 /* End of Sector 0x64FFFF */ #define FLASH_WriteSector99 0x630000 /* End of Sector 0x63FFFF */ #define FLASH_WriteSector98 0x620000 /* End of Sector 0x62FFFF */ #define FLASH_WriteSector97 0x610000 /* End of Sector 0x61FFFF */ #define FLASH_WriteSector96 0x600000 /* End of Sector 0x60FFFF */ #define FLASH_WriteSector95 0x5F0000 /* End of Sector 0x5FFFFF */ #define FLASH_WriteSector94 0x5E0000 /* End of Sector 0x5EFFFF */ #define FLASH_WriteSector93 0x5D0000 /* End of Sector 0x5DFFFF */ #define FLASH_WriteSector92 0x5C0000 /* End of Sector 0x5CFFFF */ #define FLASH_WriteSector91 0x5B0000 /* End of Sector 0x5BFFFF */ #define FLASH_WriteSector90 0x5A0000 /* End of Sector 0x5AFFFF */ #define FLASH_WriteSector89 0x590000 /* End of Sector 0x59FFFF */ #define FLASH_WriteSector88 0x580000 /* End of Sector 0x58FFFF */ #define FLASH_WriteSector87 0x570000 /* End of Sector 0x57FFFF */ #define FLASH_WriteSector86 0x560000 /* End of Sector 0x56FFFF */ #define FLASH_WriteSector85 0x550000 /* End of Sector 0x55FFFF */ #define FLASH_WriteSector84 0x540000 /* End of Sector 0x54FFFF */ #define FLASH_WriteSector83 0x530000 /* End of Sector 0x53FFFF */ #define FLASH_WriteSector82 0x520000 /* End of Sector 0x52FFFF */ #define FLASH_WriteSector81 0x510000 /* End of Sector 0x51FFFF */ #define FLASH_WriteSector80 0x500000 /* End of Sector 0x50FFFF */ #define FLASH_WriteSector79 0x4F0000 /* End of Sector 0x4FFFFF */ #define FLASH_WriteSector78 0x4E0000 /* End of Sector 0x4EFFFF */ #define FLASH_WriteSector77 0x4D0000 /* End of Sector 0x4DFFFF */ #define FLASH_WriteSector76 0x4C0000 /* End of Sector 0x4CFFFF */ #define FLASH_WriteSector75 0x4B0000 /* End of Sector 0x4BFFFF */ #define FLASH_WriteSector74 0x4A0000 /* End of Sector 0x4AFFFF */ #define FLASH_WriteSector73 0x490000 /* End of Sector 0x49FFFF */ #define FLASH_WriteSector72 0x480000 /* End of Sector 0x48FFFF */ #define FLASH_WriteSector71 0x470000 /* End of Sector 0x47FFFF */ #define FLASH_WriteSector70 0x460000 /* End of Sector 0x46FFFF */ #define FLASH_WriteSector69 0x450000 /* End of Sector 0x45FFFF */ #define FLASH_WriteSector68 0x440000 /* End of Sector 0x44FFFF */ #define FLASH_WriteSector67 0x430000 /* End of Sector 0x43FFFF */ #define FLASH_WriteSector66 0x420000 /* End of Sector 0x42FFFF */ #define FLASH_WriteSector65 0x410000 /* End of Sector 0x41FFFF */ #define FLASH_WriteSector64 0x400000 /* End of Sector 0x40FFFF */ #define FLASH_WriteSector63 0x3F0000 /* End of Sector 0x3FFFFF */ #define FLASH_WriteSector62 0x3E0000 /* End of Sector 0x3EFFFF */ #define FLASH_WriteSector61 0x3D0000 /* End of Sector 0x3DFFFF */ #define FLASH_WriteSector60 0x3C0000 /* End of Sector 0x3CFFFF */ #define FLASH_WriteSector59 0x3B0000 /* End of Sector 0x3BFFFF */ #define FLASH_WriteSector58 0x3A0000 /* End of Sector 0x3AFFFF */ #define FLASH_WriteSector57 0x390000 /* End of Sector 0x39FFFF */ #define FLASH_WriteSector56 0x380000 /* End of Sector 0x38FFFF */ #define FLASH_WriteSector55 0x370000 /* End of Sector 0x37FFFF */ #define FLASH_WriteSector54 0x360000 /* End of Sector 0x36FFFF */ #define FLASH_WriteSector53 0x350000 /* End of Sector 0x35FFFF */ #define FLASH_WriteSector52 0x340000 /* End of Sector 0x34FFFF */ #define FLASH_WriteSector51 0x330000 /* End of Sector 0x33FFFF */ #define FLASH_WriteSector50 0x320000 /* End of Sector 0x32FFFF */ #define FLASH_WriteSector49 0x310000 /* End of Sector 0x31FFFF */ #define FLASH_WriteSector48 0x300000 /* End of Sector 0x30FFFF */ #define FLASH_WriteSector47 0x2F0000 /* End of Sector 0x2FFFFF */ #define FLASH_WriteSector46 0x2E0000 /* End of Sector 0x2EFFFF */ #define FLASH_WriteSector45 0x2D0000 /* End of Sector 0x2DFFFF */ #define FLASH_WriteSector44 0x2C0000 /* End of Sector 0x2CFFFF */ #define FLASH_WriteSector43 0x2B0000 /* End of Sector 0x2BFFFF */ #define FLASH_WriteSector42 0x2A0000 /* End of Sector 0x2AFFFF */ #define FLASH_WriteSector41 0x290000 /* End of Sector 0x29FFFF */ #define FLASH_WriteSector40 0x280000 /* End of Sector 0x28FFFF */ #define FLASH_WriteSector39 0x270000 /* End of Sector 0x27FFFF */ #define FLASH_WriteSector38 0x260000 /* End of Sector 0x26FFFF */ #define FLASH_WriteSector37 0x250000 /* End of Sector 0x25FFFF */ #define FLASH_WriteSector36 0x240000 /* End of Sector 0x24FFFF */ #define FLASH_WriteSector35 0x230000 /* End of Sector 0x23FFFF */ #define FLASH_WriteSector34 0x220000 /* End of Sector 0x22FFFF */ #define FLASH_WriteSector33 0x210000 /* End of Sector 0x21FFFF */ #define FLASH_WriteSector32 0x200000 /* End of Sector 0x20FFFF */ #define FLASH_WriteSector31 0x1F0000 /* End of Sector 0x1FFFFF */ #define FLASH_WriteSector30 0x1E0000 /* End of Sector 0x1EFFFF */ #define FLASH_WriteSector29 0x1D0000 /* End of Sector 0x1DFFFF */ #define FLASH_WriteSector28 0x1C0000 /* End of Sector 0x1CFFFF */ #define FLASH_WriteSector27 0x1B0000 /* End of Sector 0x1BFFFF */ #define FLASH_WriteSector26 0x1A0000 /* End of Sector 0x1AFFFF */ #define FLASH_WriteSector25 0x190000 /* End of Sector 0x19FFFF */ #define FLASH_WriteSector24 0x180000 /* End of Sector 0x18FFFF */ #define FLASH_WriteSector23 0x170000 /* End of Sector 0x17FFFF */ #define FLASH_WriteSector22 0x160000 /* End of Sector 0x16FFFF */ #define FLASH_WriteSector21 0x150000 /* End of Sector 0x15FFFF */ #define FLASH_WriteSector20 0x140000 /* End of Sector 0x14FFFF */ #define FLASH_WriteSector19 0x130000 /* End of Sector 0x13FFFF */ #define FLASH_WriteSector18 0x120000 /* End of Sector 0x12FFFF */ #define FLASH_WriteSector17 0x110000 /* End of Sector 0x11FFFF */ #define FLASH_WriteSector16 0x100000 /* End of Sector 0x10FFFF */ #define FLASH_WriteSector15 0x0F0000 /* End of Sector 0x0FFFFF */ #define FLASH_WriteSector14 0x0E0000 /* End of Sector 0x0EFFFF */ #define FLASH_WriteSector13 0x0D0000 /* End of Sector 0x0DFFFF */ #define FLASH_WriteSector12 0x0C0000 /* End of Sector 0x0CFFFF */ #define FLASH_WriteSector11 0x0B0000 /* End of Sector 0x0BFFFF */ #define FLASH_WriteSector10 0x0A0000 /* End of Sector 0x0AFFFF */ #define FLASH_WriteSector9 0x090000 /* End of Sector 0x09FFFF */ #define FLASH_WriteSector8 0x080000 /* End of Sector 0x08FFFF */ #define FLASH_WriteSector7 0x070000 /* End of Sector 0x07FFFF */ #define FLASH_WriteSector6 0x060000 /* End of Sector 0x06FFFF */ #define FLASH_WriteSector5 0x050000 /* End of Sector 0x05FFFF */ #define FLASH_WriteSector4 0x040000 /* End of Sector 0x04FFFF */ #define FLASH_WriteSector3 0x030000 /* End of Sector 0x03FFFF */ #define FLASH_WriteSector2 0x020000 /* End of Sector 0x02FFFF */ #define FLASH_WriteSector1 0x010000 /* End of Sector 0x01FFFF */ #define FLASH_WriteSector0 0x000000 /* End of Sector 0x00FFFF */ #define FLASH_AddrSector12 0x0C0035 /* Addr inside Sector 12, In case of erase sector at this address Sector 12 shall be erase*/ #define BufferSize (countof(Tx_Buffer)-1) /* Private macro -------------------------------------------------------------*/ #define countof(a) (sizeof(a) / sizeof(*(a))) /* Private variables ---------------------------------------------------------*/ uint8_t Tx_Buffer[] = "STM32F10x SPI Firmware Library Example: communication with an M25P SPI FLASH"; uint8_t Rx_Buffer[BufferSize]; __IO uint32_t FlashID = 0; __IO uint8_t Index = 0x0; volatile TestStatus TransferStatus1 = PASSED, TransferStatus2 = PASSED, TransferStatus3 = PASSED, Test = PASSED; /* Private functions ---------------------------------------------------------*/ static TestStatus Buffercmp(uint8_t* pBuffer1, uint8_t* pBuffer2, uint16_t BufferLength); static void Flush_Rx_Buffers(uint8_t* pBuffer, uint16_t BufferLength); static void Flash_SetHint(void); /** * @brief Main program * @param None * @retval None */ void FLASH_demo(void) { /* Set Display for Demo Flash SPI */ Flash_SetHint(); /* Initialize the SPI FLASH driver */ BSP_SERIAL_FLASH_Init(); /* Get SPI Flash ID */ FlashID = BSP_SERIAL_FLASH_ReadID(); /* Check the SPI Flash ID */ if (FlashID == FLASH_SPI_M25P64_ID) { /* Initialization OK as BSP_SERIAL_FLASH_ReadID return the right value */ BSP_LCD_DisplayStringAt(20, 100, (uint8_t*)"FLASH Initialization : OK.", LEFT_MODE); /* Perform a write in the Flash followed by an erase of the written data */ /* Write Tx_Buffer data to SPI FLASH memory at beginning of Sector12*/ BSP_SERIAL_FLASH_WritePage(FLASH_WriteSector12, Tx_Buffer, BufferSize); /* Erase SPI FLASH Sector12 by giving an Addr inside range of Sector12 Addr */ BSP_SERIAL_FLASH_EraseSector(FLASH_AddrSector12); /* Read Erase data from SPI FLASH memory, shall be 0xFF */ BSP_SERIAL_FLASH_ReadData(FLASH_WriteSector12, Rx_Buffer, BufferSize); /* Check the correctness of erasing operation data */ for (Index = 0; Index < BufferSize; Index++) { if (Rx_Buffer[Index] != 0xFF) { TransferStatus1 = FAILED; } } /* Flush Data inside Rx_Buffer */ Flush_Rx_Buffers(Rx_Buffer, BufferSize); if(TransferStatus1 == PASSED) { BSP_LCD_DisplayStringAt(20, 115, (uint8_t*)"FLASH ERASE : OK.", LEFT_MODE); } else { BSP_LCD_DisplayStringAt(20, 115, (uint8_t*)"FLASH ERASE : FAILED.", LEFT_MODE); Test = FAILED; } /* Perform a write in the Flash followed by a read of the written data */ /* Write Tx_Buffer data to SPI FLASH memory at Sector0 Addr*/ BSP_SERIAL_FLASH_WritePage(FLASH_WriteSector0, Tx_Buffer, BufferSize); /* Read data from SPI FLASH memory at Sector0 Addr*/ BSP_SERIAL_FLASH_ReadData(FLASH_WriteSector0, Rx_Buffer, BufferSize); /* Check the correctness of written data */ TransferStatus2 = Buffercmp(Tx_Buffer, Rx_Buffer, BufferSize); /* Flush Data inside Rx_Buffer */ Flush_Rx_Buffers(Rx_Buffer, BufferSize); if(TransferStatus2 == PASSED) { BSP_LCD_DisplayStringAt(20, 130, (uint8_t*)"FLASH WRITE : OK.", LEFT_MODE); BSP_LCD_DisplayStringAt(20, 145, (uint8_t*)"FLASH READ : OK.", LEFT_MODE); } else { BSP_LCD_DisplayStringAt(20, 130, (uint8_t*)"FLASH WRITE : FAILED.", LEFT_MODE); BSP_LCD_DisplayStringAt(20, 145, (uint8_t*)"FLASH READ : FAILED.", LEFT_MODE); Test = FAILED; } if(Test == PASSED) { BSP_LCD_DisplayStringAt(20, 160, (uint8_t*)"FLASH Test : OK.", LEFT_MODE); } else { BSP_LCD_DisplayStringAt(20, 160, (uint8_t*)"FLASH Test : FAILED.", LEFT_MODE); } } else { /* Error Init: Test FAILED */ BSP_LCD_DisplayStringAt(20, 100, (uint8_t*)"FLASH Initialization : FAILED.", LEFT_MODE); BSP_LCD_DisplayStringAt(20, 115, (uint8_t*)"FLASH Test : FAILED.", LEFT_MODE); } while (1) { if(CheckForUserInput() > 0) { return; } } } /** * @brief Display FLASH Demo Hint * @param None * @retval None */ static void Flash_SetHint(void) { /* Clear the LCD */ BSP_LCD_Clear(LCD_COLOR_WHITE); /* Set LCD Demo description */ BSP_LCD_SetTextColor(LCD_COLOR_BLUE); BSP_LCD_FillRect(0, 0, BSP_LCD_GetXSize(), 80); BSP_LCD_SetTextColor(LCD_COLOR_WHITE); BSP_LCD_SetBackColor(LCD_COLOR_BLUE); BSP_LCD_SetFont(&Font24); BSP_LCD_DisplayStringAt(0, 0, (uint8_t*)"FLASH", CENTER_MODE); BSP_LCD_SetFont(&Font12); BSP_LCD_DisplayStringAt(0, 30, (uint8_t*)"This example shows how to write", CENTER_MODE); BSP_LCD_DisplayStringAt(0, 45, (uint8_t*)"and read data on FLASH SPI", CENTER_MODE); /* Set the LCD Text Color */ BSP_LCD_SetTextColor(LCD_COLOR_BLUE); BSP_LCD_DrawRect(10, 90, BSP_LCD_GetXSize() - 20, BSP_LCD_GetYSize()- 100); BSP_LCD_DrawRect(11, 91, BSP_LCD_GetXSize() - 22, BSP_LCD_GetYSize()- 102); BSP_LCD_SetTextColor(LCD_COLOR_BLACK); BSP_LCD_SetBackColor(LCD_COLOR_WHITE); } /** * @brief Compares two buffers. * @param pBuffer1, pBuffer2: buffers to be compared. * @param BufferLength: buffer's length * @retval PASSED: pBuffer1 identical to pBuffer2 * FAILED: pBuffer1 differs from pBuffer2 */ static TestStatus Buffercmp(uint8_t* pBuffer1, uint8_t* pBuffer2, uint16_t BufferLength) { while(BufferLength--) { if(*pBuffer1 != *pBuffer2) { return FAILED; } pBuffer1++; pBuffer2++; } return PASSED; } /** * @brief Flushes the receive buffers. * @param None * @retval None */ static void Flush_Rx_Buffers(uint8_t* pBuffer, uint16_t BufferLength) { while(BufferLength--) { *pBuffer = 0; pBuffer++; } } /** * @} */ /** * @} */
0
D://workCode//uploadProject\STM32CubeF1\Projects\STM3210E_EVAL\Examples\BSP
D://workCode//uploadProject\STM32CubeF1\Projects\STM3210E_EVAL\Examples\BSP\Src\joystick.c
/** ****************************************************************************** * @file BSP/Src/joystick.c * @author MCD Application Team * @brief This example code shows how to use the joystick feature in the * STM3210E_EVAL driver ****************************************************************************** * @attention * * Copyright (c) 2016 STMicroelectronics. * All rights reserved. * * This software is licensed under terms that can be found in the LICENSE file * in the root directory of this software component. * If no LICENSE file comes with this software, it is provided AS-IS. * ****************************************************************************** */ /* Includes ------------------------------------------------------------------*/ #include "main.h" /** @addtogroup STM32F1xx_HAL_Examples * @{ */ /** @addtogroup BSP * @{ */ /* Private typedef -----------------------------------------------------------*/ /* Private define ------------------------------------------------------------*/ /* Private macro -------------------------------------------------------------*/ /* Private variables ---------------------------------------------------------*/ static JOYState_TypeDef JoyState = JOY_NONE; /* Private function prototypes -----------------------------------------------*/ static void Joystick_SetHint(void); /* Private functions ---------------------------------------------------------*/ /** * @brief Joystick demo * @param None * @retval None */ void Joystick_demo (void) { static uint16_t xPtr = 12; static uint16_t yPtr = 92; static uint16_t old_xPtr = 12; static uint16_t old_yPtr = 92; Joystick_SetHint(); BSP_JOY_Init(JOY_MODE_GPIO); while (1) { /* Get the Joystick State */ JoyState = BSP_JOY_GetState(); switch(JoyState) { case JOY_UP: if(yPtr > 92) { yPtr--; } break; case JOY_DOWN: if(yPtr < (BSP_LCD_GetYSize() - 12 - 11)) { yPtr++; } break; case JOY_LEFT: if(xPtr > 12) { xPtr--; } break; case JOY_RIGHT: if(xPtr < (BSP_LCD_GetXSize() - 8 - 11)) { xPtr++; } break; default: break; } BSP_LCD_SetBackColor(LCD_COLOR_WHITE); BSP_LCD_SetTextColor(LCD_COLOR_BLUE); if(JoyState == JOY_SEL) { BSP_LCD_SetTextColor(LCD_COLOR_RED); BSP_LCD_DisplayChar(xPtr, yPtr, 'X'); } else if(JoyState == JOY_NONE) { BSP_LCD_SetTextColor(LCD_COLOR_BLUE); BSP_LCD_DisplayChar(xPtr, yPtr, 'X'); } else { BSP_LCD_SetTextColor(LCD_COLOR_WHITE); BSP_LCD_DisplayChar(old_xPtr, old_yPtr, 'X'); BSP_LCD_SetTextColor(LCD_COLOR_BLUE); BSP_LCD_DisplayChar(xPtr, yPtr, 'X'); old_xPtr = xPtr; old_yPtr = yPtr; } if(CheckForUserInput() > 0) { return; } HAL_Delay(5); } } /** * @brief Display joystick demo hint * @param None * @retval None */ static void Joystick_SetHint(void) { /* Clear the LCD */ BSP_LCD_Clear(LCD_COLOR_WHITE); /* Set Joystick Demo description */ BSP_LCD_SetTextColor(LCD_COLOR_BLUE); BSP_LCD_FillRect(0, 0, BSP_LCD_GetXSize(), 80); BSP_LCD_SetTextColor(LCD_COLOR_WHITE); BSP_LCD_SetBackColor(LCD_COLOR_BLUE); BSP_LCD_SetFont(&Font24); BSP_LCD_DisplayStringAt(0, 0, (uint8_t *)"Joystick", CENTER_MODE); BSP_LCD_SetFont(&Font12); BSP_LCD_DisplayStringAt(0, 30, (uint8_t *)"Please use the joystick to move the pointer", CENTER_MODE); BSP_LCD_DisplayStringAt(0, 45, (uint8_t *)"inside the rectangle, to switch to next menu", CENTER_MODE); BSP_LCD_DisplayStringAt(0, 60, (uint8_t *)"press Key push-button.", CENTER_MODE); /* Set the LCD Text Color */ BSP_LCD_SetTextColor(LCD_COLOR_BLUE); BSP_LCD_DrawRect(10, 90, BSP_LCD_GetXSize() - 20, BSP_LCD_GetYSize()- 100); BSP_LCD_DrawRect(11, 91, BSP_LCD_GetXSize() - 22, BSP_LCD_GetYSize()- 102); } /** * @} */ /** * @} */
0
D://workCode//uploadProject\STM32CubeF1\Projects\STM3210E_EVAL\Examples\BSP
D://workCode//uploadProject\STM32CubeF1\Projects\STM3210E_EVAL\Examples\BSP\Src\lcd.c
/** ****************************************************************************** * @file BSP/Src/lcd.c * @author MCD Application Team * @brief This example code shows how to use LCD drawing features. ****************************************************************************** * @attention * * Copyright (c) 2016 STMicroelectronics. * All rights reserved. * * This software is licensed under terms that can be found in the LICENSE file * in the root directory of this software component. * If no LICENSE file comes with this software, it is provided AS-IS. * ****************************************************************************** */ /* Includes ------------------------------------------------------------------*/ #include "main.h" /** @addtogroup STM32F1xx_HAL_Examples * @{ */ /** @addtogroup BSP * @{ */ /* Private typedef -----------------------------------------------------------*/ /* Private define ------------------------------------------------------------*/ #define LCD_FEATURES_NUM 3 /* Private macro -------------------------------------------------------------*/ /* Private variables ---------------------------------------------------------*/ static uint8_t LCD_Feature = 0; /* Private function prototypes -----------------------------------------------*/ static void LCD_SetHint(void); static void LCD_Show_Feature(uint8_t feature); /* Private functions ---------------------------------------------------------*/ /** * @brief LCD demo * @param None * @retval None */ void LCD_demo (void) { LCD_SetHint(); LCD_Feature = 0; LCD_Show_Feature (LCD_Feature); while (1) { if(CheckForUserInput() > 0) { if(++LCD_Feature < LCD_FEATURES_NUM) { LCD_Show_Feature (LCD_Feature); } else { return; } } HAL_Delay(100); } } /** * @brief Display LCD demo hint * @param None * @retval None */ static void LCD_SetHint(void) { /* Clear the LCD */ BSP_LCD_Clear(LCD_COLOR_WHITE); /* Set LCD Demo description */ BSP_LCD_SetTextColor(LCD_COLOR_BLUE); BSP_LCD_FillRect(0, 0, BSP_LCD_GetXSize(), 80); BSP_LCD_SetTextColor(LCD_COLOR_WHITE); BSP_LCD_SetBackColor(LCD_COLOR_BLUE); BSP_LCD_SetFont(&Font24); BSP_LCD_DisplayStringAt(0, 0, (uint8_t *)"LCD", CENTER_MODE); BSP_LCD_SetFont(&Font12); BSP_LCD_DisplayStringAt(0, 30, (uint8_t *)"This example shows the different", CENTER_MODE); BSP_LCD_DisplayStringAt(0, 45, (uint8_t *)"LCD Features, use Key push-button", CENTER_MODE); BSP_LCD_DisplayStringAt(0, 60, (uint8_t *)"to display next page", CENTER_MODE); /* Set the LCD Text Color */ BSP_LCD_SetTextColor(LCD_COLOR_BLUE); BSP_LCD_DrawRect(10, 90, BSP_LCD_GetXSize() - 20, BSP_LCD_GetYSize()- 100); BSP_LCD_DrawRect(11, 91, BSP_LCD_GetXSize() - 22, BSP_LCD_GetYSize()- 102); } /** * @brief Show LCD Features * @param feature : feature index * @retval None */ static void LCD_Show_Feature(uint8_t feature) { Point Points[]= {{20, 150}, {80, 150}, {80, 200}}; Point Points2[]= {{BSP_LCD_GetXSize() - 80, 150}, {BSP_LCD_GetXSize() - 20, 150}, {BSP_LCD_GetXSize() - 20, 200}}; BSP_LCD_SetBackColor(LCD_COLOR_WHITE); BSP_LCD_SetTextColor(LCD_COLOR_WHITE); BSP_LCD_FillRect(12, 92, BSP_LCD_GetXSize() - 24, BSP_LCD_GetYSize()- 104); BSP_LCD_SetTextColor(LCD_COLOR_BLACK); switch (feature) { case 0: /* Text Feature */ BSP_LCD_DisplayStringAt(14, 100, (uint8_t *)"Left aligned Text", LEFT_MODE); BSP_LCD_DisplayStringAt(0, 115, (uint8_t *)"Center aligned Text", CENTER_MODE); BSP_LCD_DisplayStringAt(14, 130, (uint8_t*)"Right aligned Text", RIGHT_MODE); BSP_LCD_SetFont(&Font24); BSP_LCD_DisplayStringAt(14, 180, (uint8_t *)"Font24", LEFT_MODE); BSP_LCD_SetFont(&Font20); BSP_LCD_DisplayStringAt(BSP_LCD_GetXSize()/2 -20, 180, (uint8_t *)"Font20", LEFT_MODE); BSP_LCD_SetFont(&Font16); BSP_LCD_DisplayStringAt(BSP_LCD_GetXSize() - 80, 184, (uint8_t *)"Font16", LEFT_MODE); break; case 1: /* Draw misc. Shapes */ BSP_LCD_SetTextColor(LCD_COLOR_BLACK); BSP_LCD_DrawRect(20, 100, 60 , 40); BSP_LCD_FillRect(100, 100, 60 , 40); BSP_LCD_SetTextColor(LCD_COLOR_GRAY); BSP_LCD_DrawCircle(BSP_LCD_GetXSize() - 120, 120, 20); BSP_LCD_FillCircle(BSP_LCD_GetXSize() - 40, 120, 20); BSP_LCD_SetTextColor(LCD_COLOR_GREEN); BSP_LCD_DrawPolygon(Points, 3); BSP_LCD_SetTextColor(LCD_COLOR_RED); BSP_LCD_DrawEllipse(130, 170, 30, 20); BSP_LCD_FillEllipse(200, 170, 30, 20); BSP_LCD_SetTextColor(LCD_COLOR_BLACK); BSP_LCD_DrawHLine(20, BSP_LCD_GetYSize() - 30, BSP_LCD_GetXSize() / 5); BSP_LCD_DrawLine (100, BSP_LCD_GetYSize() - 20, 230, BSP_LCD_GetYSize()- 50); BSP_LCD_DrawLine (100, BSP_LCD_GetYSize()- 50, 230, BSP_LCD_GetYSize()- 20); BSP_LCD_SetTextColor(LCD_COLOR_GREEN); BSP_LCD_FillPolygon(Points2, 3); break; case 2: /* Draw Bitmap */ BSP_LCD_DrawBitmap(20, 100, (uint8_t *)stlogo); HAL_Delay(500); BSP_LCD_DrawBitmap(BSP_LCD_GetXSize()/2 - 40, 100, (uint8_t *)stlogo); HAL_Delay(500); BSP_LCD_DrawBitmap(BSP_LCD_GetXSize()-100, 100, (uint8_t *)stlogo); HAL_Delay(500); BSP_LCD_DrawBitmap(20, BSP_LCD_GetYSize()- 80, (uint8_t *)stlogo); HAL_Delay(500); BSP_LCD_DrawBitmap(BSP_LCD_GetXSize()/2 - 40, BSP_LCD_GetYSize()- 80, (uint8_t *)stlogo); HAL_Delay(500); BSP_LCD_DrawBitmap(BSP_LCD_GetXSize()-100, BSP_LCD_GetYSize()- 80, (uint8_t *)stlogo); HAL_Delay(500); break; } } /** * @} */ /** * @} */
0
D://workCode//uploadProject\STM32CubeF1\Projects\STM3210E_EVAL\Examples\BSP
D://workCode//uploadProject\STM32CubeF1\Projects\STM3210E_EVAL\Examples\BSP\Src\log.c
/** ****************************************************************************** * @file BSP/Src/log.c * @author MCD Application Team * @brief This example code shows how to use the LCD Log firmware functions ****************************************************************************** * @attention * * Copyright (c) 2016 STMicroelectronics. * All rights reserved. * * This software is licensed under terms that can be found in the LICENSE file * in the root directory of this software component. * If no LICENSE file comes with this software, it is provided AS-IS. * ****************************************************************************** */ /* Includes ------------------------------------------------------------------*/ #include "main.h" #include "lcd_log.h" /** @addtogroup STM32F1xx_HAL_Examples * @{ */ /** @addtogroup BSP * @{ */ /* Private typedef -----------------------------------------------------------*/ /* Private define ------------------------------------------------------------*/ /* Private macro -------------------------------------------------------------*/ /* Private variables ---------------------------------------------------------*/ /* Private function prototypes -----------------------------------------------*/ /* Private functions ---------------------------------------------------------*/ /** * @brief LCD Log demo * @param None * @retval None */ void Log_demo(void) { JOYState_TypeDef JoyState = JOY_NONE; uint8_t i = 0; /* Wait For User inputs */ while(CheckForUserInput() == 0); BSP_JOY_Init(JOY_MODE_GPIO); /* Initialize LCD Log module */ LCD_LOG_Init(); /* Show Header and Footer texts */ LCD_LOG_SetHeader((uint8_t *)"Log Example"); LCD_LOG_SetFooter((uint8_t *)"Use Joystick to scroll up/down"); /* Output User logs */ for (i = 0; i < 10; i++) { LCD_UsrLog ("This is Line %d \n", i); } HAL_Delay(2000); /* Clear Old logs */ LCD_LOG_ClearTextZone(); /* Output new user logs */ for (i = 0; i < 30; i++) { LCD_UsrLog ("This is Line %d \n", i); } /* Check for joystick user input for scroll (back and forward) */ while (1) { JoyState = BSP_JOY_GetState(); switch(JoyState) { case JOY_UP: LCD_LOG_ScrollBack(); break; case JOY_DOWN: LCD_LOG_ScrollForward(); break; default: break; } if(CheckForUserInput() > 0) { return; } HAL_Delay (10); } } /** * @} */ /** * @} */
0
D://workCode//uploadProject\STM32CubeF1\Projects\STM3210E_EVAL\Examples\BSP
D://workCode//uploadProject\STM32CubeF1\Projects\STM3210E_EVAL\Examples\BSP\Src\main.c
/** ****************************************************************************** * @file BSP/Src/main.c * @author MCD Application Team * @brief This example code shows how to use the STM3210E_EVAL BSP Drivers ****************************************************************************** * @attention * * Copyright (c) 2016 STMicroelectronics. * All rights reserved. * * This software is licensed under terms that can be found in the LICENSE file * in the root directory of this software component. * If no LICENSE file comes with this software, it is provided AS-IS. * ****************************************************************************** */ /* Includes ------------------------------------------------------------------*/ #include "main.h" #include "stlogo.h" /** @addtogroup STM32F1xx_HAL_Examples * @{ */ /** @addtogroup BSP * @{ */ /* Private typedef -----------------------------------------------------------*/ /* Private define ------------------------------------------------------------*/ /* Private macro -------------------------------------------------------------*/ /* Private variables ---------------------------------------------------------*/ uint8_t DemoIndex = 0; __IO uint8_t NbLoop = 1; /* Wave Player Pause/Resume Status. Defined as external in waveplayer.c file */ __IO uint32_t PauseResumeStatus = IDLE_STATUS; __IO uint8_t UserOutputMode = OUTPUT_DEVICE_BOTH; /* Counter for Sel Joystick pressed*/ __IO uint32_t PressCount = 0; /* Volume of the audio playback */ /* Initial volume level (from 0% (Mute) to 100% (Max)) */ __IO uint8_t volume = 60; __IO uint8_t VolumeChange = 0; /* Private function prototypes -----------------------------------------------*/ void SystemClock_Config(void); static void Display_DemoDescription(void); BSP_DemoTypedef BSP_examples[]= { {Joystick_demo, "JOYSTICK", 0}, {LCD_demo, "LCD", 0}, {SD_demo, "SD", 0}, {TSENSOR_demo, "TEMPERATURE SENSOR", 0}, {AudioPlay_demo, "AUDIO PLAY", 0}, {NOR_demo, "NOR", 0}, {SRAM_demo, "SRAM", 0}, {NAND_demo, "NAND", 0}, {FLASH_demo, "FLASH", 0}, {Log_demo, "LCD LOG", 0}, }; /* Private functions ---------------------------------------------------------*/ /** * @brief Main program * @param None * @retval None */ int main(void) { /* STM32F103xG HAL library initialization: - Configure the Flash prefetch - Systick timer is configured by default as source of time base, but user can eventually implement his proper time base source (a general purpose timer for example or other time source), keeping in mind that Time base duration should be kept 1ms since PPP_TIMEOUT_VALUEs are defined and handled in milliseconds basis. - Set NVIC Group Priority to 4 - Low Level Initialization */ HAL_Init(); /* Configure the system clock to 72 MHz */ SystemClock_Config(); /* Initialize the LEDs */ BSP_LED_Init(LED_GREEN); BSP_LED_Init(LED_ORANGE); BSP_LED_Init(LED_RED); BSP_LED_Init(LED_BLUE); /* Configure the Key push-button in GPIO Mode */ BSP_PB_Init(BUTTON_KEY, BUTTON_MODE_GPIO); /*##-1- Initialize the LCD #################################################*/ /* Initialize the LCD */ BSP_LCD_Init(); Display_DemoDescription(); /* Wait For User inputs */ while (1) { if(BSP_PB_GetState(BUTTON_KEY) == GPIO_PIN_RESET) { while (BSP_PB_GetState(BUTTON_KEY) == GPIO_PIN_RESET); BSP_examples[DemoIndex++].DemoFunc(); if(DemoIndex >= COUNT_OF_EXAMPLE(BSP_examples)) { NbLoop++; DemoIndex = 0; } Display_DemoDescription(); } } } /** * @brief System Clock Configuration * The system Clock is configured as follow : * System Clock source = PLL (HSE) * SYSCLK(Hz) = 72000000 * HCLK(Hz) = 72000000 * AHB Prescaler = 1 * APB1 Prescaler = 2 * APB2 Prescaler = 1 * HSE Frequency(Hz) = 8000000 * HSE PREDIV1 = 1 * PLLMUL = 9 * Flash Latency(WS) = 2 * @param None * @retval None */ void SystemClock_Config(void) { RCC_ClkInitTypeDef clkinitstruct = {0}; RCC_OscInitTypeDef oscinitstruct = {0}; /* Enable HSE Oscillator and activate PLL with HSE as source */ oscinitstruct.OscillatorType = RCC_OSCILLATORTYPE_HSE; oscinitstruct.HSEState = RCC_HSE_ON; oscinitstruct.HSEPredivValue = RCC_HSE_PREDIV_DIV1; oscinitstruct.PLL.PLLState = RCC_PLL_ON; oscinitstruct.PLL.PLLSource = RCC_PLLSOURCE_HSE; oscinitstruct.PLL.PLLMUL = RCC_PLL_MUL9; if (HAL_RCC_OscConfig(&oscinitstruct)!= HAL_OK) { /* Initialization Error */ while(1); } /* Select PLL as system clock source and configure the HCLK, PCLK1 and PCLK2 clocks dividers */ clkinitstruct.ClockType = (RCC_CLOCKTYPE_SYSCLK | RCC_CLOCKTYPE_HCLK | RCC_CLOCKTYPE_PCLK1 | RCC_CLOCKTYPE_PCLK2); clkinitstruct.SYSCLKSource = RCC_SYSCLKSOURCE_PLLCLK; clkinitstruct.AHBCLKDivider = RCC_SYSCLK_DIV1; clkinitstruct.APB2CLKDivider = RCC_HCLK_DIV1; clkinitstruct.APB1CLKDivider = RCC_HCLK_DIV2; if (HAL_RCC_ClockConfig(&clkinitstruct, FLASH_LATENCY_2)!= HAL_OK) { /* Initialization Error */ while(1); } } /** * @brief Display main demo messages * @param None * @retval None */ static void Display_DemoDescription(void) { char desc[50]; BSP_LCD_SetFont(&LCD_DEFAULT_FONT); /* Clear the LCD */ BSP_LCD_SetBackColor(LCD_COLOR_WHITE); BSP_LCD_Clear(LCD_COLOR_WHITE); /* Set the LCD Text Color */ BSP_LCD_SetTextColor(LCD_COLOR_DARKBLUE); /* Display LCD messages */ BSP_LCD_DisplayStringAt(0, 10, (uint8_t *)"STM32F103xG BSP", CENTER_MODE); BSP_LCD_DisplayStringAt(0, 35, (uint8_t *)"Drivers examples", CENTER_MODE); /* Draw Bitmap */ BSP_LCD_DrawBitmap((BSP_LCD_GetXSize() - 80)/2, 65, (uint8_t *)stlogo); BSP_LCD_SetFont(&Font12); BSP_LCD_DisplayStringAt(0, BSP_LCD_GetYSize()- 20, (uint8_t *)"Copyright (c) STMicroelectronics 2014", CENTER_MODE); BSP_LCD_SetFont(&Font16); BSP_LCD_SetTextColor(LCD_COLOR_BLUE); BSP_LCD_FillRect(0, BSP_LCD_GetYSize()/2 + 15, BSP_LCD_GetXSize(), 60); BSP_LCD_SetTextColor(LCD_COLOR_WHITE); BSP_LCD_SetBackColor(LCD_COLOR_BLUE); BSP_LCD_DisplayStringAt(0, BSP_LCD_GetYSize() / 2 + 15, (uint8_t *)"Press Key push-button", CENTER_MODE); BSP_LCD_DisplayStringAt(0, BSP_LCD_GetYSize()/2 + 30, (uint8_t *)"to start :", CENTER_MODE); sprintf(desc,"%s example", BSP_examples[DemoIndex].DemoName); BSP_LCD_DisplayStringAt(0, BSP_LCD_GetYSize()/2 + 45, (uint8_t *)desc, CENTER_MODE); } /** * @brief Check for user input * @param None * @retval Input state (1 : active / 0 : Inactive) */ uint8_t CheckForUserInput(void) { if(BSP_PB_GetState(BUTTON_KEY) == GPIO_PIN_RESET) { while (BSP_PB_GetState(BUTTON_KEY) == GPIO_PIN_RESET); return 1 ; } return 0; } /** * @brief EXTI line detection callbacks. * @param GPIO_Pin: Specifies the pins connected EXTI line * @retval None */ void HAL_GPIO_EXTI_Callback(uint16_t GPIO_Pin) { if(HAL_GPIO_ReadPin(SEL_JOY_GPIO_PORT, SEL_JOY_PIN) != GPIO_PIN_SET) { /* SEL is used to pause and resume the audio playback */ if (PressCount == 1) { /* Resume playing Wave status */ PauseResumeStatus = RESUME_STATUS; PressCount = 0; } else { /* Pause playing Wave status */ PauseResumeStatus = PAUSE_STATUS; PressCount = 1; } } else if(HAL_GPIO_ReadPin(UP_JOY_GPIO_PORT, UP_JOY_PIN) != GPIO_PIN_SET) { /* UP is used to increment the volume of the audio playback */ volume ++; if (volume > 100) { volume = 100; } VolumeChange = 1; } else if(HAL_GPIO_ReadPin(DOWN_JOY_GPIO_PORT, DOWN_JOY_PIN) != GPIO_PIN_SET) { /* DOWN is used to decrement the volume of the audio playback */ volume --; if ((int8_t)volume < 50) { volume = 50; } VolumeChange = 1; } else if(HAL_GPIO_ReadPin(RIGHT_JOY_GPIO_PORT, RIGHT_JOY_PIN) != GPIO_PIN_SET) { /* Audio change output: speaker only */ UserOutputMode = OUTPUT_DEVICE_SPEAKER; } else if(HAL_GPIO_ReadPin(LEFT_JOY_GPIO_PORT, LEFT_JOY_PIN) != GPIO_PIN_SET) { /* Audio change output: headset only */ UserOutputMode = OUTPUT_DEVICE_HEADPHONE; } } /** * @brief Toggle Leds * @param None * @retval None */ void Toggle_Leds(void) { static uint8_t ticks = 0; if(ticks++ > 100) { BSP_LED_Toggle(LED_BLUE); ticks = 0; } } /** * @brief This function is executed in case of error occurrence. * @param None * @retval None */ void Error_Handler(void) { /* Turn LED REDon */ BSP_LED_On(LED_RED); while(1) { } } #ifdef USE_FULL_ASSERT /** * @brief Reports the name of the source file and the source line number * where the assert_param error has occurred. * @param file: pointer to the source file name * @param line: assert_param error line source number * @retval None */ void assert_failed(uint8_t* file, uint32_t line) { /* User can add his own implementation to report the file name and line number, ex: printf("Wrong parameters value: file %s on line %d\r\n", file, line) */ /* Infinite loop */ while (1) { } } #endif /* USE_FULL_ASSERT */ /** * @} */ /** * @} */
0
D://workCode//uploadProject\STM32CubeF1\Projects\STM3210E_EVAL\Examples\BSP
D://workCode//uploadProject\STM32CubeF1\Projects\STM3210E_EVAL\Examples\BSP\Src\nand.c
/** ****************************************************************************** * @file BSP/Src/nand.c * @author MCD Application Team * @brief This example code shows how to use the NAND Driver ****************************************************************************** * @attention * * Copyright (c) 2016 STMicroelectronics. * All rights reserved. * * This software is licensed under terms that can be found in the LICENSE file * in the root directory of this software component. * If no LICENSE file comes with this software, it is provided AS-IS. * ****************************************************************************** */ /* Includes ------------------------------------------------------------------*/ #include "main.h" /** @addtogroup STM32F1xx_HAL_Examples * @{ */ /** @addtogroup BSP * @{ */ /* Private typedef -----------------------------------------------------------*/ /* Private define ------------------------------------------------------------*/ #define NB_PAGE ((uint32_t)2) #define BUFFER_SIZE (NAND_PAGE_SIZE * NB_PAGE) #define WRITE_READ_ADDR ((uint32_t)0x4000000) /* Private macro -------------------------------------------------------------*/ /* Private variables ---------------------------------------------------------*/ uint8_t nand_aTxBuffer[BUFFER_SIZE]; uint8_t nand_aRxBuffer[BUFFER_SIZE]; static uint8_t ubIDStatus = 0, ubEraseStatus = 0, ubWriteStatus = 0, ubReadStatus = 0, ubInitStatus = 0; /* Private function prototypes -----------------------------------------------*/ static void NAND_SetHint(void); static void Fill_Buffer(uint8_t *pBuffer, uint32_t BufferLenght, uint32_t Offset); static uint8_t Buffercmp(uint8_t* pBuffer, uint8_t* pBuffer1, uint32_t BufferLength); static NAND_AddressTypeDef NAND_GetAddress (uint32_t Address); /* Private functions ---------------------------------------------------------*/ /** * @brief NAND Demo * @param None * @retval None */ void NAND_demo (void) { /* NAND IDs structure */ static NAND_IDTypeDef pNAND_ID = {0}; NAND_SetHint(); /*##-1- Configure the NAND device ###########################################*/ /* NAND device configuration */ if(BSP_NAND_Init() != NAND_OK) { ubInitStatus++; } /*##-2- Read & check the NAND device IDs ####################################*/ /* Read the NAND memory ID */ BSP_NAND_Read_ID(&pNAND_ID); /* Test the NAND ID correctness */ if(pNAND_ID.Maker_Id != (uint8_t)0x20) { ubIDStatus++; } if((pNAND_ID.Device_Id != (uint8_t)0x36) && (pNAND_ID.Device_Id != (uint8_t)0x76)) { ubIDStatus++; } /*##-3- Erase NAND memory ###################################################*/ if(BSP_NAND_Erase_Block(NAND_GetAddress(WRITE_READ_ADDR)) != NAND_OK) { ubEraseStatus++; } /*##-4- NAND memory read/write access ######################################*/ /* Fill the buffer to write */ Fill_Buffer(nand_aTxBuffer, BUFFER_SIZE, 0xD201); /* Write data to the NAND memory */ if(BSP_NAND_WriteData(NAND_GetAddress(WRITE_READ_ADDR), nand_aTxBuffer, NB_PAGE) != NAND_OK) { ubWriteStatus++; } /* Read back data from the NAND memory */ if(BSP_NAND_ReadData(NAND_GetAddress(WRITE_READ_ADDR), nand_aRxBuffer, NB_PAGE) != NAND_OK) { ubReadStatus++; } /*##-5- Checking data integrity ############################################*/ if(ubInitStatus != 0) { BSP_LCD_DisplayStringAt(20, 100, (uint8_t*)"NAND Initialization : FAILED.", LEFT_MODE); BSP_LCD_DisplayStringAt(20, 115, (uint8_t*)"NAND Test Aborted.", LEFT_MODE); } else { char desc[50]; if (sprintf(desc,"NAND Init: OK. MAKER=0x%02x, DEVICE=0x%02x", pNAND_ID.Maker_Id, pNAND_ID.Device_Id) > 50) { Error_Handler(); } /*sprintf(desc,"NAND Init: OK. MAKER=%d, DEVICE=%d %d %d", pNAND_ID.Maker_Id, pNAND_ID.Device_Id, pNAND_ID.Third_Id, pNAND_ID.Fourth_Id);*/ BSP_LCD_DisplayStringAt(20, 100, (uint8_t*)desc, LEFT_MODE); } if(ubEraseStatus != 0) { BSP_LCD_DisplayStringAt(20, 115, (uint8_t*)"NAND ERASE : FAILED.", LEFT_MODE); BSP_LCD_DisplayStringAt(20, 130, (uint8_t*)"NAND Test Aborted.", LEFT_MODE); } else { BSP_LCD_DisplayStringAt(20, 115, (uint8_t*)"NAND ERASE : OK. ", LEFT_MODE); } if(ubWriteStatus != 0) { BSP_LCD_DisplayStringAt(20, 130, (uint8_t*)"NAND WRITE : FAILED.", LEFT_MODE); BSP_LCD_DisplayStringAt(20, 145, (uint8_t*)"NAND Test Aborted.", LEFT_MODE); } else { BSP_LCD_DisplayStringAt(20, 130, (uint8_t*)"NAND WRITE : OK. ", LEFT_MODE); } if(ubReadStatus != 0) { BSP_LCD_DisplayStringAt(20, 145, (uint8_t*)"NAND READ : FAILED.", LEFT_MODE); BSP_LCD_DisplayStringAt(20, 160, (uint8_t*)"NAND Test Aborted.", LEFT_MODE); } else { BSP_LCD_DisplayStringAt(20, 145, (uint8_t*)"NAND READ : OK. ", LEFT_MODE); } if(Buffercmp(nand_aRxBuffer, nand_aTxBuffer, BUFFER_SIZE) > 0) { BSP_LCD_DisplayStringAt(20, 160, (uint8_t*)"NAND COMPARE : FAILED.", LEFT_MODE); BSP_LCD_DisplayStringAt(20, 175, (uint8_t*)"NAND Test Aborted.", LEFT_MODE); } else { BSP_LCD_DisplayStringAt(20, 160, (uint8_t*)"NAND Test : OK. ", LEFT_MODE); } while (1) { if(CheckForUserInput() > 0) { return; } } } /** * @brief Display NAND Demo Hint * @param None * @retval None */ static void NAND_SetHint(void) { /* Clear the LCD */ BSP_LCD_Clear(LCD_COLOR_WHITE); /* Set LCD Demo description */ BSP_LCD_SetTextColor(LCD_COLOR_BLUE); BSP_LCD_FillRect(0, 0, BSP_LCD_GetXSize(), 80); BSP_LCD_SetTextColor(LCD_COLOR_WHITE); BSP_LCD_SetBackColor(LCD_COLOR_BLUE); BSP_LCD_SetFont(&Font24); BSP_LCD_DisplayStringAt(0, 0, (uint8_t*)"NAND", CENTER_MODE); BSP_LCD_SetFont(&Font12); BSP_LCD_DisplayStringAt(0, 30, (uint8_t*)"This example shows how to write", CENTER_MODE); BSP_LCD_DisplayStringAt(0, 45, (uint8_t*)"and read data on NAND", CENTER_MODE); /* Set the LCD Text Color */ BSP_LCD_SetTextColor(LCD_COLOR_BLUE); BSP_LCD_DrawRect(10, 90, BSP_LCD_GetXSize() - 20, BSP_LCD_GetYSize()- 100); BSP_LCD_DrawRect(11, 91, BSP_LCD_GetXSize() - 22, BSP_LCD_GetYSize()- 102); BSP_LCD_SetTextColor(LCD_COLOR_BLACK); BSP_LCD_SetBackColor(LCD_COLOR_WHITE); } /** * @brief Fills buffer with user predefined data. * @param pBuffer: pointer on the buffer to fill * @param uwBufferLenght: size of the buffer to fill * @param uwOffset: first value to fill on the buffer * @retval None */ static void Fill_Buffer(uint8_t *pBuffer, uint32_t uwBufferLenght, uint32_t uwOffset) { uint32_t index = 0; /* Put in global buffer same values */ for (index = 0; index < (uwBufferLenght/2); index++ ) { pBuffer[index] = index + uwOffset; } /* Put in global buffer same values */ for (index = (uwBufferLenght/2); index < uwBufferLenght; index++ ) { pBuffer[index] = uwOffset - index; } } /** * @brief Compares two buffers. * @param pBuffer, pBuffer1: buffers to be compared. * @param uwBufferLenght: buffer's length * @retval 1: pBuffer identical to pBuffer1 * 0: pBuffer differs from pBuffer1 */ static uint8_t Buffercmp(uint8_t* pBuffer, uint8_t* pBuffer1, uint32_t uwBufferLenght) { uint32_t counter = 0; while(uwBufferLenght--) { if(*pBuffer != *pBuffer1) { return 1; } pBuffer++; pBuffer1++; counter++; } return 0; } /** * @brief Translate logical address into a phy one. * @param Address * @retval Status */ static NAND_AddressTypeDef NAND_GetAddress (uint32_t Address) { NAND_AddressTypeDef Address_t; Address_t.Page = (Address % (NAND_BLOCK_SIZE * (NAND_PAGE_SIZE + NAND_SPARE_AREA_SIZE))) / (NAND_PAGE_SIZE + NAND_SPARE_AREA_SIZE); Address_t.Block = (Address % (NAND_PLANE_SIZE * NAND_BLOCK_SIZE * (NAND_PAGE_SIZE + NAND_SPARE_AREA_SIZE))) / (NAND_BLOCK_SIZE * (NAND_PAGE_SIZE + NAND_SPARE_AREA_SIZE)); Address_t.Plane = Address / (NAND_PLANE_SIZE * NAND_BLOCK_SIZE * (NAND_PAGE_SIZE + NAND_SPARE_AREA_SIZE)); return Address_t; } /** * @} */ /** * @} */
0
D://workCode//uploadProject\STM32CubeF1\Projects\STM3210E_EVAL\Examples\BSP
D://workCode//uploadProject\STM32CubeF1\Projects\STM3210E_EVAL\Examples\BSP\Src\nor.c
/** ****************************************************************************** * @file BSP/Src/nor.c * @author MCD Application Team * @brief This example code shows how to use the NOR Driver ****************************************************************************** * @attention * * Copyright (c) 2016 STMicroelectronics. * All rights reserved. * * This software is licensed under terms that can be found in the LICENSE file * in the root directory of this software component. * If no LICENSE file comes with this software, it is provided AS-IS. * ****************************************************************************** */ /* Includes ------------------------------------------------------------------*/ #include "main.h" /** @addtogroup STM32F1xx_HAL_Examples * @{ */ /** @addtogroup BSP * @{ */ /* Private typedef -----------------------------------------------------------*/ /* Private define ------------------------------------------------------------*/ #define BUFFER_SIZE ((uint32_t)0x0100) #define WRITE_READ_ADDR ((uint32_t)0x0800) /* Private macro -------------------------------------------------------------*/ /* Private variables ---------------------------------------------------------*/ uint16_t nor_aTxBuffer[BUFFER_SIZE]; uint16_t nor_aRxBuffer[BUFFER_SIZE]; uint8_t ubIDStatus = 0, ubEraseStatus = 0, ubWriteStatus = 0, ubReadStatus = 0, ubInitStatus = 0; /* Private function prototypes -----------------------------------------------*/ static void NOR_SetHint(void); static void Fill_Buffer(uint16_t *pBuffer, uint32_t uwBufferLenght, uint32_t uwOffset); static uint8_t Buffercmp(uint16_t* pBuffer1, uint16_t* pBuffer2, uint16_t BufferLength); /* Private functions ---------------------------------------------------------*/ /** * @brief NOR Demo * @param None * @retval None */ void NOR_demo (void) { /* NOR IDs structure */ static NOR_IDTypeDef pNOR_ID; NOR_SetHint(); /*##-1- Configure the NOR device ###########################################*/ /* NOR device configuration */ if(BSP_NOR_Init() != NOR_STATUS_OK) { ubInitStatus++; } /*##-2- Read & check the NOR device IDs ####################################*/ /* Initialize the ID structure */ pNOR_ID.Manufacturer_Code = (uint16_t)0x00; pNOR_ID.Device_Code1 = (uint16_t)0x00; pNOR_ID.Device_Code2 = (uint16_t)0x00; pNOR_ID.Device_Code3 = (uint16_t)0x00; /* Read the NOR memory ID */ BSP_NOR_Read_ID(&pNOR_ID); /* Test the NOR ID correctness */ if(pNOR_ID.Manufacturer_Code != (uint16_t)0x0020) ubIDStatus++; else if(pNOR_ID.Device_Code1 != (uint16_t)0x227E) ubIDStatus++; else if (pNOR_ID.Device_Code2 != (uint16_t)0x2221) ubIDStatus++; else if (pNOR_ID.Device_Code3 != (uint16_t)0x2200) ubIDStatus++; /*##-3- Erase NOR memory ###################################################*/ /* Return to read mode */ BSP_NOR_ReturnToReadMode(); if(BSP_NOR_Erase_Block(WRITE_READ_ADDR) != NOR_STATUS_OK) { ubEraseStatus++; } /*##-4- NOR memory read/write access ######################################*/ /* Fill the buffer to write */ Fill_Buffer(nor_aTxBuffer, BUFFER_SIZE, 0xD20F); /* Write data to the NOR memory */ if(BSP_NOR_WriteData(WRITE_READ_ADDR, nor_aTxBuffer, BUFFER_SIZE) != NOR_STATUS_OK) { ubWriteStatus++; } /* Read back data from the NOR memory */ if(BSP_NOR_ReadData(WRITE_READ_ADDR, nor_aRxBuffer, BUFFER_SIZE) != NOR_STATUS_OK) { ubReadStatus++; } /*##-5- Checking data integrity ############################################*/ if(ubInitStatus != 0) { BSP_LCD_DisplayStringAt(20, 100, (uint8_t*)"NOR Initialization : FAILED.", LEFT_MODE); BSP_LCD_DisplayStringAt(20, 115, (uint8_t*)"NOR Test Aborted.", LEFT_MODE); } else { BSP_LCD_DisplayStringAt(20, 100, (uint8_t*)"NOR Initialization : OK.", LEFT_MODE); } if(ubEraseStatus != 0) { BSP_LCD_DisplayStringAt(20, 115, (uint8_t*)"NOR ERASE : FAILED.", LEFT_MODE); BSP_LCD_DisplayStringAt(20, 130, (uint8_t*)"NOR Test Aborted.", LEFT_MODE); } else { BSP_LCD_DisplayStringAt(20, 115, (uint8_t*)"NOR ERASE : OK. ", LEFT_MODE); } if(ubWriteStatus != 0) { BSP_LCD_DisplayStringAt(20, 130, (uint8_t*)"NOR WRITE : FAILED.", LEFT_MODE); BSP_LCD_DisplayStringAt(20, 145, (uint8_t*)"NOR Test Aborted.", LEFT_MODE); } else { BSP_LCD_DisplayStringAt(20, 130, (uint8_t*)"NOR WRITE : OK. ", LEFT_MODE); } if(ubReadStatus != 0) { BSP_LCD_DisplayStringAt(20, 145, (uint8_t*)"NOR READ : FAILED.", LEFT_MODE); BSP_LCD_DisplayStringAt(20, 160, (uint8_t*)"NOR Test Aborted.", LEFT_MODE); } else { BSP_LCD_DisplayStringAt(20, 145, (uint8_t*)"NOR READ : OK. ", LEFT_MODE); } if(Buffercmp(nor_aRxBuffer, nor_aTxBuffer, BUFFER_SIZE) > 0) { BSP_LCD_DisplayStringAt(20, 160, (uint8_t*)"NOR COMPARE : FAILED.", LEFT_MODE); BSP_LCD_DisplayStringAt(20, 175, (uint8_t*)"NOR Test Aborted.", LEFT_MODE); } else { BSP_LCD_DisplayStringAt(20, 160, (uint8_t*)"NOR Test : OK. ", LEFT_MODE); } while (1) { if(CheckForUserInput() > 0) { return; } } } /** * @brief Display NOR Demo Hint * @param None * @retval None */ static void NOR_SetHint(void) { /* Clear the LCD */ BSP_LCD_Clear(LCD_COLOR_WHITE); /* Set LCD Demo description */ BSP_LCD_SetTextColor(LCD_COLOR_BLUE); BSP_LCD_FillRect(0, 0, BSP_LCD_GetXSize(), 80); BSP_LCD_SetTextColor(LCD_COLOR_WHITE); BSP_LCD_SetBackColor(LCD_COLOR_BLUE); BSP_LCD_SetFont(&Font24); BSP_LCD_DisplayStringAt(0, 0, (uint8_t*)"NOR", CENTER_MODE); BSP_LCD_SetFont(&Font12); BSP_LCD_DisplayStringAt(0, 30, (uint8_t*)"This example shows how to write", CENTER_MODE); BSP_LCD_DisplayStringAt(0, 45, (uint8_t*)"and read data on NOR", CENTER_MODE); /* Set the LCD Text Color */ BSP_LCD_SetTextColor(LCD_COLOR_BLUE); BSP_LCD_DrawRect(10, 90, BSP_LCD_GetXSize() - 20, BSP_LCD_GetYSize()- 100); BSP_LCD_DrawRect(11, 91, BSP_LCD_GetXSize() - 22, BSP_LCD_GetYSize()- 102); BSP_LCD_SetTextColor(LCD_COLOR_BLACK); BSP_LCD_SetBackColor(LCD_COLOR_WHITE); } /** * @brief Fills buffer with user predefined data. * @param pBuffer: pointer on the buffer to fill * @param uwBufferLenght: size of the buffer to fill * @param uwOffset: first value to fill on the buffer * @retval None */ static void Fill_Buffer(uint16_t *pBuffer, uint32_t uwBufferLenght, uint32_t uwOffset) { uint32_t tmpIndex = 0; /* Put in global buffer different values */ for (tmpIndex = 0; tmpIndex < uwBufferLenght; tmpIndex++ ) { pBuffer[tmpIndex] = tmpIndex + uwOffset; } } /** * @brief Compares two buffers. * @param pBuffer1, pBuffer2: buffers to be compared. * @param BufferLength: buffer's length * @retval 1: pBuffer identical to pBuffer1 * 0: pBuffer differs from pBuffer1 */ static uint8_t Buffercmp(uint16_t* pBuffer1, uint16_t* pBuffer2, uint16_t BufferLength) { while (BufferLength--) { if (*pBuffer1 != *pBuffer2) { return 1; } pBuffer1++; pBuffer2++; } return 0; } /** * @} */ /** * @} */
0
D://workCode//uploadProject\STM32CubeF1\Projects\STM3210E_EVAL\Examples\BSP
D://workCode//uploadProject\STM32CubeF1\Projects\STM3210E_EVAL\Examples\BSP\Src\sd.c
/** ****************************************************************************** * @file sd.c * @author MCD Application Team * @brief This example code shows how to use the SD Driver ****************************************************************************** * @attention * * Copyright (c) 2016 STMicroelectronics. * All rights reserved. * * This software is licensed under terms that can be found in the LICENSE file * in the root directory of this software component. * If no LICENSE file comes with this software, it is provided AS-IS. * ****************************************************************************** */ /* Includes ------------------------------------------------------------------*/ #include "main.h" /** @addtogroup STM32F1xx_HAL_Examples * @{ */ /** @addtogroup BSP * @{ */ /* Private typedef -----------------------------------------------------------*/ /* Private define ------------------------------------------------------------*/ #define BLOCK_START_ADDR 0 /* Block start address */ #define NUM_OF_BLOCKS 5 /* Total number of blocks */ #define BUFFER_WORDS_SIZE ((BLOCKSIZE * NUM_OF_BLOCKS) >> 2) /* Total data size in bytes */ /* Private macro -------------------------------------------------------------*/ /* Private variables ---------------------------------------------------------*/ uint32_t aTxBuffer[BUFFER_WORDS_SIZE]; uint32_t aRxBuffer[BUFFER_WORDS_SIZE]; /* Private function prototypes -----------------------------------------------*/ static void SD_SetHint(void); static void Fill_Buffer(uint32_t *pBuffer, uint32_t uwBufferLenght, uint32_t uwOffset); static uint8_t Buffercmp(uint32_t* pBuffer1, uint32_t* pBuffer2, uint16_t BufferLength); /* Private functions ---------------------------------------------------------*/ /** * @brief SD Demo * @param None * @retval None */ void SD_demo (void) { uint8_t SD_state = MSD_OK; __IO uint8_t prev_status = 0; SD_SetHint(); SD_state = BSP_SD_Init(); /* Check if the SD card is plugged in the slot */ if(BSP_SD_IsDetected() == SD_PRESENT) { BSP_LCD_SetTextColor(LCD_COLOR_GREEN); BSP_LCD_DisplayStringAt(20, BSP_LCD_GetYSize()-30, (uint8_t *)"SD Connected ", LEFT_MODE); } else { BSP_LCD_SetTextColor(LCD_COLOR_RED); BSP_LCD_DisplayStringAt(20, BSP_LCD_GetYSize()-30, (uint8_t *)"SD Not Connected", LEFT_MODE); } BSP_LCD_SetTextColor(LCD_COLOR_BLACK); if(SD_state != MSD_OK) { BSP_LCD_DisplayStringAt(20, 100, (uint8_t *)"SD INITIALIZATION : FAIL.", LEFT_MODE); BSP_LCD_DisplayStringAt(20, 115, (uint8_t *)"SD Test Aborted.", LEFT_MODE); } else { BSP_LCD_DisplayStringAt(20, 100, (uint8_t *)"SD INITIALIZATION : OK.", LEFT_MODE); SD_state = BSP_SD_Erase(BLOCK_START_ADDR, NUM_OF_BLOCKS); /* Wait until SD cards are ready to use for new operation */ while((BSP_SD_GetCardState() != SD_TRANSFER_OK)) { } if(SD_state != MSD_OK) { BSP_LCD_DisplayStringAt(20, 115, (uint8_t *)"SD GET CARD INFO : FAIL.", LEFT_MODE); BSP_LCD_DisplayStringAt(20, 130, (uint8_t *)"SD Test Aborted.", LEFT_MODE); } else { BSP_LCD_DisplayStringAt(20, 115, (uint8_t *)"SD GET CARD INFO : OK.", LEFT_MODE); SD_state = BSP_SD_Erase(BLOCK_START_ADDR, NUM_OF_BLOCKS); /* Wait until SD cards are ready to use for new operation */ while((BSP_SD_GetCardState() != SD_TRANSFER_OK)) { } if(SD_state != MSD_OK) { BSP_LCD_DisplayStringAt(20, 130, (uint8_t *)"SD ERASE : FAILED.", LEFT_MODE); BSP_LCD_DisplayStringAt(20, 145, (uint8_t *)"SD Test Aborted.", LEFT_MODE); } else { BSP_LCD_DisplayStringAt(20, 130, (uint8_t *)"SD ERASE : OK.", LEFT_MODE); /* Fill the buffer to write */ Fill_Buffer(aTxBuffer, BUFFER_WORDS_SIZE, 0x22FF); SD_state = BSP_SD_WriteBlocks(aTxBuffer, BLOCK_START_ADDR, NUM_OF_BLOCKS, SD_DATATIMEOUT); /* Wait until SD cards are ready to use for new operation */ while((BSP_SD_GetCardState() != SD_TRANSFER_OK)) { } if(SD_state != MSD_OK) { BSP_LCD_DisplayStringAt(20, 145, (uint8_t *)"SD WRITE : FAILED.", LEFT_MODE); BSP_LCD_DisplayStringAt(20, 160, (uint8_t *)"SD Test Aborted.", LEFT_MODE); } else { BSP_LCD_DisplayStringAt(20, 145, (uint8_t *)"SD WRITE : OK.", LEFT_MODE); SD_state = BSP_SD_ReadBlocks(aRxBuffer, BLOCK_START_ADDR, NUM_OF_BLOCKS, SD_DATATIMEOUT); if(SD_state != MSD_OK) { BSP_LCD_DisplayStringAt(20, 160, (uint8_t *)"SD READ : FAILED.", LEFT_MODE); BSP_LCD_DisplayStringAt(20, 175, (uint8_t *)"SD Test Aborted.", LEFT_MODE); } else { BSP_LCD_DisplayStringAt(20, 160, (uint8_t *)"SD READ : OK.", LEFT_MODE); if(Buffercmp(aTxBuffer, aRxBuffer, BUFFER_WORDS_SIZE) > 0) { BSP_LCD_DisplayStringAt(20, 175, (uint8_t *)"SD COMPARE : FAILED.", LEFT_MODE); BSP_LCD_DisplayStringAt(20, 190, (uint8_t *)"SD Test Aborted.", LEFT_MODE); } else { BSP_LCD_DisplayStringAt(20, 175, (uint8_t *)"SD TEST : OK.", LEFT_MODE); BSP_LCD_DisplayStringAt(20, 190, (uint8_t *)"SD can be removed.", LEFT_MODE); } } } } } } while (1) { /* Check if the SD card is plugged in the slot */ if(BSP_SD_IsDetected() != SD_PRESENT) { if(prev_status == 0) { prev_status = 1; BSP_LCD_SetTextColor(LCD_COLOR_RED); BSP_LCD_DisplayStringAt(20, BSP_LCD_GetYSize()-30, (uint8_t *)"SD Not Connected", LEFT_MODE); } } else if (prev_status == 1) { BSP_SD_Init(); BSP_LCD_SetTextColor(LCD_COLOR_GREEN); BSP_LCD_DisplayStringAt(20, BSP_LCD_GetYSize()-30, (uint8_t *)"SD Connected ", LEFT_MODE); prev_status = 0; } if(CheckForUserInput() > 0) { return; } } } /** * @brief Display SD Demo Hint * @param None * @retval None */ static void SD_SetHint(void) { /* Clear the LCD */ BSP_LCD_Clear(LCD_COLOR_WHITE); /* Set LCD Demo description */ BSP_LCD_SetTextColor(LCD_COLOR_BLUE); BSP_LCD_FillRect(0, 0, BSP_LCD_GetXSize(), 80); BSP_LCD_SetTextColor(LCD_COLOR_WHITE); BSP_LCD_SetBackColor(LCD_COLOR_BLUE); BSP_LCD_SetFont(&Font24); BSP_LCD_DisplayStringAt(0, 0, (uint8_t *)"SD", CENTER_MODE); BSP_LCD_SetFont(&Font12); BSP_LCD_DisplayStringAt(0, 30, (uint8_t *)"This example shows how to write", CENTER_MODE); BSP_LCD_DisplayStringAt(0, 45, (uint8_t *)"and read data on the microSD and also", CENTER_MODE); BSP_LCD_DisplayStringAt(0, 60, (uint8_t *)"how to detect the presence of the card", CENTER_MODE); /* Set the LCD Text Color */ BSP_LCD_SetTextColor(LCD_COLOR_BLUE); BSP_LCD_DrawRect(10, 90, BSP_LCD_GetXSize() - 20, BSP_LCD_GetYSize()- 100); BSP_LCD_DrawRect(11, 91, BSP_LCD_GetXSize() - 22, BSP_LCD_GetYSize()- 102); BSP_LCD_SetTextColor(LCD_COLOR_BLACK); BSP_LCD_SetBackColor(LCD_COLOR_WHITE); } /** * @brief Fills buffer with user predefined data. * @param pBuffer: pointer on the buffer to fill * @param uwBufferLenght: size of the buffer to fill * @param uwOffset: first value to fill on the buffer * @retval None */ static void Fill_Buffer(uint32_t *pBuffer, uint32_t uwBufferLenght, uint32_t uwOffset) { uint32_t tmpIndex = 0; /* Put in global buffer different values */ for (tmpIndex = 0; tmpIndex < uwBufferLenght; tmpIndex++ ) { pBuffer[tmpIndex] = tmpIndex + uwOffset; } } /** * @brief Compares two buffers. * @param pBuffer1, pBuffer2: buffers to be compared. * @param BufferLength: buffer's length * @retval 1: pBuffer identical to pBuffer1 * 0: pBuffer differs from pBuffer1 */ static uint8_t Buffercmp(uint32_t* pBuffer1, uint32_t* pBuffer2, uint16_t BufferLength) { while (BufferLength--) { if (*pBuffer1 != *pBuffer2) { return 1; } pBuffer1++; pBuffer2++; } return 0; } /** * @} */ /** * @} */
0
D://workCode//uploadProject\STM32CubeF1\Projects\STM3210E_EVAL\Examples\BSP
D://workCode//uploadProject\STM32CubeF1\Projects\STM3210E_EVAL\Examples\BSP\Src\sram.c
/** ****************************************************************************** * @file BSP/Src/sram.c * @author MCD Application Team * @brief This example code shows how to use the SRAM Driver ****************************************************************************** * @attention * * Copyright (c) 2016 STMicroelectronics. * All rights reserved. * * This software is licensed under terms that can be found in the LICENSE file * in the root directory of this software component. * If no LICENSE file comes with this software, it is provided AS-IS. * ****************************************************************************** */ /* Includes ------------------------------------------------------------------*/ #include "main.h" /** @addtogroup STM32F1xx_HAL_Examples * @{ */ /** @addtogroup BSP * @{ */ /* Private typedef -----------------------------------------------------------*/ /* Private define ------------------------------------------------------------*/ #define BUFFER_SIZE ((uint32_t)0x0100) #define WRITE_READ_ADDR ((uint32_t)0x0800) /* Private macro -------------------------------------------------------------*/ /* Private variables ---------------------------------------------------------*/ uint16_t sram_aTxBuffer[BUFFER_SIZE]; uint16_t sram_aRxBuffer[BUFFER_SIZE]; uint8_t ubSramWrite = 0, ubSramRead = 0, ubSramInit = 0; /* Private function prototypes -----------------------------------------------*/ static void SRAM_SetHint(void); static void Fill_Buffer(uint16_t *pBuffer, uint32_t uwBufferLength, uint32_t uwOffset); static uint8_t Buffercmp(uint16_t* pBuffer1, uint16_t* pBuffer2, uint16_t BufferLength); /* Private functions ---------------------------------------------------------*/ /** * @brief SRAM Demo * @param None * @retval None */ void SRAM_demo (void) { SRAM_SetHint(); /*##-1- Configure the SRAM device ##########################################*/ /* SRAM device configuration */ if(BSP_SRAM_Init() != SRAM_OK) { ubSramInit++; } /*##-2- SRAM memory read/write access ######################################*/ /* Fill the buffer to write */ Fill_Buffer(sram_aTxBuffer, BUFFER_SIZE, 0xC20F); /* Write data to the SRAM memory */ if(BSP_SRAM_WriteData(SRAM_DEVICE_ADDR + WRITE_READ_ADDR, sram_aTxBuffer, BUFFER_SIZE) != SRAM_OK) { ubSramWrite++; } /* Read back data from the SRAM memory */ if(BSP_SRAM_ReadData(SRAM_DEVICE_ADDR + WRITE_READ_ADDR, sram_aRxBuffer, BUFFER_SIZE) != SRAM_OK) { ubSramRead++; } /*##-3- Checking data integrity ############################################*/ if(ubSramInit != 0) { BSP_LCD_DisplayStringAt(20, 100, (uint8_t *)"SRAM Initialization : FAILED.", LEFT_MODE); BSP_LCD_DisplayStringAt(20, 115, (uint8_t *)"SRAM Test Aborted.", LEFT_MODE); } else { BSP_LCD_DisplayStringAt(20, 100, (uint8_t *)"SRAM Initialization : OK.", LEFT_MODE); } if(ubSramWrite != 0) { BSP_LCD_DisplayStringAt(20, 115, (uint8_t *)"SRAM WRITE : FAILED.", LEFT_MODE); BSP_LCD_DisplayStringAt(20, 130, (uint8_t *)"SRAM Test Aborted.", LEFT_MODE); } else { BSP_LCD_DisplayStringAt(20, 115, (uint8_t *)"SRAM WRITE : OK.", LEFT_MODE); } if(ubSramRead != 0) { BSP_LCD_DisplayStringAt(20, 130, (uint8_t *)"SRAM READ : FAILED.", LEFT_MODE); BSP_LCD_DisplayStringAt(20, 145, (uint8_t *)"SRAM Test Aborted.", LEFT_MODE); } else { BSP_LCD_DisplayStringAt(20, 130, (uint8_t *)"SRAM READ : OK.", LEFT_MODE); } if(Buffercmp(sram_aRxBuffer, sram_aTxBuffer, BUFFER_SIZE) > 0) { BSP_LCD_DisplayStringAt(20, 145, (uint8_t *)"SRAM COMPARE : FAILED.", LEFT_MODE); BSP_LCD_DisplayStringAt(20, 160, (uint8_t *)"SRAM Test Aborted.", LEFT_MODE); } else { BSP_LCD_DisplayStringAt(20, 145, (uint8_t *)"SRAM Test : OK.", LEFT_MODE); } while (1) { if(CheckForUserInput() > 0) { return; } } } /** * @brief Display SRAM Demo Hint * @param None * @retval None */ static void SRAM_SetHint(void) { /* Clear the LCD */ BSP_LCD_Clear(LCD_COLOR_WHITE); /* Set LCD Demo description */ BSP_LCD_SetTextColor(LCD_COLOR_BLUE); BSP_LCD_FillRect(0, 0, BSP_LCD_GetXSize(), 80); BSP_LCD_SetTextColor(LCD_COLOR_WHITE); BSP_LCD_SetBackColor(LCD_COLOR_BLUE); BSP_LCD_SetFont(&Font24); BSP_LCD_DisplayStringAt(0, 0, (uint8_t *)"SRAM", CENTER_MODE); BSP_LCD_SetFont(&Font12); BSP_LCD_DisplayStringAt(0, 30, (uint8_t *)"This example shows how to write", CENTER_MODE); BSP_LCD_DisplayStringAt(0, 45, (uint8_t *)"and read data on the SRAM", CENTER_MODE); /* Set the LCD Text Color */ BSP_LCD_SetTextColor(LCD_COLOR_BLUE); BSP_LCD_DrawRect(10, 90, BSP_LCD_GetXSize() - 20, BSP_LCD_GetYSize()- 100); BSP_LCD_DrawRect(11, 91, BSP_LCD_GetXSize() - 22, BSP_LCD_GetYSize()- 102); BSP_LCD_SetTextColor(LCD_COLOR_BLACK); BSP_LCD_SetBackColor(LCD_COLOR_WHITE); } /** * @brief Fills buffer with user predefined data. * @param pBuffer: pointer on the buffer to fill * @param uwBufferLength: size of the buffer to fill * @param uwOffset: first value to fill on the buffer * @retval None */ static void Fill_Buffer(uint16_t *pBuffer, uint32_t uwBufferLength, uint32_t uwOffset) { uint32_t tmpindex = 0; /* Put in global buffer different values */ for (tmpindex = 0; tmpindex < uwBufferLength; tmpindex++ ) { pBuffer[tmpindex] = tmpindex + uwOffset; } } /** * @brief Compares two buffers. * @param pBuffer1, pBuffer2: buffers to be compared. * @param BufferLength: buffer's length * @retval 1: pBuffer identical to pBuffer1 * 0: pBuffer differs from pBuffer1 */ static uint8_t Buffercmp(uint16_t* pBuffer1, uint16_t* pBuffer2, uint16_t BufferLength) { while (BufferLength--) { if (*pBuffer1 != *pBuffer2) { return 1; } pBuffer1++; pBuffer2++; } return 0; } /** * @} */ /** * @} */
0
D://workCode//uploadProject\STM32CubeF1\Projects\STM3210E_EVAL\Examples\BSP
D://workCode//uploadProject\STM32CubeF1\Projects\STM3210E_EVAL\Examples\BSP\Src\stm32f1xx_it.c
/** ****************************************************************************** * @file BSP/BSP/Src/stm32f1xx_it.c * @author MCD Application Team * @brief Main Interrupt Service Routines. * This file provides template for all exceptions handler and * peripherals interrupt service routine. ****************************************************************************** * @attention * * Copyright (c) 2016 STMicroelectronics. * All rights reserved. * * This software is licensed under terms that can be found in the LICENSE file * in the root directory of this software component. * If no LICENSE file comes with this software, it is provided AS-IS. * ****************************************************************************** */ /* Includes ------------------------------------------------------------------*/ #include "main.h" #include "stm32f1xx_it.h" /** @addtogroup STM32F1xx_HAL_Examples * @{ */ /** @addtogroup BSP * @{ */ /* Private typedef -----------------------------------------------------------*/ /* Private define ------------------------------------------------------------*/ /* Private macro -------------------------------------------------------------*/ /* Private variables ---------------------------------------------------------*/ extern I2S_HandleTypeDef hAudioOutI2s; /* Private function prototypes -----------------------------------------------*/ /* Private functions ---------------------------------------------------------*/ /******************************************************************************/ /* Cortex-M3 Processor Exceptions Handlers */ /******************************************************************************/ /** * @brief This function handles NMI exception. * @param None * @retval None */ void NMI_Handler(void) { } /** * @brief This function handles Hard Fault exception. * @param None * @retval None */ void HardFault_Handler(void) { /* Go to infinite loop when Hard Fault exception occurs */ while (1) { } } /** * @brief This function handles Memory Manage exception. * @param None * @retval None */ void MemManage_Handler(void) { /* Go to infinite loop when Memory Manage exception occurs */ while (1) { } } /** * @brief This function handles Bus Fault exception. * @param None * @retval None */ void BusFault_Handler(void) { /* Go to infinite loop when Bus Fault exception occurs */ while (1) { } } /** * @brief This function handles Usage Fault exception. * @param None * @retval None */ void UsageFault_Handler(void) { /* Go to infinite loop when Usage Fault exception occurs */ while (1) { } } /** * @brief This function handles SVCall exception. * @param None * @retval None */ void SVC_Handler(void) { } /** * @brief This function handles Debug Monitor exception. * @param None * @retval None */ void DebugMon_Handler(void) { } /** * @brief This function handles PendSVC exception. * @param None * @retval None */ void PendSV_Handler(void) { } /** * @brief This function handles SysTick Handler. * @param None * @retval None */ void SysTick_Handler(void) { HAL_IncTick(); Toggle_Leds(); } /******************************************************************************/ /* STM32F1xx Peripherals Interrupt Handlers */ /* Add here the Interrupt Handler for the used peripheral(s) (PPP), for the */ /* available peripheral interrupt handler's name please refer to the startup */ /* file (startup_stm32f1xx.s). */ /******************************************************************************/ /** * @brief This function handles External line 3 interrupt request. * @param None * @retval None */ void EXTI3_IRQHandler(void) { HAL_GPIO_EXTI_IRQHandler(DOWN_JOY_PIN); } /** * @brief This function handles External line 9 to 5 interrupt request. * @param None * @retval None */ void EXTI9_5_IRQHandler(void) { HAL_GPIO_EXTI_IRQHandler(SEL_JOY_PIN); } /** * @brief This function handles External line 10 to 15 interrupt request. * @param None * @retval None */ void EXTI15_10_IRQHandler(void) { HAL_GPIO_EXTI_IRQHandler(TAMPER_BUTTON_PIN); HAL_GPIO_EXTI_IRQHandler(RIGHT_JOY_PIN); HAL_GPIO_EXTI_IRQHandler(LEFT_JOY_PIN); HAL_GPIO_EXTI_IRQHandler(UP_JOY_PIN); HAL_GPIO_EXTI_IRQHandler(SD_DETECT_PIN); } /** * @brief This function handles I2S DMA TX interrupt request. * @param None * @retval None */ void I2SOUT_IRQHandler(void) { HAL_DMA_IRQHandler(hAudioOutI2s.hdmatx); } /** * @} */ /** * @} */
0
D://workCode//uploadProject\STM32CubeF1\Projects\STM3210E_EVAL\Examples\BSP
D://workCode//uploadProject\STM32CubeF1\Projects\STM3210E_EVAL\Examples\BSP\Src\system_stm32f1xx.c
/** ****************************************************************************** * @file system_stm32f1xx.c * @author MCD Application Team * @brief CMSIS Cortex-M3 Device Peripheral Access Layer System Source File. * * 1. This file provides two functions and one global variable to be called from * user application: * - SystemInit(): Setups the system clock (System clock source, PLL Multiplier * factors, AHB/APBx prescalers and Flash settings). * This function is called at startup just after reset and * before branch to main program. This call is made inside * the "startup_stm32f1xx_xx.s" file. * * - SystemCoreClock variable: Contains the core clock (HCLK), it can be used * by the user application to setup the SysTick * timer or configure other parameters. * * - SystemCoreClockUpdate(): Updates the variable SystemCoreClock and must * be called whenever the core clock is changed * during program execution. * * 2. After each device reset the HSI (8 MHz) is used as system clock source. * Then SystemInit() function is called, in "startup_stm32f1xx_xx.s" file, to * configure the system clock before to branch to main program. * * 4. The default value of HSE crystal is set to 8 MHz (or 25 MHz, depending on * the product used), refer to "HSE_VALUE". * When HSE is used as system clock source, directly or through PLL, and you * are using different crystal you have to adapt the HSE value to your own * configuration. * ****************************************************************************** * @attention * * Copyright (c) 2016 STMicroelectronics. * All rights reserved. * * This software is licensed under terms that can be found in the LICENSE file * in the root directory of this software component. * If no LICENSE file comes with this software, it is provided AS-IS. * ****************************************************************************** */ /** @addtogroup CMSIS * @{ */ /** @addtogroup stm32f1xx_system * @{ */ /** @addtogroup STM32F1xx_System_Private_Includes * @{ */ #include "stm32f1xx.h" /** * @} */ /** @addtogroup STM32F1xx_System_Private_TypesDefinitions * @{ */ /** * @} */ /** @addtogroup STM32F1xx_System_Private_Defines * @{ */ #if !defined (HSE_VALUE) #define HSE_VALUE ((uint32_t)8000000) /*!< Default value of the External oscillator in Hz. This value can be provided and adapted by the user application. */ #endif /* HSE_VALUE */ #if !defined (HSI_VALUE) #define HSI_VALUE ((uint32_t)8000000) /*!< Default value of the Internal oscillator in Hz. This value can be provided and adapted by the user application. */ #endif /* HSI_VALUE */ /*!< Uncomment the following line if you need to use external SRAM */ #if defined(STM32F100xE) || defined(STM32F101xE) || defined(STM32F101xG) || defined(STM32F103xE) || defined(STM32F103xG) /* #define DATA_IN_ExtSRAM */ #endif /* STM32F100xE || STM32F101xE || STM32F101xG || STM32F103xE || STM32F103xG */ /*!< Uncomment the following line if you need to relocate your vector Table in Internal SRAM. */ /* #define VECT_TAB_SRAM */ #define VECT_TAB_OFFSET 0x0 /*!< Vector Table base offset field. This value must be a multiple of 0x200. */ /** * @} */ /** @addtogroup STM32F1xx_System_Private_Macros * @{ */ /** * @} */ /** @addtogroup STM32F1xx_System_Private_Variables * @{ */ /* This variable is updated in three ways: 1) by calling CMSIS function SystemCoreClockUpdate() 2) by calling HAL API function HAL_RCC_GetHCLKFreq() 3) each time HAL_RCC_ClockConfig() is called to configure the system clock frequency Note: If you use this function to configure the system clock; then there is no need to call the 2 first functions listed above, since SystemCoreClock variable is updated automatically. */ uint32_t SystemCoreClock = 16000000; const uint8_t AHBPrescTable[16] = {0, 0, 0, 0, 0, 0, 0, 0, 1, 2, 3, 4, 6, 7, 8, 9}; const uint8_t APBPrescTable[8] = {0, 0, 0, 0, 1, 2, 3, 4}; /** * @} */ /** @addtogroup STM32F1xx_System_Private_FunctionPrototypes * @{ */ #if defined(STM32F100xE) || defined(STM32F101xE) || defined(STM32F101xG) || defined(STM32F103xE) || defined(STM32F103xG) #ifdef DATA_IN_ExtSRAM static void SystemInit_ExtMemCtl(void); #endif /* DATA_IN_ExtSRAM */ #endif /* STM32F100xE || STM32F101xE || STM32F101xG || STM32F103xE || STM32F103xG */ /** * @} */ /** @addtogroup STM32F1xx_System_Private_Functions * @{ */ /** * @brief Setup the microcontroller system * Initialize the Embedded Flash Interface, the PLL and update the * SystemCoreClock variable. * @note This function should be used only after reset. * @param None * @retval None */ void SystemInit (void) { /* Reset the RCC clock configuration to the default reset state(for debug purpose) */ /* Set HSION bit */ RCC->CR |= (uint32_t)0x00000001; /* Reset SW, HPRE, PPRE1, PPRE2, ADCPRE and MCO bits */ #if !defined(STM32F105xC) && !defined(STM32F107xC) RCC->CFGR &= (uint32_t)0xF8FF0000; #else RCC->CFGR &= (uint32_t)0xF0FF0000; #endif /* STM32F105xC */ /* Reset HSEON, CSSON and PLLON bits */ RCC->CR &= (uint32_t)0xFEF6FFFF; /* Reset HSEBYP bit */ RCC->CR &= (uint32_t)0xFFFBFFFF; /* Reset PLLSRC, PLLXTPRE, PLLMUL and USBPRE/OTGFSPRE bits */ RCC->CFGR &= (uint32_t)0xFF80FFFF; #if defined(STM32F105xC) || defined(STM32F107xC) /* Reset PLL2ON and PLL3ON bits */ RCC->CR &= (uint32_t)0xEBFFFFFF; /* Disable all interrupts and clear pending bits */ RCC->CIR = 0x00FF0000; /* Reset CFGR2 register */ RCC->CFGR2 = 0x00000000; #elif defined(STM32F100xB) || defined(STM32F100xE) /* Disable all interrupts and clear pending bits */ RCC->CIR = 0x009F0000; /* Reset CFGR2 register */ RCC->CFGR2 = 0x00000000; #else /* Disable all interrupts and clear pending bits */ RCC->CIR = 0x009F0000; #endif /* STM32F105xC */ #if defined(STM32F100xE) || defined(STM32F101xE) || defined(STM32F101xG) || defined(STM32F103xE) || defined(STM32F103xG) #ifdef DATA_IN_ExtSRAM SystemInit_ExtMemCtl(); #endif /* DATA_IN_ExtSRAM */ #endif #ifdef VECT_TAB_SRAM SCB->VTOR = SRAM_BASE | VECT_TAB_OFFSET; /* Vector Table Relocation in Internal SRAM. */ #else SCB->VTOR = FLASH_BASE | VECT_TAB_OFFSET; /* Vector Table Relocation in Internal FLASH. */ #endif } /** * @brief Update SystemCoreClock variable according to Clock Register Values. * The SystemCoreClock variable contains the core clock (HCLK), it can * be used by the user application to setup the SysTick timer or configure * other parameters. * * @note Each time the core clock (HCLK) changes, this function must be called * to update SystemCoreClock variable value. Otherwise, any configuration * based on this variable will be incorrect. * * @note - The system frequency computed by this function is not the real * frequency in the chip. It is calculated based on the predefined * constant and the selected clock source: * * - If SYSCLK source is HSI, SystemCoreClock will contain the HSI_VALUE(*) * * - If SYSCLK source is HSE, SystemCoreClock will contain the HSE_VALUE(**) * * - If SYSCLK source is PLL, SystemCoreClock will contain the HSE_VALUE(**) * or HSI_VALUE(*) multiplied by the PLL factors. * * (*) HSI_VALUE is a constant defined in stm32f1xx.h file (default value * 8 MHz) but the real value may vary depending on the variations * in voltage and temperature. * * (**) HSE_VALUE is a constant defined in stm32f1xx.h file (default value * 8 MHz or 25 MHz, depending on the product used), user has to ensure * that HSE_VALUE is same as the real frequency of the crystal used. * Otherwise, this function may have wrong result. * * - The result of this function could be not correct when using fractional * value for HSE crystal. * @param None * @retval None */ void SystemCoreClockUpdate (void) { uint32_t tmp = 0, pllmull = 0, pllsource = 0; #if defined(STM32F105xC) || defined(STM32F107xC) uint32_t prediv1source = 0, prediv1factor = 0, prediv2factor = 0, pll2mull = 0; #endif /* STM32F105xC */ #if defined(STM32F100xB) || defined(STM32F100xE) uint32_t prediv1factor = 0; #endif /* STM32F100xB or STM32F100xE */ /* Get SYSCLK source -------------------------------------------------------*/ tmp = RCC->CFGR & RCC_CFGR_SWS; switch (tmp) { case 0x00: /* HSI used as system clock */ SystemCoreClock = HSI_VALUE; break; case 0x04: /* HSE used as system clock */ SystemCoreClock = HSE_VALUE; break; case 0x08: /* PLL used as system clock */ /* Get PLL clock source and multiplication factor ----------------------*/ pllmull = RCC->CFGR & RCC_CFGR_PLLMULL; pllsource = RCC->CFGR & RCC_CFGR_PLLSRC; #if !defined(STM32F105xC) && !defined(STM32F107xC) pllmull = ( pllmull >> 18) + 2; if (pllsource == 0x00) { /* HSI oscillator clock divided by 2 selected as PLL clock entry */ SystemCoreClock = (HSI_VALUE >> 1) * pllmull; } else { #if defined(STM32F100xB) || defined(STM32F100xE) prediv1factor = (RCC->CFGR2 & RCC_CFGR2_PREDIV1) + 1; /* HSE oscillator clock selected as PREDIV1 clock entry */ SystemCoreClock = (HSE_VALUE / prediv1factor) * pllmull; #else /* HSE selected as PLL clock entry */ if ((RCC->CFGR & RCC_CFGR_PLLXTPRE) != (uint32_t)RESET) {/* HSE oscillator clock divided by 2 */ SystemCoreClock = (HSE_VALUE >> 1) * pllmull; } else { SystemCoreClock = HSE_VALUE * pllmull; } #endif } #else pllmull = pllmull >> 18; if (pllmull != 0x0D) { pllmull += 2; } else { /* PLL multiplication factor = PLL input clock * 6.5 */ pllmull = 13 / 2; } if (pllsource == 0x00) { /* HSI oscillator clock divided by 2 selected as PLL clock entry */ SystemCoreClock = (HSI_VALUE >> 1) * pllmull; } else {/* PREDIV1 selected as PLL clock entry */ /* Get PREDIV1 clock source and division factor */ prediv1source = RCC->CFGR2 & RCC_CFGR2_PREDIV1SRC; prediv1factor = (RCC->CFGR2 & RCC_CFGR2_PREDIV1) + 1; if (prediv1source == 0) { /* HSE oscillator clock selected as PREDIV1 clock entry */ SystemCoreClock = (HSE_VALUE / prediv1factor) * pllmull; } else {/* PLL2 clock selected as PREDIV1 clock entry */ /* Get PREDIV2 division factor and PLL2 multiplication factor */ prediv2factor = ((RCC->CFGR2 & RCC_CFGR2_PREDIV2) >> 4) + 1; pll2mull = ((RCC->CFGR2 & RCC_CFGR2_PLL2MUL) >> 8 ) + 2; SystemCoreClock = (((HSE_VALUE / prediv2factor) * pll2mull) / prediv1factor) * pllmull; } } #endif /* STM32F105xC */ break; default: SystemCoreClock = HSI_VALUE; break; } /* Compute HCLK clock frequency ----------------*/ /* Get HCLK prescaler */ tmp = AHBPrescTable[((RCC->CFGR & RCC_CFGR_HPRE) >> 4)]; /* HCLK clock frequency */ SystemCoreClock >>= tmp; } #if defined(STM32F100xE) || defined(STM32F101xE) || defined(STM32F101xG) || defined(STM32F103xE) || defined(STM32F103xG) /** * @brief Setup the external memory controller. Called in startup_stm32f1xx.s * before jump to __main * @param None * @retval None */ #ifdef DATA_IN_ExtSRAM /** * @brief Setup the external memory controller. * Called in startup_stm32f1xx_xx.s/.c before jump to main. * This function configures the external SRAM mounted on STM3210E-EVAL * board (STM32 High density devices). This SRAM will be used as program * data memory (including heap and stack). * @param None * @retval None */ void SystemInit_ExtMemCtl(void) { __IO uint32_t tmpreg; /*!< FSMC Bank1 NOR/SRAM3 is used for the STM3210E-EVAL, if another Bank is required, then adjust the Register Addresses */ /* Enable FSMC clock */ RCC->AHBENR = 0x00000114; /* Delay after an RCC peripheral clock enabling */ tmpreg = READ_BIT(RCC->AHBENR, RCC_AHBENR_FSMCEN); /* Enable GPIOD, GPIOE, GPIOF and GPIOG clocks */ RCC->APB2ENR = 0x000001E0; /* Delay after an RCC peripheral clock enabling */ tmpreg = READ_BIT(RCC->APB2ENR, RCC_APB2ENR_IOPDEN); (void)(tmpreg); /* --------------- SRAM Data lines, NOE and NWE configuration ---------------*/ /*---------------- SRAM Address lines configuration -------------------------*/ /*---------------- NOE and NWE configuration --------------------------------*/ /*---------------- NE3 configuration ----------------------------------------*/ /*---------------- NBL0, NBL1 configuration ---------------------------------*/ GPIOD->CRL = 0x44BB44BB; GPIOD->CRH = 0xBBBBBBBB; GPIOE->CRL = 0xB44444BB; GPIOE->CRH = 0xBBBBBBBB; GPIOF->CRL = 0x44BBBBBB; GPIOF->CRH = 0xBBBB4444; GPIOG->CRL = 0x44BBBBBB; GPIOG->CRH = 0x44444B44; /*---------------- FSMC Configuration ---------------------------------------*/ /*---------------- Enable FSMC Bank1_SRAM Bank ------------------------------*/ FSMC_Bank1->BTCR[4] = 0x00001091; FSMC_Bank1->BTCR[5] = 0x00110212; } #endif /* DATA_IN_ExtSRAM */ #endif /* STM32F100xE || STM32F101xE || STM32F101xG || STM32F103xE || STM32F103xG */ /** * @} */ /** * @} */ /** * @} */
0
D://workCode//uploadProject\STM32CubeF1\Projects\STM3210E_EVAL\Examples\BSP
D://workCode//uploadProject\STM32CubeF1\Projects\STM3210E_EVAL\Examples\BSP\Src\temperature_sensor.c
/** ****************************************************************************** * @file BSP/Src/temperature_sensor.c * @author MCD Application Team * @brief This example code shows how to manage an I2C Temperature Sensor * =================================================================== * Notes: * - This driver is intended for STM32F1xx families devices only. * - The I2C Temperature Sensor is available on the STM3210E-EVAL RevD board. * =================================================================== ****************************************************************************** * @attention * * Copyright (c) 2016 STMicroelectronics. * All rights reserved. * * This software is licensed under terms that can be found in the LICENSE file * in the root directory of this software component. * If no LICENSE file comes with this software, it is provided AS-IS. * ****************************************************************************** */ /* Includes ------------------------------------------------------------------*/ #include "main.h" /** @addtogroup STM32F1xx_HAL_Examples * @{ */ /** @addtogroup BSP * @{ */ /* Private typedef -----------------------------------------------------------*/ typedef enum {FAILED = 0, PASSED = !FAILED} TestStatus; typedef enum {NOT_READY = 0, READY = !NOT_READY} Status; /* Private define ------------------------------------------------------------*/ /* Private macro -------------------------------------------------------------*/ /* Private variables ---------------------------------------------------------*/ /* Private function prototypes -----------------------------------------------*/ static void TSENSOR_SetHint(void); static void TSENSOR_Display_Temperature(uint16_t temperature); /* Private functions ---------------------------------------------------------*/ /** * @brief EEPROM Demo * @param None * @retval None */ void TSENSOR_demo (void) { uint16_t TempValue = 0; uint8_t TsensorReady = 0; uint8_t RequestSample = 0; uint32_t Tick = 0; TSENSOR_SetHint(); /* Initialize the I2C TSENSOR driver ----------------------------------------*/ BSP_LCD_SetBackColor(LCD_COLOR_WHITE); BSP_LCD_SetTextColor(LCD_COLOR_WHITE); BSP_LCD_FillRect(12, 92, BSP_LCD_GetXSize() - 24, BSP_LCD_GetYSize()- 104); BSP_LCD_SetTextColor(LCD_COLOR_BLACK); if (BSP_TSENSOR_Init() != TSENSOR_OK) { BSP_LCD_SetTextColor(LCD_COLOR_RED); BSP_LCD_DisplayStringAt(0, 115, (uint8_t*)"Initialization problem", CENTER_MODE); BSP_LCD_DisplayStringAt(0, 130, (uint8_t*)"Temperature Sensor not detected", CENTER_MODE); } else { TsensorReady = READY; RequestSample = SET; } while (1) { if((TsensorReady == READY) && (RequestSample == SET)) { TempValue = BSP_TSENSOR_ReadTemp(); TSENSOR_Display_Temperature(TempValue); Tick = HAL_GetTick(); RequestSample = RESET; } else { /* Request a Temperature sampling each 1s <-> 1000 ms */ if(HAL_GetTick() >= Tick + 1000) { RequestSample = SET; } } if(CheckForUserInput() > 0) { return; } HAL_Delay(5); } } /** * @brief Display TSENSOR Demo Hint * @param None * @retval None */ static void TSENSOR_SetHint(void) { /* Clear the LCD */ BSP_LCD_Clear(LCD_COLOR_WHITE); /* Set LCD Demo description */ BSP_LCD_SetTextColor(LCD_COLOR_BLUE); BSP_LCD_FillRect(0, 0, BSP_LCD_GetXSize(), 80); BSP_LCD_SetTextColor(LCD_COLOR_WHITE); BSP_LCD_SetBackColor(LCD_COLOR_BLUE); BSP_LCD_SetFont(&Font24); BSP_LCD_DisplayStringAt(0, 0, (uint8_t*)"TEMPERATURE SENSOR", CENTER_MODE); BSP_LCD_SetFont(&Font12); BSP_LCD_DisplayStringAt(0, 30, (uint8_t*)"This example shows how to", CENTER_MODE); BSP_LCD_DisplayStringAt(0, 45, (uint8_t*)"read a Temperature", CENTER_MODE); BSP_LCD_DisplayStringAt(0, 60, (uint8_t*)"Press key button to switch to next menu", CENTER_MODE); /* Set the LCD Text Color */ BSP_LCD_SetTextColor(LCD_COLOR_BLUE); BSP_LCD_DrawRect(10, 90, BSP_LCD_GetXSize() - 20, BSP_LCD_GetYSize()- 100); BSP_LCD_DrawRect(11, 91, BSP_LCD_GetXSize() - 22, BSP_LCD_GetYSize()- 102); } /** * @brief Display temperature * @param temperature : temperature value * @retval None */ static void TSENSOR_Display_Temperature(uint16_t temperature) { uint8_t TempCelsiusDisplay[20] = {0}; BSP_LCD_SetTextColor(LCD_COLOR_BLACK); BSP_LCD_SetFont(&Font12); BSP_LCD_DisplayStringAt(0, 115, (uint8_t*)"Measured Temperature : ", CENTER_MODE); /* Change Font size to display Temperature Value */ BSP_LCD_SetFont(&Font16); if (temperature & 0x8000) { /* Display negative temperature */ BSP_LCD_SetTextColor(LCD_COLOR_RED); if (temperature & 0x0001) { sprintf ((char*)TempCelsiusDisplay, " -%d.5 C ", ((temperature & 0x7FFF)>>1)); } else { sprintf ((char*)TempCelsiusDisplay, " -%d C ", ((temperature & 0x7FFF)>>1)); } } else { /* Display positive temperature */ BSP_LCD_SetTextColor(LCD_COLOR_GREEN); if (temperature & 0x0001) { sprintf ((char*)TempCelsiusDisplay, " %d.5 C ", ((temperature & 0x7FFF)>>1)); } else { sprintf ((char*)TempCelsiusDisplay, " %d C ", ((temperature & 0x7FFF)>>1)); } } /* Display Temperature value on LCD */ BSP_LCD_DisplayStringAt(0, 145, (uint8_t*)TempCelsiusDisplay, CENTER_MODE); BSP_LCD_SetTextColor(LCD_COLOR_BLACK); BSP_LCD_SetFont(&Font12); } /** * @} */
0
D://workCode//uploadProject\STM32CubeF1\Projects\STM3210E_EVAL\Examples\BSP
D://workCode//uploadProject\STM32CubeF1\Projects\STM3210E_EVAL\Examples\BSP\SW4STM32\syscalls.c
/* Support files for GNU libc. Files in the system namespace go here. Files in the C namespace (ie those that do not start with an underscore) go in .c. */ /* Includes */ #include <sys/stat.h> #include <stdlib.h> #include <errno.h> #include <stdio.h> #include <signal.h> #include <time.h> #include <sys/time.h> #include <sys/times.h> /* Variables */ //#undef errno extern int errno; extern int __io_putchar(int ch) __attribute__((weak)); extern int __io_getchar(void) __attribute__((weak)); register char * stack_ptr asm("sp"); char *__env[1] = { 0 }; char **environ = __env; /* Functions */ void initialise_monitor_handles() { } int _getpid(void) { return 1; } int _kill(int pid, int sig) { errno = EINVAL; return -1; } void _exit (int status) { _kill(status, -1); while (1) {} /* Make sure we hang here */ } __attribute__((weak)) int _read(int file, char *ptr, int len) { int DataIdx; for (DataIdx = 0; DataIdx < len; DataIdx++) { *ptr++ = __io_getchar(); } return len; } __attribute__((weak)) int _write(int file, char *ptr, int len) { int DataIdx; for (DataIdx = 0; DataIdx < len; DataIdx++) { __io_putchar(*ptr++); } return len; } caddr_t _sbrk(int incr) { extern char end asm("end"); static char *heap_end; char *prev_heap_end; if (heap_end == 0) heap_end = &end; prev_heap_end = heap_end; if (heap_end + incr > stack_ptr) { // write(1, "Heap and stack collision\n", 25); // abort(); errno = ENOMEM; return (caddr_t) -1; } heap_end += incr; return (caddr_t) prev_heap_end; } int _close(int file) { return -1; } int _fstat(int file, struct stat *st) { st->st_mode = S_IFCHR; return 0; } int _isatty(int file) { return 1; } int _lseek(int file, int ptr, int dir) { return 0; } int _open(char *path, int flags, ...) { /* Pretend like we always fail */ return -1; } int _wait(int *status) { errno = ECHILD; return -1; } int _unlink(char *name) { errno = ENOENT; return -1; } int _times(struct tms *buf) { return -1; } int _stat(char *file, struct stat *st) { st->st_mode = S_IFCHR; return 0; } int _link(char *old, char *new) { errno = EMLINK; return -1; } int _fork(void) { errno = EAGAIN; return -1; } int _execve(char *name, char **argv, char **env) { errno = ENOMEM; return -1; }
0
D://workCode//uploadProject\STM32CubeF1\Projects\STM3210E_EVAL\Examples\CAN\CAN_Networking
D://workCode//uploadProject\STM32CubeF1\Projects\STM3210E_EVAL\Examples\CAN\CAN_Networking\Inc\main.h
/** ****************************************************************************** * @file CAN/CAN_Networking/Inc/main.h * @author MCD Application Team * @brief Header for main.c module ****************************************************************************** * @attention * * Copyright (c) 2016 STMicroelectronics. * All rights reserved. * * This software is licensed under terms that can be found in the LICENSE file * in the root directory of this software component. * If no LICENSE file comes with this software, it is provided AS-IS. * ****************************************************************************** */ /* Define to prevent recursive inclusion -------------------------------------*/ #ifndef __MAIN_H #define __MAIN_H /* Includes ------------------------------------------------------------------*/ #include "stm32f1xx_hal.h" #include "stm3210e_eval.h" /* Exported types ------------------------------------------------------------*/ /* Exported constants --------------------------------------------------------*/ /* User can use this section to tailor CANx instance used and associated resources */ /* Definition for CANx clock resources */ #define CANx CAN1 #define CANx_CLK_ENABLE() __HAL_RCC_CAN1_CLK_ENABLE() #define CANx_GPIO_CLK_ENABLE() __HAL_RCC_GPIOB_CLK_ENABLE() #define CANx_FORCE_RESET() __HAL_RCC_CAN1_FORCE_RESET() #define CANx_RELEASE_RESET() __HAL_RCC_CAN1_RELEASE_RESET() /* Definition for CANx Pins */ #define CANx_TX_PIN GPIO_PIN_9 #define CANx_TX_GPIO_PORT GPIOB #define CANx_RX_PIN GPIO_PIN_8 #define CANx_RX_GPIO_PORT GPIOB /* Definition for CANx AFIO Remap */ #define CANx_AFIO_REMAP_CLK_ENABLE() __HAL_RCC_AFIO_CLK_ENABLE() #define CANx_AFIO_REMAP_RX_TX_PIN() __HAL_AFIO_REMAP_CAN1_2() /* Definition for CAN's NVIC */ #define CANx_RX_IRQn USB_LP_CAN1_RX0_IRQn #define CANx_RX_IRQHandler USB_LP_CAN1_RX0_IRQHandler /* Exported macro ------------------------------------------------------------*/ /* Exported functions ------------------------------------------------------- */ #endif /* __MAIN_H */
0
D://workCode//uploadProject\STM32CubeF1\Projects\STM3210E_EVAL\Examples\CAN\CAN_Networking
D://workCode//uploadProject\STM32CubeF1\Projects\STM3210E_EVAL\Examples\CAN\CAN_Networking\Inc\stm32f1xx_hal_conf.h
/** ****************************************************************************** * @file stm32f1xx_hal_conf.h * @author MCD Application Team * @brief HAL configuration file. ****************************************************************************** * @attention * * Copyright (c) 2016 STMicroelectronics. * All rights reserved. * * This software is licensed under terms that can be found in the LICENSE file * in the root directory of this software component. * If no LICENSE file comes with this software, it is provided AS-IS. * ****************************************************************************** */ /* Define to prevent recursive inclusion -------------------------------------*/ #ifndef __STM32F1xx_HAL_CONF_H #define __STM32F1xx_HAL_CONF_H #ifdef __cplusplus extern "C" { #endif /* Exported types ------------------------------------------------------------*/ /* Exported constants --------------------------------------------------------*/ /* ########################## Module Selection ############################## */ /** * @brief This is the list of modules to be used in the HAL driver */ #define HAL_MODULE_ENABLED /* #define HAL_ADC_MODULE_ENABLED */ #define HAL_CAN_MODULE_ENABLED /* #define HAL_CAN_LEGACY_MODULE_ENABLED */ /* #define HAL_CEC_MODULE_ENABLED */ #define HAL_CORTEX_MODULE_ENABLED /* #define HAL_CRC_MODULE_ENABLED */ /* #define HAL_DAC_MODULE_ENABLED */ /* #define HAL_DMA_MODULE_ENABLED */ /* #define HAL_ETH_MODULE_ENABLED */ /* #define HAL_EXTI_MODULE_ENABLED */ #define HAL_FLASH_MODULE_ENABLED #define HAL_GPIO_MODULE_ENABLED /* #define HAL_HCD_MODULE_ENABLED */ /* #define HAL_I2C_MODULE_ENABLED */ /* #define HAL_I2S_MODULE_ENABLED */ /* #define HAL_IRDA_MODULE_ENABLED */ /* #define HAL_IWDG_MODULE_ENABLED */ /* #define HAL_NAND_MODULE_ENABLED */ /* #define HAL_NOR_MODULE_ENABLED */ /* #define HAL_PCCARD_MODULE_ENABLED */ /* #define HAL_PCD_MODULE_ENABLED */ #define HAL_PWR_MODULE_ENABLED #define HAL_RCC_MODULE_ENABLED /* #define HAL_RTC_MODULE_ENABLED */ /* #define HAL_SD_MODULE_ENABLED */ /* #define HAL_SMARTCARD_MODULE_ENABLED */ /* #define HAL_SPI_MODULE_ENABLED */ /* #define HAL_SRAM_MODULE_ENABLED */ /* #define HAL_TIM_MODULE_ENABLED */ /* #define HAL_UART_MODULE_ENABLED */ /* #define HAL_USART_MODULE_ENABLED */ /* #define HAL_IRDA_MODULE_ENABLED */ /* #define HAL_SMARTCARD_MODULE_ENABLED */ /* #define HAL_WWDG_MODULE_ENABLED */ /* #define HAL_MMC_MODULE_ENABLED */ /* ########################## Oscillator Values adaptation ####################*/ /** * @brief Adjust the value of External High Speed oscillator (HSE) used in your application. * This value is used by the RCC HAL module to compute the system frequency * (when HSE is used as system clock source, directly or through the PLL). */ #if !defined (HSE_VALUE) #if defined(USE_STM3210C_EVAL) #define HSE_VALUE 25000000U /*!< Value of the External oscillator in Hz */ #else #define HSE_VALUE 8000000U /*!< Value of the External oscillator in Hz */ #endif #endif /* HSE_VALUE */ #if !defined (HSE_STARTUP_TIMEOUT) #define HSE_STARTUP_TIMEOUT 100U /*!< Time out for HSE start up, in ms */ #endif /* HSE_STARTUP_TIMEOUT */ /** * @brief Internal High Speed oscillator (HSI) value. * This value is used by the RCC HAL module to compute the system frequency * (when HSI is used as system clock source, directly or through the PLL). */ #if !defined (HSI_VALUE) #define HSI_VALUE 8000000U /*!< Value of the Internal oscillator in Hz */ #endif /* HSI_VALUE */ /** * @brief Internal Low Speed oscillator (LSI) value. */ #if !defined (LSI_VALUE) #define LSI_VALUE 40000U /*!< LSI Typical Value in Hz */ #endif /* LSI_VALUE */ /*!< Value of the Internal Low Speed oscillator in Hz The real value may vary depending on the variations in voltage and temperature. */ /** * @brief External Low Speed oscillator (LSE) value. * This value is used by the UART, RTC HAL module to compute the system frequency */ #if !defined (LSE_VALUE) #define LSE_VALUE 32768U /*!< Value of the External oscillator in Hz*/ #endif /* LSE_VALUE */ #if !defined (LSE_STARTUP_TIMEOUT) #define LSE_STARTUP_TIMEOUT 5000U /*!< Time out for LSE start up, in ms */ #endif /* LSE_STARTUP_TIMEOUT */ /* Tip: To avoid modifying this file each time you need to use different HSE, === you can define the HSE value in your toolchain compiler preprocessor. */ /* ########################### System Configuration ######################### */ /** * @brief This is the HAL system configuration section */ #define VDD_VALUE 3300U /*!< Value of VDD in mv */ #define TICK_INT_PRIORITY 0x0FU /*!< tick interrupt priority */ #define USE_RTOS 0U #define PREFETCH_ENABLE 1U #define USE_HAL_ADC_REGISTER_CALLBACKS 0U /* ADC register callback disabled */ #define USE_HAL_CAN_REGISTER_CALLBACKS 0U /* CAN register callback disabled */ #define USE_HAL_CEC_REGISTER_CALLBACKS 0U /* CEC register callback disabled */ #define USE_HAL_DAC_REGISTER_CALLBACKS 0U /* DAC register callback disabled */ #define USE_HAL_ETH_REGISTER_CALLBACKS 0U /* ETH register callback disabled */ #define USE_HAL_HCD_REGISTER_CALLBACKS 0U /* HCD register callback disabled */ #define USE_HAL_I2C_REGISTER_CALLBACKS 0U /* I2C register callback disabled */ #define USE_HAL_I2S_REGISTER_CALLBACKS 0U /* I2S register callback disabled */ #define USE_HAL_MMC_REGISTER_CALLBACKS 0U /* MMC register callback disabled */ #define USE_HAL_NAND_REGISTER_CALLBACKS 0U /* NAND register callback disabled */ #define USE_HAL_NOR_REGISTER_CALLBACKS 0U /* NOR register callback disabled */ #define USE_HAL_PCCARD_REGISTER_CALLBACKS 0U /* PCCARD register callback disabled */ #define USE_HAL_PCD_REGISTER_CALLBACKS 0U /* PCD register callback disabled */ #define USE_HAL_RTC_REGISTER_CALLBACKS 0U /* RTC register callback disabled */ #define USE_HAL_SD_REGISTER_CALLBACKS 0U /* SD register callback disabled */ #define USE_HAL_SMARTCARD_REGISTER_CALLBACKS 0U /* SMARTCARD register callback disabled */ #define USE_HAL_IRDA_REGISTER_CALLBACKS 0U /* IRDA register callback disabled */ #define USE_HAL_SRAM_REGISTER_CALLBACKS 0U /* SRAM register callback disabled */ #define USE_HAL_SPI_REGISTER_CALLBACKS 0U /* SPI register callback disabled */ #define USE_HAL_TIM_REGISTER_CALLBACKS 0U /* TIM register callback disabled */ #define USE_HAL_UART_REGISTER_CALLBACKS 0U /* UART register callback disabled */ #define USE_HAL_USART_REGISTER_CALLBACKS 0U /* USART register callback disabled */ #define USE_HAL_WWDG_REGISTER_CALLBACKS 0U /* WWDG register callback disabled */ /* ########################## Assert Selection ############################## */ /** * @brief Uncomment the line below to expanse the "assert_param" macro in the * HAL drivers code */ /* #define USE_FULL_ASSERT 1U */ /* ################## Ethernet peripheral configuration ##################### */ /* Section 1 : Ethernet peripheral configuration */ /* MAC ADDRESS: MAC_ADDR0:MAC_ADDR1:MAC_ADDR2:MAC_ADDR3:MAC_ADDR4:MAC_ADDR5 */ #define MAC_ADDR0 2U #define MAC_ADDR1 0U #define MAC_ADDR2 0U #define MAC_ADDR3 0U #define MAC_ADDR4 0U #define MAC_ADDR5 0U /* Definition of the Ethernet driver buffers size and count */ #define ETH_RX_BUF_SIZE ETH_MAX_PACKET_SIZE /* buffer size for receive */ #define ETH_TX_BUF_SIZE ETH_MAX_PACKET_SIZE /* buffer size for transmit */ #define ETH_RXBUFNB 8U /* 8 Rx buffers of size ETH_RX_BUF_SIZE */ #define ETH_TXBUFNB 4U /* 4 Tx buffers of size ETH_TX_BUF_SIZE */ /* Section 2: PHY configuration section */ /* DP83848 PHY Address*/ #define DP83848_PHY_ADDRESS 0x01U /* PHY Reset delay these values are based on a 1 ms Systick interrupt*/ #define PHY_RESET_DELAY 0x000000FFU /* PHY Configuration delay */ #define PHY_CONFIG_DELAY 0x00000FFFU #define PHY_READ_TO 0x0000FFFFU #define PHY_WRITE_TO 0x0000FFFFU /* Section 3: Common PHY Registers */ #define PHY_BCR ((uint16_t)0x0000) /*!< Transceiver Basic Control Register */ #define PHY_BSR ((uint16_t)0x0001) /*!< Transceiver Basic Status Register */ #define PHY_RESET ((uint16_t)0x8000) /*!< PHY Reset */ #define PHY_LOOPBACK ((uint16_t)0x4000) /*!< Select loop-back mode */ #define PHY_FULLDUPLEX_100M ((uint16_t)0x2100) /*!< Set the full-duplex mode at 100 Mb/s */ #define PHY_HALFDUPLEX_100M ((uint16_t)0x2000) /*!< Set the half-duplex mode at 100 Mb/s */ #define PHY_FULLDUPLEX_10M ((uint16_t)0x0100) /*!< Set the full-duplex mode at 10 Mb/s */ #define PHY_HALFDUPLEX_10M ((uint16_t)0x0000) /*!< Set the half-duplex mode at 10 Mb/s */ #define PHY_AUTONEGOTIATION ((uint16_t)0x1000) /*!< Enable auto-negotiation function */ #define PHY_RESTART_AUTONEGOTIATION ((uint16_t)0x0200) /*!< Restart auto-negotiation function */ #define PHY_POWERDOWN ((uint16_t)0x0800) /*!< Select the power down mode */ #define PHY_ISOLATE ((uint16_t)0x0400) /*!< Isolate PHY from MII */ #define PHY_AUTONEGO_COMPLETE ((uint16_t)0x0020) /*!< Auto-Negotiation process completed */ #define PHY_LINKED_STATUS ((uint16_t)0x0004) /*!< Valid link established */ #define PHY_JABBER_DETECTION ((uint16_t)0x0002) /*!< Jabber condition detected */ /* Section 4: Extended PHY Registers */ #define PHY_SR ((uint16_t)0x0010) /*!< PHY status register Offset */ #define PHY_MICR ((uint16_t)0x0011) /*!< MII Interrupt Control Register */ #define PHY_MISR ((uint16_t)0x0012) /*!< MII Interrupt Status and Misc. Control Register */ #define PHY_LINK_STATUS ((uint16_t)0x0001) /*!< PHY Link mask */ #define PHY_SPEED_STATUS ((uint16_t)0x0002) /*!< PHY Speed mask */ #define PHY_DUPLEX_STATUS ((uint16_t)0x0004) /*!< PHY Duplex mask */ #define PHY_MICR_INT_EN ((uint16_t)0x0002) /*!< PHY Enable interrupts */ #define PHY_MICR_INT_OE ((uint16_t)0x0001) /*!< PHY Enable output interrupt events */ #define PHY_MISR_LINK_INT_EN ((uint16_t)0x0020) /*!< Enable Interrupt on change of link status */ #define PHY_LINK_INTERRUPT ((uint16_t)0x2000) /*!< PHY link status interrupt mask */ /* ################## SPI peripheral configuration ########################## */ /* CRC FEATURE: Use to activate CRC feature inside HAL SPI Driver * Activated: CRC code is present inside driver * Deactivated: CRC code cleaned from driver */ #define USE_SPI_CRC 1U /* Includes ------------------------------------------------------------------*/ /** * @brief Include module's header file */ #ifdef HAL_RCC_MODULE_ENABLED #include "stm32f1xx_hal_rcc.h" #endif /* HAL_RCC_MODULE_ENABLED */ #ifdef HAL_GPIO_MODULE_ENABLED #include "stm32f1xx_hal_gpio.h" #endif /* HAL_GPIO_MODULE_ENABLED */ #ifdef HAL_EXTI_MODULE_ENABLED #include "stm32f1xx_hal_exti.h" #endif /* HAL_EXTI_MODULE_ENABLED */ #ifdef HAL_DMA_MODULE_ENABLED #include "stm32f1xx_hal_dma.h" #endif /* HAL_DMA_MODULE_ENABLED */ #ifdef HAL_ETH_MODULE_ENABLED #include "stm32f1xx_hal_eth.h" #endif /* HAL_ETH_MODULE_ENABLED */ #ifdef HAL_CAN_MODULE_ENABLED #include "stm32f1xx_hal_can.h" #endif /* HAL_CAN_MODULE_ENABLED */ #ifdef HAL_CAN_LEGACY_MODULE_ENABLED #include "Legacy/stm32f1xx_hal_can_legacy.h" #endif /* HAL_CAN_LEGACY_MODULE_ENABLED */ #ifdef HAL_CEC_MODULE_ENABLED #include "stm32f1xx_hal_cec.h" #endif /* HAL_CEC_MODULE_ENABLED */ #ifdef HAL_CORTEX_MODULE_ENABLED #include "stm32f1xx_hal_cortex.h" #endif /* HAL_CORTEX_MODULE_ENABLED */ #ifdef HAL_ADC_MODULE_ENABLED #include "stm32f1xx_hal_adc.h" #endif /* HAL_ADC_MODULE_ENABLED */ #ifdef HAL_CRC_MODULE_ENABLED #include "stm32f1xx_hal_crc.h" #endif /* HAL_CRC_MODULE_ENABLED */ #ifdef HAL_DAC_MODULE_ENABLED #include "stm32f1xx_hal_dac.h" #endif /* HAL_DAC_MODULE_ENABLED */ #ifdef HAL_FLASH_MODULE_ENABLED #include "stm32f1xx_hal_flash.h" #endif /* HAL_FLASH_MODULE_ENABLED */ #ifdef HAL_SRAM_MODULE_ENABLED #include "stm32f1xx_hal_sram.h" #endif /* HAL_SRAM_MODULE_ENABLED */ #ifdef HAL_NOR_MODULE_ENABLED #include "stm32f1xx_hal_nor.h" #endif /* HAL_NOR_MODULE_ENABLED */ #ifdef HAL_I2C_MODULE_ENABLED #include "stm32f1xx_hal_i2c.h" #endif /* HAL_I2C_MODULE_ENABLED */ #ifdef HAL_I2S_MODULE_ENABLED #include "stm32f1xx_hal_i2s.h" #endif /* HAL_I2S_MODULE_ENABLED */ #ifdef HAL_IWDG_MODULE_ENABLED #include "stm32f1xx_hal_iwdg.h" #endif /* HAL_IWDG_MODULE_ENABLED */ #ifdef HAL_PWR_MODULE_ENABLED #include "stm32f1xx_hal_pwr.h" #endif /* HAL_PWR_MODULE_ENABLED */ #ifdef HAL_RTC_MODULE_ENABLED #include "stm32f1xx_hal_rtc.h" #endif /* HAL_RTC_MODULE_ENABLED */ #ifdef HAL_PCCARD_MODULE_ENABLED #include "stm32f1xx_hal_pccard.h" #endif /* HAL_PCCARD_MODULE_ENABLED */ #ifdef HAL_SD_MODULE_ENABLED #include "stm32f1xx_hal_sd.h" #endif /* HAL_SD_MODULE_ENABLED */ #ifdef HAL_NAND_MODULE_ENABLED #include "stm32f1xx_hal_nand.h" #endif /* HAL_NAND_MODULE_ENABLED */ #ifdef HAL_SPI_MODULE_ENABLED #include "stm32f1xx_hal_spi.h" #endif /* HAL_SPI_MODULE_ENABLED */ #ifdef HAL_TIM_MODULE_ENABLED #include "stm32f1xx_hal_tim.h" #endif /* HAL_TIM_MODULE_ENABLED */ #ifdef HAL_UART_MODULE_ENABLED #include "stm32f1xx_hal_uart.h" #endif /* HAL_UART_MODULE_ENABLED */ #ifdef HAL_USART_MODULE_ENABLED #include "stm32f1xx_hal_usart.h" #endif /* HAL_USART_MODULE_ENABLED */ #ifdef HAL_IRDA_MODULE_ENABLED #include "stm32f1xx_hal_irda.h" #endif /* HAL_IRDA_MODULE_ENABLED */ #ifdef HAL_SMARTCARD_MODULE_ENABLED #include "stm32f1xx_hal_smartcard.h" #endif /* HAL_SMARTCARD_MODULE_ENABLED */ #ifdef HAL_WWDG_MODULE_ENABLED #include "stm32f1xx_hal_wwdg.h" #endif /* HAL_WWDG_MODULE_ENABLED */ #ifdef HAL_PCD_MODULE_ENABLED #include "stm32f1xx_hal_pcd.h" #endif /* HAL_PCD_MODULE_ENABLED */ #ifdef HAL_HCD_MODULE_ENABLED #include "stm32f1xx_hal_hcd.h" #endif /* HAL_HCD_MODULE_ENABLED */ #ifdef HAL_MMC_MODULE_ENABLED #include "stm32f1xx_hal_mmc.h" #endif /* HAL_MMC_MODULE_ENABLED */ /* Exported macro ------------------------------------------------------------*/ #ifdef USE_FULL_ASSERT /** * @brief The assert_param macro is used for function's parameters check. * @param expr: If expr is false, it calls assert_failed function * which reports the name of the source file and the source * line number of the call that failed. * If expr is true, it returns no value. * @retval None */ #define assert_param(expr) ((expr) ? (void)0U : assert_failed((uint8_t *)__FILE__, __LINE__)) /* Exported functions ------------------------------------------------------- */ void assert_failed(uint8_t* file, uint32_t line); #else #define assert_param(expr) ((void)0U) #endif /* USE_FULL_ASSERT */ #ifdef __cplusplus } #endif #endif /* __STM32F1xx_HAL_CONF_H */
0
D://workCode//uploadProject\STM32CubeF1\Projects\STM3210E_EVAL\Examples\CAN\CAN_Networking
D://workCode//uploadProject\STM32CubeF1\Projects\STM3210E_EVAL\Examples\CAN\CAN_Networking\Inc\stm32f1xx_it.h
/** ****************************************************************************** * @file CAN/CAN_Networking/Inc/stm32f1xx_it.h * @author MCD Application Team * @brief This file contains the headers of the interrupt handlers. ****************************************************************************** * @attention * * Copyright (c) 2016 STMicroelectronics. * All rights reserved. * * This software is licensed under terms that can be found in the LICENSE file * in the root directory of this software component. * If no LICENSE file comes with this software, it is provided AS-IS. * ****************************************************************************** */ /* Define to prevent recursive inclusion -------------------------------------*/ #ifndef __STM32F1xx_IT_H #define __STM32F1xx_IT_H #ifdef __cplusplus extern "C" { #endif /* Includes ------------------------------------------------------------------*/ /* Exported types ------------------------------------------------------------*/ /* Exported constants --------------------------------------------------------*/ /* Exported macro ------------------------------------------------------------*/ /* Exported functions ------------------------------------------------------- */ void NMI_Handler(void); void HardFault_Handler(void); void MemManage_Handler(void); void BusFault_Handler(void); void UsageFault_Handler(void); void SVC_Handler(void); void DebugMon_Handler(void); void PendSV_Handler(void); void SysTick_Handler(void); void CANx_RX_IRQHandler(void); #ifdef __cplusplus } #endif #endif /* __STM32F1xx_IT_H */
0
D://workCode//uploadProject\STM32CubeF1\Projects\STM3210E_EVAL\Examples\CAN\CAN_Networking
D://workCode//uploadProject\STM32CubeF1\Projects\STM3210E_EVAL\Examples\CAN\CAN_Networking\Src\main.c
/** ****************************************************************************** * @file CAN/CAN_Networking/Src/main.c * @author MCD Application Team * @brief This example shows how to configure the CAN peripheral * to send and receive CAN frames in normal mode. The sent frames * are used to control Leds by pressing KEY Push Button. ****************************************************************************** * @attention * * Copyright (c) 2016 STMicroelectronics. * All rights reserved. * * This software is licensed under terms that can be found in the LICENSE file * in the root directory of this software component. * If no LICENSE file comes with this software, it is provided AS-IS. * ****************************************************************************** */ /* Includes ------------------------------------------------------------------*/ #include "main.h" /** @addtogroup STM32F1xx_HAL_Examples * @{ */ /** @addtogroup CAN_Networking * @{ */ /* Private typedef -----------------------------------------------------------*/ /* Private define ------------------------------------------------------------*/ #define KEY_PRESSED 0x00 #define KEY_NOT_PRESSED 0x01 /* Private macro -------------------------------------------------------------*/ /* Private variables ---------------------------------------------------------*/ uint8_t ubKeyNumber = 0x0; CAN_HandleTypeDef CanHandle; CAN_TxHeaderTypeDef TxHeader; CAN_RxHeaderTypeDef RxHeader; uint8_t TxData[8]; uint8_t RxData[8]; uint32_t TxMailbox; /* Private function prototypes -----------------------------------------------*/ static void SystemClock_Config(void); static void Error_Handler(void); static void CAN_Config(void); static void LED_Display(uint8_t LedStatus); /* Private functions ---------------------------------------------------------*/ /** * @brief Main program. * @param None * @retval None */ int main(void) { /* STM32F103xG HAL library initialization: - Configure the Flash prefetch - Systick timer is configured by default as source of time base, but user can eventually implement his proper time base source (a general purpose timer for example or other time source), keeping in mind that Time base duration should be kept 1ms since PPP_TIMEOUT_VALUEs are defined and handled in milliseconds basis. - Set NVIC Group Priority to 4 - Low Level Initialization */ HAL_Init(); /* Configure the system clock to 72 MHz */ SystemClock_Config(); /* Configure LED1, LED2, LED3 and LED4 */ BSP_LED_Init(LED1); BSP_LED_Init(LED2); BSP_LED_Init(LED3); BSP_LED_Init(LED4); /* Configure KEY Push Button */ BSP_PB_Init(BUTTON_KEY, BUTTON_MODE_GPIO); /* Configure the CAN peripheral */ CAN_Config(); /* Infinite loop */ while (1) { while (BSP_PB_GetState(BUTTON_KEY) == KEY_PRESSED) { if (ubKeyNumber == 0x4) { ubKeyNumber = 0x00; } else { LED_Display(++ubKeyNumber); /* Set the data to be transmitted */ TxData[0] = ubKeyNumber; TxData[1] = 0xAD; /* Start the Transmission process */ if (HAL_CAN_AddTxMessage(&CanHandle, &TxHeader, TxData, &TxMailbox) != HAL_OK) { /* Transmission request Error */ Error_Handler(); } HAL_Delay(10); while (BSP_PB_GetState(BUTTON_KEY) != KEY_NOT_PRESSED) { } } } } } /** * @brief System Clock Configuration * The system Clock is configured as follow : * System Clock source = PLL (HSE) * SYSCLK(Hz) = 72000000 * HCLK(Hz) = 72000000 * AHB Prescaler = 1 * APB1 Prescaler = 2 * APB2 Prescaler = 1 * HSE Frequency(Hz) = 8000000 * HSE PREDIV1 = 1 * PLLMUL = 9 * Flash Latency(WS) = 2 * @param None * @retval None */ static void SystemClock_Config(void) { RCC_ClkInitTypeDef clkinitstruct = {0}; RCC_OscInitTypeDef oscinitstruct = {0}; /* Enable HSE Oscillator and activate PLL with HSE as source */ oscinitstruct.OscillatorType = RCC_OSCILLATORTYPE_HSE; oscinitstruct.HSEState = RCC_HSE_ON; oscinitstruct.HSEPredivValue = RCC_HSE_PREDIV_DIV1; oscinitstruct.PLL.PLLState = RCC_PLL_ON; oscinitstruct.PLL.PLLSource = RCC_PLLSOURCE_HSE; oscinitstruct.PLL.PLLMUL = RCC_PLL_MUL9; if (HAL_RCC_OscConfig(&oscinitstruct)!= HAL_OK) { /* Initialization Error */ while(1); } /* Select PLL as system clock source and configure the HCLK, PCLK1 and PCLK2 clocks dividers */ clkinitstruct.ClockType = (RCC_CLOCKTYPE_SYSCLK | RCC_CLOCKTYPE_HCLK | RCC_CLOCKTYPE_PCLK1 | RCC_CLOCKTYPE_PCLK2); clkinitstruct.SYSCLKSource = RCC_SYSCLKSOURCE_PLLCLK; clkinitstruct.AHBCLKDivider = RCC_SYSCLK_DIV1; clkinitstruct.APB2CLKDivider = RCC_HCLK_DIV1; clkinitstruct.APB1CLKDivider = RCC_HCLK_DIV2; if (HAL_RCC_ClockConfig(&clkinitstruct, FLASH_LATENCY_2)!= HAL_OK) { /* Initialization Error */ while(1); } } /** * @brief This function is executed in case of error occurrence. * @param None * @retval None */ static void Error_Handler(void) { while (1) { } } /** * @brief Configures the CAN. * @param None * @retval None */ static void CAN_Config(void) { CAN_FilterTypeDef sFilterConfig; /* Configure the CAN peripheral */ CanHandle.Instance = CANx; CanHandle.Init.TimeTriggeredMode = DISABLE; CanHandle.Init.AutoBusOff = DISABLE; CanHandle.Init.AutoWakeUp = DISABLE; CanHandle.Init.AutoRetransmission = ENABLE; CanHandle.Init.ReceiveFifoLocked = DISABLE; CanHandle.Init.TransmitFifoPriority = DISABLE; CanHandle.Init.Mode = CAN_MODE_NORMAL; CanHandle.Init.SyncJumpWidth = CAN_SJW_1TQ; CanHandle.Init.TimeSeg1 = CAN_BS1_6TQ; CanHandle.Init.TimeSeg2 = CAN_BS2_2TQ; CanHandle.Init.Prescaler = 4; if (HAL_CAN_Init(&CanHandle) != HAL_OK) { /* Initialization Error */ Error_Handler(); } /* Configure the CAN Filter */ sFilterConfig.FilterBank = 0; sFilterConfig.FilterMode = CAN_FILTERMODE_IDMASK; sFilterConfig.FilterScale = CAN_FILTERSCALE_32BIT; sFilterConfig.FilterIdHigh = 0x0000; sFilterConfig.FilterIdLow = 0x0000; sFilterConfig.FilterMaskIdHigh = 0x0000; sFilterConfig.FilterMaskIdLow = 0x0000; sFilterConfig.FilterFIFOAssignment = CAN_RX_FIFO0; sFilterConfig.FilterActivation = ENABLE; sFilterConfig.SlaveStartFilterBank = 14; if (HAL_CAN_ConfigFilter(&CanHandle, &sFilterConfig) != HAL_OK) { /* Filter configuration Error */ Error_Handler(); } /* Start the CAN peripheral */ if (HAL_CAN_Start(&CanHandle) != HAL_OK) { /* Start Error */ Error_Handler(); } /* Activate CAN RX notification */ if (HAL_CAN_ActivateNotification(&CanHandle, CAN_IT_RX_FIFO0_MSG_PENDING) != HAL_OK) { /* Notification Error */ Error_Handler(); } /* Configure Transmission process */ TxHeader.StdId = 0x321; TxHeader.ExtId = 0x01; TxHeader.RTR = CAN_RTR_DATA; TxHeader.IDE = CAN_ID_STD; TxHeader.DLC = 2; TxHeader.TransmitGlobalTime = DISABLE; } /** * @brief Rx Fifo 0 message pending callback in non blocking mode * @param CanHandle: pointer to a CAN_HandleTypeDef structure that contains * the configuration information for the specified CAN. * @retval None */ void HAL_CAN_RxFifo0MsgPendingCallback(CAN_HandleTypeDef *CanHandle) { /* Get RX message */ if (HAL_CAN_GetRxMessage(CanHandle, CAN_RX_FIFO0, &RxHeader, RxData) != HAL_OK) { /* Reception Error */ Error_Handler(); } /* Display LEDx */ if ((RxHeader.StdId == 0x321) && (RxHeader.IDE == CAN_ID_STD) && (RxHeader.DLC == 2)) { LED_Display(RxData[0]); ubKeyNumber = RxData[0]; } } /** * @brief Turns ON/OFF the dedicated LED. * @param LedStatus: LED number from 0 to 3 * @retval None */ static void LED_Display(uint8_t LedStatus) { /* Turn OFF all LEDs */ BSP_LED_Off(LED1); BSP_LED_Off(LED2); BSP_LED_Off(LED3); BSP_LED_Off(LED4); switch(LedStatus) { case (1): /* Turn ON LED1 */ BSP_LED_On(LED1); break; case (2): /* Turn ON LED2 */ BSP_LED_On(LED2); break; case (3): /* Turn ON LED3 */ BSP_LED_On(LED3); break; case (4): /* Turn ON LED4 */ BSP_LED_On(LED4); break; default: break; } } #ifdef USE_FULL_ASSERT /** * @brief Reports the name of the source file and the source line number * where the assert_param error has occurred. * @param file: pointer to the source file name * @param line: assert_param error line source number * @retval None */ void assert_failed(uint8_t *file, uint32_t line) { /* User can add his own implementation to report the file name and line number, ex: printf("Wrong parameters value: file %s on line %d\r\n", file, line) */ /* Infinite loop */ while (1) { } } #endif /** * @} */ /** * @} */
0
D://workCode//uploadProject\STM32CubeF1\Projects\STM3210E_EVAL\Examples\CAN\CAN_Networking
D://workCode//uploadProject\STM32CubeF1\Projects\STM3210E_EVAL\Examples\CAN\CAN_Networking\Src\stm32f1xx_hal_msp.c
/** ****************************************************************************** * @file CAN/CAN_Networking/Src/stm32f1xx_hal_msp.c * @author MCD Application Team * @brief HAL MSP module. ****************************************************************************** * @attention * * Copyright (c) 2016 STMicroelectronics. * All rights reserved. * * This software is licensed under terms that can be found in the LICENSE file * in the root directory of this software component. * If no LICENSE file comes with this software, it is provided AS-IS. * ****************************************************************************** */ /* Includes ------------------------------------------------------------------*/ #include "main.h" /** @addtogroup STM32F1xx_HAL_Examples * @{ */ /** @defgroup CAN_Networking * @{ */ /* Private typedef -----------------------------------------------------------*/ /* Private define ------------------------------------------------------------*/ /* Private macro -------------------------------------------------------------*/ /* Private variables ---------------------------------------------------------*/ /* Private function prototypes -----------------------------------------------*/ /* Private functions ---------------------------------------------------------*/ /** @defgroup HAL_MSP_Private_Functions * @{ */ /** * @brief CAN MSP Initialization * This function configures the hardware resources used in this example: * - Peripheral's clock enable * - Peripheral's GPIO Configuration * - NVIC configuration for DMA interrupt request enable * @param hcan: CAN handle pointer * @retval None */ void HAL_CAN_MspInit(CAN_HandleTypeDef *hcan) { GPIO_InitTypeDef GPIO_InitStruct; /*##-1- Enable peripherals and GPIO Clocks #################################*/ /* CAN1 Periph clock enable */ CANx_CLK_ENABLE(); /* Enable GPIO clock ****************************************/ CANx_GPIO_CLK_ENABLE(); /* Enable AFIO clock and Remap CAN PINs to PB8 and PB9*******/ CANx_AFIO_REMAP_CLK_ENABLE(); CANx_AFIO_REMAP_RX_TX_PIN(); /*##-2- Configure peripheral GPIO ##########################################*/ /* CAN1 TX GPIO pin configuration */ GPIO_InitStruct.Pin = CANx_TX_PIN; GPIO_InitStruct.Mode = GPIO_MODE_AF_PP; GPIO_InitStruct.Speed = GPIO_SPEED_FREQ_HIGH; GPIO_InitStruct.Pull = GPIO_PULLUP; HAL_GPIO_Init(CANx_TX_GPIO_PORT, &GPIO_InitStruct); /* CAN1 RX GPIO pin configuration */ GPIO_InitStruct.Pin = CANx_RX_PIN; GPIO_InitStruct.Mode = GPIO_MODE_INPUT; GPIO_InitStruct.Speed = GPIO_SPEED_FREQ_HIGH; GPIO_InitStruct.Pull = GPIO_PULLUP; HAL_GPIO_Init(CANx_RX_GPIO_PORT, &GPIO_InitStruct); /*##-3- Configure the NVIC #################################################*/ /* NVIC configuration for CAN1 Reception complete interrupt */ HAL_NVIC_SetPriority(CANx_RX_IRQn, 1, 0); HAL_NVIC_EnableIRQ(CANx_RX_IRQn); } /** * @brief CAN MSP De-Initialization * This function frees the hardware resources used in this example: * - Disable the Peripheral's clock * - Revert GPIO to their default state * @param hcan: CAN handle pointer * @retval None */ void HAL_CAN_MspDeInit(CAN_HandleTypeDef *hcan) { /*##-1- Reset peripherals ##################################################*/ CANx_FORCE_RESET(); CANx_RELEASE_RESET(); /*##-2- Disable peripherals and GPIO Clocks ################################*/ /* De-initialize the CAN1 TX GPIO pin */ HAL_GPIO_DeInit(CANx_TX_GPIO_PORT, CANx_TX_PIN); /* De-initialize the CAN1 RX GPIO pin */ HAL_GPIO_DeInit(CANx_RX_GPIO_PORT, CANx_RX_PIN); /*##-4- Disable the NVIC for CAN reception #################################*/ HAL_NVIC_DisableIRQ(CANx_RX_IRQn); } /** * @} */ /** * @} */ /** * @} */
0
D://workCode//uploadProject\STM32CubeF1\Projects\STM3210E_EVAL\Examples\CAN\CAN_Networking
D://workCode//uploadProject\STM32CubeF1\Projects\STM3210E_EVAL\Examples\CAN\CAN_Networking\Src\stm32f1xx_it.c
/** ****************************************************************************** * @file CAN/CAN_Networking/Src/stm32f1xx_it.c * @author MCD Application Team * @brief Main Interrupt Service Routines. * This file provides template for all exceptions handler and * peripherals interrupt service routine. ****************************************************************************** * @attention * * Copyright (c) 2016 STMicroelectronics. * All rights reserved. * * This software is licensed under terms that can be found in the LICENSE file * in the root directory of this software component. * If no LICENSE file comes with this software, it is provided AS-IS. * ****************************************************************************** */ /* Includes ------------------------------------------------------------------*/ #include "main.h" #include "stm32f1xx_it.h" /** @addtogroup STM32F1xx_HAL_Examples * @{ */ /** @addtogroup CAN_Networking * @{ */ /* Private typedef -----------------------------------------------------------*/ /* Private define ------------------------------------------------------------*/ /* Private macro -------------------------------------------------------------*/ /* Private variables ---------------------------------------------------------*/ extern CAN_HandleTypeDef CanHandle; /* Private function prototypes -----------------------------------------------*/ /* Private functions ---------------------------------------------------------*/ /******************************************************************************/ /* Cortex-M3 Processor Exceptions Handlers */ /******************************************************************************/ /** * @brief This function handles NMI exception. * @param None * @retval None */ void NMI_Handler(void) { } /** * @brief This function handles Hard Fault exception. * @param None * @retval None */ void HardFault_Handler(void) { /* Go to infinite loop when Hard Fault exception occurs */ while (1) { } } /** * @brief This function handles Memory Manage exception. * @param None * @retval None */ void MemManage_Handler(void) { /* Go to infinite loop when Memory Manage exception occurs */ while (1) { } } /** * @brief This function handles Bus Fault exception. * @param None * @retval None */ void BusFault_Handler(void) { /* Go to infinite loop when Bus Fault exception occurs */ while (1) { } } /** * @brief This function handles Usage Fault exception. * @param None * @retval None */ void UsageFault_Handler(void) { /* Go to infinite loop when Usage Fault exception occurs */ while (1) { } } /** * @brief This function handles SVCall exception. * @param None * @retval None */ void SVC_Handler(void) { } /** * @brief This function handles Debug Monitor exception. * @param None * @retval None */ void DebugMon_Handler(void) { } /** * @brief This function handles PendSVC exception. * @param None * @retval None */ void PendSV_Handler(void) { } /** * @brief This function handles SysTick Handler. * @param None * @retval None */ void SysTick_Handler(void) { HAL_IncTick(); } /******************************************************************************/ /* STM32F1xx Peripherals Interrupt Handlers */ /* Add here the Interrupt Handler for the used peripheral(s) (PPP), for the */ /* available peripheral interrupt handler's name please refer to the startup */ /* file (startup_stm32f1xx.s). */ /******************************************************************************/ /** * @brief This function handles CAN1 RX0 interrupt request. * @param None * @retval None */ void CANx_RX_IRQHandler(void) { HAL_CAN_IRQHandler(&CanHandle); } /** * @} */
0
D://workCode//uploadProject\STM32CubeF1\Projects\STM3210E_EVAL\Examples\CAN\CAN_Networking
D://workCode//uploadProject\STM32CubeF1\Projects\STM3210E_EVAL\Examples\CAN\CAN_Networking\Src\system_stm32f1xx.c
/** ****************************************************************************** * @file system_stm32f1xx.c * @author MCD Application Team * @brief CMSIS Cortex-M3 Device Peripheral Access Layer System Source File. * * 1. This file provides two functions and one global variable to be called from * user application: * - SystemInit(): Setups the system clock (System clock source, PLL Multiplier * factors, AHB/APBx prescalers and Flash settings). * This function is called at startup just after reset and * before branch to main program. This call is made inside * the "startup_stm32f1xx_xx.s" file. * * - SystemCoreClock variable: Contains the core clock (HCLK), it can be used * by the user application to setup the SysTick * timer or configure other parameters. * * - SystemCoreClockUpdate(): Updates the variable SystemCoreClock and must * be called whenever the core clock is changed * during program execution. * * 2. After each device reset the HSI (8 MHz) is used as system clock source. * Then SystemInit() function is called, in "startup_stm32f1xx_xx.s" file, to * configure the system clock before to branch to main program. * * 4. The default value of HSE crystal is set to 8 MHz (or 25 MHz, depending on * the product used), refer to "HSE_VALUE". * When HSE is used as system clock source, directly or through PLL, and you * are using different crystal you have to adapt the HSE value to your own * configuration. * ****************************************************************************** * @attention * * Copyright (c) 2016 STMicroelectronics. * All rights reserved. * * This software is licensed under terms that can be found in the LICENSE file * in the root directory of this software component. * If no LICENSE file comes with this software, it is provided AS-IS. * ****************************************************************************** */ /** @addtogroup CMSIS * @{ */ /** @addtogroup stm32f1xx_system * @{ */ /** @addtogroup STM32F1xx_System_Private_Includes * @{ */ #include "stm32f1xx.h" /** * @} */ /** @addtogroup STM32F1xx_System_Private_TypesDefinitions * @{ */ /** * @} */ /** @addtogroup STM32F1xx_System_Private_Defines * @{ */ #if !defined (HSE_VALUE) #define HSE_VALUE ((uint32_t)8000000) /*!< Default value of the External oscillator in Hz. This value can be provided and adapted by the user application. */ #endif /* HSE_VALUE */ #if !defined (HSI_VALUE) #define HSI_VALUE ((uint32_t)8000000) /*!< Default value of the Internal oscillator in Hz. This value can be provided and adapted by the user application. */ #endif /* HSI_VALUE */ /*!< Uncomment the following line if you need to use external SRAM */ #if defined(STM32F100xE) || defined(STM32F101xE) || defined(STM32F101xG) || defined(STM32F103xE) || defined(STM32F103xG) /* #define DATA_IN_ExtSRAM */ #endif /* STM32F100xE || STM32F101xE || STM32F101xG || STM32F103xE || STM32F103xG */ /*!< Uncomment the following line if you need to relocate your vector Table in Internal SRAM. */ /* #define VECT_TAB_SRAM */ #define VECT_TAB_OFFSET 0x0 /*!< Vector Table base offset field. This value must be a multiple of 0x200. */ /** * @} */ /** @addtogroup STM32F1xx_System_Private_Macros * @{ */ /** * @} */ /** @addtogroup STM32F1xx_System_Private_Variables * @{ */ /* This variable is updated in three ways: 1) by calling CMSIS function SystemCoreClockUpdate() 2) by calling HAL API function HAL_RCC_GetHCLKFreq() 3) each time HAL_RCC_ClockConfig() is called to configure the system clock frequency Note: If you use this function to configure the system clock; then there is no need to call the 2 first functions listed above, since SystemCoreClock variable is updated automatically. */ uint32_t SystemCoreClock = 16000000; const uint8_t AHBPrescTable[16] = {0, 0, 0, 0, 0, 0, 0, 0, 1, 2, 3, 4, 6, 7, 8, 9}; const uint8_t APBPrescTable[8] = {0, 0, 0, 0, 1, 2, 3, 4}; /** * @} */ /** @addtogroup STM32F1xx_System_Private_FunctionPrototypes * @{ */ #if defined(STM32F100xE) || defined(STM32F101xE) || defined(STM32F101xG) || defined(STM32F103xE) || defined(STM32F103xG) #ifdef DATA_IN_ExtSRAM static void SystemInit_ExtMemCtl(void); #endif /* DATA_IN_ExtSRAM */ #endif /* STM32F100xE || STM32F101xE || STM32F101xG || STM32F103xE || STM32F103xG */ /** * @} */ /** @addtogroup STM32F1xx_System_Private_Functions * @{ */ /** * @brief Setup the microcontroller system * Initialize the Embedded Flash Interface, the PLL and update the * SystemCoreClock variable. * @note This function should be used only after reset. * @param None * @retval None */ void SystemInit (void) { /* Reset the RCC clock configuration to the default reset state(for debug purpose) */ /* Set HSION bit */ RCC->CR |= (uint32_t)0x00000001; /* Reset SW, HPRE, PPRE1, PPRE2, ADCPRE and MCO bits */ #if !defined(STM32F105xC) && !defined(STM32F107xC) RCC->CFGR &= (uint32_t)0xF8FF0000; #else RCC->CFGR &= (uint32_t)0xF0FF0000; #endif /* STM32F105xC */ /* Reset HSEON, CSSON and PLLON bits */ RCC->CR &= (uint32_t)0xFEF6FFFF; /* Reset HSEBYP bit */ RCC->CR &= (uint32_t)0xFFFBFFFF; /* Reset PLLSRC, PLLXTPRE, PLLMUL and USBPRE/OTGFSPRE bits */ RCC->CFGR &= (uint32_t)0xFF80FFFF; #if defined(STM32F105xC) || defined(STM32F107xC) /* Reset PLL2ON and PLL3ON bits */ RCC->CR &= (uint32_t)0xEBFFFFFF; /* Disable all interrupts and clear pending bits */ RCC->CIR = 0x00FF0000; /* Reset CFGR2 register */ RCC->CFGR2 = 0x00000000; #elif defined(STM32F100xB) || defined(STM32F100xE) /* Disable all interrupts and clear pending bits */ RCC->CIR = 0x009F0000; /* Reset CFGR2 register */ RCC->CFGR2 = 0x00000000; #else /* Disable all interrupts and clear pending bits */ RCC->CIR = 0x009F0000; #endif /* STM32F105xC */ #if defined(STM32F100xE) || defined(STM32F101xE) || defined(STM32F101xG) || defined(STM32F103xE) || defined(STM32F103xG) #ifdef DATA_IN_ExtSRAM SystemInit_ExtMemCtl(); #endif /* DATA_IN_ExtSRAM */ #endif #ifdef VECT_TAB_SRAM SCB->VTOR = SRAM_BASE | VECT_TAB_OFFSET; /* Vector Table Relocation in Internal SRAM. */ #else SCB->VTOR = FLASH_BASE | VECT_TAB_OFFSET; /* Vector Table Relocation in Internal FLASH. */ #endif } /** * @brief Update SystemCoreClock variable according to Clock Register Values. * The SystemCoreClock variable contains the core clock (HCLK), it can * be used by the user application to setup the SysTick timer or configure * other parameters. * * @note Each time the core clock (HCLK) changes, this function must be called * to update SystemCoreClock variable value. Otherwise, any configuration * based on this variable will be incorrect. * * @note - The system frequency computed by this function is not the real * frequency in the chip. It is calculated based on the predefined * constant and the selected clock source: * * - If SYSCLK source is HSI, SystemCoreClock will contain the HSI_VALUE(*) * * - If SYSCLK source is HSE, SystemCoreClock will contain the HSE_VALUE(**) * * - If SYSCLK source is PLL, SystemCoreClock will contain the HSE_VALUE(**) * or HSI_VALUE(*) multiplied by the PLL factors. * * (*) HSI_VALUE is a constant defined in stm32f1xx.h file (default value * 8 MHz) but the real value may vary depending on the variations * in voltage and temperature. * * (**) HSE_VALUE is a constant defined in stm32f1xx.h file (default value * 8 MHz or 25 MHz, depending on the product used), user has to ensure * that HSE_VALUE is same as the real frequency of the crystal used. * Otherwise, this function may have wrong result. * * - The result of this function could be not correct when using fractional * value for HSE crystal. * @param None * @retval None */ void SystemCoreClockUpdate (void) { uint32_t tmp = 0, pllmull = 0, pllsource = 0; #if defined(STM32F105xC) || defined(STM32F107xC) uint32_t prediv1source = 0, prediv1factor = 0, prediv2factor = 0, pll2mull = 0; #endif /* STM32F105xC */ #if defined(STM32F100xB) || defined(STM32F100xE) uint32_t prediv1factor = 0; #endif /* STM32F100xB or STM32F100xE */ /* Get SYSCLK source -------------------------------------------------------*/ tmp = RCC->CFGR & RCC_CFGR_SWS; switch (tmp) { case 0x00: /* HSI used as system clock */ SystemCoreClock = HSI_VALUE; break; case 0x04: /* HSE used as system clock */ SystemCoreClock = HSE_VALUE; break; case 0x08: /* PLL used as system clock */ /* Get PLL clock source and multiplication factor ----------------------*/ pllmull = RCC->CFGR & RCC_CFGR_PLLMULL; pllsource = RCC->CFGR & RCC_CFGR_PLLSRC; #if !defined(STM32F105xC) && !defined(STM32F107xC) pllmull = ( pllmull >> 18) + 2; if (pllsource == 0x00) { /* HSI oscillator clock divided by 2 selected as PLL clock entry */ SystemCoreClock = (HSI_VALUE >> 1) * pllmull; } else { #if defined(STM32F100xB) || defined(STM32F100xE) prediv1factor = (RCC->CFGR2 & RCC_CFGR2_PREDIV1) + 1; /* HSE oscillator clock selected as PREDIV1 clock entry */ SystemCoreClock = (HSE_VALUE / prediv1factor) * pllmull; #else /* HSE selected as PLL clock entry */ if ((RCC->CFGR & RCC_CFGR_PLLXTPRE) != (uint32_t)RESET) {/* HSE oscillator clock divided by 2 */ SystemCoreClock = (HSE_VALUE >> 1) * pllmull; } else { SystemCoreClock = HSE_VALUE * pllmull; } #endif } #else pllmull = pllmull >> 18; if (pllmull != 0x0D) { pllmull += 2; } else { /* PLL multiplication factor = PLL input clock * 6.5 */ pllmull = 13 / 2; } if (pllsource == 0x00) { /* HSI oscillator clock divided by 2 selected as PLL clock entry */ SystemCoreClock = (HSI_VALUE >> 1) * pllmull; } else {/* PREDIV1 selected as PLL clock entry */ /* Get PREDIV1 clock source and division factor */ prediv1source = RCC->CFGR2 & RCC_CFGR2_PREDIV1SRC; prediv1factor = (RCC->CFGR2 & RCC_CFGR2_PREDIV1) + 1; if (prediv1source == 0) { /* HSE oscillator clock selected as PREDIV1 clock entry */ SystemCoreClock = (HSE_VALUE / prediv1factor) * pllmull; } else {/* PLL2 clock selected as PREDIV1 clock entry */ /* Get PREDIV2 division factor and PLL2 multiplication factor */ prediv2factor = ((RCC->CFGR2 & RCC_CFGR2_PREDIV2) >> 4) + 1; pll2mull = ((RCC->CFGR2 & RCC_CFGR2_PLL2MUL) >> 8 ) + 2; SystemCoreClock = (((HSE_VALUE / prediv2factor) * pll2mull) / prediv1factor) * pllmull; } } #endif /* STM32F105xC */ break; default: SystemCoreClock = HSI_VALUE; break; } /* Compute HCLK clock frequency ----------------*/ /* Get HCLK prescaler */ tmp = AHBPrescTable[((RCC->CFGR & RCC_CFGR_HPRE) >> 4)]; /* HCLK clock frequency */ SystemCoreClock >>= tmp; } #if defined(STM32F100xE) || defined(STM32F101xE) || defined(STM32F101xG) || defined(STM32F103xE) || defined(STM32F103xG) /** * @brief Setup the external memory controller. Called in startup_stm32f1xx.s * before jump to __main * @param None * @retval None */ #ifdef DATA_IN_ExtSRAM /** * @brief Setup the external memory controller. * Called in startup_stm32f1xx_xx.s/.c before jump to main. * This function configures the external SRAM mounted on STM3210E-EVAL * board (STM32 High density devices). This SRAM will be used as program * data memory (including heap and stack). * @param None * @retval None */ void SystemInit_ExtMemCtl(void) { __IO uint32_t tmpreg = 0x00; /*!< FSMC Bank1 NOR/SRAM3 is used for the STM3210E-EVAL, if another Bank is required, then adjust the Register Addresses */ /* Enable FSMC clock */ RCC->AHBENR = 0x00000114; /* Delay after an RCC peripheral clock enabling */ tmpreg = READ_BIT(RCC->AHBENR, RCC_AHBENR_FSMCEN); /* Enable GPIOD, GPIOE, GPIOF and GPIOG clocks */ RCC->APB2ENR = 0x000001E0; /* Delay after an RCC peripheral clock enabling */ tmpreg = READ_BIT(RCC->APB2ENR, RCC_APB2ENR_IOPDEN); (void)(tmpreg); /* --------------- SRAM Data lines, NOE and NWE configuration ---------------*/ /*---------------- SRAM Address lines configuration -------------------------*/ /*---------------- NOE and NWE configuration --------------------------------*/ /*---------------- NE3 configuration ----------------------------------------*/ /*---------------- NBL0, NBL1 configuration ---------------------------------*/ GPIOD->CRL = 0x44BB44BB; GPIOD->CRH = 0xBBBBBBBB; GPIOE->CRL = 0xB44444BB; GPIOE->CRH = 0xBBBBBBBB; GPIOF->CRL = 0x44BBBBBB; GPIOF->CRH = 0xBBBB4444; GPIOG->CRL = 0x44BBBBBB; GPIOG->CRH = 0x44444B44; /*---------------- FSMC Configuration ---------------------------------------*/ /*---------------- Enable FSMC Bank1_SRAM Bank ------------------------------*/ FSMC_Bank1->BTCR[4] = 0x00001091; FSMC_Bank1->BTCR[5] = 0x00110212; } #endif /* DATA_IN_ExtSRAM */ #endif /* STM32F100xE || STM32F101xE || STM32F101xG || STM32F103xE || STM32F103xG */ /** * @} */ /** * @} */ /** * @} */
0
D://workCode//uploadProject\STM32CubeF1\Projects\STM3210E_EVAL\Examples\Cortex\CORTEXM_ModePrivilege
D://workCode//uploadProject\STM32CubeF1\Projects\STM3210E_EVAL\Examples\Cortex\CORTEXM_ModePrivilege\Inc\main.h
/** ****************************************************************************** * @file Cortex/CORTEXM_ModePrivilege/Inc/main.h * @author MCD Application Team * @brief Header for main.c module ****************************************************************************** * @attention * * Copyright (c) 2016 STMicroelectronics. * All rights reserved. * * This software is licensed under terms that can be found in the LICENSE file * in the root directory of this software component. * If no LICENSE file comes with this software, it is provided AS-IS. * ****************************************************************************** */ /* Define to prevent recursive inclusion -------------------------------------*/ #ifndef __MAIN_H #define __MAIN_H /* Includes ------------------------------------------------------------------*/ #include "stm32f1xx_hal.h" #include "stm3210e_eval.h" /* Exported types ------------------------------------------------------------*/ /* Exported constants --------------------------------------------------------*/ /* Exported macro ------------------------------------------------------------*/ /* Exported functions ------------------------------------------------------- */ #endif /* __MAIN_H */
0
D://workCode//uploadProject\STM32CubeF1\Projects\STM3210E_EVAL\Examples\Cortex\CORTEXM_ModePrivilege
D://workCode//uploadProject\STM32CubeF1\Projects\STM3210E_EVAL\Examples\Cortex\CORTEXM_ModePrivilege\Inc\stm32f1xx_hal_conf.h
/** ****************************************************************************** * @file stm32f1xx_hal_conf.h * @author MCD Application Team * @brief HAL configuration file. ****************************************************************************** * @attention * * Copyright (c) 2016 STMicroelectronics. * All rights reserved. * * This software is licensed under terms that can be found in the LICENSE file * in the root directory of this software component. * If no LICENSE file comes with this software, it is provided AS-IS. * ****************************************************************************** */ /* Define to prevent recursive inclusion -------------------------------------*/ #ifndef __STM32F1xx_HAL_CONF_H #define __STM32F1xx_HAL_CONF_H #ifdef __cplusplus extern "C" { #endif /* Exported types ------------------------------------------------------------*/ /* Exported constants --------------------------------------------------------*/ /* ########################## Module Selection ############################## */ /** * @brief This is the list of modules to be used in the HAL driver */ #define HAL_MODULE_ENABLED /* #define HAL_ADC_MODULE_ENABLED */ /* #define HAL_CAN_MODULE_ENABLED */ /* #define HAL_CAN_LEGACY_MODULE_ENABLED */ /* #define HAL_CEC_MODULE_ENABLED */ #define HAL_CORTEX_MODULE_ENABLED /* #define HAL_CRC_MODULE_ENABLED */ /* #define HAL_DAC_MODULE_ENABLED */ #define HAL_DMA_MODULE_ENABLED /* #define HAL_ETH_MODULE_ENABLED */ /* #define HAL_EXTI_MODULE_ENABLED */ #define HAL_FLASH_MODULE_ENABLED #define HAL_GPIO_MODULE_ENABLED /* #define HAL_HCD_MODULE_ENABLED */ /* #define HAL_I2C_MODULE_ENABLED */ /* #define HAL_I2S_MODULE_ENABLED */ /* #define HAL_IRDA_MODULE_ENABLED */ /* #define HAL_IWDG_MODULE_ENABLED */ /* #define HAL_NAND_MODULE_ENABLED */ /* #define HAL_NOR_MODULE_ENABLED */ /* #define HAL_PCCARD_MODULE_ENABLED */ /* #define HAL_PCD_MODULE_ENABLED */ #define HAL_PWR_MODULE_ENABLED #define HAL_RCC_MODULE_ENABLED /* #define HAL_RTC_MODULE_ENABLED */ /* #define HAL_SD_MODULE_ENABLED */ /* #define HAL_SMARTCARD_MODULE_ENABLED */ /* #define HAL_SPI_MODULE_ENABLED */ /* #define HAL_SRAM_MODULE_ENABLED */ /* #define HAL_TIM_MODULE_ENABLED */ /* #define HAL_UART_MODULE_ENABLED */ /* #define HAL_USART_MODULE_ENABLED */ /* #define HAL_WWDG_MODULE_ENABLED */ /* #define HAL_MMC_MODULE_ENABLED */ /* ########################## Oscillator Values adaptation ####################*/ /** * @brief Adjust the value of External High Speed oscillator (HSE) used in your application. * This value is used by the RCC HAL module to compute the system frequency * (when HSE is used as system clock source, directly or through the PLL). */ #if !defined (HSE_VALUE) #if defined(USE_STM3210C_EVAL) #define HSE_VALUE 25000000U /*!< Value of the External oscillator in Hz */ #else #define HSE_VALUE 8000000U /*!< Value of the External oscillator in Hz */ #endif #endif /* HSE_VALUE */ #if !defined (HSE_STARTUP_TIMEOUT) #define HSE_STARTUP_TIMEOUT 100U /*!< Time out for HSE start up, in ms */ #endif /* HSE_STARTUP_TIMEOUT */ /** * @brief Internal High Speed oscillator (HSI) value. * This value is used by the RCC HAL module to compute the system frequency * (when HSI is used as system clock source, directly or through the PLL). */ #if !defined (HSI_VALUE) #define HSI_VALUE 8000000U /*!< Value of the Internal oscillator in Hz */ #endif /* HSI_VALUE */ /** * @brief Internal Low Speed oscillator (LSI) value. */ #if !defined (LSI_VALUE) #define LSI_VALUE 40000U /*!< LSI Typical Value in Hz */ #endif /* LSI_VALUE */ /*!< Value of the Internal Low Speed oscillator in Hz The real value may vary depending on the variations in voltage and temperature. */ /** * @brief External Low Speed oscillator (LSE) value. * This value is used by the UART, RTC HAL module to compute the system frequency */ #if !defined (LSE_VALUE) #define LSE_VALUE 32768U /*!< Value of the External oscillator in Hz*/ #endif /* LSE_VALUE */ #if !defined (LSE_STARTUP_TIMEOUT) #define LSE_STARTUP_TIMEOUT 5000U /*!< Time out for LSE start up, in ms */ #endif /* LSE_STARTUP_TIMEOUT */ /* Tip: To avoid modifying this file each time you need to use different HSE, === you can define the HSE value in your toolchain compiler preprocessor. */ /* ########################### System Configuration ######################### */ /** * @brief This is the HAL system configuration section */ #define VDD_VALUE 3300U /*!< Value of VDD in mv */ #define TICK_INT_PRIORITY 0x0FU /*!< tick interrupt priority */ #define USE_RTOS 0U #define PREFETCH_ENABLE 1U #define USE_HAL_ADC_REGISTER_CALLBACKS 0U /* ADC register callback disabled */ #define USE_HAL_CAN_REGISTER_CALLBACKS 0U /* CAN register callback disabled */ #define USE_HAL_CEC_REGISTER_CALLBACKS 0U /* CEC register callback disabled */ #define USE_HAL_DAC_REGISTER_CALLBACKS 0U /* DAC register callback disabled */ #define USE_HAL_ETH_REGISTER_CALLBACKS 0U /* ETH register callback disabled */ #define USE_HAL_HCD_REGISTER_CALLBACKS 0U /* HCD register callback disabled */ #define USE_HAL_I2C_REGISTER_CALLBACKS 0U /* I2C register callback disabled */ #define USE_HAL_I2S_REGISTER_CALLBACKS 0U /* I2S register callback disabled */ #define USE_HAL_MMC_REGISTER_CALLBACKS 0U /* MMC register callback disabled */ #define USE_HAL_NAND_REGISTER_CALLBACKS 0U /* NAND register callback disabled */ #define USE_HAL_NOR_REGISTER_CALLBACKS 0U /* NOR register callback disabled */ #define USE_HAL_PCCARD_REGISTER_CALLBACKS 0U /* PCCARD register callback disabled */ #define USE_HAL_PCD_REGISTER_CALLBACKS 0U /* PCD register callback disabled */ #define USE_HAL_RTC_REGISTER_CALLBACKS 0U /* RTC register callback disabled */ #define USE_HAL_SD_REGISTER_CALLBACKS 0U /* SD register callback disabled */ #define USE_HAL_SMARTCARD_REGISTER_CALLBACKS 0U /* SMARTCARD register callback disabled */ #define USE_HAL_IRDA_REGISTER_CALLBACKS 0U /* IRDA register callback disabled */ #define USE_HAL_SRAM_REGISTER_CALLBACKS 0U /* SRAM register callback disabled */ #define USE_HAL_SPI_REGISTER_CALLBACKS 0U /* SPI register callback disabled */ #define USE_HAL_TIM_REGISTER_CALLBACKS 0U /* TIM register callback disabled */ #define USE_HAL_UART_REGISTER_CALLBACKS 0U /* UART register callback disabled */ #define USE_HAL_USART_REGISTER_CALLBACKS 0U /* USART register callback disabled */ #define USE_HAL_WWDG_REGISTER_CALLBACKS 0U /* WWDG register callback disabled */ /* ########################## Assert Selection ############################## */ /** * @brief Uncomment the line below to expanse the "assert_param" macro in the * HAL drivers code */ /* #define USE_FULL_ASSERT 1U */ /* ################## Ethernet peripheral configuration ##################### */ /* Section 1 : Ethernet peripheral configuration */ /* MAC ADDRESS: MAC_ADDR0:MAC_ADDR1:MAC_ADDR2:MAC_ADDR3:MAC_ADDR4:MAC_ADDR5 */ #define MAC_ADDR0 2U #define MAC_ADDR1 0U #define MAC_ADDR2 0U #define MAC_ADDR3 0U #define MAC_ADDR4 0U #define MAC_ADDR5 0U /* Definition of the Ethernet driver buffers size and count */ #define ETH_RX_BUF_SIZE ETH_MAX_PACKET_SIZE /* buffer size for receive */ #define ETH_TX_BUF_SIZE ETH_MAX_PACKET_SIZE /* buffer size for transmit */ #define ETH_RXBUFNB 8U /* 8 Rx buffers of size ETH_RX_BUF_SIZE */ #define ETH_TXBUFNB 4U /* 4 Tx buffers of size ETH_TX_BUF_SIZE */ /* Section 2: PHY configuration section */ /* DP83848 PHY Address*/ #define DP83848_PHY_ADDRESS 0x01U /* PHY Reset delay these values are based on a 1 ms Systick interrupt*/ #define PHY_RESET_DELAY 0x000000FFU /* PHY Configuration delay */ #define PHY_CONFIG_DELAY 0x00000FFFU #define PHY_READ_TO 0x0000FFFFU #define PHY_WRITE_TO 0x0000FFFFU /* Section 3: Common PHY Registers */ #define PHY_BCR ((uint16_t)0x0000) /*!< Transceiver Basic Control Register */ #define PHY_BSR ((uint16_t)0x0001) /*!< Transceiver Basic Status Register */ #define PHY_RESET ((uint16_t)0x8000) /*!< PHY Reset */ #define PHY_LOOPBACK ((uint16_t)0x4000) /*!< Select loop-back mode */ #define PHY_FULLDUPLEX_100M ((uint16_t)0x2100) /*!< Set the full-duplex mode at 100 Mb/s */ #define PHY_HALFDUPLEX_100M ((uint16_t)0x2000) /*!< Set the half-duplex mode at 100 Mb/s */ #define PHY_FULLDUPLEX_10M ((uint16_t)0x0100) /*!< Set the full-duplex mode at 10 Mb/s */ #define PHY_HALFDUPLEX_10M ((uint16_t)0x0000) /*!< Set the half-duplex mode at 10 Mb/s */ #define PHY_AUTONEGOTIATION ((uint16_t)0x1000) /*!< Enable auto-negotiation function */ #define PHY_RESTART_AUTONEGOTIATION ((uint16_t)0x0200) /*!< Restart auto-negotiation function */ #define PHY_POWERDOWN ((uint16_t)0x0800) /*!< Select the power down mode */ #define PHY_ISOLATE ((uint16_t)0x0400) /*!< Isolate PHY from MII */ #define PHY_AUTONEGO_COMPLETE ((uint16_t)0x0020) /*!< Auto-Negotiation process completed */ #define PHY_LINKED_STATUS ((uint16_t)0x0004) /*!< Valid link established */ #define PHY_JABBER_DETECTION ((uint16_t)0x0002) /*!< Jabber condition detected */ /* Section 4: Extended PHY Registers */ #define PHY_SR ((uint16_t)0x0010) /*!< PHY status register Offset */ #define PHY_MICR ((uint16_t)0x0011) /*!< MII Interrupt Control Register */ #define PHY_MISR ((uint16_t)0x0012) /*!< MII Interrupt Status and Misc. Control Register */ #define PHY_LINK_STATUS ((uint16_t)0x0001) /*!< PHY Link mask */ #define PHY_SPEED_STATUS ((uint16_t)0x0002) /*!< PHY Speed mask */ #define PHY_DUPLEX_STATUS ((uint16_t)0x0004) /*!< PHY Duplex mask */ #define PHY_MICR_INT_EN ((uint16_t)0x0002) /*!< PHY Enable interrupts */ #define PHY_MICR_INT_OE ((uint16_t)0x0001) /*!< PHY Enable output interrupt events */ #define PHY_MISR_LINK_INT_EN ((uint16_t)0x0020) /*!< Enable Interrupt on change of link status */ #define PHY_LINK_INTERRUPT ((uint16_t)0x2000) /*!< PHY link status interrupt mask */ /* ################## SPI peripheral configuration ########################## */ /* CRC FEATURE: Use to activate CRC feature inside HAL SPI Driver * Activated: CRC code is present inside driver * Deactivated: CRC code cleaned from driver */ #define USE_SPI_CRC 1U /* Includes ------------------------------------------------------------------*/ /** * @brief Include module's header file */ #ifdef HAL_RCC_MODULE_ENABLED #include "stm32f1xx_hal_rcc.h" #endif /* HAL_RCC_MODULE_ENABLED */ #ifdef HAL_GPIO_MODULE_ENABLED #include "stm32f1xx_hal_gpio.h" #endif /* HAL_GPIO_MODULE_ENABLED */ #ifdef HAL_EXTI_MODULE_ENABLED #include "stm32f1xx_hal_exti.h" #endif /* HAL_EXTI_MODULE_ENABLED */ #ifdef HAL_DMA_MODULE_ENABLED #include "stm32f1xx_hal_dma.h" #endif /* HAL_DMA_MODULE_ENABLED */ #ifdef HAL_ETH_MODULE_ENABLED #include "stm32f1xx_hal_eth.h" #endif /* HAL_ETH_MODULE_ENABLED */ #ifdef HAL_CAN_MODULE_ENABLED #include "stm32f1xx_hal_can.h" #endif /* HAL_CAN_MODULE_ENABLED */ #ifdef HAL_CAN_LEGACY_MODULE_ENABLED #include "Legacy/stm32f1xx_hal_can_legacy.h" #endif /* HAL_CAN_LEGACY_MODULE_ENABLED */ #ifdef HAL_CEC_MODULE_ENABLED #include "stm32f1xx_hal_cec.h" #endif /* HAL_CEC_MODULE_ENABLED */ #ifdef HAL_CORTEX_MODULE_ENABLED #include "stm32f1xx_hal_cortex.h" #endif /* HAL_CORTEX_MODULE_ENABLED */ #ifdef HAL_ADC_MODULE_ENABLED #include "stm32f1xx_hal_adc.h" #endif /* HAL_ADC_MODULE_ENABLED */ #ifdef HAL_CRC_MODULE_ENABLED #include "stm32f1xx_hal_crc.h" #endif /* HAL_CRC_MODULE_ENABLED */ #ifdef HAL_DAC_MODULE_ENABLED #include "stm32f1xx_hal_dac.h" #endif /* HAL_DAC_MODULE_ENABLED */ #ifdef HAL_FLASH_MODULE_ENABLED #include "stm32f1xx_hal_flash.h" #endif /* HAL_FLASH_MODULE_ENABLED */ #ifdef HAL_SRAM_MODULE_ENABLED #include "stm32f1xx_hal_sram.h" #endif /* HAL_SRAM_MODULE_ENABLED */ #ifdef HAL_NOR_MODULE_ENABLED #include "stm32f1xx_hal_nor.h" #endif /* HAL_NOR_MODULE_ENABLED */ #ifdef HAL_I2C_MODULE_ENABLED #include "stm32f1xx_hal_i2c.h" #endif /* HAL_I2C_MODULE_ENABLED */ #ifdef HAL_I2S_MODULE_ENABLED #include "stm32f1xx_hal_i2s.h" #endif /* HAL_I2S_MODULE_ENABLED */ #ifdef HAL_IWDG_MODULE_ENABLED #include "stm32f1xx_hal_iwdg.h" #endif /* HAL_IWDG_MODULE_ENABLED */ #ifdef HAL_PWR_MODULE_ENABLED #include "stm32f1xx_hal_pwr.h" #endif /* HAL_PWR_MODULE_ENABLED */ #ifdef HAL_RTC_MODULE_ENABLED #include "stm32f1xx_hal_rtc.h" #endif /* HAL_RTC_MODULE_ENABLED */ #ifdef HAL_PCCARD_MODULE_ENABLED #include "stm32f1xx_hal_pccard.h" #endif /* HAL_PCCARD_MODULE_ENABLED */ #ifdef HAL_SD_MODULE_ENABLED #include "stm32f1xx_hal_sd.h" #endif /* HAL_SD_MODULE_ENABLED */ #ifdef HAL_NAND_MODULE_ENABLED #include "stm32f1xx_hal_nand.h" #endif /* HAL_NAND_MODULE_ENABLED */ #ifdef HAL_SPI_MODULE_ENABLED #include "stm32f1xx_hal_spi.h" #endif /* HAL_SPI_MODULE_ENABLED */ #ifdef HAL_TIM_MODULE_ENABLED #include "stm32f1xx_hal_tim.h" #endif /* HAL_TIM_MODULE_ENABLED */ #ifdef HAL_UART_MODULE_ENABLED #include "stm32f1xx_hal_uart.h" #endif /* HAL_UART_MODULE_ENABLED */ #ifdef HAL_USART_MODULE_ENABLED #include "stm32f1xx_hal_usart.h" #endif /* HAL_USART_MODULE_ENABLED */ #ifdef HAL_IRDA_MODULE_ENABLED #include "stm32f1xx_hal_irda.h" #endif /* HAL_IRDA_MODULE_ENABLED */ #ifdef HAL_SMARTCARD_MODULE_ENABLED #include "stm32f1xx_hal_smartcard.h" #endif /* HAL_SMARTCARD_MODULE_ENABLED */ #ifdef HAL_WWDG_MODULE_ENABLED #include "stm32f1xx_hal_wwdg.h" #endif /* HAL_WWDG_MODULE_ENABLED */ #ifdef HAL_PCD_MODULE_ENABLED #include "stm32f1xx_hal_pcd.h" #endif /* HAL_PCD_MODULE_ENABLED */ #ifdef HAL_HCD_MODULE_ENABLED #include "stm32f1xx_hal_hcd.h" #endif /* HAL_HCD_MODULE_ENABLED */ #ifdef HAL_MMC_MODULE_ENABLED #include "stm32f1xx_hal_mmc.h" #endif /* HAL_MMC_MODULE_ENABLED */ /* Exported macro ------------------------------------------------------------*/ #ifdef USE_FULL_ASSERT /** * @brief The assert_param macro is used for function's parameters check. * @param expr: If expr is false, it calls assert_failed function * which reports the name of the source file and the source * line number of the call that failed. * If expr is true, it returns no value. * @retval None */ #define assert_param(expr) ((expr) ? (void)0U : assert_failed((uint8_t *)__FILE__, __LINE__)) /* Exported functions ------------------------------------------------------- */ void assert_failed(uint8_t* file, uint32_t line); #else #define assert_param(expr) ((void)0U) #endif /* USE_FULL_ASSERT */ #ifdef __cplusplus } #endif #endif /* __STM32F1xx_HAL_CONF_H */
0
D://workCode//uploadProject\STM32CubeF1\Projects\STM3210E_EVAL\Examples\Cortex\CORTEXM_ModePrivilege
D://workCode//uploadProject\STM32CubeF1\Projects\STM3210E_EVAL\Examples\Cortex\CORTEXM_ModePrivilege\Inc\stm32f1xx_it.h
/** ****************************************************************************** * @file Cortex/CORTEXM_ModePrivilege/Inc/stm32f1xx_it.h * @author MCD Application Team * @brief This file contains the headers of the interrupt handlers. ****************************************************************************** * @attention * * Copyright (c) 2016 STMicroelectronics. * All rights reserved. * * This software is licensed under terms that can be found in the LICENSE file * in the root directory of this software component. * If no LICENSE file comes with this software, it is provided AS-IS. * ****************************************************************************** */ /* Define to prevent recursive inclusion -------------------------------------*/ #ifndef __STM32F1xx_IT_H #define __STM32F1xx_IT_H #ifdef __cplusplus extern "C" { #endif /* Includes ------------------------------------------------------------------*/ /* Exported types ------------------------------------------------------------*/ /* Exported constants --------------------------------------------------------*/ /* Exported macro ------------------------------------------------------------*/ /* Exported functions ------------------------------------------------------- */ void NMI_Handler(void); void HardFault_Handler(void); void MemManage_Handler(void); void BusFault_Handler(void); void UsageFault_Handler(void); void SVC_Handler(void); void DebugMon_Handler(void); void PendSV_Handler(void); void SysTick_Handler(void); #ifdef __cplusplus } #endif #endif /* __STM32F1xx_IT_H */
0
D://workCode//uploadProject\STM32CubeF1\Projects\STM3210E_EVAL\Examples\Cortex\CORTEXM_ModePrivilege
D://workCode//uploadProject\STM32CubeF1\Projects\STM3210E_EVAL\Examples\Cortex\CORTEXM_ModePrivilege\Src\main.c
/** ****************************************************************************** * @file Cortex/CORTEXM_ModePrivilege/Src/main.c * @author MCD Application Team * @brief Description of the Cortex-M3 Mode Privilege example. ****************************************************************************** * @attention * * Copyright (c) 2016 STMicroelectronics. * All rights reserved. * * This software is licensed under terms that can be found in the LICENSE file * in the root directory of this software component. * If no LICENSE file comes with this software, it is provided AS-IS. * ****************************************************************************** */ /* Includes ------------------------------------------------------------------*/ #include "main.h" /** @addtogroup STM32F1xx_HAL_Examples * @{ */ /** @addtogroup CORTEXM_ModePrivilege * @{ */ /* Private typedef -----------------------------------------------------------*/ /* Private define ------------------------------------------------------------*/ #define SP_PROCESS_SIZE 0x200 /* Process stack size */ #define SP_PROCESS 0x02 /* Process stack */ #define SP_MAIN 0x00 /* Main stack */ #define THREAD_MODE_PRIVILEGED 0x00 /* Thread mode has privileged access */ #define THREAD_MODE_UNPRIVILEGED 0x01 /* Thread mode has unprivileged access */ /* Private function prototypes -----------------------------------------------*/ static __INLINE void __SVC(void); /* Private macro -------------------------------------------------------------*/ #if defined ( __CC_ARM ) __ASM void __SVC(void) { SVC 0x01 BX R14 } #elif defined ( __ICCARM__ ) static __INLINE void __SVC() { __ASM("svc 0x01"); } #elif defined ( __GNUC__ ) static __INLINE void __SVC() { __ASM volatile("svc 0x01"); } #endif /* Private variables ---------------------------------------------------------*/ __IO uint8_t PSPMemAlloc[SP_PROCESS_SIZE]; __IO uint32_t Index = 0, PSPValue = 0, CurrentStack = 0, ThreadMode = 0; /* Private function prototypes -----------------------------------------------*/ void SystemClock_Config(void); /* Private functions ---------------------------------------------------------*/ /** * @brief Main program. * @param None * @retval None */ int main(void) { /* STM32F103xG HAL library initialization: - Configure the Flash prefetch - Systick timer is configured by default as source of time base, but user can eventually implement his proper time base source (a general purpose timer for example or other time source), keeping in mind that Time base duration should be kept 1ms since PPP_TIMEOUT_VALUEs are defined and handled in milliseconds basis. - Set NVIC Group Priority to 4 - Low Level Initialization */ HAL_Init(); /* Configure the system clock to 72 MHz */ SystemClock_Config(); /* Configure LED3*/ BSP_LED_Init(LED3); /* Switch Thread mode Stack from Main to Process -----------------------------*/ /* Initialize memory reserved for Process Stack */ for(Index = 0; Index < SP_PROCESS_SIZE; Index++) { PSPMemAlloc[Index] = 0x00; } /* Set Process stack value */ __set_PSP((uint32_t)PSPMemAlloc + SP_PROCESS_SIZE); /* Select Process Stack as Thread mode Stack */ __set_CONTROL(SP_PROCESS); /* Execute ISB instruction to flush pipeline as recommended by Arm */ __ISB(); /* Get the Thread mode stack used */ if((__get_CONTROL() & 0x02) == SP_MAIN) { /* Main stack is used as the current stack */ CurrentStack = SP_MAIN; } else { /* Process stack is used as the current stack */ CurrentStack = SP_PROCESS; /* Get process stack pointer value */ PSPValue = __get_PSP(); } /* Switch Thread mode from privileged to unprivileged ------------------------*/ /* Thread mode has unprivileged access */ __set_CONTROL(THREAD_MODE_UNPRIVILEGED | SP_PROCESS); /* Execute ISB instruction to flush pipeline as recommended by Arm */ __ISB(); /* Unprivileged access mainly affect ability to: - Use or not use certain instructions such as MSR fields - Access System Control Space (SCS) registers such as NVIC and SysTick */ /* Check Thread mode privilege status */ if((__get_CONTROL() & 0x01) == THREAD_MODE_PRIVILEGED) { /* Thread mode has privileged access */ ThreadMode = THREAD_MODE_PRIVILEGED; } else { /* Thread mode has unprivileged access*/ ThreadMode = THREAD_MODE_UNPRIVILEGED; } /* Switch back Thread mode from unprivileged to privileged -------------------*/ /* Try to switch back Thread mode to privileged (Not possible, this can be done only in Handler mode) */ __set_CONTROL(THREAD_MODE_PRIVILEGED | SP_PROCESS); /* Execute ISB instruction to flush pipeline as recommended by Arm */ __ISB(); /* Generate a system call exception, and in the ISR switch back Thread mode to privileged */ __SVC(); /* Check Thread mode privilege status */ if((__get_CONTROL() & 0x01) == THREAD_MODE_PRIVILEGED) { /* Thread mode has privileged access */ ThreadMode = THREAD_MODE_PRIVILEGED; } else { /* Thread mode has unprivileged access*/ ThreadMode = THREAD_MODE_UNPRIVILEGED; } /* Infinite loop */ while (1) { } } /** * @brief System Clock Configuration * The system Clock is configured as follow : * System Clock source = PLL (HSE) * SYSCLK(Hz) = 72000000 * HCLK(Hz) = 72000000 * AHB Prescaler = 1 * APB1 Prescaler = 2 * APB2 Prescaler = 1 * HSE Frequency(Hz) = 8000000 * HSE PREDIV1 = 1 * PLLMUL = 9 * Flash Latency(WS) = 2 * @param None * @retval None */ void SystemClock_Config(void) { RCC_ClkInitTypeDef clkinitstruct = {0}; RCC_OscInitTypeDef oscinitstruct = {0}; /* Enable HSE Oscillator and activate PLL with HSE as source */ oscinitstruct.OscillatorType = RCC_OSCILLATORTYPE_HSE; oscinitstruct.HSEState = RCC_HSE_ON; oscinitstruct.HSEPredivValue = RCC_HSE_PREDIV_DIV1; oscinitstruct.PLL.PLLState = RCC_PLL_ON; oscinitstruct.PLL.PLLSource = RCC_PLLSOURCE_HSE; oscinitstruct.PLL.PLLMUL = RCC_PLL_MUL9; if (HAL_RCC_OscConfig(&oscinitstruct)!= HAL_OK) { /* Initialization Error */ while(1); } /* Select PLL as system clock source and configure the HCLK, PCLK1 and PCLK2 clocks dividers */ clkinitstruct.ClockType = (RCC_CLOCKTYPE_SYSCLK | RCC_CLOCKTYPE_HCLK | RCC_CLOCKTYPE_PCLK1 | RCC_CLOCKTYPE_PCLK2); clkinitstruct.SYSCLKSource = RCC_SYSCLKSOURCE_PLLCLK; clkinitstruct.AHBCLKDivider = RCC_SYSCLK_DIV1; clkinitstruct.APB2CLKDivider = RCC_HCLK_DIV1; clkinitstruct.APB1CLKDivider = RCC_HCLK_DIV2; if (HAL_RCC_ClockConfig(&clkinitstruct, FLASH_LATENCY_2)!= HAL_OK) { /* Initialization Error */ while(1); } } #ifdef USE_FULL_ASSERT /** * @brief Reports the name of the source file and the source line number * where the assert_param error has occurred. * @param file: pointer to the source file name * @param line: assert_param error line source number * @retval None */ void assert_failed(uint8_t *file, uint32_t line) { /* User can add his own implementation to report the file name and line number, ex: printf("Wrong parameters value: file %s on line %d\r\n", file, line) */ /* Infinite loop */ while (1) { } } #endif /** * @} */ /** * @} */
0
D://workCode//uploadProject\STM32CubeF1\Projects\STM3210E_EVAL\Examples\Cortex\CORTEXM_ModePrivilege
D://workCode//uploadProject\STM32CubeF1\Projects\STM3210E_EVAL\Examples\Cortex\CORTEXM_ModePrivilege\Src\stm32f1xx_it.c
/** ****************************************************************************** * @file Cortex/CORTEXM_ModePrivilege/Src/stm32f1xx_it.c * @author MCD Application Team * @brief Main Interrupt Service Routines. * This file provides template for all exceptions handler and * peripherals interrupt service routine. ****************************************************************************** * @attention * * Copyright (c) 2016 STMicroelectronics. * All rights reserved. * * This software is licensed under terms that can be found in the LICENSE file * in the root directory of this software component. * If no LICENSE file comes with this software, it is provided AS-IS. * ****************************************************************************** */ /* Includes ------------------------------------------------------------------*/ #include "main.h" #include "stm32f1xx_it.h" /** @addtogroup STM32F1xx_HAL_Examples * @{ */ /** @addtogroup CORTEXM_ModePrivilege * @{ */ /* Private typedef -----------------------------------------------------------*/ /* Private define ------------------------------------------------------------*/ /* Private macro -------------------------------------------------------------*/ /* Private variables ---------------------------------------------------------*/ /* Private function prototypes -----------------------------------------------*/ /* Private functions ---------------------------------------------------------*/ /******************************************************************************/ /* Cortex-M3 Processor Exceptions Handlers */ /******************************************************************************/ /** * @brief This function handles NMI exception. * @param None * @retval None */ void NMI_Handler(void) { } /** * @brief This function handles Hard Fault exception. * @param None * @retval None */ void HardFault_Handler(void) { /* Go to infinite loop when Hard Fault exception occurs */ while (1) { } } /** * @brief This function handles Memory Manage exception. * @param None * @retval None */ void MemManage_Handler(void) { /* Go to infinite loop when Memory Manage exception occurs */ while (1) { } } /** * @brief This function handles Bus Fault exception. * @param None * @retval None */ void BusFault_Handler(void) { /* Go to infinite loop when Bus Fault exception occurs */ while (1) { } } /** * @brief This function handles Usage Fault exception. * @param None * @retval None */ void UsageFault_Handler(void) { /* Go to infinite loop when Usage Fault exception occurs */ while (1) { } } /** * @brief This function handles SVCall exception. * @param None * @retval None */ void SVC_Handler(void) { /* Switch back Thread mode to privileged */ __set_CONTROL(2); /* Execute ISB instruction to flush pipeline as recommended by Arm */ __ISB(); } /** * @brief This function handles Debug Monitor exception. * @param None * @retval None */ void DebugMon_Handler(void) { } /** * @brief This function handles PendSVC exception. * @param None * @retval None */ void PendSV_Handler(void) { } /** * @brief This function handles SysTick Handler. * @param None * @retval None */ void SysTick_Handler(void) { } /******************************************************************************/ /* STM32F1xx Peripherals Interrupt Handlers */ /* Add here the Interrupt Handler for the used peripheral(s) (PPP), for the */ /* available peripheral interrupt handler's name please refer to the startup */ /* file (startup_stm32f1xx.s). */ /******************************************************************************/ /** * @brief This function handles PPP interrupt request. * @param None * @retval None */ /*void PPP_IRQHandler(void) { }*/ /** * @} */ /** * @} */
0
D://workCode//uploadProject\STM32CubeF1\Projects\STM3210E_EVAL\Examples\Cortex\CORTEXM_ModePrivilege
D://workCode//uploadProject\STM32CubeF1\Projects\STM3210E_EVAL\Examples\Cortex\CORTEXM_ModePrivilege\Src\system_stm32f1xx.c
/** ****************************************************************************** * @file system_stm32f1xx.c * @author MCD Application Team * @brief CMSIS Cortex-M3 Device Peripheral Access Layer System Source File. * * 1. This file provides two functions and one global variable to be called from * user application: * - SystemInit(): Setups the system clock (System clock source, PLL Multiplier * factors, AHB/APBx prescalers and Flash settings). * This function is called at startup just after reset and * before branch to main program. This call is made inside * the "startup_stm32f1xx_xx.s" file. * * - SystemCoreClock variable: Contains the core clock (HCLK), it can be used * by the user application to setup the SysTick * timer or configure other parameters. * * - SystemCoreClockUpdate(): Updates the variable SystemCoreClock and must * be called whenever the core clock is changed * during program execution. * * 2. After each device reset the HSI (8 MHz) is used as system clock source. * Then SystemInit() function is called, in "startup_stm32f1xx_xx.s" file, to * configure the system clock before to branch to main program. * * 4. The default value of HSE crystal is set to 8 MHz (or 25 MHz, depending on * the product used), refer to "HSE_VALUE". * When HSE is used as system clock source, directly or through PLL, and you * are using different crystal you have to adapt the HSE value to your own * configuration. * ****************************************************************************** * @attention * * Copyright (c) 2016 STMicroelectronics. * All rights reserved. * * This software is licensed under terms that can be found in the LICENSE file * in the root directory of this software component. * If no LICENSE file comes with this software, it is provided AS-IS. * ****************************************************************************** */ /** @addtogroup CMSIS * @{ */ /** @addtogroup stm32f1xx_system * @{ */ /** @addtogroup STM32F1xx_System_Private_Includes * @{ */ #include "stm32f1xx.h" /** * @} */ /** @addtogroup STM32F1xx_System_Private_TypesDefinitions * @{ */ /** * @} */ /** @addtogroup STM32F1xx_System_Private_Defines * @{ */ #if !defined (HSE_VALUE) #define HSE_VALUE ((uint32_t)8000000) /*!< Default value of the External oscillator in Hz. This value can be provided and adapted by the user application. */ #endif /* HSE_VALUE */ #if !defined (HSI_VALUE) #define HSI_VALUE ((uint32_t)8000000) /*!< Default value of the Internal oscillator in Hz. This value can be provided and adapted by the user application. */ #endif /* HSI_VALUE */ /*!< Uncomment the following line if you need to use external SRAM */ #if defined(STM32F100xE) || defined(STM32F101xE) || defined(STM32F101xG) || defined(STM32F103xE) || defined(STM32F103xG) /* #define DATA_IN_ExtSRAM */ #endif /* STM32F100xE || STM32F101xE || STM32F101xG || STM32F103xE || STM32F103xG */ /*!< Uncomment the following line if you need to relocate your vector Table in Internal SRAM. */ /* #define VECT_TAB_SRAM */ #define VECT_TAB_OFFSET 0x0 /*!< Vector Table base offset field. This value must be a multiple of 0x200. */ /** * @} */ /** @addtogroup STM32F1xx_System_Private_Macros * @{ */ /** * @} */ /** @addtogroup STM32F1xx_System_Private_Variables * @{ */ /* This variable is updated in three ways: 1) by calling CMSIS function SystemCoreClockUpdate() 2) by calling HAL API function HAL_RCC_GetHCLKFreq() 3) each time HAL_RCC_ClockConfig() is called to configure the system clock frequency Note: If you use this function to configure the system clock; then there is no need to call the 2 first functions listed above, since SystemCoreClock variable is updated automatically. */ uint32_t SystemCoreClock = 16000000; const uint8_t AHBPrescTable[16] = {0, 0, 0, 0, 0, 0, 0, 0, 1, 2, 3, 4, 6, 7, 8, 9}; const uint8_t APBPrescTable[8] = {0, 0, 0, 0, 1, 2, 3, 4}; /** * @} */ /** @addtogroup STM32F1xx_System_Private_FunctionPrototypes * @{ */ #if defined(STM32F100xE) || defined(STM32F101xE) || defined(STM32F101xG) || defined(STM32F103xE) || defined(STM32F103xG) #ifdef DATA_IN_ExtSRAM static void SystemInit_ExtMemCtl(void); #endif /* DATA_IN_ExtSRAM */ #endif /* STM32F100xE || STM32F101xE || STM32F101xG || STM32F103xE || STM32F103xG */ /** * @} */ /** @addtogroup STM32F1xx_System_Private_Functions * @{ */ /** * @brief Setup the microcontroller system * Initialize the Embedded Flash Interface, the PLL and update the * SystemCoreClock variable. * @note This function should be used only after reset. * @param None * @retval None */ void SystemInit (void) { /* Reset the RCC clock configuration to the default reset state(for debug purpose) */ /* Set HSION bit */ RCC->CR |= (uint32_t)0x00000001; /* Reset SW, HPRE, PPRE1, PPRE2, ADCPRE and MCO bits */ #if !defined(STM32F105xC) && !defined(STM32F107xC) RCC->CFGR &= (uint32_t)0xF8FF0000; #else RCC->CFGR &= (uint32_t)0xF0FF0000; #endif /* STM32F105xC */ /* Reset HSEON, CSSON and PLLON bits */ RCC->CR &= (uint32_t)0xFEF6FFFF; /* Reset HSEBYP bit */ RCC->CR &= (uint32_t)0xFFFBFFFF; /* Reset PLLSRC, PLLXTPRE, PLLMUL and USBPRE/OTGFSPRE bits */ RCC->CFGR &= (uint32_t)0xFF80FFFF; #if defined(STM32F105xC) || defined(STM32F107xC) /* Reset PLL2ON and PLL3ON bits */ RCC->CR &= (uint32_t)0xEBFFFFFF; /* Disable all interrupts and clear pending bits */ RCC->CIR = 0x00FF0000; /* Reset CFGR2 register */ RCC->CFGR2 = 0x00000000; #elif defined(STM32F100xB) || defined(STM32F100xE) /* Disable all interrupts and clear pending bits */ RCC->CIR = 0x009F0000; /* Reset CFGR2 register */ RCC->CFGR2 = 0x00000000; #else /* Disable all interrupts and clear pending bits */ RCC->CIR = 0x009F0000; #endif /* STM32F105xC */ #if defined(STM32F100xE) || defined(STM32F101xE) || defined(STM32F101xG) || defined(STM32F103xE) || defined(STM32F103xG) #ifdef DATA_IN_ExtSRAM SystemInit_ExtMemCtl(); #endif /* DATA_IN_ExtSRAM */ #endif #ifdef VECT_TAB_SRAM SCB->VTOR = SRAM_BASE | VECT_TAB_OFFSET; /* Vector Table Relocation in Internal SRAM. */ #else SCB->VTOR = FLASH_BASE | VECT_TAB_OFFSET; /* Vector Table Relocation in Internal FLASH. */ #endif } /** * @brief Update SystemCoreClock variable according to Clock Register Values. * The SystemCoreClock variable contains the core clock (HCLK), it can * be used by the user application to setup the SysTick timer or configure * other parameters. * * @note Each time the core clock (HCLK) changes, this function must be called * to update SystemCoreClock variable value. Otherwise, any configuration * based on this variable will be incorrect. * * @note - The system frequency computed by this function is not the real * frequency in the chip. It is calculated based on the predefined * constant and the selected clock source: * * - If SYSCLK source is HSI, SystemCoreClock will contain the HSI_VALUE(*) * * - If SYSCLK source is HSE, SystemCoreClock will contain the HSE_VALUE(**) * * - If SYSCLK source is PLL, SystemCoreClock will contain the HSE_VALUE(**) * or HSI_VALUE(*) multiplied by the PLL factors. * * (*) HSI_VALUE is a constant defined in stm32f1xx.h file (default value * 8 MHz) but the real value may vary depending on the variations * in voltage and temperature. * * (**) HSE_VALUE is a constant defined in stm32f1xx.h file (default value * 8 MHz or 25 MHz, depending on the product used), user has to ensure * that HSE_VALUE is same as the real frequency of the crystal used. * Otherwise, this function may have wrong result. * * - The result of this function could be not correct when using fractional * value for HSE crystal. * @param None * @retval None */ void SystemCoreClockUpdate (void) { uint32_t tmp = 0, pllmull = 0, pllsource = 0; #if defined(STM32F105xC) || defined(STM32F107xC) uint32_t prediv1source = 0, prediv1factor = 0, prediv2factor = 0, pll2mull = 0; #endif /* STM32F105xC */ #if defined(STM32F100xB) || defined(STM32F100xE) uint32_t prediv1factor = 0; #endif /* STM32F100xB or STM32F100xE */ /* Get SYSCLK source -------------------------------------------------------*/ tmp = RCC->CFGR & RCC_CFGR_SWS; switch (tmp) { case 0x00: /* HSI used as system clock */ SystemCoreClock = HSI_VALUE; break; case 0x04: /* HSE used as system clock */ SystemCoreClock = HSE_VALUE; break; case 0x08: /* PLL used as system clock */ /* Get PLL clock source and multiplication factor ----------------------*/ pllmull = RCC->CFGR & RCC_CFGR_PLLMULL; pllsource = RCC->CFGR & RCC_CFGR_PLLSRC; #if !defined(STM32F105xC) && !defined(STM32F107xC) pllmull = ( pllmull >> 18) + 2; if (pllsource == 0x00) { /* HSI oscillator clock divided by 2 selected as PLL clock entry */ SystemCoreClock = (HSI_VALUE >> 1) * pllmull; } else { #if defined(STM32F100xB) || defined(STM32F100xE) prediv1factor = (RCC->CFGR2 & RCC_CFGR2_PREDIV1) + 1; /* HSE oscillator clock selected as PREDIV1 clock entry */ SystemCoreClock = (HSE_VALUE / prediv1factor) * pllmull; #else /* HSE selected as PLL clock entry */ if ((RCC->CFGR & RCC_CFGR_PLLXTPRE) != (uint32_t)RESET) {/* HSE oscillator clock divided by 2 */ SystemCoreClock = (HSE_VALUE >> 1) * pllmull; } else { SystemCoreClock = HSE_VALUE * pllmull; } #endif } #else pllmull = pllmull >> 18; if (pllmull != 0x0D) { pllmull += 2; } else { /* PLL multiplication factor = PLL input clock * 6.5 */ pllmull = 13 / 2; } if (pllsource == 0x00) { /* HSI oscillator clock divided by 2 selected as PLL clock entry */ SystemCoreClock = (HSI_VALUE >> 1) * pllmull; } else {/* PREDIV1 selected as PLL clock entry */ /* Get PREDIV1 clock source and division factor */ prediv1source = RCC->CFGR2 & RCC_CFGR2_PREDIV1SRC; prediv1factor = (RCC->CFGR2 & RCC_CFGR2_PREDIV1) + 1; if (prediv1source == 0) { /* HSE oscillator clock selected as PREDIV1 clock entry */ SystemCoreClock = (HSE_VALUE / prediv1factor) * pllmull; } else {/* PLL2 clock selected as PREDIV1 clock entry */ /* Get PREDIV2 division factor and PLL2 multiplication factor */ prediv2factor = ((RCC->CFGR2 & RCC_CFGR2_PREDIV2) >> 4) + 1; pll2mull = ((RCC->CFGR2 & RCC_CFGR2_PLL2MUL) >> 8 ) + 2; SystemCoreClock = (((HSE_VALUE / prediv2factor) * pll2mull) / prediv1factor) * pllmull; } } #endif /* STM32F105xC */ break; default: SystemCoreClock = HSI_VALUE; break; } /* Compute HCLK clock frequency ----------------*/ /* Get HCLK prescaler */ tmp = AHBPrescTable[((RCC->CFGR & RCC_CFGR_HPRE) >> 4)]; /* HCLK clock frequency */ SystemCoreClock >>= tmp; } #if defined(STM32F100xE) || defined(STM32F101xE) || defined(STM32F101xG) || defined(STM32F103xE) || defined(STM32F103xG) /** * @brief Setup the external memory controller. Called in startup_stm32f1xx.s * before jump to __main * @param None * @retval None */ #ifdef DATA_IN_ExtSRAM /** * @brief Setup the external memory controller. * Called in startup_stm32f1xx_xx.s/.c before jump to main. * This function configures the external SRAM mounted on STM3210E-EVAL * board (STM32 High density devices). This SRAM will be used as program * data memory (including heap and stack). * @param None * @retval None */ void SystemInit_ExtMemCtl(void) { __IO uint32_t tmpreg; /*!< FSMC Bank1 NOR/SRAM3 is used for the STM3210E-EVAL, if another Bank is required, then adjust the Register Addresses */ /* Enable FSMC clock */ RCC->AHBENR = 0x00000114; /* Delay after an RCC peripheral clock enabling */ tmpreg = READ_BIT(RCC->AHBENR, RCC_AHBENR_FSMCEN); /* Enable GPIOD, GPIOE, GPIOF and GPIOG clocks */ RCC->APB2ENR = 0x000001E0; /* Delay after an RCC peripheral clock enabling */ tmpreg = READ_BIT(RCC->APB2ENR, RCC_APB2ENR_IOPDEN); (void)(tmpreg); /* --------------- SRAM Data lines, NOE and NWE configuration ---------------*/ /*---------------- SRAM Address lines configuration -------------------------*/ /*---------------- NOE and NWE configuration --------------------------------*/ /*---------------- NE3 configuration ----------------------------------------*/ /*---------------- NBL0, NBL1 configuration ---------------------------------*/ GPIOD->CRL = 0x44BB44BB; GPIOD->CRH = 0xBBBBBBBB; GPIOE->CRL = 0xB44444BB; GPIOE->CRH = 0xBBBBBBBB; GPIOF->CRL = 0x44BBBBBB; GPIOF->CRH = 0xBBBB4444; GPIOG->CRL = 0x44BBBBBB; GPIOG->CRH = 0x44444B44; /*---------------- FSMC Configuration ---------------------------------------*/ /*---------------- Enable FSMC Bank1_SRAM Bank ------------------------------*/ FSMC_Bank1->BTCR[4] = 0x00001091; FSMC_Bank1->BTCR[5] = 0x00110212; } #endif /* DATA_IN_ExtSRAM */ #endif /* STM32F100xE || STM32F101xE || STM32F101xG || STM32F103xE || STM32F103xG */ /** * @} */ /** * @} */ /** * @} */
0
D://workCode//uploadProject\STM32CubeF1\Projects\STM3210E_EVAL\Examples\Cortex\CORTEXM_MPU
D://workCode//uploadProject\STM32CubeF1\Projects\STM3210E_EVAL\Examples\Cortex\CORTEXM_MPU\Inc\main.h
/** ****************************************************************************** * @file Cortex/CORTEXM_MPU/Inc/main.h * @author MCD Application Team * @brief Header for main.c module ****************************************************************************** * @attention * * Copyright (c) 2016 STMicroelectronics. * All rights reserved. * * This software is licensed under terms that can be found in the LICENSE file * in the root directory of this software component. * If no LICENSE file comes with this software, it is provided AS-IS. * ****************************************************************************** */ /* Define to prevent recursive inclusion -------------------------------------*/ #ifndef __MAIN_H #define __MAIN_H /* Includes ------------------------------------------------------------------*/ #include "stm32f1xx_hal.h" #include "stm3210e_eval.h" #include "stm32_mpu.h" /* Exported types ------------------------------------------------------------*/ /* Exported constants --------------------------------------------------------*/ /* Exported macro ------------------------------------------------------------*/ /* Exported functions ------------------------------------------------------- */ #endif /* __MAIN_H */
0
D://workCode//uploadProject\STM32CubeF1\Projects\STM3210E_EVAL\Examples\Cortex\CORTEXM_MPU
D://workCode//uploadProject\STM32CubeF1\Projects\STM3210E_EVAL\Examples\Cortex\CORTEXM_MPU\Inc\stm32f1xx_hal_conf.h
/** ****************************************************************************** * @file stm32f1xx_hal_conf.h * @author MCD Application Team * @brief HAL configuration file. ****************************************************************************** * @attention * * Copyright (c) 2016 STMicroelectronics. * All rights reserved. * * This software is licensed under terms that can be found in the LICENSE file * in the root directory of this software component. * If no LICENSE file comes with this software, it is provided AS-IS. * ****************************************************************************** */ /* Define to prevent recursive inclusion -------------------------------------*/ #ifndef __STM32F1xx_HAL_CONF_H #define __STM32F1xx_HAL_CONF_H #ifdef __cplusplus extern "C" { #endif /* Exported types ------------------------------------------------------------*/ /* Exported constants --------------------------------------------------------*/ /* ########################## Module Selection ############################## */ /** * @brief This is the list of modules to be used in the HAL driver */ #define HAL_MODULE_ENABLED /* #define HAL_ADC_MODULE_ENABLED */ /* #define HAL_CAN_MODULE_ENABLED */ /* #define HAL_CAN_LEGACY_MODULE_ENABLED */ /* #define HAL_CEC_MODULE_ENABLED */ #define HAL_CORTEX_MODULE_ENABLED /* #define HAL_CRC_MODULE_ENABLED */ /* #define HAL_DAC_MODULE_ENABLED */ #define HAL_DMA_MODULE_ENABLED /* #define HAL_ETH_MODULE_ENABLED */ /* #define HAL_EXTI_MODULE_ENABLED */ #define HAL_FLASH_MODULE_ENABLED #define HAL_GPIO_MODULE_ENABLED /* #define HAL_HCD_MODULE_ENABLED */ /* #define HAL_I2C_MODULE_ENABLED */ /* #define HAL_I2S_MODULE_ENABLED */ /* #define HAL_IRDA_MODULE_ENABLED */ /* #define HAL_IWDG_MODULE_ENABLED */ /* #define HAL_NAND_MODULE_ENABLED */ /* #define HAL_NOR_MODULE_ENABLED */ /* #define HAL_PCCARD_MODULE_ENABLED */ /* #define HAL_PCD_MODULE_ENABLED */ #define HAL_PWR_MODULE_ENABLED #define HAL_RCC_MODULE_ENABLED /* #define HAL_RTC_MODULE_ENABLED */ /* #define HAL_SD_MODULE_ENABLED */ /* #define HAL_SMARTCARD_MODULE_ENABLED */ /* #define HAL_SPI_MODULE_ENABLED */ /* #define HAL_SRAM_MODULE_ENABLED */ /* #define HAL_TIM_MODULE_ENABLED */ /* #define HAL_UART_MODULE_ENABLED */ /* #define HAL_USART_MODULE_ENABLED */ /* #define HAL_WWDG_MODULE_ENABLED */ /* #define HAL_MMC_MODULE_ENABLED */ /* ########################## Oscillator Values adaptation ####################*/ /** * @brief Adjust the value of External High Speed oscillator (HSE) used in your application. * This value is used by the RCC HAL module to compute the system frequency * (when HSE is used as system clock source, directly or through the PLL). */ #if !defined (HSE_VALUE) #if defined(USE_STM3210C_EVAL) #define HSE_VALUE 25000000U /*!< Value of the External oscillator in Hz */ #else #define HSE_VALUE 8000000U /*!< Value of the External oscillator in Hz */ #endif #endif /* HSE_VALUE */ #if !defined (HSE_STARTUP_TIMEOUT) #define HSE_STARTUP_TIMEOUT 100U /*!< Time out for HSE start up, in ms */ #endif /* HSE_STARTUP_TIMEOUT */ /** * @brief Internal High Speed oscillator (HSI) value. * This value is used by the RCC HAL module to compute the system frequency * (when HSI is used as system clock source, directly or through the PLL). */ #if !defined (HSI_VALUE) #define HSI_VALUE 8000000U /*!< Value of the Internal oscillator in Hz */ #endif /* HSI_VALUE */ /** * @brief Internal Low Speed oscillator (LSI) value. */ #if !defined (LSI_VALUE) #define LSI_VALUE 40000U /*!< LSI Typical Value in Hz */ #endif /* LSI_VALUE */ /*!< Value of the Internal Low Speed oscillator in Hz The real value may vary depending on the variations in voltage and temperature. */ /** * @brief External Low Speed oscillator (LSE) value. * This value is used by the UART, RTC HAL module to compute the system frequency */ #if !defined (LSE_VALUE) #define LSE_VALUE 32768U /*!< Value of the External oscillator in Hz*/ #endif /* LSE_VALUE */ #if !defined (LSE_STARTUP_TIMEOUT) #define LSE_STARTUP_TIMEOUT 5000U /*!< Time out for LSE start up, in ms */ #endif /* LSE_STARTUP_TIMEOUT */ /* Tip: To avoid modifying this file each time you need to use different HSE, === you can define the HSE value in your toolchain compiler preprocessor. */ /* ########################### System Configuration ######################### */ /** * @brief This is the HAL system configuration section */ #define VDD_VALUE 3300U /*!< Value of VDD in mv */ #define TICK_INT_PRIORITY 0x0FU /*!< tick interrupt priority */ #define USE_RTOS 0U #define PREFETCH_ENABLE 1U #define USE_HAL_ADC_REGISTER_CALLBACKS 0U /* ADC register callback disabled */ #define USE_HAL_CAN_REGISTER_CALLBACKS 0U /* CAN register callback disabled */ #define USE_HAL_CEC_REGISTER_CALLBACKS 0U /* CEC register callback disabled */ #define USE_HAL_DAC_REGISTER_CALLBACKS 0U /* DAC register callback disabled */ #define USE_HAL_ETH_REGISTER_CALLBACKS 0U /* ETH register callback disabled */ #define USE_HAL_HCD_REGISTER_CALLBACKS 0U /* HCD register callback disabled */ #define USE_HAL_I2C_REGISTER_CALLBACKS 0U /* I2C register callback disabled */ #define USE_HAL_I2S_REGISTER_CALLBACKS 0U /* I2S register callback disabled */ #define USE_HAL_MMC_REGISTER_CALLBACKS 0U /* MMC register callback disabled */ #define USE_HAL_NAND_REGISTER_CALLBACKS 0U /* NAND register callback disabled */ #define USE_HAL_NOR_REGISTER_CALLBACKS 0U /* NOR register callback disabled */ #define USE_HAL_PCCARD_REGISTER_CALLBACKS 0U /* PCCARD register callback disabled */ #define USE_HAL_PCD_REGISTER_CALLBACKS 0U /* PCD register callback disabled */ #define USE_HAL_RTC_REGISTER_CALLBACKS 0U /* RTC register callback disabled */ #define USE_HAL_SD_REGISTER_CALLBACKS 0U /* SD register callback disabled */ #define USE_HAL_SMARTCARD_REGISTER_CALLBACKS 0U /* SMARTCARD register callback disabled */ #define USE_HAL_IRDA_REGISTER_CALLBACKS 0U /* IRDA register callback disabled */ #define USE_HAL_SRAM_REGISTER_CALLBACKS 0U /* SRAM register callback disabled */ #define USE_HAL_SPI_REGISTER_CALLBACKS 0U /* SPI register callback disabled */ #define USE_HAL_TIM_REGISTER_CALLBACKS 0U /* TIM register callback disabled */ #define USE_HAL_UART_REGISTER_CALLBACKS 0U /* UART register callback disabled */ #define USE_HAL_USART_REGISTER_CALLBACKS 0U /* USART register callback disabled */ #define USE_HAL_WWDG_REGISTER_CALLBACKS 0U /* WWDG register callback disabled */ /* ########################## Assert Selection ############################## */ /** * @brief Uncomment the line below to expanse the "assert_param" macro in the * HAL drivers code */ /* #define USE_FULL_ASSERT 1U */ /* ################## Ethernet peripheral configuration ##################### */ /* Section 1 : Ethernet peripheral configuration */ /* MAC ADDRESS: MAC_ADDR0:MAC_ADDR1:MAC_ADDR2:MAC_ADDR3:MAC_ADDR4:MAC_ADDR5 */ #define MAC_ADDR0 2U #define MAC_ADDR1 0U #define MAC_ADDR2 0U #define MAC_ADDR3 0U #define MAC_ADDR4 0U #define MAC_ADDR5 0U /* Definition of the Ethernet driver buffers size and count */ #define ETH_RX_BUF_SIZE ETH_MAX_PACKET_SIZE /* buffer size for receive */ #define ETH_TX_BUF_SIZE ETH_MAX_PACKET_SIZE /* buffer size for transmit */ #define ETH_RXBUFNB 8U /* 8 Rx buffers of size ETH_RX_BUF_SIZE */ #define ETH_TXBUFNB 4U /* 4 Tx buffers of size ETH_TX_BUF_SIZE */ /* Section 2: PHY configuration section */ /* DP83848 PHY Address*/ #define DP83848_PHY_ADDRESS 0x01U /* PHY Reset delay these values are based on a 1 ms Systick interrupt*/ #define PHY_RESET_DELAY 0x000000FFU /* PHY Configuration delay */ #define PHY_CONFIG_DELAY 0x00000FFFU #define PHY_READ_TO 0x0000FFFFU #define PHY_WRITE_TO 0x0000FFFFU /* Section 3: Common PHY Registers */ #define PHY_BCR ((uint16_t)0x0000) /*!< Transceiver Basic Control Register */ #define PHY_BSR ((uint16_t)0x0001) /*!< Transceiver Basic Status Register */ #define PHY_RESET ((uint16_t)0x8000) /*!< PHY Reset */ #define PHY_LOOPBACK ((uint16_t)0x4000) /*!< Select loop-back mode */ #define PHY_FULLDUPLEX_100M ((uint16_t)0x2100) /*!< Set the full-duplex mode at 100 Mb/s */ #define PHY_HALFDUPLEX_100M ((uint16_t)0x2000) /*!< Set the half-duplex mode at 100 Mb/s */ #define PHY_FULLDUPLEX_10M ((uint16_t)0x0100) /*!< Set the full-duplex mode at 10 Mb/s */ #define PHY_HALFDUPLEX_10M ((uint16_t)0x0000) /*!< Set the half-duplex mode at 10 Mb/s */ #define PHY_AUTONEGOTIATION ((uint16_t)0x1000) /*!< Enable auto-negotiation function */ #define PHY_RESTART_AUTONEGOTIATION ((uint16_t)0x0200) /*!< Restart auto-negotiation function */ #define PHY_POWERDOWN ((uint16_t)0x0800) /*!< Select the power down mode */ #define PHY_ISOLATE ((uint16_t)0x0400) /*!< Isolate PHY from MII */ #define PHY_AUTONEGO_COMPLETE ((uint16_t)0x0020) /*!< Auto-Negotiation process completed */ #define PHY_LINKED_STATUS ((uint16_t)0x0004) /*!< Valid link established */ #define PHY_JABBER_DETECTION ((uint16_t)0x0002) /*!< Jabber condition detected */ /* Section 4: Extended PHY Registers */ #define PHY_SR ((uint16_t)0x0010) /*!< PHY status register Offset */ #define PHY_MICR ((uint16_t)0x0011) /*!< MII Interrupt Control Register */ #define PHY_MISR ((uint16_t)0x0012) /*!< MII Interrupt Status and Misc. Control Register */ #define PHY_LINK_STATUS ((uint16_t)0x0001) /*!< PHY Link mask */ #define PHY_SPEED_STATUS ((uint16_t)0x0002) /*!< PHY Speed mask */ #define PHY_DUPLEX_STATUS ((uint16_t)0x0004) /*!< PHY Duplex mask */ #define PHY_MICR_INT_EN ((uint16_t)0x0002) /*!< PHY Enable interrupts */ #define PHY_MICR_INT_OE ((uint16_t)0x0001) /*!< PHY Enable output interrupt events */ #define PHY_MISR_LINK_INT_EN ((uint16_t)0x0020) /*!< Enable Interrupt on change of link status */ #define PHY_LINK_INTERRUPT ((uint16_t)0x2000) /*!< PHY link status interrupt mask */ /* ################## SPI peripheral configuration ########################## */ /* CRC FEATURE: Use to activate CRC feature inside HAL SPI Driver * Activated: CRC code is present inside driver * Deactivated: CRC code cleaned from driver */ #define USE_SPI_CRC 1U /* Includes ------------------------------------------------------------------*/ /** * @brief Include module's header file */ #ifdef HAL_RCC_MODULE_ENABLED #include "stm32f1xx_hal_rcc.h" #endif /* HAL_RCC_MODULE_ENABLED */ #ifdef HAL_GPIO_MODULE_ENABLED #include "stm32f1xx_hal_gpio.h" #endif /* HAL_GPIO_MODULE_ENABLED */ #ifdef HAL_EXTI_MODULE_ENABLED #include "stm32f1xx_hal_exti.h" #endif /* HAL_EXTI_MODULE_ENABLED */ #ifdef HAL_DMA_MODULE_ENABLED #include "stm32f1xx_hal_dma.h" #endif /* HAL_DMA_MODULE_ENABLED */ #ifdef HAL_ETH_MODULE_ENABLED #include "stm32f1xx_hal_eth.h" #endif /* HAL_ETH_MODULE_ENABLED */ #ifdef HAL_CAN_MODULE_ENABLED #include "stm32f1xx_hal_can.h" #endif /* HAL_CAN_MODULE_ENABLED */ #ifdef HAL_CAN_LEGACY_MODULE_ENABLED #include "Legacy/stm32f1xx_hal_can_legacy.h" #endif /* HAL_CAN_LEGACY_MODULE_ENABLED */ #ifdef HAL_CEC_MODULE_ENABLED #include "stm32f1xx_hal_cec.h" #endif /* HAL_CEC_MODULE_ENABLED */ #ifdef HAL_CORTEX_MODULE_ENABLED #include "stm32f1xx_hal_cortex.h" #endif /* HAL_CORTEX_MODULE_ENABLED */ #ifdef HAL_ADC_MODULE_ENABLED #include "stm32f1xx_hal_adc.h" #endif /* HAL_ADC_MODULE_ENABLED */ #ifdef HAL_CRC_MODULE_ENABLED #include "stm32f1xx_hal_crc.h" #endif /* HAL_CRC_MODULE_ENABLED */ #ifdef HAL_DAC_MODULE_ENABLED #include "stm32f1xx_hal_dac.h" #endif /* HAL_DAC_MODULE_ENABLED */ #ifdef HAL_FLASH_MODULE_ENABLED #include "stm32f1xx_hal_flash.h" #endif /* HAL_FLASH_MODULE_ENABLED */ #ifdef HAL_SRAM_MODULE_ENABLED #include "stm32f1xx_hal_sram.h" #endif /* HAL_SRAM_MODULE_ENABLED */ #ifdef HAL_NOR_MODULE_ENABLED #include "stm32f1xx_hal_nor.h" #endif /* HAL_NOR_MODULE_ENABLED */ #ifdef HAL_I2C_MODULE_ENABLED #include "stm32f1xx_hal_i2c.h" #endif /* HAL_I2C_MODULE_ENABLED */ #ifdef HAL_I2S_MODULE_ENABLED #include "stm32f1xx_hal_i2s.h" #endif /* HAL_I2S_MODULE_ENABLED */ #ifdef HAL_IWDG_MODULE_ENABLED #include "stm32f1xx_hal_iwdg.h" #endif /* HAL_IWDG_MODULE_ENABLED */ #ifdef HAL_PWR_MODULE_ENABLED #include "stm32f1xx_hal_pwr.h" #endif /* HAL_PWR_MODULE_ENABLED */ #ifdef HAL_RTC_MODULE_ENABLED #include "stm32f1xx_hal_rtc.h" #endif /* HAL_RTC_MODULE_ENABLED */ #ifdef HAL_PCCARD_MODULE_ENABLED #include "stm32f1xx_hal_pccard.h" #endif /* HAL_PCCARD_MODULE_ENABLED */ #ifdef HAL_SD_MODULE_ENABLED #include "stm32f1xx_hal_sd.h" #endif /* HAL_SD_MODULE_ENABLED */ #ifdef HAL_NAND_MODULE_ENABLED #include "stm32f1xx_hal_nand.h" #endif /* HAL_NAND_MODULE_ENABLED */ #ifdef HAL_SPI_MODULE_ENABLED #include "stm32f1xx_hal_spi.h" #endif /* HAL_SPI_MODULE_ENABLED */ #ifdef HAL_TIM_MODULE_ENABLED #include "stm32f1xx_hal_tim.h" #endif /* HAL_TIM_MODULE_ENABLED */ #ifdef HAL_UART_MODULE_ENABLED #include "stm32f1xx_hal_uart.h" #endif /* HAL_UART_MODULE_ENABLED */ #ifdef HAL_USART_MODULE_ENABLED #include "stm32f1xx_hal_usart.h" #endif /* HAL_USART_MODULE_ENABLED */ #ifdef HAL_IRDA_MODULE_ENABLED #include "stm32f1xx_hal_irda.h" #endif /* HAL_IRDA_MODULE_ENABLED */ #ifdef HAL_SMARTCARD_MODULE_ENABLED #include "stm32f1xx_hal_smartcard.h" #endif /* HAL_SMARTCARD_MODULE_ENABLED */ #ifdef HAL_WWDG_MODULE_ENABLED #include "stm32f1xx_hal_wwdg.h" #endif /* HAL_WWDG_MODULE_ENABLED */ #ifdef HAL_PCD_MODULE_ENABLED #include "stm32f1xx_hal_pcd.h" #endif /* HAL_PCD_MODULE_ENABLED */ #ifdef HAL_HCD_MODULE_ENABLED #include "stm32f1xx_hal_hcd.h" #endif /* HAL_HCD_MODULE_ENABLED */ #ifdef HAL_MMC_MODULE_ENABLED #include "stm32f1xx_hal_mmc.h" #endif /* HAL_MMC_MODULE_ENABLED */ /* Exported macro ------------------------------------------------------------*/ #ifdef USE_FULL_ASSERT /** * @brief The assert_param macro is used for function's parameters check. * @param expr: If expr is false, it calls assert_failed function * which reports the name of the source file and the source * line number of the call that failed. * If expr is true, it returns no value. * @retval None */ #define assert_param(expr) ((expr) ? (void)0U : assert_failed((uint8_t *)__FILE__, __LINE__)) /* Exported functions ------------------------------------------------------- */ void assert_failed(uint8_t* file, uint32_t line); #else #define assert_param(expr) ((void)0U) #endif /* USE_FULL_ASSERT */ #ifdef __cplusplus } #endif #endif /* __STM32F1xx_HAL_CONF_H */
0
D://workCode//uploadProject\STM32CubeF1\Projects\STM3210E_EVAL\Examples\Cortex\CORTEXM_MPU
D://workCode//uploadProject\STM32CubeF1\Projects\STM3210E_EVAL\Examples\Cortex\CORTEXM_MPU\Inc\stm32f1xx_it.h
/** ****************************************************************************** * @file Cortex/CORTEXM_MPU/Inc/stm32f1xx_it.h * @author MCD Application Team * @brief This file contains the headers of the interrupt handlers. ****************************************************************************** * @attention * * Copyright (c) 2016 STMicroelectronics. * All rights reserved. * * This software is licensed under terms that can be found in the LICENSE file * in the root directory of this software component. * If no LICENSE file comes with this software, it is provided AS-IS. * ****************************************************************************** */ /* Define to prevent recursive inclusion -------------------------------------*/ #ifndef __STM32F1xx_IT_H #define __STM32F1xx_IT_H #ifdef __cplusplus extern "C" { #endif /* Includes ------------------------------------------------------------------*/ /* Exported types ------------------------------------------------------------*/ /* Exported constants --------------------------------------------------------*/ /* Exported macro ------------------------------------------------------------*/ /* Exported functions ------------------------------------------------------- */ void NMI_Handler(void); void HardFault_Handler(void); void MemManage_Handler(void); void BusFault_Handler(void); void UsageFault_Handler(void); void SVC_Handler(void); void DebugMon_Handler(void); void PendSV_Handler(void); void SysTick_Handler(void); #ifdef __cplusplus } #endif #endif /* __STM32F1xx_IT_H */
0
D://workCode//uploadProject\STM32CubeF1\Projects\STM3210E_EVAL\Examples\Cortex\CORTEXM_MPU
D://workCode//uploadProject\STM32CubeF1\Projects\STM3210E_EVAL\Examples\Cortex\CORTEXM_MPU\Inc\stm32_mpu.h
/** ****************************************************************************** * @file Cortex/CORTEXM_MPU/Inc/stm32_mpu.h * @author MCD Application Team * @brief Header for stm32_mpu.c module ****************************************************************************** * @attention * * Copyright (c) 2016 STMicroelectronics. * All rights reserved. * * This software is licensed under terms that can be found in the LICENSE file * in the root directory of this software component. * If no LICENSE file comes with this software, it is provided AS-IS. * ****************************************************************************** */ /* Define to prevent recursive inclusion -------------------------------------*/ #ifndef __STM32_MPU_H #define __STM32_MPU_H /* Includes ------------------------------------------------------------------*/ #include "stm32f1xx.h" /* Exported types ------------------------------------------------------------*/ /* Exported constants --------------------------------------------------------*/ #define RAM_ADDRESS_START (0x20000000UL) #define RAM_SIZE MPU_REGION_SIZE_128KB #define PERIPH_ADDRESS_START (0x40000000) #define PERIPH_SIZE MPU_REGION_SIZE_512KB #define FLASH_ADDRESS_START (0x08000000) #define FLASH_SIZE MPU_REGION_SIZE_1MB #define portMPU_REGION_READ_WRITE MPU_REGION_FULL_ACCESS #define portMPU_REGION_PRIVILEGED_READ_ONLY MPU_REGION_PRIV_RO #define portMPU_REGION_READ_ONLY MPU_REGION_PRIV_RO_URO #define portMPU_REGION_PRIVILEGED_READ_WRITE MPU_REGION_PRIV_RW #define RAM_REGION_NUMBER MPU_REGION_NUMBER0 #define FLASH_REGION_NUMBER MPU_REGION_NUMBER1 #define PERIPH_REGION_NUMBER MPU_REGION_NUMBER2 /* Exported macro ------------------------------------------------------------*/ /* Exported functions ------------------------------------------------------- */ void MPU_Config(void); void MPU_AccessPermConfig(void); #endif /* __STM32_MPU_H */
0
D://workCode//uploadProject\STM32CubeF1\Projects\STM3210E_EVAL\Examples\Cortex\CORTEXM_MPU
D://workCode//uploadProject\STM32CubeF1\Projects\STM3210E_EVAL\Examples\Cortex\CORTEXM_MPU\Src\main.c
/** ****************************************************************************** * @file Cortex/CORTEXM_MPU/Src/main.c * @author MCD Application Team * @brief This example describes how to use Polling mode to convert data. ****************************************************************************** * @attention * * Copyright (c) 2016 STMicroelectronics. * All rights reserved. * * This software is licensed under terms that can be found in the LICENSE file * in the root directory of this software component. * If no LICENSE file comes with this software, it is provided AS-IS. * ****************************************************************************** */ /* Includes ------------------------------------------------------------------*/ #include "main.h" /** @addtogroup STM32F1xx_HAL_Examples * @{ */ /** @addtogroup CORTEXM_MPU * @{ */ /* Private typedef -----------------------------------------------------------*/ /* Private define ------------------------------------------------------------*/ #define ACCESS_PERMISSION /* Private macro -------------------------------------------------------------*/ /* Private variables ---------------------------------------------------------*/ /* Private function prototypes -----------------------------------------------*/ void SystemClock_Config(void); /* Private functions ---------------------------------------------------------*/ /** * @brief Main program. * @param None * @retval None */ int main(void) { /* STM32F103xG HAL library initialization: - Configure the Flash prefetch - Systick timer is configured by default as source of time base, but user can eventually implement his proper time base source (a general purpose timer for example or other time source), keeping in mind that Time base duration should be kept 1ms since PPP_TIMEOUT_VALUEs are defined and handled in milliseconds basis. - Set NVIC Group Priority to 4 - Low Level Initialization */ HAL_Init(); /* Configure the system clock to 72 MHz */ SystemClock_Config(); /* Configure LED1 and LED2 */ BSP_LED_Init(LED1); BSP_LED_Init(LED2); /* Set MPU regions */ MPU_Config(); #ifdef ACCESS_PERMISSION MPU_AccessPermConfig(); #endif /* Infinite loop */ while (1) { /* Toggle LED1 */ BSP_LED_Toggle(LED1); /* Insert a delay */ HAL_Delay(100); } } /** * @brief System Clock Configuration * The system Clock is configured as follow : * System Clock source = PLL (HSE) * SYSCLK(Hz) = 72000000 * HCLK(Hz) = 72000000 * AHB Prescaler = 1 * APB1 Prescaler = 2 * APB2 Prescaler = 1 * HSE Frequency(Hz) = 8000000 * HSE PREDIV1 = 1 * PLLMUL = 9 * Flash Latency(WS) = 2 * @param None * @retval None */ void SystemClock_Config(void) { RCC_ClkInitTypeDef clkinitstruct = {0}; RCC_OscInitTypeDef oscinitstruct = {0}; /* Enable HSE Oscillator and activate PLL with HSE as source */ oscinitstruct.OscillatorType = RCC_OSCILLATORTYPE_HSE; oscinitstruct.HSEState = RCC_HSE_ON; oscinitstruct.HSEPredivValue = RCC_HSE_PREDIV_DIV1; oscinitstruct.PLL.PLLState = RCC_PLL_ON; oscinitstruct.PLL.PLLSource = RCC_PLLSOURCE_HSE; oscinitstruct.PLL.PLLMUL = RCC_PLL_MUL9; if (HAL_RCC_OscConfig(&oscinitstruct)!= HAL_OK) { /* Initialization Error */ while(1); } /* Select PLL as system clock source and configure the HCLK, PCLK1 and PCLK2 clocks dividers */ clkinitstruct.ClockType = (RCC_CLOCKTYPE_SYSCLK | RCC_CLOCKTYPE_HCLK | RCC_CLOCKTYPE_PCLK1 | RCC_CLOCKTYPE_PCLK2); clkinitstruct.SYSCLKSource = RCC_SYSCLKSOURCE_PLLCLK; clkinitstruct.AHBCLKDivider = RCC_SYSCLK_DIV1; clkinitstruct.APB2CLKDivider = RCC_HCLK_DIV1; clkinitstruct.APB1CLKDivider = RCC_HCLK_DIV2; if (HAL_RCC_ClockConfig(&clkinitstruct, FLASH_LATENCY_2)!= HAL_OK) { /* Initialization Error */ while(1); } } #ifdef USE_FULL_ASSERT /** * @brief Reports the name of the source file and the source line number * where the assert_param error has occurred. * @param file: pointer to the source file name * @param line: assert_param error line source number * @retval None */ void assert_failed(uint8_t *file, uint32_t line) { /* User can add his own implementation to report the file name and line number, ex: printf("Wrong parameters value: file %s on line %d\r\n", file, line) */ /* Infinite loop */ while (1) { } } #endif /** * @} */ /** * @} */
0
D://workCode//uploadProject\STM32CubeF1\Projects\STM3210E_EVAL\Examples\Cortex\CORTEXM_MPU
D://workCode//uploadProject\STM32CubeF1\Projects\STM3210E_EVAL\Examples\Cortex\CORTEXM_MPU\Src\stm32f1xx_it.c
/** ****************************************************************************** * @file Cortex/CORTEXM_MPU/Src/stm32f1xx_it.c * @author MCD Application Team * @brief Main Interrupt Service Routines. * This file provides template for all exceptions handler and * peripherals interrupt service routine. ****************************************************************************** * @attention * * Copyright (c) 2016 STMicroelectronics. * All rights reserved. * * This software is licensed under terms that can be found in the LICENSE file * in the root directory of this software component. * If no LICENSE file comes with this software, it is provided AS-IS. * ****************************************************************************** */ /* Includes ------------------------------------------------------------------*/ #include "main.h" #include "stm32f1xx_it.h" /** @addtogroup STM32F1xx_HAL_Examples * @{ */ /** @addtogroup CORTEXM_MPU * @{ */ /* Private typedef -----------------------------------------------------------*/ /* Private define ------------------------------------------------------------*/ /* Private macro -------------------------------------------------------------*/ /* Private variables ---------------------------------------------------------*/ /* Private function prototypes -----------------------------------------------*/ /* Private functions ---------------------------------------------------------*/ /******************************************************************************/ /* Cortex-M3 Processor Exceptions Handlers */ /******************************************************************************/ /** * @brief This function handles NMI exception. * @param None * @retval None */ void NMI_Handler(void) { } /** * @brief This function handles Hard Fault exception. * @param None * @retval None */ void HardFault_Handler(void) { /* Go to infinite loop when Hard Fault exception occurs */ while (1) { } } /** * @brief This function handles Memory Manage exception. * @param None * @retval None */ void MemManage_Handler(void) { /* Turn on LED2 */ BSP_LED_On(LED2); /* Go to infinite loop when Memory Manage exception occurs */ while (1) { } } /** * @brief This function handles Bus Fault exception. * @param None * @retval None */ void BusFault_Handler(void) { /* Go to infinite loop when Bus Fault exception occurs */ while (1) { } } /** * @brief This function handles Usage Fault exception. * @param None * @retval None */ void UsageFault_Handler(void) { /* Go to infinite loop when Usage Fault exception occurs */ while (1) { } } /** * @brief This function handles SVCall exception. * @param None * @retval None */ void SVC_Handler(void) { } /** * @brief This function handles Debug Monitor exception. * @param None * @retval None */ void DebugMon_Handler(void) { } /** * @brief This function handles PendSVC exception. * @param None * @retval None */ void PendSV_Handler(void) { } /** * @brief This function handles SysTick Handler. * @param None * @retval None */ void SysTick_Handler(void) { HAL_IncTick(); } /******************************************************************************/ /* STM32F1xx Peripherals Interrupt Handlers */ /* Add here the Interrupt Handler for the used peripheral(s) (PPP), for the */ /* available peripheral interrupt handler's name please refer to the startup */ /* file (startup_stm32f1xx.s). */ /******************************************************************************/ /** * @brief This function handles PPP interrupt request. * @param None * @retval None */ /*void PPP_IRQHandler(void) { }*/ /** * @} */
0
D://workCode//uploadProject\STM32CubeF1\Projects\STM3210E_EVAL\Examples\Cortex\CORTEXM_MPU
D://workCode//uploadProject\STM32CubeF1\Projects\STM3210E_EVAL\Examples\Cortex\CORTEXM_MPU\Src\system_stm32f1xx.c
/** ****************************************************************************** * @file system_stm32f1xx.c * @author MCD Application Team * @brief CMSIS Cortex-M3 Device Peripheral Access Layer System Source File. * * 1. This file provides two functions and one global variable to be called from * user application: * - SystemInit(): Setups the system clock (System clock source, PLL Multiplier * factors, AHB/APBx prescalers and Flash settings). * This function is called at startup just after reset and * before branch to main program. This call is made inside * the "startup_stm32f1xx_xx.s" file. * * - SystemCoreClock variable: Contains the core clock (HCLK), it can be used * by the user application to setup the SysTick * timer or configure other parameters. * * - SystemCoreClockUpdate(): Updates the variable SystemCoreClock and must * be called whenever the core clock is changed * during program execution. * * 2. After each device reset the HSI (8 MHz) is used as system clock source. * Then SystemInit() function is called, in "startup_stm32f1xx_xx.s" file, to * configure the system clock before to branch to main program. * * 4. The default value of HSE crystal is set to 8 MHz (or 25 MHz, depending on * the product used), refer to "HSE_VALUE". * When HSE is used as system clock source, directly or through PLL, and you * are using different crystal you have to adapt the HSE value to your own * configuration. * ****************************************************************************** * @attention * * Copyright (c) 2016 STMicroelectronics. * All rights reserved. * * This software is licensed under terms that can be found in the LICENSE file * in the root directory of this software component. * If no LICENSE file comes with this software, it is provided AS-IS. * ****************************************************************************** */ /** @addtogroup CMSIS * @{ */ /** @addtogroup stm32f1xx_system * @{ */ /** @addtogroup STM32F1xx_System_Private_Includes * @{ */ #include "stm32f1xx.h" /** * @} */ /** @addtogroup STM32F1xx_System_Private_TypesDefinitions * @{ */ /** * @} */ /** @addtogroup STM32F1xx_System_Private_Defines * @{ */ #if !defined (HSE_VALUE) #define HSE_VALUE ((uint32_t)8000000) /*!< Default value of the External oscillator in Hz. This value can be provided and adapted by the user application. */ #endif /* HSE_VALUE */ #if !defined (HSI_VALUE) #define HSI_VALUE ((uint32_t)8000000) /*!< Default value of the Internal oscillator in Hz. This value can be provided and adapted by the user application. */ #endif /* HSI_VALUE */ /*!< Uncomment the following line if you need to use external SRAM */ #if defined(STM32F100xE) || defined(STM32F101xE) || defined(STM32F101xG) || defined(STM32F103xE) || defined(STM32F103xG) /* #define DATA_IN_ExtSRAM */ #endif /* STM32F100xE || STM32F101xE || STM32F101xG || STM32F103xE || STM32F103xG */ /*!< Uncomment the following line if you need to relocate your vector Table in Internal SRAM. */ /* #define VECT_TAB_SRAM */ #define VECT_TAB_OFFSET 0x0 /*!< Vector Table base offset field. This value must be a multiple of 0x200. */ /** * @} */ /** @addtogroup STM32F1xx_System_Private_Macros * @{ */ /** * @} */ /** @addtogroup STM32F1xx_System_Private_Variables * @{ */ /* This variable is updated in three ways: 1) by calling CMSIS function SystemCoreClockUpdate() 2) by calling HAL API function HAL_RCC_GetHCLKFreq() 3) each time HAL_RCC_ClockConfig() is called to configure the system clock frequency Note: If you use this function to configure the system clock; then there is no need to call the 2 first functions listed above, since SystemCoreClock variable is updated automatically. */ uint32_t SystemCoreClock = 16000000; const uint8_t AHBPrescTable[16] = {0, 0, 0, 0, 0, 0, 0, 0, 1, 2, 3, 4, 6, 7, 8, 9}; const uint8_t APBPrescTable[8] = {0, 0, 0, 0, 1, 2, 3, 4}; /** * @} */ /** @addtogroup STM32F1xx_System_Private_FunctionPrototypes * @{ */ #if defined(STM32F100xE) || defined(STM32F101xE) || defined(STM32F101xG) || defined(STM32F103xE) || defined(STM32F103xG) #ifdef DATA_IN_ExtSRAM static void SystemInit_ExtMemCtl(void); #endif /* DATA_IN_ExtSRAM */ #endif /* STM32F100xE || STM32F101xE || STM32F101xG || STM32F103xE || STM32F103xG */ /** * @} */ /** @addtogroup STM32F1xx_System_Private_Functions * @{ */ /** * @brief Setup the microcontroller system * Initialize the Embedded Flash Interface, the PLL and update the * SystemCoreClock variable. * @note This function should be used only after reset. * @param None * @retval None */ void SystemInit (void) { /* Reset the RCC clock configuration to the default reset state(for debug purpose) */ /* Set HSION bit */ RCC->CR |= (uint32_t)0x00000001; /* Reset SW, HPRE, PPRE1, PPRE2, ADCPRE and MCO bits */ #if !defined(STM32F105xC) && !defined(STM32F107xC) RCC->CFGR &= (uint32_t)0xF8FF0000; #else RCC->CFGR &= (uint32_t)0xF0FF0000; #endif /* STM32F105xC */ /* Reset HSEON, CSSON and PLLON bits */ RCC->CR &= (uint32_t)0xFEF6FFFF; /* Reset HSEBYP bit */ RCC->CR &= (uint32_t)0xFFFBFFFF; /* Reset PLLSRC, PLLXTPRE, PLLMUL and USBPRE/OTGFSPRE bits */ RCC->CFGR &= (uint32_t)0xFF80FFFF; #if defined(STM32F105xC) || defined(STM32F107xC) /* Reset PLL2ON and PLL3ON bits */ RCC->CR &= (uint32_t)0xEBFFFFFF; /* Disable all interrupts and clear pending bits */ RCC->CIR = 0x00FF0000; /* Reset CFGR2 register */ RCC->CFGR2 = 0x00000000; #elif defined(STM32F100xB) || defined(STM32F100xE) /* Disable all interrupts and clear pending bits */ RCC->CIR = 0x009F0000; /* Reset CFGR2 register */ RCC->CFGR2 = 0x00000000; #else /* Disable all interrupts and clear pending bits */ RCC->CIR = 0x009F0000; #endif /* STM32F105xC */ #if defined(STM32F100xE) || defined(STM32F101xE) || defined(STM32F101xG) || defined(STM32F103xE) || defined(STM32F103xG) #ifdef DATA_IN_ExtSRAM SystemInit_ExtMemCtl(); #endif /* DATA_IN_ExtSRAM */ #endif #ifdef VECT_TAB_SRAM SCB->VTOR = SRAM_BASE | VECT_TAB_OFFSET; /* Vector Table Relocation in Internal SRAM. */ #else SCB->VTOR = FLASH_BASE | VECT_TAB_OFFSET; /* Vector Table Relocation in Internal FLASH. */ #endif } /** * @brief Update SystemCoreClock variable according to Clock Register Values. * The SystemCoreClock variable contains the core clock (HCLK), it can * be used by the user application to setup the SysTick timer or configure * other parameters. * * @note Each time the core clock (HCLK) changes, this function must be called * to update SystemCoreClock variable value. Otherwise, any configuration * based on this variable will be incorrect. * * @note - The system frequency computed by this function is not the real * frequency in the chip. It is calculated based on the predefined * constant and the selected clock source: * * - If SYSCLK source is HSI, SystemCoreClock will contain the HSI_VALUE(*) * * - If SYSCLK source is HSE, SystemCoreClock will contain the HSE_VALUE(**) * * - If SYSCLK source is PLL, SystemCoreClock will contain the HSE_VALUE(**) * or HSI_VALUE(*) multiplied by the PLL factors. * * (*) HSI_VALUE is a constant defined in stm32f1xx.h file (default value * 8 MHz) but the real value may vary depending on the variations * in voltage and temperature. * * (**) HSE_VALUE is a constant defined in stm32f1xx.h file (default value * 8 MHz or 25 MHz, depending on the product used), user has to ensure * that HSE_VALUE is same as the real frequency of the crystal used. * Otherwise, this function may have wrong result. * * - The result of this function could be not correct when using fractional * value for HSE crystal. * @param None * @retval None */ void SystemCoreClockUpdate (void) { uint32_t tmp = 0, pllmull = 0, pllsource = 0; #if defined(STM32F105xC) || defined(STM32F107xC) uint32_t prediv1source = 0, prediv1factor = 0, prediv2factor = 0, pll2mull = 0; #endif /* STM32F105xC */ #if defined(STM32F100xB) || defined(STM32F100xE) uint32_t prediv1factor = 0; #endif /* STM32F100xB or STM32F100xE */ /* Get SYSCLK source -------------------------------------------------------*/ tmp = RCC->CFGR & RCC_CFGR_SWS; switch (tmp) { case 0x00: /* HSI used as system clock */ SystemCoreClock = HSI_VALUE; break; case 0x04: /* HSE used as system clock */ SystemCoreClock = HSE_VALUE; break; case 0x08: /* PLL used as system clock */ /* Get PLL clock source and multiplication factor ----------------------*/ pllmull = RCC->CFGR & RCC_CFGR_PLLMULL; pllsource = RCC->CFGR & RCC_CFGR_PLLSRC; #if !defined(STM32F105xC) && !defined(STM32F107xC) pllmull = ( pllmull >> 18) + 2; if (pllsource == 0x00) { /* HSI oscillator clock divided by 2 selected as PLL clock entry */ SystemCoreClock = (HSI_VALUE >> 1) * pllmull; } else { #if defined(STM32F100xB) || defined(STM32F100xE) prediv1factor = (RCC->CFGR2 & RCC_CFGR2_PREDIV1) + 1; /* HSE oscillator clock selected as PREDIV1 clock entry */ SystemCoreClock = (HSE_VALUE / prediv1factor) * pllmull; #else /* HSE selected as PLL clock entry */ if ((RCC->CFGR & RCC_CFGR_PLLXTPRE) != (uint32_t)RESET) {/* HSE oscillator clock divided by 2 */ SystemCoreClock = (HSE_VALUE >> 1) * pllmull; } else { SystemCoreClock = HSE_VALUE * pllmull; } #endif } #else pllmull = pllmull >> 18; if (pllmull != 0x0D) { pllmull += 2; } else { /* PLL multiplication factor = PLL input clock * 6.5 */ pllmull = 13 / 2; } if (pllsource == 0x00) { /* HSI oscillator clock divided by 2 selected as PLL clock entry */ SystemCoreClock = (HSI_VALUE >> 1) * pllmull; } else {/* PREDIV1 selected as PLL clock entry */ /* Get PREDIV1 clock source and division factor */ prediv1source = RCC->CFGR2 & RCC_CFGR2_PREDIV1SRC; prediv1factor = (RCC->CFGR2 & RCC_CFGR2_PREDIV1) + 1; if (prediv1source == 0) { /* HSE oscillator clock selected as PREDIV1 clock entry */ SystemCoreClock = (HSE_VALUE / prediv1factor) * pllmull; } else {/* PLL2 clock selected as PREDIV1 clock entry */ /* Get PREDIV2 division factor and PLL2 multiplication factor */ prediv2factor = ((RCC->CFGR2 & RCC_CFGR2_PREDIV2) >> 4) + 1; pll2mull = ((RCC->CFGR2 & RCC_CFGR2_PLL2MUL) >> 8 ) + 2; SystemCoreClock = (((HSE_VALUE / prediv2factor) * pll2mull) / prediv1factor) * pllmull; } } #endif /* STM32F105xC */ break; default: SystemCoreClock = HSI_VALUE; break; } /* Compute HCLK clock frequency ----------------*/ /* Get HCLK prescaler */ tmp = AHBPrescTable[((RCC->CFGR & RCC_CFGR_HPRE) >> 4)]; /* HCLK clock frequency */ SystemCoreClock >>= tmp; } #if defined(STM32F100xE) || defined(STM32F101xE) || defined(STM32F101xG) || defined(STM32F103xE) || defined(STM32F103xG) /** * @brief Setup the external memory controller. Called in startup_stm32f1xx.s * before jump to __main * @param None * @retval None */ #ifdef DATA_IN_ExtSRAM /** * @brief Setup the external memory controller. * Called in startup_stm32f1xx_xx.s/.c before jump to main. * This function configures the external SRAM mounted on STM3210E-EVAL * board (STM32 High density devices). This SRAM will be used as program * data memory (including heap and stack). * @param None * @retval None */ void SystemInit_ExtMemCtl(void) { __IO uint32_t tmpreg; /*!< FSMC Bank1 NOR/SRAM3 is used for the STM3210E-EVAL, if another Bank is required, then adjust the Register Addresses */ /* Enable FSMC clock */ RCC->AHBENR = 0x00000114; /* Delay after an RCC peripheral clock enabling */ tmpreg = READ_BIT(RCC->AHBENR, RCC_AHBENR_FSMCEN); /* Enable GPIOD, GPIOE, GPIOF and GPIOG clocks */ RCC->APB2ENR = 0x000001E0; /* Delay after an RCC peripheral clock enabling */ tmpreg = READ_BIT(RCC->APB2ENR, RCC_APB2ENR_IOPDEN); (void)(tmpreg); /* --------------- SRAM Data lines, NOE and NWE configuration ---------------*/ /*---------------- SRAM Address lines configuration -------------------------*/ /*---------------- NOE and NWE configuration --------------------------------*/ /*---------------- NE3 configuration ----------------------------------------*/ /*---------------- NBL0, NBL1 configuration ---------------------------------*/ GPIOD->CRL = 0x44BB44BB; GPIOD->CRH = 0xBBBBBBBB; GPIOE->CRL = 0xB44444BB; GPIOE->CRH = 0xBBBBBBBB; GPIOF->CRL = 0x44BBBBBB; GPIOF->CRH = 0xBBBB4444; GPIOG->CRL = 0x44BBBBBB; GPIOG->CRH = 0x444B4B44; /*---------------- FSMC Configuration ---------------------------------------*/ /*---------------- Enable FSMC Bank1_SRAM Bank ------------------------------*/ FSMC_Bank1->BTCR[4] = 0x00001091; FSMC_Bank1->BTCR[5] = 0x00110212; } #endif /* DATA_IN_ExtSRAM */ #endif /* STM32F100xE || STM32F101xE || STM32F101xG || STM32F103xE || STM32F103xG */ /** * @} */ /** * @} */ /** * @} */
0
D://workCode//uploadProject\STM32CubeF1\Projects\STM3210E_EVAL\Examples\Cortex\CORTEXM_SysTick
D://workCode//uploadProject\STM32CubeF1\Projects\STM3210E_EVAL\Examples\Cortex\CORTEXM_SysTick\Inc\main.h
/** ****************************************************************************** * @file Cortex/CORTEXM_SysTick/Inc/main.h * @author MCD Application Team * @brief Header for main.c module ****************************************************************************** * @attention * * Copyright (c) 2016 STMicroelectronics. * All rights reserved. * * This software is licensed under terms that can be found in the LICENSE file * in the root directory of this software component. * If no LICENSE file comes with this software, it is provided AS-IS. * ****************************************************************************** */ /* Define to prevent recursive inclusion -------------------------------------*/ #ifndef __MAIN_H #define __MAIN_H /* Includes ------------------------------------------------------------------*/ #include "stm32f1xx_hal.h" #include "stm3210e_eval.h" /* Exported types ------------------------------------------------------------*/ /* Exported constants --------------------------------------------------------*/ /* Exported macro ------------------------------------------------------------*/ /* Exported functions ------------------------------------------------------- */ #endif /* __MAIN_H */
0
D://workCode//uploadProject\STM32CubeF1\Projects\STM3210E_EVAL\Examples\Cortex\CORTEXM_SysTick
D://workCode//uploadProject\STM32CubeF1\Projects\STM3210E_EVAL\Examples\Cortex\CORTEXM_SysTick\Inc\stm32f1xx_hal_conf.h
/** ****************************************************************************** * @file stm32f1xx_hal_conf.h * @author MCD Application Team * @brief HAL configuration file. ****************************************************************************** * @attention * * Copyright (c) 2016 STMicroelectronics. * All rights reserved. * * This software is licensed under terms that can be found in the LICENSE file * in the root directory of this software component. * If no LICENSE file comes with this software, it is provided AS-IS. * ****************************************************************************** */ /* Define to prevent recursive inclusion -------------------------------------*/ #ifndef __STM32F1xx_HAL_CONF_H #define __STM32F1xx_HAL_CONF_H #ifdef __cplusplus extern "C" { #endif /* Exported types ------------------------------------------------------------*/ /* Exported constants --------------------------------------------------------*/ /* ########################## Module Selection ############################## */ /** * @brief This is the list of modules to be used in the HAL driver */ #define HAL_MODULE_ENABLED /* #define HAL_ADC_MODULE_ENABLED */ /* #define HAL_CAN_MODULE_ENABLED */ /* #define HAL_CAN_LEGACY_MODULE_ENABLED */ /* #define HAL_CEC_MODULE_ENABLED */ #define HAL_CORTEX_MODULE_ENABLED /* #define HAL_CRC_MODULE_ENABLED */ /* #define HAL_DAC_MODULE_ENABLED */ /* #define HAL_DMA_MODULE_ENABLED */ /* #define HAL_ETH_MODULE_ENABLED */ /* #define HAL_EXTI_MODULE_ENABLED */ #define HAL_FLASH_MODULE_ENABLED #define HAL_GPIO_MODULE_ENABLED /* #define HAL_HCD_MODULE_ENABLED */ /* #define HAL_I2C_MODULE_ENABLED */ /* #define HAL_I2S_MODULE_ENABLED */ /* #define HAL_IRDA_MODULE_ENABLED */ /* #define HAL_IWDG_MODULE_ENABLED */ /* #define HAL_NAND_MODULE_ENABLED */ /* #define HAL_NOR_MODULE_ENABLED */ /* #define HAL_PCCARD_MODULE_ENABLED */ /* #define HAL_PCD_MODULE_ENABLED */ #define HAL_PWR_MODULE_ENABLED #define HAL_RCC_MODULE_ENABLED /* #define HAL_RTC_MODULE_ENABLED */ /* #define HAL_SD_MODULE_ENABLED */ /* #define HAL_SMARTCARD_MODULE_ENABLED */ /* #define HAL_SPI_MODULE_ENABLED */ /* #define HAL_SRAM_MODULE_ENABLED */ /* #define HAL_TIM_MODULE_ENABLED */ /* #define HAL_UART_MODULE_ENABLED */ /* #define HAL_USART_MODULE_ENABLED */ /* #define HAL_WWDG_MODULE_ENABLED */ /* #define HAL_MMC_MODULE_ENABLED */ /* ########################## Oscillator Values adaptation ####################*/ /** * @brief Adjust the value of External High Speed oscillator (HSE) used in your application. * This value is used by the RCC HAL module to compute the system frequency * (when HSE is used as system clock source, directly or through the PLL). */ #if !defined (HSE_VALUE) #if defined(USE_STM3210C_EVAL) #define HSE_VALUE 25000000U /*!< Value of the External oscillator in Hz */ #else #define HSE_VALUE 8000000U /*!< Value of the External oscillator in Hz */ #endif #endif /* HSE_VALUE */ #if !defined (HSE_STARTUP_TIMEOUT) #define HSE_STARTUP_TIMEOUT 100U /*!< Time out for HSE start up, in ms */ #endif /* HSE_STARTUP_TIMEOUT */ /** * @brief Internal High Speed oscillator (HSI) value. * This value is used by the RCC HAL module to compute the system frequency * (when HSI is used as system clock source, directly or through the PLL). */ #if !defined (HSI_VALUE) #define HSI_VALUE 8000000U /*!< Value of the Internal oscillator in Hz */ #endif /* HSI_VALUE */ /** * @brief Internal Low Speed oscillator (LSI) value. */ #if !defined (LSI_VALUE) #define LSI_VALUE 40000U /*!< LSI Typical Value in Hz */ #endif /* LSI_VALUE */ /*!< Value of the Internal Low Speed oscillator in Hz The real value may vary depending on the variations in voltage and temperature. */ /** * @brief External Low Speed oscillator (LSE) value. * This value is used by the UART, RTC HAL module to compute the system frequency */ #if !defined (LSE_VALUE) #define LSE_VALUE 32768U /*!< Value of the External oscillator in Hz*/ #endif /* LSE_VALUE */ #if !defined (LSE_STARTUP_TIMEOUT) #define LSE_STARTUP_TIMEOUT 5000U /*!< Time out for LSE start up, in ms */ #endif /* LSE_STARTUP_TIMEOUT */ /* Tip: To avoid modifying this file each time you need to use different HSE, === you can define the HSE value in your toolchain compiler preprocessor. */ /* ########################### System Configuration ######################### */ /** * @brief This is the HAL system configuration section */ #define VDD_VALUE 3300U /*!< Value of VDD in mv */ #define TICK_INT_PRIORITY 0x0FU /*!< tick interrupt priority */ #define USE_RTOS 0U #define PREFETCH_ENABLE 1U #define USE_HAL_ADC_REGISTER_CALLBACKS 0U /* ADC register callback disabled */ #define USE_HAL_CAN_REGISTER_CALLBACKS 0U /* CAN register callback disabled */ #define USE_HAL_CEC_REGISTER_CALLBACKS 0U /* CEC register callback disabled */ #define USE_HAL_DAC_REGISTER_CALLBACKS 0U /* DAC register callback disabled */ #define USE_HAL_ETH_REGISTER_CALLBACKS 0U /* ETH register callback disabled */ #define USE_HAL_HCD_REGISTER_CALLBACKS 0U /* HCD register callback disabled */ #define USE_HAL_I2C_REGISTER_CALLBACKS 0U /* I2C register callback disabled */ #define USE_HAL_I2S_REGISTER_CALLBACKS 0U /* I2S register callback disabled */ #define USE_HAL_MMC_REGISTER_CALLBACKS 0U /* MMC register callback disabled */ #define USE_HAL_NAND_REGISTER_CALLBACKS 0U /* NAND register callback disabled */ #define USE_HAL_NOR_REGISTER_CALLBACKS 0U /* NOR register callback disabled */ #define USE_HAL_PCCARD_REGISTER_CALLBACKS 0U /* PCCARD register callback disabled */ #define USE_HAL_PCD_REGISTER_CALLBACKS 0U /* PCD register callback disabled */ #define USE_HAL_RTC_REGISTER_CALLBACKS 0U /* RTC register callback disabled */ #define USE_HAL_SD_REGISTER_CALLBACKS 0U /* SD register callback disabled */ #define USE_HAL_SMARTCARD_REGISTER_CALLBACKS 0U /* SMARTCARD register callback disabled */ #define USE_HAL_IRDA_REGISTER_CALLBACKS 0U /* IRDA register callback disabled */ #define USE_HAL_SRAM_REGISTER_CALLBACKS 0U /* SRAM register callback disabled */ #define USE_HAL_SPI_REGISTER_CALLBACKS 0U /* SPI register callback disabled */ #define USE_HAL_TIM_REGISTER_CALLBACKS 0U /* TIM register callback disabled */ #define USE_HAL_UART_REGISTER_CALLBACKS 0U /* UART register callback disabled */ #define USE_HAL_USART_REGISTER_CALLBACKS 0U /* USART register callback disabled */ #define USE_HAL_WWDG_REGISTER_CALLBACKS 0U /* WWDG register callback disabled */ /* ########################## Assert Selection ############################## */ /** * @brief Uncomment the line below to expanse the "assert_param" macro in the * HAL drivers code */ /* #define USE_FULL_ASSERT 1U */ /* ################## Ethernet peripheral configuration ##################### */ /* Section 1 : Ethernet peripheral configuration */ /* MAC ADDRESS: MAC_ADDR0:MAC_ADDR1:MAC_ADDR2:MAC_ADDR3:MAC_ADDR4:MAC_ADDR5 */ #define MAC_ADDR0 2U #define MAC_ADDR1 0U #define MAC_ADDR2 0U #define MAC_ADDR3 0U #define MAC_ADDR4 0U #define MAC_ADDR5 0U /* Definition of the Ethernet driver buffers size and count */ #define ETH_RX_BUF_SIZE ETH_MAX_PACKET_SIZE /* buffer size for receive */ #define ETH_TX_BUF_SIZE ETH_MAX_PACKET_SIZE /* buffer size for transmit */ #define ETH_RXBUFNB 8U /* 8 Rx buffers of size ETH_RX_BUF_SIZE */ #define ETH_TXBUFNB 4U /* 4 Tx buffers of size ETH_TX_BUF_SIZE */ /* Section 2: PHY configuration section */ /* DP83848 PHY Address*/ #define DP83848_PHY_ADDRESS 0x01U /* PHY Reset delay these values are based on a 1 ms Systick interrupt*/ #define PHY_RESET_DELAY 0x000000FFU /* PHY Configuration delay */ #define PHY_CONFIG_DELAY 0x00000FFFU #define PHY_READ_TO 0x0000FFFFU #define PHY_WRITE_TO 0x0000FFFFU /* Section 3: Common PHY Registers */ #define PHY_BCR ((uint16_t)0x0000) /*!< Transceiver Basic Control Register */ #define PHY_BSR ((uint16_t)0x0001) /*!< Transceiver Basic Status Register */ #define PHY_RESET ((uint16_t)0x8000) /*!< PHY Reset */ #define PHY_LOOPBACK ((uint16_t)0x4000) /*!< Select loop-back mode */ #define PHY_FULLDUPLEX_100M ((uint16_t)0x2100) /*!< Set the full-duplex mode at 100 Mb/s */ #define PHY_HALFDUPLEX_100M ((uint16_t)0x2000) /*!< Set the half-duplex mode at 100 Mb/s */ #define PHY_FULLDUPLEX_10M ((uint16_t)0x0100) /*!< Set the full-duplex mode at 10 Mb/s */ #define PHY_HALFDUPLEX_10M ((uint16_t)0x0000) /*!< Set the half-duplex mode at 10 Mb/s */ #define PHY_AUTONEGOTIATION ((uint16_t)0x1000) /*!< Enable auto-negotiation function */ #define PHY_RESTART_AUTONEGOTIATION ((uint16_t)0x0200) /*!< Restart auto-negotiation function */ #define PHY_POWERDOWN ((uint16_t)0x0800) /*!< Select the power down mode */ #define PHY_ISOLATE ((uint16_t)0x0400) /*!< Isolate PHY from MII */ #define PHY_AUTONEGO_COMPLETE ((uint16_t)0x0020) /*!< Auto-Negotiation process completed */ #define PHY_LINKED_STATUS ((uint16_t)0x0004) /*!< Valid link established */ #define PHY_JABBER_DETECTION ((uint16_t)0x0002) /*!< Jabber condition detected */ /* Section 4: Extended PHY Registers */ #define PHY_SR ((uint16_t)0x0010) /*!< PHY status register Offset */ #define PHY_MICR ((uint16_t)0x0011) /*!< MII Interrupt Control Register */ #define PHY_MISR ((uint16_t)0x0012) /*!< MII Interrupt Status and Misc. Control Register */ #define PHY_LINK_STATUS ((uint16_t)0x0001) /*!< PHY Link mask */ #define PHY_SPEED_STATUS ((uint16_t)0x0002) /*!< PHY Speed mask */ #define PHY_DUPLEX_STATUS ((uint16_t)0x0004) /*!< PHY Duplex mask */ #define PHY_MICR_INT_EN ((uint16_t)0x0002) /*!< PHY Enable interrupts */ #define PHY_MICR_INT_OE ((uint16_t)0x0001) /*!< PHY Enable output interrupt events */ #define PHY_MISR_LINK_INT_EN ((uint16_t)0x0020) /*!< Enable Interrupt on change of link status */ #define PHY_LINK_INTERRUPT ((uint16_t)0x2000) /*!< PHY link status interrupt mask */ /* ################## SPI peripheral configuration ########################## */ /* CRC FEATURE: Use to activate CRC feature inside HAL SPI Driver * Activated: CRC code is present inside driver * Deactivated: CRC code cleaned from driver */ #define USE_SPI_CRC 1U /* Includes ------------------------------------------------------------------*/ /** * @brief Include module's header file */ #ifdef HAL_RCC_MODULE_ENABLED #include "stm32f1xx_hal_rcc.h" #endif /* HAL_RCC_MODULE_ENABLED */ #ifdef HAL_GPIO_MODULE_ENABLED #include "stm32f1xx_hal_gpio.h" #endif /* HAL_GPIO_MODULE_ENABLED */ #ifdef HAL_EXTI_MODULE_ENABLED #include "stm32f1xx_hal_exti.h" #endif /* HAL_EXTI_MODULE_ENABLED */ #ifdef HAL_DMA_MODULE_ENABLED #include "stm32f1xx_hal_dma.h" #endif /* HAL_DMA_MODULE_ENABLED */ #ifdef HAL_ETH_MODULE_ENABLED #include "stm32f1xx_hal_eth.h" #endif /* HAL_ETH_MODULE_ENABLED */ #ifdef HAL_CAN_MODULE_ENABLED #include "stm32f1xx_hal_can.h" #endif /* HAL_CAN_MODULE_ENABLED */ #ifdef HAL_CAN_LEGACY_MODULE_ENABLED #include "Legacy/stm32f1xx_hal_can_legacy.h" #endif /* HAL_CAN_LEGACY_MODULE_ENABLED */ #ifdef HAL_CEC_MODULE_ENABLED #include "stm32f1xx_hal_cec.h" #endif /* HAL_CEC_MODULE_ENABLED */ #ifdef HAL_CORTEX_MODULE_ENABLED #include "stm32f1xx_hal_cortex.h" #endif /* HAL_CORTEX_MODULE_ENABLED */ #ifdef HAL_ADC_MODULE_ENABLED #include "stm32f1xx_hal_adc.h" #endif /* HAL_ADC_MODULE_ENABLED */ #ifdef HAL_CRC_MODULE_ENABLED #include "stm32f1xx_hal_crc.h" #endif /* HAL_CRC_MODULE_ENABLED */ #ifdef HAL_DAC_MODULE_ENABLED #include "stm32f1xx_hal_dac.h" #endif /* HAL_DAC_MODULE_ENABLED */ #ifdef HAL_FLASH_MODULE_ENABLED #include "stm32f1xx_hal_flash.h" #endif /* HAL_FLASH_MODULE_ENABLED */ #ifdef HAL_SRAM_MODULE_ENABLED #include "stm32f1xx_hal_sram.h" #endif /* HAL_SRAM_MODULE_ENABLED */ #ifdef HAL_NOR_MODULE_ENABLED #include "stm32f1xx_hal_nor.h" #endif /* HAL_NOR_MODULE_ENABLED */ #ifdef HAL_I2C_MODULE_ENABLED #include "stm32f1xx_hal_i2c.h" #endif /* HAL_I2C_MODULE_ENABLED */ #ifdef HAL_I2S_MODULE_ENABLED #include "stm32f1xx_hal_i2s.h" #endif /* HAL_I2S_MODULE_ENABLED */ #ifdef HAL_IWDG_MODULE_ENABLED #include "stm32f1xx_hal_iwdg.h" #endif /* HAL_IWDG_MODULE_ENABLED */ #ifdef HAL_PWR_MODULE_ENABLED #include "stm32f1xx_hal_pwr.h" #endif /* HAL_PWR_MODULE_ENABLED */ #ifdef HAL_RTC_MODULE_ENABLED #include "stm32f1xx_hal_rtc.h" #endif /* HAL_RTC_MODULE_ENABLED */ #ifdef HAL_PCCARD_MODULE_ENABLED #include "stm32f1xx_hal_pccard.h" #endif /* HAL_PCCARD_MODULE_ENABLED */ #ifdef HAL_SD_MODULE_ENABLED #include "stm32f1xx_hal_sd.h" #endif /* HAL_SD_MODULE_ENABLED */ #ifdef HAL_NAND_MODULE_ENABLED #include "stm32f1xx_hal_nand.h" #endif /* HAL_NAND_MODULE_ENABLED */ #ifdef HAL_SPI_MODULE_ENABLED #include "stm32f1xx_hal_spi.h" #endif /* HAL_SPI_MODULE_ENABLED */ #ifdef HAL_TIM_MODULE_ENABLED #include "stm32f1xx_hal_tim.h" #endif /* HAL_TIM_MODULE_ENABLED */ #ifdef HAL_UART_MODULE_ENABLED #include "stm32f1xx_hal_uart.h" #endif /* HAL_UART_MODULE_ENABLED */ #ifdef HAL_USART_MODULE_ENABLED #include "stm32f1xx_hal_usart.h" #endif /* HAL_USART_MODULE_ENABLED */ #ifdef HAL_IRDA_MODULE_ENABLED #include "stm32f1xx_hal_irda.h" #endif /* HAL_IRDA_MODULE_ENABLED */ #ifdef HAL_SMARTCARD_MODULE_ENABLED #include "stm32f1xx_hal_smartcard.h" #endif /* HAL_SMARTCARD_MODULE_ENABLED */ #ifdef HAL_WWDG_MODULE_ENABLED #include "stm32f1xx_hal_wwdg.h" #endif /* HAL_WWDG_MODULE_ENABLED */ #ifdef HAL_PCD_MODULE_ENABLED #include "stm32f1xx_hal_pcd.h" #endif /* HAL_PCD_MODULE_ENABLED */ #ifdef HAL_HCD_MODULE_ENABLED #include "stm32f1xx_hal_hcd.h" #endif /* HAL_HCD_MODULE_ENABLED */ #ifdef HAL_MMC_MODULE_ENABLED #include "stm32f1xx_hal_mmc.h" #endif /* HAL_MMC_MODULE_ENABLED */ /* Exported macro ------------------------------------------------------------*/ #ifdef USE_FULL_ASSERT /** * @brief The assert_param macro is used for function's parameters check. * @param expr: If expr is false, it calls assert_failed function * which reports the name of the source file and the source * line number of the call that failed. * If expr is true, it returns no value. * @retval None */ #define assert_param(expr) ((expr) ? (void)0U : assert_failed((uint8_t *)__FILE__, __LINE__)) /* Exported functions ------------------------------------------------------- */ void assert_failed(uint8_t* file, uint32_t line); #else #define assert_param(expr) ((void)0U) #endif /* USE_FULL_ASSERT */ #ifdef __cplusplus } #endif #endif /* __STM32F1xx_HAL_CONF_H */
0
D://workCode//uploadProject\STM32CubeF1\Projects\STM3210E_EVAL\Examples\Cortex\CORTEXM_SysTick
D://workCode//uploadProject\STM32CubeF1\Projects\STM3210E_EVAL\Examples\Cortex\CORTEXM_SysTick\Inc\stm32f1xx_it.h
/** ****************************************************************************** * @file Cortex/CORTEXM_SysTick/Inc/stm32f1xx_it.h * @author MCD Application Team * @brief This file contains the headers of the interrupt handlers. ****************************************************************************** * @attention * * Copyright (c) 2016 STMicroelectronics. * All rights reserved. * * This software is licensed under terms that can be found in the LICENSE file * in the root directory of this software component. * If no LICENSE file comes with this software, it is provided AS-IS. * ****************************************************************************** */ /* Define to prevent recursive inclusion -------------------------------------*/ #ifndef __STM32F1xx_IT_H #define __STM32F1xx_IT_H #ifdef __cplusplus extern "C" { #endif /* Includes ------------------------------------------------------------------*/ /* Exported types ------------------------------------------------------------*/ /* Exported constants --------------------------------------------------------*/ /* Exported macro ------------------------------------------------------------*/ /* Exported functions ------------------------------------------------------- */ void NMI_Handler(void); void HardFault_Handler(void); void MemManage_Handler(void); void BusFault_Handler(void); void UsageFault_Handler(void); void SVC_Handler(void); void DebugMon_Handler(void); void PendSV_Handler(void); void SysTick_Handler(void); #ifdef __cplusplus } #endif #endif /* __STM32F1xx_IT_H */
0
D://workCode//uploadProject\STM32CubeF1\Projects\STM3210E_EVAL\Examples\Cortex\CORTEXM_SysTick
D://workCode//uploadProject\STM32CubeF1\Projects\STM3210E_EVAL\Examples\Cortex\CORTEXM_SysTick\Src\main.c
/** ****************************************************************************** * @file Cortex/CORTEXM_SysTick/Src/main.c * @author MCD Application Team * @brief This example shows how to configure the SysTick. ****************************************************************************** * @attention * * Copyright (c) 2016 STMicroelectronics. * All rights reserved. * * This software is licensed under terms that can be found in the LICENSE file * in the root directory of this software component. * If no LICENSE file comes with this software, it is provided AS-IS. * ****************************************************************************** */ /* Includes ------------------------------------------------------------------*/ #include "main.h" /** @addtogroup STM32F1xx_HAL_Examples * @{ */ /** @addtogroup CORTEXM_SysTick * @{ */ /* Private typedef -----------------------------------------------------------*/ /* Private define ------------------------------------------------------------*/ #define ACCESS_PERMISSION /* Private macro -------------------------------------------------------------*/ /* Private variables ---------------------------------------------------------*/ /* Private function prototypes -----------------------------------------------*/ void SystemClock_Config(void); /* Private functions ---------------------------------------------------------*/ /** * @brief Main program. * @param None * @retval None */ int main(void) { /* STM32F103xG HAL library initialization: - Configure the Flash prefetch - Systick timer is configured by default as source of time base, but user can eventually implement his proper time base source (a general purpose timer for example or other time source), keeping in mind that Time base duration should be kept 1ms since PPP_TIMEOUT_VALUEs are defined and handled in milliseconds basis. - Set NVIC Group Priority to 4 - Low Level Initialization */ HAL_Init(); /* Configure the system clock to 72 MHz */ SystemClock_Config(); /* Initialize LEDs */ BSP_LED_Init(LED1); BSP_LED_Init(LED2); BSP_LED_Init(LED3); BSP_LED_Init(LED4); /* Turn on LED1 and LED3 */ BSP_LED_On(LED1); BSP_LED_On(LED3); /* SysTick Timer is configured by default to generate an interrupt each 1 msec. --------------------------------------------------------------------------- 1. The configuration is done using HAL_SYSTICK_Config() located in HAL_Init(). 2. The HAL_SYSTICK_Config() function configure: - The SysTick Reload register with value passed as function parameter. - Configure the SysTick IRQ priority to the lowest value. - Reset the SysTick Counter register. - Configure the SysTick Counter clock source to be Core Clock Source (HCLK). - Enable the SysTick Interrupt. - Start the SysTick Counter. 3. The SysTick time base 1 msec is computed using the following formula: Reload Value = SysTick Counter Clock (Hz) x Desired Time base (s) - Reload Value is the parameter to be passed for SysTick_Config() function - Reload Value should not exceed 0xFFFFFF @note: Caution, the SysTick time base 1 msec must not be changed due to use of these time base by HAL driver. */ /* Infinite loop */ while (1) { /* Toggle LED2 and LED4 */ BSP_LED_Toggle(LED2); BSP_LED_Toggle(LED4); /* Insert 50 ms delay */ HAL_Delay(50); /* Toggle LED1 and LED3 */ BSP_LED_Toggle(LED1); BSP_LED_Toggle(LED3); /* Insert 100 ms delay */ HAL_Delay(100); } } /** * @brief System Clock Configuration * The system Clock is configured as follow : * System Clock source = PLL (HSE) * SYSCLK(Hz) = 72000000 * HCLK(Hz) = 72000000 * AHB Prescaler = 1 * APB1 Prescaler = 2 * APB2 Prescaler = 1 * HSE Frequency(Hz) = 8000000 * HSE PREDIV1 = 1 * PLLMUL = 9 * Flash Latency(WS) = 2 * @param None * @retval None */ void SystemClock_Config(void) { RCC_ClkInitTypeDef clkinitstruct = {0}; RCC_OscInitTypeDef oscinitstruct = {0}; /* Enable HSE Oscillator and activate PLL with HSE as source */ oscinitstruct.OscillatorType = RCC_OSCILLATORTYPE_HSE; oscinitstruct.HSEState = RCC_HSE_ON; oscinitstruct.HSEPredivValue = RCC_HSE_PREDIV_DIV1; oscinitstruct.PLL.PLLState = RCC_PLL_ON; oscinitstruct.PLL.PLLSource = RCC_PLLSOURCE_HSE; oscinitstruct.PLL.PLLMUL = RCC_PLL_MUL9; if (HAL_RCC_OscConfig(&oscinitstruct)!= HAL_OK) { /* Initialization Error */ while(1); } /* Select PLL as system clock source and configure the HCLK, PCLK1 and PCLK2 clocks dividers */ clkinitstruct.ClockType = (RCC_CLOCKTYPE_SYSCLK | RCC_CLOCKTYPE_HCLK | RCC_CLOCKTYPE_PCLK1 | RCC_CLOCKTYPE_PCLK2); clkinitstruct.SYSCLKSource = RCC_SYSCLKSOURCE_PLLCLK; clkinitstruct.AHBCLKDivider = RCC_SYSCLK_DIV1; clkinitstruct.APB2CLKDivider = RCC_HCLK_DIV1; clkinitstruct.APB1CLKDivider = RCC_HCLK_DIV2; if (HAL_RCC_ClockConfig(&clkinitstruct, FLASH_LATENCY_2)!= HAL_OK) { /* Initialization Error */ while(1); } } #ifdef USE_FULL_ASSERT /** * @brief Reports the name of the source file and the source line number * where the assert_param error has occurred. * @param file: pointer to the source file name * @param line: assert_param error line source number * @retval None */ void assert_failed(uint8_t* file, uint32_t line) { /* User can add his own implementation to report the file name and line number, ex: printf("Wrong parameters value: file %s on line %d\r\n", file, line) */ /* Infinite loop */ while (1) { } } #endif /** * @} */ /** * @} */
0
D://workCode//uploadProject\STM32CubeF1\Projects\STM3210E_EVAL\Examples\Cortex\CORTEXM_SysTick
D://workCode//uploadProject\STM32CubeF1\Projects\STM3210E_EVAL\Examples\Cortex\CORTEXM_SysTick\Src\stm32f1xx_it.c
/** ****************************************************************************** * @file Cortex/CORTEXM_SysTick/Src/stm32f1xx_it.c * @author MCD Application Team * @brief Main Interrupt Service Routines. * This file provides template for all exceptions handler and * peripherals interrupt service routine. ****************************************************************************** * @attention * * Copyright (c) 2016 STMicroelectronics. * All rights reserved. * * This software is licensed under terms that can be found in the LICENSE file * in the root directory of this software component. * If no LICENSE file comes with this software, it is provided AS-IS. * ****************************************************************************** */ /* Includes ------------------------------------------------------------------*/ #include "main.h" #include "stm32f1xx_it.h" /** @addtogroup STM32F1xx_HAL_Examples * @{ */ /** @addtogroup CORTEXM_SysTick * @{ */ /* Private typedef -----------------------------------------------------------*/ /* Private define ------------------------------------------------------------*/ /* Private macro -------------------------------------------------------------*/ /* Private variables ---------------------------------------------------------*/ /* Private function prototypes -----------------------------------------------*/ /* Private functions ---------------------------------------------------------*/ /******************************************************************************/ /* Cortex-M3 Processor Exceptions Handlers */ /******************************************************************************/ /** * @brief This function handles NMI exception. * @param None * @retval None */ void NMI_Handler(void) { } /** * @brief This function handles Hard Fault exception. * @param None * @retval None */ void HardFault_Handler(void) { /* Go to infinite loop when Hard Fault exception occurs */ while (1) { } } /** * @brief This function handles Memory Manage exception. * @param None * @retval None */ void MemManage_Handler(void) { /* Go to infinite loop when Memory Manage exception occurs */ while (1) { } } /** * @brief This function handles Bus Fault exception. * @param None * @retval None */ void BusFault_Handler(void) { /* Go to infinite loop when Bus Fault exception occurs */ while (1) { } } /** * @brief This function handles Usage Fault exception. * @param None * @retval None */ void UsageFault_Handler(void) { /* Go to infinite loop when Usage Fault exception occurs */ while (1) { } } /** * @brief This function handles SVCall exception. * @param None * @retval None */ void SVC_Handler(void) { } /** * @brief This function handles Debug Monitor exception. * @param None * @retval None */ void DebugMon_Handler(void) { } /** * @brief This function handles PendSVC exception. * @param None * @retval None */ void PendSV_Handler(void) { } /** * @brief This function handles SysTick Handler. * @param None * @retval None */ void SysTick_Handler(void) { HAL_IncTick(); } /******************************************************************************/ /* STM32F1xx Peripherals Interrupt Handlers */ /* Add here the Interrupt Handler for the used peripheral(s) (PPP), for the */ /* available peripheral interrupt handler's name please refer to the startup */ /* file (startup_stm32f1xx.s). */ /******************************************************************************/ /** * @brief This function handles PPP interrupt request. * @param None * @retval None */ /*void PPP_IRQHandler(void) { }*/ /** * @} */
0
D://workCode//uploadProject\STM32CubeF1\Projects\STM3210E_EVAL\Examples\Cortex\CORTEXM_SysTick
D://workCode//uploadProject\STM32CubeF1\Projects\STM3210E_EVAL\Examples\Cortex\CORTEXM_SysTick\Src\system_stm32f1xx.c
/** ****************************************************************************** * @file system_stm32f1xx.c * @author MCD Application Team * @brief CMSIS Cortex-M3 Device Peripheral Access Layer System Source File. * * 1. This file provides two functions and one global variable to be called from * user application: * - SystemInit(): Setups the system clock (System clock source, PLL Multiplier * factors, AHB/APBx prescalers and Flash settings). * This function is called at startup just after reset and * before branch to main program. This call is made inside * the "startup_stm32f1xx_xx.s" file. * * - SystemCoreClock variable: Contains the core clock (HCLK), it can be used * by the user application to setup the SysTick * timer or configure other parameters. * * - SystemCoreClockUpdate(): Updates the variable SystemCoreClock and must * be called whenever the core clock is changed * during program execution. * * 2. After each device reset the HSI (8 MHz) is used as system clock source. * Then SystemInit() function is called, in "startup_stm32f1xx_xx.s" file, to * configure the system clock before to branch to main program. * * 4. The default value of HSE crystal is set to 8 MHz (or 25 MHz, depending on * the product used), refer to "HSE_VALUE". * When HSE is used as system clock source, directly or through PLL, and you * are using different crystal you have to adapt the HSE value to your own * configuration. * ****************************************************************************** * @attention * * Copyright (c) 2016 STMicroelectronics. * All rights reserved. * * This software is licensed under terms that can be found in the LICENSE file * in the root directory of this software component. * If no LICENSE file comes with this software, it is provided AS-IS. * ****************************************************************************** */ /** @addtogroup CMSIS * @{ */ /** @addtogroup stm32f1xx_system * @{ */ /** @addtogroup STM32F1xx_System_Private_Includes * @{ */ #include "stm32f1xx.h" /** * @} */ /** @addtogroup STM32F1xx_System_Private_TypesDefinitions * @{ */ /** * @} */ /** @addtogroup STM32F1xx_System_Private_Defines * @{ */ #if !defined (HSE_VALUE) #define HSE_VALUE ((uint32_t)8000000) /*!< Default value of the External oscillator in Hz. This value can be provided and adapted by the user application. */ #endif /* HSE_VALUE */ #if !defined (HSI_VALUE) #define HSI_VALUE ((uint32_t)8000000) /*!< Default value of the Internal oscillator in Hz. This value can be provided and adapted by the user application. */ #endif /* HSI_VALUE */ /*!< Uncomment the following line if you need to use external SRAM */ #if defined(STM32F100xE) || defined(STM32F101xE) || defined(STM32F101xG) || defined(STM32F103xE) || defined(STM32F103xG) /* #define DATA_IN_ExtSRAM */ #endif /* STM32F100xE || STM32F101xE || STM32F101xG || STM32F103xE || STM32F103xG */ /*!< Uncomment the following line if you need to relocate your vector Table in Internal SRAM. */ /* #define VECT_TAB_SRAM */ #define VECT_TAB_OFFSET 0x0 /*!< Vector Table base offset field. This value must be a multiple of 0x200. */ /** * @} */ /** @addtogroup STM32F1xx_System_Private_Macros * @{ */ /** * @} */ /** @addtogroup STM32F1xx_System_Private_Variables * @{ */ /* This variable is updated in three ways: 1) by calling CMSIS function SystemCoreClockUpdate() 2) by calling HAL API function HAL_RCC_GetHCLKFreq() 3) each time HAL_RCC_ClockConfig() is called to configure the system clock frequency Note: If you use this function to configure the system clock; then there is no need to call the 2 first functions listed above, since SystemCoreClock variable is updated automatically. */ uint32_t SystemCoreClock = 16000000; const uint8_t AHBPrescTable[16] = {0, 0, 0, 0, 0, 0, 0, 0, 1, 2, 3, 4, 6, 7, 8, 9}; const uint8_t APBPrescTable[8] = {0, 0, 0, 0, 1, 2, 3, 4}; /** * @} */ /** @addtogroup STM32F1xx_System_Private_FunctionPrototypes * @{ */ #if defined(STM32F100xE) || defined(STM32F101xE) || defined(STM32F101xG) || defined(STM32F103xE) || defined(STM32F103xG) #ifdef DATA_IN_ExtSRAM static void SystemInit_ExtMemCtl(void); #endif /* DATA_IN_ExtSRAM */ #endif /* STM32F100xE || STM32F101xE || STM32F101xG || STM32F103xE || STM32F103xG */ /** * @} */ /** @addtogroup STM32F1xx_System_Private_Functions * @{ */ /** * @brief Setup the microcontroller system * Initialize the Embedded Flash Interface, the PLL and update the * SystemCoreClock variable. * @note This function should be used only after reset. * @param None * @retval None */ void SystemInit (void) { /* Reset the RCC clock configuration to the default reset state(for debug purpose) */ /* Set HSION bit */ RCC->CR |= (uint32_t)0x00000001; /* Reset SW, HPRE, PPRE1, PPRE2, ADCPRE and MCO bits */ #if !defined(STM32F105xC) && !defined(STM32F107xC) RCC->CFGR &= (uint32_t)0xF8FF0000; #else RCC->CFGR &= (uint32_t)0xF0FF0000; #endif /* STM32F105xC */ /* Reset HSEON, CSSON and PLLON bits */ RCC->CR &= (uint32_t)0xFEF6FFFF; /* Reset HSEBYP bit */ RCC->CR &= (uint32_t)0xFFFBFFFF; /* Reset PLLSRC, PLLXTPRE, PLLMUL and USBPRE/OTGFSPRE bits */ RCC->CFGR &= (uint32_t)0xFF80FFFF; #if defined(STM32F105xC) || defined(STM32F107xC) /* Reset PLL2ON and PLL3ON bits */ RCC->CR &= (uint32_t)0xEBFFFFFF; /* Disable all interrupts and clear pending bits */ RCC->CIR = 0x00FF0000; /* Reset CFGR2 register */ RCC->CFGR2 = 0x00000000; #elif defined(STM32F100xB) || defined(STM32F100xE) /* Disable all interrupts and clear pending bits */ RCC->CIR = 0x009F0000; /* Reset CFGR2 register */ RCC->CFGR2 = 0x00000000; #else /* Disable all interrupts and clear pending bits */ RCC->CIR = 0x009F0000; #endif /* STM32F105xC */ #if defined(STM32F100xE) || defined(STM32F101xE) || defined(STM32F101xG) || defined(STM32F103xE) || defined(STM32F103xG) #ifdef DATA_IN_ExtSRAM SystemInit_ExtMemCtl(); #endif /* DATA_IN_ExtSRAM */ #endif #ifdef VECT_TAB_SRAM SCB->VTOR = SRAM_BASE | VECT_TAB_OFFSET; /* Vector Table Relocation in Internal SRAM. */ #else SCB->VTOR = FLASH_BASE | VECT_TAB_OFFSET; /* Vector Table Relocation in Internal FLASH. */ #endif } /** * @brief Update SystemCoreClock variable according to Clock Register Values. * The SystemCoreClock variable contains the core clock (HCLK), it can * be used by the user application to setup the SysTick timer or configure * other parameters. * * @note Each time the core clock (HCLK) changes, this function must be called * to update SystemCoreClock variable value. Otherwise, any configuration * based on this variable will be incorrect. * * @note - The system frequency computed by this function is not the real * frequency in the chip. It is calculated based on the predefined * constant and the selected clock source: * * - If SYSCLK source is HSI, SystemCoreClock will contain the HSI_VALUE(*) * * - If SYSCLK source is HSE, SystemCoreClock will contain the HSE_VALUE(**) * * - If SYSCLK source is PLL, SystemCoreClock will contain the HSE_VALUE(**) * or HSI_VALUE(*) multiplied by the PLL factors. * * (*) HSI_VALUE is a constant defined in stm32f1xx.h file (default value * 8 MHz) but the real value may vary depending on the variations * in voltage and temperature. * * (**) HSE_VALUE is a constant defined in stm32f1xx.h file (default value * 8 MHz or 25 MHz, depending on the product used), user has to ensure * that HSE_VALUE is same as the real frequency of the crystal used. * Otherwise, this function may have wrong result. * * - The result of this function could be not correct when using fractional * value for HSE crystal. * @param None * @retval None */ void SystemCoreClockUpdate (void) { uint32_t tmp = 0, pllmull = 0, pllsource = 0; #if defined(STM32F105xC) || defined(STM32F107xC) uint32_t prediv1source = 0, prediv1factor = 0, prediv2factor = 0, pll2mull = 0; #endif /* STM32F105xC */ #if defined(STM32F100xB) || defined(STM32F100xE) uint32_t prediv1factor = 0; #endif /* STM32F100xB or STM32F100xE */ /* Get SYSCLK source -------------------------------------------------------*/ tmp = RCC->CFGR & RCC_CFGR_SWS; switch (tmp) { case 0x00: /* HSI used as system clock */ SystemCoreClock = HSI_VALUE; break; case 0x04: /* HSE used as system clock */ SystemCoreClock = HSE_VALUE; break; case 0x08: /* PLL used as system clock */ /* Get PLL clock source and multiplication factor ----------------------*/ pllmull = RCC->CFGR & RCC_CFGR_PLLMULL; pllsource = RCC->CFGR & RCC_CFGR_PLLSRC; #if !defined(STM32F105xC) && !defined(STM32F107xC) pllmull = ( pllmull >> 18) + 2; if (pllsource == 0x00) { /* HSI oscillator clock divided by 2 selected as PLL clock entry */ SystemCoreClock = (HSI_VALUE >> 1) * pllmull; } else { #if defined(STM32F100xB) || defined(STM32F100xE) prediv1factor = (RCC->CFGR2 & RCC_CFGR2_PREDIV1) + 1; /* HSE oscillator clock selected as PREDIV1 clock entry */ SystemCoreClock = (HSE_VALUE / prediv1factor) * pllmull; #else /* HSE selected as PLL clock entry */ if ((RCC->CFGR & RCC_CFGR_PLLXTPRE) != (uint32_t)RESET) {/* HSE oscillator clock divided by 2 */ SystemCoreClock = (HSE_VALUE >> 1) * pllmull; } else { SystemCoreClock = HSE_VALUE * pllmull; } #endif } #else pllmull = pllmull >> 18; if (pllmull != 0x0D) { pllmull += 2; } else { /* PLL multiplication factor = PLL input clock * 6.5 */ pllmull = 13 / 2; } if (pllsource == 0x00) { /* HSI oscillator clock divided by 2 selected as PLL clock entry */ SystemCoreClock = (HSI_VALUE >> 1) * pllmull; } else {/* PREDIV1 selected as PLL clock entry */ /* Get PREDIV1 clock source and division factor */ prediv1source = RCC->CFGR2 & RCC_CFGR2_PREDIV1SRC; prediv1factor = (RCC->CFGR2 & RCC_CFGR2_PREDIV1) + 1; if (prediv1source == 0) { /* HSE oscillator clock selected as PREDIV1 clock entry */ SystemCoreClock = (HSE_VALUE / prediv1factor) * pllmull; } else {/* PLL2 clock selected as PREDIV1 clock entry */ /* Get PREDIV2 division factor and PLL2 multiplication factor */ prediv2factor = ((RCC->CFGR2 & RCC_CFGR2_PREDIV2) >> 4) + 1; pll2mull = ((RCC->CFGR2 & RCC_CFGR2_PLL2MUL) >> 8 ) + 2; SystemCoreClock = (((HSE_VALUE / prediv2factor) * pll2mull) / prediv1factor) * pllmull; } } #endif /* STM32F105xC */ break; default: SystemCoreClock = HSI_VALUE; break; } /* Compute HCLK clock frequency ----------------*/ /* Get HCLK prescaler */ tmp = AHBPrescTable[((RCC->CFGR & RCC_CFGR_HPRE) >> 4)]; /* HCLK clock frequency */ SystemCoreClock >>= tmp; } #if defined(STM32F100xE) || defined(STM32F101xE) || defined(STM32F101xG) || defined(STM32F103xE) || defined(STM32F103xG) /** * @brief Setup the external memory controller. Called in startup_stm32f1xx.s * before jump to __main * @param None * @retval None */ #ifdef DATA_IN_ExtSRAM /** * @brief Setup the external memory controller. * Called in startup_stm32f1xx_xx.s/.c before jump to main. * This function configures the external SRAM mounted on STM3210E-EVAL * board (STM32 High density devices). This SRAM will be used as program * data memory (including heap and stack). * @param None * @retval None */ void SystemInit_ExtMemCtl(void) { __IO uint32_t tmpreg; /*!< FSMC Bank1 NOR/SRAM3 is used for the STM3210E-EVAL, if another Bank is required, then adjust the Register Addresses */ /* Enable FSMC clock */ RCC->AHBENR = 0x00000114; /* Delay after an RCC peripheral clock enabling */ tmpreg = READ_BIT(RCC->AHBENR, RCC_AHBENR_FSMCEN); /* Enable GPIOD, GPIOE, GPIOF and GPIOG clocks */ RCC->APB2ENR = 0x000001E0; /* Delay after an RCC peripheral clock enabling */ tmpreg = READ_BIT(RCC->APB2ENR, RCC_APB2ENR_IOPDEN); (void)(tmpreg); /* --------------- SRAM Data lines, NOE and NWE configuration ---------------*/ /*---------------- SRAM Address lines configuration -------------------------*/ /*---------------- NOE and NWE configuration --------------------------------*/ /*---------------- NE3 configuration ----------------------------------------*/ /*---------------- NBL0, NBL1 configuration ---------------------------------*/ GPIOD->CRL = 0x44BB44BB; GPIOD->CRH = 0xBBBBBBBB; GPIOE->CRL = 0xB44444BB; GPIOE->CRH = 0xBBBBBBBB; GPIOF->CRL = 0x44BBBBBB; GPIOF->CRH = 0xBBBB4444; GPIOG->CRL = 0x44BBBBBB; GPIOG->CRH = 0x44444B44; /*---------------- FSMC Configuration ---------------------------------------*/ /*---------------- Enable FSMC Bank1_SRAM Bank ------------------------------*/ FSMC_Bank1->BTCR[4] = 0x00001091; FSMC_Bank1->BTCR[5] = 0x00110212; } #endif /* DATA_IN_ExtSRAM */ #endif /* STM32F100xE || STM32F101xE || STM32F101xG || STM32F103xE || STM32F103xG */ /** * @} */ /** * @} */ /** * @} */
0
D://workCode//uploadProject\STM32CubeF1\Projects\STM3210E_EVAL\Examples\CRC\CRC_Example
D://workCode//uploadProject\STM32CubeF1\Projects\STM3210E_EVAL\Examples\CRC\CRC_Example\Inc\main.h
/** ****************************************************************************** * @file CRC/CRC_Example/Inc/main.h * @author MCD Application Team * @brief Header for main.c module ****************************************************************************** * @attention * * Copyright (c) 2016 STMicroelectronics. * All rights reserved. * * This software is licensed under terms that can be found in the LICENSE file * in the root directory of this software component. * If no LICENSE file comes with this software, it is provided AS-IS. * ****************************************************************************** */ /* Define to prevent recursive inclusion -------------------------------------*/ #ifndef __MAIN_H #define __MAIN_H /* Includes ------------------------------------------------------------------*/ #include "stm32f1xx_hal.h" #include "stm3210e_eval.h" /* Exported types ------------------------------------------------------------*/ /* Exported constants --------------------------------------------------------*/ /* Exported macro ------------------------------------------------------------*/ /* Exported functions ------------------------------------------------------- */ #endif /* __MAIN_H */
0
D://workCode//uploadProject\STM32CubeF1\Projects\STM3210E_EVAL\Examples\CRC\CRC_Example
D://workCode//uploadProject\STM32CubeF1\Projects\STM3210E_EVAL\Examples\CRC\CRC_Example\Inc\stm32f1xx_hal_conf.h
/** ****************************************************************************** * @file stm32f1xx_hal_conf.h * @author MCD Application Team * @brief HAL configuration file. ****************************************************************************** * @attention * * Copyright (c) 2016 STMicroelectronics. * All rights reserved. * * This software is licensed under terms that can be found in the LICENSE file * in the root directory of this software component. * If no LICENSE file comes with this software, it is provided AS-IS. * ****************************************************************************** */ /* Define to prevent recursive inclusion -------------------------------------*/ #ifndef __STM32F1xx_HAL_CONF_H #define __STM32F1xx_HAL_CONF_H #ifdef __cplusplus extern "C" { #endif /* Exported types ------------------------------------------------------------*/ /* Exported constants --------------------------------------------------------*/ /* ########################## Module Selection ############################## */ /** * @brief This is the list of modules to be used in the HAL driver */ #define HAL_MODULE_ENABLED /* #define HAL_ADC_MODULE_ENABLED */ /* #define HAL_CAN_MODULE_ENABLED */ /* #define HAL_CAN_LEGACY_MODULE_ENABLED */ /* #define HAL_CEC_MODULE_ENABLED */ #define HAL_CORTEX_MODULE_ENABLED #define HAL_CRC_MODULE_ENABLED /* #define HAL_DAC_MODULE_ENABLED */ #define HAL_DMA_MODULE_ENABLED /* #define HAL_ETH_MODULE_ENABLED */ /* #define HAL_EXTI_MODULE_ENABLED */ #define HAL_FLASH_MODULE_ENABLED #define HAL_GPIO_MODULE_ENABLED /* #define HAL_HCD_MODULE_ENABLED */ /* #define HAL_I2C_MODULE_ENABLED */ /* #define HAL_I2S_MODULE_ENABLED */ /* #define HAL_IRDA_MODULE_ENABLED */ /* #define HAL_IWDG_MODULE_ENABLED */ /* #define HAL_NAND_MODULE_ENABLED */ /* #define HAL_NOR_MODULE_ENABLED */ /* #define HAL_PCCARD_MODULE_ENABLED */ /* #define HAL_PCD_MODULE_ENABLED */ #define HAL_PWR_MODULE_ENABLED #define HAL_RCC_MODULE_ENABLED /* #define HAL_RTC_MODULE_ENABLED */ /* #define HAL_SD_MODULE_ENABLED */ /* #define HAL_SMARTCARD_MODULE_ENABLED */ /* #define HAL_SPI_MODULE_ENABLED */ /* #define HAL_SRAM_MODULE_ENABLED */ /* #define HAL_TIM_MODULE_ENABLED */ /* #define HAL_UART_MODULE_ENABLED */ /* #define HAL_USART_MODULE_ENABLED */ /* #define HAL_WWDG_MODULE_ENABLED */ /* #define HAL_MMC_MODULE_ENABLED */ /* ########################## Oscillator Values adaptation ####################*/ /** * @brief Adjust the value of External High Speed oscillator (HSE) used in your application. * This value is used by the RCC HAL module to compute the system frequency * (when HSE is used as system clock source, directly or through the PLL). */ #if !defined (HSE_VALUE) #if defined(USE_STM3210C_EVAL) #define HSE_VALUE 25000000U /*!< Value of the External oscillator in Hz */ #else #define HSE_VALUE 8000000U /*!< Value of the External oscillator in Hz */ #endif #endif /* HSE_VALUE */ #if !defined (HSE_STARTUP_TIMEOUT) #define HSE_STARTUP_TIMEOUT 100U /*!< Time out for HSE start up, in ms */ #endif /* HSE_STARTUP_TIMEOUT */ /** * @brief Internal High Speed oscillator (HSI) value. * This value is used by the RCC HAL module to compute the system frequency * (when HSI is used as system clock source, directly or through the PLL). */ #if !defined (HSI_VALUE) #define HSI_VALUE 8000000U /*!< Value of the Internal oscillator in Hz */ #endif /* HSI_VALUE */ /** * @brief Internal Low Speed oscillator (LSI) value. */ #if !defined (LSI_VALUE) #define LSI_VALUE 40000U /*!< LSI Typical Value in Hz */ #endif /* LSI_VALUE */ /*!< Value of the Internal Low Speed oscillator in Hz The real value may vary depending on the variations in voltage and temperature. */ /** * @brief External Low Speed oscillator (LSE) value. * This value is used by the UART, RTC HAL module to compute the system frequency */ #if !defined (LSE_VALUE) #define LSE_VALUE 32768U /*!< Value of the External oscillator in Hz*/ #endif /* LSE_VALUE */ #if !defined (LSE_STARTUP_TIMEOUT) #define LSE_STARTUP_TIMEOUT 5000U /*!< Time out for LSE start up, in ms */ #endif /* LSE_STARTUP_TIMEOUT */ /* Tip: To avoid modifying this file each time you need to use different HSE, === you can define the HSE value in your toolchain compiler preprocessor. */ /* ########################### System Configuration ######################### */ /** * @brief This is the HAL system configuration section */ #define VDD_VALUE 3300U /*!< Value of VDD in mv */ #define TICK_INT_PRIORITY 0x0FU /*!< tick interrupt priority */ #define USE_RTOS 0U #define PREFETCH_ENABLE 1U #define USE_HAL_ADC_REGISTER_CALLBACKS 0U /* ADC register callback disabled */ #define USE_HAL_CAN_REGISTER_CALLBACKS 0U /* CAN register callback disabled */ #define USE_HAL_CEC_REGISTER_CALLBACKS 0U /* CEC register callback disabled */ #define USE_HAL_DAC_REGISTER_CALLBACKS 0U /* DAC register callback disabled */ #define USE_HAL_ETH_REGISTER_CALLBACKS 0U /* ETH register callback disabled */ #define USE_HAL_HCD_REGISTER_CALLBACKS 0U /* HCD register callback disabled */ #define USE_HAL_I2C_REGISTER_CALLBACKS 0U /* I2C register callback disabled */ #define USE_HAL_I2S_REGISTER_CALLBACKS 0U /* I2S register callback disabled */ #define USE_HAL_MMC_REGISTER_CALLBACKS 0U /* MMC register callback disabled */ #define USE_HAL_NAND_REGISTER_CALLBACKS 0U /* NAND register callback disabled */ #define USE_HAL_NOR_REGISTER_CALLBACKS 0U /* NOR register callback disabled */ #define USE_HAL_PCCARD_REGISTER_CALLBACKS 0U /* PCCARD register callback disabled */ #define USE_HAL_PCD_REGISTER_CALLBACKS 0U /* PCD register callback disabled */ #define USE_HAL_RTC_REGISTER_CALLBACKS 0U /* RTC register callback disabled */ #define USE_HAL_SD_REGISTER_CALLBACKS 0U /* SD register callback disabled */ #define USE_HAL_SMARTCARD_REGISTER_CALLBACKS 0U /* SMARTCARD register callback disabled */ #define USE_HAL_IRDA_REGISTER_CALLBACKS 0U /* IRDA register callback disabled */ #define USE_HAL_SRAM_REGISTER_CALLBACKS 0U /* SRAM register callback disabled */ #define USE_HAL_SPI_REGISTER_CALLBACKS 0U /* SPI register callback disabled */ #define USE_HAL_TIM_REGISTER_CALLBACKS 0U /* TIM register callback disabled */ #define USE_HAL_UART_REGISTER_CALLBACKS 0U /* UART register callback disabled */ #define USE_HAL_USART_REGISTER_CALLBACKS 0U /* USART register callback disabled */ #define USE_HAL_WWDG_REGISTER_CALLBACKS 0U /* WWDG register callback disabled */ /* ########################## Assert Selection ############################## */ /** * @brief Uncomment the line below to expanse the "assert_param" macro in the * HAL drivers code */ /* #define USE_FULL_ASSERT 1U */ /* ################## Ethernet peripheral configuration ##################### */ /* Section 1 : Ethernet peripheral configuration */ /* MAC ADDRESS: MAC_ADDR0:MAC_ADDR1:MAC_ADDR2:MAC_ADDR3:MAC_ADDR4:MAC_ADDR5 */ #define MAC_ADDR0 2U #define MAC_ADDR1 0U #define MAC_ADDR2 0U #define MAC_ADDR3 0U #define MAC_ADDR4 0U #define MAC_ADDR5 0U /* Definition of the Ethernet driver buffers size and count */ #define ETH_RX_BUF_SIZE ETH_MAX_PACKET_SIZE /* buffer size for receive */ #define ETH_TX_BUF_SIZE ETH_MAX_PACKET_SIZE /* buffer size for transmit */ #define ETH_RXBUFNB 8U /* 8 Rx buffers of size ETH_RX_BUF_SIZE */ #define ETH_TXBUFNB 4U /* 4 Tx buffers of size ETH_TX_BUF_SIZE */ /* Section 2: PHY configuration section */ /* DP83848 PHY Address*/ #define DP83848_PHY_ADDRESS 0x01U /* PHY Reset delay these values are based on a 1 ms Systick interrupt*/ #define PHY_RESET_DELAY 0x000000FFU /* PHY Configuration delay */ #define PHY_CONFIG_DELAY 0x00000FFFU #define PHY_READ_TO 0x0000FFFFU #define PHY_WRITE_TO 0x0000FFFFU /* Section 3: Common PHY Registers */ #define PHY_BCR ((uint16_t)0x0000) /*!< Transceiver Basic Control Register */ #define PHY_BSR ((uint16_t)0x0001) /*!< Transceiver Basic Status Register */ #define PHY_RESET ((uint16_t)0x8000) /*!< PHY Reset */ #define PHY_LOOPBACK ((uint16_t)0x4000) /*!< Select loop-back mode */ #define PHY_FULLDUPLEX_100M ((uint16_t)0x2100) /*!< Set the full-duplex mode at 100 Mb/s */ #define PHY_HALFDUPLEX_100M ((uint16_t)0x2000) /*!< Set the half-duplex mode at 100 Mb/s */ #define PHY_FULLDUPLEX_10M ((uint16_t)0x0100) /*!< Set the full-duplex mode at 10 Mb/s */ #define PHY_HALFDUPLEX_10M ((uint16_t)0x0000) /*!< Set the half-duplex mode at 10 Mb/s */ #define PHY_AUTONEGOTIATION ((uint16_t)0x1000) /*!< Enable auto-negotiation function */ #define PHY_RESTART_AUTONEGOTIATION ((uint16_t)0x0200) /*!< Restart auto-negotiation function */ #define PHY_POWERDOWN ((uint16_t)0x0800) /*!< Select the power down mode */ #define PHY_ISOLATE ((uint16_t)0x0400) /*!< Isolate PHY from MII */ #define PHY_AUTONEGO_COMPLETE ((uint16_t)0x0020) /*!< Auto-Negotiation process completed */ #define PHY_LINKED_STATUS ((uint16_t)0x0004) /*!< Valid link established */ #define PHY_JABBER_DETECTION ((uint16_t)0x0002) /*!< Jabber condition detected */ /* Section 4: Extended PHY Registers */ #define PHY_SR ((uint16_t)0x0010) /*!< PHY status register Offset */ #define PHY_MICR ((uint16_t)0x0011) /*!< MII Interrupt Control Register */ #define PHY_MISR ((uint16_t)0x0012) /*!< MII Interrupt Status and Misc. Control Register */ #define PHY_LINK_STATUS ((uint16_t)0x0001) /*!< PHY Link mask */ #define PHY_SPEED_STATUS ((uint16_t)0x0002) /*!< PHY Speed mask */ #define PHY_DUPLEX_STATUS ((uint16_t)0x0004) /*!< PHY Duplex mask */ #define PHY_MICR_INT_EN ((uint16_t)0x0002) /*!< PHY Enable interrupts */ #define PHY_MICR_INT_OE ((uint16_t)0x0001) /*!< PHY Enable output interrupt events */ #define PHY_MISR_LINK_INT_EN ((uint16_t)0x0020) /*!< Enable Interrupt on change of link status */ #define PHY_LINK_INTERRUPT ((uint16_t)0x2000) /*!< PHY link status interrupt mask */ /* ################## SPI peripheral configuration ########################## */ /* CRC FEATURE: Use to activate CRC feature inside HAL SPI Driver * Activated: CRC code is present inside driver * Deactivated: CRC code cleaned from driver */ #define USE_SPI_CRC 1U /* Includes ------------------------------------------------------------------*/ /** * @brief Include module's header file */ #ifdef HAL_RCC_MODULE_ENABLED #include "stm32f1xx_hal_rcc.h" #endif /* HAL_RCC_MODULE_ENABLED */ #ifdef HAL_GPIO_MODULE_ENABLED #include "stm32f1xx_hal_gpio.h" #endif /* HAL_GPIO_MODULE_ENABLED */ #ifdef HAL_EXTI_MODULE_ENABLED #include "stm32f1xx_hal_exti.h" #endif /* HAL_EXTI_MODULE_ENABLED */ #ifdef HAL_DMA_MODULE_ENABLED #include "stm32f1xx_hal_dma.h" #endif /* HAL_DMA_MODULE_ENABLED */ #ifdef HAL_ETH_MODULE_ENABLED #include "stm32f1xx_hal_eth.h" #endif /* HAL_ETH_MODULE_ENABLED */ #ifdef HAL_CAN_MODULE_ENABLED #include "stm32f1xx_hal_can.h" #endif /* HAL_CAN_MODULE_ENABLED */ #ifdef HAL_CAN_LEGACY_MODULE_ENABLED #include "Legacy/stm32f1xx_hal_can_legacy.h" #endif /* HAL_CAN_LEGACY_MODULE_ENABLED */ #ifdef HAL_CEC_MODULE_ENABLED #include "stm32f1xx_hal_cec.h" #endif /* HAL_CEC_MODULE_ENABLED */ #ifdef HAL_CORTEX_MODULE_ENABLED #include "stm32f1xx_hal_cortex.h" #endif /* HAL_CORTEX_MODULE_ENABLED */ #ifdef HAL_ADC_MODULE_ENABLED #include "stm32f1xx_hal_adc.h" #endif /* HAL_ADC_MODULE_ENABLED */ #ifdef HAL_CRC_MODULE_ENABLED #include "stm32f1xx_hal_crc.h" #endif /* HAL_CRC_MODULE_ENABLED */ #ifdef HAL_DAC_MODULE_ENABLED #include "stm32f1xx_hal_dac.h" #endif /* HAL_DAC_MODULE_ENABLED */ #ifdef HAL_FLASH_MODULE_ENABLED #include "stm32f1xx_hal_flash.h" #endif /* HAL_FLASH_MODULE_ENABLED */ #ifdef HAL_SRAM_MODULE_ENABLED #include "stm32f1xx_hal_sram.h" #endif /* HAL_SRAM_MODULE_ENABLED */ #ifdef HAL_NOR_MODULE_ENABLED #include "stm32f1xx_hal_nor.h" #endif /* HAL_NOR_MODULE_ENABLED */ #ifdef HAL_I2C_MODULE_ENABLED #include "stm32f1xx_hal_i2c.h" #endif /* HAL_I2C_MODULE_ENABLED */ #ifdef HAL_I2S_MODULE_ENABLED #include "stm32f1xx_hal_i2s.h" #endif /* HAL_I2S_MODULE_ENABLED */ #ifdef HAL_IWDG_MODULE_ENABLED #include "stm32f1xx_hal_iwdg.h" #endif /* HAL_IWDG_MODULE_ENABLED */ #ifdef HAL_PWR_MODULE_ENABLED #include "stm32f1xx_hal_pwr.h" #endif /* HAL_PWR_MODULE_ENABLED */ #ifdef HAL_RTC_MODULE_ENABLED #include "stm32f1xx_hal_rtc.h" #endif /* HAL_RTC_MODULE_ENABLED */ #ifdef HAL_PCCARD_MODULE_ENABLED #include "stm32f1xx_hal_pccard.h" #endif /* HAL_PCCARD_MODULE_ENABLED */ #ifdef HAL_SD_MODULE_ENABLED #include "stm32f1xx_hal_sd.h" #endif /* HAL_SD_MODULE_ENABLED */ #ifdef HAL_NAND_MODULE_ENABLED #include "stm32f1xx_hal_nand.h" #endif /* HAL_NAND_MODULE_ENABLED */ #ifdef HAL_SPI_MODULE_ENABLED #include "stm32f1xx_hal_spi.h" #endif /* HAL_SPI_MODULE_ENABLED */ #ifdef HAL_TIM_MODULE_ENABLED #include "stm32f1xx_hal_tim.h" #endif /* HAL_TIM_MODULE_ENABLED */ #ifdef HAL_UART_MODULE_ENABLED #include "stm32f1xx_hal_uart.h" #endif /* HAL_UART_MODULE_ENABLED */ #ifdef HAL_USART_MODULE_ENABLED #include "stm32f1xx_hal_usart.h" #endif /* HAL_USART_MODULE_ENABLED */ #ifdef HAL_IRDA_MODULE_ENABLED #include "stm32f1xx_hal_irda.h" #endif /* HAL_IRDA_MODULE_ENABLED */ #ifdef HAL_SMARTCARD_MODULE_ENABLED #include "stm32f1xx_hal_smartcard.h" #endif /* HAL_SMARTCARD_MODULE_ENABLED */ #ifdef HAL_WWDG_MODULE_ENABLED #include "stm32f1xx_hal_wwdg.h" #endif /* HAL_WWDG_MODULE_ENABLED */ #ifdef HAL_PCD_MODULE_ENABLED #include "stm32f1xx_hal_pcd.h" #endif /* HAL_PCD_MODULE_ENABLED */ #ifdef HAL_HCD_MODULE_ENABLED #include "stm32f1xx_hal_hcd.h" #endif /* HAL_HCD_MODULE_ENABLED */ #ifdef HAL_MMC_MODULE_ENABLED #include "stm32f1xx_hal_mmc.h" #endif /* HAL_MMC_MODULE_ENABLED */ /* Exported macro ------------------------------------------------------------*/ #ifdef USE_FULL_ASSERT /** * @brief The assert_param macro is used for function's parameters check. * @param expr: If expr is false, it calls assert_failed function * which reports the name of the source file and the source * line number of the call that failed. * If expr is true, it returns no value. * @retval None */ #define assert_param(expr) ((expr) ? (void)0U : assert_failed((uint8_t *)__FILE__, __LINE__)) /* Exported functions ------------------------------------------------------- */ void assert_failed(uint8_t* file, uint32_t line); #else #define assert_param(expr) ((void)0U) #endif /* USE_FULL_ASSERT */ #ifdef __cplusplus } #endif #endif /* __STM32F1xx_HAL_CONF_H */
0
D://workCode//uploadProject\STM32CubeF1\Projects\STM3210E_EVAL\Examples\CRC\CRC_Example
D://workCode//uploadProject\STM32CubeF1\Projects\STM3210E_EVAL\Examples\CRC\CRC_Example\Inc\stm32f1xx_it.h
/** ****************************************************************************** * @file CRC/CRC_Example/Inc/stm32f1xx_it.h * @author MCD Application Team * @brief This file contains the headers of the interrupt handlers. ****************************************************************************** * @attention * * Copyright (c) 2016 STMicroelectronics. * All rights reserved. * * This software is licensed under terms that can be found in the LICENSE file * in the root directory of this software component. * If no LICENSE file comes with this software, it is provided AS-IS. * ****************************************************************************** */ /* Define to prevent recursive inclusion -------------------------------------*/ #ifndef __STM32F1xx_IT_H #define __STM32F1xx_IT_H #ifdef __cplusplus extern "C" { #endif /* Includes ------------------------------------------------------------------*/ /* Exported types ------------------------------------------------------------*/ /* Exported constants --------------------------------------------------------*/ /* Exported macro ------------------------------------------------------------*/ /* Exported functions ------------------------------------------------------- */ void NMI_Handler(void); void HardFault_Handler(void); void MemManage_Handler(void); void BusFault_Handler(void); void UsageFault_Handler(void); void SVC_Handler(void); void DebugMon_Handler(void); void PendSV_Handler(void); void SysTick_Handler(void); #ifdef __cplusplus } #endif #endif /* __STM32F1xx_IT_H */
0
D://workCode//uploadProject\STM32CubeF1\Projects\STM3210E_EVAL\Examples\CRC\CRC_Example
D://workCode//uploadProject\STM32CubeF1\Projects\STM3210E_EVAL\Examples\CRC\CRC_Example\Src\main.c
/** ****************************************************************************** * @file CRC/CRC_Example/Src/main.c * @author MCD Application Team * @brief This sample code shows how to use the STM32F1xx CRC HAL API * to get a CRC code of a given buffer of data word(32-bit), * based on a fixed generator polynomial(0x4C11DB7). ****************************************************************************** * @attention * * Copyright (c) 2016 STMicroelectronics. * All rights reserved. * * This software is licensed under terms that can be found in the LICENSE file * in the root directory of this software component. * If no LICENSE file comes with this software, it is provided AS-IS. * ****************************************************************************** */ /* Includes ------------------------------------------------------------------*/ #include "main.h" /** @addtogroup STM32F1xx_HAL_Examples * @{ */ /** @addtogroup CRC_Example * @{ */ /* Private typedef -----------------------------------------------------------*/ /* Private define ------------------------------------------------------------*/ #define BUFFER_SIZE 114 /* Private macro -------------------------------------------------------------*/ /* Private variables ---------------------------------------------------------*/ /* CRC handler declaration */ CRC_HandleTypeDef CrcHandle; /* Used for storing CRC Value */ __IO uint32_t uwCRCValue = 0; static const uint32_t aDataBuffer[BUFFER_SIZE] = { 0x00001021, 0x20423063, 0x408450a5, 0x60c670e7, 0x9129a14a, 0xb16bc18c, 0xd1ade1ce, 0xf1ef1231, 0x32732252, 0x52b54294, 0x72f762d6, 0x93398318, 0xa35ad3bd, 0xc39cf3ff, 0xe3de2462, 0x34430420, 0x64e674c7, 0x44a45485, 0xa56ab54b, 0x85289509, 0xf5cfc5ac, 0xd58d3653, 0x26721611, 0x063076d7, 0x569546b4, 0xb75ba77a, 0x97198738, 0xf7dfe7fe, 0xc7bc48c4, 0x58e56886, 0x78a70840, 0x18612802, 0xc9ccd9ed, 0xe98ef9af, 0x89489969, 0xa90ab92b, 0x4ad47ab7, 0x6a961a71, 0x0a503a33, 0x2a12dbfd, 0xfbbfeb9e, 0x9b798b58, 0xbb3bab1a, 0x6ca67c87, 0x5cc52c22, 0x3c030c60, 0x1c41edae, 0xfd8fcdec, 0xad2abd0b, 0x8d689d49, 0x7e976eb6, 0x5ed54ef4, 0x2e321e51, 0x0e70ff9f, 0xefbedfdd, 0xcffcbf1b, 0x9f598f78, 0x918881a9, 0xb1caa1eb, 0xd10cc12d, 0xe16f1080, 0x00a130c2, 0x20e35004, 0x40257046, 0x83b99398, 0xa3fbb3da, 0xc33dd31c, 0xe37ff35e, 0x129022f3, 0x32d24235, 0x52146277, 0x7256b5ea, 0x95a88589, 0xf56ee54f, 0xd52cc50d, 0x34e224c3, 0x04817466, 0x64475424, 0x4405a7db, 0xb7fa8799, 0xe75ff77e, 0xc71dd73c, 0x26d336f2, 0x069116b0, 0x76764615, 0x5634d94c, 0xc96df90e, 0xe92f99c8, 0xb98aa9ab, 0x58444865, 0x78066827, 0x18c008e1, 0x28a3cb7d, 0xdb5ceb3f, 0xfb1e8bf9, 0x9bd8abbb, 0x4a755a54, 0x6a377a16, 0x0af11ad0, 0x2ab33a92, 0xed0fdd6c, 0xcd4dbdaa, 0xad8b9de8, 0x8dc97c26, 0x5c644c45, 0x3ca22c83, 0x1ce00cc1, 0xef1fff3e, 0xdf7caf9b, 0xbfba8fd9, 0x9ff86e17, 0x7e364e55, 0x2e933eb2, 0x0ed11ef0 }; /* Expected CRC Value */ uint32_t uwExpectedCRCValue = 0x379E9F06; /* Private function prototypes -----------------------------------------------*/ void SystemClock_Config(void); static void Error_Handler(void); /* Private functions ---------------------------------------------------------*/ /** * @brief Main program * @param None * @retval None */ int main(void) { /* STM32F103xG HAL library initialization: - Configure the Flash prefetch - Systick timer is configured by default as source of time base, but user can eventually implement his proper time base source (a general purpose timer for example or other time source), keeping in mind that Time base duration should be kept 1ms since PPP_TIMEOUT_VALUEs are defined and handled in milliseconds basis. - Set NVIC Group Priority to 4 - Low Level Initialization */ HAL_Init(); /* Configure the system clock to 72 MHz */ SystemClock_Config(); /* Configure LED1 and LED3 */ BSP_LED_Init(LED1); BSP_LED_Init(LED3); /*##-1- Configure the CRC peripheral #######################################*/ CrcHandle.Instance = CRC; if (HAL_CRC_Init(&CrcHandle) != HAL_OK) { /* Initialization Error */ Error_Handler(); } /*##-2- Compute the CRC of "aDataBuffer" ###################################*/ uwCRCValue = HAL_CRC_Accumulate(&CrcHandle, (uint32_t *)aDataBuffer, BUFFER_SIZE); /*##-3- Compare the CRC value to the Expected one ##########################*/ if (uwCRCValue != uwExpectedCRCValue) { /* Wrong CRC value: Turn LED3 on */ Error_Handler(); } else { /* Right CRC value: Turn LED1 on */ BSP_LED_On(LED1); } /* Infinite loop */ while (1) { } } /** * @brief System Clock Configuration * The system Clock is configured as follow : * System Clock source = PLL (HSE) * SYSCLK(Hz) = 72000000 * HCLK(Hz) = 72000000 * AHB Prescaler = 1 * APB1 Prescaler = 2 * APB2 Prescaler = 1 * HSE Frequency(Hz) = 8000000 * HSE PREDIV1 = 1 * PLLMUL = 9 * Flash Latency(WS) = 2 * @param None * @retval None */ void SystemClock_Config(void) { RCC_ClkInitTypeDef clkinitstruct = {0}; RCC_OscInitTypeDef oscinitstruct = {0}; /* Enable HSE Oscillator and activate PLL with HSE as source */ oscinitstruct.OscillatorType = RCC_OSCILLATORTYPE_HSE; oscinitstruct.HSEState = RCC_HSE_ON; oscinitstruct.HSEPredivValue = RCC_HSE_PREDIV_DIV1; oscinitstruct.PLL.PLLState = RCC_PLL_ON; oscinitstruct.PLL.PLLSource = RCC_PLLSOURCE_HSE; oscinitstruct.PLL.PLLMUL = RCC_PLL_MUL9; if (HAL_RCC_OscConfig(&oscinitstruct)!= HAL_OK) { /* Initialization Error */ while(1); } /* Select PLL as system clock source and configure the HCLK, PCLK1 and PCLK2 clocks dividers */ clkinitstruct.ClockType = (RCC_CLOCKTYPE_SYSCLK | RCC_CLOCKTYPE_HCLK | RCC_CLOCKTYPE_PCLK1 | RCC_CLOCKTYPE_PCLK2); clkinitstruct.SYSCLKSource = RCC_SYSCLKSOURCE_PLLCLK; clkinitstruct.AHBCLKDivider = RCC_SYSCLK_DIV1; clkinitstruct.APB2CLKDivider = RCC_HCLK_DIV1; clkinitstruct.APB1CLKDivider = RCC_HCLK_DIV2; if (HAL_RCC_ClockConfig(&clkinitstruct, FLASH_LATENCY_2)!= HAL_OK) { /* Initialization Error */ while(1); } } /** * @brief This function is executed in case of error occurrence. * @param None * @retval None */ static void Error_Handler(void) { /* Turn LED3 on */ BSP_LED_On(LED3); while (1) { } } #ifdef USE_FULL_ASSERT /** * @brief Reports the name of the source file and the source line number * where the assert_param error has occurred. * @param file: pointer to the source file name * @param line: assert_param error line source number * @retval None */ void assert_failed(uint8_t *file, uint32_t line) { /* User can add his own implementation to report the file name and line number, ex: printf("Wrong parameters value: file %s on line %d\r\n", file, line) */ /* Infinite loop */ while (1) { } } #endif /** * @} */ /** * @} */
0
D://workCode//uploadProject\STM32CubeF1\Projects\STM3210E_EVAL\Examples\CRC\CRC_Example
D://workCode//uploadProject\STM32CubeF1\Projects\STM3210E_EVAL\Examples\CRC\CRC_Example\Src\stm32f1xx_hal_msp.c
/** ****************************************************************************** * @file CRC/CRC_Example/Src/stm32f1xx_hal_msp.c * @author MCD Application Team * @brief HAL MSP module. ****************************************************************************** * @attention * * Copyright (c) 2016 STMicroelectronics. * All rights reserved. * * This software is licensed under terms that can be found in the LICENSE file * in the root directory of this software component. * If no LICENSE file comes with this software, it is provided AS-IS. * ****************************************************************************** */ /* Includes ------------------------------------------------------------------*/ #include "main.h" /** @addtogroup STM32F1xx_HAL_Examples * @{ */ /** @defgroup HAL_MSP * @brief HAL MSP module. * @{ */ /* Private typedef -----------------------------------------------------------*/ /* Private define ------------------------------------------------------------*/ /* Private macro -------------------------------------------------------------*/ /* Private variables ---------------------------------------------------------*/ /* Private function prototypes -----------------------------------------------*/ /* Private functions ---------------------------------------------------------*/ /** @defgroup HAL_MSP_Private_Functions * @{ */ /** * @brief CRC MSP Initialization * This function configures the hardware resources used in this example: * - Peripheral's clock enable * @param hcrc: CRC handle pointer * @retval None */ void HAL_CRC_MspInit(CRC_HandleTypeDef *hcrc) { /* CRC Peripheral clock enable */ __HAL_RCC_CRC_CLK_ENABLE(); } /** * @brief CRC MSP De-Initialization * This function freeze the hardware resources used in this example: * - Disable the Peripheral's clock * @param hcrc: CRC handle pointer * @retval None */ void HAL_CRC_MspDeInit(CRC_HandleTypeDef *hcrc) { /* CRC Peripheral clock disable */ __HAL_RCC_CRC_CLK_DISABLE(); } /** * @} */ /** * @} */ /** * @} */
0