STM32H735xx HAL User Manual
stm32h7xx_hal_hrtim.c
Go to the documentation of this file.
00001 /**
00002   ******************************************************************************
00003   * @file    stm32h7xx_hal_hrtim.c
00004   * @author  MCD Application Team
00005   * @brief   TIM HAL module driver.
00006   *          This file provides firmware functions to manage the following
00007   *          functionalities of the High Resolution Timer (HRTIM) peripheral:
00008   *           + HRTIM Initialization
00009   *           + Timer Time Base Unit Configuration
00010   *           + Simple Time Base Start/Stop
00011   *           + Simple Time Base Start/Stop Interrupt
00012   *           + Simple Time Base Start/Stop DMA Request
00013   *           + Simple Output Compare/PWM Channel Configuration
00014   *           + Simple Output Compare/PWM Channel Start/Stop Interrupt
00015   *           + Simple Output Compare/PWM Channel Start/Stop DMA Request
00016   *           + Simple Input Capture Channel Configuration
00017   *           + Simple Input Capture Channel Start/Stop Interrupt
00018   *           + Simple Input Capture Channel Start/Stop DMA Request
00019   *           + Simple One Pulse Channel Configuration
00020   *           + Simple One Pulse Channel Start/Stop Interrupt
00021   *           + HRTIM External Synchronization Configuration
00022   *           + HRTIM Burst Mode Controller Configuration
00023   *           + HRTIM Burst Mode Controller Enabling
00024   *           + HRTIM External Events Conditioning Configuration
00025   *           + HRTIM Faults Conditioning Configuration
00026   *           + HRTIM Faults Enabling
00027   *           + HRTIM ADC trigger Configuration
00028   *           + Waveform Timer Configuration
00029   *           + Waveform Event Filtering Configuration
00030   *           + Waveform Dead Time Insertion Configuration
00031   *           + Waveform Chopper Mode Configuration
00032   *           + Waveform Compare Unit Configuration
00033   *           + Waveform Capture Unit Configuration
00034   *           + Waveform Output Configuration
00035   *           + Waveform Counter Start/Stop
00036   *           + Waveform Counter Start/Stop Interrupt
00037   *           + Waveform Counter Start/Stop DMA Request
00038   *           + Waveform Output Enabling
00039   *           + Waveform Output Level Set/Get
00040   *           + Waveform Output State Get
00041   *           + Waveform Burst DMA Operation Configuration
00042   *           + Waveform Burst DMA Operation Start
00043   *           + Waveform Timer Counter Software Reset
00044   *           + Waveform Capture Software Trigger
00045   *           + Waveform Burst Mode Controller Software Trigger
00046   *           + Waveform Timer Pre-loadable Registers Update Enabling
00047   *           + Waveform Timer Pre-loadable Registers Software Update
00048   *           + Waveform Timer Delayed Protection Status Get
00049   *           + Waveform Timer Burst Status Get
00050   *           + Waveform Timer Push-Pull Status Get
00051   *           + Peripheral State Get
00052   *
00053   ******************************************************************************
00054   * @attention
00055   *
00056   * Copyright (c) 2017 STMicroelectronics.
00057   * All rights reserved.
00058   *
00059   * This software is licensed under terms that can be found in the LICENSE file
00060   * in the root directory of this software component.
00061   * If no LICENSE file comes with this software, it is provided AS-IS.
00062   *
00063   ******************************************************************************
00064   @verbatim
00065 ==============================================================================
00066                       ##### Simple mode v.s. waveform mode #####
00067 ==============================================================================
00068   [..] The HRTIM HAL API is split into 2 categories:
00069     (#)Simple functions: these functions allow for using a HRTIM timer as a
00070        general purpose timer with high resolution capabilities.
00071        HRTIM simple modes are managed through the set of functions named
00072        HAL_HRTIM_Simple<Function>. These functions are similar in name and usage
00073        to the one defined for the TIM peripheral. When a HRTIM timer operates in
00074        simple mode, only a very limited set of HRTIM features are used.
00075        Following simple modes are proposed:
00076          (++)Output compare mode,
00077          (++)PWM output mode,
00078          (++)Input capture mode,
00079          (++)One pulse mode.
00080     (#)Waveform functions: These functions allow taking advantage of the HRTIM
00081        flexibility to produce numerous types of control signal. When a HRTIM timer
00082        operates in waveform mode, all the HRTIM features are accessible without
00083        any restriction. HRTIM waveform modes are managed through the set of
00084        functions named HAL_HRTIM_Waveform<Function>
00085 
00086 ==============================================================================
00087                       ##### How to use this driver #####
00088 ==============================================================================
00089     [..]
00090      (#)Initialize the HRTIM low level resources by implementing the
00091         HAL_HRTIM_MspInit() function:
00092         (##)Enable the HRTIM clock source using __HRTIMx_CLK_ENABLE()
00093         (##)Connect HRTIM pins to MCU I/Os
00094             (+++) Enable the clock for the HRTIM GPIOs using the following
00095                   function: __HAL_RCC_GPIOx_CLK_ENABLE()
00096             (+++) Configure these GPIO pins in Alternate Function mode using
00097                   HAL_GPIO_Init()
00098         (##)When using DMA to control data transfer (e.g HAL_HRTIM_SimpleBaseStart_DMA())
00099             (+++)Enable the DMAx interface clock using __DMAx_CLK_ENABLE()
00100             (+++)Initialize the DMA handle
00101             (+++)Associate the initialized DMA handle to the appropriate DMA
00102                  handle of the HRTIM handle using __HAL_LINKDMA()
00103             (+++)Initialize the DMA channel using HAL_DMA_Init()
00104             (+++)Configure the priority and enable the NVIC for the transfer
00105                  complete interrupt on the DMA channel using HAL_NVIC_SetPriority()
00106                  and HAL_NVIC_EnableIRQ()
00107         (##)In case of using interrupt mode (e.g HAL_HRTIM_SimpleBaseStart_IT())
00108             (+++)Configure the priority and enable the NVIC for the concerned
00109                  HRTIM interrupt using HAL_NVIC_SetPriority() and HAL_NVIC_EnableIRQ()
00110 
00111     (#)Initialize the HRTIM HAL using HAL_HRTIM_Init(). The HRTIM configuration
00112        structure (field of the HRTIM handle) specifies which global interrupt of
00113        whole HRTIM must be enabled (Burst mode period, System fault, Faults).
00114        It also contains the HRTIM external synchronization configuration. HRTIM
00115        can act as a master (generating a synchronization signal) or as a slave
00116        (waiting for a trigger to be synchronized).
00117 
00118      (#) Configure HRTIM resources shared by all HRTIM timers
00119         (##)Burst Mode Controller:
00120                 (+++)HAL_HRTIM_BurstModeConfig(): configures the HRTIM burst mode
00121                      controller: operating mode (continuous or one-shot mode), clock
00122                      (source, prescaler) , trigger(s), period, idle duration.
00123         (##)External Events Conditioning:
00124                 (+++)HAL_HRTIM_EventConfig(): configures the conditioning of an
00125                      external event channel: source, polarity, edge-sensitivity.
00126                      External event can be used as triggers (timer reset, input
00127                      capture, burst mode, ADC triggers, delayed protection)
00128                      They can also be used to set or reset timer outputs. Up to
00129                      10 event channels are available.
00130                 (+++)HAL_HRTIM_EventPrescalerConfig(): configures the external
00131                      event sampling clock (used for digital filtering).
00132         (##)Fault Conditioning:
00133                 (+++)HAL_HRTIM_FaultConfig(): configures the conditioning of a
00134                      fault channel: source, polarity, edge-sensitivity. Fault
00135                      channels are used to disable the outputs in case of an
00136                      abnormal operation. Up to 5 fault channels are available.
00137                 (+++)HAL_HRTIM_FaultPrescalerConfig(): configures the fault
00138                      sampling clock (used for digital filtering).
00139                 (+++)HAL_HRTIM_FaultModeCtl(): Enables or disables fault input(s)
00140                      circuitry. By default all fault inputs are disabled.
00141         (##)ADC trigger:
00142                 (+++)HAL_HRTIM_ADCTriggerConfig(): configures the source triggering
00143                      the update of the ADC trigger register and the ADC trigger.
00144                      4 independent triggers are available to start both the regular
00145                      and the injected sequencers of the 2 ADCs
00146 
00147      (#) Configure HRTIM timer time base using HAL_HRTIM_TimeBaseConfig(). This
00148          function must be called whatever the HRTIM timer operating mode is
00149          (simple v.s. waveform). It configures mainly:
00150         (##)The HRTIM  timer counter operating mode (continuous v.s. one shot)
00151         (##)The HRTIM  timer clock prescaler
00152         (##)The HRTIM  timer period
00153         (##)The HRTIM  timer repetition counter
00154 
00155      *** If the HRTIM timer operates in simple mode ***
00156      ===================================================
00157      [..]
00158      (#) Start or Stop simple timers
00159               (++)Simple time base: HAL_HRTIM_SimpleBaseStart(),HAL_HRTIM_SimpleBaseStop(),
00160                   HAL_HRTIM_SimpleBaseStart_IT(),HAL_HRTIM_SimpleBaseStop_IT(),
00161                   HAL_HRTIM_SimpleBaseStart_DMA(),HAL_HRTIM_SimpleBaseStop_DMA().
00162               (++)Simple output compare: HAL_HRTIM_SimpleOCChannelConfig(),
00163                   HAL_HRTIM_SimpleOCStart(),HAL_HRTIM_SimpleOCStop(),
00164                   HAL_HRTIM_SimpleOCStart_IT(),HAL_HRTIM_SimpleOCStop_IT(),
00165                   HAL_HRTIM_SimpleOCStart_DMA(),HAL_HRTIM_SimpleOCStop_DMA(),
00166               (++)Simple PWM output: HAL_HRTIM_SimplePWMChannelConfig(),
00167                   HAL_HRTIM_SimplePWMStart(),HAL_HRTIM_SimplePWMStop(),
00168                   HAL_HRTIM_SimplePWMStart_IT(),HAL_HRTIM_SimplePWMStop_IT(),
00169                   HAL_HRTIM_SimplePWMStart_DMA(),HAL_HRTIM_SimplePWMStop_DMA(),
00170               (++)Simple input capture: HAL_HRTIM_SimpleCaptureChannelConfig(),
00171                   HAL_HRTIM_SimpleCaptureStart(),HAL_HRTIM_SimpleCaptureStop(),
00172                   HAL_HRTIM_SimpleCaptureStart_IT(),HAL_HRTIM_SimpleCaptureStop_IT(),
00173                   HAL_HRTIM_SimpleCaptureStart_DMA(),HAL_HRTIM_SimpleCaptureStop_DMA().
00174               (++)Simple one pulse: HAL_HRTIM_SimpleOnePulseChannelConfig(),
00175                   HAL_HRTIM_SimpleOnePulseStart(),HAL_HRTIM_SimpleOnePulseStop(),
00176                   HAL_HRTIM_SimpleOnePulseStart_IT(),HAL_HRTIM_SimpleOnePulseStop_It().
00177 
00178      *** If the HRTIM timer operates in waveform mode ***
00179      ====================================================
00180      [..]
00181      (#) Completes waveform timer configuration
00182               (++)HAL_HRTIM_WaveformTimerConfig(): configuration of a HRTIM timer
00183                   operating in wave form mode mainly consists in:
00184                 (+++)Enabling the HRTIM timer interrupts and DMA requests.
00185                 (+++)Enabling the half mode for the HRTIM timer.
00186                 (+++)Defining how the HRTIM timer reacts to external synchronization input.
00187                 (+++)Enabling the push-pull mode for the HRTIM timer.
00188                 (+++)Enabling the fault channels for the HRTIM timer.
00189                 (+++)Enabling the dead-time insertion for the HRTIM timer.
00190                 (+++)Setting the delayed protection mode for the HRTIM timer (source and outputs
00191                      on which the delayed protection are applied).
00192                 (+++)Specifying the HRTIM timer update and reset triggers.
00193                 (+++)Specifying the HRTIM timer registers update policy (e.g. pre-load enabling).
00194               (++)HAL_HRTIM_TimerEventFilteringConfig(): configures external
00195                   event blanking and windowing circuitry of a HRTIM timer:
00196                 (+++)Blanking:  to mask external events during a defined  time period a defined time period
00197                 (+++)Windowing, to enable external events only during a defined time period
00198               (++)HAL_HRTIM_DeadTimeConfig(): configures the dead-time insertion
00199                   unit for a HRTIM timer. Allows to generate a couple of
00200                   complementary signals from a single reference waveform,
00201                   with programmable delays between active state.
00202               (++)HAL_HRTIM_ChopperModeConfig(): configures the parameters of
00203                   the high-frequency carrier signal added on top of the timing
00204                   unit output. Chopper mode can be enabled or disabled for each
00205                    timer output separately (see  HAL_HRTIM_WaveformOutputConfig()).
00206               (++)HAL_HRTIM_BurstDMAConfig(): configures the burst DMA burst
00207                   controller. Allows having multiple HRTIM registers updated
00208                   with a single DMA request. The burst DMA operation is started
00209                   by calling HAL_HRTIM_BurstDMATransfer().
00210               (++)HAL_HRTIM_WaveformCompareConfig():configures the compare unit
00211                   of a HRTIM timer. This operation consists in setting the
00212                   compare value and possibly specifying the auto delayed mode
00213                   for compare units 2 and 4 (allows to have compare events
00214                   generated relatively to capture events). Note that when auto
00215                   delayed mode is needed, the capture unit associated to the
00216                   compare unit must be configured separately.
00217               (++)HAL_HRTIM_WaveformCaptureConfig(): configures the capture unit
00218                   of a HRTIM timer. This operation consists in specifying the
00219                   source(s)  triggering the capture (timer register update event,
00220                   external event, timer output set/reset event, other HRTIM
00221                   timer related events).
00222               (++)HAL_HRTIM_WaveformOutputConfig(): configuration of a HRTIM timer
00223                   output mainly consists in:
00224                 (+++)Setting the output polarity (active high or active low),
00225                 (+++)Defining the set/reset crossbar for the output,
00226                 (+++)Specifying the fault level (active or inactive) in IDLE and FAULT states.,
00227 
00228      (#) Set waveform timer output(s) level
00229               (++)HAL_HRTIM_WaveformSetOutputLevel(): forces the output to its
00230                   active or inactive level. For example, when deadtime insertion
00231                   is enabled it is necessary to force the output level by software
00232                   to have the outputs in a complementary state as soon as the RUN mode is entered.
00233 
00234      (#) Enable or Disable waveform timer output(s)
00235               (++)HAL_HRTIM_WaveformOutputStart(),HAL_HRTIM_WaveformOutputStop().
00236 
00237      (#) Start or Stop waveform HRTIM timer(s).
00238               (++)HAL_HRTIM_WaveformCountStart(),HAL_HRTIM_WaveformCountStop(),
00239               (++)HAL_HRTIM_WaveformCountStart_IT(),HAL_HRTIM_WaveformCountStop_IT(),
00240               (++)HAL_HRTIM_WaveformCountStart_DMA(),HAL_HRTIM_WaveformCountStop_DMA(),
00241      (#) Burst mode controller enabling:
00242               (++)HAL_HRTIM_BurstModeCtl(): activates or de-activates the
00243                   burst mode controller.
00244 
00245      (#) Some HRTIM operations can be triggered by software:
00246               (++)HAL_HRTIM_BurstModeSoftwareTrigger(): calling this function
00247                   trigs the burst operation.
00248               (++)HAL_HRTIM_SoftwareCapture(): calling this function trigs the
00249                   capture of the HRTIM timer counter.
00250               (++)HAL_HRTIM_SoftwareUpdate(): calling this function trigs the
00251                   update of the pre-loadable registers of the HRTIM timer
00252               (++)HAL_HRTIM_SoftwareReset():calling this function resets the
00253                   HRTIM timer counter.
00254 
00255      (#) Some functions can be used any time to retrieve HRTIM timer related
00256             information
00257               (++)HAL_HRTIM_GetCapturedValue(): returns actual value of the
00258                   capture register of the designated capture unit.
00259               (++)HAL_HRTIM_WaveformGetOutputLevel(): returns actual level
00260                  (ACTIVE/INACTIVE) of the designated timer output.
00261               (++)HAL_HRTIM_WaveformGetOutputState():returns actual state
00262                  (IDLE/RUN/FAULT) of the designated timer output.
00263               (++)HAL_HRTIM_GetDelayedProtectionStatus():returns actual level
00264                  (ACTIVE/INACTIVE) of the designated output when the delayed
00265                   protection was triggered.
00266               (++)HAL_HRTIM_GetBurstStatus(): returns the actual status
00267                  (ACTIVE/INACTIVE) of the burst mode controller.
00268               (++)HAL_HRTIM_GetCurrentPushPullStatus(): when the push-pull mode
00269                  is enabled for the HRTIM timer (see HAL_HRTIM_WaveformTimerConfig()),
00270                  the push-pull status indicates on which output the signal is currently
00271                  active (e.g signal applied on output 1 and output 2 forced
00272                  inactive or vice versa).
00273              (++)HAL_HRTIM_GetIdlePushPullStatus(): when the push-pull mode
00274                  is enabled for the HRTIM timer (see HAL_HRTIM_WaveformTimerConfig()),
00275                  the idle push-pull status indicates during which period the
00276                  delayed protection request occurred (e.g. protection occurred
00277                  when the output 1 was active and output 2 forced inactive or
00278                  vice versa).
00279 
00280      (#) Some functions can be used any time to retrieve actual HRTIM status
00281              (++)HAL_HRTIM_GetState(): returns actual HRTIM instance HAL state.
00282 
00283      *** Callback registration ***
00284      =============================
00285      [..]
00286      The compilation flag USE_HAL_HRTIM_REGISTER_CALLBACKS when set to 1
00287      allows the user to configure dynamically the driver callbacks.
00288      Use Functions HAL_HRTIM_RegisterCallback() or HAL_HRTIM_TIMxRegisterCallback()
00289      to register an interrupt callback.
00290 
00291      [..]
00292      Function HAL_HRTIM_RegisterCallback() allows to register following callbacks:
00293        (+) Fault1Callback               : Fault 1 interrupt callback function
00294        (+) Fault2Callback               : Fault 2 interrupt callback function
00295        (+) Fault3Callback               : Fault 3 interrupt callback function
00296        (+) Fault4Callback               : Fault 4 interrupt callback function
00297        (+) Fault5Callback               : Fault 5 interrupt callback function
00298        (+) SystemFaultCallback          : System fault interrupt callback function
00299        (+) BurstModePeriodCallback      : Burst mode period interrupt callback function
00300        (+) SynchronizationEventCallback : Sync Input interrupt callback function
00301        (+) ErrorCallback                : DMA error callback function
00302        (+) MspInitCallback              : HRTIM MspInit callback function
00303        (+) MspDeInitCallback            : HRTIM MspInit callback function
00304 
00305      [..]
00306      Function HAL_HRTIM_TIMxRegisterCallback() allows to register following callbacks:
00307        (+) RegistersUpdateCallback   : Timer x Update interrupt callback function
00308        (+) RepetitionEventCallback   : Timer x Repetition interrupt callback function
00309        (+) Compare1EventCallback     : Timer x Compare 1 match interrupt callback function
00310        (+) Compare2EventCallback     : Timer x Compare 2 match interrupt callback function
00311        (+) Compare3EventCallback     : Timer x Compare 3 match interrupt callback function
00312        (+) Compare4EventCallback     : Timer x Compare 4 match interrupt callback function
00313        (+) Capture1EventCallback     : Timer x Capture 1 interrupts callback function
00314        (+) Capture2EventCallback     : Timer x Capture 2 interrupts callback function
00315        (+) DelayedProtectionCallback : Timer x Delayed protection interrupt callback function
00316        (+) CounterResetCallback      : Timer x counter reset/roll-over interrupt callback function
00317        (+) Output1SetCallback        : Timer x output 1 set interrupt callback function
00318        (+) Output1ResetCallback      : Timer x output 1 reset interrupt callback function
00319        (+) Output2SetCallback        : Timer x output 2 set interrupt callback function
00320        (+) Output2ResetCallback      : Timer x output 2 reset interrupt callback function
00321        (+) BurstDMATransferCallback  : Timer x Burst DMA completed interrupt callback function
00322 
00323      [..]
00324      Both functions take as parameters the HAL peripheral handle, the Callback ID
00325      and a pointer to the user callback function.
00326 
00327      [..]
00328      Use function HAL_HRTIM_UnRegisterCallback or HAL_HRTIM_TIMxUnRegisterCallback
00329      to reset a callback to the default weak function. Both functions take  as parameters
00330      the HAL peripheral handle and the Callback ID.
00331 
00332      [..]
00333      By default, after the HAL_HRTIM_Init() and when the state is HAL_HRTIM_STATE_RESET
00334      all callbacks are set to the corresponding weak functions (e.g HAL_HRTIM_Fault1Callback)
00335      Exception done for MspInit and MspDeInit functions that are reset to the legacy
00336      weak functions in the HAL_HRTIM_Init()/ HAL_HRTIM_DeInit() only when these
00337      callbacks are null (not registered beforehand). If MspInit or MspDeInit are
00338      not null, the HAL_HRTIM_Init()/ HAL_HRTIM_DeInit() keep and use the user
00339      MspInit/MspDeInit callbacks (registered beforehand) whatever the state.
00340 
00341      [..]
00342      Callbacks can be registered/unregistered in HAL_HRTIM_STATE_READY state only.
00343      Exception done MspInit/MspDeInit functions that can be registered/unregistered
00344      in HAL_HRTIM_STATE_READY or HAL_HRTIM_STATE_RESET states, thus registered
00345      (user) MspInit/DeInit callbacks can be used during the Init/DeInit.
00346      Then, the user first registers the MspInit/MspDeInit user callbacks
00347      using HAL_HRTIM_RegisterCallback() before calling HAL_HRTIM_DeInit()
00348      or HAL_HRTIM_Init() function.
00349 
00350      [..]
00351      When the compilation flag USE_HAL_HRTIM_REGISTER_CALLBACKS is set to 0 or
00352      not defined, the callback registration feature is not available and all
00353      callbacks are set to the corresponding weak functions.
00354 
00355   @endverbatim
00356   ******************************************************************************
00357   */
00358 
00359 /* Includes ------------------------------------------------------------------*/
00360 #include "stm32h7xx_hal.h"
00361 
00362 /** @addtogroup STM32H7xx_HAL_Driver
00363   * @{
00364   */
00365 
00366 #ifdef HAL_HRTIM_MODULE_ENABLED
00367 
00368 #if defined(HRTIM1)
00369 
00370 /** @defgroup HRTIM HRTIM
00371   * @brief HRTIM HAL module driver
00372   * @{
00373   */
00374 
00375 /* Private typedef -----------------------------------------------------------*/
00376 /* Private define ------------------------------------------------------------*/
00377 /** @defgroup HRTIM_Private_Defines HRTIM Private Define
00378   * @{
00379   */
00380 #define HRTIM_FLTR_FLTxEN (HRTIM_FLTR_FLT1EN |\
00381                            HRTIM_FLTR_FLT2EN |\
00382                            HRTIM_FLTR_FLT3EN |\
00383                            HRTIM_FLTR_FLT4EN | \
00384                            HRTIM_FLTR_FLT5EN)
00385 
00386 #define HRTIM_TIMCR_TIMUPDATETRIGGER (HRTIM_TIMUPDATETRIGGER_MASTER  |\
00387                                       HRTIM_TIMUPDATETRIGGER_TIMER_A |\
00388                                       HRTIM_TIMUPDATETRIGGER_TIMER_B |\
00389                                       HRTIM_TIMUPDATETRIGGER_TIMER_C |\
00390                                       HRTIM_TIMUPDATETRIGGER_TIMER_D |\
00391                                       HRTIM_TIMUPDATETRIGGER_TIMER_E)
00392 
00393 #define HRTIM_FLTINR1_FLTxLCK ((HRTIM_FAULTLOCK_READONLY)        | \
00394                                (HRTIM_FAULTLOCK_READONLY << 8U)  | \
00395                                (HRTIM_FAULTLOCK_READONLY << 16U) | \
00396                                (HRTIM_FAULTLOCK_READONLY << 24U))
00397 
00398 #define HRTIM_FLTINR2_FLTxLCK ((HRTIM_FAULTLOCK_READONLY)        | \
00399                                (HRTIM_FAULTLOCK_READONLY << 8U))
00400 /**
00401   * @}
00402   */
00403 
00404 /* Private macro -------------------------------------------------------------*/
00405 /* Private variables ---------------------------------------------------------*/
00406 /** @defgroup HRTIM_Private_Variables HRTIM Private Variables
00407   * @{
00408   */
00409 static uint32_t TimerIdxToTimerId[] =
00410 {
00411   HRTIM_TIMERID_TIMER_A,
00412   HRTIM_TIMERID_TIMER_B,
00413   HRTIM_TIMERID_TIMER_C,
00414   HRTIM_TIMERID_TIMER_D,
00415   HRTIM_TIMERID_TIMER_E,
00416   HRTIM_TIMERID_MASTER,
00417 };
00418 /**
00419   * @}
00420   */
00421 
00422 /* Private function prototypes -----------------------------------------------*/
00423 /** @defgroup HRTIM_Private_Functions HRTIM Private Functions
00424   * @{
00425   */
00426 static void HRTIM_MasterBase_Config(HRTIM_HandleTypeDef * hhrtim,
00427                                     HRTIM_TimeBaseCfgTypeDef * pTimeBaseCfg);
00428 
00429 static void HRTIM_TimingUnitBase_Config(HRTIM_HandleTypeDef * hhrtim,
00430                                         uint32_t TimerIdx,
00431                                         HRTIM_TimeBaseCfgTypeDef * pTimeBaseCfg);
00432 
00433 static void HRTIM_MasterWaveform_Config(HRTIM_HandleTypeDef * hhrtim,
00434                                         HRTIM_TimerCfgTypeDef * pTimerCfg);
00435 
00436 static void HRTIM_TimingUnitWaveform_Config(HRTIM_HandleTypeDef * hhrtim,
00437                                             uint32_t TimerIdx,
00438                                             HRTIM_TimerCfgTypeDef * pTimerCfg);
00439 
00440 
00441 static void HRTIM_CaptureUnitConfig(HRTIM_HandleTypeDef * hhrtim,
00442                                     uint32_t TimerIdx,
00443                                     uint32_t CaptureUnit,
00444                                     uint32_t Event);
00445 
00446 static void HRTIM_OutputConfig(HRTIM_HandleTypeDef * hhrtim,
00447                                 uint32_t TimerIdx,
00448                                 uint32_t Output,
00449                                 HRTIM_OutputCfgTypeDef * pOutputCfg);
00450 
00451 static void HRTIM_EventConfig(HRTIM_HandleTypeDef * hhrtim,
00452                               uint32_t Event,
00453                               HRTIM_EventCfgTypeDef * pEventCfg);
00454 
00455 static void HRTIM_TIM_ResetConfig(HRTIM_HandleTypeDef * hhrtim,
00456                                   uint32_t TimerIdx,
00457                                   uint32_t Event);
00458 
00459 static uint32_t HRTIM_GetITFromOCMode(HRTIM_HandleTypeDef * hhrtim,
00460                                       uint32_t TimerIdx,
00461                                       uint32_t OCChannel);
00462 
00463 static uint32_t HRTIM_GetDMAFromOCMode(HRTIM_HandleTypeDef * hhrtim,
00464                                        uint32_t TimerIdx,
00465                                        uint32_t OCChannel);
00466 
00467 static DMA_HandleTypeDef * HRTIM_GetDMAHandleFromTimerIdx(HRTIM_HandleTypeDef * hhrtim,
00468                                                           uint32_t TimerIdx);
00469 
00470 static uint32_t GetTimerIdxFromDMAHandle(HRTIM_HandleTypeDef * hhrtim,
00471                                          DMA_HandleTypeDef * hdma);
00472 
00473 static void HRTIM_ForceRegistersUpdate(HRTIM_HandleTypeDef * hhrtim,
00474                                       uint32_t TimerIdx);
00475 
00476 static void HRTIM_HRTIM_ISR(HRTIM_HandleTypeDef * hhrtim);
00477 
00478 static void HRTIM_Master_ISR(HRTIM_HandleTypeDef * hhrtim);
00479 
00480 static void HRTIM_Timer_ISR(HRTIM_HandleTypeDef * hhrtim,
00481                                        uint32_t TimerIdx);
00482 
00483 static void HRTIM_DMAMasterCplt(DMA_HandleTypeDef *hdma);
00484 
00485 static void HRTIM_DMATimerxCplt(DMA_HandleTypeDef *hdma);
00486 
00487 static void HRTIM_DMAError(DMA_HandleTypeDef *hdma);
00488 
00489 static void HRTIM_BurstDMACplt(DMA_HandleTypeDef *hdma);
00490 /**
00491   * @}
00492   */
00493 
00494 /* Exported functions ---------------------------------------------------------*/
00495 /** @defgroup HRTIM_Exported_Functions HRTIM Exported Functions
00496   * @{
00497   */
00498 
00499 /** @defgroup HRTIM_Exported_Functions_Group1 Initialization and de-initialization functions
00500  *  @brief    Initialization and Configuration functions
00501 @verbatim
00502  ===============================================================================
00503               ##### Initialization and Time Base Configuration functions #####
00504  ===============================================================================
00505     [..]  This section provides functions allowing to:
00506       (+) Initialize a HRTIM instance
00507       (+) De-initialize a HRTIM instance
00508       (+) Initialize the HRTIM MSP
00509       (+) De-initialize the HRTIM MSP
00510       (+) Configure the time base unit of a HRTIM timer
00511 
00512 @endverbatim
00513   * @{
00514   */
00515 
00516 /**
00517   * @brief  Initialize a HRTIM instance
00518   * @param  hhrtim pointer to HAL HRTIM handle
00519   * @retval HAL status
00520   */
00521 HAL_StatusTypeDef HAL_HRTIM_Init(HRTIM_HandleTypeDef * hhrtim)
00522 {
00523   uint8_t timer_idx;
00524   uint32_t hrtim_mcr;
00525 
00526   /* Check the HRTIM handle allocation */
00527   if(hhrtim == NULL)
00528   {
00529     return HAL_ERROR;
00530   }
00531 
00532   /* Check the parameters */
00533   assert_param(IS_HRTIM_ALL_INSTANCE(hhrtim->Instance));
00534   assert_param(IS_HRTIM_IT(hhrtim->Init.HRTIMInterruptResquests));
00535 
00536 #if (USE_HAL_HRTIM_REGISTER_CALLBACKS == 1)
00537   if (hhrtim->State == HAL_HRTIM_STATE_RESET)
00538   {
00539     /* Initialize callback function pointers to their default values */
00540     hhrtim->Fault1Callback               = HAL_HRTIM_Fault1Callback;
00541     hhrtim->Fault2Callback               = HAL_HRTIM_Fault2Callback;
00542     hhrtim->Fault3Callback               = HAL_HRTIM_Fault3Callback;
00543     hhrtim->Fault4Callback               = HAL_HRTIM_Fault4Callback;
00544     hhrtim->Fault5Callback               = HAL_HRTIM_Fault5Callback;
00545     hhrtim->SystemFaultCallback          = HAL_HRTIM_SystemFaultCallback;
00546     hhrtim->BurstModePeriodCallback      = HAL_HRTIM_BurstModePeriodCallback;
00547     hhrtim->SynchronizationEventCallback = HAL_HRTIM_SynchronizationEventCallback;
00548     hhrtim->ErrorCallback                = HAL_HRTIM_ErrorCallback;
00549     hhrtim->RegistersUpdateCallback      = HAL_HRTIM_RegistersUpdateCallback;
00550     hhrtim->RepetitionEventCallback      = HAL_HRTIM_RepetitionEventCallback;
00551     hhrtim->Compare1EventCallback        = HAL_HRTIM_Compare1EventCallback;
00552     hhrtim->Compare2EventCallback        = HAL_HRTIM_Compare2EventCallback;
00553     hhrtim->Compare3EventCallback        = HAL_HRTIM_Compare3EventCallback;
00554     hhrtim->Compare4EventCallback        = HAL_HRTIM_Compare4EventCallback;
00555     hhrtim->Capture1EventCallback        = HAL_HRTIM_Capture1EventCallback;
00556     hhrtim->Capture2EventCallback        = HAL_HRTIM_Capture2EventCallback;
00557     hhrtim->DelayedProtectionCallback    = HAL_HRTIM_DelayedProtectionCallback;
00558     hhrtim->CounterResetCallback         = HAL_HRTIM_CounterResetCallback;
00559     hhrtim->Output1SetCallback           = HAL_HRTIM_Output1SetCallback;
00560     hhrtim->Output1ResetCallback         = HAL_HRTIM_Output1ResetCallback;
00561     hhrtim->Output2SetCallback           = HAL_HRTIM_Output2SetCallback;
00562     hhrtim->Output2ResetCallback         = HAL_HRTIM_Output2ResetCallback;
00563     hhrtim->BurstDMATransferCallback     = HAL_HRTIM_BurstDMATransferCallback;
00564 
00565     if (hhrtim->MspInitCallback == NULL)
00566     {
00567       hhrtim->MspInitCallback = HAL_HRTIM_MspInit;
00568     }
00569   }
00570 #endif /* USE_HAL_HRTIM_REGISTER_CALLBACKS */
00571 
00572   /* Set the HRTIM state */
00573   hhrtim->State = HAL_HRTIM_STATE_BUSY;
00574 
00575   /* Initialize the DMA handles */
00576   hhrtim->hdmaMaster = (DMA_HandleTypeDef *)NULL;
00577   hhrtim->hdmaTimerA = (DMA_HandleTypeDef *)NULL;
00578   hhrtim->hdmaTimerB = (DMA_HandleTypeDef *)NULL;
00579   hhrtim->hdmaTimerC = (DMA_HandleTypeDef *)NULL;
00580   hhrtim->hdmaTimerD = (DMA_HandleTypeDef *)NULL;
00581   hhrtim->hdmaTimerE = (DMA_HandleTypeDef *)NULL;
00582 
00583   /* HRTIM output synchronization configuration (if required) */
00584   if ((hhrtim->Init.SyncOptions & HRTIM_SYNCOPTION_MASTER) != (uint32_t)RESET)
00585   {
00586     /* Check parameters */
00587     assert_param(IS_HRTIM_SYNCOUTPUTSOURCE(hhrtim->Init.SyncOutputSource));
00588     assert_param(IS_HRTIM_SYNCOUTPUTPOLARITY(hhrtim->Init.SyncOutputPolarity));
00589 
00590     /* The synchronization output initialization procedure must be done prior
00591        to the configuration of the MCU outputs (done within HAL_HRTIM_MspInit)
00592     */
00593     if (hhrtim->Instance == HRTIM1)
00594     {
00595       /* Enable the HRTIM peripheral clock */
00596       __HAL_RCC_HRTIM1_CLK_ENABLE();
00597     }
00598 
00599     hrtim_mcr = hhrtim->Instance->sMasterRegs.MCR;
00600 
00601     /* Set the event to be sent on the synchronization output */
00602     hrtim_mcr &= ~(HRTIM_MCR_SYNC_SRC);
00603     hrtim_mcr |= (hhrtim->Init.SyncOutputSource & HRTIM_MCR_SYNC_SRC);
00604 
00605     /* Set the polarity of the synchronization output */
00606     hrtim_mcr &= ~(HRTIM_MCR_SYNC_OUT);
00607     hrtim_mcr |= (hhrtim->Init.SyncOutputPolarity & HRTIM_MCR_SYNC_OUT);
00608 
00609     /* Update the HRTIM registers */
00610     hhrtim->Instance->sMasterRegs.MCR = hrtim_mcr;
00611   }
00612 
00613   /* Init the low level hardware : GPIO, CLOCK, NVIC and DMA */
00614 #if (USE_HAL_HRTIM_REGISTER_CALLBACKS == 1)
00615   hhrtim->MspInitCallback(hhrtim);
00616 #else
00617   HAL_HRTIM_MspInit(hhrtim);
00618 #endif /* USE_HAL_HRTIM_REGISTER_CALLBACKS */
00619 
00620   /* HRTIM input synchronization configuration (if required) */
00621   if ((hhrtim->Init.SyncOptions & HRTIM_SYNCOPTION_SLAVE) != (uint32_t)RESET)
00622   {
00623     /* Check parameters */
00624     assert_param(IS_HRTIM_SYNCINPUTSOURCE(hhrtim->Init.SyncInputSource));
00625 
00626     hrtim_mcr = hhrtim->Instance->sMasterRegs.MCR;
00627 
00628     /* Set the synchronization input source */
00629     hrtim_mcr &= ~(HRTIM_MCR_SYNC_IN);
00630     hrtim_mcr |= (hhrtim->Init.SyncInputSource & HRTIM_MCR_SYNC_IN);
00631 
00632     /* Update the HRTIM registers */
00633     hhrtim->Instance->sMasterRegs.MCR = hrtim_mcr;
00634   }
00635 
00636   /* Initialize the HRTIM state*/
00637   hhrtim->State = HAL_HRTIM_STATE_READY;
00638 
00639   /* Initialize the lock status of the HRTIM HAL API */
00640   __HAL_UNLOCK(hhrtim);
00641 
00642   /* Initialize timer related parameters */
00643   for (timer_idx = HRTIM_TIMERINDEX_TIMER_A ;
00644        timer_idx <= HRTIM_TIMERINDEX_MASTER ;
00645        timer_idx++)
00646   {
00647     hhrtim->TimerParam[timer_idx].CaptureTrigger1 = HRTIM_CAPTURETRIGGER_NONE;
00648     hhrtim->TimerParam[timer_idx].CaptureTrigger2 = HRTIM_CAPTURETRIGGER_NONE;
00649     hhrtim->TimerParam[timer_idx].InterruptRequests = HRTIM_IT_NONE;
00650     hhrtim->TimerParam[timer_idx].DMARequests = HRTIM_IT_NONE;
00651     hhrtim->TimerParam[timer_idx].DMASrcAddress = 0U;
00652     hhrtim->TimerParam[timer_idx].DMASize = 0U;
00653   }
00654 
00655   return HAL_OK;
00656 }
00657 
00658 /**
00659   * @brief  De-initialize a HRTIM instance
00660   * @param  hhrtim pointer to HAL HRTIM handle
00661   * @retval HAL status
00662   */
00663 HAL_StatusTypeDef HAL_HRTIM_DeInit (HRTIM_HandleTypeDef * hhrtim)
00664 {
00665   /* Check the HRTIM handle allocation */
00666   if(hhrtim == NULL)
00667   {
00668     return HAL_ERROR;
00669   }
00670 
00671   /* Check the parameters */
00672   assert_param(IS_HRTIM_ALL_INSTANCE(hhrtim->Instance));
00673 
00674   /* Set the HRTIM state */
00675   hhrtim->State = HAL_HRTIM_STATE_BUSY;
00676 
00677   /* DeInit the low level hardware */
00678 #if (USE_HAL_HRTIM_REGISTER_CALLBACKS == 1)
00679   if (hhrtim->MspDeInitCallback == NULL)
00680   {
00681     hhrtim->MspDeInitCallback = HAL_HRTIM_MspDeInit;
00682   }
00683 
00684   hhrtim->MspDeInitCallback(hhrtim);
00685 #else
00686   HAL_HRTIM_MspDeInit(hhrtim);
00687 #endif /* USE_HAL_HRTIM_REGISTER_CALLBACKS */
00688 
00689   hhrtim->State = HAL_HRTIM_STATE_READY;
00690 
00691   return HAL_OK;
00692 }
00693 
00694 /**
00695   * @brief  MSP initialization for a HRTIM instance
00696   * @param  hhrtim pointer to HAL HRTIM handle
00697   * @retval None
00698   */
00699 __weak void HAL_HRTIM_MspInit(HRTIM_HandleTypeDef * hhrtim)
00700 {
00701   /* Prevent unused argument(s) compilation warning */
00702   UNUSED(hhrtim);
00703 
00704   /* NOTE: This function should not be modified, when the callback is needed,
00705            the HAL_HRTIM_MspInit could be implemented in the user file
00706    */
00707 }
00708 
00709 /**
00710   * @brief  MSP de-initialization of a HRTIM instance
00711   * @param  hhrtim pointer to HAL HRTIM handle
00712   * @retval None
00713   */
00714 __weak void HAL_HRTIM_MspDeInit(HRTIM_HandleTypeDef * hhrtim)
00715 {
00716   /* Prevent unused argument(s) compilation warning */
00717   UNUSED(hhrtim);
00718 
00719   /* NOTE: This function should not be modified, when the callback is needed,
00720            the HAL_HRTIM_MspDeInit could be implemented in the user file
00721    */
00722 }
00723 
00724 /**
00725   * @brief  Configure the time base unit of a timer
00726   * @param  hhrtim pointer to HAL HRTIM handle
00727   * @param  TimerIdx Timer index
00728   *                   This parameter can be one of the following values:
00729   *                   @arg HRTIM_TIMERINDEX_MASTER for master timer
00730   *                   @arg HRTIM_TIMERINDEX_TIMER_A for timer A
00731   *                   @arg HRTIM_TIMERINDEX_TIMER_B for timer B
00732   *                   @arg HRTIM_TIMERINDEX_TIMER_C for timer C
00733   *                   @arg HRTIM_TIMERINDEX_TIMER_D for timer D
00734   *                   @arg HRTIM_TIMERINDEX_TIMER_E for timer E
00735   * @param  pTimeBaseCfg pointer to the time base configuration structure
00736   * @note This function must be called prior starting the timer
00737   * @note   The time-base unit initialization parameters specify:
00738   *           The timer counter operating mode (continuous, one shot),
00739   *           The timer clock prescaler,
00740   *           The timer period,
00741   *           The timer repetition counter.
00742   * @retval HAL status
00743   */
00744 HAL_StatusTypeDef HAL_HRTIM_TimeBaseConfig(HRTIM_HandleTypeDef *hhrtim,
00745                                            uint32_t TimerIdx,
00746                                            HRTIM_TimeBaseCfgTypeDef * pTimeBaseCfg)
00747 {
00748   /* Check the parameters */
00749   assert_param(IS_HRTIM_TIMERINDEX(TimerIdx));
00750   assert_param(IS_HRTIM_PRESCALERRATIO(pTimeBaseCfg->PrescalerRatio));
00751   assert_param(IS_HRTIM_MODE(pTimeBaseCfg->Mode));
00752 
00753   if(hhrtim->State == HAL_HRTIM_STATE_BUSY)
00754   {
00755      return HAL_BUSY;
00756   }
00757 
00758   /* Set the HRTIM state */
00759   hhrtim->State = HAL_HRTIM_STATE_BUSY;
00760 
00761   if (TimerIdx == HRTIM_TIMERINDEX_MASTER)
00762   {
00763     /* Configure master timer time base unit */
00764     HRTIM_MasterBase_Config(hhrtim, pTimeBaseCfg);
00765   }
00766   else
00767   {
00768     /* Configure timing unit time base unit */
00769     HRTIM_TimingUnitBase_Config(hhrtim, TimerIdx, pTimeBaseCfg);
00770   }
00771 
00772   /* Set HRTIM state */
00773   hhrtim->State = HAL_HRTIM_STATE_READY;
00774 
00775   return HAL_OK;
00776 }
00777 
00778 /**
00779   * @}
00780   */
00781 
00782 /** @defgroup HRTIM_Exported_Functions_Group2 Simple time base mode functions
00783  *  @brief    Simple time base mode functions.
00784 @verbatim
00785  ===============================================================================
00786               ##### Simple time base mode functions #####
00787  ===============================================================================
00788     [..]  This section provides functions allowing to:
00789       (+) Start simple time base
00790       (+) Stop simple time base
00791       (+) Start simple time base and enable interrupt
00792       (+) Stop simple time base and disable interrupt
00793       (+) Start simple time base and enable DMA transfer
00794       (+) Stop simple time base and disable DMA transfer
00795       -@-  When a HRTIM timer operates in simple time base mode, the timer
00796            counter counts from 0 to the period value.
00797 
00798 @endverbatim
00799   * @{
00800   */
00801 
00802 /**
00803   * @brief  Start the counter of a timer operating in simple time base mode.
00804   * @param  hhrtim pointer to HAL HRTIM handle
00805   * @param  TimerIdx Timer index.
00806   *                   This parameter can be one of the following values:
00807   *                   @arg HRTIM_TIMERINDEX_MASTER  for master timer
00808   *                   @arg HRTIM_TIMERINDEX_TIMER_A for timer A
00809   *                   @arg HRTIM_TIMERINDEX_TIMER_B for timer B
00810   *                   @arg HRTIM_TIMERINDEX_TIMER_C for timer C
00811   *                   @arg HRTIM_TIMERINDEX_TIMER_D for timer D
00812   *                   @arg HRTIM_TIMERINDEX_TIMER_E for timer E
00813   * @retval HAL status
00814   */
00815 HAL_StatusTypeDef HAL_HRTIM_SimpleBaseStart(HRTIM_HandleTypeDef * hhrtim,
00816                                            uint32_t TimerIdx)
00817 {
00818    /* Check the parameters */
00819   assert_param(IS_HRTIM_TIMERINDEX(TimerIdx));
00820 
00821   /* Process Locked */
00822   __HAL_LOCK(hhrtim);
00823 
00824   hhrtim->State = HAL_HRTIM_STATE_BUSY;
00825 
00826   /* Enable the timer counter */
00827   __HAL_HRTIM_ENABLE(hhrtim, TimerIdxToTimerId[TimerIdx]);
00828 
00829   hhrtim->State = HAL_HRTIM_STATE_READY;
00830 
00831   /* Process Unlocked */
00832   __HAL_UNLOCK(hhrtim);
00833 
00834   return HAL_OK;
00835 }
00836 
00837 /**
00838   * @brief  Stop the counter of a timer operating in simple time base mode.
00839   * @param  hhrtim pointer to HAL HRTIM handle
00840   * @param  TimerIdx Timer index.
00841   *                   This parameter can be one of the following values:
00842   *                   @arg HRTIM_TIMERINDEX_MASTER  for master timer
00843   *                   @arg HRTIM_TIMERINDEX_TIMER_A for timer A
00844   *                   @arg HRTIM_TIMERINDEX_TIMER_B for timer B
00845   *                   @arg HRTIM_TIMERINDEX_TIMER_C for timer C
00846   *                   @arg HRTIM_TIMERINDEX_TIMER_D for timer D
00847   *                   @arg HRTIM_TIMERINDEX_TIMER_E for timer E
00848   * @retval HAL status
00849   */
00850 HAL_StatusTypeDef HAL_HRTIM_SimpleBaseStop(HRTIM_HandleTypeDef * hhrtim,
00851                                           uint32_t TimerIdx)
00852 {
00853    /* Check the parameters */
00854   assert_param(IS_HRTIM_TIMERINDEX(TimerIdx));
00855 
00856   /* Process Locked */
00857   __HAL_LOCK(hhrtim);
00858 
00859   hhrtim->State = HAL_HRTIM_STATE_BUSY;
00860 
00861   /* Disable the timer counter */
00862   __HAL_HRTIM_DISABLE(hhrtim, TimerIdxToTimerId[TimerIdx]);
00863 
00864   hhrtim->State = HAL_HRTIM_STATE_READY;
00865 
00866   /* Process Unlocked */
00867   __HAL_UNLOCK(hhrtim);
00868 
00869   return HAL_OK;
00870 }
00871 
00872 /**
00873   * @brief  Start the counter of a timer operating in simple time base mode
00874   *         (Timer repetition interrupt is enabled).
00875   * @param  hhrtim pointer to HAL HRTIM handle
00876   * @param  TimerIdx Timer index.
00877   *                   This parameter can be one of the following values:
00878   *                   @arg HRTIM_TIMERINDEX_MASTER  for master timer
00879   *                   @arg HRTIM_TIMERINDEX_TIMER_A for timer A
00880   *                   @arg HRTIM_TIMERINDEX_TIMER_B for timer B
00881   *                   @arg HRTIM_TIMERINDEX_TIMER_C for timer C
00882   *                   @arg HRTIM_TIMERINDEX_TIMER_D for timer D
00883   *                   @arg HRTIM_TIMERINDEX_TIMER_E for timer E
00884   * @retval HAL status
00885   */
00886 HAL_StatusTypeDef HAL_HRTIM_SimpleBaseStart_IT(HRTIM_HandleTypeDef * hhrtim,
00887                                               uint32_t TimerIdx)
00888 {
00889    /* Check the parameters */
00890   assert_param(IS_HRTIM_TIMERINDEX(TimerIdx));
00891 
00892   /* Process Locked */
00893   __HAL_LOCK(hhrtim);
00894 
00895   hhrtim->State = HAL_HRTIM_STATE_BUSY;
00896 
00897   /* Enable the repetition interrupt */
00898   if (TimerIdx == HRTIM_TIMERINDEX_MASTER)
00899   {
00900     __HAL_HRTIM_MASTER_ENABLE_IT(hhrtim, HRTIM_MASTER_IT_MREP);
00901   }
00902   else
00903   {
00904     __HAL_HRTIM_TIMER_ENABLE_IT(hhrtim, TimerIdx, HRTIM_TIM_IT_REP);
00905   }
00906 
00907   /* Enable the timer counter */
00908   __HAL_HRTIM_ENABLE(hhrtim, TimerIdxToTimerId[TimerIdx]);
00909 
00910   hhrtim->State = HAL_HRTIM_STATE_READY;
00911 
00912   /* Process Unlocked */
00913   __HAL_UNLOCK(hhrtim);
00914 
00915   return HAL_OK;
00916 }
00917 
00918 /**
00919   * @brief  Stop the counter of a timer operating in simple time base mode
00920   *         (Timer repetition interrupt is disabled).
00921   * @param  hhrtim pointer to HAL HRTIM handle
00922   * @param  TimerIdx Timer index.
00923   *                   This parameter can be one of the following values:
00924   *                   @arg HRTIM_TIMERINDEX_MASTER  for master timer
00925   *                   @arg HRTIM_TIMERINDEX_TIMER_A for timer A
00926   *                   @arg HRTIM_TIMERINDEX_TIMER_B for timer B
00927   *                   @arg HRTIM_TIMERINDEX_TIMER_C for timer C
00928   *                   @arg HRTIM_TIMERINDEX_TIMER_D for timer D
00929   *                   @arg HRTIM_TIMERINDEX_TIMER_E for timer E
00930   * @retval HAL status
00931   */
00932 HAL_StatusTypeDef HAL_HRTIM_SimpleBaseStop_IT(HRTIM_HandleTypeDef * hhrtim,
00933                                              uint32_t TimerIdx)
00934 {
00935    /* Check the parameters */
00936   assert_param(IS_HRTIM_TIMERINDEX(TimerIdx));
00937 
00938   /* Process Locked */
00939   __HAL_LOCK(hhrtim);
00940 
00941   hhrtim->State = HAL_HRTIM_STATE_BUSY;
00942 
00943   /* Disable the repetition interrupt */
00944   if (TimerIdx == HRTIM_TIMERINDEX_MASTER)
00945   {
00946     __HAL_HRTIM_MASTER_DISABLE_IT(hhrtim, HRTIM_MASTER_IT_MREP);
00947   }
00948   else
00949   {
00950     __HAL_HRTIM_TIMER_DISABLE_IT(hhrtim, TimerIdx, HRTIM_TIM_IT_REP);
00951   }
00952 
00953   /* Disable the timer counter */
00954   __HAL_HRTIM_DISABLE(hhrtim, TimerIdxToTimerId[TimerIdx]);
00955 
00956   hhrtim->State = HAL_HRTIM_STATE_READY;
00957 
00958   /* Process Unlocked */
00959   __HAL_UNLOCK(hhrtim);
00960 
00961   return HAL_OK;
00962 }
00963 
00964 /**
00965   * @brief  Start the counter of a timer operating in simple time base mode
00966   *         (Timer repetition DMA request is enabled).
00967   * @param  hhrtim pointer to HAL HRTIM handle
00968   * @param  TimerIdx Timer index.
00969   *                   This parameter can be one of the following values:
00970   *                    @arg HRTIM_TIMERINDEX_MASTER  for master timer
00971   *                    @arg HRTIM_TIMERINDEX_TIMER_A for timer A
00972   *                    @arg HRTIM_TIMERINDEX_TIMER_B for timer B
00973   *                    @arg HRTIM_TIMERINDEX_TIMER_C for timer C
00974   *                    @arg HRTIM_TIMERINDEX_TIMER_D for timer D
00975   *                    @arg HRTIM_TIMERINDEX_TIMER_E for timer E
00976   * @param  SrcAddr DMA transfer source address
00977   * @param  DestAddr DMA transfer destination address
00978   * @param  Length The length of data items (data size) to be transferred
00979   *                     from source to destination
00980   */
00981 HAL_StatusTypeDef HAL_HRTIM_SimpleBaseStart_DMA(HRTIM_HandleTypeDef * hhrtim,
00982                                                uint32_t TimerIdx,
00983                                                uint32_t SrcAddr,
00984                                                uint32_t DestAddr,
00985                                                uint32_t Length)
00986 {
00987   DMA_HandleTypeDef * hdma;
00988 
00989   /* Check the parameters */
00990   assert_param(IS_HRTIM_TIMERINDEX(TimerIdx));
00991 
00992   if(hhrtim->State == HAL_HRTIM_STATE_BUSY)
00993   {
00994      return HAL_BUSY;
00995   }
00996   if(hhrtim->State == HAL_HRTIM_STATE_READY)
00997   {
00998     if((SrcAddr == 0U ) || (DestAddr == 0U ) || (Length == 0U))
00999     {
01000       return HAL_ERROR;
01001     }
01002     else
01003     {
01004       hhrtim->State = HAL_HRTIM_STATE_BUSY;
01005     }
01006   }
01007 
01008   /* Process Locked */
01009   __HAL_LOCK(hhrtim);
01010 
01011   /* Get the timer DMA handler */
01012   hdma = HRTIM_GetDMAHandleFromTimerIdx(hhrtim, TimerIdx);
01013 
01014   if (hdma == NULL)
01015   {
01016    hhrtim->State = HAL_HRTIM_STATE_ERROR;
01017 
01018    /* Process Unlocked */
01019    __HAL_UNLOCK(hhrtim);
01020 
01021    return HAL_ERROR;
01022   }
01023 
01024   /* Set the DMA transfer completed callback */
01025   if (TimerIdx == HRTIM_TIMERINDEX_MASTER)
01026   {
01027     hdma->XferCpltCallback = HRTIM_DMAMasterCplt;
01028   }
01029   else
01030   {
01031     hdma->XferCpltCallback = HRTIM_DMATimerxCplt;
01032   }
01033 
01034   /* Set the DMA error callback */
01035   hdma->XferErrorCallback = HRTIM_DMAError ;
01036 
01037   /* Enable the DMA channel */
01038   if (HAL_DMA_Start_IT(hdma, SrcAddr, DestAddr, Length) != HAL_OK)
01039     {
01040         hhrtim->State = HAL_HRTIM_STATE_ERROR;
01041 
01042         /* Process Unlocked */
01043         __HAL_UNLOCK(hhrtim);
01044 
01045         return HAL_ERROR;
01046     }
01047 
01048   /* Enable the timer repetition DMA request */
01049   if (TimerIdx == HRTIM_TIMERINDEX_MASTER)
01050   {
01051     __HAL_HRTIM_MASTER_ENABLE_DMA(hhrtim, HRTIM_MASTER_DMA_MREP);
01052   }
01053   else
01054   {
01055     __HAL_HRTIM_TIMER_ENABLE_DMA(hhrtim, TimerIdx, HRTIM_TIM_DMA_REP);
01056   }
01057 
01058   /* Enable the timer counter */
01059   __HAL_HRTIM_ENABLE(hhrtim, TimerIdxToTimerId[TimerIdx]);
01060 
01061   hhrtim->State = HAL_HRTIM_STATE_READY;
01062 
01063   /* Process Unlocked */
01064   __HAL_UNLOCK(hhrtim);
01065 
01066   return HAL_OK;
01067 }
01068 
01069 /**
01070   * @brief  Stop the counter of a timer operating in simple time base mode
01071   *         (Timer repetition DMA request is disabled).
01072   * @param  hhrtim pointer to HAL HRTIM handle
01073   * @param  TimerIdx Timer index.
01074   *                   This parameter can be one of the following values:
01075   *                   @arg HRTIM_TIMERINDEX_MASTER  for master timer
01076   *                   @arg HRTIM_TIMERINDEX_TIMER_A for timer A
01077   *                   @arg HRTIM_TIMERINDEX_TIMER_B for timer B
01078   *                   @arg HRTIM_TIMERINDEX_TIMER_C for timer C
01079   *                   @arg HRTIM_TIMERINDEX_TIMER_D for timer D
01080   *                   @arg HRTIM_TIMERINDEX_TIMER_E for timer E
01081   * @retval HAL status
01082   */
01083 HAL_StatusTypeDef HAL_HRTIM_SimpleBaseStop_DMA(HRTIM_HandleTypeDef * hhrtim,
01084                                               uint32_t TimerIdx)
01085 {
01086   DMA_HandleTypeDef * hdma;
01087 
01088   /* Check the parameters */
01089   assert_param(IS_HRTIM_TIMERINDEX(TimerIdx));
01090 
01091   /* Process Locked */
01092   __HAL_LOCK(hhrtim);
01093 
01094   if (TimerIdx == HRTIM_TIMERINDEX_MASTER)
01095   {
01096     hhrtim->State = HAL_HRTIM_STATE_READY;
01097 
01098     /* Disable the DMA */
01099     if (HAL_DMA_Abort(hhrtim->hdmaMaster) != HAL_OK)
01100     {
01101         hhrtim->State = HAL_HRTIM_STATE_ERROR;
01102     }
01103     /* Disable the timer repetition DMA request */
01104     __HAL_HRTIM_MASTER_DISABLE_DMA(hhrtim, HRTIM_MASTER_DMA_MREP);
01105   }
01106   else
01107   {
01108     /* Get the timer DMA handler */
01109     hdma = HRTIM_GetDMAHandleFromTimerIdx(hhrtim, TimerIdx);
01110 
01111     if (hdma == NULL)
01112     {
01113       hhrtim->State = HAL_HRTIM_STATE_ERROR;
01114     }
01115     else
01116     {
01117       hhrtim->State = HAL_HRTIM_STATE_READY;
01118 
01119       /* Disable the DMA */
01120       if (HAL_DMA_Abort(hdma) != HAL_OK)
01121       {
01122          hhrtim->State = HAL_HRTIM_STATE_ERROR;
01123       }
01124 
01125       /* Disable the timer repetition DMA request */
01126       __HAL_HRTIM_TIMER_DISABLE_DMA(hhrtim, TimerIdx, HRTIM_TIM_DMA_REP);
01127      }
01128   }
01129 
01130   /* Disable the timer counter */
01131   __HAL_HRTIM_DISABLE(hhrtim, TimerIdxToTimerId[TimerIdx]);
01132 
01133   /* Process Unlocked */
01134   __HAL_UNLOCK(hhrtim);
01135 
01136   if (hhrtim->State == HAL_HRTIM_STATE_ERROR)
01137   {
01138       return HAL_ERROR;
01139   }
01140   else
01141   {
01142       return HAL_OK;
01143   }
01144 }
01145 
01146 /**
01147   * @}
01148   */
01149 
01150 /** @defgroup HRTIM_Exported_Functions_Group3 Simple output compare mode functions
01151  *  @brief    Simple output compare functions
01152 @verbatim
01153  ===============================================================================
01154               ##### Simple output compare functions #####
01155  ===============================================================================
01156     [..]  This section provides functions allowing to:
01157       (+) Configure simple output channel
01158       (+) Start simple output compare
01159       (+) Stop simple output compare
01160       (+) Start simple output compare and enable interrupt
01161       (+) Stop simple output compare and disable interrupt
01162       (+) Start simple output compare and enable DMA transfer
01163       (+) Stop simple output compare and disable DMA transfer
01164        -@- When a HRTIM timer operates in simple output compare mode
01165            the output level is set to a programmable value when a match
01166            is found between the compare register and the counter.
01167            Compare unit 1 is automatically associated to output 1
01168            Compare unit 2 is automatically associated to output 2
01169 @endverbatim
01170   * @{
01171   */
01172 
01173 /**
01174   * @brief  Configure an output in simple output compare mode
01175   * @param  hhrtim pointer to HAL HRTIM handle
01176   * @param  TimerIdx Timer index
01177   *                   This parameter can be one of the following values:
01178   *                   @arg HRTIM_TIMERINDEX_TIMER_A for timer A
01179   *                   @arg HRTIM_TIMERINDEX_TIMER_B for timer B
01180   *                   @arg HRTIM_TIMERINDEX_TIMER_C for timer C
01181   *                   @arg HRTIM_TIMERINDEX_TIMER_D for timer D
01182   *                   @arg HRTIM_TIMERINDEX_TIMER_E for timer E
01183   * @param  OCChannel Timer output
01184   *                    This parameter can be one of the following values:
01185   *                    @arg HRTIM_OUTPUT_TA1: Timer A - Output 1
01186   *                    @arg HRTIM_OUTPUT_TA2: Timer A - Output 2
01187   *                    @arg HRTIM_OUTPUT_TB1: Timer B - Output 1
01188   *                    @arg HRTIM_OUTPUT_TB2: Timer B - Output 2
01189   *                    @arg HRTIM_OUTPUT_TC1: Timer C - Output 1
01190   *                    @arg HRTIM_OUTPUT_TC2: Timer C - Output 2
01191   *                    @arg HRTIM_OUTPUT_TD1: Timer D - Output 1
01192   *                    @arg HRTIM_OUTPUT_TD2: Timer D - Output 2
01193   *                    @arg HRTIM_OUTPUT_TE1: Timer E - Output 1
01194   *                    @arg HRTIM_OUTPUT_TE2: Timer E - Output 2
01195   * @param  pSimpleOCChannelCfg pointer to the simple output compare output configuration structure
01196   * @note When the timer operates in simple output compare mode:
01197   *         Output 1 is implicitly controlled by the compare unit 1
01198   *         Output 2 is implicitly controlled by the compare unit 2
01199   *       Output Set/Reset crossbar is set according to the selected output compare mode:
01200   *         Toggle: SETxyR = RSTxyR = CMPy
01201   *         Active: SETxyR = CMPy, RSTxyR = 0
01202   *         Inactive: SETxy =0, RSTxy = CMPy
01203   * @retval HAL status
01204   */
01205 HAL_StatusTypeDef HAL_HRTIM_SimpleOCChannelConfig(HRTIM_HandleTypeDef * hhrtim,
01206                                                  uint32_t TimerIdx,
01207                                                  uint32_t OCChannel,
01208                                                  HRTIM_SimpleOCChannelCfgTypeDef* pSimpleOCChannelCfg)
01209 {
01210   uint32_t CompareUnit = (uint32_t)RESET;
01211   HRTIM_OutputCfgTypeDef OutputCfg;
01212 
01213   /* Check parameters */
01214   assert_param(IS_HRTIM_TIMER_OUTPUT(TimerIdx, OCChannel));
01215   assert_param(IS_HRTIM_BASICOCMODE(pSimpleOCChannelCfg->Mode));
01216   assert_param(IS_HRTIM_OUTPUTPULSE(pSimpleOCChannelCfg->Pulse));
01217   assert_param(IS_HRTIM_OUTPUTPOLARITY(pSimpleOCChannelCfg->Polarity));
01218   assert_param(IS_HRTIM_OUTPUTIDLELEVEL(pSimpleOCChannelCfg->IdleLevel));
01219 
01220   if(hhrtim->State == HAL_HRTIM_STATE_BUSY)
01221   {
01222      return HAL_BUSY;
01223   }
01224 
01225   /* Process Locked */
01226   __HAL_LOCK(hhrtim);
01227 
01228   /* Set HRTIM state */
01229   hhrtim->State = HAL_HRTIM_STATE_BUSY;
01230 
01231   /* Configure timer compare unit */
01232   switch (OCChannel)
01233   {
01234   case HRTIM_OUTPUT_TA1:
01235   case HRTIM_OUTPUT_TB1:
01236   case HRTIM_OUTPUT_TC1:
01237   case HRTIM_OUTPUT_TD1:
01238   case HRTIM_OUTPUT_TE1:
01239     {
01240       CompareUnit = HRTIM_COMPAREUNIT_1;
01241       hhrtim->Instance->sTimerxRegs[TimerIdx].CMP1xR = pSimpleOCChannelCfg->Pulse;
01242       break;
01243     }
01244   case HRTIM_OUTPUT_TA2:
01245   case HRTIM_OUTPUT_TB2:
01246   case HRTIM_OUTPUT_TC2:
01247   case HRTIM_OUTPUT_TD2:
01248   case HRTIM_OUTPUT_TE2:
01249     {
01250       CompareUnit = HRTIM_COMPAREUNIT_2;
01251       hhrtim->Instance->sTimerxRegs[TimerIdx].CMP2xR = pSimpleOCChannelCfg->Pulse;
01252       break;
01253     }
01254   default:
01255     {
01256       hhrtim->State = HAL_HRTIM_STATE_ERROR;
01257 
01258       /* Process Unlocked */
01259       __HAL_UNLOCK(hhrtim);
01260 
01261       break;
01262     }
01263   }
01264 
01265   if(hhrtim->State == HAL_HRTIM_STATE_ERROR)
01266   {
01267      return HAL_ERROR;
01268   }
01269 
01270   /* Configure timer output */
01271   OutputCfg.Polarity = (pSimpleOCChannelCfg->Polarity & HRTIM_OUTR_POL1);
01272   OutputCfg.IdleLevel = (pSimpleOCChannelCfg->IdleLevel & HRTIM_OUTR_IDLES1);
01273   OutputCfg.FaultLevel = HRTIM_OUTPUTFAULTLEVEL_NONE;
01274   OutputCfg.IdleMode = HRTIM_OUTPUTIDLEMODE_NONE;
01275   OutputCfg.ChopperModeEnable = HRTIM_OUTPUTCHOPPERMODE_DISABLED;
01276   OutputCfg.BurstModeEntryDelayed = HRTIM_OUTPUTBURSTMODEENTRY_REGULAR;
01277 
01278   switch (pSimpleOCChannelCfg->Mode)
01279   {
01280   case HRTIM_BASICOCMODE_TOGGLE:
01281     {
01282       if (CompareUnit == HRTIM_COMPAREUNIT_1)
01283       {
01284         OutputCfg.SetSource = HRTIM_OUTPUTSET_TIMCMP1;
01285       }
01286       else
01287       {
01288         OutputCfg.SetSource = HRTIM_OUTPUTSET_TIMCMP2;
01289       }
01290       OutputCfg.ResetSource = OutputCfg.SetSource;
01291       break;
01292     }
01293 
01294   case HRTIM_BASICOCMODE_ACTIVE:
01295     {
01296       if (CompareUnit == HRTIM_COMPAREUNIT_1)
01297       {
01298         OutputCfg.SetSource = HRTIM_OUTPUTSET_TIMCMP1;
01299       }
01300       else
01301       {
01302         OutputCfg.SetSource = HRTIM_OUTPUTSET_TIMCMP2;
01303       }
01304       OutputCfg.ResetSource = HRTIM_OUTPUTRESET_NONE;
01305       break;
01306     }
01307 
01308   case HRTIM_BASICOCMODE_INACTIVE:
01309     {
01310       if (CompareUnit == HRTIM_COMPAREUNIT_1)
01311       {
01312         OutputCfg.ResetSource = HRTIM_OUTPUTRESET_TIMCMP1;
01313       }
01314       else
01315       {
01316         OutputCfg.ResetSource = HRTIM_OUTPUTRESET_TIMCMP2;
01317       }
01318       OutputCfg.SetSource = HRTIM_OUTPUTSET_NONE;
01319       break;
01320     }
01321 
01322   default:
01323     {
01324       OutputCfg.SetSource = HRTIM_OUTPUTSET_NONE;
01325       OutputCfg.ResetSource = HRTIM_OUTPUTRESET_NONE;
01326 
01327       hhrtim->State = HAL_HRTIM_STATE_ERROR;
01328 
01329       /* Process Unlocked */
01330       __HAL_UNLOCK(hhrtim);
01331 
01332       break;
01333     }
01334   }
01335 
01336   if(hhrtim->State == HAL_HRTIM_STATE_ERROR)
01337   {
01338      return HAL_ERROR;
01339   }
01340 
01341   HRTIM_OutputConfig(hhrtim,
01342                      TimerIdx,
01343                      OCChannel,
01344                      &OutputCfg);
01345 
01346   /* Set HRTIM state */
01347   hhrtim->State = HAL_HRTIM_STATE_READY;
01348 
01349   /* Process Unlocked */
01350   __HAL_UNLOCK(hhrtim);
01351 
01352   return HAL_OK;
01353 }
01354 
01355 /**
01356   * @brief  Start the output compare signal generation on the designed timer output
01357   * @param  hhrtim pointer to HAL HRTIM handle
01358   * @param  TimerIdx Timer index
01359   *                   This parameter can be one of the following values:
01360   *                   @arg HRTIM_TIMERINDEX_TIMER_A for timer A
01361   *                   @arg HRTIM_TIMERINDEX_TIMER_B for timer B
01362   *                   @arg HRTIM_TIMERINDEX_TIMER_C for timer C
01363   *                   @arg HRTIM_TIMERINDEX_TIMER_D for timer D
01364   *                   @arg HRTIM_TIMERINDEX_TIMER_E for timer E
01365   * @param  OCChannel Timer output
01366   *                    This parameter can be one of the following values:
01367   *                    @arg HRTIM_OUTPUT_TA1: Timer A - Output 1
01368   *                    @arg HRTIM_OUTPUT_TA2: Timer A - Output 2
01369   *                    @arg HRTIM_OUTPUT_TB1: Timer B - Output 1
01370   *                    @arg HRTIM_OUTPUT_TB2: Timer B - Output 2
01371   *                    @arg HRTIM_OUTPUT_TC1: Timer C - Output 1
01372   *                    @arg HRTIM_OUTPUT_TC2: Timer C - Output 2
01373   *                    @arg HRTIM_OUTPUT_TD1: Timer D - Output 1
01374   *                    @arg HRTIM_OUTPUT_TD2: Timer D - Output 2
01375   *                    @arg HRTIM_OUTPUT_TE1: Timer E - Output 1
01376   *                    @arg HRTIM_OUTPUT_TE2: Timer E - Output 2
01377   * @retval HAL status
01378   */
01379 HAL_StatusTypeDef HAL_HRTIM_SimpleOCStart(HRTIM_HandleTypeDef * hhrtim,
01380                                          uint32_t TimerIdx,
01381                                          uint32_t OCChannel)
01382 {
01383    /* Check the parameters */
01384   assert_param(IS_HRTIM_TIMER_OUTPUT(TimerIdx, OCChannel));
01385 
01386   /* Process Locked */
01387   __HAL_LOCK(hhrtim);
01388 
01389   hhrtim->State = HAL_HRTIM_STATE_BUSY;
01390 
01391   /* Enable the timer output */
01392   hhrtim->Instance->sCommonRegs.OENR |= OCChannel;
01393 
01394   /* Enable the timer counter */
01395   __HAL_HRTIM_ENABLE(hhrtim, TimerIdxToTimerId[TimerIdx]);
01396 
01397   hhrtim->State = HAL_HRTIM_STATE_READY;
01398 
01399   /* Process Unlocked */
01400   __HAL_UNLOCK(hhrtim);
01401 
01402   return HAL_OK;
01403 }
01404 
01405 /**
01406   * @brief  Stop the output compare signal generation on the designed timer output
01407   * @param  hhrtim pointer to HAL HRTIM handle
01408   * @param  TimerIdx Timer index
01409   *                   This parameter can be one of the following values:
01410   *                   @arg HRTIM_TIMERINDEX_TIMER_A for timer A
01411   *                   @arg HRTIM_TIMERINDEX_TIMER_B for timer B
01412   *                   @arg HRTIM_TIMERINDEX_TIMER_C for timer C
01413   *                   @arg HRTIM_TIMERINDEX_TIMER_D for timer D
01414   *                   @arg HRTIM_TIMERINDEX_TIMER_E for timer E
01415   * @param  OCChannel Timer output
01416   *                    This parameter can be one of the following values:
01417   *                    @arg HRTIM_OUTPUT_TA1: Timer A - Output 1
01418   *                    @arg HRTIM_OUTPUT_TA2: Timer A - Output 2
01419   *                    @arg HRTIM_OUTPUT_TB1: Timer B - Output 1
01420   *                    @arg HRTIM_OUTPUT_TB2: Timer B - Output 2
01421   *                    @arg HRTIM_OUTPUT_TC1: Timer C - Output 1
01422   *                    @arg HRTIM_OUTPUT_TC2: Timer C - Output 2
01423   *                    @arg HRTIM_OUTPUT_TD1: Timer D - Output 1
01424   *                    @arg HRTIM_OUTPUT_TD2: Timer D - Output 2
01425   *                    @arg HRTIM_OUTPUT_TE1: Timer E - Output 1
01426   *                    @arg HRTIM_OUTPUT_TE2: Timer E - Output 2
01427   * @retval HAL status
01428   */
01429 HAL_StatusTypeDef HAL_HRTIM_SimpleOCStop(HRTIM_HandleTypeDef * hhrtim,
01430                                         uint32_t TimerIdx,
01431                                         uint32_t OCChannel)
01432 {
01433    /* Check the parameters */
01434   assert_param(IS_HRTIM_TIMER_OUTPUT(TimerIdx, OCChannel));
01435 
01436   /* Process Locked */
01437   __HAL_LOCK(hhrtim);
01438 
01439   hhrtim->State = HAL_HRTIM_STATE_BUSY;
01440 
01441   /* Disable the timer output */
01442   hhrtim->Instance->sCommonRegs.ODISR |= OCChannel;
01443 
01444   /* Disable the timer counter */
01445   __HAL_HRTIM_DISABLE(hhrtim, TimerIdxToTimerId[TimerIdx]);
01446 
01447   hhrtim->State = HAL_HRTIM_STATE_READY;
01448 
01449   /* Process Unlocked */
01450   __HAL_UNLOCK(hhrtim);
01451 
01452   return HAL_OK;
01453 }
01454 
01455 /**
01456   * @brief  Start the output compare signal generation on the designed timer output
01457   *         (Interrupt is enabled (see note note below)).
01458   * @param  hhrtim pointer to HAL HRTIM handle
01459   * @param  TimerIdx Timer index
01460   *                   This parameter can be one of the following values:
01461   *                   @arg HRTIM_TIMERINDEX_TIMER_A for timer A
01462   *                   @arg HRTIM_TIMERINDEX_TIMER_B for timer B
01463   *                   @arg HRTIM_TIMERINDEX_TIMER_C for timer C
01464   *                   @arg HRTIM_TIMERINDEX_TIMER_D for timer D
01465   *                   @arg HRTIM_TIMERINDEX_TIMER_E for timer E
01466   * @param  OCChannel Timer output
01467   *                    This parameter can be one of the following values:
01468   *                    @arg HRTIM_OUTPUT_TA1: Timer A - Output 1
01469   *                    @arg HRTIM_OUTPUT_TA2: Timer A - Output 2
01470   *                    @arg HRTIM_OUTPUT_TB1: Timer B - Output 1
01471   *                    @arg HRTIM_OUTPUT_TB2: Timer B - Output 2
01472   *                    @arg HRTIM_OUTPUT_TC1: Timer C - Output 1
01473   *                    @arg HRTIM_OUTPUT_TC2: Timer C - Output 2
01474   *                    @arg HRTIM_OUTPUT_TD1: Timer D - Output 1
01475   *                    @arg HRTIM_OUTPUT_TD2: Timer D - Output 2
01476   *                    @arg HRTIM_OUTPUT_TE1: Timer E - Output 1
01477   *                    @arg HRTIM_OUTPUT_TE2: Timer E - Output 2
01478   * @note Interrupt enabling depends on the chosen output compare mode
01479   *          Output toggle: compare match interrupt is enabled
01480   *          Output set active:  output set interrupt is enabled
01481   *          Output set inactive:  output reset interrupt is enabled
01482   * @retval HAL status
01483   */
01484 HAL_StatusTypeDef HAL_HRTIM_SimpleOCStart_IT(HRTIM_HandleTypeDef * hhrtim,
01485                                             uint32_t TimerIdx,
01486                                             uint32_t OCChannel)
01487 {
01488   uint32_t interrupt;
01489 
01490    /* Check the parameters */
01491   assert_param(IS_HRTIM_TIMER_OUTPUT(TimerIdx, OCChannel));
01492 
01493   /* Process Locked */
01494   __HAL_LOCK(hhrtim);
01495 
01496   hhrtim->State = HAL_HRTIM_STATE_BUSY;
01497 
01498   /* Get the interrupt to enable (depends on the output compare mode) */
01499   interrupt = HRTIM_GetITFromOCMode(hhrtim, TimerIdx, OCChannel);
01500 
01501   /* Enable the timer output */
01502   hhrtim->Instance->sCommonRegs.OENR |= OCChannel;
01503 
01504   /* Enable the timer interrupt (depends on the output compare mode) */
01505   __HAL_HRTIM_TIMER_ENABLE_IT(hhrtim, TimerIdx, interrupt);
01506 
01507   /* Enable the timer counter */
01508   __HAL_HRTIM_ENABLE(hhrtim, TimerIdxToTimerId[TimerIdx]);
01509 
01510   hhrtim->State = HAL_HRTIM_STATE_READY;
01511 
01512   /* Process Unlocked */
01513   __HAL_UNLOCK(hhrtim);
01514 
01515   return HAL_OK;
01516 }
01517 
01518 /**
01519   * @brief  Stop the output compare signal generation on the designed timer output
01520   *         (Interrupt is disabled).
01521   * @param  hhrtim pointer to HAL HRTIM handle
01522   * @param  TimerIdx Timer index
01523   *                   This parameter can be one of the following values:
01524   *                   @arg HRTIM_TIMERINDEX_TIMER_A for timer A
01525   *                   @arg HRTIM_TIMERINDEX_TIMER_B for timer B
01526   *                   @arg HRTIM_TIMERINDEX_TIMER_C for timer C
01527   *                   @arg HRTIM_TIMERINDEX_TIMER_D for timer D
01528   *                   @arg HRTIM_TIMERINDEX_TIMER_E for timer E
01529   * @param  OCChannel Timer output
01530   *                    This parameter can be one of the following values:
01531   *                    @arg HRTIM_OUTPUT_TA1: Timer A - Output 1
01532   *                    @arg HRTIM_OUTPUT_TA2: Timer A - Output 2
01533   *                    @arg HRTIM_OUTPUT_TB1: Timer B - Output 1
01534   *                    @arg HRTIM_OUTPUT_TB2: Timer B - Output 2
01535   *                    @arg HRTIM_OUTPUT_TC1: Timer C - Output 1
01536   *                    @arg HRTIM_OUTPUT_TC2: Timer C - Output 2
01537   *                    @arg HRTIM_OUTPUT_TD1: Timer D - Output 1
01538   *                    @arg HRTIM_OUTPUT_TD2: Timer D - Output 2
01539   *                    @arg HRTIM_OUTPUT_TE1: Timer E - Output 1
01540   *                    @arg HRTIM_OUTPUT_TE2: Timer E - Output 2
01541   * @retval HAL status
01542   */
01543 HAL_StatusTypeDef HAL_HRTIM_SimpleOCStop_IT(HRTIM_HandleTypeDef * hhrtim,
01544                                            uint32_t TimerIdx,
01545                                            uint32_t OCChannel)
01546 {
01547   uint32_t interrupt;
01548 
01549    /* Check the parameters */
01550   assert_param(IS_HRTIM_TIMER_OUTPUT(TimerIdx, OCChannel));
01551 
01552   /* Process Locked */
01553   __HAL_LOCK(hhrtim);
01554 
01555   hhrtim->State = HAL_HRTIM_STATE_BUSY;
01556 
01557   /* Disable the timer output */
01558   hhrtim->Instance->sCommonRegs.ODISR |= OCChannel;
01559 
01560   /* Get the interrupt to disable (depends on the output compare mode) */
01561   interrupt = HRTIM_GetITFromOCMode(hhrtim, TimerIdx, OCChannel);
01562 
01563   /* Disable the timer interrupt */
01564   __HAL_HRTIM_TIMER_DISABLE_IT(hhrtim, TimerIdx, interrupt);
01565 
01566   /* Disable the timer counter */
01567   __HAL_HRTIM_DISABLE(hhrtim, TimerIdxToTimerId[TimerIdx]);
01568 
01569   hhrtim->State = HAL_HRTIM_STATE_READY;
01570 
01571   /* Process Unlocked */
01572   __HAL_UNLOCK(hhrtim);
01573 
01574   return HAL_OK;
01575 }
01576 
01577 /**
01578   * @brief  Start the output compare signal generation on the designed timer output
01579   *         (DMA request is enabled (see note below)).
01580   * @param  hhrtim pointer to HAL HRTIM handle
01581   * @param  TimerIdx Timer index
01582   *                   This parameter can be one of the following values:
01583   *                   @arg HRTIM_TIMERINDEX_TIMER_A for timer A
01584   *                   @arg HRTIM_TIMERINDEX_TIMER_B for timer B
01585   *                   @arg HRTIM_TIMERINDEX_TIMER_C for timer C
01586   *                   @arg HRTIM_TIMERINDEX_TIMER_D for timer D
01587   *                   @arg HRTIM_TIMERINDEX_TIMER_E for timer E
01588   * @param  OCChannel Timer output
01589   *                    This parameter can be one of the following values:
01590   *                    @arg HRTIM_OUTPUT_TA1: Timer A - Output 1
01591   *                    @arg HRTIM_OUTPUT_TA2: Timer A - Output 2
01592   *                    @arg HRTIM_OUTPUT_TB1: Timer B - Output 1
01593   *                    @arg HRTIM_OUTPUT_TB2: Timer B - Output 2
01594   *                    @arg HRTIM_OUTPUT_TC1: Timer C - Output 1
01595   *                    @arg HRTIM_OUTPUT_TC2: Timer C - Output 2
01596   *                    @arg HRTIM_OUTPUT_TD1: Timer D - Output 1
01597   *                    @arg HRTIM_OUTPUT_TD2: Timer D - Output 2
01598   *                    @arg HRTIM_OUTPUT_TE1: Timer E - Output 1
01599   *                    @arg HRTIM_OUTPUT_TE2: Timer E - Output 2
01600   * @param  SrcAddr DMA transfer source address
01601   * @param  DestAddr DMA transfer destination address
01602   * @param  Length The length of data items (data size) to be transferred
01603   *                     from source to destination
01604   * @note  DMA request enabling depends on the chosen output compare mode
01605   *          Output toggle: compare match DMA request is enabled
01606   *          Output set active:  output set DMA request is enabled
01607   *          Output set inactive:  output reset DMA request is enabled
01608   * @retval HAL status
01609   */
01610 HAL_StatusTypeDef HAL_HRTIM_SimpleOCStart_DMA(HRTIM_HandleTypeDef * hhrtim,
01611                                              uint32_t TimerIdx,
01612                                              uint32_t OCChannel,
01613                                              uint32_t SrcAddr,
01614                                              uint32_t DestAddr,
01615                                              uint32_t Length)
01616 {
01617   DMA_HandleTypeDef * hdma;
01618   uint32_t dma_request;
01619 
01620   /* Check the parameters */
01621   assert_param(IS_HRTIM_TIMER_OUTPUT(TimerIdx, OCChannel));
01622 
01623   if(hhrtim->State == HAL_HRTIM_STATE_BUSY)
01624   {
01625      return HAL_BUSY;
01626   }
01627   if(hhrtim->State == HAL_HRTIM_STATE_READY)
01628   {
01629     if((SrcAddr == 0U ) || (DestAddr == 0U ) || (Length == 0U))
01630     {
01631       return HAL_ERROR;
01632     }
01633     else
01634     {
01635       hhrtim->State = HAL_HRTIM_STATE_BUSY;
01636     }
01637   }
01638 
01639   /* Process Locked */
01640   __HAL_LOCK(hhrtim);
01641 
01642    /* Enable the timer output */
01643   hhrtim->Instance->sCommonRegs.OENR |= OCChannel;
01644 
01645   /* Get the DMA request to enable */
01646   dma_request = HRTIM_GetDMAFromOCMode(hhrtim, TimerIdx, OCChannel);
01647 
01648   /* Get the timer DMA handler */
01649   hdma = HRTIM_GetDMAHandleFromTimerIdx(hhrtim, TimerIdx);
01650 
01651   if (hdma == NULL)
01652   {
01653    hhrtim->State = HAL_HRTIM_STATE_ERROR;
01654 
01655    /* Process Unlocked */
01656    __HAL_UNLOCK(hhrtim);
01657 
01658    return HAL_ERROR;
01659   }
01660 
01661   /* Set the DMA error callback */
01662   hdma->XferErrorCallback = HRTIM_DMAError ;
01663 
01664   /* Set the DMA transfer completed callback */
01665   hdma->XferCpltCallback = HRTIM_DMATimerxCplt;
01666 
01667   /* Enable the DMA channel */
01668   if (HAL_DMA_Start_IT(hdma, SrcAddr, DestAddr, Length) != HAL_OK)
01669     {
01670         hhrtim->State = HAL_HRTIM_STATE_ERROR;
01671 
01672         /* Process Unlocked */
01673         __HAL_UNLOCK(hhrtim);
01674 
01675         return HAL_ERROR;
01676     }
01677 
01678   /* Enable the timer DMA request */
01679   __HAL_HRTIM_TIMER_ENABLE_DMA(hhrtim, TimerIdx, dma_request);
01680 
01681   /* Enable the timer counter */
01682   __HAL_HRTIM_ENABLE(hhrtim, TimerIdxToTimerId[TimerIdx]);
01683 
01684   hhrtim->State = HAL_HRTIM_STATE_READY;
01685 
01686   /* Process Unlocked */
01687   __HAL_UNLOCK(hhrtim);
01688 
01689   return HAL_OK;
01690 }
01691 
01692 /**
01693   * @brief  Stop the output compare signal generation on the designed timer output
01694   *         (DMA request is disabled).
01695   * @param  hhrtim pointer to HAL HRTIM handle
01696   * @param  TimerIdx Timer index
01697   *                   This parameter can be one of the following values:
01698   *                   @arg HRTIM_TIMERINDEX_TIMER_A for timer A
01699   *                   @arg HRTIM_TIMERINDEX_TIMER_B for timer B
01700   *                   @arg HRTIM_TIMERINDEX_TIMER_C for timer C
01701   *                   @arg HRTIM_TIMERINDEX_TIMER_D for timer D
01702   *                   @arg HRTIM_TIMERINDEX_TIMER_E for timer E
01703   * @param  OCChannel Timer output
01704   *                    This parameter can be one of the following values:
01705   *                    @arg HRTIM_OUTPUT_TA1: Timer A - Output 1
01706   *                    @arg HRTIM_OUTPUT_TA2: Timer A - Output 2
01707   *                    @arg HRTIM_OUTPUT_TB1: Timer B - Output 1
01708   *                    @arg HRTIM_OUTPUT_TB2: Timer B - Output 2
01709   *                    @arg HRTIM_OUTPUT_TC1: Timer C - Output 1
01710   *                    @arg HRTIM_OUTPUT_TC2: Timer C - Output 2
01711   *                    @arg HRTIM_OUTPUT_TD1: Timer D - Output 1
01712   *                    @arg HRTIM_OUTPUT_TD2: Timer D - Output 2
01713   *                    @arg HRTIM_OUTPUT_TE1: Timer E - Output 1
01714   *                    @arg HRTIM_OUTPUT_TE2: Timer E - Output 2
01715   * @retval HAL status
01716   */
01717 HAL_StatusTypeDef HAL_HRTIM_SimpleOCStop_DMA(HRTIM_HandleTypeDef * hhrtim,
01718                                             uint32_t TimerIdx,
01719                                             uint32_t OCChannel)
01720 {
01721   uint32_t dma_request;
01722 
01723   /* Check the parameters */
01724   assert_param(IS_HRTIM_TIMER_OUTPUT(TimerIdx, OCChannel));
01725 
01726   /* Process Locked */
01727   __HAL_LOCK(hhrtim);
01728 
01729   hhrtim->State = HAL_HRTIM_STATE_BUSY;
01730 
01731   /* Disable the timer output */
01732   hhrtim->Instance->sCommonRegs.ODISR |= OCChannel;
01733 
01734   /* Get the timer DMA handler */
01735   /* Disable the DMA */
01736   if (HAL_DMA_Abort(HRTIM_GetDMAHandleFromTimerIdx(hhrtim, TimerIdx)) != HAL_OK)
01737   {
01738     hhrtim->State = HAL_HRTIM_STATE_ERROR;
01739 
01740     /* Process Unlocked */
01741     __HAL_UNLOCK(hhrtim);
01742 
01743     return HAL_ERROR;
01744   }
01745 
01746   /* Get the DMA request to disable */
01747   dma_request = HRTIM_GetDMAFromOCMode(hhrtim, TimerIdx, OCChannel);
01748 
01749   /* Disable the timer DMA request */
01750   __HAL_HRTIM_TIMER_DISABLE_DMA(hhrtim, TimerIdx, dma_request);
01751 
01752   /* Disable the timer counter */
01753   __HAL_HRTIM_DISABLE(hhrtim, TimerIdxToTimerId[TimerIdx]);
01754 
01755   hhrtim->State = HAL_HRTIM_STATE_READY;
01756 
01757   /* Process Unlocked */
01758   __HAL_UNLOCK(hhrtim);
01759 
01760   return HAL_OK;
01761 }
01762 
01763 /**
01764   * @}
01765   */
01766 
01767 /** @defgroup HRTIM_Exported_Functions_Group4 Simple PWM output mode functions
01768  *  @brief    Simple PWM output functions
01769 @verbatim
01770  ===============================================================================
01771               ##### Simple PWM output functions #####
01772  ===============================================================================
01773     [..]  This section provides functions allowing to:
01774       (+) Configure simple PWM output channel
01775       (+) Start simple PWM output
01776       (+) Stop simple PWM output
01777       (+) Start simple PWM output and enable interrupt
01778       (+) Stop simple PWM output and disable interrupt
01779       (+) Start simple PWM output and enable DMA transfer
01780       (+) Stop simple PWM output and disable DMA transfer
01781       -@- When a HRTIM timer operates in simple PWM output mode
01782           the output level is set to a programmable value when a match is
01783           found between the compare register and the counter and reset when
01784           the timer period is reached. Duty cycle is determined by the
01785           comparison value.
01786           Compare unit 1 is automatically associated to output 1
01787           Compare unit 2 is automatically associated to output 2
01788 @endverbatim
01789   * @{
01790   */
01791 
01792 /**
01793   * @brief  Configure an output in simple PWM mode
01794   * @param  hhrtim pointer to HAL HRTIM handle
01795   * @param  TimerIdx Timer index
01796   *                   This parameter can be one of the following values:
01797   *                   @arg HRTIM_TIMERINDEX_TIMER_A for timer A
01798   *                   @arg HRTIM_TIMERINDEX_TIMER_B for timer B
01799   *                   @arg HRTIM_TIMERINDEX_TIMER_C for timer C
01800   *                   @arg HRTIM_TIMERINDEX_TIMER_D for timer D
01801   *                   @arg HRTIM_TIMERINDEX_TIMER_E for timer E
01802   * @param  PWMChannel Timer output
01803   *                    This parameter can be one of the following values:
01804   *                    @arg HRTIM_OUTPUT_TA1: Timer A - Output 1
01805   *                    @arg HRTIM_OUTPUT_TA2: Timer A - Output 2
01806   *                    @arg HRTIM_OUTPUT_TB1: Timer B - Output 1
01807   *                    @arg HRTIM_OUTPUT_TB2: Timer B - Output 2
01808   *                    @arg HRTIM_OUTPUT_TC1: Timer C - Output 1
01809   *                    @arg HRTIM_OUTPUT_TC2: Timer C - Output 2
01810   *                    @arg HRTIM_OUTPUT_TD1: Timer D - Output 1
01811   *                    @arg HRTIM_OUTPUT_TD2: Timer D - Output 2
01812   *                    @arg HRTIM_OUTPUT_TE1: Timer E - Output 1
01813   *                    @arg HRTIM_OUTPUT_TE2: Timer E - Output 2
01814   * @param  pSimplePWMChannelCfg pointer to the simple PWM output configuration structure
01815   * @note When the timer operates in simple PWM output mode:
01816   *         Output 1 is implicitly controlled by the compare unit 1
01817   *         Output 2 is implicitly controlled by the compare unit 2
01818   *       Output Set/Reset crossbar is set as follows:
01819   *         Output 1: SETx1R = CMP1, RSTx1R = PER
01820   *         Output 2: SETx2R = CMP2, RST2R = PER
01821   * @note When Simple PWM mode is used the registers preload mechanism is
01822   *       enabled (otherwise the behavior is not guaranteed).
01823   * @retval HAL status
01824   */
01825 HAL_StatusTypeDef HAL_HRTIM_SimplePWMChannelConfig(HRTIM_HandleTypeDef * hhrtim,
01826                                                   uint32_t TimerIdx,
01827                                                   uint32_t PWMChannel,
01828                                                   HRTIM_SimplePWMChannelCfgTypeDef* pSimplePWMChannelCfg)
01829 {
01830   HRTIM_OutputCfgTypeDef OutputCfg;
01831   uint32_t hrtim_timcr;
01832 
01833   /* Check parameters */
01834   assert_param(IS_HRTIM_TIMER_OUTPUT(TimerIdx, PWMChannel));
01835   assert_param(IS_HRTIM_OUTPUTPOLARITY(pSimplePWMChannelCfg->Polarity));
01836   assert_param(IS_HRTIM_OUTPUTPULSE(pSimplePWMChannelCfg->Pulse));
01837   assert_param(IS_HRTIM_OUTPUTIDLELEVEL(pSimplePWMChannelCfg->IdleLevel));
01838 
01839   if(hhrtim->State == HAL_HRTIM_STATE_BUSY)
01840   {
01841      return HAL_BUSY;
01842   }
01843 
01844   /* Process Locked */
01845   __HAL_LOCK(hhrtim);
01846 
01847   hhrtim->State = HAL_HRTIM_STATE_BUSY;
01848 
01849   /* Configure timer compare unit */
01850   switch (PWMChannel)
01851   {
01852   case HRTIM_OUTPUT_TA1:
01853   case HRTIM_OUTPUT_TB1:
01854   case HRTIM_OUTPUT_TC1:
01855   case HRTIM_OUTPUT_TD1:
01856   case HRTIM_OUTPUT_TE1:
01857     {
01858       hhrtim->Instance->sTimerxRegs[TimerIdx].CMP1xR = pSimplePWMChannelCfg->Pulse;
01859       OutputCfg.SetSource = HRTIM_OUTPUTSET_TIMCMP1;
01860       break;
01861     }
01862 
01863   case HRTIM_OUTPUT_TA2:
01864   case HRTIM_OUTPUT_TB2:
01865   case HRTIM_OUTPUT_TC2:
01866   case HRTIM_OUTPUT_TD2:
01867   case HRTIM_OUTPUT_TE2:
01868     {
01869       hhrtim->Instance->sTimerxRegs[TimerIdx].CMP2xR = pSimplePWMChannelCfg->Pulse;
01870       OutputCfg.SetSource = HRTIM_OUTPUTSET_TIMCMP2;
01871       break;
01872     }
01873   default:
01874     {
01875       OutputCfg.SetSource = HRTIM_OUTPUTSET_NONE;
01876       OutputCfg.ResetSource = HRTIM_OUTPUTRESET_NONE;
01877 
01878       hhrtim->State = HAL_HRTIM_STATE_ERROR;
01879 
01880       /* Process Unlocked */
01881       __HAL_UNLOCK(hhrtim);
01882 
01883       break;
01884     }
01885   }
01886 
01887   if(hhrtim->State == HAL_HRTIM_STATE_ERROR)
01888   {
01889      return HAL_ERROR;
01890   }
01891 
01892   /* Configure timer output */
01893   OutputCfg.Polarity = (pSimplePWMChannelCfg->Polarity & HRTIM_OUTR_POL1);
01894   OutputCfg.IdleLevel = (pSimplePWMChannelCfg->IdleLevel& HRTIM_OUTR_IDLES1);
01895   OutputCfg.FaultLevel = HRTIM_OUTPUTFAULTLEVEL_NONE;
01896   OutputCfg.IdleMode = HRTIM_OUTPUTIDLEMODE_NONE;
01897   OutputCfg.ChopperModeEnable = HRTIM_OUTPUTCHOPPERMODE_DISABLED;
01898   OutputCfg.BurstModeEntryDelayed = HRTIM_OUTPUTBURSTMODEENTRY_REGULAR;
01899   OutputCfg.ResetSource = HRTIM_OUTPUTRESET_TIMPER;
01900 
01901   HRTIM_OutputConfig(hhrtim,
01902                      TimerIdx,
01903                      PWMChannel,
01904                      &OutputCfg);
01905 
01906   /* Enable the registers preload mechanism */
01907   hrtim_timcr = hhrtim->Instance->sTimerxRegs[TimerIdx].TIMxCR;
01908   hrtim_timcr |= HRTIM_TIMCR_PREEN;
01909   hhrtim->Instance->sTimerxRegs[TimerIdx].TIMxCR = hrtim_timcr;
01910 
01911   hhrtim->State = HAL_HRTIM_STATE_READY;
01912 
01913   /* Process Unlocked */
01914   __HAL_UNLOCK(hhrtim);
01915 
01916   return HAL_OK;
01917 }
01918 
01919 /**
01920   * @brief  Start the PWM output signal generation on the designed timer output
01921   * @param  hhrtim pointer to HAL HRTIM handle
01922   * @param  TimerIdx Timer index
01923   *                   This parameter can be one of the following values:
01924   *                   @arg HRTIM_TIMERINDEX_TIMER_A for timer A
01925   *                   @arg HRTIM_TIMERINDEX_TIMER_B for timer B
01926   *                   @arg HRTIM_TIMERINDEX_TIMER_C for timer C
01927   *                   @arg HRTIM_TIMERINDEX_TIMER_D for timer D
01928   *                   @arg HRTIM_TIMERINDEX_TIMER_E for timer E
01929   * @param  PWMChannel Timer output
01930   *                    This parameter can be one of the following values:
01931   *                    @arg HRTIM_OUTPUT_TA1: Timer A - Output 1
01932   *                    @arg HRTIM_OUTPUT_TA2: Timer A - Output 2
01933   *                    @arg HRTIM_OUTPUT_TB1: Timer B - Output 1
01934   *                    @arg HRTIM_OUTPUT_TB2: Timer B - Output 2
01935   *                    @arg HRTIM_OUTPUT_TC1: Timer C - Output 1
01936   *                    @arg HRTIM_OUTPUT_TC2: Timer C - Output 2
01937   *                    @arg HRTIM_OUTPUT_TD1: Timer D - Output 1
01938   *                    @arg HRTIM_OUTPUT_TD2: Timer D - Output 2
01939   *                    @arg HRTIM_OUTPUT_TE1: Timer E - Output 1
01940   *                    @arg HRTIM_OUTPUT_TE2: Timer E - Output 2
01941   * @retval HAL status
01942   */
01943 HAL_StatusTypeDef HAL_HRTIM_SimplePWMStart(HRTIM_HandleTypeDef * hhrtim,
01944                                           uint32_t TimerIdx,
01945                                           uint32_t PWMChannel)
01946 {
01947    /* Check the parameters */
01948   assert_param(IS_HRTIM_TIMER_OUTPUT(TimerIdx, PWMChannel));
01949 
01950   /* Process Locked */
01951   __HAL_LOCK(hhrtim);
01952 
01953   hhrtim->State = HAL_HRTIM_STATE_BUSY;
01954 
01955   /* Enable the timer output */
01956   hhrtim->Instance->sCommonRegs.OENR |= PWMChannel;
01957 
01958   /* Enable the timer counter */
01959   __HAL_HRTIM_ENABLE(hhrtim, TimerIdxToTimerId[TimerIdx]);
01960 
01961   hhrtim->State = HAL_HRTIM_STATE_READY;
01962 
01963   /* Process Unlocked */
01964   __HAL_UNLOCK(hhrtim);
01965 
01966   return HAL_OK;
01967 }
01968 
01969 /**
01970   * @brief  Stop the PWM output signal generation on the designed timer output
01971   * @param  hhrtim pointer to HAL HRTIM handle
01972   * @param  TimerIdx Timer index
01973   *                   This parameter can be one of the following values:
01974   *                   @arg HRTIM_TIMERINDEX_TIMER_A for timer A
01975   *                   @arg HRTIM_TIMERINDEX_TIMER_B for timer B
01976   *                   @arg HRTIM_TIMERINDEX_TIMER_C for timer C
01977   *                   @arg HRTIM_TIMERINDEX_TIMER_D for timer D
01978   *                   @arg HRTIM_TIMERINDEX_TIMER_E for timer E
01979   * @param  PWMChannel Timer output
01980   *                    This parameter can be one of the following values:
01981   *                    @arg HRTIM_OUTPUT_TA1: Timer A - Output 1
01982   *                    @arg HRTIM_OUTPUT_TA2: Timer A - Output 2
01983   *                    @arg HRTIM_OUTPUT_TB1: Timer B - Output 1
01984   *                    @arg HRTIM_OUTPUT_TB2: Timer B - Output 2
01985   *                    @arg HRTIM_OUTPUT_TC1: Timer C - Output 1
01986   *                    @arg HRTIM_OUTPUT_TC2: Timer C - Output 2
01987   *                    @arg HRTIM_OUTPUT_TD1: Timer D - Output 1
01988   *                    @arg HRTIM_OUTPUT_TD2: Timer D - Output 2
01989   *                    @arg HRTIM_OUTPUT_TE1: Timer E - Output 1
01990   *                    @arg HRTIM_OUTPUT_TE2: Timer E - Output 2
01991   * @retval HAL status
01992   */
01993 HAL_StatusTypeDef HAL_HRTIM_SimplePWMStop(HRTIM_HandleTypeDef * hhrtim,
01994                                          uint32_t TimerIdx,
01995                                          uint32_t PWMChannel)
01996 {
01997    /* Check the parameters */
01998   assert_param(IS_HRTIM_TIMER_OUTPUT(TimerIdx, PWMChannel));
01999 
02000   /* Process Locked */
02001   __HAL_LOCK(hhrtim);
02002 
02003   hhrtim->State = HAL_HRTIM_STATE_BUSY;
02004 
02005   /* Disable the timer output */
02006   hhrtim->Instance->sCommonRegs.ODISR |= PWMChannel;
02007 
02008   /* Disable the timer counter */
02009   __HAL_HRTIM_DISABLE(hhrtim, TimerIdxToTimerId[TimerIdx]);
02010 
02011   hhrtim->State = HAL_HRTIM_STATE_READY;
02012 
02013   /* Process Unlocked */
02014   __HAL_UNLOCK(hhrtim);
02015 
02016   return HAL_OK;
02017 }
02018 
02019 /**
02020   * @brief  Start the PWM output signal generation on the designed timer output
02021   *         (The compare interrupt is enabled).
02022   * @param  hhrtim pointer to HAL HRTIM handle
02023   * @param  TimerIdx Timer index
02024   *                   This parameter can be one of the following values:
02025   *                   @arg HRTIM_TIMERINDEX_TIMER_A for timer A
02026   *                   @arg HRTIM_TIMERINDEX_TIMER_B for timer B
02027   *                   @arg HRTIM_TIMERINDEX_TIMER_C for timer C
02028   *                   @arg HRTIM_TIMERINDEX_TIMER_D for timer D
02029   *                   @arg HRTIM_TIMERINDEX_TIMER_E for timer E
02030   * @param  PWMChannel Timer output
02031   *                    This parameter can be one of the following values:
02032   *                    @arg HRTIM_OUTPUT_TA1: Timer A - Output 1
02033   *                    @arg HRTIM_OUTPUT_TA2: Timer A - Output 2
02034   *                    @arg HRTIM_OUTPUT_TB1: Timer B - Output 1
02035   *                    @arg HRTIM_OUTPUT_TB2: Timer B - Output 2
02036   *                    @arg HRTIM_OUTPUT_TC1: Timer C - Output 1
02037   *                    @arg HRTIM_OUTPUT_TC2: Timer C - Output 2
02038   *                    @arg HRTIM_OUTPUT_TD1: Timer D - Output 1
02039   *                    @arg HRTIM_OUTPUT_TD2: Timer D - Output 2
02040   *                    @arg HRTIM_OUTPUT_TE1: Timer E - Output 1
02041   *                    @arg HRTIM_OUTPUT_TE2: Timer E - Output 2
02042   * @retval HAL status
02043   */
02044 HAL_StatusTypeDef HAL_HRTIM_SimplePWMStart_IT(HRTIM_HandleTypeDef * hhrtim,
02045                                              uint32_t TimerIdx,
02046                                              uint32_t PWMChannel)
02047 {
02048    /* Check the parameters */
02049   assert_param(IS_HRTIM_TIMER_OUTPUT(TimerIdx, PWMChannel));
02050 
02051   /* Process Locked */
02052   __HAL_LOCK(hhrtim);
02053 
02054   hhrtim->State = HAL_HRTIM_STATE_BUSY;
02055 
02056   /* Enable the timer output */
02057   hhrtim->Instance->sCommonRegs.OENR |= PWMChannel;
02058 
02059   /* Enable the timer interrupt (depends on the PWM output) */
02060   switch (PWMChannel)
02061   {
02062   case HRTIM_OUTPUT_TA1:
02063   case HRTIM_OUTPUT_TB1:
02064   case HRTIM_OUTPUT_TC1:
02065   case HRTIM_OUTPUT_TD1:
02066   case HRTIM_OUTPUT_TE1:
02067     {
02068       __HAL_HRTIM_TIMER_ENABLE_IT(hhrtim, TimerIdx, HRTIM_TIM_IT_CMP1);
02069       break;
02070     }
02071 
02072   case HRTIM_OUTPUT_TA2:
02073   case HRTIM_OUTPUT_TB2:
02074   case HRTIM_OUTPUT_TC2:
02075   case HRTIM_OUTPUT_TD2:
02076   case HRTIM_OUTPUT_TE2:
02077     {
02078       __HAL_HRTIM_TIMER_ENABLE_IT(hhrtim, TimerIdx, HRTIM_TIM_IT_CMP2);
02079       break;
02080     }
02081 
02082   default:
02083     {
02084       hhrtim->State = HAL_HRTIM_STATE_ERROR;
02085 
02086       /* Process Unlocked */
02087       __HAL_UNLOCK(hhrtim);
02088 
02089       break;
02090     }
02091   }
02092 
02093   if(hhrtim->State == HAL_HRTIM_STATE_ERROR)
02094   {
02095      return HAL_ERROR;
02096   }
02097 
02098   /* Enable the timer counter */
02099   __HAL_HRTIM_ENABLE(hhrtim, TimerIdxToTimerId[TimerIdx]);
02100 
02101   hhrtim->State = HAL_HRTIM_STATE_READY;
02102 
02103   /* Process Unlocked */
02104   __HAL_UNLOCK(hhrtim);
02105 
02106   return HAL_OK;
02107 }
02108 
02109 /**
02110   * @brief  Stop the PWM output signal generation on the designed timer output
02111   *         (The compare interrupt is disabled).
02112   * @param  hhrtim pointer to HAL HRTIM handle
02113   * @param  TimerIdx Timer index
02114   *                   This parameter can be one of the following values:
02115   *                   @arg HRTIM_TIMERINDEX_TIMER_A for timer A
02116   *                   @arg HRTIM_TIMERINDEX_TIMER_B for timer B
02117   *                   @arg HRTIM_TIMERINDEX_TIMER_C for timer C
02118   *                   @arg HRTIM_TIMERINDEX_TIMER_D for timer D
02119   *                   @arg HRTIM_TIMERINDEX_TIMER_E for timer E
02120   * @param  PWMChannel Timer output
02121   *                    This parameter can be one of the following values:
02122   *                    @arg HRTIM_OUTPUT_TA1: Timer A - Output 1
02123   *                    @arg HRTIM_OUTPUT_TA2: Timer A - Output 2
02124   *                    @arg HRTIM_OUTPUT_TB1: Timer B - Output 1
02125   *                    @arg HRTIM_OUTPUT_TB2: Timer B - Output 2
02126   *                    @arg HRTIM_OUTPUT_TC1: Timer C - Output 1
02127   *                    @arg HRTIM_OUTPUT_TC2: Timer C - Output 2
02128   *                    @arg HRTIM_OUTPUT_TD1: Timer D - Output 1
02129   *                    @arg HRTIM_OUTPUT_TD2: Timer D - Output 2
02130   *                    @arg HRTIM_OUTPUT_TE1: Timer E - Output 1
02131   *                    @arg HRTIM_OUTPUT_TE2: Timer E - Output 2
02132   * @retval HAL status
02133   */
02134 HAL_StatusTypeDef HAL_HRTIM_SimplePWMStop_IT(HRTIM_HandleTypeDef * hhrtim,
02135                                             uint32_t TimerIdx,
02136                                             uint32_t PWMChannel)
02137 {
02138    /* Check the parameters */
02139   assert_param(IS_HRTIM_TIMER_OUTPUT(TimerIdx, PWMChannel));
02140 
02141   /* Process Locked */
02142   __HAL_LOCK(hhrtim);
02143 
02144   hhrtim->State = HAL_HRTIM_STATE_BUSY;
02145 
02146   /* Disable the timer output */
02147   hhrtim->Instance->sCommonRegs.ODISR |= PWMChannel;
02148 
02149   /* Disable the timer interrupt (depends on the PWM output) */
02150   switch (PWMChannel)
02151   {
02152   case HRTIM_OUTPUT_TA1:
02153   case HRTIM_OUTPUT_TB1:
02154   case HRTIM_OUTPUT_TC1:
02155   case HRTIM_OUTPUT_TD1:
02156   case HRTIM_OUTPUT_TE1:
02157     {
02158       __HAL_HRTIM_TIMER_DISABLE_IT(hhrtim, TimerIdx, HRTIM_TIM_IT_CMP1);
02159       break;
02160     }
02161 
02162   case HRTIM_OUTPUT_TA2:
02163   case HRTIM_OUTPUT_TB2:
02164   case HRTIM_OUTPUT_TC2:
02165   case HRTIM_OUTPUT_TD2:
02166   case HRTIM_OUTPUT_TE2:
02167     {
02168       __HAL_HRTIM_TIMER_DISABLE_IT(hhrtim, TimerIdx, HRTIM_TIM_IT_CMP2);
02169       break;
02170     }
02171 
02172   default:
02173     {
02174       hhrtim->State = HAL_HRTIM_STATE_ERROR;
02175 
02176       /* Process Unlocked */
02177       __HAL_UNLOCK(hhrtim);
02178 
02179       break;
02180     }
02181   }
02182 
02183   if(hhrtim->State == HAL_HRTIM_STATE_ERROR)
02184   {
02185      return HAL_ERROR;
02186   }
02187 
02188   /* Disable the timer counter */
02189   __HAL_HRTIM_DISABLE(hhrtim, TimerIdxToTimerId[TimerIdx]);
02190 
02191   hhrtim->State = HAL_HRTIM_STATE_READY;
02192 
02193   /* Process Unlocked */
02194   __HAL_UNLOCK(hhrtim);
02195 
02196   return HAL_OK;
02197 }
02198 
02199 /**
02200   * @brief  Start the PWM output signal generation on the designed timer output
02201   *         (The compare DMA request is enabled).
02202   * @param  hhrtim pointer to HAL HRTIM handle
02203   * @param  TimerIdx Timer index
02204   *                   This parameter can be one of the following values:
02205   *                   @arg HRTIM_TIMERINDEX_TIMER_A for timer A
02206   *                   @arg HRTIM_TIMERINDEX_TIMER_B for timer B
02207   *                   @arg HRTIM_TIMERINDEX_TIMER_C for timer C
02208   *                   @arg HRTIM_TIMERINDEX_TIMER_D for timer D
02209   *                   @arg HRTIM_TIMERINDEX_TIMER_E for timer E
02210   * @param  PWMChannel Timer output
02211   *                    This parameter can be one of the following values:
02212   *                    @arg HRTIM_OUTPUT_TA1: Timer A - Output 1
02213   *                    @arg HRTIM_OUTPUT_TA2: Timer A - Output 2
02214   *                    @arg HRTIM_OUTPUT_TB1: Timer B - Output 1
02215   *                    @arg HRTIM_OUTPUT_TB2: Timer B - Output 2
02216   *                    @arg HRTIM_OUTPUT_TC1: Timer C - Output 1
02217   *                    @arg HRTIM_OUTPUT_TC2: Timer C - Output 2
02218   *                    @arg HRTIM_OUTPUT_TD1: Timer D - Output 1
02219   *                    @arg HRTIM_OUTPUT_TD2: Timer D - Output 2
02220   *                    @arg HRTIM_OUTPUT_TE1: Timer E - Output 1
02221   *                    @arg HRTIM_OUTPUT_TE2: Timer E - Output 2
02222   * @param  SrcAddr DMA transfer source address
02223   * @param  DestAddr DMA transfer destination address
02224   * @param  Length The length of data items (data size) to be transferred
02225   *                     from source to destination
02226   * @retval HAL status
02227   */
02228 HAL_StatusTypeDef HAL_HRTIM_SimplePWMStart_DMA(HRTIM_HandleTypeDef * hhrtim,
02229                                               uint32_t TimerIdx,
02230                                               uint32_t PWMChannel,
02231                                               uint32_t SrcAddr,
02232                                               uint32_t DestAddr,
02233                                               uint32_t Length)
02234 {
02235   DMA_HandleTypeDef * hdma;
02236 
02237   /* Check the parameters */
02238   assert_param(IS_HRTIM_TIMER_OUTPUT(TimerIdx, PWMChannel));
02239 
02240   if(hhrtim->State == HAL_HRTIM_STATE_BUSY)
02241   {
02242      return HAL_BUSY;
02243   }
02244   if(hhrtim->State == HAL_HRTIM_STATE_READY)
02245   {
02246     if((SrcAddr == 0U ) || (DestAddr == 0U ) || (Length == 0U))
02247     {
02248       return HAL_ERROR;
02249     }
02250     else
02251     {
02252       hhrtim->State = HAL_HRTIM_STATE_BUSY;
02253     }
02254   }
02255 
02256   /* Process Locked */
02257   __HAL_LOCK(hhrtim);
02258 
02259   /* Enable the timer output */
02260   hhrtim->Instance->sCommonRegs.OENR |= PWMChannel;
02261 
02262   /* Get the timer DMA handler */
02263   hdma = HRTIM_GetDMAHandleFromTimerIdx(hhrtim, TimerIdx);
02264 
02265   if (hdma == NULL)
02266   {
02267     hhrtim->State = HAL_HRTIM_STATE_ERROR;
02268 
02269     /* Process Unlocked */
02270     __HAL_UNLOCK(hhrtim);
02271 
02272     return HAL_ERROR;
02273   }
02274 
02275   /* Set the DMA error callback */
02276   hdma->XferErrorCallback = HRTIM_DMAError ;
02277 
02278   /* Set the DMA transfer completed callback */
02279   hdma->XferCpltCallback = HRTIM_DMATimerxCplt;
02280 
02281   /* Enable the DMA channel */
02282   if (HAL_DMA_Start_IT(hdma, SrcAddr, DestAddr, Length) != HAL_OK)
02283     {
02284         hhrtim->State = HAL_HRTIM_STATE_ERROR;
02285 
02286         /* Process Unlocked */
02287         __HAL_UNLOCK(hhrtim);
02288 
02289         return HAL_ERROR;
02290     }
02291 
02292   /* Enable the timer DMA request */
02293   switch (PWMChannel)
02294   {
02295   case HRTIM_OUTPUT_TA1:
02296   case HRTIM_OUTPUT_TB1:
02297   case HRTIM_OUTPUT_TC1:
02298   case HRTIM_OUTPUT_TD1:
02299   case HRTIM_OUTPUT_TE1:
02300     {
02301       __HAL_HRTIM_TIMER_ENABLE_DMA(hhrtim, TimerIdx, HRTIM_TIM_DMA_CMP1);
02302       break;
02303     }
02304 
02305   case HRTIM_OUTPUT_TA2:
02306   case HRTIM_OUTPUT_TB2:
02307   case HRTIM_OUTPUT_TC2:
02308   case HRTIM_OUTPUT_TD2:
02309   case HRTIM_OUTPUT_TE2:
02310     {
02311       __HAL_HRTIM_TIMER_ENABLE_DMA(hhrtim, TimerIdx, HRTIM_TIM_DMA_CMP2);
02312       break;
02313     }
02314 
02315   default:
02316     {
02317       hhrtim->State = HAL_HRTIM_STATE_ERROR;
02318 
02319       /* Process Unlocked */
02320       __HAL_UNLOCK(hhrtim);
02321 
02322       break;
02323     }
02324   }
02325 
02326   if(hhrtim->State == HAL_HRTIM_STATE_ERROR)
02327   {
02328      return HAL_ERROR;
02329   }
02330 
02331   /* Enable the timer counter */
02332   __HAL_HRTIM_ENABLE(hhrtim, TimerIdxToTimerId[TimerIdx]);
02333 
02334   hhrtim->State = HAL_HRTIM_STATE_READY;
02335 
02336   /* Process Unlocked */
02337   __HAL_UNLOCK(hhrtim);
02338 
02339   return HAL_OK;
02340 }
02341 
02342 /**
02343   * @brief  Stop the PWM output signal generation on the designed timer output
02344   *         (The compare DMA request is disabled).
02345   * @param  hhrtim pointer to HAL HRTIM handle
02346   * @param  TimerIdx Timer index
02347   *                   This parameter can be one of the following values:
02348   *                   @arg HRTIM_TIMERINDEX_TIMER_A for timer A
02349   *                   @arg HRTIM_TIMERINDEX_TIMER_B for timer B
02350   *                   @arg HRTIM_TIMERINDEX_TIMER_C for timer C
02351   *                   @arg HRTIM_TIMERINDEX_TIMER_D for timer D
02352   *                   @arg HRTIM_TIMERINDEX_TIMER_E for timer E
02353   * @param  PWMChannel Timer output
02354   *                    This parameter can be one of the following values:
02355   *                    @arg HRTIM_OUTPUT_TA1: Timer A - Output 1
02356   *                    @arg HRTIM_OUTPUT_TA2: Timer A - Output 2
02357   *                    @arg HRTIM_OUTPUT_TB1: Timer B - Output 1
02358   *                    @arg HRTIM_OUTPUT_TB2: Timer B - Output 2
02359   *                    @arg HRTIM_OUTPUT_TC1: Timer C - Output 1
02360   *                    @arg HRTIM_OUTPUT_TC2: Timer C - Output 2
02361   *                    @arg HRTIM_OUTPUT_TD1: Timer D - Output 1
02362   *                    @arg HRTIM_OUTPUT_TD2: Timer D - Output 2
02363   *                    @arg HRTIM_OUTPUT_TE1: Timer E - Output 1
02364   *                    @arg HRTIM_OUTPUT_TE2: Timer E - Output 2
02365   * @retval HAL status
02366   */
02367 HAL_StatusTypeDef HAL_HRTIM_SimplePWMStop_DMA(HRTIM_HandleTypeDef * hhrtim,
02368                                              uint32_t TimerIdx,
02369                                              uint32_t PWMChannel)
02370 {
02371   /* Check the parameters */
02372   assert_param(IS_HRTIM_TIMER_OUTPUT(TimerIdx, PWMChannel));
02373 
02374   /* Process Locked */
02375   __HAL_LOCK(hhrtim);
02376 
02377   hhrtim->State = HAL_HRTIM_STATE_BUSY;
02378 
02379   /* Disable the timer output */
02380   hhrtim->Instance->sCommonRegs.ODISR |= PWMChannel;
02381 
02382   /* Get the timer DMA handler */
02383   /* Disable the DMA */
02384   if (HAL_DMA_Abort(HRTIM_GetDMAHandleFromTimerIdx(hhrtim, TimerIdx)) != HAL_OK)
02385   {
02386     hhrtim->State = HAL_HRTIM_STATE_ERROR;
02387 
02388     /* Process Unlocked */
02389     __HAL_UNLOCK(hhrtim);
02390 
02391     return HAL_ERROR;
02392   }
02393 
02394   /* Disable the timer DMA request */
02395   switch (PWMChannel)
02396   {
02397   case HRTIM_OUTPUT_TA1:
02398   case HRTIM_OUTPUT_TB1:
02399   case HRTIM_OUTPUT_TC1:
02400   case HRTIM_OUTPUT_TD1:
02401   case HRTIM_OUTPUT_TE1:
02402     {
02403       __HAL_HRTIM_TIMER_DISABLE_DMA(hhrtim, TimerIdx, HRTIM_TIM_DMA_CMP1);
02404       break;
02405     }
02406 
02407   case HRTIM_OUTPUT_TA2:
02408   case HRTIM_OUTPUT_TB2:
02409   case HRTIM_OUTPUT_TC2:
02410   case HRTIM_OUTPUT_TD2:
02411   case HRTIM_OUTPUT_TE2:
02412     {
02413       __HAL_HRTIM_TIMER_DISABLE_DMA(hhrtim, TimerIdx, HRTIM_TIM_DMA_CMP2);
02414       break;
02415     }
02416 
02417   default:
02418     {
02419       hhrtim->State = HAL_HRTIM_STATE_ERROR;
02420 
02421       /* Process Unlocked */
02422       __HAL_UNLOCK(hhrtim);
02423 
02424       break;
02425     }
02426   }
02427 
02428   if(hhrtim->State == HAL_HRTIM_STATE_ERROR)
02429   {
02430      return HAL_ERROR;
02431   }
02432 
02433   /* Disable the timer counter */
02434   __HAL_HRTIM_DISABLE(hhrtim, TimerIdxToTimerId[TimerIdx]);
02435 
02436   hhrtim->State = HAL_HRTIM_STATE_READY;
02437 
02438   /* Process Unlocked */
02439   __HAL_UNLOCK(hhrtim);
02440 
02441   return HAL_OK;
02442 }
02443 
02444 /**
02445   * @}
02446   */
02447 
02448 /** @defgroup HRTIM_Exported_Functions_Group5 Simple input capture functions
02449  *  @brief    Simple input capture functions
02450 @verbatim
02451  ===============================================================================
02452               ##### Simple input capture functions #####
02453  ===============================================================================
02454     [..]  This section provides functions allowing to:
02455       (+) Configure simple input capture channel
02456       (+) Start simple input capture
02457       (+) Stop simple input capture
02458       (+) Start simple input capture and enable interrupt
02459       (+) Stop simple input capture and disable interrupt
02460       (+) Start simple input capture and enable DMA transfer
02461       (+) Stop simple input capture and disable DMA transfer
02462       -@- When a HRTIM timer operates in simple input capture mode
02463           the Capture Register (HRTIM_CPT1/2xR) is used to latch the
02464          value of the timer counter counter after a transition detected
02465          on a given external event input.
02466 @endverbatim
02467   * @{
02468   */
02469 
02470 /**
02471   * @brief  Configure a simple capture
02472   * @param  hhrtim pointer to HAL HRTIM handle
02473   * @param  TimerIdx Timer index
02474   *                   This parameter can be one of the following values:
02475   *                   @arg HRTIM_TIMERINDEX_TIMER_A for timer A
02476   *                   @arg HRTIM_TIMERINDEX_TIMER_B for timer B
02477   *                   @arg HRTIM_TIMERINDEX_TIMER_C for timer C
02478   *                   @arg HRTIM_TIMERINDEX_TIMER_D for timer D
02479   *                   @arg HRTIM_TIMERINDEX_TIMER_E for timer E
02480   * @param  CaptureChannel Capture unit
02481   *                    This parameter can be one of the following values:
02482   *                    @arg HRTIM_CAPTUREUNIT_1: Capture unit 1
02483   *                    @arg HRTIM_CAPTUREUNIT_2: Capture unit 2
02484   * @param  pSimpleCaptureChannelCfg pointer to the simple capture configuration structure
02485   * @note When the timer operates in simple capture mode the capture is triggered
02486   *       by the designated external event and GPIO input is implicitly used as event source.
02487   *       The cature can be triggered by a rising edge, a falling edge or both
02488   *       edges on event channel.
02489   * @retval HAL status
02490   */
02491 HAL_StatusTypeDef HAL_HRTIM_SimpleCaptureChannelConfig(HRTIM_HandleTypeDef * hhrtim,
02492                                                       uint32_t TimerIdx,
02493                                                       uint32_t CaptureChannel,
02494                                                       HRTIM_SimpleCaptureChannelCfgTypeDef* pSimpleCaptureChannelCfg)
02495 {
02496   HRTIM_EventCfgTypeDef EventCfg;
02497 
02498   /* Check parameters */
02499   assert_param(IS_HRTIM_TIMING_UNIT(TimerIdx));
02500   assert_param(IS_HRTIM_CAPTUREUNIT(CaptureChannel));
02501   assert_param(IS_HRTIM_EVENT(pSimpleCaptureChannelCfg->Event));
02502   assert_param(IS_HRTIM_EVENTPOLARITY(pSimpleCaptureChannelCfg->EventSensitivity,
02503                                       pSimpleCaptureChannelCfg->EventPolarity));
02504   assert_param(IS_HRTIM_EVENTSENSITIVITY(pSimpleCaptureChannelCfg->EventSensitivity));
02505   assert_param(IS_HRTIM_EVENTFILTER(pSimpleCaptureChannelCfg->Event,
02506                                     pSimpleCaptureChannelCfg->EventFilter));
02507 
02508   if(hhrtim->State == HAL_HRTIM_STATE_BUSY)
02509   {
02510      return HAL_BUSY;
02511   }
02512 
02513   /* Process Locked */
02514   __HAL_LOCK(hhrtim);
02515 
02516   hhrtim->State = HAL_HRTIM_STATE_BUSY;
02517 
02518   /* Configure external event channel */
02519   EventCfg.FastMode = HRTIM_EVENTFASTMODE_DISABLE;
02520   EventCfg.Filter = (pSimpleCaptureChannelCfg->EventFilter & HRTIM_EECR3_EE6F);
02521   EventCfg.Polarity = (pSimpleCaptureChannelCfg->EventPolarity & HRTIM_EECR1_EE1POL);
02522   EventCfg.Sensitivity = (pSimpleCaptureChannelCfg->EventSensitivity & HRTIM_EECR1_EE1SNS);
02523   EventCfg.Source = HRTIM_EVENTSRC_1;
02524 
02525   HRTIM_EventConfig(hhrtim,
02526                     pSimpleCaptureChannelCfg->Event,
02527                     &EventCfg);
02528 
02529   /* Memorize capture trigger (will be configured when the capture is started */
02530   HRTIM_CaptureUnitConfig(hhrtim,
02531                           TimerIdx,
02532                           CaptureChannel,
02533                           pSimpleCaptureChannelCfg->Event);
02534 
02535   hhrtim->State = HAL_HRTIM_STATE_READY;
02536 
02537   /* Process Unlocked */
02538   __HAL_UNLOCK(hhrtim);
02539 
02540   return HAL_OK;
02541 }
02542 
02543 /**
02544   * @brief  Enable a simple capture on the designed capture unit
02545   * @param  hhrtim pointer to HAL HRTIM handle
02546   * @param  TimerIdx Timer index
02547   *                   This parameter can be one of the following values:
02548   *                   @arg HRTIM_TIMERINDEX_TIMER_A for timer A
02549   *                   @arg HRTIM_TIMERINDEX_TIMER_B for timer B
02550   *                   @arg HRTIM_TIMERINDEX_TIMER_C for timer C
02551   *                   @arg HRTIM_TIMERINDEX_TIMER_D for timer D
02552   *                   @arg HRTIM_TIMERINDEX_TIMER_E for timer E
02553   * @param  CaptureChannel Timer output
02554   *                    This parameter can be one of the following values:
02555   *                    @arg HRTIM_CAPTUREUNIT_1: Capture unit 1
02556   *                    @arg HRTIM_CAPTUREUNIT_2: Capture unit 2
02557   * @retval HAL status
02558   * @note  The external event triggering the capture is available for all timing
02559   *        units. It can be used directly and is active as soon as the timing
02560   *        unit counter is enabled.
02561   */
02562 HAL_StatusTypeDef HAL_HRTIM_SimpleCaptureStart(HRTIM_HandleTypeDef * hhrtim,
02563                                               uint32_t TimerIdx,
02564                                               uint32_t CaptureChannel)
02565 {
02566    /* Check the parameters */
02567   assert_param(IS_HRTIM_TIMING_UNIT(TimerIdx));
02568   assert_param(IS_HRTIM_CAPTUREUNIT(CaptureChannel));
02569 
02570   /* Process Locked */
02571   __HAL_LOCK(hhrtim);
02572 
02573   hhrtim->State = HAL_HRTIM_STATE_BUSY;
02574 
02575   /* Set the capture unit trigger */
02576   switch (CaptureChannel)
02577   {
02578   case HRTIM_CAPTUREUNIT_1:
02579     {
02580       hhrtim->Instance->sTimerxRegs[TimerIdx].CPT1xCR = hhrtim->TimerParam[TimerIdx].CaptureTrigger1;
02581       break;
02582     }
02583 
02584   case HRTIM_CAPTUREUNIT_2:
02585     {
02586       hhrtim->Instance->sTimerxRegs[TimerIdx].CPT2xCR = hhrtim->TimerParam[TimerIdx].CaptureTrigger2;
02587       break;
02588     }
02589 
02590   default:
02591     {
02592       hhrtim->State = HAL_HRTIM_STATE_ERROR;
02593 
02594       /* Process Unlocked */
02595       __HAL_UNLOCK(hhrtim);
02596 
02597       break;
02598     }
02599   }
02600 
02601   if(hhrtim->State == HAL_HRTIM_STATE_ERROR)
02602   {
02603      return HAL_ERROR;
02604   }
02605 
02606   /* Enable the timer counter */
02607   __HAL_HRTIM_ENABLE(hhrtim, TimerIdxToTimerId[TimerIdx]);
02608 
02609   hhrtim->State = HAL_HRTIM_STATE_READY;
02610 
02611   /* Process Unlocked */
02612   __HAL_UNLOCK(hhrtim);
02613 
02614   return HAL_OK;
02615 }
02616 
02617 /**
02618   * @brief  Disable a simple capture on the designed capture unit
02619   * @param  hhrtim pointer to HAL HRTIM handle
02620   * @param  TimerIdx Timer index
02621   *                   This parameter can be one of the following values:
02622   *                   @arg HRTIM_TIMERINDEX_TIMER_A for timer A
02623   *                   @arg HRTIM_TIMERINDEX_TIMER_B for timer B
02624   *                   @arg HRTIM_TIMERINDEX_TIMER_C for timer C
02625   *                   @arg HRTIM_TIMERINDEX_TIMER_D for timer D
02626   *                   @arg HRTIM_TIMERINDEX_TIMER_E for timer E
02627   * @param  CaptureChannel Timer output
02628   *                    This parameter can be one of the following values:
02629   *                    @arg HRTIM_CAPTUREUNIT_1: Capture unit 1
02630   *                    @arg HRTIM_CAPTUREUNIT_2: Capture unit 2
02631   * @retval HAL status
02632   */
02633 HAL_StatusTypeDef HAL_HRTIM_SimpleCaptureStop(HRTIM_HandleTypeDef * hhrtim,
02634                                              uint32_t TimerIdx,
02635                                              uint32_t CaptureChannel)
02636 {
02637   uint32_t hrtim_cpt1cr;
02638   uint32_t hrtim_cpt2cr;
02639 
02640    /* Check the parameters */
02641   assert_param(IS_HRTIM_TIMING_UNIT(TimerIdx));
02642   assert_param(IS_HRTIM_CAPTUREUNIT(CaptureChannel));
02643 
02644   /* Process Locked */
02645   __HAL_LOCK(hhrtim);
02646 
02647   hhrtim->State = HAL_HRTIM_STATE_BUSY;
02648 
02649   /* Set the capture unit trigger */
02650   switch (CaptureChannel)
02651   {
02652   case HRTIM_CAPTUREUNIT_1:
02653     {
02654       hhrtim->Instance->sTimerxRegs[TimerIdx].CPT1xCR = HRTIM_CAPTURETRIGGER_NONE;
02655       break;
02656     }
02657 
02658   case HRTIM_CAPTUREUNIT_2:
02659     {
02660       hhrtim->Instance->sTimerxRegs[TimerIdx].CPT2xCR = HRTIM_CAPTURETRIGGER_NONE;
02661       break;
02662     }
02663 
02664   default:
02665     {
02666       hhrtim->State = HAL_HRTIM_STATE_ERROR;
02667 
02668       /* Process Unlocked */
02669       __HAL_UNLOCK(hhrtim);
02670 
02671       break;
02672     }
02673   }
02674 
02675   if(hhrtim->State == HAL_HRTIM_STATE_ERROR)
02676   {
02677      return HAL_ERROR;
02678   }
02679 
02680   hrtim_cpt1cr = hhrtim->Instance->sTimerxRegs[TimerIdx].CPT1xCR;
02681   hrtim_cpt2cr = hhrtim->Instance->sTimerxRegs[TimerIdx].CPT2xCR;
02682 
02683   /* Disable the timer counter */
02684   if ((hrtim_cpt1cr == HRTIM_CAPTURETRIGGER_NONE) &&
02685       (hrtim_cpt2cr == HRTIM_CAPTURETRIGGER_NONE))
02686   {
02687     __HAL_HRTIM_DISABLE(hhrtim, TimerIdxToTimerId[TimerIdx]);
02688   }
02689 
02690   hhrtim->State = HAL_HRTIM_STATE_READY;
02691 
02692   /* Process Unlocked */
02693   __HAL_UNLOCK(hhrtim);
02694 
02695   return HAL_OK;
02696 }
02697 
02698 /**
02699   * @brief  Enable a simple capture on the designed capture unit
02700   *         (Capture interrupt is enabled).
02701   * @param  hhrtim pointer to HAL HRTIM handle
02702   * @param  TimerIdx Timer index
02703   *                   This parameter can be one of the following values:
02704   *                   @arg HRTIM_TIMERINDEX_TIMER_A for timer A
02705   *                   @arg HRTIM_TIMERINDEX_TIMER_B for timer B
02706   *                   @arg HRTIM_TIMERINDEX_TIMER_C for timer C
02707   *                   @arg HRTIM_TIMERINDEX_TIMER_D for timer D
02708   *                   @arg HRTIM_TIMERINDEX_TIMER_E for timer E
02709   * @param  CaptureChannel Timer output
02710   *                    This parameter can be one of the following values:
02711   *                    @arg HRTIM_CAPTUREUNIT_1: Capture unit 1
02712   *                    @arg HRTIM_CAPTUREUNIT_2: Capture unit 2
02713   * @retval HAL status
02714   */
02715 HAL_StatusTypeDef HAL_HRTIM_SimpleCaptureStart_IT(HRTIM_HandleTypeDef * hhrtim,
02716                                                  uint32_t TimerIdx,
02717                                                  uint32_t CaptureChannel)
02718 {
02719    /* Check the parameters */
02720   assert_param(IS_HRTIM_TIMING_UNIT(TimerIdx));
02721   assert_param(IS_HRTIM_CAPTUREUNIT(CaptureChannel));
02722 
02723   /* Process Locked */
02724   __HAL_LOCK(hhrtim);
02725 
02726   hhrtim->State = HAL_HRTIM_STATE_BUSY;
02727 
02728   /* Set the capture unit trigger */
02729   switch (CaptureChannel)
02730   {
02731   case HRTIM_CAPTUREUNIT_1:
02732     {
02733       hhrtim->Instance->sTimerxRegs[TimerIdx].CPT1xCR = hhrtim->TimerParam[TimerIdx].CaptureTrigger1;
02734 
02735       /* Enable the capture unit 1 interrupt */
02736       __HAL_HRTIM_TIMER_ENABLE_IT(hhrtim, TimerIdx, HRTIM_TIM_IT_CPT1);
02737       break;
02738     }
02739 
02740   case HRTIM_CAPTUREUNIT_2:
02741     {
02742       hhrtim->Instance->sTimerxRegs[TimerIdx].CPT2xCR = hhrtim->TimerParam[TimerIdx].CaptureTrigger2;
02743 
02744       /* Enable the capture unit 2 interrupt */
02745       __HAL_HRTIM_TIMER_ENABLE_IT(hhrtim, TimerIdx, HRTIM_TIM_IT_CPT2);
02746       break;
02747     }
02748 
02749   default:
02750     {
02751       hhrtim->State = HAL_HRTIM_STATE_ERROR;
02752 
02753       /* Process Unlocked */
02754       __HAL_UNLOCK(hhrtim);
02755 
02756       break;
02757     }
02758   }
02759 
02760   if(hhrtim->State == HAL_HRTIM_STATE_ERROR)
02761   {
02762      return HAL_ERROR;
02763   }
02764 
02765   /* Enable the timer counter */
02766   __HAL_HRTIM_ENABLE(hhrtim, TimerIdxToTimerId[TimerIdx]);
02767 
02768   hhrtim->State = HAL_HRTIM_STATE_READY;
02769 
02770   /* Process Unlocked */
02771   __HAL_UNLOCK(hhrtim);
02772 
02773   return HAL_OK;
02774 }
02775 
02776 /**
02777   * @brief  Disable a simple capture on the designed capture unit
02778   *         (Capture interrupt is disabled).
02779   * @param  hhrtim pointer to HAL HRTIM handle
02780   * @param  TimerIdx Timer index
02781   *                   This parameter can be one of the following values:
02782   *                   @arg HRTIM_TIMERINDEX_TIMER_A for timer A
02783   *                   @arg HRTIM_TIMERINDEX_TIMER_B for timer B
02784   *                   @arg HRTIM_TIMERINDEX_TIMER_C for timer C
02785   *                   @arg HRTIM_TIMERINDEX_TIMER_D for timer D
02786   *                   @arg HRTIM_TIMERINDEX_TIMER_E for timer E
02787   * @param  CaptureChannel Timer output
02788   *                    This parameter can be one of the following values:
02789   *                    @arg HRTIM_CAPTUREUNIT_1: Capture unit 1
02790   *                    @arg HRTIM_CAPTUREUNIT_2: Capture unit 2
02791   * @retval HAL status
02792   */
02793 HAL_StatusTypeDef HAL_HRTIM_SimpleCaptureStop_IT(HRTIM_HandleTypeDef * hhrtim,
02794                                                 uint32_t TimerIdx,
02795                                                 uint32_t CaptureChannel)
02796 {
02797 
02798   uint32_t hrtim_cpt1cr;
02799   uint32_t hrtim_cpt2cr;
02800 
02801    /* Check the parameters */
02802   assert_param(IS_HRTIM_TIMING_UNIT(TimerIdx));
02803   assert_param(IS_HRTIM_CAPTUREUNIT(CaptureChannel));
02804 
02805   /* Process Locked */
02806   __HAL_LOCK(hhrtim);
02807 
02808   hhrtim->State = HAL_HRTIM_STATE_BUSY;
02809 
02810   /* Set the capture unit trigger */
02811   switch (CaptureChannel)
02812   {
02813   case HRTIM_CAPTUREUNIT_1:
02814     {
02815       hhrtim->Instance->sTimerxRegs[TimerIdx].CPT1xCR = HRTIM_CAPTURETRIGGER_NONE;
02816 
02817       /* Disable the capture unit 1 interrupt */
02818       __HAL_HRTIM_TIMER_DISABLE_IT(hhrtim, TimerIdx, HRTIM_TIM_IT_CPT1);
02819       break;
02820     }
02821 
02822   case HRTIM_CAPTUREUNIT_2:
02823     {
02824       hhrtim->Instance->sTimerxRegs[TimerIdx].CPT2xCR = HRTIM_CAPTURETRIGGER_NONE;
02825 
02826       /* Disable the capture unit 2 interrupt */
02827       __HAL_HRTIM_TIMER_DISABLE_IT(hhrtim, TimerIdx, HRTIM_TIM_IT_CPT2);
02828       break;
02829     }
02830 
02831   default:
02832     {
02833       hhrtim->State = HAL_HRTIM_STATE_ERROR;
02834 
02835       /* Process Unlocked */
02836       __HAL_UNLOCK(hhrtim);
02837 
02838       break;
02839     }
02840   }
02841 
02842   if(hhrtim->State == HAL_HRTIM_STATE_ERROR)
02843   {
02844      return HAL_ERROR;
02845   }
02846 
02847   hrtim_cpt1cr = hhrtim->Instance->sTimerxRegs[TimerIdx].CPT1xCR;
02848   hrtim_cpt2cr = hhrtim->Instance->sTimerxRegs[TimerIdx].CPT2xCR;
02849 
02850   /* Disable the timer counter */
02851   if ((hrtim_cpt1cr == HRTIM_CAPTURETRIGGER_NONE) &&
02852       (hrtim_cpt2cr == HRTIM_CAPTURETRIGGER_NONE))
02853   {
02854     __HAL_HRTIM_DISABLE(hhrtim, TimerIdxToTimerId[TimerIdx]);
02855   }
02856 
02857   hhrtim->State = HAL_HRTIM_STATE_READY;
02858 
02859   /* Process Unlocked */
02860   __HAL_UNLOCK(hhrtim);
02861 
02862   return HAL_OK;
02863 }
02864 
02865 /**
02866   * @brief  Enable a simple capture on the designed capture unit
02867   *         (Capture DMA request is enabled).
02868   * @param  hhrtim pointer to HAL HRTIM handle
02869   * @param  TimerIdx Timer index
02870   *                   This parameter can be one of the following values:
02871   *                   @arg HRTIM_TIMERINDEX_TIMER_A for timer A
02872   *                   @arg HRTIM_TIMERINDEX_TIMER_B for timer B
02873   *                   @arg HRTIM_TIMERINDEX_TIMER_C for timer C
02874   *                   @arg HRTIM_TIMERINDEX_TIMER_D for timer D
02875   *                   @arg HRTIM_TIMERINDEX_TIMER_E for timer E
02876   * @param  CaptureChannel Timer output
02877   *                    This parameter can be one of the following values:
02878   *                    @arg HRTIM_CAPTUREUNIT_1: Capture unit 1
02879   *                    @arg HRTIM_CAPTUREUNIT_2: Capture unit 2
02880   * @param  SrcAddr DMA transfer source address
02881   * @param  DestAddr DMA transfer destination address
02882   * @param  Length The length of data items (data size) to be transferred
02883   *                     from source to destination
02884   * @retval HAL status
02885   */
02886 HAL_StatusTypeDef HAL_HRTIM_SimpleCaptureStart_DMA(HRTIM_HandleTypeDef * hhrtim,
02887                                                   uint32_t TimerIdx,
02888                                                   uint32_t CaptureChannel,
02889                                                   uint32_t SrcAddr,
02890                                                   uint32_t DestAddr,
02891                                                   uint32_t Length)
02892 {
02893   DMA_HandleTypeDef * hdma;
02894 
02895    /* Check the parameters */
02896   assert_param(IS_HRTIM_TIMING_UNIT(TimerIdx));
02897   assert_param(IS_HRTIM_CAPTUREUNIT(CaptureChannel));
02898 
02899   /* Process Locked */
02900   __HAL_LOCK(hhrtim);
02901 
02902   hhrtim->State = HAL_HRTIM_STATE_BUSY;
02903 
02904   /* Get the timer DMA handler */
02905   hdma = HRTIM_GetDMAHandleFromTimerIdx(hhrtim, TimerIdx);
02906 
02907   if (hdma == NULL)
02908   {
02909    hhrtim->State = HAL_HRTIM_STATE_ERROR;
02910 
02911    /* Process Unlocked */
02912    __HAL_UNLOCK(hhrtim);
02913 
02914    return HAL_ERROR;
02915   }
02916 
02917   /* Set the DMA error callback */
02918   hdma->XferErrorCallback = HRTIM_DMAError ;
02919 
02920   /* Set the DMA transfer completed callback */
02921   hdma->XferCpltCallback = HRTIM_DMATimerxCplt;
02922 
02923   /* Enable the DMA channel */
02924   if (HAL_DMA_Start_IT(hdma, SrcAddr, DestAddr, Length) != HAL_OK)
02925     {
02926         hhrtim->State = HAL_HRTIM_STATE_ERROR;
02927 
02928         /* Process Unlocked */
02929         __HAL_UNLOCK(hhrtim);
02930 
02931         return HAL_ERROR;
02932     }
02933 
02934   switch (CaptureChannel)
02935   {
02936   case HRTIM_CAPTUREUNIT_1:
02937     {
02938       /* Set the capture unit trigger */
02939       hhrtim->Instance->sTimerxRegs[TimerIdx].CPT1xCR = hhrtim->TimerParam[TimerIdx].CaptureTrigger1;
02940 
02941       __HAL_HRTIM_TIMER_ENABLE_DMA(hhrtim, TimerIdx, HRTIM_TIM_DMA_CPT1);
02942       break;
02943     }
02944 
02945   case HRTIM_CAPTUREUNIT_2:
02946     {
02947       /* Set the capture unit trigger */
02948       hhrtim->Instance->sTimerxRegs[TimerIdx].CPT2xCR = hhrtim->TimerParam[TimerIdx].CaptureTrigger2;
02949 
02950       /* Enable the timer DMA request */
02951       __HAL_HRTIM_TIMER_ENABLE_DMA(hhrtim, TimerIdx, HRTIM_TIM_DMA_CPT2);
02952       break;
02953     }
02954 
02955   default:
02956     {
02957       hhrtim->State = HAL_HRTIM_STATE_ERROR;
02958 
02959       /* Process Unlocked */
02960       __HAL_UNLOCK(hhrtim);
02961 
02962       break;
02963     }
02964  }
02965 
02966  if(hhrtim->State == HAL_HRTIM_STATE_ERROR)
02967   {
02968      return HAL_ERROR;
02969   }
02970 
02971   /* Enable the timer counter */
02972   __HAL_HRTIM_ENABLE(hhrtim, TimerIdxToTimerId[TimerIdx]);
02973 
02974   hhrtim->State = HAL_HRTIM_STATE_READY;
02975 
02976   /* Process Unlocked */
02977   __HAL_UNLOCK(hhrtim);
02978 
02979   return HAL_OK;
02980 }
02981 
02982 /**
02983   * @brief  Disable a simple capture on the designed capture unit
02984   *         (Capture DMA request is disabled).
02985   * @param  hhrtim pointer to HAL HRTIM handle
02986   * @param  TimerIdx Timer index
02987   *                   This parameter can be one of the following values:
02988   *                   @arg HRTIM_TIMERINDEX_TIMER_A for timer A
02989   *                   @arg HRTIM_TIMERINDEX_TIMER_B for timer B
02990   *                   @arg HRTIM_TIMERINDEX_TIMER_C for timer C
02991   *                   @arg HRTIM_TIMERINDEX_TIMER_D for timer D
02992   *                   @arg HRTIM_TIMERINDEX_TIMER_E for timer E
02993   * @param  CaptureChannel Timer output
02994   *                    This parameter can be one of the following values:
02995   *                    @arg HRTIM_CAPTUREUNIT_1: Capture unit 1
02996   *                    @arg HRTIM_CAPTUREUNIT_2: Capture unit 2
02997   * @retval HAL status
02998   */
02999 HAL_StatusTypeDef HAL_HRTIM_SimpleCaptureStop_DMA(HRTIM_HandleTypeDef * hhrtim,
03000                                                  uint32_t TimerIdx,
03001                                                  uint32_t CaptureChannel)
03002 {
03003 
03004   uint32_t hrtim_cpt1cr;
03005   uint32_t hrtim_cpt2cr;
03006 
03007   /* Check the parameters */
03008   assert_param(IS_HRTIM_TIMING_UNIT(TimerIdx));
03009   assert_param(IS_HRTIM_CAPTUREUNIT(CaptureChannel));
03010 
03011   /* Process Locked */
03012   __HAL_LOCK(hhrtim);
03013 
03014   hhrtim->State = HAL_HRTIM_STATE_BUSY;
03015 
03016   /* Get the timer DMA handler */
03017   /* Disable the DMA */
03018   if (HAL_DMA_Abort(HRTIM_GetDMAHandleFromTimerIdx(hhrtim, TimerIdx)) != HAL_OK)
03019   {
03020         hhrtim->State = HAL_HRTIM_STATE_ERROR;
03021 
03022         /* Process Unlocked */
03023         __HAL_UNLOCK(hhrtim);
03024 
03025         return HAL_ERROR;
03026   }
03027 
03028   switch (CaptureChannel)
03029   {
03030   case HRTIM_CAPTUREUNIT_1:
03031     {
03032       /* Reset the capture unit trigger */
03033       hhrtim->Instance->sTimerxRegs[TimerIdx].CPT1xCR = HRTIM_CAPTURETRIGGER_NONE;
03034 
03035       /* Disable the capture unit 1 DMA request */
03036       __HAL_HRTIM_TIMER_DISABLE_DMA(hhrtim, TimerIdx, HRTIM_TIM_DMA_CPT1);
03037       break;
03038     }
03039 
03040   case HRTIM_CAPTUREUNIT_2:
03041     {
03042       /* Reset the capture unit trigger */
03043       hhrtim->Instance->sTimerxRegs[TimerIdx].CPT2xCR = HRTIM_CAPTURETRIGGER_NONE;
03044 
03045       /* Disable the capture unit 2 DMA request */
03046       __HAL_HRTIM_TIMER_DISABLE_DMA(hhrtim, TimerIdx, HRTIM_TIM_DMA_CPT2);
03047       break;
03048     }
03049 
03050   default:
03051     {
03052       hhrtim->State = HAL_HRTIM_STATE_ERROR;
03053 
03054       /* Process Unlocked */
03055       __HAL_UNLOCK(hhrtim);
03056 
03057       break;
03058     }
03059   }
03060 
03061   if(hhrtim->State == HAL_HRTIM_STATE_ERROR)
03062   {
03063      return HAL_ERROR;
03064   }
03065 
03066   hrtim_cpt1cr = hhrtim->Instance->sTimerxRegs[TimerIdx].CPT1xCR;
03067   hrtim_cpt2cr = hhrtim->Instance->sTimerxRegs[TimerIdx].CPT2xCR;
03068 
03069   /* Disable the timer counter */
03070   if ((hrtim_cpt1cr == HRTIM_CAPTURETRIGGER_NONE) &&
03071       (hrtim_cpt2cr == HRTIM_CAPTURETRIGGER_NONE))
03072   {
03073     __HAL_HRTIM_DISABLE(hhrtim, TimerIdxToTimerId[TimerIdx]);
03074   }
03075 
03076   hhrtim->State = HAL_HRTIM_STATE_READY;
03077 
03078   /* Process Unlocked */
03079   __HAL_UNLOCK(hhrtim);
03080 
03081   return HAL_OK;
03082 }
03083 
03084 /**
03085   * @}
03086   */
03087 
03088 /** @defgroup HRTIM_Exported_Functions_Group6 Simple one pulse functions
03089  *  @brief    Simple one pulse functions
03090 @verbatim
03091  ===============================================================================
03092               ##### Simple one pulse functions #####
03093  ===============================================================================
03094     [..]  This section provides functions allowing to:
03095       (+) Configure one pulse channel
03096       (+) Start one pulse generation
03097       (+) Stop one pulse generation
03098       (+) Start one pulse generation and enable interrupt
03099       (+) Stop one pulse generation and disable interrupt
03100       -@- When a HRTIM timer operates in simple one pulse mode
03101           the timer counter is started in response to transition detected
03102           on a given external event input to generate a pulse with a
03103           programmable length after a programmable delay.
03104 @endverbatim
03105   * @{
03106   */
03107 
03108 /**
03109   * @brief  Configure an output simple one pulse mode
03110   * @param  hhrtim pointer to HAL HRTIM handle
03111   * @param  TimerIdx Timer index
03112   *                   This parameter can be one of the following values:
03113   *                   @arg HRTIM_TIMERINDEX_TIMER_A for timer A
03114   *                   @arg HRTIM_TIMERINDEX_TIMER_B for timer B
03115   *                   @arg HRTIM_TIMERINDEX_TIMER_C for timer C
03116   *                   @arg HRTIM_TIMERINDEX_TIMER_D for timer D
03117   *                   @arg HRTIM_TIMERINDEX_TIMER_E for timer E
03118   * @param  OnePulseChannel Timer output
03119   *                    This parameter can be one of the following values:
03120   *                    @arg HRTIM_OUTPUT_TA1: Timer A - Output 1
03121   *                    @arg HRTIM_OUTPUT_TA2: Timer A - Output 2
03122   *                    @arg HRTIM_OUTPUT_TB1: Timer B - Output 1
03123   *                    @arg HRTIM_OUTPUT_TB2: Timer B - Output 2
03124   *                    @arg HRTIM_OUTPUT_TC1: Timer C - Output 1
03125   *                    @arg HRTIM_OUTPUT_TC2: Timer C - Output 2
03126   *                    @arg HRTIM_OUTPUT_TD1: Timer D - Output 1
03127   *                    @arg HRTIM_OUTPUT_TD2: Timer D - Output 2
03128   *                    @arg HRTIM_OUTPUT_TE1: Timer E - Output 1
03129   *                    @arg HRTIM_OUTPUT_TE2: Timer E - Output 2
03130   * @param  pSimpleOnePulseChannelCfg pointer to the simple one pulse output configuration structure
03131   * @note When the timer operates in simple one pulse mode:
03132   *         the timer counter is implicitly started by the reset event,
03133   *         the reset of the timer counter is triggered by the designated external event
03134   *         GPIO input is implicitly used as event source,
03135   *         Output 1 is implicitly controlled by the compare unit 1,
03136   *         Output 2 is implicitly controlled by the compare unit 2.
03137   *       Output Set/Reset crossbar is set as follows:
03138   *         Output 1: SETx1R = CMP1, RSTx1R = PER
03139   *         Output 2: SETx2R = CMP2, RST2R = PER
03140   * @retval HAL status
03141   * @note If HAL_HRTIM_SimpleOnePulseChannelConfig is called for both timer
03142   *       outputs, the reset event related configuration data provided in the
03143   *       second call will override the reset event related configuration data
03144   *       provided in the first call.
03145   */
03146 HAL_StatusTypeDef HAL_HRTIM_SimpleOnePulseChannelConfig(HRTIM_HandleTypeDef * hhrtim,
03147                                                        uint32_t TimerIdx,
03148                                                        uint32_t OnePulseChannel,
03149                                                        HRTIM_SimpleOnePulseChannelCfgTypeDef* pSimpleOnePulseChannelCfg)
03150 {
03151   HRTIM_OutputCfgTypeDef OutputCfg;
03152   HRTIM_EventCfgTypeDef EventCfg;
03153 
03154   /* Check parameters */
03155   assert_param(IS_HRTIM_TIMER_OUTPUT(TimerIdx, OnePulseChannel));
03156   assert_param(IS_HRTIM_OUTPUTPULSE(pSimpleOnePulseChannelCfg->Pulse));
03157   assert_param(IS_HRTIM_OUTPUTPOLARITY(pSimpleOnePulseChannelCfg->OutputPolarity));
03158   assert_param(IS_HRTIM_OUTPUTIDLELEVEL(pSimpleOnePulseChannelCfg->OutputIdleLevel));
03159   assert_param(IS_HRTIM_EVENT(pSimpleOnePulseChannelCfg->Event));
03160   assert_param(IS_HRTIM_EVENTPOLARITY(pSimpleOnePulseChannelCfg->EventSensitivity,
03161                                       pSimpleOnePulseChannelCfg->EventPolarity));
03162   assert_param(IS_HRTIM_EVENTSENSITIVITY(pSimpleOnePulseChannelCfg->EventSensitivity));
03163   assert_param(IS_HRTIM_EVENTFILTER(pSimpleOnePulseChannelCfg->Event,
03164                                     pSimpleOnePulseChannelCfg->EventFilter));
03165 
03166   if(hhrtim->State == HAL_HRTIM_STATE_BUSY)
03167   {
03168      return HAL_BUSY;
03169   }
03170 
03171   /* Process Locked */
03172   __HAL_LOCK(hhrtim);
03173 
03174   hhrtim->State = HAL_HRTIM_STATE_BUSY;
03175 
03176   /* Configure timer compare unit */
03177   switch (OnePulseChannel)
03178   {
03179   case HRTIM_OUTPUT_TA1:
03180   case HRTIM_OUTPUT_TB1:
03181   case HRTIM_OUTPUT_TC1:
03182   case HRTIM_OUTPUT_TD1:
03183   case HRTIM_OUTPUT_TE1:
03184     {
03185       hhrtim->Instance->sTimerxRegs[TimerIdx].CMP1xR = pSimpleOnePulseChannelCfg->Pulse;
03186       OutputCfg.SetSource = HRTIM_OUTPUTSET_TIMCMP1;
03187       break;
03188     }
03189 
03190   case HRTIM_OUTPUT_TA2:
03191   case HRTIM_OUTPUT_TB2:
03192   case HRTIM_OUTPUT_TC2:
03193   case HRTIM_OUTPUT_TD2:
03194   case HRTIM_OUTPUT_TE2:
03195     {
03196       hhrtim->Instance->sTimerxRegs[TimerIdx].CMP2xR = pSimpleOnePulseChannelCfg->Pulse;
03197       OutputCfg.SetSource = HRTIM_OUTPUTSET_TIMCMP2;
03198       break;
03199     }
03200 
03201   default:
03202     {
03203       OutputCfg.SetSource = HRTIM_OUTPUTSET_NONE;
03204       OutputCfg.ResetSource = HRTIM_OUTPUTRESET_NONE;
03205 
03206       hhrtim->State = HAL_HRTIM_STATE_ERROR;
03207 
03208       /* Process Unlocked */
03209       __HAL_UNLOCK(hhrtim);
03210 
03211       break;
03212     }
03213   }
03214 
03215   if(hhrtim->State == HAL_HRTIM_STATE_ERROR)
03216   {
03217      return HAL_ERROR;
03218   }
03219 
03220   /* Configure timer output */
03221   OutputCfg.Polarity =  (pSimpleOnePulseChannelCfg->OutputPolarity & HRTIM_OUTR_POL1);
03222   OutputCfg.IdleLevel = (pSimpleOnePulseChannelCfg->OutputIdleLevel & HRTIM_OUTR_IDLES1);
03223   OutputCfg.FaultLevel = HRTIM_OUTPUTFAULTLEVEL_NONE;
03224   OutputCfg.IdleMode = HRTIM_OUTPUTIDLEMODE_NONE;
03225   OutputCfg.ChopperModeEnable = HRTIM_OUTPUTCHOPPERMODE_DISABLED;
03226   OutputCfg.BurstModeEntryDelayed = HRTIM_OUTPUTBURSTMODEENTRY_REGULAR;
03227   OutputCfg.ResetSource = HRTIM_OUTPUTRESET_TIMPER;
03228 
03229   HRTIM_OutputConfig(hhrtim,
03230                      TimerIdx,
03231                      OnePulseChannel,
03232                      &OutputCfg);
03233 
03234   /* Configure external event channel */
03235   EventCfg.FastMode = HRTIM_EVENTFASTMODE_DISABLE;
03236   EventCfg.Filter = (pSimpleOnePulseChannelCfg->EventFilter & HRTIM_EECR3_EE6F);
03237   EventCfg.Polarity = (pSimpleOnePulseChannelCfg->EventPolarity & HRTIM_OUTR_POL1);
03238   EventCfg.Sensitivity = (pSimpleOnePulseChannelCfg->EventSensitivity &HRTIM_EECR1_EE1SNS);
03239   EventCfg.Source = HRTIM_EVENTSRC_1;
03240 
03241   HRTIM_EventConfig(hhrtim,
03242                     pSimpleOnePulseChannelCfg->Event,
03243                     &EventCfg);
03244 
03245   /* Configure the timer reset register */
03246   HRTIM_TIM_ResetConfig(hhrtim,
03247                         TimerIdx,
03248                         pSimpleOnePulseChannelCfg->Event);
03249 
03250   hhrtim->State = HAL_HRTIM_STATE_READY;
03251 
03252   /* Process Unlocked */
03253   __HAL_UNLOCK(hhrtim);
03254 
03255   return HAL_OK;
03256 }
03257 
03258 /**
03259   * @brief  Enable the simple one pulse signal generation on the designed output
03260   * @param  hhrtim pointer to HAL HRTIM handle
03261   * @param  TimerIdx Timer index
03262   *                   This parameter can be one of the following values:
03263   *                   @arg HRTIM_TIMERINDEX_TIMER_A for timer A
03264   *                   @arg HRTIM_TIMERINDEX_TIMER_B for timer B
03265   *                   @arg HRTIM_TIMERINDEX_TIMER_C for timer C
03266   *                   @arg HRTIM_TIMERINDEX_TIMER_D for timer D
03267   *                   @arg HRTIM_TIMERINDEX_TIMER_E for timer E
03268   * @param  OnePulseChannel Timer output
03269   *                    This parameter can be one of the following values:
03270   *                    @arg HRTIM_OUTPUT_TA1: Timer A - Output 1
03271   *                    @arg HRTIM_OUTPUT_TA2: Timer A - Output 2
03272   *                    @arg HRTIM_OUTPUT_TB1: Timer B - Output 1
03273   *                    @arg HRTIM_OUTPUT_TB2: Timer B - Output 2
03274   *                    @arg HRTIM_OUTPUT_TC1: Timer C - Output 1
03275   *                    @arg HRTIM_OUTPUT_TC2: Timer C - Output 2
03276   *                    @arg HRTIM_OUTPUT_TD1: Timer D - Output 1
03277   *                    @arg HRTIM_OUTPUT_TD2: Timer D - Output 2
03278   *                    @arg HRTIM_OUTPUT_TE1: Timer E - Output 1
03279   *                    @arg HRTIM_OUTPUT_TE2: Timer E - Output 2
03280   * @retval HAL status
03281   */
03282 HAL_StatusTypeDef HAL_HRTIM_SimpleOnePulseStart(HRTIM_HandleTypeDef * hhrtim,
03283                                                 uint32_t TimerIdx,
03284                                                 uint32_t OnePulseChannel)
03285 {
03286   /* Check the parameters */
03287   assert_param(IS_HRTIM_TIMER_OUTPUT(TimerIdx, OnePulseChannel));
03288 
03289   /* Process Locked */
03290   __HAL_LOCK(hhrtim);
03291 
03292   hhrtim->State = HAL_HRTIM_STATE_BUSY;
03293 
03294   /* Enable the timer output */
03295   hhrtim->Instance->sCommonRegs.OENR |= OnePulseChannel;
03296 
03297   /* Enable the timer counter */
03298   __HAL_HRTIM_ENABLE(hhrtim, TimerIdxToTimerId[TimerIdx]);
03299 
03300   hhrtim->State = HAL_HRTIM_STATE_READY;
03301 
03302   /* Process Unlocked */
03303   __HAL_UNLOCK(hhrtim);
03304 
03305   return HAL_OK;
03306 }
03307 
03308 /**
03309   * @brief  Disable the simple one pulse signal generation on the designed output
03310   * @param  hhrtim pointer to HAL HRTIM handle
03311   * @param  TimerIdx Timer index
03312   *                   This parameter can be one of the following values:
03313   *                   @arg HRTIM_TIMERINDEX_TIMER_A for timer A
03314   *                   @arg HRTIM_TIMERINDEX_TIMER_B for timer B
03315   *                   @arg HRTIM_TIMERINDEX_TIMER_C for timer C
03316   *                   @arg HRTIM_TIMERINDEX_TIMER_D for timer D
03317   *                   @arg HRTIM_TIMERINDEX_TIMER_E for timer E
03318   * @param  OnePulseChannel Timer output
03319   *                    This parameter can be one of the following values:
03320   *                    @arg HRTIM_OUTPUT_TA1: Timer A - Output 1
03321   *                    @arg HRTIM_OUTPUT_TA2: Timer A - Output 2
03322   *                    @arg HRTIM_OUTPUT_TB1: Timer B - Output 1
03323   *                    @arg HRTIM_OUTPUT_TB2: Timer B - Output 2
03324   *                    @arg HRTIM_OUTPUT_TC1: Timer C - Output 1
03325   *                    @arg HRTIM_OUTPUT_TC2: Timer C - Output 2
03326   *                    @arg HRTIM_OUTPUT_TD1: Timer D - Output 1
03327   *                    @arg HRTIM_OUTPUT_TD2: Timer D - Output 2
03328   *                    @arg HRTIM_OUTPUT_TE1: Timer E - Output 1
03329   *                    @arg HRTIM_OUTPUT_TE2: Timer E - Output 2
03330   * @retval HAL status
03331   */
03332 HAL_StatusTypeDef HAL_HRTIM_SimpleOnePulseStop(HRTIM_HandleTypeDef * hhrtim,
03333                                               uint32_t TimerIdx,
03334                                               uint32_t OnePulseChannel)
03335 {
03336   /* Check the parameters */
03337   assert_param(IS_HRTIM_TIMER_OUTPUT(TimerIdx, OnePulseChannel));
03338 
03339   /* Process Locked */
03340   __HAL_LOCK(hhrtim);
03341 
03342   hhrtim->State = HAL_HRTIM_STATE_BUSY;
03343 
03344   /* Disable the timer output */
03345   hhrtim->Instance->sCommonRegs.ODISR |= OnePulseChannel;
03346 
03347   /* Disable the timer counter */
03348   __HAL_HRTIM_DISABLE(hhrtim, TimerIdxToTimerId[TimerIdx]);
03349 
03350   hhrtim->State = HAL_HRTIM_STATE_READY;
03351 
03352   /* Process Unlocked */
03353   __HAL_UNLOCK(hhrtim);
03354 
03355   return HAL_OK;
03356 }
03357 
03358 /**
03359   * @brief  Enable the simple one pulse signal generation on the designed output
03360   *         (The compare interrupt is enabled (pulse start)).
03361   * @param  hhrtim pointer to HAL HRTIM handle
03362   * @param  TimerIdx Timer index
03363   *                   This parameter can be one of the following values:
03364   *                   @arg HRTIM_TIMERINDEX_TIMER_A for timer A
03365   *                   @arg HRTIM_TIMERINDEX_TIMER_B for timer B
03366   *                   @arg HRTIM_TIMERINDEX_TIMER_C for timer C
03367   *                   @arg HRTIM_TIMERINDEX_TIMER_D for timer D
03368   *                   @arg HRTIM_TIMERINDEX_TIMER_E for timer E
03369   * @param  OnePulseChannel Timer output
03370   *                    This parameter can be one of the following values:
03371   *                    @arg HRTIM_OUTPUT_TA1: Timer A - Output 1
03372   *                    @arg HRTIM_OUTPUT_TA2: Timer A - Output 2
03373   *                    @arg HRTIM_OUTPUT_TB1: Timer B - Output 1
03374   *                    @arg HRTIM_OUTPUT_TB2: Timer B - Output 2
03375   *                    @arg HRTIM_OUTPUT_TC1: Timer C - Output 1
03376   *                    @arg HRTIM_OUTPUT_TC2: Timer C - Output 2
03377   *                    @arg HRTIM_OUTPUT_TD1: Timer D - Output 1
03378   *                    @arg HRTIM_OUTPUT_TD2: Timer D - Output 2
03379   *                    @arg HRTIM_OUTPUT_TE1: Timer E - Output 1
03380   *                    @arg HRTIM_OUTPUT_TE2: Timer E - Output 2
03381   * @retval HAL status
03382   */
03383 HAL_StatusTypeDef HAL_HRTIM_SimpleOnePulseStart_IT(HRTIM_HandleTypeDef * hhrtim,
03384                                                   uint32_t TimerIdx,
03385                                                   uint32_t OnePulseChannel)
03386 {
03387   /* Check the parameters */
03388   assert_param(IS_HRTIM_TIMER_OUTPUT(TimerIdx, OnePulseChannel));
03389 
03390   /* Process Locked */
03391   __HAL_LOCK(hhrtim);
03392 
03393   hhrtim->State = HAL_HRTIM_STATE_BUSY;
03394 
03395   /* Enable the timer output */
03396   hhrtim->Instance->sCommonRegs.OENR |= OnePulseChannel;
03397 
03398   /* Enable the timer interrupt (depends on the OnePulse output) */
03399   switch (OnePulseChannel)
03400   {
03401   case HRTIM_OUTPUT_TA1:
03402   case HRTIM_OUTPUT_TB1:
03403   case HRTIM_OUTPUT_TC1:
03404   case HRTIM_OUTPUT_TD1:
03405   case HRTIM_OUTPUT_TE1:
03406     {
03407       __HAL_HRTIM_TIMER_ENABLE_IT(hhrtim, TimerIdx, HRTIM_TIM_IT_CMP1);
03408       break;
03409     }
03410 
03411   case HRTIM_OUTPUT_TA2:
03412   case HRTIM_OUTPUT_TB2:
03413   case HRTIM_OUTPUT_TC2:
03414   case HRTIM_OUTPUT_TD2:
03415   case HRTIM_OUTPUT_TE2:
03416     {
03417       __HAL_HRTIM_TIMER_ENABLE_IT(hhrtim, TimerIdx, HRTIM_TIM_IT_CMP2);
03418       break;
03419     }
03420 
03421   default:
03422     {
03423       hhrtim->State = HAL_HRTIM_STATE_ERROR;
03424 
03425       /* Process Unlocked */
03426       __HAL_UNLOCK(hhrtim);
03427 
03428       break;
03429     }
03430   }
03431 
03432   if(hhrtim->State == HAL_HRTIM_STATE_ERROR)
03433   {
03434      return HAL_ERROR;
03435   }
03436 
03437   /* Enable the timer counter */
03438   __HAL_HRTIM_ENABLE(hhrtim, TimerIdxToTimerId[TimerIdx]);
03439 
03440   hhrtim->State = HAL_HRTIM_STATE_READY;
03441 
03442   /* Process Unlocked */
03443   __HAL_UNLOCK(hhrtim);
03444 
03445   return HAL_OK;
03446 }
03447 
03448 /**
03449   * @brief  Disable the simple one pulse signal generation on the designed output
03450   *         (The compare interrupt is disabled).
03451   * @param  hhrtim pointer to HAL HRTIM handle
03452   * @param  TimerIdx Timer index
03453   *                   This parameter can be one of the following values:
03454   *                   @arg HRTIM_TIMERINDEX_TIMER_A for timer A
03455   *                   @arg HRTIM_TIMERINDEX_TIMER_B for timer B
03456   *                   @arg HRTIM_TIMERINDEX_TIMER_C for timer C
03457   *                   @arg HRTIM_TIMERINDEX_TIMER_D for timer D
03458   *                   @arg HRTIM_TIMERINDEX_TIMER_E for timer E
03459   * @param  OnePulseChannel Timer output
03460   *                    This parameter can be one of the following values:
03461   *                    @arg HRTIM_OUTPUT_TA1: Timer A - Output 1
03462   *                    @arg HRTIM_OUTPUT_TA2: Timer A - Output 2
03463   *                    @arg HRTIM_OUTPUT_TB1: Timer B - Output 1
03464   *                    @arg HRTIM_OUTPUT_TB2: Timer B - Output 2
03465   *                    @arg HRTIM_OUTPUT_TC1: Timer C - Output 1
03466   *                    @arg HRTIM_OUTPUT_TC2: Timer C - Output 2
03467   *                    @arg HRTIM_OUTPUT_TD1: Timer D - Output 1
03468   *                    @arg HRTIM_OUTPUT_TD2: Timer D - Output 2
03469   *                    @arg HRTIM_OUTPUT_TE1: Timer E - Output 1
03470   *                    @arg HRTIM_OUTPUT_TE2: Timer E - Output 2
03471   * @retval HAL status
03472   */
03473 HAL_StatusTypeDef HAL_HRTIM_SimpleOnePulseStop_IT(HRTIM_HandleTypeDef * hhrtim,
03474                                                  uint32_t TimerIdx,
03475                                                  uint32_t OnePulseChannel)
03476 {
03477   /* Check the parameters */
03478   assert_param(IS_HRTIM_TIMER_OUTPUT(TimerIdx, OnePulseChannel));
03479 
03480   /* Process Locked */
03481   __HAL_LOCK(hhrtim);
03482 
03483   hhrtim->State = HAL_HRTIM_STATE_BUSY;
03484 
03485   /* Disable the timer output */
03486   hhrtim->Instance->sCommonRegs.ODISR |= OnePulseChannel;
03487 
03488   /* Disable the timer interrupt (depends on the OnePulse output) */
03489   switch (OnePulseChannel)
03490   {
03491   case HRTIM_OUTPUT_TA1:
03492   case HRTIM_OUTPUT_TB1:
03493   case HRTIM_OUTPUT_TC1:
03494   case HRTIM_OUTPUT_TD1:
03495   case HRTIM_OUTPUT_TE1:
03496     {
03497       __HAL_HRTIM_TIMER_DISABLE_IT(hhrtim, TimerIdx, HRTIM_TIM_IT_CMP1);
03498       break;
03499     }
03500 
03501   case HRTIM_OUTPUT_TA2:
03502   case HRTIM_OUTPUT_TB2:
03503   case HRTIM_OUTPUT_TC2:
03504   case HRTIM_OUTPUT_TD2:
03505   case HRTIM_OUTPUT_TE2:
03506     {
03507       __HAL_HRTIM_TIMER_DISABLE_IT(hhrtim, TimerIdx, HRTIM_TIM_IT_CMP2);
03508       break;
03509     }
03510 
03511   default:
03512     {
03513       hhrtim->State = HAL_HRTIM_STATE_ERROR;
03514 
03515       /* Process Unlocked */
03516       __HAL_UNLOCK(hhrtim);
03517 
03518       break;
03519     }
03520   }
03521 
03522   if(hhrtim->State == HAL_HRTIM_STATE_ERROR)
03523   {
03524      return HAL_ERROR;
03525   }
03526 
03527   /* Disable the timer counter */
03528   __HAL_HRTIM_DISABLE(hhrtim, TimerIdxToTimerId[TimerIdx]);
03529 
03530   hhrtim->State = HAL_HRTIM_STATE_READY;
03531 
03532   /* Process Unlocked */
03533   __HAL_UNLOCK(hhrtim);
03534 
03535   return HAL_OK;
03536 }
03537 
03538 /**
03539   * @}
03540   */
03541 
03542 /** @defgroup HRTIM_Exported_Functions_Group7 Configuration functions
03543  *  @brief    HRTIM configuration functions
03544 @verbatim
03545  ===============================================================================
03546               ##### HRTIM configuration functions #####
03547  ===============================================================================
03548     [..]  This section provides functions allowing to configure the HRTIM
03549           resources shared by all the HRTIM timers operating in waveform mode:
03550       (+) Configure the burst mode controller
03551       (+) Configure an external event conditioning
03552       (+) Configure the external events sampling clock
03553       (+) Configure a fault conditioning
03554       (+) Enable or disable fault inputs
03555       (+) Configure the faults sampling clock
03556       (+) Configure an ADC trigger
03557 
03558 @endverbatim
03559   * @{
03560   */
03561 
03562 /**
03563   * @brief  Configure the burst mode feature of the HRTIM
03564   * @param  hhrtim pointer to HAL HRTIM handle
03565   * @param  pBurstModeCfg pointer to the burst mode configuration structure
03566   * @retval HAL status
03567   * @note This function must be called before starting the burst mode
03568   *       controller
03569   */
03570 HAL_StatusTypeDef HAL_HRTIM_BurstModeConfig(HRTIM_HandleTypeDef * hhrtim,
03571                                             HRTIM_BurstModeCfgTypeDef* pBurstModeCfg)
03572 {
03573   uint32_t hrtim_bmcr;
03574 
03575   /* Check parameters */
03576   assert_param(IS_HRTIM_BURSTMODE(pBurstModeCfg->Mode));
03577   assert_param(IS_HRTIM_BURSTMODECLOCKSOURCE(pBurstModeCfg->ClockSource));
03578   assert_param(IS_HRTIM_HRTIM_BURSTMODEPRESCALER(pBurstModeCfg->Prescaler));
03579   assert_param(IS_HRTIM_BURSTMODEPRELOAD(pBurstModeCfg->PreloadEnable));
03580   assert_param(IS_HRTIM_BURSTMODETRIGGER(pBurstModeCfg->Trigger));
03581 
03582   if(hhrtim->State == HAL_HRTIM_STATE_BUSY)
03583   {
03584      return HAL_BUSY;
03585   }
03586 
03587   /* Process Locked */
03588   __HAL_LOCK(hhrtim);
03589 
03590   hhrtim->State = HAL_HRTIM_STATE_BUSY;
03591 
03592   hrtim_bmcr = hhrtim->Instance->sCommonRegs.BMCR;
03593 
03594   /* Set the burst mode operating mode */
03595   hrtim_bmcr &= ~(HRTIM_BMCR_BMOM);
03596   hrtim_bmcr |= (pBurstModeCfg->Mode & HRTIM_BMCR_BMOM);
03597 
03598   /* Set the burst mode clock source */
03599   hrtim_bmcr &= ~(HRTIM_BMCR_BMCLK);
03600   hrtim_bmcr |= (pBurstModeCfg->ClockSource & HRTIM_BMCR_BMCLK);
03601 
03602   /* Set the burst mode prescaler */
03603   hrtim_bmcr &= ~(HRTIM_BMCR_BMPRSC);
03604   hrtim_bmcr |= pBurstModeCfg->Prescaler;
03605 
03606   /* Enable/disable burst mode registers preload */
03607   hrtim_bmcr &= ~(HRTIM_BMCR_BMPREN);
03608   hrtim_bmcr |= (pBurstModeCfg->PreloadEnable & HRTIM_BMCR_BMPREN);
03609 
03610   /* Set the burst mode trigger */
03611   hhrtim->Instance->sCommonRegs.BMTRGR = pBurstModeCfg->Trigger;
03612 
03613   /* Set the burst mode compare value */
03614   hhrtim->Instance->sCommonRegs.BMCMPR = pBurstModeCfg->IdleDuration;
03615 
03616   /* Set the burst mode period */
03617   hhrtim->Instance->sCommonRegs.BMPER = pBurstModeCfg->Period;
03618 
03619   /* Update the HRTIM registers */
03620   hhrtim->Instance->sCommonRegs.BMCR = hrtim_bmcr;
03621 
03622   hhrtim->State = HAL_HRTIM_STATE_READY;
03623 
03624   /* Process Unlocked */
03625   __HAL_UNLOCK(hhrtim);
03626 
03627   return HAL_OK;
03628 }
03629 
03630 /**
03631   * @brief  Configure the conditioning of an external event
03632   * @param  hhrtim pointer to HAL HRTIM handle
03633   * @param  Event external event to configure
03634   *                    This parameter can be one of the following values:
03635   *                    @arg HRTIM_EVENT_NONE: no external Event
03636   *                    @arg HRTIM_EVENT_1: External event 1
03637   *                    @arg HRTIM_EVENT_2: External event 2
03638   *                    @arg HRTIM_EVENT_3: External event 3
03639   *                    @arg HRTIM_EVENT_4: External event 4
03640   *                    @arg HRTIM_EVENT_5: External event 5
03641   *                    @arg HRTIM_EVENT_6: External event 6
03642   *                    @arg HRTIM_EVENT_7: External event 7
03643   *                    @arg HRTIM_EVENT_8: External event 8
03644   *                    @arg HRTIM_EVENT_9: External event 9
03645   *                    @arg HRTIM_EVENT_10: External event 10
03646   * @param  pEventCfg pointer to the event conditioning configuration structure
03647   * @note This function must be called before starting the timer
03648   * @retval HAL status
03649   */
03650 HAL_StatusTypeDef HAL_HRTIM_EventConfig(HRTIM_HandleTypeDef * hhrtim,
03651                                         uint32_t Event,
03652                                         HRTIM_EventCfgTypeDef* pEventCfg)
03653 {
03654   /* Check parameters */
03655   assert_param(IS_HRTIM_EVENT(Event));
03656   assert_param(IS_HRTIM_EVENTSRC(pEventCfg->Source));
03657   assert_param(IS_HRTIM_EVENTPOLARITY(pEventCfg->Sensitivity, pEventCfg->Polarity));
03658   assert_param(IS_HRTIM_EVENTSENSITIVITY(pEventCfg->Sensitivity));
03659   assert_param(IS_HRTIM_EVENTFASTMODE(Event, pEventCfg->FastMode));
03660   assert_param(IS_HRTIM_EVENTFILTER(Event, pEventCfg->Filter));
03661 
03662   if(hhrtim->State == HAL_HRTIM_STATE_BUSY)
03663   {
03664      return HAL_BUSY;
03665   }
03666 
03667   /* Process Locked */
03668   __HAL_LOCK(hhrtim);
03669 
03670   hhrtim->State = HAL_HRTIM_STATE_BUSY;
03671 
03672   /* Configure the event channel */
03673   HRTIM_EventConfig(hhrtim, Event, pEventCfg);
03674 
03675   hhrtim->State = HAL_HRTIM_STATE_READY;
03676 
03677   /* Process Unlocked */
03678   __HAL_UNLOCK(hhrtim);
03679 
03680   return HAL_OK;
03681 }
03682 
03683 /**
03684   * @brief  Configure the external event conditioning block prescaler
03685   * @param  hhrtim pointer to HAL HRTIM handle
03686   * @param  Prescaler Prescaler value
03687   *                    This parameter can be one of the following values:
03688   *                    @arg HRTIM_EVENTPRESCALER_DIV1: fEEVS=fHRTIM
03689   *                    @arg HRTIM_EVENTPRESCALER_DIV2: fEEVS=fHRTIM / 2
03690   *                    @arg HRTIM_EVENTPRESCALER_DIV4: fEEVS=fHRTIM / 4
03691   *                    @arg HRTIM_EVENTPRESCALER_DIV8: fEEVS=fHRTIM / 8
03692   * @note This function must be called before starting the timer
03693   * @retval HAL status
03694   */
03695 HAL_StatusTypeDef HAL_HRTIM_EventPrescalerConfig(HRTIM_HandleTypeDef * hhrtim,
03696                                                  uint32_t Prescaler)
03697 {
03698   /* Check parameters */
03699   assert_param(IS_HRTIM_EVENTPRESCALER(Prescaler));
03700 
03701   if(hhrtim->State == HAL_HRTIM_STATE_BUSY)
03702   {
03703      return HAL_BUSY;
03704   }
03705 
03706   /* Process Locked */
03707   __HAL_LOCK(hhrtim);
03708 
03709   hhrtim->State = HAL_HRTIM_STATE_BUSY;
03710 
03711   /* Set the external event prescaler */
03712   MODIFY_REG(hhrtim->Instance->sCommonRegs.EECR3, HRTIM_EECR3_EEVSD, (Prescaler & HRTIM_EECR3_EEVSD));
03713 
03714   hhrtim->State = HAL_HRTIM_STATE_READY;
03715 
03716   /* Process Unlocked */
03717   __HAL_UNLOCK(hhrtim);
03718 
03719   return HAL_OK;
03720 }
03721 
03722 /**
03723   * @brief  Configure the conditioning of fault input
03724   * @param  hhrtim pointer to HAL HRTIM handle
03725   * @param  Fault fault input to configure
03726   *                    This parameter can be one of the following values:
03727   *                    @arg HRTIM_FAULT_1: Fault input 1
03728   *                    @arg HRTIM_FAULT_2: Fault input 2
03729   *                    @arg HRTIM_FAULT_3: Fault input 3
03730   *                    @arg HRTIM_FAULT_4: Fault input 4
03731   *                    @arg HRTIM_FAULT_5: Fault input 5
03732   * @param  pFaultCfg pointer to the fault conditioning configuration structure
03733   * @note This function must be called before starting the timer and before
03734   *       enabling faults inputs
03735   * @retval HAL status
03736   */
03737 HAL_StatusTypeDef HAL_HRTIM_FaultConfig(HRTIM_HandleTypeDef * hhrtim,
03738                                         uint32_t Fault,
03739                                         HRTIM_FaultCfgTypeDef* pFaultCfg)
03740 {
03741   uint32_t hrtim_fltinr1;
03742   uint32_t hrtim_fltinr2;
03743 
03744   /* Check parameters */
03745   assert_param(IS_HRTIM_FAULT(Fault));
03746   assert_param(IS_HRTIM_FAULTSOURCE(pFaultCfg->Source));
03747   assert_param(IS_HRTIM_FAULTPOLARITY(pFaultCfg->Polarity));
03748   assert_param(IS_HRTIM_FAULTFILTER(pFaultCfg->Filter));
03749   assert_param(IS_HRTIM_FAULTLOCK(pFaultCfg->Lock));
03750 
03751   if(hhrtim->State == HAL_HRTIM_STATE_BUSY)
03752   {
03753      return HAL_BUSY;
03754   }
03755 
03756   /* Process Locked */
03757   __HAL_LOCK(hhrtim);
03758 
03759   hhrtim->State = HAL_HRTIM_STATE_BUSY;
03760 
03761   /* Configure fault channel */
03762   hrtim_fltinr1 = hhrtim->Instance->sCommonRegs.FLTINR1;
03763   hrtim_fltinr2 = hhrtim->Instance->sCommonRegs.FLTINR2;
03764 
03765   switch (Fault)
03766   {
03767   case HRTIM_FAULT_1:
03768     {
03769       hrtim_fltinr1 &= ~(HRTIM_FLTINR1_FLT1P | HRTIM_FLTINR1_FLT1SRC | HRTIM_FLTINR1_FLT1F | HRTIM_FLTINR1_FLT1LCK);
03770       hrtim_fltinr1 |= (pFaultCfg->Polarity & HRTIM_FLTINR1_FLT1P);
03771       hrtim_fltinr1 |= (pFaultCfg->Source & HRTIM_FLTINR1_FLT1SRC);
03772       hrtim_fltinr1 |= (pFaultCfg->Filter & HRTIM_FLTINR1_FLT1F);
03773       hrtim_fltinr1 |= (pFaultCfg->Lock & HRTIM_FLTINR1_FLT1LCK);
03774       break;
03775     }
03776 
03777   case HRTIM_FAULT_2:
03778     {
03779       hrtim_fltinr1 &= ~(HRTIM_FLTINR1_FLT2P | HRTIM_FLTINR1_FLT2SRC | HRTIM_FLTINR1_FLT2F | HRTIM_FLTINR1_FLT2LCK);
03780       hrtim_fltinr1 |= ((pFaultCfg->Polarity << 8U) & HRTIM_FLTINR1_FLT2P);
03781       hrtim_fltinr1 |= ((pFaultCfg->Source << 8U) & HRTIM_FLTINR1_FLT2SRC);
03782       hrtim_fltinr1 |= ((pFaultCfg->Filter << 8U) & HRTIM_FLTINR1_FLT2F);
03783       hrtim_fltinr1 |= ((pFaultCfg->Lock << 8U) & HRTIM_FLTINR1_FLT2LCK);
03784       break;
03785     }
03786 
03787   case HRTIM_FAULT_3:
03788     {
03789       hrtim_fltinr1 &= ~(HRTIM_FLTINR1_FLT3P | HRTIM_FLTINR1_FLT3SRC | HRTIM_FLTINR1_FLT3F | HRTIM_FLTINR1_FLT3LCK);
03790       hrtim_fltinr1 |= ((pFaultCfg->Polarity << 16U) & HRTIM_FLTINR1_FLT3P);
03791       hrtim_fltinr1 |= ((pFaultCfg->Source << 16U) & HRTIM_FLTINR1_FLT3SRC);
03792       hrtim_fltinr1 |= ((pFaultCfg->Filter << 16U) & HRTIM_FLTINR1_FLT3F);
03793       hrtim_fltinr1 |= ((pFaultCfg->Lock << 16U) & HRTIM_FLTINR1_FLT3LCK);
03794       break;
03795      }
03796 
03797   case HRTIM_FAULT_4:
03798     {
03799       hrtim_fltinr1 &= ~(HRTIM_FLTINR1_FLT4P | HRTIM_FLTINR1_FLT4SRC | HRTIM_FLTINR1_FLT4F | HRTIM_FLTINR1_FLT4LCK);
03800       hrtim_fltinr1 |= ((pFaultCfg->Polarity << 24U) & HRTIM_FLTINR1_FLT4P);
03801       hrtim_fltinr1 |= ((pFaultCfg->Source << 24U) & HRTIM_FLTINR1_FLT4SRC);
03802       hrtim_fltinr1 |= ((pFaultCfg->Filter << 24U) & HRTIM_FLTINR1_FLT4F);
03803       hrtim_fltinr1 |= ((pFaultCfg->Lock << 24U) & HRTIM_FLTINR1_FLT4LCK);
03804       break;
03805     }
03806 
03807   case HRTIM_FAULT_5:
03808     {
03809       hrtim_fltinr2 &= ~(HRTIM_FLTINR2_FLT5P | HRTIM_FLTINR2_FLT5SRC | HRTIM_FLTINR2_FLT5F | HRTIM_FLTINR2_FLT5LCK);
03810       hrtim_fltinr2 |= (pFaultCfg->Polarity & HRTIM_FLTINR2_FLT5P);
03811       hrtim_fltinr2 |= (pFaultCfg->Source & HRTIM_FLTINR2_FLT5SRC);
03812       hrtim_fltinr2 |= (pFaultCfg->Filter & HRTIM_FLTINR2_FLT5F);
03813       hrtim_fltinr2 |= (pFaultCfg->Lock & HRTIM_FLTINR2_FLT5LCK);
03814       break;
03815     }
03816 
03817   default:
03818     {
03819       hhrtim->State = HAL_HRTIM_STATE_ERROR;
03820 
03821       /* Process Unlocked */
03822       __HAL_UNLOCK(hhrtim);
03823 
03824       break;
03825     }
03826   }
03827 
03828   if(hhrtim->State == HAL_HRTIM_STATE_ERROR)
03829   {
03830      return HAL_ERROR;
03831   }
03832 
03833   /* Update the HRTIM registers except LOCK bit */
03834   hhrtim->Instance->sCommonRegs.FLTINR1 = (hrtim_fltinr1 & (~(HRTIM_FLTINR1_FLTxLCK)));
03835   hhrtim->Instance->sCommonRegs.FLTINR2 = (hrtim_fltinr2 & (~(HRTIM_FLTINR2_FLTxLCK)));
03836 
03837   /* Update the HRTIM registers LOCK bit */
03838   SET_BIT(hhrtim->Instance->sCommonRegs.FLTINR1,(hrtim_fltinr1 & HRTIM_FLTINR1_FLTxLCK));
03839   SET_BIT(hhrtim->Instance->sCommonRegs.FLTINR2,(hrtim_fltinr2 & HRTIM_FLTINR2_FLTxLCK));
03840 
03841   hhrtim->State = HAL_HRTIM_STATE_READY;
03842 
03843   /* Process Unlocked */
03844   __HAL_UNLOCK(hhrtim);
03845 
03846   return HAL_OK;
03847 }
03848 
03849 /**
03850   * @brief  Configure the fault conditioning block prescaler
03851   * @param  hhrtim pointer to HAL HRTIM handle
03852   * @param  Prescaler Prescaler value
03853   *                    This parameter can be one of the following values:
03854   *                    @arg HRTIM_FAULTPRESCALER_DIV1: fFLTS=fHRTIM
03855   *                    @arg HRTIM_FAULTPRESCALER_DIV2: fFLTS=fHRTIM / 2
03856   *                    @arg HRTIM_FAULTPRESCALER_DIV4: fFLTS=fHRTIM / 4
03857   *                    @arg HRTIM_FAULTPRESCALER_DIV8: fFLTS=fHRTIM / 8
03858   * @retval HAL status
03859   * @note This function must be called before starting the timer and before
03860   *       enabling faults inputs
03861   */
03862 HAL_StatusTypeDef HAL_HRTIM_FaultPrescalerConfig(HRTIM_HandleTypeDef * hhrtim,
03863                                                  uint32_t Prescaler)
03864 {
03865   /* Check parameters */
03866   assert_param(IS_HRTIM_FAULTPRESCALER(Prescaler));
03867 
03868   if(hhrtim->State == HAL_HRTIM_STATE_BUSY)
03869   {
03870      return HAL_BUSY;
03871   }
03872 
03873   /* Process Locked */
03874   __HAL_LOCK(hhrtim);
03875 
03876   hhrtim->State = HAL_HRTIM_STATE_BUSY;
03877 
03878   /* Set the external event prescaler */
03879   MODIFY_REG(hhrtim->Instance->sCommonRegs.FLTINR2, HRTIM_FLTINR2_FLTSD, (Prescaler & HRTIM_FLTINR2_FLTSD));
03880 
03881   hhrtim->State = HAL_HRTIM_STATE_READY;
03882 
03883   /* Process Unlocked */
03884   __HAL_UNLOCK(hhrtim);
03885 
03886   return HAL_OK;
03887 }
03888 
03889 /**
03890   * @brief  Enable or disables the HRTIMx Fault mode.
03891   * @param  hhrtim pointer to HAL HRTIM handle
03892   * @param  Faults fault input(s) to enable or disable
03893   *                   This parameter can be any combination of the following values:
03894   *                    @arg HRTIM_FAULT_1: Fault input 1
03895   *                    @arg HRTIM_FAULT_2: Fault input 2
03896   *                    @arg HRTIM_FAULT_3: Fault input 3
03897   *                    @arg HRTIM_FAULT_4: Fault input 4
03898   *                    @arg HRTIM_FAULT_5: Fault input 5
03899   * @param  Enable Fault(s) enabling
03900   *                    This parameter can be one of the following values:
03901   *                    @arg HRTIM_FAULTMODECTL_ENABLED: Fault(s) enabled
03902   *                    @arg HRTIM_FAULTMODECTL_DISABLED: Fault(s) disabled
03903   * @retval None
03904   */
03905 void HAL_HRTIM_FaultModeCtl(HRTIM_HandleTypeDef * hhrtim,
03906                         uint32_t Faults,
03907                         uint32_t Enable)
03908 {
03909   /* Check parameters */
03910   assert_param(IS_HRTIM_FAULT(Faults));
03911   assert_param(IS_HRTIM_FAULTMODECTL(Enable));
03912 
03913   if ((Faults & HRTIM_FAULT_1) != (uint32_t)RESET)
03914   {
03915     MODIFY_REG(hhrtim->Instance->sCommonRegs.FLTINR1, HRTIM_FLTINR1_FLT1E, (Enable & HRTIM_FLTINR1_FLT1E));
03916   }
03917   if ((Faults & HRTIM_FAULT_2) != (uint32_t)RESET)
03918   {
03919     MODIFY_REG(hhrtim->Instance->sCommonRegs.FLTINR1, HRTIM_FLTINR1_FLT2E, ((Enable << 8U) & HRTIM_FLTINR1_FLT2E));
03920   }
03921   if ((Faults & HRTIM_FAULT_3) != (uint32_t)RESET)
03922   {
03923     MODIFY_REG(hhrtim->Instance->sCommonRegs.FLTINR1, HRTIM_FLTINR1_FLT3E, ((Enable << 16U) & HRTIM_FLTINR1_FLT3E));
03924   }
03925   if ((Faults & HRTIM_FAULT_4) != (uint32_t)RESET)
03926   {
03927     MODIFY_REG(hhrtim->Instance->sCommonRegs.FLTINR1, HRTIM_FLTINR1_FLT4E, ((Enable << 24U) & HRTIM_FLTINR1_FLT4E));
03928   }
03929   if ((Faults & HRTIM_FAULT_5) != (uint32_t)RESET)
03930   {
03931     MODIFY_REG(hhrtim->Instance->sCommonRegs.FLTINR2, HRTIM_FLTINR2_FLT5E, ((Enable) & HRTIM_FLTINR2_FLT5E));
03932   }
03933 }
03934 
03935 /**
03936   * @brief  Configure both the ADC trigger register update source and the ADC
03937   *         trigger source.
03938   * @param  hhrtim pointer to HAL HRTIM handle
03939   * @param  ADCTrigger ADC trigger to configure
03940   *                    This parameter can be one of the following values:
03941   *                    @arg HRTIM_ADCTRIGGER_1: ADC trigger 1
03942   *                    @arg HRTIM_ADCTRIGGER_2: ADC trigger 2
03943   *                    @arg HRTIM_ADCTRIGGER_3: ADC trigger 3
03944   *                    @arg HRTIM_ADCTRIGGER_4: ADC trigger 4
03945   * @param  pADCTriggerCfg pointer to the ADC trigger configuration structure
03946   * @retval HAL status
03947   * @note This function must be called before starting the timer
03948   */
03949 HAL_StatusTypeDef HAL_HRTIM_ADCTriggerConfig(HRTIM_HandleTypeDef * hhrtim,
03950                                              uint32_t ADCTrigger,
03951                                              HRTIM_ADCTriggerCfgTypeDef* pADCTriggerCfg)
03952 {
03953   uint32_t hrtim_cr1;
03954 
03955   /* Check parameters */
03956   assert_param(IS_HRTIM_ADCTRIGGER(ADCTrigger));
03957   assert_param(IS_HRTIM_ADCTRIGGERUPDATE(pADCTriggerCfg->UpdateSource));
03958 
03959   if(hhrtim->State == HAL_HRTIM_STATE_BUSY)
03960   {
03961      return HAL_BUSY;
03962   }
03963 
03964   /* Process Locked */
03965   __HAL_LOCK(hhrtim);
03966 
03967   hhrtim->State = HAL_HRTIM_STATE_BUSY;
03968 
03969   /* Set the ADC trigger update source */
03970   hrtim_cr1 = hhrtim->Instance->sCommonRegs.CR1;
03971 
03972   switch (ADCTrigger)
03973   {
03974   case HRTIM_ADCTRIGGER_1:
03975     {
03976       hrtim_cr1 &= ~(HRTIM_CR1_ADC1USRC);
03977       hrtim_cr1 |= (pADCTriggerCfg->UpdateSource & HRTIM_CR1_ADC1USRC);
03978 
03979       /* Set the ADC trigger 1 source */
03980       hhrtim->Instance->sCommonRegs.ADC1R = pADCTriggerCfg->Trigger;
03981       break;
03982     }
03983 
03984   case HRTIM_ADCTRIGGER_2:
03985     {
03986       hrtim_cr1 &= ~(HRTIM_CR1_ADC2USRC);
03987       hrtim_cr1 |= ((pADCTriggerCfg->UpdateSource << 3U) & HRTIM_CR1_ADC2USRC);
03988 
03989       /* Set the ADC trigger 2 source */
03990       hhrtim->Instance->sCommonRegs.ADC2R = pADCTriggerCfg->Trigger;
03991       break;
03992     }
03993 
03994   case HRTIM_ADCTRIGGER_3:
03995     {
03996       hrtim_cr1 &= ~(HRTIM_CR1_ADC3USRC);
03997       hrtim_cr1 |= ((pADCTriggerCfg->UpdateSource << 6U) & HRTIM_CR1_ADC3USRC);
03998 
03999       /* Set the ADC trigger 3 source */
04000       hhrtim->Instance->sCommonRegs.ADC3R = pADCTriggerCfg->Trigger;
04001       break;
04002     }
04003 
04004   case HRTIM_ADCTRIGGER_4:
04005     {
04006       hrtim_cr1 &= ~(HRTIM_CR1_ADC4USRC);
04007       hrtim_cr1 |= ((pADCTriggerCfg->UpdateSource << 9U) & HRTIM_CR1_ADC4USRC);
04008 
04009       /* Set the ADC trigger 4 source */
04010       hhrtim->Instance->sCommonRegs.ADC4R = pADCTriggerCfg->Trigger;
04011       break;
04012     }
04013 
04014   default:
04015     {
04016       hhrtim->State = HAL_HRTIM_STATE_ERROR;
04017 
04018       /* Process Unlocked */
04019       __HAL_UNLOCK(hhrtim);
04020 
04021       break;
04022     }
04023   }
04024 
04025   if(hhrtim->State == HAL_HRTIM_STATE_ERROR)
04026   {
04027      return HAL_ERROR;
04028   }
04029 
04030   /* Update the HRTIM registers */
04031   hhrtim->Instance->sCommonRegs.CR1 = hrtim_cr1;
04032 
04033   hhrtim->State = HAL_HRTIM_STATE_READY;
04034 
04035   /* Process Unlocked */
04036   __HAL_UNLOCK(hhrtim);
04037 
04038   return HAL_OK;
04039 }
04040 
04041 
04042 /**
04043   * @}
04044   */
04045 
04046 /** @defgroup HRTIM_Exported_Functions_Group8 Timer waveform configuration and functions
04047  *  @brief    HRTIM timer configuration and control functions
04048 @verbatim
04049  ===============================================================================
04050               ##### HRTIM timer configuration and control functions #####
04051  ===============================================================================
04052     [..]  This section provides functions used to configure and control a
04053           HRTIM timer operating in waveform mode:
04054       (+) Configure HRTIM timer general behavior
04055       (+) Configure HRTIM timer event filtering
04056       (+) Configure HRTIM timer deadtime insertion
04057       (+) Configure HRTIM timer chopper mode
04058       (+) Configure HRTIM timer burst DMA
04059       (+) Configure HRTIM timer compare unit
04060       (+) Configure HRTIM timer capture unit
04061       (+) Configure HRTIM timer output
04062       (+) Set HRTIM timer output level
04063       (+) Enable HRTIM timer output
04064       (+) Disable HRTIM timer output
04065       (+) Start HRTIM timer
04066       (+) Stop HRTIM timer
04067       (+) Start HRTIM timer and enable interrupt
04068       (+) Stop HRTIM timer and disable interrupt
04069       (+) Start HRTIM timer and enable DMA transfer
04070       (+) Stop HRTIM timer and disable DMA transfer
04071       (+) Enable or disable the burst mode controller
04072       (+) Start the burst mode controller (by software)
04073       (+) Trigger a Capture (by software)
04074       (+) Update the HRTIM timer preloadable registers (by software)
04075       (+) Reset the HRTIM timer counter (by software)
04076       (+) Start a burst DMA transfer
04077       (+) Enable timer register update
04078       (+) Disable timer register update
04079 
04080 @endverbatim
04081   * @{
04082   */
04083 
04084 /**
04085   * @brief  Configure the general behavior of a timer operating in waveform mode
04086   * @param  hhrtim pointer to HAL HRTIM handle
04087   * @param  TimerIdx Timer index
04088   *                   This parameter can be one of the following values:
04089   *                   @arg HRTIM_TIMERINDEX_MASTER  for master timer
04090   *                   @arg HRTIM_TIMERINDEX_TIMER_A for timer A
04091   *                   @arg HRTIM_TIMERINDEX_TIMER_B for timer B
04092   *                   @arg HRTIM_TIMERINDEX_TIMER_C for timer C
04093   *                   @arg HRTIM_TIMERINDEX_TIMER_D for timer D
04094   *                   @arg HRTIM_TIMERINDEX_TIMER_E for timer E
04095   * @param  pTimerCfg pointer to the timer configuration structure
04096   * @note When the timer operates in waveform mode, all the features supported by
04097   *       the HRTIM are available without any limitation.
04098   * @retval HAL status
04099   * @note This function must be called before starting the timer
04100   */
04101 HAL_StatusTypeDef HAL_HRTIM_WaveformTimerConfig(HRTIM_HandleTypeDef * hhrtim,
04102                                                 uint32_t TimerIdx,
04103                                                 HRTIM_TimerCfgTypeDef * pTimerCfg)
04104 {
04105   /* Check parameters */
04106   assert_param(IS_HRTIM_TIMERINDEX(TimerIdx));
04107 
04108   /* Relevant for all HRTIM timers, including the master */
04109   assert_param(IS_HRTIM_HALFMODE(pTimerCfg->HalfModeEnable));
04110   assert_param(IS_HRTIM_SYNCSTART(pTimerCfg->StartOnSync));
04111   assert_param(IS_HRTIM_SYNCRESET(pTimerCfg->ResetOnSync));
04112   assert_param(IS_HRTIM_DACSYNC(pTimerCfg->DACSynchro));
04113   assert_param(IS_HRTIM_PRELOAD(pTimerCfg->PreloadEnable));
04114   assert_param(IS_HRTIM_TIMERBURSTMODE(pTimerCfg->BurstMode));
04115   assert_param(IS_HRTIM_UPDATEONREPETITION(pTimerCfg->RepetitionUpdate));
04116 
04117   if(hhrtim->State == HAL_HRTIM_STATE_BUSY)
04118   {
04119      return HAL_BUSY;
04120   }
04121 
04122   /* Process Locked */
04123   __HAL_LOCK(hhrtim);
04124 
04125   hhrtim->State = HAL_HRTIM_STATE_BUSY;
04126 
04127   if (TimerIdx == HRTIM_TIMERINDEX_MASTER)
04128   {
04129     /* Check parameters */
04130     assert_param(IS_HRTIM_UPDATEGATING_MASTER(pTimerCfg->UpdateGating));
04131     assert_param(IS_HRTIM_MASTER_IT(pTimerCfg->InterruptRequests));
04132     assert_param(IS_HRTIM_MASTER_DMA(pTimerCfg->DMARequests));
04133 
04134     /* Configure master timer */
04135     HRTIM_MasterWaveform_Config(hhrtim, pTimerCfg);
04136   }
04137   else
04138   {
04139     /* Check parameters */
04140     assert_param(IS_HRTIM_UPDATEGATING_TIM(pTimerCfg->UpdateGating));
04141     assert_param(IS_HRTIM_TIM_IT(pTimerCfg->InterruptRequests));
04142     assert_param(IS_HRTIM_TIM_DMA(pTimerCfg->DMARequests));
04143     assert_param(IS_HRTIM_TIMPUSHPULLMODE(pTimerCfg->PushPull));
04144     assert_param(IS_HRTIM_TIMFAULTENABLE(pTimerCfg->FaultEnable));
04145     assert_param(IS_HRTIM_TIMFAULTLOCK(pTimerCfg->FaultLock));
04146     assert_param(IS_HRTIM_TIMDEADTIMEINSERTION(pTimerCfg->PushPull,
04147                                                pTimerCfg->DeadTimeInsertion));
04148     assert_param(IS_HRTIM_TIMDELAYEDPROTECTION(pTimerCfg->PushPull,
04149                                                pTimerCfg->DelayedProtectionMode));
04150     assert_param(IS_HRTIM_TIMUPDATETRIGGER(pTimerCfg->UpdateTrigger));
04151     assert_param(IS_HRTIM_TIMRESETTRIGGER(pTimerCfg->ResetTrigger));
04152     assert_param(IS_HRTIM_TIMUPDATEONRESET(pTimerCfg->ResetUpdate));
04153 
04154     /* Configure timing unit */
04155     HRTIM_TimingUnitWaveform_Config(hhrtim, TimerIdx, pTimerCfg);
04156   }
04157 
04158   /* Update timer parameters */
04159   hhrtim->TimerParam[TimerIdx].InterruptRequests = pTimerCfg->InterruptRequests;
04160   hhrtim->TimerParam[TimerIdx].DMARequests = pTimerCfg->DMARequests;
04161   hhrtim->TimerParam[TimerIdx].DMASrcAddress = pTimerCfg->DMASrcAddress;
04162   hhrtim->TimerParam[TimerIdx].DMADstAddress = pTimerCfg->DMADstAddress;
04163   hhrtim->TimerParam[TimerIdx].DMASize = pTimerCfg->DMASize;
04164 
04165   /* Force a software update */
04166   HRTIM_ForceRegistersUpdate(hhrtim, TimerIdx);
04167 
04168   hhrtim->State = HAL_HRTIM_STATE_READY;
04169 
04170   /* Process Unlocked */
04171   __HAL_UNLOCK(hhrtim);
04172 
04173   return HAL_OK;
04174 }
04175 
04176 /**
04177   * @brief  Configure the event filtering capabilities of a timer (blanking, windowing)
04178   * @param  hhrtim pointer to HAL HRTIM handle
04179   * @param  TimerIdx Timer index
04180   *                   This parameter can be one of the following values:
04181   *                   @arg HRTIM_TIMERINDEX_TIMER_A for timer A
04182   *                   @arg HRTIM_TIMERINDEX_TIMER_B for timer B
04183   *                   @arg HRTIM_TIMERINDEX_TIMER_C for timer C
04184   *                   @arg HRTIM_TIMERINDEX_TIMER_D for timer D
04185   *                   @arg HRTIM_TIMERINDEX_TIMER_E for timer E
04186   * @param  Event external event for which timer event filtering must be configured
04187   *                    This parameter can be one of the following values:
04188   *                    @arg HRTIM_EVENT_1: External event 1
04189   *                    @arg HRTIM_EVENT_2: External event 2
04190   *                    @arg HRTIM_EVENT_3: External event 3
04191   *                    @arg HRTIM_EVENT_4: External event 4
04192   *                    @arg HRTIM_EVENT_5: External event 5
04193   *                    @arg HRTIM_EVENT_6: External event 6
04194   *                    @arg HRTIM_EVENT_7: External event 7
04195   *                    @arg HRTIM_EVENT_8: External event 8
04196   *                    @arg HRTIM_EVENT_9: External event 9
04197   *                    @arg HRTIM_EVENT_10: External event 10
04198   * @param  pTimerEventFilteringCfg pointer to the timer event filtering configuration structure
04199   * @note This function must be called before starting the timer
04200   * @retval HAL status
04201   */
04202 HAL_StatusTypeDef HAL_HRTIM_TimerEventFilteringConfig(HRTIM_HandleTypeDef * hhrtim,
04203                                                       uint32_t TimerIdx,
04204                                                       uint32_t Event,
04205                                                       HRTIM_TimerEventFilteringCfgTypeDef* pTimerEventFilteringCfg)
04206 {
04207   /* Check parameters */
04208   assert_param(IS_HRTIM_TIMING_UNIT(TimerIdx));
04209   assert_param(IS_HRTIM_EVENT(Event));
04210   assert_param(IS_HRTIM_TIMEVENTFILTER(pTimerEventFilteringCfg->Filter));
04211 
04212   assert_param(IS_HRTIM_TIMEVENTLATCH(pTimerEventFilteringCfg->Latch));
04213 
04214   if(hhrtim->State == HAL_HRTIM_STATE_BUSY)
04215   {
04216      return HAL_BUSY;
04217   }
04218 
04219   /* Process Locked */
04220   __HAL_LOCK(hhrtim);
04221 
04222   hhrtim->State = HAL_HRTIM_STATE_BUSY;
04223 
04224   /* Configure timer event filtering capabilities */
04225   switch (Event)
04226   {
04227   case HRTIM_EVENT_NONE:
04228     {
04229       CLEAR_REG(hhrtim->Instance->sTimerxRegs[TimerIdx].EEFxR1);
04230       CLEAR_REG(hhrtim->Instance->sTimerxRegs[TimerIdx].EEFxR2);
04231       break;
04232     }
04233 
04234   case HRTIM_EVENT_1:
04235     {
04236       MODIFY_REG(hhrtim->Instance->sTimerxRegs[TimerIdx].EEFxR1, (HRTIM_EEFR1_EE1FLTR | HRTIM_EEFR1_EE1LTCH), (pTimerEventFilteringCfg->Filter | pTimerEventFilteringCfg->Latch));
04237       break;
04238     }
04239 
04240   case HRTIM_EVENT_2:
04241     {
04242       MODIFY_REG(hhrtim->Instance->sTimerxRegs[TimerIdx].EEFxR1, (HRTIM_EEFR1_EE2FLTR | HRTIM_EEFR1_EE2LTCH), ((pTimerEventFilteringCfg->Filter | pTimerEventFilteringCfg->Latch) << 6U) );
04243       break;
04244     }
04245 
04246   case HRTIM_EVENT_3:
04247     {
04248       MODIFY_REG(hhrtim->Instance->sTimerxRegs[TimerIdx].EEFxR1, (HRTIM_EEFR1_EE3FLTR | HRTIM_EEFR1_EE3LTCH), ((pTimerEventFilteringCfg->Filter | pTimerEventFilteringCfg->Latch) << 12U) );
04249       break;
04250     }
04251 
04252   case HRTIM_EVENT_4:
04253     {
04254       MODIFY_REG(hhrtim->Instance->sTimerxRegs[TimerIdx].EEFxR1, (HRTIM_EEFR1_EE4FLTR | HRTIM_EEFR1_EE4LTCH), ((pTimerEventFilteringCfg->Filter | pTimerEventFilteringCfg->Latch) << 18U) );
04255       break;
04256     }
04257 
04258   case HRTIM_EVENT_5:
04259     {
04260       MODIFY_REG(hhrtim->Instance->sTimerxRegs[TimerIdx].EEFxR1, (HRTIM_EEFR1_EE5FLTR | HRTIM_EEFR1_EE5LTCH), ((pTimerEventFilteringCfg->Filter | pTimerEventFilteringCfg->Latch) << 24U) );
04261       break;
04262     }
04263 
04264   case HRTIM_EVENT_6:
04265     {
04266       MODIFY_REG(hhrtim->Instance->sTimerxRegs[TimerIdx].EEFxR2, (HRTIM_EEFR2_EE6FLTR | HRTIM_EEFR2_EE6LTCH), (pTimerEventFilteringCfg->Filter | pTimerEventFilteringCfg->Latch) );
04267       break;
04268     }
04269 
04270   case HRTIM_EVENT_7:
04271     {
04272       MODIFY_REG(hhrtim->Instance->sTimerxRegs[TimerIdx].EEFxR2, (HRTIM_EEFR2_EE7FLTR | HRTIM_EEFR2_EE7LTCH), ((pTimerEventFilteringCfg->Filter | pTimerEventFilteringCfg->Latch) << 6U) );
04273       break;
04274     }
04275 
04276   case HRTIM_EVENT_8:
04277     {
04278       MODIFY_REG(hhrtim->Instance->sTimerxRegs[TimerIdx].EEFxR2, (HRTIM_EEFR2_EE8FLTR | HRTIM_EEFR2_EE8LTCH), ((pTimerEventFilteringCfg->Filter | pTimerEventFilteringCfg->Latch) << 12U) );
04279       break;
04280     }
04281 
04282   case HRTIM_EVENT_9:
04283     {
04284       MODIFY_REG(hhrtim->Instance->sTimerxRegs[TimerIdx].EEFxR2, (HRTIM_EEFR2_EE9FLTR | HRTIM_EEFR2_EE9LTCH), ((pTimerEventFilteringCfg->Filter | pTimerEventFilteringCfg->Latch) << 18U) );
04285       break;
04286     }
04287 
04288   case HRTIM_EVENT_10:
04289     {
04290       MODIFY_REG(hhrtim->Instance->sTimerxRegs[TimerIdx].EEFxR2, (HRTIM_EEFR2_EE10FLTR | HRTIM_EEFR2_EE10LTCH), ((pTimerEventFilteringCfg->Filter | pTimerEventFilteringCfg->Latch) << 24U) );
04291       break;
04292     }
04293 
04294   default:
04295    {
04296       hhrtim->State = HAL_HRTIM_STATE_ERROR;
04297 
04298       /* Process Unlocked */
04299       __HAL_UNLOCK(hhrtim);
04300 
04301       break;
04302     }
04303   }
04304 
04305   if(hhrtim->State == HAL_HRTIM_STATE_ERROR)
04306   {
04307      return HAL_ERROR;
04308   }
04309 
04310   hhrtim->State = HAL_HRTIM_STATE_READY;
04311 
04312   /* Process Unlocked */
04313   __HAL_UNLOCK(hhrtim);
04314 
04315   return HAL_OK;
04316 }
04317 
04318 /**
04319   * @brief  Configure the dead-time insertion feature for a timer
04320   * @param  hhrtim pointer to HAL HRTIM handle
04321   * @param  TimerIdx Timer index
04322   *                   This parameter can be one of the following values:
04323   *                   @arg HRTIM_TIMERINDEX_TIMER_A for timer A
04324   *                   @arg HRTIM_TIMERINDEX_TIMER_B for timer B
04325   *                   @arg HRTIM_TIMERINDEX_TIMER_C for timer C
04326   *                   @arg HRTIM_TIMERINDEX_TIMER_D for timer D
04327   *                   @arg HRTIM_TIMERINDEX_TIMER_E for timer E
04328   * @param  pDeadTimeCfg pointer to the deadtime insertion configuration structure
04329   * @retval HAL status
04330   * @note This function must be called before starting the timer
04331   */
04332 HAL_StatusTypeDef HAL_HRTIM_DeadTimeConfig(HRTIM_HandleTypeDef * hhrtim,
04333                                            uint32_t TimerIdx,
04334                                            HRTIM_DeadTimeCfgTypeDef* pDeadTimeCfg)
04335 {
04336   uint32_t hrtim_dtr;
04337 
04338   /* Check parameters */
04339   assert_param(IS_HRTIM_TIMING_UNIT(TimerIdx));
04340   assert_param(IS_HRTIM_TIMDEADTIME_PRESCALERRATIO(pDeadTimeCfg->Prescaler));
04341   assert_param(IS_HRTIM_TIMDEADTIME_RISINGSIGN(pDeadTimeCfg->RisingSign));
04342   assert_param(IS_HRTIM_TIMDEADTIME_RISINGLOCK(pDeadTimeCfg->RisingLock));
04343   assert_param(IS_HRTIM_TIMDEADTIME_RISINGSIGNLOCK(pDeadTimeCfg->RisingSignLock));
04344   assert_param(IS_HRTIM_TIMDEADTIME_FALLINGSIGN(pDeadTimeCfg->FallingSign));
04345   assert_param(IS_HRTIM_TIMDEADTIME_FALLINGLOCK(pDeadTimeCfg->FallingLock));
04346   assert_param(IS_HRTIM_TIMDEADTIME_FALLINGSIGNLOCK(pDeadTimeCfg->FallingSignLock));
04347 
04348   if(hhrtim->State == HAL_HRTIM_STATE_BUSY)
04349   {
04350      return HAL_BUSY;
04351   }
04352 
04353   /* Process Locked */
04354   __HAL_LOCK(hhrtim);
04355 
04356   hhrtim->State = HAL_HRTIM_STATE_BUSY;
04357 
04358   /* Set timer deadtime configuration */
04359   hrtim_dtr  = (pDeadTimeCfg->Prescaler & HRTIM_DTR_DTPRSC);
04360   hrtim_dtr |= (pDeadTimeCfg->RisingValue & HRTIM_DTR_DTR);
04361   hrtim_dtr |= (pDeadTimeCfg->RisingSign & HRTIM_DTR_SDTR);
04362   hrtim_dtr |= (pDeadTimeCfg->RisingSignLock & HRTIM_DTR_DTRSLK);
04363   hrtim_dtr |= (pDeadTimeCfg->RisingLock & HRTIM_DTR_DTRLK);
04364   hrtim_dtr |= ((pDeadTimeCfg->FallingValue << 16U) & HRTIM_DTR_DTF);
04365   hrtim_dtr |= (pDeadTimeCfg->FallingSign & HRTIM_DTR_SDTF);
04366   hrtim_dtr |= (pDeadTimeCfg->FallingSignLock & HRTIM_DTR_DTFSLK);
04367   hrtim_dtr |= (pDeadTimeCfg->FallingLock & HRTIM_DTR_DTFLK);
04368 
04369   /* Update the HRTIM registers */
04370   MODIFY_REG(hhrtim->Instance->sTimerxRegs[TimerIdx].DTxR, (
04371                  HRTIM_DTR_DTR | HRTIM_DTR_SDTR | HRTIM_DTR_DTPRSC |
04372                  HRTIM_DTR_DTRSLK | HRTIM_DTR_DTRLK | HRTIM_DTR_DTF |
04373                  HRTIM_DTR_SDTF | HRTIM_DTR_DTFSLK | HRTIM_DTR_DTFLK), hrtim_dtr);
04374 
04375   hhrtim->State = HAL_HRTIM_STATE_READY;
04376 
04377   /* Process Unlocked */
04378   __HAL_UNLOCK(hhrtim);
04379 
04380   return HAL_OK;
04381 }
04382 
04383 /**
04384   * @brief  Configure the chopper mode feature for a timer
04385   * @param  hhrtim pointer to HAL HRTIM handle
04386   * @param  TimerIdx Timer index
04387   *                   This parameter can be one of the following values:
04388   *                   @arg HRTIM_TIMERINDEX_TIMER_A for timer A
04389   *                   @arg HRTIM_TIMERINDEX_TIMER_B for timer B
04390   *                   @arg HRTIM_TIMERINDEX_TIMER_C for timer C
04391   *                   @arg HRTIM_TIMERINDEX_TIMER_D for timer D
04392   *                   @arg HRTIM_TIMERINDEX_TIMER_E for timer E
04393   * @param  pChopperModeCfg pointer to the chopper mode configuration structure
04394   * @retval HAL status
04395   * @note This function must be called before configuring the timer output(s)
04396   */
04397 HAL_StatusTypeDef HAL_HRTIM_ChopperModeConfig(HRTIM_HandleTypeDef * hhrtim,
04398                                               uint32_t TimerIdx,
04399                                               HRTIM_ChopperModeCfgTypeDef* pChopperModeCfg)
04400 {
04401   uint32_t hrtim_chpr;
04402 
04403   /* Check parameters */
04404   assert_param(IS_HRTIM_TIMING_UNIT(TimerIdx));
04405   assert_param(IS_HRTIM_CHOPPER_PRESCALERRATIO(pChopperModeCfg->CarrierFreq));
04406   assert_param(IS_HRTIM_CHOPPER_DUTYCYCLE(pChopperModeCfg->DutyCycle));
04407   assert_param(IS_HRTIM_CHOPPER_PULSEWIDTH(pChopperModeCfg->StartPulse));
04408 
04409   if(hhrtim->State == HAL_HRTIM_STATE_BUSY)
04410   {
04411      return HAL_BUSY;
04412   }
04413 
04414   /* Process Locked */
04415   __HAL_LOCK(hhrtim);
04416 
04417   hhrtim->State = HAL_HRTIM_STATE_BUSY;
04418 
04419   /* Set timer choppe mode configuration */
04420   hrtim_chpr  = (pChopperModeCfg->CarrierFreq & HRTIM_CHPR_CARFRQ);
04421   hrtim_chpr |= (pChopperModeCfg->DutyCycle & HRTIM_CHPR_CARDTY);
04422   hrtim_chpr |= (pChopperModeCfg->StartPulse & HRTIM_CHPR_STRPW);
04423 
04424   /* Update the HRTIM registers */
04425   MODIFY_REG(hhrtim->Instance->sTimerxRegs[TimerIdx].CHPxR, (HRTIM_CHPR_CARFRQ |                                                           HRTIM_CHPR_CARDTY |
04426                                                              HRTIM_CHPR_STRPW) ,
04427                                                              hrtim_chpr);
04428 
04429   hhrtim->State = HAL_HRTIM_STATE_READY;
04430 
04431   /* Process Unlocked */
04432   __HAL_UNLOCK(hhrtim);
04433 
04434   return HAL_OK;
04435 }
04436 
04437 /**
04438   * @brief  Configure the burst DMA controller for a timer
04439   * @param  hhrtim pointer to HAL HRTIM handle
04440   * @param  TimerIdx Timer index
04441   *                  This parameter can be one of the following values:
04442   *                   @arg HRTIM_TIMERINDEX_MASTER  for master timer
04443   *                   @arg HRTIM_TIMERINDEX_TIMER_A for timer A
04444   *                   @arg HRTIM_TIMERINDEX_TIMER_B for timer B
04445   *                   @arg HRTIM_TIMERINDEX_TIMER_C for timer C
04446   *                   @arg HRTIM_TIMERINDEX_TIMER_D for timer D
04447   *                   @arg HRTIM_TIMERINDEX_TIMER_E for timer E
04448   * @param  RegistersToUpdate registers to be written by DMA
04449   *                    This parameter can be any combination of the following values:
04450   *                    @arg HRTIM_BURSTDMA_CR: HRTIM_MCR or HRTIM_TIMxCR
04451   *                    @arg HRTIM_BURSTDMA_ICR: HRTIM_MICR or HRTIM_TIMxICR
04452   *                    @arg HRTIM_BURSTDMA_DIER: HRTIM_MDIER or HRTIM_TIMxDIER
04453   *                    @arg HRTIM_BURSTDMA_CNT: HRTIM_MCNT or HRTIM_TIMxCNT
04454   *                    @arg HRTIM_BURSTDMA_PER: HRTIM_MPER or HRTIM_TIMxPER
04455   *                    @arg HRTIM_BURSTDMA_REP: HRTIM_MREP or HRTIM_TIMxREP
04456   *                    @arg HRTIM_BURSTDMA_CMP1: HRTIM_MCMP1 or HRTIM_TIMxCMP1
04457   *                    @arg HRTIM_BURSTDMA_CMP2: HRTIM_MCMP2 or HRTIM_TIMxCMP2
04458   *                    @arg HRTIM_BURSTDMA_CMP3: HRTIM_MCMP3 or HRTIM_TIMxCMP3
04459   *                    @arg HRTIM_BURSTDMA_CMP4: HRTIM_MCMP4 or HRTIM_TIMxCMP4
04460   *                    @arg HRTIM_BURSTDMA_DTR: HRTIM_TIMxDTR
04461   *                    @arg HRTIM_BURSTDMA_SET1R: HRTIM_TIMxSET1R
04462   *                    @arg HRTIM_BURSTDMA_RST1R: HRTIM_TIMxRST1R
04463   *                    @arg HRTIM_BURSTDMA_SET2R: HRTIM_TIMxSET2R
04464   *                    @arg HRTIM_BURSTDMA_RST2R: HRTIM_TIMxRST2R
04465   *                    @arg HRTIM_BURSTDMA_EEFR1: HRTIM_TIMxEEFR1
04466   *                    @arg HRTIM_BURSTDMA_EEFR2: HRTIM_TIMxEEFR2
04467   *                    @arg HRTIM_BURSTDMA_RSTR: HRTIM_TIMxRSTR
04468   *                    @arg HRTIM_BURSTDMA_CHPR: HRTIM_TIMxCHPR
04469   *                    @arg HRTIM_BURSTDMA_OUTR: HRTIM_TIMxOUTR
04470   *                    @arg HRTIM_BURSTDMA_FLTR: HRTIM_TIMxFLTR
04471   * @retval HAL status
04472   * @note This function must be called before starting the timer
04473   */
04474 HAL_StatusTypeDef HAL_HRTIM_BurstDMAConfig(HRTIM_HandleTypeDef * hhrtim,
04475                                            uint32_t TimerIdx,
04476                                            uint32_t RegistersToUpdate)
04477 {
04478   /* Check parameters */
04479   assert_param(IS_HRTIM_TIMER_BURSTDMA(TimerIdx, RegistersToUpdate));
04480 
04481   if(hhrtim->State == HAL_HRTIM_STATE_BUSY)
04482   {
04483      return HAL_BUSY;
04484   }
04485 
04486   /* Process Locked */
04487   __HAL_LOCK(hhrtim);
04488 
04489   hhrtim->State = HAL_HRTIM_STATE_BUSY;
04490 
04491   /* Set the burst DMA timer update register */
04492   switch (TimerIdx)
04493   {
04494   case HRTIM_TIMERINDEX_TIMER_A:
04495     {
04496       hhrtim->Instance->sCommonRegs.BDTAUPR = RegistersToUpdate;
04497       break;
04498     }
04499 
04500   case HRTIM_TIMERINDEX_TIMER_B:
04501     {
04502       hhrtim->Instance->sCommonRegs.BDTBUPR = RegistersToUpdate;
04503       break;
04504     }
04505 
04506   case HRTIM_TIMERINDEX_TIMER_C:
04507     {
04508       hhrtim->Instance->sCommonRegs.BDTCUPR = RegistersToUpdate;
04509       break;
04510     }
04511 
04512   case HRTIM_TIMERINDEX_TIMER_D:
04513     {
04514       hhrtim->Instance->sCommonRegs.BDTDUPR = RegistersToUpdate;
04515       break;
04516     }
04517 
04518   case HRTIM_TIMERINDEX_TIMER_E:
04519     {
04520       hhrtim->Instance->sCommonRegs.BDTEUPR = RegistersToUpdate;
04521       break;
04522     }
04523 
04524   case HRTIM_TIMERINDEX_MASTER:
04525     {
04526       hhrtim->Instance->sCommonRegs.BDMUPR = RegistersToUpdate;
04527       break;
04528     }
04529 
04530   default:
04531    {
04532       hhrtim->State = HAL_HRTIM_STATE_ERROR;
04533 
04534       /* Process Unlocked */
04535       __HAL_UNLOCK(hhrtim);
04536 
04537       break;
04538     }
04539   }
04540 
04541   if(hhrtim->State == HAL_HRTIM_STATE_ERROR)
04542   {
04543      return HAL_ERROR;
04544   }
04545 
04546   hhrtim->State = HAL_HRTIM_STATE_READY;
04547 
04548   /* Process Unlocked */
04549   __HAL_UNLOCK(hhrtim);
04550 
04551   return HAL_OK;
04552 }
04553 
04554 /**
04555   * @brief  Configure the compare unit of a timer operating in waveform mode
04556   * @param  hhrtim pointer to HAL HRTIM handle
04557   * @param  TimerIdx Timer index
04558   *                   This parameter can be one of the following values:
04559   *                   @arg HRTIM_TIMERINDEX_MASTER  for master timer
04560   *                   @arg HRTIM_TIMERINDEX_TIMER_A for timer A
04561   *                   @arg HRTIM_TIMERINDEX_TIMER_B for timer B
04562   *                   @arg HRTIM_TIMERINDEX_TIMER_C for timer C
04563   *                   @arg HRTIM_TIMERINDEX_TIMER_D for timer D
04564   *                   @arg HRTIM_TIMERINDEX_TIMER_E for timer E
04565   * @param  CompareUnit Compare unit to configure
04566   *                    This parameter can be one of the following values:
04567   *                    @arg HRTIM_COMPAREUNIT_1: Compare unit 1
04568   *                    @arg HRTIM_COMPAREUNIT_2: Compare unit 2
04569   *                    @arg HRTIM_COMPAREUNIT_3: Compare unit 3
04570   *                    @arg HRTIM_COMPAREUNIT_4: Compare unit 4
04571   * @param  pCompareCfg pointer to the compare unit configuration structure
04572   * @note When auto delayed mode is required for compare unit 2 or compare unit 4,
04573   *       application has to configure separately the capture unit. Capture unit
04574   *       to configure in that case depends on the compare unit auto delayed mode
04575   *       is applied to (see below):
04576   *         Auto delayed on output compare 2: capture unit 1 must be configured
04577   *         Auto delayed on output compare 4: capture unit 2 must be configured
04578   * @retval HAL status
04579   * @note This function must be called before starting the timer
04580   */
04581 HAL_StatusTypeDef HAL_HRTIM_WaveformCompareConfig(HRTIM_HandleTypeDef * hhrtim,
04582                                                   uint32_t TimerIdx,
04583                                                   uint32_t CompareUnit,
04584                                                   HRTIM_CompareCfgTypeDef* pCompareCfg)
04585 {
04586   /* Check parameters */
04587   assert_param(IS_HRTIM_TIMERINDEX(TimerIdx));
04588 
04589   if(hhrtim->State == HAL_HRTIM_STATE_BUSY)
04590   {
04591      return HAL_BUSY;
04592   }
04593 
04594   /* Process Locked */
04595   __HAL_LOCK(hhrtim);
04596 
04597   hhrtim->State = HAL_HRTIM_STATE_BUSY;
04598 
04599   /* Configure the compare unit */
04600   if (TimerIdx == HRTIM_TIMERINDEX_MASTER)
04601   {
04602     switch (CompareUnit)
04603     {
04604       case HRTIM_COMPAREUNIT_1:
04605         {
04606         hhrtim->Instance->sMasterRegs.MCMP1R = pCompareCfg->CompareValue;
04607         break;
04608         }
04609 
04610       case HRTIM_COMPAREUNIT_2:
04611         {
04612         hhrtim->Instance->sMasterRegs.MCMP2R = pCompareCfg->CompareValue;
04613         break;
04614         }
04615 
04616       case HRTIM_COMPAREUNIT_3:
04617         {
04618         hhrtim->Instance->sMasterRegs.MCMP3R = pCompareCfg->CompareValue;
04619         break;
04620         }
04621 
04622       case HRTIM_COMPAREUNIT_4:
04623         {
04624         hhrtim->Instance->sMasterRegs.MCMP4R = pCompareCfg->CompareValue;
04625         break;
04626         }
04627 
04628       default:
04629         {
04630         hhrtim->State = HAL_HRTIM_STATE_ERROR;
04631 
04632         /* Process Unlocked */
04633         __HAL_UNLOCK(hhrtim);
04634 
04635         break;
04636         }
04637     }
04638 
04639     if(hhrtim->State == HAL_HRTIM_STATE_ERROR)
04640     {
04641      return HAL_ERROR;
04642     }
04643 
04644   }
04645   else
04646   {
04647     switch (CompareUnit)
04648     {
04649     case HRTIM_COMPAREUNIT_1:
04650       {
04651         /* Set the compare value */
04652         hhrtim->Instance->sTimerxRegs[TimerIdx].CMP1xR = pCompareCfg->CompareValue;
04653         break;
04654       }
04655 
04656     case HRTIM_COMPAREUNIT_2:
04657       {
04658         /* Check parameters */
04659         assert_param(IS_HRTIM_COMPAREUNIT_AUTODELAYEDMODE(CompareUnit, pCompareCfg->AutoDelayedMode));
04660 
04661         /* Set the compare value */
04662         hhrtim->Instance->sTimerxRegs[TimerIdx].CMP2xR = pCompareCfg->CompareValue;
04663 
04664         if (pCompareCfg->AutoDelayedMode != HRTIM_AUTODELAYEDMODE_REGULAR)
04665         {
04666           /* Configure auto-delayed mode */
04667           /* DELCMP2 bitfield must be reset when reprogrammed from one value */
04668           /* to the other to reinitialize properly the auto-delayed mechanism */
04669           hhrtim->Instance->sTimerxRegs[TimerIdx].TIMxCR &= ~HRTIM_TIMCR_DELCMP2;
04670           hhrtim->Instance->sTimerxRegs[TimerIdx].TIMxCR |= pCompareCfg->AutoDelayedMode;
04671 
04672           /* Set the compare value for timeout compare unit (if any) */
04673           if (pCompareCfg->AutoDelayedMode == HRTIM_AUTODELAYEDMODE_AUTODELAYED_TIMEOUTCMP1)
04674           {
04675             hhrtim->Instance->sTimerxRegs[TimerIdx].CMP1xR = pCompareCfg->AutoDelayedTimeout;
04676           }
04677           else if (pCompareCfg->AutoDelayedMode == HRTIM_AUTODELAYEDMODE_AUTODELAYED_TIMEOUTCMP3)
04678           {
04679             hhrtim->Instance->sTimerxRegs[TimerIdx].CMP3xR = pCompareCfg->AutoDelayedTimeout;
04680           }
04681           else
04682           {
04683             /* nothing to do */
04684           }
04685         }
04686         else
04687         {
04688           /* Clear HRTIM_TIMxCR.DELCMP2 bitfield */
04689           MODIFY_REG(hhrtim->Instance->sTimerxRegs[TimerIdx].TIMxCR, HRTIM_TIMCR_DELCMP2, 0U);
04690         }
04691          break;
04692       }
04693 
04694     case HRTIM_COMPAREUNIT_3:
04695       {
04696         /* Set the compare value */
04697         hhrtim->Instance->sTimerxRegs[TimerIdx].CMP3xR = pCompareCfg->CompareValue;
04698         break;
04699       }
04700 
04701     case HRTIM_COMPAREUNIT_4:
04702       {
04703         /* Check parameters */
04704         assert_param(IS_HRTIM_COMPAREUNIT_AUTODELAYEDMODE(CompareUnit, pCompareCfg->AutoDelayedMode));
04705 
04706         /* Set the compare value */
04707         hhrtim->Instance->sTimerxRegs[TimerIdx].CMP4xR = pCompareCfg->CompareValue;
04708 
04709         if (pCompareCfg->AutoDelayedMode != HRTIM_AUTODELAYEDMODE_REGULAR)
04710         {
04711           /* Configure auto-delayed mode */
04712           /* DELCMP4 bitfield must be reset when reprogrammed from one value */
04713           /* to the other to reinitialize properly the auto-delayed mechanism */
04714           hhrtim->Instance->sTimerxRegs[TimerIdx].TIMxCR &= ~HRTIM_TIMCR_DELCMP4;
04715           hhrtim->Instance->sTimerxRegs[TimerIdx].TIMxCR |= (pCompareCfg->AutoDelayedMode << 2U);
04716 
04717           /* Set the compare value for timeout compare unit (if any) */
04718           if (pCompareCfg->AutoDelayedMode == HRTIM_AUTODELAYEDMODE_AUTODELAYED_TIMEOUTCMP1)
04719           {
04720             hhrtim->Instance->sTimerxRegs[TimerIdx].CMP1xR = pCompareCfg->AutoDelayedTimeout;
04721           }
04722           else if (pCompareCfg->AutoDelayedMode == HRTIM_AUTODELAYEDMODE_AUTODELAYED_TIMEOUTCMP3)
04723           {
04724             hhrtim->Instance->sTimerxRegs[TimerIdx].CMP3xR = pCompareCfg->AutoDelayedTimeout;
04725           }
04726           else
04727           {
04728             /* nothing to do */
04729           }
04730         }
04731         else
04732         {
04733           /* Clear HRTIM_TIMxCR.DELCMP4 bitfield */
04734           MODIFY_REG(hhrtim->Instance->sTimerxRegs[TimerIdx].TIMxCR, HRTIM_TIMCR_DELCMP4, 0U);
04735         }
04736          break;
04737       }
04738 
04739   default:
04740      {
04741       hhrtim->State = HAL_HRTIM_STATE_ERROR;
04742 
04743       /* Process Unlocked */
04744       __HAL_UNLOCK(hhrtim);
04745 
04746       break;
04747      }
04748    }
04749 
04750    if(hhrtim->State == HAL_HRTIM_STATE_ERROR)
04751    {
04752      return HAL_ERROR;
04753    }
04754 
04755   }
04756   hhrtim->State = HAL_HRTIM_STATE_READY;
04757 
04758   /* Process Unlocked */
04759   __HAL_UNLOCK(hhrtim);
04760 
04761   return HAL_OK;
04762 }
04763 
04764 /**
04765   * @brief  Configure the capture unit of a timer operating in waveform mode
04766   * @param  hhrtim pointer to HAL HRTIM handle
04767   * @param  TimerIdx Timer index
04768   *                   This parameter can be one of the following values:
04769   *                   @arg HRTIM_TIMERINDEX_TIMER_A for timer A
04770   *                   @arg HRTIM_TIMERINDEX_TIMER_B for timer B
04771   *                   @arg HRTIM_TIMERINDEX_TIMER_C for timer C
04772   *                   @arg HRTIM_TIMERINDEX_TIMER_D for timer D
04773   *                   @arg HRTIM_TIMERINDEX_TIMER_E for timer E
04774   * @param  CaptureUnit Capture unit to configure
04775   *                    This parameter can be one of the following values:
04776   *                    @arg HRTIM_CAPTUREUNIT_1: Capture unit 1
04777   *                    @arg HRTIM_CAPTUREUNIT_2: Capture unit 2
04778   * @param  pCaptureCfg pointer to the compare unit configuration structure
04779   * @retval HAL status
04780   * @note This function must be called before starting the timer
04781   */
04782 HAL_StatusTypeDef HAL_HRTIM_WaveformCaptureConfig(HRTIM_HandleTypeDef * hhrtim,
04783                                                   uint32_t TimerIdx,
04784                                                   uint32_t CaptureUnit,
04785                                                   HRTIM_CaptureCfgTypeDef* pCaptureCfg)
04786 {
04787   /* Check parameters */
04788   assert_param(IS_HRTIM_TIMER_CAPTURETRIGGER(TimerIdx, pCaptureCfg->Trigger));
04789 
04790 
04791   if(hhrtim->State == HAL_HRTIM_STATE_BUSY)
04792   {
04793      return HAL_BUSY;
04794   }
04795 
04796   /* Process Locked */
04797   __HAL_LOCK(hhrtim);
04798 
04799   hhrtim->State = HAL_HRTIM_STATE_BUSY;
04800 
04801   /* Configure the capture unit */
04802   switch (CaptureUnit)
04803   {
04804   case HRTIM_CAPTUREUNIT_1:
04805     {
04806       WRITE_REG(hhrtim->Instance->sTimerxRegs[TimerIdx].CPT1xCR, pCaptureCfg->Trigger);
04807       break;
04808     }
04809 
04810   case HRTIM_CAPTUREUNIT_2:
04811     {
04812       WRITE_REG(hhrtim->Instance->sTimerxRegs[TimerIdx].CPT2xCR, pCaptureCfg->Trigger);
04813       break;
04814     }
04815 
04816   default:
04817     {
04818       hhrtim->State = HAL_HRTIM_STATE_ERROR;
04819 
04820       /* Process Unlocked */
04821       __HAL_UNLOCK(hhrtim);
04822 
04823       break;
04824     }
04825   }
04826 
04827   if(hhrtim->State == HAL_HRTIM_STATE_ERROR)
04828   {
04829      return HAL_ERROR;
04830   }
04831 
04832 
04833   hhrtim->State = HAL_HRTIM_STATE_READY;
04834 
04835   /* Process Unlocked */
04836   __HAL_UNLOCK(hhrtim);
04837 
04838   return HAL_OK;
04839 }
04840 
04841 /**
04842   * @brief  Configure the output of a timer operating in waveform mode
04843   * @param  hhrtim pointer to HAL HRTIM handle
04844   * @param  TimerIdx Timer index
04845   *                   This parameter can be one of the following values:
04846   *                   @arg HRTIM_TIMERINDEX_TIMER_A for timer A
04847   *                   @arg HRTIM_TIMERINDEX_TIMER_B for timer B
04848   *                   @arg HRTIM_TIMERINDEX_TIMER_C for timer C
04849   *                   @arg HRTIM_TIMERINDEX_TIMER_D for timer D
04850   *                   @arg HRTIM_TIMERINDEX_TIMER_E for timer E
04851   * @param  Output Timer output
04852   *                    This parameter can be one of the following values:
04853   *                    @arg HRTIM_OUTPUT_TA1: Timer A - Output 1
04854   *                    @arg HRTIM_OUTPUT_TA2: Timer A - Output 2
04855   *                    @arg HRTIM_OUTPUT_TB1: Timer B - Output 1
04856   *                    @arg HRTIM_OUTPUT_TB2: Timer B - Output 2
04857   *                    @arg HRTIM_OUTPUT_TC1: Timer C - Output 1
04858   *                    @arg HRTIM_OUTPUT_TC2: Timer C - Output 2
04859   *                    @arg HRTIM_OUTPUT_TD1: Timer D - Output 1
04860   *                    @arg HRTIM_OUTPUT_TD2: Timer D - Output 2
04861   *                    @arg HRTIM_OUTPUT_TE1: Timer E - Output 1
04862   *                    @arg HRTIM_OUTPUT_TE2: Timer E - Output 2
04863   * @param  pOutputCfg pointer to the timer output configuration structure
04864   * @retval HAL status
04865   * @note This function must be called before configuring the timer and after
04866   *       configuring the deadtime insertion feature (if required).
04867   */
04868 HAL_StatusTypeDef HAL_HRTIM_WaveformOutputConfig(HRTIM_HandleTypeDef * hhrtim,
04869                                                 uint32_t TimerIdx,
04870                                                 uint32_t Output,
04871                                                 HRTIM_OutputCfgTypeDef * pOutputCfg)
04872 {
04873   /* Check parameters */
04874   assert_param(IS_HRTIM_TIMER_OUTPUT(TimerIdx, Output));
04875   assert_param(IS_HRTIM_OUTPUTPOLARITY(pOutputCfg->Polarity));
04876   assert_param(IS_HRTIM_OUTPUTIDLELEVEL(pOutputCfg->IdleLevel));
04877   assert_param(IS_HRTIM_OUTPUTIDLEMODE(pOutputCfg->IdleMode));
04878   assert_param(IS_HRTIM_OUTPUTFAULTLEVEL(pOutputCfg->FaultLevel));
04879   assert_param(IS_HRTIM_OUTPUTCHOPPERMODE(pOutputCfg->ChopperModeEnable));
04880   assert_param(IS_HRTIM_OUTPUTBURSTMODEENTRY(pOutputCfg->BurstModeEntryDelayed));
04881 
04882   if(hhrtim->State == HAL_HRTIM_STATE_BUSY)
04883   {
04884      return HAL_BUSY;
04885   }
04886 
04887   /* Process Locked */
04888   __HAL_LOCK(hhrtim);
04889 
04890   hhrtim->State = HAL_HRTIM_STATE_BUSY;
04891 
04892   /* Configure the timer output */
04893   HRTIM_OutputConfig(hhrtim,
04894                      TimerIdx,
04895                      Output,
04896                      pOutputCfg);
04897 
04898   hhrtim->State = HAL_HRTIM_STATE_READY;
04899 
04900   /* Process Unlocked */
04901   __HAL_UNLOCK(hhrtim);
04902 
04903   return HAL_OK;
04904 }
04905 
04906 /**
04907   * @brief  Force the timer output to its active or inactive state
04908   * @param  hhrtim pointer to HAL HRTIM handle
04909   * @param  TimerIdx Timer index
04910   *                   This parameter can be one of the following values:
04911   *                   @arg HRTIM_TIMERINDEX_TIMER_A for timer A
04912   *                   @arg HRTIM_TIMERINDEX_TIMER_B for timer B
04913   *                   @arg HRTIM_TIMERINDEX_TIMER_C for timer C
04914   *                   @arg HRTIM_TIMERINDEX_TIMER_D for timer D
04915   *                   @arg HRTIM_TIMERINDEX_TIMER_E for timer E
04916   * @param  Output Timer output
04917   *                    This parameter can be one of the following values:
04918   *                    @arg HRTIM_OUTPUT_TA1: Timer A - Output 1
04919   *                    @arg HRTIM_OUTPUT_TA2: Timer A - Output 2
04920   *                    @arg HRTIM_OUTPUT_TB1: Timer B - Output 1
04921   *                    @arg HRTIM_OUTPUT_TB2: Timer B - Output 2
04922   *                    @arg HRTIM_OUTPUT_TC1: Timer C - Output 1
04923   *                    @arg HRTIM_OUTPUT_TC2: Timer C - Output 2
04924   *                    @arg HRTIM_OUTPUT_TD1: Timer D - Output 1
04925   *                    @arg HRTIM_OUTPUT_TD2: Timer D - Output 2
04926   *                    @arg HRTIM_OUTPUT_TE1: Timer E - Output 1
04927   *                    @arg HRTIM_OUTPUT_TE2: Timer E - Output 2
04928   * @param OutputLevel indicates whether the output is forced to its active or inactive level
04929   *                    This parameter can be one of the following values:
04930   *                    @arg HRTIM_OUTPUTLEVEL_ACTIVE: output is forced to its active level
04931   *                    @arg HRTIM_OUTPUTLEVEL_INACTIVE: output is forced to its inactive level
04932   * @retval HAL status
04933   * @note The 'software set/reset trigger' bit in the output set/reset registers
04934   *       is automatically reset by hardware
04935   */
04936 HAL_StatusTypeDef HAL_HRTIM_WaveformSetOutputLevel(HRTIM_HandleTypeDef * hhrtim,
04937                                                    uint32_t TimerIdx,
04938                                                    uint32_t Output,
04939                                                    uint32_t OutputLevel)
04940 {
04941   /* Check parameters */
04942   assert_param(IS_HRTIM_TIMER_OUTPUT(TimerIdx, Output));
04943   assert_param(IS_HRTIM_OUTPUTLEVEL(OutputLevel));
04944 
04945   if(hhrtim->State == HAL_HRTIM_STATE_BUSY)
04946   {
04947      return HAL_BUSY;
04948   }
04949 
04950   /* Process Locked */
04951   __HAL_LOCK(hhrtim);
04952 
04953   hhrtim->State = HAL_HRTIM_STATE_BUSY;
04954 
04955   /* Force timer output level */
04956   switch (Output)
04957   {
04958   case HRTIM_OUTPUT_TA1:
04959   case HRTIM_OUTPUT_TB1:
04960   case HRTIM_OUTPUT_TC1:
04961   case HRTIM_OUTPUT_TD1:
04962   case HRTIM_OUTPUT_TE1:
04963     {
04964       if (OutputLevel == HRTIM_OUTPUTLEVEL_ACTIVE)
04965       {
04966         /* Force output to its active state */
04967         SET_BIT(hhrtim->Instance->sTimerxRegs[TimerIdx].SETx1R,HRTIM_SET1R_SST);
04968       }
04969       else
04970       {
04971         /* Force output to its inactive state */
04972         SET_BIT(hhrtim->Instance->sTimerxRegs[TimerIdx].RSTx1R, HRTIM_RST1R_SRT);
04973       }
04974       break;
04975     }
04976 
04977   case HRTIM_OUTPUT_TA2:
04978   case HRTIM_OUTPUT_TB2:
04979   case HRTIM_OUTPUT_TC2:
04980   case HRTIM_OUTPUT_TD2:
04981   case HRTIM_OUTPUT_TE2:
04982     {
04983       if (OutputLevel == HRTIM_OUTPUTLEVEL_ACTIVE)
04984       {
04985         /* Force output to its active state */
04986         SET_BIT(hhrtim->Instance->sTimerxRegs[TimerIdx].SETx2R, HRTIM_SET2R_SST);
04987       }
04988       else
04989       {
04990         /* Force output to its inactive state */
04991         SET_BIT(hhrtim->Instance->sTimerxRegs[TimerIdx].RSTx2R, HRTIM_RST2R_SRT);
04992       }
04993       break;
04994     }
04995 
04996   default:
04997     {
04998       hhrtim->State = HAL_HRTIM_STATE_ERROR;
04999 
05000       /* Process Unlocked */
05001       __HAL_UNLOCK(hhrtim);
05002 
05003       break;
05004     }
05005   }
05006 
05007   if(hhrtim->State == HAL_HRTIM_STATE_ERROR)
05008   {
05009      return HAL_ERROR;
05010   }
05011 
05012   hhrtim->State = HAL_HRTIM_STATE_READY;
05013 
05014   /* Process Unlocked */
05015   __HAL_UNLOCK(hhrtim);
05016 
05017   return HAL_OK;
05018 }
05019 
05020 /**
05021   * @brief  Enable the generation of the waveform signal on the designated output(s)
05022   *         Outputs can be combined (ORed) to allow for simultaneous output enabling.
05023   * @param  hhrtim pointer to HAL HRTIM handle
05024   * @param  OutputsToStart Timer output(s) to enable
05025   *                    This parameter can be any combination of the following values:
05026   *                    @arg HRTIM_OUTPUT_TA1: Timer A - Output 1
05027   *                    @arg HRTIM_OUTPUT_TA2: Timer A - Output 2
05028   *                    @arg HRTIM_OUTPUT_TB1: Timer B - Output 1
05029   *                    @arg HRTIM_OUTPUT_TB2: Timer B - Output 2
05030   *                    @arg HRTIM_OUTPUT_TC1: Timer C - Output 1
05031   *                    @arg HRTIM_OUTPUT_TC2: Timer C - Output 2
05032   *                    @arg HRTIM_OUTPUT_TD1: Timer D - Output 1
05033   *                    @arg HRTIM_OUTPUT_TD2: Timer D - Output 2
05034   *                    @arg HRTIM_OUTPUT_TE1: Timer E - Output 1
05035   *                    @arg HRTIM_OUTPUT_TE2: Timer E - Output 2
05036   * @retval HAL status
05037   */
05038 HAL_StatusTypeDef HAL_HRTIM_WaveformOutputStart(HRTIM_HandleTypeDef * hhrtim,
05039                                                 uint32_t OutputsToStart)
05040 {
05041    /* Check the parameters */
05042   assert_param(IS_HRTIM_OUTPUT(OutputsToStart));
05043 
05044   /* Process Locked */
05045   __HAL_LOCK(hhrtim);
05046 
05047   hhrtim->State = HAL_HRTIM_STATE_BUSY;
05048 
05049   /* Enable the HRTIM outputs */
05050   hhrtim->Instance->sCommonRegs.OENR |= (OutputsToStart);
05051 
05052   hhrtim->State = HAL_HRTIM_STATE_READY;
05053 
05054   /* Process Unlocked */
05055   __HAL_UNLOCK(hhrtim);
05056 
05057   return HAL_OK;
05058 }
05059 
05060 /**
05061   * @brief  Disable the generation of the waveform signal on the designated output(s)
05062   *         Outputs can be combined (ORed) to allow for simultaneous output disabling.
05063   * @param  hhrtim pointer to HAL HRTIM handle
05064   * @param  OutputsToStop Timer output(s) to disable
05065   *                    This parameter can be any combination of the following values:
05066   *                    @arg HRTIM_OUTPUT_TA1: Timer A - Output 1
05067   *                    @arg HRTIM_OUTPUT_TA2: Timer A - Output 2
05068   *                    @arg HRTIM_OUTPUT_TB1: Timer B - Output 1
05069   *                    @arg HRTIM_OUTPUT_TB2: Timer B - Output 2
05070   *                    @arg HRTIM_OUTPUT_TC1: Timer C - Output 1
05071   *                    @arg HRTIM_OUTPUT_TC2: Timer C - Output 2
05072   *                    @arg HRTIM_OUTPUT_TD1: Timer D - Output 1
05073   *                    @arg HRTIM_OUTPUT_TD2: Timer D - Output 2
05074   *                    @arg HRTIM_OUTPUT_TE1: Timer E - Output 1
05075   *                    @arg HRTIM_OUTPUT_TE2: Timer E - Output 2
05076   * @retval HAL status
05077   */
05078 HAL_StatusTypeDef HAL_HRTIM_WaveformOutputStop(HRTIM_HandleTypeDef * hhrtim,
05079                                                uint32_t OutputsToStop)
05080 {
05081    /* Check the parameters */
05082   assert_param(IS_HRTIM_OUTPUT(OutputsToStop));
05083 
05084   /* Process Locked */
05085   __HAL_LOCK(hhrtim);
05086 
05087   hhrtim->State = HAL_HRTIM_STATE_BUSY;
05088 
05089   /* Enable the HRTIM outputs */
05090   hhrtim->Instance->sCommonRegs.ODISR |= (OutputsToStop);
05091 
05092   hhrtim->State = HAL_HRTIM_STATE_READY;
05093 
05094   /* Process Unlocked */
05095   __HAL_UNLOCK(hhrtim);
05096 
05097   return HAL_OK;
05098 }
05099 
05100 /**
05101   * @brief  Start the counter of the designated timer(s) operating in waveform mode
05102   *         Timers can be combined (ORed) to allow for simultaneous counter start.
05103   * @param  hhrtim pointer to HAL HRTIM handle
05104   * @param  Timers Timer counter(s) to start
05105   *                   This parameter can be any combination of the following values:
05106   *                   @arg HRTIM_TIMERID_MASTER
05107   *                   @arg HRTIM_TIMERID_TIMER_A
05108   *                   @arg HRTIM_TIMERID_TIMER_B
05109   *                   @arg HRTIM_TIMERID_TIMER_C
05110   *                   @arg HRTIM_TIMERID_TIMER_D
05111   *                   @arg HRTIM_TIMERID_TIMER_E
05112   * @retval HAL status
05113   */
05114 HAL_StatusTypeDef HAL_HRTIM_WaveformCountStart(HRTIM_HandleTypeDef * hhrtim,
05115                                                  uint32_t Timers)
05116 {
05117   /* Check the parameters */
05118   assert_param(IS_HRTIM_TIMERID(Timers));
05119 
05120   /* Process Locked */
05121   __HAL_LOCK(hhrtim);
05122 
05123   hhrtim->State = HAL_HRTIM_STATE_BUSY;
05124 
05125   /* Enable timer(s) counter */
05126   hhrtim->Instance->sMasterRegs.MCR |= (Timers);
05127 
05128   hhrtim->State = HAL_HRTIM_STATE_READY;
05129 
05130   /* Process Unlocked */
05131   __HAL_UNLOCK(hhrtim);
05132 
05133   return HAL_OK;
05134 }
05135 
05136 /**
05137   * @brief  Stop the counter of the designated timer(s) operating in waveform mode
05138   *         Timers can be combined (ORed) to allow for simultaneous counter stop.
05139   * @param  hhrtim pointer to HAL HRTIM handle
05140   * @param  Timers Timer counter(s) to stop
05141   *                   This parameter can be any combination of the following values:
05142   *                   @arg HRTIM_TIMERID_MASTER
05143   *                   @arg HRTIM_TIMERID_TIMER_A
05144   *                   @arg HRTIM_TIMERID_TIMER_B
05145   *                   @arg HRTIM_TIMERID_TIMER_C
05146   *                   @arg HRTIM_TIMERID_TIMER_D
05147   *                   @arg HRTIM_TIMERID_TIMER_E
05148   * @retval HAL status
05149   * @note The counter of a timer is stopped only if all timer outputs are disabled
05150   */
05151 HAL_StatusTypeDef HAL_HRTIM_WaveformCountStop(HRTIM_HandleTypeDef * hhrtim,
05152                                                 uint32_t Timers)
05153 {
05154   /* Check the parameters */
05155   assert_param(IS_HRTIM_TIMERID(Timers));
05156 
05157   /* Process Locked */
05158   __HAL_LOCK(hhrtim);
05159 
05160   hhrtim->State = HAL_HRTIM_STATE_BUSY;
05161 
05162   /* Disable timer(s) counter */
05163   hhrtim->Instance->sMasterRegs.MCR &= ~(Timers);
05164 
05165   hhrtim->State = HAL_HRTIM_STATE_READY;
05166 
05167   /* Process Unlocked */
05168   __HAL_UNLOCK(hhrtim);
05169 
05170   return HAL_OK;
05171 }
05172 
05173 /**
05174   * @brief  Start the counter of the designated timer(s) operating in waveform mode
05175   *         Timers can be combined (ORed) to allow for simultaneous counter start.
05176   * @param  hhrtim pointer to HAL HRTIM handle
05177   * @param  Timers Timer counter(s) to start
05178   *                   This parameter can be any combination of the following values:
05179   *                   @arg HRTIM_TIMERID_MASTER
05180   *                   @arg HRTIM_TIMERID_TIMER_A
05181   *                   @arg HRTIM_TIMERID_TIMER_B
05182   *                   @arg HRTIM_TIMERID_TIMER_C
05183   *                   @arg HRTIM_TIMERID_TIMER_D
05184   *                   @arg HRTIM_TIMERID_TIMER_E
05185   * @note HRTIM interrupts (e.g. faults interrupts) and interrupts related
05186   *       to the timers to start are enabled within this function.
05187   *       Interrupts to enable are selected through HAL_HRTIM_WaveformTimerConfig
05188   *       function.
05189   * @retval HAL status
05190   */
05191 HAL_StatusTypeDef HAL_HRTIM_WaveformCountStart_IT(HRTIM_HandleTypeDef * hhrtim,
05192                                                     uint32_t Timers)
05193 {
05194   uint8_t timer_idx;
05195 
05196   /* Check the parameters */
05197   assert_param(IS_HRTIM_TIMERID(Timers));
05198 
05199   /* Process Locked */
05200   __HAL_LOCK(hhrtim);
05201 
05202   hhrtim->State = HAL_HRTIM_STATE_BUSY;
05203 
05204   /* Enable HRTIM interrupts (if required) */
05205   __HAL_HRTIM_ENABLE_IT(hhrtim, hhrtim->Init.HRTIMInterruptResquests);
05206 
05207   /* Enable master timer related interrupts (if required) */
05208   if ((Timers & HRTIM_TIMERID_MASTER) != 0U)
05209   {
05210     __HAL_HRTIM_MASTER_ENABLE_IT(hhrtim,
05211                                  hhrtim->TimerParam[HRTIM_TIMERINDEX_MASTER].InterruptRequests);
05212   }
05213 
05214   /* Enable timing unit related interrupts (if required) */
05215   for (timer_idx = HRTIM_TIMERINDEX_TIMER_A ;
05216        timer_idx < HRTIM_TIMERINDEX_MASTER ;
05217        timer_idx++)
05218   {
05219     if ((Timers & TimerIdxToTimerId[timer_idx]) != 0U)
05220     {
05221       __HAL_HRTIM_TIMER_ENABLE_IT(hhrtim,
05222                                   timer_idx,
05223                                   hhrtim->TimerParam[timer_idx].InterruptRequests);
05224     }
05225   }
05226 
05227   /* Enable timer(s) counter */
05228   hhrtim->Instance->sMasterRegs.MCR |= (Timers);
05229 
05230   hhrtim->State = HAL_HRTIM_STATE_READY;
05231 
05232   /* Process Unlocked */
05233   __HAL_UNLOCK(hhrtim);
05234 
05235   return HAL_OK;}
05236 
05237 /**
05238   * @brief  Stop the counter of the designated timer(s) operating in waveform mode
05239   *         Timers can be combined (ORed) to allow for simultaneous counter stop.
05240   * @param  hhrtim pointer to HAL HRTIM handle
05241   * @param  Timers Timer counter(s) to stop
05242   *                   This parameter can be any combination of the following values:
05243   *                   @arg HRTIM_TIMERID_MASTER
05244   *                   @arg HRTIM_TIMERID_TIMER_A
05245   *                   @arg HRTIM_TIMERID_TIMER_B
05246   *                   @arg HRTIM_TIMERID_TIMER_C
05247   *                   @arg HRTIM_TIMERID_TIMER_D
05248   *                   @arg HRTIM_TIMERID_TIMER_E
05249   * @retval HAL status
05250   * @note The counter of a timer is stopped only if all timer outputs are disabled
05251   * @note All enabled timer related interrupts are disabled.
05252   */
05253 HAL_StatusTypeDef HAL_HRTIM_WaveformCountStop_IT(HRTIM_HandleTypeDef * hhrtim,
05254                                                    uint32_t Timers)
05255 {
05256   /* ++ WA */
05257   __IO uint32_t delai = (uint32_t)(0x17FU);
05258   /* -- WA */
05259 
05260   uint8_t timer_idx;
05261 
05262   /* Check the parameters */
05263   assert_param(IS_HRTIM_TIMERID(Timers));
05264 
05265   /* Process Locked */
05266   __HAL_LOCK(hhrtim);
05267 
05268   hhrtim->State = HAL_HRTIM_STATE_BUSY;
05269 
05270   /* Disable HRTIM interrupts (if required) */
05271   __HAL_HRTIM_DISABLE_IT(hhrtim, hhrtim->Init.HRTIMInterruptResquests);
05272 
05273   /* Disable master timer related interrupts (if required) */
05274   if ((Timers & HRTIM_TIMERID_MASTER) != 0U)
05275   {
05276     /* Interrupts enable flag must be cleared one by one */
05277     __HAL_HRTIM_MASTER_DISABLE_IT(hhrtim, hhrtim->TimerParam[HRTIM_TIMERINDEX_MASTER].InterruptRequests);
05278   }
05279 
05280   /* Disable timing unit related interrupts (if required) */
05281   for (timer_idx = HRTIM_TIMERINDEX_TIMER_A ;
05282        timer_idx < HRTIM_TIMERINDEX_MASTER ;
05283        timer_idx++)
05284   {
05285     if ((Timers & TimerIdxToTimerId[timer_idx]) != 0U)
05286     {
05287       __HAL_HRTIM_TIMER_DISABLE_IT(hhrtim, timer_idx, hhrtim->TimerParam[timer_idx].InterruptRequests);
05288     }
05289   }
05290 
05291   /* ++ WA */
05292   do { delai--; } while (delai != 0U);
05293   /* -- WA */
05294 
05295   /* Disable timer(s) counter */
05296   hhrtim->Instance->sMasterRegs.MCR &= ~(Timers);
05297 
05298   hhrtim->State = HAL_HRTIM_STATE_READY;
05299 
05300   /* Process Unlocked */
05301   __HAL_UNLOCK(hhrtim);
05302 
05303   return HAL_OK;
05304 }
05305 
05306 /**
05307   * @brief  Start the counter of the designated timer(s) operating in waveform mode
05308   *         Timers can be combined (ORed) to allow for simultaneous counter start.
05309   * @param  hhrtim pointer to HAL HRTIM handle
05310   * @param  Timers Timer counter(s) to start
05311   *                   This parameter can be any combination of the following values:
05312   *                   @arg HRTIM_TIMERID_MASTER
05313   *                   @arg HRTIM_TIMERID_TIMER_A
05314   *                   @arg HRTIM_TIMERID_TIMER_B
05315   *                   @arg HRTIM_TIMERID_TIMER_C
05316   *                   @arg HRTIM_TIMERID_TIMER_D
05317   *                   @arg HRTIM_TIMERID_TIMER_E
05318   * @retval HAL status
05319   * @note This function enables the dma request(s) mentioned in the timer
05320   *       configuration data structure for every timers to start.
05321   * @note The source memory address, the destination memory address and the
05322   *       size of each DMA transfer are specified at timer configuration time
05323   *       (see HAL_HRTIM_WaveformTimerConfig)
05324   */
05325 HAL_StatusTypeDef HAL_HRTIM_WaveformCountStart_DMA(HRTIM_HandleTypeDef * hhrtim,
05326                                                      uint32_t Timers)
05327 {
05328   uint8_t timer_idx;
05329   DMA_HandleTypeDef * hdma;
05330 
05331   /* Check the parameters */
05332   assert_param(IS_HRTIM_TIMERID(Timers));
05333 
05334   if(hhrtim->State == HAL_HRTIM_STATE_BUSY)
05335   {
05336      return HAL_BUSY;
05337   }
05338 
05339   hhrtim->State = HAL_HRTIM_STATE_BUSY;
05340 
05341   /* Process Locked */
05342   __HAL_LOCK(hhrtim);
05343 
05344   if (((Timers & HRTIM_TIMERID_MASTER) != (uint32_t)RESET) &&
05345       (hhrtim->TimerParam[HRTIM_TIMERINDEX_MASTER].DMARequests != 0U))
05346   {
05347       /* Set the DMA error callback */
05348       hhrtim->hdmaMaster->XferErrorCallback = HRTIM_DMAError ;
05349 
05350       /* Set the DMA transfer completed callback */
05351       hhrtim->hdmaMaster->XferCpltCallback = HRTIM_DMAMasterCplt;
05352 
05353       /* Enable the DMA channel */
05354       if (HAL_DMA_Start_IT(hhrtim->hdmaMaster,
05355                        hhrtim->TimerParam[HRTIM_TIMERINDEX_MASTER].DMASrcAddress,
05356                        hhrtim->TimerParam[HRTIM_TIMERINDEX_MASTER].DMADstAddress,
05357                        hhrtim->TimerParam[HRTIM_TIMERINDEX_MASTER].DMASize) != HAL_OK)
05358     {
05359             hhrtim->State = HAL_HRTIM_STATE_ERROR;
05360 
05361             /* Process Unlocked */
05362             __HAL_UNLOCK(hhrtim);
05363 
05364             return HAL_ERROR;
05365         }
05366 
05367       /* Enable the timer DMA request */
05368       __HAL_HRTIM_MASTER_ENABLE_DMA(hhrtim,
05369                                    hhrtim->TimerParam[HRTIM_TIMERINDEX_MASTER].DMARequests);
05370   }
05371 
05372   for (timer_idx = HRTIM_TIMERINDEX_TIMER_A ;
05373        timer_idx < HRTIM_TIMERINDEX_MASTER ;
05374        timer_idx++)
05375   {
05376     if (((Timers & TimerIdxToTimerId[timer_idx]) != (uint32_t)RESET) &&
05377          (hhrtim->TimerParam[timer_idx].DMARequests != 0U))
05378     {
05379       /* Get the timer DMA handler */
05380       hdma = HRTIM_GetDMAHandleFromTimerIdx(hhrtim, timer_idx);
05381 
05382       if (hdma == NULL)
05383       {
05384         hhrtim->State = HAL_HRTIM_STATE_ERROR;
05385 
05386         /* Process Unlocked */
05387         __HAL_UNLOCK(hhrtim);
05388 
05389         return HAL_ERROR;
05390       }
05391 
05392        /* Set the DMA error callback */
05393       hdma->XferErrorCallback = HRTIM_DMAError ;
05394 
05395       /* Set the DMA transfer completed callback */
05396       hdma->XferCpltCallback = HRTIM_DMATimerxCplt;
05397 
05398       /* Enable the DMA channel */
05399       if (HAL_DMA_Start_IT(hdma,
05400                        hhrtim->TimerParam[timer_idx].DMASrcAddress,
05401                        hhrtim->TimerParam[timer_idx].DMADstAddress,
05402                        hhrtim->TimerParam[timer_idx].DMASize) != HAL_OK)
05403     {
05404               hhrtim->State = HAL_HRTIM_STATE_ERROR;
05405 
05406               /* Process Unlocked */
05407               __HAL_UNLOCK(hhrtim);
05408 
05409               return HAL_ERROR;
05410         }
05411 
05412       /* Enable the timer DMA request */
05413       __HAL_HRTIM_TIMER_ENABLE_DMA(hhrtim,
05414                                    timer_idx,
05415                                    hhrtim->TimerParam[timer_idx].DMARequests);
05416     }
05417   }
05418 
05419   /* Enable the timer counter */
05420   __HAL_HRTIM_ENABLE(hhrtim, Timers);
05421 
05422   hhrtim->State = HAL_HRTIM_STATE_READY;
05423 
05424   /* Process Unlocked */
05425   __HAL_UNLOCK(hhrtim);
05426 
05427   return HAL_OK;
05428 }
05429 
05430 /**
05431   * @brief  Stop the counter of the designated timer(s) operating in waveform mode
05432   *         Timers can be combined (ORed) to allow for simultaneous counter stop.
05433   * @param  hhrtim pointer to HAL HRTIM handle
05434   * @param  Timers Timer counter(s) to stop
05435   *                   This parameter can be any combination of the following values:
05436   *                   @arg HRTIM_TIMERID_MASTER
05437   *                   @arg HRTIM_TIMERID_TIMER_A
05438   *                   @arg HRTIM_TIMERID_TIMER_B
05439   *                   @arg HRTIM_TIMERID_TIMER_C
05440   *                   @arg HRTIM_TIMERID_TIMER_D
05441   *                   @arg HRTIM_TIMERID_TIMER_E
05442   * @retval HAL status
05443   * @note  The counter of a timer is stopped only if all timer outputs are disabled
05444   * @note  All enabled timer related DMA requests are disabled.
05445   */
05446 HAL_StatusTypeDef HAL_HRTIM_WaveformCountStop_DMA(HRTIM_HandleTypeDef * hhrtim,
05447                                                     uint32_t Timers)
05448 {
05449   uint8_t timer_idx;
05450 
05451   /* Check the parameters */
05452   assert_param(IS_HRTIM_TIMERID(Timers));
05453 
05454   hhrtim->State = HAL_HRTIM_STATE_BUSY;
05455 
05456   if (((Timers & HRTIM_TIMERID_MASTER) != 0U) &&
05457       (hhrtim->TimerParam[HRTIM_TIMERINDEX_MASTER].DMARequests != 0U))
05458   {
05459     /* Disable the DMA */
05460     if (HAL_DMA_Abort(hhrtim->hdmaMaster) != HAL_OK)
05461     {
05462           hhrtim->State = HAL_HRTIM_STATE_ERROR;
05463     }
05464     else
05465     {
05466           hhrtim->State = HAL_HRTIM_STATE_READY;
05467           /* Disable the DMA request(s) */
05468           __HAL_HRTIM_MASTER_DISABLE_DMA(hhrtim,
05469                                          hhrtim->TimerParam[HRTIM_TIMERINDEX_MASTER].DMARequests);
05470     }
05471   }
05472 
05473   for (timer_idx = HRTIM_TIMERINDEX_TIMER_A ;
05474        timer_idx < HRTIM_TIMERINDEX_MASTER ;
05475        timer_idx++)
05476   {
05477     if (((Timers & TimerIdxToTimerId[timer_idx]) != 0U) &&
05478         (hhrtim->TimerParam[timer_idx].DMARequests != 0U))
05479     {
05480       /* Get the timer DMA handler */
05481       /* Disable the DMA */
05482       if (HAL_DMA_Abort(HRTIM_GetDMAHandleFromTimerIdx(hhrtim, timer_idx)) != HAL_OK)
05483       {
05484         hhrtim->State = HAL_HRTIM_STATE_ERROR;
05485       }
05486       else
05487       {
05488         hhrtim->State = HAL_HRTIM_STATE_READY;
05489 
05490         /* Disable the DMA request(s) */
05491         __HAL_HRTIM_TIMER_DISABLE_DMA(hhrtim,
05492                                       timer_idx,
05493                                       hhrtim->TimerParam[timer_idx].DMARequests);
05494       }
05495     }
05496   }
05497 
05498   /* Disable the timer counter */
05499   __HAL_HRTIM_DISABLE(hhrtim, Timers);
05500 
05501   if (hhrtim->State == HAL_HRTIM_STATE_ERROR)
05502   {
05503       return HAL_ERROR;
05504   }
05505   else
05506   {
05507       return HAL_OK;
05508   }
05509 }
05510 
05511 /**
05512   * @brief  Enable or disables the HRTIM burst mode controller.
05513   * @param  hhrtim pointer to HAL HRTIM handle
05514   * @param  Enable Burst mode controller enabling
05515   *                    This parameter can be one of the following values:
05516   *                    @arg HRTIM_BURSTMODECTL_ENABLED: Burst mode enabled
05517   *                    @arg HRTIM_BURSTMODECTL_DISABLED: Burst mode disabled
05518   * @retval HAL status
05519   * @note This function must be called after starting the timer(s)
05520   */
05521 HAL_StatusTypeDef HAL_HRTIM_BurstModeCtl(HRTIM_HandleTypeDef * hhrtim,
05522                                          uint32_t Enable)
05523 {
05524   /* Check parameters */
05525   assert_param(IS_HRTIM_BURSTMODECTL(Enable));
05526 
05527   if(hhrtim->State == HAL_HRTIM_STATE_BUSY)
05528   {
05529      return HAL_BUSY;
05530   }
05531 
05532   /* Process Locked */
05533   __HAL_LOCK(hhrtim);
05534 
05535   hhrtim->State = HAL_HRTIM_STATE_BUSY;
05536 
05537   /* Enable/Disable the burst mode controller */
05538   MODIFY_REG(hhrtim->Instance->sCommonRegs.BMCR, HRTIM_BMCR_BME, Enable);
05539 
05540   hhrtim->State = HAL_HRTIM_STATE_READY;
05541 
05542   /* Process Unlocked */
05543   __HAL_UNLOCK(hhrtim);
05544 
05545   return HAL_OK;
05546 }
05547 
05548 /**
05549   * @brief  Trig the burst mode operation.
05550   * @param  hhrtim pointer to HAL HRTIM handle
05551   * @retval HAL status
05552   */
05553 HAL_StatusTypeDef HAL_HRTIM_BurstModeSoftwareTrigger(HRTIM_HandleTypeDef *hhrtim)
05554 {
05555   if(hhrtim->State == HAL_HRTIM_STATE_BUSY)
05556   {
05557      return HAL_BUSY;
05558   }
05559 
05560   /* Process Locked */
05561   __HAL_LOCK(hhrtim);
05562 
05563   hhrtim->State = HAL_HRTIM_STATE_BUSY;
05564 
05565   /* Software trigger of the burst mode controller */
05566   SET_BIT(hhrtim->Instance->sCommonRegs.BMTRGR, HRTIM_BMTRGR_SW);
05567 
05568   hhrtim->State = HAL_HRTIM_STATE_READY;
05569 
05570   /* Process Unlocked */
05571   __HAL_UNLOCK(hhrtim);
05572 
05573   return HAL_OK;
05574 }
05575 
05576 /**
05577   * @brief  Trig a software capture on the designed capture unit
05578   * @param  hhrtim pointer to HAL HRTIM handle
05579   * @param  TimerIdx Timer index
05580   *                   This parameter can be one of the following values:
05581   *                   @arg HRTIM_TIMERINDEX_TIMER_A for timer A
05582   *                   @arg HRTIM_TIMERINDEX_TIMER_B for timer B
05583   *                   @arg HRTIM_TIMERINDEX_TIMER_C for timer C
05584   *                   @arg HRTIM_TIMERINDEX_TIMER_D for timer D
05585   *                   @arg HRTIM_TIMERINDEX_TIMER_E for timer E
05586   * @param  CaptureUnit Capture unit to trig
05587   *                    This parameter can be one of the following values:
05588   *                    @arg HRTIM_CAPTUREUNIT_1: Capture unit 1
05589   *                    @arg HRTIM_CAPTUREUNIT_2: Capture unit 2
05590   * @retval HAL status
05591   * @note The 'software capture' bit in the capure configuration register is
05592   *       automatically reset by hardware
05593   */
05594 HAL_StatusTypeDef HAL_HRTIM_SoftwareCapture(HRTIM_HandleTypeDef * hhrtim,
05595                                             uint32_t TimerIdx,
05596                                             uint32_t CaptureUnit)
05597 {
05598   /* Check parameters */
05599   assert_param(IS_HRTIM_TIMING_UNIT(TimerIdx));
05600   assert_param(IS_HRTIM_CAPTUREUNIT(CaptureUnit));
05601 
05602   if(hhrtim->State == HAL_HRTIM_STATE_BUSY)
05603   {
05604      return HAL_BUSY;
05605   }
05606 
05607   /* Process Locked */
05608   __HAL_LOCK(hhrtim);
05609 
05610   hhrtim->State = HAL_HRTIM_STATE_BUSY;
05611 
05612   /* Force a software capture on concerned capture unit */
05613   switch (CaptureUnit)
05614   {
05615   case HRTIM_CAPTUREUNIT_1:
05616     {
05617       SET_BIT(hhrtim->Instance->sTimerxRegs[TimerIdx].CPT1xCR, HRTIM_CPT1CR_SWCPT);
05618       break;
05619     }
05620 
05621   case HRTIM_CAPTUREUNIT_2:
05622     {
05623       SET_BIT(hhrtim->Instance->sTimerxRegs[TimerIdx].CPT2xCR, HRTIM_CPT2CR_SWCPT);
05624       break;
05625     }
05626 
05627   default:
05628     {
05629       hhrtim->State = HAL_HRTIM_STATE_ERROR;
05630 
05631       /* Process Unlocked */
05632       __HAL_UNLOCK(hhrtim);
05633 
05634     break;
05635     }
05636   }
05637 
05638   if(hhrtim->State == HAL_HRTIM_STATE_ERROR)
05639   {
05640      return HAL_ERROR;
05641   }
05642 
05643   hhrtim->State = HAL_HRTIM_STATE_READY;
05644 
05645   /* Process Unlocked */
05646   __HAL_UNLOCK(hhrtim);
05647 
05648   return HAL_OK;
05649 }
05650 
05651 /**
05652   * @brief  Trig the update of the registers of one or several timers
05653   * @param  hhrtim pointer to HAL HRTIM handle
05654   * @param  Timers timers concerned with the software register update
05655   *                   This parameter can be any combination of the following values:
05656   *                   @arg HRTIM_TIMERUPDATE_MASTER
05657   *                   @arg HRTIM_TIMERUPDATE_A
05658   *                   @arg HRTIM_TIMERUPDATE_B
05659   *                   @arg HRTIM_TIMERUPDATE_C
05660   *                   @arg HRTIM_TIMERUPDATE_D
05661   *                   @arg HRTIM_TIMERUPDATE_E
05662   * @retval HAL status
05663   * @note The 'software update' bits in the HRTIM control register 2 register are
05664   *       automatically reset by hardware
05665   */
05666 HAL_StatusTypeDef HAL_HRTIM_SoftwareUpdate(HRTIM_HandleTypeDef * hhrtim,
05667                                            uint32_t Timers)
05668 {
05669   /* Check parameters */
05670   assert_param(IS_HRTIM_TIMERUPDATE(Timers));
05671 
05672   if(hhrtim->State == HAL_HRTIM_STATE_BUSY)
05673   {
05674      return HAL_BUSY;
05675   }
05676 
05677   /* Process Locked */
05678   __HAL_LOCK(hhrtim);
05679 
05680   hhrtim->State = HAL_HRTIM_STATE_BUSY;
05681 
05682   /* Force timer(s) registers update */
05683   hhrtim->Instance->sCommonRegs.CR2 |= Timers;
05684 
05685   hhrtim->State = HAL_HRTIM_STATE_READY;
05686 
05687   /* Process Unlocked */
05688   __HAL_UNLOCK(hhrtim);
05689 
05690   return HAL_OK;
05691 }
05692 
05693 /**
05694   * @brief  Trig the reset of one or several timers
05695   * @param  hhrtim pointer to HAL HRTIM handle
05696   * @param  Timers timers concerned with the software counter reset
05697   *                   This parameter can be any combination of the following values:
05698   *                   @arg HRTIM_TIMERRESET_MASTER
05699   *                   @arg HRTIM_TIMERRESET_TIMER_A
05700   *                   @arg HRTIM_TIMERRESET_TIMER_B
05701   *                   @arg HRTIM_TIMERRESET_TIMER_C
05702   *                   @arg HRTIM_TIMERRESET_TIMER_D
05703   *                   @arg HRTIM_TIMERRESET_TIMER_E
05704   * @retval HAL status
05705   * @note The 'software reset' bits in the HRTIM control register 2  are
05706   *       automatically reset by hardware
05707   */
05708 HAL_StatusTypeDef HAL_HRTIM_SoftwareReset(HRTIM_HandleTypeDef * hhrtim,
05709                                           uint32_t Timers)
05710 {
05711   /* Check parameters */
05712   assert_param(IS_HRTIM_TIMERRESET(Timers));
05713 
05714   if(hhrtim->State == HAL_HRTIM_STATE_BUSY)
05715   {
05716      return HAL_BUSY;
05717   }
05718 
05719   /* Process Locked */
05720   __HAL_LOCK(hhrtim);
05721 
05722   hhrtim->State = HAL_HRTIM_STATE_BUSY;
05723 
05724   /* Force timer(s) registers reset */
05725   hhrtim->Instance->sCommonRegs.CR2 = Timers;
05726 
05727   hhrtim->State = HAL_HRTIM_STATE_READY;
05728 
05729   /* Process Unlocked */
05730   __HAL_UNLOCK(hhrtim);
05731 
05732   return HAL_OK;
05733 }
05734 
05735 /**
05736   * @brief  Start a burst DMA operation to update HRTIM control registers content
05737   * @param  hhrtim pointer to HAL HRTIM handle
05738   * @param  TimerIdx Timer index
05739   *                   This parameter can be one of the following values:
05740   *                   @arg HRTIM_TIMERINDEX_MASTER  for master timer
05741   *                   @arg HRTIM_TIMERINDEX_TIMER_A for timer A
05742   *                   @arg HRTIM_TIMERINDEX_TIMER_B for timer B
05743   *                   @arg HRTIM_TIMERINDEX_TIMER_C for timer C
05744   *                   @arg HRTIM_TIMERINDEX_TIMER_D for timer D
05745   *                   @arg HRTIM_TIMERINDEX_TIMER_E for timer E
05746   * @param  BurstBufferAddress address of the buffer the HRTIM control registers
05747   *                             content will be updated from.
05748   * @param  BurstBufferLength size (in WORDS) of the burst buffer.
05749   * @retval HAL status
05750   * @note The TimerIdx parameter determines the dma channel to be used by the
05751   *       DMA burst controller (see below)
05752   *       HRTIM_TIMERINDEX_MASTER: DMA channel 2 is used by the DMA burst controller
05753   *       HRTIM_TIMERINDEX_TIMER_A: DMA channel 3 is used by the DMA burst controller
05754   *       HRTIM_TIMERINDEX_TIMER_B: DMA channel 4 is used by the DMA burst controller
05755   *       HRTIM_TIMERINDEX_TIMER_C: DMA channel 5 is used by the DMA burst controller
05756   *       HRTIM_TIMERINDEX_TIMER_D: DMA channel 6 is used by the DMA burst controller
05757   *       HRTIM_TIMERINDEX_TIMER_E: DMA channel 7 is used by the DMA burst controller
05758   */
05759 HAL_StatusTypeDef HAL_HRTIM_BurstDMATransfer(HRTIM_HandleTypeDef *hhrtim,
05760                                              uint32_t TimerIdx,
05761                                              uint32_t BurstBufferAddress,
05762                                              uint32_t BurstBufferLength)
05763 {
05764   DMA_HandleTypeDef * hdma;
05765 
05766   /* Check the parameters */
05767   assert_param(IS_HRTIM_TIMERINDEX(TimerIdx));
05768 
05769   if(hhrtim->State == HAL_HRTIM_STATE_BUSY)
05770   {
05771      return HAL_BUSY;
05772   }
05773   if(hhrtim->State == HAL_HRTIM_STATE_READY)
05774   {
05775     if((BurstBufferAddress == 0U ) || (BurstBufferLength == 0U))
05776     {
05777       return HAL_ERROR;
05778     }
05779     else
05780     {
05781       hhrtim->State = HAL_HRTIM_STATE_BUSY;
05782     }
05783   }
05784 
05785   /* Process Locked */
05786   __HAL_LOCK(hhrtim);
05787 
05788   /* Get the timer DMA handler */
05789   hdma = HRTIM_GetDMAHandleFromTimerIdx(hhrtim, TimerIdx);
05790 
05791   if (hdma == NULL)
05792   {
05793     hhrtim->State = HAL_HRTIM_STATE_ERROR;
05794 
05795     /* Process Unlocked */
05796     __HAL_UNLOCK(hhrtim);
05797 
05798     return HAL_ERROR;
05799   }
05800 
05801   /* Set the DMA transfer completed callback */
05802   hdma->XferCpltCallback = HRTIM_BurstDMACplt;
05803 
05804   /* Set the DMA error callback */
05805   hdma->XferErrorCallback = HRTIM_DMAError ;
05806 
05807   /* Enable the DMA channel */
05808   if (HAL_DMA_Start_IT(hdma,
05809                    BurstBufferAddress,
05810                    (uint32_t)&(hhrtim->Instance->sCommonRegs.BDMADR),
05811                    BurstBufferLength) != HAL_OK)
05812     {
05813            hhrtim->State = HAL_HRTIM_STATE_ERROR;
05814 
05815            /* Process Unlocked */
05816            __HAL_UNLOCK(hhrtim);
05817 
05818            return HAL_ERROR;
05819         }
05820 
05821   hhrtim->State = HAL_HRTIM_STATE_READY;
05822 
05823   /* Process Unlocked */
05824   __HAL_UNLOCK(hhrtim);
05825 
05826   return HAL_OK;
05827 }
05828 
05829 /**
05830   * @brief  Enable the transfer from preload to active registers for one
05831   *         or several timing units (including master timer).
05832   * @param  hhrtim pointer to HAL HRTIM handle
05833   * @param  Timers Timer(s) concerned by the register preload enabling command
05834   *                   This parameter can be any combination of the following values:
05835   *                   @arg HRTIM_TIMERUPDATE_MASTER
05836   *                   @arg HRTIM_TIMERUPDATE_A
05837   *                   @arg HRTIM_TIMERUPDATE_B
05838   *                   @arg HRTIM_TIMERUPDATE_C
05839   *                   @arg HRTIM_TIMERUPDATE_D
05840   *                   @arg HRTIM_TIMERUPDATE_E
05841   * @retval HAL status
05842   */
05843 HAL_StatusTypeDef HAL_HRTIM_UpdateEnable(HRTIM_HandleTypeDef *hhrtim,
05844                                           uint32_t Timers)
05845 {
05846    /* Check the parameters */
05847   assert_param(IS_HRTIM_TIMERUPDATE(Timers));
05848 
05849   /* Process Locked */
05850   __HAL_LOCK(hhrtim);
05851 
05852   hhrtim->State = HAL_HRTIM_STATE_BUSY;
05853 
05854   /* Enable timer(s) registers update */
05855   hhrtim->Instance->sCommonRegs.CR1 &= ~(Timers);
05856 
05857   hhrtim->State = HAL_HRTIM_STATE_READY;
05858 
05859   /* Process Unlocked */
05860   __HAL_UNLOCK(hhrtim);
05861 
05862   return HAL_OK;
05863   }
05864 
05865 /**
05866   * @brief  Disable the transfer from preload to active registers for one
05867   *         or several timing units (including master timer).
05868   * @param  hhrtim pointer to HAL HRTIM handle
05869   * @param  Timers Timer(s) concerned by the register preload disabling command
05870   *                   This parameter can be any combination of the following values:
05871   *                   @arg HRTIM_TIMERUPDATE_MASTER
05872   *                   @arg HRTIM_TIMERUPDATE_A
05873   *                   @arg HRTIM_TIMERUPDATE_B
05874   *                   @arg HRTIM_TIMERUPDATE_C
05875   *                   @arg HRTIM_TIMERUPDATE_D
05876   *                   @arg HRTIM_TIMERUPDATE_E
05877   * @retval HAL status
05878   */
05879 HAL_StatusTypeDef HAL_HRTIM_UpdateDisable(HRTIM_HandleTypeDef *hhrtim,
05880                                           uint32_t Timers)
05881 {
05882   /* Check the parameters */
05883   assert_param(IS_HRTIM_TIMERUPDATE(Timers));
05884 
05885   /* Process Locked */
05886   __HAL_LOCK(hhrtim);
05887 
05888   hhrtim->State = HAL_HRTIM_STATE_BUSY;
05889 
05890   /* Enable timer(s) registers update */
05891   hhrtim->Instance->sCommonRegs.CR1 |= (Timers);
05892 
05893   hhrtim->State = HAL_HRTIM_STATE_READY;
05894 
05895   /* Process Unlocked */
05896   __HAL_UNLOCK(hhrtim);
05897 
05898   return HAL_OK;
05899   }
05900 
05901 /**
05902   * @}
05903   */
05904 
05905 /** @defgroup HRTIM_Exported_Functions_Group9 Peripheral state functions
05906  *  @brief    Peripheral State functions
05907 @verbatim
05908  ===============================================================================
05909               ##### Peripheral State functions #####
05910  ===============================================================================
05911     [..]  This section provides functions used to get HRTIM or HRTIM timer
05912           specific information:
05913       (+) Get HRTIM HAL state
05914       (+) Get captured value
05915       (+) Get HRTIM timer output level
05916       (+) Get HRTIM timer output state
05917       (+) Get delayed protection status
05918       (+) Get burst status
05919       (+) Get current push-pull status
05920       (+) Get idle push-pull status
05921 
05922 @endverbatim
05923   * @{
05924   */
05925 
05926 /**
05927   * @brief  Return the HRTIM HAL state
05928   * @param  hhrtim pointer to HAL HRTIM handle
05929   * @retval HAL state
05930   */
05931 HAL_HRTIM_StateTypeDef HAL_HRTIM_GetState(HRTIM_HandleTypeDef* hhrtim)
05932 {
05933   /* Return HRTIM state */
05934   return hhrtim->State;
05935 }
05936 
05937 /**
05938   * @brief  Return actual value of the capture register of the designated capture unit
05939   * @param  hhrtim pointer to HAL HRTIM handle
05940   * @param  TimerIdx Timer index
05941   *                   This parameter can be one of the following values:
05942   *                   @arg HRTIM_TIMERINDEX_TIMER_A for timer A
05943   *                   @arg HRTIM_TIMERINDEX_TIMER_B for timer B
05944   *                   @arg HRTIM_TIMERINDEX_TIMER_C for timer C
05945   *                   @arg HRTIM_TIMERINDEX_TIMER_D for timer D
05946   *                   @arg HRTIM_TIMERINDEX_TIMER_E for timer E
05947   * @param  CaptureUnit Capture unit to trig
05948   *                    This parameter can be one of the following values:
05949   *                    @arg HRTIM_CAPTUREUNIT_1: Capture unit 1
05950   *                    @arg HRTIM_CAPTUREUNIT_2: Capture unit 2
05951   * @retval Captured value
05952   */
05953 uint32_t HAL_HRTIM_GetCapturedValue(HRTIM_HandleTypeDef * hhrtim,
05954                                     uint32_t TimerIdx,
05955                                     uint32_t CaptureUnit)
05956 {
05957   uint32_t captured_value;
05958 
05959   /* Check parameters */
05960   assert_param(IS_HRTIM_TIMING_UNIT(TimerIdx));
05961   assert_param(IS_HRTIM_CAPTUREUNIT(CaptureUnit));
05962 
05963   /* Read captured value */
05964   switch (CaptureUnit)
05965   {
05966   case HRTIM_CAPTUREUNIT_1:
05967     {
05968       captured_value = hhrtim->Instance->sTimerxRegs[TimerIdx].CPT1xR;
05969       break;
05970     }
05971 
05972   case HRTIM_CAPTUREUNIT_2:
05973     {
05974       captured_value = hhrtim->Instance->sTimerxRegs[TimerIdx].CPT2xR;
05975       break;
05976     }
05977 
05978   default:
05979    {
05980        captured_value = 0xFFFFFFFFUL;
05981 
05982        hhrtim->State = HAL_HRTIM_STATE_ERROR;
05983 
05984       /* Process Unlocked */
05985       __HAL_UNLOCK(hhrtim);
05986       break;
05987     }
05988 
05989   }
05990 
05991   return captured_value;
05992 }
05993 
05994 
05995 /**
05996   * @brief  Return actual level (active or inactive) of the designated output
05997   * @param  hhrtim pointer to HAL HRTIM handle
05998   * @param  TimerIdx Timer index
05999   *                   This parameter can be one of the following values:
06000   *                   @arg HRTIM_TIMERINDEX_TIMER_A for timer A
06001   *                   @arg HRTIM_TIMERINDEX_TIMER_B for timer B
06002   *                   @arg HRTIM_TIMERINDEX_TIMER_C for timer C
06003   *                   @arg HRTIM_TIMERINDEX_TIMER_D for timer D
06004   *                   @arg HRTIM_TIMERINDEX_TIMER_E for timer E
06005   * @param  Output Timer output
06006   *                    This parameter can be one of the following values:
06007   *                    @arg HRTIM_OUTPUT_TA1: Timer A - Output 1
06008   *                    @arg HRTIM_OUTPUT_TA2: Timer A - Output 2
06009   *                    @arg HRTIM_OUTPUT_TB1: Timer B - Output 1
06010   *                    @arg HRTIM_OUTPUT_TB2: Timer B - Output 2
06011   *                    @arg HRTIM_OUTPUT_TC1: Timer C - Output 1
06012   *                    @arg HRTIM_OUTPUT_TC2: Timer C - Output 2
06013   *                    @arg HRTIM_OUTPUT_TD1: Timer D - Output 1
06014   *                    @arg HRTIM_OUTPUT_TD2: Timer D - Output 2
06015   *                    @arg HRTIM_OUTPUT_TE1: Timer E - Output 1
06016   *                    @arg HRTIM_OUTPUT_TE2: Timer E - Output 2
06017   * @retval Output level
06018   * @note Returned output level is taken before the output stage (chopper,
06019   *        polarity).
06020   */
06021 uint32_t HAL_HRTIM_WaveformGetOutputLevel(HRTIM_HandleTypeDef * hhrtim,
06022                                           uint32_t TimerIdx,
06023                                           uint32_t Output)
06024 {
06025   uint32_t output_level = (uint32_t)RESET;
06026 
06027   /* Check parameters */
06028   assert_param(IS_HRTIM_TIMER_OUTPUT(TimerIdx, Output));
06029 
06030   /* Read the output level */
06031   switch (Output)
06032   {
06033   case HRTIM_OUTPUT_TA1:
06034   case HRTIM_OUTPUT_TB1:
06035   case HRTIM_OUTPUT_TC1:
06036   case HRTIM_OUTPUT_TD1:
06037   case HRTIM_OUTPUT_TE1:
06038     {
06039       if ((hhrtim->Instance->sTimerxRegs[TimerIdx].TIMxISR & HRTIM_TIMISR_O1CPY) != (uint32_t)RESET)
06040       {
06041         output_level = HRTIM_OUTPUTLEVEL_ACTIVE;
06042       }
06043       else
06044       {
06045         output_level = HRTIM_OUTPUTLEVEL_INACTIVE;
06046       }
06047      break;
06048     }
06049 
06050   case HRTIM_OUTPUT_TA2:
06051   case HRTIM_OUTPUT_TB2:
06052   case HRTIM_OUTPUT_TC2:
06053   case HRTIM_OUTPUT_TD2:
06054   case HRTIM_OUTPUT_TE2:
06055     {
06056       if ((hhrtim->Instance->sTimerxRegs[TimerIdx].TIMxISR & HRTIM_TIMISR_O2CPY) != (uint32_t)RESET)
06057       {
06058         output_level = HRTIM_OUTPUTLEVEL_ACTIVE;
06059       }
06060       else
06061       {
06062         output_level = HRTIM_OUTPUTLEVEL_INACTIVE;
06063       }
06064       break;
06065     }
06066 
06067   default:
06068     {
06069       hhrtim->State = HAL_HRTIM_STATE_ERROR;
06070 
06071       /* Process Unlocked */
06072       __HAL_UNLOCK(hhrtim);
06073 
06074       break;
06075     }
06076   }
06077 
06078   if(hhrtim->State == HAL_HRTIM_STATE_ERROR)
06079   {
06080      return (uint32_t)HAL_ERROR;
06081   }
06082 
06083   return output_level;
06084 }
06085 
06086 /**
06087   * @brief  Return actual state (RUN, IDLE, FAULT) of the designated output
06088   * @param  hhrtim pointer to HAL HRTIM handle
06089   * @param  TimerIdx Timer index
06090   *                   This parameter can be one of the following values:
06091   *                   @arg HRTIM_TIMERINDEX_TIMER_A for timer A
06092   *                   @arg HRTIM_TIMERINDEX_TIMER_B for timer B
06093   *                   @arg HRTIM_TIMERINDEX_TIMER_C for timer C
06094   *                   @arg HRTIM_TIMERINDEX_TIMER_D for timer D
06095   *                   @arg HRTIM_TIMERINDEX_TIMER_E for timer E
06096   * @param  Output Timer output
06097   *                    This parameter can be one of the following values:
06098   *                    @arg HRTIM_OUTPUT_TA1: Timer A - Output 1
06099   *                    @arg HRTIM_OUTPUT_TA2: Timer A - Output 2
06100   *                    @arg HRTIM_OUTPUT_TB1: Timer B - Output 1
06101   *                    @arg HRTIM_OUTPUT_TB2: Timer B - Output 2
06102   *                    @arg HRTIM_OUTPUT_TC1: Timer C - Output 1
06103   *                    @arg HRTIM_OUTPUT_TC2: Timer C - Output 2
06104   *                    @arg HRTIM_OUTPUT_TD1: Timer D - Output 1
06105   *                    @arg HRTIM_OUTPUT_TD2: Timer D - Output 2
06106   *                    @arg HRTIM_OUTPUT_TE1: Timer E - Output 1
06107   *                    @arg HRTIM_OUTPUT_TE2: Timer E - Output 2
06108   * @retval Output state
06109   */
06110 uint32_t HAL_HRTIM_WaveformGetOutputState(HRTIM_HandleTypeDef * hhrtim,
06111                                           uint32_t TimerIdx,
06112                                           uint32_t Output)
06113 {
06114   uint32_t output_bit = (uint32_t)RESET;
06115   uint32_t output_state;
06116 
06117   /* Check parameters */
06118   assert_param(IS_HRTIM_TIMER_OUTPUT(TimerIdx, Output));
06119 
06120   /* Prevent unused argument(s) compilation warning */
06121   UNUSED(TimerIdx);
06122 
06123   /* Set output state according to output control status and output disable status */
06124   switch (Output)
06125   {
06126   case HRTIM_OUTPUT_TA1:
06127     {
06128       output_bit = HRTIM_OENR_TA1OEN;
06129       break;
06130     }
06131 
06132   case HRTIM_OUTPUT_TA2:
06133     {
06134       output_bit = HRTIM_OENR_TA2OEN;
06135       break;
06136     }
06137 
06138   case HRTIM_OUTPUT_TB1:
06139     {
06140       output_bit = HRTIM_OENR_TB1OEN;
06141       break;
06142     }
06143 
06144   case HRTIM_OUTPUT_TB2:
06145     {
06146       output_bit = HRTIM_OENR_TB2OEN;
06147       break;
06148     }
06149 
06150   case HRTIM_OUTPUT_TC1:
06151     {
06152       output_bit = HRTIM_OENR_TC1OEN;
06153       break;
06154     }
06155 
06156   case HRTIM_OUTPUT_TC2:
06157     {
06158       output_bit = HRTIM_OENR_TC2OEN;
06159       break;
06160     }
06161 
06162   case HRTIM_OUTPUT_TD1:
06163     {
06164       output_bit = HRTIM_OENR_TD1OEN;
06165       break;
06166     }
06167 
06168   case HRTIM_OUTPUT_TD2:
06169     {
06170       output_bit = HRTIM_OENR_TD2OEN;
06171       break;
06172     }
06173 
06174   case HRTIM_OUTPUT_TE1:
06175     {
06176       output_bit = HRTIM_OENR_TE1OEN;
06177       break;
06178     }
06179 
06180   case HRTIM_OUTPUT_TE2:
06181     {
06182       output_bit = HRTIM_OENR_TE2OEN;
06183       break;
06184     }
06185 
06186   default:
06187     {
06188       hhrtim->State = HAL_HRTIM_STATE_ERROR;
06189 
06190       /* Process Unlocked */
06191       __HAL_UNLOCK(hhrtim);
06192 
06193       break;
06194     }
06195   }
06196 
06197   if(hhrtim->State == HAL_HRTIM_STATE_ERROR)
06198   {
06199      return (uint32_t)HAL_ERROR;
06200   }
06201 
06202   if ((hhrtim->Instance->sCommonRegs.OENR & output_bit) != (uint32_t)RESET)
06203   {
06204     /* Output is enabled: output in RUN state (whatever output disable status is)*/
06205     output_state = HRTIM_OUTPUTSTATE_RUN;
06206   }
06207   else
06208   {
06209     if ((hhrtim->Instance->sCommonRegs.ODSR & output_bit) != (uint32_t)RESET)
06210     {
06211       /* Output is disabled: output in FAULT state */
06212       output_state = HRTIM_OUTPUTSTATE_FAULT;
06213     }
06214     else
06215     {
06216       /* Output is disabled: output in IDLE state */
06217       output_state = HRTIM_OUTPUTSTATE_IDLE;
06218     }
06219   }
06220 
06221   return(output_state);
06222 }
06223 
06224 /**
06225   * @brief  Return the level (active or inactive) of the designated output
06226   *         when the delayed protection was triggered.
06227   * @param  hhrtim pointer to HAL HRTIM handle
06228   * @param  TimerIdx Timer index
06229   *                   This parameter can be one of the following values:
06230   *                   @arg HRTIM_TIMERINDEX_TIMER_A for timer A
06231   *                   @arg HRTIM_TIMERINDEX_TIMER_B for timer B
06232   *                   @arg HRTIM_TIMERINDEX_TIMER_C for timer C
06233   *                   @arg HRTIM_TIMERINDEX_TIMER_D for timer D
06234   *                   @arg HRTIM_TIMERINDEX_TIMER_E for timer E
06235   * @param  Output Timer output
06236   *                    This parameter can be one of the following values:
06237   *                    @arg HRTIM_OUTPUT_TA1: Timer A - Output 1
06238   *                    @arg HRTIM_OUTPUT_TA2: Timer A - Output 2
06239   *                    @arg HRTIM_OUTPUT_TB1: Timer B - Output 1
06240   *                    @arg HRTIM_OUTPUT_TB2: Timer B - Output 2
06241   *                    @arg HRTIM_OUTPUT_TC1: Timer C - Output 1
06242   *                    @arg HRTIM_OUTPUT_TC2: Timer C - Output 2
06243   *                    @arg HRTIM_OUTPUT_TD1: Timer D - Output 1
06244   *                    @arg HRTIM_OUTPUT_TD2: Timer D - Output 2
06245   *                    @arg HRTIM_OUTPUT_TE1: Timer E - Output 1
06246   *                    @arg HRTIM_OUTPUT_TE2: Timer E - Output 2
06247   * @retval Delayed protection status
06248   */
06249 uint32_t HAL_HRTIM_GetDelayedProtectionStatus(HRTIM_HandleTypeDef * hhrtim,
06250                                               uint32_t TimerIdx,
06251                                               uint32_t Output)
06252 {
06253   uint32_t delayed_protection_status = (uint32_t)RESET;
06254 
06255   /* Check parameters */
06256   assert_param(IS_HRTIM_TIMER_OUTPUT(TimerIdx, Output));
06257 
06258   /* Read the delayed protection status */
06259   switch (Output)
06260   {
06261   case HRTIM_OUTPUT_TA1:
06262   case HRTIM_OUTPUT_TB1:
06263   case HRTIM_OUTPUT_TC1:
06264   case HRTIM_OUTPUT_TD1:
06265   case HRTIM_OUTPUT_TE1:
06266     {
06267       if ((hhrtim->Instance->sTimerxRegs[TimerIdx].TIMxISR & HRTIM_TIMISR_O1STAT) != (uint32_t)RESET)
06268       {
06269         /* Output 1 was active when the delayed idle protection was triggered */
06270         delayed_protection_status = HRTIM_OUTPUTLEVEL_ACTIVE;
06271       }
06272       else
06273       {
06274         /* Output 1 was inactive when the delayed idle protection was triggered */
06275         delayed_protection_status = HRTIM_OUTPUTLEVEL_INACTIVE;
06276       }
06277       break;
06278     }
06279 
06280   case HRTIM_OUTPUT_TA2:
06281   case HRTIM_OUTPUT_TB2:
06282   case HRTIM_OUTPUT_TC2:
06283   case HRTIM_OUTPUT_TD2:
06284   case HRTIM_OUTPUT_TE2:
06285     {
06286       if ((hhrtim->Instance->sTimerxRegs[TimerIdx].TIMxISR & HRTIM_TIMISR_O2STAT) != (uint32_t)RESET)
06287       {
06288         /* Output 2 was active when the delayed idle protection was triggered */
06289         delayed_protection_status = HRTIM_OUTPUTLEVEL_ACTIVE;
06290       }
06291       else
06292       {
06293         /* Output 2 was inactive when the delayed idle protection was triggered */
06294         delayed_protection_status = HRTIM_OUTPUTLEVEL_INACTIVE;
06295       }
06296       break;
06297     }
06298 
06299   default:
06300     {
06301       hhrtim->State = HAL_HRTIM_STATE_ERROR;
06302 
06303       /* Process Unlocked */
06304       __HAL_UNLOCK(hhrtim);
06305 
06306       break;
06307     }
06308   }
06309 
06310   if(hhrtim->State == HAL_HRTIM_STATE_ERROR)
06311   {
06312      return (uint32_t)HAL_ERROR;
06313   }
06314 
06315   return delayed_protection_status;
06316 }
06317 
06318 /**
06319   * @brief  Return the actual status (active or inactive) of the burst mode controller
06320   * @param  hhrtim pointer to HAL HRTIM handle
06321   * @retval Burst mode controller status
06322   */
06323 uint32_t HAL_HRTIM_GetBurstStatus(HRTIM_HandleTypeDef * hhrtim)
06324 {
06325   uint32_t burst_mode_status;
06326 
06327   /* Read burst mode status */
06328   burst_mode_status = (hhrtim->Instance->sCommonRegs.BMCR & HRTIM_BMCR_BMSTAT);
06329 
06330   return burst_mode_status;
06331 }
06332 
06333 /**
06334   * @brief  Indicate on which output the signal is currently active (when the
06335   *         push pull mode is enabled).
06336   * @param  hhrtim pointer to HAL HRTIM handle
06337   * @param  TimerIdx Timer index
06338   *                   This parameter can be one of the following values:
06339   *                   @arg HRTIM_TIMERINDEX_TIMER_A for timer A
06340   *                   @arg HRTIM_TIMERINDEX_TIMER_B for timer B
06341   *                   @arg HRTIM_TIMERINDEX_TIMER_C for timer C
06342   *                   @arg HRTIM_TIMERINDEX_TIMER_D for timer D
06343   *                   @arg HRTIM_TIMERINDEX_TIMER_E for timer E
06344   * @retval Burst mode controller status
06345   */
06346 uint32_t HAL_HRTIM_GetCurrentPushPullStatus(HRTIM_HandleTypeDef * hhrtim,
06347                                             uint32_t TimerIdx)
06348 {
06349   uint32_t current_pushpull_status;
06350 
06351   /* Check the parameters */
06352   assert_param(IS_HRTIM_TIMING_UNIT(TimerIdx));
06353 
06354   /* Read current push pull status */
06355   current_pushpull_status = (hhrtim->Instance->sTimerxRegs[TimerIdx].TIMxISR & HRTIM_TIMISR_CPPSTAT);
06356 
06357   return current_pushpull_status;
06358 }
06359 
06360 
06361 /**
06362   * @brief  Indicate on which output the signal was applied, in push-pull mode,
06363             balanced fault mode or delayed idle mode, when the protection was triggered.
06364   * @param  hhrtim pointer to HAL HRTIM handle
06365   * @param  TimerIdx Timer index
06366   *                   This parameter can be one of the following values:
06367   *                   @arg HRTIM_TIMERINDEX_TIMER_A for timer A
06368   *                   @arg HRTIM_TIMERINDEX_TIMER_B for timer B
06369   *                   @arg HRTIM_TIMERINDEX_TIMER_C for timer C
06370   *                   @arg HRTIM_TIMERINDEX_TIMER_D for timer D
06371   *                   @arg HRTIM_TIMERINDEX_TIMER_E for timer E
06372   * @retval Idle Push Pull Status
06373   */
06374 uint32_t HAL_HRTIM_GetIdlePushPullStatus(HRTIM_HandleTypeDef * hhrtim,
06375                                          uint32_t TimerIdx)
06376 {
06377   uint32_t idle_pushpull_status;
06378 
06379   /* Check the parameters */
06380   assert_param(IS_HRTIM_TIMING_UNIT(TimerIdx));
06381 
06382   /* Read current push pull status */
06383   idle_pushpull_status = (hhrtim->Instance->sTimerxRegs[TimerIdx].TIMxISR & HRTIM_TIMISR_IPPSTAT);
06384 
06385   return idle_pushpull_status;
06386 }
06387 
06388 /**
06389   * @}
06390   */
06391 
06392 /** @defgroup HRTIM_Exported_Functions_Group10 Interrupts handling
06393  *  @brief  Functions called when HRTIM generates an interrupt
06394  *          7 interrupts can be generated by the master timer:
06395  *            - Master timer registers update
06396  *            - Synchronization event received
06397  *            - Master timer repetition event
06398  *            - Master Compare 1 to 4 event
06399  *          14 interrupts can be generated by each timing unit:
06400  *            - Delayed protection triggered
06401  *            - Counter reset or roll-over event
06402  *            - Output 1 and output 2 reset (transition active to inactive)
06403  *            - Output 1 and output 2 set (transition inactive to active)
06404  *            - Capture 1 and 2 events
06405  *            - Timing unit registers update
06406  *            - Repetition event
06407  *            - Compare 1 to 4 event
06408  *          7 global interrupts are generated for the whole HRTIM:
06409  *            - System fault and Fault 1 to 5 (regardless of the timing unit attribution)
06410  *            - Burst mode period completed
06411 @verbatim
06412  ===============================================================================
06413                       ##### HRTIM interrupts handling #####
06414  ===============================================================================
06415     [..]
06416     This subsection provides a set of functions allowing to manage the HRTIM
06417     interrupts:
06418       (+)  HRTIM interrupt handler
06419       (+)  Callback function called when Fault1 interrupt occurs
06420       (+)  Callback function called when Fault2 interrupt occurs
06421       (+)  Callback function called when Fault3 interrupt occurs
06422       (+)  Callback function called when Fault4 interrupt occurs
06423       (+)  Callback function called when Fault5 interrupt occurs
06424       (+)  Callback function called when system Fault interrupt occurs
06425       (+)  Callback function called when burst mode period interrupt occurs
06426       (+)  Callback function called when synchronization input interrupt occurs
06427       (+)  Callback function called when a timer register update interrupt occurs
06428       (+)  Callback function called when a timer repetition interrupt occurs
06429       (+)  Callback function called when a compare 1 match interrupt occurs
06430       (+)  Callback function called when a compare 2 match interrupt occurs
06431       (+)  Callback function called when a compare 3 match interrupt occurs
06432       (+)  Callback function called when a compare 4 match interrupt occurs
06433       (+)  Callback function called when a capture 1 interrupt occurs
06434       (+)  Callback function called when a capture 2 interrupt occurs
06435       (+)  Callback function called when a delayed protection interrupt occurs
06436       (+)  Callback function called when a timer counter reset interrupt occurs
06437       (+)  Callback function called when a timer output 1 set interrupt occurs
06438       (+)  Callback function called when a timer output 1 reset interrupt occurs
06439       (+)  Callback function called when a timer output 2 set interrupt occurs
06440       (+)  Callback function called when a timer output 2 reset interrupt occurs
06441       (+)  Callback function called when a timer output 2 reset interrupt occurs
06442       (+)  Callback function called upon completion of a burst DMA transfer
06443       (+)  HRTIM callback function registration
06444       (+)  HRTIM callback function unregistration
06445       (+)  HRTIM Timer x callback function registration
06446       (+)  HRTIM Timer x callback function unregistration
06447 
06448 @endverbatim
06449   * @{
06450   */
06451 
06452 /**
06453   * @brief  This function handles HRTIM interrupt request.
06454   * @param  hhrtim pointer to HAL HRTIM handle
06455   * @param  TimerIdx Timer index
06456   *                   This parameter can be any value of HRTIM_Timer_Index
06457   * @retval None
06458   */
06459 void HAL_HRTIM_IRQHandler(HRTIM_HandleTypeDef * hhrtim,
06460                           uint32_t TimerIdx)
06461 {
06462   /* HRTIM interrupts handling */
06463   if (TimerIdx == HRTIM_TIMERINDEX_COMMON)
06464   {
06465     HRTIM_HRTIM_ISR(hhrtim);
06466   }
06467   else if (TimerIdx == HRTIM_TIMERINDEX_MASTER)
06468   {
06469     /* Master related interrupts handling */
06470     HRTIM_Master_ISR(hhrtim);
06471   }
06472   else
06473   {
06474     /* Timing unit related interrupts handling */
06475     HRTIM_Timer_ISR(hhrtim, TimerIdx);
06476   }
06477 
06478 }
06479 
06480 /**
06481   * @brief  Callback function invoked when a fault 1 interrupt occurred
06482   * @param  hhrtim pointer to HAL HRTIM handle  * @retval None
06483   * @retval None
06484   */
06485 __weak void HAL_HRTIM_Fault1Callback(HRTIM_HandleTypeDef * hhrtim)
06486 {
06487   /* Prevent unused argument(s) compilation warning */
06488   UNUSED(hhrtim);
06489 
06490   /* NOTE : This function should not be modified, when the callback is needed,
06491             the HAL_HRTIM_Fault1Callback could be implemented in the user file
06492    */
06493 }
06494 
06495 /**
06496   * @brief  Callback function invoked when a fault 2 interrupt occurred
06497   * @param  hhrtim pointer to HAL HRTIM handle
06498   * @retval None
06499   */
06500 __weak void HAL_HRTIM_Fault2Callback(HRTIM_HandleTypeDef * hhrtim)
06501 {
06502   /* Prevent unused argument(s) compilation warning */
06503   UNUSED(hhrtim);
06504 
06505   /* NOTE : This function should not be modified, when the callback is needed,
06506             the HAL_HRTIM_Fault2Callback could be implemented in the user file
06507    */
06508 }
06509 
06510 /**
06511   * @brief  Callback function invoked when a fault 3 interrupt occurred
06512   * @param  hhrtim pointer to HAL HRTIM handle
06513   * @retval None
06514   */
06515 __weak void HAL_HRTIM_Fault3Callback(HRTIM_HandleTypeDef * hhrtim)
06516 {
06517   /* Prevent unused argument(s) compilation warning */
06518   UNUSED(hhrtim);
06519 
06520   /* NOTE : This function should not be modified, when the callback is needed,
06521             the HAL_HRTIM_Fault3Callback could be implemented in the user file
06522    */
06523 }
06524 
06525 /**
06526   * @brief  Callback function invoked when a fault 4 interrupt occurred
06527   * @param  hhrtim pointer to HAL HRTIM handle
06528   * @retval None
06529   */
06530 __weak void HAL_HRTIM_Fault4Callback(HRTIM_HandleTypeDef * hhrtim)
06531 {
06532   /* Prevent unused argument(s) compilation warning */
06533   UNUSED(hhrtim);
06534 
06535   /* NOTE : This function should not be modified, when the callback is needed,
06536             the HAL_HRTIM_Fault4Callback could be implemented in the user file
06537    */
06538 }
06539 
06540 /**
06541   * @brief  Callback function invoked when a fault 5 interrupt occurred
06542   * @param  hhrtim pointer to HAL HRTIM handle
06543   * @retval None
06544   */
06545 __weak void HAL_HRTIM_Fault5Callback(HRTIM_HandleTypeDef * hhrtim)
06546 {
06547   /* Prevent unused argument(s) compilation warning */
06548   UNUSED(hhrtim);
06549 
06550   /* NOTE : This function should not be modified, when the callback is needed,
06551             the HAL_HRTIM_Fault5Callback could be implemented in the user file
06552    */
06553 }
06554 
06555 /**
06556   * @brief  Callback function invoked when a system fault interrupt occurred
06557   * @param  hhrtim pointer to HAL HRTIM handle
06558   * @retval None
06559   */
06560 __weak void HAL_HRTIM_SystemFaultCallback(HRTIM_HandleTypeDef * hhrtim)
06561 {
06562   /* Prevent unused argument(s) compilation warning */
06563   UNUSED(hhrtim);
06564 
06565   /* NOTE : This function should not be modified, when the callback is needed,
06566             the HAL_HRTIM_SystemFaultCallback could be implemented in the user file
06567    */
06568 }
06569 
06570 /**
06571   * @brief  Callback function invoked when the end of the burst mode period is reached
06572   * @param  hhrtim pointer to HAL HRTIM handle
06573   * @retval None
06574   */
06575 __weak void HAL_HRTIM_BurstModePeriodCallback(HRTIM_HandleTypeDef * hhrtim)
06576 {
06577   /* Prevent unused argument(s) compilation warning */
06578   UNUSED(hhrtim);
06579 
06580   /* NOTE : This function should not be modified, when the callback is needed,
06581             the HAL_HRTIM_BurstModeCallback could be implemented in the user file
06582    */
06583 }
06584 
06585 /**
06586   * @brief  Callback function invoked when a synchronization input event is received
06587   * @param  hhrtim pointer to HAL HRTIM handle
06588   * @retval None
06589   */
06590 __weak void HAL_HRTIM_SynchronizationEventCallback(HRTIM_HandleTypeDef * hhrtim)
06591 {
06592   /* Prevent unused argument(s) compilation warning */
06593   UNUSED(hhrtim);
06594 
06595   /* NOTE : This function should not be modified, when the callback is needed,
06596             the HAL_HRTIM_SynchronizationEventCallback could be implemented in the user file
06597    */
06598 }
06599 
06600 /**
06601   * @brief  Callback function invoked when timer registers are updated
06602   * @param  hhrtim pointer to HAL HRTIM handle
06603   * @param  TimerIdx Timer index
06604   *                   This parameter can be one of the following values:
06605   *                   @arg HRTIM_TIMERINDEX_MASTER  for master timer
06606   *                   @arg HRTIM_TIMERINDEX_TIMER_A for timer A
06607   *                   @arg HRTIM_TIMERINDEX_TIMER_B for timer B
06608   *                   @arg HRTIM_TIMERINDEX_TIMER_C for timer C
06609   *                   @arg HRTIM_TIMERINDEX_TIMER_D for timer D
06610   *                   @arg HRTIM_TIMERINDEX_TIMER_E for timer E
06611   * @retval None
06612   */
06613 __weak void HAL_HRTIM_RegistersUpdateCallback(HRTIM_HandleTypeDef * hhrtim,
06614                                               uint32_t TimerIdx)
06615 {
06616   /* Prevent unused argument(s) compilation warning */
06617   UNUSED(hhrtim);
06618   UNUSED(TimerIdx);
06619 
06620   /* NOTE : This function should not be modified, when the callback is needed,
06621             the HAL_HRTIM_Master_RegistersUpdateCallback could be implemented in the user file
06622    */
06623 }
06624 
06625 /**
06626   * @brief  Callback function invoked when timer repetition period has elapsed
06627   * @param  hhrtim pointer to HAL HRTIM handle
06628   * @param  TimerIdx Timer index
06629   *                   This parameter can be one of the following values:
06630   *                   @arg HRTIM_TIMERINDEX_MASTER  for master timer
06631   *                   @arg HRTIM_TIMERINDEX_TIMER_A for timer A
06632   *                   @arg HRTIM_TIMERINDEX_TIMER_B for timer B
06633   *                   @arg HRTIM_TIMERINDEX_TIMER_C for timer C
06634   *                   @arg HRTIM_TIMERINDEX_TIMER_D for timer D
06635   *                   @arg HRTIM_TIMERINDEX_TIMER_E for timer E
06636   * @retval None
06637   */
06638 __weak void HAL_HRTIM_RepetitionEventCallback(HRTIM_HandleTypeDef * hhrtim,
06639                                               uint32_t TimerIdx)
06640 {
06641   /* Prevent unused argument(s) compilation warning */
06642   UNUSED(hhrtim);
06643   UNUSED(TimerIdx);
06644 
06645   /* NOTE : This function should not be modified, when the callback is needed,
06646             the HAL_HRTIM_Master_RepetitionEventCallback could be implemented in the user file
06647    */
06648 }
06649 
06650 /**
06651   * @brief  Callback function invoked when the timer counter matches the value
06652   *         programmed in the compare 1 register
06653   * @param  hhrtim pointer to HAL HRTIM handle
06654   * @param  TimerIdx Timer index
06655   *                   This parameter can be one of the following values:
06656   *                   @arg HRTIM_TIMERINDEX_MASTER  for master timer
06657   *                   @arg HRTIM_TIMERINDEX_TIMER_A for timer A
06658   *                   @arg HRTIM_TIMERINDEX_TIMER_B for timer B
06659   *                   @arg HRTIM_TIMERINDEX_TIMER_C for timer C
06660   *                   @arg HRTIM_TIMERINDEX_TIMER_D for timer D
06661   *                   @arg HRTIM_TIMERINDEX_TIMER_E for timer E
06662   * @retval None
06663   */
06664 __weak void HAL_HRTIM_Compare1EventCallback(HRTIM_HandleTypeDef * hhrtim,
06665                                               uint32_t TimerIdx)
06666 {
06667   /* Prevent unused argument(s) compilation warning */
06668   UNUSED(hhrtim);
06669   UNUSED(TimerIdx);
06670 
06671   /* NOTE : This function should not be modified, when the callback is needed,
06672             the HAL_HRTIM_Master_Compare1EventCallback could be implemented in the user file
06673    */
06674 }
06675 
06676 /**
06677   * @brief  Callback function invoked when the timer counter matches the value
06678   *         programmed in the compare 2 register
06679   * @param  hhrtim pointer to HAL HRTIM handle
06680   * @retval None
06681   * @param  TimerIdx Timer index
06682   *                   This parameter can be one of the following values:
06683   *                   @arg HRTIM_TIMERINDEX_MASTER  for master timer
06684   *                   @arg HRTIM_TIMERINDEX_TIMER_A for timer A
06685   *                   @arg HRTIM_TIMERINDEX_TIMER_B for timer B
06686   *                   @arg HRTIM_TIMERINDEX_TIMER_C for timer C
06687   *                   @arg HRTIM_TIMERINDEX_TIMER_D for timer D
06688   *                   @arg HRTIM_TIMERINDEX_TIMER_E for timer E
06689   */
06690 __weak void HAL_HRTIM_Compare2EventCallback(HRTIM_HandleTypeDef * hhrtim,
06691                                               uint32_t TimerIdx)
06692 {
06693   /* Prevent unused argument(s) compilation warning */
06694   UNUSED(hhrtim);
06695   UNUSED(TimerIdx);
06696 
06697   /* NOTE : This function should not be modified, when the callback is needed,
06698             the HAL_HRTIM_Master_Compare2EventCallback could be implemented in the user file
06699    */
06700 }
06701 
06702 /**
06703   * @brief  Callback function invoked when the timer counter matches the value
06704   *         programmed in the compare 3 register
06705   * @param  hhrtim pointer to HAL HRTIM handle
06706   * @param  TimerIdx Timer index
06707   *                   This parameter can be one of the following values:
06708   *                   @arg HRTIM_TIMERINDEX_MASTER  for master timer
06709   *                   @arg HRTIM_TIMERINDEX_TIMER_A for timer A
06710   *                   @arg HRTIM_TIMERINDEX_TIMER_B for timer B
06711   *                   @arg HRTIM_TIMERINDEX_TIMER_C for timer C
06712   *                   @arg HRTIM_TIMERINDEX_TIMER_D for timer D
06713   *                   @arg HRTIM_TIMERINDEX_TIMER_E for timer E
06714   * @retval None
06715   */
06716 __weak void HAL_HRTIM_Compare3EventCallback(HRTIM_HandleTypeDef * hhrtim,
06717                                               uint32_t TimerIdx)
06718 {
06719   /* Prevent unused argument(s) compilation warning */
06720   UNUSED(hhrtim);
06721   UNUSED(TimerIdx);
06722 
06723   /* NOTE : This function should not be modified, when the callback is needed,
06724             the HAL_HRTIM_Master_Compare3EventCallback could be implemented in the user file
06725    */
06726 }
06727 
06728 /**
06729   * @brief  Callback function invoked when the timer counter matches the value
06730   *         programmed in the compare 4 register.
06731   * @param  hhrtim pointer to HAL HRTIM handle
06732   * @param  TimerIdx Timer index
06733   *                   This parameter can be one of the following values:
06734   *                   @arg HRTIM_TIMERINDEX_MASTER  for master timer
06735   *                   @arg HRTIM_TIMERINDEX_TIMER_A for timer A
06736   *                   @arg HRTIM_TIMERINDEX_TIMER_B for timer B
06737   *                   @arg HRTIM_TIMERINDEX_TIMER_C for timer C
06738   *                   @arg HRTIM_TIMERINDEX_TIMER_D for timer D
06739   *                   @arg HRTIM_TIMERINDEX_TIMER_E for timer E
06740   * @retval None
06741   */
06742 __weak void HAL_HRTIM_Compare4EventCallback(HRTIM_HandleTypeDef * hhrtim,
06743                                               uint32_t TimerIdx)
06744 {
06745   /* Prevent unused argument(s) compilation warning */
06746   UNUSED(hhrtim);
06747   UNUSED(TimerIdx);
06748 
06749   /* NOTE : This function should not be modified, when the callback is needed,
06750             the HAL_HRTIM_Master_Compare4EventCallback could be implemented in the user file
06751    */
06752 }
06753 
06754 /**
06755   * @brief  Callback function invoked when the timer x capture 1 event occurs
06756   * @param  hhrtim pointer to HAL HRTIM handle
06757   * @param  TimerIdx Timer index
06758   *                   This parameter can be one of the following values:
06759   *                   @arg HRTIM_TIMERINDEX_TIMER_A for timer A
06760   *                   @arg HRTIM_TIMERINDEX_TIMER_B for timer B
06761   *                   @arg HRTIM_TIMERINDEX_TIMER_C for timer C
06762   *                   @arg HRTIM_TIMERINDEX_TIMER_D for timer D
06763   *                   @arg HRTIM_TIMERINDEX_TIMER_E for timer E
06764   * @retval None
06765   */
06766 __weak void HAL_HRTIM_Capture1EventCallback(HRTIM_HandleTypeDef * hhrtim,
06767                                               uint32_t TimerIdx)
06768 {
06769   /* Prevent unused argument(s) compilation warning */
06770   UNUSED(hhrtim);
06771   UNUSED(TimerIdx);
06772 
06773   /* NOTE : This function should not be modified, when the callback is needed,
06774             the HAL_HRTIM_Timer_Capture1EventCallback could be implemented in the user file
06775    */
06776 }
06777 
06778 /**
06779   * @brief  Callback function invoked when the timer x capture 2 event occurs
06780   * @param  hhrtim pointer to HAL HRTIM handle
06781   * @param  TimerIdx Timer index
06782   *                   This parameter can be one of the following values:
06783   *                   @arg HRTIM_TIMERINDEX_TIMER_A for timer A
06784   *                   @arg HRTIM_TIMERINDEX_TIMER_B for timer B
06785   *                   @arg HRTIM_TIMERINDEX_TIMER_C for timer C
06786   *                   @arg HRTIM_TIMERINDEX_TIMER_D for timer D
06787   *                   @arg HRTIM_TIMERINDEX_TIMER_E for timer E
06788   * @retval None
06789   */
06790 __weak void HAL_HRTIM_Capture2EventCallback(HRTIM_HandleTypeDef * hhrtim,
06791                                               uint32_t TimerIdx)
06792 {
06793   /* Prevent unused argument(s) compilation warning */
06794   UNUSED(hhrtim);
06795   UNUSED(TimerIdx);
06796 
06797   /* NOTE : This function should not be modified, when the callback is needed,
06798             the HAL_HRTIM_Timer_Capture2EventCallback could be implemented in the user file
06799    */
06800 }
06801 
06802 /**
06803   * @brief  Callback function invoked when the delayed idle or balanced idle mode is
06804   *         entered.
06805   * @param  hhrtim pointer to HAL HRTIM handle
06806   * @param  TimerIdx Timer index
06807   *                   This parameter can be one of the following values:
06808   *                   @arg HRTIM_TIMERINDEX_TIMER_A for timer A
06809   *                   @arg HRTIM_TIMERINDEX_TIMER_B for timer B
06810   *                   @arg HRTIM_TIMERINDEX_TIMER_C for timer C
06811   *                   @arg HRTIM_TIMERINDEX_TIMER_D for timer D
06812   *                   @arg HRTIM_TIMERINDEX_TIMER_E for timer E
06813   * @retval None
06814   */
06815 __weak void HAL_HRTIM_DelayedProtectionCallback(HRTIM_HandleTypeDef * hhrtim,
06816                                               uint32_t TimerIdx)
06817 {
06818   /* Prevent unused argument(s) compilation warning */
06819   UNUSED(hhrtim);
06820   UNUSED(TimerIdx);
06821 
06822   /* NOTE : This function should not be modified, when the callback is needed,
06823             the HAL_HRTIM_Timer_DelayedProtectionCallback could be implemented in the user file
06824    */
06825 }
06826 
06827 /**
06828   * @brief  Callback function invoked when the timer x counter reset/roll-over
06829   *         event occurs.
06830   * @param  hhrtim pointer to HAL HRTIM handle
06831   * @param  TimerIdx Timer index
06832   *                   This parameter can be one of the following values:
06833   *                   @arg HRTIM_TIMERINDEX_TIMER_A for timer A
06834   *                   @arg HRTIM_TIMERINDEX_TIMER_B for timer B
06835   *                   @arg HRTIM_TIMERINDEX_TIMER_C for timer C
06836   *                   @arg HRTIM_TIMERINDEX_TIMER_D for timer D
06837   *                   @arg HRTIM_TIMERINDEX_TIMER_E for timer E
06838   * @retval None
06839   */
06840 __weak void HAL_HRTIM_CounterResetCallback(HRTIM_HandleTypeDef * hhrtim,
06841                                               uint32_t TimerIdx)
06842 {
06843   /* Prevent unused argument(s) compilation warning */
06844   UNUSED(hhrtim);
06845   UNUSED(TimerIdx);
06846 
06847   /* NOTE : This function should not be modified, when the callback is needed,
06848             the HAL_HRTIM_Timer_CounterResetCallback could be implemented in the user file
06849    */
06850 }
06851 
06852 /**
06853   * @brief  Callback function invoked when the timer x output 1 is set
06854   * @param  hhrtim pointer to HAL HRTIM handle
06855   * @param  TimerIdx Timer index
06856   *                   This parameter can be one of the following values:
06857   *                   @arg HRTIM_TIMERINDEX_TIMER_A for timer A
06858   *                   @arg HRTIM_TIMERINDEX_TIMER_B for timer B
06859   *                   @arg HRTIM_TIMERINDEX_TIMER_C for timer C
06860   *                   @arg HRTIM_TIMERINDEX_TIMER_D for timer D
06861   *                   @arg HRTIM_TIMERINDEX_TIMER_E for timer E
06862   * @retval None
06863   */
06864 __weak void HAL_HRTIM_Output1SetCallback(HRTIM_HandleTypeDef * hhrtim,
06865                                               uint32_t TimerIdx)
06866 {
06867   /* Prevent unused argument(s) compilation warning */
06868   UNUSED(hhrtim);
06869   UNUSED(TimerIdx);
06870 
06871   /* NOTE : This function should not be modified, when the callback is needed,
06872             the HAL_HRTIM_Timer_Output1SetCallback could be implemented in the user file
06873    */
06874 }
06875 
06876 /**
06877   * @brief  Callback function invoked when the timer x output 1 is reset
06878   * @param  hhrtim pointer to HAL HRTIM handle
06879   * @param  TimerIdx Timer index
06880   *                   This parameter can be one of the following values:
06881   *                   @arg HRTIM_TIMERINDEX_TIMER_A for timer A
06882   *                   @arg HRTIM_TIMERINDEX_TIMER_B for timer B
06883   *                   @arg HRTIM_TIMERINDEX_TIMER_C for timer C
06884   *                   @arg HRTIM_TIMERINDEX_TIMER_D for timer D
06885   *                   @arg HRTIM_TIMERINDEX_TIMER_E for timer E
06886   * @retval None
06887   */
06888 __weak void HAL_HRTIM_Output1ResetCallback(HRTIM_HandleTypeDef * hhrtim,
06889                                               uint32_t TimerIdx)
06890 {
06891   /* Prevent unused argument(s) compilation warning */
06892   UNUSED(hhrtim);
06893   UNUSED(TimerIdx);
06894 
06895   /* NOTE : This function should not be modified, when the callback is needed,
06896             the HAL_HRTIM_Timer_Output1ResetCallback could be implemented in the user file
06897    */
06898 }
06899 
06900 /**
06901   * @brief  Callback function invoked when the timer x output 2 is set
06902   * @param  hhrtim pointer to HAL HRTIM handle
06903   * @param  TimerIdx Timer index
06904   *                   This parameter can be one of the following values:
06905   *                   @arg HRTIM_TIMERINDEX_TIMER_A for timer A
06906   *                   @arg HRTIM_TIMERINDEX_TIMER_B for timer B
06907   *                   @arg HRTIM_TIMERINDEX_TIMER_C for timer C
06908   *                   @arg HRTIM_TIMERINDEX_TIMER_D for timer D
06909   *                   @arg HRTIM_TIMERINDEX_TIMER_E for timer E
06910   * @retval None
06911   */
06912 __weak void HAL_HRTIM_Output2SetCallback(HRTIM_HandleTypeDef * hhrtim,
06913                                               uint32_t TimerIdx)
06914 {
06915   /* Prevent unused argument(s) compilation warning */
06916   UNUSED(hhrtim);
06917   UNUSED(TimerIdx);
06918 
06919   /* NOTE : This function should not be modified, when the callback is needed,
06920             the HAL_HRTIM_Timer_Output2SetCallback could be implemented in the user file
06921    */
06922 }
06923 
06924 /**
06925   * @brief  Callback function invoked when the timer x output 2 is reset
06926   * @param  hhrtim pointer to HAL HRTIM handle
06927   * @param  TimerIdx Timer index
06928   *                   This parameter can be one of the following values:
06929   *                   @arg HRTIM_TIMERINDEX_TIMER_A for timer A
06930   *                   @arg HRTIM_TIMERINDEX_TIMER_B for timer B
06931   *                   @arg HRTIM_TIMERINDEX_TIMER_C for timer C
06932   *                   @arg HRTIM_TIMERINDEX_TIMER_D for timer D
06933   *                   @arg HRTIM_TIMERINDEX_TIMER_E for timer E
06934   * @retval None
06935   */
06936 __weak void HAL_HRTIM_Output2ResetCallback(HRTIM_HandleTypeDef * hhrtim,
06937                                               uint32_t TimerIdx)
06938 {
06939   /* Prevent unused argument(s) compilation warning */
06940   UNUSED(hhrtim);
06941   UNUSED(TimerIdx);
06942 
06943   /* NOTE : This function should not be modified, when the callback is needed,
06944             the HAL_HRTIM_Timer_Output2ResetCallback could be implemented in the user file
06945    */
06946 }
06947 
06948 /**
06949   * @brief  Callback function invoked when a DMA burst transfer is completed
06950   * @param  hhrtim pointer to HAL HRTIM handle
06951   * @param  TimerIdx Timer index
06952   *                   This parameter can be one of the following values:
06953   *                   @arg HRTIM_TIMERINDEX_MASTER  for master timer
06954   *                   @arg HRTIM_TIMERINDEX_TIMER_A for timer A
06955   *                   @arg HRTIM_TIMERINDEX_TIMER_B for timer B
06956   *                   @arg HRTIM_TIMERINDEX_TIMER_C for timer C
06957   *                   @arg HRTIM_TIMERINDEX_TIMER_D for timer D
06958   *                   @arg HRTIM_TIMERINDEX_TIMER_E for timer E
06959   * @retval None
06960   */
06961 __weak void HAL_HRTIM_BurstDMATransferCallback(HRTIM_HandleTypeDef * hhrtim,
06962                                                uint32_t TimerIdx)
06963 {
06964   /* Prevent unused argument(s) compilation warning */
06965   UNUSED(hhrtim);
06966   UNUSED(TimerIdx);
06967 
06968   /* NOTE : This function should not be modified, when the callback is needed,
06969             the HAL_HRTIM_BurstDMATransferCallback could be implemented in the user file
06970    */
06971 }
06972 
06973 /**
06974   * @brief  Callback function invoked when a DMA error occurs
06975   * @param  hhrtim pointer to HAL HRTIM handle
06976   * @retval None
06977   */
06978 __weak void HAL_HRTIM_ErrorCallback(HRTIM_HandleTypeDef *hhrtim)
06979 {
06980   /* Prevent unused argument(s) compilation warning */
06981   UNUSED(hhrtim);
06982 
06983   /* NOTE : This function should not be modified, when the callback is needed,
06984             the HAL_HRTIM_ErrorCallback could be implemented in the user file
06985    */
06986 }
06987 
06988 #if (USE_HAL_HRTIM_REGISTER_CALLBACKS == 1)
06989 /**
06990   * @brief  HRTIM callback function registration
06991   * @param  hhrtim pointer to HAL HRTIM handle
06992   * @param  CallbackID ID of the HRTIM callback function to register
06993   *                   This parameter can be one of the following values:
06994   *                   @arg HAL_HRTIM_FAULT1CALLBACK_CB_ID
06995   *                   @arg HAL_HRTIM_FAULT2CALLBACK_CB_ID
06996   *                   @arg HAL_HRTIM_FAULT3CALLBACK_CB_ID
06997   *                   @arg HAL_HRTIM_FAULT4CALLBACK_CB_ID
06998   *                   @arg HAL_HRTIM_FAULT5CALLBACK_CB_ID
06999   *                   @arg HAL_HRTIM_SYSTEMFAULTCALLBACK_CB_ID
07000   *                   @arg HAL_HRTIM_BURSTMODEPERIODCALLBACK_CB_ID
07001   *                   @arg HAL_HRTIM_SYNCHRONIZATIONEVENTCALLBACK_CB_ID
07002   *                   @arg HAL_HRTIM_ERRORCALLBACK_CB_ID
07003   *                   @arg HAL_HRTIM_MSPINIT_CB_ID
07004   *                   @arg HAL_HRTIM_MSPDEINIT_CB_ID
07005   * @param  pCallback Callback function pointer
07006   * @retval HAL status
07007   */
07008 HAL_StatusTypeDef HAL_HRTIM_RegisterCallback(HRTIM_HandleTypeDef *       hhrtim,
07009                                              HAL_HRTIM_CallbackIDTypeDef CallbackID,
07010                                              pHRTIM_CallbackTypeDef      pCallback)
07011 {
07012   HAL_StatusTypeDef status = HAL_OK;
07013 
07014   if (pCallback == NULL)
07015   {
07016     /* Update the state */
07017     hhrtim->State = HAL_HRTIM_STATE_INVALID_CALLBACK;
07018 
07019     return HAL_ERROR;
07020   }
07021 
07022   /* Process locked */
07023   __HAL_LOCK(hhrtim);
07024 
07025   if (HAL_HRTIM_STATE_READY == hhrtim->State)
07026   {
07027     switch (CallbackID)
07028     {
07029       case HAL_HRTIM_FAULT1CALLBACK_CB_ID :
07030         hhrtim->Fault1Callback = pCallback;
07031         break;
07032 
07033       case HAL_HRTIM_FAULT2CALLBACK_CB_ID :
07034         hhrtim->Fault2Callback = pCallback;
07035         break;
07036 
07037       case HAL_HRTIM_FAULT3CALLBACK_CB_ID :
07038         hhrtim->Fault3Callback = pCallback;
07039         break;
07040 
07041       case HAL_HRTIM_FAULT4CALLBACK_CB_ID :
07042         hhrtim->Fault4Callback = pCallback;
07043         break;
07044 
07045       case HAL_HRTIM_FAULT5CALLBACK_CB_ID :
07046         hhrtim->Fault5Callback = pCallback;
07047         break;
07048 
07049       case HAL_HRTIM_SYSTEMFAULTCALLBACK_CB_ID :
07050         hhrtim->SystemFaultCallback = pCallback;
07051         break;
07052 
07053 
07054       case HAL_HRTIM_BURSTMODEPERIODCALLBACK_CB_ID :
07055         hhrtim->BurstModePeriodCallback = pCallback;
07056         break;
07057 
07058       case HAL_HRTIM_SYNCHRONIZATIONEVENTCALLBACK_CB_ID :
07059         hhrtim->SynchronizationEventCallback = pCallback;
07060         break;
07061 
07062       case HAL_HRTIM_ERRORCALLBACK_CB_ID :
07063         hhrtim->ErrorCallback = pCallback;
07064         break;
07065 
07066       case HAL_HRTIM_MSPINIT_CB_ID :
07067         hhrtim->MspInitCallback = pCallback;
07068         break;
07069 
07070       case HAL_HRTIM_MSPDEINIT_CB_ID :
07071         hhrtim->MspDeInitCallback = pCallback;
07072         break;
07073 
07074       default :
07075         /* Update the state */
07076         hhrtim->State = HAL_HRTIM_STATE_INVALID_CALLBACK;
07077 
07078         /* Return error status */
07079         status = HAL_ERROR;
07080         break;
07081     }
07082   }
07083   else if (HAL_HRTIM_STATE_RESET == hhrtim->State)
07084   {
07085     switch (CallbackID)
07086     {
07087       case HAL_HRTIM_MSPINIT_CB_ID :
07088         hhrtim->MspInitCallback = pCallback;
07089         break;
07090 
07091       case HAL_HRTIM_MSPDEINIT_CB_ID :
07092         hhrtim->MspDeInitCallback = pCallback;
07093         break;
07094 
07095       default :
07096         /* Update the state */
07097         hhrtim->State = HAL_HRTIM_STATE_INVALID_CALLBACK;
07098 
07099         /* Return error status */
07100         status = HAL_ERROR;
07101         break;
07102     }
07103   }
07104   else
07105   {
07106     /* Update the state */
07107     hhrtim->State = HAL_HRTIM_STATE_INVALID_CALLBACK;
07108 
07109     /* Return error status */
07110     status = HAL_ERROR;
07111   }
07112 
07113   /* Release Lock */
07114   __HAL_UNLOCK(hhrtim);
07115 
07116   return status;
07117 }
07118 
07119 /**
07120   * @brief  HRTIM callback function un-registration
07121   * @param  hhrtim pointer to HAL HRTIM handle
07122   * @param  CallbackID ID of the HRTIM callback function to unregister
07123   *                   This parameter can be one of the following values:
07124   *                   @arg HAL_HRTIM_FAULT1CALLBACK_CB_ID
07125   *                   @arg HAL_HRTIM_FAULT2CALLBACK_CB_ID
07126   *                   @arg HAL_HRTIM_FAULT3CALLBACK_CB_ID
07127   *                   @arg HAL_HRTIM_FAULT4CALLBACK_CB_ID
07128   *                   @arg HAL_HRTIM_FAULT5CALLBACK_CB_ID
07129   *                   @arg HAL_HRTIM_SYSTEMFAULTCALLBACK_CB_ID
07130   *                   @arg HAL_HRTIM_BURSTMODEPERIODCALLBACK_CB_ID
07131   *                   @arg HAL_HRTIM_SYNCHRONIZATIONEVENTCALLBACK_CB_ID
07132   *                   @arg HAL_HRTIM_ERRORCALLBACK_CB_ID
07133   *                   @arg HAL_HRTIM_MSPINIT_CB_ID
07134   *                   @arg HAL_HRTIM_MSPDEINIT_CB_ID
07135   * @retval HAL status
07136   */
07137 HAL_StatusTypeDef HAL_HRTIM_UnRegisterCallback(HRTIM_HandleTypeDef * hhrtim,
07138                                                HAL_HRTIM_CallbackIDTypeDef CallbackID)
07139 {
07140   HAL_StatusTypeDef status = HAL_OK;
07141 
07142   /* Process locked */
07143   __HAL_LOCK(hhrtim);
07144 
07145   if (HAL_HRTIM_STATE_READY == hhrtim->State)
07146   {
07147     switch (CallbackID)
07148     {
07149     case HAL_HRTIM_FAULT1CALLBACK_CB_ID :
07150       hhrtim->Fault1Callback = HAL_HRTIM_Fault1Callback;
07151       break;
07152 
07153     case HAL_HRTIM_FAULT2CALLBACK_CB_ID :
07154       hhrtim->Fault2Callback = HAL_HRTIM_Fault2Callback;
07155       break;
07156 
07157     case HAL_HRTIM_FAULT3CALLBACK_CB_ID :
07158       hhrtim->Fault3Callback = HAL_HRTIM_Fault3Callback;
07159       break;
07160 
07161     case HAL_HRTIM_FAULT4CALLBACK_CB_ID :
07162       hhrtim->Fault4Callback = HAL_HRTIM_Fault4Callback;
07163       break;
07164 
07165     case HAL_HRTIM_FAULT5CALLBACK_CB_ID :
07166       hhrtim->Fault5Callback = HAL_HRTIM_Fault5Callback;
07167       break;
07168 
07169     case HAL_HRTIM_SYSTEMFAULTCALLBACK_CB_ID :
07170       hhrtim->SystemFaultCallback = HAL_HRTIM_SystemFaultCallback;
07171       break;
07172 
07173 
07174     case HAL_HRTIM_BURSTMODEPERIODCALLBACK_CB_ID :
07175       hhrtim->BurstModePeriodCallback = HAL_HRTIM_BurstModePeriodCallback;
07176       break;
07177 
07178     case HAL_HRTIM_SYNCHRONIZATIONEVENTCALLBACK_CB_ID :
07179       hhrtim->SynchronizationEventCallback = HAL_HRTIM_SynchronizationEventCallback;
07180       break;
07181 
07182     case HAL_HRTIM_ERRORCALLBACK_CB_ID :
07183       hhrtim->ErrorCallback = HAL_HRTIM_ErrorCallback;
07184       break;
07185 
07186     case HAL_HRTIM_MSPINIT_CB_ID :
07187       hhrtim->MspInitCallback = HAL_HRTIM_MspInit;
07188       break;
07189 
07190     case HAL_HRTIM_MSPDEINIT_CB_ID :
07191       hhrtim->MspDeInitCallback = HAL_HRTIM_MspDeInit;
07192       break;
07193 
07194     default :
07195     /* Update the state */
07196     hhrtim->State = HAL_HRTIM_STATE_INVALID_CALLBACK;
07197 
07198     /* Return error status */
07199     status = HAL_ERROR;
07200       break;
07201     }
07202   }
07203   else if (HAL_HRTIM_STATE_RESET == hhrtim->State)
07204   {
07205     switch (CallbackID)
07206     {
07207     case HAL_HRTIM_MSPINIT_CB_ID :
07208       hhrtim->MspInitCallback = HAL_HRTIM_MspInit;
07209       break;
07210 
07211     case HAL_HRTIM_MSPDEINIT_CB_ID :
07212       hhrtim->MspDeInitCallback = HAL_HRTIM_MspDeInit;
07213       break;
07214 
07215     default :
07216     /* Update the state */
07217     hhrtim->State = HAL_HRTIM_STATE_INVALID_CALLBACK;
07218 
07219     /* Return error status */
07220     status =  HAL_ERROR;
07221       break;
07222     }
07223   }
07224   else
07225   {
07226     /* Update the state */
07227     hhrtim->State = HAL_HRTIM_STATE_INVALID_CALLBACK;
07228 
07229     /* Return error status */
07230     status =  HAL_ERROR;
07231   }
07232 
07233   /* Release Lock */
07234   __HAL_UNLOCK(hhrtim);
07235 
07236   return status;
07237 }
07238 
07239 /**
07240   * @brief  HRTIM Timer x callback function registration
07241   * @param  hhrtim pointer to HAL HRTIM handle
07242   * @param  CallbackID ID of the HRTIM Timer x callback function to register
07243   *                   This parameter can be one of the following values:
07244   *                   @arg HAL_HRTIM_REGISTERSUPDATECALLBACK_CB_ID
07245   *                   @arg HAL_HRTIM_REPETITIONEVENTCALLBACK_CB_ID
07246   *                   @arg HAL_HRTIM_COMPARE1EVENTCALLBACK_CB_ID
07247   *                   @arg HAL_HRTIM_COMPARE2EVENTCALLBACK_CB_ID
07248   *                   @arg HAL_HRTIM_COMPARE3EVENTCALLBACK_CB_ID
07249   *                   @arg HAL_HRTIM_COMPARE4EVENTCALLBACK_CB_ID
07250   *                   @arg HAL_HRTIM_CAPTURE1EVENTCALLBACK_CB_ID
07251   *                   @arg HAL_HRTIM_CAPTURE2EVENTCALLBACK_CB_ID
07252   *                   @arg HAL_HRTIM_DELAYEDPROTECTIONCALLBACK_CB_ID
07253   *                   @arg HAL_HRTIM_COUNTERRESETCALLBACK_CB_ID
07254   *                   @arg HAL_HRTIM_OUTPUT1SETCALLBACK_CB_ID
07255   *                   @arg HAL_HRTIM_OUTPUT1RESETCALLBACK_CB_ID
07256   *                   @arg HAL_HRTIM_OUTPUT2SETCALLBACK_CB_ID
07257   *                   @arg HAL_HRTIM_OUTPUT2RESETCALLBACK_CB_ID
07258   *                   @arg HAL_HRTIM_BURSTDMATRANSFERCALLBACK_CB_ID
07259   * @param  pCallback Callback function pointer
07260   * @retval HAL status
07261   */
07262 HAL_StatusTypeDef HAL_HRTIM_TIMxRegisterCallback(HRTIM_HandleTypeDef * hhrtim,
07263                                                  HAL_HRTIM_CallbackIDTypeDef CallbackID,
07264                                                  pHRTIM_TIMxCallbackTypeDef pCallback)
07265 {
07266   HAL_StatusTypeDef status = HAL_OK;
07267 
07268   if (pCallback == NULL)
07269   {
07270     /* Update the state */
07271     hhrtim->State = HAL_HRTIM_STATE_INVALID_CALLBACK;
07272 
07273     return HAL_ERROR;
07274   }
07275 
07276   /* Process locked */
07277   __HAL_LOCK(hhrtim);
07278 
07279   if (HAL_HRTIM_STATE_READY == hhrtim->State)
07280   {
07281     switch (CallbackID)
07282     {
07283       case HAL_HRTIM_REGISTERSUPDATECALLBACK_CB_ID :
07284         hhrtim->RegistersUpdateCallback = pCallback;
07285         break;
07286 
07287       case HAL_HRTIM_REPETITIONEVENTCALLBACK_CB_ID :
07288         hhrtim->RepetitionEventCallback = pCallback;
07289         break;
07290 
07291       case HAL_HRTIM_COMPARE1EVENTCALLBACK_CB_ID :
07292         hhrtim->Compare1EventCallback = pCallback;
07293         break;
07294 
07295       case HAL_HRTIM_COMPARE2EVENTCALLBACK_CB_ID :
07296         hhrtim->Compare2EventCallback = pCallback;
07297         break;
07298 
07299       case HAL_HRTIM_COMPARE3EVENTCALLBACK_CB_ID :
07300         hhrtim->Compare3EventCallback = pCallback;
07301         break;
07302 
07303       case HAL_HRTIM_COMPARE4EVENTCALLBACK_CB_ID :
07304         hhrtim->Compare4EventCallback = pCallback;
07305         break;
07306 
07307       case HAL_HRTIM_CAPTURE1EVENTCALLBACK_CB_ID :
07308         hhrtim->Capture1EventCallback = pCallback;
07309         break;
07310 
07311       case HAL_HRTIM_CAPTURE2EVENTCALLBACK_CB_ID :
07312         hhrtim->Capture2EventCallback = pCallback;
07313         break;
07314 
07315       case HAL_HRTIM_DELAYEDPROTECTIONCALLBACK_CB_ID :
07316         hhrtim->DelayedProtectionCallback = pCallback;
07317         break;
07318 
07319       case HAL_HRTIM_COUNTERRESETCALLBACK_CB_ID :
07320         hhrtim->CounterResetCallback = pCallback;
07321         break;
07322 
07323       case HAL_HRTIM_OUTPUT1SETCALLBACK_CB_ID :
07324         hhrtim->Output1SetCallback = pCallback;
07325         break;
07326 
07327       case HAL_HRTIM_OUTPUT1RESETCALLBACK_CB_ID :
07328         hhrtim->Output1ResetCallback = pCallback;
07329         break;
07330 
07331       case HAL_HRTIM_OUTPUT2SETCALLBACK_CB_ID :
07332         hhrtim->Output2SetCallback = pCallback;
07333         break;
07334 
07335       case HAL_HRTIM_OUTPUT2RESETCALLBACK_CB_ID :
07336         hhrtim->Output2ResetCallback = pCallback;
07337         break;
07338 
07339       case HAL_HRTIM_BURSTDMATRANSFERCALLBACK_CB_ID :
07340         hhrtim->BurstDMATransferCallback = pCallback;
07341         break;
07342 
07343     default :
07344         /* Update the state */
07345         hhrtim->State = HAL_HRTIM_STATE_INVALID_CALLBACK;
07346 
07347         /* Return error status */
07348         status = HAL_ERROR;
07349         break;
07350     }
07351   }
07352   else
07353   {
07354     /* Update the state */
07355     hhrtim->State = HAL_HRTIM_STATE_INVALID_CALLBACK;
07356 
07357     /* Return error status */
07358     status = HAL_ERROR;
07359   }
07360 
07361   /* Release Lock */
07362   __HAL_UNLOCK(hhrtim);
07363 
07364   return status;
07365 }
07366 
07367 /**
07368   * @brief  HRTIM Timer x callback function un-registration
07369   * @param  hhrtim pointer to HAL HRTIM handle
07370   * @param  CallbackID ID of the HRTIM callback Timer x function to unregister
07371   *                   This parameter can be one of the following values:
07372   *                   @arg HAL_HRTIM_REGISTERSUPDATECALLBACK_CB_ID
07373   *                   @arg HAL_HRTIM_REPETITIONEVENTCALLBACK_CB_ID
07374   *                   @arg HAL_HRTIM_COMPARE1EVENTCALLBACK_CB_ID
07375   *                   @arg HAL_HRTIM_COMPARE2EVENTCALLBACK_CB_ID
07376   *                   @arg HAL_HRTIM_COMPARE3EVENTCALLBACK_CB_ID
07377   *                   @arg HAL_HRTIM_COMPARE4EVENTCALLBACK_CB_ID
07378   *                   @arg HAL_HRTIM_CAPTURE1EVENTCALLBACK_CB_ID
07379   *                   @arg HAL_HRTIM_CAPTURE2EVENTCALLBACK_CB_ID
07380   *                   @arg HAL_HRTIM_DELAYEDPROTECTIONCALLBACK_CB_ID
07381   *                   @arg HAL_HRTIM_COUNTERRESETCALLBACK_CB_ID
07382   *                   @arg HAL_HRTIM_OUTPUT1SETCALLBACK_CB_ID
07383   *                   @arg HAL_HRTIM_OUTPUT1RESETCALLBACK_CB_ID
07384   *                   @arg HAL_HRTIM_OUTPUT2SETCALLBACK_CB_ID
07385   *                   @arg HAL_HRTIM_OUTPUT2RESETCALLBACK_CB_ID
07386   *                   @arg HAL_HRTIM_BURSTDMATRANSFERCALLBACK_CB_ID
07387   * @retval HAL status
07388   */
07389 HAL_StatusTypeDef HAL_HRTIM_TIMxUnRegisterCallback(HRTIM_HandleTypeDef * hhrtim,
07390                                                    HAL_HRTIM_CallbackIDTypeDef CallbackID)
07391 {
07392   HAL_StatusTypeDef status = HAL_OK;
07393 
07394   /* Process locked */
07395   __HAL_LOCK(hhrtim);
07396 
07397   if (HAL_HRTIM_STATE_READY == hhrtim->State)
07398   {
07399     switch (CallbackID)
07400     {
07401       case HAL_HRTIM_REGISTERSUPDATECALLBACK_CB_ID :
07402         hhrtim->RegistersUpdateCallback = HAL_HRTIM_RegistersUpdateCallback;
07403         break;
07404 
07405       case HAL_HRTIM_REPETITIONEVENTCALLBACK_CB_ID :
07406         hhrtim->RepetitionEventCallback = HAL_HRTIM_RepetitionEventCallback;
07407         break;
07408 
07409       case HAL_HRTIM_COMPARE1EVENTCALLBACK_CB_ID :
07410         hhrtim->Compare1EventCallback = HAL_HRTIM_Compare1EventCallback;
07411         break;
07412 
07413       case HAL_HRTIM_COMPARE2EVENTCALLBACK_CB_ID :
07414         hhrtim->Compare2EventCallback = HAL_HRTIM_Compare2EventCallback;
07415         break;
07416 
07417       case HAL_HRTIM_COMPARE3EVENTCALLBACK_CB_ID :
07418         hhrtim->Compare3EventCallback = HAL_HRTIM_Compare3EventCallback;
07419         break;
07420 
07421       case HAL_HRTIM_COMPARE4EVENTCALLBACK_CB_ID :
07422         hhrtim->Compare4EventCallback = HAL_HRTIM_Compare4EventCallback;
07423         break;
07424 
07425       case HAL_HRTIM_CAPTURE1EVENTCALLBACK_CB_ID :
07426         hhrtim->Capture1EventCallback = HAL_HRTIM_Capture1EventCallback;
07427         break;
07428 
07429       case HAL_HRTIM_CAPTURE2EVENTCALLBACK_CB_ID :
07430         hhrtim->Capture2EventCallback = HAL_HRTIM_Capture2EventCallback;
07431         break;
07432 
07433       case HAL_HRTIM_DELAYEDPROTECTIONCALLBACK_CB_ID :
07434         hhrtim->DelayedProtectionCallback = HAL_HRTIM_DelayedProtectionCallback;
07435         break;
07436 
07437       case HAL_HRTIM_COUNTERRESETCALLBACK_CB_ID :
07438         hhrtim->CounterResetCallback = HAL_HRTIM_CounterResetCallback;
07439         break;
07440 
07441       case HAL_HRTIM_OUTPUT1SETCALLBACK_CB_ID :
07442         hhrtim->Output1SetCallback = HAL_HRTIM_Output1SetCallback;
07443         break;
07444 
07445       case HAL_HRTIM_OUTPUT1RESETCALLBACK_CB_ID :
07446         hhrtim->Output1ResetCallback = HAL_HRTIM_Output1ResetCallback;
07447         break;
07448 
07449       case HAL_HRTIM_OUTPUT2SETCALLBACK_CB_ID :
07450         hhrtim->Output2SetCallback = HAL_HRTIM_Output2SetCallback;
07451         break;
07452 
07453       case HAL_HRTIM_OUTPUT2RESETCALLBACK_CB_ID :
07454         hhrtim->Output2ResetCallback = HAL_HRTIM_Output2ResetCallback;
07455         break;
07456 
07457       case HAL_HRTIM_BURSTDMATRANSFERCALLBACK_CB_ID :
07458         hhrtim->BurstDMATransferCallback = HAL_HRTIM_BurstDMATransferCallback;
07459         break;
07460 
07461     default :
07462         /* Update the state */
07463         hhrtim->State = HAL_HRTIM_STATE_INVALID_CALLBACK;
07464 
07465         /* Return error status */
07466         status = HAL_ERROR;
07467         break;
07468     }
07469   }
07470   else
07471   {
07472     /* Update the state */
07473     hhrtim->State = HAL_HRTIM_STATE_INVALID_CALLBACK;
07474 
07475     /* Return error status */
07476     status = HAL_ERROR;
07477   }
07478 
07479   /* Release Lock */
07480   __HAL_UNLOCK(hhrtim);
07481 
07482   return status;
07483 }
07484 #endif /* USE_HAL_HRTIM_REGISTER_CALLBACKS */
07485 /**
07486   * @}
07487   */
07488 
07489 /**
07490   * @}
07491   */
07492 
07493 /** @addtogroup HRTIM_Private_Functions
07494   * @{
07495   */
07496 
07497 /**
07498   * @brief  Configure the master timer time base
07499   * @param  hhrtim pointer to HAL HRTIM handle
07500   * @param  pTimeBaseCfg pointer to the time base configuration structure
07501   * @retval None
07502   */
07503 static void HRTIM_MasterBase_Config(HRTIM_HandleTypeDef * hhrtim,
07504                                      HRTIM_TimeBaseCfgTypeDef * pTimeBaseCfg)
07505 {
07506   uint32_t hrtim_mcr;
07507 
07508   /* Configure master timer */
07509   hrtim_mcr = hhrtim->Instance->sMasterRegs.MCR;
07510 
07511   /* Set the prescaler ratio */
07512   hrtim_mcr &= (uint32_t) ~(HRTIM_MCR_CK_PSC);
07513   hrtim_mcr |= (uint32_t)pTimeBaseCfg->PrescalerRatio;
07514 
07515   /* Set the operating mode */
07516   hrtim_mcr &= (uint32_t) ~(HRTIM_MCR_CONT | HRTIM_MCR_RETRIG);
07517   hrtim_mcr |= (uint32_t)pTimeBaseCfg->Mode;
07518 
07519   /* Update the HRTIM registers */
07520   hhrtim->Instance->sMasterRegs.MCR = hrtim_mcr;
07521   hhrtim->Instance->sMasterRegs.MPER = pTimeBaseCfg->Period;
07522   hhrtim->Instance->sMasterRegs.MREP = pTimeBaseCfg->RepetitionCounter;
07523 }
07524 
07525 /**
07526   * @brief  Configure timing unit (Timer A to Timer E) time base
07527   * @param  hhrtim pointer to HAL HRTIM handle
07528   * @param  TimerIdx Timer index
07529   * @param  pTimeBaseCfg pointer to the time base configuration structure
07530   * @retval None
07531   */
07532 static void HRTIM_TimingUnitBase_Config(HRTIM_HandleTypeDef * hhrtim,
07533                                          uint32_t TimerIdx ,
07534                                          HRTIM_TimeBaseCfgTypeDef * pTimeBaseCfg)
07535 {
07536   uint32_t hrtim_timcr;
07537 
07538   /* Configure master timing unit */
07539   hrtim_timcr = hhrtim->Instance->sTimerxRegs[TimerIdx].TIMxCR;
07540 
07541   /* Set the prescaler ratio */
07542   hrtim_timcr &= (uint32_t) ~(HRTIM_TIMCR_CK_PSC);
07543   hrtim_timcr |= (uint32_t)pTimeBaseCfg->PrescalerRatio;
07544 
07545   /* Set the operating mode */
07546   hrtim_timcr &= (uint32_t) ~(HRTIM_TIMCR_CONT | HRTIM_TIMCR_RETRIG);
07547   hrtim_timcr |= (uint32_t)pTimeBaseCfg->Mode;
07548 
07549   /* Update the HRTIM registers */
07550   hhrtim->Instance->sTimerxRegs[TimerIdx].TIMxCR = hrtim_timcr;
07551   hhrtim->Instance->sTimerxRegs[TimerIdx].PERxR = pTimeBaseCfg->Period;
07552   hhrtim->Instance->sTimerxRegs[TimerIdx].REPxR = pTimeBaseCfg->RepetitionCounter;
07553 }
07554 
07555 /**
07556   * @brief  Configure the master timer in waveform mode
07557   * @param  hhrtim pointer to HAL HRTIM handle
07558   * @param  pTimerCfg pointer to the timer configuration data structure
07559   * @retval None
07560   */
07561 static void HRTIM_MasterWaveform_Config(HRTIM_HandleTypeDef * hhrtim,
07562                                          HRTIM_TimerCfgTypeDef * pTimerCfg)
07563 {
07564   uint32_t hrtim_mcr;
07565   uint32_t hrtim_bmcr;
07566 
07567   /* Configure master timer */
07568   hrtim_mcr = hhrtim->Instance->sMasterRegs.MCR;
07569   hrtim_bmcr = hhrtim->Instance->sCommonRegs.BMCR;
07570 
07571   /* Enable/Disable the half mode */
07572   hrtim_mcr &= ~(HRTIM_MCR_HALF);
07573   hrtim_mcr |= pTimerCfg->HalfModeEnable;
07574 
07575   /* Enable/Disable the timer start upon synchronization event reception */
07576   hrtim_mcr &= ~(HRTIM_MCR_SYNCSTRTM);
07577   hrtim_mcr |= pTimerCfg->StartOnSync;
07578 
07579   /* Enable/Disable the timer reset upon synchronization event reception */
07580   hrtim_mcr &= ~(HRTIM_MCR_SYNCRSTM);
07581   hrtim_mcr |= pTimerCfg->ResetOnSync;
07582 
07583   /* Enable/Disable the DAC synchronization event generation */
07584   hrtim_mcr &= ~(HRTIM_MCR_DACSYNC);
07585   hrtim_mcr |= pTimerCfg->DACSynchro;
07586 
07587   /* Enable/Disable preload mechanism for timer registers */
07588   hrtim_mcr &= ~(HRTIM_MCR_PREEN);
07589   hrtim_mcr |= pTimerCfg->PreloadEnable;
07590 
07591   /* Master timer registers update handling */
07592   hrtim_mcr &= ~(HRTIM_MCR_BRSTDMA);
07593   hrtim_mcr |= (pTimerCfg->UpdateGating << 2U);
07594 
07595   /* Enable/Disable registers update on repetition */
07596   hrtim_mcr &= ~(HRTIM_MCR_MREPU);
07597   hrtim_mcr |= pTimerCfg->RepetitionUpdate;
07598 
07599   /* Set the timer burst mode */
07600   hrtim_bmcr &= ~(HRTIM_BMCR_MTBM);
07601   hrtim_bmcr |= pTimerCfg->BurstMode;
07602 
07603   /* Update the HRTIM registers */
07604   hhrtim->Instance->sMasterRegs.MCR = hrtim_mcr;
07605   hhrtim->Instance->sCommonRegs.BMCR = hrtim_bmcr;
07606 }
07607 
07608 /**
07609   * @brief  Configure timing unit (Timer A to Timer E) in waveform mode
07610   * @param  hhrtim pointer to HAL HRTIM handle
07611   * @param  TimerIdx Timer index
07612   * @param  pTimerCfg pointer to the timer configuration data structure
07613   * @retval None
07614   */
07615 static void  HRTIM_TimingUnitWaveform_Config(HRTIM_HandleTypeDef * hhrtim,
07616                                              uint32_t TimerIdx,
07617                                              HRTIM_TimerCfgTypeDef * pTimerCfg)
07618 {
07619   uint32_t hrtim_timcr;
07620   uint32_t hrtim_timfltr;
07621   uint32_t hrtim_timoutr;
07622   uint32_t hrtim_timrstr;
07623   uint32_t hrtim_bmcr;
07624 
07625   /* UPDGAT bitfield must be reset before programming a new value */
07626   hhrtim->Instance->sTimerxRegs[TimerIdx].TIMxCR &= ~(HRTIM_TIMCR_UPDGAT);
07627 
07628   /* Configure timing unit (Timer A to Timer E) */
07629   hrtim_timcr = hhrtim->Instance->sTimerxRegs[TimerIdx].TIMxCR;
07630   hrtim_timfltr = hhrtim->Instance->sTimerxRegs[TimerIdx].FLTxR;
07631   hrtim_timoutr = hhrtim->Instance->sTimerxRegs[TimerIdx].OUTxR;
07632   hrtim_bmcr = hhrtim->Instance->sCommonRegs.BMCR;
07633 
07634   /* Enable/Disable the half mode */
07635   hrtim_timcr &= ~(HRTIM_TIMCR_HALF);
07636   hrtim_timcr |= pTimerCfg->HalfModeEnable;
07637 
07638   /* Enable/Disable the timer start upon synchronization event reception */
07639   hrtim_timcr &= ~(HRTIM_TIMCR_SYNCSTRT);
07640   hrtim_timcr |= pTimerCfg->StartOnSync;
07641 
07642   /* Enable/Disable the timer reset upon synchronization event reception */
07643   hrtim_timcr &= ~(HRTIM_TIMCR_SYNCRST);
07644   hrtim_timcr |= pTimerCfg->ResetOnSync;
07645 
07646   /* Enable/Disable the DAC synchronization event generation */
07647   hrtim_timcr &= ~(HRTIM_TIMCR_DACSYNC);
07648   hrtim_timcr |= pTimerCfg->DACSynchro;
07649 
07650   /* Enable/Disable preload mechanism for timer registers */
07651   hrtim_timcr &= ~(HRTIM_TIMCR_PREEN);
07652   hrtim_timcr |= pTimerCfg->PreloadEnable;
07653 
07654   /* Timing unit registers update handling */
07655   hrtim_timcr &= ~(HRTIM_TIMCR_UPDGAT);
07656   hrtim_timcr |= pTimerCfg->UpdateGating;
07657 
07658   /* Enable/Disable registers update on repetition */
07659   hrtim_timcr &= ~(HRTIM_TIMCR_TREPU);
07660   if (pTimerCfg->RepetitionUpdate == HRTIM_UPDATEONREPETITION_ENABLED)
07661   {
07662     hrtim_timcr |= HRTIM_TIMCR_TREPU;
07663   }
07664 
07665   /* Set the push-pull mode */
07666   hrtim_timcr &= ~(HRTIM_TIMCR_PSHPLL);
07667   hrtim_timcr |= pTimerCfg->PushPull;
07668 
07669   /* Enable/Disable registers update on timer counter reset */
07670   hrtim_timcr &= ~(HRTIM_TIMCR_TRSTU);
07671   hrtim_timcr |= pTimerCfg->ResetUpdate;
07672 
07673   /* Set the timer update trigger */
07674   hrtim_timcr &= ~(HRTIM_TIMCR_TIMUPDATETRIGGER);
07675   hrtim_timcr |= pTimerCfg->UpdateTrigger;
07676 
07677   /* Enable/Disable the fault channel at timer level */
07678   hrtim_timfltr &= ~(HRTIM_FLTR_FLTxEN);
07679   hrtim_timfltr |= (pTimerCfg->FaultEnable & HRTIM_FLTR_FLTxEN);
07680 
07681   /* Lock/Unlock fault sources at timer level */
07682   hrtim_timfltr &= ~(HRTIM_FLTR_FLTLCK);
07683   hrtim_timfltr |= pTimerCfg->FaultLock;
07684 
07685   /* The deadtime cannot be used simultaneously with the push-pull mode */
07686   if (pTimerCfg->PushPull == HRTIM_TIMPUSHPULLMODE_DISABLED)
07687   {
07688     /* Enable/Disable dead time insertion at timer level */
07689     hrtim_timoutr &= ~(HRTIM_OUTR_DTEN);
07690     hrtim_timoutr |= pTimerCfg->DeadTimeInsertion;
07691   }
07692 
07693   /* Enable/Disable delayed protection at timer level
07694      Delayed Idle is available whatever the timer operating mode (regular, push-pull)
07695      Balanced Idle is only available in push-pull mode
07696   */
07697   if ( ((pTimerCfg->DelayedProtectionMode != HRTIM_TIMER_A_B_C_DELAYEDPROTECTION_BALANCED_EEV6)
07698        && (pTimerCfg->DelayedProtectionMode != HRTIM_TIMER_A_B_C_DELAYEDPROTECTION_BALANCED_EEV7))
07699        || (pTimerCfg->PushPull == HRTIM_TIMPUSHPULLMODE_ENABLED))
07700   {
07701     hrtim_timoutr &= ~(HRTIM_OUTR_DLYPRT| HRTIM_OUTR_DLYPRTEN);
07702     hrtim_timoutr |= pTimerCfg->DelayedProtectionMode;
07703   }
07704 
07705   /* Set the timer counter reset trigger */
07706   hrtim_timrstr = pTimerCfg->ResetTrigger;
07707 
07708   /* Set the timer burst mode */
07709   switch (TimerIdx)
07710   {
07711   case HRTIM_TIMERINDEX_TIMER_A:
07712     {
07713       hrtim_bmcr &= ~(HRTIM_BMCR_TABM);
07714       hrtim_bmcr |= ( pTimerCfg->BurstMode << 1U);
07715       break;
07716     }
07717 
07718   case HRTIM_TIMERINDEX_TIMER_B:
07719     {
07720       hrtim_bmcr &= ~(HRTIM_BMCR_TBBM);
07721       hrtim_bmcr |= ( pTimerCfg->BurstMode << 2U);
07722       break;
07723     }
07724 
07725   case HRTIM_TIMERINDEX_TIMER_C:
07726     {
07727       hrtim_bmcr &= ~(HRTIM_BMCR_TCBM);
07728       hrtim_bmcr |= ( pTimerCfg->BurstMode << 3U);
07729       break;
07730     }
07731 
07732   case HRTIM_TIMERINDEX_TIMER_D:
07733     {
07734       hrtim_bmcr &= ~(HRTIM_BMCR_TDBM);
07735       hrtim_bmcr |= ( pTimerCfg->BurstMode << 4U);
07736       break;
07737     }
07738 
07739   case HRTIM_TIMERINDEX_TIMER_E:
07740     {
07741       hrtim_bmcr &= ~(HRTIM_BMCR_TEBM);
07742       hrtim_bmcr |= ( pTimerCfg->BurstMode << 5U);
07743       break;
07744     }
07745 
07746   default:
07747     break;
07748   }
07749 
07750   /* Update the HRTIM registers */
07751   hhrtim->Instance->sTimerxRegs[TimerIdx].TIMxCR = hrtim_timcr;
07752   hhrtim->Instance->sTimerxRegs[TimerIdx].FLTxR = hrtim_timfltr;
07753   hhrtim->Instance->sTimerxRegs[TimerIdx].OUTxR = hrtim_timoutr;
07754   hhrtim->Instance->sTimerxRegs[TimerIdx].RSTxR = hrtim_timrstr;
07755   hhrtim->Instance->sCommonRegs.BMCR = hrtim_bmcr;
07756 }
07757 
07758 /**
07759   * @brief  Configure a capture unit
07760   * @param  hhrtim pointer to HAL HRTIM handle
07761   * @param  TimerIdx Timer index
07762   * @param  CaptureUnit Capture unit identifier
07763   * @param  Event Event reference
07764   * @retval None
07765   */
07766 static void HRTIM_CaptureUnitConfig(HRTIM_HandleTypeDef * hhrtim,
07767                                     uint32_t TimerIdx,
07768                                     uint32_t CaptureUnit,
07769                                     uint32_t Event)
07770 {
07771   uint32_t CaptureTrigger = 0xFFFFFFFFU;
07772 
07773   switch (Event)
07774   {
07775   case HRTIM_EVENT_1:
07776     {
07777       CaptureTrigger = HRTIM_CAPTURETRIGGER_EEV_1;
07778       break;
07779     }
07780 
07781   case HRTIM_EVENT_2:
07782     {
07783       CaptureTrigger = HRTIM_CAPTURETRIGGER_EEV_2;
07784       break;
07785     }
07786 
07787   case HRTIM_EVENT_3:
07788     {
07789       CaptureTrigger = HRTIM_CAPTURETRIGGER_EEV_3;
07790       break;
07791     }
07792 
07793   case HRTIM_EVENT_4:
07794     {
07795       CaptureTrigger = HRTIM_CAPTURETRIGGER_EEV_4;
07796       break;
07797     }
07798 
07799   case HRTIM_EVENT_5:
07800     {
07801       CaptureTrigger = HRTIM_CAPTURETRIGGER_EEV_5;
07802       break;
07803     }
07804 
07805   case HRTIM_EVENT_6:
07806     {
07807       CaptureTrigger = HRTIM_CAPTURETRIGGER_EEV_6;
07808       break;
07809     }
07810 
07811   case HRTIM_EVENT_7:
07812     {
07813       CaptureTrigger = HRTIM_CAPTURETRIGGER_EEV_7;
07814       break;
07815     }
07816 
07817   case HRTIM_EVENT_8:
07818     {
07819       CaptureTrigger = HRTIM_CAPTURETRIGGER_EEV_8;
07820       break;
07821     }
07822 
07823   case HRTIM_EVENT_9:
07824     {
07825       CaptureTrigger = HRTIM_CAPTURETRIGGER_EEV_9;
07826       break;
07827     }
07828 
07829   case HRTIM_EVENT_10:
07830     {
07831       CaptureTrigger = HRTIM_CAPTURETRIGGER_EEV_10;
07832       break;
07833     }
07834 
07835   default:
07836     break;
07837   }
07838 
07839   switch (CaptureUnit)
07840   {
07841   case HRTIM_CAPTUREUNIT_1:
07842     {
07843       hhrtim->TimerParam[TimerIdx].CaptureTrigger1 = CaptureTrigger;
07844       break;
07845     }
07846 
07847   case HRTIM_CAPTUREUNIT_2:
07848     {
07849       hhrtim->TimerParam[TimerIdx].CaptureTrigger2 = CaptureTrigger;
07850       break;
07851     }
07852 
07853   default:
07854     break;
07855   }
07856 }
07857 
07858 /**
07859   * @brief  Configure the output of a timing unit
07860   * @param  hhrtim pointer to HAL HRTIM handle
07861   * @param  TimerIdx Timer index
07862   * @param  Output timing unit output identifier
07863   * @param  pOutputCfg pointer to the output configuration data structure
07864   * @retval None
07865   */
07866 static void  HRTIM_OutputConfig(HRTIM_HandleTypeDef * hhrtim,
07867                                 uint32_t TimerIdx,
07868                                 uint32_t Output,
07869                                 HRTIM_OutputCfgTypeDef * pOutputCfg)
07870 {
07871   uint32_t hrtim_outr;
07872   uint32_t hrtim_dtr;
07873 
07874   uint32_t shift = 0U;
07875 
07876   hrtim_outr = hhrtim->Instance->sTimerxRegs[TimerIdx].OUTxR;
07877   hrtim_dtr = hhrtim->Instance->sTimerxRegs[TimerIdx].DTxR;
07878 
07879   switch (Output)
07880   {
07881   case HRTIM_OUTPUT_TA1:
07882   case HRTIM_OUTPUT_TB1:
07883   case HRTIM_OUTPUT_TC1:
07884   case HRTIM_OUTPUT_TD1:
07885   case HRTIM_OUTPUT_TE1:
07886     {
07887       /* Set the output set/reset crossbar */
07888       hhrtim->Instance->sTimerxRegs[TimerIdx].SETx1R = pOutputCfg->SetSource;
07889       hhrtim->Instance->sTimerxRegs[TimerIdx].RSTx1R = pOutputCfg->ResetSource;
07890       break;
07891     }
07892 
07893   case HRTIM_OUTPUT_TA2:
07894   case HRTIM_OUTPUT_TB2:
07895   case HRTIM_OUTPUT_TC2:
07896   case HRTIM_OUTPUT_TD2:
07897   case HRTIM_OUTPUT_TE2:
07898     {
07899       /* Set the output set/reset crossbar */
07900       hhrtim->Instance->sTimerxRegs[TimerIdx].SETx2R = pOutputCfg->SetSource;
07901       hhrtim->Instance->sTimerxRegs[TimerIdx].RSTx2R = pOutputCfg->ResetSource;
07902       shift = 16U;
07903       break;
07904     }
07905 
07906   default:
07907     break;
07908   }
07909 
07910   /* Clear output config */
07911   hrtim_outr &= ~((HRTIM_OUTR_POL1 |
07912                    HRTIM_OUTR_IDLM1 |
07913                    HRTIM_OUTR_IDLES1|
07914                    HRTIM_OUTR_FAULT1|
07915                    HRTIM_OUTR_CHP1 |
07916                    HRTIM_OUTR_DIDL1) << shift);
07917 
07918   /* Set the polarity */
07919   hrtim_outr |= (pOutputCfg->Polarity << shift);
07920 
07921   /* Set the IDLE mode */
07922   hrtim_outr |= (pOutputCfg->IdleMode << shift);
07923 
07924   /* Set the IDLE state */
07925   hrtim_outr |= (pOutputCfg->IdleLevel << shift);
07926 
07927   /* Set the FAULT state */
07928   hrtim_outr |= (pOutputCfg->FaultLevel << shift);
07929 
07930   /* Set the chopper mode */
07931   hrtim_outr |= (pOutputCfg->ChopperModeEnable << shift);
07932 
07933   /* Set the burst mode entry mode : deadtime insertion when entering the idle
07934      state during a burst mode operation is allowed only under the following
07935      conditions:
07936      - the outputs is active during the burst mode (IDLES=1U)
07937      - positive deadtimes (SDTR/SDTF set to 0U)
07938   */
07939   if ((pOutputCfg->IdleLevel == HRTIM_OUTPUTIDLELEVEL_ACTIVE) &&
07940       ((hrtim_dtr & HRTIM_DTR_SDTR) == (uint32_t)RESET) &&
07941       ((hrtim_dtr & HRTIM_DTR_SDTF) == (uint32_t)RESET))
07942   {
07943     hrtim_outr |= (pOutputCfg->BurstModeEntryDelayed << shift);
07944   }
07945 
07946   /* Update HRTIM register */
07947   hhrtim->Instance->sTimerxRegs[TimerIdx].OUTxR = hrtim_outr;
07948 }
07949 
07950 /**
07951   * @brief  Configure an external event channel
07952   * @param  hhrtim pointer to HAL HRTIM handle
07953   * @param  Event Event channel identifier
07954   * @param  pEventCfg pointer to the event channel configuration data structure
07955   * @retval None
07956   */
07957 static void HRTIM_EventConfig(HRTIM_HandleTypeDef * hhrtim,
07958                               uint32_t Event,
07959                               HRTIM_EventCfgTypeDef *pEventCfg)
07960 {
07961   uint32_t hrtim_eecr1;
07962   uint32_t hrtim_eecr2;
07963   uint32_t hrtim_eecr3;
07964 
07965   /* Configure external event channel */
07966   hrtim_eecr1 = hhrtim->Instance->sCommonRegs.EECR1;
07967   hrtim_eecr2 = hhrtim->Instance->sCommonRegs.EECR2;
07968   hrtim_eecr3 = hhrtim->Instance->sCommonRegs.EECR3;
07969 
07970   switch (Event)
07971   {
07972   case HRTIM_EVENT_NONE:
07973     {
07974       /* Update the HRTIM registers */
07975       hhrtim->Instance->sCommonRegs.EECR1 = 0U;
07976       hhrtim->Instance->sCommonRegs.EECR2 = 0U;
07977       hhrtim->Instance->sCommonRegs.EECR3 = 0U;
07978       break;
07979     }
07980 
07981   case HRTIM_EVENT_1:
07982     {
07983       hrtim_eecr1 &= ~(HRTIM_EECR1_EE1SRC | HRTIM_EECR1_EE1POL | HRTIM_EECR1_EE1SNS | HRTIM_EECR1_EE1FAST);
07984       hrtim_eecr1 |= (pEventCfg->Source & HRTIM_EECR1_EE1SRC);
07985       hrtim_eecr1 |= (pEventCfg->Polarity & HRTIM_EECR1_EE1POL);
07986       hrtim_eecr1 |= (pEventCfg->Sensitivity & HRTIM_EECR1_EE1SNS);
07987       /* Update the HRTIM registers (all bitfields but EE1FAST bit) */
07988       hhrtim->Instance->sCommonRegs.EECR1 = hrtim_eecr1;
07989       /* Update the HRTIM registers (EE1FAST bit) */
07990       hrtim_eecr1 |= (pEventCfg->FastMode  & HRTIM_EECR1_EE1FAST);
07991       hhrtim->Instance->sCommonRegs.EECR1 = hrtim_eecr1;
07992       break;
07993     }
07994 
07995   case HRTIM_EVENT_2:
07996     {
07997       hrtim_eecr1 &= ~(HRTIM_EECR1_EE2SRC | HRTIM_EECR1_EE2POL | HRTIM_EECR1_EE2SNS | HRTIM_EECR1_EE2FAST);
07998       hrtim_eecr1 |= ((pEventCfg->Source << 6U) & HRTIM_EECR1_EE2SRC);
07999       hrtim_eecr1 |= ((pEventCfg->Polarity << 6U) & HRTIM_EECR1_EE2POL);
08000       hrtim_eecr1 |= ((pEventCfg->Sensitivity << 6U) & HRTIM_EECR1_EE2SNS);
08001       /* Update the HRTIM registers (all bitfields but EE2FAST bit) */
08002       hhrtim->Instance->sCommonRegs.EECR1 = hrtim_eecr1;
08003       /* Update the HRTIM registers (EE2FAST bit) */
08004       hrtim_eecr1 |= ((pEventCfg->FastMode << 6U) & HRTIM_EECR1_EE2FAST);
08005       hhrtim->Instance->sCommonRegs.EECR1 = hrtim_eecr1;
08006       break;
08007     }
08008 
08009   case HRTIM_EVENT_3:
08010     {
08011       hrtim_eecr1 &= ~(HRTIM_EECR1_EE3SRC | HRTIM_EECR1_EE3POL | HRTIM_EECR1_EE3SNS | HRTIM_EECR1_EE3FAST);
08012       hrtim_eecr1 |= ((pEventCfg->Source << 12U) & HRTIM_EECR1_EE3SRC);
08013       hrtim_eecr1 |= ((pEventCfg->Polarity << 12U) & HRTIM_EECR1_EE3POL);
08014       hrtim_eecr1 |= ((pEventCfg->Sensitivity << 12U) & HRTIM_EECR1_EE3SNS);
08015       /* Update the HRTIM registers (all bitfields but EE3FAST bit) */
08016       hhrtim->Instance->sCommonRegs.EECR1 = hrtim_eecr1;
08017       /* Update the HRTIM registers (EE3FAST bit) */
08018       hrtim_eecr1 |= ((pEventCfg->FastMode << 12U) & HRTIM_EECR1_EE3FAST);
08019       hhrtim->Instance->sCommonRegs.EECR1 = hrtim_eecr1;
08020       break;
08021     }
08022 
08023   case HRTIM_EVENT_4:
08024     {
08025       hrtim_eecr1 &= ~(HRTIM_EECR1_EE4SRC | HRTIM_EECR1_EE4POL | HRTIM_EECR1_EE4SNS | HRTIM_EECR1_EE4FAST);
08026       hrtim_eecr1 |= ((pEventCfg->Source << 18U) & HRTIM_EECR1_EE4SRC);
08027       hrtim_eecr1 |= ((pEventCfg->Polarity << 18U) & HRTIM_EECR1_EE4POL);
08028       hrtim_eecr1 |= ((pEventCfg->Sensitivity << 18U) & HRTIM_EECR1_EE4SNS);
08029       /* Update the HRTIM registers (all bitfields but EE4FAST bit) */
08030       hhrtim->Instance->sCommonRegs.EECR1 = hrtim_eecr1;
08031       /* Update the HRTIM registers (EE4FAST bit) */
08032       hrtim_eecr1 |= ((pEventCfg->FastMode << 18U) & HRTIM_EECR1_EE4FAST);
08033       hhrtim->Instance->sCommonRegs.EECR1 = hrtim_eecr1;
08034       break;
08035     }
08036 
08037   case HRTIM_EVENT_5:
08038     {
08039       hrtim_eecr1 &= ~(HRTIM_EECR1_EE5SRC | HRTIM_EECR1_EE5POL | HRTIM_EECR1_EE5SNS | HRTIM_EECR1_EE5FAST);
08040       hrtim_eecr1 |= ((pEventCfg->Source << 24U) & HRTIM_EECR1_EE5SRC);
08041       hrtim_eecr1 |= ((pEventCfg->Polarity << 24U) & HRTIM_EECR1_EE5POL);
08042       hrtim_eecr1 |= ((pEventCfg->Sensitivity << 24U) & HRTIM_EECR1_EE5SNS);
08043       /* Update the HRTIM registers (all bitfields but EE5FAST bit) */
08044       hhrtim->Instance->sCommonRegs.EECR1 = hrtim_eecr1;
08045       /* Update the HRTIM registers (EE5FAST bit) */
08046       hrtim_eecr1 |= ((pEventCfg->FastMode << 24U) & HRTIM_EECR1_EE5FAST);
08047       hhrtim->Instance->sCommonRegs.EECR1 = hrtim_eecr1;
08048       break;
08049     }
08050 
08051   case HRTIM_EVENT_6:
08052     {
08053       hrtim_eecr2 &= ~(HRTIM_EECR2_EE6SRC | HRTIM_EECR2_EE6POL | HRTIM_EECR2_EE6SNS);
08054       hrtim_eecr2 |= (pEventCfg->Source & HRTIM_EECR2_EE6SRC);
08055       hrtim_eecr2 |= (pEventCfg->Polarity & HRTIM_EECR2_EE6POL);
08056       hrtim_eecr2 |= (pEventCfg->Sensitivity & HRTIM_EECR2_EE6SNS);
08057       hrtim_eecr3 &= ~(HRTIM_EECR3_EE6F);
08058       hrtim_eecr3 |= (pEventCfg->Filter & HRTIM_EECR3_EE6F);
08059       /* Update the HRTIM registers */
08060       hhrtim->Instance->sCommonRegs.EECR2 = hrtim_eecr2;
08061       hhrtim->Instance->sCommonRegs.EECR3 = hrtim_eecr3;
08062       break;
08063     }
08064 
08065   case HRTIM_EVENT_7:
08066     {
08067       hrtim_eecr2 &= ~(HRTIM_EECR2_EE7SRC | HRTIM_EECR2_EE7POL | HRTIM_EECR2_EE7SNS);
08068       hrtim_eecr2 |= ((pEventCfg->Source << 6U) & HRTIM_EECR2_EE7SRC);
08069       hrtim_eecr2 |= ((pEventCfg->Polarity << 6U) & HRTIM_EECR2_EE7POL);
08070       hrtim_eecr2 |= ((pEventCfg->Sensitivity << 6U) & HRTIM_EECR2_EE7SNS);
08071       hrtim_eecr3 &= ~(HRTIM_EECR3_EE7F);
08072       hrtim_eecr3 |= ((pEventCfg->Filter << 6U) & HRTIM_EECR3_EE7F);
08073       /* Update the HRTIM registers */
08074       hhrtim->Instance->sCommonRegs.EECR2 = hrtim_eecr2;
08075       hhrtim->Instance->sCommonRegs.EECR3 = hrtim_eecr3;
08076       break;
08077     }
08078 
08079   case HRTIM_EVENT_8:
08080     {
08081       hrtim_eecr2 &= ~(HRTIM_EECR2_EE8SRC | HRTIM_EECR2_EE8POL | HRTIM_EECR2_EE8SNS);
08082       hrtim_eecr2 |= ((pEventCfg->Source << 12U) & HRTIM_EECR2_EE8SRC);
08083       hrtim_eecr2 |= ((pEventCfg->Polarity << 12U) & HRTIM_EECR2_EE8POL);
08084       hrtim_eecr2 |= ((pEventCfg->Sensitivity << 12U) & HRTIM_EECR2_EE8SNS);
08085       hrtim_eecr3 &= ~(HRTIM_EECR3_EE8F);
08086       hrtim_eecr3 |= ((pEventCfg->Filter << 12U) & HRTIM_EECR3_EE8F );
08087       /* Update the HRTIM registers */
08088       hhrtim->Instance->sCommonRegs.EECR2 = hrtim_eecr2;
08089       hhrtim->Instance->sCommonRegs.EECR3 = hrtim_eecr3;
08090       break;
08091     }
08092 
08093   case HRTIM_EVENT_9:
08094     {
08095       hrtim_eecr2 &= ~(HRTIM_EECR2_EE9SRC | HRTIM_EECR2_EE9POL | HRTIM_EECR2_EE9SNS);
08096       hrtim_eecr2 |= ((pEventCfg->Source << 18U) & HRTIM_EECR2_EE9SRC);
08097       hrtim_eecr2 |= ((pEventCfg->Polarity << 18U) & HRTIM_EECR2_EE9POL);
08098       hrtim_eecr2 |= ((pEventCfg->Sensitivity << 18U) & HRTIM_EECR2_EE9SNS);
08099       hrtim_eecr3 &= ~(HRTIM_EECR3_EE9F);
08100       hrtim_eecr3 |= ((pEventCfg->Filter << 18U) & HRTIM_EECR3_EE9F);
08101       /* Update the HRTIM registers */
08102       hhrtim->Instance->sCommonRegs.EECR2 = hrtim_eecr2;
08103       hhrtim->Instance->sCommonRegs.EECR3 = hrtim_eecr3;
08104       break;
08105     }
08106 
08107   case HRTIM_EVENT_10:
08108     {
08109       hrtim_eecr2 &= ~(HRTIM_EECR2_EE10SRC | HRTIM_EECR2_EE10POL | HRTIM_EECR2_EE10SNS);
08110       hrtim_eecr2 |= ((pEventCfg->Source << 24U) & HRTIM_EECR2_EE10SRC);
08111       hrtim_eecr2 |= ((pEventCfg->Polarity << 24U) & HRTIM_EECR2_EE10POL);
08112       hrtim_eecr2 |= ((pEventCfg->Sensitivity << 24U) & HRTIM_EECR2_EE10SNS);
08113       hrtim_eecr3 &= ~(HRTIM_EECR3_EE10F);
08114       hrtim_eecr3 |= ((pEventCfg->Filter << 24U) & HRTIM_EECR3_EE10F);
08115       /* Update the HRTIM registers */
08116       hhrtim->Instance->sCommonRegs.EECR2 = hrtim_eecr2;
08117       hhrtim->Instance->sCommonRegs.EECR3 = hrtim_eecr3;
08118       break;
08119     }
08120 
08121   default:
08122     break;
08123   }
08124 }
08125 
08126 /**
08127   * @brief  Configure the timer counter reset
08128   * @param  hhrtim pointer to HAL HRTIM handle
08129   * @param  TimerIdx Timer index
08130   * @param  Event Event channel identifier
08131   * @retval None
08132   */
08133 static void HRTIM_TIM_ResetConfig(HRTIM_HandleTypeDef * hhrtim,
08134                                   uint32_t TimerIdx,
08135                                   uint32_t Event)
08136 {
08137   switch (Event)
08138   {
08139   case HRTIM_EVENT_1:
08140     {
08141       hhrtim->Instance->sTimerxRegs[TimerIdx].RSTxR = HRTIM_TIMRESETTRIGGER_EEV_1;
08142       break;
08143     }
08144 
08145   case HRTIM_EVENT_2:
08146     {
08147       hhrtim->Instance->sTimerxRegs[TimerIdx].RSTxR = HRTIM_TIMRESETTRIGGER_EEV_2;
08148       break;
08149     }
08150 
08151   case HRTIM_EVENT_3:
08152     {
08153       hhrtim->Instance->sTimerxRegs[TimerIdx].RSTxR = HRTIM_TIMRESETTRIGGER_EEV_3;
08154       break;
08155     }
08156 
08157   case HRTIM_EVENT_4:
08158     {
08159       hhrtim->Instance->sTimerxRegs[TimerIdx].RSTxR = HRTIM_TIMRESETTRIGGER_EEV_4;
08160       break;
08161     }
08162 
08163   case HRTIM_EVENT_5:
08164     {
08165       hhrtim->Instance->sTimerxRegs[TimerIdx].RSTxR = HRTIM_TIMRESETTRIGGER_EEV_5;
08166       break;
08167     }
08168 
08169   case HRTIM_EVENT_6:
08170     {
08171       hhrtim->Instance->sTimerxRegs[TimerIdx].RSTxR = HRTIM_TIMRESETTRIGGER_EEV_6;
08172       break;
08173     }
08174 
08175   case HRTIM_EVENT_7:
08176     {
08177       hhrtim->Instance->sTimerxRegs[TimerIdx].RSTxR = HRTIM_TIMRESETTRIGGER_EEV_7;
08178       break;
08179     }
08180 
08181   case HRTIM_EVENT_8:
08182     {
08183       hhrtim->Instance->sTimerxRegs[TimerIdx].RSTxR = HRTIM_TIMRESETTRIGGER_EEV_8;
08184       break;
08185     }
08186 
08187   case HRTIM_EVENT_9:
08188     {
08189       hhrtim->Instance->sTimerxRegs[TimerIdx].RSTxR = HRTIM_TIMRESETTRIGGER_EEV_9;
08190       break;
08191     }
08192 
08193   case HRTIM_EVENT_10:
08194     {
08195       hhrtim->Instance->sTimerxRegs[TimerIdx].RSTxR = HRTIM_TIMRESETTRIGGER_EEV_10;
08196       break;
08197     }
08198 
08199   default:
08200     break;
08201   }
08202 }
08203 
08204 /**
08205   * @brief  Return the interrupt to enable or disable according to the
08206   *         OC mode.
08207   * @param  hhrtim pointer to HAL HRTIM handle
08208   * @param  TimerIdx Timer index
08209   * @param  OCChannel Timer output
08210   *                    This parameter can be one of the following values:
08211   *                    @arg HRTIM_OUTPUT_TA1: Timer A - Output 1
08212   *                    @arg HRTIM_OUTPUT_TA2: Timer A - Output 2
08213   *                    @arg HRTIM_OUTPUT_TB1: Timer B - Output 1
08214   *                    @arg HRTIM_OUTPUT_TB2: Timer B - Output 2
08215   *                    @arg HRTIM_OUTPUT_TC1: Timer C - Output 1
08216   *                    @arg HRTIM_OUTPUT_TC2: Timer C - Output 2
08217   *                    @arg HRTIM_OUTPUT_TD1: Timer D - Output 1
08218   *                    @arg HRTIM_OUTPUT_TD2: Timer D - Output 2
08219   *                    @arg HRTIM_OUTPUT_TE1: Timer E - Output 1
08220   *                    @arg HRTIM_OUTPUT_TE2: Timer E - Output 2
08221   * @retval Interrupt to enable or disable
08222   */
08223 static uint32_t HRTIM_GetITFromOCMode(HRTIM_HandleTypeDef * hhrtim,
08224                                       uint32_t TimerIdx,
08225                                       uint32_t OCChannel)
08226 {
08227   uint32_t hrtim_set;
08228   uint32_t hrtim_reset;
08229   uint32_t interrupt = 0U;
08230 
08231   switch (OCChannel)
08232   {
08233   case HRTIM_OUTPUT_TA1:
08234   case HRTIM_OUTPUT_TB1:
08235   case HRTIM_OUTPUT_TC1:
08236   case HRTIM_OUTPUT_TD1:
08237   case HRTIM_OUTPUT_TE1:
08238     {
08239       /* Retreives actual OC mode and set interrupt accordingly */
08240       hrtim_set = hhrtim->Instance->sTimerxRegs[TimerIdx].SETx1R;
08241       hrtim_reset = hhrtim->Instance->sTimerxRegs[TimerIdx].RSTx1R;
08242 
08243       if (((hrtim_set & HRTIM_OUTPUTSET_TIMCMP1) == HRTIM_OUTPUTSET_TIMCMP1) &&
08244           ((hrtim_reset & HRTIM_OUTPUTRESET_TIMCMP1) == HRTIM_OUTPUTRESET_TIMCMP1))
08245       {
08246         /* OC mode: HRTIM_BASICOCMODE_TOGGLE */
08247         interrupt = HRTIM_TIM_IT_CMP1;
08248       }
08249       else if (((hrtim_set & HRTIM_OUTPUTSET_TIMCMP1) == HRTIM_OUTPUTSET_TIMCMP1) &&
08250                (hrtim_reset == 0U))
08251       {
08252          /* OC mode: HRTIM_BASICOCMODE_ACTIVE */
08253         interrupt = HRTIM_TIM_IT_SET1;
08254       }
08255       else if ((hrtim_set == 0U) &&
08256                ((hrtim_reset & HRTIM_OUTPUTRESET_TIMCMP1) == HRTIM_OUTPUTRESET_TIMCMP1))
08257       {
08258          /* OC mode: HRTIM_BASICOCMODE_INACTIVE */
08259         interrupt = HRTIM_TIM_IT_RST1;
08260       }
08261       else
08262       {
08263        /* nothing to do */
08264       }
08265       break;
08266     }
08267 
08268   case HRTIM_OUTPUT_TA2:
08269   case HRTIM_OUTPUT_TB2:
08270   case HRTIM_OUTPUT_TC2:
08271   case HRTIM_OUTPUT_TD2:
08272   case HRTIM_OUTPUT_TE2:
08273     {
08274       /* Retreives actual OC mode and set interrupt accordingly */
08275       hrtim_set = hhrtim->Instance->sTimerxRegs[TimerIdx].SETx2R;
08276       hrtim_reset = hhrtim->Instance->sTimerxRegs[TimerIdx].RSTx2R;
08277 
08278       if (((hrtim_set & HRTIM_OUTPUTSET_TIMCMP2) == HRTIM_OUTPUTSET_TIMCMP2) &&
08279           ((hrtim_reset & HRTIM_OUTPUTRESET_TIMCMP2) == HRTIM_OUTPUTRESET_TIMCMP2))
08280       {
08281         /* OC mode: HRTIM_BASICOCMODE_TOGGLE */
08282         interrupt = HRTIM_TIM_IT_CMP2;
08283       }
08284       else if (((hrtim_set & HRTIM_OUTPUTSET_TIMCMP2) == HRTIM_OUTPUTSET_TIMCMP2) &&
08285                (hrtim_reset == 0U))
08286       {
08287          /* OC mode: HRTIM_BASICOCMODE_ACTIVE */
08288         interrupt = HRTIM_TIM_IT_SET2;
08289       }
08290       else if ((hrtim_set == 0U) &&
08291                ((hrtim_reset & HRTIM_OUTPUTRESET_TIMCMP2) == HRTIM_OUTPUTRESET_TIMCMP2))
08292       {
08293          /* OC mode: HRTIM_BASICOCMODE_INACTIVE */
08294         interrupt = HRTIM_TIM_IT_RST2;
08295       }
08296       else
08297       {
08298        /* nothing to do */
08299       }
08300       break;
08301     }
08302 
08303   default:
08304     break;
08305   }
08306 
08307   return interrupt;
08308 }
08309 
08310 /**
08311   * @brief  Return the DMA request to enable or disable according to the
08312   *         OC mode.
08313   * @param  hhrtim pointer to HAL HRTIM handle
08314   * @param  TimerIdx Timer index
08315   * @param  OCChannel Timer output
08316   *                    This parameter can be one of the following values:
08317   *                    @arg HRTIM_OUTPUT_TA1: Timer A - Output 1
08318   *                    @arg HRTIM_OUTPUT_TA2: Timer A - Output 2
08319   *                    @arg HRTIM_OUTPUT_TB1: Timer B - Output 1
08320   *                    @arg HRTIM_OUTPUT_TB2: Timer B - Output 2
08321   *                    @arg HRTIM_OUTPUT_TC1: Timer C - Output 1
08322   *                    @arg HRTIM_OUTPUT_TC2: Timer C - Output 2
08323   *                    @arg HRTIM_OUTPUT_TD1: Timer D - Output 1
08324   *                    @arg HRTIM_OUTPUT_TD2: Timer D - Output 2
08325   *                    @arg HRTIM_OUTPUT_TE1: Timer E - Output 1
08326   *                    @arg HRTIM_OUTPUT_TE2: Timer E - Output 2
08327   * @retval DMA request to enable or disable
08328   */
08329 static uint32_t HRTIM_GetDMAFromOCMode(HRTIM_HandleTypeDef * hhrtim,
08330                                        uint32_t TimerIdx,
08331                                        uint32_t OCChannel)
08332 {
08333   uint32_t hrtim_set;
08334   uint32_t hrtim_reset;
08335   uint32_t dma_request = 0U;
08336 
08337   switch (OCChannel)
08338   {
08339   case HRTIM_OUTPUT_TA1:
08340   case HRTIM_OUTPUT_TB1:
08341   case HRTIM_OUTPUT_TC1:
08342   case HRTIM_OUTPUT_TD1:
08343   case HRTIM_OUTPUT_TE1:
08344     {
08345       /* Retreives actual OC mode and set dma_request accordingly */
08346       hrtim_set = hhrtim->Instance->sTimerxRegs[TimerIdx].SETx1R;
08347       hrtim_reset = hhrtim->Instance->sTimerxRegs[TimerIdx].RSTx1R;
08348 
08349       if (((hrtim_set & HRTIM_OUTPUTSET_TIMCMP1) == HRTIM_OUTPUTSET_TIMCMP1) &&
08350           ((hrtim_reset & HRTIM_OUTPUTRESET_TIMCMP1) == HRTIM_OUTPUTRESET_TIMCMP1))
08351       {
08352         /* OC mode: HRTIM_BASICOCMODE_TOGGLE */
08353         dma_request = HRTIM_TIM_DMA_CMP1;
08354       }
08355       else if (((hrtim_set & HRTIM_OUTPUTSET_TIMCMP1) == HRTIM_OUTPUTSET_TIMCMP1) &&
08356                (hrtim_reset == 0U))
08357       {
08358          /* OC mode: HRTIM_BASICOCMODE_ACTIVE */
08359         dma_request = HRTIM_TIM_DMA_SET1;
08360       }
08361       else if ((hrtim_set == 0U) &&
08362                ((hrtim_reset & HRTIM_OUTPUTRESET_TIMCMP1) == HRTIM_OUTPUTRESET_TIMCMP1))
08363       {
08364          /* OC mode: HRTIM_BASICOCMODE_INACTIVE */
08365         dma_request = HRTIM_TIM_DMA_RST1;
08366       }
08367       else
08368       {
08369     /* nothing to do */
08370       }
08371       break;
08372     }
08373 
08374   case HRTIM_OUTPUT_TA2:
08375   case HRTIM_OUTPUT_TB2:
08376   case HRTIM_OUTPUT_TC2:
08377   case HRTIM_OUTPUT_TD2:
08378   case HRTIM_OUTPUT_TE2:
08379     {
08380       /* Retreives actual OC mode and set dma_request accordingly */
08381       hrtim_set = hhrtim->Instance->sTimerxRegs[TimerIdx].SETx2R;
08382       hrtim_reset = hhrtim->Instance->sTimerxRegs[TimerIdx].RSTx2R;
08383 
08384       if (((hrtim_set & HRTIM_OUTPUTSET_TIMCMP2) == HRTIM_OUTPUTSET_TIMCMP2) &&
08385           ((hrtim_reset & HRTIM_OUTPUTRESET_TIMCMP2) == HRTIM_OUTPUTRESET_TIMCMP2))
08386       {
08387         /* OC mode: HRTIM_BASICOCMODE_TOGGLE */
08388         dma_request = HRTIM_TIM_DMA_CMP2;
08389       }
08390       else if (((hrtim_set & HRTIM_OUTPUTSET_TIMCMP2) == HRTIM_OUTPUTSET_TIMCMP2) &&
08391                (hrtim_reset == 0U))
08392       {
08393          /* OC mode: HRTIM_BASICOCMODE_ACTIVE */
08394         dma_request = HRTIM_TIM_DMA_SET2;
08395       }
08396       else if ((hrtim_set == 0U) &&
08397                ((hrtim_reset & HRTIM_OUTPUTRESET_TIMCMP2) == HRTIM_OUTPUTRESET_TIMCMP2))
08398       {
08399          /* OC mode: HRTIM_BASICOCMODE_INACTIVE */
08400         dma_request = HRTIM_TIM_DMA_RST2;
08401       }
08402       else
08403       {
08404     /* nothing to do */
08405       }
08406       break;
08407     }
08408 
08409   default:
08410     break;
08411   }
08412 
08413   return dma_request;
08414 }
08415 
08416 static DMA_HandleTypeDef * HRTIM_GetDMAHandleFromTimerIdx(HRTIM_HandleTypeDef * hhrtim,
08417                                                           uint32_t TimerIdx)
08418 {
08419   DMA_HandleTypeDef * hdma = (DMA_HandleTypeDef *)NULL;
08420 
08421   switch (TimerIdx)
08422   {
08423   case HRTIM_TIMERINDEX_MASTER:
08424     {
08425       hdma = hhrtim->hdmaMaster;
08426       break;
08427     }
08428 
08429   case HRTIM_TIMERINDEX_TIMER_A:
08430     {
08431       hdma = hhrtim->hdmaTimerA;
08432       break;
08433     }
08434 
08435   case HRTIM_TIMERINDEX_TIMER_B:
08436     {
08437       hdma = hhrtim->hdmaTimerB;
08438       break;
08439     }
08440 
08441   case HRTIM_TIMERINDEX_TIMER_C:
08442     {
08443       hdma = hhrtim->hdmaTimerC;
08444       break;
08445     }
08446 
08447   case HRTIM_TIMERINDEX_TIMER_D:
08448     {
08449       hdma = hhrtim->hdmaTimerD;
08450       break;
08451     }
08452 
08453   case HRTIM_TIMERINDEX_TIMER_E:
08454     {
08455       hdma = hhrtim->hdmaTimerE;
08456       break;
08457     }
08458 
08459   default:
08460     break;
08461   }
08462 
08463   return hdma;
08464 }
08465 
08466 static uint32_t GetTimerIdxFromDMAHandle(HRTIM_HandleTypeDef * hhrtim,
08467                                          DMA_HandleTypeDef * hdma)
08468 {
08469   uint32_t timed_idx = 0xFFFFFFFFU;
08470 
08471   if (hdma == hhrtim->hdmaMaster)
08472   {
08473     timed_idx = HRTIM_TIMERINDEX_MASTER;
08474   }
08475   else if (hdma == hhrtim->hdmaTimerA)
08476   {
08477     timed_idx = HRTIM_TIMERINDEX_TIMER_A;
08478   }
08479   else if (hdma == hhrtim->hdmaTimerB)
08480   {
08481     timed_idx = HRTIM_TIMERINDEX_TIMER_B;
08482   }
08483   else if (hdma == hhrtim->hdmaTimerC)
08484   {
08485     timed_idx = HRTIM_TIMERINDEX_TIMER_C;
08486   }
08487   else if (hdma == hhrtim->hdmaTimerD)
08488   {
08489     timed_idx = HRTIM_TIMERINDEX_TIMER_D;
08490   }
08491   else if (hdma == hhrtim->hdmaTimerE)
08492   {
08493     timed_idx = HRTIM_TIMERINDEX_TIMER_E;
08494   }
08495   else
08496   {
08497     /* nothing to do */
08498   }
08499   return timed_idx;
08500 }
08501 
08502 /**
08503   * @brief  Force an immediate transfer from the preload to the active
08504   *         registers.
08505   * @param  hhrtim pointer to HAL HRTIM handle
08506   * @param  TimerIdx Timer index
08507   * @retval None
08508   */
08509 static void HRTIM_ForceRegistersUpdate(HRTIM_HandleTypeDef * hhrtim,
08510                                        uint32_t TimerIdx)
08511 {
08512   switch (TimerIdx)
08513   {
08514   case HRTIM_TIMERINDEX_MASTER:
08515     {
08516       hhrtim->Instance->sCommonRegs.CR2 |= HRTIM_CR2_MSWU;
08517       break;
08518     }
08519 
08520   case HRTIM_TIMERINDEX_TIMER_A:
08521     {
08522       hhrtim->Instance->sCommonRegs.CR2 |= HRTIM_CR2_TASWU;
08523       break;
08524     }
08525 
08526   case HRTIM_TIMERINDEX_TIMER_B:
08527     {
08528       hhrtim->Instance->sCommonRegs.CR2 |= HRTIM_CR2_TBSWU;
08529       break;
08530     }
08531 
08532   case HRTIM_TIMERINDEX_TIMER_C:
08533     {
08534       hhrtim->Instance->sCommonRegs.CR2 |= HRTIM_CR2_TCSWU;
08535       break;
08536     }
08537 
08538   case HRTIM_TIMERINDEX_TIMER_D:
08539     {
08540       hhrtim->Instance->sCommonRegs.CR2 |= HRTIM_CR2_TDSWU;
08541       break;
08542     }
08543 
08544   case HRTIM_TIMERINDEX_TIMER_E:
08545     {
08546       hhrtim->Instance->sCommonRegs.CR2 |= HRTIM_CR2_TESWU;
08547       break;
08548     }
08549 
08550   default:
08551     break;
08552   }
08553 }
08554 
08555 
08556 /**
08557   * @brief  HRTIM interrupts service routine
08558   * @param  hhrtim pointer to HAL HRTIM handle
08559   * @retval None
08560   */
08561 static void HRTIM_HRTIM_ISR(HRTIM_HandleTypeDef * hhrtim)
08562 {
08563   uint32_t isrflags = READ_REG(hhrtim->Instance->sCommonRegs.ISR);
08564   uint32_t ierits   = READ_REG(hhrtim->Instance->sCommonRegs.IER);
08565 
08566   /* Fault 1 event */
08567   if((uint32_t)(isrflags & HRTIM_FLAG_FLT1) != (uint32_t)RESET)
08568   {
08569     if((uint32_t)(ierits & HRTIM_IT_FLT1) != (uint32_t)RESET)
08570     {
08571       __HAL_HRTIM_CLEAR_IT(hhrtim, HRTIM_IT_FLT1);
08572 
08573       /* Invoke Fault 1 event callback */
08574 #if (USE_HAL_HRTIM_REGISTER_CALLBACKS == 1)
08575       hhrtim->Fault1Callback(hhrtim);
08576 #else
08577       HAL_HRTIM_Fault1Callback(hhrtim);
08578 #endif /* USE_HAL_HRTIM_REGISTER_CALLBACKS */
08579     }
08580   }
08581 
08582   /* Fault 2 event */
08583   if((uint32_t)(isrflags & HRTIM_FLAG_FLT2) != (uint32_t)RESET)
08584   {
08585     if((uint32_t)(ierits & HRTIM_IT_FLT2) != (uint32_t)RESET)
08586     {
08587       __HAL_HRTIM_CLEAR_IT(hhrtim, HRTIM_IT_FLT2);
08588 
08589       /* Invoke Fault 2 event callback */
08590 #if (USE_HAL_HRTIM_REGISTER_CALLBACKS == 1)
08591       hhrtim->Fault2Callback(hhrtim);
08592 #else
08593       HAL_HRTIM_Fault2Callback(hhrtim);
08594 #endif /* USE_HAL_HRTIM_REGISTER_CALLBACKS */
08595     }
08596   }
08597 
08598   /* Fault 3 event */
08599   if((uint32_t)(isrflags & HRTIM_FLAG_FLT3) != (uint32_t)RESET)
08600   {
08601     if((uint32_t)(ierits & HRTIM_IT_FLT3) != (uint32_t)RESET)
08602     {
08603       __HAL_HRTIM_CLEAR_IT(hhrtim, HRTIM_IT_FLT3);
08604 
08605       /* Invoke Fault 3 event callback */
08606 #if (USE_HAL_HRTIM_REGISTER_CALLBACKS == 1)
08607       hhrtim->Fault3Callback(hhrtim);
08608 #else
08609       HAL_HRTIM_Fault3Callback(hhrtim);
08610 #endif /* USE_HAL_HRTIM_REGISTER_CALLBACKS */
08611     }
08612   }
08613 
08614   /* Fault 4 event */
08615   if((uint32_t)(isrflags & HRTIM_FLAG_FLT4) != (uint32_t)RESET)
08616   {
08617     if((uint32_t)(ierits & HRTIM_IT_FLT4) != (uint32_t)RESET)
08618     {
08619       __HAL_HRTIM_CLEAR_IT(hhrtim, HRTIM_IT_FLT4);
08620 
08621       /* Invoke Fault 4 event callback */
08622 #if (USE_HAL_HRTIM_REGISTER_CALLBACKS == 1)
08623       hhrtim->Fault4Callback(hhrtim);
08624 #else
08625       HAL_HRTIM_Fault4Callback(hhrtim);
08626 #endif /* USE_HAL_HRTIM_REGISTER_CALLBACKS */
08627     }
08628   }
08629 
08630   /* Fault 5 event */
08631   if((uint32_t)(isrflags & HRTIM_FLAG_FLT5) != (uint32_t)RESET)
08632   {
08633     if((uint32_t)(ierits & HRTIM_IT_FLT5) != (uint32_t)RESET)
08634     {
08635       __HAL_HRTIM_CLEAR_IT(hhrtim, HRTIM_IT_FLT5);
08636 
08637       /* Invoke Fault 5 event callback */
08638 #if (USE_HAL_HRTIM_REGISTER_CALLBACKS == 1)
08639       hhrtim->Fault5Callback(hhrtim);
08640 #else
08641       HAL_HRTIM_Fault5Callback(hhrtim);
08642 #endif /* USE_HAL_HRTIM_REGISTER_CALLBACKS */
08643     }
08644   }
08645 
08646   /* System fault event */
08647   if((uint32_t)(isrflags & HRTIM_FLAG_SYSFLT) != (uint32_t)RESET)
08648   {
08649     if((uint32_t)(ierits & HRTIM_IT_SYSFLT) != (uint32_t)RESET)
08650     {
08651       __HAL_HRTIM_CLEAR_IT(hhrtim, HRTIM_IT_SYSFLT);
08652 
08653       /* Invoke System fault event callback */
08654 #if (USE_HAL_HRTIM_REGISTER_CALLBACKS == 1)
08655       hhrtim->SystemFaultCallback(hhrtim);
08656 #else
08657       HAL_HRTIM_SystemFaultCallback(hhrtim);
08658 #endif /* USE_HAL_HRTIM_REGISTER_CALLBACKS */
08659     }
08660   }
08661 }
08662 
08663 /**
08664 * @brief  Master timer interrupts service routine
08665 * @param  hhrtim pointer to HAL HRTIM handle
08666 * @retval None
08667 */
08668 static void HRTIM_Master_ISR(HRTIM_HandleTypeDef * hhrtim)
08669 {
08670   uint32_t isrflags  = READ_REG(hhrtim->Instance->sCommonRegs.ISR);
08671   uint32_t ierits    = READ_REG(hhrtim->Instance->sCommonRegs.IER);
08672   uint32_t misrflags = READ_REG(hhrtim->Instance->sMasterRegs.MISR);
08673   uint32_t mdierits  = READ_REG(hhrtim->Instance->sMasterRegs.MDIER);
08674 
08675   /* Burst mode period event */
08676   if((uint32_t)(isrflags & HRTIM_FLAG_BMPER) != (uint32_t)RESET)
08677   {
08678     if((uint32_t)(ierits & HRTIM_IT_BMPER) != (uint32_t)RESET)
08679     {
08680       __HAL_HRTIM_CLEAR_IT(hhrtim, HRTIM_IT_BMPER);
08681 
08682       /* Invoke Burst mode period event callback */
08683 #if (USE_HAL_HRTIM_REGISTER_CALLBACKS == 1)
08684       hhrtim->BurstModePeriodCallback(hhrtim);
08685 #else
08686       HAL_HRTIM_BurstModePeriodCallback(hhrtim);
08687 #endif /* USE_HAL_HRTIM_REGISTER_CALLBACKS */
08688     }
08689   }
08690 
08691   /* Master timer compare 1 event */
08692   if((uint32_t)(misrflags & HRTIM_MASTER_FLAG_MCMP1) != (uint32_t)RESET)
08693   {
08694     if((uint32_t)(mdierits & HRTIM_MASTER_IT_MCMP1) != (uint32_t)RESET)
08695     {
08696       __HAL_HRTIM_MASTER_CLEAR_IT(hhrtim, HRTIM_MASTER_IT_MCMP1);
08697 
08698       /* Invoke compare 1 event callback */
08699 #if (USE_HAL_HRTIM_REGISTER_CALLBACKS == 1)
08700       hhrtim->Compare1EventCallback(hhrtim, HRTIM_TIMERINDEX_MASTER);
08701 #else
08702       HAL_HRTIM_Compare1EventCallback(hhrtim, HRTIM_TIMERINDEX_MASTER);
08703 #endif /* USE_HAL_HRTIM_REGISTER_CALLBACKS */
08704     }
08705   }
08706 
08707   /* Master timer compare 2 event */
08708   if((uint32_t)(misrflags & HRTIM_MASTER_FLAG_MCMP2) != (uint32_t)RESET)
08709   {
08710     if((uint32_t)(mdierits & HRTIM_MASTER_IT_MCMP2) != (uint32_t)RESET)
08711     {
08712       __HAL_HRTIM_MASTER_CLEAR_IT(hhrtim, HRTIM_MASTER_IT_MCMP2);
08713 
08714       /* Invoke compare 2 event callback */
08715 #if (USE_HAL_HRTIM_REGISTER_CALLBACKS == 1)
08716       hhrtim->Compare2EventCallback(hhrtim, HRTIM_TIMERINDEX_MASTER);
08717 #else
08718       HAL_HRTIM_Compare2EventCallback(hhrtim, HRTIM_TIMERINDEX_MASTER);
08719 #endif /* USE_HAL_HRTIM_REGISTER_CALLBACKS */
08720     }
08721   }
08722 
08723   /* Master timer compare 3 event */
08724   if((uint32_t)(misrflags & HRTIM_MASTER_FLAG_MCMP3) != (uint32_t)RESET)
08725   {
08726     if((uint32_t)(mdierits & HRTIM_MASTER_IT_MCMP3) != (uint32_t)RESET)
08727     {
08728       __HAL_HRTIM_MASTER_CLEAR_IT(hhrtim, HRTIM_MASTER_IT_MCMP3);
08729 
08730       /* Invoke compare 3 event callback */
08731 #if (USE_HAL_HRTIM_REGISTER_CALLBACKS == 1)
08732       hhrtim->Compare3EventCallback(hhrtim, HRTIM_TIMERINDEX_MASTER);
08733 #else
08734       HAL_HRTIM_Compare3EventCallback(hhrtim, HRTIM_TIMERINDEX_MASTER);
08735 #endif /* USE_HAL_HRTIM_REGISTER_CALLBACKS */
08736     }
08737   }
08738 
08739   /* Master timer compare 4 event */
08740   if((uint32_t)(misrflags & HRTIM_MASTER_FLAG_MCMP4) != (uint32_t)RESET)
08741   {
08742     if((uint32_t)(mdierits & HRTIM_MASTER_IT_MCMP4) != (uint32_t)RESET)
08743     {
08744       __HAL_HRTIM_MASTER_CLEAR_IT(hhrtim, HRTIM_MASTER_IT_MCMP4);
08745 
08746       /* Invoke compare 4 event callback */
08747 #if (USE_HAL_HRTIM_REGISTER_CALLBACKS == 1)
08748       hhrtim->Compare4EventCallback(hhrtim, HRTIM_TIMERINDEX_MASTER);
08749 #else
08750       HAL_HRTIM_Compare4EventCallback(hhrtim, HRTIM_TIMERINDEX_MASTER);
08751 #endif /* USE_HAL_HRTIM_REGISTER_CALLBACKS */
08752     }
08753   }
08754 
08755   /* Master timer repetition event */
08756   if((uint32_t)(misrflags & HRTIM_MASTER_FLAG_MREP) != (uint32_t)RESET)
08757   {
08758     if((uint32_t)(mdierits & HRTIM_MASTER_IT_MREP) != (uint32_t)RESET)
08759     {
08760       __HAL_HRTIM_MASTER_CLEAR_IT(hhrtim, HRTIM_MASTER_IT_MREP);
08761 
08762       /* Invoke repetition event callback */
08763 #if (USE_HAL_HRTIM_REGISTER_CALLBACKS == 1)
08764       hhrtim->RepetitionEventCallback(hhrtim, HRTIM_TIMERINDEX_MASTER);
08765 #else
08766       HAL_HRTIM_RepetitionEventCallback(hhrtim, HRTIM_TIMERINDEX_MASTER);
08767 #endif /* USE_HAL_HRTIM_REGISTER_CALLBACKS */
08768     }
08769   }
08770 
08771   /* Synchronization input event */
08772   if((uint32_t)(misrflags & HRTIM_MASTER_FLAG_SYNC) != (uint32_t)RESET)
08773   {
08774     if((uint32_t)(mdierits & HRTIM_MASTER_IT_SYNC) != (uint32_t)RESET)
08775     {
08776       __HAL_HRTIM_MASTER_CLEAR_IT(hhrtim, HRTIM_MASTER_IT_SYNC);
08777 
08778       /* Invoke synchronization event callback */
08779 #if (USE_HAL_HRTIM_REGISTER_CALLBACKS == 1)
08780       hhrtim->SynchronizationEventCallback(hhrtim);
08781 #else
08782       HAL_HRTIM_SynchronizationEventCallback(hhrtim);
08783 #endif /* USE_HAL_HRTIM_REGISTER_CALLBACKS */
08784     }
08785   }
08786 
08787   /* Master timer registers update event */
08788   if((uint32_t)(misrflags & HRTIM_MASTER_FLAG_MUPD) != (uint32_t)RESET)
08789   {
08790     if((uint32_t)(mdierits & HRTIM_MASTER_IT_MUPD) != (uint32_t)RESET)
08791     {
08792       __HAL_HRTIM_MASTER_CLEAR_IT(hhrtim, HRTIM_MASTER_IT_MUPD);
08793 
08794       /* Invoke registers update event callback */
08795 #if (USE_HAL_HRTIM_REGISTER_CALLBACKS == 1)
08796       hhrtim->RegistersUpdateCallback(hhrtim, HRTIM_TIMERINDEX_MASTER);
08797 #else
08798       HAL_HRTIM_RegistersUpdateCallback(hhrtim, HRTIM_TIMERINDEX_MASTER);
08799 #endif /* USE_HAL_HRTIM_REGISTER_CALLBACKS */
08800     }
08801   }
08802 }
08803 
08804 /**
08805   * @brief  Timer interrupts service routine
08806   * @param  hhrtim pointer to HAL HRTIM handle
08807   * @param  TimerIdx Timer index
08808   *                   This parameter can be one of the following values:
08809   *                   @arg HRTIM_TIMERINDEX_TIMER_A for timer A
08810   *                   @arg HRTIM_TIMERINDEX_TIMER_B for timer B
08811   *                   @arg HRTIM_TIMERINDEX_TIMER_C for timer C
08812   *                   @arg HRTIM_TIMERINDEX_TIMER_D for timer D
08813   *                   @arg HRTIM_TIMERINDEX_TIMER_E for timer E
08814   * @retval None
08815 */
08816 static void HRTIM_Timer_ISR(HRTIM_HandleTypeDef * hhrtim,
08817                      uint32_t TimerIdx)
08818 {
08819   uint32_t tisrflags = READ_REG(hhrtim->Instance->sTimerxRegs[TimerIdx].TIMxISR);
08820   uint32_t tdierits  = READ_REG(hhrtim->Instance->sTimerxRegs[TimerIdx].TIMxDIER);
08821 
08822   /* Timer compare 1 event */
08823   if((uint32_t)(tisrflags & HRTIM_TIM_FLAG_CMP1) != (uint32_t)RESET)
08824   {
08825     if((uint32_t)(tdierits & HRTIM_TIM_IT_CMP1) != (uint32_t)RESET)
08826     {
08827       __HAL_HRTIM_TIMER_CLEAR_IT(hhrtim, TimerIdx, HRTIM_TIM_IT_CMP1);
08828 
08829       /* Invoke compare 1 event callback */
08830 #if (USE_HAL_HRTIM_REGISTER_CALLBACKS == 1)
08831       hhrtim->Compare1EventCallback(hhrtim, TimerIdx);
08832 #else
08833       HAL_HRTIM_Compare1EventCallback(hhrtim, TimerIdx);
08834 #endif /* USE_HAL_HRTIM_REGISTER_CALLBACKS */
08835     }
08836   }
08837 
08838   /* Timer compare 2 event */
08839   if((uint32_t)(tisrflags & HRTIM_TIM_FLAG_CMP2) != (uint32_t)RESET)
08840   {
08841     if((uint32_t)(tdierits & HRTIM_TIM_IT_CMP2) != (uint32_t)RESET)
08842     {
08843       __HAL_HRTIM_TIMER_CLEAR_IT(hhrtim, TimerIdx, HRTIM_TIM_IT_CMP2);
08844 
08845       /* Invoke compare 2 event callback */
08846 #if (USE_HAL_HRTIM_REGISTER_CALLBACKS == 1)
08847       hhrtim->Compare2EventCallback(hhrtim, TimerIdx);
08848 #else
08849       HAL_HRTIM_Compare2EventCallback(hhrtim, TimerIdx);
08850 #endif /* USE_HAL_HRTIM_REGISTER_CALLBACKS */
08851     }
08852   }
08853 
08854   /* Timer compare 3 event */
08855   if((uint32_t)(tisrflags & HRTIM_TIM_FLAG_CMP3) != (uint32_t)RESET)
08856   {
08857     if((uint32_t)(tdierits & HRTIM_TIM_IT_CMP3) != (uint32_t)RESET)
08858     {
08859       __HAL_HRTIM_TIMER_CLEAR_IT(hhrtim, TimerIdx, HRTIM_TIM_IT_CMP3);
08860 
08861       /* Invoke compare 3 event callback */
08862 #if (USE_HAL_HRTIM_REGISTER_CALLBACKS == 1)
08863       hhrtim->Compare3EventCallback(hhrtim, TimerIdx);
08864 #else
08865       HAL_HRTIM_Compare3EventCallback(hhrtim, TimerIdx);
08866 #endif /* USE_HAL_HRTIM_REGISTER_CALLBACKS */
08867     }
08868   }
08869 
08870   /* Timer compare 4 event */
08871   if((uint32_t)(tisrflags & HRTIM_TIM_FLAG_CMP4) != (uint32_t)RESET)
08872   {
08873     if((uint32_t)(tdierits & HRTIM_TIM_IT_CMP4) != (uint32_t)RESET)
08874     {
08875       __HAL_HRTIM_TIMER_CLEAR_IT(hhrtim, TimerIdx, HRTIM_TIM_IT_CMP4);
08876 
08877       /* Invoke compare 4 event callback */
08878 #if (USE_HAL_HRTIM_REGISTER_CALLBACKS == 1)
08879       hhrtim->Compare4EventCallback(hhrtim, TimerIdx);
08880 #else
08881       HAL_HRTIM_Compare4EventCallback(hhrtim, TimerIdx);
08882 #endif /* USE_HAL_HRTIM_REGISTER_CALLBACKS */
08883     }
08884   }
08885 
08886   /* Timer repetition event */
08887   if((uint32_t)(tisrflags & HRTIM_TIM_FLAG_REP) != (uint32_t)RESET)
08888   {
08889     if((uint32_t)(tdierits & HRTIM_TIM_IT_REP) != (uint32_t)RESET)
08890     {
08891       __HAL_HRTIM_TIMER_CLEAR_IT(hhrtim, TimerIdx, HRTIM_TIM_IT_REP);
08892 
08893       /* Invoke repetition event callback */
08894 #if (USE_HAL_HRTIM_REGISTER_CALLBACKS == 1)
08895       hhrtim->RepetitionEventCallback(hhrtim, TimerIdx);
08896 #else
08897       HAL_HRTIM_RepetitionEventCallback(hhrtim, TimerIdx);
08898 #endif /* USE_HAL_HRTIM_REGISTER_CALLBACKS */
08899     }
08900   }
08901 
08902   /* Timer registers update event */
08903   if((uint32_t)(tisrflags & HRTIM_TIM_FLAG_UPD) != (uint32_t)RESET)
08904   {
08905     if((uint32_t)(tdierits & HRTIM_TIM_IT_UPD) != (uint32_t)RESET)
08906     {
08907       __HAL_HRTIM_TIMER_CLEAR_IT(hhrtim, TimerIdx, HRTIM_TIM_IT_UPD);
08908 
08909       /* Invoke registers update event callback */
08910 #if (USE_HAL_HRTIM_REGISTER_CALLBACKS == 1)
08911       hhrtim->RegistersUpdateCallback(hhrtim, TimerIdx);
08912 #else
08913       HAL_HRTIM_RegistersUpdateCallback(hhrtim, TimerIdx);
08914 #endif /* USE_HAL_HRTIM_REGISTER_CALLBACKS */
08915     }
08916   }
08917 
08918   /* Timer capture 1 event */
08919   if((uint32_t)(tisrflags & HRTIM_TIM_FLAG_CPT1) != (uint32_t)RESET)
08920   {
08921     if((uint32_t)(tdierits & HRTIM_TIM_IT_CPT1) != (uint32_t)RESET)
08922     {
08923       __HAL_HRTIM_TIMER_CLEAR_IT(hhrtim, TimerIdx, HRTIM_TIM_IT_CPT1);
08924 
08925       /* Invoke capture 1 event callback */
08926 #if (USE_HAL_HRTIM_REGISTER_CALLBACKS == 1)
08927       hhrtim->Capture1EventCallback(hhrtim, TimerIdx);
08928 #else
08929       HAL_HRTIM_Capture1EventCallback(hhrtim, TimerIdx);
08930 #endif /* USE_HAL_HRTIM_REGISTER_CALLBACKS */
08931     }
08932   }
08933 
08934   /* Timer capture 2 event */
08935   if((uint32_t)(tisrflags & HRTIM_TIM_FLAG_CPT2) != (uint32_t)RESET)
08936   {
08937     if((uint32_t)(tdierits & HRTIM_TIM_IT_CPT2) != (uint32_t)RESET)
08938     {
08939       __HAL_HRTIM_TIMER_CLEAR_IT(hhrtim, TimerIdx, HRTIM_TIM_IT_CPT2);
08940 
08941       /* Invoke capture 2 event callback */
08942 #if (USE_HAL_HRTIM_REGISTER_CALLBACKS == 1)
08943       hhrtim->Capture2EventCallback(hhrtim, TimerIdx);
08944 #else
08945       HAL_HRTIM_Capture2EventCallback(hhrtim, TimerIdx);
08946 #endif /* USE_HAL_HRTIM_REGISTER_CALLBACKS */
08947     }
08948   }
08949 
08950   /* Timer output 1 set event */
08951   if((uint32_t)(tisrflags & HRTIM_TIM_FLAG_SET1) != (uint32_t)RESET)
08952   {
08953     if((uint32_t)(tdierits & HRTIM_TIM_IT_SET1) != (uint32_t)RESET)
08954     {
08955       __HAL_HRTIM_TIMER_CLEAR_IT(hhrtim, TimerIdx, HRTIM_TIM_IT_SET1);
08956 
08957       /* Invoke output 1 set event callback */
08958 #if (USE_HAL_HRTIM_REGISTER_CALLBACKS == 1)
08959       hhrtim->Output1SetCallback(hhrtim, TimerIdx);
08960 #else
08961       HAL_HRTIM_Output1SetCallback(hhrtim, TimerIdx);
08962 #endif /* USE_HAL_HRTIM_REGISTER_CALLBACKS */
08963     }
08964   }
08965 
08966   /* Timer output 1 reset event */
08967   if((uint32_t)(tisrflags & HRTIM_TIM_FLAG_RST1) != (uint32_t)RESET)
08968   {
08969     if((uint32_t)(tdierits & HRTIM_TIM_IT_RST1) != (uint32_t)RESET)
08970     {
08971       __HAL_HRTIM_TIMER_CLEAR_IT(hhrtim, TimerIdx, HRTIM_TIM_IT_RST1);
08972 
08973       /* Invoke output 1 reset event callback */
08974 #if (USE_HAL_HRTIM_REGISTER_CALLBACKS == 1)
08975       hhrtim->Output1ResetCallback(hhrtim, TimerIdx);
08976 #else
08977       HAL_HRTIM_Output1ResetCallback(hhrtim, TimerIdx);
08978 #endif /* USE_HAL_HRTIM_REGISTER_CALLBACKS */
08979     }
08980   }
08981 
08982   /* Timer output 2 set event */
08983   if((uint32_t)(tisrflags & HRTIM_TIM_FLAG_SET2) != (uint32_t)RESET)
08984   {
08985     if((uint32_t)(tdierits & HRTIM_TIM_IT_SET2) != (uint32_t)RESET)
08986     {
08987       __HAL_HRTIM_TIMER_CLEAR_IT(hhrtim, TimerIdx, HRTIM_TIM_IT_SET2);
08988 
08989       /* Invoke output 2 set event callback */
08990 #if (USE_HAL_HRTIM_REGISTER_CALLBACKS == 1)
08991       hhrtim->Output2SetCallback(hhrtim, TimerIdx);
08992 #else
08993       HAL_HRTIM_Output2SetCallback(hhrtim, TimerIdx);
08994 #endif /* USE_HAL_HRTIM_REGISTER_CALLBACKS */
08995     }
08996   }
08997 
08998   /* Timer output 2 reset event */
08999   if((uint32_t)(tisrflags & HRTIM_TIM_FLAG_RST2) != (uint32_t)RESET)
09000   {
09001     if((uint32_t)(tdierits & HRTIM_TIM_IT_RST2) != (uint32_t)RESET)
09002     {
09003       __HAL_HRTIM_TIMER_CLEAR_IT(hhrtim, TimerIdx, HRTIM_TIM_IT_RST2);
09004 
09005       /* Invoke output 2 reset event callback */
09006 #if (USE_HAL_HRTIM_REGISTER_CALLBACKS == 1)
09007       hhrtim->Output2ResetCallback(hhrtim, TimerIdx);
09008 #else
09009       HAL_HRTIM_Output2ResetCallback(hhrtim, TimerIdx);
09010 #endif /* USE_HAL_HRTIM_REGISTER_CALLBACKS */
09011     }
09012   }
09013 
09014   /* Timer reset event */
09015   if((uint32_t)(tisrflags & HRTIM_TIM_FLAG_RST) != (uint32_t)RESET)
09016   {
09017     if((uint32_t)(tdierits & HRTIM_TIM_IT_RST) != (uint32_t)RESET)
09018     {
09019       __HAL_HRTIM_TIMER_CLEAR_IT(hhrtim, TimerIdx, HRTIM_TIM_IT_RST);
09020 
09021       /* Invoke timer reset callback */
09022 #if (USE_HAL_HRTIM_REGISTER_CALLBACKS == 1)
09023       hhrtim->CounterResetCallback(hhrtim, TimerIdx);
09024 #else
09025       HAL_HRTIM_CounterResetCallback(hhrtim, TimerIdx);
09026 #endif /* USE_HAL_HRTIM_REGISTER_CALLBACKS */
09027     }
09028   }
09029 
09030   /* Delayed protection event */
09031   if((uint32_t)(tisrflags & HRTIM_TIM_FLAG_DLYPRT) != (uint32_t)RESET)
09032   {
09033     if((uint32_t)(tdierits & HRTIM_TIM_IT_DLYPRT) != (uint32_t)RESET)
09034     {
09035       __HAL_HRTIM_TIMER_CLEAR_IT(hhrtim, TimerIdx, HRTIM_TIM_IT_DLYPRT);
09036 
09037       /* Invoke delayed protection callback */
09038 #if (USE_HAL_HRTIM_REGISTER_CALLBACKS == 1)
09039       hhrtim->DelayedProtectionCallback(hhrtim, TimerIdx);
09040 #else
09041       HAL_HRTIM_DelayedProtectionCallback(hhrtim, TimerIdx);
09042 #endif /* USE_HAL_HRTIM_REGISTER_CALLBACKS */
09043     }
09044   }
09045 }
09046 
09047 /**
09048   * @brief  DMA callback invoked upon master timer related DMA request completion
09049   * @param  hdma pointer to DMA handle.
09050   * @retval None
09051   */
09052 static void HRTIM_DMAMasterCplt(DMA_HandleTypeDef *hdma)
09053 {
09054   HRTIM_HandleTypeDef * hrtim = (HRTIM_HandleTypeDef *)((DMA_HandleTypeDef* )hdma)->Parent;
09055 
09056   if ((hrtim->Instance->sMasterRegs.MDIER & HRTIM_MASTER_DMA_MCMP1) != (uint32_t)RESET)
09057   {
09058 #if (USE_HAL_HRTIM_REGISTER_CALLBACKS == 1)
09059     hrtim->Compare1EventCallback(hrtim, HRTIM_TIMERINDEX_MASTER);
09060 #else
09061     HAL_HRTIM_Compare1EventCallback(hrtim, HRTIM_TIMERINDEX_MASTER);
09062 #endif /* USE_HAL_HRTIM_REGISTER_CALLBACKS */
09063   }
09064   else if ((hrtim->Instance->sMasterRegs.MDIER & HRTIM_MASTER_DMA_MCMP2) != (uint32_t)RESET)
09065   {
09066 #if (USE_HAL_HRTIM_REGISTER_CALLBACKS == 1)
09067     hrtim->Compare2EventCallback(hrtim, HRTIM_TIMERINDEX_MASTER);
09068 #else
09069     HAL_HRTIM_Compare2EventCallback(hrtim, HRTIM_TIMERINDEX_MASTER);
09070 #endif /* USE_HAL_HRTIM_REGISTER_CALLBACKS */
09071   }
09072   else if ((hrtim->Instance->sMasterRegs.MDIER & HRTIM_MASTER_DMA_MCMP3) != (uint32_t)RESET)
09073   {
09074 #if (USE_HAL_HRTIM_REGISTER_CALLBACKS == 1)
09075     hrtim->Compare3EventCallback(hrtim, HRTIM_TIMERINDEX_MASTER);
09076 #else
09077     HAL_HRTIM_Compare3EventCallback(hrtim, HRTIM_TIMERINDEX_MASTER);
09078 #endif /* USE_HAL_HRTIM_REGISTER_CALLBACKS */
09079   }
09080   else if ((hrtim->Instance->sMasterRegs.MDIER & HRTIM_MASTER_DMA_MCMP4) != (uint32_t)RESET)
09081   {
09082 #if (USE_HAL_HRTIM_REGISTER_CALLBACKS == 1)
09083     hrtim->Compare4EventCallback(hrtim, HRTIM_TIMERINDEX_MASTER);
09084 #else
09085     HAL_HRTIM_Compare4EventCallback(hrtim, HRTIM_TIMERINDEX_MASTER);
09086 #endif /* USE_HAL_HRTIM_REGISTER_CALLBACKS */
09087   }
09088   else if ((hrtim->Instance->sMasterRegs.MDIER & HRTIM_MASTER_DMA_SYNC) != (uint32_t)RESET)
09089   {
09090 #if (USE_HAL_HRTIM_REGISTER_CALLBACKS == 1)
09091     hrtim->SynchronizationEventCallback(hrtim);
09092 #else
09093     HAL_HRTIM_SynchronizationEventCallback(hrtim);
09094 #endif /* USE_HAL_HRTIM_REGISTER_CALLBACKS */
09095   }
09096   else if ((hrtim->Instance->sMasterRegs.MDIER & HRTIM_MASTER_DMA_MUPD) != (uint32_t)RESET)
09097   {
09098 #if (USE_HAL_HRTIM_REGISTER_CALLBACKS == 1)
09099     hrtim->RegistersUpdateCallback(hrtim, HRTIM_TIMERINDEX_MASTER);
09100 #else
09101     HAL_HRTIM_RegistersUpdateCallback(hrtim, HRTIM_TIMERINDEX_MASTER);
09102 #endif /* USE_HAL_HRTIM_REGISTER_CALLBACKS */
09103   }
09104   else if ((hrtim->Instance->sMasterRegs.MDIER & HRTIM_MASTER_DMA_MREP) != (uint32_t)RESET)
09105   {
09106 #if (USE_HAL_HRTIM_REGISTER_CALLBACKS == 1)
09107     hrtim->RepetitionEventCallback(hrtim, HRTIM_TIMERINDEX_MASTER);
09108 #else
09109     HAL_HRTIM_RepetitionEventCallback(hrtim, HRTIM_TIMERINDEX_MASTER);
09110 #endif /* USE_HAL_HRTIM_REGISTER_CALLBACKS */
09111   }
09112   else
09113   {
09114     /* nothing to do */
09115   }
09116 }
09117 
09118 /**
09119   * @brief  DMA callback invoked upon timer A..E related DMA request completion
09120   * @param  hdma pointer to DMA handle.
09121   * @retval None
09122   */
09123 static void HRTIM_DMATimerxCplt(DMA_HandleTypeDef *hdma)
09124 {
09125   uint8_t timer_idx;
09126 
09127   HRTIM_HandleTypeDef * hrtim = (HRTIM_HandleTypeDef *)((DMA_HandleTypeDef* )hdma)->Parent;
09128 
09129   timer_idx = (uint8_t)GetTimerIdxFromDMAHandle(hrtim, hdma);
09130 
09131   if ( !IS_HRTIM_TIMING_UNIT(timer_idx) ) {return;}
09132 
09133   if ((hrtim->Instance->sTimerxRegs[timer_idx].TIMxDIER & HRTIM_TIM_DMA_CMP1) != (uint32_t)RESET)
09134   {
09135 #if (USE_HAL_HRTIM_REGISTER_CALLBACKS == 1)
09136     hrtim->Compare1EventCallback(hrtim, timer_idx);
09137 #else
09138     HAL_HRTIM_Compare1EventCallback(hrtim, timer_idx);
09139 #endif /* USE_HAL_HRTIM_REGISTER_CALLBACKS */
09140   }
09141   else if ((hrtim->Instance->sTimerxRegs[timer_idx].TIMxDIER & HRTIM_TIM_DMA_CMP2) != (uint32_t)RESET)
09142   {
09143 #if (USE_HAL_HRTIM_REGISTER_CALLBACKS == 1)
09144     hrtim->Compare2EventCallback(hrtim, timer_idx);
09145 #else
09146     HAL_HRTIM_Compare2EventCallback(hrtim, timer_idx);
09147 #endif /* USE_HAL_HRTIM_REGISTER_CALLBACKS */
09148   }
09149   else if ((hrtim->Instance->sTimerxRegs[timer_idx].TIMxDIER & HRTIM_TIM_DMA_CMP3) != (uint32_t)RESET)
09150   {
09151 #if (USE_HAL_HRTIM_REGISTER_CALLBACKS == 1)
09152     hrtim->Compare3EventCallback(hrtim, timer_idx);
09153 #else
09154     HAL_HRTIM_Compare3EventCallback(hrtim, timer_idx);
09155 #endif /* USE_HAL_HRTIM_REGISTER_CALLBACKS */
09156   }
09157   else if ((hrtim->Instance->sTimerxRegs[timer_idx].TIMxDIER & HRTIM_TIM_DMA_CMP4) != (uint32_t)RESET)
09158   {
09159 #if (USE_HAL_HRTIM_REGISTER_CALLBACKS == 1)
09160     hrtim->Compare4EventCallback(hrtim, timer_idx);
09161 #else
09162     HAL_HRTIM_Compare4EventCallback(hrtim, timer_idx);
09163 #endif /* USE_HAL_HRTIM_REGISTER_CALLBACKS */
09164   }
09165   else if ((hrtim->Instance->sTimerxRegs[timer_idx].TIMxDIER & HRTIM_TIM_DMA_UPD) != (uint32_t)RESET)
09166   {
09167 #if (USE_HAL_HRTIM_REGISTER_CALLBACKS == 1)
09168     hrtim->RegistersUpdateCallback(hrtim, timer_idx);
09169 #else
09170     HAL_HRTIM_RegistersUpdateCallback(hrtim, timer_idx);
09171 #endif /* USE_HAL_HRTIM_REGISTER_CALLBACKS */
09172   }
09173   else if ((hrtim->Instance->sTimerxRegs[timer_idx].TIMxDIER & HRTIM_TIM_DMA_CPT1) != (uint32_t)RESET)
09174   {
09175 #if (USE_HAL_HRTIM_REGISTER_CALLBACKS == 1)
09176     hrtim->Capture1EventCallback(hrtim, timer_idx);
09177 #else
09178     HAL_HRTIM_Capture1EventCallback(hrtim, timer_idx);
09179 #endif /* USE_HAL_HRTIM_REGISTER_CALLBACKS */
09180   }
09181   else if ((hrtim->Instance->sTimerxRegs[timer_idx].TIMxDIER & HRTIM_TIM_DMA_CPT2) != (uint32_t)RESET)
09182   {
09183 #if (USE_HAL_HRTIM_REGISTER_CALLBACKS == 1)
09184     hrtim->Capture2EventCallback(hrtim, timer_idx);
09185 #else
09186     HAL_HRTIM_Capture2EventCallback(hrtim, timer_idx);
09187 #endif /* USE_HAL_HRTIM_REGISTER_CALLBACKS */
09188   }
09189   else if ((hrtim->Instance->sTimerxRegs[timer_idx].TIMxDIER & HRTIM_TIM_DMA_SET1) != (uint32_t)RESET)
09190   {
09191 #if (USE_HAL_HRTIM_REGISTER_CALLBACKS == 1)
09192     hrtim->Output1SetCallback(hrtim, timer_idx);
09193 #else
09194     HAL_HRTIM_Output1SetCallback(hrtim, timer_idx);
09195 #endif /* USE_HAL_HRTIM_REGISTER_CALLBACKS */
09196   }
09197   else if ((hrtim->Instance->sTimerxRegs[timer_idx].TIMxDIER & HRTIM_TIM_DMA_RST1) != (uint32_t)RESET)
09198   {
09199 #if (USE_HAL_HRTIM_REGISTER_CALLBACKS == 1)
09200     hrtim->Output1ResetCallback(hrtim, timer_idx);
09201 #else
09202     HAL_HRTIM_Output1ResetCallback(hrtim, timer_idx);
09203 #endif /* USE_HAL_HRTIM_REGISTER_CALLBACKS */
09204   }
09205   else if ((hrtim->Instance->sTimerxRegs[timer_idx].TIMxDIER & HRTIM_TIM_DMA_SET2) != (uint32_t)RESET)
09206   {
09207 #if (USE_HAL_HRTIM_REGISTER_CALLBACKS == 1)
09208     hrtim->Output2SetCallback(hrtim, timer_idx);
09209 #else
09210     HAL_HRTIM_Output2SetCallback(hrtim, timer_idx);
09211 #endif /* USE_HAL_HRTIM_REGISTER_CALLBACKS */
09212   }
09213   else if ((hrtim->Instance->sTimerxRegs[timer_idx].TIMxDIER & HRTIM_TIM_DMA_RST2) != (uint32_t)RESET)
09214   {
09215 #if (USE_HAL_HRTIM_REGISTER_CALLBACKS == 1)
09216     hrtim->Output2ResetCallback(hrtim, timer_idx);
09217 #else
09218     HAL_HRTIM_Output2ResetCallback(hrtim, timer_idx);
09219 #endif /* USE_HAL_HRTIM_REGISTER_CALLBACKS */
09220   }
09221   else if ((hrtim->Instance->sTimerxRegs[timer_idx].TIMxDIER & HRTIM_TIM_DMA_RST) != (uint32_t)RESET)
09222   {
09223 #if (USE_HAL_HRTIM_REGISTER_CALLBACKS == 1)
09224     hrtim->CounterResetCallback(hrtim, timer_idx);
09225 #else
09226     HAL_HRTIM_CounterResetCallback(hrtim, timer_idx);
09227 #endif /* USE_HAL_HRTIM_REGISTER_CALLBACKS */
09228   }
09229   else if ((hrtim->Instance->sTimerxRegs[timer_idx].TIMxDIER & HRTIM_TIM_DMA_DLYPRT) != (uint32_t)RESET)
09230   {
09231 #if (USE_HAL_HRTIM_REGISTER_CALLBACKS == 1)
09232     hrtim->DelayedProtectionCallback(hrtim, timer_idx);
09233 #else
09234     HAL_HRTIM_DelayedProtectionCallback(hrtim, timer_idx);
09235 #endif /* USE_HAL_HRTIM_REGISTER_CALLBACKS */
09236   }
09237   else if ((hrtim->Instance->sTimerxRegs[timer_idx].TIMxDIER & HRTIM_TIM_DMA_REP) != (uint32_t)RESET)
09238   {
09239 #if (USE_HAL_HRTIM_REGISTER_CALLBACKS == 1)
09240     hrtim->RepetitionEventCallback(hrtim, timer_idx);
09241 #else
09242     HAL_HRTIM_RepetitionEventCallback(hrtim, timer_idx);
09243 #endif /* USE_HAL_HRTIM_REGISTER_CALLBACKS */
09244   }
09245   else
09246   {
09247     /* nothing to do */
09248   }
09249 }
09250 
09251 /**
09252 * @brief  DMA error callback
09253 * @param  hdma pointer to DMA handle.
09254 * @retval None
09255 */
09256 static void HRTIM_DMAError(DMA_HandleTypeDef *hdma)
09257 {
09258   HRTIM_HandleTypeDef * hrtim = (HRTIM_HandleTypeDef *)((DMA_HandleTypeDef* )hdma)->Parent;
09259 
09260 #if (USE_HAL_HRTIM_REGISTER_CALLBACKS == 1)
09261     hrtim->ErrorCallback(hrtim);
09262 #else
09263   HAL_HRTIM_ErrorCallback(hrtim);
09264 #endif /* USE_HAL_HRTIM_REGISTER_CALLBACKS */
09265 }
09266 
09267 /**
09268   * @brief  DMA callback invoked upon burst DMA transfer completion
09269   * @param  hdma pointer to DMA handle.
09270   * @retval None
09271   */
09272 static void HRTIM_BurstDMACplt(DMA_HandleTypeDef *hdma)
09273 {
09274   HRTIM_HandleTypeDef * hrtim = (HRTIM_HandleTypeDef *)((DMA_HandleTypeDef* )hdma)->Parent;
09275 
09276 #if (USE_HAL_HRTIM_REGISTER_CALLBACKS == 1)
09277     hrtim->BurstDMATransferCallback(hrtim, GetTimerIdxFromDMAHandle(hrtim, hdma));
09278 #else
09279   HAL_HRTIM_BurstDMATransferCallback(hrtim, GetTimerIdxFromDMAHandle(hrtim, hdma));
09280 #endif /* USE_HAL_HRTIM_REGISTER_CALLBACKS */
09281 }
09282 
09283 /**
09284   * @}
09285   */
09286 
09287 /**
09288   * @}
09289   */
09290 
09291 #endif /* HRTIM1 */
09292 
09293 #endif /* HAL_HRTIM_MODULE_ENABLED */
09294 
09295 /**
09296   * @}
09297   */