Subversion Repositories dashGPS

Rev

Rev 9 | Rev 13 | Go to most recent revision | Blame | Compare with Previous | Last modification | View Log | Download | RSS feed

  1. /* USER CODE BEGIN Header */
  2. /**
  3.   ******************************************************************************
  4.   * File Name          : stm32f1xx_hal_msp.c
  5.   * Description        : This file provides code for the MSP Initialization
  6.   *                      and de-Initialization codes.
  7.   ******************************************************************************
  8.   * @attention
  9.   *
  10.   * <h2><center>&copy; Copyright (c) 2020 STMicroelectronics.
  11.   * All rights reserved.</center></h2>
  12.   *
  13.   * This software component is licensed by ST under BSD 3-Clause license,
  14.   * the "License"; You may not use this file except in compliance with the
  15.   * License. You may obtain a copy of the License at:
  16.   *                        opensource.org/licenses/BSD-3-Clause
  17.   *
  18.   ******************************************************************************
  19.   */
  20. /* USER CODE END Header */
  21.  
  22. /* Includes ------------------------------------------------------------------*/
  23. #include "main.h"
  24. /* USER CODE BEGIN Includes */
  25.  
  26. /* USER CODE END Includes */
  27.  
  28. /* Private typedef -----------------------------------------------------------*/
  29. /* USER CODE BEGIN TD */
  30.  
  31. /* USER CODE END TD */
  32.  
  33. /* Private define ------------------------------------------------------------*/
  34. /* USER CODE BEGIN Define */
  35.  
  36. /* USER CODE END Define */
  37.  
  38. /* Private macro -------------------------------------------------------------*/
  39. /* USER CODE BEGIN Macro */
  40.  
  41. /* USER CODE END Macro */
  42.  
  43. /* Private variables ---------------------------------------------------------*/
  44. /* USER CODE BEGIN PV */
  45.  
  46. /* USER CODE END PV */
  47.  
  48. /* Private function prototypes -----------------------------------------------*/
  49. /* USER CODE BEGIN PFP */
  50.  
  51. /* USER CODE END PFP */
  52.  
  53. /* External functions --------------------------------------------------------*/
  54. /* USER CODE BEGIN ExternalFunctions */
  55.  
  56. /* USER CODE END ExternalFunctions */
  57.  
  58. /* USER CODE BEGIN 0 */
  59.  
  60. /* USER CODE END 0 */
  61. /**
  62.   * Initializes the Global MSP.
  63.   */
  64. void HAL_MspInit(void)
  65. {
  66.   /* USER CODE BEGIN MspInit 0 */
  67.  
  68.   /* USER CODE END MspInit 0 */
  69.  
  70.   __HAL_RCC_AFIO_CLK_ENABLE();
  71.   __HAL_RCC_PWR_CLK_ENABLE();
  72.  
  73.   /* System interrupt init*/
  74.  
  75.   /** NOJTAG: JTAG-DP Disabled and SW-DP Enabled
  76.   */
  77.   __HAL_AFIO_REMAP_SWJ_NOJTAG();
  78.  
  79.   /* USER CODE BEGIN MspInit 1 */
  80.  
  81.   /* USER CODE END MspInit 1 */
  82. }
  83.  
  84. /**
  85. * @brief CAN MSP Initialization
  86. * This function configures the hardware resources used in this example
  87. * @param hcan: CAN handle pointer
  88. * @retval None
  89. */
  90. void HAL_CAN_MspInit(CAN_HandleTypeDef* hcan)
  91. {
  92.   GPIO_InitTypeDef GPIO_InitStruct = {0};
  93.   if(hcan->Instance==CAN1)
  94.   {
  95.   /* USER CODE BEGIN CAN1_MspInit 0 */
  96.  
  97.   /* USER CODE END CAN1_MspInit 0 */
  98.     /* Peripheral clock enable */
  99.     __HAL_RCC_CAN1_CLK_ENABLE();
  100.  
  101.     __HAL_RCC_GPIOA_CLK_ENABLE();
  102.     /**CAN GPIO Configuration
  103.     PA11     ------> CAN_RX
  104.     PA12     ------> CAN_TX
  105.     */
  106.     GPIO_InitStruct.Pin = GPIO_PIN_11;
  107.     GPIO_InitStruct.Mode = GPIO_MODE_INPUT;
  108.     GPIO_InitStruct.Pull = GPIO_NOPULL;
  109.     HAL_GPIO_Init(GPIOA, &GPIO_InitStruct);
  110.  
  111.     GPIO_InitStruct.Pin = GPIO_PIN_12;
  112.     GPIO_InitStruct.Mode = GPIO_MODE_AF_PP;
  113.     GPIO_InitStruct.Speed = GPIO_SPEED_FREQ_HIGH;
  114.     HAL_GPIO_Init(GPIOA, &GPIO_InitStruct);
  115.  
  116.   /* USER CODE BEGIN CAN1_MspInit 1 */
  117.  
  118.   /* USER CODE END CAN1_MspInit 1 */
  119.   }
  120.  
  121. }
  122.  
  123. /**
  124. * @brief CAN MSP De-Initialization
  125. * This function freeze the hardware resources used in this example
  126. * @param hcan: CAN handle pointer
  127. * @retval None
  128. */
  129. void HAL_CAN_MspDeInit(CAN_HandleTypeDef* hcan)
  130. {
  131.   if(hcan->Instance==CAN1)
  132.   {
  133.   /* USER CODE BEGIN CAN1_MspDeInit 0 */
  134.  
  135.   /* USER CODE END CAN1_MspDeInit 0 */
  136.     /* Peripheral clock disable */
  137.     __HAL_RCC_CAN1_CLK_DISABLE();
  138.  
  139.     /**CAN GPIO Configuration
  140.     PA11     ------> CAN_RX
  141.     PA12     ------> CAN_TX
  142.     */
  143.     HAL_GPIO_DeInit(GPIOA, GPIO_PIN_11|GPIO_PIN_12);
  144.  
  145.   /* USER CODE BEGIN CAN1_MspDeInit 1 */
  146.  
  147.   /* USER CODE END CAN1_MspDeInit 1 */
  148.   }
  149.  
  150. }
  151.  
  152. /**
  153. * @brief I2C MSP Initialization
  154. * This function configures the hardware resources used in this example
  155. * @param hi2c: I2C handle pointer
  156. * @retval None
  157. */
  158. void HAL_I2C_MspInit(I2C_HandleTypeDef* hi2c)
  159. {
  160.   GPIO_InitTypeDef GPIO_InitStruct = {0};
  161.   if(hi2c->Instance==I2C2)
  162.   {
  163.   /* USER CODE BEGIN I2C2_MspInit 0 */
  164.  
  165.   /* USER CODE END I2C2_MspInit 0 */
  166.  
  167.     __HAL_RCC_GPIOB_CLK_ENABLE();
  168.     /**I2C2 GPIO Configuration
  169.     PB10     ------> I2C2_SCL
  170.     PB11     ------> I2C2_SDA
  171.     */
  172.     GPIO_InitStruct.Pin = GPIO_PIN_10|GPIO_PIN_11;
  173.     GPIO_InitStruct.Mode = GPIO_MODE_AF_OD;
  174.     GPIO_InitStruct.Speed = GPIO_SPEED_FREQ_HIGH;
  175.     HAL_GPIO_Init(GPIOB, &GPIO_InitStruct);
  176.  
  177.     /* Peripheral clock enable */
  178.     __HAL_RCC_I2C2_CLK_ENABLE();
  179.   /* USER CODE BEGIN I2C2_MspInit 1 */
  180.  
  181.   /* USER CODE END I2C2_MspInit 1 */
  182.   }
  183.  
  184. }
  185.  
  186. /**
  187. * @brief I2C MSP De-Initialization
  188. * This function freeze the hardware resources used in this example
  189. * @param hi2c: I2C handle pointer
  190. * @retval None
  191. */
  192. void HAL_I2C_MspDeInit(I2C_HandleTypeDef* hi2c)
  193. {
  194.   if(hi2c->Instance==I2C2)
  195.   {
  196.   /* USER CODE BEGIN I2C2_MspDeInit 0 */
  197.  
  198.   /* USER CODE END I2C2_MspDeInit 0 */
  199.     /* Peripheral clock disable */
  200.     __HAL_RCC_I2C2_CLK_DISABLE();
  201.  
  202.     /**I2C2 GPIO Configuration
  203.     PB10     ------> I2C2_SCL
  204.     PB11     ------> I2C2_SDA
  205.     */
  206.     HAL_GPIO_DeInit(GPIOB, GPIO_PIN_10);
  207.  
  208.     HAL_GPIO_DeInit(GPIOB, GPIO_PIN_11);
  209.  
  210.   /* USER CODE BEGIN I2C2_MspDeInit 1 */
  211.  
  212.   /* USER CODE END I2C2_MspDeInit 1 */
  213.   }
  214.  
  215. }
  216.  
  217. /**
  218. * @brief SPI MSP Initialization
  219. * This function configures the hardware resources used in this example
  220. * @param hspi: SPI handle pointer
  221. * @retval None
  222. */
  223. void HAL_SPI_MspInit(SPI_HandleTypeDef* hspi)
  224. {
  225.   GPIO_InitTypeDef GPIO_InitStruct = {0};
  226.   if(hspi->Instance==SPI1)
  227.   {
  228.   /* USER CODE BEGIN SPI1_MspInit 0 */
  229.  
  230.   /* USER CODE END SPI1_MspInit 0 */
  231.     /* Peripheral clock enable */
  232.     __HAL_RCC_SPI1_CLK_ENABLE();
  233.  
  234.     __HAL_RCC_GPIOA_CLK_ENABLE();
  235.     /**SPI1 GPIO Configuration
  236.     PA5     ------> SPI1_SCK
  237.     PA7     ------> SPI1_MOSI
  238.     */
  239.     GPIO_InitStruct.Pin = SPI_SCK_Pin|SPI_MOSI_Pin;
  240.     GPIO_InitStruct.Mode = GPIO_MODE_AF_PP;
  241.     GPIO_InitStruct.Speed = GPIO_SPEED_FREQ_HIGH;
  242.     HAL_GPIO_Init(GPIOA, &GPIO_InitStruct);
  243.  
  244.   /* USER CODE BEGIN SPI1_MspInit 1 */
  245.  
  246.   /* USER CODE END SPI1_MspInit 1 */
  247.   }
  248.  
  249. }
  250.  
  251. /**
  252. * @brief SPI MSP De-Initialization
  253. * This function freeze the hardware resources used in this example
  254. * @param hspi: SPI handle pointer
  255. * @retval None
  256. */
  257. void HAL_SPI_MspDeInit(SPI_HandleTypeDef* hspi)
  258. {
  259.   if(hspi->Instance==SPI1)
  260.   {
  261.   /* USER CODE BEGIN SPI1_MspDeInit 0 */
  262.  
  263.   /* USER CODE END SPI1_MspDeInit 0 */
  264.     /* Peripheral clock disable */
  265.     __HAL_RCC_SPI1_CLK_DISABLE();
  266.  
  267.     /**SPI1 GPIO Configuration
  268.     PA5     ------> SPI1_SCK
  269.     PA7     ------> SPI1_MOSI
  270.     */
  271.     HAL_GPIO_DeInit(GPIOA, SPI_SCK_Pin|SPI_MOSI_Pin);
  272.  
  273.   /* USER CODE BEGIN SPI1_MspDeInit 1 */
  274.  
  275.   /* USER CODE END SPI1_MspDeInit 1 */
  276.   }
  277.  
  278. }
  279.  
  280. /**
  281. * @brief TIM_OC MSP Initialization
  282. * This function configures the hardware resources used in this example
  283. * @param htim_oc: TIM_OC handle pointer
  284. * @retval None
  285. */
  286. void HAL_TIM_OC_MspInit(TIM_HandleTypeDef* htim_oc)
  287. {
  288.   if(htim_oc->Instance==TIM3)
  289.   {
  290.   /* USER CODE BEGIN TIM3_MspInit 0 */
  291.  
  292.   /* USER CODE END TIM3_MspInit 0 */
  293.     /* Peripheral clock enable */
  294.     __HAL_RCC_TIM3_CLK_ENABLE();
  295.   /* USER CODE BEGIN TIM3_MspInit 1 */
  296.  
  297.   /* USER CODE END TIM3_MspInit 1 */
  298.   }
  299.  
  300. }
  301.  
  302. /**
  303. * @brief TIM_Encoder MSP Initialization
  304. * This function configures the hardware resources used in this example
  305. * @param htim_encoder: TIM_Encoder handle pointer
  306. * @retval None
  307. */
  308. void HAL_TIM_Encoder_MspInit(TIM_HandleTypeDef* htim_encoder)
  309. {
  310.   GPIO_InitTypeDef GPIO_InitStruct = {0};
  311.   if(htim_encoder->Instance==TIM4)
  312.   {
  313.   /* USER CODE BEGIN TIM4_MspInit 0 */
  314.  
  315.   /* USER CODE END TIM4_MspInit 0 */
  316.     /* Peripheral clock enable */
  317.     __HAL_RCC_TIM4_CLK_ENABLE();
  318.  
  319.     __HAL_RCC_GPIOB_CLK_ENABLE();
  320.     /**TIM4 GPIO Configuration
  321.     PB6     ------> TIM4_CH1
  322.     PB7     ------> TIM4_CH2
  323.     */
  324.     GPIO_InitStruct.Pin = GPIO_PIN_6|GPIO_PIN_7;
  325.     GPIO_InitStruct.Mode = GPIO_MODE_INPUT;
  326.     GPIO_InitStruct.Pull = GPIO_NOPULL;
  327.     HAL_GPIO_Init(GPIOB, &GPIO_InitStruct);
  328.  
  329.   /* USER CODE BEGIN TIM4_MspInit 1 */
  330.  
  331.   /* USER CODE END TIM4_MspInit 1 */
  332.   }
  333.  
  334. }
  335.  
  336. /**
  337. * @brief TIM_OC MSP De-Initialization
  338. * This function freeze the hardware resources used in this example
  339. * @param htim_oc: TIM_OC handle pointer
  340. * @retval None
  341. */
  342. void HAL_TIM_OC_MspDeInit(TIM_HandleTypeDef* htim_oc)
  343. {
  344.   if(htim_oc->Instance==TIM3)
  345.   {
  346.   /* USER CODE BEGIN TIM3_MspDeInit 0 */
  347.  
  348.   /* USER CODE END TIM3_MspDeInit 0 */
  349.     /* Peripheral clock disable */
  350.     __HAL_RCC_TIM3_CLK_DISABLE();
  351.   /* USER CODE BEGIN TIM3_MspDeInit 1 */
  352.  
  353.   /* USER CODE END TIM3_MspDeInit 1 */
  354.   }
  355.  
  356. }
  357.  
  358. /**
  359. * @brief TIM_Encoder MSP De-Initialization
  360. * This function freeze the hardware resources used in this example
  361. * @param htim_encoder: TIM_Encoder handle pointer
  362. * @retval None
  363. */
  364. void HAL_TIM_Encoder_MspDeInit(TIM_HandleTypeDef* htim_encoder)
  365. {
  366.   if(htim_encoder->Instance==TIM4)
  367.   {
  368.   /* USER CODE BEGIN TIM4_MspDeInit 0 */
  369.  
  370.   /* USER CODE END TIM4_MspDeInit 0 */
  371.     /* Peripheral clock disable */
  372.     __HAL_RCC_TIM4_CLK_DISABLE();
  373.  
  374.     /**TIM4 GPIO Configuration
  375.     PB6     ------> TIM4_CH1
  376.     PB7     ------> TIM4_CH2
  377.     */
  378.     HAL_GPIO_DeInit(GPIOB, GPIO_PIN_6|GPIO_PIN_7);
  379.  
  380.   /* USER CODE BEGIN TIM4_MspDeInit 1 */
  381.  
  382.   /* USER CODE END TIM4_MspDeInit 1 */
  383.   }
  384.  
  385. }
  386.  
  387. /**
  388. * @brief UART MSP Initialization
  389. * This function configures the hardware resources used in this example
  390. * @param huart: UART handle pointer
  391. * @retval None
  392. */
  393. void HAL_UART_MspInit(UART_HandleTypeDef* huart)
  394. {
  395.   GPIO_InitTypeDef GPIO_InitStruct = {0};
  396.   if(huart->Instance==USART1)
  397.   {
  398.   /* USER CODE BEGIN USART1_MspInit 0 */
  399.  
  400.   /* USER CODE END USART1_MspInit 0 */
  401.     /* Peripheral clock enable */
  402.     __HAL_RCC_USART1_CLK_ENABLE();
  403.  
  404.     __HAL_RCC_GPIOA_CLK_ENABLE();
  405.     /**USART1 GPIO Configuration
  406.     PA9     ------> USART1_TX
  407.     PA10     ------> USART1_RX
  408.     */
  409.     GPIO_InitStruct.Pin = GPIO_PIN_9;
  410.     GPIO_InitStruct.Mode = GPIO_MODE_AF_PP;
  411.     GPIO_InitStruct.Speed = GPIO_SPEED_FREQ_HIGH;
  412.     HAL_GPIO_Init(GPIOA, &GPIO_InitStruct);
  413.  
  414.     GPIO_InitStruct.Pin = GPIO_PIN_10;
  415.     GPIO_InitStruct.Mode = GPIO_MODE_INPUT;
  416.     GPIO_InitStruct.Pull = GPIO_NOPULL;
  417.     HAL_GPIO_Init(GPIOA, &GPIO_InitStruct);
  418.  
  419.     /* USART1 interrupt Init */
  420.     HAL_NVIC_SetPriority(USART1_IRQn, 0, 0);
  421.     HAL_NVIC_EnableIRQ(USART1_IRQn);
  422.   /* USER CODE BEGIN USART1_MspInit 1 */
  423.  
  424.   /* USER CODE END USART1_MspInit 1 */
  425.   }
  426.  
  427. }
  428.  
  429. /**
  430. * @brief UART MSP De-Initialization
  431. * This function freeze the hardware resources used in this example
  432. * @param huart: UART handle pointer
  433. * @retval None
  434. */
  435. void HAL_UART_MspDeInit(UART_HandleTypeDef* huart)
  436. {
  437.   if(huart->Instance==USART1)
  438.   {
  439.   /* USER CODE BEGIN USART1_MspDeInit 0 */
  440.  
  441.   /* USER CODE END USART1_MspDeInit 0 */
  442.     /* Peripheral clock disable */
  443.     __HAL_RCC_USART1_CLK_DISABLE();
  444.  
  445.     /**USART1 GPIO Configuration
  446.     PA9     ------> USART1_TX
  447.     PA10     ------> USART1_RX
  448.     */
  449.     HAL_GPIO_DeInit(GPIOA, GPIO_PIN_9|GPIO_PIN_10);
  450.  
  451.     /* USART1 interrupt DeInit */
  452.     HAL_NVIC_DisableIRQ(USART1_IRQn);
  453.   /* USER CODE BEGIN USART1_MspDeInit 1 */
  454.  
  455.   /* USER CODE END USART1_MspDeInit 1 */
  456.   }
  457.  
  458. }
  459.  
  460. /* USER CODE BEGIN 1 */
  461.  
  462. /* USER CODE END 1 */
  463.  
  464. /************************ (C) COPYRIGHT STMicroelectronics *****END OF FILE****/
  465.