diff options
Diffstat (limited to 'src')
-rw-r--r-- | src/entropy/stm32f4xx_hal_msp.c | 194 | ||||
-rw-r--r-- | src/entropy/stm32f4xx_it.c | 6 | ||||
-rw-r--r-- | src/led-test/stm32f4xx_it.c | 6 | ||||
-rw-r--r-- | src/led-test/system_stm32f4xx.c | 56 | ||||
-rw-r--r-- | src/uart-test/stm32f4xx_hal_msp.c | 84 | ||||
-rw-r--r-- | src/uart-test/stm32f4xx_it.c | 6 | ||||
-rw-r--r-- | src/uart-test/system_stm32f4xx.c | 56 |
7 files changed, 204 insertions, 204 deletions
diff --git a/src/entropy/stm32f4xx_hal_msp.c b/src/entropy/stm32f4xx_hal_msp.c index cf59a07..fc27e04 100644 --- a/src/entropy/stm32f4xx_hal_msp.c +++ b/src/entropy/stm32f4xx_hal_msp.c @@ -1,97 +1,97 @@ -#include "stm_init.h"
-#include "stm32f4xx_hal.h"
-
-static void Error_Handler(void);
-extern void HAL_DMA_XferCpltCallback(DMA_HandleTypeDef *hdma);
-
-void HAL_TIM_IC_MspInit(TIM_HandleTypeDef* htim)
-{
- if (htim->Instance == TIM2) {
- /* Configure DMA input capturing.
- *
- * Amplified avalanche noise is present at pin PA1,
- * which has Alternate Function TIM2_CH2.
- *
- * TIM2_CH2 is DMA1 stream 6, channel 3 according to Table 28
- * (DMA1 request mapping) in the reference manual (RM0368).
- */
- __DMA1_CLK_ENABLE();
- __TIM2_CLK_ENABLE();
- __GPIOA_CLK_ENABLE();
-
- hdma_tim.Instance = DMA1_Stream6;
-
- hdma_tim.Init.Channel = DMA_CHANNEL_3;
- hdma_tim.Init.Direction = DMA_PERIPH_TO_MEMORY;
- hdma_tim.Init.PeriphInc = DMA_PINC_DISABLE;
- hdma_tim.Init.MemInc = DMA_MINC_ENABLE;
- hdma_tim.Init.PeriphDataAlignment = DMA_PDATAALIGN_WORD;
- hdma_tim.Init.MemDataAlignment = DMA_MDATAALIGN_WORD;
- hdma_tim.Init.Mode = DMA_NORMAL;
- hdma_tim.Init.Priority = DMA_PRIORITY_HIGH;
- hdma_tim.Init.FIFOMode = DMA_FIFOMODE_DISABLE;
- hdma_tim.Init.FIFOThreshold = DMA_FIFO_THRESHOLD_FULL;
- hdma_tim.Init.MemBurst = DMA_MBURST_SINGLE;
- hdma_tim.Init.PeriphBurst = DMA_PBURST_SINGLE;
-
- /* Link hdma_tim to hdma[2] (channel3) */
- __HAL_LINKDMA(htim, hdma[TIM_DMA_ID_CC2], hdma_tim);
-
- /* Initialize TIMx DMA handle */
- if (HAL_DMA_Init(&hdma_tim) != HAL_OK) {
- Error_Handler();
- }
- }
-}
-
-void HAL_UART_MspInit(UART_HandleTypeDef* huart)
-{
- GPIO_InitTypeDef GPIO_InitStruct;
-
- if (huart->Instance == USART1) {
- /* Peripheral clock enable */
- __USART1_CLK_ENABLE();
-
- /**USART1 GPIO Configuration
- PA9 ------> USART1_TX
- PA10 ------> USART1_RX
- */
- GPIO_InitStruct.Pin = GPIO_PIN_9 | GPIO_PIN_10;
- GPIO_InitStruct.Mode = GPIO_MODE_AF_PP;
- GPIO_InitStruct.Pull = GPIO_PULLUP;
- GPIO_InitStruct.Speed = GPIO_SPEED_FAST;
- GPIO_InitStruct.Alternate = GPIO_AF7_USART1;
- HAL_GPIO_Init(GPIOA, &GPIO_InitStruct);
-
- /* NVIC for interrupt mode */
- HAL_NVIC_SetPriority(USART1_IRQn, 0, 1);
- HAL_NVIC_EnableIRQ(USART1_IRQn);
- }
-}
-
-void HAL_UART_MspDeInit(UART_HandleTypeDef* huart)
-{
- if (huart->Instance == USART1) {
- /* Peripheral clock disable */
- __USART1_CLK_DISABLE();
-
- /**USART1 GPIO Configuration
- PA9 ------> USART1_TX
- PA10 ------> USART1_RX
- */
- HAL_GPIO_DeInit(GPIOA, GPIO_PIN_9 | GPIO_PIN_10);
- }
-}
-
-/**
- * @brief This function is executed in case of error occurrence.
- * @param None
- * @retval None
- */
-static void Error_Handler(void)
-{
- /* Turn on RED LED and then loop indefinitely */
- HAL_GPIO_WritePin(LED_PORT, LED_RED, GPIO_PIN_SET);
-
- while (1) { ; }
-}
+#include "stm_init.h" +#include "stm32f4xx_hal.h" + +static void Error_Handler(void); +extern void HAL_DMA_XferCpltCallback(DMA_HandleTypeDef *hdma); + +void HAL_TIM_IC_MspInit(TIM_HandleTypeDef* htim) +{ + if (htim->Instance == TIM2) { + /* Configure DMA input capturing. + * + * Amplified avalanche noise is present at pin PA1, + * which has Alternate Function TIM2_CH2. + * + * TIM2_CH2 is DMA1 stream 6, channel 3 according to Table 28 + * (DMA1 request mapping) in the reference manual (RM0368). + */ + __DMA1_CLK_ENABLE(); + __TIM2_CLK_ENABLE(); + __GPIOA_CLK_ENABLE(); + + hdma_tim.Instance = DMA1_Stream6; + + hdma_tim.Init.Channel = DMA_CHANNEL_3; + hdma_tim.Init.Direction = DMA_PERIPH_TO_MEMORY; + hdma_tim.Init.PeriphInc = DMA_PINC_DISABLE; + hdma_tim.Init.MemInc = DMA_MINC_ENABLE; + hdma_tim.Init.PeriphDataAlignment = DMA_PDATAALIGN_WORD; + hdma_tim.Init.MemDataAlignment = DMA_MDATAALIGN_WORD; + hdma_tim.Init.Mode = DMA_NORMAL; + hdma_tim.Init.Priority = DMA_PRIORITY_HIGH; + hdma_tim.Init.FIFOMode = DMA_FIFOMODE_DISABLE; + hdma_tim.Init.FIFOThreshold = DMA_FIFO_THRESHOLD_FULL; + hdma_tim.Init.MemBurst = DMA_MBURST_SINGLE; + hdma_tim.Init.PeriphBurst = DMA_PBURST_SINGLE; + + /* Link hdma_tim to hdma[2] (channel3) */ + __HAL_LINKDMA(htim, hdma[TIM_DMA_ID_CC2], hdma_tim); + + /* Initialize TIMx DMA handle */ + if (HAL_DMA_Init(&hdma_tim) != HAL_OK) { + Error_Handler(); + } + } +} + +void HAL_UART_MspInit(UART_HandleTypeDef* huart) +{ + GPIO_InitTypeDef GPIO_InitStruct; + + if (huart->Instance == USART1) { + /* Peripheral clock enable */ + __USART1_CLK_ENABLE(); + + /**USART1 GPIO Configuration + PA9 ------> USART1_TX + PA10 ------> USART1_RX + */ + GPIO_InitStruct.Pin = GPIO_PIN_9 | GPIO_PIN_10; + GPIO_InitStruct.Mode = GPIO_MODE_AF_PP; + GPIO_InitStruct.Pull = GPIO_PULLUP; + GPIO_InitStruct.Speed = GPIO_SPEED_FAST; + GPIO_InitStruct.Alternate = GPIO_AF7_USART1; + HAL_GPIO_Init(GPIOA, &GPIO_InitStruct); + + /* NVIC for interrupt mode */ + HAL_NVIC_SetPriority(USART1_IRQn, 0, 1); + HAL_NVIC_EnableIRQ(USART1_IRQn); + } +} + +void HAL_UART_MspDeInit(UART_HandleTypeDef* huart) +{ + if (huart->Instance == USART1) { + /* Peripheral clock disable */ + __USART1_CLK_DISABLE(); + + /**USART1 GPIO Configuration + PA9 ------> USART1_TX + PA10 ------> USART1_RX + */ + HAL_GPIO_DeInit(GPIOA, GPIO_PIN_9 | GPIO_PIN_10); + } +} + +/** + * @brief This function is executed in case of error occurrence. + * @param None + * @retval None + */ +static void Error_Handler(void) +{ + /* Turn on RED LED and then loop indefinitely */ + HAL_GPIO_WritePin(LED_PORT, LED_RED, GPIO_PIN_SET); + + while (1) { ; } +} diff --git a/src/entropy/stm32f4xx_it.c b/src/entropy/stm32f4xx_it.c index 17a7cf9..231b4fc 100644 --- a/src/entropy/stm32f4xx_it.c +++ b/src/entropy/stm32f4xx_it.c @@ -1,11 +1,11 @@ /** ****************************************************************************** - * @file GPIO/GPIO_IOToggle/Src/stm32f4xx_it.c + * @file GPIO/GPIO_IOToggle/Src/stm32f4xx_it.c * @author MCD Application Team * @version V1.0.1 * @date 26-February-2014 * @brief Main Interrupt Service Routines. - * This file provides template for all exceptions handler and + * This file provides template for all exceptions handler and * peripherals interrupt service routine. ****************************************************************************** * @attention @@ -191,7 +191,7 @@ void DMA1_Stream6_IRQHandler(void) /** * @} - */ + */ /** * @} diff --git a/src/led-test/stm32f4xx_it.c b/src/led-test/stm32f4xx_it.c index e387408..42d8713 100644 --- a/src/led-test/stm32f4xx_it.c +++ b/src/led-test/stm32f4xx_it.c @@ -1,11 +1,11 @@ /** ****************************************************************************** - * @file GPIO/GPIO_IOToggle/Src/stm32f4xx_it.c + * @file GPIO/GPIO_IOToggle/Src/stm32f4xx_it.c * @author MCD Application Team * @version V1.0.1 * @date 26-February-2014 * @brief Main Interrupt Service Routines. - * This file provides template for all exceptions handler and + * This file provides template for all exceptions handler and * peripherals interrupt service routine. ****************************************************************************** * @attention @@ -180,7 +180,7 @@ void SysTick_Handler(void) /** * @} - */ + */ /** * @} diff --git a/src/led-test/system_stm32f4xx.c b/src/led-test/system_stm32f4xx.c index 3068a90..35f79ba 100644 --- a/src/led-test/system_stm32f4xx.c +++ b/src/led-test/system_stm32f4xx.c @@ -6,16 +6,16 @@ * @date 26-February-2014 * @brief CMSIS Cortex-M4 Device Peripheral Access Layer System Source File. * - * This file provides two functions and one global variable to be called from + * This file provides two functions and one global variable to be called from * user application: - * - SystemInit(): This function is called at startup just after reset and + * - SystemInit(): This function is called at startup just after reset and * before branch to main program. This call is made inside * the "startup_stm32f4xx.s" file. * * - SystemCoreClock variable: Contains the core clock (HCLK), it can be used - * by the user application to setup the SysTick + * 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. @@ -57,8 +57,8 @@ /** @addtogroup stm32f4xx_system * @{ - */ - + */ + /** @addtogroup STM32F4xx_System_Private_Includes * @{ */ @@ -86,7 +86,7 @@ /*!< Uncomment the following line if you need to relocate your vector Table in Internal SRAM. */ /* #define VECT_TAB_SRAM */ -#define VECT_TAB_OFFSET 0x00 /*!< Vector Table base offset field. +#define VECT_TAB_OFFSET 0x00 /*!< Vector Table base offset field. This value must be a multiple of 0x200. */ /******************************************************************************/ @@ -108,7 +108,7 @@ /* 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 + 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. @@ -134,7 +134,7 @@ /** * @brief Setup the microcontroller system - * Initialize the FPU setting, vector table location and External memory + * Initialize the FPU setting, vector table location and External memory * configuration. * @param None * @retval None @@ -177,41 +177,41 @@ void SystemInit(void) * 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 + * 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(**) + * + * - If SYSCLK source is PLL, SystemCoreClock will contain the HSE_VALUE(**) * or HSI_VALUE(*) multiplied/divided by the PLL factors. - * + * * (*) HSI_VALUE is a constant defined in stm32f4xx_hal_conf.h file (default value * 16 MHz) but the real value may vary depending on the variations - * in voltage and temperature. - * + * in voltage and temperature. + * * (**) HSE_VALUE is a constant defined in stm32f4xx_hal_conf.h file (its value * depends on the application requirements), 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, pllvco = 0, pllp = 2, pllsource = 0, pllm = 2; - + /* Get SYSCLK source -------------------------------------------------------*/ tmp = RCC->CFGR & RCC_CFGR_SWS; @@ -227,10 +227,10 @@ void SystemCoreClockUpdate(void) /* PLL_VCO = (HSE_VALUE or HSI_VALUE / PLL_M) * PLL_N SYSCLK = PLL_VCO / PLL_P - */ + */ pllsource = (RCC->PLLCFGR & RCC_PLLCFGR_PLLSRC) >> 22; pllm = RCC->PLLCFGR & RCC_PLLCFGR_PLLM; - + if (pllsource != 0) { /* HSE used as PLL clock source */ @@ -263,8 +263,8 @@ void SystemCoreClockUpdate(void) /** * @} */ - + /** * @} - */ + */ /************************ (C) COPYRIGHT STMicroelectronics *****END OF FILE****/ diff --git a/src/uart-test/stm32f4xx_hal_msp.c b/src/uart-test/stm32f4xx_hal_msp.c index 2b1da7e..7cee9ce 100644 --- a/src/uart-test/stm32f4xx_hal_msp.c +++ b/src/uart-test/stm32f4xx_hal_msp.c @@ -1,42 +1,42 @@ -/*
- * Init/de-init USART1.
- *
- * Pins used:
- *
- * PA9: USART1_TX
- * PA10: USART1_RX
- */
-
-#include "stm32f4xx_hal.h"
-
-
-void HAL_UART_MspInit(UART_HandleTypeDef* huart)
-{
- GPIO_InitTypeDef GPIO_InitStruct;
-
- if (huart->Instance == USART1) {
- /* Peripheral clock enable */
- __USART1_CLK_ENABLE();
- GPIO_InitStruct.Pin = GPIO_PIN_9 | GPIO_PIN_10;
- GPIO_InitStruct.Mode = GPIO_MODE_AF_PP;
- GPIO_InitStruct.Pull = GPIO_PULLUP;
- GPIO_InitStruct.Speed = GPIO_SPEED_FAST;
- GPIO_InitStruct.Alternate = GPIO_AF7_USART1;
- HAL_GPIO_Init(GPIOA, &GPIO_InitStruct);
-
- /* NVIC for interrupt mode */
- HAL_NVIC_SetPriority(USART1_IRQn, 0, 1);
- HAL_NVIC_EnableIRQ(USART1_IRQn);
- }
-
-}
-
-void HAL_UART_MspDeInit(UART_HandleTypeDef* huart)
-{
-
- if (huart->Instance == USART1) {
- __USART1_CLK_DISABLE();
- HAL_GPIO_DeInit(GPIOA, GPIO_PIN_9 | GPIO_PIN_10);
- }
-
-}
+/* + * Init/de-init USART1. + * + * Pins used: + * + * PA9: USART1_TX + * PA10: USART1_RX + */ + +#include "stm32f4xx_hal.h" + + +void HAL_UART_MspInit(UART_HandleTypeDef* huart) +{ + GPIO_InitTypeDef GPIO_InitStruct; + + if (huart->Instance == USART1) { + /* Peripheral clock enable */ + __USART1_CLK_ENABLE(); + GPIO_InitStruct.Pin = GPIO_PIN_9 | GPIO_PIN_10; + GPIO_InitStruct.Mode = GPIO_MODE_AF_PP; + GPIO_InitStruct.Pull = GPIO_PULLUP; + GPIO_InitStruct.Speed = GPIO_SPEED_FAST; + GPIO_InitStruct.Alternate = GPIO_AF7_USART1; + HAL_GPIO_Init(GPIOA, &GPIO_InitStruct); + + /* NVIC for interrupt mode */ + HAL_NVIC_SetPriority(USART1_IRQn, 0, 1); + HAL_NVIC_EnableIRQ(USART1_IRQn); + } + +} + +void HAL_UART_MspDeInit(UART_HandleTypeDef* huart) +{ + + if (huart->Instance == USART1) { + __USART1_CLK_DISABLE(); + HAL_GPIO_DeInit(GPIOA, GPIO_PIN_9 | GPIO_PIN_10); + } + +} diff --git a/src/uart-test/stm32f4xx_it.c b/src/uart-test/stm32f4xx_it.c index 4dcf0e9..4e5bd89 100644 --- a/src/uart-test/stm32f4xx_it.c +++ b/src/uart-test/stm32f4xx_it.c @@ -1,11 +1,11 @@ /** ****************************************************************************** - * @file GPIO/GPIO_IOToggle/Src/stm32f4xx_it.c + * @file GPIO/GPIO_IOToggle/Src/stm32f4xx_it.c * @author MCD Application Team * @version V1.0.1 * @date 26-February-2014 * @brief Main Interrupt Service Routines. - * This file provides template for all exceptions handler and + * This file provides template for all exceptions handler and * peripherals interrupt service routine. ****************************************************************************** * @attention @@ -192,7 +192,7 @@ void USART1_IRQHandler(void) /** * @} - */ + */ /** * @} diff --git a/src/uart-test/system_stm32f4xx.c b/src/uart-test/system_stm32f4xx.c index 3068a90..35f79ba 100644 --- a/src/uart-test/system_stm32f4xx.c +++ b/src/uart-test/system_stm32f4xx.c @@ -6,16 +6,16 @@ * @date 26-February-2014 * @brief CMSIS Cortex-M4 Device Peripheral Access Layer System Source File. * - * This file provides two functions and one global variable to be called from + * This file provides two functions and one global variable to be called from * user application: - * - SystemInit(): This function is called at startup just after reset and + * - SystemInit(): This function is called at startup just after reset and * before branch to main program. This call is made inside * the "startup_stm32f4xx.s" file. * * - SystemCoreClock variable: Contains the core clock (HCLK), it can be used - * by the user application to setup the SysTick + * 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. @@ -57,8 +57,8 @@ /** @addtogroup stm32f4xx_system * @{ - */ - + */ + /** @addtogroup STM32F4xx_System_Private_Includes * @{ */ @@ -86,7 +86,7 @@ /*!< Uncomment the following line if you need to relocate your vector Table in Internal SRAM. */ /* #define VECT_TAB_SRAM */ -#define VECT_TAB_OFFSET 0x00 /*!< Vector Table base offset field. +#define VECT_TAB_OFFSET 0x00 /*!< Vector Table base offset field. This value must be a multiple of 0x200. */ /******************************************************************************/ @@ -108,7 +108,7 @@ /* 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 + 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. @@ -134,7 +134,7 @@ /** * @brief Setup the microcontroller system - * Initialize the FPU setting, vector table location and External memory + * Initialize the FPU setting, vector table location and External memory * configuration. * @param None * @retval None @@ -177,41 +177,41 @@ void SystemInit(void) * 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 + * 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(**) + * + * - If SYSCLK source is PLL, SystemCoreClock will contain the HSE_VALUE(**) * or HSI_VALUE(*) multiplied/divided by the PLL factors. - * + * * (*) HSI_VALUE is a constant defined in stm32f4xx_hal_conf.h file (default value * 16 MHz) but the real value may vary depending on the variations - * in voltage and temperature. - * + * in voltage and temperature. + * * (**) HSE_VALUE is a constant defined in stm32f4xx_hal_conf.h file (its value * depends on the application requirements), 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, pllvco = 0, pllp = 2, pllsource = 0, pllm = 2; - + /* Get SYSCLK source -------------------------------------------------------*/ tmp = RCC->CFGR & RCC_CFGR_SWS; @@ -227,10 +227,10 @@ void SystemCoreClockUpdate(void) /* PLL_VCO = (HSE_VALUE or HSI_VALUE / PLL_M) * PLL_N SYSCLK = PLL_VCO / PLL_P - */ + */ pllsource = (RCC->PLLCFGR & RCC_PLLCFGR_PLLSRC) >> 22; pllm = RCC->PLLCFGR & RCC_PLLCFGR_PLLM; - + if (pllsource != 0) { /* HSE used as PLL clock source */ @@ -263,8 +263,8 @@ void SystemCoreClockUpdate(void) /** * @} */ - + /** * @} - */ + */ /************************ (C) COPYRIGHT STMicroelectronics *****END OF FILE****/ |