tim.c 2.7 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106
  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) 2025 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 htim15;
  25. /* TIM15 init function */
  26. void MX_TIM15_Init(void)
  27. {
  28. /* USER CODE BEGIN TIM15_Init 0 */
  29. /* USER CODE END TIM15_Init 0 */
  30. TIM_ClockConfigTypeDef sClockSourceConfig = {0};
  31. TIM_MasterConfigTypeDef sMasterConfig = {0};
  32. /* USER CODE BEGIN TIM15_Init 1 */
  33. /* USER CODE END TIM15_Init 1 */
  34. htim15.Instance = TIM15;
  35. htim15.Init.Prescaler = 16-1;
  36. htim15.Init.CounterMode = TIM_COUNTERMODE_UP;
  37. htim15.Init.Period = 65535;
  38. htim15.Init.ClockDivision = TIM_CLOCKDIVISION_DIV1;
  39. htim15.Init.RepetitionCounter = 0;
  40. htim15.Init.AutoReloadPreload = TIM_AUTORELOAD_PRELOAD_DISABLE;
  41. if (HAL_TIM_Base_Init(&htim15) != HAL_OK)
  42. {
  43. Error_Handler();
  44. }
  45. sClockSourceConfig.ClockSource = TIM_CLOCKSOURCE_INTERNAL;
  46. if (HAL_TIM_ConfigClockSource(&htim15, &sClockSourceConfig) != HAL_OK)
  47. {
  48. Error_Handler();
  49. }
  50. sMasterConfig.MasterOutputTrigger = TIM_TRGO_RESET;
  51. sMasterConfig.MasterSlaveMode = TIM_MASTERSLAVEMODE_DISABLE;
  52. if (HAL_TIMEx_MasterConfigSynchronization(&htim15, &sMasterConfig) != HAL_OK)
  53. {
  54. Error_Handler();
  55. }
  56. /* USER CODE BEGIN TIM15_Init 2 */
  57. /* USER CODE END TIM15_Init 2 */
  58. }
  59. void HAL_TIM_Base_MspInit(TIM_HandleTypeDef* tim_baseHandle)
  60. {
  61. if(tim_baseHandle->Instance==TIM15)
  62. {
  63. /* USER CODE BEGIN TIM15_MspInit 0 */
  64. /* USER CODE END TIM15_MspInit 0 */
  65. /* TIM15 clock enable */
  66. __HAL_RCC_TIM15_CLK_ENABLE();
  67. /* USER CODE BEGIN TIM15_MspInit 1 */
  68. /* USER CODE END TIM15_MspInit 1 */
  69. }
  70. }
  71. void HAL_TIM_Base_MspDeInit(TIM_HandleTypeDef* tim_baseHandle)
  72. {
  73. if(tim_baseHandle->Instance==TIM15)
  74. {
  75. /* USER CODE BEGIN TIM15_MspDeInit 0 */
  76. /* USER CODE END TIM15_MspDeInit 0 */
  77. /* Peripheral clock disable */
  78. __HAL_RCC_TIM15_CLK_DISABLE();
  79. /* USER CODE BEGIN TIM15_MspDeInit 1 */
  80. /* USER CODE END TIM15_MspDeInit 1 */
  81. }
  82. }
  83. /* USER CODE BEGIN 1 */
  84. /* USER CODE END 1 */