You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

104 lines
2.6 KiB

3 years ago
  1. /* USER CODE BEGIN Header */
  2. /**
  3. ******************************************************************************
  4. * @file tim.c
  5. * @brief This file provides code for the configuration
  6. * of the TIM instances.
  7. ******************************************************************************
  8. * @attention
  9. *
  10. * Copyright (c) 2023 STMicroelectronics.
  11. * All rights reserved.
  12. *
  13. * This software is licensed under terms that can be found in the LICENSE file
  14. * in the root directory of this software component.
  15. * If no LICENSE file comes with this software, it is provided AS-IS.
  16. *
  17. ******************************************************************************
  18. */
  19. /* USER CODE END Header */
  20. /* Includes ------------------------------------------------------------------*/
  21. #include "tim.h"
  22. /* USER CODE BEGIN 0 */
  23. /* USER CODE END 0 */
  24. TIM_HandleTypeDef htim6;
  25. /* TIM6 init function */
  26. void MX_TIM6_Init(void)
  27. {
  28. /* USER CODE BEGIN TIM6_Init 0 */
  29. /* USER CODE END TIM6_Init 0 */
  30. TIM_MasterConfigTypeDef sMasterConfig = {0};
  31. /* USER CODE BEGIN TIM6_Init 1 */
  32. /* USER CODE END TIM6_Init 1 */
  33. htim6.Instance = TIM6;
  34. htim6.Init.Prescaler = 84-1;
  35. htim6.Init.CounterMode = TIM_COUNTERMODE_UP;
  36. htim6.Init.Period = 1000-1;
  37. htim6.Init.AutoReloadPreload = TIM_AUTORELOAD_PRELOAD_ENABLE;
  38. if (HAL_TIM_Base_Init(&htim6) != HAL_OK)
  39. {
  40. Error_Handler();
  41. }
  42. sMasterConfig.MasterOutputTrigger = TIM_TRGO_RESET;
  43. sMasterConfig.MasterSlaveMode = TIM_MASTERSLAVEMODE_DISABLE;
  44. if (HAL_TIMEx_MasterConfigSynchronization(&htim6, &sMasterConfig) != HAL_OK)
  45. {
  46. Error_Handler();
  47. }
  48. /* USER CODE BEGIN TIM6_Init 2 */
  49. /* USER CODE END TIM6_Init 2 */
  50. }
  51. void HAL_TIM_Base_MspInit(TIM_HandleTypeDef* tim_baseHandle)
  52. {
  53. if(tim_baseHandle->Instance==TIM6)
  54. {
  55. /* USER CODE BEGIN TIM6_MspInit 0 */
  56. /* USER CODE END TIM6_MspInit 0 */
  57. /* TIM6 clock enable */
  58. __HAL_RCC_TIM6_CLK_ENABLE();
  59. /* TIM6 interrupt Init */
  60. HAL_NVIC_SetPriority(TIM6_DAC_IRQn, 5, 0);
  61. HAL_NVIC_EnableIRQ(TIM6_DAC_IRQn);
  62. /* USER CODE BEGIN TIM6_MspInit 1 */
  63. /* USER CODE END TIM6_MspInit 1 */
  64. }
  65. }
  66. void HAL_TIM_Base_MspDeInit(TIM_HandleTypeDef* tim_baseHandle)
  67. {
  68. if(tim_baseHandle->Instance==TIM6)
  69. {
  70. /* USER CODE BEGIN TIM6_MspDeInit 0 */
  71. /* USER CODE END TIM6_MspDeInit 0 */
  72. /* Peripheral clock disable */
  73. __HAL_RCC_TIM6_CLK_DISABLE();
  74. /* TIM6 interrupt Deinit */
  75. HAL_NVIC_DisableIRQ(TIM6_DAC_IRQn);
  76. /* USER CODE BEGIN TIM6_MspDeInit 1 */
  77. /* USER CODE END TIM6_MspDeInit 1 */
  78. }
  79. }
  80. /* USER CODE BEGIN 1 */
  81. /* USER CODE END 1 */