Rev 2 | Show entire file | Ignore whitespace | Details | Blame | Last modification | View Log | RSS feed
| Rev 2 | Rev 6 | ||
|---|---|---|---|
| Line 80... | Line 80... | ||
| 80 | ============================================= |
80 | ============================================= |
| 81 | 81 | ||
| 82 | [..] |
82 | [..] |
| 83 | The compilation flag USE_HAL_TSC_REGISTER_CALLBACKS when set to 1 |
83 | The compilation flag USE_HAL_TSC_REGISTER_CALLBACKS when set to 1 |
| 84 | allows the user to configure dynamically the driver callbacks. |
84 | allows the user to configure dynamically the driver callbacks. |
| 85 | Use Functions @ref HAL_TSC_RegisterCallback() to register an interrupt callback. |
85 | Use Functions HAL_TSC_RegisterCallback() to register an interrupt callback. |
| 86 | 86 | ||
| 87 | [..] |
87 | [..] |
| 88 | Function @ref HAL_TSC_RegisterCallback() allows to register following callbacks: |
88 | Function HAL_TSC_RegisterCallback() allows to register following callbacks: |
| 89 | (+) ConvCpltCallback : callback for conversion complete process. |
89 | (+) ConvCpltCallback : callback for conversion complete process. |
| 90 | (+) ErrorCallback : callback for error detection. |
90 | (+) ErrorCallback : callback for error detection. |
| 91 | (+) MspInitCallback : callback for Msp Init. |
91 | (+) MspInitCallback : callback for Msp Init. |
| 92 | (+) MspDeInitCallback : callback for Msp DeInit. |
92 | (+) MspDeInitCallback : callback for Msp DeInit. |
| 93 | [..] |
93 | [..] |
| 94 | This function takes as parameters the HAL peripheral handle, the Callback ID |
94 | This function takes as parameters the HAL peripheral handle, the Callback ID |
| 95 | and a pointer to the user callback function. |
95 | and a pointer to the user callback function. |
| 96 | 96 | ||
| 97 | [..] |
97 | [..] |
| 98 | Use function @ref HAL_TSC_UnRegisterCallback to reset a callback to the default |
98 | Use function HAL_TSC_UnRegisterCallback to reset a callback to the default |
| 99 | weak function. |
99 | weak function. |
| 100 | @ref HAL_TSC_UnRegisterCallback takes as parameters the HAL peripheral handle, |
100 | HAL_TSC_UnRegisterCallback takes as parameters the HAL peripheral handle, |
| 101 | and the Callback ID. |
101 | and the Callback ID. |
| 102 | [..] |
102 | [..] |
| 103 | This function allows to reset following callbacks: |
103 | This function allows to reset following callbacks: |
| 104 | (+) ConvCpltCallback : callback for conversion complete process. |
104 | (+) ConvCpltCallback : callback for conversion complete process. |
| 105 | (+) ErrorCallback : callback for error detection. |
105 | (+) ErrorCallback : callback for error detection. |
| 106 | (+) MspInitCallback : callback for Msp Init. |
106 | (+) MspInitCallback : callback for Msp Init. |
| 107 | (+) MspDeInitCallback : callback for Msp DeInit. |
107 | (+) MspDeInitCallback : callback for Msp DeInit. |
| 108 | 108 | ||
| 109 | [..] |
109 | [..] |
| 110 | By default, after the @ref HAL_TSC_Init() and when the state is @ref HAL_TSC_STATE_RESET |
110 | By default, after the HAL_TSC_Init() and when the state is HAL_TSC_STATE_RESET |
| 111 | all callbacks are set to the corresponding weak functions: |
111 | all callbacks are set to the corresponding weak functions: |
| 112 | examples @ref HAL_TSC_ConvCpltCallback(), @ref HAL_TSC_ErrorCallback(). |
112 | examples HAL_TSC_ConvCpltCallback(), HAL_TSC_ErrorCallback(). |
| 113 | Exception done for MspInit and MspDeInit functions that are |
113 | Exception done for MspInit and MspDeInit functions that are |
| 114 | reset to the legacy weak functions in the @ref HAL_TSC_Init()/ @ref HAL_TSC_DeInit() only when |
114 | reset to the legacy weak functions in the HAL_TSC_Init()/ HAL_TSC_DeInit() only when |
| 115 | these callbacks are null (not registered beforehand). |
115 | these callbacks are null (not registered beforehand). |
| 116 | If MspInit or MspDeInit are not null, the @ref HAL_TSC_Init()/ @ref HAL_TSC_DeInit() |
116 | If MspInit or MspDeInit are not null, the HAL_TSC_Init()/ HAL_TSC_DeInit() |
| 117 | keep and use the user MspInit/MspDeInit callbacks (registered beforehand) whatever the state. |
117 | keep and use the user MspInit/MspDeInit callbacks (registered beforehand) whatever the state. |
| 118 | 118 | ||
| 119 | [..] |
119 | [..] |
| 120 | Callbacks can be registered/unregistered in @ref HAL_TSC_STATE_READY state only. |
120 | Callbacks can be registered/unregistered in HAL_TSC_STATE_READY state only. |
| 121 | Exception done MspInit/MspDeInit functions that can be registered/unregistered |
121 | Exception done MspInit/MspDeInit functions that can be registered/unregistered |
| 122 | in @ref HAL_TSC_STATE_READY or @ref HAL_TSC_STATE_RESET state, |
122 | in HAL_TSC_STATE_READY or HAL_TSC_STATE_RESET state, |
| 123 | thus registered (user) MspInit/DeInit callbacks can be used during the Init/DeInit. |
123 | thus registered (user) MspInit/DeInit callbacks can be used during the Init/DeInit. |
| 124 | Then, the user first registers the MspInit/MspDeInit user callbacks |
124 | Then, the user first registers the MspInit/MspDeInit user callbacks |
| 125 | using @ref HAL_TSC_RegisterCallback() before calling @ref HAL_TSC_DeInit() |
125 | using HAL_TSC_RegisterCallback() before calling HAL_TSC_DeInit() |
| 126 | or @ref HAL_TSC_Init() function. |
126 | or HAL_TSC_Init() function. |
| 127 | 127 | ||
| 128 | [..] |
128 | [..] |
| 129 | When the compilation flag USE_HAL_TSC_REGISTER_CALLBACKS is set to 0 or |
129 | When the compilation flag USE_HAL_TSC_REGISTER_CALLBACKS is set to 0 or |
| 130 | not defined, the callback registration feature is not available and all callbacks |
130 | not defined, the callback registration feature is not available and all callbacks |
| 131 | are set to the corresponding weak functions. |
131 | are set to the corresponding weak functions. |
| Line 173... | Line 173... | ||
| 173 | /** @defgroup TSC_Exported_Functions TSC Exported Functions |
173 | /** @defgroup TSC_Exported_Functions TSC Exported Functions |
| 174 | * @{ |
174 | * @{ |
| 175 | */ |
175 | */ |
| 176 | 176 | ||
| 177 | /** @defgroup TSC_Exported_Functions_Group1 Initialization and de-initialization functions |
177 | /** @defgroup TSC_Exported_Functions_Group1 Initialization and de-initialization functions |
| 178 | * @brief Initialization and Configuration functions |
178 | * @brief Initialization and Configuration functions |
| 179 | * |
179 | * |
| 180 | @verbatim |
180 | @verbatim |
| 181 | =============================================================================== |
181 | =============================================================================== |
| 182 | ##### Initialization and de-initialization functions ##### |
182 | ##### Initialization and de-initialization functions ##### |
| 183 | =============================================================================== |
183 | =============================================================================== |
| 184 | [..] This section provides functions allowing to: |
184 | [..] This section provides functions allowing to: |
| Line 208... | Line 208... | ||
| 208 | assert_param(IS_TSC_CTPL(htsc->Init.CTPulseLowLength)); |
208 | assert_param(IS_TSC_CTPL(htsc->Init.CTPulseLowLength)); |
| 209 | assert_param(IS_TSC_SS(htsc->Init.SpreadSpectrum)); |
209 | assert_param(IS_TSC_SS(htsc->Init.SpreadSpectrum)); |
| 210 | assert_param(IS_TSC_SSD(htsc->Init.SpreadSpectrumDeviation)); |
210 | assert_param(IS_TSC_SSD(htsc->Init.SpreadSpectrumDeviation)); |
| 211 | assert_param(IS_TSC_SS_PRESC(htsc->Init.SpreadSpectrumPrescaler)); |
211 | assert_param(IS_TSC_SS_PRESC(htsc->Init.SpreadSpectrumPrescaler)); |
| 212 | assert_param(IS_TSC_PG_PRESC(htsc->Init.PulseGeneratorPrescaler)); |
212 | assert_param(IS_TSC_PG_PRESC(htsc->Init.PulseGeneratorPrescaler)); |
| - | 213 | assert_param(IS_TSC_PG_PRESC_VS_CTPL(htsc->Init.PulseGeneratorPrescaler, htsc->Init.CTPulseLowLength)); |
|
| 213 | assert_param(IS_TSC_MCV(htsc->Init.MaxCountValue)); |
214 | assert_param(IS_TSC_MCV(htsc->Init.MaxCountValue)); |
| 214 | assert_param(IS_TSC_IODEF(htsc->Init.IODefaultMode)); |
215 | assert_param(IS_TSC_IODEF(htsc->Init.IODefaultMode)); |
| 215 | assert_param(IS_TSC_SYNC_POL(htsc->Init.SynchroPinPolarity)); |
216 | assert_param(IS_TSC_SYNC_POL(htsc->Init.SynchroPinPolarity)); |
| 216 | assert_param(IS_TSC_ACQ_MODE(htsc->Init.AcquisitionMode)); |
217 | assert_param(IS_TSC_ACQ_MODE(htsc->Init.AcquisitionMode)); |
| 217 | assert_param(IS_TSC_MCE_IT(htsc->Init.MaxCountInterrupt)); |
218 | assert_param(IS_TSC_MCE_IT(htsc->Init.MaxCountInterrupt)); |
| Line 381... | Line 382... | ||
| 381 | * @arg @ref HAL_TSC_MSPINIT_CB_ID MspInit callback ID |
382 | * @arg @ref HAL_TSC_MSPINIT_CB_ID MspInit callback ID |
| 382 | * @arg @ref HAL_TSC_MSPDEINIT_CB_ID MspDeInit callback ID |
383 | * @arg @ref HAL_TSC_MSPDEINIT_CB_ID MspDeInit callback ID |
| 383 | * @param pCallback pointer to the Callback function |
384 | * @param pCallback pointer to the Callback function |
| 384 | * @retval HAL status |
385 | * @retval HAL status |
| 385 | */ |
386 | */ |
| 386 | HAL_StatusTypeDef HAL_TSC_RegisterCallback(TSC_HandleTypeDef *htsc, HAL_TSC_CallbackIDTypeDef CallbackID, pTSC_CallbackTypeDef pCallback) |
387 | HAL_StatusTypeDef HAL_TSC_RegisterCallback(TSC_HandleTypeDef *htsc, HAL_TSC_CallbackIDTypeDef CallbackID, |
| - | 388 | pTSC_CallbackTypeDef pCallback) |
|
| 387 | { |
389 | { |
| 388 | HAL_StatusTypeDef status = HAL_OK; |
390 | HAL_StatusTypeDef status = HAL_OK; |
| 389 | 391 | ||
| 390 | if (pCallback == NULL) |
392 | if (pCallback == NULL) |
| 391 | { |
393 | { |
| Line 551... | Line 553... | ||
| 551 | /** |
553 | /** |
| 552 | * @} |
554 | * @} |
| 553 | */ |
555 | */ |
| 554 | 556 | ||
| 555 | /** @defgroup TSC_Exported_Functions_Group2 Input and Output operation functions |
557 | /** @defgroup TSC_Exported_Functions_Group2 Input and Output operation functions |
| 556 | * @brief Input and Output operation functions |
558 | * @brief Input and Output operation functions |
| 557 | * |
559 | * |
| 558 | @verbatim |
560 | @verbatim |
| 559 | =============================================================================== |
561 | =============================================================================== |
| 560 | ##### IO Operation functions ##### |
562 | ##### IO Operation functions ##### |
| 561 | =============================================================================== |
563 | =============================================================================== |
| 562 | [..] This section provides functions allowing to: |
564 | [..] This section provides functions allowing to: |
| Line 802... | Line 804... | ||
| 802 | /** |
804 | /** |
| 803 | * @} |
805 | * @} |
| 804 | */ |
806 | */ |
| 805 | 807 | ||
| 806 | /** @defgroup TSC_Exported_Functions_Group3 Peripheral Control functions |
808 | /** @defgroup TSC_Exported_Functions_Group3 Peripheral Control functions |
| 807 | * @brief Peripheral Control functions |
809 | * @brief Peripheral Control functions |
| 808 | * |
810 | * |
| 809 | @verbatim |
811 | @verbatim |
| 810 | =============================================================================== |
812 | =============================================================================== |
| 811 | ##### Peripheral Control functions ##### |
813 | ##### Peripheral Control functions ##### |
| 812 | =============================================================================== |
814 | =============================================================================== |
| 813 | [..] This section provides functions allowing to: |
815 | [..] This section provides functions allowing to: |
| Line 891... | Line 893... | ||
| 891 | /** |
893 | /** |
| 892 | * @} |
894 | * @} |
| 893 | */ |
895 | */ |
| 894 | 896 | ||
| 895 | /** @defgroup TSC_Exported_Functions_Group4 Peripheral State and Errors functions |
897 | /** @defgroup TSC_Exported_Functions_Group4 Peripheral State and Errors functions |
| 896 | * @brief Peripheral State and Errors functions |
898 | * @brief Peripheral State and Errors functions |
| 897 | * |
899 | * |
| 898 | @verbatim |
900 | @verbatim |
| 899 | =============================================================================== |
901 | =============================================================================== |
| 900 | ##### State and Errors functions ##### |
902 | ##### State and Errors functions ##### |
| 901 | =============================================================================== |
903 | =============================================================================== |
| 902 | [..] |
904 | [..] |
| Line 944... | Line 946... | ||
| 944 | /** |
946 | /** |
| 945 | * @} |
947 | * @} |
| 946 | */ |
948 | */ |
| 947 | 949 | ||
| 948 | /** @defgroup TSC_IRQ_Handler_and_Callbacks IRQ Handler and Callbacks |
950 | /** @defgroup TSC_IRQ_Handler_and_Callbacks IRQ Handler and Callbacks |
| 949 | * @{ |
951 | * @{ |
| 950 | */ |
952 | */ |
| 951 | 953 | ||
| 952 | /** |
954 | /** |
| 953 | * @brief Handle TSC interrupt request. |
955 | * @brief Handle TSC interrupt request. |
| 954 | * @param htsc Pointer to a TSC_HandleTypeDef structure that contains |
956 | * @param htsc Pointer to a TSC_HandleTypeDef structure that contains |
| 955 | * the configuration information for the specified TSC. |
957 | * the configuration information for the specified TSC. |
| Line 1049... | Line 1051... | ||
| 1049 | uint32_t groups = 0UL; |
1051 | uint32_t groups = 0UL; |
| 1050 | uint32_t idx; |
1052 | uint32_t idx; |
| 1051 | 1053 | ||
| 1052 | for (idx = 0UL; idx < (uint32_t)TSC_NB_OF_GROUPS; idx++) |
1054 | for (idx = 0UL; idx < (uint32_t)TSC_NB_OF_GROUPS; idx++) |
| 1053 | { |
1055 | { |
| 1054 | if ((iomask & (0x0FUL << (idx * 4UL))) != 0UL ) |
1056 | if ((iomask & (0x0FUL << (idx * 4UL))) != 0UL) |
| 1055 | { |
1057 | { |
| 1056 | groups |= (1UL << idx); |
1058 | groups |= (1UL << idx); |
| 1057 | } |
1059 | } |
| 1058 | } |
1060 | } |
| 1059 | 1061 | ||