2 ******************************************************************************
3 * @file stm32f30x_hrtim.c
4 * @author MCD Application Team
6 * @date 27-February-2014
7 * @brief HRTIMx module driver.
9 * This file provides firmware functions to manage the following
10 * functionalities of the HRTIMx peripheral:
11 * + Initialization/de-initialization methods
12 * + I/O operation methods
13 * + Peripheral Control methods
16 ================================================================================
17 ##### <HRTIM specific features> #####
18 ================================================================================
20 [..] < HRTIM introduction:
21 (#) The high-resolution timer can generate up to 10 digital signals with
22 highly accurate timings.
23 It is primarily intended to drive power conversion systems such as
24 switch mode power supplies or lighting systems,
25 but can be of general purpose usage, whenever a very fine timing
26 resolution is expected.
28 (#) Its modular architecture allows to generate either independent or
30 The wave-shape is defined by self-contained timings
31 (using counters and compare units) and a broad range of external events,
32 such as analog or digital feedbacks and synchronisation signals.
33 This allows to produce a large variety of control signal (PWM, phase-shifted,
34 constant Ton,...) and address most of conversion topologies.
36 (#) For control and monitoring purposes, the timer has also timing measure
37 capabilities and links to built-in ADC and DAC converters.
38 Last, it features light-load management mode and is able to handle
39 various fault schemes for safe shut-down purposes.
42 ##### How to use this driver #####
43 ================================================================================
44 [..] This driver provides functions to configure and program the HRTIM
45 of all stm32f33x devices.
46 These functions are split in 9 groups:
48 (#) HRTIM Simple TimeBase management: this group includes all needed functions
49 to configure the HRTIM Timebase unit:
50 (++) Initializes the HRTIMx timer in simple time base mode
51 (++) Start/Stop the time base generation
52 (++) Deinitialize the HRTIM peripheral
55 (#) HRTIM simple Output Compare management: this group includes all needed
56 functions to configure the Compare unit used in Output compare mode:
57 (++) Initializes the HRTIMx timer time base unit
58 (++) Configure the compare unit in in simple Output Compare mode
59 (++) Start/Stop the Output compare generation
61 (#) HRTIM simple PWM management: this group includes all needed
62 functions to configure the Compare unit used in PWM mode:
63 (++) Initializes the HRTIMx timer time base unit
64 (++) Configure the compare unit in in simple PWM mode
65 (++) Start/Stop the PWM generation
67 (#) HRTIM simple Capture management: this group includes all needed
68 functions to configure the Capture unit used in Capture mode:
69 (++) Initializes the HRTIMx timer time base unit
70 (++) Configure the compare unit in in simple Capture mode
71 (++) Start/Stop the Capture mode
73 (#) HRTIM simple One Pulse management: this group includes all needed
74 functions to configure the Capture unit and Compare unit used in One Pulse mode:
75 (++) Initializes the HRTIMx timer time base unit
76 (++) Configure the compare unit and the capture unit in in simple One Pulse mode
77 (++) Start/Stop the One Pulse mode generation
79 (#) HRTIM Waveform management: this group includes all needed
80 functions to configure the HRTIM possible waveform mode:
81 (++) Initializes the HRTIMx timer Master time base unit
82 (++) Initializes the HRTIMx timer Slaves time base unit
83 (++) Configures the HRTIMx timer Compare unit
84 (++) Configures the HRTIMx Slave timer Capture unit
85 (++) Configures the HRTIMx timer Output unit
86 (++) Configures the HRTIMx timer DeadTime / Chopper / Burst features
87 (++) Configures the HRTIMx timer Fault / External event features
88 (++) Configures the HRTIMx timer Synchronization features: Internal/External connection, DACs,...
89 (++) Configures the HRTIMx timer Synchronization features: ADCs Triggers
90 (++) HRTIMx timer Outputs Start/Stop
91 (++) Start/Stop the HRTIMx Timer counters
93 (#) HRTIM interrupts, DMA and flags management
94 (++) Enable/Disable interrupt sources
96 (++) Clear flags/ Pending bits
97 (++) Enable/Disable DMA requests
98 (++) Configure DMA burst mode
100 (#) TIM specific interface management, this group includes all
101 needed functions to use the specific TIM interface:
102 (++) HRTIMx timer DLL calibration
105 ******************************************************************************
108 * <h2><center>© COPYRIGHT(c) 2014 STMicroelectronics</center></h2>
110 * Redistribution and use in source and binary forms, with or without modification,
111 * are permitted provided that the following conditions are met:
112 * 1. Redistributions of source code must retain the above copyright notice,
113 * this list of conditions and the following disclaimer.
114 * 2. Redistributions in binary form must reproduce the above copyright notice,
115 * this list of conditions and the following disclaimer in the documentation
116 * and/or other materials provided with the distribution.
117 * 3. Neither the name of STMicroelectronics nor the names of its contributors
118 * may be used to endorse or promote products derived from this software
119 * without specific prior written permission.
121 * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
122 * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
123 * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
124 * DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE
125 * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
126 * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR
127 * SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER
128 * CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY,
129 * OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
130 * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
132 ******************************************************************************
134 /* Includes ------------------------------------------------------------------*/
135 #include "stm32f30x_hrtim.h"
137 /** @addtogroup STM32F30x_StdPeriph_Driver
142 * @brief HRTIM driver module
146 /* Private typedef -----------------------------------------------------------*/
147 /* Private define ------------------------------------------------------------*/
148 #define HRTIM_FLTR_FLTxEN (HRTIM_FLTR_FLT1EN |\
151 HRTIM_FLTR_FLT4EN | \
154 #define HRTIM_TIMCR_TIMUPDATETRIGGER (HRTIM_TIMUPDATETRIGGER_MASTER |\
155 HRTIM_TIMUPDATETRIGGER_TIMER_A |\
156 HRTIM_TIMUPDATETRIGGER_TIMER_B |\
157 HRTIM_TIMUPDATETRIGGER_TIMER_C |\
158 HRTIM_TIMUPDATETRIGGER_TIMER_D |\
159 HRTIM_TIMUPDATETRIGGER_TIMER_E)
161 #define HRTIM_TIM_OFFSET (uint32_t)0x00000080
162 /* Private macro -------------------------------------------------------------*/
163 /* Private variables ---------------------------------------------------------*/
164 static uint32_t TimerIdxToTimerId[] =
166 HRTIM_TIMERID_TIMER_A,
167 HRTIM_TIMERID_TIMER_B,
168 HRTIM_TIMERID_TIMER_C,
169 HRTIM_TIMERID_TIMER_D,
170 HRTIM_TIMERID_TIMER_E,
171 HRTIM_TIMERID_MASTER,
174 /* Private function prototypes -----------------------------------------------*/
175 /* Private functions ---------------------------------------------------------*/
176 static void HRTIM_MasterBase_Config(HRTIM_TypeDef* HRTIMx, HRTIM_BaseInitTypeDef* HRTIM_BaseInitStruc);
177 static void HRTIM_TimingUnitBase_Config(HRTIM_TypeDef * HRTIMx, uint32_t TimerIdx, HRTIM_BaseInitTypeDef* HRTIM_BaseInitStruct);
178 static void HRTIM_MasterWaveform_Config(HRTIM_TypeDef * HRTIMx, HRTIM_TimerInitTypeDef * TimerInit);
179 static void HRTIM_TimingUnitWaveform_Config(HRTIM_TypeDef * HRTIMx,
181 HRTIM_TimerInitTypeDef * TimerInit);
182 static void HRTIM_CompareUnitConfig(HRTIM_TypeDef * HRTIMx,
184 uint32_t CompareUnit,
185 HRTIM_CompareCfgTypeDef * CompareCfg);
186 static void HRTIM_CaptureUnitConfig(HRTIM_TypeDef * HRTIMx,
188 uint32_t CaptureUnit,
190 static void HRTIM_OutputConfig(HRTIM_TypeDef * HRTIMx,
193 HRTIM_OutputCfgTypeDef * OutputCfg);
194 static void HRTIM_ExternalEventConfig(HRTIM_TypeDef * HRTIMx,
196 HRTIM_EventCfgTypeDef * EventCfg);
197 static void HRTIM_TIM_ResetConfig(HRTIM_TypeDef * HRTIMx,
200 /** @defgroup HRTIM_Private_Functions
204 /** @defgroup HRTIM_Group1 Initialization/de-initialization methods
205 * @brief Initialization and Configuration functions
208 ===============================================================================
209 ##### Initialization/de-initialization methods #####
210 ===============================================================================
211 [..] This section provides functions allowing to:
212 (+)Initializes timer in basic time base mode
213 (+)Initializes timer in basic OC mode
214 (+)Initializes timer in basic PWM mode
215 (+)Initializes timer in basic Capture mode
216 (+)Initializes timer in One Pulse mode
217 (+)Initializes a timer operating in waveform mode
218 (+)De-initializes the HRTIMx timer
225 * @brief Initializes the HRTIMx timer in basic time base mode
226 * @param HRTIMx: pointer to HRTIMx peripheral
227 * @param TimerIdx: Timer index
228 * This parameter can be one of the following values:
229 * @arg 0x0 for master timer
230 * @arg 0x1 to 0x5 for timers A to E
231 * @note The time-base unit initialization parameters specify:
232 * The timer counter operating mode (continuous, one shot)
233 * The timer clock prescaler
235 * The timer repetition counter.
238 void HRTIM_SimpleBase_Init(HRTIM_TypeDef* HRTIMx, uint32_t TimerIdx, HRTIM_BaseInitTypeDef* HRTIM_BaseInitStruct)
240 /* Check the parameters */
241 assert_param(IS_HRTIM_TIMERINDEX(TimerIdx));
242 assert_param(IS_HRTIM_MODE(HRTIM_BaseInitStruct->Mode));
244 if (TimerIdx == HRTIM_TIMERINDEX_MASTER)
246 /* Configure master timer */
247 HRTIM_MasterBase_Config(HRTIMx, HRTIM_BaseInitStruct);
251 /* Configure timing unit */
252 HRTIM_TimingUnitBase_Config(HRTIMx, TimerIdx, HRTIM_BaseInitStruct);
257 * @brief De-initializes a timer operating in all mode
258 * @param HRTIMx: pointer to HRTIMx peripheral
261 void HRTIM_DeInit(HRTIM_TypeDef* HRTIMx)
263 /* Check the parameters */
264 RCC_APB2PeriphResetCmd(RCC_APB2Periph_HRTIM1, ENABLE);
265 RCC_APB2PeriphResetCmd(RCC_APB2Periph_HRTIM1, DISABLE);
269 * @brief Initializes the HRTIMx timer in basic output compare mode
270 * @param HRTIMx: pointer to HRTIMx peripheral
271 * @param TimerIdx: Timer index
272 * This parameter can be one of the following values:
273 * @arg 0x1 to 0x5 for timers A to E
274 * @note Initializes the time-base unit of the timer and prepare it to
275 * operate in output compare mode
278 void HRTIM_SimpleOC_Init(HRTIM_TypeDef * HRTIMx, uint32_t TimerIdx, HRTIM_BaseInitTypeDef* HRTIM_BaseInitStruct)
280 /* Check the parameters */
281 assert_param(IS_HRTIM_TIMERINDEX(TimerIdx));
282 assert_param(IS_HRTIM_MODE(HRTIM_BaseInitStruct->Mode));
284 /* Configure timing unit */
285 HRTIM_TimingUnitBase_Config(HRTIMx, TimerIdx, HRTIM_BaseInitStruct);
289 * @brief Initializes the HRTIMx timer in basic PWM mode
290 * @param HRTIMx: pointer to HRTIMx peripheral
291 * @param TimerIdx: Timer index
292 * This parameter can be one of the following values:
293 * @arg 0x1 to 0x5 for timers A to E
294 * @note Initializes the time-base unit of the timer and prepare it to
295 * operate in capture mode
298 void HRTIM_SimplePWM_Init(HRTIM_TypeDef * HRTIMx, uint32_t TimerIdx, HRTIM_BaseInitTypeDef* HRTIM_BaseInitStruct)
300 /* Check the parameters */
301 assert_param(IS_HRTIM_TIMERINDEX(TimerIdx));
302 assert_param(IS_HRTIM_MODE(HRTIM_BaseInitStruct->Mode));
304 /* Configure timing unit */
305 HRTIM_TimingUnitBase_Config(HRTIMx, TimerIdx, HRTIM_BaseInitStruct);
309 * @brief Initializes a timer operating in basic capture mode
310 * @param HRTIMx: pointer to HRTIMx peripheral
311 * @param TimerIdx: Timer index
312 * This parameter can be one of the following values:
313 * @arg 0x1 to 0x5 for timers A to E
316 void HRTIM_SimpleCapture_Init(HRTIM_TypeDef * HRTIMx, uint32_t TimerIdx, HRTIM_BaseInitTypeDef* HRTIM_BaseInitStruct)
318 /* Check the parameters */
319 assert_param(IS_HRTIM_TIMERINDEX(TimerIdx));
320 assert_param(IS_HRTIM_MODE(HRTIM_BaseInitStruct->Mode));
322 /* Configure timing unit */
323 HRTIM_TimingUnitBase_Config(HRTIMx, TimerIdx, HRTIM_BaseInitStruct);
327 * @brief Initializes the HRTIMx timer in basic one pulse mode
328 * @param HRTIMx: pointer to HRTIMx peripheral
329 * @param TimerIdx: Timer index
330 * This parameter can be one of the following values:
331 * @arg 0x1 to 0x5 for timers A to E
332 * @note Initializes the time-base unit of the timer and prepare it to
333 * operate in one pulse mode. In this mode the counter operates
334 * in single shot mode (retriggerable or not)
337 void HRTIM_SimpleOnePulse_Init(HRTIM_TypeDef * HRTIMx, uint32_t TimerIdx, HRTIM_BaseInitTypeDef* HRTIM_BaseInitStruct)
339 /* Check the parameters */
340 assert_param(IS_HRTIM_TIMERINDEX(TimerIdx));
341 assert_param(IS_HRTIM_MODE(HRTIM_BaseInitStruct->Mode));
343 /* Configure timing unit */
344 HRTIM_TimingUnitBase_Config(HRTIMx, TimerIdx, HRTIM_BaseInitStruct);
348 * @brief Initializes a timer operating in waveform mode
349 * @param HRTIMx: pointer to HRTIMx peripheral
350 * @param TimerIdx: Timer index
351 * This parameter can be one of the following values:
352 * @arg 0x0 for master timer
353 * @arg 0x1 to 0x5 for timers A to E
354 * @param pTimerInit: pointer to the timer initialization data structure
357 void HRTIM_Waveform_Init(HRTIM_TypeDef * HRTIMx,
359 HRTIM_BaseInitTypeDef* HRTIM_BaseInitStruct,
360 HRTIM_TimerInitTypeDef* HRTIM_TimerInitStruct)
362 /* Check the parameters */
363 assert_param(IS_HRTIM_HALFMODE(HRTIM_TimerInitStruct->HalfModeEnable));
364 assert_param(IS_HRTIM_SYNCSTART(HRTIM_TimerInitStruct->StartOnSync));
365 assert_param(IS_HRTIM_SYNCRESET(HRTIM_TimerInitStruct->ResetOnSync));
366 assert_param(IS_HRTIM_DACSYNC(HRTIM_TimerInitStruct->DACSynchro));
367 assert_param(IS_HRTIM_PRELOAD(HRTIM_TimerInitStruct->PreloadEnable));
368 assert_param(IS_HRTIM_TIMERBURSTMODE(HRTIM_TimerInitStruct->BurstMode));
369 assert_param(IS_HRTIM_UPDATEONREPETITION(HRTIM_TimerInitStruct->RepetitionUpdate));
371 if (TimerIdx == HRTIM_TIMERINDEX_MASTER)
373 /* Check parameters */
374 assert_param(IS_HRTIM_UPDATEGATING_MASTER(HRTIM_TimerInitStruct->UpdateGating));
376 /* Configure master timer */
377 HRTIM_MasterBase_Config(HRTIMx, HRTIM_BaseInitStruct);
378 HRTIM_MasterWaveform_Config(HRTIMx, HRTIM_TimerInitStruct);
382 /* Check parameters */
383 assert_param(IS_HRTIM_UPDATEGATING_TIM(HRTIM_TimerInitStruct->UpdateGating));
385 /* Configure timing unit */
386 HRTIM_TimingUnitBase_Config(HRTIMx, TimerIdx, HRTIM_BaseInitStruct);
387 HRTIM_TimingUnitWaveform_Config(HRTIMx, TimerIdx, HRTIM_TimerInitStruct);
395 /** @defgroup HRTIM_Group2 I/O operation methods
396 * @brief Data transfers functions
399 ===============================================================================
400 ##### IO operation methods #####
401 ===============================================================================
403 This subsection provides a set of functions allowing to manage the HRTIMx data
405 (+) Starts the DLL calibration.
406 (+) Starts / stops the counter of a timer operating in basic time base mode
407 (+) Starts / stops the output compare signal generation on the designed timer output
408 (+) Starts / stops the PWM output signal generation on the designed timer output
409 (+) Enables / disables a basic capture on the designed capture unit
416 * @brief Starts the DLL calibration
417 * @param HRTIMx: pointer to HRTIMx peripheral
418 * @param CalibrationRate: DLL calibration period
419 * This parameter can be one of the following values:
420 * @arg HRTIM_CALIBRATIONRATE_7300: 7.3 ms
421 * @arg HRTIM_CALIBRATIONRATE_910: 910 us
422 * @arg HRTIM_CALIBRATIONRATE_114: 114 us
423 * @arg HRTIM_CALIBRATIONRATE_14: 14 us
426 void HRTIM_DLLCalibrationStart(HRTIM_TypeDef * HRTIMx, uint32_t CalibrationRate)
428 uint32_t HRTIM_dllcr;
430 /* Check the parameters */
431 assert_param(IS_HRTIM_CALIBRATIONRATE(CalibrationRate));
433 /* Configure DLL Calibration */
434 HRTIM_dllcr = (HRTIMx->HRTIM_COMMON).DLLCR;
436 /* Set the Calibration rate */
437 HRTIM_dllcr &= ~(HRTIM_DLLCR_CALRTE);
438 HRTIM_dllcr |= CalibrationRate;
440 /* Start DLL calibration */
441 HRTIM_dllcr |= HRTIM_DLLCR_CAL;
443 /* Update HRTIMx register */
444 (HRTIMx->HRTIM_COMMON).DLLCR = HRTIM_dllcr;
448 * @brief Starts the counter of a timer operating in basic time base mode
449 * @param HRTIMx: pointer to HRTIM peripheral
450 * @param TimerIdx: Timer index
451 * This parameter can be one of the following values:
452 * @arg 0x5 for master timer
453 * @arg 0x0 to 0x4 for timers A to E
456 void HRTIM_SimpleBaseStart(HRTIM_TypeDef * HRTIMx, uint32_t TimerIdx)
458 /* Check the parameters */
459 assert_param(IS_HRTIM_TIMERINDEX(TimerIdx));
461 /* Enable the timer counter */
462 __HRTIM_ENABLE(HRTIMx, TimerIdxToTimerId[TimerIdx]);
466 * @brief Stops the counter of a timer operating in basic time base mode
467 * @param HRTIMx: pointer to HRTIM peripheral
468 * @param TimerIdx: Timer index
469 * This parameter can be one of the following values:
470 * @arg 0x5 for master timer
471 * @arg 0x0 to 0x4 for timers A to E
474 void HRTIM_SimpleBaseStop(HRTIM_TypeDef * HRTIMx, uint32_t TimerIdx)
476 /* Check the parameters */
477 assert_param(IS_HRTIM_TIMERINDEX(TimerIdx));
479 /* Disable the timer counter */
480 __HRTIM_DISABLE(HRTIMx, TimerIdxToTimerId[TimerIdx]);
484 * @brief Starts the output compare signal generation on the designed timer output
485 * @param HRTIMx: pointer to HRTIM peripheral
486 * @param TimerIdx: Timer index
487 * This parameter can be one of the following values:
488 * @arg 0x0 to 0x4 for timers A to E
489 * @param OCChannel: Timer output
490 * This parameter can be one of the following values:
491 * @arg HRTIM_OUTPUT_TA1: Timer A - Output 1
492 * @arg HRTIM_OUTPUT_TA2: Timer A - Output 2
493 * @arg HRTIM_OUTPUT_TB1: Timer B - Output 1
494 * @arg HRTIM_OUTPUT_TB2: Timer B - Output 2
495 * @arg HRTIM_OUTPUT_TC1: Timer C - Output 1
496 * @arg HRTIM_OUTPUT_TC2: Timer C - Output 2
497 * @arg HRTIM_OUTPUT_TD1: Timer D - Output 1
498 * @arg HRTIM_OUTPUT_TD2: Timer D - Output 2
499 * @arg HRTIM_OUTPUT_TE1: Timer E - Output 1
500 * @arg HRTIM_OUTPUT_TE2: Timer E - Output 2
503 void HRTIM_SimpleOCStart(HRTIM_TypeDef * HRTIMx,
507 /* Check the parameters */
508 assert_param(IS_HRTIM_TIMER_OUTPUT(TimerIdx, OCChannel));
510 /* Enable the timer output */
511 (HRTIMx->HRTIM_COMMON).OENR |= OCChannel;
513 /* Enable the timer counter */
514 __HRTIM_ENABLE(HRTIMx, TimerIdxToTimerId[TimerIdx]);
519 * @brief Stops the output compare signal generation on the designed timer output
520 * @param HRTIMx: pointer to HRTIM peripheral
521 * @param TimerIdx: Timer index
522 * This parameter can be one of the following values:
523 * @arg 0x0 to 0x4 for timers A to E
524 * @param OCChannel: Timer output
525 * This parameter can be one of the following values:
526 * @arg HRTIM_OUTPUT_TA1: Timer A - Output 1
527 * @arg HRTIM_OUTPUT_TA2: Timer A - Output 2
528 * @arg HRTIM_OUTPUT_TB1: Timer B - Output 1
529 * @arg HRTIM_OUTPUT_TB2: Timer B - Output 2
530 * @arg HRTIM_OUTPUT_TC1: Timer C - Output 1
531 * @arg HRTIM_OUTPUT_TC2: Timer C - Output 2
532 * @arg HRTIM_OUTPUT_TD1: Timer D - Output 1
533 * @arg HRTIM_OUTPUT_TD2: Timer D - Output 2
534 * @arg HRTIM_OUTPUT_TE1: Timer E - Output 1
535 * @arg HRTIM_OUTPUT_TE2: Timer E - Output 2
538 void HRTIM_SimpleOCStop(HRTIM_TypeDef * HRTIMx,
542 /* Check the parameters */
543 assert_param(IS_HRTIM_TIMER_OUTPUT(TimerIdx, OCChannel));
545 /* Disable the timer output */
546 HRTIMx->HRTIM_COMMON.DISR |= OCChannel;
548 /* Disable the timer counter */
549 __HRTIM_DISABLE(HRTIMx, TimerIdxToTimerId[TimerIdx]);
553 * @brief Starts the PWM output signal generation on the designed timer output
554 * @param HRTIMx: pointer to HRTIM peripheral
555 * @param TimerIdx: Timer index
556 * This parameter can be one of the following values:
557 * @arg 0x0 to 0x4 for timers A to E
558 * @param PWMChannel: Timer output
559 * This parameter can be one of the following values:
560 * @arg HRTIM_OUTPUT_TA1: Timer A - Output 1
561 * @arg HRTIM_OUTPUT_TA2: Timer A - Output 2
562 * @arg HRTIM_OUTPUT_TB1: Timer B - Output 1
563 * @arg HRTIM_OUTPUT_TB2: Timer B - Output 2
564 * @arg HRTIM_OUTPUT_TC1: Timer C - Output 1
565 * @arg HRTIM_OUTPUT_TC2: Timer C - Output 2
566 * @arg HRTIM_OUTPUT_TD1: Timer D - Output 1
567 * @arg HRTIM_OUTPUT_TD2: Timer D - Output 2
568 * @arg HRTIM_OUTPUT_TE1: Timer E - Output 1
569 * @arg HRTIM_OUTPUT_TE2: Timer E - Output 2
572 void HRTIM_SimplePWMStart(HRTIM_TypeDef * HRTIMx,
576 /* Check the parameters */
577 assert_param(IS_HRTIM_TIMER_OUTPUT(TimerIdx, PWMChannel));
579 /* Enable the timer output */
580 HRTIMx->HRTIM_COMMON.OENR |= PWMChannel;
582 /* Enable the timer counter */
583 __HRTIM_ENABLE(HRTIMx, TimerIdxToTimerId[TimerIdx]);
587 * @brief Stops the PWM output signal generation on the designed timer output
588 * @param HRTIMx: pointer to HRTIM peripheral
589 * @param TimerIdx: Timer index
590 * This parameter can be one of the following values:
591 * @arg 0x0 to 0x4 for timers A to E
592 * @param PWMChannel: Timer output
593 * This parameter can be one of the following values:
594 * @arg HRTIM_OUTPUT_TA1: Timer A - Output 1
595 * @arg HRTIM_OUTPUT_TA2: Timer A - Output 2
596 * @arg HRTIM_OUTPUT_TB1: Timer B - Output 1
597 * @arg HRTIM_OUTPUT_TB2: Timer B - Output 2
598 * @arg HRTIM_OUTPUT_TC1: Timer C - Output 1
599 * @arg HRTIM_OUTPUT_TC2: Timer C - Output 2
600 * @arg HRTIM_OUTPUT_TD1: Timer D - Output 1
601 * @arg HRTIM_OUTPUT_TD2: Timer D - Output 2
602 * @arg HRTIM_OUTPUT_TE1: Timer E - Output 1
603 * @arg HRTIM_OUTPUT_TE2: Timer E - Output 2
606 void HRTIM_SimplePWMStop(HRTIM_TypeDef * HRTIMx,
610 /* Check the parameters */
611 assert_param(IS_HRTIM_TIMER_OUTPUT(TimerIdx, PWMChannel));
613 /* Disable the timer output */
614 HRTIMx->HRTIM_COMMON.DISR |= PWMChannel;
616 /* Disable the timer counter */
617 __HRTIM_DISABLE(HRTIMx, TimerIdxToTimerId[TimerIdx]);
621 * @brief Enables a basic capture on the designed capture unit
622 * @param HRTIMx: pointer to HRTIM peripheral
623 * @param TimerIdx: Timer index
624 * This parameter can be one of the following values:
625 * @arg 0x0 to 0x4 for timers A to E
626 * @param CaptureChannel: Timer output
627 * This parameter can be one of the following values:
628 * @arg HRTIM_CAPTUREUNIT_1: Capture unit 1
629 * @arg HRTIM_CAPTUREUNIT_2: Capture unit 2
631 * @note The external event triggering the capture is available for all timing
632 * units. It can be used directly and is active as soon as the timing
633 * unit counter is enabled.
635 void HRTIM_SimpleCaptureStart(HRTIM_TypeDef * HRTIMx,
637 uint32_t CaptureChannel)
639 /* Enable the timer counter */
640 __HRTIM_ENABLE(HRTIMx, TimerIdxToTimerId[TimerIdx]);
645 * @brief Disables a basic capture on the designed capture unit
646 * @param HRTIMx: pointer to HRTIMx peripheral
647 * @param TimerIdx: Timer index
648 * This parameter can be one of the following values:
649 * @arg 0x0 to 0x4 for timers A to E
650 * @param CaptureChannel: Timer output
651 * This parameter can be one of the following values:
652 * @arg HRTIM_CAPTUREUNIT_1: Capture unit 1
653 * @arg HRTIM_CAPTUREUNIT_2: Capture unit 2
656 void HRTIM_SimpleCaptureStop(HRTIM_TypeDef * HRTIMx,
658 uint32_t CaptureChannel)
660 /* Check the parameters */
661 assert_param(IS_HRTIM_TIMING_UNIT(TimerIdx));
662 assert_param(IS_HRTIM_CAPTUREUNIT(CaptureChannel));
664 /* Set the capture unit trigger */
665 switch (CaptureChannel)
667 case HRTIM_CAPTUREUNIT_1:
669 HRTIMx->HRTIM_TIMERx[TimerIdx].CPT1xCR = HRTIM_CAPTURETRIGGER_NONE;
672 case HRTIM_CAPTUREUNIT_2:
674 HRTIMx->HRTIM_TIMERx[TimerIdx].CPT2xCR = HRTIM_CAPTURETRIGGER_NONE;
681 /* Disable the timer counter */
682 if ((HRTIMx->HRTIM_TIMERx[TimerIdx].CPT1xCR == HRTIM_CAPTURETRIGGER_NONE) &&
683 (HRTIMx->HRTIM_TIMERx[TimerIdx].CPT2xCR == HRTIM_CAPTURETRIGGER_NONE))
685 __HRTIM_DISABLE(HRTIMx, TimerIdxToTimerId[TimerIdx]);
691 * @brief Enables the basic one pulse signal generation on the designed output
692 * @param HRTIMx: pointer to HRTIMx peripheral
693 * @param TimerIdx: Timer index
694 * This parameter can be one of the following values:
695 * @arg 0x0 to 0x4 for timers A to E
696 * @param OnePulseChannel: Timer output
697 * This parameter can be one of the following values:
698 * @arg HRTIM_OUTPUT_TA1: Timer A - Output 1
699 * @arg HRTIM_OUTPUT_TA2: Timer A - Output 2
700 * @arg HRTIM_OUTPUT_TB1: Timer B - Output 1
701 * @arg HRTIM_OUTPUT_TB2: Timer B - Output 2
702 * @arg HRTIM_OUTPUT_TC1: Timer C - Output 1
703 * @arg HRTIM_OUTPUT_TC2: Timer C - Output 2
704 * @arg HRTIM_OUTPUT_TD1: Timer D - Output 1
705 * @arg HRTIM_OUTPUT_TD2: Timer D - Output 2
706 * @arg HRTIM_OUTPUT_TE1: Timer E - Output 1
707 * @arg HRTIM_OUTPUT_TE2: Timer E - Output 2
710 void HRTIM_SimpleOnePulseStart(HRTIM_TypeDef * HRTIMx,
712 uint32_t OnePulseChannel)
714 /* Check the parameters */
715 assert_param(IS_HRTIM_TIMER_OUTPUT(TimerIdx, OnePulseChannel));
717 /* Enable the timer output */
718 HRTIMx->HRTIM_COMMON.OENR |= OnePulseChannel;
720 /* Enable the timer counter */
721 __HRTIM_ENABLE(HRTIMx, TimerIdxToTimerId[TimerIdx]);
725 * @brief Disables the basic one pulse signal generation on the designed output
726 * @param HRTIMx: pointer to HRTIMx peripheral
727 * @param TimerIdx: Timer index
728 * This parameter can be one of the following values:
729 * @arg 0x0 to 0x4 for timers A to E
730 * @param OnePulseChannel: Timer output
731 * This parameter can be one of the following values:
732 * @arg HRTIM_OUTPUT_TA1: Timer A - Output 1
733 * @arg HRTIM_OUTPUT_TA2: Timer A - Output 2
734 * @arg HRTIM_OUTPUT_TB1: Timer B - Output 1
735 * @arg HRTIM_OUTPUT_TB2: Timer B - Output 2
736 * @arg HRTIM_OUTPUT_TC1: Timer C - Output 1
737 * @arg HRTIM_OUTPUT_TC2: Timer C - Output 2
738 * @arg HRTIM_OUTPUT_TD1: Timer D - Output 1
739 * @arg HRTIM_OUTPUT_TD2: Timer D - Output 2
740 * @arg HRTIM_OUTPUT_TE1: Timer E - Output 1
741 * @arg HRTIM_OUTPUT_TE2: Timer E - Output 2
744 void HRTIM_SimpleOnePulseStop(HRTIM_TypeDef * HRTIMx,
746 uint32_t OnePulseChannel)
748 /* Check the parameters */
749 assert_param(IS_HRTIM_TIMER_OUTPUT(TimerIdx, OnePulseChannel));
751 /* Disable the timer output */
752 HRTIMx->HRTIM_COMMON.DISR |= OnePulseChannel;
754 /* Disable the timer counter */
755 __HRTIM_DISABLE(HRTIMx, TimerIdxToTimerId[TimerIdx]);
759 * @brief Starts the counter of the designated timer(s) operating in waveform mode
760 * Timers can be combined (ORed) to allow for simultaneous counter start
761 * @param HRTIMx: pointer to HRTIMx peripheral
762 * @param TimersToStart: Timer counter(s) to start
763 * This parameter can be any combination of the following values:
764 * @arg HRTIM_TIMERID_MASTER
765 * @arg HRTIM_TIMERID_TIMER_A
766 * @arg HRTIM_TIMERID_TIMER_B
767 * @arg HRTIM_TIMERID_TIMER_C
768 * @arg HRTIM_TIMERID_TIMER_D
769 * @arg HRTIM_TIMERID_TIMER_E
772 void HRTIM_WaveformCounterStart(HRTIM_TypeDef * HRTIMx,
773 uint32_t TimersToStart)
775 /* Enable timer(s) counter */
776 HRTIMx->HRTIM_MASTER.MCR |= TimersToStart;
780 * @brief Stops the counter of the designated timer(s) operating in waveform mode
781 * Timers can be combined (ORed) to allow for simultaneous counter stop
782 * @param HRTIMx: pointer to HRTIMx peripheral
783 * @param TimersToStop: Timer counter(s) to stop
784 * This parameter can be any combination of the following values:
785 * @arg HRTIM_TIMER_MASTER
793 void HRTIM_WaveformCounterStop(HRTIM_TypeDef * HRTIMx,
794 uint32_t TimersToStop)
796 /* Disable timer(s) counter */
797 HRTIMx->HRTIM_MASTER.MCR &= ~TimersToStop;
801 * @brief Enables the generation of the waveform signal on the designated output(s)
802 * Outputs can be combined (ORed) to allow for simultaneous output enabling
803 * @param HRTIMx: pointer to HRTIMx peripheral
804 * @param OutputsToStart: Timer output(s) to enable
805 * This parameter can be any combination of the following values:
806 * @arg HRTIM_OUTPUT_TA1: Timer A - Output 1
807 * @arg HRTIM_OUTPUT_TA2: Timer A - Output 2
808 * @arg HRTIM_OUTPUT_TB1: Timer B - Output 1
809 * @arg HRTIM_OUTPUT_TB2: Timer B - Output 2
810 * @arg HRTIM_OUTPUT_TC1: Timer C - Output 1
811 * @arg HRTIM_OUTPUT_TC2: Timer C - Output 2
812 * @arg HRTIM_OUTPUT_TD1: Timer D - Output 1
813 * @arg HRTIM_OUTPUT_TD2: Timer D - Output 2
814 * @arg HRTIM_OUTPUT_TE1: Timer E - Output 1
815 * @arg HRTIM_OUTPUT_TE2: Timer E - Output 2
818 void HRTIM_WaveformOutputStart(HRTIM_TypeDef * HRTIMx,
819 uint32_t OutputsToStart)
821 /* Enable the HRTIM outputs */
822 HRTIMx->HRTIM_COMMON.OENR = OutputsToStart;
826 * @brief Disables the generation of the waveform signal on the designated output(s)
827 * Outputs can be combined (ORed) to allow for simultaneous output disabling
828 * @param HRTIMx: pointer to HRTIMx peripheral
829 * @param OutputsToStop: Timer output(s) to disable
830 * This parameter can be any combination of the following values:
831 * @arg HRTIM_OUTPUT_TA1: Timer A - Output 1
832 * @arg HRTIM_OUTPUT_TA2: Timer A - Output 2
833 * @arg HRTIM_OUTPUT_TB1: Timer B - Output 1
834 * @arg HRTIM_OUTPUT_TB2: Timer B - Output 2
835 * @arg HRTIM_OUTPUT_TC1: Timer C - Output 1
836 * @arg HRTIM_OUTPUT_TC2: Timer C - Output 2
837 * @arg HRTIM_OUTPUT_TD1: Timer D - Output 1
838 * @arg HRTIM_OUTPUT_TD2: Timer D - Output 2
839 * @arg HRTIM_OUTPUT_TE1: Timer E - Output 1
840 * @arg HRTIM_OUTPUT_TE2: Timer E - Output 2
843 void HRTIM_WaveformOutputStop(HRTIM_TypeDef * HRTIMx,
844 uint32_t OutputsToStop)
846 /* Disable the HRTIM outputs */
847 HRTIMx->HRTIM_COMMON.DISR = OutputsToStop;
851 * @brief Enables or disables the Master and slaves interrupt request
852 * @param HRTIMx: pointer to HRTIMx peripheral
853 * @param TimerIdx: Timer index
854 * This parameter can be one of the following values:
855 * @arg 0x0 to 0x4 for timers A to E
856 * @param HRTIM_IT: specifies the HRTIM interrupts sources to be enabled or disabled.
857 * This parameter can be any combination of the following values:
858 * @arg HRTIM_MASTER_IT_MCMP1: Master compare 1 interrupt source
859 * @arg HRTIM_MASTER_IT_MCMP2: Master compare 2 interrupt source
860 * @arg HRTIM_MASTER_IT_MCMP3: Master compare 3 interrupt Interrupt source
861 * @arg HRTIM_MASTER_IT_MCMP4: Master compare 4 Interrupt source
862 * @arg HRTIM_MASTER_IT_MREP: Master Repetition Interrupt source
863 * @arg HRTIM_MASTER_IT_SYNC: Synchronization input Interrupt source
864 * @arg HRTIM_MASTER_IT_MUPD: Master update Interrupt source
865 * @arg HRTIM_TIM_IT_CMP1: Timer compare 1 Interrupt source
866 * @arg HRTIM_TIM_IT_CMP2: Timer compare 2 Interrupt source
867 * @arg HRTIM_TIM_IT_CMP3: Timer compare 3 Interrupt source
868 * @arg HRTIM_TIM_IT_CMP4: Timer compare 4 Interrupt source
869 * @arg HRTIM_TIM_IT_REP: Timer repetition Interrupt source
870 * @arg HRTIM_TIM_IT_UPD: Timer update Interrupt source
871 * @arg HRTIM_TIM_IT_CPT1: Timer capture 1 Interrupt source
872 * @arg HRTIM_TIM_IT_CPT2: Timer capture 2 Interrupt source
873 * @arg HRTIM_TIM_IT_SET1: Timer output 1 set Interrupt source
874 * @arg HRTIM_TIM_IT_RST1: Timer output 1 reset Interrupt source
875 * @arg HRTIM_TIM_IT_SET2: Timer output 2 set Interrupt source
876 * @arg HRTIM_TIM_IT_RST2: Timer output 2 reset Interrupt source
877 * @arg HRTIM_TIM_IT_RST: Timer reset Interrupt source
878 * @arg HRTIM_TIM_IT_DLYPRT1: Timer delay protection Interrupt source
879 * @param NewState: new state of the TIM interrupts.
880 * This parameter can be: ENABLE or DISABLE.
883 void HRTIM_ITConfig(HRTIM_TypeDef * HRTIMx, uint32_t TimerIdx, uint32_t HRTIM_IT, FunctionalState NewState)
885 if(TimerIdx != HRTIM_TIMERINDEX_MASTER)
887 if(NewState != DISABLE)
889 HRTIMx->HRTIM_TIMERx[TimerIdx].TIMxDIER |= HRTIM_IT;
893 HRTIMx->HRTIM_TIMERx[TimerIdx].TIMxDIER &= ~HRTIM_IT;
898 if(NewState != DISABLE)
900 HRTIMx->HRTIM_MASTER.MDIER |= HRTIM_IT;
904 HRTIMx->HRTIM_MASTER.MDIER &= ~HRTIM_IT;
910 * @brief Enables or disables the common interrupt request
911 * @param HRTIMx: pointer to HRTIMx peripheral
912 * @param HRTIM_IT: specifies the HRTIM interrupts sources to be enabled or disabled.
913 * This parameter can be any combination of the following values:
914 * @arg HRTIM_IT_FLT1: Fault 1 interrupt source
915 * @arg HRTIM_IT_FLT2: Fault 2 interrupt source
916 * @arg HRTIM_IT_FLT3: Fault 3 interrupt Interrupt source
917 * @arg HRTIM_IT_FLT4: Fault 4 Interrupt source
918 * @arg HRTIM_IT_FLT5: Fault 5 Interrupt source
919 * @arg HRTIM_IT_SYSFLT: System Fault Interrupt source
920 * @arg HRTIM_IT_DLLRDY: DLL ready Interrupt source
921 * @arg HRTIM_IT_BMPER: Burst mode period Interrupt source
922 * @param NewState: new state of the TIM interrupts.
923 * This parameter can be: ENABLE or DISABLE.
926 void HRTIM_ITCommonConfig(HRTIM_TypeDef * HRTIMx, uint32_t HRTIM_CommonIT, FunctionalState NewState)
928 if(NewState != DISABLE)
930 HRTIMx->HRTIM_COMMON.IER |= HRTIM_CommonIT;
934 HRTIMx->HRTIM_COMMON.IER &= ~HRTIM_CommonIT;
939 * @brief Clears the Master and slaves interrupt flags
940 * @param HRTIMx: pointer to HRTIMx peripheral
941 * @param TimerIdx: Timer index
942 * This parameter can be one of the following values:
943 * @arg 0x0 to 0x4 for timers A to E
944 * @param HRTIM_FLAG: specifies the HRTIM flags sources to be cleared.
945 * This parameter can be any combination of the following values:
946 * @arg HRTIM_MASTER_FLAG_MCMP1: Master compare 1 interrupt flag
947 * @arg HRTIM_MASTER_FLAG_MCMP2: Master compare 2 interrupt flag
948 * @arg HRTIM_MASTER_FLAG_MCMP3: Master compare 3 interrupt Interrupt flag
949 * @arg HRTIM_MASTER_FLAG_MCMP4: Master compare 4 Interrupt flag
950 * @arg HRTIM_MASTER_FLAG_MREP: Master Repetition Interrupt flag
951 * @arg HRTIM_MASTER_FLAG_SYNC: Synchronization input Interrupt flag
952 * @arg HRTIM_MASTER_FLAG_MUPD: Master update Interrupt flag
953 * @arg HRTIM_TIM_FLAG_CMP1: Timer compare 1 Interrupt flag
954 * @arg HRTIM_TIM_FLAG_CMP2: Timer compare 2 Interrupt flag
955 * @arg HRTIM_TIM_FLAG_CMP3: Timer compare 3 Interrupt flag
956 * @arg HRTIM_TIM_FLAG_CMP4: Timer compare 4 Interrupt flag
957 * @arg HRTIM_TIM_FLAG_REP: Timer repetition Interrupt flag
958 * @arg HRTIM_TIM_FLAG_UPD: Timer update Interrupt flag
959 * @arg HRTIM_TIM_FLAG_CPT1: Timer capture 1 Interrupt flag
960 * @arg HRTIM_TIM_FLAG_CPT2: Timer capture 2 Interrupt flag
961 * @arg HRTIM_TIM_FLAG_SET1: Timer output 1 set Interrupt flag
962 * @arg HRTIM_TIM_FLAG_RST1: Timer output 1 reset Interrupt flag
963 * @arg HRTIM_TIM_FLAG_SET2: Timer output 2 set Interrupt flag
964 * @arg HRTIM_TIM_FLAG_RST2: Timer output 2 reset Interrupt flag
965 * @arg HRTIM_TIM_FLAG_RST: Timer reset Interrupt flag
966 * @arg HRTIM_TIM_FLAG_DLYPRT1: Timer delay protection Interrupt flag
969 void HRTIM_ClearFlag(HRTIM_TypeDef * HRTIMx, uint32_t TimerIdx, uint32_t HRTIM_FLAG)
971 if(TimerIdx != HRTIM_TIMERINDEX_MASTER)
973 HRTIMx->HRTIM_MASTER.MICR |= HRTIM_FLAG;
977 HRTIMx->HRTIM_TIMERx[TimerIdx].TIMxICR |= HRTIM_FLAG;
982 * @brief Clears the common interrupt flags
983 * @param HRTIMx: pointer to HRTIMx peripheral
984 * @param HRTIM_FLAG: specifies the HRTIM flags to be cleared.
985 * This parameter can be any combination of the following values:
986 * @arg HRTIM_FLAG_FLT1: Fault 1 interrupt flag
987 * @arg HRTIM_FLAG_FLT2: Fault 2 interrupt flag
988 * @arg HRTIM_FLAG_FLT3: Fault 3 interrupt Interrupt flag
989 * @arg HRTIM_FLAG_FLT4: Fault 4 Interrupt flag
990 * @arg HRTIM_FLAG_FLT5: Fault 5 Interrupt flag
991 * @arg HRTIM_FLAG_SYSFLT: System Fault Interrupt flag
992 * @arg HRTIM_FLAG_DLLRDY: DLL ready Interrupt flag
993 * @arg HRTIM_FLAG_BMPER: Burst mode period Interrupt flag
996 void HRTIM_ClearCommonFlag(HRTIM_TypeDef * HRTIMx, uint32_t HRTIM_CommonFLAG)
998 HRTIMx->HRTIM_COMMON.ICR |= HRTIM_CommonFLAG;
1002 * @brief Clears the Master and slaves interrupt request pending bits
1003 * @param HRTIMx: pointer to HRTIMx peripheral
1004 * @param TimerIdx: Timer index
1005 * This parameter can be one of the following values:
1006 * @arg 0x0 to 0x4 for timers A to E
1007 * @param HRTIM_IT: specifies the HRTIM interrupts sources to be enabled or disabled.
1008 * This parameter can be any combination of the following values:
1009 * @arg HRTIM_MASTER_IT_MCMP1: Master compare 1 interrupt source
1010 * @arg HRTIM_MASTER_IT_MCMP2: Master compare 2 interrupt source
1011 * @arg HRTIM_MASTER_IT_MCMP3: Master compare 3 interrupt Interrupt source
1012 * @arg HRTIM_MASTER_IT_MCMP4: Master compare 4 Interrupt source
1013 * @arg HRTIM_MASTER_IT_MREP: Master Repetition Interrupt source
1014 * @arg HRTIM_MASTER_IT_SYNC: Synchronization input Interrupt source
1015 * @arg HRTIM_MASTER_IT_MUPD: Master update Interrupt source
1016 * @arg HRTIM_TIM_IT_CMP1: Timer compare 1 Interrupt source
1017 * @arg HRTIM_TIM_IT_CMP2: Timer compare 2 Interrupt source
1018 * @arg HRTIM_TIM_IT_CMP3: Timer compare 3 Interrupt source
1019 * @arg HRTIM_TIM_IT_CMP4: Timer compare 4 Interrupt source
1020 * @arg HRTIM_TIM_IT_REP: Timer repetition Interrupt source
1021 * @arg HRTIM_TIM_IT_UPD: Timer update Interrupt source
1022 * @arg HRTIM_TIM_IT_CPT1: Timer capture 1 Interrupt source
1023 * @arg HRTIM_TIM_IT_CPT2: Timer capture 2 Interrupt source
1024 * @arg HRTIM_TIM_IT_SET1: Timer output 1 set Interrupt source
1025 * @arg HRTIM_TIM_IT_RST1: Timer output 1 reset Interrupt source
1026 * @arg HRTIM_TIM_IT_SET2: Timer output 2 set Interrupt source
1027 * @arg HRTIM_TIM_IT_RST2: Timer output 2 reset Interrupt source
1028 * @arg HRTIM_TIM_IT_RST: Timer reset Interrupt source
1029 * @arg HRTIM_TIM_IT_DLYPRT: Timer delay protection Interrupt source
1032 void HRTIM_ClearITPendingBit(HRTIM_TypeDef * HRTIMx, uint32_t TimerIdx, uint32_t HRTIM_IT)
1034 if(TimerIdx != HRTIM_TIMERINDEX_MASTER)
1036 HRTIMx->HRTIM_TIMERx[TimerIdx].TIMxICR |= HRTIM_IT;
1040 HRTIMx->HRTIM_MASTER.MICR |= HRTIM_IT;
1045 * @brief Clears the common interrupt pending bits
1046 * @param HRTIMx: pointer to HRTIMx peripheral
1047 * @param HRTIM_IT: specifies the HRTIM interrupts sources to be cleared.
1048 * This parameter can be any combination of the following values:
1049 * @arg HRTIM_IT_FLT1: Fault 1 interrupt source
1050 * @arg HRTIM_IT_FLT2: Fault 2 interrupt source
1051 * @arg HRTIM_IT_FLT3: Fault 3 interrupt Interrupt source
1052 * @arg HRTIM_IT_FLT4: Fault 4 Interrupt source
1053 * @arg HRTIM_IT_FLT5: Fault 5 Interrupt source
1054 * @arg HRTIM_IT_SYSFLT: System Fault Interrupt source
1055 * @arg HRTIM_IT_DLLRDY: DLL ready Interrupt source
1056 * @arg HRTIM_IT_BMPER: Burst mode period Interrupt source
1059 void HRTIM_ClearCommonITPendingBit(HRTIM_TypeDef * HRTIMx, uint32_t HRTIM_CommonIT)
1061 HRTIMx->HRTIM_COMMON.ICR |= HRTIM_CommonIT;
1066 * @brief Checks whether the specified HRTIM flag is set or not.
1067 * @param HRTIMx: pointer to HRTIMx peripheral
1068 * @param TimerIdx: Timer index
1069 * This parameter can be one of the following values:
1070 * @arg 0x0 to 0x4 for timers A to E
1071 * @param HRTIM_FLAG: specifies the HRTIM flags to check.
1072 * This parameter can be any combination of the following values:
1073 * @arg HRTIM_MASTER_FLAG_MCMP1: Master compare 1 interrupt flag
1074 * @arg HRTIM_MASTER_FLAG_MCMP2: Master compare 2 interrupt flag
1075 * @arg HRTIM_MASTER_FLAG_MCMP3: Master compare 3 interrupt Interrupt flag
1076 * @arg HRTIM_MASTER_FLAG_MCMP4: Master compare 4 Interrupt flag
1077 * @arg HRTIM_MASTER_FLAG_MREP: Master Repetition Interrupt flag
1078 * @arg HRTIM_MASTER_FLAG_SYNC: Synchronization input Interrupt flag
1079 * @arg HRTIM_MASTER_FLAG_MUPD: Master update Interrupt flag
1080 * @arg HRTIM_TIM_FLAG_CMP1: Timer compare 1 Interrupt flag
1081 * @arg HRTIM_TIM_FLAG_CMP2: Timer compare 2 Interrupt flag
1082 * @arg HRTIM_TIM_FLAG_CMP3: Timer compare 3 Interrupt flag
1083 * @arg HRTIM_TIM_FLAG_CMP4: Timer compare 4 Interrupt flag
1084 * @arg HRTIM_TIM_FLAG_REP: Timer repetition Interrupt flag
1085 * @arg HRTIM_TIM_FLAG_UPD: Timer update Interrupt flag
1086 * @arg HRTIM_TIM_FLAG_CPT1: Timer capture 1 Interrupt flag
1087 * @arg HRTIM_TIM_FLAG_CPT2: Timer capture 2 Interrupt flag
1088 * @arg HRTIM_TIM_FLAG_SET1: Timer output 1 set Interrupt flag
1089 * @arg HRTIM_TIM_FLAG_RST1: Timer output 1 reset Interrupt flag
1090 * @arg HRTIM_TIM_FLAG_SET2: Timer output 2 set Interrupt flag
1091 * @arg HRTIM_TIM_FLAG_RST2: Timer output 2 reset Interrupt flag
1092 * @arg HRTIM_TIM_FLAG_RST: Timer reset Interrupt flag
1093 * @arg HRTIM_TIM_FLAG_DLYPRT: Timer delay protection Interrupt flag
1094 * @retval The new state of HRTIM_FLAG (SET or RESET).
1096 FlagStatus HRTIM_GetFlagStatus(HRTIM_TypeDef * HRTIMx, uint32_t TimerIdx, uint32_t HRTIM_FLAG)
1098 FlagStatus bitstatus = RESET;
1100 if(TimerIdx != HRTIM_TIMERINDEX_MASTER)
1102 if ((HRTIMx->HRTIM_TIMERx[TimerIdx].TIMxISR & HRTIM_FLAG) != RESET)
1113 if ((HRTIMx->HRTIM_MASTER.MISR & HRTIM_FLAG) != RESET)
1126 * @brief Checks whether the specified HRTIM common flag is set or not.
1127 * @param HRTIMx: pointer to HRTIMx peripheral
1128 * @param HRTIM_FLAG: specifies the HRTIM flags to check.
1129 * This parameter can be any combination of the following values:
1130 * @arg HRTIM_FLAG_FLT1: Fault 1 interrupt flag
1131 * @arg HRTIM_FLAG_FLT2: Fault 2 interrupt flag
1132 * @arg HRTIM_FLAG_FLT3: Fault 3 interrupt Interrupt flag
1133 * @arg HRTIM_FLAG_FLT4: Fault 4 Interrupt flag
1134 * @arg HRTIM_FLAG_FLT5: Fault 5 Interrupt flag
1135 * @arg HRTIM_FLAG_SYSFLT: System Fault Interrupt flag
1136 * @arg HRTIM_FLAG_DLLRDY: DLL ready Interrupt flag
1137 * @arg HRTIM_FLAG_BMPER: Burst mode period Interrupt flag
1138 * @retval The new state of HRTIM_FLAG (SET or RESET).
1140 FlagStatus HRTIM_GetCommonFlagStatus(HRTIM_TypeDef * HRTIMx, uint32_t HRTIM_CommonFLAG)
1142 FlagStatus bitstatus = RESET;
1144 if((HRTIMx->HRTIM_COMMON.ISR & HRTIM_CommonFLAG) != RESET)
1156 * @brief Checks whether the specified HRTIM interrupt has occurred or not.
1157 * @param HRTIMx: pointer to HRTIMx peripheral
1158 * @param TimerIdx: Timer index
1159 * This parameter can be one of the following values:
1160 * @arg 0x0 to 0x4 for timers A to E
1161 * @param HRTIM_IT: specifies the HRTIM flags sources to be cleared.
1162 * This parameter can be any combination of the following values:
1163 * @arg HRTIM_MASTER_IT_MCMP1: Master compare 1 interrupt
1164 * @arg HRTIM_MASTER_IT_MCMP2: Master compare 2 interrupt
1165 * @arg HRTIM_MASTER_IT_MCMP3: Master compare 3 interrupt Interrupt
1166 * @arg HRTIM_MASTER_IT_MCMP4: Master compare 4 Interrupt
1167 * @arg HRTIM_MASTER_IT_MREP: Master Repetition Interrupt
1168 * @arg HRTIM_MASTER_IT_SYNC: Synchronization input Interrupt
1169 * @arg HRTIM_MASTER_IT_MUPD: Master update Interrupt
1170 * @arg HRTIM_TIM_IT_CMP1: Timer compare 1 Interrupt
1171 * @arg HRTIM_TIM_IT_CMP2: Timer compare 2 Interrupt
1172 * @arg HRTIM_TIM_IT_CMP3: Timer compare 3 Interrupt
1173 * @arg HRTIM_TIM_IT_CMP4: Timer compare 4 Interrupt
1174 * @arg HRTIM_TIM_IT_REP: Timer repetition Interrupt
1175 * @arg HRTIM_TIM_IT_UPD: Timer update Interrupt
1176 * @arg HRTIM_TIM_IT_CPT1: Timer capture 1 Interrupt
1177 * @arg HRTIM_TIM_IT_CPT2: Timer capture 2 Interrupt
1178 * @arg HRTIM_TIM_IT_SET1: Timer output 1 set Interrupt
1179 * @arg HRTIM_TIM_IT_RST1: Timer output 1 reset Interrupt
1180 * @arg HRTIM_TIM_IT_SET2: Timer output 2 set Interrupt
1181 * @arg HRTIM_TIM_IT_RST2: Timer output 2 reset Interrupt
1182 * @arg HRTIM_TIM_IT_RST: Timer reset Interrupt
1183 * @arg HRTIM_TIM_IT_DLYPRT: Timer delay protection Interrupt
1184 * @retval The new state of the HRTIM_IT(SET or RESET).
1186 ITStatus HRTIM_GetITStatus(HRTIM_TypeDef * HRTIMx, uint32_t TimerIdx, uint32_t HRTIM_IT)
1188 ITStatus bitstatus = RESET;
1189 uint16_t itstatus = 0x0, itenable = 0x0;
1191 if(TimerIdx != HRTIM_TIMERINDEX_MASTER)
1193 itstatus = HRTIMx->HRTIM_TIMERx[TimerIdx].TIMxISR & HRTIM_IT;
1195 itenable = HRTIMx->HRTIM_TIMERx[TimerIdx].TIMxDIER & HRTIM_IT;
1196 if ((itstatus != (uint16_t)RESET) && (itenable != (uint16_t)RESET))
1207 itstatus = HRTIMx->HRTIM_MASTER.MISR & HRTIM_IT;
1209 itenable = HRTIMx->HRTIM_MASTER.MDIER & HRTIM_IT;
1210 if ((itstatus != (uint16_t)RESET) && (itenable != (uint16_t)RESET))
1223 * @brief Checks whether the specified HRTIM common interrupt has occurred or not.
1224 * @param HRTIMx: pointer to HRTIMx peripheral
1225 * @param HRTIM_IT: specifies the HRTIM interrupt source to check.
1226 * This parameter can be any combination of the following values:
1227 * @arg HRTIM_IT_FLT1: Fault 1 interrupt
1228 * @arg HRTIM_IT_FLT2: Fault 2 interrupt
1229 * @arg HRTIM_IT_FLT3: Fault 3 interrupt Interrupt
1230 * @arg HRTIM_IT_FLT4: Fault 4 Interrupt
1231 * @arg HRTIM_IT_FLT5: Fault 5 Interrupt
1232 * @arg HRTIM_IT_SYSFLT: System Fault Interrupt
1233 * @arg HRTIM_IT_DLLRDY: DLL ready Interrupt flag
1234 * @arg HRTIM_IT_BMPER: Burst mode period Interrupt
1235 * @retval The new state of HRTIM_FLAG (SET or RESET).
1237 ITStatus HRTIM_GetCommonITStatus(HRTIM_TypeDef * HRTIMx, uint32_t HRTIM_CommonIT)
1239 ITStatus bitstatus = RESET;
1240 uint16_t itstatus = 0x0, itenable = 0x0;
1242 itstatus = HRTIMx->HRTIM_COMMON.ISR & HRTIM_CommonIT;
1243 itenable = HRTIMx->HRTIM_COMMON.IER & HRTIM_CommonIT;
1245 if ((itstatus != (uint16_t)RESET) && (itenable != (uint16_t)RESET))
1258 * @brief Enables or disables the HRTIMx's DMA Requests.
1259 * @param HRTIMx: pointer to HRTIMx peripheral
1260 * @param TimerIdx: Timer index
1261 * This parameter can be one of the following values:
1262 * @arg 0x0 to 0x4 for timers A to E
1263 * @param HRTIM_DMA: specifies the DMA Request sources.
1264 * This parameter can be any combination of the following values:
1265 * @arg HRTIM_MASTER_DMA_MCMP1: Master compare 1 DMA request source
1266 * @arg HRTIM_MASTER_DMA_MCMP2: Master compare 2 DMA request source
1267 * @arg HRTIM_MASTER_DMA_MCMP3: Master compare 3 DMA request source
1268 * @arg HRTIM_MASTER_DMA_MCMP4: Master compare 4 DMA request source
1269 * @arg HRTIM_MASTER_DMA_MREP: Master Repetition DMA request source
1270 * @arg HRTIM_MASTER_DMA_SYNC: Synchronization input DMA request source
1271 * @arg HRTIM_MASTER_DMA_MUPD:Master update DMA request source
1272 * @arg HRTIM_TIM_DMA_CMP1: Timer compare 1 DMA request source
1273 * @arg HRTIM_TIM_DMA_CMP2: Timer compare 2 DMA request source
1274 * @arg HRTIM_TIM_DMA_CMP3: Timer compare 3 DMA request source
1275 * @arg HRTIM_TIM_DMA_CMP4: Timer compare 4 DMA request source
1276 * @arg HRTIM_TIM_DMA_REP: Timer repetition DMA request source
1277 * @arg HRTIM_TIM_DMA_UPD: Timer update DMA request source
1278 * @arg HRTIM_TIM_DMA_CPT1: Timer capture 1 DMA request source
1279 * @arg HRTIM_TIM_DMA_CPT2: Timer capture 2 DMA request source
1280 * @arg HRTIM_TIM_DMA_SET1: Timer output 1 set DMA request source
1281 * @arg HRTIM_TIM_DMA_RST1: Timer output 1 reset DMA request source
1282 * @arg HRTIM_TIM_DMA_SET2: Timer output 2 set DMA request source
1283 * @arg HRTIM_TIM_DMA_RST2: Timer output 2 reset DMA request source
1284 * @arg HRTIM_TIM_DMA_RST: Timer reset DMA request source
1285 * @arg HRTIM_TIM_DMA_DLYPRT: Timer delay protection DMA request source
1286 * @param NewState: new state of the DMA Request sources.
1287 * This parameter can be: ENABLE or DISABLE.
1290 void HRTIM_DMACmd(HRTIM_TypeDef* HRTIMx, uint32_t TimerIdx, uint32_t HRTIM_DMA, FunctionalState NewState)
1292 if(TimerIdx != HRTIM_TIMERINDEX_MASTER)
1294 if(NewState != DISABLE)
1296 HRTIMx->HRTIM_TIMERx[TimerIdx].TIMxDIER |= HRTIM_DMA;
1300 HRTIMx->HRTIM_TIMERx[TimerIdx].TIMxDIER &= ~HRTIM_DMA;
1305 if(NewState != DISABLE)
1307 HRTIMx->HRTIM_MASTER.MDIER |= HRTIM_DMA;
1311 HRTIMx->HRTIM_MASTER.MDIER &= ~HRTIM_DMA;
1320 /** @defgroup HRTIM_Group3 Peripheral Control methods
1321 * @brief management functions
1324 ===============================================================================
1325 ##### Peripheral Control methods #####
1326 ===============================================================================
1328 This subsection provides a set of functions allowing to control the HRTIMx data
1336 * @brief Configures an output in basic output compare mode
1337 * @param HRTIMx: pointer to HRTIMx peripheral
1338 * @param TimerIdx: Timer index
1339 * This parameter can be one of the following values:
1340 * @arg 0x0 to 0x4 for timers A to E
1341 * @param OCChannel: Timer output
1342 * This parameter can be one of the following values:
1343 * @arg HRTIM_OUTPUT_TA1: Timer A - Output 1
1344 * @arg HRTIM_OUTPUT_TA2: Timer A - Output 2
1345 * @arg HRTIM_OUTPUT_TB1: Timer B - Output 1
1346 * @arg HRTIM_OUTPUT_TB2: Timer B - Output 2
1347 * @arg HRTIM_OUTPUT_TC1: Timer C - Output 1
1348 * @arg HRTIM_OUTPUT_TC2: Timer C - Output 2
1349 * @arg HRTIM_OUTPUT_TD1: Timer D - Output 1
1350 * @arg HRTIM_OUTPUT_TD2: Timer D - Output 2
1351 * @arg HRTIM_OUTPUT_TE1: Timer E - Output 1
1352 * @arg HRTIM_OUTPUT_TE2: Timer E - Output 2
1353 * @param pBasicOCChannelCfg: pointer to the basic output compare output configuration structure
1354 * @note When the timer operates in basic output compare mode:
1355 * Output 1 is implicitely controled by the compare unit 1
1356 * Output 2 is implicitely controled by the compare unit 2
1357 * Output Set/Reset crossbar is set according to the selected output compare mode:
1358 * Toggle: SETxyR = RSTxyR = CMPy
1359 * Active: SETxyR = CMPy, RSTxyR = 0
1360 * Inactive: SETxy =0, RSTxy = CMPy
1363 void HRTIM_SimpleOCChannelConfig(HRTIM_TypeDef * HRTIM_,
1366 HRTIM_BasicOCChannelCfgTypeDef* pBasicOCChannelCfg)
1368 uint32_t CompareUnit = HRTIM_COMPAREUNIT_1;
1369 HRTIM_CompareCfgTypeDef CompareCfg;
1370 HRTIM_OutputCfgTypeDef OutputCfg;
1372 /* Check parameters */
1373 assert_param(IS_HRTIM_TIMER_OUTPUT(TimerIdx, OCChannel));
1374 assert_param(IS_HRTIM_BASICOCMODE(pBasicOCChannelCfg->Mode));
1375 assert_param(IS_HRTIM_OUTPUTPOLARITY(pBasicOCChannelCfg->Polarity));
1376 assert_param(IS_HRTIM_OUTPUTIDLESTATE(pBasicOCChannelCfg->IdleState));
1378 /* Configure timer compare unit */
1381 case HRTIM_OUTPUT_TA1:
1382 case HRTIM_OUTPUT_TB1:
1383 case HRTIM_OUTPUT_TC1:
1384 case HRTIM_OUTPUT_TD1:
1385 case HRTIM_OUTPUT_TE1:
1387 CompareUnit = HRTIM_COMPAREUNIT_1;
1390 case HRTIM_OUTPUT_TA2:
1391 case HRTIM_OUTPUT_TB2:
1392 case HRTIM_OUTPUT_TC2:
1393 case HRTIM_OUTPUT_TD2:
1394 case HRTIM_OUTPUT_TE2:
1396 CompareUnit = HRTIM_COMPAREUNIT_2;
1403 CompareCfg.CompareValue = pBasicOCChannelCfg->Pulse;
1404 CompareCfg.AutoDelayedMode = HRTIM_AUTODELAYEDMODE_REGULAR;
1405 CompareCfg.AutoDelayedTimeout = 0;
1407 HRTIM_CompareUnitConfig(HRTIM_,
1412 /* Configure timer output */
1413 OutputCfg.Polarity = pBasicOCChannelCfg->Polarity;
1414 OutputCfg.IdleState = pBasicOCChannelCfg->IdleState;
1415 OutputCfg.FaultState = HRTIM_OUTPUTFAULTSTATE_NONE;
1416 OutputCfg.IdleMode = HRTIM_OUTPUTIDLEMODE_NONE;
1417 OutputCfg.ChopperModeEnable = HRTIM_OUTPUTCHOPPERMODE_DISABLED;
1418 OutputCfg.BurstModeEntryDelayed = HRTIM_OUTPUTBURSTMODEENTRY_REGULAR;
1420 switch (pBasicOCChannelCfg->Mode)
1422 case HRTIM_BASICOCMODE_TOGGLE:
1424 if (CompareUnit == HRTIM_COMPAREUNIT_1)
1426 OutputCfg.SetSource = HRTIM_OUTPUTSET_TIMCMP1;
1430 OutputCfg.SetSource = HRTIM_OUTPUTSET_TIMCMP2;
1432 OutputCfg.ResetSource = OutputCfg.SetSource;
1435 case HRTIM_BASICOCMODE_ACTIVE:
1437 if (CompareUnit == HRTIM_COMPAREUNIT_1)
1439 OutputCfg.SetSource = HRTIM_OUTPUTSET_TIMCMP1;
1443 OutputCfg.SetSource = HRTIM_OUTPUTSET_TIMCMP2;
1445 OutputCfg.ResetSource = HRTIM_OUTPUTRESET_NONE;
1448 case HRTIM_BASICOCMODE_INACTIVE:
1450 if (CompareUnit == HRTIM_COMPAREUNIT_1)
1452 OutputCfg.ResetSource = HRTIM_OUTPUTRESET_TIMCMP1;
1456 OutputCfg.ResetSource = HRTIM_OUTPUTRESET_TIMCMP2;
1458 OutputCfg.SetSource = HRTIM_OUTPUTSET_NONE;
1465 HRTIM_OutputConfig(HRTIM_, TimerIdx, OCChannel, &OutputCfg);
1469 * @brief Configures an output in basic PWM mode
1470 * @param HRTIMx: pointer to HRTIMx peripheral
1471 * @param TimerIdx: Timer index
1472 * This parameter can be one of the following values:
1473 * @arg 0x0 to 0x4 for timers A to E
1474 * @param PWMChannel: Timer output
1475 * This parameter can be one of the following values:
1476 * @arg HRTIM_OUTPUT_TA1: Timer A - Output 1
1477 * @arg HRTIM_OUTPUT_TA2: Timer A - Output 2
1478 * @arg HRTIM_OUTPUT_TB1: Timer B - Output 1
1479 * @arg HRTIM_OUTPUT_TB2: Timer B - Output 2
1480 * @arg HRTIM_OUTPUT_TC1: Timer C - Output 1
1481 * @arg HRTIM_OUTPUT_TC2: Timer C - Output 2
1482 * @arg HRTIM_OUTPUT_TD1: Timer D - Output 1
1483 * @arg HRTIM_OUTPUT_TD2: Timer D - Output 2
1484 * @arg HRTIM_OUTPUT_TE1: Timer E - Output 1
1485 * @arg HRTIM_OUTPUT_TE2: Timer E - Output 2
1486 * @param pBasicPWMChannelCfg: pointer to the basic PWM output configuration structure
1487 * @note When the timer operates in basic PWM output mode:
1488 * Output 1 is implicitly controled by the compare unit 1
1489 * Output 2 is implicitly controled by the compare unit 2
1490 * Output Set/Reset crossbar is set as follows:
1491 * Output 1: SETx1R = CMP1, RSTx1R = PER
1492 * Output 2: SETx2R = CMP2, RST2R = PER
1495 void HRTIM_SimplePWMChannelConfig(HRTIM_TypeDef * HRTIM_,
1497 uint32_t PWMChannel,
1498 HRTIM_BasicPWMChannelCfgTypeDef* pBasicPWMChannelCfg)
1500 uint32_t CompareUnit = HRTIM_COMPAREUNIT_1;
1501 HRTIM_CompareCfgTypeDef CompareCfg;
1502 HRTIM_OutputCfgTypeDef OutputCfg;
1504 /* Check parameters */
1505 assert_param(IS_HRTIM_TIMER_OUTPUT(TimerIdx, PWMChannel));
1506 assert_param(IS_HRTIM_OUTPUTPOLARITY(pBasicPWMChannelCfg->Polarity));
1507 assert_param(IS_HRTIM_OUTPUTIDLESTATE(pBasicPWMChannelCfg->IdleState));
1509 /* Configure timer compare unit */
1512 case HRTIM_OUTPUT_TA1:
1513 case HRTIM_OUTPUT_TB1:
1514 case HRTIM_OUTPUT_TC1:
1515 case HRTIM_OUTPUT_TD1:
1516 case HRTIM_OUTPUT_TE1:
1518 CompareUnit = HRTIM_COMPAREUNIT_1;
1521 case HRTIM_OUTPUT_TA2:
1522 case HRTIM_OUTPUT_TB2:
1523 case HRTIM_OUTPUT_TC2:
1524 case HRTIM_OUTPUT_TD2:
1525 case HRTIM_OUTPUT_TE2:
1527 CompareUnit = HRTIM_COMPAREUNIT_2;
1534 CompareCfg.CompareValue = pBasicPWMChannelCfg->Pulse;
1535 CompareCfg.AutoDelayedMode = HRTIM_AUTODELAYEDMODE_REGULAR;
1536 CompareCfg.AutoDelayedTimeout = 0;
1538 HRTIM_CompareUnitConfig(HRTIM_,
1543 /* Configure timer output */
1544 OutputCfg.Polarity = pBasicPWMChannelCfg->Polarity;
1545 OutputCfg.IdleState = pBasicPWMChannelCfg->IdleState;
1546 OutputCfg.FaultState = HRTIM_OUTPUTFAULTSTATE_NONE;
1547 OutputCfg.IdleMode = HRTIM_OUTPUTIDLEMODE_NONE;
1548 OutputCfg.ChopperModeEnable = HRTIM_OUTPUTCHOPPERMODE_DISABLED;
1549 OutputCfg.BurstModeEntryDelayed = HRTIM_OUTPUTBURSTMODEENTRY_REGULAR;
1551 if (CompareUnit == HRTIM_COMPAREUNIT_1)
1553 OutputCfg.SetSource = HRTIM_OUTPUTSET_TIMCMP1;
1557 OutputCfg.SetSource = HRTIM_OUTPUTSET_TIMCMP2;
1559 OutputCfg.ResetSource = HRTIM_OUTPUTSET_TIMPER;
1561 HRTIM_OutputConfig(HRTIM_, TimerIdx, PWMChannel, &OutputCfg);
1565 * @brief Configures a basic capture
1566 * @param HRTIMx: pointer to HRTIMx peripheral
1567 * @param TimerIdx: Timer index
1568 * This parameter can be one of the following values:
1569 * @arg 0x0 to 0x4 for timers A to E
1570 * @param CaptureChannel: Capture unit
1571 * This parameter can be one of the following values:
1572 * @arg HRTIM_CAPTUREUNIT_1: Capture unit 1
1573 * @arg HRTIM_CAPTUREUNIT_2: Capture unit 2
1574 * @param pBasicCaptureChannelCfg: pointer to the basic capture configuration structure
1575 * @note When the timer operates in basic capture mode the capture is triggered
1576 * by the designated external event and GPIO input is implicitly used as event source.
1577 * The cature can be triggered by a rising edge, a falling edge or both
1578 * edges on event channel.
1581 void HRTIM_SimpleCaptureChannelConfig(HRTIM_TypeDef * HRTIMx,
1583 uint32_t CaptureChannel,
1584 HRTIM_BasicCaptureChannelCfgTypeDef* pBasicCaptureChannelCfg)
1586 HRTIM_EventCfgTypeDef EventCfg;
1588 /* Check parameters */
1589 assert_param(IS_HRTIM_TIMING_UNIT(TimerIdx));
1590 assert_param(IS_HRTIM_CAPTUREUNIT(CaptureChannel));
1591 assert_param(IS_HRTIM_EVENT(pBasicCaptureChannelCfg->Event));
1592 assert_param(IS_HRTIM_EVENTPOLARITY(pBasicCaptureChannelCfg->EventPolarity));
1593 assert_param(IS_HRTIM_EVENTSENSITIVITY(pBasicCaptureChannelCfg->EventSensitivity));
1594 assert_param(IS_HRTIM_EVENTFILTER(pBasicCaptureChannelCfg->EventFilter));
1596 /* Configure external event channel */
1597 EventCfg.FastMode = HRTIM_EVENTFASTMODE_DISABLE;
1598 EventCfg.Filter = pBasicCaptureChannelCfg->EventFilter;
1599 EventCfg.Polarity = pBasicCaptureChannelCfg->EventPolarity;
1600 EventCfg.Sensitivity = pBasicCaptureChannelCfg->EventSensitivity;
1601 EventCfg.Source = HRTIM_EVENTSRC_1;
1603 HRTIM_ExternalEventConfig(HRTIMx,
1604 pBasicCaptureChannelCfg->Event,
1607 /* Memorize capture trigger (will be configured when the capture is started */
1608 HRTIM_CaptureUnitConfig(HRTIMx,
1611 pBasicCaptureChannelCfg->Event);
1615 * @brief Configures an output basic one pulse mode
1616 * @param HRTIMx: pointer to HRTIMx peripheral
1617 * @param TimerIdx: Timer index
1618 * This parameter can be one of the following values:
1619 * @arg 0x0 to 0x4 for timers A to E
1620 * @param OnePulseChannel: Timer output
1621 * This parameter can be one of the following values:
1622 * @arg HRTIM_OUTPUT_TA1: Timer A - Output 1
1623 * @arg HRTIM_OUTPUT_TA2: Timer A - Output 2
1624 * @arg HRTIM_OUTPUT_TB1: Timer B - Output 1
1625 * @arg HRTIM_OUTPUT_TB2: Timer B - Output 2
1626 * @arg HRTIM_OUTPUT_TC1: Timer C - Output 1
1627 * @arg HRTIM_OUTPUT_TC2: Timer C - Output 2
1628 * @arg HRTIM_OUTPUT_TD1: Timer D - Output 1
1629 * @arg HRTIM_OUTPUT_TD2: Timer D - Output 2
1630 * @arg HRTIM_OUTPUT_TE1: Timer E - Output 1
1631 * @arg HRTIM_OUTPUT_TE2: Timer E - Output 2
1632 * @param pBasicOnePulseChannelCfg: pointer to the basic one pulse output configuration structure
1633 * @note When the timer operates in basic one pulse mode:
1634 * the timer counter is implicitly started by the reset event,
1635 * the reset of the timer counter is triggered by the designated external event
1636 * GPIO input is implicitly used as event source,
1637 * Output 1 is implicitly controled by the compare unit 1,
1638 * Output 2 is implicitly controled by the compare unit 2.
1639 * Output Set/Reset crossbar is set as follows:
1640 * Output 1: SETx1R = CMP1, RSTx1R = PER
1641 * Output 2: SETx2R = CMP2, RST2R = PER
1642 * The counter mode should be HRTIM_MODE_SINGLESHOT_RETRIGGERABLE
1645 void HRTIM_SimpleOnePulseChannelConfig(HRTIM_TypeDef * HRTIM_,
1647 uint32_t OnePulseChannel,
1648 HRTIM_BasicOnePulseChannelCfgTypeDef* pBasicOnePulseChannelCfg)
1650 uint32_t CompareUnit = HRTIM_COMPAREUNIT_1;
1651 HRTIM_CompareCfgTypeDef CompareCfg;
1652 HRTIM_OutputCfgTypeDef OutputCfg;
1653 HRTIM_EventCfgTypeDef EventCfg;
1655 /* Check parameters */
1656 assert_param(IS_HRTIM_TIMER_OUTPUT(TimerIdx, OnePulseChannel));
1657 assert_param(IS_HRTIM_OUTPUTPOLARITY(pBasicOnePulseChannelCfg->OutputPolarity));
1658 assert_param(IS_HRTIM_OUTPUTIDLESTATE(pBasicOnePulseChannelCfg->OutputIdleState));
1659 assert_param(IS_HRTIM_EVENT(pBasicOnePulseChannelCfg->Event));
1660 assert_param(IS_HRTIM_EVENTPOLARITY(pBasicOnePulseChannelCfg->EventPolarity));
1661 assert_param(IS_HRTIM_EVENTSENSITIVITY(pBasicOnePulseChannelCfg->EventSensitivity));
1662 assert_param(IS_HRTIM_EVENTFILTER(pBasicOnePulseChannelCfg->EventFilter));
1664 /* Configure timer compare unit */
1665 switch (OnePulseChannel)
1667 case HRTIM_OUTPUT_TA1:
1668 case HRTIM_OUTPUT_TB1:
1669 case HRTIM_OUTPUT_TC1:
1670 case HRTIM_OUTPUT_TD1:
1671 case HRTIM_OUTPUT_TE1:
1673 CompareUnit = HRTIM_COMPAREUNIT_1;
1676 case HRTIM_OUTPUT_TA2:
1677 case HRTIM_OUTPUT_TB2:
1678 case HRTIM_OUTPUT_TC2:
1679 case HRTIM_OUTPUT_TD2:
1680 case HRTIM_OUTPUT_TE2:
1682 CompareUnit = HRTIM_COMPAREUNIT_2;
1689 CompareCfg.CompareValue = pBasicOnePulseChannelCfg->Pulse;
1690 CompareCfg.AutoDelayedMode = HRTIM_AUTODELAYEDMODE_REGULAR;
1691 CompareCfg.AutoDelayedTimeout = 0;
1693 HRTIM_CompareUnitConfig(HRTIM_,
1698 /* Configure timer output */
1699 OutputCfg.Polarity = pBasicOnePulseChannelCfg->OutputPolarity;
1700 OutputCfg.IdleState = pBasicOnePulseChannelCfg->OutputIdleState;
1701 OutputCfg.FaultState = HRTIM_OUTPUTFAULTSTATE_NONE;
1702 OutputCfg.IdleMode = HRTIM_OUTPUTIDLEMODE_NONE;
1703 OutputCfg.ChopperModeEnable = HRTIM_OUTPUTCHOPPERMODE_DISABLED;
1704 OutputCfg.BurstModeEntryDelayed = HRTIM_OUTPUTBURSTMODEENTRY_REGULAR;
1706 if (CompareUnit == HRTIM_COMPAREUNIT_1)
1708 OutputCfg.SetSource = HRTIM_OUTPUTSET_TIMCMP1;
1712 OutputCfg.SetSource = HRTIM_OUTPUTSET_TIMCMP2;
1714 OutputCfg.ResetSource = HRTIM_OUTPUTSET_TIMPER;
1716 HRTIM_OutputConfig(HRTIM_,
1721 /* Configure external event channel */
1722 EventCfg.FastMode = HRTIM_EVENTFASTMODE_DISABLE;
1723 EventCfg.Filter = pBasicOnePulseChannelCfg->EventFilter;
1724 EventCfg.Polarity = pBasicOnePulseChannelCfg->EventPolarity;
1725 EventCfg.Sensitivity = pBasicOnePulseChannelCfg->EventSensitivity;
1726 EventCfg.Source = HRTIM_EVENTSRC_1;
1728 HRTIM_ExternalEventConfig(HRTIM_,
1729 pBasicOnePulseChannelCfg->Event,
1732 /* Configure the timer reset register */
1733 HRTIM_TIM_ResetConfig(HRTIM_,
1735 pBasicOnePulseChannelCfg->Event);
1739 * @brief Configures the general behavior of a timer operating in waveform mode
1740 * @param HRTIMx: pointer to HRTIMx peripheral
1741 * @param TimerIdx: Timer index
1742 * This parameter can be one of the following values:
1743 * @arg 0x0 to 0x4 for timers A to E
1744 * @param pTimerCfg: pointer to the timer configuration structure
1745 * @note When the timer operates in waveform mode, all the features supported by
1746 * the HRTIMx are available without any limitation.
1749 void HRTIM_WaveformTimerConfig(HRTIM_TypeDef * HRTIMx,
1751 HRTIM_TimerCfgTypeDef * pTimerCfg)
1753 uint32_t HRTIM_timcr;
1754 uint32_t HRTIM_timfltr;
1755 uint32_t HRTIM_timoutr;
1756 uint32_t HRTIM_timrstr;
1758 /* Check parameters */
1759 assert_param(IS_HRTIM_TIMING_UNIT(TimerIdx));
1760 assert_param(IS_HRTIM_TIMPUSHPULLMODE(pTimerCfg->PushPull));
1761 assert_param(IS_HRTIM_TIMFAULTENABLE(pTimerCfg->FaultEnable));
1762 assert_param(IS_HRTIM_TIMFAULTLOCK(pTimerCfg->FaultLock));
1763 assert_param(IS_HRTIM_TIMDEADTIMEINSERTION(pTimerCfg->DeadTimeInsertion));
1764 assert_param(IS_HRTIM_TIMDELAYEDPROTECTION(pTimerCfg->DelayedProtectionMode));
1765 assert_param(IS_HRTIM_TIMUPDATETRIGGER(pTimerCfg->UpdateTrigger));
1766 assert_param(IS_HRTIM_TIMRESETTRIGGER(pTimerCfg->ResetTrigger));
1767 assert_param(IS_HRTIM_TIMUPDATEONRESET(pTimerCfg->ResetUpdate));
1769 /* Configure timing unit (Timer A to Timer E) */
1770 HRTIM_timcr = HRTIMx->HRTIM_TIMERx[TimerIdx].TIMxCR;
1771 HRTIM_timfltr = HRTIMx->HRTIM_TIMERx[TimerIdx].FLTxR;
1772 HRTIM_timoutr = HRTIMx->HRTIM_TIMERx[TimerIdx].OUTxR;
1773 HRTIM_timrstr = HRTIMx->HRTIM_TIMERx[TimerIdx].RSTxR;
1775 /* Set the push-pull mode */
1776 HRTIM_timcr &= ~(HRTIM_TIMCR_PSHPLL);
1777 HRTIM_timcr |= pTimerCfg->PushPull;
1779 /* Enable/Disable registers update on timer counter reset */
1780 HRTIM_timcr &= ~(HRTIM_TIMCR_TRSTU);
1781 HRTIM_timcr |= pTimerCfg->ResetUpdate;
1783 /* Set the timer update trigger */
1784 HRTIM_timcr &= ~(HRTIM_TIMCR_TIMUPDATETRIGGER);
1785 HRTIM_timcr |= pTimerCfg->UpdateTrigger;
1787 /* Enable/Disable the fault channel at timer level */
1788 HRTIM_timfltr &= ~(HRTIM_FLTR_FLTxEN);
1789 HRTIM_timfltr |= (pTimerCfg->FaultEnable & HRTIM_FLTR_FLTxEN);
1791 /* Lock/Unlock fault sources at timer level */
1792 HRTIM_timfltr &= ~(HRTIM_FLTR_FLTCLK);
1793 HRTIM_timfltr |= pTimerCfg->FaultLock;
1795 /* Enable/Disable dead time insertion at timer level */
1796 HRTIM_timoutr &= ~(HRTIM_OUTR_DTEN);
1797 HRTIM_timoutr |= pTimerCfg->DeadTimeInsertion;
1799 /* Enable/Disable delayed protection at timer level */
1800 HRTIM_timoutr &= ~(HRTIM_OUTR_DLYPRT| HRTIM_OUTR_DLYPRTEN);
1801 HRTIM_timoutr |= pTimerCfg->DelayedProtectionMode;
1803 /* Set the timer counter reset trigger */
1804 HRTIM_timrstr = pTimerCfg->ResetTrigger;
1806 /* Update the HRTIMx registers */
1807 HRTIMx->HRTIM_TIMERx[TimerIdx].TIMxCR = HRTIM_timcr;
1808 HRTIMx->HRTIM_TIMERx[TimerIdx].FLTxR = HRTIM_timfltr;
1809 HRTIMx->HRTIM_TIMERx[TimerIdx].OUTxR = HRTIM_timoutr;
1810 HRTIMx->HRTIM_TIMERx[TimerIdx].RSTxR = HRTIM_timrstr;
1814 * @brief Configures the compare unit of a timer operating in waveform mode
1815 * @param HRTIMx: pointer to HRTIMx peripheral
1816 * @param TimerIdx: Timer index
1817 * 0xFF for master timer
1818 * This parameter can be one of the following values:
1819 * @arg 0x0 to 0x4 for timers A to E
1820 * @param CompareUnit: Compare unit to configure
1821 * This parameter can be one of the following values:
1822 * @arg HRTIM_COMPAREUNIT_1: Compare unit 1
1823 * @arg HRTIM_COMPAREUNIT_2: Compare unit 2
1824 * @arg HRTIM_COMPAREUNIT_3: Compare unit 3
1825 * @arg HRTIM_COMPAREUNIT_4: Compare unit 4
1826 * @param pCompareCfg: pointer to the compare unit configuration structure
1827 * @note When auto delayed mode is required for compare unit 2 or compare unit 4,
1828 * application has to configure separately the capture unit. Capture unit
1829 * to configure in that case depends on the compare unit auto delayed mode
1830 * is applied to (see below):
1831 * Auto delayed on output compare 2: capture unit 1 must be configured
1832 * Auto delayed on output compare 4: capture unit 2 must be configured
1835 void HRTIM_WaveformCompareConfig(HRTIM_TypeDef * HRTIMx,
1837 uint32_t CompareUnit,
1838 HRTIM_CompareCfgTypeDef* pCompareCfg)
1840 uint32_t HRTIM_timcr;
1842 /* Check parameters */
1843 assert_param(IS_HRTIM_TIMING_UNIT(TimerIdx));
1844 assert_param(IS_HRTIM_COMPAREUNIT_AUTODELAYEDMODE(CompareUnit, pCompareCfg->AutoDelayedMode));
1846 /* Configure the compare unit */
1847 switch (CompareUnit)
1849 case HRTIM_COMPAREUNIT_1:
1851 /* Set the compare value */
1852 HRTIMx->HRTIM_TIMERx[TimerIdx].CMP1xR = pCompareCfg->CompareValue;
1855 case HRTIM_COMPAREUNIT_2:
1857 /* Set the compare value */
1858 HRTIMx->HRTIM_TIMERx[TimerIdx].CMP2xR = pCompareCfg->CompareValue;
1860 if (pCompareCfg->AutoDelayedMode != HRTIM_AUTODELAYEDMODE_REGULAR)
1862 /* Configure auto-delayed mode */
1863 HRTIM_timcr = HRTIMx->HRTIM_TIMERx[TimerIdx].TIMxCR;
1864 HRTIM_timcr &= ~HRTIM_TIMCR_DELCMP2;
1865 HRTIM_timcr |= pCompareCfg->AutoDelayedMode;
1866 HRTIMx->HRTIM_TIMERx[TimerIdx].TIMxCR = HRTIM_timcr;
1868 /* Set the compare value for timeout compare unit (if any) */
1869 if (pCompareCfg->AutoDelayedMode == HRTIM_AUTODELAYEDMODE_AUTODELAYED_TIMEOUTCMP1)
1871 HRTIMx->HRTIM_TIMERx[TimerIdx].CMP1xR = pCompareCfg->AutoDelayedTimeout;
1873 else if (pCompareCfg->AutoDelayedMode == HRTIM_AUTODELAYEDMODE_AUTODELAYED_TIMEOUTCMP3)
1875 HRTIMx->HRTIM_TIMERx[TimerIdx].CMP3xR = pCompareCfg->AutoDelayedTimeout;
1880 case HRTIM_COMPAREUNIT_3:
1882 /* Set the compare value */
1883 HRTIMx->HRTIM_TIMERx[TimerIdx].CMP3xR = pCompareCfg->CompareValue;
1886 case HRTIM_COMPAREUNIT_4:
1888 /* Set the compare value */
1889 HRTIMx->HRTIM_TIMERx[TimerIdx].CMP4xR = pCompareCfg->CompareValue;
1891 if (pCompareCfg->AutoDelayedMode != HRTIM_AUTODELAYEDMODE_REGULAR)
1893 /* Configure auto-delayed mode */
1894 HRTIM_timcr = HRTIMx->HRTIM_TIMERx[TimerIdx].TIMxCR;
1895 HRTIM_timcr &= ~HRTIM_TIMCR_DELCMP4;
1896 HRTIM_timcr |= (pCompareCfg->AutoDelayedMode << 2);
1897 HRTIMx->HRTIM_TIMERx[TimerIdx].TIMxCR = HRTIM_timcr;
1899 /* Set the compare value for timeout compare unit (if any) */
1900 if (pCompareCfg->AutoDelayedMode == HRTIM_AUTODELAYEDMODE_AUTODELAYED_TIMEOUTCMP1)
1902 HRTIMx->HRTIM_TIMERx[TimerIdx].CMP1xR = pCompareCfg->AutoDelayedTimeout;
1904 else if (pCompareCfg->AutoDelayedMode == HRTIM_AUTODELAYEDMODE_AUTODELAYED_TIMEOUTCMP3)
1906 HRTIMx->HRTIM_TIMERx[TimerIdx].CMP3xR = pCompareCfg->AutoDelayedTimeout;
1917 * @brief Sets the HRTIMx Master Comparex Register value
1918 * @param HRTIMx: pointer to HRTIMx peripheral
1919 * @param CompareUnit: Compare unit to configure
1920 * This parameter can be one of the following values:
1921 * @arg HRTIM_COMPAREUNIT_1: Compare unit 1
1922 * @arg HRTIM_COMPAREUNIT_2: Compare unit 2
1923 * @arg HRTIM_COMPAREUNIT_3: Compare unit 3
1924 * @arg HRTIM_COMPAREUNIT_4: Compare unit 4
1925 * @param Compare: specifies the Comparex register new value
1928 void HRTIM_MasterSetCompare(HRTIM_TypeDef * HRTIMx,
1929 uint32_t CompareUnit,
1932 /* Check parameters */
1933 assert_param(IS_HRTIM_COMPAREUNIT(CompareUnit));
1935 /* Configure the compare unit */
1936 switch (CompareUnit)
1938 case HRTIM_COMPAREUNIT_1:
1940 /* Set the compare value */
1941 HRTIMx->HRTIM_MASTER.MCMP1R = Compare;
1944 case HRTIM_COMPAREUNIT_2:
1946 /* Set the compare value */
1947 HRTIMx->HRTIM_MASTER.MCMP2R = Compare;
1950 case HRTIM_COMPAREUNIT_3:
1952 /* Set the compare value */
1953 HRTIMx->HRTIM_MASTER.MCMP3R = Compare;
1956 case HRTIM_COMPAREUNIT_4:
1958 /* Set the compare value */
1959 HRTIMx->HRTIM_MASTER.MCMP4R = Compare;
1967 * @brief Configures the capture unit of a timer operating in waveform mode
1968 * @param HRTIMx: pointer to HRTIMx peripheral
1969 * @param TimerIdx: Timer index
1970 * This parameter can be one of the following values:
1971 * @arg 0x0 to 0x4 for timers A to E
1972 * @param CaptureChannel: Capture unit to configure
1973 * This parameter can be one of the following values:
1974 * @arg HRTIM_CAPTUREUNIT_1: Capture unit 1
1975 * @arg HRTIM_CAPTUREUNIT_2: Capture unit 2
1976 * @param pCaptureCfg: pointer to the compare unit configuration structure
1979 void HRTIM_WaveformCaptureConfig(HRTIM_TypeDef * HRTIMx,
1981 uint32_t CaptureUnit,
1982 HRTIM_CaptureCfgTypeDef* pCaptureCfg)
1984 /* Configure the capture unit */
1985 switch (CaptureUnit)
1987 case HRTIM_CAPTUREUNIT_1:
1989 HRTIMx->HRTIM_TIMERx[TimerIdx].CPT1xCR = pCaptureCfg->Trigger;
1992 case HRTIM_CAPTUREUNIT_2:
1994 HRTIMx->HRTIM_TIMERx[TimerIdx].CPT2xCR = pCaptureCfg->Trigger;
2003 * @brief Configures the output of a timer operating in waveform mode
2004 * @param HRTIMx: pointer to HRTIMx peripheral
2005 * @param TimerIdx: Timer index
2006 * This parameter can be one of the following values:
2007 * @arg 0x0 to 0x4 for timers A to E
2008 * @param Output: Timer output
2009 * This parameter can be one of the following values:
2010 * @arg HRTIM_OUTPUT_TA1: Timer A - Output 1
2011 * @arg HRTIM_OUTPUT_TA2: Timer A - Output 2
2012 * @arg HRTIM_OUTPUT_TB1: Timer B - Output 1
2013 * @arg HRTIM_OUTPUT_TB2: Timer B - Output 2
2014 * @arg HRTIM_OUTPUT_TC1: Timer C - Output 1
2015 * @arg HRTIM_OUTPUT_TC2: Timer C - Output 2
2016 * @arg HRTIM_OUTPUT_TD1: Timer D - Output 1
2017 * @arg HRTIM_OUTPUT_TD2: Timer D - Output 2
2018 * @arg HRTIM_OUTPUT_TE1: Timer E - Output 1
2019 * @arg HRTIM_OUTPUT_TE2: Timer E - Output 2
2020 * @param pOutputCfg: pointer to the timer output configuration structure
2023 void HRTIM_WaveformOutputConfig(HRTIM_TypeDef * HRTIM_,
2026 HRTIM_OutputCfgTypeDef * pOutputCfg)
2028 /* Check parameters */
2029 assert_param(IS_HRTIM_TIMER_OUTPUT(TimerIdx, Output));
2030 assert_param(IS_HRTIM_OUTPUTPOLARITY(pOutputCfg->Polarity));
2031 assert_param(IS_HRTIM_OUTPUTIDLESTATE(pOutputCfg->IdleState));
2032 assert_param(IS_HRTIM_OUTPUTIDLEMODE(pOutputCfg->IdleMode));
2033 assert_param(IS_HRTIM_OUTPUTFAULTSTATE(pOutputCfg->FaultState));
2034 assert_param(IS_HRTIM_OUTPUTCHOPPERMODE(pOutputCfg->ChopperModeEnable));
2035 assert_param(IS_HRTIM_OUTPUTBURSTMODEENTRY(pOutputCfg->BurstModeEntryDelayed));
2037 /* Configure the timer output */
2038 HRTIM_OutputConfig(HRTIM_, TimerIdx, Output, pOutputCfg);
2042 * @brief Configures the event filtering capabilities of a timer (blanking, windowing)
2043 * @param HRTIMx: pointer to HRTIMx peripheral
2044 * @param TimerIdx: Timer index
2045 * This parameter can be one of the following values:
2046 * @arg 0x0 to 0x4 for timers A to E
2047 * @param Event: external event for which timer event filtering must be configured
2048 * This parameter can be one of the following values:
2049 * @arg HRTIM_EVENT_1: External event 1
2050 * @arg HRTIM_EVENT_2: External event 2
2051 * @arg HRTIM_EVENT_3: External event 3
2052 * @arg HRTIM_EVENT_4: External event 4
2053 * @arg HRTIM_EVENT_5: External event 5
2054 * @arg HRTIM_EVENT_6: External event 6
2055 * @arg HRTIM_EVENT_7: External event 7
2056 * @arg HRTIM_EVENT_8: External event 8
2057 * @arg HRTIM_EVENT_9: External event 9
2058 * @arg HRTIM_EVENT_10: External event 10
2059 * @param pTimerEventFilteringCfg: pointer to the timer event filtering configuration structure
2062 void HRTIM_TimerEventFilteringConfig(HRTIM_TypeDef * HRTIMx,
2065 HRTIM_TimerEventFilteringCfgTypeDef* pTimerEventFilteringCfg)
2067 uint32_t HRTIM_eefr;
2069 /* Check parameters */
2070 assert_param(IS_HRTIM_TIMING_UNIT(TimerIdx));
2071 assert_param(IS_HRTIM_EVENT(Event));
2072 assert_param(IS_HRTIM_TIMEVENTFILTER(pTimerEventFilteringCfg->Filter));
2073 assert_param(IS_HRTIM_TIMEVENTLATCH(pTimerEventFilteringCfg->Latch));
2075 /* Configure timer event filtering capabilities */
2078 case HRTIM_TIMEVENTFILTER_NONE:
2080 HRTIMx->HRTIM_TIMERx[TimerIdx].EEFxR1 = 0;
2081 HRTIMx->HRTIM_TIMERx[TimerIdx].EEFxR2 = 0;
2086 HRTIM_eefr = HRTIMx->HRTIM_TIMERx[TimerIdx].EEFxR1;
2087 HRTIM_eefr &= ~(HRTIM_EEFR1_EE1FLTR | HRTIM_EEFR1_EE1LTCH);
2088 HRTIM_eefr |= (pTimerEventFilteringCfg->Filter | pTimerEventFilteringCfg->Latch);
2089 HRTIMx->HRTIM_TIMERx[TimerIdx].EEFxR1 = HRTIM_eefr;
2094 HRTIM_eefr = HRTIMx->HRTIM_TIMERx[TimerIdx].EEFxR1;
2095 HRTIM_eefr &= ~(HRTIM_EEFR1_EE2FLTR | HRTIM_EEFR1_EE2LTCH);
2096 HRTIM_eefr |= ((pTimerEventFilteringCfg->Filter | pTimerEventFilteringCfg->Latch) << 6);
2097 HRTIMx->HRTIM_TIMERx[TimerIdx].EEFxR1 = HRTIM_eefr;
2102 HRTIM_eefr = HRTIMx->HRTIM_TIMERx[TimerIdx].EEFxR1;
2103 HRTIM_eefr &= ~(HRTIM_EEFR1_EE3FLTR | HRTIM_EEFR1_EE3LTCH);
2104 HRTIM_eefr |= ((pTimerEventFilteringCfg->Filter | pTimerEventFilteringCfg->Latch) << 12);
2105 HRTIMx->HRTIM_TIMERx[TimerIdx].EEFxR1 = HRTIM_eefr;
2110 HRTIM_eefr = HRTIMx->HRTIM_TIMERx[TimerIdx].EEFxR1;
2111 HRTIM_eefr &= ~(HRTIM_EEFR1_EE4FLTR | HRTIM_EEFR1_EE4LTCH);
2112 HRTIM_eefr |= ((pTimerEventFilteringCfg->Filter | pTimerEventFilteringCfg->Latch) << 18);
2113 HRTIMx->HRTIM_TIMERx[TimerIdx].EEFxR1 = HRTIM_eefr;
2118 HRTIM_eefr = HRTIMx->HRTIM_TIMERx[TimerIdx].EEFxR1;
2119 HRTIM_eefr &= ~(HRTIM_EEFR1_EE5FLTR | HRTIM_EEFR1_EE5LTCH);
2120 HRTIM_eefr |= ((pTimerEventFilteringCfg->Filter | pTimerEventFilteringCfg->Latch) << 24);
2121 HRTIMx->HRTIM_TIMERx[TimerIdx].EEFxR1 = HRTIM_eefr;
2126 HRTIM_eefr = HRTIMx->HRTIM_TIMERx[TimerIdx].EEFxR2;
2127 HRTIM_eefr &= ~(HRTIM_EEFR2_EE6FLTR | HRTIM_EEFR2_EE6LTCH);
2128 HRTIM_eefr |= (pTimerEventFilteringCfg->Filter | pTimerEventFilteringCfg->Latch);
2129 HRTIMx->HRTIM_TIMERx[TimerIdx].EEFxR2 = HRTIM_eefr;
2134 HRTIM_eefr = HRTIMx->HRTIM_TIMERx[TimerIdx].EEFxR2;
2135 HRTIM_eefr &= ~(HRTIM_EEFR2_EE7FLTR | HRTIM_EEFR2_EE7LTCH);
2136 HRTIM_eefr |= ((pTimerEventFilteringCfg->Filter | pTimerEventFilteringCfg->Latch) << 6);
2137 HRTIMx->HRTIM_TIMERx[TimerIdx].EEFxR2 = HRTIM_eefr;
2142 HRTIM_eefr = HRTIMx->HRTIM_TIMERx[TimerIdx].EEFxR2;
2143 HRTIM_eefr &= ~(HRTIM_EEFR2_EE8FLTR | HRTIM_EEFR2_EE8LTCH);
2144 HRTIM_eefr |= ((pTimerEventFilteringCfg->Filter | pTimerEventFilteringCfg->Latch) << 12);
2145 HRTIMx->HRTIM_TIMERx[TimerIdx].EEFxR2 = HRTIM_eefr;
2150 HRTIM_eefr = HRTIMx->HRTIM_TIMERx[TimerIdx].EEFxR2;
2151 HRTIM_eefr &= ~(HRTIM_EEFR2_EE9FLTR | HRTIM_EEFR2_EE9LTCH);
2152 HRTIM_eefr |= ((pTimerEventFilteringCfg->Filter | pTimerEventFilteringCfg->Latch) << 18);
2153 HRTIMx->HRTIM_TIMERx[TimerIdx].EEFxR2 = HRTIM_eefr;
2156 case HRTIM_EVENT_10:
2158 HRTIM_eefr = HRTIMx->HRTIM_TIMERx[TimerIdx].EEFxR2;
2159 HRTIM_eefr &= ~(HRTIM_EEFR2_EE10FLTR | HRTIM_EEFR2_EE10LTCH);
2160 HRTIM_eefr |= ((pTimerEventFilteringCfg->Filter | pTimerEventFilteringCfg->Latch) << 24);
2161 HRTIMx->HRTIM_TIMERx[TimerIdx].EEFxR2 = HRTIM_eefr;
2170 * @brief Configures the dead time insertion feature for a timer
2171 * @param HRTIMx: pointer to HRTIMx peripheral
2172 * @param TimerIdx: Timer index
2173 * This parameter can be one of the following values:
2174 * @arg 0x0 to 0x4 for timers A to E
2175 * @param pDeadTimeCfg: pointer to the dead time insertion configuration structure
2178 void HRTIM_DeadTimeConfig(HRTIM_TypeDef * HRTIMx,
2180 HRTIM_DeadTimeCfgTypeDef* pDeadTimeCfg)
2184 /* Check parameters */
2185 assert_param(IS_HRTIM_TIMING_UNIT(TimerIdx));
2186 assert_param(IS_HRTIM_TIMDEADTIME_RISINGSIGN(pDeadTimeCfg->RisingSign));
2187 assert_param(IS_HRTIM_TIMDEADTIME_RISINGLOCK(pDeadTimeCfg->RisingLock));
2188 assert_param(IS_HRTIM_TIMDEADTIME_RISINGSIGNLOCK(pDeadTimeCfg->RisingSignLock));
2189 assert_param(IS_HRTIM_TIMDEADTIME_FALLINGSIGN(pDeadTimeCfg->FallingSign));
2190 assert_param(IS_HRTIM_TIMDEADTIME_FALLINGLOCK(pDeadTimeCfg->FallingLock));
2191 assert_param(IS_HRTIM_TIMDEADTIME_FALLINGSIGNLOCK(pDeadTimeCfg->FallingSignLock));
2193 HRTIM_dtr = HRTIMx->HRTIM_TIMERx[TimerIdx].DTxR;
2195 /* Clear timer dead times configuration */
2196 HRTIM_dtr &= ~(HRTIM_DTR_DTR | HRTIM_DTR_SDTR | HRTIM_DTR_DTPRSC |
2197 HRTIM_DTR_DTRSLK | HRTIM_DTR_DTRLK | HRTIM_DTR_SDTF |
2198 HRTIM_DTR_SDTR | HRTIM_DTR_DTFSLK | HRTIM_DTR_DTFLK);
2200 /* Set timer dead times configuration */
2201 HRTIM_dtr |= (pDeadTimeCfg->Prescaler << 10);
2202 HRTIM_dtr |= pDeadTimeCfg->RisingValue;
2203 HRTIM_dtr |= pDeadTimeCfg->RisingSign;
2204 HRTIM_dtr |= pDeadTimeCfg->RisingSignLock;
2205 HRTIM_dtr |= pDeadTimeCfg->RisingLock;
2206 HRTIM_dtr |= (pDeadTimeCfg->FallingValue << 16);
2207 HRTIM_dtr |= pDeadTimeCfg->FallingSign;
2208 HRTIM_dtr |= pDeadTimeCfg->FallingSignLock;
2209 HRTIM_dtr |= pDeadTimeCfg->FallingLock;
2211 /* Update the HRTIMx registers */
2212 HRTIMx->HRTIM_TIMERx[TimerIdx].DTxR = HRTIM_dtr;
2216 * @brief Configures the chopper mode feature for a timer
2217 * @param HRTIMx: pointer to HRTIMx peripheral
2218 * @param TimerIdx: Timer index
2219 * This parameter can be one of the following values:
2220 * @arg 0x0 to 0x4 for timers A to E
2221 * @param pChopperModeCfg: pointer to the chopper mode configuration structure
2224 void HRTIM_ChopperModeConfig(HRTIM_TypeDef * HRTIMx,
2226 HRTIM_ChopperModeCfgTypeDef* pChopperModeCfg)
2228 uint32_t HRTIM_chpr;
2230 /* Check parameters */
2231 assert_param(IS_HRTIM_TIMING_UNIT(TimerIdx));
2233 HRTIM_chpr = HRTIMx->HRTIM_TIMERx[TimerIdx].CHPxR;
2235 /* Clear timer chopper mode configuration */
2236 HRTIM_chpr &= ~(HRTIM_CHPR_CARFRQ | HRTIM_CHPR_CARDTY | HRTIM_CHPR_STRPW);
2238 /* Set timer chopper mode configuration */
2239 HRTIM_chpr |= pChopperModeCfg->CarrierFreq;
2240 HRTIM_chpr |= (pChopperModeCfg->DutyCycle << 4);
2241 HRTIM_chpr |= (pChopperModeCfg->StartPulse << 7);
2243 /* Update the HRTIMx registers */
2244 HRTIMx->HRTIM_TIMERx[TimerIdx].CHPxR = HRTIM_chpr;
2248 * @brief Configures the burst DMA controller for a timer
2249 * @param HRTIMx: pointer to HRTIMx peripheral
2250 * @param TimerIdx: Timer index
2251 * This parameter can be one of the following values:
2252 * @arg 0x5 for master timer
2253 * @arg 0x0 to 0x4 for timers A to E
2254 * @param RegistersToUpdate: registers to be written by DMA
2255 * This parameter can be any combination of the following values:
2256 * @arg HRTIM_BURSTDMA_CR: HRTIM_MCR or HRTIM_TIMxCR
2257 * @arg HRTIM_BURSTDMA_ICR: HRTIM_MICR or HRTIM_TIMxICR
2258 * @arg HRTIM_BURSTDMA_DIER: HRTIM_MDIER or HRTIM_TIMxDIER
2259 * @arg HRTIM_BURSTDMA_CNT: HRTIM_MCNT or HRTIM_TIMxCNT
2260 * @arg HRTIM_BURSTDMA_PER: HRTIM_MPER or HRTIM_TIMxPER
2261 * @arg HRTIM_BURSTDMA_REP: HRTIM_MREP or HRTIM_TIMxREP
2262 * @arg HRTIM_BURSTDMA_CMP1: HRTIM_MCMP1 or HRTIM_TIMxCMP1
2263 * @arg HRTIM_BURSTDMA_CMP2: HRTIM_MCMP2 or HRTIM_TIMxCMP2
2264 * @arg HRTIM_BURSTDMA_CMP3: HRTIM_MCMP3 or HRTIM_TIMxCMP3
2265 * @arg HRTIM_BURSTDMA_CMP4: HRTIM_MCMP4 or HRTIM_TIMxCMP4
2266 * @arg HRTIM_BURSTDMA_DTR: HRTIM_TIMxDTR
2267 * @arg HRTIM_BURSTDMA_SET1R: HRTIM_TIMxSET1R
2268 * @arg HRTIM_BURSTDMA_RST1R: HRTIM_TIMxRST1R
2269 * @arg HRTIM_BURSTDMA_SET2R: HRTIM_TIMxSET2R
2270 * @arg HRTIM_BURSTDMA_RST2R: HRTIM_TIMxRST2R
2271 * @arg HRTIM_BURSTDMA_EEFR1: HRTIM_TIMxEEFR1
2272 * @arg HRTIM_BURSTDMA_EEFR2: HRTIM_TIMxEEFR2
2273 * @arg HRTIM_BURSTDMA_RSTR: HRTIM_TIMxRSTR
2274 * @arg HRTIM_BURSTDMA_CHPR: HRTIM_TIMxCHPR
2275 * @arg HRTIM_BURSTDMA_OUTR: HRTIM_TIMxOUTR
2276 * @arg HRTIM_BURSTDMA_FLTR: HRTIM_TIMxFLTR
2279 void HRTIM_BurstDMAConfig(HRTIM_TypeDef * HRTIMx,
2281 uint32_t RegistersToUpdate)
2283 /* Check parameters */
2284 assert_param(IS_HRTIM_TIMER_BURSTDMA(TimerIdx, RegistersToUpdate));
2286 /* Set the burst DMA timer update register */
2289 case HRTIM_TIMERINDEX_TIMER_A:
2291 HRTIMx->HRTIM_COMMON.BDTAUPR = RegistersToUpdate;
2294 case HRTIM_TIMERINDEX_TIMER_B:
2296 HRTIMx->HRTIM_COMMON.BDTBUPR = RegistersToUpdate;
2299 case HRTIM_TIMERINDEX_TIMER_C:
2301 HRTIMx->HRTIM_COMMON.BDTCUPR = RegistersToUpdate;
2304 case HRTIM_TIMERINDEX_TIMER_D:
2306 HRTIMx->HRTIM_COMMON.BDTDUPR = RegistersToUpdate;
2309 case HRTIM_TIMERINDEX_TIMER_E:
2311 HRTIMx->HRTIM_COMMON.BDTEUPR = RegistersToUpdate;
2314 case HRTIM_TIMERINDEX_MASTER:
2316 HRTIMx->HRTIM_COMMON.BDMUPDR = RegistersToUpdate;
2325 * @brief Configures the external input/output synchronization of the HRTIMx
2326 * @param HRTIMx: pointer to HRTIMx peripheral
2327 * @param pSynchroCfg: pointer to the input/output synchronization configuration structure
2330 void HRTIM_SynchronizationConfig(HRTIM_TypeDef *HRTIMx, HRTIM_SynchroCfgTypeDef * pSynchroCfg)
2334 /* Check parameters */
2335 assert_param(IS_HRTIM_SYNCINPUTSOURCE(pSynchroCfg->SyncInputSource));
2336 assert_param(IS_HRTIM_SYNCOUTPUTSOURCE(pSynchroCfg->SyncOutputSource));
2337 assert_param(IS_HRTIM_SYNCOUTPUTPOLARITY(pSynchroCfg->SyncOutputPolarity));
2339 HRTIM_mcr = HRTIMx->HRTIM_MASTER.MCR;
2341 /* Set the synchronization input source */
2342 HRTIM_mcr &= ~(HRTIM_MCR_SYNC_IN);
2343 HRTIM_mcr |= pSynchroCfg->SyncInputSource;
2345 /* Set the event to be sent on the synchronization output */
2346 HRTIM_mcr &= ~(HRTIM_MCR_SYNC_SRC);
2347 HRTIM_mcr |= pSynchroCfg->SyncOutputSource;
2349 /* Set the polarity of the synchronization output */
2350 HRTIM_mcr &= ~(HRTIM_MCR_SYNC_OUT);
2351 HRTIM_mcr |= pSynchroCfg->SyncOutputPolarity;
2353 /* Update the HRTIMx registers */
2354 HRTIMx->HRTIM_MASTER.MCR = HRTIM_mcr;
2358 * @brief Configures the burst mode feature of the HRTIMx
2359 * @param HRTIMx: pointer to HRTIMx peripheral
2360 * @param pBurstModeCfg: pointer to the burst mode configuration structure
2363 void HRTIM_BurstModeConfig(HRTIM_TypeDef * HRTIMx,
2364 HRTIM_BurstModeCfgTypeDef* pBurstModeCfg)
2366 uint32_t HRTIM_bmcr;
2368 /* Check parameters */
2369 assert_param(IS_HRTIM_BURSTMODE(pBurstModeCfg->Mode));
2370 assert_param(IS_HRTIM_BURSTMODECLOCKSOURCE(pBurstModeCfg->ClockSource));
2371 assert_param(IS_HRTIM_HRTIM_BURSTMODEPRESCALER(pBurstModeCfg->Prescaler));
2372 assert_param(IS_HRTIM_BURSTMODEPRELOAD(pBurstModeCfg->PreloadEnable));
2374 HRTIM_bmcr = HRTIMx->HRTIM_COMMON.BMCR;
2376 /* Set the burst mode operating mode */
2377 HRTIM_bmcr &= ~(HRTIM_BMCR_BMOM);
2378 HRTIM_bmcr |= pBurstModeCfg->Mode;
2380 /* Set the burst mode clock source */
2381 HRTIM_bmcr &= ~(HRTIM_BMCR_BMCLK);
2382 HRTIM_bmcr |= pBurstModeCfg->ClockSource;
2384 /* Set the burst mode prescaler */
2385 HRTIM_bmcr &= ~(HRTIM_BMCR_BMPSC);
2386 HRTIM_bmcr |= pBurstModeCfg->Prescaler;
2388 /* Enable/disable burst mode registers preload */
2389 HRTIM_bmcr &= ~(HRTIM_BMCR_BMPREN);
2390 HRTIM_bmcr |= pBurstModeCfg->PreloadEnable;
2392 /* Set the burst mode trigger */
2393 HRTIMx->HRTIM_COMMON.BMTRGR = pBurstModeCfg->Trigger;
2395 /* Set the burst mode compare value */
2396 HRTIMx->HRTIM_COMMON.BMCMPR = pBurstModeCfg->IdleDuration;
2398 /* Set the burst mode period */
2399 HRTIMx->HRTIM_COMMON.BMPER = pBurstModeCfg->Period;
2401 /* Update the HRTIMx registers */
2402 HRTIMx->HRTIM_COMMON.BMCR = HRTIM_bmcr;
2406 * @brief Configures the conditioning of an external event
2407 * @param HRTIMx: pointer to HRTIMx peripheral
2408 * @param Event: external event to configure
2409 * This parameter can be one of the following values:
2410 * @arg HRTIM_EVENT_1: External event 1
2411 * @arg HRTIM_EVENT_2: External event 2
2412 * @arg HRTIM_EVENT_3: External event 3
2413 * @arg HRTIM_EVENT_4: External event 4
2414 * @arg HRTIM_EVENT_5: External event 5
2415 * @arg HRTIM_EVENT_6: External event 6
2416 * @arg HRTIM_EVENT_7: External event 7
2417 * @arg HRTIM_EVENT_8: External event 8
2418 * @arg HRTIM_EVENT_9: External event 9
2419 * @arg HRTIM_EVENT_10: External event 10
2420 * @param pEventCfg: pointer to the event conditioning configuration structure
2423 void HRTIM_EventConfig(HRTIM_TypeDef * HRTIMx,
2425 HRTIM_EventCfgTypeDef* pEventCfg)
2427 /* Check parameters */
2428 assert_param(IS_HRTIM_EVENTSRC(pEventCfg->Source));
2429 assert_param(IS_HRTIM_EVENTPOLARITY(pEventCfg->Polarity));
2430 assert_param(IS_HRTIM_EVENTSENSITIVITY(pEventCfg->Sensitivity));
2431 assert_param(IS_HRTIM_EVENTFASTMODE(pEventCfg->FastMode));
2432 assert_param(IS_HRTIM_EVENTFILTER(pEventCfg->Filter));
2434 /* Configure the event channel */
2435 HRTIM_ExternalEventConfig(HRTIMx, Event, pEventCfg);
2440 * @brief Configures the external event conditioning block prescaler
2441 * @param HRTIMx: pointer to HRTIMx peripheral
2442 * @param Prescaler: Prescaler value
2443 * This parameter can be one of the following values:
2444 * @arg HRTIM_EVENTPRESCALER_DIV1: fEEVS=fHRTIMx
2445 * @arg HRTIM_EVENTPRESCALER_DIV2: fEEVS=fHRTIMx / 2
2446 * @arg HRTIM_EVENTPRESCALER_DIV4: fEEVS=fHRTIMx / 4
2447 * @arg HRTIM_EVENTPRESCALER_DIV8: fEEVS=fHRTIMx / 8
2450 void HRTIM_EventPrescalerConfig(HRTIM_TypeDef * HRTIMx,
2453 uint32_t HRTIM_eecr3;
2455 /* Check parameters */
2456 assert_param(IS_HRTIM_EVENTPRESCALER(Prescaler));
2458 /* Set the external event prescaler */
2459 HRTIM_eecr3 = HRTIMx->HRTIM_COMMON.EECR3;
2460 HRTIM_eecr3 &= ~(HRTIM_EECR3_EEVSD);
2461 HRTIM_eecr3 |= Prescaler;
2463 /* Update the HRTIMx registers */
2464 HRTIMx->HRTIM_COMMON.EECR3 = HRTIM_eecr3;
2468 * @brief Configures the conditioning of fault input
2469 * @param HRTIMx: pointer to HRTIMx peripheral
2470 * @param Fault: fault input to configure
2471 * This parameter can be one of the following values:
2472 * @arg HRTIM_FAULT_1: Fault input 1
2473 * @arg HRTIM_FAULT_2: Fault input 2
2474 * @arg HRTIM_FAULT_3: Fault input 3
2475 * @arg HRTIM_FAULT_4: Fault input 4
2476 * @arg HRTIM_FAULT_5: Fault input 5
2477 * @param pFaultCfg: pointer to the fault conditioning configuration structure
2480 void HRTIM_FaultConfig(HRTIM_TypeDef * HRTIMx,
2481 HRTIM_FaultCfgTypeDef* pFaultCfg,
2484 uint32_t HRTIM_fltinr1;
2485 uint32_t HRTIM_fltinr2;
2487 /* Check parameters */
2488 assert_param(IS_HRTIM_FAULT(Fault));
2489 assert_param(IS_HRTIM_FAULTSOURCE(pFaultCfg->Source));
2490 assert_param(IS_HRTIM_FAULTPOLARITY(pFaultCfg->Polarity));
2491 assert_param(IS_HRTIM_FAULTFILTER(pFaultCfg->Filter));
2492 assert_param(IS_HRTIM_FAULTLOCK(pFaultCfg->Lock));
2494 /* Configure fault channel */
2495 HRTIM_fltinr1 = HRTIMx->HRTIM_COMMON.FLTINxR1;
2496 HRTIM_fltinr2 = HRTIMx->HRTIM_COMMON.FLTINxR2;
2502 HRTIM_fltinr1 &= ~(HRTIM_FLTINR1_FLT1P | HRTIM_FLTINR1_FLT1SRC | HRTIM_FLTINR1_FLT1F | HRTIM_FLTINR1_FLT1LCK);
2503 HRTIM_fltinr1 |= pFaultCfg->Polarity;
2504 HRTIM_fltinr1 |= pFaultCfg->Source;
2505 HRTIM_fltinr1 |= pFaultCfg->Filter;
2506 HRTIM_fltinr1 |= pFaultCfg->Lock;
2511 HRTIM_fltinr1 &= ~(HRTIM_FLTINR1_FLT2P | HRTIM_FLTINR1_FLT2SRC | HRTIM_FLTINR1_FLT2F | HRTIM_FLTINR1_FLT2LCK);
2512 HRTIM_fltinr1 |= (pFaultCfg->Polarity << 8);
2513 HRTIM_fltinr1 |= (pFaultCfg->Source << 8);
2514 HRTIM_fltinr1 |= (pFaultCfg->Filter << 8);
2515 HRTIM_fltinr1 |= (pFaultCfg->Lock << 8);
2520 HRTIM_fltinr1 &= ~(HRTIM_FLTINR1_FLT3P | HRTIM_FLTINR1_FLT3SRC | HRTIM_FLTINR1_FLT3F | HRTIM_FLTINR1_FLT3LCK);
2521 HRTIM_fltinr1 |= (pFaultCfg->Polarity << 16);
2522 HRTIM_fltinr1 |= (pFaultCfg->Source << 16);
2523 HRTIM_fltinr1 |= (pFaultCfg->Filter << 16);
2524 HRTIM_fltinr1 |= (pFaultCfg->Lock << 16);
2529 HRTIM_fltinr1 &= ~(HRTIM_FLTINR1_FLT4P | HRTIM_FLTINR1_FLT4SRC | HRTIM_FLTINR1_FLT4F | HRTIM_FLTINR1_FLT4LCK);
2530 HRTIM_fltinr1 |= (pFaultCfg->Polarity << 24);
2531 HRTIM_fltinr1 |= (pFaultCfg->Source << 24);
2532 HRTIM_fltinr1 |= (pFaultCfg->Filter << 24);
2533 HRTIM_fltinr1 |= (pFaultCfg->Lock << 24);
2538 HRTIM_fltinr2 &= ~(HRTIM_FLTINR2_FLT5P | HRTIM_FLTINR2_FLT5SRC | HRTIM_FLTINR2_FLT5F | HRTIM_FLTINR2_FLT5LCK);
2539 HRTIM_fltinr2 |= pFaultCfg->Polarity;
2540 HRTIM_fltinr2 |= pFaultCfg->Source;
2541 HRTIM_fltinr2 |= pFaultCfg->Filter;
2542 HRTIM_fltinr2 |= pFaultCfg->Lock;
2549 /* Update the HRTIMx registers */
2550 HRTIMx->HRTIM_COMMON.FLTINxR1 = HRTIM_fltinr1;
2551 HRTIMx->HRTIM_COMMON.FLTINxR2 = HRTIM_fltinr2;
2555 * @brief Configures the fault conditioning block prescaler
2556 * @param HRTIMx: pointer to HRTIMx peripheral
2557 * @param Prescaler: Prescaler value
2558 * This parameter can be one of the following values:
2559 * @arg HRTIM_FAULTPRESCALER_DIV1: fFLTS=fHRTIMx
2560 * @arg HRTIM_FAULTPRESCALER_DIV2: fFLTS=fHRTIMx / 2
2561 * @arg HRTIM_FAULTPRESCALER_DIV4: fFLTS=fHRTIMx / 4
2562 * @arg HRTIM_FAULTPRESCALER_DIV8: fFLTS=fHRTIMx / 8
2565 void HRTIM_FaultPrescalerConfig(HRTIM_TypeDef * HRTIMx,
2568 uint32_t HRTIM_fltinr2;
2570 /* Check parameters */
2571 assert_param(IS_HRTIM_FAULTPRESCALER(Prescaler));
2573 /* Set the external event prescaler */
2574 HRTIM_fltinr2 = HRTIMx->HRTIM_COMMON.FLTINxR2;
2575 HRTIM_fltinr2 &= ~(HRTIM_FLTINR2_FLTSD);
2576 HRTIM_fltinr2 |= Prescaler;
2578 /* Update the HRTIMx registers */
2579 HRTIMx->HRTIM_COMMON.FLTINxR2 = HRTIM_fltinr2;
2583 * @brief Enables or disables the HRTIMx Fault mode.
2584 * @param HRTIMx: pointer to HRTIMx peripheral
2585 * @param Fault: fault input to configure
2586 * This parameter can be one of the following values:
2587 * @arg HRTIM_FAULT_1: Fault input 1
2588 * @arg HRTIM_FAULT_2: Fault input 2
2589 * @arg HRTIM_FAULT_3: Fault input 3
2590 * @arg HRTIM_FAULT_4: Fault input 4
2591 * @arg HRTIM_FAULT_5: Fault input 5
2592 * @param Enable: Fault mode controller enabling
2593 * This parameter can be one of the following values:
2594 * @arg HRTIM_FAULT_ENABLED: Fault mode enabled
2595 * @arg HRTIM_FAULT_DISABLED: Fault mode disabled
2598 void HRTIM_FaultModeCtl(HRTIM_TypeDef * HRTIMx, uint32_t Fault, uint32_t Enable)
2600 uint32_t HRTIM_fltinr1;
2601 uint32_t HRTIM_fltinr2;
2603 /* Check parameters */
2604 assert_param(IS_HRTIM_FAULT(Fault));
2605 assert_param(IS_HRTIM_FAULTCTL(Enable));
2607 /* Configure fault channel */
2608 HRTIM_fltinr1 = HRTIMx->HRTIM_COMMON.FLTINxR1;
2609 HRTIM_fltinr2 = HRTIMx->HRTIM_COMMON.FLTINxR2;
2615 HRTIM_fltinr1 &= ~HRTIM_FLTINR1_FLT1E;
2616 HRTIM_fltinr1 |= Enable;
2621 HRTIM_fltinr1 &= ~HRTIM_FLTINR1_FLT2E;
2622 HRTIM_fltinr1 |= (Enable<< 8);
2627 HRTIM_fltinr1 &= ~HRTIM_FLTINR1_FLT3E;
2628 HRTIM_fltinr1 |= (Enable << 16);
2633 HRTIM_fltinr1 &= ~HRTIM_FLTINR1_FLT4E;
2634 HRTIM_fltinr1 |= (Enable << 24);
2639 HRTIM_fltinr2 &= ~HRTIM_FLTINR2_FLT5E;
2640 HRTIM_fltinr2 |= Enable;
2647 /* Update the HRTIMx registers */
2648 HRTIMx->HRTIM_COMMON.FLTINxR1 = HRTIM_fltinr1;
2649 HRTIMx->HRTIM_COMMON.FLTINxR2 = HRTIM_fltinr2;
2653 * @brief Configures both the ADC trigger register update source and the ADC
2655 * @param HRTIMx: pointer to HRTIMx peripheral
2656 * @param ADC trigger: ADC trigger to configure
2657 * This parameter can be one of the following values:
2658 * @arg HRTIM_ADCTRIGGER_1: ADC trigger 1
2659 * @arg HRTIM_ADCTRIGGER_2: ADC trigger 2
2660 * @arg HRTIM_ADCTRIGGER_3: ADC trigger 3
2661 * @arg HRTIM_ADCTRIGGER_4: ADC trigger 4
2662 * @param pADCTriggerCfg: pointer to the ADC trigger configuration structure
2665 void HRTIM_ADCTriggerConfig(HRTIM_TypeDef * HRTIMx,
2666 uint32_t ADCTrigger,
2667 HRTIM_ADCTriggerCfgTypeDef* pADCTriggerCfg)
2671 /* Check parameters */
2672 assert_param(IS_HRTIM_ADCTRIGGER(ADCTrigger));
2673 assert_param(IS_HRTIM_ADCTRIGGERUPDATE(pADCTriggerCfg->UpdateSource));
2675 /* Set the ADC trigger update source */
2676 HRTIM_cr1 = HRTIMx->HRTIM_COMMON.CR1;
2680 case HRTIM_ADCTRIGGER_1:
2682 HRTIM_cr1 &= ~(HRTIM_CR1_ADC1USRC);
2683 HRTIM_cr1 |= pADCTriggerCfg->UpdateSource;
2685 /* Set the ADC trigger 1 source */
2686 HRTIMx->HRTIM_COMMON.ADC1R = pADCTriggerCfg->Trigger;
2689 case HRTIM_ADCTRIGGER_2:
2691 HRTIM_cr1 &= ~(HRTIM_CR1_ADC2USRC);
2692 HRTIM_cr1 |= (pADCTriggerCfg->UpdateSource << 3);
2694 /* Set the ADC trigger 2 source */
2695 HRTIMx->HRTIM_COMMON.ADC2R = pADCTriggerCfg->Trigger;
2698 case HRTIM_ADCTRIGGER_3:
2700 HRTIM_cr1 &= ~(HRTIM_CR1_ADC3USRC);
2701 HRTIM_cr1 |= (pADCTriggerCfg->UpdateSource << 6);
2703 /* Set the ADC trigger 3 source */
2704 HRTIMx->HRTIM_COMMON.ADC3R = pADCTriggerCfg->Trigger;
2706 case HRTIM_ADCTRIGGER_4:
2708 HRTIM_cr1 &= ~(HRTIM_CR1_ADC4USRC);
2709 HRTIM_cr1 |= (pADCTriggerCfg->UpdateSource << 9);
2711 /* Set the ADC trigger 4 source */
2712 HRTIMx->HRTIM_COMMON.ADC4R = pADCTriggerCfg->Trigger;
2719 /* Update the HRTIMx registers */
2720 HRTIMx->HRTIM_COMMON.CR1 = HRTIM_cr1;
2725 * @brief Enables or disables the HRTIMx burst mode controller.
2726 * @param HRTIMx: pointer to HRTIMx peripheral
2727 * @param Enable: Burst mode controller enabling
2728 * This parameter can be one of the following values:
2729 * @arg HRTIM_BURSTMODECTL_ENABLED: Burst mode enabled
2730 * @arg HRTIM_BURSTMODECTL_DISABLED: Burst mode disabled
2733 void HRTIM_BurstModeCtl(HRTIM_TypeDef * HRTIMx, uint32_t Enable)
2735 uint32_t HRTIM_bmcr;
2737 /* Check parameters */
2738 assert_param(IS_HRTIM_BURSTMODECTL(Enable));
2740 /* Enable/Disable the burst mode controller */
2741 HRTIM_bmcr = HRTIMx->HRTIM_COMMON.BMCR;
2742 HRTIM_bmcr &= ~(HRTIM_BMCR_BME);
2743 HRTIM_bmcr |= Enable;
2745 /* Update the HRTIMx registers */
2746 HRTIMx->HRTIM_COMMON.BMCR = HRTIM_bmcr;
2750 * @brief Triggers a software capture on the designed capture unit
2751 * @param HRTIMx: pointer to HRTIMx peripheral
2752 * @param TimerIdx: Timer index
2753 * This parameter can be one of the following values:
2754 * @arg 0x0 to 0x4 for timers A to E
2755 * @param CaptureUnit: Capture unit to trig
2756 * This parameter can be one of the following values:
2757 * @arg HRTIM_CAPTUREUNIT_1: Capture unit 1
2758 * @arg HRTIM_CAPTUREUNIT_2: Capture unit 2
2760 * @note The 'software capture' bit in the capure configuration register is
2761 * automatically reset by hardware
2763 void HRTIM_SoftwareCapture(HRTIM_TypeDef * HRTIMx,
2765 uint32_t CaptureUnit)
2767 /* Check parameters */
2768 assert_param(IS_HRTIM_TIMING_UNIT(TimerIdx));
2769 assert_param(IS_HRTIM_CAPTUREUNIT(CaptureUnit));
2771 /* Force a software capture on concerned capture unit */
2772 switch (CaptureUnit)
2774 case HRTIM_CAPTUREUNIT_1:
2776 HRTIMx->HRTIM_TIMERx[TimerIdx].CPT1xCR |= HRTIM_CPT1CR_SWCPT;
2779 case HRTIM_CAPTUREUNIT_2:
2781 HRTIMx->HRTIM_TIMERx[TimerIdx].CPT2xCR |= HRTIM_CPT2CR_SWCPT;
2790 * @brief Triggers the update of the registers of one or several timers
2791 * @param HRTIMx: pointer to HRTIMx peripheral
2792 * @param TimersToUpdate: timers concerned with the software register update
2793 * This parameter can be any combination of the following values:
2794 * @arg HRTIM_TIMERUPDATE_MASTER
2795 * @arg HRTIM_TIMERUPDATE_A
2796 * @arg HRTIM_TIMERUPDATE_B
2797 * @arg HRTIM_TIMERUPDATE_C
2798 * @arg HRTIM_TIMERUPDATE_D
2799 * @arg HRTIM_TIMERUPDATE_E
2801 * @note The 'software update' bits in the HRTIMx control register 2 register are
2802 * automatically reset by hardware
2804 void HRTIM_SoftwareUpdate(HRTIM_TypeDef * HRTIMx,
2805 uint32_t TimersToUpdate)
2807 /* Check parameters */
2808 assert_param(IS_HRTIM_TIMERUPDATE(TimersToUpdate));
2810 /* Force timer(s) registers update */
2811 HRTIMx->HRTIM_COMMON.CR2 |= TimersToUpdate;
2816 * @brief Triggers the reset of one or several timers
2817 * @param HRTIMx: pointer to HRTIMx peripheral
2818 * @param TimersToUpdate: timers concerned with the software counter reset
2819 * This parameter can be any combination of the following values:
2820 * @arg HRTIM_TIMER_MASTER
2821 * @arg HRTIM_TIMER_A
2822 * @arg HRTIM_TIMER_B
2823 * @arg HRTIM_TIMER_C
2824 * @arg HRTIM_TIMER_D
2825 * @arg HRTIM_TIMER_E
2827 * @note The 'software reset' bits in the HRTIMx control register 2 are
2828 * automatically reset by hardware
2830 void HRTIM_SoftwareReset(HRTIM_TypeDef * HRTIMx,
2831 uint32_t TimersToReset)
2833 /* Check parameters */
2834 assert_param(IS_HRTIM_TIMERRESET(TimersToReset));
2836 /* Force timer(s) registers update */
2837 HRTIMx->HRTIM_COMMON.CR2 |= TimersToReset;
2842 * @brief Forces the timer output to its active or inactive state
2843 * @param HRTIMx: pointer to HRTIMx peripheral
2844 * @param TimerIdx: Timer index
2845 * This parameter can be one of the following values:
2846 * @arg 0x0 to 0x4 for timers A to E
2847 * @param Output: Timer output
2848 * This parameter can be one of the following values:
2849 * @arg HRTIM_OUTPUT_TA1: Timer A - Output 1
2850 * @arg HRTIM_OUTPUT_TA2: Timer A - Output 2
2851 * @arg HRTIM_OUTPUT_TB1: Timer B - Output 1
2852 * @arg HRTIM_OUTPUT_TB2: Timer B - Output 2
2853 * @arg HRTIM_OUTPUT_TC1: Timer C - Output 1
2854 * @arg HRTIM_OUTPUT_TC2: Timer C - Output 2
2855 * @arg HRTIM_OUTPUT_TD1: Timer D - Output 1
2856 * @arg HRTIM_OUTPUT_TD2: Timer D - Output 2
2857 * @arg HRTIM_OUTPUT_TE1: Timer E - Output 1
2858 * @arg HRTIM_OUTPUT_TE2: Timer E - Output 2
2859 * @param OutputLevel: indicates whether the output is forced to its active or inactive state
2860 * This parameter can be one of the following values:
2861 * @arg HRTIM_OUTPUTLEVEL_ACTIVE: output is forced to its active state
2862 * @arg HRTIM_OUTPUTLEVEL_INACTIVE: output is forced to its inactive state
2864 * @note The 'software set/reset trigger' bit in the output set/reset registers
2865 * is automatically reset by hardware
2867 void HRTIM_WaveformSetOutputLevel(HRTIM_TypeDef * HRTIMx,
2870 uint32_t OutputLevel)
2872 /* Check parameters */
2873 assert_param(IS_HRTIM_TIMER_OUTPUT(TimerIdx, Output));
2874 assert_param(IS_HRTIM_OUTPUTLEVEL(OutputLevel));
2876 /* Force timer output level */
2879 case HRTIM_OUTPUT_TA1:
2880 case HRTIM_OUTPUT_TB1:
2881 case HRTIM_OUTPUT_TC1:
2882 case HRTIM_OUTPUT_TD1:
2883 case HRTIM_OUTPUT_TE1:
2885 if (OutputLevel == HRTIM_OUTPUTLEVEL_ACTIVE)
2887 /* Force output to its active state */
2888 HRTIMx->HRTIM_TIMERx[TimerIdx].SETx1R |= HRTIM_SET1R_SST;
2892 /* Force output to its inactive state */
2893 HRTIMx->HRTIM_TIMERx[TimerIdx].RSTx1R |= HRTIM_RST1R_SRT;
2897 case HRTIM_OUTPUT_TA2:
2898 case HRTIM_OUTPUT_TB2:
2899 case HRTIM_OUTPUT_TC2:
2900 case HRTIM_OUTPUT_TD2:
2901 case HRTIM_OUTPUT_TE2:
2903 if (OutputLevel == HRTIM_OUTPUTLEVEL_ACTIVE)
2905 /* Force output to its active state */
2906 HRTIMx->HRTIM_TIMERx[TimerIdx].SETx2R |= HRTIM_SET2R_SST;
2910 /* Force output to its inactive state */
2911 HRTIMx->HRTIM_TIMERx[TimerIdx].RSTx2R |= HRTIM_RST2R_SRT;
2925 /** @defgroup HRTIM_Group4 Peripheral State methods
2926 * @brief Peripheral State functions
2929 ===============================================================================
2930 ##### Peripheral State methods #####
2931 ===============================================================================
2933 This subsection permit to get in run-time the status of the peripheral
2941 * @brief Returns actual value of the capture register of the designated capture unit
2942 * @param HRTIMx: pointer to HRTIMx peripheral
2943 * @param TimerIdx: Timer index
2944 * This parameter can be one of the following values:
2945 * @arg 0x0 to 0x4 for timers A to E
2946 * @param CaptureUnit: Capture unit to trig
2947 * This parameter can be one of the following values:
2948 * @arg HRTIM_CAPTUREUNIT_1: Capture unit 1
2949 * @arg HRTIM_CAPTUREUNIT_2: Capture unit 2
2950 * @retval Captured value
2952 uint32_t HRTIM_GetCapturedValue(HRTIM_TypeDef * HRTIMx,
2954 uint32_t CaptureUnit)
2956 uint32_t captured_value = 0;
2958 /* Check parameters */
2959 assert_param(IS_HRTIM_TIMING_UNIT(TimerIdx));
2960 assert_param(IS_HRTIM_CAPTUREUNIT(CaptureUnit));
2962 /* Read captured value */
2963 switch (CaptureUnit)
2965 case HRTIM_CAPTUREUNIT_1:
2967 captured_value = HRTIMx->HRTIM_TIMERx[TimerIdx].CPT1xR;
2970 case HRTIM_CAPTUREUNIT_2:
2972 captured_value = HRTIMx->HRTIM_TIMERx[TimerIdx].CPT2xR;
2979 return captured_value;
2983 * @brief Returns actual level (active or inactive) of the designated output
2984 * @param HRTIMx: pointer to HRTIMx peripheral
2985 * @param TimerIdx: Timer index
2986 * This parameter can be one of the following values:
2987 * @arg 0x0 to 0x4 for timers A to E
2988 * @param Output: Timer output
2989 * This parameter can be one of the following values:
2990 * @arg HRTIM_OUTPUT_TA1: Timer A - Output 1
2991 * @arg HRTIM_OUTPUT_TA2: Timer A - Output 2
2992 * @arg HRTIM_OUTPUT_TB1: Timer B - Output 1
2993 * @arg HRTIM_OUTPUT_TB2: Timer B - Output 2
2994 * @arg HRTIM_OUTPUT_TC1: Timer C - Output 1
2995 * @arg HRTIM_OUTPUT_TC2: Timer C - Output 2
2996 * @arg HRTIM_OUTPUT_TD1: Timer D - Output 1
2997 * @arg HRTIM_OUTPUT_TD2: Timer D - Output 2
2998 * @arg HRTIM_OUTPUT_TE1: Timer E - Output 1
2999 * @arg HRTIM_OUTPUT_TE2: Timer E - Output 2
3000 * @retval Output level
3001 * @note Returned output level is taken before the output stage (chopper,
3004 uint32_t HRTIM_WaveformGetOutputLevel(HRTIM_TypeDef * HRTIMx,
3008 uint32_t output_level = HRTIM_OUTPUTLEVEL_INACTIVE;
3010 /* Check parameters */
3011 assert_param(IS_HRTIM_TIMER_OUTPUT(TimerIdx, Output));
3013 /* Read the output level */
3016 case HRTIM_OUTPUT_TA1:
3017 case HRTIM_OUTPUT_TB1:
3018 case HRTIM_OUTPUT_TC1:
3019 case HRTIM_OUTPUT_TD1:
3020 case HRTIM_OUTPUT_TE1:
3022 if ((HRTIMx->HRTIM_TIMERx[TimerIdx].TIMxISR & HRTIM_TIMISR_O1CPY) != RESET)
3024 output_level = HRTIM_OUTPUTLEVEL_ACTIVE;
3028 output_level = HRTIM_OUTPUTLEVEL_INACTIVE;
3032 case HRTIM_OUTPUT_TA2:
3033 case HRTIM_OUTPUT_TB2:
3034 case HRTIM_OUTPUT_TC2:
3035 case HRTIM_OUTPUT_TD2:
3036 case HRTIM_OUTPUT_TE2:
3038 if ((HRTIMx->HRTIM_TIMERx[TimerIdx].TIMxISR & HRTIM_TIMISR_O2CPY) != RESET)
3040 output_level = HRTIM_OUTPUTLEVEL_ACTIVE;
3044 output_level = HRTIM_OUTPUTLEVEL_INACTIVE;
3052 return output_level;
3056 * @brief Returns actual state (RUN, IDLE, FAULT) of the designated output
3057 * @param HRTIMx: pointer to HRTIMx peripheral
3058 * @param TimerIdx: Timer index
3059 * This parameter can be one of the following values:
3060 * @arg 0x0 to 0x4 for timers A to E
3061 * @param Output: Timer output
3062 * This parameter can be one of the following values:
3063 * @arg HRTIM_OUTPUT_TA1: Timer A - Output 1
3064 * @arg HRTIM_OUTPUT_TA2: Timer A - Output 2
3065 * @arg HRTIM_OUTPUT_TB1: Timer B - Output 1
3066 * @arg HRTIM_OUTPUT_TB2: Timer B - Output 2
3067 * @arg HRTIM_OUTPUT_TC1: Timer C - Output 1
3068 * @arg HRTIM_OUTPUT_TC2: Timer C - Output 2
3069 * @arg HRTIM_OUTPUT_TD1: Timer D - Output 1
3070 * @arg HRTIM_OUTPUT_TD2: Timer D - Output 2
3071 * @arg HRTIM_OUTPUT_TE1: Timer E - Output 1
3072 * @arg HRTIM_OUTPUT_TE2: Timer E - Output 2
3073 * @retval Output state
3075 uint32_t HRTIM_WaveformGetOutputState(HRTIM_TypeDef * HRTIMx,
3079 uint32_t output_bit = 0;
3080 uint32_t output_state = HRTIM_OUTPUTSTATE_IDLE;
3082 /* Check parameters */
3083 assert_param(IS_HRTIM_TIMER_OUTPUT(TimerIdx, Output));
3085 /* Set output state according to output control status and output disable status */
3088 case HRTIM_OUTPUT_TA1:
3090 output_bit = HRTIM_OENR_TA1OEN;
3093 case HRTIM_OUTPUT_TA2:
3095 output_bit = HRTIM_OENR_TA2OEN;
3098 case HRTIM_OUTPUT_TB1:
3100 output_bit = HRTIM_OENR_TB1OEN;
3103 case HRTIM_OUTPUT_TB2:
3105 output_bit = HRTIM_OENR_TB2OEN;
3108 case HRTIM_OUTPUT_TC1:
3110 output_bit = HRTIM_OENR_TC1OEN;
3113 case HRTIM_OUTPUT_TC2:
3115 output_bit = HRTIM_OENR_TC2OEN;
3118 case HRTIM_OUTPUT_TD1:
3120 output_bit = HRTIM_OENR_TD1OEN;
3123 case HRTIM_OUTPUT_TD2:
3125 output_bit = HRTIM_OENR_TD2OEN;
3128 case HRTIM_OUTPUT_TE1:
3130 output_bit = HRTIM_OENR_TE1OEN;
3133 case HRTIM_OUTPUT_TE2:
3135 output_bit = HRTIM_OENR_TE2OEN;
3142 if ((HRTIMx->HRTIM_COMMON.OENR & output_bit) != RESET)
3144 /* Output is enabled: output in RUN state (whatever ouput disable status is)*/
3145 output_state = HRTIM_OUTPUTSTATE_RUN;
3149 if ((HRTIMx->HRTIM_COMMON.ODSR & output_bit) != RESET)
3151 /* Output is disabled: output in FAULT state */
3152 output_state = HRTIM_OUTPUTSTATE_FAULT;
3156 /* Output is disabled: output in IDLE state */
3157 output_state = HRTIM_OUTPUTSTATE_IDLE;
3161 return(output_state);
3165 * @brief Returns the level (active or inactive) of the designated output
3166 * when the delayed protection was triggered
3167 * @param HRTIMx: pointer to HRTIMx peripheral
3168 * @param TimerIdx: Timer index
3169 * This parameter can be one of the following values:
3170 * @arg 0x0 to 0x4 for timers A to E
3171 * @param Output: Timer output
3172 * This parameter can be one of the following values:
3173 * @arg HRTIM_OUTPUT_TA1: Timer A - Output 1
3174 * @arg HRTIM_OUTPUT_TA2: Timer A - Output 2
3175 * @arg HRTIM_OUTPUT_TB1: Timer B - Output 1
3176 * @arg HRTIM_OUTPUT_TB2: Timer B - Output 2
3177 * @arg HRTIM_OUTPUT_TC1: Timer C - Output 1
3178 * @arg HRTIM_OUTPUT_TC2: Timer C - Output 2
3179 * @arg HRTIM_OUTPUT_TD1: Timer D - Output 1
3180 * @arg HRTIM_OUTPUT_TD2: Timer D - Output 2
3181 * @arg HRTIM_OUTPUT_TD1: Timer E - Output 1
3182 * @arg HRTIM_OUTPUT_TD2: Timer E - Output 2
3183 * @retval Delayed protection status
3185 uint32_t HRTIM_GetDelayedProtectionStatus(HRTIM_TypeDef * HRTIMx,
3189 uint32_t delayed_protection_status = HRTIM_OUTPUTLEVEL_INACTIVE;
3191 /* Check parameters */
3192 assert_param(IS_HRTIM_TIMER_OUTPUT(TimerIdx, Output));
3194 /* Read the delayed protection status */
3197 case HRTIM_OUTPUT_TA1:
3198 case HRTIM_OUTPUT_TB1:
3199 case HRTIM_OUTPUT_TC1:
3200 case HRTIM_OUTPUT_TD1:
3201 case HRTIM_OUTPUT_TE1:
3203 if ((HRTIMx->HRTIM_TIMERx[TimerIdx].TIMxISR & HRTIM_TIMISR_O1STAT) != RESET)
3205 /* Output 1 was active when the delayed idle protection was triggered */
3206 delayed_protection_status = HRTIM_OUTPUTLEVEL_ACTIVE;
3210 /* Output 1 was inactive when the delayed idle protection was triggered */
3211 delayed_protection_status = HRTIM_OUTPUTLEVEL_INACTIVE;
3215 case HRTIM_OUTPUT_TA2:
3216 case HRTIM_OUTPUT_TB2:
3217 case HRTIM_OUTPUT_TC2:
3218 case HRTIM_OUTPUT_TD2:
3219 case HRTIM_OUTPUT_TE2:
3221 if ((HRTIMx->HRTIM_TIMERx[TimerIdx].TIMxISR & HRTIM_TIMISR_O2STAT) != RESET)
3223 /* Output 2 was active when the delayed idle protection was triggered */
3224 delayed_protection_status = HRTIM_OUTPUTLEVEL_ACTIVE;
3228 /* Output 2 was inactive when the delayed idle protection was triggered */
3229 delayed_protection_status = HRTIM_OUTPUTLEVEL_INACTIVE;
3237 return delayed_protection_status;
3241 * @brief Returns the actual status (active or inactive) of the burst mode controller
3242 * @param HRTIMx: pointer to HRTIMx peripheral
3243 * @retval Burst mode controller status
3245 uint32_t HRTIM_GetBurstStatus(HRTIM_TypeDef * HRTIMx)
3247 uint32_t burst_mode_status;
3249 /* Read burst mode status */
3250 burst_mode_status = (HRTIMx->HRTIM_COMMON.BMCR & HRTIM_BMCR_BMSTAT);
3252 return burst_mode_status;
3256 * @brief Indicates on which output the signal is currently active (when the
3257 * push pull mode is enabled)
3258 * @param HRTIMx: pointer to HRTIMx peripheral
3259 * @param TimerIdx: Timer index
3260 * This parameter can be one of the following values:
3261 * @arg 0x0 to 0x4 for timers A to E
3262 * @retval Burst mode controller status
3264 uint32_t HRTIM_GetCurrentPushPullStatus(HRTIM_TypeDef * HRTIMx,
3267 uint32_t current_pushpull_status;
3269 /* Check the parameters */
3270 assert_param(IS_HRTIM_TIMING_UNIT(TimerIdx));
3272 /* Read current push pull status */
3273 current_pushpull_status = (HRTIMx->HRTIM_TIMERx[TimerIdx].TIMxISR & HRTIM_TIMISR_CPPSTAT);
3275 return current_pushpull_status;
3280 * @brief Indicates on which output the signal was applied, in push-pull mode
3281 balanced fault mode or delayed idle mode, when the protection was triggered
3282 * @param HRTIMx: pointer to HRTIMx peripheral
3283 * @param TimerIdx: Timer index
3284 * This parameter can be one of the following values:
3285 * @arg 0x0 to 0x4 for timers A to E
3286 * @retval Idle Push Pull Status
3288 uint32_t HRTIM_GetIdlePushPullStatus(HRTIM_TypeDef * HRTIMx,
3291 uint32_t idle_pushpull_status;
3293 /* Check the parameters */
3294 assert_param(IS_HRTIM_TIMING_UNIT(TimerIdx));
3296 /* Read current push pull status */
3297 idle_pushpull_status = (HRTIMx->HRTIM_TIMERx[TimerIdx].TIMxISR & HRTIM_TIMISR_IPPSTAT);
3299 return idle_pushpull_status;
3303 * @brief Configures the master timer time base
3304 * @param HRTIMx: pointer to HRTIMx peripheral
3307 void HRTIM_MasterBase_Config(HRTIM_TypeDef * HRTIMx, HRTIM_BaseInitTypeDef* HRTIM_BaseInitStruct)
3309 /* Set the prescaler ratio */
3310 HRTIMx->HRTIM_MASTER.MCR &= (uint32_t) ~(HRTIM_MCR_CK_PSC);
3311 HRTIMx->HRTIM_MASTER.MCR |= (uint32_t)HRTIM_BaseInitStruct->PrescalerRatio;
3313 /* Set the operating mode */
3314 HRTIMx->HRTIM_MASTER.MCR &= (uint32_t) ~(HRTIM_MCR_CONT | HRTIM_MCR_RETRIG);
3315 HRTIMx->HRTIM_MASTER.MCR |= (uint32_t)HRTIM_BaseInitStruct->Mode;
3317 /* Update the HRTIMx registers */
3318 HRTIMx->HRTIM_MASTER.MPER = HRTIM_BaseInitStruct->Period;
3319 HRTIMx->HRTIM_MASTER.MREP = HRTIM_BaseInitStruct->RepetitionCounter;
3323 * @brief Configures timing unit (timer A to timer E) time base
3324 * @param HRTIMx: pointer to HRTIMx peripheral
3325 * @param TimerIdx: Timer index
3328 void HRTIM_TimingUnitBase_Config(HRTIM_TypeDef * HRTIMx, uint32_t TimerIdx, HRTIM_BaseInitTypeDef* HRTIM_BaseInitStruct)
3330 /* Set the prescaler ratio */
3331 HRTIMx->HRTIM_TIMERx[TimerIdx].TIMxCR &= (uint32_t) ~(HRTIM_TIMCR_CK_PSC);
3332 HRTIMx->HRTIM_TIMERx[TimerIdx].TIMxCR |= (uint32_t)HRTIM_BaseInitStruct->PrescalerRatio;
3334 /* Set the operating mode */
3335 HRTIMx->HRTIM_TIMERx[TimerIdx].TIMxCR &= (uint32_t) ~(HRTIM_TIMCR_CONT | HRTIM_TIMCR_RETRIG);
3336 HRTIMx->HRTIM_TIMERx[TimerIdx].TIMxCR |= (uint32_t)HRTIM_BaseInitStruct->Mode;
3338 /* Update the HRTIMx registers */
3339 HRTIMx->HRTIM_TIMERx[TimerIdx].PERxR = HRTIM_BaseInitStruct->Period;
3340 HRTIMx->HRTIM_TIMERx[TimerIdx].REPxR = HRTIM_BaseInitStruct->RepetitionCounter;
3344 * @brief Configures the master timer in waveform mode
3345 * @param HRTIMx: pointer to HRTIMx peripheral
3346 * @param TimerIdx: Timer index
3347 * @param pTimerInit: pointer to the timer initialization data structure
3350 void HRTIM_MasterWaveform_Config(HRTIM_TypeDef * HRTIMx,
3351 HRTIM_TimerInitTypeDef * pTimerInit)
3354 uint32_t HRTIM_bmcr;
3356 /* Configure master timer */
3357 HRTIM_mcr = HRTIMx->HRTIM_MASTER.MCR;
3358 HRTIM_bmcr = HRTIMx->HRTIM_COMMON.BMCR;
3360 /* Enable/Disable the half mode */
3361 HRTIM_mcr &= ~(HRTIM_MCR_HALF);
3362 HRTIM_mcr |= pTimerInit->HalfModeEnable;
3364 /* Enable/Disable the timer start upon synchronization event reception */
3365 HRTIM_mcr &= ~(HRTIM_MCR_SYNCSTRTM);
3366 HRTIM_mcr |= pTimerInit->StartOnSync;
3368 /* Enable/Disable the timer reset upon synchronization event reception */
3369 HRTIM_mcr &= ~(HRTIM_MCR_SYNCRSTM);
3370 HRTIM_mcr |= pTimerInit->ResetOnSync;
3372 /* Enable/Disable the DAC synchronization event generation */
3373 HRTIM_mcr &= ~(HRTIM_MCR_DACSYNC);
3374 HRTIM_mcr |= pTimerInit->DACSynchro;
3376 /* Enable/Disable preload mechanism for timer registers */
3377 HRTIM_mcr &= ~(HRTIM_MCR_PREEN);
3378 HRTIM_mcr |= pTimerInit->PreloadEnable;
3380 /* Master timer registers update handling */
3381 HRTIM_mcr &= ~(HRTIM_MCR_BRSTDMA);
3382 HRTIM_mcr |= (pTimerInit->UpdateGating << 2);
3384 /* Enable/Disable registers update on repetition */
3385 HRTIM_mcr &= ~(HRTIM_MCR_MREPU);
3386 HRTIM_mcr |= pTimerInit->RepetitionUpdate;
3388 /* Set the timer burst mode */
3389 HRTIM_bmcr &= ~(HRTIM_BMCR_MTBM);
3390 HRTIM_bmcr |= pTimerInit->BurstMode;
3392 /* Update the HRTIMx registers */
3393 HRTIMx->HRTIM_MASTER.MCR = HRTIM_mcr;
3394 HRTIMx->HRTIM_COMMON.BMCR = HRTIM_bmcr;
3399 * @brief Configures timing unit (timer A to timer E) in waveform mode
3400 * @param HRTIMx: pointer to HRTIMx peripheral
3401 * @param TimerIdx: Timer index
3402 * @param pTimerInit: pointer to the timer initialization data structure
3405 void HRTIM_TimingUnitWaveform_Config(HRTIM_TypeDef * HRTIMx,
3407 HRTIM_TimerInitTypeDef * pTimerInit)
3409 uint32_t HRTIM_timcr;
3410 uint32_t HRTIM_bmcr;
3412 /* Configure timing unit */
3413 HRTIM_timcr = HRTIMx->HRTIM_TIMERx[TimerIdx].TIMxCR;
3414 HRTIM_bmcr = HRTIMx->HRTIM_COMMON.BMCR;
3416 /* Enable/Disable the half mode */
3417 HRTIM_timcr &= ~(HRTIM_TIMCR_HALF);
3418 HRTIM_timcr |= pTimerInit->HalfModeEnable;
3420 /* Enable/Disable the timer start upon synchronization event reception */
3421 HRTIM_timcr &= ~(HRTIM_TIMCR_SYNCSTRT);
3422 HRTIM_timcr |= pTimerInit->StartOnSync;
3424 /* Enable/Disable the timer reset upon synchronization event reception */
3425 HRTIM_timcr &= ~(HRTIM_TIMCR_SYNCRST);
3426 HRTIM_timcr |= pTimerInit->ResetOnSync;
3428 /* Enable/Disable the DAC synchronization event generation */
3429 HRTIM_timcr &= ~(HRTIM_TIMCR_DACSYNC);
3430 HRTIM_timcr |= pTimerInit->DACSynchro;
3432 /* Enable/Disable preload mechanism for timer registers */
3433 HRTIM_timcr &= ~(HRTIM_TIMCR_PREEN);
3434 HRTIM_timcr |= pTimerInit->PreloadEnable;
3436 /* Timing unit registers update handling */
3437 HRTIM_timcr &= ~(HRTIM_TIMCR_UPDGAT);
3438 HRTIM_timcr |= pTimerInit->UpdateGating;
3440 /* Enable/Disable registers update on repetition */
3441 HRTIM_timcr &= ~(HRTIM_TIMCR_TREPU);
3442 if (pTimerInit->RepetitionUpdate == HRTIM_UPDATEONREPETITION_ENABLED)
3444 HRTIM_timcr |= HRTIM_TIMCR_TREPU;
3447 /* Set the timer burst mode */
3450 case HRTIM_TIMERINDEX_TIMER_A:
3452 HRTIM_bmcr &= ~(HRTIM_BMCR_TABM);
3453 HRTIM_bmcr |= ( pTimerInit->BurstMode << 1);
3456 case HRTIM_TIMERINDEX_TIMER_B:
3458 HRTIM_bmcr &= ~(HRTIM_BMCR_TBBM);
3459 HRTIM_bmcr |= ( pTimerInit->BurstMode << 2);
3462 case HRTIM_TIMERINDEX_TIMER_C:
3464 HRTIM_bmcr &= ~(HRTIM_BMCR_TCBM);
3465 HRTIM_bmcr |= ( pTimerInit->BurstMode << 3);
3468 case HRTIM_TIMERINDEX_TIMER_D:
3470 HRTIM_bmcr &= ~(HRTIM_BMCR_TDBM);
3471 HRTIM_bmcr |= ( pTimerInit->BurstMode << 4);
3474 case HRTIM_TIMERINDEX_TIMER_E:
3476 HRTIM_bmcr &= ~(HRTIM_BMCR_TEBM);
3477 HRTIM_bmcr |= ( pTimerInit->BurstMode << 5);
3484 /* Update the HRTIMx registers */
3485 HRTIMx->HRTIM_TIMERx[TimerIdx].TIMxCR = HRTIM_timcr;
3486 HRTIMx->HRTIM_COMMON.BMCR = HRTIM_bmcr;
3490 * @brief Configures a compare unit
3491 * @param HRTIMx: pointer to HRTIMx peripheral
3492 * @param TimerIdx: Timer index
3493 * @param CompareUnit: Compare unit identifier
3494 * @param pCompareCfg: pointer to the compare unit configuration data structure
3497 void HRTIM_CompareUnitConfig(HRTIM_TypeDef * HRTIMx,
3499 uint32_t CompareUnit,
3500 HRTIM_CompareCfgTypeDef * pCompareCfg)
3502 if (TimerIdx == HRTIM_TIMERINDEX_MASTER)
3504 /* Configure the compare unit of the master timer */
3505 switch (CompareUnit)
3507 case HRTIM_COMPAREUNIT_1:
3509 HRTIMx->HRTIM_MASTER.MCMP1R = pCompareCfg->CompareValue;
3512 case HRTIM_COMPAREUNIT_2:
3514 HRTIMx->HRTIM_MASTER.MCMP2R = pCompareCfg->CompareValue;
3517 case HRTIM_COMPAREUNIT_3:
3519 HRTIMx->HRTIM_MASTER.MCMP3R = pCompareCfg->CompareValue;
3522 case HRTIM_COMPAREUNIT_4:
3524 HRTIMx->HRTIM_MASTER.MCMP4R = pCompareCfg->CompareValue;
3533 /* Configure the compare unit of the timing unit */
3534 switch (CompareUnit)
3536 case HRTIM_COMPAREUNIT_1:
3538 HRTIMx->HRTIM_TIMERx[TimerIdx].CMP1xR = pCompareCfg->CompareValue;
3541 case HRTIM_COMPAREUNIT_2:
3543 HRTIMx->HRTIM_TIMERx[TimerIdx].CMP2xR = pCompareCfg->CompareValue;
3546 case HRTIM_COMPAREUNIT_3:
3548 HRTIMx->HRTIM_TIMERx[TimerIdx].CMP3xR = pCompareCfg->CompareValue;
3551 case HRTIM_COMPAREUNIT_4:
3553 HRTIMx->HRTIM_TIMERx[TimerIdx].CMP4xR = pCompareCfg->CompareValue;
3563 * @brief Configures a capture unit
3564 * @param HRTIMx: pointer to HRTIMx peripheral
3565 * @param TimerIdx: Timer index
3566 * @param CaptureUnit: Capture unit identifier
3567 * @param pCaptureCfg: pointer to the compare unit configuration data structure
3570 void HRTIM_CaptureUnitConfig(HRTIM_TypeDef * HRTIMx,
3572 uint32_t CaptureUnit,
3575 uint32_t CaptureTrigger = HRTIM_CAPTURETRIGGER_EEV_1;
3581 CaptureTrigger = HRTIM_CAPTURETRIGGER_EEV_1;
3586 CaptureTrigger = HRTIM_CAPTURETRIGGER_EEV_2;
3591 CaptureTrigger = HRTIM_CAPTURETRIGGER_EEV_3;
3596 CaptureTrigger = HRTIM_CAPTURETRIGGER_EEV_4;
3601 CaptureTrigger = HRTIM_CAPTURETRIGGER_EEV_5;
3606 CaptureTrigger = HRTIM_CAPTURETRIGGER_EEV_6;
3611 CaptureTrigger = HRTIM_CAPTURETRIGGER_EEV_7;
3616 CaptureTrigger = HRTIM_CAPTURETRIGGER_EEV_8;
3621 CaptureTrigger = HRTIM_CAPTURETRIGGER_EEV_9;
3624 case HRTIM_EVENT_10:
3626 CaptureTrigger = HRTIM_CAPTURETRIGGER_EEV_10;
3633 switch (CaptureUnit)
3635 case HRTIM_CAPTUREUNIT_1:
3637 HRTIMx->HRTIM_TIMERx[TimerIdx].CPT1xCR = CaptureTrigger;
3640 case HRTIM_CAPTUREUNIT_2:
3642 HRTIMx->HRTIM_TIMERx[TimerIdx].CPT2xCR = CaptureTrigger;
3651 * @brief Configures the output of a timing unit
3652 * @param HRTIMx: pointer to HRTIMx peripheral
3653 * @param TimerIdx: Timer index
3654 * @param Output: timing unit output identifier
3655 * @param pOutputCfg: pointer to the output configuration data structure
3658 void HRTIM_OutputConfig(HRTIM_TypeDef * HRTIMx,
3661 HRTIM_OutputCfgTypeDef * pOutputCfg)
3663 uint32_t HRTIM_outr;
3666 HRTIM_outr = HRTIMx->HRTIM_TIMERx[TimerIdx].OUTxR;
3670 case HRTIM_OUTPUT_TA1:
3671 case HRTIM_OUTPUT_TB1:
3672 case HRTIM_OUTPUT_TC1:
3673 case HRTIM_OUTPUT_TD1:
3674 case HRTIM_OUTPUT_TE1:
3676 /* Set the output set/reset crossbar */
3677 HRTIMx->HRTIM_TIMERx[TimerIdx].SETx1R = pOutputCfg->SetSource;
3678 HRTIMx->HRTIM_TIMERx[TimerIdx].RSTx1R = pOutputCfg->ResetSource;
3683 case HRTIM_OUTPUT_TA2:
3684 case HRTIM_OUTPUT_TB2:
3685 case HRTIM_OUTPUT_TC2:
3686 case HRTIM_OUTPUT_TD2:
3687 case HRTIM_OUTPUT_TE2:
3689 /* Set the output set/reset crossbar */
3690 HRTIMx->HRTIM_TIMERx[TimerIdx].SETx2R = pOutputCfg->SetSource;
3691 HRTIMx->HRTIM_TIMERx[TimerIdx].RSTx2R = pOutputCfg->ResetSource;
3700 /* Clear output config */
3701 HRTIM_outr &= ~((HRTIM_OUTR_POL1 |
3706 HRTIM_OUTR_DIDL1) << shift);
3708 /* Set the polarity */
3709 HRTIM_outr |= (pOutputCfg->Polarity << shift);
3711 /* Set the IDLE mode */
3712 HRTIM_outr |= (pOutputCfg->IdleMode << shift);
3714 /* Set the IDLE state */
3715 HRTIM_outr |= (pOutputCfg->IdleState << shift);
3717 /* Set the FAULT state */
3718 HRTIM_outr |= (pOutputCfg->FaultState << shift);
3720 /* Set the chopper mode */
3721 HRTIM_outr |= (pOutputCfg->ChopperModeEnable << shift);
3723 /* Set the burst mode entry mode */
3724 HRTIM_outr |= (pOutputCfg->BurstModeEntryDelayed << shift);
3726 /* Update HRTIMx register */
3727 HRTIMx->HRTIM_TIMERx[TimerIdx].OUTxR = HRTIM_outr;
3731 * @brief Configures an external event channel
3732 * @param HRTIMx: pointer to HRTIMx peripheral
3733 * @param Event: Event channel identifier
3734 * @param pEventCfg: pointer to the event channel configuration data structure
3737 static void HRTIM_ExternalEventConfig(HRTIM_TypeDef * HRTIMx,
3739 HRTIM_EventCfgTypeDef *pEventCfg)
3741 uint32_t hrtim_eecr1;
3742 uint32_t hrtim_eecr2;
3743 uint32_t hrtim_eecr3;
3745 /* Configure external event channel */
3746 hrtim_eecr1 = HRTIMx->HRTIM_COMMON.EECR1;
3747 hrtim_eecr2 = HRTIMx->HRTIM_COMMON.EECR2;
3748 hrtim_eecr3 = HRTIMx->HRTIM_COMMON.EECR3;
3754 hrtim_eecr1 &= ~(HRTIM_EECR1_EE1SRC | HRTIM_EECR1_EE1POL | HRTIM_EECR1_EE1SNS | HRTIM_EECR1_EE1FAST);
3755 hrtim_eecr1 |= pEventCfg->Source;
3756 hrtim_eecr1 |= pEventCfg->Polarity;
3757 hrtim_eecr1 |= pEventCfg->Sensitivity;
3758 /* Update the HRTIM registers (all bit fields but EE1FAST bit) */
3759 HRTIMx->HRTIM_COMMON.EECR1 = hrtim_eecr1;
3760 /* Update the HRTIM registers (EE1FAST bit) */
3761 hrtim_eecr1 |= pEventCfg->FastMode;
3762 HRTIMx->HRTIM_COMMON.EECR1 = hrtim_eecr1;
3767 hrtim_eecr1 &= ~(HRTIM_EECR1_EE2SRC | HRTIM_EECR1_EE2POL | HRTIM_EECR1_EE2SNS | HRTIM_EECR1_EE2FAST);
3768 hrtim_eecr1 |= (pEventCfg->Source << 6);
3769 hrtim_eecr1 |= (pEventCfg->Polarity << 6);
3770 hrtim_eecr1 |= (pEventCfg->Sensitivity << 6);
3771 /* Update the HRTIM registers (all bit fields but EE2FAST bit) */
3772 HRTIMx->HRTIM_COMMON.EECR1 = hrtim_eecr1;
3773 /* Update the HRTIM registers (EE2FAST bit) */
3774 hrtim_eecr1 |= (pEventCfg->FastMode << 6);
3775 HRTIMx->HRTIM_COMMON.EECR1 = hrtim_eecr1;
3780 hrtim_eecr1 &= ~(HRTIM_EECR1_EE3SRC | HRTIM_EECR1_EE3POL | HRTIM_EECR1_EE3SNS | HRTIM_EECR1_EE3FAST);
3781 hrtim_eecr1 |= (pEventCfg->Source << 12);
3782 hrtim_eecr1 |= (pEventCfg->Polarity << 12);
3783 hrtim_eecr1 |= (pEventCfg->Sensitivity << 12);
3784 /* Update the HRTIM registers (all bit fields but EE3FAST bit) */
3785 HRTIMx->HRTIM_COMMON.EECR1 = hrtim_eecr1;
3786 /* Update the HRTIM registers (EE3FAST bit) */
3787 hrtim_eecr1 |= (pEventCfg->FastMode << 12);
3788 HRTIMx->HRTIM_COMMON.EECR1 = hrtim_eecr1;
3793 hrtim_eecr1 &= ~(HRTIM_EECR1_EE4SRC | HRTIM_EECR1_EE4POL | HRTIM_EECR1_EE4SNS | HRTIM_EECR1_EE4FAST);
3794 hrtim_eecr1 |= (pEventCfg->Source << 18);
3795 hrtim_eecr1 |= (pEventCfg->Polarity << 18);
3796 hrtim_eecr1 |= (pEventCfg->Sensitivity << 18);
3797 /* Update the HRTIM registers (all bit fields but EE4FAST bit) */
3798 HRTIMx->HRTIM_COMMON.EECR1 = hrtim_eecr1;
3799 /* Update the HRTIM registers (EE4FAST bit) */
3800 hrtim_eecr1 |= (pEventCfg->FastMode << 18);
3801 HRTIMx->HRTIM_COMMON.EECR1 = hrtim_eecr1;
3806 hrtim_eecr1 &= ~(HRTIM_EECR1_EE5SRC | HRTIM_EECR1_EE5POL | HRTIM_EECR1_EE5SNS | HRTIM_EECR1_EE5FAST);
3807 hrtim_eecr1 |= (pEventCfg->Source << 24);
3808 hrtim_eecr1 |= (pEventCfg->Polarity << 24);
3809 hrtim_eecr1 |= (pEventCfg->Sensitivity << 24);
3810 /* Update the HRTIM registers (all bit fields but EE5FAST bit) */
3811 HRTIMx->HRTIM_COMMON.EECR1 = hrtim_eecr1;
3812 /* Update the HRTIM registers (EE5FAST bit) */
3813 hrtim_eecr1 |= (pEventCfg->FastMode << 24);
3814 HRTIMx->HRTIM_COMMON.EECR1 = hrtim_eecr1;
3819 hrtim_eecr2 &= ~(HRTIM_EECR2_EE6SRC | HRTIM_EECR2_EE6POL | HRTIM_EECR2_EE6SNS);
3820 hrtim_eecr2 |= pEventCfg->Source;
3821 hrtim_eecr2 |= pEventCfg->Polarity;
3822 hrtim_eecr2 |= pEventCfg->Sensitivity;
3823 hrtim_eecr3 &= ~(HRTIM_EECR3_EE6F);
3824 hrtim_eecr3 |= pEventCfg->Filter;
3825 /* Update the HRTIM registers */
3826 HRTIMx->HRTIM_COMMON.EECR2 = hrtim_eecr2;
3827 HRTIMx->HRTIM_COMMON.EECR3 = hrtim_eecr3;
3832 hrtim_eecr2 &= ~(HRTIM_EECR2_EE7SRC | HRTIM_EECR2_EE7POL | HRTIM_EECR2_EE7SNS);
3833 hrtim_eecr2 |= (pEventCfg->Source << 6);
3834 hrtim_eecr2 |= (pEventCfg->Polarity << 6);
3835 hrtim_eecr2 |= (pEventCfg->Sensitivity << 6);
3836 hrtim_eecr3 &= ~(HRTIM_EECR3_EE7F);
3837 hrtim_eecr3 |= (pEventCfg->Filter << 6);
3838 /* Update the HRTIM registers */
3839 HRTIMx->HRTIM_COMMON.EECR2 = hrtim_eecr2;
3840 HRTIMx->HRTIM_COMMON.EECR3 = hrtim_eecr3;
3845 hrtim_eecr2 &= ~(HRTIM_EECR2_EE8SRC | HRTIM_EECR2_EE8POL | HRTIM_EECR2_EE8SNS);
3846 hrtim_eecr2 |= (pEventCfg->Source << 12);
3847 hrtim_eecr2 |= (pEventCfg->Polarity << 12);
3848 hrtim_eecr2 |= (pEventCfg->Sensitivity << 12);
3849 hrtim_eecr3 &= ~(HRTIM_EECR3_EE8F);
3850 hrtim_eecr3 |= (pEventCfg->Filter << 12);
3851 /* Update the HRTIM registers */
3852 HRTIMx->HRTIM_COMMON.EECR2 = hrtim_eecr2;
3853 HRTIMx->HRTIM_COMMON.EECR3 = hrtim_eecr3;
3858 hrtim_eecr2 &= ~(HRTIM_EECR2_EE9SRC | HRTIM_EECR2_EE9POL | HRTIM_EECR2_EE9SNS);
3859 hrtim_eecr2 |= (pEventCfg->Source << 18);
3860 hrtim_eecr2 |= (pEventCfg->Polarity << 18);
3861 hrtim_eecr2 |= (pEventCfg->Sensitivity << 18);
3862 hrtim_eecr3 &= ~(HRTIM_EECR3_EE9F);
3863 hrtim_eecr3 |= (pEventCfg->Filter << 18);
3864 /* Update the HRTIM registers */
3865 HRTIMx->HRTIM_COMMON.EECR2 = hrtim_eecr2;
3866 HRTIMx->HRTIM_COMMON.EECR3 = hrtim_eecr3;
3869 case HRTIM_EVENT_10:
3871 hrtim_eecr2 &= ~(HRTIM_EECR2_EE10SRC | HRTIM_EECR2_EE10POL | HRTIM_EECR2_EE10SNS);
3872 hrtim_eecr2 |= (pEventCfg->Source << 24);
3873 hrtim_eecr2 |= (pEventCfg->Polarity << 24);
3874 hrtim_eecr2 |= (pEventCfg->Sensitivity << 24);
3875 hrtim_eecr3 &= ~(HRTIM_EECR3_EE10F);
3876 hrtim_eecr3 |= (pEventCfg->Filter << 24);
3877 /* Update the HRTIM registers */
3878 HRTIMx->HRTIM_COMMON.EECR2 = hrtim_eecr2;
3879 HRTIMx->HRTIM_COMMON.EECR3 = hrtim_eecr3;
3888 * @brief Configures the timer counter reset
3889 * @param HRTIMx: pointer to HRTIMx peripheral
3890 * @param TimerIdx: Timer index
3891 * @param Event: Event channel identifier
3894 void HRTIM_TIM_ResetConfig(HRTIM_TypeDef * HRTIMx,
3902 HRTIMx->HRTIM_TIMERx[TimerIdx].RSTxR = HRTIM_TIMRESETTRIGGER_EEV_1;
3907 HRTIMx->HRTIM_TIMERx[TimerIdx].RSTxR = HRTIM_TIMRESETTRIGGER_EEV_2;
3912 HRTIMx->HRTIM_TIMERx[TimerIdx].RSTxR = HRTIM_TIMRESETTRIGGER_EEV_3;
3917 HRTIMx->HRTIM_TIMERx[TimerIdx].RSTxR = HRTIM_TIMRESETTRIGGER_EEV_4;
3922 HRTIMx->HRTIM_TIMERx[TimerIdx].RSTxR = HRTIM_TIMRESETTRIGGER_EEV_5;
3927 HRTIMx->HRTIM_TIMERx[TimerIdx].RSTxR = HRTIM_TIMRESETTRIGGER_EEV_6;
3932 HRTIMx->HRTIM_TIMERx[TimerIdx].RSTxR = HRTIM_TIMRESETTRIGGER_EEV_7;
3937 HRTIMx->HRTIM_TIMERx[TimerIdx].RSTxR = HRTIM_TIMRESETTRIGGER_EEV_8;
3942 HRTIMx->HRTIM_TIMERx[TimerIdx].RSTxR = HRTIM_TIMRESETTRIGGER_EEV_9;
3945 case HRTIM_EVENT_10:
3947 HRTIMx->HRTIM_TIMERx[TimerIdx].RSTxR = HRTIM_TIMRESETTRIGGER_EEV_10;
3965 /************************ (C) COPYRIGHT STMicroelectronics *****END OF FILE****/