Subversion Repositories FuelGauge

Rev

Rev 2 | Show entire file | Ignore whitespace | Details | Blame | Last modification | View Log | RSS feed

Rev 2 Rev 6
Line 101... Line 101...
101
  [..]
101
  [..]
102
  The compilation define  USE_HAL_TIM_REGISTER_CALLBACKS when set to 1
102
  The compilation define  USE_HAL_TIM_REGISTER_CALLBACKS when set to 1
103
  allows the user to configure dynamically the driver callbacks.
103
  allows the user to configure dynamically the driver callbacks.
104
 
104
 
105
  [..]
105
  [..]
106
  Use Function @ref HAL_TIM_RegisterCallback() to register a callback.
106
  Use Function HAL_TIM_RegisterCallback() to register a callback.
107
  @ref HAL_TIM_RegisterCallback() takes as parameters the HAL peripheral handle,
107
  HAL_TIM_RegisterCallback() takes as parameters the HAL peripheral handle,
108
  the Callback ID and a pointer to the user callback function.
108
  the Callback ID and a pointer to the user callback function.
109
 
109
 
110
  [..]
110
  [..]
111
  Use function @ref HAL_TIM_UnRegisterCallback() to reset a callback to the default
111
  Use function HAL_TIM_UnRegisterCallback() to reset a callback to the default
112
  weak function.
112
  weak function.
113
  @ref HAL_TIM_UnRegisterCallback takes as parameters the HAL peripheral handle,
113
  HAL_TIM_UnRegisterCallback takes as parameters the HAL peripheral handle,
114
  and the Callback ID.
114
  and the Callback ID.
115
 
115
 
116
  [..]
116
  [..]
117
  These functions allow to register/unregister following callbacks:
117
  These functions allow to register/unregister following callbacks:
118
    (+) Base_MspInitCallback              : TIM Base Msp Init Callback.
118
    (+) Base_MspInitCallback              : TIM Base Msp Init Callback.
Line 144... Line 144...
144
    (+) BreakCallback                     : TIM Break Callback.
144
    (+) BreakCallback                     : TIM Break Callback.
145
 
145
 
146
  [..]
146
  [..]
147
By default, after the Init and when the state is HAL_TIM_STATE_RESET
147
By default, after the Init and when the state is HAL_TIM_STATE_RESET
148
all interrupt callbacks are set to the corresponding weak functions:
148
all interrupt callbacks are set to the corresponding weak functions:
149
  examples @ref HAL_TIM_TriggerCallback(), @ref HAL_TIM_ErrorCallback().
149
  examples HAL_TIM_TriggerCallback(), HAL_TIM_ErrorCallback().
150
 
150
 
151
  [..]
151
  [..]
152
  Exception done for MspInit and MspDeInit functions that are reset to the legacy weak
152
  Exception done for MspInit and MspDeInit functions that are reset to the legacy weak
153
  functionalities in the Init / DeInit only when these callbacks are null
153
  functionalities in the Init / DeInit only when these callbacks are null
154
  (not registered beforehand). If not, MspInit or MspDeInit are not null, the Init / DeInit
154
  (not registered beforehand). If not, MspInit or MspDeInit are not null, the Init / DeInit
Line 158... Line 158...
158
    Callbacks can be registered / unregistered in HAL_TIM_STATE_READY state only.
158
    Callbacks can be registered / unregistered in HAL_TIM_STATE_READY state only.
159
    Exception done MspInit / MspDeInit that can be registered / unregistered
159
    Exception done MspInit / MspDeInit that can be registered / unregistered
160
    in HAL_TIM_STATE_READY or HAL_TIM_STATE_RESET state,
160
    in HAL_TIM_STATE_READY or HAL_TIM_STATE_RESET state,
161
    thus registered(user) MspInit / DeInit callbacks can be used during the Init / DeInit.
161
    thus registered(user) MspInit / DeInit callbacks can be used during the Init / DeInit.
162
  In that case first register the MspInit/MspDeInit user callbacks
162
  In that case first register the MspInit/MspDeInit user callbacks
163
      using @ref HAL_TIM_RegisterCallback() before calling DeInit or Init function.
163
      using HAL_TIM_RegisterCallback() before calling DeInit or Init function.
164
 
164
 
165
  [..]
165
  [..]
166
      When The compilation define USE_HAL_TIM_REGISTER_CALLBACKS is set to 0 or
166
      When The compilation define USE_HAL_TIM_REGISTER_CALLBACKS is set to 0 or
167
      not defined, the callback registration feature is not available and all callbacks
167
      not defined, the callback registration feature is not available and all callbacks
168
      are set to the corresponding weak functions.
168
      are set to the corresponding weak functions.
Line 196... Line 196...
196
 
196
 
197
#ifdef HAL_TIM_MODULE_ENABLED
197
#ifdef HAL_TIM_MODULE_ENABLED
198
 
198
 
199
/* Private typedef -----------------------------------------------------------*/
199
/* Private typedef -----------------------------------------------------------*/
200
/* Private define ------------------------------------------------------------*/
200
/* Private define ------------------------------------------------------------*/
201
/* Private macro -------------------------------------------------------------*/
201
/* Private macros ------------------------------------------------------------*/
202
/* Private variables ---------------------------------------------------------*/
202
/* Private variables ---------------------------------------------------------*/
203
/* Private function prototypes -----------------------------------------------*/
203
/* Private function prototypes -----------------------------------------------*/
204
/** @addtogroup TIM_Private_Functions
204
/** @addtogroup TIM_Private_Functions
205
  * @{
205
  * @{
206
  */
206
  */
Line 216... Line 216...
216
static void TIM_TI4_SetConfig(TIM_TypeDef *TIMx, uint32_t TIM_ICPolarity, uint32_t TIM_ICSelection,
216
static void TIM_TI4_SetConfig(TIM_TypeDef *TIMx, uint32_t TIM_ICPolarity, uint32_t TIM_ICSelection,
217
                              uint32_t TIM_ICFilter);
217
                              uint32_t TIM_ICFilter);
218
static void TIM_ITRx_SetConfig(TIM_TypeDef *TIMx, uint32_t InputTriggerSource);
218
static void TIM_ITRx_SetConfig(TIM_TypeDef *TIMx, uint32_t InputTriggerSource);
219
static void TIM_DMAPeriodElapsedCplt(DMA_HandleTypeDef *hdma);
219
static void TIM_DMAPeriodElapsedCplt(DMA_HandleTypeDef *hdma);
220
static void TIM_DMAPeriodElapsedHalfCplt(DMA_HandleTypeDef *hdma);
220
static void TIM_DMAPeriodElapsedHalfCplt(DMA_HandleTypeDef *hdma);
-
 
221
static void TIM_DMADelayPulseCplt(DMA_HandleTypeDef *hdma);
221
static void TIM_DMATriggerCplt(DMA_HandleTypeDef *hdma);
222
static void TIM_DMATriggerCplt(DMA_HandleTypeDef *hdma);
222
static void TIM_DMATriggerHalfCplt(DMA_HandleTypeDef *hdma);
223
static void TIM_DMATriggerHalfCplt(DMA_HandleTypeDef *hdma);
223
static HAL_StatusTypeDef TIM_SlaveTimer_SetConfig(TIM_HandleTypeDef *htim,
224
static HAL_StatusTypeDef TIM_SlaveTimer_SetConfig(TIM_HandleTypeDef *htim,
224
                                                  TIM_SlaveConfigTypeDef *sSlaveConfig);
225
                                                  TIM_SlaveConfigTypeDef *sSlaveConfig);
225
/**
226
/**
Line 301... Line 302...
301
  htim->State = HAL_TIM_STATE_BUSY;
302
  htim->State = HAL_TIM_STATE_BUSY;
302
 
303
 
303
  /* Set the Time Base configuration */
304
  /* Set the Time Base configuration */
304
  TIM_Base_SetConfig(htim->Instance, &htim->Init);
305
  TIM_Base_SetConfig(htim->Instance, &htim->Init);
305
 
306
 
-
 
307
  /* Initialize the DMA burst operation state */
-
 
308
  htim->DMABurstState = HAL_DMA_BURST_STATE_READY;
-
 
309
 
-
 
310
  /* Initialize the TIM channels state */
-
 
311
  TIM_CHANNEL_STATE_SET_ALL(htim, HAL_TIM_CHANNEL_STATE_READY);
-
 
312
  TIM_CHANNEL_N_STATE_SET_ALL(htim, HAL_TIM_CHANNEL_STATE_READY);
-
 
313
 
306
  /* Initialize the TIM state*/
314
  /* Initialize the TIM state*/
307
  htim->State = HAL_TIM_STATE_READY;
315
  htim->State = HAL_TIM_STATE_READY;
308
 
316
 
309
  return HAL_OK;
317
  return HAL_OK;
310
}
318
}
Line 334... Line 342...
334
#else
342
#else
335
  /* DeInit the low level hardware: GPIO, CLOCK, NVIC */
343
  /* DeInit the low level hardware: GPIO, CLOCK, NVIC */
336
  HAL_TIM_Base_MspDeInit(htim);
344
  HAL_TIM_Base_MspDeInit(htim);
337
#endif /* USE_HAL_TIM_REGISTER_CALLBACKS */
345
#endif /* USE_HAL_TIM_REGISTER_CALLBACKS */
338
 
346
 
-
 
347
  /* Change the DMA burst operation state */
-
 
348
  htim->DMABurstState = HAL_DMA_BURST_STATE_RESET;
-
 
349
 
-
 
350
  /* Change the TIM channels state */
-
 
351
  TIM_CHANNEL_STATE_SET_ALL(htim, HAL_TIM_CHANNEL_STATE_RESET);
-
 
352
  TIM_CHANNEL_N_STATE_SET_ALL(htim, HAL_TIM_CHANNEL_STATE_RESET);
-
 
353
 
339
  /* Change TIM state */
354
  /* Change TIM state */
340
  htim->State = HAL_TIM_STATE_RESET;
355
  htim->State = HAL_TIM_STATE_RESET;
341
 
356
 
342
  /* Release Lock */
357
  /* Release Lock */
343
  __HAL_UNLOCK(htim);
358
  __HAL_UNLOCK(htim);
Line 386... Line 401...
386
  uint32_t tmpsmcr;
401
  uint32_t tmpsmcr;
387
 
402
 
388
  /* Check the parameters */
403
  /* Check the parameters */
389
  assert_param(IS_TIM_INSTANCE(htim->Instance));
404
  assert_param(IS_TIM_INSTANCE(htim->Instance));
390
 
405
 
-
 
406
  /* Check the TIM state */
-
 
407
  if (htim->State != HAL_TIM_STATE_READY)
-
 
408
  {
-
 
409
    return HAL_ERROR;
-
 
410
  }
-
 
411
 
391
  /* Set the TIM state */
412
  /* Set the TIM state */
392
  htim->State = HAL_TIM_STATE_BUSY;
413
  htim->State = HAL_TIM_STATE_BUSY;
393
 
414
 
394
  /* Enable the Peripheral, except in trigger mode where enable is automatically done with trigger */
415
  /* Enable the Peripheral, except in trigger mode where enable is automatically done with trigger */
-
 
416
  if (IS_TIM_SLAVE_INSTANCE(htim->Instance))
-
 
417
  {
395
  tmpsmcr = htim->Instance->SMCR & TIM_SMCR_SMS;
418
    tmpsmcr = htim->Instance->SMCR & TIM_SMCR_SMS;
396
  if (!IS_TIM_SLAVEMODE_TRIGGER_ENABLED(tmpsmcr))
419
    if (!IS_TIM_SLAVEMODE_TRIGGER_ENABLED(tmpsmcr))
-
 
420
    {
-
 
421
      __HAL_TIM_ENABLE(htim);
-
 
422
    }
-
 
423
  }
-
 
424
  else
397
  {
425
  {
398
    __HAL_TIM_ENABLE(htim);
426
    __HAL_TIM_ENABLE(htim);
399
  }
427
  }
400
 
428
 
401
  /* Change the TIM state*/
-
 
402
  htim->State = HAL_TIM_STATE_READY;
-
 
403
 
-
 
404
  /* Return function status */
429
  /* Return function status */
405
  return HAL_OK;
430
  return HAL_OK;
406
}
431
}
407
 
432
 
408
/**
433
/**
Line 413... Line 438...
413
HAL_StatusTypeDef HAL_TIM_Base_Stop(TIM_HandleTypeDef *htim)
438
HAL_StatusTypeDef HAL_TIM_Base_Stop(TIM_HandleTypeDef *htim)
414
{
439
{
415
  /* Check the parameters */
440
  /* Check the parameters */
416
  assert_param(IS_TIM_INSTANCE(htim->Instance));
441
  assert_param(IS_TIM_INSTANCE(htim->Instance));
417
 
442
 
418
  /* Set the TIM state */
-
 
419
  htim->State = HAL_TIM_STATE_BUSY;
-
 
420
 
-
 
421
  /* Disable the Peripheral */
443
  /* Disable the Peripheral */
422
  __HAL_TIM_DISABLE(htim);
444
  __HAL_TIM_DISABLE(htim);
423
 
445
 
424
  /* Change the TIM state*/
446
  /* Set the TIM state */
425
  htim->State = HAL_TIM_STATE_READY;
447
  htim->State = HAL_TIM_STATE_READY;
426
 
448
 
427
  /* Return function status */
449
  /* Return function status */
428
  return HAL_OK;
450
  return HAL_OK;
429
}
451
}
Line 438... Line 460...
438
  uint32_t tmpsmcr;
460
  uint32_t tmpsmcr;
439
 
461
 
440
  /* Check the parameters */
462
  /* Check the parameters */
441
  assert_param(IS_TIM_INSTANCE(htim->Instance));
463
  assert_param(IS_TIM_INSTANCE(htim->Instance));
442
 
464
 
-
 
465
  /* Check the TIM state */
-
 
466
  if (htim->State != HAL_TIM_STATE_READY)
-
 
467
  {
-
 
468
    return HAL_ERROR;
-
 
469
  }
-
 
470
 
-
 
471
  /* Set the TIM state */
-
 
472
  htim->State = HAL_TIM_STATE_BUSY;
-
 
473
 
443
  /* Enable the TIM Update interrupt */
474
  /* Enable the TIM Update interrupt */
444
  __HAL_TIM_ENABLE_IT(htim, TIM_IT_UPDATE);
475
  __HAL_TIM_ENABLE_IT(htim, TIM_IT_UPDATE);
445
 
476
 
446
  /* Enable the Peripheral, except in trigger mode where enable is automatically done with trigger */
477
  /* Enable the Peripheral, except in trigger mode where enable is automatically done with trigger */
-
 
478
  if (IS_TIM_SLAVE_INSTANCE(htim->Instance))
-
 
479
  {
447
  tmpsmcr = htim->Instance->SMCR & TIM_SMCR_SMS;
480
    tmpsmcr = htim->Instance->SMCR & TIM_SMCR_SMS;
448
  if (!IS_TIM_SLAVEMODE_TRIGGER_ENABLED(tmpsmcr))
481
    if (!IS_TIM_SLAVEMODE_TRIGGER_ENABLED(tmpsmcr))
-
 
482
    {
-
 
483
      __HAL_TIM_ENABLE(htim);
-
 
484
    }
-
 
485
  }
-
 
486
  else
449
  {
487
  {
450
    __HAL_TIM_ENABLE(htim);
488
    __HAL_TIM_ENABLE(htim);
451
  }
489
  }
452
 
490
 
453
  /* Return function status */
491
  /* Return function status */
Line 461... Line 499...
461
  */
499
  */
462
HAL_StatusTypeDef HAL_TIM_Base_Stop_IT(TIM_HandleTypeDef *htim)
500
HAL_StatusTypeDef HAL_TIM_Base_Stop_IT(TIM_HandleTypeDef *htim)
463
{
501
{
464
  /* Check the parameters */
502
  /* Check the parameters */
465
  assert_param(IS_TIM_INSTANCE(htim->Instance));
503
  assert_param(IS_TIM_INSTANCE(htim->Instance));
-
 
504
 
466
  /* Disable the TIM Update interrupt */
505
  /* Disable the TIM Update interrupt */
467
  __HAL_TIM_DISABLE_IT(htim, TIM_IT_UPDATE);
506
  __HAL_TIM_DISABLE_IT(htim, TIM_IT_UPDATE);
468
 
507
 
469
  /* Disable the Peripheral */
508
  /* Disable the Peripheral */
470
  __HAL_TIM_DISABLE(htim);
509
  __HAL_TIM_DISABLE(htim);
471
 
510
 
-
 
511
  /* Set the TIM state */
-
 
512
  htim->State = HAL_TIM_STATE_READY;
-
 
513
 
472
  /* Return function status */
514
  /* Return function status */
473
  return HAL_OK;
515
  return HAL_OK;
474
}
516
}
475
 
517
 
476
/**
518
/**
Line 485... Line 527...
485
  uint32_t tmpsmcr;
527
  uint32_t tmpsmcr;
486
 
528
 
487
  /* Check the parameters */
529
  /* Check the parameters */
488
  assert_param(IS_TIM_DMA_INSTANCE(htim->Instance));
530
  assert_param(IS_TIM_DMA_INSTANCE(htim->Instance));
489
 
531
 
-
 
532
  /* Set the TIM state */
490
  if (htim->State == HAL_TIM_STATE_BUSY)
533
  if (htim->State == HAL_TIM_STATE_BUSY)
491
  {
534
  {
492
    return HAL_BUSY;
535
    return HAL_BUSY;
493
  }
536
  }
494
  else if (htim->State == HAL_TIM_STATE_READY)
537
  else if (htim->State == HAL_TIM_STATE_READY)
Line 502... Line 545...
502
      htim->State = HAL_TIM_STATE_BUSY;
545
      htim->State = HAL_TIM_STATE_BUSY;
503
    }
546
    }
504
  }
547
  }
505
  else
548
  else
506
  {
549
  {
507
    /* nothing to do */
550
    return HAL_ERROR;
508
  }
551
  }
509
 
552
 
510
  /* Set the DMA Period elapsed callbacks */
553
  /* Set the DMA Period elapsed callbacks */
511
  htim->hdma[TIM_DMA_ID_UPDATE]->XferCpltCallback = TIM_DMAPeriodElapsedCplt;
554
  htim->hdma[TIM_DMA_ID_UPDATE]->XferCpltCallback = TIM_DMAPeriodElapsedCplt;
512
  htim->hdma[TIM_DMA_ID_UPDATE]->XferHalfCpltCallback = TIM_DMAPeriodElapsedHalfCplt;
555
  htim->hdma[TIM_DMA_ID_UPDATE]->XferHalfCpltCallback = TIM_DMAPeriodElapsedHalfCplt;
513
 
556
 
514
  /* Set the DMA error callback */
557
  /* Set the DMA error callback */
515
  htim->hdma[TIM_DMA_ID_UPDATE]->XferErrorCallback = TIM_DMAError ;
558
  htim->hdma[TIM_DMA_ID_UPDATE]->XferErrorCallback = TIM_DMAError ;
516
 
559
 
517
  /* Enable the DMA channel */
560
  /* Enable the DMA channel */
518
  if (HAL_DMA_Start_IT(htim->hdma[TIM_DMA_ID_UPDATE], (uint32_t)pData, (uint32_t)&htim->Instance->ARR, Length) != HAL_OK)
561
  if (HAL_DMA_Start_IT(htim->hdma[TIM_DMA_ID_UPDATE], (uint32_t)pData, (uint32_t)&htim->Instance->ARR,
-
 
562
                       Length) != HAL_OK)
519
  {
563
  {
-
 
564
    /* Return error status */
520
    return HAL_ERROR;
565
    return HAL_ERROR;
521
  }
566
  }
522
 
567
 
523
  /* Enable the TIM Update DMA request */
568
  /* Enable the TIM Update DMA request */
524
  __HAL_TIM_ENABLE_DMA(htim, TIM_DMA_UPDATE);
569
  __HAL_TIM_ENABLE_DMA(htim, TIM_DMA_UPDATE);
525
 
570
 
526
  /* Enable the Peripheral, except in trigger mode where enable is automatically done with trigger */
571
  /* Enable the Peripheral, except in trigger mode where enable is automatically done with trigger */
-
 
572
  if (IS_TIM_SLAVE_INSTANCE(htim->Instance))
-
 
573
  {
527
  tmpsmcr = htim->Instance->SMCR & TIM_SMCR_SMS;
574
    tmpsmcr = htim->Instance->SMCR & TIM_SMCR_SMS;
528
  if (!IS_TIM_SLAVEMODE_TRIGGER_ENABLED(tmpsmcr))
575
    if (!IS_TIM_SLAVEMODE_TRIGGER_ENABLED(tmpsmcr))
-
 
576
    {
-
 
577
      __HAL_TIM_ENABLE(htim);
-
 
578
    }
-
 
579
  }
-
 
580
  else
529
  {
581
  {
530
    __HAL_TIM_ENABLE(htim);
582
    __HAL_TIM_ENABLE(htim);
531
  }
583
  }
532
 
584
 
533
  /* Return function status */
585
  /* Return function status */
Line 550... Line 602...
550
  (void)HAL_DMA_Abort_IT(htim->hdma[TIM_DMA_ID_UPDATE]);
602
  (void)HAL_DMA_Abort_IT(htim->hdma[TIM_DMA_ID_UPDATE]);
551
 
603
 
552
  /* Disable the Peripheral */
604
  /* Disable the Peripheral */
553
  __HAL_TIM_DISABLE(htim);
605
  __HAL_TIM_DISABLE(htim);
554
 
606
 
555
  /* Change the htim state */
607
  /* Set the TIM state */
556
  htim->State = HAL_TIM_STATE_READY;
608
  htim->State = HAL_TIM_STATE_READY;
557
 
609
 
558
  /* Return function status */
610
  /* Return function status */
559
  return HAL_OK;
611
  return HAL_OK;
560
}
612
}
Line 633... Line 685...
633
  htim->State = HAL_TIM_STATE_BUSY;
685
  htim->State = HAL_TIM_STATE_BUSY;
634
 
686
 
635
  /* Init the base time for the Output Compare */
687
  /* Init the base time for the Output Compare */
636
  TIM_Base_SetConfig(htim->Instance,  &htim->Init);
688
  TIM_Base_SetConfig(htim->Instance,  &htim->Init);
637
 
689
 
-
 
690
  /* Initialize the DMA burst operation state */
-
 
691
  htim->DMABurstState = HAL_DMA_BURST_STATE_READY;
-
 
692
 
-
 
693
  /* Initialize the TIM channels state */
-
 
694
  TIM_CHANNEL_STATE_SET_ALL(htim, HAL_TIM_CHANNEL_STATE_READY);
-
 
695
  TIM_CHANNEL_N_STATE_SET_ALL(htim, HAL_TIM_CHANNEL_STATE_READY);
-
 
696
 
638
  /* Initialize the TIM state*/
697
  /* Initialize the TIM state*/
639
  htim->State = HAL_TIM_STATE_READY;
698
  htim->State = HAL_TIM_STATE_READY;
640
 
699
 
641
  return HAL_OK;
700
  return HAL_OK;
642
}
701
}
Line 666... Line 725...
666
#else
725
#else
667
  /* DeInit the low level hardware: GPIO, CLOCK, NVIC and DMA */
726
  /* DeInit the low level hardware: GPIO, CLOCK, NVIC and DMA */
668
  HAL_TIM_OC_MspDeInit(htim);
727
  HAL_TIM_OC_MspDeInit(htim);
669
#endif /* USE_HAL_TIM_REGISTER_CALLBACKS */
728
#endif /* USE_HAL_TIM_REGISTER_CALLBACKS */
670
 
729
 
-
 
730
  /* Change the DMA burst operation state */
-
 
731
  htim->DMABurstState = HAL_DMA_BURST_STATE_RESET;
-
 
732
 
-
 
733
  /* Change the TIM channels state */
-
 
734
  TIM_CHANNEL_STATE_SET_ALL(htim, HAL_TIM_CHANNEL_STATE_RESET);
-
 
735
  TIM_CHANNEL_N_STATE_SET_ALL(htim, HAL_TIM_CHANNEL_STATE_RESET);
-
 
736
 
671
  /* Change TIM state */
737
  /* Change TIM state */
672
  htim->State = HAL_TIM_STATE_RESET;
738
  htim->State = HAL_TIM_STATE_RESET;
673
 
739
 
674
  /* Release Lock */
740
  /* Release Lock */
675
  __HAL_UNLOCK(htim);
741
  __HAL_UNLOCK(htim);
Line 723... Line 789...
723
  uint32_t tmpsmcr;
789
  uint32_t tmpsmcr;
724
 
790
 
725
  /* Check the parameters */
791
  /* Check the parameters */
726
  assert_param(IS_TIM_CCX_INSTANCE(htim->Instance, Channel));
792
  assert_param(IS_TIM_CCX_INSTANCE(htim->Instance, Channel));
727
 
793
 
-
 
794
  /* Check the TIM channel state */
-
 
795
  if (TIM_CHANNEL_STATE_GET(htim, Channel) != HAL_TIM_CHANNEL_STATE_READY)
-
 
796
  {
-
 
797
    return HAL_ERROR;
-
 
798
  }
-
 
799
 
-
 
800
  /* Set the TIM channel state */
-
 
801
  TIM_CHANNEL_STATE_SET(htim, Channel, HAL_TIM_CHANNEL_STATE_BUSY);
-
 
802
 
728
  /* Enable the Output compare channel */
803
  /* Enable the Output compare channel */
729
  TIM_CCxChannelCmd(htim->Instance, Channel, TIM_CCx_ENABLE);
804
  TIM_CCxChannelCmd(htim->Instance, Channel, TIM_CCx_ENABLE);
730
 
805
 
731
  if (IS_TIM_BREAK_INSTANCE(htim->Instance) != RESET)
806
  if (IS_TIM_BREAK_INSTANCE(htim->Instance) != RESET)
732
  {
807
  {
733
    /* Enable the main output */
808
    /* Enable the main output */
734
    __HAL_TIM_MOE_ENABLE(htim);
809
    __HAL_TIM_MOE_ENABLE(htim);
735
  }
810
  }
736
 
811
 
737
  /* Enable the Peripheral, except in trigger mode where enable is automatically done with trigger */
812
  /* Enable the Peripheral, except in trigger mode where enable is automatically done with trigger */
-
 
813
  if (IS_TIM_SLAVE_INSTANCE(htim->Instance))
-
 
814
  {
738
  tmpsmcr = htim->Instance->SMCR & TIM_SMCR_SMS;
815
    tmpsmcr = htim->Instance->SMCR & TIM_SMCR_SMS;
739
  if (!IS_TIM_SLAVEMODE_TRIGGER_ENABLED(tmpsmcr))
816
    if (!IS_TIM_SLAVEMODE_TRIGGER_ENABLED(tmpsmcr))
-
 
817
    {
-
 
818
      __HAL_TIM_ENABLE(htim);
-
 
819
    }
-
 
820
  }
-
 
821
  else
740
  {
822
  {
741
    __HAL_TIM_ENABLE(htim);
823
    __HAL_TIM_ENABLE(htim);
742
  }
824
  }
743
 
825
 
744
  /* Return function status */
826
  /* Return function status */
Line 771... Line 853...
771
  }
853
  }
772
 
854
 
773
  /* Disable the Peripheral */
855
  /* Disable the Peripheral */
774
  __HAL_TIM_DISABLE(htim);
856
  __HAL_TIM_DISABLE(htim);
775
 
857
 
-
 
858
  /* Set the TIM channel state */
-
 
859
  TIM_CHANNEL_STATE_SET(htim, Channel, HAL_TIM_CHANNEL_STATE_READY);
-
 
860
 
776
  /* Return function status */
861
  /* Return function status */
777
  return HAL_OK;
862
  return HAL_OK;
778
}
863
}
779
 
864
 
780
/**
865
/**
Line 788... Line 873...
788
  *            @arg TIM_CHANNEL_4: TIM Channel 4 selected
873
  *            @arg TIM_CHANNEL_4: TIM Channel 4 selected
789
  * @retval HAL status
874
  * @retval HAL status
790
  */
875
  */
791
HAL_StatusTypeDef HAL_TIM_OC_Start_IT(TIM_HandleTypeDef *htim, uint32_t Channel)
876
HAL_StatusTypeDef HAL_TIM_OC_Start_IT(TIM_HandleTypeDef *htim, uint32_t Channel)
792
{
877
{
-
 
878
  HAL_StatusTypeDef status = HAL_OK;
793
  uint32_t tmpsmcr;
879
  uint32_t tmpsmcr;
794
 
880
 
795
  /* Check the parameters */
881
  /* Check the parameters */
796
  assert_param(IS_TIM_CCX_INSTANCE(htim->Instance, Channel));
882
  assert_param(IS_TIM_CCX_INSTANCE(htim->Instance, Channel));
797
 
883
 
-
 
884
  /* Check the TIM channel state */
-
 
885
  if (TIM_CHANNEL_STATE_GET(htim, Channel) != HAL_TIM_CHANNEL_STATE_READY)
-
 
886
  {
-
 
887
    return HAL_ERROR;
-
 
888
  }
-
 
889
 
-
 
890
  /* Set the TIM channel state */
-
 
891
  TIM_CHANNEL_STATE_SET(htim, Channel, HAL_TIM_CHANNEL_STATE_BUSY);
-
 
892
 
798
  switch (Channel)
893
  switch (Channel)
799
  {
894
  {
800
    case TIM_CHANNEL_1:
895
    case TIM_CHANNEL_1:
801
    {
896
    {
802
      /* Enable the TIM Capture/Compare 1 interrupt */
897
      /* Enable the TIM Capture/Compare 1 interrupt */
Line 824... Line 919...
824
      __HAL_TIM_ENABLE_IT(htim, TIM_IT_CC4);
919
      __HAL_TIM_ENABLE_IT(htim, TIM_IT_CC4);
825
      break;
920
      break;
826
    }
921
    }
827
 
922
 
828
    default:
923
    default:
-
 
924
      status = HAL_ERROR;
829
      break;
925
      break;
830
  }
926
  }
831
 
927
 
832
  /* Enable the Output compare channel */
928
  if (status == HAL_OK)
833
  TIM_CCxChannelCmd(htim->Instance, Channel, TIM_CCx_ENABLE);
-
 
834
 
-
 
835
  if (IS_TIM_BREAK_INSTANCE(htim->Instance) != RESET)
-
 
836
  {
929
  {
837
    /* Enable the main output */
930
    /* Enable the Output compare channel */
838
    __HAL_TIM_MOE_ENABLE(htim);
931
    TIM_CCxChannelCmd(htim->Instance, Channel, TIM_CCx_ENABLE);
839
  }
-
 
840
 
932
 
-
 
933
    if (IS_TIM_BREAK_INSTANCE(htim->Instance) != RESET)
-
 
934
    {
-
 
935
      /* Enable the main output */
-
 
936
      __HAL_TIM_MOE_ENABLE(htim);
-
 
937
    }
-
 
938
 
841
  /* Enable the Peripheral, except in trigger mode where enable is automatically done with trigger */
939
    /* Enable the Peripheral, except in trigger mode where enable is automatically done with trigger */
-
 
940
    if (IS_TIM_SLAVE_INSTANCE(htim->Instance))
-
 
941
    {
842
  tmpsmcr = htim->Instance->SMCR & TIM_SMCR_SMS;
942
      tmpsmcr = htim->Instance->SMCR & TIM_SMCR_SMS;
843
  if (!IS_TIM_SLAVEMODE_TRIGGER_ENABLED(tmpsmcr))
943
      if (!IS_TIM_SLAVEMODE_TRIGGER_ENABLED(tmpsmcr))
-
 
944
      {
-
 
945
        __HAL_TIM_ENABLE(htim);
-
 
946
      }
-
 
947
    }
-
 
948
    else
844
  {
949
    {
845
    __HAL_TIM_ENABLE(htim);
950
      __HAL_TIM_ENABLE(htim);
-
 
951
    }
846
  }
952
  }
847
 
953
 
848
  /* Return function status */
954
  /* Return function status */
849
  return HAL_OK;
955
  return status;
850
}
956
}
851
 
957
 
852
/**
958
/**
853
  * @brief  Stops the TIM Output Compare signal generation in interrupt mode.
959
  * @brief  Stops the TIM Output Compare signal generation in interrupt mode.
854
  * @param  htim TIM Output Compare handle
960
  * @param  htim TIM Output Compare handle
Line 860... Line 966...
860
  *            @arg TIM_CHANNEL_4: TIM Channel 4 selected
966
  *            @arg TIM_CHANNEL_4: TIM Channel 4 selected
861
  * @retval HAL status
967
  * @retval HAL status
862
  */
968
  */
863
HAL_StatusTypeDef HAL_TIM_OC_Stop_IT(TIM_HandleTypeDef *htim, uint32_t Channel)
969
HAL_StatusTypeDef HAL_TIM_OC_Stop_IT(TIM_HandleTypeDef *htim, uint32_t Channel)
864
{
970
{
-
 
971
  HAL_StatusTypeDef status = HAL_OK;
-
 
972
 
865
  /* Check the parameters */
973
  /* Check the parameters */
866
  assert_param(IS_TIM_CCX_INSTANCE(htim->Instance, Channel));
974
  assert_param(IS_TIM_CCX_INSTANCE(htim->Instance, Channel));
867
 
975
 
868
  switch (Channel)
976
  switch (Channel)
869
  {
977
  {
Line 894... Line 1002...
894
      __HAL_TIM_DISABLE_IT(htim, TIM_IT_CC4);
1002
      __HAL_TIM_DISABLE_IT(htim, TIM_IT_CC4);
895
      break;
1003
      break;
896
    }
1004
    }
897
 
1005
 
898
    default:
1006
    default:
-
 
1007
      status = HAL_ERROR;
899
      break;
1008
      break;
900
  }
1009
  }
901
 
1010
 
902
  /* Disable the Output compare channel */
1011
  if (status == HAL_OK)
903
  TIM_CCxChannelCmd(htim->Instance, Channel, TIM_CCx_DISABLE);
-
 
904
 
-
 
905
  if (IS_TIM_BREAK_INSTANCE(htim->Instance) != RESET)
-
 
906
  {
1012
  {
907
    /* Disable the Main Output */
1013
    /* Disable the Output compare channel */
908
    __HAL_TIM_MOE_DISABLE(htim);
1014
    TIM_CCxChannelCmd(htim->Instance, Channel, TIM_CCx_DISABLE);
909
  }
-
 
910
 
1015
 
-
 
1016
    if (IS_TIM_BREAK_INSTANCE(htim->Instance) != RESET)
-
 
1017
    {
-
 
1018
      /* Disable the Main Output */
-
 
1019
      __HAL_TIM_MOE_DISABLE(htim);
-
 
1020
    }
-
 
1021
 
911
  /* Disable the Peripheral */
1022
    /* Disable the Peripheral */
912
  __HAL_TIM_DISABLE(htim);
1023
    __HAL_TIM_DISABLE(htim);
-
 
1024
 
-
 
1025
    /* Set the TIM channel state */
-
 
1026
    TIM_CHANNEL_STATE_SET(htim, Channel, HAL_TIM_CHANNEL_STATE_READY);
-
 
1027
  }
913
 
1028
 
914
  /* Return function status */
1029
  /* Return function status */
915
  return HAL_OK;
1030
  return status;
916
}
1031
}
917
 
1032
 
918
/**
1033
/**
919
  * @brief  Starts the TIM Output Compare signal generation in DMA mode.
1034
  * @brief  Starts the TIM Output Compare signal generation in DMA mode.
920
  * @param  htim TIM Output Compare handle
1035
  * @param  htim TIM Output Compare handle
Line 928... Line 1043...
928
  * @param  Length The length of data to be transferred from memory to TIM peripheral
1043
  * @param  Length The length of data to be transferred from memory to TIM peripheral
929
  * @retval HAL status
1044
  * @retval HAL status
930
  */
1045
  */
931
HAL_StatusTypeDef HAL_TIM_OC_Start_DMA(TIM_HandleTypeDef *htim, uint32_t Channel, uint32_t *pData, uint16_t Length)
1046
HAL_StatusTypeDef HAL_TIM_OC_Start_DMA(TIM_HandleTypeDef *htim, uint32_t Channel, uint32_t *pData, uint16_t Length)
932
{
1047
{
-
 
1048
  HAL_StatusTypeDef status = HAL_OK;
933
  uint32_t tmpsmcr;
1049
  uint32_t tmpsmcr;
934
 
1050
 
935
  /* Check the parameters */
1051
  /* Check the parameters */
936
  assert_param(IS_TIM_CCX_INSTANCE(htim->Instance, Channel));
1052
  assert_param(IS_TIM_CCX_INSTANCE(htim->Instance, Channel));
937
 
1053
 
-
 
1054
  /* Set the TIM channel state */
938
  if (htim->State == HAL_TIM_STATE_BUSY)
1055
  if (TIM_CHANNEL_STATE_GET(htim, Channel) == HAL_TIM_CHANNEL_STATE_BUSY)
939
  {
1056
  {
940
    return HAL_BUSY;
1057
    return HAL_BUSY;
941
  }
1058
  }
942
  else if (htim->State == HAL_TIM_STATE_READY)
1059
  else if (TIM_CHANNEL_STATE_GET(htim, Channel) == HAL_TIM_CHANNEL_STATE_READY)
943
  {
1060
  {
944
    if ((pData == NULL) && (Length > 0U))
1061
    if ((pData == NULL) && (Length > 0U))
945
    {
1062
    {
946
      return HAL_ERROR;
1063
      return HAL_ERROR;
947
    }
1064
    }
948
    else
1065
    else
949
    {
1066
    {
950
      htim->State = HAL_TIM_STATE_BUSY;
1067
      TIM_CHANNEL_STATE_SET(htim, Channel, HAL_TIM_CHANNEL_STATE_BUSY);
951
    }
1068
    }
952
  }
1069
  }
953
  else
1070
  else
954
  {
1071
  {
955
    /* nothing to do */
1072
    return HAL_ERROR;
956
  }
1073
  }
957
 
1074
 
958
  switch (Channel)
1075
  switch (Channel)
959
  {
1076
  {
960
    case TIM_CHANNEL_1:
1077
    case TIM_CHANNEL_1:
Line 965... Line 1082...
965
 
1082
 
966
      /* Set the DMA error callback */
1083
      /* Set the DMA error callback */
967
      htim->hdma[TIM_DMA_ID_CC1]->XferErrorCallback = TIM_DMAError ;
1084
      htim->hdma[TIM_DMA_ID_CC1]->XferErrorCallback = TIM_DMAError ;
968
 
1085
 
969
      /* Enable the DMA channel */
1086
      /* Enable the DMA channel */
970
      if (HAL_DMA_Start_IT(htim->hdma[TIM_DMA_ID_CC1], (uint32_t)pData, (uint32_t)&htim->Instance->CCR1, Length) != HAL_OK)
1087
      if (HAL_DMA_Start_IT(htim->hdma[TIM_DMA_ID_CC1], (uint32_t)pData, (uint32_t)&htim->Instance->CCR1,
-
 
1088
                           Length) != HAL_OK)
971
      {
1089
      {
-
 
1090
        /* Return error status */
972
        return HAL_ERROR;
1091
        return HAL_ERROR;
973
      }
1092
      }
974
 
1093
 
975
      /* Enable the TIM Capture/Compare 1 DMA request */
1094
      /* Enable the TIM Capture/Compare 1 DMA request */
976
      __HAL_TIM_ENABLE_DMA(htim, TIM_DMA_CC1);
1095
      __HAL_TIM_ENABLE_DMA(htim, TIM_DMA_CC1);
Line 985... Line 1104...
985
 
1104
 
986
      /* Set the DMA error callback */
1105
      /* Set the DMA error callback */
987
      htim->hdma[TIM_DMA_ID_CC2]->XferErrorCallback = TIM_DMAError ;
1106
      htim->hdma[TIM_DMA_ID_CC2]->XferErrorCallback = TIM_DMAError ;
988
 
1107
 
989
      /* Enable the DMA channel */
1108
      /* Enable the DMA channel */
990
      if (HAL_DMA_Start_IT(htim->hdma[TIM_DMA_ID_CC2], (uint32_t)pData, (uint32_t)&htim->Instance->CCR2, Length) != HAL_OK)
1109
      if (HAL_DMA_Start_IT(htim->hdma[TIM_DMA_ID_CC2], (uint32_t)pData, (uint32_t)&htim->Instance->CCR2,
-
 
1110
                           Length) != HAL_OK)
991
      {
1111
      {
-
 
1112
        /* Return error status */
992
        return HAL_ERROR;
1113
        return HAL_ERROR;
993
      }
1114
      }
994
 
1115
 
995
      /* Enable the TIM Capture/Compare 2 DMA request */
1116
      /* Enable the TIM Capture/Compare 2 DMA request */
996
      __HAL_TIM_ENABLE_DMA(htim, TIM_DMA_CC2);
1117
      __HAL_TIM_ENABLE_DMA(htim, TIM_DMA_CC2);
Line 1005... Line 1126...
1005
 
1126
 
1006
      /* Set the DMA error callback */
1127
      /* Set the DMA error callback */
1007
      htim->hdma[TIM_DMA_ID_CC3]->XferErrorCallback = TIM_DMAError ;
1128
      htim->hdma[TIM_DMA_ID_CC3]->XferErrorCallback = TIM_DMAError ;
1008
 
1129
 
1009
      /* Enable the DMA channel */
1130
      /* Enable the DMA channel */
1010
      if (HAL_DMA_Start_IT(htim->hdma[TIM_DMA_ID_CC3], (uint32_t)pData, (uint32_t)&htim->Instance->CCR3, Length) != HAL_OK)
1131
      if (HAL_DMA_Start_IT(htim->hdma[TIM_DMA_ID_CC3], (uint32_t)pData, (uint32_t)&htim->Instance->CCR3,
-
 
1132
                           Length) != HAL_OK)
1011
      {
1133
      {
-
 
1134
        /* Return error status */
1012
        return HAL_ERROR;
1135
        return HAL_ERROR;
1013
      }
1136
      }
1014
      /* Enable the TIM Capture/Compare 3 DMA request */
1137
      /* Enable the TIM Capture/Compare 3 DMA request */
1015
      __HAL_TIM_ENABLE_DMA(htim, TIM_DMA_CC3);
1138
      __HAL_TIM_ENABLE_DMA(htim, TIM_DMA_CC3);
1016
      break;
1139
      break;
Line 1024... Line 1147...
1024
 
1147
 
1025
      /* Set the DMA error callback */
1148
      /* Set the DMA error callback */
1026
      htim->hdma[TIM_DMA_ID_CC4]->XferErrorCallback = TIM_DMAError ;
1149
      htim->hdma[TIM_DMA_ID_CC4]->XferErrorCallback = TIM_DMAError ;
1027
 
1150
 
1028
      /* Enable the DMA channel */
1151
      /* Enable the DMA channel */
1029
      if (HAL_DMA_Start_IT(htim->hdma[TIM_DMA_ID_CC4], (uint32_t)pData, (uint32_t)&htim->Instance->CCR4, Length) != HAL_OK)
1152
      if (HAL_DMA_Start_IT(htim->hdma[TIM_DMA_ID_CC4], (uint32_t)pData, (uint32_t)&htim->Instance->CCR4,
-
 
1153
                           Length) != HAL_OK)
1030
      {
1154
      {
-
 
1155
        /* Return error status */
1031
        return HAL_ERROR;
1156
        return HAL_ERROR;
1032
      }
1157
      }
1033
      /* Enable the TIM Capture/Compare 4 DMA request */
1158
      /* Enable the TIM Capture/Compare 4 DMA request */
1034
      __HAL_TIM_ENABLE_DMA(htim, TIM_DMA_CC4);
1159
      __HAL_TIM_ENABLE_DMA(htim, TIM_DMA_CC4);
1035
      break;
1160
      break;
1036
    }
1161
    }
1037
 
1162
 
1038
    default:
1163
    default:
-
 
1164
      status = HAL_ERROR;
1039
      break;
1165
      break;
1040
  }
1166
  }
1041
 
1167
 
1042
  /* Enable the Output compare channel */
1168
  if (status == HAL_OK)
1043
  TIM_CCxChannelCmd(htim->Instance, Channel, TIM_CCx_ENABLE);
-
 
1044
 
-
 
1045
  if (IS_TIM_BREAK_INSTANCE(htim->Instance) != RESET)
-
 
1046
  {
1169
  {
1047
    /* Enable the main output */
1170
    /* Enable the Output compare channel */
1048
    __HAL_TIM_MOE_ENABLE(htim);
1171
    TIM_CCxChannelCmd(htim->Instance, Channel, TIM_CCx_ENABLE);
1049
  }
-
 
1050
 
1172
 
-
 
1173
    if (IS_TIM_BREAK_INSTANCE(htim->Instance) != RESET)
-
 
1174
    {
-
 
1175
      /* Enable the main output */
-
 
1176
      __HAL_TIM_MOE_ENABLE(htim);
-
 
1177
    }
-
 
1178
 
1051
  /* Enable the Peripheral, except in trigger mode where enable is automatically done with trigger */
1179
    /* Enable the Peripheral, except in trigger mode where enable is automatically done with trigger */
-
 
1180
    if (IS_TIM_SLAVE_INSTANCE(htim->Instance))
-
 
1181
    {
1052
  tmpsmcr = htim->Instance->SMCR & TIM_SMCR_SMS;
1182
      tmpsmcr = htim->Instance->SMCR & TIM_SMCR_SMS;
1053
  if (!IS_TIM_SLAVEMODE_TRIGGER_ENABLED(tmpsmcr))
1183
      if (!IS_TIM_SLAVEMODE_TRIGGER_ENABLED(tmpsmcr))
-
 
1184
      {
-
 
1185
        __HAL_TIM_ENABLE(htim);
-
 
1186
      }
-
 
1187
    }
-
 
1188
    else
1054
  {
1189
    {
1055
    __HAL_TIM_ENABLE(htim);
1190
      __HAL_TIM_ENABLE(htim);
-
 
1191
    }
1056
  }
1192
  }
1057
 
1193
 
1058
  /* Return function status */
1194
  /* Return function status */
1059
  return HAL_OK;
1195
  return status;
1060
}
1196
}
1061
 
1197
 
1062
/**
1198
/**
1063
  * @brief  Stops the TIM Output Compare signal generation in DMA mode.
1199
  * @brief  Stops the TIM Output Compare signal generation in DMA mode.
1064
  * @param  htim TIM Output Compare handle
1200
  * @param  htim TIM Output Compare handle
Line 1070... Line 1206...
1070
  *            @arg TIM_CHANNEL_4: TIM Channel 4 selected
1206
  *            @arg TIM_CHANNEL_4: TIM Channel 4 selected
1071
  * @retval HAL status
1207
  * @retval HAL status
1072
  */
1208
  */
1073
HAL_StatusTypeDef HAL_TIM_OC_Stop_DMA(TIM_HandleTypeDef *htim, uint32_t Channel)
1209
HAL_StatusTypeDef HAL_TIM_OC_Stop_DMA(TIM_HandleTypeDef *htim, uint32_t Channel)
1074
{
1210
{
-
 
1211
  HAL_StatusTypeDef status = HAL_OK;
-
 
1212
 
1075
  /* Check the parameters */
1213
  /* Check the parameters */
1076
  assert_param(IS_TIM_CCX_INSTANCE(htim->Instance, Channel));
1214
  assert_param(IS_TIM_CCX_INSTANCE(htim->Instance, Channel));
1077
 
1215
 
1078
  switch (Channel)
1216
  switch (Channel)
1079
  {
1217
  {
Line 1108... Line 1246...
1108
      (void)HAL_DMA_Abort_IT(htim->hdma[TIM_DMA_ID_CC4]);
1246
      (void)HAL_DMA_Abort_IT(htim->hdma[TIM_DMA_ID_CC4]);
1109
      break;
1247
      break;
1110
    }
1248
    }
1111
 
1249
 
1112
    default:
1250
    default:
-
 
1251
      status = HAL_ERROR;
1113
      break;
1252
      break;
1114
  }
1253
  }
1115
 
1254
 
1116
  /* Disable the Output compare channel */
1255
  if (status == HAL_OK)
1117
  TIM_CCxChannelCmd(htim->Instance, Channel, TIM_CCx_DISABLE);
-
 
1118
 
-
 
1119
  if (IS_TIM_BREAK_INSTANCE(htim->Instance) != RESET)
-
 
1120
  {
1256
  {
1121
    /* Disable the Main Output */
1257
    /* Disable the Output compare channel */
1122
    __HAL_TIM_MOE_DISABLE(htim);
1258
    TIM_CCxChannelCmd(htim->Instance, Channel, TIM_CCx_DISABLE);
1123
  }
-
 
1124
 
1259
 
-
 
1260
    if (IS_TIM_BREAK_INSTANCE(htim->Instance) != RESET)
-
 
1261
    {
1125
  /* Disable the Peripheral */
1262
      /* Disable the Main Output */
1126
  __HAL_TIM_DISABLE(htim);
1263
      __HAL_TIM_MOE_DISABLE(htim);
-
 
1264
    }
1127
 
1265
 
1128
  /* Change the htim state */
1266
    /* Disable the Peripheral */
1129
  htim->State = HAL_TIM_STATE_READY;
1267
    __HAL_TIM_DISABLE(htim);
-
 
1268
 
-
 
1269
    /* Set the TIM channel state */
-
 
1270
    TIM_CHANNEL_STATE_SET(htim, Channel, HAL_TIM_CHANNEL_STATE_READY);
-
 
1271
  }
1130
 
1272
 
1131
  /* Return function status */
1273
  /* Return function status */
1132
  return HAL_OK;
1274
  return status;
1133
}
1275
}
1134
 
1276
 
1135
/**
1277
/**
1136
  * @}
1278
  * @}
1137
  */
1279
  */
Line 1206... Line 1348...
1206
  htim->State = HAL_TIM_STATE_BUSY;
1348
  htim->State = HAL_TIM_STATE_BUSY;
1207
 
1349
 
1208
  /* Init the base time for the PWM */
1350
  /* Init the base time for the PWM */
1209
  TIM_Base_SetConfig(htim->Instance, &htim->Init);
1351
  TIM_Base_SetConfig(htim->Instance, &htim->Init);
1210
 
1352
 
-
 
1353
  /* Initialize the DMA burst operation state */
-
 
1354
  htim->DMABurstState = HAL_DMA_BURST_STATE_READY;
-
 
1355
 
-
 
1356
  /* Initialize the TIM channels state */
-
 
1357
  TIM_CHANNEL_STATE_SET_ALL(htim, HAL_TIM_CHANNEL_STATE_READY);
-
 
1358
  TIM_CHANNEL_N_STATE_SET_ALL(htim, HAL_TIM_CHANNEL_STATE_READY);
-
 
1359
 
1211
  /* Initialize the TIM state*/
1360
  /* Initialize the TIM state*/
1212
  htim->State = HAL_TIM_STATE_READY;
1361
  htim->State = HAL_TIM_STATE_READY;
1213
 
1362
 
1214
  return HAL_OK;
1363
  return HAL_OK;
1215
}
1364
}
Line 1239... Line 1388...
1239
#else
1388
#else
1240
  /* DeInit the low level hardware: GPIO, CLOCK, NVIC and DMA */
1389
  /* DeInit the low level hardware: GPIO, CLOCK, NVIC and DMA */
1241
  HAL_TIM_PWM_MspDeInit(htim);
1390
  HAL_TIM_PWM_MspDeInit(htim);
1242
#endif /* USE_HAL_TIM_REGISTER_CALLBACKS */
1391
#endif /* USE_HAL_TIM_REGISTER_CALLBACKS */
1243
 
1392
 
-
 
1393
  /* Change the DMA burst operation state */
-
 
1394
  htim->DMABurstState = HAL_DMA_BURST_STATE_RESET;
-
 
1395
 
-
 
1396
  /* Change the TIM channels state */
-
 
1397
  TIM_CHANNEL_STATE_SET_ALL(htim, HAL_TIM_CHANNEL_STATE_RESET);
-
 
1398
  TIM_CHANNEL_N_STATE_SET_ALL(htim, HAL_TIM_CHANNEL_STATE_RESET);
-
 
1399
 
1244
  /* Change TIM state */
1400
  /* Change TIM state */
1245
  htim->State = HAL_TIM_STATE_RESET;
1401
  htim->State = HAL_TIM_STATE_RESET;
1246
 
1402
 
1247
  /* Release Lock */
1403
  /* Release Lock */
1248
  __HAL_UNLOCK(htim);
1404
  __HAL_UNLOCK(htim);
Line 1296... Line 1452...
1296
  uint32_t tmpsmcr;
1452
  uint32_t tmpsmcr;
1297
 
1453
 
1298
  /* Check the parameters */
1454
  /* Check the parameters */
1299
  assert_param(IS_TIM_CCX_INSTANCE(htim->Instance, Channel));
1455
  assert_param(IS_TIM_CCX_INSTANCE(htim->Instance, Channel));
1300
 
1456
 
-
 
1457
  /* Check the TIM channel state */
-
 
1458
  if (TIM_CHANNEL_STATE_GET(htim, Channel) != HAL_TIM_CHANNEL_STATE_READY)
-
 
1459
  {
-
 
1460
    return HAL_ERROR;
-
 
1461
  }
-
 
1462
 
-
 
1463
  /* Set the TIM channel state */
-
 
1464
  TIM_CHANNEL_STATE_SET(htim, Channel, HAL_TIM_CHANNEL_STATE_BUSY);
-
 
1465
 
1301
  /* Enable the Capture compare channel */
1466
  /* Enable the Capture compare channel */
1302
  TIM_CCxChannelCmd(htim->Instance, Channel, TIM_CCx_ENABLE);
1467
  TIM_CCxChannelCmd(htim->Instance, Channel, TIM_CCx_ENABLE);
1303
 
1468
 
1304
  if (IS_TIM_BREAK_INSTANCE(htim->Instance) != RESET)
1469
  if (IS_TIM_BREAK_INSTANCE(htim->Instance) != RESET)
1305
  {
1470
  {
1306
    /* Enable the main output */
1471
    /* Enable the main output */
1307
    __HAL_TIM_MOE_ENABLE(htim);
1472
    __HAL_TIM_MOE_ENABLE(htim);
1308
  }
1473
  }
1309
 
1474
 
1310
  /* Enable the Peripheral, except in trigger mode where enable is automatically done with trigger */
1475
  /* Enable the Peripheral, except in trigger mode where enable is automatically done with trigger */
-
 
1476
  if (IS_TIM_SLAVE_INSTANCE(htim->Instance))
-
 
1477
  {
1311
  tmpsmcr = htim->Instance->SMCR & TIM_SMCR_SMS;
1478
    tmpsmcr = htim->Instance->SMCR & TIM_SMCR_SMS;
1312
  if (!IS_TIM_SLAVEMODE_TRIGGER_ENABLED(tmpsmcr))
1479
    if (!IS_TIM_SLAVEMODE_TRIGGER_ENABLED(tmpsmcr))
-
 
1480
    {
-
 
1481
      __HAL_TIM_ENABLE(htim);
-
 
1482
    }
-
 
1483
  }
-
 
1484
  else
1313
  {
1485
  {
1314
    __HAL_TIM_ENABLE(htim);
1486
    __HAL_TIM_ENABLE(htim);
1315
  }
1487
  }
1316
 
1488
 
1317
  /* Return function status */
1489
  /* Return function status */
Line 1344... Line 1516...
1344
  }
1516
  }
1345
 
1517
 
1346
  /* Disable the Peripheral */
1518
  /* Disable the Peripheral */
1347
  __HAL_TIM_DISABLE(htim);
1519
  __HAL_TIM_DISABLE(htim);
1348
 
1520
 
1349
  /* Change the htim state */
1521
  /* Set the TIM channel state */
1350
  htim->State = HAL_TIM_STATE_READY;
1522
  TIM_CHANNEL_STATE_SET(htim, Channel, HAL_TIM_CHANNEL_STATE_READY);
1351
 
1523
 
1352
  /* Return function status */
1524
  /* Return function status */
1353
  return HAL_OK;
1525
  return HAL_OK;
1354
}
1526
}
1355
 
1527
 
Line 1364... Line 1536...
1364
  *            @arg TIM_CHANNEL_4: TIM Channel 4 selected
1536
  *            @arg TIM_CHANNEL_4: TIM Channel 4 selected
1365
  * @retval HAL status
1537
  * @retval HAL status
1366
  */
1538
  */
1367
HAL_StatusTypeDef HAL_TIM_PWM_Start_IT(TIM_HandleTypeDef *htim, uint32_t Channel)
1539
HAL_StatusTypeDef HAL_TIM_PWM_Start_IT(TIM_HandleTypeDef *htim, uint32_t Channel)
1368
{
1540
{
-
 
1541
  HAL_StatusTypeDef status = HAL_OK;
1369
  uint32_t tmpsmcr;
1542
  uint32_t tmpsmcr;
-
 
1543
 
1370
  /* Check the parameters */
1544
  /* Check the parameters */
1371
  assert_param(IS_TIM_CCX_INSTANCE(htim->Instance, Channel));
1545
  assert_param(IS_TIM_CCX_INSTANCE(htim->Instance, Channel));
1372
 
1546
 
-
 
1547
  /* Check the TIM channel state */
-
 
1548
  if (TIM_CHANNEL_STATE_GET(htim, Channel) != HAL_TIM_CHANNEL_STATE_READY)
-
 
1549
  {
-
 
1550
    return HAL_ERROR;
-
 
1551
  }
-
 
1552
 
-
 
1553
  /* Set the TIM channel state */
-
 
1554
  TIM_CHANNEL_STATE_SET(htim, Channel, HAL_TIM_CHANNEL_STATE_BUSY);
-
 
1555
 
1373
  switch (Channel)
1556
  switch (Channel)
1374
  {
1557
  {
1375
    case TIM_CHANNEL_1:
1558
    case TIM_CHANNEL_1:
1376
    {
1559
    {
1377
      /* Enable the TIM Capture/Compare 1 interrupt */
1560
      /* Enable the TIM Capture/Compare 1 interrupt */
Line 1399... Line 1582...
1399
      __HAL_TIM_ENABLE_IT(htim, TIM_IT_CC4);
1582
      __HAL_TIM_ENABLE_IT(htim, TIM_IT_CC4);
1400
      break;
1583
      break;
1401
    }
1584
    }
1402
 
1585
 
1403
    default:
1586
    default:
-
 
1587
      status = HAL_ERROR;
1404
      break;
1588
      break;
1405
  }
1589
  }
1406
 
1590
 
1407
  /* Enable the Capture compare channel */
1591
  if (status == HAL_OK)
1408
  TIM_CCxChannelCmd(htim->Instance, Channel, TIM_CCx_ENABLE);
-
 
1409
 
-
 
1410
  if (IS_TIM_BREAK_INSTANCE(htim->Instance) != RESET)
-
 
1411
  {
1592
  {
1412
    /* Enable the main output */
1593
    /* Enable the Capture compare channel */
1413
    __HAL_TIM_MOE_ENABLE(htim);
1594
    TIM_CCxChannelCmd(htim->Instance, Channel, TIM_CCx_ENABLE);
1414
  }
-
 
1415
 
1595
 
-
 
1596
    if (IS_TIM_BREAK_INSTANCE(htim->Instance) != RESET)
-
 
1597
    {
-
 
1598
      /* Enable the main output */
-
 
1599
      __HAL_TIM_MOE_ENABLE(htim);
-
 
1600
    }
-
 
1601
 
1416
  /* Enable the Peripheral, except in trigger mode where enable is automatically done with trigger */
1602
    /* Enable the Peripheral, except in trigger mode where enable is automatically done with trigger */
-
 
1603
    if (IS_TIM_SLAVE_INSTANCE(htim->Instance))
-
 
1604
    {
1417
  tmpsmcr = htim->Instance->SMCR & TIM_SMCR_SMS;
1605
      tmpsmcr = htim->Instance->SMCR & TIM_SMCR_SMS;
1418
  if (!IS_TIM_SLAVEMODE_TRIGGER_ENABLED(tmpsmcr))
1606
      if (!IS_TIM_SLAVEMODE_TRIGGER_ENABLED(tmpsmcr))
-
 
1607
      {
-
 
1608
        __HAL_TIM_ENABLE(htim);
-
 
1609
      }
-
 
1610
    }
-
 
1611
    else
1419
  {
1612
    {
1420
    __HAL_TIM_ENABLE(htim);
1613
      __HAL_TIM_ENABLE(htim);
-
 
1614
    }
1421
  }
1615
  }
1422
 
1616
 
1423
  /* Return function status */
1617
  /* Return function status */
1424
  return HAL_OK;
1618
  return status;
1425
}
1619
}
1426
 
1620
 
1427
/**
1621
/**
1428
  * @brief  Stops the PWM signal generation in interrupt mode.
1622
  * @brief  Stops the PWM signal generation in interrupt mode.
1429
  * @param  htim TIM PWM handle
1623
  * @param  htim TIM PWM handle
Line 1435... Line 1629...
1435
  *            @arg TIM_CHANNEL_4: TIM Channel 4 selected
1629
  *            @arg TIM_CHANNEL_4: TIM Channel 4 selected
1436
  * @retval HAL status
1630
  * @retval HAL status
1437
  */
1631
  */
1438
HAL_StatusTypeDef HAL_TIM_PWM_Stop_IT(TIM_HandleTypeDef *htim, uint32_t Channel)
1632
HAL_StatusTypeDef HAL_TIM_PWM_Stop_IT(TIM_HandleTypeDef *htim, uint32_t Channel)
1439
{
1633
{
-
 
1634
  HAL_StatusTypeDef status = HAL_OK;
-
 
1635
 
1440
  /* Check the parameters */
1636
  /* Check the parameters */
1441
  assert_param(IS_TIM_CCX_INSTANCE(htim->Instance, Channel));
1637
  assert_param(IS_TIM_CCX_INSTANCE(htim->Instance, Channel));
1442
 
1638
 
1443
  switch (Channel)
1639
  switch (Channel)
1444
  {
1640
  {
Line 1469... Line 1665...
1469
      __HAL_TIM_DISABLE_IT(htim, TIM_IT_CC4);
1665
      __HAL_TIM_DISABLE_IT(htim, TIM_IT_CC4);
1470
      break;
1666
      break;
1471
    }
1667
    }
1472
 
1668
 
1473
    default:
1669
    default:
-
 
1670
      status = HAL_ERROR;
1474
      break;
1671
      break;
1475
  }
1672
  }
1476
 
1673
 
1477
  /* Disable the Capture compare channel */
1674
  if (status == HAL_OK)
1478
  TIM_CCxChannelCmd(htim->Instance, Channel, TIM_CCx_DISABLE);
-
 
1479
 
-
 
1480
  if (IS_TIM_BREAK_INSTANCE(htim->Instance) != RESET)
-
 
1481
  {
1675
  {
1482
    /* Disable the Main Output */
1676
    /* Disable the Capture compare channel */
1483
    __HAL_TIM_MOE_DISABLE(htim);
1677
    TIM_CCxChannelCmd(htim->Instance, Channel, TIM_CCx_DISABLE);
1484
  }
-
 
1485
 
1678
 
-
 
1679
    if (IS_TIM_BREAK_INSTANCE(htim->Instance) != RESET)
-
 
1680
    {
-
 
1681
      /* Disable the Main Output */
-
 
1682
      __HAL_TIM_MOE_DISABLE(htim);
-
 
1683
    }
-
 
1684
 
1486
  /* Disable the Peripheral */
1685
    /* Disable the Peripheral */
1487
  __HAL_TIM_DISABLE(htim);
1686
    __HAL_TIM_DISABLE(htim);
-
 
1687
 
-
 
1688
    /* Set the TIM channel state */
-
 
1689
    TIM_CHANNEL_STATE_SET(htim, Channel, HAL_TIM_CHANNEL_STATE_READY);
-
 
1690
  }
1488
 
1691
 
1489
  /* Return function status */
1692
  /* Return function status */
1490
  return HAL_OK;
1693
  return status;
1491
}
1694
}
1492
 
1695
 
1493
/**
1696
/**
1494
  * @brief  Starts the TIM PWM signal generation in DMA mode.
1697
  * @brief  Starts the TIM PWM signal generation in DMA mode.
1495
  * @param  htim TIM PWM handle
1698
  * @param  htim TIM PWM handle
Line 1503... Line 1706...
1503
  * @param  Length The length of data to be transferred from memory to TIM peripheral
1706
  * @param  Length The length of data to be transferred from memory to TIM peripheral
1504
  * @retval HAL status
1707
  * @retval HAL status
1505
  */
1708
  */
1506
HAL_StatusTypeDef HAL_TIM_PWM_Start_DMA(TIM_HandleTypeDef *htim, uint32_t Channel, uint32_t *pData, uint16_t Length)
1709
HAL_StatusTypeDef HAL_TIM_PWM_Start_DMA(TIM_HandleTypeDef *htim, uint32_t Channel, uint32_t *pData, uint16_t Length)
1507
{
1710
{
-
 
1711
  HAL_StatusTypeDef status = HAL_OK;
1508
  uint32_t tmpsmcr;
1712
  uint32_t tmpsmcr;
1509
 
1713
 
1510
  /* Check the parameters */
1714
  /* Check the parameters */
1511
  assert_param(IS_TIM_CCX_INSTANCE(htim->Instance, Channel));
1715
  assert_param(IS_TIM_CCX_INSTANCE(htim->Instance, Channel));
1512
 
1716
 
-
 
1717
  /* Set the TIM channel state */
1513
  if (htim->State == HAL_TIM_STATE_BUSY)
1718
  if (TIM_CHANNEL_STATE_GET(htim, Channel) == HAL_TIM_CHANNEL_STATE_BUSY)
1514
  {
1719
  {
1515
    return HAL_BUSY;
1720
    return HAL_BUSY;
1516
  }
1721
  }
1517
  else if (htim->State == HAL_TIM_STATE_READY)
1722
  else if (TIM_CHANNEL_STATE_GET(htim, Channel) == HAL_TIM_CHANNEL_STATE_READY)
1518
  {
1723
  {
1519
    if ((pData == NULL) && (Length > 0U))
1724
    if ((pData == NULL) && (Length > 0U))
1520
    {
1725
    {
1521
      return HAL_ERROR;
1726
      return HAL_ERROR;
1522
    }
1727
    }
1523
    else
1728
    else
1524
    {
1729
    {
1525
      htim->State = HAL_TIM_STATE_BUSY;
1730
      TIM_CHANNEL_STATE_SET(htim, Channel, HAL_TIM_CHANNEL_STATE_BUSY);
1526
    }
1731
    }
1527
  }
1732
  }
1528
  else
1733
  else
1529
  {
1734
  {
1530
    /* nothing to do */
1735
    return HAL_ERROR;
1531
  }
1736
  }
1532
 
1737
 
1533
  switch (Channel)
1738
  switch (Channel)
1534
  {
1739
  {
1535
    case TIM_CHANNEL_1:
1740
    case TIM_CHANNEL_1:
Line 1540... Line 1745...
1540
 
1745
 
1541
      /* Set the DMA error callback */
1746
      /* Set the DMA error callback */
1542
      htim->hdma[TIM_DMA_ID_CC1]->XferErrorCallback = TIM_DMAError ;
1747
      htim->hdma[TIM_DMA_ID_CC1]->XferErrorCallback = TIM_DMAError ;
1543
 
1748
 
1544
      /* Enable the DMA channel */
1749
      /* Enable the DMA channel */
1545
      if (HAL_DMA_Start_IT(htim->hdma[TIM_DMA_ID_CC1], (uint32_t)pData, (uint32_t)&htim->Instance->CCR1, Length) != HAL_OK)
1750
      if (HAL_DMA_Start_IT(htim->hdma[TIM_DMA_ID_CC1], (uint32_t)pData, (uint32_t)&htim->Instance->CCR1,
-
 
1751
                           Length) != HAL_OK)
1546
      {
1752
      {
-
 
1753
        /* Return error status */
1547
        return HAL_ERROR;
1754
        return HAL_ERROR;
1548
      }
1755
      }
1549
 
1756
 
1550
      /* Enable the TIM Capture/Compare 1 DMA request */
1757
      /* Enable the TIM Capture/Compare 1 DMA request */
1551
      __HAL_TIM_ENABLE_DMA(htim, TIM_DMA_CC1);
1758
      __HAL_TIM_ENABLE_DMA(htim, TIM_DMA_CC1);
Line 1560... Line 1767...
1560
 
1767
 
1561
      /* Set the DMA error callback */
1768
      /* Set the DMA error callback */
1562
      htim->hdma[TIM_DMA_ID_CC2]->XferErrorCallback = TIM_DMAError ;
1769
      htim->hdma[TIM_DMA_ID_CC2]->XferErrorCallback = TIM_DMAError ;
1563
 
1770
 
1564
      /* Enable the DMA channel */
1771
      /* Enable the DMA channel */
1565
      if (HAL_DMA_Start_IT(htim->hdma[TIM_DMA_ID_CC2], (uint32_t)pData, (uint32_t)&htim->Instance->CCR2, Length) != HAL_OK)
1772
      if (HAL_DMA_Start_IT(htim->hdma[TIM_DMA_ID_CC2], (uint32_t)pData, (uint32_t)&htim->Instance->CCR2,
-
 
1773
                           Length) != HAL_OK)
1566
      {
1774
      {
-
 
1775
        /* Return error status */
1567
        return HAL_ERROR;
1776
        return HAL_ERROR;
1568
      }
1777
      }
1569
      /* Enable the TIM Capture/Compare 2 DMA request */
1778
      /* Enable the TIM Capture/Compare 2 DMA request */
1570
      __HAL_TIM_ENABLE_DMA(htim, TIM_DMA_CC2);
1779
      __HAL_TIM_ENABLE_DMA(htim, TIM_DMA_CC2);
1571
      break;
1780
      break;
Line 1579... Line 1788...
1579
 
1788
 
1580
      /* Set the DMA error callback */
1789
      /* Set the DMA error callback */
1581
      htim->hdma[TIM_DMA_ID_CC3]->XferErrorCallback = TIM_DMAError ;
1790
      htim->hdma[TIM_DMA_ID_CC3]->XferErrorCallback = TIM_DMAError ;
1582
 
1791
 
1583
      /* Enable the DMA channel */
1792
      /* Enable the DMA channel */
1584
      if (HAL_DMA_Start_IT(htim->hdma[TIM_DMA_ID_CC3], (uint32_t)pData, (uint32_t)&htim->Instance->CCR3, Length) != HAL_OK)
1793
      if (HAL_DMA_Start_IT(htim->hdma[TIM_DMA_ID_CC3], (uint32_t)pData, (uint32_t)&htim->Instance->CCR3,
-
 
1794
                           Length) != HAL_OK)
1585
      {
1795
      {
-
 
1796
        /* Return error status */
1586
        return HAL_ERROR;
1797
        return HAL_ERROR;
1587
      }
1798
      }
1588
      /* Enable the TIM Output Capture/Compare 3 request */
1799
      /* Enable the TIM Output Capture/Compare 3 request */
1589
      __HAL_TIM_ENABLE_DMA(htim, TIM_DMA_CC3);
1800
      __HAL_TIM_ENABLE_DMA(htim, TIM_DMA_CC3);
1590
      break;
1801
      break;
Line 1598... Line 1809...
1598
 
1809
 
1599
      /* Set the DMA error callback */
1810
      /* Set the DMA error callback */
1600
      htim->hdma[TIM_DMA_ID_CC4]->XferErrorCallback = TIM_DMAError ;
1811
      htim->hdma[TIM_DMA_ID_CC4]->XferErrorCallback = TIM_DMAError ;
1601
 
1812
 
1602
      /* Enable the DMA channel */
1813
      /* Enable the DMA channel */
1603
      if (HAL_DMA_Start_IT(htim->hdma[TIM_DMA_ID_CC4], (uint32_t)pData, (uint32_t)&htim->Instance->CCR4, Length) != HAL_OK)
1814
      if (HAL_DMA_Start_IT(htim->hdma[TIM_DMA_ID_CC4], (uint32_t)pData, (uint32_t)&htim->Instance->CCR4,
-
 
1815
                           Length) != HAL_OK)
1604
      {
1816
      {
-
 
1817
        /* Return error status */
1605
        return HAL_ERROR;
1818
        return HAL_ERROR;
1606
      }
1819
      }
1607
      /* Enable the TIM Capture/Compare 4 DMA request */
1820
      /* Enable the TIM Capture/Compare 4 DMA request */
1608
      __HAL_TIM_ENABLE_DMA(htim, TIM_DMA_CC4);
1821
      __HAL_TIM_ENABLE_DMA(htim, TIM_DMA_CC4);
1609
      break;
1822
      break;
1610
    }
1823
    }
1611
 
1824
 
1612
    default:
1825
    default:
-
 
1826
      status = HAL_ERROR;
1613
      break;
1827
      break;
1614
  }
1828
  }
1615
 
1829
 
1616
  /* Enable the Capture compare channel */
1830
  if (status == HAL_OK)
1617
  TIM_CCxChannelCmd(htim->Instance, Channel, TIM_CCx_ENABLE);
-
 
1618
 
-
 
1619
  if (IS_TIM_BREAK_INSTANCE(htim->Instance) != RESET)
-
 
1620
  {
1831
  {
1621
    /* Enable the main output */
1832
    /* Enable the Capture compare channel */
1622
    __HAL_TIM_MOE_ENABLE(htim);
1833
    TIM_CCxChannelCmd(htim->Instance, Channel, TIM_CCx_ENABLE);
1623
  }
-
 
1624
 
1834
 
-
 
1835
    if (IS_TIM_BREAK_INSTANCE(htim->Instance) != RESET)
-
 
1836
    {
-
 
1837
      /* Enable the main output */
-
 
1838
      __HAL_TIM_MOE_ENABLE(htim);
-
 
1839
    }
-
 
1840
 
1625
  /* Enable the Peripheral, except in trigger mode where enable is automatically done with trigger */
1841
    /* Enable the Peripheral, except in trigger mode where enable is automatically done with trigger */
-
 
1842
    if (IS_TIM_SLAVE_INSTANCE(htim->Instance))
-
 
1843
    {
1626
  tmpsmcr = htim->Instance->SMCR & TIM_SMCR_SMS;
1844
      tmpsmcr = htim->Instance->SMCR & TIM_SMCR_SMS;
1627
  if (!IS_TIM_SLAVEMODE_TRIGGER_ENABLED(tmpsmcr))
1845
      if (!IS_TIM_SLAVEMODE_TRIGGER_ENABLED(tmpsmcr))
-
 
1846
      {
-
 
1847
        __HAL_TIM_ENABLE(htim);
-
 
1848
      }
-
 
1849
    }
-
 
1850
    else
1628
  {
1851
    {
1629
    __HAL_TIM_ENABLE(htim);
1852
      __HAL_TIM_ENABLE(htim);
-
 
1853
    }
1630
  }
1854
  }
1631
 
1855
 
1632
  /* Return function status */
1856
  /* Return function status */
1633
  return HAL_OK;
1857
  return status;
1634
}
1858
}
1635
 
1859
 
1636
/**
1860
/**
1637
  * @brief  Stops the TIM PWM signal generation in DMA mode.
1861
  * @brief  Stops the TIM PWM signal generation in DMA mode.
1638
  * @param  htim TIM PWM handle
1862
  * @param  htim TIM PWM handle
Line 1644... Line 1868...
1644
  *            @arg TIM_CHANNEL_4: TIM Channel 4 selected
1868
  *            @arg TIM_CHANNEL_4: TIM Channel 4 selected
1645
  * @retval HAL status
1869
  * @retval HAL status
1646
  */
1870
  */
1647
HAL_StatusTypeDef HAL_TIM_PWM_Stop_DMA(TIM_HandleTypeDef *htim, uint32_t Channel)
1871
HAL_StatusTypeDef HAL_TIM_PWM_Stop_DMA(TIM_HandleTypeDef *htim, uint32_t Channel)
1648
{
1872
{
-
 
1873
  HAL_StatusTypeDef status = HAL_OK;
-
 
1874
 
1649
  /* Check the parameters */
1875
  /* Check the parameters */
1650
  assert_param(IS_TIM_CCX_INSTANCE(htim->Instance, Channel));
1876
  assert_param(IS_TIM_CCX_INSTANCE(htim->Instance, Channel));
1651
 
1877
 
1652
  switch (Channel)
1878
  switch (Channel)
1653
  {
1879
  {
Line 1682... Line 1908...
1682
      (void)HAL_DMA_Abort_IT(htim->hdma[TIM_DMA_ID_CC4]);
1908
      (void)HAL_DMA_Abort_IT(htim->hdma[TIM_DMA_ID_CC4]);
1683
      break;
1909
      break;
1684
    }
1910
    }
1685
 
1911
 
1686
    default:
1912
    default:
-
 
1913
      status = HAL_ERROR;
1687
      break;
1914
      break;
1688
  }
1915
  }
1689
 
1916
 
1690
  /* Disable the Capture compare channel */
1917
  if (status == HAL_OK)
1691
  TIM_CCxChannelCmd(htim->Instance, Channel, TIM_CCx_DISABLE);
-
 
1692
 
-
 
1693
  if (IS_TIM_BREAK_INSTANCE(htim->Instance) != RESET)
-
 
1694
  {
1918
  {
1695
    /* Disable the Main Output */
1919
    /* Disable the Capture compare channel */
1696
    __HAL_TIM_MOE_DISABLE(htim);
1920
    TIM_CCxChannelCmd(htim->Instance, Channel, TIM_CCx_DISABLE);
1697
  }
-
 
1698
 
1921
 
-
 
1922
    if (IS_TIM_BREAK_INSTANCE(htim->Instance) != RESET)
-
 
1923
    {
1699
  /* Disable the Peripheral */
1924
      /* Disable the Main Output */
1700
  __HAL_TIM_DISABLE(htim);
1925
      __HAL_TIM_MOE_DISABLE(htim);
-
 
1926
    }
1701
 
1927
 
1702
  /* Change the htim state */
1928
    /* Disable the Peripheral */
1703
  htim->State = HAL_TIM_STATE_READY;
1929
    __HAL_TIM_DISABLE(htim);
-
 
1930
 
-
 
1931
    /* Set the TIM channel state */
-
 
1932
    TIM_CHANNEL_STATE_SET(htim, Channel, HAL_TIM_CHANNEL_STATE_READY);
-
 
1933
  }
1704
 
1934
 
1705
  /* Return function status */
1935
  /* Return function status */
1706
  return HAL_OK;
1936
  return status;
1707
}
1937
}
1708
 
1938
 
1709
/**
1939
/**
1710
  * @}
1940
  * @}
1711
  */
1941
  */
Line 1780... Line 2010...
1780
  htim->State = HAL_TIM_STATE_BUSY;
2010
  htim->State = HAL_TIM_STATE_BUSY;
1781
 
2011
 
1782
  /* Init the base time for the input capture */
2012
  /* Init the base time for the input capture */
1783
  TIM_Base_SetConfig(htim->Instance, &htim->Init);
2013
  TIM_Base_SetConfig(htim->Instance, &htim->Init);
1784
 
2014
 
-
 
2015
  /* Initialize the DMA burst operation state */
-
 
2016
  htim->DMABurstState = HAL_DMA_BURST_STATE_READY;
-
 
2017
 
-
 
2018
  /* Initialize the TIM channels state */
-
 
2019
  TIM_CHANNEL_STATE_SET_ALL(htim, HAL_TIM_CHANNEL_STATE_READY);
-
 
2020
  TIM_CHANNEL_N_STATE_SET_ALL(htim, HAL_TIM_CHANNEL_STATE_READY);
-
 
2021
 
1785
  /* Initialize the TIM state*/
2022
  /* Initialize the TIM state*/
1786
  htim->State = HAL_TIM_STATE_READY;
2023
  htim->State = HAL_TIM_STATE_READY;
1787
 
2024
 
1788
  return HAL_OK;
2025
  return HAL_OK;
1789
}
2026
}
Line 1813... Line 2050...
1813
#else
2050
#else
1814
  /* DeInit the low level hardware: GPIO, CLOCK, NVIC and DMA */
2051
  /* DeInit the low level hardware: GPIO, CLOCK, NVIC and DMA */
1815
  HAL_TIM_IC_MspDeInit(htim);
2052
  HAL_TIM_IC_MspDeInit(htim);
1816
#endif /* USE_HAL_TIM_REGISTER_CALLBACKS */
2053
#endif /* USE_HAL_TIM_REGISTER_CALLBACKS */
1817
 
2054
 
-
 
2055
  /* Change the DMA burst operation state */
-
 
2056
  htim->DMABurstState = HAL_DMA_BURST_STATE_RESET;
-
 
2057
 
-
 
2058
  /* Change the TIM channels state */
-
 
2059
  TIM_CHANNEL_STATE_SET_ALL(htim, HAL_TIM_CHANNEL_STATE_RESET);
-
 
2060
  TIM_CHANNEL_N_STATE_SET_ALL(htim, HAL_TIM_CHANNEL_STATE_RESET);
-
 
2061
 
1818
  /* Change TIM state */
2062
  /* Change TIM state */
1819
  htim->State = HAL_TIM_STATE_RESET;
2063
  htim->State = HAL_TIM_STATE_RESET;
1820
 
2064
 
1821
  /* Release Lock */
2065
  /* Release Lock */
1822
  __HAL_UNLOCK(htim);
2066
  __HAL_UNLOCK(htim);
Line 1866... Line 2110...
1866
  * @retval HAL status
2110
  * @retval HAL status
1867
  */
2111
  */
1868
HAL_StatusTypeDef HAL_TIM_IC_Start(TIM_HandleTypeDef *htim, uint32_t Channel)
2112
HAL_StatusTypeDef HAL_TIM_IC_Start(TIM_HandleTypeDef *htim, uint32_t Channel)
1869
{
2113
{
1870
  uint32_t tmpsmcr;
2114
  uint32_t tmpsmcr;
-
 
2115
  HAL_TIM_ChannelStateTypeDef channel_state = TIM_CHANNEL_STATE_GET(htim, Channel);
-
 
2116
  HAL_TIM_ChannelStateTypeDef complementary_channel_state = TIM_CHANNEL_N_STATE_GET(htim, Channel);
1871
 
2117
 
1872
  /* Check the parameters */
2118
  /* Check the parameters */
1873
  assert_param(IS_TIM_CCX_INSTANCE(htim->Instance, Channel));
2119
  assert_param(IS_TIM_CCX_INSTANCE(htim->Instance, Channel));
1874
 
2120
 
-
 
2121
  /* Check the TIM channel state */
-
 
2122
  if ((channel_state != HAL_TIM_CHANNEL_STATE_READY)
-
 
2123
      || (complementary_channel_state != HAL_TIM_CHANNEL_STATE_READY))
-
 
2124
  {
-
 
2125
    return HAL_ERROR;
-
 
2126
  }
-
 
2127
 
-
 
2128
  /* Set the TIM channel state */
-
 
2129
  TIM_CHANNEL_STATE_SET(htim, Channel, HAL_TIM_CHANNEL_STATE_BUSY);
-
 
2130
  TIM_CHANNEL_N_STATE_SET(htim, Channel, HAL_TIM_CHANNEL_STATE_BUSY);
-
 
2131
 
1875
  /* Enable the Input Capture channel */
2132
  /* Enable the Input Capture channel */
1876
  TIM_CCxChannelCmd(htim->Instance, Channel, TIM_CCx_ENABLE);
2133
  TIM_CCxChannelCmd(htim->Instance, Channel, TIM_CCx_ENABLE);
1877
 
2134
 
1878
  /* Enable the Peripheral, except in trigger mode where enable is automatically done with trigger */
2135
  /* Enable the Peripheral, except in trigger mode where enable is automatically done with trigger */
-
 
2136
  if (IS_TIM_SLAVE_INSTANCE(htim->Instance))
-
 
2137
  {
1879
  tmpsmcr = htim->Instance->SMCR & TIM_SMCR_SMS;
2138
    tmpsmcr = htim->Instance->SMCR & TIM_SMCR_SMS;
1880
  if (!IS_TIM_SLAVEMODE_TRIGGER_ENABLED(tmpsmcr))
2139
    if (!IS_TIM_SLAVEMODE_TRIGGER_ENABLED(tmpsmcr))
-
 
2140
    {
-
 
2141
      __HAL_TIM_ENABLE(htim);
-
 
2142
    }
-
 
2143
  }
-
 
2144
  else
1881
  {
2145
  {
1882
    __HAL_TIM_ENABLE(htim);
2146
    __HAL_TIM_ENABLE(htim);
1883
  }
2147
  }
1884
 
2148
 
1885
  /* Return function status */
2149
  /* Return function status */
Line 1906... Line 2170...
1906
  TIM_CCxChannelCmd(htim->Instance, Channel, TIM_CCx_DISABLE);
2170
  TIM_CCxChannelCmd(htim->Instance, Channel, TIM_CCx_DISABLE);
1907
 
2171
 
1908
  /* Disable the Peripheral */
2172
  /* Disable the Peripheral */
1909
  __HAL_TIM_DISABLE(htim);
2173
  __HAL_TIM_DISABLE(htim);
1910
 
2174
 
-
 
2175
  /* Set the TIM channel state */
-
 
2176
  TIM_CHANNEL_STATE_SET(htim, Channel, HAL_TIM_CHANNEL_STATE_READY);
-
 
2177
  TIM_CHANNEL_N_STATE_SET(htim, Channel, HAL_TIM_CHANNEL_STATE_READY);
-
 
2178
 
1911
  /* Return function status */
2179
  /* Return function status */
1912
  return HAL_OK;
2180
  return HAL_OK;
1913
}
2181
}
1914
 
2182
 
1915
/**
2183
/**
Line 1923... Line 2191...
1923
  *            @arg TIM_CHANNEL_4: TIM Channel 4 selected
2191
  *            @arg TIM_CHANNEL_4: TIM Channel 4 selected
1924
  * @retval HAL status
2192
  * @retval HAL status
1925
  */
2193
  */
1926
HAL_StatusTypeDef HAL_TIM_IC_Start_IT(TIM_HandleTypeDef *htim, uint32_t Channel)
2194
HAL_StatusTypeDef HAL_TIM_IC_Start_IT(TIM_HandleTypeDef *htim, uint32_t Channel)
1927
{
2195
{
-
 
2196
  HAL_StatusTypeDef status = HAL_OK;
1928
  uint32_t tmpsmcr;
2197
  uint32_t tmpsmcr;
1929
 
2198
 
-
 
2199
  HAL_TIM_ChannelStateTypeDef channel_state = TIM_CHANNEL_STATE_GET(htim, Channel);
-
 
2200
  HAL_TIM_ChannelStateTypeDef complementary_channel_state = TIM_CHANNEL_N_STATE_GET(htim, Channel);
-
 
2201
 
1930
  /* Check the parameters */
2202
  /* Check the parameters */
1931
  assert_param(IS_TIM_CCX_INSTANCE(htim->Instance, Channel));
2203
  assert_param(IS_TIM_CCX_INSTANCE(htim->Instance, Channel));
1932
 
2204
 
-
 
2205
  /* Check the TIM channel state */
-
 
2206
  if ((channel_state != HAL_TIM_CHANNEL_STATE_READY)
-
 
2207
      || (complementary_channel_state != HAL_TIM_CHANNEL_STATE_READY))
-
 
2208
  {
-
 
2209
    return HAL_ERROR;
-
 
2210
  }
-
 
2211
 
-
 
2212
  /* Set the TIM channel state */
-
 
2213
  TIM_CHANNEL_STATE_SET(htim, Channel, HAL_TIM_CHANNEL_STATE_BUSY);
-
 
2214
  TIM_CHANNEL_N_STATE_SET(htim, Channel, HAL_TIM_CHANNEL_STATE_BUSY);
-
 
2215
 
1933
  switch (Channel)
2216
  switch (Channel)
1934
  {
2217
  {
1935
    case TIM_CHANNEL_1:
2218
    case TIM_CHANNEL_1:
1936
    {
2219
    {
1937
      /* Enable the TIM Capture/Compare 1 interrupt */
2220
      /* Enable the TIM Capture/Compare 1 interrupt */
Line 1959... Line 2242...
1959
      __HAL_TIM_ENABLE_IT(htim, TIM_IT_CC4);
2242
      __HAL_TIM_ENABLE_IT(htim, TIM_IT_CC4);
1960
      break;
2243
      break;
1961
    }
2244
    }
1962
 
2245
 
1963
    default:
2246
    default:
-
 
2247
      status = HAL_ERROR;
1964
      break;
2248
      break;
1965
  }
2249
  }
1966
  /* Enable the Input Capture channel */
-
 
1967
  TIM_CCxChannelCmd(htim->Instance, Channel, TIM_CCx_ENABLE);
-
 
1968
 
2250
 
1969
  /* Enable the Peripheral, except in trigger mode where enable is automatically done with trigger */
-
 
1970
  tmpsmcr = htim->Instance->SMCR & TIM_SMCR_SMS;
-
 
1971
  if (!IS_TIM_SLAVEMODE_TRIGGER_ENABLED(tmpsmcr))
2251
  if (status == HAL_OK)
1972
  {
2252
  {
-
 
2253
    /* Enable the Input Capture channel */
-
 
2254
    TIM_CCxChannelCmd(htim->Instance, Channel, TIM_CCx_ENABLE);
-
 
2255
 
-
 
2256
    /* Enable the Peripheral, except in trigger mode where enable is automatically done with trigger */
-
 
2257
    if (IS_TIM_SLAVE_INSTANCE(htim->Instance))
-
 
2258
    {
-
 
2259
      tmpsmcr = htim->Instance->SMCR & TIM_SMCR_SMS;
-
 
2260
      if (!IS_TIM_SLAVEMODE_TRIGGER_ENABLED(tmpsmcr))
-
 
2261
      {
-
 
2262
        __HAL_TIM_ENABLE(htim);
-
 
2263
      }
-
 
2264
    }
-
 
2265
    else
-
 
2266
    {
1973
    __HAL_TIM_ENABLE(htim);
2267
      __HAL_TIM_ENABLE(htim);
-
 
2268
    }
1974
  }
2269
  }
1975
 
2270
 
1976
  /* Return function status */
2271
  /* Return function status */
1977
  return HAL_OK;
2272
  return status;
1978
}
2273
}
1979
 
2274
 
1980
/**
2275
/**
1981
  * @brief  Stops the TIM Input Capture measurement in interrupt mode.
2276
  * @brief  Stops the TIM Input Capture measurement in interrupt mode.
1982
  * @param  htim TIM Input Capture handle
2277
  * @param  htim TIM Input Capture handle
Line 1988... Line 2283...
1988
  *            @arg TIM_CHANNEL_4: TIM Channel 4 selected
2283
  *            @arg TIM_CHANNEL_4: TIM Channel 4 selected
1989
  * @retval HAL status
2284
  * @retval HAL status
1990
  */
2285
  */
1991
HAL_StatusTypeDef HAL_TIM_IC_Stop_IT(TIM_HandleTypeDef *htim, uint32_t Channel)
2286
HAL_StatusTypeDef HAL_TIM_IC_Stop_IT(TIM_HandleTypeDef *htim, uint32_t Channel)
1992
{
2287
{
-
 
2288
  HAL_StatusTypeDef status = HAL_OK;
-
 
2289
 
1993
  /* Check the parameters */
2290
  /* Check the parameters */
1994
  assert_param(IS_TIM_CCX_INSTANCE(htim->Instance, Channel));
2291
  assert_param(IS_TIM_CCX_INSTANCE(htim->Instance, Channel));
1995
 
2292
 
1996
  switch (Channel)
2293
  switch (Channel)
1997
  {
2294
  {
Line 2022... Line 2319...
2022
      __HAL_TIM_DISABLE_IT(htim, TIM_IT_CC4);
2319
      __HAL_TIM_DISABLE_IT(htim, TIM_IT_CC4);
2023
      break;
2320
      break;
2024
    }
2321
    }
2025
 
2322
 
2026
    default:
2323
    default:
-
 
2324
      status = HAL_ERROR;
2027
      break;
2325
      break;
2028
  }
2326
  }
2029
 
2327
 
-
 
2328
  if (status == HAL_OK)
-
 
2329
  {
2030
  /* Disable the Input Capture channel */
2330
    /* Disable the Input Capture channel */
2031
  TIM_CCxChannelCmd(htim->Instance, Channel, TIM_CCx_DISABLE);
2331
    TIM_CCxChannelCmd(htim->Instance, Channel, TIM_CCx_DISABLE);
2032
 
2332
 
2033
  /* Disable the Peripheral */
2333
    /* Disable the Peripheral */
2034
  __HAL_TIM_DISABLE(htim);
2334
    __HAL_TIM_DISABLE(htim);
-
 
2335
 
-
 
2336
    /* Set the TIM channel state */
-
 
2337
    TIM_CHANNEL_STATE_SET(htim, Channel, HAL_TIM_CHANNEL_STATE_READY);
-
 
2338
    TIM_CHANNEL_N_STATE_SET(htim, Channel, HAL_TIM_CHANNEL_STATE_READY);
-
 
2339
  }
2035
 
2340
 
2036
  /* Return function status */
2341
  /* Return function status */
2037
  return HAL_OK;
2342
  return status;
2038
}
2343
}
2039
 
2344
 
2040
/**
2345
/**
2041
  * @brief  Starts the TIM Input Capture measurement in DMA mode.
2346
  * @brief  Starts the TIM Input Capture measurement in DMA mode.
2042
  * @param  htim TIM Input Capture handle
2347
  * @param  htim TIM Input Capture handle
Line 2050... Line 2355...
2050
  * @param  Length The length of data to be transferred from TIM peripheral to memory.
2355
  * @param  Length The length of data to be transferred from TIM peripheral to memory.
2051
  * @retval HAL status
2356
  * @retval HAL status
2052
  */
2357
  */
2053
HAL_StatusTypeDef HAL_TIM_IC_Start_DMA(TIM_HandleTypeDef *htim, uint32_t Channel, uint32_t *pData, uint16_t Length)
2358
HAL_StatusTypeDef HAL_TIM_IC_Start_DMA(TIM_HandleTypeDef *htim, uint32_t Channel, uint32_t *pData, uint16_t Length)
2054
{
2359
{
-
 
2360
  HAL_StatusTypeDef status = HAL_OK;
2055
  uint32_t tmpsmcr;
2361
  uint32_t tmpsmcr;
2056
 
2362
 
-
 
2363
  HAL_TIM_ChannelStateTypeDef channel_state = TIM_CHANNEL_STATE_GET(htim, Channel);
-
 
2364
  HAL_TIM_ChannelStateTypeDef complementary_channel_state = TIM_CHANNEL_N_STATE_GET(htim, Channel);
-
 
2365
 
2057
  /* Check the parameters */
2366
  /* Check the parameters */
2058
  assert_param(IS_TIM_CCX_INSTANCE(htim->Instance, Channel));
2367
  assert_param(IS_TIM_CCX_INSTANCE(htim->Instance, Channel));
2059
  assert_param(IS_TIM_DMA_CC_INSTANCE(htim->Instance));
2368
  assert_param(IS_TIM_DMA_CC_INSTANCE(htim->Instance));
2060
 
2369
 
-
 
2370
  /* Set the TIM channel state */
2061
  if (htim->State == HAL_TIM_STATE_BUSY)
2371
  if ((channel_state == HAL_TIM_CHANNEL_STATE_BUSY)
-
 
2372
      || (complementary_channel_state == HAL_TIM_CHANNEL_STATE_BUSY))
2062
  {
2373
  {
2063
    return HAL_BUSY;
2374
    return HAL_BUSY;
2064
  }
2375
  }
2065
  else if (htim->State == HAL_TIM_STATE_READY)
2376
  else if ((channel_state == HAL_TIM_CHANNEL_STATE_READY)
-
 
2377
           && (complementary_channel_state == HAL_TIM_CHANNEL_STATE_READY))
2066
  {
2378
  {
2067
    if ((pData == NULL) && (Length > 0U))
2379
    if ((pData == NULL) && (Length > 0U))
2068
    {
2380
    {
2069
      return HAL_ERROR;
2381
      return HAL_ERROR;
2070
    }
2382
    }
2071
    else
2383
    else
2072
    {
2384
    {
2073
      htim->State = HAL_TIM_STATE_BUSY;
2385
      TIM_CHANNEL_STATE_SET(htim, Channel, HAL_TIM_CHANNEL_STATE_BUSY);
-
 
2386
      TIM_CHANNEL_N_STATE_SET(htim, Channel, HAL_TIM_CHANNEL_STATE_BUSY);
2074
    }
2387
    }
2075
  }
2388
  }
2076
  else
2389
  else
2077
  {
2390
  {
2078
    /* nothing to do */
2391
    return HAL_ERROR;
2079
  }
2392
  }
2080
 
2393
 
-
 
2394
  /* Enable the Input Capture channel */
-
 
2395
  TIM_CCxChannelCmd(htim->Instance, Channel, TIM_CCx_ENABLE);
-
 
2396
 
2081
  switch (Channel)
2397
  switch (Channel)
2082
  {
2398
  {
2083
    case TIM_CHANNEL_1:
2399
    case TIM_CHANNEL_1:
2084
    {
2400
    {
2085
      /* Set the DMA capture callbacks */
2401
      /* Set the DMA capture callbacks */
Line 2088... Line 2404...
2088
 
2404
 
2089
      /* Set the DMA error callback */
2405
      /* Set the DMA error callback */
2090
      htim->hdma[TIM_DMA_ID_CC1]->XferErrorCallback = TIM_DMAError ;
2406
      htim->hdma[TIM_DMA_ID_CC1]->XferErrorCallback = TIM_DMAError ;
2091
 
2407
 
2092
      /* Enable the DMA channel */
2408
      /* Enable the DMA channel */
2093
      if (HAL_DMA_Start_IT(htim->hdma[TIM_DMA_ID_CC1], (uint32_t)&htim->Instance->CCR1, (uint32_t)pData, Length) != HAL_OK)
2409
      if (HAL_DMA_Start_IT(htim->hdma[TIM_DMA_ID_CC1], (uint32_t)&htim->Instance->CCR1, (uint32_t)pData,
-
 
2410
                           Length) != HAL_OK)
2094
      {
2411
      {
-
 
2412
        /* Return error status */
2095
        return HAL_ERROR;
2413
        return HAL_ERROR;
2096
      }
2414
      }
2097
      /* Enable the TIM Capture/Compare 1 DMA request */
2415
      /* Enable the TIM Capture/Compare 1 DMA request */
2098
      __HAL_TIM_ENABLE_DMA(htim, TIM_DMA_CC1);
2416
      __HAL_TIM_ENABLE_DMA(htim, TIM_DMA_CC1);
2099
      break;
2417
      break;
Line 2107... Line 2425...
2107
 
2425
 
2108
      /* Set the DMA error callback */
2426
      /* Set the DMA error callback */
2109
      htim->hdma[TIM_DMA_ID_CC2]->XferErrorCallback = TIM_DMAError ;
2427
      htim->hdma[TIM_DMA_ID_CC2]->XferErrorCallback = TIM_DMAError ;
2110
 
2428
 
2111
      /* Enable the DMA channel */
2429
      /* Enable the DMA channel */
2112
      if (HAL_DMA_Start_IT(htim->hdma[TIM_DMA_ID_CC2], (uint32_t)&htim->Instance->CCR2, (uint32_t)pData, Length) != HAL_OK)
2430
      if (HAL_DMA_Start_IT(htim->hdma[TIM_DMA_ID_CC2], (uint32_t)&htim->Instance->CCR2, (uint32_t)pData,
-
 
2431
                           Length) != HAL_OK)
2113
      {
2432
      {
-
 
2433
        /* Return error status */
2114
        return HAL_ERROR;
2434
        return HAL_ERROR;
2115
      }
2435
      }
2116
      /* Enable the TIM Capture/Compare 2  DMA request */
2436
      /* Enable the TIM Capture/Compare 2  DMA request */
2117
      __HAL_TIM_ENABLE_DMA(htim, TIM_DMA_CC2);
2437
      __HAL_TIM_ENABLE_DMA(htim, TIM_DMA_CC2);
2118
      break;
2438
      break;
Line 2126... Line 2446...
2126
 
2446
 
2127
      /* Set the DMA error callback */
2447
      /* Set the DMA error callback */
2128
      htim->hdma[TIM_DMA_ID_CC3]->XferErrorCallback = TIM_DMAError ;
2448
      htim->hdma[TIM_DMA_ID_CC3]->XferErrorCallback = TIM_DMAError ;
2129
 
2449
 
2130
      /* Enable the DMA channel */
2450
      /* Enable the DMA channel */
2131
      if (HAL_DMA_Start_IT(htim->hdma[TIM_DMA_ID_CC3], (uint32_t)&htim->Instance->CCR3, (uint32_t)pData, Length) != HAL_OK)
2451
      if (HAL_DMA_Start_IT(htim->hdma[TIM_DMA_ID_CC3], (uint32_t)&htim->Instance->CCR3, (uint32_t)pData,
-
 
2452
                           Length) != HAL_OK)
2132
      {
2453
      {
-
 
2454
        /* Return error status */
2133
        return HAL_ERROR;
2455
        return HAL_ERROR;
2134
      }
2456
      }
2135
      /* Enable the TIM Capture/Compare 3  DMA request */
2457
      /* Enable the TIM Capture/Compare 3  DMA request */
2136
      __HAL_TIM_ENABLE_DMA(htim, TIM_DMA_CC3);
2458
      __HAL_TIM_ENABLE_DMA(htim, TIM_DMA_CC3);
2137
      break;
2459
      break;
Line 2145... Line 2467...
2145
 
2467
 
2146
      /* Set the DMA error callback */
2468
      /* Set the DMA error callback */
2147
      htim->hdma[TIM_DMA_ID_CC4]->XferErrorCallback = TIM_DMAError ;
2469
      htim->hdma[TIM_DMA_ID_CC4]->XferErrorCallback = TIM_DMAError ;
2148
 
2470
 
2149
      /* Enable the DMA channel */
2471
      /* Enable the DMA channel */
2150
      if (HAL_DMA_Start_IT(htim->hdma[TIM_DMA_ID_CC4], (uint32_t)&htim->Instance->CCR4, (uint32_t)pData, Length) != HAL_OK)
2472
      if (HAL_DMA_Start_IT(htim->hdma[TIM_DMA_ID_CC4], (uint32_t)&htim->Instance->CCR4, (uint32_t)pData,
-
 
2473
                           Length) != HAL_OK)
2151
      {
2474
      {
-
 
2475
        /* Return error status */
2152
        return HAL_ERROR;
2476
        return HAL_ERROR;
2153
      }
2477
      }
2154
      /* Enable the TIM Capture/Compare 4  DMA request */
2478
      /* Enable the TIM Capture/Compare 4  DMA request */
2155
      __HAL_TIM_ENABLE_DMA(htim, TIM_DMA_CC4);
2479
      __HAL_TIM_ENABLE_DMA(htim, TIM_DMA_CC4);
2156
      break;
2480
      break;
2157
    }
2481
    }
2158
 
2482
 
2159
    default:
2483
    default:
-
 
2484
      status = HAL_ERROR;
2160
      break;
2485
      break;
2161
  }
2486
  }
2162
 
2487
 
2163
  /* Enable the Input Capture channel */
-
 
2164
  TIM_CCxChannelCmd(htim->Instance, Channel, TIM_CCx_ENABLE);
-
 
2165
 
-
 
2166
  /* Enable the Peripheral, except in trigger mode where enable is automatically done with trigger */
2488
  /* Enable the Peripheral, except in trigger mode where enable is automatically done with trigger */
-
 
2489
  if (IS_TIM_SLAVE_INSTANCE(htim->Instance))
-
 
2490
  {
2167
  tmpsmcr = htim->Instance->SMCR & TIM_SMCR_SMS;
2491
    tmpsmcr = htim->Instance->SMCR & TIM_SMCR_SMS;
2168
  if (!IS_TIM_SLAVEMODE_TRIGGER_ENABLED(tmpsmcr))
2492
    if (!IS_TIM_SLAVEMODE_TRIGGER_ENABLED(tmpsmcr))
-
 
2493
    {
-
 
2494
      __HAL_TIM_ENABLE(htim);
-
 
2495
    }
-
 
2496
  }
-
 
2497
  else
2169
  {
2498
  {
2170
    __HAL_TIM_ENABLE(htim);
2499
    __HAL_TIM_ENABLE(htim);
2171
  }
2500
  }
2172
 
2501
 
2173
  /* Return function status */
2502
  /* Return function status */
2174
  return HAL_OK;
2503
  return status;
2175
}
2504
}
2176
 
2505
 
2177
/**
2506
/**
2178
  * @brief  Stops the TIM Input Capture measurement in DMA mode.
2507
  * @brief  Stops the TIM Input Capture measurement in DMA mode.
2179
  * @param  htim TIM Input Capture handle
2508
  * @param  htim TIM Input Capture handle
Line 2185... Line 2514...
2185
  *            @arg TIM_CHANNEL_4: TIM Channel 4 selected
2514
  *            @arg TIM_CHANNEL_4: TIM Channel 4 selected
2186
  * @retval HAL status
2515
  * @retval HAL status
2187
  */
2516
  */
2188
HAL_StatusTypeDef HAL_TIM_IC_Stop_DMA(TIM_HandleTypeDef *htim, uint32_t Channel)
2517
HAL_StatusTypeDef HAL_TIM_IC_Stop_DMA(TIM_HandleTypeDef *htim, uint32_t Channel)
2189
{
2518
{
-
 
2519
  HAL_StatusTypeDef status = HAL_OK;
-
 
2520
 
2190
  /* Check the parameters */
2521
  /* Check the parameters */
2191
  assert_param(IS_TIM_CCX_INSTANCE(htim->Instance, Channel));
2522
  assert_param(IS_TIM_CCX_INSTANCE(htim->Instance, Channel));
2192
  assert_param(IS_TIM_DMA_CC_INSTANCE(htim->Instance));
2523
  assert_param(IS_TIM_DMA_CC_INSTANCE(htim->Instance));
2193
 
2524
 
-
 
2525
  /* Disable the Input Capture channel */
-
 
2526
  TIM_CCxChannelCmd(htim->Instance, Channel, TIM_CCx_DISABLE);
-
 
2527
 
2194
  switch (Channel)
2528
  switch (Channel)
2195
  {
2529
  {
2196
    case TIM_CHANNEL_1:
2530
    case TIM_CHANNEL_1:
2197
    {
2531
    {
2198
      /* Disable the TIM Capture/Compare 1 DMA request */
2532
      /* Disable the TIM Capture/Compare 1 DMA request */
Line 2224... Line 2558...
2224
      (void)HAL_DMA_Abort_IT(htim->hdma[TIM_DMA_ID_CC4]);
2558
      (void)HAL_DMA_Abort_IT(htim->hdma[TIM_DMA_ID_CC4]);
2225
      break;
2559
      break;
2226
    }
2560
    }
2227
 
2561
 
2228
    default:
2562
    default:
-
 
2563
      status = HAL_ERROR;
2229
      break;
2564
      break;
2230
  }
2565
  }
2231
 
2566
 
2232
  /* Disable the Input Capture channel */
2567
  if (status == HAL_OK)
2233
  TIM_CCxChannelCmd(htim->Instance, Channel, TIM_CCx_DISABLE);
-
 
2234
 
2568
  {
2235
  /* Disable the Peripheral */
2569
    /* Disable the Peripheral */
2236
  __HAL_TIM_DISABLE(htim);
2570
    __HAL_TIM_DISABLE(htim);
2237
 
2571
 
2238
  /* Change the htim state */
2572
    /* Set the TIM channel state */
2239
  htim->State = HAL_TIM_STATE_READY;
2573
    TIM_CHANNEL_STATE_SET(htim, Channel, HAL_TIM_CHANNEL_STATE_READY);
-
 
2574
    TIM_CHANNEL_N_STATE_SET(htim, Channel, HAL_TIM_CHANNEL_STATE_READY);
-
 
2575
  }
2240
 
2576
 
2241
  /* Return function status */
2577
  /* Return function status */
2242
  return HAL_OK;
2578
  return status;
2243
}
2579
}
2244
/**
2580
/**
2245
  * @}
2581
  * @}
2246
  */
2582
  */
2247
 
2583
 
Line 2271... Line 2607...
2271
  *         parameters in the TIM_HandleTypeDef and initializes the associated handle.
2607
  *         parameters in the TIM_HandleTypeDef and initializes the associated handle.
2272
  * @note   Switching from Center Aligned counter mode to Edge counter mode (or reverse)
2608
  * @note   Switching from Center Aligned counter mode to Edge counter mode (or reverse)
2273
  *         requires a timer reset to avoid unexpected direction
2609
  *         requires a timer reset to avoid unexpected direction
2274
  *         due to DIR bit readonly in center aligned mode.
2610
  *         due to DIR bit readonly in center aligned mode.
2275
  *         Ex: call @ref HAL_TIM_OnePulse_DeInit() before HAL_TIM_OnePulse_Init()
2611
  *         Ex: call @ref HAL_TIM_OnePulse_DeInit() before HAL_TIM_OnePulse_Init()
-
 
2612
  * @note   When the timer instance is initialized in One Pulse mode, timer
-
 
2613
  *         channels 1 and channel 2 are reserved and cannot be used for other
-
 
2614
  *         purpose.
2276
  * @param  htim TIM One Pulse handle
2615
  * @param  htim TIM One Pulse handle
2277
  * @param  OnePulseMode Select the One pulse mode.
2616
  * @param  OnePulseMode Select the One pulse mode.
2278
  *         This parameter can be one of the following values:
2617
  *         This parameter can be one of the following values:
2279
  *            @arg TIM_OPMODE_SINGLE: Only one pulse will be generated.
2618
  *            @arg TIM_OPMODE_SINGLE: Only one pulse will be generated.
2280
  *            @arg TIM_OPMODE_REPETITIVE: Repetitive pulses will be generated.
2619
  *            @arg TIM_OPMODE_REPETITIVE: Repetitive pulses will be generated.
Line 2326... Line 2665...
2326
  htim->Instance->CR1 &= ~TIM_CR1_OPM;
2665
  htim->Instance->CR1 &= ~TIM_CR1_OPM;
2327
 
2666
 
2328
  /* Configure the OPM Mode */
2667
  /* Configure the OPM Mode */
2329
  htim->Instance->CR1 |= OnePulseMode;
2668
  htim->Instance->CR1 |= OnePulseMode;
2330
 
2669
 
-
 
2670
  /* Initialize the DMA burst operation state */
-
 
2671
  htim->DMABurstState = HAL_DMA_BURST_STATE_READY;
-
 
2672
 
-
 
2673
  /* Initialize the TIM channels state */
-
 
2674
  TIM_CHANNEL_STATE_SET(htim, TIM_CHANNEL_1, HAL_TIM_CHANNEL_STATE_READY);
-
 
2675
  TIM_CHANNEL_STATE_SET(htim, TIM_CHANNEL_2, HAL_TIM_CHANNEL_STATE_READY);
-
 
2676
  TIM_CHANNEL_N_STATE_SET(htim, TIM_CHANNEL_1, HAL_TIM_CHANNEL_STATE_READY);
-
 
2677
  TIM_CHANNEL_N_STATE_SET(htim, TIM_CHANNEL_2, HAL_TIM_CHANNEL_STATE_READY);
-
 
2678
 
2331
  /* Initialize the TIM state*/
2679
  /* Initialize the TIM state*/
2332
  htim->State = HAL_TIM_STATE_READY;
2680
  htim->State = HAL_TIM_STATE_READY;
2333
 
2681
 
2334
  return HAL_OK;
2682
  return HAL_OK;
2335
}
2683
}
Line 2359... Line 2707...
2359
#else
2707
#else
2360
  /* DeInit the low level hardware: GPIO, CLOCK, NVIC */
2708
  /* DeInit the low level hardware: GPIO, CLOCK, NVIC */
2361
  HAL_TIM_OnePulse_MspDeInit(htim);
2709
  HAL_TIM_OnePulse_MspDeInit(htim);
2362
#endif /* USE_HAL_TIM_REGISTER_CALLBACKS */
2710
#endif /* USE_HAL_TIM_REGISTER_CALLBACKS */
2363
 
2711
 
-
 
2712
  /* Change the DMA burst operation state */
-
 
2713
  htim->DMABurstState = HAL_DMA_BURST_STATE_RESET;
-
 
2714
 
-
 
2715
  /* Set the TIM channel state */
-
 
2716
  TIM_CHANNEL_STATE_SET(htim, TIM_CHANNEL_1, HAL_TIM_CHANNEL_STATE_RESET);
-
 
2717
  TIM_CHANNEL_STATE_SET(htim, TIM_CHANNEL_2, HAL_TIM_CHANNEL_STATE_RESET);
-
 
2718
  TIM_CHANNEL_N_STATE_SET(htim, TIM_CHANNEL_1, HAL_TIM_CHANNEL_STATE_RESET);
-
 
2719
  TIM_CHANNEL_N_STATE_SET(htim, TIM_CHANNEL_2, HAL_TIM_CHANNEL_STATE_RESET);
-
 
2720
 
2364
  /* Change TIM state */
2721
  /* Change TIM state */
2365
  htim->State = HAL_TIM_STATE_RESET;
2722
  htim->State = HAL_TIM_STATE_RESET;
2366
 
2723
 
2367
  /* Release Lock */
2724
  /* Release Lock */
2368
  __HAL_UNLOCK(htim);
2725
  __HAL_UNLOCK(htim);
Line 2400... Line 2757...
2400
   */
2757
   */
2401
}
2758
}
2402
 
2759
 
2403
/**
2760
/**
2404
  * @brief  Starts the TIM One Pulse signal generation.
2761
  * @brief  Starts the TIM One Pulse signal generation.
-
 
2762
  * @note Though OutputChannel parameter is deprecated and ignored by the function
-
 
2763
  *        it has been kept to avoid HAL_TIM API compatibility break.
-
 
2764
  * @note The pulse output channel is determined when calling
-
 
2765
  *       @ref HAL_TIM_OnePulse_ConfigChannel().
2405
  * @param  htim TIM One Pulse handle
2766
  * @param  htim TIM One Pulse handle
2406
  * @param  OutputChannel TIM Channels to be enabled
2767
  * @param  OutputChannel See note above
2407
  *          This parameter can be one of the following values:
-
 
2408
  *            @arg TIM_CHANNEL_1: TIM Channel 1 selected
-
 
2409
  *            @arg TIM_CHANNEL_2: TIM Channel 2 selected
-
 
2410
  * @retval HAL status
2768
  * @retval HAL status
2411
  */
2769
  */
2412
HAL_StatusTypeDef HAL_TIM_OnePulse_Start(TIM_HandleTypeDef *htim, uint32_t OutputChannel)
2770
HAL_StatusTypeDef HAL_TIM_OnePulse_Start(TIM_HandleTypeDef *htim, uint32_t OutputChannel)
2413
{
2771
{
-
 
2772
  HAL_TIM_ChannelStateTypeDef channel_1_state = TIM_CHANNEL_STATE_GET(htim, TIM_CHANNEL_1);
-
 
2773
  HAL_TIM_ChannelStateTypeDef channel_2_state = TIM_CHANNEL_STATE_GET(htim, TIM_CHANNEL_2);
-
 
2774
  HAL_TIM_ChannelStateTypeDef complementary_channel_1_state = TIM_CHANNEL_N_STATE_GET(htim, TIM_CHANNEL_1);
-
 
2775
  HAL_TIM_ChannelStateTypeDef complementary_channel_2_state = TIM_CHANNEL_N_STATE_GET(htim, TIM_CHANNEL_2);
-
 
2776
 
2414
  /* Prevent unused argument(s) compilation warning */
2777
  /* Prevent unused argument(s) compilation warning */
2415
  UNUSED(OutputChannel);
2778
  UNUSED(OutputChannel);
2416
 
2779
 
-
 
2780
  /* Check the TIM channels state */
-
 
2781
  if ((channel_1_state != HAL_TIM_CHANNEL_STATE_READY)
-
 
2782
      || (channel_2_state != HAL_TIM_CHANNEL_STATE_READY)
-
 
2783
      || (complementary_channel_1_state != HAL_TIM_CHANNEL_STATE_READY)
-
 
2784
      || (complementary_channel_2_state != HAL_TIM_CHANNEL_STATE_READY))
-
 
2785
  {
-
 
2786
    return HAL_ERROR;
-
 
2787
  }
-
 
2788
 
-
 
2789
  /* Set the TIM channels state */
-
 
2790
  TIM_CHANNEL_STATE_SET(htim, TIM_CHANNEL_1, HAL_TIM_CHANNEL_STATE_BUSY);
-
 
2791
  TIM_CHANNEL_STATE_SET(htim, TIM_CHANNEL_2, HAL_TIM_CHANNEL_STATE_BUSY);
-
 
2792
  TIM_CHANNEL_N_STATE_SET(htim, TIM_CHANNEL_1, HAL_TIM_CHANNEL_STATE_BUSY);
-
 
2793
  TIM_CHANNEL_N_STATE_SET(htim, TIM_CHANNEL_2, HAL_TIM_CHANNEL_STATE_BUSY);
-
 
2794
 
2417
  /* Enable the Capture compare and the Input Capture channels
2795
  /* Enable the Capture compare and the Input Capture channels
2418
    (in the OPM Mode the two possible channels that can be used are TIM_CHANNEL_1 and TIM_CHANNEL_2)
2796
    (in the OPM Mode the two possible channels that can be used are TIM_CHANNEL_1 and TIM_CHANNEL_2)
2419
    if TIM_CHANNEL_1 is used as output, the TIM_CHANNEL_2 will be used as input and
2797
    if TIM_CHANNEL_1 is used as output, the TIM_CHANNEL_2 will be used as input and
2420
    if TIM_CHANNEL_1 is used as input, the TIM_CHANNEL_2 will be used as output
2798
    if TIM_CHANNEL_1 is used as input, the TIM_CHANNEL_2 will be used as output
2421
    in all combinations, the TIM_CHANNEL_1 and TIM_CHANNEL_2 should be enabled together
2799
    whatever the combination, the TIM_CHANNEL_1 and TIM_CHANNEL_2 should be enabled together
2422
 
2800
 
2423
    No need to enable the counter, it's enabled automatically by hardware
2801
    No need to enable the counter, it's enabled automatically by hardware
2424
    (the counter starts in response to a stimulus and generate a pulse */
2802
    (the counter starts in response to a stimulus and generate a pulse */
2425
 
2803
 
2426
  TIM_CCxChannelCmd(htim->Instance, TIM_CHANNEL_1, TIM_CCx_ENABLE);
2804
  TIM_CCxChannelCmd(htim->Instance, TIM_CHANNEL_1, TIM_CCx_ENABLE);
Line 2436... Line 2814...
2436
  return HAL_OK;
2814
  return HAL_OK;
2437
}
2815
}
2438
 
2816
 
2439
/**
2817
/**
2440
  * @brief  Stops the TIM One Pulse signal generation.
2818
  * @brief  Stops the TIM One Pulse signal generation.
-
 
2819
  * @note Though OutputChannel parameter is deprecated and ignored by the function
-
 
2820
  *        it has been kept to avoid HAL_TIM API compatibility break.
-
 
2821
  * @note The pulse output channel is determined when calling
-
 
2822
  *       @ref HAL_TIM_OnePulse_ConfigChannel().
2441
  * @param  htim TIM One Pulse handle
2823
  * @param  htim TIM One Pulse handle
2442
  * @param  OutputChannel TIM Channels to be disable
2824
  * @param  OutputChannel See note above
2443
  *          This parameter can be one of the following values:
-
 
2444
  *            @arg TIM_CHANNEL_1: TIM Channel 1 selected
-
 
2445
  *            @arg TIM_CHANNEL_2: TIM Channel 2 selected
-
 
2446
  * @retval HAL status
2825
  * @retval HAL status
2447
  */
2826
  */
2448
HAL_StatusTypeDef HAL_TIM_OnePulse_Stop(TIM_HandleTypeDef *htim, uint32_t OutputChannel)
2827
HAL_StatusTypeDef HAL_TIM_OnePulse_Stop(TIM_HandleTypeDef *htim, uint32_t OutputChannel)
2449
{
2828
{
2450
  /* Prevent unused argument(s) compilation warning */
2829
  /* Prevent unused argument(s) compilation warning */
Line 2452... Line 2831...
2452
 
2831
 
2453
  /* Disable the Capture compare and the Input Capture channels
2832
  /* Disable the Capture compare and the Input Capture channels
2454
  (in the OPM Mode the two possible channels that can be used are TIM_CHANNEL_1 and TIM_CHANNEL_2)
2833
  (in the OPM Mode the two possible channels that can be used are TIM_CHANNEL_1 and TIM_CHANNEL_2)
2455
  if TIM_CHANNEL_1 is used as output, the TIM_CHANNEL_2 will be used as input and
2834
  if TIM_CHANNEL_1 is used as output, the TIM_CHANNEL_2 will be used as input and
2456
  if TIM_CHANNEL_1 is used as input, the TIM_CHANNEL_2 will be used as output
2835
  if TIM_CHANNEL_1 is used as input, the TIM_CHANNEL_2 will be used as output
2457
  in all combinations, the TIM_CHANNEL_1 and TIM_CHANNEL_2 should be disabled together */
2836
  whatever the combination, the TIM_CHANNEL_1 and TIM_CHANNEL_2 should be disabled together */
2458
 
2837
 
2459
  TIM_CCxChannelCmd(htim->Instance, TIM_CHANNEL_1, TIM_CCx_DISABLE);
2838
  TIM_CCxChannelCmd(htim->Instance, TIM_CHANNEL_1, TIM_CCx_DISABLE);
2460
  TIM_CCxChannelCmd(htim->Instance, TIM_CHANNEL_2, TIM_CCx_DISABLE);
2839
  TIM_CCxChannelCmd(htim->Instance, TIM_CHANNEL_2, TIM_CCx_DISABLE);
2461
 
2840
 
2462
  if (IS_TIM_BREAK_INSTANCE(htim->Instance) != RESET)
2841
  if (IS_TIM_BREAK_INSTANCE(htim->Instance) != RESET)
Line 2466... Line 2845...
2466
  }
2845
  }
2467
 
2846
 
2468
  /* Disable the Peripheral */
2847
  /* Disable the Peripheral */
2469
  __HAL_TIM_DISABLE(htim);
2848
  __HAL_TIM_DISABLE(htim);
2470
 
2849
 
-
 
2850
  /* Set the TIM channels state */
-
 
2851
  TIM_CHANNEL_STATE_SET(htim, TIM_CHANNEL_1, HAL_TIM_CHANNEL_STATE_READY);
-
 
2852
  TIM_CHANNEL_STATE_SET(htim, TIM_CHANNEL_2, HAL_TIM_CHANNEL_STATE_READY);
-
 
2853
  TIM_CHANNEL_N_STATE_SET(htim, TIM_CHANNEL_1, HAL_TIM_CHANNEL_STATE_READY);
-
 
2854
  TIM_CHANNEL_N_STATE_SET(htim, TIM_CHANNEL_2, HAL_TIM_CHANNEL_STATE_READY);
-
 
2855
 
2471
  /* Return function status */
2856
  /* Return function status */
2472
  return HAL_OK;
2857
  return HAL_OK;
2473
}
2858
}
2474
 
2859
 
2475
/**
2860
/**
2476
  * @brief  Starts the TIM One Pulse signal generation in interrupt mode.
2861
  * @brief  Starts the TIM One Pulse signal generation in interrupt mode.
-
 
2862
  * @note Though OutputChannel parameter is deprecated and ignored by the function
-
 
2863
  *        it has been kept to avoid HAL_TIM API compatibility break.
-
 
2864
  * @note The pulse output channel is determined when calling
-
 
2865
  *       @ref HAL_TIM_OnePulse_ConfigChannel().
2477
  * @param  htim TIM One Pulse handle
2866
  * @param  htim TIM One Pulse handle
2478
  * @param  OutputChannel TIM Channels to be enabled
2867
  * @param  OutputChannel See note above
2479
  *          This parameter can be one of the following values:
-
 
2480
  *            @arg TIM_CHANNEL_1: TIM Channel 1 selected
-
 
2481
  *            @arg TIM_CHANNEL_2: TIM Channel 2 selected
-
 
2482
  * @retval HAL status
2868
  * @retval HAL status
2483
  */
2869
  */
2484
HAL_StatusTypeDef HAL_TIM_OnePulse_Start_IT(TIM_HandleTypeDef *htim, uint32_t OutputChannel)
2870
HAL_StatusTypeDef HAL_TIM_OnePulse_Start_IT(TIM_HandleTypeDef *htim, uint32_t OutputChannel)
2485
{
2871
{
-
 
2872
  HAL_TIM_ChannelStateTypeDef channel_1_state = TIM_CHANNEL_STATE_GET(htim, TIM_CHANNEL_1);
-
 
2873
  HAL_TIM_ChannelStateTypeDef channel_2_state = TIM_CHANNEL_STATE_GET(htim, TIM_CHANNEL_2);
-
 
2874
  HAL_TIM_ChannelStateTypeDef complementary_channel_1_state = TIM_CHANNEL_N_STATE_GET(htim, TIM_CHANNEL_1);
-
 
2875
  HAL_TIM_ChannelStateTypeDef complementary_channel_2_state = TIM_CHANNEL_N_STATE_GET(htim, TIM_CHANNEL_2);
-
 
2876
 
2486
  /* Prevent unused argument(s) compilation warning */
2877
  /* Prevent unused argument(s) compilation warning */
2487
  UNUSED(OutputChannel);
2878
  UNUSED(OutputChannel);
2488
 
2879
 
-
 
2880
  /* Check the TIM channels state */
-
 
2881
  if ((channel_1_state != HAL_TIM_CHANNEL_STATE_READY)
-
 
2882
      || (channel_2_state != HAL_TIM_CHANNEL_STATE_READY)
-
 
2883
      || (complementary_channel_1_state != HAL_TIM_CHANNEL_STATE_READY)
-
 
2884
      || (complementary_channel_2_state != HAL_TIM_CHANNEL_STATE_READY))
-
 
2885
  {
-
 
2886
    return HAL_ERROR;
-
 
2887
  }
-
 
2888
 
-
 
2889
  /* Set the TIM channels state */
-
 
2890
  TIM_CHANNEL_STATE_SET(htim, TIM_CHANNEL_1, HAL_TIM_CHANNEL_STATE_BUSY);
-
 
2891
  TIM_CHANNEL_STATE_SET(htim, TIM_CHANNEL_2, HAL_TIM_CHANNEL_STATE_BUSY);
-
 
2892
  TIM_CHANNEL_N_STATE_SET(htim, TIM_CHANNEL_1, HAL_TIM_CHANNEL_STATE_BUSY);
-
 
2893
  TIM_CHANNEL_N_STATE_SET(htim, TIM_CHANNEL_2, HAL_TIM_CHANNEL_STATE_BUSY);
-
 
2894
 
2489
  /* Enable the Capture compare and the Input Capture channels
2895
  /* Enable the Capture compare and the Input Capture channels
2490
    (in the OPM Mode the two possible channels that can be used are TIM_CHANNEL_1 and TIM_CHANNEL_2)
2896
    (in the OPM Mode the two possible channels that can be used are TIM_CHANNEL_1 and TIM_CHANNEL_2)
2491
    if TIM_CHANNEL_1 is used as output, the TIM_CHANNEL_2 will be used as input and
2897
    if TIM_CHANNEL_1 is used as output, the TIM_CHANNEL_2 will be used as input and
2492
    if TIM_CHANNEL_1 is used as input, the TIM_CHANNEL_2 will be used as output
2898
    if TIM_CHANNEL_1 is used as input, the TIM_CHANNEL_2 will be used as output
2493
    in all combinations, the TIM_CHANNEL_1 and TIM_CHANNEL_2 should be enabled together
2899
    whatever the combination, the TIM_CHANNEL_1 and TIM_CHANNEL_2 should be enabled together
2494
 
2900
 
2495
    No need to enable the counter, it's enabled automatically by hardware
2901
    No need to enable the counter, it's enabled automatically by hardware
2496
    (the counter starts in response to a stimulus and generate a pulse */
2902
    (the counter starts in response to a stimulus and generate a pulse */
2497
 
2903
 
2498
  /* Enable the TIM Capture/Compare 1 interrupt */
2904
  /* Enable the TIM Capture/Compare 1 interrupt */
Line 2514... Line 2920...
2514
  return HAL_OK;
2920
  return HAL_OK;
2515
}
2921
}
2516
 
2922
 
2517
/**
2923
/**
2518
  * @brief  Stops the TIM One Pulse signal generation in interrupt mode.
2924
  * @brief  Stops the TIM One Pulse signal generation in interrupt mode.
-
 
2925
  * @note Though OutputChannel parameter is deprecated and ignored by the function
-
 
2926
  *        it has been kept to avoid HAL_TIM API compatibility break.
-
 
2927
  * @note The pulse output channel is determined when calling
-
 
2928
  *       @ref HAL_TIM_OnePulse_ConfigChannel().
2519
  * @param  htim TIM One Pulse handle
2929
  * @param  htim TIM One Pulse handle
2520
  * @param  OutputChannel TIM Channels to be enabled
2930
  * @param  OutputChannel See note above
2521
  *          This parameter can be one of the following values:
-
 
2522
  *            @arg TIM_CHANNEL_1: TIM Channel 1 selected
-
 
2523
  *            @arg TIM_CHANNEL_2: TIM Channel 2 selected
-
 
2524
  * @retval HAL status
2931
  * @retval HAL status
2525
  */
2932
  */
2526
HAL_StatusTypeDef HAL_TIM_OnePulse_Stop_IT(TIM_HandleTypeDef *htim, uint32_t OutputChannel)
2933
HAL_StatusTypeDef HAL_TIM_OnePulse_Stop_IT(TIM_HandleTypeDef *htim, uint32_t OutputChannel)
2527
{
2934
{
2528
  /* Prevent unused argument(s) compilation warning */
2935
  /* Prevent unused argument(s) compilation warning */
Line 2536... Line 2943...
2536
 
2943
 
2537
  /* Disable the Capture compare and the Input Capture channels
2944
  /* Disable the Capture compare and the Input Capture channels
2538
  (in the OPM Mode the two possible channels that can be used are TIM_CHANNEL_1 and TIM_CHANNEL_2)
2945
  (in the OPM Mode the two possible channels that can be used are TIM_CHANNEL_1 and TIM_CHANNEL_2)
2539
  if TIM_CHANNEL_1 is used as output, the TIM_CHANNEL_2 will be used as input and
2946
  if TIM_CHANNEL_1 is used as output, the TIM_CHANNEL_2 will be used as input and
2540
  if TIM_CHANNEL_1 is used as input, the TIM_CHANNEL_2 will be used as output
2947
  if TIM_CHANNEL_1 is used as input, the TIM_CHANNEL_2 will be used as output
2541
  in all combinations, the TIM_CHANNEL_1 and TIM_CHANNEL_2 should be disabled together */
2948
  whatever the combination, the TIM_CHANNEL_1 and TIM_CHANNEL_2 should be disabled together */
2542
  TIM_CCxChannelCmd(htim->Instance, TIM_CHANNEL_1, TIM_CCx_DISABLE);
2949
  TIM_CCxChannelCmd(htim->Instance, TIM_CHANNEL_1, TIM_CCx_DISABLE);
2543
  TIM_CCxChannelCmd(htim->Instance, TIM_CHANNEL_2, TIM_CCx_DISABLE);
2950
  TIM_CCxChannelCmd(htim->Instance, TIM_CHANNEL_2, TIM_CCx_DISABLE);
2544
 
2951
 
2545
  if (IS_TIM_BREAK_INSTANCE(htim->Instance) != RESET)
2952
  if (IS_TIM_BREAK_INSTANCE(htim->Instance) != RESET)
2546
  {
2953
  {
Line 2549... Line 2956...
2549
  }
2956
  }
2550
 
2957
 
2551
  /* Disable the Peripheral */
2958
  /* Disable the Peripheral */
2552
  __HAL_TIM_DISABLE(htim);
2959
  __HAL_TIM_DISABLE(htim);
2553
 
2960
 
-
 
2961
  /* Set the TIM channels state */
-
 
2962
  TIM_CHANNEL_STATE_SET(htim, TIM_CHANNEL_1, HAL_TIM_CHANNEL_STATE_READY);
-
 
2963
  TIM_CHANNEL_STATE_SET(htim, TIM_CHANNEL_2, HAL_TIM_CHANNEL_STATE_READY);
-
 
2964
  TIM_CHANNEL_N_STATE_SET(htim, TIM_CHANNEL_1, HAL_TIM_CHANNEL_STATE_READY);
-
 
2965
  TIM_CHANNEL_N_STATE_SET(htim, TIM_CHANNEL_2, HAL_TIM_CHANNEL_STATE_READY);
-
 
2966
 
2554
  /* Return function status */
2967
  /* Return function status */
2555
  return HAL_OK;
2968
  return HAL_OK;
2556
}
2969
}
2557
 
2970
 
2558
/**
2971
/**
Line 2587... Line 3000...
2587
  *         due to DIR bit readonly in center aligned mode.
3000
  *         due to DIR bit readonly in center aligned mode.
2588
  *         Ex: call @ref HAL_TIM_Encoder_DeInit() before HAL_TIM_Encoder_Init()
3001
  *         Ex: call @ref HAL_TIM_Encoder_DeInit() before HAL_TIM_Encoder_Init()
2589
  * @note   Encoder mode and External clock mode 2 are not compatible and must not be selected together
3002
  * @note   Encoder mode and External clock mode 2 are not compatible and must not be selected together
2590
  *         Ex: A call for @ref HAL_TIM_Encoder_Init will erase the settings of @ref HAL_TIM_ConfigClockSource
3003
  *         Ex: A call for @ref HAL_TIM_Encoder_Init will erase the settings of @ref HAL_TIM_ConfigClockSource
2591
  *         using TIM_CLOCKSOURCE_ETRMODE2 and vice versa
3004
  *         using TIM_CLOCKSOURCE_ETRMODE2 and vice versa
-
 
3005
  * @note   When the timer instance is initialized in Encoder mode, timer
-
 
3006
  *         channels 1 and channel 2 are reserved and cannot be used for other
-
 
3007
  *         purpose.
2592
  * @param  htim TIM Encoder Interface handle
3008
  * @param  htim TIM Encoder Interface handle
2593
  * @param  sConfig TIM Encoder Interface configuration structure
3009
  * @param  sConfig TIM Encoder Interface configuration structure
2594
  * @retval HAL status
3010
  * @retval HAL status
2595
  */
3011
  */
2596
HAL_StatusTypeDef HAL_TIM_Encoder_Init(TIM_HandleTypeDef *htim,  TIM_Encoder_InitTypeDef *sConfig)
3012
HAL_StatusTypeDef HAL_TIM_Encoder_Init(TIM_HandleTypeDef *htim,  TIM_Encoder_InitTypeDef *sConfig)
Line 2604... Line 3020...
2604
  {
3020
  {
2605
    return HAL_ERROR;
3021
    return HAL_ERROR;
2606
  }
3022
  }
2607
 
3023
 
2608
  /* Check the parameters */
3024
  /* Check the parameters */
-
 
3025
  assert_param(IS_TIM_ENCODER_INTERFACE_INSTANCE(htim->Instance));
2609
  assert_param(IS_TIM_COUNTER_MODE(htim->Init.CounterMode));
3026
  assert_param(IS_TIM_COUNTER_MODE(htim->Init.CounterMode));
2610
  assert_param(IS_TIM_CLOCKDIVISION_DIV(htim->Init.ClockDivision));
3027
  assert_param(IS_TIM_CLOCKDIVISION_DIV(htim->Init.ClockDivision));
2611
  assert_param(IS_TIM_AUTORELOAD_PRELOAD(htim->Init.AutoReloadPreload));
3028
  assert_param(IS_TIM_AUTORELOAD_PRELOAD(htim->Init.AutoReloadPreload));
2612
  assert_param(IS_TIM_CC2_INSTANCE(htim->Instance));
-
 
2613
  assert_param(IS_TIM_ENCODER_MODE(sConfig->EncoderMode));
3029
  assert_param(IS_TIM_ENCODER_MODE(sConfig->EncoderMode));
2614
  assert_param(IS_TIM_IC_SELECTION(sConfig->IC1Selection));
3030
  assert_param(IS_TIM_IC_SELECTION(sConfig->IC1Selection));
2615
  assert_param(IS_TIM_IC_SELECTION(sConfig->IC2Selection));
3031
  assert_param(IS_TIM_IC_SELECTION(sConfig->IC2Selection));
2616
  assert_param(IS_TIM_ENCODERINPUT_POLARITY(sConfig->IC1Polarity));
3032
  assert_param(IS_TIM_ENCODERINPUT_POLARITY(sConfig->IC1Polarity));
2617
  assert_param(IS_TIM_ENCODERINPUT_POLARITY(sConfig->IC2Polarity));
3033
  assert_param(IS_TIM_ENCODERINPUT_POLARITY(sConfig->IC2Polarity));
Line 2684... Line 3100...
2684
  htim->Instance->CCMR1 = tmpccmr1;
3100
  htim->Instance->CCMR1 = tmpccmr1;
2685
 
3101
 
2686
  /* Write to TIMx CCER */
3102
  /* Write to TIMx CCER */
2687
  htim->Instance->CCER = tmpccer;
3103
  htim->Instance->CCER = tmpccer;
2688
 
3104
 
-
 
3105
  /* Initialize the DMA burst operation state */
-
 
3106
  htim->DMABurstState = HAL_DMA_BURST_STATE_READY;
-
 
3107
 
-
 
3108
  /* Set the TIM channels state */
-
 
3109
  TIM_CHANNEL_STATE_SET(htim, TIM_CHANNEL_1, HAL_TIM_CHANNEL_STATE_READY);
-
 
3110
  TIM_CHANNEL_STATE_SET(htim, TIM_CHANNEL_2, HAL_TIM_CHANNEL_STATE_READY);
-
 
3111
  TIM_CHANNEL_N_STATE_SET(htim, TIM_CHANNEL_1, HAL_TIM_CHANNEL_STATE_READY);
-
 
3112
  TIM_CHANNEL_N_STATE_SET(htim, TIM_CHANNEL_2, HAL_TIM_CHANNEL_STATE_READY);
-
 
3113
 
2689
  /* Initialize the TIM state*/
3114
  /* Initialize the TIM state*/
2690
  htim->State = HAL_TIM_STATE_READY;
3115
  htim->State = HAL_TIM_STATE_READY;
2691
 
3116
 
2692
  return HAL_OK;
3117
  return HAL_OK;
2693
}
3118
}
Line 2718... Line 3143...
2718
#else
3143
#else
2719
  /* DeInit the low level hardware: GPIO, CLOCK, NVIC */
3144
  /* DeInit the low level hardware: GPIO, CLOCK, NVIC */
2720
  HAL_TIM_Encoder_MspDeInit(htim);
3145
  HAL_TIM_Encoder_MspDeInit(htim);
2721
#endif /* USE_HAL_TIM_REGISTER_CALLBACKS */
3146
#endif /* USE_HAL_TIM_REGISTER_CALLBACKS */
2722
 
3147
 
-
 
3148
  /* Change the DMA burst operation state */
-
 
3149
  htim->DMABurstState = HAL_DMA_BURST_STATE_RESET;
-
 
3150
 
-
 
3151
  /* Set the TIM channels state */
-
 
3152
  TIM_CHANNEL_STATE_SET(htim, TIM_CHANNEL_1, HAL_TIM_CHANNEL_STATE_RESET);
-
 
3153
  TIM_CHANNEL_STATE_SET(htim, TIM_CHANNEL_2, HAL_TIM_CHANNEL_STATE_RESET);
-
 
3154
  TIM_CHANNEL_N_STATE_SET(htim, TIM_CHANNEL_1, HAL_TIM_CHANNEL_STATE_RESET);
-
 
3155
  TIM_CHANNEL_N_STATE_SET(htim, TIM_CHANNEL_2, HAL_TIM_CHANNEL_STATE_RESET);
-
 
3156
 
2723
  /* Change TIM state */
3157
  /* Change TIM state */
2724
  htim->State = HAL_TIM_STATE_RESET;
3158
  htim->State = HAL_TIM_STATE_RESET;
2725
 
3159
 
2726
  /* Release Lock */
3160
  /* Release Lock */
2727
  __HAL_UNLOCK(htim);
3161
  __HAL_UNLOCK(htim);
Line 2769... Line 3203...
2769
  *            @arg TIM_CHANNEL_ALL: TIM Channel 1 and TIM Channel 2 are selected
3203
  *            @arg TIM_CHANNEL_ALL: TIM Channel 1 and TIM Channel 2 are selected
2770
  * @retval HAL status
3204
  * @retval HAL status
2771
  */
3205
  */
2772
HAL_StatusTypeDef HAL_TIM_Encoder_Start(TIM_HandleTypeDef *htim, uint32_t Channel)
3206
HAL_StatusTypeDef HAL_TIM_Encoder_Start(TIM_HandleTypeDef *htim, uint32_t Channel)
2773
{
3207
{
-
 
3208
  HAL_TIM_ChannelStateTypeDef channel_1_state = TIM_CHANNEL_STATE_GET(htim, TIM_CHANNEL_1);
-
 
3209
  HAL_TIM_ChannelStateTypeDef channel_2_state = TIM_CHANNEL_STATE_GET(htim, TIM_CHANNEL_2);
-
 
3210
  HAL_TIM_ChannelStateTypeDef complementary_channel_1_state = TIM_CHANNEL_N_STATE_GET(htim, TIM_CHANNEL_1);
-
 
3211
  HAL_TIM_ChannelStateTypeDef complementary_channel_2_state = TIM_CHANNEL_N_STATE_GET(htim, TIM_CHANNEL_2);
-
 
3212
 
2774
  /* Check the parameters */
3213
  /* Check the parameters */
2775
  assert_param(IS_TIM_CC2_INSTANCE(htim->Instance));
3214
  assert_param(IS_TIM_ENCODER_INTERFACE_INSTANCE(htim->Instance));
-
 
3215
 
-
 
3216
  /* Set the TIM channel(s) state */
-
 
3217
  if (Channel == TIM_CHANNEL_1)
-
 
3218
  {
-
 
3219
    if ((channel_1_state != HAL_TIM_CHANNEL_STATE_READY)
-
 
3220
        || (complementary_channel_1_state != HAL_TIM_CHANNEL_STATE_READY))
-
 
3221
    {
-
 
3222
      return HAL_ERROR;
-
 
3223
    }
-
 
3224
    else
-
 
3225
    {
-
 
3226
      TIM_CHANNEL_STATE_SET(htim, TIM_CHANNEL_1, HAL_TIM_CHANNEL_STATE_BUSY);
-
 
3227
      TIM_CHANNEL_N_STATE_SET(htim, TIM_CHANNEL_1, HAL_TIM_CHANNEL_STATE_BUSY);
-
 
3228
    }
-
 
3229
  }
-
 
3230
  else if (Channel == TIM_CHANNEL_2)
-
 
3231
  {
-
 
3232
    if ((channel_2_state != HAL_TIM_CHANNEL_STATE_READY)
-
 
3233
        || (complementary_channel_2_state != HAL_TIM_CHANNEL_STATE_READY))
-
 
3234
    {
-
 
3235
      return HAL_ERROR;
-
 
3236
    }
-
 
3237
    else
-
 
3238
    {
-
 
3239
      TIM_CHANNEL_STATE_SET(htim, TIM_CHANNEL_2, HAL_TIM_CHANNEL_STATE_BUSY);
-
 
3240
      TIM_CHANNEL_N_STATE_SET(htim, TIM_CHANNEL_2, HAL_TIM_CHANNEL_STATE_BUSY);
-
 
3241
    }
-
 
3242
  }
-
 
3243
  else
-
 
3244
  {
-
 
3245
    if ((channel_1_state != HAL_TIM_CHANNEL_STATE_READY)
-
 
3246
        || (channel_2_state != HAL_TIM_CHANNEL_STATE_READY)
-
 
3247
        || (complementary_channel_1_state != HAL_TIM_CHANNEL_STATE_READY)
-
 
3248
        || (complementary_channel_2_state != HAL_TIM_CHANNEL_STATE_READY))
-
 
3249
    {
-
 
3250
      return HAL_ERROR;
-
 
3251
    }
-
 
3252
    else
-
 
3253
    {
-
 
3254
      TIM_CHANNEL_STATE_SET(htim, TIM_CHANNEL_1, HAL_TIM_CHANNEL_STATE_BUSY);
-
 
3255
      TIM_CHANNEL_STATE_SET(htim, TIM_CHANNEL_2, HAL_TIM_CHANNEL_STATE_BUSY);
-
 
3256
      TIM_CHANNEL_N_STATE_SET(htim, TIM_CHANNEL_1, HAL_TIM_CHANNEL_STATE_BUSY);
-
 
3257
      TIM_CHANNEL_N_STATE_SET(htim, TIM_CHANNEL_2, HAL_TIM_CHANNEL_STATE_BUSY);
-
 
3258
    }
-
 
3259
  }
2776
 
3260
 
2777
  /* Enable the encoder interface channels */
3261
  /* Enable the encoder interface channels */
2778
  switch (Channel)
3262
  switch (Channel)
2779
  {
3263
  {
2780
    case TIM_CHANNEL_1:
3264
    case TIM_CHANNEL_1:
Line 2814... Line 3298...
2814
  * @retval HAL status
3298
  * @retval HAL status
2815
  */
3299
  */
2816
HAL_StatusTypeDef HAL_TIM_Encoder_Stop(TIM_HandleTypeDef *htim, uint32_t Channel)
3300
HAL_StatusTypeDef HAL_TIM_Encoder_Stop(TIM_HandleTypeDef *htim, uint32_t Channel)
2817
{
3301
{
2818
  /* Check the parameters */
3302
  /* Check the parameters */
2819
  assert_param(IS_TIM_CC2_INSTANCE(htim->Instance));
3303
  assert_param(IS_TIM_ENCODER_INTERFACE_INSTANCE(htim->Instance));
2820
 
3304
 
2821
  /* Disable the Input Capture channels 1 and 2
3305
  /* Disable the Input Capture channels 1 and 2
2822
    (in the EncoderInterface the two possible channels that can be used are TIM_CHANNEL_1 and TIM_CHANNEL_2) */
3306
    (in the EncoderInterface the two possible channels that can be used are TIM_CHANNEL_1 and TIM_CHANNEL_2) */
2823
  switch (Channel)
3307
  switch (Channel)
2824
  {
3308
  {
Line 2843... Line 3327...
2843
  }
3327
  }
2844
 
3328
 
2845
  /* Disable the Peripheral */
3329
  /* Disable the Peripheral */
2846
  __HAL_TIM_DISABLE(htim);
3330
  __HAL_TIM_DISABLE(htim);
2847
 
3331
 
-
 
3332
  /* Set the TIM channel(s) state */
-
 
3333
  if ((Channel == TIM_CHANNEL_1) || (Channel == TIM_CHANNEL_2))
-
 
3334
  {
-
 
3335
    TIM_CHANNEL_STATE_SET(htim, Channel, HAL_TIM_CHANNEL_STATE_READY);
-
 
3336
    TIM_CHANNEL_N_STATE_SET(htim, Channel, HAL_TIM_CHANNEL_STATE_READY);
-
 
3337
  }
-
 
3338
  else
-
 
3339
  {
-
 
3340
    TIM_CHANNEL_STATE_SET(htim, TIM_CHANNEL_1, HAL_TIM_CHANNEL_STATE_READY);
-
 
3341
    TIM_CHANNEL_STATE_SET(htim, TIM_CHANNEL_2, HAL_TIM_CHANNEL_STATE_READY);
-
 
3342
    TIM_CHANNEL_N_STATE_SET(htim, TIM_CHANNEL_1, HAL_TIM_CHANNEL_STATE_READY);
-
 
3343
    TIM_CHANNEL_N_STATE_SET(htim, TIM_CHANNEL_2, HAL_TIM_CHANNEL_STATE_READY);
-
 
3344
  }
-
 
3345
 
2848
  /* Return function status */
3346
  /* Return function status */
2849
  return HAL_OK;
3347
  return HAL_OK;
2850
}
3348
}
2851
 
3349
 
2852
/**
3350
/**
Line 2859... Line 3357...
2859
  *            @arg TIM_CHANNEL_ALL: TIM Channel 1 and TIM Channel 2 are selected
3357
  *            @arg TIM_CHANNEL_ALL: TIM Channel 1 and TIM Channel 2 are selected
2860
  * @retval HAL status
3358
  * @retval HAL status
2861
  */
3359
  */
2862
HAL_StatusTypeDef HAL_TIM_Encoder_Start_IT(TIM_HandleTypeDef *htim, uint32_t Channel)
3360
HAL_StatusTypeDef HAL_TIM_Encoder_Start_IT(TIM_HandleTypeDef *htim, uint32_t Channel)
2863
{
3361
{
-
 
3362
  HAL_TIM_ChannelStateTypeDef channel_1_state = TIM_CHANNEL_STATE_GET(htim, TIM_CHANNEL_1);
-
 
3363
  HAL_TIM_ChannelStateTypeDef channel_2_state = TIM_CHANNEL_STATE_GET(htim, TIM_CHANNEL_2);
-
 
3364
  HAL_TIM_ChannelStateTypeDef complementary_channel_1_state = TIM_CHANNEL_N_STATE_GET(htim, TIM_CHANNEL_1);
-
 
3365
  HAL_TIM_ChannelStateTypeDef complementary_channel_2_state = TIM_CHANNEL_N_STATE_GET(htim, TIM_CHANNEL_2);
-
 
3366
 
2864
  /* Check the parameters */
3367
  /* Check the parameters */
2865
  assert_param(IS_TIM_CC2_INSTANCE(htim->Instance));
3368
  assert_param(IS_TIM_ENCODER_INTERFACE_INSTANCE(htim->Instance));
-
 
3369
 
-
 
3370
  /* Set the TIM channel(s) state */
-
 
3371
  if (Channel == TIM_CHANNEL_1)
-
 
3372
  {
-
 
3373
    if ((channel_1_state != HAL_TIM_CHANNEL_STATE_READY)
-
 
3374
        || (complementary_channel_1_state != HAL_TIM_CHANNEL_STATE_READY))
-
 
3375
    {
-
 
3376
      return HAL_ERROR;
-
 
3377
    }
-
 
3378
    else
-
 
3379
    {
-
 
3380
      TIM_CHANNEL_STATE_SET(htim, TIM_CHANNEL_1, HAL_TIM_CHANNEL_STATE_BUSY);
-
 
3381
      TIM_CHANNEL_N_STATE_SET(htim, TIM_CHANNEL_1, HAL_TIM_CHANNEL_STATE_BUSY);
-
 
3382
    }
-
 
3383
  }
-
 
3384
  else if (Channel == TIM_CHANNEL_2)
-
 
3385
  {
-
 
3386
    if ((channel_2_state != HAL_TIM_CHANNEL_STATE_READY)
-
 
3387
        || (complementary_channel_2_state != HAL_TIM_CHANNEL_STATE_READY))
-
 
3388
    {
-
 
3389
      return HAL_ERROR;
-
 
3390
    }
-
 
3391
    else
-
 
3392
    {
-
 
3393
      TIM_CHANNEL_STATE_SET(htim, TIM_CHANNEL_2, HAL_TIM_CHANNEL_STATE_BUSY);
-
 
3394
      TIM_CHANNEL_N_STATE_SET(htim, TIM_CHANNEL_2, HAL_TIM_CHANNEL_STATE_BUSY);
-
 
3395
    }
-
 
3396
  }
-
 
3397
  else
-
 
3398
  {
-
 
3399
    if ((channel_1_state != HAL_TIM_CHANNEL_STATE_READY)
-
 
3400
        || (channel_2_state != HAL_TIM_CHANNEL_STATE_READY)
-
 
3401
        || (complementary_channel_1_state != HAL_TIM_CHANNEL_STATE_READY)
-
 
3402
        || (complementary_channel_2_state != HAL_TIM_CHANNEL_STATE_READY))
-
 
3403
    {
-
 
3404
      return HAL_ERROR;
-
 
3405
    }
-
 
3406
    else
-
 
3407
    {
-
 
3408
      TIM_CHANNEL_STATE_SET(htim, TIM_CHANNEL_1, HAL_TIM_CHANNEL_STATE_BUSY);
-
 
3409
      TIM_CHANNEL_STATE_SET(htim, TIM_CHANNEL_2, HAL_TIM_CHANNEL_STATE_BUSY);
-
 
3410
      TIM_CHANNEL_N_STATE_SET(htim, TIM_CHANNEL_1, HAL_TIM_CHANNEL_STATE_BUSY);
-
 
3411
      TIM_CHANNEL_N_STATE_SET(htim, TIM_CHANNEL_2, HAL_TIM_CHANNEL_STATE_BUSY);
-
 
3412
    }
-
 
3413
  }
2866
 
3414
 
2867
  /* Enable the encoder interface channels */
3415
  /* Enable the encoder interface channels */
2868
  /* Enable the capture compare Interrupts 1 and/or 2 */
3416
  /* Enable the capture compare Interrupts 1 and/or 2 */
2869
  switch (Channel)
3417
  switch (Channel)
2870
  {
3418
  {
Line 2910... Line 3458...
2910
  * @retval HAL status
3458
  * @retval HAL status
2911
  */
3459
  */
2912
HAL_StatusTypeDef HAL_TIM_Encoder_Stop_IT(TIM_HandleTypeDef *htim, uint32_t Channel)
3460
HAL_StatusTypeDef HAL_TIM_Encoder_Stop_IT(TIM_HandleTypeDef *htim, uint32_t Channel)
2913
{
3461
{
2914
  /* Check the parameters */
3462
  /* Check the parameters */
2915
  assert_param(IS_TIM_CC2_INSTANCE(htim->Instance));
3463
  assert_param(IS_TIM_ENCODER_INTERFACE_INSTANCE(htim->Instance));
2916
 
3464
 
2917
  /* Disable the Input Capture channels 1 and 2
3465
  /* Disable the Input Capture channels 1 and 2
2918
    (in the EncoderInterface the two possible channels that can be used are TIM_CHANNEL_1 and TIM_CHANNEL_2) */
3466
    (in the EncoderInterface the two possible channels that can be used are TIM_CHANNEL_1 and TIM_CHANNEL_2) */
2919
  if (Channel == TIM_CHANNEL_1)
3467
  if (Channel == TIM_CHANNEL_1)
2920
  {
3468
  {
Line 2941... Line 3489...
2941
  }
3489
  }
2942
 
3490
 
2943
  /* Disable the Peripheral */
3491
  /* Disable the Peripheral */
2944
  __HAL_TIM_DISABLE(htim);
3492
  __HAL_TIM_DISABLE(htim);
2945
 
3493
 
2946
  /* Change the htim state */
3494
  /* Set the TIM channel(s) state */
-
 
3495
  if ((Channel == TIM_CHANNEL_1) || (Channel == TIM_CHANNEL_2))
-
 
3496
  {
2947
  htim->State = HAL_TIM_STATE_READY;
3497
    TIM_CHANNEL_STATE_SET(htim, Channel, HAL_TIM_CHANNEL_STATE_READY);
-
 
3498
    TIM_CHANNEL_N_STATE_SET(htim, Channel, HAL_TIM_CHANNEL_STATE_READY);
-
 
3499
  }
-
 
3500
  else
-
 
3501
  {
-
 
3502
    TIM_CHANNEL_STATE_SET(htim, TIM_CHANNEL_1, HAL_TIM_CHANNEL_STATE_READY);
-
 
3503
    TIM_CHANNEL_STATE_SET(htim, TIM_CHANNEL_2, HAL_TIM_CHANNEL_STATE_READY);
-
 
3504
    TIM_CHANNEL_N_STATE_SET(htim, TIM_CHANNEL_1, HAL_TIM_CHANNEL_STATE_READY);
-
 
3505
    TIM_CHANNEL_N_STATE_SET(htim, TIM_CHANNEL_2, HAL_TIM_CHANNEL_STATE_READY);
-
 
3506
  }
2948
 
3507
 
2949
  /* Return function status */
3508
  /* Return function status */
2950
  return HAL_OK;
3509
  return HAL_OK;
2951
}
3510
}
2952
 
3511
 
Line 2964... Line 3523...
2964
  * @retval HAL status
3523
  * @retval HAL status
2965
  */
3524
  */
2966
HAL_StatusTypeDef HAL_TIM_Encoder_Start_DMA(TIM_HandleTypeDef *htim, uint32_t Channel, uint32_t *pData1,
3525
HAL_StatusTypeDef HAL_TIM_Encoder_Start_DMA(TIM_HandleTypeDef *htim, uint32_t Channel, uint32_t *pData1,
2967
                                            uint32_t *pData2, uint16_t Length)
3526
                                            uint32_t *pData2, uint16_t Length)
2968
{
3527
{
-
 
3528
  HAL_TIM_ChannelStateTypeDef channel_1_state = TIM_CHANNEL_STATE_GET(htim, TIM_CHANNEL_1);
-
 
3529
  HAL_TIM_ChannelStateTypeDef channel_2_state = TIM_CHANNEL_STATE_GET(htim, TIM_CHANNEL_2);
-
 
3530
  HAL_TIM_ChannelStateTypeDef complementary_channel_1_state = TIM_CHANNEL_N_STATE_GET(htim, TIM_CHANNEL_1);
-
 
3531
  HAL_TIM_ChannelStateTypeDef complementary_channel_2_state = TIM_CHANNEL_N_STATE_GET(htim, TIM_CHANNEL_2);
-
 
3532
 
2969
  /* Check the parameters */
3533
  /* Check the parameters */
2970
  assert_param(IS_TIM_DMA_CC_INSTANCE(htim->Instance));
3534
  assert_param(IS_TIM_ENCODER_INTERFACE_INSTANCE(htim->Instance));
2971
 
3535
 
-
 
3536
  /* Set the TIM channel(s) state */
2972
  if (htim->State == HAL_TIM_STATE_BUSY)
3537
  if (Channel == TIM_CHANNEL_1)
2973
  {
3538
  {
-
 
3539
    if ((channel_1_state == HAL_TIM_CHANNEL_STATE_BUSY)
-
 
3540
        || (complementary_channel_1_state == HAL_TIM_CHANNEL_STATE_BUSY))
-
 
3541
    {
2974
    return HAL_BUSY;
3542
      return HAL_BUSY;
-
 
3543
    }
-
 
3544
    else if ((channel_1_state == HAL_TIM_CHANNEL_STATE_READY)
-
 
3545
             && (complementary_channel_1_state == HAL_TIM_CHANNEL_STATE_READY))
-
 
3546
    {
-
 
3547
      if ((pData1 == NULL) && (Length > 0U))
-
 
3548
      {
-
 
3549
        return HAL_ERROR;
-
 
3550
      }
-
 
3551
      else
-
 
3552
      {
-
 
3553
        TIM_CHANNEL_STATE_SET(htim, TIM_CHANNEL_1, HAL_TIM_CHANNEL_STATE_BUSY);
-
 
3554
        TIM_CHANNEL_N_STATE_SET(htim, TIM_CHANNEL_1, HAL_TIM_CHANNEL_STATE_BUSY);
-
 
3555
      }
-
 
3556
    }
-
 
3557
    else
-
 
3558
    {
-
 
3559
      return HAL_ERROR;
-
 
3560
    }
2975
  }
3561
  }
2976
  else if (htim->State == HAL_TIM_STATE_READY)
3562
  else if (Channel == TIM_CHANNEL_2)
2977
  {
3563
  {
2978
    if ((((pData1 == NULL) || (pData2 == NULL))) && (Length > 0U))
3564
    if ((channel_2_state == HAL_TIM_CHANNEL_STATE_BUSY)
-
 
3565
        || (complementary_channel_2_state == HAL_TIM_CHANNEL_STATE_BUSY))
2979
    {
3566
    {
-
 
3567
      return HAL_BUSY;
-
 
3568
    }
-
 
3569
    else if ((channel_2_state == HAL_TIM_CHANNEL_STATE_READY)
-
 
3570
             && (complementary_channel_2_state == HAL_TIM_CHANNEL_STATE_READY))
-
 
3571
    {
-
 
3572
      if ((pData2 == NULL) && (Length > 0U))
-
 
3573
      {
2980
      return HAL_ERROR;
3574
        return HAL_ERROR;
-
 
3575
      }
-
 
3576
      else
-
 
3577
      {
-
 
3578
        TIM_CHANNEL_STATE_SET(htim, TIM_CHANNEL_2, HAL_TIM_CHANNEL_STATE_BUSY);
-
 
3579
        TIM_CHANNEL_N_STATE_SET(htim, TIM_CHANNEL_2, HAL_TIM_CHANNEL_STATE_BUSY);
-
 
3580
      }
2981
    }
3581
    }
2982
    else
3582
    else
2983
    {
3583
    {
2984
      htim->State = HAL_TIM_STATE_BUSY;
3584
      return HAL_ERROR;
2985
    }
3585
    }
2986
  }
3586
  }
2987
  else
3587
  else
2988
  {
3588
  {
-
 
3589
    if ((channel_1_state == HAL_TIM_CHANNEL_STATE_BUSY)
-
 
3590
        || (channel_2_state == HAL_TIM_CHANNEL_STATE_BUSY)
-
 
3591
        || (complementary_channel_1_state == HAL_TIM_CHANNEL_STATE_BUSY)
-
 
3592
        || (complementary_channel_2_state == HAL_TIM_CHANNEL_STATE_BUSY))
-
 
3593
    {
2989
    /* nothing to do */
3594
      return HAL_BUSY;
-
 
3595
    }
-
 
3596
    else if ((channel_1_state == HAL_TIM_CHANNEL_STATE_READY)
-
 
3597
             && (channel_2_state == HAL_TIM_CHANNEL_STATE_READY)
-
 
3598
             && (complementary_channel_1_state == HAL_TIM_CHANNEL_STATE_READY)
-
 
3599
             && (complementary_channel_2_state == HAL_TIM_CHANNEL_STATE_READY))
-
 
3600
    {
-
 
3601
      if ((((pData1 == NULL) || (pData2 == NULL))) && (Length > 0U))
-
 
3602
      {
-
 
3603
        return HAL_ERROR;
-
 
3604
      }
-
 
3605
      else
-
 
3606
      {
-
 
3607
        TIM_CHANNEL_STATE_SET(htim, TIM_CHANNEL_1, HAL_TIM_CHANNEL_STATE_BUSY);
-
 
3608
        TIM_CHANNEL_STATE_SET(htim, TIM_CHANNEL_2, HAL_TIM_CHANNEL_STATE_BUSY);
-
 
3609
        TIM_CHANNEL_N_STATE_SET(htim, TIM_CHANNEL_1, HAL_TIM_CHANNEL_STATE_BUSY);
-
 
3610
        TIM_CHANNEL_N_STATE_SET(htim, TIM_CHANNEL_2, HAL_TIM_CHANNEL_STATE_BUSY);
-
 
3611
      }
-
 
3612
    }
-
 
3613
    else
-
 
3614
    {
-
 
3615
      return HAL_ERROR;
-
 
3616
    }
2990
  }
3617
  }
2991
 
3618
 
2992
  switch (Channel)
3619
  switch (Channel)
2993
  {
3620
  {
2994
    case TIM_CHANNEL_1:
3621
    case TIM_CHANNEL_1:
Line 2999... Line 3626...
2999
 
3626
 
3000
      /* Set the DMA error callback */
3627
      /* Set the DMA error callback */
3001
      htim->hdma[TIM_DMA_ID_CC1]->XferErrorCallback = TIM_DMAError ;
3628
      htim->hdma[TIM_DMA_ID_CC1]->XferErrorCallback = TIM_DMAError ;
3002
 
3629
 
3003
      /* Enable the DMA channel */
3630
      /* Enable the DMA channel */
3004
      if (HAL_DMA_Start_IT(htim->hdma[TIM_DMA_ID_CC1], (uint32_t)&htim->Instance->CCR1, (uint32_t)pData1, Length) != HAL_OK)
3631
      if (HAL_DMA_Start_IT(htim->hdma[TIM_DMA_ID_CC1], (uint32_t)&htim->Instance->CCR1, (uint32_t)pData1,
-
 
3632
                           Length) != HAL_OK)
3005
      {
3633
      {
-
 
3634
        /* Return error status */
3006
        return HAL_ERROR;
3635
        return HAL_ERROR;
3007
      }
3636
      }
3008
      /* Enable the TIM Input Capture DMA request */
3637
      /* Enable the TIM Input Capture DMA request */
3009
      __HAL_TIM_ENABLE_DMA(htim, TIM_DMA_CC1);
3638
      __HAL_TIM_ENABLE_DMA(htim, TIM_DMA_CC1);
3010
 
3639
 
-
 
3640
      /* Enable the Capture compare channel */
-
 
3641
      TIM_CCxChannelCmd(htim->Instance, TIM_CHANNEL_1, TIM_CCx_ENABLE);
-
 
3642
 
3011
      /* Enable the Peripheral */
3643
      /* Enable the Peripheral */
3012
      __HAL_TIM_ENABLE(htim);
3644
      __HAL_TIM_ENABLE(htim);
3013
 
3645
 
3014
      /* Enable the Capture compare channel */
-
 
3015
      TIM_CCxChannelCmd(htim->Instance, TIM_CHANNEL_1, TIM_CCx_ENABLE);
-
 
3016
      break;
3646
      break;
3017
    }
3647
    }
3018
 
3648
 
3019
    case TIM_CHANNEL_2:
3649
    case TIM_CHANNEL_2:
3020
    {
3650
    {
Line 3023... Line 3653...
3023
      htim->hdma[TIM_DMA_ID_CC2]->XferHalfCpltCallback = TIM_DMACaptureHalfCplt;
3653
      htim->hdma[TIM_DMA_ID_CC2]->XferHalfCpltCallback = TIM_DMACaptureHalfCplt;
3024
 
3654
 
3025
      /* Set the DMA error callback */
3655
      /* Set the DMA error callback */
3026
      htim->hdma[TIM_DMA_ID_CC2]->XferErrorCallback = TIM_DMAError;
3656
      htim->hdma[TIM_DMA_ID_CC2]->XferErrorCallback = TIM_DMAError;
3027
      /* Enable the DMA channel */
3657
      /* Enable the DMA channel */
3028
      if (HAL_DMA_Start_IT(htim->hdma[TIM_DMA_ID_CC2], (uint32_t)&htim->Instance->CCR2, (uint32_t)pData2, Length) != HAL_OK)
3658
      if (HAL_DMA_Start_IT(htim->hdma[TIM_DMA_ID_CC2], (uint32_t)&htim->Instance->CCR2, (uint32_t)pData2,
-
 
3659
                           Length) != HAL_OK)
3029
      {
3660
      {
-
 
3661
        /* Return error status */
3030
        return HAL_ERROR;
3662
        return HAL_ERROR;
3031
      }
3663
      }
3032
      /* Enable the TIM Input Capture  DMA request */
3664
      /* Enable the TIM Input Capture  DMA request */
3033
      __HAL_TIM_ENABLE_DMA(htim, TIM_DMA_CC2);
3665
      __HAL_TIM_ENABLE_DMA(htim, TIM_DMA_CC2);
3034
 
3666
 
-
 
3667
      /* Enable the Capture compare channel */
-
 
3668
      TIM_CCxChannelCmd(htim->Instance, TIM_CHANNEL_2, TIM_CCx_ENABLE);
-
 
3669
 
3035
      /* Enable the Peripheral */
3670
      /* Enable the Peripheral */
3036
      __HAL_TIM_ENABLE(htim);
3671
      __HAL_TIM_ENABLE(htim);
3037
 
3672
 
3038
      /* Enable the Capture compare channel */
-
 
3039
      TIM_CCxChannelCmd(htim->Instance, TIM_CHANNEL_2, TIM_CCx_ENABLE);
-
 
3040
      break;
3673
      break;
3041
    }
3674
    }
3042
 
3675
 
3043
    case TIM_CHANNEL_ALL:
3676
    default:
3044
    {
3677
    {
3045
      /* Set the DMA capture callbacks */
3678
      /* Set the DMA capture callbacks */
3046
      htim->hdma[TIM_DMA_ID_CC1]->XferCpltCallback = TIM_DMACaptureCplt;
3679
      htim->hdma[TIM_DMA_ID_CC1]->XferCpltCallback = TIM_DMACaptureCplt;
3047
      htim->hdma[TIM_DMA_ID_CC1]->XferHalfCpltCallback = TIM_DMACaptureHalfCplt;
3680
      htim->hdma[TIM_DMA_ID_CC1]->XferHalfCpltCallback = TIM_DMACaptureHalfCplt;
3048
 
3681
 
3049
      /* Set the DMA error callback */
3682
      /* Set the DMA error callback */
3050
      htim->hdma[TIM_DMA_ID_CC1]->XferErrorCallback = TIM_DMAError ;
3683
      htim->hdma[TIM_DMA_ID_CC1]->XferErrorCallback = TIM_DMAError ;
3051
 
3684
 
3052
      /* Enable the DMA channel */
3685
      /* Enable the DMA channel */
3053
      if (HAL_DMA_Start_IT(htim->hdma[TIM_DMA_ID_CC1], (uint32_t)&htim->Instance->CCR1, (uint32_t)pData1, Length) != HAL_OK)
3686
      if (HAL_DMA_Start_IT(htim->hdma[TIM_DMA_ID_CC1], (uint32_t)&htim->Instance->CCR1, (uint32_t)pData1,
-
 
3687
                           Length) != HAL_OK)
3054
      {
3688
      {
-
 
3689
        /* Return error status */
3055
        return HAL_ERROR;
3690
        return HAL_ERROR;
3056
      }
3691
      }
3057
 
3692
 
3058
      /* Set the DMA capture callbacks */
3693
      /* Set the DMA capture callbacks */
3059
      htim->hdma[TIM_DMA_ID_CC2]->XferCpltCallback = TIM_DMACaptureCplt;
3694
      htim->hdma[TIM_DMA_ID_CC2]->XferCpltCallback = TIM_DMACaptureCplt;
Line 3061... Line 3696...
3061
 
3696
 
3062
      /* Set the DMA error callback */
3697
      /* Set the DMA error callback */
3063
      htim->hdma[TIM_DMA_ID_CC2]->XferErrorCallback = TIM_DMAError ;
3698
      htim->hdma[TIM_DMA_ID_CC2]->XferErrorCallback = TIM_DMAError ;
3064
 
3699
 
3065
      /* Enable the DMA channel */
3700
      /* Enable the DMA channel */
3066
      if (HAL_DMA_Start_IT(htim->hdma[TIM_DMA_ID_CC2], (uint32_t)&htim->Instance->CCR2, (uint32_t)pData2, Length) != HAL_OK)
3701
      if (HAL_DMA_Start_IT(htim->hdma[TIM_DMA_ID_CC2], (uint32_t)&htim->Instance->CCR2, (uint32_t)pData2,
-
 
3702
                           Length) != HAL_OK)
3067
      {
3703
      {
-
 
3704
        /* Return error status */
3068
        return HAL_ERROR;
3705
        return HAL_ERROR;
3069
      }
3706
      }
3070
      /* Enable the Peripheral */
-
 
3071
      __HAL_TIM_ENABLE(htim);
-
 
3072
 
-
 
3073
      /* Enable the Capture compare channel */
-
 
3074
      TIM_CCxChannelCmd(htim->Instance, TIM_CHANNEL_1, TIM_CCx_ENABLE);
-
 
3075
      TIM_CCxChannelCmd(htim->Instance, TIM_CHANNEL_2, TIM_CCx_ENABLE);
-
 
3076
 
3707
 
3077
      /* Enable the TIM Input Capture  DMA request */
3708
      /* Enable the TIM Input Capture  DMA request */
3078
      __HAL_TIM_ENABLE_DMA(htim, TIM_DMA_CC1);
3709
      __HAL_TIM_ENABLE_DMA(htim, TIM_DMA_CC1);
3079
      /* Enable the TIM Input Capture  DMA request */
3710
      /* Enable the TIM Input Capture  DMA request */
3080
      __HAL_TIM_ENABLE_DMA(htim, TIM_DMA_CC2);
3711
      __HAL_TIM_ENABLE_DMA(htim, TIM_DMA_CC2);
3081
      break;
-
 
3082
    }
-
 
3083
 
3712
 
-
 
3713
      /* Enable the Capture compare channel */
-
 
3714
      TIM_CCxChannelCmd(htim->Instance, TIM_CHANNEL_1, TIM_CCx_ENABLE);
-
 
3715
      TIM_CCxChannelCmd(htim->Instance, TIM_CHANNEL_2, TIM_CCx_ENABLE);
-
 
3716
 
3084
    default:
3717
      /* Enable the Peripheral */
-
 
3718
      __HAL_TIM_ENABLE(htim);
-
 
3719
 
3085
      break;
3720
      break;
-
 
3721
    }
3086
  }
3722
  }
-
 
3723
 
3087
  /* Return function status */
3724
  /* Return function status */
3088
  return HAL_OK;
3725
  return HAL_OK;
3089
}
3726
}
3090
 
3727
 
3091
/**
3728
/**
Line 3099... Line 3736...
3099
  * @retval HAL status
3736
  * @retval HAL status
3100
  */
3737
  */
3101
HAL_StatusTypeDef HAL_TIM_Encoder_Stop_DMA(TIM_HandleTypeDef *htim, uint32_t Channel)
3738
HAL_StatusTypeDef HAL_TIM_Encoder_Stop_DMA(TIM_HandleTypeDef *htim, uint32_t Channel)
3102
{
3739
{
3103
  /* Check the parameters */
3740
  /* Check the parameters */
3104
  assert_param(IS_TIM_DMA_CC_INSTANCE(htim->Instance));
3741
  assert_param(IS_TIM_ENCODER_INTERFACE_INSTANCE(htim->Instance));
3105
 
3742
 
3106
  /* Disable the Input Capture channels 1 and 2
3743
  /* Disable the Input Capture channels 1 and 2
3107
    (in the EncoderInterface the two possible channels that can be used are TIM_CHANNEL_1 and TIM_CHANNEL_2) */
3744
    (in the EncoderInterface the two possible channels that can be used are TIM_CHANNEL_1 and TIM_CHANNEL_2) */
3108
  if (Channel == TIM_CHANNEL_1)
3745
  if (Channel == TIM_CHANNEL_1)
3109
  {
3746
  {
Line 3134... Line 3771...
3134
  }
3771
  }
3135
 
3772
 
3136
  /* Disable the Peripheral */
3773
  /* Disable the Peripheral */
3137
  __HAL_TIM_DISABLE(htim);
3774
  __HAL_TIM_DISABLE(htim);
3138
 
3775
 
3139
  /* Change the htim state */
3776
  /* Set the TIM channel(s) state */
-
 
3777
  if ((Channel == TIM_CHANNEL_1) || (Channel == TIM_CHANNEL_2))
-
 
3778
  {
3140
  htim->State = HAL_TIM_STATE_READY;
3779
    TIM_CHANNEL_STATE_SET(htim, Channel, HAL_TIM_CHANNEL_STATE_READY);
-
 
3780
    TIM_CHANNEL_N_STATE_SET(htim, Channel, HAL_TIM_CHANNEL_STATE_READY);
-
 
3781
  }
-
 
3782
  else
-
 
3783
  {
-
 
3784
    TIM_CHANNEL_STATE_SET(htim, TIM_CHANNEL_1, HAL_TIM_CHANNEL_STATE_READY);
-
 
3785
    TIM_CHANNEL_STATE_SET(htim, TIM_CHANNEL_2, HAL_TIM_CHANNEL_STATE_READY);
-
 
3786
    TIM_CHANNEL_N_STATE_SET(htim, TIM_CHANNEL_1, HAL_TIM_CHANNEL_STATE_READY);
-
 
3787
    TIM_CHANNEL_N_STATE_SET(htim, TIM_CHANNEL_2, HAL_TIM_CHANNEL_STATE_READY);
-
 
3788
  }
3141
 
3789
 
3142
  /* Return function status */
3790
  /* Return function status */
3143
  return HAL_OK;
3791
  return HAL_OK;
3144
}
3792
}
3145
 
3793
 
Line 3381... Line 4029...
3381
  */
4029
  */
3382
HAL_StatusTypeDef HAL_TIM_OC_ConfigChannel(TIM_HandleTypeDef *htim,
4030
HAL_StatusTypeDef HAL_TIM_OC_ConfigChannel(TIM_HandleTypeDef *htim,
3383
                                           TIM_OC_InitTypeDef *sConfig,
4031
                                           TIM_OC_InitTypeDef *sConfig,
3384
                                           uint32_t Channel)
4032
                                           uint32_t Channel)
3385
{
4033
{
-
 
4034
  HAL_StatusTypeDef status = HAL_OK;
-
 
4035
 
3386
  /* Check the parameters */
4036
  /* Check the parameters */
3387
  assert_param(IS_TIM_CHANNELS(Channel));
4037
  assert_param(IS_TIM_CHANNELS(Channel));
3388
  assert_param(IS_TIM_OC_MODE(sConfig->OCMode));
4038
  assert_param(IS_TIM_OC_MODE(sConfig->OCMode));
3389
  assert_param(IS_TIM_OC_POLARITY(sConfig->OCPolarity));
4039
  assert_param(IS_TIM_OC_POLARITY(sConfig->OCPolarity));
3390
 
4040
 
3391
  /* Process Locked */
4041
  /* Process Locked */
3392
  __HAL_LOCK(htim);
4042
  __HAL_LOCK(htim);
3393
 
4043
 
3394
  htim->State = HAL_TIM_STATE_BUSY;
-
 
3395
 
-
 
3396
  switch (Channel)
4044
  switch (Channel)
3397
  {
4045
  {
3398
    case TIM_CHANNEL_1:
4046
    case TIM_CHANNEL_1:
3399
    {
4047
    {
3400
      /* Check the parameters */
4048
      /* Check the parameters */
Line 3434... Line 4082...
3434
      TIM_OC4_SetConfig(htim->Instance, sConfig);
4082
      TIM_OC4_SetConfig(htim->Instance, sConfig);
3435
      break;
4083
      break;
3436
    }
4084
    }
3437
 
4085
 
3438
    default:
4086
    default:
-
 
4087
      status = HAL_ERROR;
3439
      break;
4088
      break;
3440
  }
4089
  }
3441
 
4090
 
3442
  htim->State = HAL_TIM_STATE_READY;
-
 
3443
 
-
 
3444
  __HAL_UNLOCK(htim);
4091
  __HAL_UNLOCK(htim);
3445
 
4092
 
3446
  return HAL_OK;
4093
  return status;
3447
}
4094
}
3448
 
4095
 
3449
/**
4096
/**
3450
  * @brief  Initializes the TIM Input Capture Channels according to the specified
4097
  * @brief  Initializes the TIM Input Capture Channels according to the specified
3451
  *         parameters in the TIM_IC_InitTypeDef.
4098
  *         parameters in the TIM_IC_InitTypeDef.
Line 3459... Line 4106...
3459
  *            @arg TIM_CHANNEL_4: TIM Channel 4 selected
4106
  *            @arg TIM_CHANNEL_4: TIM Channel 4 selected
3460
  * @retval HAL status
4107
  * @retval HAL status
3461
  */
4108
  */
3462
HAL_StatusTypeDef HAL_TIM_IC_ConfigChannel(TIM_HandleTypeDef *htim, TIM_IC_InitTypeDef *sConfig, uint32_t Channel)
4109
HAL_StatusTypeDef HAL_TIM_IC_ConfigChannel(TIM_HandleTypeDef *htim, TIM_IC_InitTypeDef *sConfig, uint32_t Channel)
3463
{
4110
{
-
 
4111
  HAL_StatusTypeDef status = HAL_OK;
-
 
4112
 
3464
  /* Check the parameters */
4113
  /* Check the parameters */
3465
  assert_param(IS_TIM_CC1_INSTANCE(htim->Instance));
4114
  assert_param(IS_TIM_CC1_INSTANCE(htim->Instance));
3466
  assert_param(IS_TIM_IC_POLARITY(sConfig->ICPolarity));
4115
  assert_param(IS_TIM_IC_POLARITY(sConfig->ICPolarity));
3467
  assert_param(IS_TIM_IC_SELECTION(sConfig->ICSelection));
4116
  assert_param(IS_TIM_IC_SELECTION(sConfig->ICSelection));
3468
  assert_param(IS_TIM_IC_PRESCALER(sConfig->ICPrescaler));
4117
  assert_param(IS_TIM_IC_PRESCALER(sConfig->ICPrescaler));
3469
  assert_param(IS_TIM_IC_FILTER(sConfig->ICFilter));
4118
  assert_param(IS_TIM_IC_FILTER(sConfig->ICFilter));
3470
 
4119
 
3471
  /* Process Locked */
4120
  /* Process Locked */
3472
  __HAL_LOCK(htim);
4121
  __HAL_LOCK(htim);
3473
 
4122
 
3474
  htim->State = HAL_TIM_STATE_BUSY;
-
 
3475
 
-
 
3476
  if (Channel == TIM_CHANNEL_1)
4123
  if (Channel == TIM_CHANNEL_1)
3477
  {
4124
  {
3478
    /* TI1 Configuration */
4125
    /* TI1 Configuration */
3479
    TIM_TI1_SetConfig(htim->Instance,
4126
    TIM_TI1_SetConfig(htim->Instance,
3480
                      sConfig->ICPolarity,
4127
                      sConfig->ICPolarity,
Line 3517... Line 4164...
3517
    htim->Instance->CCMR2 &= ~TIM_CCMR2_IC3PSC;
4164
    htim->Instance->CCMR2 &= ~TIM_CCMR2_IC3PSC;
3518
 
4165
 
3519
    /* Set the IC3PSC value */
4166
    /* Set the IC3PSC value */
3520
    htim->Instance->CCMR2 |= sConfig->ICPrescaler;
4167
    htim->Instance->CCMR2 |= sConfig->ICPrescaler;
3521
  }
4168
  }
3522
  else
4169
  else if (Channel == TIM_CHANNEL_4)
3523
  {
4170
  {
3524
    /* TI4 Configuration */
4171
    /* TI4 Configuration */
3525
    assert_param(IS_TIM_CC4_INSTANCE(htim->Instance));
4172
    assert_param(IS_TIM_CC4_INSTANCE(htim->Instance));
3526
 
4173
 
3527
    TIM_TI4_SetConfig(htim->Instance,
4174
    TIM_TI4_SetConfig(htim->Instance,
Line 3533... Line 4180...
3533
    htim->Instance->CCMR2 &= ~TIM_CCMR2_IC4PSC;
4180
    htim->Instance->CCMR2 &= ~TIM_CCMR2_IC4PSC;
3534
 
4181
 
3535
    /* Set the IC4PSC value */
4182
    /* Set the IC4PSC value */
3536
    htim->Instance->CCMR2 |= (sConfig->ICPrescaler << 8U);
4183
    htim->Instance->CCMR2 |= (sConfig->ICPrescaler << 8U);
3537
  }
4184
  }
-
 
4185
  else
3538
 
4186
  {
3539
  htim->State = HAL_TIM_STATE_READY;
4187
    status = HAL_ERROR;
-
 
4188
  }
3540
 
4189
 
3541
  __HAL_UNLOCK(htim);
4190
  __HAL_UNLOCK(htim);
3542
 
4191
 
3543
  return HAL_OK;
4192
  return status;
3544
}
4193
}
3545
 
4194
 
3546
/**
4195
/**
3547
  * @brief  Initializes the TIM PWM  channels according to the specified
4196
  * @brief  Initializes the TIM PWM  channels according to the specified
3548
  *         parameters in the TIM_OC_InitTypeDef.
4197
  *         parameters in the TIM_OC_InitTypeDef.
Line 3558... Line 4207...
3558
  */
4207
  */
3559
HAL_StatusTypeDef HAL_TIM_PWM_ConfigChannel(TIM_HandleTypeDef *htim,
4208
HAL_StatusTypeDef HAL_TIM_PWM_ConfigChannel(TIM_HandleTypeDef *htim,
3560
                                            TIM_OC_InitTypeDef *sConfig,
4209
                                            TIM_OC_InitTypeDef *sConfig,
3561
                                            uint32_t Channel)
4210
                                            uint32_t Channel)
3562
{
4211
{
-
 
4212
  HAL_StatusTypeDef status = HAL_OK;
-
 
4213
 
3563
  /* Check the parameters */
4214
  /* Check the parameters */
3564
  assert_param(IS_TIM_CHANNELS(Channel));
4215
  assert_param(IS_TIM_CHANNELS(Channel));
3565
  assert_param(IS_TIM_PWM_MODE(sConfig->OCMode));
4216
  assert_param(IS_TIM_PWM_MODE(sConfig->OCMode));
3566
  assert_param(IS_TIM_OC_POLARITY(sConfig->OCPolarity));
4217
  assert_param(IS_TIM_OC_POLARITY(sConfig->OCPolarity));
3567
  assert_param(IS_TIM_FAST_STATE(sConfig->OCFastMode));
4218
  assert_param(IS_TIM_FAST_STATE(sConfig->OCFastMode));
3568
 
4219
 
3569
  /* Process Locked */
4220
  /* Process Locked */
3570
  __HAL_LOCK(htim);
4221
  __HAL_LOCK(htim);
3571
 
4222
 
3572
  htim->State = HAL_TIM_STATE_BUSY;
-
 
3573
 
-
 
3574
  switch (Channel)
4223
  switch (Channel)
3575
  {
4224
  {
3576
    case TIM_CHANNEL_1:
4225
    case TIM_CHANNEL_1:
3577
    {
4226
    {
3578
      /* Check the parameters */
4227
      /* Check the parameters */
Line 3640... Line 4289...
3640
      htim->Instance->CCMR2 |= sConfig->OCFastMode << 8U;
4289
      htim->Instance->CCMR2 |= sConfig->OCFastMode << 8U;
3641
      break;
4290
      break;
3642
    }
4291
    }
3643
 
4292
 
3644
    default:
4293
    default:
-
 
4294
      status = HAL_ERROR;
3645
      break;
4295
      break;
3646
  }
4296
  }
3647
 
4297
 
3648
  htim->State = HAL_TIM_STATE_READY;
-
 
3649
 
-
 
3650
  __HAL_UNLOCK(htim);
4298
  __HAL_UNLOCK(htim);
3651
 
4299
 
3652
  return HAL_OK;
4300
  return status;
3653
}
4301
}
3654
 
4302
 
3655
/**
4303
/**
3656
  * @brief  Initializes the TIM One Pulse Channels according to the specified
4304
  * @brief  Initializes the TIM One Pulse Channels according to the specified
3657
  *         parameters in the TIM_OnePulse_InitTypeDef.
4305
  *         parameters in the TIM_OnePulse_InitTypeDef.
Line 3672... Line 4320...
3672
  * @retval HAL status
4320
  * @retval HAL status
3673
  */
4321
  */
3674
HAL_StatusTypeDef HAL_TIM_OnePulse_ConfigChannel(TIM_HandleTypeDef *htim,  TIM_OnePulse_InitTypeDef *sConfig,
4322
HAL_StatusTypeDef HAL_TIM_OnePulse_ConfigChannel(TIM_HandleTypeDef *htim,  TIM_OnePulse_InitTypeDef *sConfig,
3675
                                                 uint32_t OutputChannel,  uint32_t InputChannel)
4323
                                                 uint32_t OutputChannel,  uint32_t InputChannel)
3676
{
4324
{
-
 
4325
  HAL_StatusTypeDef status = HAL_OK;
3677
  TIM_OC_InitTypeDef temp1;
4326
  TIM_OC_InitTypeDef temp1;
3678
 
4327
 
3679
  /* Check the parameters */
4328
  /* Check the parameters */
3680
  assert_param(IS_TIM_OPM_CHANNELS(OutputChannel));
4329
  assert_param(IS_TIM_OPM_CHANNELS(OutputChannel));
3681
  assert_param(IS_TIM_OPM_CHANNELS(InputChannel));
4330
  assert_param(IS_TIM_OPM_CHANNELS(InputChannel));
Line 3702... Line 4351...
3702
        assert_param(IS_TIM_CC1_INSTANCE(htim->Instance));
4351
        assert_param(IS_TIM_CC1_INSTANCE(htim->Instance));
3703
 
4352
 
3704
        TIM_OC1_SetConfig(htim->Instance, &temp1);
4353
        TIM_OC1_SetConfig(htim->Instance, &temp1);
3705
        break;
4354
        break;
3706
      }
4355
      }
-
 
4356
 
3707
      case TIM_CHANNEL_2:
4357
      case TIM_CHANNEL_2:
3708
      {
4358
      {
3709
        assert_param(IS_TIM_CC2_INSTANCE(htim->Instance));
4359
        assert_param(IS_TIM_CC2_INSTANCE(htim->Instance));
3710
 
4360
 
3711
        TIM_OC2_SetConfig(htim->Instance, &temp1);
4361
        TIM_OC2_SetConfig(htim->Instance, &temp1);
3712
        break;
4362
        break;
3713
      }
4363
      }
-
 
4364
 
3714
      default:
4365
      default:
-
 
4366
        status = HAL_ERROR;
3715
        break;
4367
        break;
3716
    }
4368
    }
3717
 
4369
 
3718
    switch (InputChannel)
4370
    if (status == HAL_OK)
3719
    {
4371
    {
3720
      case TIM_CHANNEL_1:
4372
      switch (InputChannel)
3721
      {
4373
      {
-
 
4374
        case TIM_CHANNEL_1:
-
 
4375
        {
3722
        assert_param(IS_TIM_CC1_INSTANCE(htim->Instance));
4376
          assert_param(IS_TIM_CC1_INSTANCE(htim->Instance));
3723
 
4377
 
3724
        TIM_TI1_SetConfig(htim->Instance, sConfig->ICPolarity,
4378
          TIM_TI1_SetConfig(htim->Instance, sConfig->ICPolarity,
3725
                          sConfig->ICSelection, sConfig->ICFilter);
4379
                            sConfig->ICSelection, sConfig->ICFilter);
3726
 
4380
 
3727
        /* Reset the IC1PSC Bits */
4381
          /* Reset the IC1PSC Bits */
3728
        htim->Instance->CCMR1 &= ~TIM_CCMR1_IC1PSC;
4382
          htim->Instance->CCMR1 &= ~TIM_CCMR1_IC1PSC;
3729
 
4383
 
3730
        /* Select the Trigger source */
4384
          /* Select the Trigger source */
3731
        htim->Instance->SMCR &= ~TIM_SMCR_TS;
4385
          htim->Instance->SMCR &= ~TIM_SMCR_TS;
3732
        htim->Instance->SMCR |= TIM_TS_TI1FP1;
4386
          htim->Instance->SMCR |= TIM_TS_TI1FP1;
3733
 
4387
 
3734
        /* Select the Slave Mode */
4388
          /* Select the Slave Mode */
3735
        htim->Instance->SMCR &= ~TIM_SMCR_SMS;
4389
          htim->Instance->SMCR &= ~TIM_SMCR_SMS;
3736
        htim->Instance->SMCR |= TIM_SLAVEMODE_TRIGGER;
4390
          htim->Instance->SMCR |= TIM_SLAVEMODE_TRIGGER;
3737
        break;
4391
          break;
3738
      }
4392
        }
3739
      case TIM_CHANNEL_2:
-
 
3740
      {
-
 
3741
        assert_param(IS_TIM_CC2_INSTANCE(htim->Instance));
-
 
3742
 
4393
 
3743
        TIM_TI2_SetConfig(htim->Instance, sConfig->ICPolarity,
4394
        case TIM_CHANNEL_2:
-
 
4395
        {
3744
                          sConfig->ICSelection, sConfig->ICFilter);
4396
          assert_param(IS_TIM_CC2_INSTANCE(htim->Instance));
3745
 
4397
 
3746
        /* Reset the IC2PSC Bits */
4398
          TIM_TI2_SetConfig(htim->Instance, sConfig->ICPolarity,
3747
        htim->Instance->CCMR1 &= ~TIM_CCMR1_IC2PSC;
4399
                            sConfig->ICSelection, sConfig->ICFilter);
3748
 
4400
 
3749
        /* Select the Trigger source */
-
 
3750
        htim->Instance->SMCR &= ~TIM_SMCR_TS;
-
 
3751
        htim->Instance->SMCR |= TIM_TS_TI2FP2;
-
 
3752
 
-
 
3753
        /* Select the Slave Mode */
4401
          /* Reset the IC2PSC Bits */
3754
        htim->Instance->SMCR &= ~TIM_SMCR_SMS;
4402
          htim->Instance->CCMR1 &= ~TIM_CCMR1_IC2PSC;
3755
        htim->Instance->SMCR |= TIM_SLAVEMODE_TRIGGER;
-
 
3756
        break;
-
 
3757
      }
-
 
3758
 
4403
 
-
 
4404
          /* Select the Trigger source */
-
 
4405
          htim->Instance->SMCR &= ~TIM_SMCR_TS;
-
 
4406
          htim->Instance->SMCR |= TIM_TS_TI2FP2;
-
 
4407
 
-
 
4408
          /* Select the Slave Mode */
-
 
4409
          htim->Instance->SMCR &= ~TIM_SMCR_SMS;
-
 
4410
          htim->Instance->SMCR |= TIM_SLAVEMODE_TRIGGER;
-
 
4411
          break;
-
 
4412
        }
-
 
4413
 
3759
      default:
4414
        default:
-
 
4415
          status = HAL_ERROR;
3760
        break;
4416
          break;
-
 
4417
      }
3761
    }
4418
    }
3762
 
4419
 
3763
    htim->State = HAL_TIM_STATE_READY;
4420
    htim->State = HAL_TIM_STATE_READY;
3764
 
4421
 
3765
    __HAL_UNLOCK(htim);
4422
    __HAL_UNLOCK(htim);
3766
 
4423
 
3767
    return HAL_OK;
4424
    return status;
3768
  }
4425
  }
3769
  else
4426
  else
3770
  {
4427
  {
3771
    return HAL_ERROR;
4428
    return HAL_ERROR;
3772
  }
4429
  }
Line 3811... Line 4468...
3811
  * @retval HAL status
4468
  * @retval HAL status
3812
  */
4469
  */
3813
HAL_StatusTypeDef HAL_TIM_DMABurst_WriteStart(TIM_HandleTypeDef *htim, uint32_t BurstBaseAddress,
4470
HAL_StatusTypeDef HAL_TIM_DMABurst_WriteStart(TIM_HandleTypeDef *htim, uint32_t BurstBaseAddress,
3814
                                              uint32_t BurstRequestSrc, uint32_t *BurstBuffer, uint32_t  BurstLength)
4471
                                              uint32_t BurstRequestSrc, uint32_t *BurstBuffer, uint32_t  BurstLength)
3815
{
4472
{
-
 
4473
  HAL_StatusTypeDef status = HAL_OK;
-
 
4474
 
-
 
4475
  if (status == HAL_OK)
-
 
4476
  {
3816
  return HAL_TIM_DMABurst_MultiWriteStart(htim, BurstBaseAddress, BurstRequestSrc, BurstBuffer, BurstLength,
4477
    status = HAL_TIM_DMABurst_MultiWriteStart(htim, BurstBaseAddress, BurstRequestSrc, BurstBuffer, BurstLength,
3817
                                          ((BurstLength) >> 8U) + 1U);
4478
                                              ((BurstLength) >> 8U) + 1U);
-
 
4479
  }
-
 
4480
 
-
 
4481
 
-
 
4482
  return status;
3818
}
4483
}
3819
 
4484
 
3820
/**
4485
/**
3821
  * @brief  Configure the DMA Burst to transfer multiple Data from the memory to the TIM peripheral
4486
  * @brief  Configure the DMA Burst to transfer multiple Data from the memory to the TIM peripheral
3822
  * @param  htim TIM handle
4487
  * @param  htim TIM handle
Line 3858... Line 4523...
3858
  */
4523
  */
3859
HAL_StatusTypeDef HAL_TIM_DMABurst_MultiWriteStart(TIM_HandleTypeDef *htim, uint32_t BurstBaseAddress,
4524
HAL_StatusTypeDef HAL_TIM_DMABurst_MultiWriteStart(TIM_HandleTypeDef *htim, uint32_t BurstBaseAddress,
3860
                                                   uint32_t BurstRequestSrc, uint32_t *BurstBuffer,
4525
                                                   uint32_t BurstRequestSrc, uint32_t *BurstBuffer,
3861
                                                   uint32_t  BurstLength,  uint32_t  DataLength)
4526
                                                   uint32_t  BurstLength,  uint32_t  DataLength)
3862
{
4527
{
-
 
4528
  HAL_StatusTypeDef status = HAL_OK;
-
 
4529
 
3863
  /* Check the parameters */
4530
  /* Check the parameters */
3864
  assert_param(IS_TIM_DMABURST_INSTANCE(htim->Instance));
4531
  assert_param(IS_TIM_DMABURST_INSTANCE(htim->Instance));
3865
  assert_param(IS_TIM_DMA_BASE(BurstBaseAddress));
4532
  assert_param(IS_TIM_DMA_BASE(BurstBaseAddress));
3866
  assert_param(IS_TIM_DMA_SOURCE(BurstRequestSrc));
4533
  assert_param(IS_TIM_DMA_SOURCE(BurstRequestSrc));
3867
  assert_param(IS_TIM_DMA_LENGTH(BurstLength));
4534
  assert_param(IS_TIM_DMA_LENGTH(BurstLength));
3868
  assert_param(IS_TIM_DMA_DATA_LENGTH(DataLength));
4535
  assert_param(IS_TIM_DMA_DATA_LENGTH(DataLength));
3869
 
4536
 
3870
  if (htim->State == HAL_TIM_STATE_BUSY)
4537
  if (htim->DMABurstState == HAL_DMA_BURST_STATE_BUSY)
3871
  {
4538
  {
3872
    return HAL_BUSY;
4539
    return HAL_BUSY;
3873
  }
4540
  }
3874
  else if (htim->State == HAL_TIM_STATE_READY)
4541
  else if (htim->DMABurstState == HAL_DMA_BURST_STATE_READY)
3875
  {
4542
  {
3876
    if ((BurstBuffer == NULL) && (BurstLength > 0U))
4543
    if ((BurstBuffer == NULL) && (BurstLength > 0U))
3877
    {
4544
    {
3878
      return HAL_ERROR;
4545
      return HAL_ERROR;
3879
    }
4546
    }
3880
    else
4547
    else
3881
    {
4548
    {
3882
      htim->State = HAL_TIM_STATE_BUSY;
4549
      htim->DMABurstState = HAL_DMA_BURST_STATE_BUSY;
3883
    }
4550
    }
3884
  }
4551
  }
3885
  else
4552
  else
3886
  {
4553
  {
3887
    /* nothing to do */
4554
    /* nothing to do */
3888
  }
4555
  }
-
 
4556
 
3889
  switch (BurstRequestSrc)
4557
  switch (BurstRequestSrc)
3890
  {
4558
  {
3891
    case TIM_DMA_UPDATE:
4559
    case TIM_DMA_UPDATE:
3892
    {
4560
    {
3893
      /* Set the DMA Period elapsed callbacks */
4561
      /* Set the DMA Period elapsed callbacks */
Line 3899... Line 4567...
3899
 
4567
 
3900
      /* Enable the DMA channel */
4568
      /* Enable the DMA channel */
3901
      if (HAL_DMA_Start_IT(htim->hdma[TIM_DMA_ID_UPDATE], (uint32_t)BurstBuffer,
4569
      if (HAL_DMA_Start_IT(htim->hdma[TIM_DMA_ID_UPDATE], (uint32_t)BurstBuffer,
3902
                           (uint32_t)&htim->Instance->DMAR, DataLength) != HAL_OK)
4570
                           (uint32_t)&htim->Instance->DMAR, DataLength) != HAL_OK)
3903
      {
4571
      {
-
 
4572
        /* Return error status */
3904
        return HAL_ERROR;
4573
        return HAL_ERROR;
3905
      }
4574
      }
3906
      break;
4575
      break;
3907
    }
4576
    }
3908
    case TIM_DMA_CC1:
4577
    case TIM_DMA_CC1:
Line 3916... Line 4585...
3916
 
4585
 
3917
      /* Enable the DMA channel */
4586
      /* Enable the DMA channel */
3918
      if (HAL_DMA_Start_IT(htim->hdma[TIM_DMA_ID_CC1], (uint32_t)BurstBuffer,
4587
      if (HAL_DMA_Start_IT(htim->hdma[TIM_DMA_ID_CC1], (uint32_t)BurstBuffer,
3919
                           (uint32_t)&htim->Instance->DMAR, DataLength) != HAL_OK)
4588
                           (uint32_t)&htim->Instance->DMAR, DataLength) != HAL_OK)
3920
      {
4589
      {
-
 
4590
        /* Return error status */
3921
        return HAL_ERROR;
4591
        return HAL_ERROR;
3922
      }
4592
      }
3923
      break;
4593
      break;
3924
    }
4594
    }
3925
    case TIM_DMA_CC2:
4595
    case TIM_DMA_CC2:
Line 3933... Line 4603...
3933
 
4603
 
3934
      /* Enable the DMA channel */
4604
      /* Enable the DMA channel */
3935
      if (HAL_DMA_Start_IT(htim->hdma[TIM_DMA_ID_CC2], (uint32_t)BurstBuffer,
4605
      if (HAL_DMA_Start_IT(htim->hdma[TIM_DMA_ID_CC2], (uint32_t)BurstBuffer,
3936
                           (uint32_t)&htim->Instance->DMAR, DataLength) != HAL_OK)
4606
                           (uint32_t)&htim->Instance->DMAR, DataLength) != HAL_OK)
3937
      {
4607
      {
-
 
4608
        /* Return error status */
3938
        return HAL_ERROR;
4609
        return HAL_ERROR;
3939
      }
4610
      }
3940
      break;
4611
      break;
3941
    }
4612
    }
3942
    case TIM_DMA_CC3:
4613
    case TIM_DMA_CC3:
Line 3950... Line 4621...
3950
 
4621
 
3951
      /* Enable the DMA channel */
4622
      /* Enable the DMA channel */
3952
      if (HAL_DMA_Start_IT(htim->hdma[TIM_DMA_ID_CC3], (uint32_t)BurstBuffer,
4623
      if (HAL_DMA_Start_IT(htim->hdma[TIM_DMA_ID_CC3], (uint32_t)BurstBuffer,
3953
                           (uint32_t)&htim->Instance->DMAR, DataLength) != HAL_OK)
4624
                           (uint32_t)&htim->Instance->DMAR, DataLength) != HAL_OK)
3954
      {
4625
      {
-
 
4626
        /* Return error status */
3955
        return HAL_ERROR;
4627
        return HAL_ERROR;
3956
      }
4628
      }
3957
      break;
4629
      break;
3958
    }
4630
    }
3959
    case TIM_DMA_CC4:
4631
    case TIM_DMA_CC4:
Line 3967... Line 4639...
3967
 
4639
 
3968
      /* Enable the DMA channel */
4640
      /* Enable the DMA channel */
3969
      if (HAL_DMA_Start_IT(htim->hdma[TIM_DMA_ID_CC4], (uint32_t)BurstBuffer,
4641
      if (HAL_DMA_Start_IT(htim->hdma[TIM_DMA_ID_CC4], (uint32_t)BurstBuffer,
3970
                           (uint32_t)&htim->Instance->DMAR, DataLength) != HAL_OK)
4642
                           (uint32_t)&htim->Instance->DMAR, DataLength) != HAL_OK)
3971
      {
4643
      {
-
 
4644
        /* Return error status */
3972
        return HAL_ERROR;
4645
        return HAL_ERROR;
3973
      }
4646
      }
3974
      break;
4647
      break;
3975
    }
4648
    }
3976
    case TIM_DMA_COM:
4649
    case TIM_DMA_COM:
Line 3984... Line 4657...
3984
 
4657
 
3985
      /* Enable the DMA channel */
4658
      /* Enable the DMA channel */
3986
      if (HAL_DMA_Start_IT(htim->hdma[TIM_DMA_ID_COMMUTATION], (uint32_t)BurstBuffer,
4659
      if (HAL_DMA_Start_IT(htim->hdma[TIM_DMA_ID_COMMUTATION], (uint32_t)BurstBuffer,
3987
                           (uint32_t)&htim->Instance->DMAR, DataLength) != HAL_OK)
4660
                           (uint32_t)&htim->Instance->DMAR, DataLength) != HAL_OK)
3988
      {
4661
      {
-
 
4662
        /* Return error status */
3989
        return HAL_ERROR;
4663
        return HAL_ERROR;
3990
      }
4664
      }
3991
      break;
4665
      break;
3992
    }
4666
    }
3993
    case TIM_DMA_TRIGGER:
4667
    case TIM_DMA_TRIGGER:
Line 4001... Line 4675...
4001
 
4675
 
4002
      /* Enable the DMA channel */
4676
      /* Enable the DMA channel */
4003
      if (HAL_DMA_Start_IT(htim->hdma[TIM_DMA_ID_TRIGGER], (uint32_t)BurstBuffer,
4677
      if (HAL_DMA_Start_IT(htim->hdma[TIM_DMA_ID_TRIGGER], (uint32_t)BurstBuffer,
4004
                           (uint32_t)&htim->Instance->DMAR, DataLength) != HAL_OK)
4678
                           (uint32_t)&htim->Instance->DMAR, DataLength) != HAL_OK)
4005
      {
4679
      {
-
 
4680
        /* Return error status */
4006
        return HAL_ERROR;
4681
        return HAL_ERROR;
4007
      }
4682
      }
4008
      break;
4683
      break;
4009
    }
4684
    }
4010
    default:
4685
    default:
-
 
4686
      status = HAL_ERROR;
4011
      break;
4687
      break;
4012
  }
4688
  }
4013
 
4689
 
-
 
4690
  if (status == HAL_OK)
-
 
4691
  {
4014
  /* Configure the DMA Burst Mode */
4692
    /* Configure the DMA Burst Mode */
4015
  htim->Instance->DCR = (BurstBaseAddress | BurstLength);
4693
    htim->Instance->DCR = (BurstBaseAddress | BurstLength);
4016
  /* Enable the TIM DMA Request */
4694
    /* Enable the TIM DMA Request */
4017
  __HAL_TIM_ENABLE_DMA(htim, BurstRequestSrc);
4695
    __HAL_TIM_ENABLE_DMA(htim, BurstRequestSrc);
4018
 
4696
  }
4019
  htim->State = HAL_TIM_STATE_READY;
-
 
4020
 
4697
 
4021
  /* Return function status */
4698
  /* Return function status */
4022
  return HAL_OK;
4699
  return status;
4023
}
4700
}
4024
 
4701
 
4025
/**
4702
/**
4026
  * @brief  Stops the TIM DMA Burst mode
4703
  * @brief  Stops the TIM DMA Burst mode
4027
  * @param  htim TIM handle
4704
  * @param  htim TIM handle
Line 4029... Line 4706...
4029
  * @retval HAL status
4706
  * @retval HAL status
4030
  */
4707
  */
4031
HAL_StatusTypeDef HAL_TIM_DMABurst_WriteStop(TIM_HandleTypeDef *htim, uint32_t BurstRequestSrc)
4708
HAL_StatusTypeDef HAL_TIM_DMABurst_WriteStop(TIM_HandleTypeDef *htim, uint32_t BurstRequestSrc)
4032
{
4709
{
4033
  HAL_StatusTypeDef status = HAL_OK;
4710
  HAL_StatusTypeDef status = HAL_OK;
-
 
4711
 
4034
  /* Check the parameters */
4712
  /* Check the parameters */
4035
  assert_param(IS_TIM_DMA_SOURCE(BurstRequestSrc));
4713
  assert_param(IS_TIM_DMA_SOURCE(BurstRequestSrc));
4036
 
4714
 
4037
  /* Abort the DMA transfer (at least disable the DMA channel) */
4715
  /* Abort the DMA transfer (at least disable the DMA channel) */
4038
  switch (BurstRequestSrc)
4716
  switch (BurstRequestSrc)
4039
  {
4717
  {
4040
    case TIM_DMA_UPDATE:
4718
    case TIM_DMA_UPDATE:
4041
    {
4719
    {
4042
      status = HAL_DMA_Abort_IT(htim->hdma[TIM_DMA_ID_UPDATE]);
4720
      (void)HAL_DMA_Abort_IT(htim->hdma[TIM_DMA_ID_UPDATE]);
4043
      break;
4721
      break;
4044
    }
4722
    }
4045
    case TIM_DMA_CC1:
4723
    case TIM_DMA_CC1:
4046
    {
4724
    {
4047
      status = HAL_DMA_Abort_IT(htim->hdma[TIM_DMA_ID_CC1]);
4725
      (void)HAL_DMA_Abort_IT(htim->hdma[TIM_DMA_ID_CC1]);
4048
      break;
4726
      break;
4049
    }
4727
    }
4050
    case TIM_DMA_CC2:
4728
    case TIM_DMA_CC2:
4051
    {
4729
    {
4052
      status = HAL_DMA_Abort_IT(htim->hdma[TIM_DMA_ID_CC2]);
4730
      (void)HAL_DMA_Abort_IT(htim->hdma[TIM_DMA_ID_CC2]);
4053
      break;
4731
      break;
4054
    }
4732
    }
4055
    case TIM_DMA_CC3:
4733
    case TIM_DMA_CC3:
4056
    {
4734
    {
4057
      status =  HAL_DMA_Abort_IT(htim->hdma[TIM_DMA_ID_CC3]);
4735
      (void)HAL_DMA_Abort_IT(htim->hdma[TIM_DMA_ID_CC3]);
4058
      break;
4736
      break;
4059
    }
4737
    }
4060
    case TIM_DMA_CC4:
4738
    case TIM_DMA_CC4:
4061
    {
4739
    {
4062
      status = HAL_DMA_Abort_IT(htim->hdma[TIM_DMA_ID_CC4]);
4740
      (void)HAL_DMA_Abort_IT(htim->hdma[TIM_DMA_ID_CC4]);
4063
      break;
4741
      break;
4064
    }
4742
    }
4065
    case TIM_DMA_COM:
4743
    case TIM_DMA_COM:
4066
    {
4744
    {
4067
      status = HAL_DMA_Abort_IT(htim->hdma[TIM_DMA_ID_COMMUTATION]);
4745
      (void)HAL_DMA_Abort_IT(htim->hdma[TIM_DMA_ID_COMMUTATION]);
4068
      break;
4746
      break;
4069
    }
4747
    }
4070
    case TIM_DMA_TRIGGER:
4748
    case TIM_DMA_TRIGGER:
4071
    {
4749
    {
4072
      status = HAL_DMA_Abort_IT(htim->hdma[TIM_DMA_ID_TRIGGER]);
4750
      (void)HAL_DMA_Abort_IT(htim->hdma[TIM_DMA_ID_TRIGGER]);
4073
      break;
4751
      break;
4074
    }
4752
    }
4075
    default:
4753
    default:
-
 
4754
      status = HAL_ERROR;
4076
      break;
4755
      break;
4077
  }
4756
  }
4078
 
4757
 
4079
  if (HAL_OK == status)
4758
  if (status == HAL_OK)
4080
  {
4759
  {
4081
    /* Disable the TIM Update DMA request */
4760
    /* Disable the TIM Update DMA request */
4082
    __HAL_TIM_DISABLE_DMA(htim, BurstRequestSrc);
4761
    __HAL_TIM_DISABLE_DMA(htim, BurstRequestSrc);
-
 
4762
 
-
 
4763
    /* Change the DMA burst operation state */
-
 
4764
    htim->DMABurstState = HAL_DMA_BURST_STATE_READY;
4083
  }
4765
  }
4084
 
4766
 
4085
  /* Return function status */
4767
  /* Return function status */
4086
  return status;
4768
  return status;
4087
}
4769
}
Line 4125... Line 4807...
4125
  * @retval HAL status
4807
  * @retval HAL status
4126
  */
4808
  */
4127
HAL_StatusTypeDef HAL_TIM_DMABurst_ReadStart(TIM_HandleTypeDef *htim, uint32_t BurstBaseAddress,
4809
HAL_StatusTypeDef HAL_TIM_DMABurst_ReadStart(TIM_HandleTypeDef *htim, uint32_t BurstBaseAddress,
4128
                                             uint32_t BurstRequestSrc, uint32_t  *BurstBuffer, uint32_t  BurstLength)
4810
                                             uint32_t BurstRequestSrc, uint32_t  *BurstBuffer, uint32_t  BurstLength)
4129
{
4811
{
-
 
4812
  HAL_StatusTypeDef status = HAL_OK;
-
 
4813
 
-
 
4814
  if (status == HAL_OK)
-
 
4815
  {
4130
  return HAL_TIM_DMABurst_MultiReadStart(htim, BurstBaseAddress, BurstRequestSrc, BurstBuffer, BurstLength,
4816
    status = HAL_TIM_DMABurst_MultiReadStart(htim, BurstBaseAddress, BurstRequestSrc, BurstBuffer, BurstLength,
4131
                                         ((BurstLength) >> 8U) + 1U);
4817
                                             ((BurstLength) >> 8U) + 1U);
-
 
4818
  }
-
 
4819
 
-
 
4820
  return status;
4132
}
4821
}
4133
 
4822
 
4134
/**
4823
/**
4135
  * @brief  Configure the DMA Burst to transfer Data from the TIM peripheral to the memory
4824
  * @brief  Configure the DMA Burst to transfer Data from the TIM peripheral to the memory
4136
  * @param  htim TIM handle
4825
  * @param  htim TIM handle
Line 4172... Line 4861...
4172
  */
4861
  */
4173
HAL_StatusTypeDef HAL_TIM_DMABurst_MultiReadStart(TIM_HandleTypeDef *htim, uint32_t BurstBaseAddress,
4862
HAL_StatusTypeDef HAL_TIM_DMABurst_MultiReadStart(TIM_HandleTypeDef *htim, uint32_t BurstBaseAddress,
4174
                                                  uint32_t BurstRequestSrc, uint32_t  *BurstBuffer,
4863
                                                  uint32_t BurstRequestSrc, uint32_t  *BurstBuffer,
4175
                                                  uint32_t  BurstLength, uint32_t  DataLength)
4864
                                                  uint32_t  BurstLength, uint32_t  DataLength)
4176
{
4865
{
-
 
4866
  HAL_StatusTypeDef status = HAL_OK;
-
 
4867
 
4177
  /* Check the parameters */
4868
  /* Check the parameters */
4178
  assert_param(IS_TIM_DMABURST_INSTANCE(htim->Instance));
4869
  assert_param(IS_TIM_DMABURST_INSTANCE(htim->Instance));
4179
  assert_param(IS_TIM_DMA_BASE(BurstBaseAddress));
4870
  assert_param(IS_TIM_DMA_BASE(BurstBaseAddress));
4180
  assert_param(IS_TIM_DMA_SOURCE(BurstRequestSrc));
4871
  assert_param(IS_TIM_DMA_SOURCE(BurstRequestSrc));
4181
  assert_param(IS_TIM_DMA_LENGTH(BurstLength));
4872
  assert_param(IS_TIM_DMA_LENGTH(BurstLength));
4182
  assert_param(IS_TIM_DMA_DATA_LENGTH(DataLength));
4873
  assert_param(IS_TIM_DMA_DATA_LENGTH(DataLength));
4183
 
4874
 
4184
  if (htim->State == HAL_TIM_STATE_BUSY)
4875
  if (htim->DMABurstState == HAL_DMA_BURST_STATE_BUSY)
4185
  {
4876
  {
4186
    return HAL_BUSY;
4877
    return HAL_BUSY;
4187
  }
4878
  }
4188
  else if (htim->State == HAL_TIM_STATE_READY)
4879
  else if (htim->DMABurstState == HAL_DMA_BURST_STATE_READY)
4189
  {
4880
  {
4190
    if ((BurstBuffer == NULL) && (BurstLength > 0U))
4881
    if ((BurstBuffer == NULL) && (BurstLength > 0U))
4191
    {
4882
    {
4192
      return HAL_ERROR;
4883
      return HAL_ERROR;
4193
    }
4884
    }
4194
    else
4885
    else
4195
    {
4886
    {
4196
      htim->State = HAL_TIM_STATE_BUSY;
4887
      htim->DMABurstState = HAL_DMA_BURST_STATE_BUSY;
4197
    }
4888
    }
4198
  }
4889
  }
4199
  else
4890
  else
4200
  {
4891
  {
4201
    /* nothing to do */
4892
    /* nothing to do */
Line 4213... Line 4904...
4213
 
4904
 
4214
      /* Enable the DMA channel */
4905
      /* Enable the DMA channel */
4215
      if (HAL_DMA_Start_IT(htim->hdma[TIM_DMA_ID_UPDATE], (uint32_t)&htim->Instance->DMAR, (uint32_t)BurstBuffer,
4906
      if (HAL_DMA_Start_IT(htim->hdma[TIM_DMA_ID_UPDATE], (uint32_t)&htim->Instance->DMAR, (uint32_t)BurstBuffer,
4216
                           DataLength) != HAL_OK)
4907
                           DataLength) != HAL_OK)
4217
      {
4908
      {
-
 
4909
        /* Return error status */
4218
        return HAL_ERROR;
4910
        return HAL_ERROR;
4219
      }
4911
      }
4220
      break;
4912
      break;
4221
    }
4913
    }
4222
    case TIM_DMA_CC1:
4914
    case TIM_DMA_CC1:
Line 4230... Line 4922...
4230
 
4922
 
4231
      /* Enable the DMA channel */
4923
      /* Enable the DMA channel */
4232
      if (HAL_DMA_Start_IT(htim->hdma[TIM_DMA_ID_CC1], (uint32_t)&htim->Instance->DMAR, (uint32_t)BurstBuffer,
4924
      if (HAL_DMA_Start_IT(htim->hdma[TIM_DMA_ID_CC1], (uint32_t)&htim->Instance->DMAR, (uint32_t)BurstBuffer,
4233
                           DataLength) != HAL_OK)
4925
                           DataLength) != HAL_OK)
4234
      {
4926
      {
-
 
4927
        /* Return error status */
4235
        return HAL_ERROR;
4928
        return HAL_ERROR;
4236
      }
4929
      }
4237
      break;
4930
      break;
4238
    }
4931
    }
4239
    case TIM_DMA_CC2:
4932
    case TIM_DMA_CC2:
Line 4247... Line 4940...
4247
 
4940
 
4248
      /* Enable the DMA channel */
4941
      /* Enable the DMA channel */
4249
      if (HAL_DMA_Start_IT(htim->hdma[TIM_DMA_ID_CC2], (uint32_t)&htim->Instance->DMAR, (uint32_t)BurstBuffer,
4942
      if (HAL_DMA_Start_IT(htim->hdma[TIM_DMA_ID_CC2], (uint32_t)&htim->Instance->DMAR, (uint32_t)BurstBuffer,
4250
                           DataLength) != HAL_OK)
4943
                           DataLength) != HAL_OK)
4251
      {
4944
      {
-
 
4945
        /* Return error status */
4252
        return HAL_ERROR;
4946
        return HAL_ERROR;
4253
      }
4947
      }
4254
      break;
4948
      break;
4255
    }
4949
    }
4256
    case TIM_DMA_CC3:
4950
    case TIM_DMA_CC3:
Line 4264... Line 4958...
4264
 
4958
 
4265
      /* Enable the DMA channel */
4959
      /* Enable the DMA channel */
4266
      if (HAL_DMA_Start_IT(htim->hdma[TIM_DMA_ID_CC3], (uint32_t)&htim->Instance->DMAR, (uint32_t)BurstBuffer,
4960
      if (HAL_DMA_Start_IT(htim->hdma[TIM_DMA_ID_CC3], (uint32_t)&htim->Instance->DMAR, (uint32_t)BurstBuffer,
4267
                           DataLength) != HAL_OK)
4961
                           DataLength) != HAL_OK)
4268
      {
4962
      {
-
 
4963
        /* Return error status */
4269
        return HAL_ERROR;
4964
        return HAL_ERROR;
4270
      }
4965
      }
4271
      break;
4966
      break;
4272
    }
4967
    }
4273
    case TIM_DMA_CC4:
4968
    case TIM_DMA_CC4:
Line 4281... Line 4976...
4281
 
4976
 
4282
      /* Enable the DMA channel */
4977
      /* Enable the DMA channel */
4283
      if (HAL_DMA_Start_IT(htim->hdma[TIM_DMA_ID_CC4], (uint32_t)&htim->Instance->DMAR, (uint32_t)BurstBuffer,
4978
      if (HAL_DMA_Start_IT(htim->hdma[TIM_DMA_ID_CC4], (uint32_t)&htim->Instance->DMAR, (uint32_t)BurstBuffer,
4284
                           DataLength) != HAL_OK)
4979
                           DataLength) != HAL_OK)
4285
      {
4980
      {
-
 
4981
        /* Return error status */
4286
        return HAL_ERROR;
4982
        return HAL_ERROR;
4287
      }
4983
      }
4288
      break;
4984
      break;
4289
    }
4985
    }
4290
    case TIM_DMA_COM:
4986
    case TIM_DMA_COM:
Line 4298... Line 4994...
4298
 
4994
 
4299
      /* Enable the DMA channel */
4995
      /* Enable the DMA channel */
4300
      if (HAL_DMA_Start_IT(htim->hdma[TIM_DMA_ID_COMMUTATION], (uint32_t)&htim->Instance->DMAR, (uint32_t)BurstBuffer,
4996
      if (HAL_DMA_Start_IT(htim->hdma[TIM_DMA_ID_COMMUTATION], (uint32_t)&htim->Instance->DMAR, (uint32_t)BurstBuffer,
4301
                           DataLength) != HAL_OK)
4997
                           DataLength) != HAL_OK)
4302
      {
4998
      {
-
 
4999
        /* Return error status */
4303
        return HAL_ERROR;
5000
        return HAL_ERROR;
4304
      }
5001
      }
4305
      break;
5002
      break;
4306
    }
5003
    }
4307
    case TIM_DMA_TRIGGER:
5004
    case TIM_DMA_TRIGGER:
Line 4315... Line 5012...
4315
 
5012
 
4316
      /* Enable the DMA channel */
5013
      /* Enable the DMA channel */
4317
      if (HAL_DMA_Start_IT(htim->hdma[TIM_DMA_ID_TRIGGER], (uint32_t)&htim->Instance->DMAR, (uint32_t)BurstBuffer,
5014
      if (HAL_DMA_Start_IT(htim->hdma[TIM_DMA_ID_TRIGGER], (uint32_t)&htim->Instance->DMAR, (uint32_t)BurstBuffer,
4318
                           DataLength) != HAL_OK)
5015
                           DataLength) != HAL_OK)
4319
      {
5016
      {
-
 
5017
        /* Return error status */
4320
        return HAL_ERROR;
5018
        return HAL_ERROR;
4321
      }
5019
      }
4322
      break;
5020
      break;
4323
    }
5021
    }
4324
    default:
5022
    default:
-
 
5023
      status = HAL_ERROR;
4325
      break;
5024
      break;
4326
  }
5025
  }
4327
 
5026
 
4328
  /* Configure the DMA Burst Mode */
5027
  if (status == HAL_OK)
4329
  htim->Instance->DCR = (BurstBaseAddress | BurstLength);
-
 
4330
 
5028
  {
4331
  /* Enable the TIM DMA Request */
5029
    /* Configure the DMA Burst Mode */
4332
  __HAL_TIM_ENABLE_DMA(htim, BurstRequestSrc);
5030
    htim->Instance->DCR = (BurstBaseAddress | BurstLength);
4333
 
5031
 
4334
  htim->State = HAL_TIM_STATE_READY;
5032
    /* Enable the TIM DMA Request */
-
 
5033
    __HAL_TIM_ENABLE_DMA(htim, BurstRequestSrc);
-
 
5034
  }
4335
 
5035
 
4336
  /* Return function status */
5036
  /* Return function status */
4337
  return HAL_OK;
5037
  return status;
4338
}
5038
}
4339
 
5039
 
4340
/**
5040
/**
4341
  * @brief  Stop the DMA burst reading
5041
  * @brief  Stop the DMA burst reading
4342
  * @param  htim TIM handle
5042
  * @param  htim TIM handle
Line 4344... Line 5044...
4344
  * @retval HAL status
5044
  * @retval HAL status
4345
  */
5045
  */
4346
HAL_StatusTypeDef HAL_TIM_DMABurst_ReadStop(TIM_HandleTypeDef *htim, uint32_t BurstRequestSrc)
5046
HAL_StatusTypeDef HAL_TIM_DMABurst_ReadStop(TIM_HandleTypeDef *htim, uint32_t BurstRequestSrc)
4347
{
5047
{
4348
  HAL_StatusTypeDef status = HAL_OK;
5048
  HAL_StatusTypeDef status = HAL_OK;
-
 
5049
 
4349
  /* Check the parameters */
5050
  /* Check the parameters */
4350
  assert_param(IS_TIM_DMA_SOURCE(BurstRequestSrc));
5051
  assert_param(IS_TIM_DMA_SOURCE(BurstRequestSrc));
4351
 
5052
 
4352
  /* Abort the DMA transfer (at least disable the DMA channel) */
5053
  /* Abort the DMA transfer (at least disable the DMA channel) */
4353
  switch (BurstRequestSrc)
5054
  switch (BurstRequestSrc)
4354
  {
5055
  {
4355
    case TIM_DMA_UPDATE:
5056
    case TIM_DMA_UPDATE:
4356
    {
5057
    {
4357
      status = HAL_DMA_Abort_IT(htim->hdma[TIM_DMA_ID_UPDATE]);
5058
      (void)HAL_DMA_Abort_IT(htim->hdma[TIM_DMA_ID_UPDATE]);
4358
      break;
5059
      break;
4359
    }
5060
    }
4360
    case TIM_DMA_CC1:
5061
    case TIM_DMA_CC1:
4361
    {
5062
    {
4362
      status = HAL_DMA_Abort_IT(htim->hdma[TIM_DMA_ID_CC1]);
5063
      (void)HAL_DMA_Abort_IT(htim->hdma[TIM_DMA_ID_CC1]);
4363
      break;
5064
      break;
4364
    }
5065
    }
4365
    case TIM_DMA_CC2:
5066
    case TIM_DMA_CC2:
4366
    {
5067
    {
4367
      status = HAL_DMA_Abort_IT(htim->hdma[TIM_DMA_ID_CC2]);
5068
      (void)HAL_DMA_Abort_IT(htim->hdma[TIM_DMA_ID_CC2]);
4368
      break;
5069
      break;
4369
    }
5070
    }
4370
    case TIM_DMA_CC3:
5071
    case TIM_DMA_CC3:
4371
    {
5072
    {
4372
      status = HAL_DMA_Abort_IT(htim->hdma[TIM_DMA_ID_CC3]);
5073
      (void)HAL_DMA_Abort_IT(htim->hdma[TIM_DMA_ID_CC3]);
4373
      break;
5074
      break;
4374
    }
5075
    }
4375
    case TIM_DMA_CC4:
5076
    case TIM_DMA_CC4:
4376
    {
5077
    {
4377
      status = HAL_DMA_Abort_IT(htim->hdma[TIM_DMA_ID_CC4]);
5078
      (void)HAL_DMA_Abort_IT(htim->hdma[TIM_DMA_ID_CC4]);
4378
      break;
5079
      break;
4379
    }
5080
    }
4380
    case TIM_DMA_COM:
5081
    case TIM_DMA_COM:
4381
    {
5082
    {
4382
      status = HAL_DMA_Abort_IT(htim->hdma[TIM_DMA_ID_COMMUTATION]);
5083
      (void)HAL_DMA_Abort_IT(htim->hdma[TIM_DMA_ID_COMMUTATION]);
4383
      break;
5084
      break;
4384
    }
5085
    }
4385
    case TIM_DMA_TRIGGER:
5086
    case TIM_DMA_TRIGGER:
4386
    {
5087
    {
4387
      status = HAL_DMA_Abort_IT(htim->hdma[TIM_DMA_ID_TRIGGER]);
5088
      (void)HAL_DMA_Abort_IT(htim->hdma[TIM_DMA_ID_TRIGGER]);
4388
      break;
5089
      break;
4389
    }
5090
    }
4390
    default:
5091
    default:
-
 
5092
      status = HAL_ERROR;
4391
      break;
5093
      break;
4392
  }
5094
  }
4393
 
5095
 
4394
  if (HAL_OK == status)
5096
  if (status == HAL_OK)
4395
  {
5097
  {
4396
    /* Disable the TIM Update DMA request */
5098
    /* Disable the TIM Update DMA request */
4397
    __HAL_TIM_DISABLE_DMA(htim, BurstRequestSrc);
5099
    __HAL_TIM_DISABLE_DMA(htim, BurstRequestSrc);
-
 
5100
 
-
 
5101
    /* Change the DMA burst operation state */
-
 
5102
    htim->DMABurstState = HAL_DMA_BURST_STATE_READY;
4398
  }
5103
  }
4399
 
5104
 
4400
  /* Return function status */
5105
  /* Return function status */
4401
  return status;
5106
  return status;
4402
}
5107
}
Line 4460... Line 5165...
4460
  */
5165
  */
4461
HAL_StatusTypeDef HAL_TIM_ConfigOCrefClear(TIM_HandleTypeDef *htim,
5166
HAL_StatusTypeDef HAL_TIM_ConfigOCrefClear(TIM_HandleTypeDef *htim,
4462
                                           TIM_ClearInputConfigTypeDef *sClearInputConfig,
5167
                                           TIM_ClearInputConfigTypeDef *sClearInputConfig,
4463
                                           uint32_t Channel)
5168
                                           uint32_t Channel)
4464
{
5169
{
-
 
5170
  HAL_StatusTypeDef status = HAL_OK;
-
 
5171
 
4465
  /* Check the parameters */
5172
  /* Check the parameters */
4466
  assert_param(IS_TIM_OCXREF_CLEAR_INSTANCE(htim->Instance));
5173
  assert_param(IS_TIM_OCXREF_CLEAR_INSTANCE(htim->Instance));
4467
  assert_param(IS_TIM_CLEARINPUT_SOURCE(sClearInputConfig->ClearInputSource));
5174
  assert_param(IS_TIM_CLEARINPUT_SOURCE(sClearInputConfig->ClearInputSource));
4468
 
5175
 
4469
  /* Process Locked */
5176
  /* Process Locked */
Line 4510... Line 5217...
4510
      SET_BIT(htim->Instance->SMCR, TIM_SMCR_OCCS);
5217
      SET_BIT(htim->Instance->SMCR, TIM_SMCR_OCCS);
4511
      break;
5218
      break;
4512
    }
5219
    }
4513
 
5220
 
4514
    default:
5221
    default:
-
 
5222
      status = HAL_ERROR;
4515
      break;
5223
      break;
4516
  }
5224
  }
4517
 
5225
 
4518
  switch (Channel)
5226
  if (status == HAL_OK)
4519
  {
5227
  {
4520
    case TIM_CHANNEL_1:
5228
    switch (Channel)
4521
    {
-
 
4522
      if (sClearInputConfig->ClearInputState != (uint32_t)DISABLE)
-
 
4523
      {
-
 
4524
        /* Enable the OCREF clear feature for Channel 1 */
-
 
4525
        SET_BIT(htim->Instance->CCMR1, TIM_CCMR1_OC1CE);
-
 
4526
      }
-
 
4527
      else
-
 
4528
      {
-
 
4529
        /* Disable the OCREF clear feature for Channel 1 */
-
 
4530
        CLEAR_BIT(htim->Instance->CCMR1, TIM_CCMR1_OC1CE);
-
 
4531
      }
-
 
4532
      break;
-
 
4533
    }
-
 
4534
    case TIM_CHANNEL_2:
-
 
4535
    {
5229
    {
4536
      if (sClearInputConfig->ClearInputState != (uint32_t)DISABLE)
-
 
4537
      {
-
 
4538
        /* Enable the OCREF clear feature for Channel 2 */
-
 
4539
        SET_BIT(htim->Instance->CCMR1, TIM_CCMR1_OC2CE);
-
 
4540
      }
-
 
4541
      else
-
 
4542
      {
-
 
4543
        /* Disable the OCREF clear feature for Channel 2 */
-
 
4544
        CLEAR_BIT(htim->Instance->CCMR1, TIM_CCMR1_OC2CE);
-
 
4545
      }
-
 
4546
      break;
-
 
4547
    }
-
 
4548
    case TIM_CHANNEL_3:
5230
      case TIM_CHANNEL_1:
4549
    {
-
 
4550
      if (sClearInputConfig->ClearInputState != (uint32_t)DISABLE)
-
 
4551
      {
5231
      {
-
 
5232
        if (sClearInputConfig->ClearInputState != (uint32_t)DISABLE)
-
 
5233
        {
4552
        /* Enable the OCREF clear feature for Channel 3 */
5234
          /* Enable the OCREF clear feature for Channel 1 */
4553
        SET_BIT(htim->Instance->CCMR2, TIM_CCMR2_OC3CE);
5235
          SET_BIT(htim->Instance->CCMR1, TIM_CCMR1_OC1CE);
-
 
5236
        }
-
 
5237
        else
-
 
5238
        {
-
 
5239
          /* Disable the OCREF clear feature for Channel 1 */
-
 
5240
          CLEAR_BIT(htim->Instance->CCMR1, TIM_CCMR1_OC1CE);
-
 
5241
        }
-
 
5242
        break;
4554
      }
5243
      }
4555
      else
5244
      case TIM_CHANNEL_2:
4556
      {
5245
      {
-
 
5246
        if (sClearInputConfig->ClearInputState != (uint32_t)DISABLE)
-
 
5247
        {
-
 
5248
          /* Enable the OCREF clear feature for Channel 2 */
-
 
5249
          SET_BIT(htim->Instance->CCMR1, TIM_CCMR1_OC2CE);
-
 
5250
        }
-
 
5251
        else
-
 
5252
        {
4557
        /* Disable the OCREF clear feature for Channel 3 */
5253
          /* Disable the OCREF clear feature for Channel 2 */
4558
        CLEAR_BIT(htim->Instance->CCMR2, TIM_CCMR2_OC3CE);
5254
          CLEAR_BIT(htim->Instance->CCMR1, TIM_CCMR1_OC2CE);
-
 
5255
        }
-
 
5256
        break;
4559
      }
5257
      }
4560
      break;
-
 
4561
    }
-
 
4562
    case TIM_CHANNEL_4:
5258
      case TIM_CHANNEL_3:
4563
    {
-
 
4564
      if (sClearInputConfig->ClearInputState != (uint32_t)DISABLE)
-
 
4565
      {
5259
      {
-
 
5260
        if (sClearInputConfig->ClearInputState != (uint32_t)DISABLE)
-
 
5261
        {
4566
        /* Enable the OCREF clear feature for Channel 4 */
5262
          /* Enable the OCREF clear feature for Channel 3 */
4567
        SET_BIT(htim->Instance->CCMR2, TIM_CCMR2_OC4CE);
5263
          SET_BIT(htim->Instance->CCMR2, TIM_CCMR2_OC3CE);
-
 
5264
        }
-
 
5265
        else
-
 
5266
        {
-
 
5267
          /* Disable the OCREF clear feature for Channel 3 */
-
 
5268
          CLEAR_BIT(htim->Instance->CCMR2, TIM_CCMR2_OC3CE);
-
 
5269
        }
-
 
5270
        break;
4568
      }
5271
      }
4569
      else
5272
      case TIM_CHANNEL_4:
4570
      {
5273
      {
-
 
5274
        if (sClearInputConfig->ClearInputState != (uint32_t)DISABLE)
-
 
5275
        {
-
 
5276
          /* Enable the OCREF clear feature for Channel 4 */
-
 
5277
          SET_BIT(htim->Instance->CCMR2, TIM_CCMR2_OC4CE);
-
 
5278
        }
-
 
5279
        else
-
 
5280
        {
4571
        /* Disable the OCREF clear feature for Channel 4 */
5281
          /* Disable the OCREF clear feature for Channel 4 */
4572
        CLEAR_BIT(htim->Instance->CCMR2, TIM_CCMR2_OC4CE);
5282
          CLEAR_BIT(htim->Instance->CCMR2, TIM_CCMR2_OC4CE);
-
 
5283
        }
-
 
5284
        break;
4573
      }
5285
      }
-
 
5286
      default:
4574
      break;
5287
        break;
4575
    }
5288
    }
4576
    default:
-
 
4577
      break;
-
 
4578
  }
5289
  }
4579
 
5290
 
4580
  htim->State = HAL_TIM_STATE_READY;
5291
  htim->State = HAL_TIM_STATE_READY;
4581
 
5292
 
4582
  __HAL_UNLOCK(htim);
5293
  __HAL_UNLOCK(htim);
4583
 
5294
 
4584
  return HAL_OK;
5295
  return status;
4585
}
5296
}
4586
 
5297
 
4587
/**
5298
/**
4588
  * @brief   Configures the clock source to be used
5299
  * @brief   Configures the clock source to be used
4589
  * @param  htim TIM handle
5300
  * @param  htim TIM handle
Line 4591... Line 5302...
4591
  *         contains the clock source information for the TIM peripheral.
5302
  *         contains the clock source information for the TIM peripheral.
4592
  * @retval HAL status
5303
  * @retval HAL status
4593
  */
5304
  */
4594
HAL_StatusTypeDef HAL_TIM_ConfigClockSource(TIM_HandleTypeDef *htim, TIM_ClockConfigTypeDef *sClockSourceConfig)
5305
HAL_StatusTypeDef HAL_TIM_ConfigClockSource(TIM_HandleTypeDef *htim, TIM_ClockConfigTypeDef *sClockSourceConfig)
4595
{
5306
{
-
 
5307
  HAL_StatusTypeDef status = HAL_OK;
4596
  uint32_t tmpsmcr;
5308
  uint32_t tmpsmcr;
4597
 
5309
 
4598
  /* Process Locked */
5310
  /* Process Locked */
4599
  __HAL_LOCK(htim);
5311
  __HAL_LOCK(htim);
4600
 
5312
 
Line 4720... Line 5432...
4720
      TIM_ITRx_SetConfig(htim->Instance, sClockSourceConfig->ClockSource);
5432
      TIM_ITRx_SetConfig(htim->Instance, sClockSourceConfig->ClockSource);
4721
      break;
5433
      break;
4722
    }
5434
    }
4723
 
5435
 
4724
    default:
5436
    default:
-
 
5437
      status = HAL_ERROR;
4725
      break;
5438
      break;
4726
  }
5439
  }
4727
  htim->State = HAL_TIM_STATE_READY;
5440
  htim->State = HAL_TIM_STATE_READY;
4728
 
5441
 
4729
  __HAL_UNLOCK(htim);
5442
  __HAL_UNLOCK(htim);
4730
 
5443
 
4731
  return HAL_OK;
5444
  return status;
4732
}
5445
}
4733
 
5446
 
4734
/**
5447
/**
4735
  * @brief  Selects the signal connected to the TI1 input: direct from CH1_input
5448
  * @brief  Selects the signal connected to the TI1 input: direct from CH1_input
4736
  *         or a XOR combination between CH1_input, CH2_input & CH3_input
5449
  *         or a XOR combination between CH1_input, CH2_input & CH3_input
Line 5247... Line 5960...
5247
        htim->BreakCallback                        = pCallback;
5960
        htim->BreakCallback                        = pCallback;
5248
        break;
5961
        break;
5249
 
5962
 
5250
      default :
5963
      default :
5251
        /* Return error status */
5964
        /* Return error status */
5252
        status =  HAL_ERROR;
5965
        status = HAL_ERROR;
5253
        break;
5966
        break;
5254
    }
5967
    }
5255
  }
5968
  }
5256
  else if (htim->State == HAL_TIM_STATE_RESET)
5969
  else if (htim->State == HAL_TIM_STATE_RESET)
5257
  {
5970
  {
Line 5313... Line 6026...
5313
        htim->HallSensor_MspDeInitCallback = pCallback;
6026
        htim->HallSensor_MspDeInitCallback = pCallback;
5314
        break;
6027
        break;
5315
 
6028
 
5316
      default :
6029
      default :
5317
        /* Return error status */
6030
        /* Return error status */
5318
        status =  HAL_ERROR;
6031
        status = HAL_ERROR;
5319
        break;
6032
        break;
5320
    }
6033
    }
5321
  }
6034
  }
5322
  else
6035
  else
5323
  {
6036
  {
5324
    /* Return error status */
6037
    /* Return error status */
5325
    status =  HAL_ERROR;
6038
    status = HAL_ERROR;
5326
  }
6039
  }
5327
 
6040
 
5328
  /* Release Lock */
6041
  /* Release Lock */
5329
  __HAL_UNLOCK(htim);
6042
  __HAL_UNLOCK(htim);
5330
 
6043
 
Line 5376... Line 6089...
5376
  if (htim->State == HAL_TIM_STATE_READY)
6089
  if (htim->State == HAL_TIM_STATE_READY)
5377
  {
6090
  {
5378
    switch (CallbackID)
6091
    switch (CallbackID)
5379
    {
6092
    {
5380
      case HAL_TIM_BASE_MSPINIT_CB_ID :
6093
      case HAL_TIM_BASE_MSPINIT_CB_ID :
-
 
6094
        /* Legacy weak Base MspInit Callback */
5381
        htim->Base_MspInitCallback              = HAL_TIM_Base_MspInit;                      /* Legacy weak Base MspInit Callback */
6095
        htim->Base_MspInitCallback              = HAL_TIM_Base_MspInit;
5382
        break;
6096
        break;
5383
 
6097
 
5384
      case HAL_TIM_BASE_MSPDEINIT_CB_ID :
6098
      case HAL_TIM_BASE_MSPDEINIT_CB_ID :
-
 
6099
        /* Legacy weak Base Msp DeInit Callback */
5385
        htim->Base_MspDeInitCallback            = HAL_TIM_Base_MspDeInit;                    /* Legacy weak Base Msp DeInit Callback */
6100
        htim->Base_MspDeInitCallback            = HAL_TIM_Base_MspDeInit;
5386
        break;
6101
        break;
5387
 
6102
 
5388
      case HAL_TIM_IC_MSPINIT_CB_ID :
6103
      case HAL_TIM_IC_MSPINIT_CB_ID :
-
 
6104
        /* Legacy weak IC Msp Init Callback */
5389
        htim->IC_MspInitCallback                = HAL_TIM_IC_MspInit;                        /* Legacy weak IC Msp Init Callback */
6105
        htim->IC_MspInitCallback                = HAL_TIM_IC_MspInit;
5390
        break;
6106
        break;
5391
 
6107
 
5392
      case HAL_TIM_IC_MSPDEINIT_CB_ID :
6108
      case HAL_TIM_IC_MSPDEINIT_CB_ID :
-
 
6109
        /* Legacy weak IC Msp DeInit Callback */
5393
        htim->IC_MspDeInitCallback              = HAL_TIM_IC_MspDeInit;                      /* Legacy weak IC Msp DeInit Callback */
6110
        htim->IC_MspDeInitCallback              = HAL_TIM_IC_MspDeInit;
5394
        break;
6111
        break;
5395
 
6112
 
5396
      case HAL_TIM_OC_MSPINIT_CB_ID :
6113
      case HAL_TIM_OC_MSPINIT_CB_ID :
-
 
6114
        /* Legacy weak OC Msp Init Callback */
5397
        htim->OC_MspInitCallback                = HAL_TIM_OC_MspInit;                        /* Legacy weak OC Msp Init Callback */
6115
        htim->OC_MspInitCallback                = HAL_TIM_OC_MspInit;
5398
        break;
6116
        break;
5399
 
6117
 
5400
      case HAL_TIM_OC_MSPDEINIT_CB_ID :
6118
      case HAL_TIM_OC_MSPDEINIT_CB_ID :
-
 
6119
        /* Legacy weak OC Msp DeInit Callback */
5401
        htim->OC_MspDeInitCallback              = HAL_TIM_OC_MspDeInit;                      /* Legacy weak OC Msp DeInit Callback */
6120
        htim->OC_MspDeInitCallback              = HAL_TIM_OC_MspDeInit;
5402
        break;
6121
        break;
5403
 
6122
 
5404
      case HAL_TIM_PWM_MSPINIT_CB_ID :
6123
      case HAL_TIM_PWM_MSPINIT_CB_ID :
-
 
6124
        /* Legacy weak PWM Msp Init Callback */
5405
        htim->PWM_MspInitCallback               = HAL_TIM_PWM_MspInit;                       /* Legacy weak PWM Msp Init Callback */
6125
        htim->PWM_MspInitCallback               = HAL_TIM_PWM_MspInit;
5406
        break;
6126
        break;
5407
 
6127
 
5408
      case HAL_TIM_PWM_MSPDEINIT_CB_ID :
6128
      case HAL_TIM_PWM_MSPDEINIT_CB_ID :
-
 
6129
        /* Legacy weak PWM Msp DeInit Callback */
5409
        htim->PWM_MspDeInitCallback             = HAL_TIM_PWM_MspDeInit;                     /* Legacy weak PWM Msp DeInit Callback */
6130
        htim->PWM_MspDeInitCallback             = HAL_TIM_PWM_MspDeInit;
5410
        break;
6131
        break;
5411
 
6132
 
5412
      case HAL_TIM_ONE_PULSE_MSPINIT_CB_ID :
6133
      case HAL_TIM_ONE_PULSE_MSPINIT_CB_ID :
-
 
6134
        /* Legacy weak One Pulse Msp Init Callback */
5413
        htim->OnePulse_MspInitCallback          = HAL_TIM_OnePulse_MspInit;                  /* Legacy weak One Pulse Msp Init Callback */
6135
        htim->OnePulse_MspInitCallback          = HAL_TIM_OnePulse_MspInit;
5414
        break;
6136
        break;
5415
 
6137
 
5416
      case HAL_TIM_ONE_PULSE_MSPDEINIT_CB_ID :
6138
      case HAL_TIM_ONE_PULSE_MSPDEINIT_CB_ID :
-
 
6139
        /* Legacy weak One Pulse Msp DeInit Callback */
5417
        htim->OnePulse_MspDeInitCallback        = HAL_TIM_OnePulse_MspDeInit;                /* Legacy weak One Pulse Msp DeInit Callback */
6140
        htim->OnePulse_MspDeInitCallback        = HAL_TIM_OnePulse_MspDeInit;
5418
        break;
6141
        break;
5419
 
6142
 
5420
      case HAL_TIM_ENCODER_MSPINIT_CB_ID :
6143
      case HAL_TIM_ENCODER_MSPINIT_CB_ID :
-
 
6144
        /* Legacy weak Encoder Msp Init Callback */
5421
        htim->Encoder_MspInitCallback           = HAL_TIM_Encoder_MspInit;                   /* Legacy weak Encoder Msp Init Callback */
6145
        htim->Encoder_MspInitCallback           = HAL_TIM_Encoder_MspInit;
5422
        break;
6146
        break;
5423
 
6147
 
5424
      case HAL_TIM_ENCODER_MSPDEINIT_CB_ID :
6148
      case HAL_TIM_ENCODER_MSPDEINIT_CB_ID :
-
 
6149
        /* Legacy weak Encoder Msp DeInit Callback */
5425
        htim->Encoder_MspDeInitCallback         = HAL_TIM_Encoder_MspDeInit;                 /* Legacy weak Encoder Msp DeInit Callback */
6150
        htim->Encoder_MspDeInitCallback         = HAL_TIM_Encoder_MspDeInit;
5426
        break;
6151
        break;
5427
 
6152
 
5428
      case HAL_TIM_HALL_SENSOR_MSPINIT_CB_ID :
6153
      case HAL_TIM_HALL_SENSOR_MSPINIT_CB_ID :
-
 
6154
        /* Legacy weak Hall Sensor Msp Init Callback */
5429
        htim->HallSensor_MspInitCallback        = HAL_TIMEx_HallSensor_MspInit;              /* Legacy weak Hall Sensor Msp Init Callback */
6155
        htim->HallSensor_MspInitCallback        = HAL_TIMEx_HallSensor_MspInit;
5430
        break;
6156
        break;
5431
 
6157
 
5432
      case HAL_TIM_HALL_SENSOR_MSPDEINIT_CB_ID :
6158
      case HAL_TIM_HALL_SENSOR_MSPDEINIT_CB_ID :
-
 
6159
        /* Legacy weak Hall Sensor Msp DeInit Callback */
5433
        htim->HallSensor_MspDeInitCallback      = HAL_TIMEx_HallSensor_MspDeInit;            /* Legacy weak Hall Sensor Msp DeInit Callback */
6160
        htim->HallSensor_MspDeInitCallback      = HAL_TIMEx_HallSensor_MspDeInit;
5434
        break;
6161
        break;
5435
 
6162
 
5436
      case HAL_TIM_PERIOD_ELAPSED_CB_ID :
6163
      case HAL_TIM_PERIOD_ELAPSED_CB_ID :
-
 
6164
        /* Legacy weak Period Elapsed Callback */
5437
        htim->PeriodElapsedCallback             = HAL_TIM_PeriodElapsedCallback;             /* Legacy weak Period Elapsed Callback */
6165
        htim->PeriodElapsedCallback             = HAL_TIM_PeriodElapsedCallback;
5438
        break;
6166
        break;
5439
 
6167
 
5440
      case HAL_TIM_PERIOD_ELAPSED_HALF_CB_ID :
6168
      case HAL_TIM_PERIOD_ELAPSED_HALF_CB_ID :
-
 
6169
        /* Legacy weak Period Elapsed half complete Callback */
5441
        htim->PeriodElapsedHalfCpltCallback     = HAL_TIM_PeriodElapsedHalfCpltCallback;     /* Legacy weak Period Elapsed half complete Callback */
6170
        htim->PeriodElapsedHalfCpltCallback     = HAL_TIM_PeriodElapsedHalfCpltCallback;
5442
        break;
6171
        break;
5443
 
6172
 
5444
      case HAL_TIM_TRIGGER_CB_ID :
6173
      case HAL_TIM_TRIGGER_CB_ID :
-
 
6174
        /* Legacy weak Trigger Callback */
5445
        htim->TriggerCallback                   = HAL_TIM_TriggerCallback;                   /* Legacy weak Trigger Callback */
6175
        htim->TriggerCallback                   = HAL_TIM_TriggerCallback;
5446
        break;
6176
        break;
5447
 
6177
 
5448
      case HAL_TIM_TRIGGER_HALF_CB_ID :
6178
      case HAL_TIM_TRIGGER_HALF_CB_ID :
-
 
6179
        /* Legacy weak Trigger half complete Callback */
5449
        htim->TriggerHalfCpltCallback           = HAL_TIM_TriggerHalfCpltCallback;           /* Legacy weak Trigger half complete Callback */
6180
        htim->TriggerHalfCpltCallback           = HAL_TIM_TriggerHalfCpltCallback;
5450
        break;
6181
        break;
5451
 
6182
 
5452
      case HAL_TIM_IC_CAPTURE_CB_ID :
6183
      case HAL_TIM_IC_CAPTURE_CB_ID :
-
 
6184
        /* Legacy weak IC Capture Callback */
5453
        htim->IC_CaptureCallback                = HAL_TIM_IC_CaptureCallback;                /* Legacy weak IC Capture Callback */
6185
        htim->IC_CaptureCallback                = HAL_TIM_IC_CaptureCallback;
5454
        break;
6186
        break;
5455
 
6187
 
5456
      case HAL_TIM_IC_CAPTURE_HALF_CB_ID :
6188
      case HAL_TIM_IC_CAPTURE_HALF_CB_ID :
-
 
6189
        /* Legacy weak IC Capture half complete Callback */
5457
        htim->IC_CaptureHalfCpltCallback        = HAL_TIM_IC_CaptureHalfCpltCallback;        /* Legacy weak IC Capture half complete Callback */
6190
        htim->IC_CaptureHalfCpltCallback        = HAL_TIM_IC_CaptureHalfCpltCallback;
5458
        break;
6191
        break;
5459
 
6192
 
5460
      case HAL_TIM_OC_DELAY_ELAPSED_CB_ID :
6193
      case HAL_TIM_OC_DELAY_ELAPSED_CB_ID :
-
 
6194
        /* Legacy weak OC Delay Elapsed Callback */
5461
        htim->OC_DelayElapsedCallback           = HAL_TIM_OC_DelayElapsedCallback;           /* Legacy weak OC Delay Elapsed Callback */
6195
        htim->OC_DelayElapsedCallback           = HAL_TIM_OC_DelayElapsedCallback;
5462
        break;
6196
        break;
5463
 
6197
 
5464
      case HAL_TIM_PWM_PULSE_FINISHED_CB_ID :
6198
      case HAL_TIM_PWM_PULSE_FINISHED_CB_ID :
-
 
6199
        /* Legacy weak PWM Pulse Finished Callback */
5465
        htim->PWM_PulseFinishedCallback         = HAL_TIM_PWM_PulseFinishedCallback;         /* Legacy weak PWM Pulse Finished Callback */
6200
        htim->PWM_PulseFinishedCallback         = HAL_TIM_PWM_PulseFinishedCallback;
5466
        break;
6201
        break;
5467
 
6202
 
5468
      case HAL_TIM_PWM_PULSE_FINISHED_HALF_CB_ID :
6203
      case HAL_TIM_PWM_PULSE_FINISHED_HALF_CB_ID :
-
 
6204
        /* Legacy weak PWM Pulse Finished half complete Callback */
5469
        htim->PWM_PulseFinishedHalfCpltCallback = HAL_TIM_PWM_PulseFinishedHalfCpltCallback; /* Legacy weak PWM Pulse Finished half complete Callback */
6205
        htim->PWM_PulseFinishedHalfCpltCallback = HAL_TIM_PWM_PulseFinishedHalfCpltCallback;
5470
        break;
6206
        break;
5471
 
6207
 
5472
      case HAL_TIM_ERROR_CB_ID :
6208
      case HAL_TIM_ERROR_CB_ID :
-
 
6209
        /* Legacy weak Error Callback */
5473
        htim->ErrorCallback                     = HAL_TIM_ErrorCallback;                     /* Legacy weak Error Callback */
6210
        htim->ErrorCallback                     = HAL_TIM_ErrorCallback;
5474
        break;
6211
        break;
5475
 
6212
 
5476
      case HAL_TIM_COMMUTATION_CB_ID :
6213
      case HAL_TIM_COMMUTATION_CB_ID :
-
 
6214
        /* Legacy weak Commutation Callback */
5477
        htim->CommutationCallback               = HAL_TIMEx_CommutCallback;                  /* Legacy weak Commutation Callback */
6215
        htim->CommutationCallback               = HAL_TIMEx_CommutCallback;
5478
        break;
6216
        break;
5479
 
6217
 
5480
      case HAL_TIM_COMMUTATION_HALF_CB_ID :
6218
      case HAL_TIM_COMMUTATION_HALF_CB_ID :
-
 
6219
        /* Legacy weak Commutation half complete Callback */
5481
        htim->CommutationHalfCpltCallback       = HAL_TIMEx_CommutHalfCpltCallback;          /* Legacy weak Commutation half complete Callback */
6220
        htim->CommutationHalfCpltCallback       = HAL_TIMEx_CommutHalfCpltCallback;
5482
        break;
6221
        break;
5483
 
6222
 
5484
      case HAL_TIM_BREAK_CB_ID :
6223
      case HAL_TIM_BREAK_CB_ID :
-
 
6224
        /* Legacy weak Break Callback */
5485
        htim->BreakCallback                     = HAL_TIMEx_BreakCallback;                   /* Legacy weak Break Callback */
6225
        htim->BreakCallback                     = HAL_TIMEx_BreakCallback;
5486
        break;
6226
        break;
5487
 
6227
 
5488
      default :
6228
      default :
5489
        /* Return error status */
6229
        /* Return error status */
5490
        status =  HAL_ERROR;
6230
        status = HAL_ERROR;
5491
        break;
6231
        break;
5492
    }
6232
    }
5493
  }
6233
  }
5494
  else if (htim->State == HAL_TIM_STATE_RESET)
6234
  else if (htim->State == HAL_TIM_STATE_RESET)
5495
  {
6235
  {
5496
    switch (CallbackID)
6236
    switch (CallbackID)
5497
    {
6237
    {
5498
      case HAL_TIM_BASE_MSPINIT_CB_ID :
6238
      case HAL_TIM_BASE_MSPINIT_CB_ID :
-
 
6239
        /* Legacy weak Base MspInit Callback */
5499
        htim->Base_MspInitCallback         = HAL_TIM_Base_MspInit;              /* Legacy weak Base MspInit Callback */
6240
        htim->Base_MspInitCallback         = HAL_TIM_Base_MspInit;
5500
        break;
6241
        break;
5501
 
6242
 
5502
      case HAL_TIM_BASE_MSPDEINIT_CB_ID :
6243
      case HAL_TIM_BASE_MSPDEINIT_CB_ID :
-
 
6244
        /* Legacy weak Base Msp DeInit Callback */
5503
        htim->Base_MspDeInitCallback       = HAL_TIM_Base_MspDeInit;            /* Legacy weak Base Msp DeInit Callback */
6245
        htim->Base_MspDeInitCallback       = HAL_TIM_Base_MspDeInit;
5504
        break;
6246
        break;
5505
 
6247
 
5506
      case HAL_TIM_IC_MSPINIT_CB_ID :
6248
      case HAL_TIM_IC_MSPINIT_CB_ID :
-
 
6249
        /* Legacy weak IC Msp Init Callback */
5507
        htim->IC_MspInitCallback           = HAL_TIM_IC_MspInit;                /* Legacy weak IC Msp Init Callback */
6250
        htim->IC_MspInitCallback           = HAL_TIM_IC_MspInit;
5508
        break;
6251
        break;
5509
 
6252
 
5510
      case HAL_TIM_IC_MSPDEINIT_CB_ID :
6253
      case HAL_TIM_IC_MSPDEINIT_CB_ID :
-
 
6254
        /* Legacy weak IC Msp DeInit Callback */
5511
        htim->IC_MspDeInitCallback         = HAL_TIM_IC_MspDeInit;              /* Legacy weak IC Msp DeInit Callback */
6255
        htim->IC_MspDeInitCallback         = HAL_TIM_IC_MspDeInit;
5512
        break;
6256
        break;
5513
 
6257
 
5514
      case HAL_TIM_OC_MSPINIT_CB_ID :
6258
      case HAL_TIM_OC_MSPINIT_CB_ID :
-
 
6259
        /* Legacy weak OC Msp Init Callback */
5515
        htim->OC_MspInitCallback           = HAL_TIM_OC_MspInit;                /* Legacy weak OC Msp Init Callback */
6260
        htim->OC_MspInitCallback           = HAL_TIM_OC_MspInit;
5516
        break;
6261
        break;
5517
 
6262
 
5518
      case HAL_TIM_OC_MSPDEINIT_CB_ID :
6263
      case HAL_TIM_OC_MSPDEINIT_CB_ID :
-
 
6264
        /* Legacy weak OC Msp DeInit Callback */
5519
        htim->OC_MspDeInitCallback         = HAL_TIM_OC_MspDeInit;              /* Legacy weak OC Msp DeInit Callback */
6265
        htim->OC_MspDeInitCallback         = HAL_TIM_OC_MspDeInit;
5520
        break;
6266
        break;
5521
 
6267
 
5522
      case HAL_TIM_PWM_MSPINIT_CB_ID :
6268
      case HAL_TIM_PWM_MSPINIT_CB_ID :
-
 
6269
        /* Legacy weak PWM Msp Init Callback */
5523
        htim->PWM_MspInitCallback          = HAL_TIM_PWM_MspInit;               /* Legacy weak PWM Msp Init Callback */
6270
        htim->PWM_MspInitCallback          = HAL_TIM_PWM_MspInit;
5524
        break;
6271
        break;
5525
 
6272
 
5526
      case HAL_TIM_PWM_MSPDEINIT_CB_ID :
6273
      case HAL_TIM_PWM_MSPDEINIT_CB_ID :
-
 
6274
        /* Legacy weak PWM Msp DeInit Callback */
5527
        htim->PWM_MspDeInitCallback        = HAL_TIM_PWM_MspDeInit;             /* Legacy weak PWM Msp DeInit Callback */
6275
        htim->PWM_MspDeInitCallback        = HAL_TIM_PWM_MspDeInit;
5528
        break;
6276
        break;
5529
 
6277
 
5530
      case HAL_TIM_ONE_PULSE_MSPINIT_CB_ID :
6278
      case HAL_TIM_ONE_PULSE_MSPINIT_CB_ID :
-
 
6279
        /* Legacy weak One Pulse Msp Init Callback */
5531
        htim->OnePulse_MspInitCallback     = HAL_TIM_OnePulse_MspInit;          /* Legacy weak One Pulse Msp Init Callback */
6280
        htim->OnePulse_MspInitCallback     = HAL_TIM_OnePulse_MspInit;
5532
        break;
6281
        break;
5533
 
6282
 
5534
      case HAL_TIM_ONE_PULSE_MSPDEINIT_CB_ID :
6283
      case HAL_TIM_ONE_PULSE_MSPDEINIT_CB_ID :
-
 
6284
        /* Legacy weak One Pulse Msp DeInit Callback */
5535
        htim->OnePulse_MspDeInitCallback   = HAL_TIM_OnePulse_MspDeInit;        /* Legacy weak One Pulse Msp DeInit Callback */
6285
        htim->OnePulse_MspDeInitCallback   = HAL_TIM_OnePulse_MspDeInit;
5536
        break;
6286
        break;
5537
 
6287
 
5538
      case HAL_TIM_ENCODER_MSPINIT_CB_ID :
6288
      case HAL_TIM_ENCODER_MSPINIT_CB_ID :
-
 
6289
        /* Legacy weak Encoder Msp Init Callback */
5539
        htim->Encoder_MspInitCallback      = HAL_TIM_Encoder_MspInit;           /* Legacy weak Encoder Msp Init Callback */
6290
        htim->Encoder_MspInitCallback      = HAL_TIM_Encoder_MspInit;
5540
        break;
6291
        break;
5541
 
6292
 
5542
      case HAL_TIM_ENCODER_MSPDEINIT_CB_ID :
6293
      case HAL_TIM_ENCODER_MSPDEINIT_CB_ID :
-
 
6294
        /* Legacy weak Encoder Msp DeInit Callback */
5543
        htim->Encoder_MspDeInitCallback    = HAL_TIM_Encoder_MspDeInit;         /* Legacy weak Encoder Msp DeInit Callback */
6295
        htim->Encoder_MspDeInitCallback    = HAL_TIM_Encoder_MspDeInit;
5544
        break;
6296
        break;
5545
 
6297
 
5546
      case HAL_TIM_HALL_SENSOR_MSPINIT_CB_ID :
6298
      case HAL_TIM_HALL_SENSOR_MSPINIT_CB_ID :
-
 
6299
        /* Legacy weak Hall Sensor Msp Init Callback */
5547
        htim->HallSensor_MspInitCallback   = HAL_TIMEx_HallSensor_MspInit;      /* Legacy weak Hall Sensor Msp Init Callback */
6300
        htim->HallSensor_MspInitCallback   = HAL_TIMEx_HallSensor_MspInit;
5548
        break;
6301
        break;
5549
 
6302
 
5550
      case HAL_TIM_HALL_SENSOR_MSPDEINIT_CB_ID :
6303
      case HAL_TIM_HALL_SENSOR_MSPDEINIT_CB_ID :
-
 
6304
        /* Legacy weak Hall Sensor Msp DeInit Callback */
5551
        htim->HallSensor_MspDeInitCallback = HAL_TIMEx_HallSensor_MspDeInit;    /* Legacy weak Hall Sensor Msp DeInit Callback */
6305
        htim->HallSensor_MspDeInitCallback = HAL_TIMEx_HallSensor_MspDeInit;
5552
        break;
6306
        break;
5553
 
6307
 
5554
      default :
6308
      default :
5555
        /* Return error status */
6309
        /* Return error status */
5556
        status =  HAL_ERROR;
6310
        status = HAL_ERROR;
5557
        break;
6311
        break;
5558
    }
6312
    }
5559
  }
6313
  }
5560
  else
6314
  else
5561
  {
6315
  {
5562
    /* Return error status */
6316
    /* Return error status */
5563
    status =  HAL_ERROR;
6317
    status = HAL_ERROR;
5564
  }
6318
  }
5565
 
6319
 
5566
  /* Release Lock */
6320
  /* Release Lock */
5567
  __HAL_UNLOCK(htim);
6321
  __HAL_UNLOCK(htim);
5568
 
6322
 
Line 5648... Line 6402...
5648
{
6402
{
5649
  return htim->State;
6403
  return htim->State;
5650
}
6404
}
5651
 
6405
 
5652
/**
6406
/**
-
 
6407
  * @brief  Return the TIM Encoder Mode handle state.
-
 
6408
  * @param  htim TIM handle
-
 
6409
  * @retval Active channel
-
 
6410
  */
-
 
6411
HAL_TIM_ActiveChannel HAL_TIM_GetActiveChannel(TIM_HandleTypeDef *htim)
-
 
6412
{
-
 
6413
  return htim->Channel;
-
 
6414
}
-
 
6415
 
-
 
6416
/**
-
 
6417
  * @brief  Return actual state of the TIM channel.
-
 
6418
  * @param  htim TIM handle
-
 
6419
  * @param  Channel TIM Channel
-
 
6420
  *          This parameter can be one of the following values:
-
 
6421
  *            @arg TIM_CHANNEL_1: TIM Channel 1
-
 
6422
  *            @arg TIM_CHANNEL_2: TIM Channel 2
-
 
6423
  *            @arg TIM_CHANNEL_3: TIM Channel 3
-
 
6424
  *            @arg TIM_CHANNEL_4: TIM Channel 4
-
 
6425
  *            @arg TIM_CHANNEL_5: TIM Channel 5
-
 
6426
  *            @arg TIM_CHANNEL_6: TIM Channel 6
-
 
6427
  * @retval TIM Channel state
-
 
6428
  */
-
 
6429
HAL_TIM_ChannelStateTypeDef HAL_TIM_GetChannelState(TIM_HandleTypeDef *htim,  uint32_t Channel)
-
 
6430
{
-
 
6431
  HAL_TIM_ChannelStateTypeDef channel_state;
-
 
6432
 
-
 
6433
  /* Check the parameters */
-
 
6434
  assert_param(IS_TIM_CCX_INSTANCE(htim->Instance, Channel));
-
 
6435
 
-
 
6436
  channel_state = TIM_CHANNEL_STATE_GET(htim, Channel);
-
 
6437
 
-
 
6438
  return channel_state;
-
 
6439
}
-
 
6440
 
-
 
6441
/**
-
 
6442
  * @brief  Return actual state of a DMA burst operation.
-
 
6443
  * @param  htim TIM handle
-
 
6444
  * @retval DMA burst state
-
 
6445
  */
-
 
6446
HAL_TIM_DMABurstStateTypeDef HAL_TIM_DMABurstState(TIM_HandleTypeDef *htim)
-
 
6447
{
-
 
6448
  /* Check the parameters */
-
 
6449
  assert_param(IS_TIM_DMABURST_INSTANCE(htim->Instance));
-
 
6450
 
-
 
6451
  return htim->DMABurstState;
-
 
6452
}
-
 
6453
 
-
 
6454
/**
5653
  * @}
6455
  * @}
5654
  */
6456
  */
5655
 
6457
 
5656
/**
6458
/**
5657
  * @}
6459
  * @}
Line 5668... Line 6470...
5668
  */
6470
  */
5669
void TIM_DMAError(DMA_HandleTypeDef *hdma)
6471
void TIM_DMAError(DMA_HandleTypeDef *hdma)
5670
{
6472
{
5671
  TIM_HandleTypeDef *htim = (TIM_HandleTypeDef *)((DMA_HandleTypeDef *)hdma)->Parent;
6473
  TIM_HandleTypeDef *htim = (TIM_HandleTypeDef *)((DMA_HandleTypeDef *)hdma)->Parent;
5672
 
6474
 
-
 
6475
  if (hdma == htim->hdma[TIM_DMA_ID_CC1])
-
 
6476
  {
-
 
6477
    htim->Channel = HAL_TIM_ACTIVE_CHANNEL_1;
-
 
6478
    TIM_CHANNEL_STATE_SET(htim, TIM_CHANNEL_1, HAL_TIM_CHANNEL_STATE_READY);
-
 
6479
  }
-
 
6480
  else if (hdma == htim->hdma[TIM_DMA_ID_CC2])
-
 
6481
  {
-
 
6482
    htim->Channel = HAL_TIM_ACTIVE_CHANNEL_2;
-
 
6483
    TIM_CHANNEL_STATE_SET(htim, TIM_CHANNEL_2, HAL_TIM_CHANNEL_STATE_READY);
-
 
6484
  }
-
 
6485
  else if (hdma == htim->hdma[TIM_DMA_ID_CC3])
-
 
6486
  {
-
 
6487
    htim->Channel = HAL_TIM_ACTIVE_CHANNEL_3;
-
 
6488
    TIM_CHANNEL_STATE_SET(htim, TIM_CHANNEL_3, HAL_TIM_CHANNEL_STATE_READY);
-
 
6489
  }
-
 
6490
  else if (hdma == htim->hdma[TIM_DMA_ID_CC4])
-
 
6491
  {
-
 
6492
    htim->Channel = HAL_TIM_ACTIVE_CHANNEL_4;
-
 
6493
    TIM_CHANNEL_STATE_SET(htim, TIM_CHANNEL_4, HAL_TIM_CHANNEL_STATE_READY);
-
 
6494
  }
-
 
6495
  else
-
 
6496
  {
5673
  htim->State = HAL_TIM_STATE_READY;
6497
    htim->State = HAL_TIM_STATE_READY;
-
 
6498
  }
5674
 
6499
 
5675
#if (USE_HAL_TIM_REGISTER_CALLBACKS == 1)
6500
#if (USE_HAL_TIM_REGISTER_CALLBACKS == 1)
5676
  htim->ErrorCallback(htim);
6501
  htim->ErrorCallback(htim);
5677
#else
6502
#else
5678
  HAL_TIM_ErrorCallback(htim);
6503
  HAL_TIM_ErrorCallback(htim);
5679
#endif /* USE_HAL_TIM_REGISTER_CALLBACKS */
6504
#endif /* USE_HAL_TIM_REGISTER_CALLBACKS */
-
 
6505
 
-
 
6506
  htim->Channel = HAL_TIM_ACTIVE_CHANNEL_CLEARED;
5680
}
6507
}
5681
 
6508
 
5682
/**
6509
/**
5683
  * @brief  TIM DMA Delay Pulse complete callback.
6510
  * @brief  TIM DMA Delay Pulse complete callback.
5684
  * @param  hdma pointer to DMA handle.
6511
  * @param  hdma pointer to DMA handle.
5685
  * @retval None
6512
  * @retval None
5686
  */
6513
  */
5687
void TIM_DMADelayPulseCplt(DMA_HandleTypeDef *hdma)
6514
static void TIM_DMADelayPulseCplt(DMA_HandleTypeDef *hdma)
5688
{
6515
{
5689
  TIM_HandleTypeDef *htim = (TIM_HandleTypeDef *)((DMA_HandleTypeDef *)hdma)->Parent;
6516
  TIM_HandleTypeDef *htim = (TIM_HandleTypeDef *)((DMA_HandleTypeDef *)hdma)->Parent;
5690
 
6517
 
5691
  htim->State = HAL_TIM_STATE_READY;
-
 
5692
 
-
 
5693
  if (hdma == htim->hdma[TIM_DMA_ID_CC1])
6518
  if (hdma == htim->hdma[TIM_DMA_ID_CC1])
5694
  {
6519
  {
5695
    htim->Channel = HAL_TIM_ACTIVE_CHANNEL_1;
6520
    htim->Channel = HAL_TIM_ACTIVE_CHANNEL_1;
-
 
6521
 
-
 
6522
    if (hdma->Init.Mode == DMA_NORMAL)
-
 
6523
    {
-
 
6524
      TIM_CHANNEL_STATE_SET(htim, TIM_CHANNEL_1, HAL_TIM_CHANNEL_STATE_READY);
-
 
6525
    }
5696
  }
6526
  }
5697
  else if (hdma == htim->hdma[TIM_DMA_ID_CC2])
6527
  else if (hdma == htim->hdma[TIM_DMA_ID_CC2])
5698
  {
6528
  {
5699
    htim->Channel = HAL_TIM_ACTIVE_CHANNEL_2;
6529
    htim->Channel = HAL_TIM_ACTIVE_CHANNEL_2;
-
 
6530
 
-
 
6531
    if (hdma->Init.Mode == DMA_NORMAL)
-
 
6532
    {
-
 
6533
      TIM_CHANNEL_STATE_SET(htim, TIM_CHANNEL_2, HAL_TIM_CHANNEL_STATE_READY);
-
 
6534
    }
5700
  }
6535
  }
5701
  else if (hdma == htim->hdma[TIM_DMA_ID_CC3])
6536
  else if (hdma == htim->hdma[TIM_DMA_ID_CC3])
5702
  {
6537
  {
5703
    htim->Channel = HAL_TIM_ACTIVE_CHANNEL_3;
6538
    htim->Channel = HAL_TIM_ACTIVE_CHANNEL_3;
-
 
6539
 
-
 
6540
    if (hdma->Init.Mode == DMA_NORMAL)
-
 
6541
    {
-
 
6542
      TIM_CHANNEL_STATE_SET(htim, TIM_CHANNEL_3, HAL_TIM_CHANNEL_STATE_READY);
-
 
6543
    }
5704
  }
6544
  }
5705
  else if (hdma == htim->hdma[TIM_DMA_ID_CC4])
6545
  else if (hdma == htim->hdma[TIM_DMA_ID_CC4])
5706
  {
6546
  {
5707
    htim->Channel = HAL_TIM_ACTIVE_CHANNEL_4;
6547
    htim->Channel = HAL_TIM_ACTIVE_CHANNEL_4;
-
 
6548
 
-
 
6549
    if (hdma->Init.Mode == DMA_NORMAL)
-
 
6550
    {
-
 
6551
      TIM_CHANNEL_STATE_SET(htim, TIM_CHANNEL_4, HAL_TIM_CHANNEL_STATE_READY);
-
 
6552
    }
5708
  }
6553
  }
5709
  else
6554
  else
5710
  {
6555
  {
5711
    /* nothing to do */
6556
    /* nothing to do */
5712
  }
6557
  }
Line 5727... Line 6572...
5727
  */
6572
  */
5728
void TIM_DMADelayPulseHalfCplt(DMA_HandleTypeDef *hdma)
6573
void TIM_DMADelayPulseHalfCplt(DMA_HandleTypeDef *hdma)
5729
{
6574
{
5730
  TIM_HandleTypeDef *htim = (TIM_HandleTypeDef *)((DMA_HandleTypeDef *)hdma)->Parent;
6575
  TIM_HandleTypeDef *htim = (TIM_HandleTypeDef *)((DMA_HandleTypeDef *)hdma)->Parent;
5731
 
6576
 
5732
  htim->State = HAL_TIM_STATE_READY;
-
 
5733
 
-
 
5734
  if (hdma == htim->hdma[TIM_DMA_ID_CC1])
6577
  if (hdma == htim->hdma[TIM_DMA_ID_CC1])
5735
  {
6578
  {
5736
    htim->Channel = HAL_TIM_ACTIVE_CHANNEL_1;
6579
    htim->Channel = HAL_TIM_ACTIVE_CHANNEL_1;
5737
  }
6580
  }
5738
  else if (hdma == htim->hdma[TIM_DMA_ID_CC2])
6581
  else if (hdma == htim->hdma[TIM_DMA_ID_CC2])
Line 5768... Line 6611...
5768
  */
6611
  */
5769
void TIM_DMACaptureCplt(DMA_HandleTypeDef *hdma)
6612
void TIM_DMACaptureCplt(DMA_HandleTypeDef *hdma)
5770
{
6613
{
5771
  TIM_HandleTypeDef *htim = (TIM_HandleTypeDef *)((DMA_HandleTypeDef *)hdma)->Parent;
6614
  TIM_HandleTypeDef *htim = (TIM_HandleTypeDef *)((DMA_HandleTypeDef *)hdma)->Parent;
5772
 
6615
 
5773
  htim->State = HAL_TIM_STATE_READY;
-
 
5774
 
-
 
5775
  if (hdma == htim->hdma[TIM_DMA_ID_CC1])
6616
  if (hdma == htim->hdma[TIM_DMA_ID_CC1])
5776
  {
6617
  {
5777
    htim->Channel = HAL_TIM_ACTIVE_CHANNEL_1;
6618
    htim->Channel = HAL_TIM_ACTIVE_CHANNEL_1;
-
 
6619
 
-
 
6620
    if (hdma->Init.Mode == DMA_NORMAL)
-
 
6621
    {
-
 
6622
      TIM_CHANNEL_STATE_SET(htim, TIM_CHANNEL_1, HAL_TIM_CHANNEL_STATE_READY);
-
 
6623
      TIM_CHANNEL_N_STATE_SET(htim, TIM_CHANNEL_1, HAL_TIM_CHANNEL_STATE_READY);
-
 
6624
    }
5778
  }
6625
  }
5779
  else if (hdma == htim->hdma[TIM_DMA_ID_CC2])
6626
  else if (hdma == htim->hdma[TIM_DMA_ID_CC2])
5780
  {
6627
  {
5781
    htim->Channel = HAL_TIM_ACTIVE_CHANNEL_2;
6628
    htim->Channel = HAL_TIM_ACTIVE_CHANNEL_2;
-
 
6629
 
-
 
6630
    if (hdma->Init.Mode == DMA_NORMAL)
-
 
6631
    {
-
 
6632
      TIM_CHANNEL_STATE_SET(htim, TIM_CHANNEL_2, HAL_TIM_CHANNEL_STATE_READY);
-
 
6633
      TIM_CHANNEL_N_STATE_SET(htim, TIM_CHANNEL_2, HAL_TIM_CHANNEL_STATE_READY);
-
 
6634
    }
5782
  }
6635
  }
5783
  else if (hdma == htim->hdma[TIM_DMA_ID_CC3])
6636
  else if (hdma == htim->hdma[TIM_DMA_ID_CC3])
5784
  {
6637
  {
5785
    htim->Channel = HAL_TIM_ACTIVE_CHANNEL_3;
6638
    htim->Channel = HAL_TIM_ACTIVE_CHANNEL_3;
-
 
6639
 
-
 
6640
    if (hdma->Init.Mode == DMA_NORMAL)
-
 
6641
    {
-
 
6642
      TIM_CHANNEL_STATE_SET(htim, TIM_CHANNEL_3, HAL_TIM_CHANNEL_STATE_READY);
-
 
6643
      TIM_CHANNEL_N_STATE_SET(htim, TIM_CHANNEL_3, HAL_TIM_CHANNEL_STATE_READY);
-
 
6644
    }
5786
  }
6645
  }
5787
  else if (hdma == htim->hdma[TIM_DMA_ID_CC4])
6646
  else if (hdma == htim->hdma[TIM_DMA_ID_CC4])
5788
  {
6647
  {
5789
    htim->Channel = HAL_TIM_ACTIVE_CHANNEL_4;
6648
    htim->Channel = HAL_TIM_ACTIVE_CHANNEL_4;
-
 
6649
 
-
 
6650
    if (hdma->Init.Mode == DMA_NORMAL)
-
 
6651
    {
-
 
6652
      TIM_CHANNEL_STATE_SET(htim, TIM_CHANNEL_4, HAL_TIM_CHANNEL_STATE_READY);
-
 
6653
      TIM_CHANNEL_N_STATE_SET(htim, TIM_CHANNEL_4, HAL_TIM_CHANNEL_STATE_READY);
-
 
6654
    }
5790
  }
6655
  }
5791
  else
6656
  else
5792
  {
6657
  {
5793
    /* nothing to do */
6658
    /* nothing to do */
5794
  }
6659
  }
Line 5809... Line 6674...
5809
  */
6674
  */
5810
void TIM_DMACaptureHalfCplt(DMA_HandleTypeDef *hdma)
6675
void TIM_DMACaptureHalfCplt(DMA_HandleTypeDef *hdma)
5811
{
6676
{
5812
  TIM_HandleTypeDef *htim = (TIM_HandleTypeDef *)((DMA_HandleTypeDef *)hdma)->Parent;
6677
  TIM_HandleTypeDef *htim = (TIM_HandleTypeDef *)((DMA_HandleTypeDef *)hdma)->Parent;
5813
 
6678
 
5814
  htim->State = HAL_TIM_STATE_READY;
-
 
5815
 
-
 
5816
  if (hdma == htim->hdma[TIM_DMA_ID_CC1])
6679
  if (hdma == htim->hdma[TIM_DMA_ID_CC1])
5817
  {
6680
  {
5818
    htim->Channel = HAL_TIM_ACTIVE_CHANNEL_1;
6681
    htim->Channel = HAL_TIM_ACTIVE_CHANNEL_1;
5819
  }
6682
  }
5820
  else if (hdma == htim->hdma[TIM_DMA_ID_CC2])
6683
  else if (hdma == htim->hdma[TIM_DMA_ID_CC2])
Line 5850... Line 6713...
5850
  */
6713
  */
5851
static void TIM_DMAPeriodElapsedCplt(DMA_HandleTypeDef *hdma)
6714
static void TIM_DMAPeriodElapsedCplt(DMA_HandleTypeDef *hdma)
5852
{
6715
{
5853
  TIM_HandleTypeDef *htim = (TIM_HandleTypeDef *)((DMA_HandleTypeDef *)hdma)->Parent;
6716
  TIM_HandleTypeDef *htim = (TIM_HandleTypeDef *)((DMA_HandleTypeDef *)hdma)->Parent;
5854
 
6717
 
-
 
6718
  if (htim->hdma[TIM_DMA_ID_UPDATE]->Init.Mode == DMA_NORMAL)
-
 
6719
  {
5855
  htim->State = HAL_TIM_STATE_READY;
6720
    htim->State = HAL_TIM_STATE_READY;
-
 
6721
  }
5856
 
6722
 
5857
#if (USE_HAL_TIM_REGISTER_CALLBACKS == 1)
6723
#if (USE_HAL_TIM_REGISTER_CALLBACKS == 1)
5858
  htim->PeriodElapsedCallback(htim);
6724
  htim->PeriodElapsedCallback(htim);
5859
#else
6725
#else
5860
  HAL_TIM_PeriodElapsedCallback(htim);
6726
  HAL_TIM_PeriodElapsedCallback(htim);
Line 5868... Line 6734...
5868
  */
6734
  */
5869
static void TIM_DMAPeriodElapsedHalfCplt(DMA_HandleTypeDef *hdma)
6735
static void TIM_DMAPeriodElapsedHalfCplt(DMA_HandleTypeDef *hdma)
5870
{
6736
{
5871
  TIM_HandleTypeDef *htim = (TIM_HandleTypeDef *)((DMA_HandleTypeDef *)hdma)->Parent;
6737
  TIM_HandleTypeDef *htim = (TIM_HandleTypeDef *)((DMA_HandleTypeDef *)hdma)->Parent;
5872
 
6738
 
5873
  htim->State = HAL_TIM_STATE_READY;
-
 
5874
 
-
 
5875
#if (USE_HAL_TIM_REGISTER_CALLBACKS == 1)
6739
#if (USE_HAL_TIM_REGISTER_CALLBACKS == 1)
5876
  htim->PeriodElapsedHalfCpltCallback(htim);
6740
  htim->PeriodElapsedHalfCpltCallback(htim);
5877
#else
6741
#else
5878
  HAL_TIM_PeriodElapsedHalfCpltCallback(htim);
6742
  HAL_TIM_PeriodElapsedHalfCpltCallback(htim);
5879
#endif /* USE_HAL_TIM_REGISTER_CALLBACKS */
6743
#endif /* USE_HAL_TIM_REGISTER_CALLBACKS */
Line 5886... Line 6750...
5886
  */
6750
  */
5887
static void TIM_DMATriggerCplt(DMA_HandleTypeDef *hdma)
6751
static void TIM_DMATriggerCplt(DMA_HandleTypeDef *hdma)
5888
{
6752
{
5889
  TIM_HandleTypeDef *htim = (TIM_HandleTypeDef *)((DMA_HandleTypeDef *)hdma)->Parent;
6753
  TIM_HandleTypeDef *htim = (TIM_HandleTypeDef *)((DMA_HandleTypeDef *)hdma)->Parent;
5890
 
6754
 
-
 
6755
  if (htim->hdma[TIM_DMA_ID_TRIGGER]->Init.Mode == DMA_NORMAL)
-
 
6756
  {
5891
  htim->State = HAL_TIM_STATE_READY;
6757
    htim->State = HAL_TIM_STATE_READY;
-
 
6758
  }
5892
 
6759
 
5893
#if (USE_HAL_TIM_REGISTER_CALLBACKS == 1)
6760
#if (USE_HAL_TIM_REGISTER_CALLBACKS == 1)
5894
  htim->TriggerCallback(htim);
6761
  htim->TriggerCallback(htim);
5895
#else
6762
#else
5896
  HAL_TIM_TriggerCallback(htim);
6763
  HAL_TIM_TriggerCallback(htim);
Line 5904... Line 6771...
5904
  */
6771
  */
5905
static void TIM_DMATriggerHalfCplt(DMA_HandleTypeDef *hdma)
6772
static void TIM_DMATriggerHalfCplt(DMA_HandleTypeDef *hdma)
5906
{
6773
{
5907
  TIM_HandleTypeDef *htim = (TIM_HandleTypeDef *)((DMA_HandleTypeDef *)hdma)->Parent;
6774
  TIM_HandleTypeDef *htim = (TIM_HandleTypeDef *)((DMA_HandleTypeDef *)hdma)->Parent;
5908
 
6775
 
5909
  htim->State = HAL_TIM_STATE_READY;
-
 
5910
 
-
 
5911
#if (USE_HAL_TIM_REGISTER_CALLBACKS == 1)
6776
#if (USE_HAL_TIM_REGISTER_CALLBACKS == 1)
5912
  htim->TriggerHalfCpltCallback(htim);
6777
  htim->TriggerHalfCpltCallback(htim);
5913
#else
6778
#else
5914
  HAL_TIM_TriggerHalfCpltCallback(htim);
6779
  HAL_TIM_TriggerHalfCpltCallback(htim);
5915
#endif /* USE_HAL_TIM_REGISTER_CALLBACKS */
6780
#endif /* USE_HAL_TIM_REGISTER_CALLBACKS */
Line 5964... Line 6829...
5964
}
6829
}
5965
 
6830
 
5966
/**
6831
/**
5967
  * @brief  Timer Output Compare 1 configuration
6832
  * @brief  Timer Output Compare 1 configuration
5968
  * @param  TIMx to select the TIM peripheral
6833
  * @param  TIMx to select the TIM peripheral
5969
  * @param  OC_Config The ouput configuration structure
6834
  * @param  OC_Config The output configuration structure
5970
  * @retval None
6835
  * @retval None
5971
  */
6836
  */
5972
static void TIM_OC1_SetConfig(TIM_TypeDef *TIMx, TIM_OC_InitTypeDef *OC_Config)
6837
static void TIM_OC1_SetConfig(TIM_TypeDef *TIMx, TIM_OC_InitTypeDef *OC_Config)
5973
{
6838
{
5974
  uint32_t tmpccmrx;
6839
  uint32_t tmpccmrx;
Line 6039... Line 6904...
6039
}
6904
}
6040
 
6905
 
6041
/**
6906
/**
6042
  * @brief  Timer Output Compare 2 configuration
6907
  * @brief  Timer Output Compare 2 configuration
6043
  * @param  TIMx to select the TIM peripheral
6908
  * @param  TIMx to select the TIM peripheral
6044
  * @param  OC_Config The ouput configuration structure
6909
  * @param  OC_Config The output configuration structure
6045
  * @retval None
6910
  * @retval None
6046
  */
6911
  */
6047
void TIM_OC2_SetConfig(TIM_TypeDef *TIMx, TIM_OC_InitTypeDef *OC_Config)
6912
void TIM_OC2_SetConfig(TIM_TypeDef *TIMx, TIM_OC_InitTypeDef *OC_Config)
6048
{
6913
{
6049
  uint32_t tmpccmrx;
6914
  uint32_t tmpccmrx;
Line 6115... Line 6980...
6115
}
6980
}
6116
 
6981
 
6117
/**
6982
/**
6118
  * @brief  Timer Output Compare 3 configuration
6983
  * @brief  Timer Output Compare 3 configuration
6119
  * @param  TIMx to select the TIM peripheral
6984
  * @param  TIMx to select the TIM peripheral
6120
  * @param  OC_Config The ouput configuration structure
6985
  * @param  OC_Config The output configuration structure
6121
  * @retval None
6986
  * @retval None
6122
  */
6987
  */
6123
static void TIM_OC3_SetConfig(TIM_TypeDef *TIMx, TIM_OC_InitTypeDef *OC_Config)
6988
static void TIM_OC3_SetConfig(TIM_TypeDef *TIMx, TIM_OC_InitTypeDef *OC_Config)
6124
{
6989
{
6125
  uint32_t tmpccmrx;
6990
  uint32_t tmpccmrx;
Line 6189... Line 7054...
6189
}
7054
}
6190
 
7055
 
6191
/**
7056
/**
6192
  * @brief  Timer Output Compare 4 configuration
7057
  * @brief  Timer Output Compare 4 configuration
6193
  * @param  TIMx to select the TIM peripheral
7058
  * @param  TIMx to select the TIM peripheral
6194
  * @param  OC_Config The ouput configuration structure
7059
  * @param  OC_Config The output configuration structure
6195
  * @retval None
7060
  * @retval None
6196
  */
7061
  */
6197
static void TIM_OC4_SetConfig(TIM_TypeDef *TIMx, TIM_OC_InitTypeDef *OC_Config)
7062
static void TIM_OC4_SetConfig(TIM_TypeDef *TIMx, TIM_OC_InitTypeDef *OC_Config)
6198
{
7063
{
6199
  uint32_t tmpccmrx;
7064
  uint32_t tmpccmrx;
Line 6255... Line 7120...
6255
  * @retval None
7120
  * @retval None
6256
  */
7121
  */
6257
static HAL_StatusTypeDef TIM_SlaveTimer_SetConfig(TIM_HandleTypeDef *htim,
7122
static HAL_StatusTypeDef TIM_SlaveTimer_SetConfig(TIM_HandleTypeDef *htim,
6258
                                                  TIM_SlaveConfigTypeDef *sSlaveConfig)
7123
                                                  TIM_SlaveConfigTypeDef *sSlaveConfig)
6259
{
7124
{
-
 
7125
  HAL_StatusTypeDef status = HAL_OK;
6260
  uint32_t tmpsmcr;
7126
  uint32_t tmpsmcr;
6261
  uint32_t tmpccmr1;
7127
  uint32_t tmpccmr1;
6262
  uint32_t tmpccer;
7128
  uint32_t tmpccer;
6263
 
7129
 
6264
  /* Get the TIMx SMCR register value */
7130
  /* Get the TIMx SMCR register value */
Line 6299... Line 7165...
6299
    {
7165
    {
6300
      /* Check the parameters */
7166
      /* Check the parameters */
6301
      assert_param(IS_TIM_CC1_INSTANCE(htim->Instance));
7167
      assert_param(IS_TIM_CC1_INSTANCE(htim->Instance));
6302
      assert_param(IS_TIM_TRIGGERFILTER(sSlaveConfig->TriggerFilter));
7168
      assert_param(IS_TIM_TRIGGERFILTER(sSlaveConfig->TriggerFilter));
6303
 
7169
 
6304
      if(sSlaveConfig->SlaveMode == TIM_SLAVEMODE_GATED)
7170
      if (sSlaveConfig->SlaveMode == TIM_SLAVEMODE_GATED)
6305
      {
7171
      {
6306
        return HAL_ERROR;
7172
        return HAL_ERROR;
6307
      }
7173
      }
6308
 
7174
 
6309
      /* Disable the Channel 1: Reset the CC1E Bit */
7175
      /* Disable the Channel 1: Reset the CC1E Bit */
Line 6358... Line 7224...
6358
      assert_param(IS_TIM_CC2_INSTANCE(htim->Instance));
7224
      assert_param(IS_TIM_CC2_INSTANCE(htim->Instance));
6359
      break;
7225
      break;
6360
    }
7226
    }
6361
 
7227
 
6362
    default:
7228
    default:
-
 
7229
      status = HAL_ERROR;
6363
      break;
7230
      break;
6364
  }
7231
  }
-
 
7232
 
6365
  return HAL_OK;
7233
  return status;
6366
}
7234
}
6367
 
7235
 
6368
/**
7236
/**
6369
  * @brief  Configure the TI1 as Input.
7237
  * @brief  Configure the TI1 as Input.
6370
  * @param  TIMx to select the TIM peripheral.
7238
  * @param  TIMx to select the TIM peripheral.
Line 6734... Line 7602...
6734
  * @retval None
7602
  * @retval None
6735
  */
7603
  */
6736
void TIM_ResetCallback(TIM_HandleTypeDef *htim)
7604
void TIM_ResetCallback(TIM_HandleTypeDef *htim)
6737
{
7605
{
6738
  /* Reset the TIM callback to the legacy weak callbacks */
7606
  /* Reset the TIM callback to the legacy weak callbacks */
6739
  htim->PeriodElapsedCallback             = HAL_TIM_PeriodElapsedCallback;             /* Legacy weak PeriodElapsedCallback             */
7607
  htim->PeriodElapsedCallback             = HAL_TIM_PeriodElapsedCallback;
6740
  htim->PeriodElapsedHalfCpltCallback     = HAL_TIM_PeriodElapsedHalfCpltCallback;     /* Legacy weak PeriodElapsedHalfCpltCallback     */
7608
  htim->PeriodElapsedHalfCpltCallback     = HAL_TIM_PeriodElapsedHalfCpltCallback;
6741
  htim->TriggerCallback                   = HAL_TIM_TriggerCallback;                   /* Legacy weak TriggerCallback                   */
7609
  htim->TriggerCallback                   = HAL_TIM_TriggerCallback;
6742
  htim->TriggerHalfCpltCallback           = HAL_TIM_TriggerHalfCpltCallback;           /* Legacy weak TriggerHalfCpltCallback           */
7610
  htim->TriggerHalfCpltCallback           = HAL_TIM_TriggerHalfCpltCallback;
6743
  htim->IC_CaptureCallback                = HAL_TIM_IC_CaptureCallback;                /* Legacy weak IC_CaptureCallback                */
7611
  htim->IC_CaptureCallback                = HAL_TIM_IC_CaptureCallback;
6744
  htim->IC_CaptureHalfCpltCallback        = HAL_TIM_IC_CaptureHalfCpltCallback;        /* Legacy weak IC_CaptureHalfCpltCallback        */
7612
  htim->IC_CaptureHalfCpltCallback        = HAL_TIM_IC_CaptureHalfCpltCallback;
6745
  htim->OC_DelayElapsedCallback           = HAL_TIM_OC_DelayElapsedCallback;           /* Legacy weak OC_DelayElapsedCallback           */
7613
  htim->OC_DelayElapsedCallback           = HAL_TIM_OC_DelayElapsedCallback;
6746
  htim->PWM_PulseFinishedCallback         = HAL_TIM_PWM_PulseFinishedCallback;         /* Legacy weak PWM_PulseFinishedCallback         */
7614
  htim->PWM_PulseFinishedCallback         = HAL_TIM_PWM_PulseFinishedCallback;
6747
  htim->PWM_PulseFinishedHalfCpltCallback = HAL_TIM_PWM_PulseFinishedHalfCpltCallback; /* Legacy weak PWM_PulseFinishedHalfCpltCallback */
7615
  htim->PWM_PulseFinishedHalfCpltCallback = HAL_TIM_PWM_PulseFinishedHalfCpltCallback;
6748
  htim->ErrorCallback                     = HAL_TIM_ErrorCallback;                     /* Legacy weak ErrorCallback                     */
7616
  htim->ErrorCallback                     = HAL_TIM_ErrorCallback;
6749
  htim->CommutationCallback               = HAL_TIMEx_CommutCallback;                  /* Legacy weak CommutationCallback               */
7617
  htim->CommutationCallback               = HAL_TIMEx_CommutCallback;
6750
  htim->CommutationHalfCpltCallback       = HAL_TIMEx_CommutHalfCpltCallback;          /* Legacy weak CommutationHalfCpltCallback       */
7618
  htim->CommutationHalfCpltCallback       = HAL_TIMEx_CommutHalfCpltCallback;
6751
  htim->BreakCallback                     = HAL_TIMEx_BreakCallback;                   /* Legacy weak BreakCallback                     */
7619
  htim->BreakCallback                     = HAL_TIMEx_BreakCallback;
6752
}
7620
}
6753
#endif /* USE_HAL_TIM_REGISTER_CALLBACKS */
7621
#endif /* USE_HAL_TIM_REGISTER_CALLBACKS */
6754
 
7622
 
6755
/**
7623
/**
6756
  * @}
7624
  * @}