Rev 2 | Show entire file | Ignore whitespace | Details | Blame | Last modification | View Log | RSS feed
| Rev 2 | Rev 5 | ||
|---|---|---|---|
| Line 1... | Line 1... | ||
| 1 | /** |
1 | /** |
| 2 | ****************************************************************************** |
2 | ****************************************************************************** |
| 3 | * @file stm32f1xx_hal_tim.c |
3 | * @file stm32f1xx_hal_tim.c |
| 4 | * @author MCD Application Team |
4 | * @author MCD Application Team |
| 5 | * @version V1.0.1 |
5 | * @version V1.0.4 |
| 6 | * @date 31-July-2015 |
6 | * @date 29-April-2016 |
| 7 | * @brief TIM HAL module driver |
7 | * @brief TIM HAL module driver |
| 8 | * This file provides firmware functions to manage the following |
8 | * This file provides firmware functions to manage the following |
| 9 | * functionalities of the Timer (TIM) peripheral: |
9 | * functionalities of the Timer (TIM) peripheral: |
| 10 | * + Time Base Initialization |
10 | * + Time Base Initialization |
| 11 | * + Time Base Start |
11 | * + Time Base Start |
| Line 59... | Line 59... | ||
| 59 | 59 | ||
| 60 | (#) Initialize the TIM low level resources : |
60 | (#) Initialize the TIM low level resources : |
| 61 | (##) Enable the TIM interface clock using __HAL_RCC_TIMx_CLK_ENABLE(); |
61 | (##) Enable the TIM interface clock using __HAL_RCC_TIMx_CLK_ENABLE(); |
| 62 | (##) TIM pins configuration |
62 | (##) TIM pins configuration |
| 63 | (+++) Enable the clock for the TIM GPIOs using the following function: |
63 | (+++) Enable the clock for the TIM GPIOs using the following function: |
| 64 | __HAL_GPIOx_CLK_ENABLE(); |
64 | __HAL_RCC_GPIOx_CLK_ENABLE(); |
| 65 | (+++) Configure these TIM pins in Alternate function mode using HAL_GPIO_Init(); |
65 | (+++) Configure these TIM pins in Alternate function mode using HAL_GPIO_Init(); |
| 66 | 66 | ||
| 67 | (#) The external Clock can be configured, if needed (the default clock is the |
67 | (#) The external Clock can be configured, if needed (the default clock is the |
| 68 | internal clock from the APBx), using the following function: |
68 | internal clock from the APBx), using the following function: |
| 69 | HAL_TIM_ConfigClockSource, the clock configuration should be done before |
69 | HAL_TIM_ConfigClockSource, the clock configuration should be done before |
| Line 96... | Line 96... | ||
| 96 | 96 | ||
| 97 | @endverbatim |
97 | @endverbatim |
| 98 | ****************************************************************************** |
98 | ****************************************************************************** |
| 99 | * @attention |
99 | * @attention |
| 100 | * |
100 | * |
| 101 | * <h2><center>© COPYRIGHT(c) 2015 STMicroelectronics</center></h2> |
101 | * <h2><center>© COPYRIGHT(c) 2016 STMicroelectronics</center></h2> |
| 102 | * |
102 | * |
| 103 | * Redistribution and use in source and binary forms, with or without modification, |
103 | * Redistribution and use in source and binary forms, with or without modification, |
| 104 | * are permitted provided that the following conditions are met: |
104 | * are permitted provided that the following conditions are met: |
| 105 | * 1. Redistributions of source code must retain the above copyright notice, |
105 | * 1. Redistributions of source code must retain the above copyright notice, |
| 106 | * this list of conditions and the following disclaimer. |
106 | * this list of conditions and the following disclaimer. |
| Line 269... | Line 269... | ||
| 269 | * @param htim : TIM handle |
269 | * @param htim : TIM handle |
| 270 | * @retval None |
270 | * @retval None |
| 271 | */ |
271 | */ |
| 272 | __weak void HAL_TIM_Base_MspInit(TIM_HandleTypeDef *htim) |
272 | __weak void HAL_TIM_Base_MspInit(TIM_HandleTypeDef *htim) |
| 273 | { |
273 | { |
| - | 274 | /* Prevent unused argument(s) compilation warning */ |
|
| - | 275 | UNUSED(htim); |
|
| 274 | /* NOTE : This function Should not be modified, when the callback is needed, |
276 | /* NOTE : This function Should not be modified, when the callback is needed, |
| 275 | the HAL_TIM_Base_MspInit could be implemented in the user file |
277 | the HAL_TIM_Base_MspInit could be implemented in the user file |
| 276 | */ |
278 | */ |
| 277 | } |
279 | } |
| 278 | 280 | ||
| Line 281... | Line 283... | ||
| 281 | * @param htim : TIM handle |
283 | * @param htim : TIM handle |
| 282 | * @retval None |
284 | * @retval None |
| 283 | */ |
285 | */ |
| 284 | __weak void HAL_TIM_Base_MspDeInit(TIM_HandleTypeDef *htim) |
286 | __weak void HAL_TIM_Base_MspDeInit(TIM_HandleTypeDef *htim) |
| 285 | { |
287 | { |
| - | 288 | /* Prevent unused argument(s) compilation warning */ |
|
| - | 289 | UNUSED(htim); |
|
| 286 | /* NOTE : This function Should not be modified, when the callback is needed, |
290 | /* NOTE : This function Should not be modified, when the callback is needed, |
| 287 | the HAL_TIM_Base_MspDeInit could be implemented in the user file |
291 | the HAL_TIM_Base_MspDeInit could be implemented in the user file |
| 288 | */ |
292 | */ |
| 289 | } |
293 | } |
| 290 | 294 | ||
| Line 540... | Line 544... | ||
| 540 | * @param htim : TIM handle |
544 | * @param htim : TIM handle |
| 541 | * @retval None |
545 | * @retval None |
| 542 | */ |
546 | */ |
| 543 | __weak void HAL_TIM_OC_MspInit(TIM_HandleTypeDef *htim) |
547 | __weak void HAL_TIM_OC_MspInit(TIM_HandleTypeDef *htim) |
| 544 | { |
548 | { |
| - | 549 | /* Prevent unused argument(s) compilation warning */ |
|
| - | 550 | UNUSED(htim); |
|
| 545 | /* NOTE : This function Should not be modified, when the callback is needed, |
551 | /* NOTE : This function Should not be modified, when the callback is needed, |
| 546 | the HAL_TIM_OC_MspInit could be implemented in the user file |
552 | the HAL_TIM_OC_MspInit could be implemented in the user file |
| 547 | */ |
553 | */ |
| 548 | } |
554 | } |
| 549 | 555 | ||
| Line 552... | Line 558... | ||
| 552 | * @param htim : TIM handle |
558 | * @param htim : TIM handle |
| 553 | * @retval None |
559 | * @retval None |
| 554 | */ |
560 | */ |
| 555 | __weak void HAL_TIM_OC_MspDeInit(TIM_HandleTypeDef *htim) |
561 | __weak void HAL_TIM_OC_MspDeInit(TIM_HandleTypeDef *htim) |
| 556 | { |
562 | { |
| - | 563 | /* Prevent unused argument(s) compilation warning */ |
|
| - | 564 | UNUSED(htim); |
|
| 557 | /* NOTE : This function Should not be modified, when the callback is needed, |
565 | /* NOTE : This function Should not be modified, when the callback is needed, |
| 558 | the HAL_TIM_OC_MspDeInit could be implemented in the user file |
566 | the HAL_TIM_OC_MspDeInit could be implemented in the user file |
| 559 | */ |
567 | */ |
| 560 | } |
568 | } |
| 561 | 569 | ||
| Line 1040... | Line 1048... | ||
| 1040 | * @param htim : TIM handle |
1048 | * @param htim : TIM handle |
| 1041 | * @retval None |
1049 | * @retval None |
| 1042 | */ |
1050 | */ |
| 1043 | __weak void HAL_TIM_PWM_MspInit(TIM_HandleTypeDef *htim) |
1051 | __weak void HAL_TIM_PWM_MspInit(TIM_HandleTypeDef *htim) |
| 1044 | { |
1052 | { |
| - | 1053 | /* Prevent unused argument(s) compilation warning */ |
|
| - | 1054 | UNUSED(htim); |
|
| 1045 | /* NOTE : This function Should not be modified, when the callback is needed, |
1055 | /* NOTE : This function Should not be modified, when the callback is needed, |
| 1046 | the HAL_TIM_PWM_MspInit could be implemented in the user file |
1056 | the HAL_TIM_PWM_MspInit could be implemented in the user file |
| 1047 | */ |
1057 | */ |
| 1048 | } |
1058 | } |
| 1049 | 1059 | ||
| Line 1052... | Line 1062... | ||
| 1052 | * @param htim : TIM handle |
1062 | * @param htim : TIM handle |
| 1053 | * @retval None |
1063 | * @retval None |
| 1054 | */ |
1064 | */ |
| 1055 | __weak void HAL_TIM_PWM_MspDeInit(TIM_HandleTypeDef *htim) |
1065 | __weak void HAL_TIM_PWM_MspDeInit(TIM_HandleTypeDef *htim) |
| 1056 | { |
1066 | { |
| - | 1067 | /* Prevent unused argument(s) compilation warning */ |
|
| - | 1068 | UNUSED(htim); |
|
| 1057 | /* NOTE : This function Should not be modified, when the callback is needed, |
1069 | /* NOTE : This function Should not be modified, when the callback is needed, |
| 1058 | the HAL_TIM_PWM_MspDeInit could be implemented in the user file |
1070 | the HAL_TIM_PWM_MspDeInit could be implemented in the user file |
| 1059 | */ |
1071 | */ |
| 1060 | } |
1072 | } |
| 1061 | 1073 | ||
| Line 1543... | Line 1555... | ||
| 1543 | * @param htim : TIM handle |
1555 | * @param htim : TIM handle |
| 1544 | * @retval None |
1556 | * @retval None |
| 1545 | */ |
1557 | */ |
| 1546 | __weak void HAL_TIM_IC_MspInit(TIM_HandleTypeDef *htim) |
1558 | __weak void HAL_TIM_IC_MspInit(TIM_HandleTypeDef *htim) |
| 1547 | { |
1559 | { |
| - | 1560 | /* Prevent unused argument(s) compilation warning */ |
|
| - | 1561 | UNUSED(htim); |
|
| 1548 | /* NOTE : This function Should not be modified, when the callback is needed, |
1562 | /* NOTE : This function Should not be modified, when the callback is needed, |
| 1549 | the HAL_TIM_IC_MspInit could be implemented in the user file |
1563 | the HAL_TIM_IC_MspInit could be implemented in the user file |
| 1550 | */ |
1564 | */ |
| 1551 | } |
1565 | } |
| 1552 | 1566 | ||
| Line 1555... | Line 1569... | ||
| 1555 | * @param htim : TIM handle |
1569 | * @param htim : TIM handle |
| 1556 | * @retval None |
1570 | * @retval None |
| 1557 | */ |
1571 | */ |
| 1558 | __weak void HAL_TIM_IC_MspDeInit(TIM_HandleTypeDef *htim) |
1572 | __weak void HAL_TIM_IC_MspDeInit(TIM_HandleTypeDef *htim) |
| 1559 | { |
1573 | { |
| - | 1574 | /* Prevent unused argument(s) compilation warning */ |
|
| - | 1575 | UNUSED(htim); |
|
| 1560 | /* NOTE : This function Should not be modified, when the callback is needed, |
1576 | /* NOTE : This function Should not be modified, when the callback is needed, |
| 1561 | the HAL_TIM_IC_MspDeInit could be implemented in the user file |
1577 | the HAL_TIM_IC_MspDeInit could be implemented in the user file |
| 1562 | */ |
1578 | */ |
| 1563 | } |
1579 | } |
| 1564 | 1580 | ||
| Line 2019... | Line 2035... | ||
| 2019 | * @param htim : TIM handle |
2035 | * @param htim : TIM handle |
| 2020 | * @retval None |
2036 | * @retval None |
| 2021 | */ |
2037 | */ |
| 2022 | __weak void HAL_TIM_OnePulse_MspInit(TIM_HandleTypeDef *htim) |
2038 | __weak void HAL_TIM_OnePulse_MspInit(TIM_HandleTypeDef *htim) |
| 2023 | { |
2039 | { |
| - | 2040 | /* Prevent unused argument(s) compilation warning */ |
|
| - | 2041 | UNUSED(htim); |
|
| 2024 | /* NOTE : This function Should not be modified, when the callback is needed, |
2042 | /* NOTE : This function Should not be modified, when the callback is needed, |
| 2025 | the HAL_TIM_OnePulse_MspInit could be implemented in the user file |
2043 | the HAL_TIM_OnePulse_MspInit could be implemented in the user file |
| 2026 | */ |
2044 | */ |
| 2027 | } |
2045 | } |
| 2028 | 2046 | ||
| Line 2031... | Line 2049... | ||
| 2031 | * @param htim : TIM handle |
2049 | * @param htim : TIM handle |
| 2032 | * @retval None |
2050 | * @retval None |
| 2033 | */ |
2051 | */ |
| 2034 | __weak void HAL_TIM_OnePulse_MspDeInit(TIM_HandleTypeDef *htim) |
2052 | __weak void HAL_TIM_OnePulse_MspDeInit(TIM_HandleTypeDef *htim) |
| 2035 | { |
2053 | { |
| - | 2054 | /* Prevent unused argument(s) compilation warning */ |
|
| - | 2055 | UNUSED(htim); |
|
| 2036 | /* NOTE : This function Should not be modified, when the callback is needed, |
2056 | /* NOTE : This function Should not be modified, when the callback is needed, |
| 2037 | the HAL_TIM_OnePulse_MspDeInit could be implemented in the user file |
2057 | the HAL_TIM_OnePulse_MspDeInit could be implemented in the user file |
| 2038 | */ |
2058 | */ |
| 2039 | } |
2059 | } |
| 2040 | 2060 | ||
| Line 2329... | Line 2349... | ||
| 2329 | * @param htim : TIM handle |
2349 | * @param htim : TIM handle |
| 2330 | * @retval None |
2350 | * @retval None |
| 2331 | */ |
2351 | */ |
| 2332 | __weak void HAL_TIM_Encoder_MspInit(TIM_HandleTypeDef *htim) |
2352 | __weak void HAL_TIM_Encoder_MspInit(TIM_HandleTypeDef *htim) |
| 2333 | { |
2353 | { |
| - | 2354 | /* Prevent unused argument(s) compilation warning */ |
|
| - | 2355 | UNUSED(htim); |
|
| 2334 | /* NOTE : This function Should not be modified, when the callback is needed, |
2356 | /* NOTE : This function Should not be modified, when the callback is needed, |
| 2335 | the HAL_TIM_Encoder_MspInit could be implemented in the user file |
2357 | the HAL_TIM_Encoder_MspInit could be implemented in the user file |
| 2336 | */ |
2358 | */ |
| 2337 | } |
2359 | } |
| 2338 | 2360 | ||
| Line 2341... | Line 2363... | ||
| 2341 | * @param htim : TIM handle |
2363 | * @param htim : TIM handle |
| 2342 | * @retval None |
2364 | * @retval None |
| 2343 | */ |
2365 | */ |
| 2344 | __weak void HAL_TIM_Encoder_MspDeInit(TIM_HandleTypeDef *htim) |
2366 | __weak void HAL_TIM_Encoder_MspDeInit(TIM_HandleTypeDef *htim) |
| 2345 | { |
2367 | { |
| - | 2368 | /* Prevent unused argument(s) compilation warning */ |
|
| - | 2369 | UNUSED(htim); |
|
| 2346 | /* NOTE : This function Should not be modified, when the callback is needed, |
2370 | /* NOTE : This function Should not be modified, when the callback is needed, |
| 2347 | the HAL_TIM_Encoder_MspDeInit could be implemented in the user file |
2371 | the HAL_TIM_Encoder_MspDeInit could be implemented in the user file |
| 2348 | */ |
2372 | */ |
| 2349 | } |
2373 | } |
| 2350 | 2374 | ||
| Line 2892... | Line 2916... | ||
| 2892 | { |
2916 | { |
| 2893 | /* Check the parameters */ |
2917 | /* Check the parameters */ |
| 2894 | assert_param(IS_TIM_CHANNELS(Channel)); |
2918 | assert_param(IS_TIM_CHANNELS(Channel)); |
| 2895 | assert_param(IS_TIM_OC_MODE(sConfig->OCMode)); |
2919 | assert_param(IS_TIM_OC_MODE(sConfig->OCMode)); |
| 2896 | assert_param(IS_TIM_OC_POLARITY(sConfig->OCPolarity)); |
2920 | assert_param(IS_TIM_OC_POLARITY(sConfig->OCPolarity)); |
| 2897 | assert_param(IS_TIM_OCN_POLARITY(sConfig->OCNPolarity)); |
- | |
| 2898 | assert_param(IS_TIM_OCNIDLE_STATE(sConfig->OCNIdleState)); |
- | |
| 2899 | assert_param(IS_TIM_OCIDLE_STATE(sConfig->OCIdleState)); |
- | |
| 2900 | 2921 | ||
| 2901 | /* Check input state */ |
2922 | /* Check input state */ |
| 2902 | __HAL_LOCK(htim); |
2923 | __HAL_LOCK(htim); |
| 2903 | 2924 | ||
| 2904 | htim->State = HAL_TIM_STATE_BUSY; |
2925 | htim->State = HAL_TIM_STATE_BUSY; |
| Line 3062... | Line 3083... | ||
| 3062 | 3083 | ||
| 3063 | /* Check the parameters */ |
3084 | /* Check the parameters */ |
| 3064 | assert_param(IS_TIM_CHANNELS(Channel)); |
3085 | assert_param(IS_TIM_CHANNELS(Channel)); |
| 3065 | assert_param(IS_TIM_PWM_MODE(sConfig->OCMode)); |
3086 | assert_param(IS_TIM_PWM_MODE(sConfig->OCMode)); |
| 3066 | assert_param(IS_TIM_OC_POLARITY(sConfig->OCPolarity)); |
3087 | assert_param(IS_TIM_OC_POLARITY(sConfig->OCPolarity)); |
| 3067 | assert_param(IS_TIM_OCN_POLARITY(sConfig->OCNPolarity)); |
- | |
| 3068 | assert_param(IS_TIM_FAST_STATE(sConfig->OCFastMode)); |
3088 | assert_param(IS_TIM_FAST_STATE(sConfig->OCFastMode)); |
| 3069 | assert_param(IS_TIM_OCNIDLE_STATE(sConfig->OCNIdleState)); |
- | |
| 3070 | assert_param(IS_TIM_OCIDLE_STATE(sConfig->OCIdleState)); |
- | |
| 3071 | 3089 | ||
| 3072 | htim->State = HAL_TIM_STATE_BUSY; |
3090 | htim->State = HAL_TIM_STATE_BUSY; |
| 3073 | 3091 | ||
| 3074 | switch (Channel) |
3092 | switch (Channel) |
| 3075 | { |
3093 | { |
| Line 3893... | Line 3911... | ||
| 3893 | 3911 | ||
| 3894 | htim->State = HAL_TIM_STATE_BUSY; |
3912 | htim->State = HAL_TIM_STATE_BUSY; |
| 3895 | 3913 | ||
| 3896 | /* Check the parameters */ |
3914 | /* Check the parameters */ |
| 3897 | assert_param(IS_TIM_CLOCKSOURCE(sClockSourceConfig->ClockSource)); |
3915 | assert_param(IS_TIM_CLOCKSOURCE(sClockSourceConfig->ClockSource)); |
| 3898 | assert_param(IS_TIM_CLOCKPOLARITY(sClockSourceConfig->ClockPolarity)); |
- | |
| 3899 | assert_param(IS_TIM_CLOCKPRESCALER(sClockSourceConfig->ClockPrescaler)); |
- | |
| 3900 | assert_param(IS_TIM_CLOCKFILTER(sClockSourceConfig->ClockFilter)); |
- | |
| 3901 | 3916 | ||
| 3902 | /* Reset the SMS, TS, ECE, ETPS and ETRF bits */ |
3917 | /* Reset the SMS, TS, ECE, ETPS and ETRF bits */ |
| 3903 | tmpsmcr = htim->Instance->SMCR; |
3918 | tmpsmcr = htim->Instance->SMCR; |
| 3904 | tmpsmcr &= ~(TIM_SMCR_SMS | TIM_SMCR_TS); |
3919 | tmpsmcr &= ~(TIM_SMCR_SMS | TIM_SMCR_TS); |
| 3905 | tmpsmcr &= ~(TIM_SMCR_ETF | TIM_SMCR_ETPS | TIM_SMCR_ECE | TIM_SMCR_ETP); |
3920 | tmpsmcr &= ~(TIM_SMCR_ETF | TIM_SMCR_ETPS | TIM_SMCR_ECE | TIM_SMCR_ETP); |
| Line 3918... | Line 3933... | ||
| 3918 | case TIM_CLOCKSOURCE_ETRMODE1: |
3933 | case TIM_CLOCKSOURCE_ETRMODE1: |
| 3919 | { |
3934 | { |
| 3920 | /* Check whether or not the timer instance supports external trigger input mode 1 (ETRF)*/ |
3935 | /* Check whether or not the timer instance supports external trigger input mode 1 (ETRF)*/ |
| 3921 | assert_param(IS_TIM_CLOCKSOURCE_ETRMODE1_INSTANCE(htim->Instance)); |
3936 | assert_param(IS_TIM_CLOCKSOURCE_ETRMODE1_INSTANCE(htim->Instance)); |
| 3922 | 3937 | ||
| - | 3938 | /* Check ETR input conditioning related parameters */ |
|
| - | 3939 | assert_param(IS_TIM_CLOCKPRESCALER(sClockSourceConfig->ClockPrescaler)); |
|
| - | 3940 | assert_param(IS_TIM_CLOCKPOLARITY(sClockSourceConfig->ClockPolarity)); |
|
| - | 3941 | assert_param(IS_TIM_CLOCKFILTER(sClockSourceConfig->ClockFilter)); |
|
| - | 3942 | ||
| 3923 | /* Configure the ETR Clock source */ |
3943 | /* Configure the ETR Clock source */ |
| 3924 | TIM_ETR_SetConfig(htim->Instance, |
3944 | TIM_ETR_SetConfig(htim->Instance, |
| 3925 | sClockSourceConfig->ClockPrescaler, |
3945 | sClockSourceConfig->ClockPrescaler, |
| 3926 | sClockSourceConfig->ClockPolarity, |
3946 | sClockSourceConfig->ClockPolarity, |
| 3927 | sClockSourceConfig->ClockFilter); |
3947 | sClockSourceConfig->ClockFilter); |
| Line 3939... | Line 3959... | ||
| 3939 | case TIM_CLOCKSOURCE_ETRMODE2: |
3959 | case TIM_CLOCKSOURCE_ETRMODE2: |
| 3940 | { |
3960 | { |
| 3941 | /* Check whether or not the timer instance supports external trigger input mode 2 (ETRF)*/ |
3961 | /* Check whether or not the timer instance supports external trigger input mode 2 (ETRF)*/ |
| 3942 | assert_param(IS_TIM_CLOCKSOURCE_ETRMODE2_INSTANCE(htim->Instance)); |
3962 | assert_param(IS_TIM_CLOCKSOURCE_ETRMODE2_INSTANCE(htim->Instance)); |
| 3943 | 3963 | ||
| - | 3964 | /* Check ETR input conditioning related parameters */ |
|
| - | 3965 | assert_param(IS_TIM_CLOCKPRESCALER(sClockSourceConfig->ClockPrescaler)); |
|
| - | 3966 | assert_param(IS_TIM_CLOCKPOLARITY(sClockSourceConfig->ClockPolarity)); |
|
| - | 3967 | assert_param(IS_TIM_CLOCKFILTER(sClockSourceConfig->ClockFilter)); |
|
| - | 3968 | ||
| 3944 | /* Configure the ETR Clock source */ |
3969 | /* Configure the ETR Clock source */ |
| 3945 | TIM_ETR_SetConfig(htim->Instance, |
3970 | TIM_ETR_SetConfig(htim->Instance, |
| 3946 | sClockSourceConfig->ClockPrescaler, |
3971 | sClockSourceConfig->ClockPrescaler, |
| 3947 | sClockSourceConfig->ClockPolarity, |
3972 | sClockSourceConfig->ClockPolarity, |
| 3948 | sClockSourceConfig->ClockFilter); |
3973 | sClockSourceConfig->ClockFilter); |
| Line 3954... | Line 3979... | ||
| 3954 | case TIM_CLOCKSOURCE_TI1: |
3979 | case TIM_CLOCKSOURCE_TI1: |
| 3955 | { |
3980 | { |
| 3956 | /* Check whether or not the timer instance supports external clock mode 1 */ |
3981 | /* Check whether or not the timer instance supports external clock mode 1 */ |
| 3957 | assert_param(IS_TIM_CLOCKSOURCE_TIX_INSTANCE(htim->Instance)); |
3982 | assert_param(IS_TIM_CLOCKSOURCE_TIX_INSTANCE(htim->Instance)); |
| 3958 | 3983 | ||
| - | 3984 | /* Check TI1 input conditioning related parameters */ |
|
| - | 3985 | assert_param(IS_TIM_CLOCKPOLARITY(sClockSourceConfig->ClockPolarity)); |
|
| - | 3986 | assert_param(IS_TIM_CLOCKFILTER(sClockSourceConfig->ClockFilter)); |
|
| - | 3987 | ||
| 3959 | TIM_TI1_ConfigInputStage(htim->Instance, |
3988 | TIM_TI1_ConfigInputStage(htim->Instance, |
| 3960 | sClockSourceConfig->ClockPolarity, |
3989 | sClockSourceConfig->ClockPolarity, |
| 3961 | sClockSourceConfig->ClockFilter); |
3990 | sClockSourceConfig->ClockFilter); |
| 3962 | TIM_ITRx_SetConfig(htim->Instance, TIM_CLOCKSOURCE_TI1); |
3991 | TIM_ITRx_SetConfig(htim->Instance, TIM_CLOCKSOURCE_TI1); |
| 3963 | } |
3992 | } |
| Line 3965... | Line 3994... | ||
| 3965 | case TIM_CLOCKSOURCE_TI2: |
3994 | case TIM_CLOCKSOURCE_TI2: |
| 3966 | { |
3995 | { |
| 3967 | /* Check whether or not the timer instance supports external clock mode 1 (ETRF)*/ |
3996 | /* Check whether or not the timer instance supports external clock mode 1 (ETRF)*/ |
| 3968 | assert_param(IS_TIM_CLOCKSOURCE_TIX_INSTANCE(htim->Instance)); |
3997 | assert_param(IS_TIM_CLOCKSOURCE_TIX_INSTANCE(htim->Instance)); |
| 3969 | 3998 | ||
| - | 3999 | /* Check TI2 input conditioning related parameters */ |
|
| - | 4000 | assert_param(IS_TIM_CLOCKPOLARITY(sClockSourceConfig->ClockPolarity)); |
|
| - | 4001 | assert_param(IS_TIM_CLOCKFILTER(sClockSourceConfig->ClockFilter)); |
|
| - | 4002 | ||
| 3970 | TIM_TI2_ConfigInputStage(htim->Instance, |
4003 | TIM_TI2_ConfigInputStage(htim->Instance, |
| 3971 | sClockSourceConfig->ClockPolarity, |
4004 | sClockSourceConfig->ClockPolarity, |
| 3972 | sClockSourceConfig->ClockFilter); |
4005 | sClockSourceConfig->ClockFilter); |
| 3973 | TIM_ITRx_SetConfig(htim->Instance, TIM_CLOCKSOURCE_TI2); |
4006 | TIM_ITRx_SetConfig(htim->Instance, TIM_CLOCKSOURCE_TI2); |
| 3974 | } |
4007 | } |
| Line 3976... | Line 4009... | ||
| 3976 | case TIM_CLOCKSOURCE_TI1ED: |
4009 | case TIM_CLOCKSOURCE_TI1ED: |
| 3977 | { |
4010 | { |
| 3978 | /* Check whether or not the timer instance supports external clock mode 1 */ |
4011 | /* Check whether or not the timer instance supports external clock mode 1 */ |
| 3979 | assert_param(IS_TIM_CLOCKSOURCE_TIX_INSTANCE(htim->Instance)); |
4012 | assert_param(IS_TIM_CLOCKSOURCE_TIX_INSTANCE(htim->Instance)); |
| 3980 | 4013 | ||
| - | 4014 | /* Check TI1 input conditioning related parameters */ |
|
| - | 4015 | assert_param(IS_TIM_CLOCKPOLARITY(sClockSourceConfig->ClockPolarity)); |
|
| - | 4016 | assert_param(IS_TIM_CLOCKFILTER(sClockSourceConfig->ClockFilter)); |
|
| - | 4017 | ||
| 3981 | TIM_TI1_ConfigInputStage(htim->Instance, |
4018 | TIM_TI1_ConfigInputStage(htim->Instance, |
| 3982 | sClockSourceConfig->ClockPolarity, |
4019 | sClockSourceConfig->ClockPolarity, |
| 3983 | sClockSourceConfig->ClockFilter); |
4020 | sClockSourceConfig->ClockFilter); |
| 3984 | TIM_ITRx_SetConfig(htim->Instance, TIM_CLOCKSOURCE_TI1ED); |
4021 | TIM_ITRx_SetConfig(htim->Instance, TIM_CLOCKSOURCE_TI1ED); |
| 3985 | } |
4022 | } |
| Line 4231... | Line 4268... | ||
| 4231 | * @param htim : TIM handle |
4268 | * @param htim : TIM handle |
| 4232 | * @retval None |
4269 | * @retval None |
| 4233 | */ |
4270 | */ |
| 4234 | __weak void HAL_TIM_PeriodElapsedCallback(TIM_HandleTypeDef *htim) |
4271 | __weak void HAL_TIM_PeriodElapsedCallback(TIM_HandleTypeDef *htim) |
| 4235 | { |
4272 | { |
| - | 4273 | /* Prevent unused argument(s) compilation warning */ |
|
| - | 4274 | UNUSED(htim); |
|
| 4236 | /* NOTE : This function Should not be modified, when the callback is needed, |
4275 | /* NOTE : This function Should not be modified, when the callback is needed, |
| 4237 | the __HAL_TIM_PeriodElapsedCallback could be implemented in the user file |
4276 | the __HAL_TIM_PeriodElapsedCallback could be implemented in the user file |
| 4238 | */ |
4277 | */ |
| 4239 | 4278 | ||
| 4240 | } |
4279 | } |
| Line 4243... | Line 4282... | ||
| 4243 | * @param htim : TIM OC handle |
4282 | * @param htim : TIM OC handle |
| 4244 | * @retval None |
4283 | * @retval None |
| 4245 | */ |
4284 | */ |
| 4246 | __weak void HAL_TIM_OC_DelayElapsedCallback(TIM_HandleTypeDef *htim) |
4285 | __weak void HAL_TIM_OC_DelayElapsedCallback(TIM_HandleTypeDef *htim) |
| 4247 | { |
4286 | { |
| - | 4287 | /* Prevent unused argument(s) compilation warning */ |
|
| - | 4288 | UNUSED(htim); |
|
| 4248 | /* NOTE : This function Should not be modified, when the callback is needed, |
4289 | /* NOTE : This function Should not be modified, when the callback is needed, |
| 4249 | the __HAL_TIM_OC_DelayElapsedCallback could be implemented in the user file |
4290 | the __HAL_TIM_OC_DelayElapsedCallback could be implemented in the user file |
| 4250 | */ |
4291 | */ |
| 4251 | } |
4292 | } |
| 4252 | /** |
4293 | /** |
| Line 4254... | Line 4295... | ||
| 4254 | * @param htim : TIM IC handle |
4295 | * @param htim : TIM IC handle |
| 4255 | * @retval None |
4296 | * @retval None |
| 4256 | */ |
4297 | */ |
| 4257 | __weak void HAL_TIM_IC_CaptureCallback(TIM_HandleTypeDef *htim) |
4298 | __weak void HAL_TIM_IC_CaptureCallback(TIM_HandleTypeDef *htim) |
| 4258 | { |
4299 | { |
| - | 4300 | /* Prevent unused argument(s) compilation warning */ |
|
| - | 4301 | UNUSED(htim); |
|
| 4259 | /* NOTE : This function Should not be modified, when the callback is needed, |
4302 | /* NOTE : This function Should not be modified, when the callback is needed, |
| 4260 | the __HAL_TIM_IC_CaptureCallback could be implemented in the user file |
4303 | the __HAL_TIM_IC_CaptureCallback could be implemented in the user file |
| 4261 | */ |
4304 | */ |
| 4262 | } |
4305 | } |
| 4263 | 4306 | ||
| Line 4266... | Line 4309... | ||
| 4266 | * @param htim : TIM handle |
4309 | * @param htim : TIM handle |
| 4267 | * @retval None |
4310 | * @retval None |
| 4268 | */ |
4311 | */ |
| 4269 | __weak void HAL_TIM_PWM_PulseFinishedCallback(TIM_HandleTypeDef *htim) |
4312 | __weak void HAL_TIM_PWM_PulseFinishedCallback(TIM_HandleTypeDef *htim) |
| 4270 | { |
4313 | { |
| - | 4314 | /* Prevent unused argument(s) compilation warning */ |
|
| - | 4315 | UNUSED(htim); |
|
| 4271 | /* NOTE : This function Should not be modified, when the callback is needed, |
4316 | /* NOTE : This function Should not be modified, when the callback is needed, |
| 4272 | the __HAL_TIM_PWM_PulseFinishedCallback could be implemented in the user file |
4317 | the __HAL_TIM_PWM_PulseFinishedCallback could be implemented in the user file |
| 4273 | */ |
4318 | */ |
| 4274 | } |
4319 | } |
| 4275 | 4320 | ||
| Line 4278... | Line 4323... | ||
| 4278 | * @param htim : TIM handle |
4323 | * @param htim : TIM handle |
| 4279 | * @retval None |
4324 | * @retval None |
| 4280 | */ |
4325 | */ |
| 4281 | __weak void HAL_TIM_TriggerCallback(TIM_HandleTypeDef *htim) |
4326 | __weak void HAL_TIM_TriggerCallback(TIM_HandleTypeDef *htim) |
| 4282 | { |
4327 | { |
| - | 4328 | /* Prevent unused argument(s) compilation warning */ |
|
| - | 4329 | UNUSED(htim); |
|
| 4283 | /* NOTE : This function Should not be modified, when the callback is needed, |
4330 | /* NOTE : This function Should not be modified, when the callback is needed, |
| 4284 | the HAL_TIM_TriggerCallback could be implemented in the user file |
4331 | the HAL_TIM_TriggerCallback could be implemented in the user file |
| 4285 | */ |
4332 | */ |
| 4286 | } |
4333 | } |
| 4287 | 4334 | ||
| Line 4290... | Line 4337... | ||
| 4290 | * @param htim : TIM handle |
4337 | * @param htim : TIM handle |
| 4291 | * @retval None |
4338 | * @retval None |
| 4292 | */ |
4339 | */ |
| 4293 | __weak void HAL_TIM_ErrorCallback(TIM_HandleTypeDef *htim) |
4340 | __weak void HAL_TIM_ErrorCallback(TIM_HandleTypeDef *htim) |
| 4294 | { |
4341 | { |
| - | 4342 | /* Prevent unused argument(s) compilation warning */ |
|
| - | 4343 | UNUSED(htim); |
|
| 4295 | /* NOTE : This function Should not be modified, when the callback is needed, |
4344 | /* NOTE : This function Should not be modified, when the callback is needed, |
| 4296 | the HAL_TIM_ErrorCallback could be implemented in the user file |
4345 | the HAL_TIM_ErrorCallback could be implemented in the user file |
| 4297 | */ |
4346 | */ |
| 4298 | } |
4347 | } |
| 4299 | 4348 | ||
| Line 4650... | Line 4699... | ||
| 4650 | tmpccer |= (OC_Config->OCPolarity << 4); |
4699 | tmpccer |= (OC_Config->OCPolarity << 4); |
| 4651 | 4700 | ||
| 4652 | if(IS_TIM_CCXN_INSTANCE(TIMx, TIM_CHANNEL_2)) |
4701 | if(IS_TIM_CCXN_INSTANCE(TIMx, TIM_CHANNEL_2)) |
| 4653 | { |
4702 | { |
| 4654 | assert_param(IS_TIM_OCN_POLARITY(OC_Config->OCNPolarity)); |
4703 | assert_param(IS_TIM_OCN_POLARITY(OC_Config->OCNPolarity)); |
| 4655 | assert_param(IS_TIM_OCNIDLE_STATE(OC_Config->OCNIdleState)); |
- | |
| 4656 | assert_param(IS_TIM_OCIDLE_STATE(OC_Config->OCIdleState)); |
- | |
| 4657 | 4704 | ||
| 4658 | /* Reset the Output N Polarity level */ |
4705 | /* Reset the Output N Polarity level */ |
| 4659 | tmpccer &= ~TIM_CCER_CC2NP; |
4706 | tmpccer &= ~TIM_CCER_CC2NP; |
| 4660 | /* Set the Output N Polarity */ |
4707 | /* Set the Output N Polarity */ |
| 4661 | tmpccer |= (OC_Config->OCNPolarity << 4); |
4708 | tmpccer |= (OC_Config->OCNPolarity << 4); |
| Line 4727... | Line 4774... | ||
| 4727 | tmpccer |= (OC_Config->OCPolarity << 8); |
4774 | tmpccer |= (OC_Config->OCPolarity << 8); |
| 4728 | 4775 | ||
| 4729 | if(IS_TIM_CCXN_INSTANCE(TIMx, TIM_CHANNEL_3)) |
4776 | if(IS_TIM_CCXN_INSTANCE(TIMx, TIM_CHANNEL_3)) |
| 4730 | { |
4777 | { |
| 4731 | assert_param(IS_TIM_OCN_POLARITY(OC_Config->OCNPolarity)); |
4778 | assert_param(IS_TIM_OCN_POLARITY(OC_Config->OCNPolarity)); |
| 4732 | assert_param(IS_TIM_OCNIDLE_STATE(OC_Config->OCNIdleState)); |
- | |
| 4733 | assert_param(IS_TIM_OCIDLE_STATE(OC_Config->OCIdleState)); |
- | |
| 4734 | 4779 | ||
| 4735 | /* Reset the Output N Polarity level */ |
4780 | /* Reset the Output N Polarity level */ |
| 4736 | tmpccer &= ~TIM_CCER_CC3NP; |
4781 | tmpccer &= ~TIM_CCER_CC3NP; |
| 4737 | /* Set the Output N Polarity */ |
4782 | /* Set the Output N Polarity */ |
| 4738 | tmpccer |= (OC_Config->OCNPolarity << 8); |
4783 | tmpccer |= (OC_Config->OCNPolarity << 8); |
| Line 5192... | Line 5237... | ||
| 5192 | * @arg TIM_ICSELECTION_DIRECTTI: TIM Input 4 is selected to be connected to IC4. |
5237 | * @arg TIM_ICSELECTION_DIRECTTI: TIM Input 4 is selected to be connected to IC4. |
| 5193 | * @arg TIM_ICSELECTION_INDIRECTTI: TIM Input 4 is selected to be connected to IC3. |
5238 | * @arg TIM_ICSELECTION_INDIRECTTI: TIM Input 4 is selected to be connected to IC3. |
| 5194 | * @arg TIM_ICSELECTION_TRC: TIM Input 4 is selected to be connected to TRC. |
5239 | * @arg TIM_ICSELECTION_TRC: TIM Input 4 is selected to be connected to TRC. |
| 5195 | * @param TIM_ICFilter : Specifies the Input Capture Filter. |
5240 | * @param TIM_ICFilter : Specifies the Input Capture Filter. |
| 5196 | * This parameter must be a value between 0x00 and 0x0F. |
5241 | * This parameter must be a value between 0x00 and 0x0F. |
| 5197 | * @retval None |
- | |
| 5198 | * @note TIM_ICFilter and TIM_ICPolarity are not used in INDIRECT mode as TI4FP3 |
5242 | * @note TIM_ICFilter and TIM_ICPolarity are not used in INDIRECT mode as TI4FP3 |
| 5199 | * (on channel1 path) is used as the input signal. Therefore CCMR2 must be |
5243 | * (on channel1 path) is used as the input signal. Therefore CCMR2 must be |
| 5200 | * protected against un-initialized filter and polarity values. |
5244 | * protected against un-initialized filter and polarity values. |
| - | 5245 | * @retval None |
|
| 5201 | */ |
5246 | */ |
| 5202 | static void TIM_TI4_SetConfig(TIM_TypeDef *TIMx, uint32_t TIM_ICPolarity, uint32_t TIM_ICSelection, |
5247 | static void TIM_TI4_SetConfig(TIM_TypeDef *TIMx, uint32_t TIM_ICPolarity, uint32_t TIM_ICSelection, |
| 5203 | uint32_t TIM_ICFilter) |
5248 | uint32_t TIM_ICFilter) |
| 5204 | { |
5249 | { |
| 5205 | uint32_t tmpccmr2 = 0; |
5250 | uint32_t tmpccmr2 = 0; |