STM32F769IDiscovery  1.00
uDANTE Audio Networking with STM32F7 DISCO board
stm32f7xx_hal_tim.c
Go to the documentation of this file.
1 
128 /* Includes ------------------------------------------------------------------*/
129 #include "stm32f7xx_hal.h"
130 
140 #ifdef HAL_TIM_MODULE_ENABLED
141 
142 /* Private typedef -----------------------------------------------------------*/
143 /* Private define ------------------------------------------------------------*/
144 /* Private macro -------------------------------------------------------------*/
145 /* Private variables ---------------------------------------------------------*/
149 /* Private function prototypes -----------------------------------------------*/
150 static void TIM_TI1_ConfigInputStage(TIM_TypeDef *TIMx, uint32_t TIM_ICPolarity, uint32_t TIM_ICFilter);
151 static void TIM_TI2_SetConfig(TIM_TypeDef *TIMx, uint32_t TIM_ICPolarity, uint32_t TIM_ICSelection,
152  uint32_t TIM_ICFilter);
153 static void TIM_TI2_ConfigInputStage(TIM_TypeDef *TIMx, uint32_t TIM_ICPolarity, uint32_t TIM_ICFilter);
154 static void TIM_TI3_SetConfig(TIM_TypeDef *TIMx, uint32_t TIM_ICPolarity, uint32_t TIM_ICSelection,
155  uint32_t TIM_ICFilter);
156 static void TIM_TI4_SetConfig(TIM_TypeDef *TIMx, uint32_t TIM_ICPolarity, uint32_t TIM_ICSelection,
157  uint32_t TIM_ICFilter);
158 
159 static void TIM_ITRx_SetConfig(TIM_TypeDef* TIMx, uint16_t TIM_ITRx);
160 static void TIM_DMAPeriodElapsedCplt(DMA_HandleTypeDef *hdma);
161 static void TIM_DMATriggerCplt(DMA_HandleTypeDef *hdma);
162 static void TIM_SlaveTimer_SetConfig(TIM_HandleTypeDef *htim,
163  TIM_SlaveConfigTypeDef * sSlaveConfig);
168 /* Exported functions --------------------------------------------------------*/
202 {
203  /* Check the TIM handle allocation */
204  if(htim == NULL)
205  {
206  return HAL_ERROR;
207  }
208 
209  /* Check the parameters */
213 
214  if(htim->State == HAL_TIM_STATE_RESET)
215  {
216  /* Init the low level hardware : GPIO, CLOCK, NVIC */
217  HAL_TIM_Base_MspInit(htim);
218  }
219 
220  /* Set the TIM state */
221  htim->State= HAL_TIM_STATE_BUSY;
222 
223  /* Set the Time Base configuration */
224  TIM_Base_SetConfig(htim->Instance, &htim->Init);
225 
226  /* Initialize the TIM state*/
227  htim->State= HAL_TIM_STATE_READY;
228 
229  return HAL_OK;
230 }
231 
239 {
240  /* Check the parameters */
242 
243  htim->State = HAL_TIM_STATE_BUSY;
244 
245  /* Disable the TIM Peripheral Clock */
246  __HAL_TIM_DISABLE(htim);
247 
248  /* DeInit the low level hardware: GPIO, CLOCK, NVIC */
250 
251  /* Change TIM state */
252  htim->State = HAL_TIM_STATE_RESET;
253 
254  /* Release Lock */
255  __HAL_UNLOCK(htim);
256 
257  return HAL_OK;
258 }
259 
266 __weak void HAL_TIM_Base_MspInit(TIM_HandleTypeDef *htim)
267 {
268  /* Prevent unused argument(s) compilation warning */
269  UNUSED(htim);
270 
271  /* NOTE : This function Should not be modified, when the callback is needed,
272  the HAL_TIM_Base_MspInit could be implemented in the user file
273  */
274 }
275 
282 __weak void HAL_TIM_Base_MspDeInit(TIM_HandleTypeDef *htim)
283 {
284  /* Prevent unused argument(s) compilation warning */
285  UNUSED(htim);
286 
287  /* NOTE : This function Should not be modified, when the callback is needed,
288  the HAL_TIM_Base_MspDeInit could be implemented in the user file
289  */
290 }
291 
299 {
300  /* Check the parameters */
302 
303  /* Set the TIM state */
304  htim->State= HAL_TIM_STATE_BUSY;
305 
306  /* Enable the Peripheral */
307  __HAL_TIM_ENABLE(htim);
308 
309  /* Change the TIM state*/
310  htim->State= HAL_TIM_STATE_READY;
311 
312  /* Return function status */
313  return HAL_OK;
314 }
315 
323 {
324  /* Check the parameters */
326 
327  /* Set the TIM state */
328  htim->State= HAL_TIM_STATE_BUSY;
329 
330  /* Disable the Peripheral */
331  __HAL_TIM_DISABLE(htim);
332 
333  /* Change the TIM state*/
334  htim->State= HAL_TIM_STATE_READY;
335 
336  /* Return function status */
337  return HAL_OK;
338 }
339 
347 {
348  /* Check the parameters */
350 
351  /* Enable the TIM Update interrupt */
353 
354  /* Enable the Peripheral */
355  __HAL_TIM_ENABLE(htim);
356 
357  /* Return function status */
358  return HAL_OK;
359 }
360 
368 {
369  /* Check the parameters */
371  /* Disable the TIM Update interrupt */
373 
374  /* Disable the Peripheral */
375  __HAL_TIM_DISABLE(htim);
376 
377  /* Return function status */
378  return HAL_OK;
379 }
380 
389 HAL_StatusTypeDef HAL_TIM_Base_Start_DMA(TIM_HandleTypeDef *htim, uint32_t *pData, uint16_t Length)
390 {
391  /* Check the parameters */
393 
394  if((htim->State == HAL_TIM_STATE_BUSY))
395  {
396  return HAL_BUSY;
397  }
398  else if((htim->State == HAL_TIM_STATE_READY))
399  {
400  if((pData == 0 ) && (Length > 0))
401  {
402  return HAL_ERROR;
403  }
404  else
405  {
406  htim->State = HAL_TIM_STATE_BUSY;
407  }
408  }
409  /* Set the DMA Period elapsed callback */
410  htim->hdma[TIM_DMA_ID_UPDATE]->XferCpltCallback = TIM_DMAPeriodElapsedCplt;
411 
412  /* Set the DMA error callback */
414 
415  /* Enable the DMA Stream */
416  HAL_DMA_Start_IT(htim->hdma[TIM_DMA_ID_UPDATE], (uint32_t)pData, (uint32_t)&htim->Instance->ARR, Length);
417 
418  /* Enable the TIM Update DMA request */
420 
421  /* Enable the Peripheral */
422  __HAL_TIM_ENABLE(htim);
423 
424  /* Return function status */
425  return HAL_OK;
426 }
427 
435 {
436  /* Check the parameters */
438 
439  /* Disable the TIM Update DMA request */
441 
442  /* Disable the Peripheral */
443  __HAL_TIM_DISABLE(htim);
444 
445  /* Change the htim state */
446  htim->State = HAL_TIM_STATE_READY;
447 
448  /* Return function status */
449  return HAL_OK;
450 }
451 
485 {
486  /* Check the TIM handle allocation */
487  if(htim == NULL)
488  {
489  return HAL_ERROR;
490  }
491 
492  /* Check the parameters */
496 
497  if(htim->State == HAL_TIM_STATE_RESET)
498  {
499  /* Allocate lock resource and initialize it */
500  htim->Lock = HAL_UNLOCKED;
501  /* Init the low level hardware : GPIO, CLOCK, NVIC and DMA */
502  HAL_TIM_OC_MspInit(htim);
503  }
504 
505  /* Set the TIM state */
506  htim->State= HAL_TIM_STATE_BUSY;
507 
508  /* Init the base time for the Output Compare */
509  TIM_Base_SetConfig(htim->Instance, &htim->Init);
510 
511  /* Initialize the TIM state*/
512  htim->State= HAL_TIM_STATE_READY;
513 
514  return HAL_OK;
515 }
516 
524 {
525  /* Check the parameters */
527 
528  htim->State = HAL_TIM_STATE_BUSY;
529 
530  /* Disable the TIM Peripheral Clock */
531  __HAL_TIM_DISABLE(htim);
532 
533  /* DeInit the low level hardware: GPIO, CLOCK, NVIC and DMA */
534  HAL_TIM_OC_MspDeInit(htim);
535 
536  /* Change TIM state */
537  htim->State = HAL_TIM_STATE_RESET;
538 
539  /* Release Lock */
540  __HAL_UNLOCK(htim);
541 
542  return HAL_OK;
543 }
544 
551 __weak void HAL_TIM_OC_MspInit(TIM_HandleTypeDef *htim)
552 {
553  /* Prevent unused argument(s) compilation warning */
554  UNUSED(htim);
555 
556  /* NOTE : This function Should not be modified, when the callback is needed,
557  the HAL_TIM_OC_MspInit could be implemented in the user file
558  */
559 }
560 
567 __weak void HAL_TIM_OC_MspDeInit(TIM_HandleTypeDef *htim)
568 {
569  /* Prevent unused argument(s) compilation warning */
570  UNUSED(htim);
571 
572  /* NOTE : This function Should not be modified, when the callback is needed,
573  the HAL_TIM_OC_MspDeInit could be implemented in the user file
574  */
575 }
576 
590 {
591  /* Check the parameters */
592  assert_param(IS_TIM_CCX_INSTANCE(htim->Instance, Channel));
593 
594  /* Enable the Output compare channel */
595  TIM_CCxChannelCmd(htim->Instance, Channel, TIM_CCx_ENABLE);
596 
598  {
599  /* Enable the main output */
600  __HAL_TIM_MOE_ENABLE(htim);
601  }
602 
603  /* Enable the Peripheral */
604  __HAL_TIM_ENABLE(htim);
605 
606  /* Return function status */
607  return HAL_OK;
608 }
609 
622 HAL_StatusTypeDef HAL_TIM_OC_Stop(TIM_HandleTypeDef *htim, uint32_t Channel)
623 {
624  /* Check the parameters */
625  assert_param(IS_TIM_CCX_INSTANCE(htim->Instance, Channel));
626 
627  /* Disable the Output compare channel */
628  TIM_CCxChannelCmd(htim->Instance, Channel, TIM_CCx_DISABLE);
629 
631  {
632  /* Disable the Main Output */
633  __HAL_TIM_MOE_DISABLE(htim);
634  }
635 
636  /* Disable the Peripheral */
637  __HAL_TIM_DISABLE(htim);
638 
639  /* Return function status */
640  return HAL_OK;
641 }
642 
656 {
657  /* Check the parameters */
658  assert_param(IS_TIM_CCX_INSTANCE(htim->Instance, Channel));
659 
660  switch (Channel)
661  {
662  case TIM_CHANNEL_1:
663  {
664  /* Enable the TIM Capture/Compare 1 interrupt */
666  }
667  break;
668 
669  case TIM_CHANNEL_2:
670  {
671  /* Enable the TIM Capture/Compare 2 interrupt */
673  }
674  break;
675 
676  case TIM_CHANNEL_3:
677  {
678  /* Enable the TIM Capture/Compare 3 interrupt */
680  }
681  break;
682 
683  case TIM_CHANNEL_4:
684  {
685  /* Enable the TIM Capture/Compare 4 interrupt */
687  }
688  break;
689 
690  default:
691  break;
692  }
693 
694  /* Enable the Output compare channel */
695  TIM_CCxChannelCmd(htim->Instance, Channel, TIM_CCx_ENABLE);
696 
698  {
699  /* Enable the main output */
700  __HAL_TIM_MOE_ENABLE(htim);
701  }
702 
703  /* Enable the Peripheral */
704  __HAL_TIM_ENABLE(htim);
705 
706  /* Return function status */
707  return HAL_OK;
708 }
709 
723 {
724  /* Check the parameters */
725  assert_param(IS_TIM_CCX_INSTANCE(htim->Instance, Channel));
726 
727  switch (Channel)
728  {
729  case TIM_CHANNEL_1:
730  {
731  /* Disable the TIM Capture/Compare 1 interrupt */
733  }
734  break;
735 
736  case TIM_CHANNEL_2:
737  {
738  /* Disable the TIM Capture/Compare 2 interrupt */
740  }
741  break;
742 
743  case TIM_CHANNEL_3:
744  {
745  /* Disable the TIM Capture/Compare 3 interrupt */
747  }
748  break;
749 
750  case TIM_CHANNEL_4:
751  {
752  /* Disable the TIM Capture/Compare 4 interrupt */
754  }
755  break;
756 
757  default:
758  break;
759  }
760 
761  /* Disable the Output compare channel */
762  TIM_CCxChannelCmd(htim->Instance, Channel, TIM_CCx_DISABLE);
763 
765  {
766  /* Disable the Main Output */
767  __HAL_TIM_MOE_DISABLE(htim);
768  }
769 
770  /* Disable the Peripheral */
771  __HAL_TIM_DISABLE(htim);
772 
773  /* Return function status */
774  return HAL_OK;
775 }
776 
791 HAL_StatusTypeDef HAL_TIM_OC_Start_DMA(TIM_HandleTypeDef *htim, uint32_t Channel, uint32_t *pData, uint16_t Length)
792 {
793  /* Check the parameters */
794  assert_param(IS_TIM_CCX_INSTANCE(htim->Instance, Channel));
795 
796  if((htim->State == HAL_TIM_STATE_BUSY))
797  {
798  return HAL_BUSY;
799  }
800  else if((htim->State == HAL_TIM_STATE_READY))
801  {
802  if(((uint32_t)pData == 0 ) && (Length > 0))
803  {
804  return HAL_ERROR;
805  }
806  else
807  {
808  htim->State = HAL_TIM_STATE_BUSY;
809  }
810  }
811  switch (Channel)
812  {
813  case TIM_CHANNEL_1:
814  {
815  /* Set the DMA Period elapsed callback */
817 
818  /* Set the DMA error callback */
820 
821  /* Enable the DMA Stream */
822  HAL_DMA_Start_IT(htim->hdma[TIM_DMA_ID_CC1], (uint32_t)pData, (uint32_t)&htim->Instance->CCR1, Length);
823 
824  /* Enable the TIM Capture/Compare 1 DMA request */
826  }
827  break;
828 
829  case TIM_CHANNEL_2:
830  {
831  /* Set the DMA Period elapsed callback */
833 
834  /* Set the DMA error callback */
836 
837  /* Enable the DMA Stream */
838  HAL_DMA_Start_IT(htim->hdma[TIM_DMA_ID_CC2], (uint32_t)pData, (uint32_t)&htim->Instance->CCR2, Length);
839 
840  /* Enable the TIM Capture/Compare 2 DMA request */
842  }
843  break;
844 
845  case TIM_CHANNEL_3:
846  {
847  /* Set the DMA Period elapsed callback */
849 
850  /* Set the DMA error callback */
852 
853  /* Enable the DMA Stream */
854  HAL_DMA_Start_IT(htim->hdma[TIM_DMA_ID_CC3], (uint32_t)pData, (uint32_t)&htim->Instance->CCR3,Length);
855 
856  /* Enable the TIM Capture/Compare 3 DMA request */
858  }
859  break;
860 
861  case TIM_CHANNEL_4:
862  {
863  /* Set the DMA Period elapsed callback */
865 
866  /* Set the DMA error callback */
868 
869  /* Enable the DMA Stream */
870  HAL_DMA_Start_IT(htim->hdma[TIM_DMA_ID_CC4], (uint32_t)pData, (uint32_t)&htim->Instance->CCR4, Length);
871 
872  /* Enable the TIM Capture/Compare 4 DMA request */
874  }
875  break;
876 
877  default:
878  break;
879  }
880 
881  /* Enable the Output compare channel */
882  TIM_CCxChannelCmd(htim->Instance, Channel, TIM_CCx_ENABLE);
883 
885  {
886  /* Enable the main output */
887  __HAL_TIM_MOE_ENABLE(htim);
888  }
889 
890  /* Enable the Peripheral */
891  __HAL_TIM_ENABLE(htim);
892 
893  /* Return function status */
894  return HAL_OK;
895 }
896 
910 {
911  /* Check the parameters */
912  assert_param(IS_TIM_CCX_INSTANCE(htim->Instance, Channel));
913 
914  switch (Channel)
915  {
916  case TIM_CHANNEL_1:
917  {
918  /* Disable the TIM Capture/Compare 1 DMA request */
920  }
921  break;
922 
923  case TIM_CHANNEL_2:
924  {
925  /* Disable the TIM Capture/Compare 2 DMA request */
927  }
928  break;
929 
930  case TIM_CHANNEL_3:
931  {
932  /* Disable the TIM Capture/Compare 3 DMA request */
934  }
935  break;
936 
937  case TIM_CHANNEL_4:
938  {
939  /* Disable the TIM Capture/Compare 4 interrupt */
941  }
942  break;
943 
944  default:
945  break;
946  }
947 
948  /* Disable the Output compare channel */
949  TIM_CCxChannelCmd(htim->Instance, Channel, TIM_CCx_DISABLE);
950 
952  {
953  /* Disable the Main Output */
954  __HAL_TIM_MOE_DISABLE(htim);
955  }
956 
957  /* Disable the Peripheral */
958  __HAL_TIM_DISABLE(htim);
959 
960  /* Change the htim state */
961  htim->State = HAL_TIM_STATE_READY;
962 
963  /* Return function status */
964  return HAL_OK;
965 }
966 
1000 {
1001  /* Check the TIM handle allocation */
1002  if(htim == NULL)
1003  {
1004  return HAL_ERROR;
1005  }
1006 
1007  /* Check the parameters */
1011 
1012  if(htim->State == HAL_TIM_STATE_RESET)
1013  {
1014  /* Allocate lock resource and initialize it */
1015  htim->Lock = HAL_UNLOCKED;
1016  /* Init the low level hardware : GPIO, CLOCK, NVIC and DMA */
1017  HAL_TIM_PWM_MspInit(htim);
1018  }
1019 
1020  /* Set the TIM state */
1021  htim->State= HAL_TIM_STATE_BUSY;
1022 
1023  /* Init the base time for the PWM */
1024  TIM_Base_SetConfig(htim->Instance, &htim->Init);
1025 
1026  /* Initialize the TIM state*/
1027  htim->State= HAL_TIM_STATE_READY;
1028 
1029  return HAL_OK;
1030 }
1031 
1039 {
1040  /* Check the parameters */
1042 
1043  htim->State = HAL_TIM_STATE_BUSY;
1044 
1045  /* Disable the TIM Peripheral Clock */
1046  __HAL_TIM_DISABLE(htim);
1047 
1048  /* DeInit the low level hardware: GPIO, CLOCK, NVIC and DMA */
1049  HAL_TIM_PWM_MspDeInit(htim);
1050 
1051  /* Change TIM state */
1052  htim->State = HAL_TIM_STATE_RESET;
1053 
1054  /* Release Lock */
1055  __HAL_UNLOCK(htim);
1056 
1057  return HAL_OK;
1058 }
1059 
1066 __weak void HAL_TIM_PWM_MspInit(TIM_HandleTypeDef *htim)
1067 {
1068  /* Prevent unused argument(s) compilation warning */
1069  UNUSED(htim);
1070 
1071  /* NOTE : This function Should not be modified, when the callback is needed,
1072  the HAL_TIM_PWM_MspInit could be implemented in the user file
1073  */
1074 }
1075 
1082 __weak void HAL_TIM_PWM_MspDeInit(TIM_HandleTypeDef *htim)
1083 {
1084  /* Prevent unused argument(s) compilation warning */
1085  UNUSED(htim);
1086 
1087  /* NOTE : This function Should not be modified, when the callback is needed,
1088  the HAL_TIM_PWM_MspDeInit could be implemented in the user file
1089  */
1090 }
1091 
1104 HAL_StatusTypeDef HAL_TIM_PWM_Start(TIM_HandleTypeDef *htim, uint32_t Channel)
1105 {
1106  /* Check the parameters */
1107  assert_param(IS_TIM_CCX_INSTANCE(htim->Instance, Channel));
1108 
1109  /* Enable the Capture compare channel */
1110  TIM_CCxChannelCmd(htim->Instance, Channel, TIM_CCx_ENABLE);
1111 
1112  if(IS_TIM_ADVANCED_INSTANCE(htim->Instance) != RESET)
1113  {
1114  /* Enable the main output */
1115  __HAL_TIM_MOE_ENABLE(htim);
1116  }
1117 
1118  /* Enable the Peripheral */
1119  __HAL_TIM_ENABLE(htim);
1120 
1121  /* Return function status */
1122  return HAL_OK;
1123 }
1124 
1137 HAL_StatusTypeDef HAL_TIM_PWM_Stop(TIM_HandleTypeDef *htim, uint32_t Channel)
1138 {
1139  /* Check the parameters */
1140  assert_param(IS_TIM_CCX_INSTANCE(htim->Instance, Channel));
1141 
1142  /* Disable the Capture compare channel */
1143  TIM_CCxChannelCmd(htim->Instance, Channel, TIM_CCx_DISABLE);
1144 
1145  if(IS_TIM_ADVANCED_INSTANCE(htim->Instance) != RESET)
1146  {
1147  /* Disable the Main Output */
1148  __HAL_TIM_MOE_DISABLE(htim);
1149  }
1150 
1151  /* Disable the Peripheral */
1152  __HAL_TIM_DISABLE(htim);
1153 
1154  /* Change the htim state */
1155  htim->State = HAL_TIM_STATE_READY;
1156 
1157  /* Return function status */
1158  return HAL_OK;
1159 }
1160 
1174 {
1175  /* Check the parameters */
1176  assert_param(IS_TIM_CCX_INSTANCE(htim->Instance, Channel));
1177 
1178  switch (Channel)
1179  {
1180  case TIM_CHANNEL_1:
1181  {
1182  /* Enable the TIM Capture/Compare 1 interrupt */
1184  }
1185  break;
1186 
1187  case TIM_CHANNEL_2:
1188  {
1189  /* Enable the TIM Capture/Compare 2 interrupt */
1191  }
1192  break;
1193 
1194  case TIM_CHANNEL_3:
1195  {
1196  /* Enable the TIM Capture/Compare 3 interrupt */
1198  }
1199  break;
1200 
1201  case TIM_CHANNEL_4:
1202  {
1203  /* Enable the TIM Capture/Compare 4 interrupt */
1205  }
1206  break;
1207 
1208  default:
1209  break;
1210  }
1211 
1212  /* Enable the Capture compare channel */
1213  TIM_CCxChannelCmd(htim->Instance, Channel, TIM_CCx_ENABLE);
1214 
1215  if(IS_TIM_ADVANCED_INSTANCE(htim->Instance) != RESET)
1216  {
1217  /* Enable the main output */
1218  __HAL_TIM_MOE_ENABLE(htim);
1219  }
1220 
1221  /* Enable the Peripheral */
1222  __HAL_TIM_ENABLE(htim);
1223 
1224  /* Return function status */
1225  return HAL_OK;
1226 }
1227 
1241 {
1242  /* Check the parameters */
1243  assert_param(IS_TIM_CCX_INSTANCE(htim->Instance, Channel));
1244 
1245  switch (Channel)
1246  {
1247  case TIM_CHANNEL_1:
1248  {
1249  /* Disable the TIM Capture/Compare 1 interrupt */
1251  }
1252  break;
1253 
1254  case TIM_CHANNEL_2:
1255  {
1256  /* Disable the TIM Capture/Compare 2 interrupt */
1258  }
1259  break;
1260 
1261  case TIM_CHANNEL_3:
1262  {
1263  /* Disable the TIM Capture/Compare 3 interrupt */
1265  }
1266  break;
1267 
1268  case TIM_CHANNEL_4:
1269  {
1270  /* Disable the TIM Capture/Compare 4 interrupt */
1272  }
1273  break;
1274 
1275  default:
1276  break;
1277  }
1278 
1279  /* Disable the Capture compare channel */
1280  TIM_CCxChannelCmd(htim->Instance, Channel, TIM_CCx_DISABLE);
1281 
1282  if(IS_TIM_ADVANCED_INSTANCE(htim->Instance) != RESET)
1283  {
1284  /* Disable the Main Output */
1285  __HAL_TIM_MOE_DISABLE(htim);
1286  }
1287 
1288  /* Disable the Peripheral */
1289  __HAL_TIM_DISABLE(htim);
1290 
1291  /* Return function status */
1292  return HAL_OK;
1293 }
1294 
1309 HAL_StatusTypeDef HAL_TIM_PWM_Start_DMA(TIM_HandleTypeDef *htim, uint32_t Channel, uint32_t *pData, uint16_t Length)
1310 {
1311  /* Check the parameters */
1312  assert_param(IS_TIM_CCX_INSTANCE(htim->Instance, Channel));
1313 
1314  if((htim->State == HAL_TIM_STATE_BUSY))
1315  {
1316  return HAL_BUSY;
1317  }
1318  else if((htim->State == HAL_TIM_STATE_READY))
1319  {
1320  if(((uint32_t)pData == 0 ) && (Length > 0))
1321  {
1322  return HAL_ERROR;
1323  }
1324  else
1325  {
1326  htim->State = HAL_TIM_STATE_BUSY;
1327  }
1328  }
1329  switch (Channel)
1330  {
1331  case TIM_CHANNEL_1:
1332  {
1333  /* Set the DMA Period elapsed callback */
1335 
1336  /* Set the DMA error callback */
1338 
1339  /* Enable the DMA Stream */
1340  HAL_DMA_Start_IT(htim->hdma[TIM_DMA_ID_CC1], (uint32_t)pData, (uint32_t)&htim->Instance->CCR1, Length);
1341 
1342  /* Enable the TIM Capture/Compare 1 DMA request */
1344  }
1345  break;
1346 
1347  case TIM_CHANNEL_2:
1348  {
1349  /* Set the DMA Period elapsed callback */
1351 
1352  /* Set the DMA error callback */
1354 
1355  /* Enable the DMA Stream */
1356  HAL_DMA_Start_IT(htim->hdma[TIM_DMA_ID_CC2], (uint32_t)pData, (uint32_t)&htim->Instance->CCR2, Length);
1357 
1358  /* Enable the TIM Capture/Compare 2 DMA request */
1360  }
1361  break;
1362 
1363  case TIM_CHANNEL_3:
1364  {
1365  /* Set the DMA Period elapsed callback */
1367 
1368  /* Set the DMA error callback */
1370 
1371  /* Enable the DMA Stream */
1372  HAL_DMA_Start_IT(htim->hdma[TIM_DMA_ID_CC3], (uint32_t)pData, (uint32_t)&htim->Instance->CCR3,Length);
1373 
1374  /* Enable the TIM Output Capture/Compare 3 request */
1376  }
1377  break;
1378 
1379  case TIM_CHANNEL_4:
1380  {
1381  /* Set the DMA Period elapsed callback */
1383 
1384  /* Set the DMA error callback */
1386 
1387  /* Enable the DMA Stream */
1388  HAL_DMA_Start_IT(htim->hdma[TIM_DMA_ID_CC4], (uint32_t)pData, (uint32_t)&htim->Instance->CCR4, Length);
1389 
1390  /* Enable the TIM Capture/Compare 4 DMA request */
1392  }
1393  break;
1394 
1395  default:
1396  break;
1397  }
1398 
1399  /* Enable the Capture compare channel */
1400  TIM_CCxChannelCmd(htim->Instance, Channel, TIM_CCx_ENABLE);
1401 
1402  if(IS_TIM_ADVANCED_INSTANCE(htim->Instance) != RESET)
1403  {
1404  /* Enable the main output */
1405  __HAL_TIM_MOE_ENABLE(htim);
1406  }
1407 
1408  /* Enable the Peripheral */
1409  __HAL_TIM_ENABLE(htim);
1410 
1411  /* Return function status */
1412  return HAL_OK;
1413 }
1414 
1428 {
1429  /* Check the parameters */
1430  assert_param(IS_TIM_CCX_INSTANCE(htim->Instance, Channel));
1431 
1432  switch (Channel)
1433  {
1434  case TIM_CHANNEL_1:
1435  {
1436  /* Disable the TIM Capture/Compare 1 DMA request */
1438  }
1439  break;
1440 
1441  case TIM_CHANNEL_2:
1442  {
1443  /* Disable the TIM Capture/Compare 2 DMA request */
1445  }
1446  break;
1447 
1448  case TIM_CHANNEL_3:
1449  {
1450  /* Disable the TIM Capture/Compare 3 DMA request */
1452  }
1453  break;
1454 
1455  case TIM_CHANNEL_4:
1456  {
1457  /* Disable the TIM Capture/Compare 4 interrupt */
1459  }
1460  break;
1461 
1462  default:
1463  break;
1464  }
1465 
1466  /* Disable the Capture compare channel */
1467  TIM_CCxChannelCmd(htim->Instance, Channel, TIM_CCx_DISABLE);
1468 
1469  if(IS_TIM_ADVANCED_INSTANCE(htim->Instance) != RESET)
1470  {
1471  /* Disable the Main Output */
1472  __HAL_TIM_MOE_DISABLE(htim);
1473  }
1474 
1475  /* Disable the Peripheral */
1476  __HAL_TIM_DISABLE(htim);
1477 
1478  /* Change the htim state */
1479  htim->State = HAL_TIM_STATE_READY;
1480 
1481  /* Return function status */
1482  return HAL_OK;
1483 }
1484 
1518 {
1519  /* Check the TIM handle allocation */
1520  if(htim == NULL)
1521  {
1522  return HAL_ERROR;
1523  }
1524 
1525  /* Check the parameters */
1529 
1530  if(htim->State == HAL_TIM_STATE_RESET)
1531  {
1532  /* Allocate lock resource and initialize it */
1533  htim->Lock = HAL_UNLOCKED;
1534  /* Init the low level hardware : GPIO, CLOCK, NVIC and DMA */
1535  HAL_TIM_IC_MspInit(htim);
1536  }
1537 
1538  /* Set the TIM state */
1539  htim->State= HAL_TIM_STATE_BUSY;
1540 
1541  /* Init the base time for the input capture */
1542  TIM_Base_SetConfig(htim->Instance, &htim->Init);
1543 
1544  /* Initialize the TIM state*/
1545  htim->State= HAL_TIM_STATE_READY;
1546 
1547  return HAL_OK;
1548 }
1549 
1557 {
1558  /* Check the parameters */
1560 
1561  htim->State = HAL_TIM_STATE_BUSY;
1562 
1563  /* Disable the TIM Peripheral Clock */
1564  __HAL_TIM_DISABLE(htim);
1565 
1566  /* DeInit the low level hardware: GPIO, CLOCK, NVIC and DMA */
1567  HAL_TIM_IC_MspDeInit(htim);
1568 
1569  /* Change TIM state */
1570  htim->State = HAL_TIM_STATE_RESET;
1571 
1572  /* Release Lock */
1573  __HAL_UNLOCK(htim);
1574 
1575  return HAL_OK;
1576 }
1577 
1584 __weak void HAL_TIM_IC_MspInit(TIM_HandleTypeDef *htim)
1585 {
1586  /* Prevent unused argument(s) compilation warning */
1587  UNUSED(htim);
1588 
1589  /* NOTE : This function Should not be modified, when the callback is needed,
1590  the HAL_TIM_IC_MspInit could be implemented in the user file
1591  */
1592 }
1593 
1600 __weak void HAL_TIM_IC_MspDeInit(TIM_HandleTypeDef *htim)
1601 {
1602  /* Prevent unused argument(s) compilation warning */
1603  UNUSED(htim);
1604 
1605  /* NOTE : This function Should not be modified, when the callback is needed,
1606  the HAL_TIM_IC_MspDeInit could be implemented in the user file
1607  */
1608 }
1609 
1622 HAL_StatusTypeDef HAL_TIM_IC_Start (TIM_HandleTypeDef *htim, uint32_t Channel)
1623 {
1624  /* Check the parameters */
1625  assert_param(IS_TIM_CCX_INSTANCE(htim->Instance, Channel));
1626 
1627  /* Enable the Input Capture channel */
1628  TIM_CCxChannelCmd(htim->Instance, Channel, TIM_CCx_ENABLE);
1629 
1630  /* Enable the Peripheral */
1631  __HAL_TIM_ENABLE(htim);
1632 
1633  /* Return function status */
1634  return HAL_OK;
1635 }
1636 
1649 HAL_StatusTypeDef HAL_TIM_IC_Stop(TIM_HandleTypeDef *htim, uint32_t Channel)
1650 {
1651  /* Check the parameters */
1652  assert_param(IS_TIM_CCX_INSTANCE(htim->Instance, Channel));
1653 
1654  /* Disable the Input Capture channel */
1655  TIM_CCxChannelCmd(htim->Instance, Channel, TIM_CCx_DISABLE);
1656 
1657  /* Disable the Peripheral */
1658  __HAL_TIM_DISABLE(htim);
1659 
1660  /* Return function status */
1661  return HAL_OK;
1662 }
1663 
1677 {
1678  /* Check the parameters */
1679  assert_param(IS_TIM_CCX_INSTANCE(htim->Instance, Channel));
1680 
1681  switch (Channel)
1682  {
1683  case TIM_CHANNEL_1:
1684  {
1685  /* Enable the TIM Capture/Compare 1 interrupt */
1687  }
1688  break;
1689 
1690  case TIM_CHANNEL_2:
1691  {
1692  /* Enable the TIM Capture/Compare 2 interrupt */
1694  }
1695  break;
1696 
1697  case TIM_CHANNEL_3:
1698  {
1699  /* Enable the TIM Capture/Compare 3 interrupt */
1701  }
1702  break;
1703 
1704  case TIM_CHANNEL_4:
1705  {
1706  /* Enable the TIM Capture/Compare 4 interrupt */
1708  }
1709  break;
1710 
1711  default:
1712  break;
1713  }
1714  /* Enable the Input Capture channel */
1715  TIM_CCxChannelCmd(htim->Instance, Channel, TIM_CCx_ENABLE);
1716 
1717  /* Enable the Peripheral */
1718  __HAL_TIM_ENABLE(htim);
1719 
1720  /* Return function status */
1721  return HAL_OK;
1722 }
1723 
1737 {
1738  /* Check the parameters */
1739  assert_param(IS_TIM_CCX_INSTANCE(htim->Instance, Channel));
1740 
1741  switch (Channel)
1742  {
1743  case TIM_CHANNEL_1:
1744  {
1745  /* Disable the TIM Capture/Compare 1 interrupt */
1747  }
1748  break;
1749 
1750  case TIM_CHANNEL_2:
1751  {
1752  /* Disable the TIM Capture/Compare 2 interrupt */
1754  }
1755  break;
1756 
1757  case TIM_CHANNEL_3:
1758  {
1759  /* Disable the TIM Capture/Compare 3 interrupt */
1761  }
1762  break;
1763 
1764  case TIM_CHANNEL_4:
1765  {
1766  /* Disable the TIM Capture/Compare 4 interrupt */
1768  }
1769  break;
1770 
1771  default:
1772  break;
1773  }
1774 
1775  /* Disable the Input Capture channel */
1776  TIM_CCxChannelCmd(htim->Instance, Channel, TIM_CCx_DISABLE);
1777 
1778  /* Disable the Peripheral */
1779  __HAL_TIM_DISABLE(htim);
1780 
1781  /* Return function status */
1782  return HAL_OK;
1783 }
1784 
1799 HAL_StatusTypeDef HAL_TIM_IC_Start_DMA(TIM_HandleTypeDef *htim, uint32_t Channel, uint32_t *pData, uint16_t Length)
1800 {
1801  /* Check the parameters */
1802  assert_param(IS_TIM_CCX_INSTANCE(htim->Instance, Channel));
1804 
1805  if((htim->State == HAL_TIM_STATE_BUSY))
1806  {
1807  return HAL_BUSY;
1808  }
1809  else if((htim->State == HAL_TIM_STATE_READY))
1810  {
1811  if((pData == 0 ) && (Length > 0))
1812  {
1813  return HAL_ERROR;
1814  }
1815  else
1816  {
1817  htim->State = HAL_TIM_STATE_BUSY;
1818  }
1819  }
1820 
1821  switch (Channel)
1822  {
1823  case TIM_CHANNEL_1:
1824  {
1825  /* Set the DMA Period elapsed callback */
1827 
1828  /* Set the DMA error callback */
1830 
1831  /* Enable the DMA Stream */
1832  HAL_DMA_Start_IT(htim->hdma[TIM_DMA_ID_CC1], (uint32_t)&htim->Instance->CCR1, (uint32_t)pData, Length);
1833 
1834  /* Enable the TIM Capture/Compare 1 DMA request */
1836  }
1837  break;
1838 
1839  case TIM_CHANNEL_2:
1840  {
1841  /* Set the DMA Period elapsed callback */
1843 
1844  /* Set the DMA error callback */
1846 
1847  /* Enable the DMA Stream */
1848  HAL_DMA_Start_IT(htim->hdma[TIM_DMA_ID_CC2], (uint32_t)&htim->Instance->CCR2, (uint32_t)pData, Length);
1849 
1850  /* Enable the TIM Capture/Compare 2 DMA request */
1852  }
1853  break;
1854 
1855  case TIM_CHANNEL_3:
1856  {
1857  /* Set the DMA Period elapsed callback */
1859 
1860  /* Set the DMA error callback */
1862 
1863  /* Enable the DMA Stream */
1864  HAL_DMA_Start_IT(htim->hdma[TIM_DMA_ID_CC3], (uint32_t)&htim->Instance->CCR3, (uint32_t)pData, Length);
1865 
1866  /* Enable the TIM Capture/Compare 3 DMA request */
1868  }
1869  break;
1870 
1871  case TIM_CHANNEL_4:
1872  {
1873  /* Set the DMA Period elapsed callback */
1875 
1876  /* Set the DMA error callback */
1878 
1879  /* Enable the DMA Stream */
1880  HAL_DMA_Start_IT(htim->hdma[TIM_DMA_ID_CC4], (uint32_t)&htim->Instance->CCR4, (uint32_t)pData, Length);
1881 
1882  /* Enable the TIM Capture/Compare 4 DMA request */
1884  }
1885  break;
1886 
1887  default:
1888  break;
1889  }
1890 
1891  /* Enable the Input Capture channel */
1892  TIM_CCxChannelCmd(htim->Instance, Channel, TIM_CCx_ENABLE);
1893 
1894  /* Enable the Peripheral */
1895  __HAL_TIM_ENABLE(htim);
1896 
1897  /* Return function status */
1898  return HAL_OK;
1899 }
1900 
1914 {
1915  /* Check the parameters */
1916  assert_param(IS_TIM_CCX_INSTANCE(htim->Instance, Channel));
1918 
1919  switch (Channel)
1920  {
1921  case TIM_CHANNEL_1:
1922  {
1923  /* Disable the TIM Capture/Compare 1 DMA request */
1925  }
1926  break;
1927 
1928  case TIM_CHANNEL_2:
1929  {
1930  /* Disable the TIM Capture/Compare 2 DMA request */
1932  }
1933  break;
1934 
1935  case TIM_CHANNEL_3:
1936  {
1937  /* Disable the TIM Capture/Compare 3 DMA request */
1939  }
1940  break;
1941 
1942  case TIM_CHANNEL_4:
1943  {
1944  /* Disable the TIM Capture/Compare 4 DMA request */
1946  }
1947  break;
1948 
1949  default:
1950  break;
1951  }
1952 
1953  /* Disable the Input Capture channel */
1954  TIM_CCxChannelCmd(htim->Instance, Channel, TIM_CCx_DISABLE);
1955 
1956  /* Disable the Peripheral */
1957  __HAL_TIM_DISABLE(htim);
1958 
1959  /* Change the htim state */
1960  htim->State = HAL_TIM_STATE_READY;
1961 
1962  /* Return function status */
1963  return HAL_OK;
1964 }
2001 HAL_StatusTypeDef HAL_TIM_OnePulse_Init(TIM_HandleTypeDef *htim, uint32_t OnePulseMode)
2002 {
2003  /* Check the TIM handle allocation */
2004  if(htim == NULL)
2005  {
2006  return HAL_ERROR;
2007  }
2008 
2009  /* Check the parameters */
2013  assert_param(IS_TIM_OPM_MODE(OnePulseMode));
2014 
2015  if(htim->State == HAL_TIM_STATE_RESET)
2016  {
2017  /* Allocate lock resource and initialize it */
2018  htim->Lock = HAL_UNLOCKED;
2019  /* Init the low level hardware : GPIO, CLOCK, NVIC and DMA */
2021  }
2022 
2023  /* Set the TIM state */
2024  htim->State= HAL_TIM_STATE_BUSY;
2025 
2026  /* Configure the Time base in the One Pulse Mode */
2027  TIM_Base_SetConfig(htim->Instance, &htim->Init);
2028 
2029  /* Reset the OPM Bit */
2030  htim->Instance->CR1 &= ~TIM_CR1_OPM;
2031 
2032  /* Configure the OPM Mode */
2033  htim->Instance->CR1 |= OnePulseMode;
2034 
2035  /* Initialize the TIM state*/
2036  htim->State= HAL_TIM_STATE_READY;
2037 
2038  return HAL_OK;
2039 }
2040 
2048 {
2049  /* Check the parameters */
2051 
2052  htim->State = HAL_TIM_STATE_BUSY;
2053 
2054  /* Disable the TIM Peripheral Clock */
2055  __HAL_TIM_DISABLE(htim);
2056 
2057  /* DeInit the low level hardware: GPIO, CLOCK, NVIC */
2059 
2060  /* Change TIM state */
2061  htim->State = HAL_TIM_STATE_RESET;
2062 
2063  /* Release Lock */
2064  __HAL_UNLOCK(htim);
2065 
2066  return HAL_OK;
2067 }
2068 
2076 {
2077  /* Prevent unused argument(s) compilation warning */
2078  UNUSED(htim);
2079 
2080  /* NOTE : This function Should not be modified, when the callback is needed,
2081  the HAL_TIM_OnePulse_MspInit could be implemented in the user file
2082  */
2083 }
2084 
2092 {
2093  /* Prevent unused argument(s) compilation warning */
2094  UNUSED(htim);
2095 
2096  /* NOTE : This function Should not be modified, when the callback is needed,
2097  the HAL_TIM_OnePulse_MspDeInit could be implemented in the user file
2098  */
2099 }
2100 
2111 HAL_StatusTypeDef HAL_TIM_OnePulse_Start(TIM_HandleTypeDef *htim, uint32_t OutputChannel)
2112 {
2113  /* Enable the Capture compare and the Input Capture channels
2114  (in the OPM Mode the two possible channels that can be used are TIM_CHANNEL_1 and TIM_CHANNEL_2)
2115  if TIM_CHANNEL_1 is used as output, the TIM_CHANNEL_2 will be used as input and
2116  if TIM_CHANNEL_1 is used as input, the TIM_CHANNEL_2 will be used as output
2117  in all combinations, the TIM_CHANNEL_1 and TIM_CHANNEL_2 should be enabled together
2118 
2119  No need to enable the counter, it's enabled automatically by hardware
2120  (the counter starts in response to a stimulus and generate a pulse */
2121 
2124 
2125  if(IS_TIM_ADVANCED_INSTANCE(htim->Instance) != RESET)
2126  {
2127  /* Enable the main output */
2128  __HAL_TIM_MOE_ENABLE(htim);
2129  }
2130 
2131  /* Return function status */
2132  return HAL_OK;
2133 }
2134 
2145 HAL_StatusTypeDef HAL_TIM_OnePulse_Stop(TIM_HandleTypeDef *htim, uint32_t OutputChannel)
2146 {
2147  /* Disable the Capture compare and the Input Capture channels
2148  (in the OPM Mode the two possible channels that can be used are TIM_CHANNEL_1 and TIM_CHANNEL_2)
2149  if TIM_CHANNEL_1 is used as output, the TIM_CHANNEL_2 will be used as input and
2150  if TIM_CHANNEL_1 is used as input, the TIM_CHANNEL_2 will be used as output
2151  in all combinations, the TIM_CHANNEL_1 and TIM_CHANNEL_2 should be disabled together */
2152 
2155 
2156  if(IS_TIM_ADVANCED_INSTANCE(htim->Instance) != RESET)
2157  {
2158  /* Disable the Main Output */
2159  __HAL_TIM_MOE_DISABLE(htim);
2160  }
2161 
2162  /* Disable the Peripheral */
2163  __HAL_TIM_DISABLE(htim);
2164 
2165  /* Return function status */
2166  return HAL_OK;
2167 }
2168 
2179 HAL_StatusTypeDef HAL_TIM_OnePulse_Start_IT(TIM_HandleTypeDef *htim, uint32_t OutputChannel)
2180 {
2181  /* Enable the Capture compare and the Input Capture channels
2182  (in the OPM Mode the two possible channels that can be used are TIM_CHANNEL_1 and TIM_CHANNEL_2)
2183  if TIM_CHANNEL_1 is used as output, the TIM_CHANNEL_2 will be used as input and
2184  if TIM_CHANNEL_1 is used as input, the TIM_CHANNEL_2 will be used as output
2185  in all combinations, the TIM_CHANNEL_1 and TIM_CHANNEL_2 should be enabled together
2186 
2187  No need to enable the counter, it's enabled automatically by hardware
2188  (the counter starts in response to a stimulus and generate a pulse */
2189 
2190  /* Enable the TIM Capture/Compare 1 interrupt */
2192 
2193  /* Enable the TIM Capture/Compare 2 interrupt */
2195 
2198 
2199  if(IS_TIM_ADVANCED_INSTANCE(htim->Instance) != RESET)
2200  {
2201  /* Enable the main output */
2202  __HAL_TIM_MOE_ENABLE(htim);
2203  }
2204 
2205  /* Return function status */
2206  return HAL_OK;
2207 }
2208 
2219 HAL_StatusTypeDef HAL_TIM_OnePulse_Stop_IT(TIM_HandleTypeDef *htim, uint32_t OutputChannel)
2220 {
2221  /* Disable the TIM Capture/Compare 1 interrupt */
2223 
2224  /* Disable the TIM Capture/Compare 2 interrupt */
2226 
2227  /* Disable the Capture compare and the Input Capture channels
2228  (in the OPM Mode the two possible channels that can be used are TIM_CHANNEL_1 and TIM_CHANNEL_2)
2229  if TIM_CHANNEL_1 is used as output, the TIM_CHANNEL_2 will be used as input and
2230  if TIM_CHANNEL_1 is used as input, the TIM_CHANNEL_2 will be used as output
2231  in all combinations, the TIM_CHANNEL_1 and TIM_CHANNEL_2 should be disabled together */
2234 
2235  if(IS_TIM_ADVANCED_INSTANCE(htim->Instance) != RESET)
2236  {
2237  /* Disable the Main Output */
2238  __HAL_TIM_MOE_DISABLE(htim);
2239  }
2240 
2241  /* Disable the Peripheral */
2242  __HAL_TIM_DISABLE(htim);
2243 
2244  /* Return function status */
2245  return HAL_OK;
2246 }
2247 
2281 {
2282  uint32_t tmpsmcr = 0;
2283  uint32_t tmpccmr1 = 0;
2284  uint32_t tmpccer = 0;
2285 
2286  /* Check the TIM handle allocation */
2287  if(htim == NULL)
2288  {
2289  return HAL_ERROR;
2290  }
2291 
2292  /* Check the parameters */
2303 
2304  if(htim->State == HAL_TIM_STATE_RESET)
2305  {
2306  /* Allocate lock resource and initialize it */
2307  htim->Lock = HAL_UNLOCKED;
2308  /* Init the low level hardware : GPIO, CLOCK, NVIC and DMA */
2310  }
2311 
2312  /* Set the TIM state */
2313  htim->State= HAL_TIM_STATE_BUSY;
2314 
2315  /* Reset the SMS bits */
2316  htim->Instance->SMCR &= ~TIM_SMCR_SMS;
2317 
2318  /* Configure the Time base in the Encoder Mode */
2319  TIM_Base_SetConfig(htim->Instance, &htim->Init);
2320 
2321  /* Get the TIMx SMCR register value */
2322  tmpsmcr = htim->Instance->SMCR;
2323 
2324  /* Get the TIMx CCMR1 register value */
2325  tmpccmr1 = htim->Instance->CCMR1;
2326 
2327  /* Get the TIMx CCER register value */
2328  tmpccer = htim->Instance->CCER;
2329 
2330  /* Set the encoder Mode */
2331  tmpsmcr |= sConfig->EncoderMode;
2332 
2333  /* Select the Capture Compare 1 and the Capture Compare 2 as input */
2334  tmpccmr1 &= ~(TIM_CCMR1_CC1S | TIM_CCMR1_CC2S);
2335  tmpccmr1 |= (sConfig->IC1Selection | (sConfig->IC2Selection << 8));
2336 
2337  /* Set the Capture Compare 1 and the Capture Compare 2 prescalers and filters */
2338  tmpccmr1 &= ~(TIM_CCMR1_IC1PSC | TIM_CCMR1_IC2PSC);
2339  tmpccmr1 &= ~(TIM_CCMR1_IC1F | TIM_CCMR1_IC2F);
2340  tmpccmr1 |= sConfig->IC1Prescaler | (sConfig->IC2Prescaler << 8);
2341  tmpccmr1 |= (sConfig->IC1Filter << 4) | (sConfig->IC2Filter << 12);
2342 
2343  /* Set the TI1 and the TI2 Polarities */
2344  tmpccer &= ~(TIM_CCER_CC1P | TIM_CCER_CC2P);
2345  tmpccer &= ~(TIM_CCER_CC1NP | TIM_CCER_CC2NP);
2346  tmpccer |= sConfig->IC1Polarity | (sConfig->IC2Polarity << 4);
2347 
2348  /* Write to TIMx SMCR */
2349  htim->Instance->SMCR = tmpsmcr;
2350 
2351  /* Write to TIMx CCMR1 */
2352  htim->Instance->CCMR1 = tmpccmr1;
2353 
2354  /* Write to TIMx CCER */
2355  htim->Instance->CCER = tmpccer;
2356 
2357  /* Initialize the TIM state*/
2358  htim->State= HAL_TIM_STATE_READY;
2359 
2360  return HAL_OK;
2361 }
2362 
2370 {
2371  /* Check the parameters */
2373 
2374  htim->State = HAL_TIM_STATE_BUSY;
2375 
2376  /* Disable the TIM Peripheral Clock */
2377  __HAL_TIM_DISABLE(htim);
2378 
2379  /* DeInit the low level hardware: GPIO, CLOCK, NVIC */
2381 
2382  /* Change TIM state */
2383  htim->State = HAL_TIM_STATE_RESET;
2384 
2385  /* Release Lock */
2386  __HAL_UNLOCK(htim);
2387 
2388  return HAL_OK;
2389 }
2390 
2397 __weak void HAL_TIM_Encoder_MspInit(TIM_HandleTypeDef *htim)
2398 {
2399  /* Prevent unused argument(s) compilation warning */
2400  UNUSED(htim);
2401 
2402  /* NOTE : This function Should not be modified, when the callback is needed,
2403  the HAL_TIM_Encoder_MspInit could be implemented in the user file
2404  */
2405 }
2406 
2414 {
2415  /* Prevent unused argument(s) compilation warning */
2416  UNUSED(htim);
2417 
2418  /* NOTE : This function Should not be modified, when the callback is needed,
2419  the HAL_TIM_Encoder_MspDeInit could be implemented in the user file
2420  */
2421 }
2422 
2435 {
2436  /* Check the parameters */
2438 
2439  /* Enable the encoder interface channels */
2440  switch (Channel)
2441  {
2442  case TIM_CHANNEL_1:
2443  {
2445  break;
2446  }
2447  case TIM_CHANNEL_2:
2448  {
2450  break;
2451  }
2452  default :
2453  {
2456  break;
2457  }
2458  }
2459  /* Enable the Peripheral */
2460  __HAL_TIM_ENABLE(htim);
2461 
2462  /* Return function status */
2463  return HAL_OK;
2464 }
2465 
2478 {
2479  /* Check the parameters */
2481 
2482  /* Disable the Input Capture channels 1 and 2
2483  (in the EncoderInterface the two possible channels that can be used are TIM_CHANNEL_1 and TIM_CHANNEL_2) */
2484  switch (Channel)
2485  {
2486  case TIM_CHANNEL_1:
2487  {
2489  break;
2490  }
2491  case TIM_CHANNEL_2:
2492  {
2494  break;
2495  }
2496  default :
2497  {
2500  break;
2501  }
2502  }
2503  /* Disable the Peripheral */
2504  __HAL_TIM_DISABLE(htim);
2505 
2506  /* Return function status */
2507  return HAL_OK;
2508 }
2509 
2522 {
2523  /* Check the parameters */
2525 
2526  /* Enable the encoder interface channels */
2527  /* Enable the capture compare Interrupts 1 and/or 2 */
2528  switch (Channel)
2529  {
2530  case TIM_CHANNEL_1:
2531  {
2534  break;
2535  }
2536  case TIM_CHANNEL_2:
2537  {
2540  break;
2541  }
2542  default :
2543  {
2548  break;
2549  }
2550  }
2551 
2552  /* Enable the Peripheral */
2553  __HAL_TIM_ENABLE(htim);
2554 
2555  /* Return function status */
2556  return HAL_OK;
2557 }
2558 
2571 {
2572  /* Check the parameters */
2574 
2575  /* Disable the Input Capture channels 1 and 2
2576  (in the EncoderInterface the two possible channels that can be used are TIM_CHANNEL_1 and TIM_CHANNEL_2) */
2577  if(Channel == TIM_CHANNEL_1)
2578  {
2580 
2581  /* Disable the capture compare Interrupts 1 */
2583  }
2584  else if(Channel == TIM_CHANNEL_2)
2585  {
2587 
2588  /* Disable the capture compare Interrupts 2 */
2590  }
2591  else
2592  {
2595 
2596  /* Disable the capture compare Interrupts 1 and 2 */
2599  }
2600 
2601  /* Disable the Peripheral */
2602  __HAL_TIM_DISABLE(htim);
2603 
2604  /* Change the htim state */
2605  htim->State = HAL_TIM_STATE_READY;
2606 
2607  /* Return function status */
2608  return HAL_OK;
2609 }
2610 
2625 HAL_StatusTypeDef HAL_TIM_Encoder_Start_DMA(TIM_HandleTypeDef *htim, uint32_t Channel, uint32_t *pData1, uint32_t *pData2, uint16_t Length)
2626 {
2627  /* Check the parameters */
2629 
2630  if((htim->State == HAL_TIM_STATE_BUSY))
2631  {
2632  return HAL_BUSY;
2633  }
2634  else if((htim->State == HAL_TIM_STATE_READY))
2635  {
2636  if((((pData1 == 0) || (pData2 == 0) )) && (Length > 0))
2637  {
2638  return HAL_ERROR;
2639  }
2640  else
2641  {
2642  htim->State = HAL_TIM_STATE_BUSY;
2643  }
2644  }
2645 
2646  switch (Channel)
2647  {
2648  case TIM_CHANNEL_1:
2649  {
2650  /* Set the DMA Period elapsed callback */
2652 
2653  /* Set the DMA error callback */
2655 
2656  /* Enable the DMA Stream */
2657  HAL_DMA_Start_IT(htim->hdma[TIM_DMA_ID_CC1], (uint32_t)&htim->Instance->CCR1, (uint32_t )pData1, Length);
2658 
2659  /* Enable the TIM Input Capture DMA request */
2661 
2662  /* Enable the Peripheral */
2663  __HAL_TIM_ENABLE(htim);
2664 
2665  /* Enable the Capture compare channel */
2667  }
2668  break;
2669 
2670  case TIM_CHANNEL_2:
2671  {
2672  /* Set the DMA Period elapsed callback */
2674 
2675  /* Set the DMA error callback */
2677  /* Enable the DMA Stream */
2678  HAL_DMA_Start_IT(htim->hdma[TIM_DMA_ID_CC2], (uint32_t)&htim->Instance->CCR2, (uint32_t)pData2, Length);
2679 
2680  /* Enable the TIM Input Capture DMA request */
2682 
2683  /* Enable the Peripheral */
2684  __HAL_TIM_ENABLE(htim);
2685 
2686  /* Enable the Capture compare channel */
2688  }
2689  break;
2690 
2691  case TIM_CHANNEL_ALL:
2692  {
2693  /* Set the DMA Period elapsed callback */
2695 
2696  /* Set the DMA error callback */
2698 
2699  /* Enable the DMA Stream */
2700  HAL_DMA_Start_IT(htim->hdma[TIM_DMA_ID_CC1], (uint32_t)&htim->Instance->CCR1, (uint32_t)pData1, Length);
2701 
2702  /* Set the DMA Period elapsed callback */
2704 
2705  /* Set the DMA error callback */
2707 
2708  /* Enable the DMA Stream */
2709  HAL_DMA_Start_IT(htim->hdma[TIM_DMA_ID_CC2], (uint32_t)&htim->Instance->CCR2, (uint32_t)pData2, Length);
2710 
2711  /* Enable the Peripheral */
2712  __HAL_TIM_ENABLE(htim);
2713 
2714  /* Enable the Capture compare channel */
2717 
2718  /* Enable the TIM Input Capture DMA request */
2720  /* Enable the TIM Input Capture DMA request */
2722  }
2723  break;
2724 
2725  default:
2726  break;
2727  }
2728  /* Return function status */
2729  return HAL_OK;
2730 }
2731 
2744 {
2745  /* Check the parameters */
2747 
2748  /* Disable the Input Capture channels 1 and 2
2749  (in the EncoderInterface the two possible channels that can be used are TIM_CHANNEL_1 and TIM_CHANNEL_2) */
2750  if(Channel == TIM_CHANNEL_1)
2751  {
2753 
2754  /* Disable the capture compare DMA Request 1 */
2756  }
2757  else if(Channel == TIM_CHANNEL_2)
2758  {
2760 
2761  /* Disable the capture compare DMA Request 2 */
2763  }
2764  else
2765  {
2768 
2769  /* Disable the capture compare DMA Request 1 and 2 */
2772  }
2773 
2774  /* Disable the Peripheral */
2775  __HAL_TIM_DISABLE(htim);
2776 
2777  /* Change the htim state */
2778  htim->State = HAL_TIM_STATE_READY;
2779 
2780  /* Return function status */
2781  return HAL_OK;
2782 }
2783 
2807 {
2808  /* Capture compare 1 event */
2809  if(__HAL_TIM_GET_FLAG(htim, TIM_FLAG_CC1) != RESET)
2810  {
2812  {
2813  {
2816 
2817  /* Input capture event */
2818  if((htim->Instance->CCMR1 & TIM_CCMR1_CC1S) != 0x00)
2819  {
2821  }
2822  /* Output compare event */
2823  else
2824  {
2827  }
2829  }
2830  }
2831  }
2832  /* Capture compare 2 event */
2833  if(__HAL_TIM_GET_FLAG(htim, TIM_FLAG_CC2) != RESET)
2834  {
2836  {
2839  /* Input capture event */
2840  if((htim->Instance->CCMR1 & TIM_CCMR1_CC2S) != 0x00)
2841  {
2843  }
2844  /* Output compare event */
2845  else
2846  {
2849  }
2851  }
2852  }
2853  /* Capture compare 3 event */
2854  if(__HAL_TIM_GET_FLAG(htim, TIM_FLAG_CC3) != RESET)
2855  {
2857  {
2860  /* Input capture event */
2861  if((htim->Instance->CCMR2 & TIM_CCMR2_CC3S) != 0x00)
2862  {
2864  }
2865  /* Output compare event */
2866  else
2867  {
2870  }
2872  }
2873  }
2874  /* Capture compare 4 event */
2875  if(__HAL_TIM_GET_FLAG(htim, TIM_FLAG_CC4) != RESET)
2876  {
2878  {
2881  /* Input capture event */
2882  if((htim->Instance->CCMR2 & TIM_CCMR2_CC4S) != 0x00)
2883  {
2885  }
2886  /* Output compare event */
2887  else
2888  {
2891  }
2893  }
2894  }
2895  /* TIM Update event */
2897  {
2899  {
2902  }
2903  }
2904  /* TIM Break input event */
2906  {
2908  {
2911  }
2912  }
2913 
2914  /* TIM Break input event */
2916  {
2918  {
2921  }
2922  }
2923 
2924  /* TIM Trigger detection event */
2926  {
2928  {
2931  }
2932  }
2933  /* TIM commutation event */
2934  if(__HAL_TIM_GET_FLAG(htim, TIM_FLAG_COM) != RESET)
2935  {
2937  {
2940  }
2941  }
2942 }
2943 
2981 __weak HAL_StatusTypeDef HAL_TIM_OC_ConfigChannel(TIM_HandleTypeDef *htim, TIM_OC_InitTypeDef* sConfig, uint32_t Channel)
2982 {
2983  /* Check the parameters */
2984  assert_param(IS_TIM_CHANNELS(Channel));
2985  assert_param(IS_TIM_OC_MODE(sConfig->OCMode));
2987 
2988  /* Check input state */
2989  __HAL_LOCK(htim);
2990 
2991  htim->State = HAL_TIM_STATE_BUSY;
2992 
2993  switch (Channel)
2994  {
2995  case TIM_CHANNEL_1:
2996  {
2998  /* Configure the TIM Channel 1 in Output Compare */
2999  TIM_OC1_SetConfig(htim->Instance, sConfig);
3000  }
3001  break;
3002 
3003  case TIM_CHANNEL_2:
3004  {
3006  /* Configure the TIM Channel 2 in Output Compare */
3007  TIM_OC2_SetConfig(htim->Instance, sConfig);
3008  }
3009  break;
3010 
3011  case TIM_CHANNEL_3:
3012  {
3014  /* Configure the TIM Channel 3 in Output Compare */
3015  TIM_OC3_SetConfig(htim->Instance, sConfig);
3016  }
3017  break;
3018 
3019  case TIM_CHANNEL_4:
3020  {
3022  /* Configure the TIM Channel 4 in Output Compare */
3023  TIM_OC4_SetConfig(htim->Instance, sConfig);
3024  }
3025  break;
3026 
3027  default:
3028  break;
3029  }
3030  htim->State = HAL_TIM_STATE_READY;
3031 
3032  __HAL_UNLOCK(htim);
3033 
3034  return HAL_OK;
3035 }
3036 
3052 {
3053  /* Check the parameters */
3059 
3060  __HAL_LOCK(htim);
3061 
3062  htim->State = HAL_TIM_STATE_BUSY;
3063 
3064  if (Channel == TIM_CHANNEL_1)
3065  {
3066  /* TI1 Configuration */
3068  sConfig->ICPolarity,
3069  sConfig->ICSelection,
3070  sConfig->ICFilter);
3071 
3072  /* Reset the IC1PSC Bits */
3073  htim->Instance->CCMR1 &= ~TIM_CCMR1_IC1PSC;
3074 
3075  /* Set the IC1PSC value */
3076  htim->Instance->CCMR1 |= sConfig->ICPrescaler;
3077  }
3078  else if (Channel == TIM_CHANNEL_2)
3079  {
3080  /* TI2 Configuration */
3082 
3083  TIM_TI2_SetConfig(htim->Instance,
3084  sConfig->ICPolarity,
3085  sConfig->ICSelection,
3086  sConfig->ICFilter);
3087 
3088  /* Reset the IC2PSC Bits */
3089  htim->Instance->CCMR1 &= ~TIM_CCMR1_IC2PSC;
3090 
3091  /* Set the IC2PSC value */
3092  htim->Instance->CCMR1 |= (sConfig->ICPrescaler << 8);
3093  }
3094  else if (Channel == TIM_CHANNEL_3)
3095  {
3096  /* TI3 Configuration */
3098 
3099  TIM_TI3_SetConfig(htim->Instance,
3100  sConfig->ICPolarity,
3101  sConfig->ICSelection,
3102  sConfig->ICFilter);
3103 
3104  /* Reset the IC3PSC Bits */
3105  htim->Instance->CCMR2 &= ~TIM_CCMR2_IC3PSC;
3106 
3107  /* Set the IC3PSC value */
3108  htim->Instance->CCMR2 |= sConfig->ICPrescaler;
3109  }
3110  else
3111  {
3112  /* TI4 Configuration */
3114 
3115  TIM_TI4_SetConfig(htim->Instance,
3116  sConfig->ICPolarity,
3117  sConfig->ICSelection,
3118  sConfig->ICFilter);
3119 
3120  /* Reset the IC4PSC Bits */
3121  htim->Instance->CCMR2 &= ~TIM_CCMR2_IC4PSC;
3122 
3123  /* Set the IC4PSC value */
3124  htim->Instance->CCMR2 |= (sConfig->ICPrescaler << 8);
3125  }
3126 
3127  htim->State = HAL_TIM_STATE_READY;
3128 
3129  __HAL_UNLOCK(htim);
3130 
3131  return HAL_OK;
3132 }
3133 
3148 __weak HAL_StatusTypeDef HAL_TIM_PWM_ConfigChannel(TIM_HandleTypeDef *htim, TIM_OC_InitTypeDef* sConfig, uint32_t Channel)
3149 {
3150  __HAL_LOCK(htim);
3151 
3152  /* Check the parameters */
3153  assert_param(IS_TIM_CHANNELS(Channel));
3154  assert_param(IS_TIM_PWM_MODE(sConfig->OCMode));
3157 
3158  htim->State = HAL_TIM_STATE_BUSY;
3159 
3160  switch (Channel)
3161  {
3162  case TIM_CHANNEL_1:
3163  {
3165  /* Configure the Channel 1 in PWM mode */
3166  TIM_OC1_SetConfig(htim->Instance, sConfig);
3167 
3168  /* Set the Preload enable bit for channel1 */
3169  htim->Instance->CCMR1 |= TIM_CCMR1_OC1PE;
3170 
3171  /* Configure the Output Fast mode */
3172  htim->Instance->CCMR1 &= ~TIM_CCMR1_OC1FE;
3173  htim->Instance->CCMR1 |= sConfig->OCFastMode;
3174  }
3175  break;
3176 
3177  case TIM_CHANNEL_2:
3178  {
3180  /* Configure the Channel 2 in PWM mode */
3181  TIM_OC2_SetConfig(htim->Instance, sConfig);
3182 
3183  /* Set the Preload enable bit for channel2 */
3184  htim->Instance->CCMR1 |= TIM_CCMR1_OC2PE;
3185 
3186  /* Configure the Output Fast mode */
3187  htim->Instance->CCMR1 &= ~TIM_CCMR1_OC2FE;
3188  htim->Instance->CCMR1 |= sConfig->OCFastMode << 8;
3189  }
3190  break;
3191 
3192  case TIM_CHANNEL_3:
3193  {
3195  /* Configure the Channel 3 in PWM mode */
3196  TIM_OC3_SetConfig(htim->Instance, sConfig);
3197 
3198  /* Set the Preload enable bit for channel3 */
3199  htim->Instance->CCMR2 |= TIM_CCMR2_OC3PE;
3200 
3201  /* Configure the Output Fast mode */
3202  htim->Instance->CCMR2 &= ~TIM_CCMR2_OC3FE;
3203  htim->Instance->CCMR2 |= sConfig->OCFastMode;
3204  }
3205  break;
3206 
3207  case TIM_CHANNEL_4:
3208  {
3210  /* Configure the Channel 4 in PWM mode */
3211  TIM_OC4_SetConfig(htim->Instance, sConfig);
3212 
3213  /* Set the Preload enable bit for channel4 */
3214  htim->Instance->CCMR2 |= TIM_CCMR2_OC4PE;
3215 
3216  /* Configure the Output Fast mode */
3217  htim->Instance->CCMR2 &= ~TIM_CCMR2_OC4FE;
3218  htim->Instance->CCMR2 |= sConfig->OCFastMode << 8;
3219  }
3220  break;
3221 
3222  default:
3223  break;
3224  }
3225 
3226  htim->State = HAL_TIM_STATE_READY;
3227 
3228  __HAL_UNLOCK(htim);
3229 
3230  return HAL_OK;
3231 }
3232 
3249 HAL_StatusTypeDef HAL_TIM_OnePulse_ConfigChannel(TIM_HandleTypeDef *htim, TIM_OnePulse_InitTypeDef* sConfig, uint32_t OutputChannel, uint32_t InputChannel)
3250 {
3251  TIM_OC_InitTypeDef temp1;
3252 
3253  /* Check the parameters */
3254  assert_param(IS_TIM_OPM_CHANNELS(OutputChannel));
3255  assert_param(IS_TIM_OPM_CHANNELS(InputChannel));
3256 
3257  if(OutputChannel != InputChannel)
3258  {
3259  __HAL_LOCK(htim);
3260 
3261  htim->State = HAL_TIM_STATE_BUSY;
3262 
3263  /* Extract the Output compare configuration from sConfig structure */
3264  temp1.OCMode = sConfig->OCMode;
3265  temp1.Pulse = sConfig->Pulse;
3266  temp1.OCPolarity = sConfig->OCPolarity;
3267  temp1.OCNPolarity = sConfig->OCNPolarity;
3268  temp1.OCIdleState = sConfig->OCIdleState;
3269  temp1.OCNIdleState = sConfig->OCNIdleState;
3270 
3271  switch (OutputChannel)
3272  {
3273  case TIM_CHANNEL_1:
3274  {
3276 
3277  TIM_OC1_SetConfig(htim->Instance, &temp1);
3278  }
3279  break;
3280  case TIM_CHANNEL_2:
3281  {
3283 
3284  TIM_OC2_SetConfig(htim->Instance, &temp1);
3285  }
3286  break;
3287  default:
3288  break;
3289  }
3290  switch (InputChannel)
3291  {
3292  case TIM_CHANNEL_1:
3293  {
3295 
3296  TIM_TI1_SetConfig(htim->Instance, sConfig->ICPolarity,
3297  sConfig->ICSelection, sConfig->ICFilter);
3298 
3299  /* Reset the IC1PSC Bits */
3300  htim->Instance->CCMR1 &= ~TIM_CCMR1_IC1PSC;
3301 
3302  /* Select the Trigger source */
3303  htim->Instance->SMCR &= ~TIM_SMCR_TS;
3304  htim->Instance->SMCR |= TIM_TS_TI1FP1;
3305 
3306  /* Select the Slave Mode */
3307  htim->Instance->SMCR &= ~TIM_SMCR_SMS;
3309  }
3310  break;
3311  case TIM_CHANNEL_2:
3312  {
3314 
3315  TIM_TI2_SetConfig(htim->Instance, sConfig->ICPolarity,
3316  sConfig->ICSelection, sConfig->ICFilter);
3317 
3318  /* Reset the IC2PSC Bits */
3319  htim->Instance->CCMR1 &= ~TIM_CCMR1_IC2PSC;
3320 
3321  /* Select the Trigger source */
3322  htim->Instance->SMCR &= ~TIM_SMCR_TS;
3323  htim->Instance->SMCR |= TIM_TS_TI2FP2;
3324 
3325  /* Select the Slave Mode */
3326  htim->Instance->SMCR &= ~TIM_SMCR_SMS;
3328  }
3329  break;
3330 
3331  default:
3332  break;
3333  }
3334 
3335  htim->State = HAL_TIM_STATE_READY;
3336 
3337  __HAL_UNLOCK(htim);
3338 
3339  return HAL_OK;
3340  }
3341  else
3342  {
3343  return HAL_ERROR;
3344  }
3345 }
3346 
3386 HAL_StatusTypeDef HAL_TIM_DMABurst_WriteStart(TIM_HandleTypeDef *htim, uint32_t BurstBaseAddress, uint32_t BurstRequestSrc,
3387  uint32_t* BurstBuffer, uint32_t BurstLength)
3388 {
3389  /* Check the parameters */
3391  assert_param(IS_TIM_DMA_BASE(BurstBaseAddress));
3392  assert_param(IS_TIM_DMA_SOURCE(BurstRequestSrc));
3393  assert_param(IS_TIM_DMA_LENGTH(BurstLength));
3394 
3395  if((htim->State == HAL_TIM_STATE_BUSY))
3396  {
3397  return HAL_BUSY;
3398  }
3399  else if((htim->State == HAL_TIM_STATE_READY))
3400  {
3401  if((BurstBuffer == 0 ) && (BurstLength > 0))
3402  {
3403  return HAL_ERROR;
3404  }
3405  else
3406  {
3407  htim->State = HAL_TIM_STATE_BUSY;
3408  }
3409  }
3410  switch(BurstRequestSrc)
3411  {
3412  case TIM_DMA_UPDATE:
3413  {
3414  /* Set the DMA Period elapsed callback */
3415  htim->hdma[TIM_DMA_ID_UPDATE]->XferCpltCallback = TIM_DMAPeriodElapsedCplt;
3416 
3417  /* Set the DMA error callback */
3419 
3420  /* Enable the DMA Stream */
3421  HAL_DMA_Start_IT(htim->hdma[TIM_DMA_ID_UPDATE], (uint32_t)BurstBuffer, (uint32_t)&htim->Instance->DMAR, ((BurstLength) >> 8) + 1);
3422  }
3423  break;
3424  case TIM_DMA_CC1:
3425  {
3426  /* Set the DMA Period elapsed callback */
3428 
3429  /* Set the DMA error callback */
3431 
3432  /* Enable the DMA Stream */
3433  HAL_DMA_Start_IT(htim->hdma[TIM_DMA_ID_CC1], (uint32_t)BurstBuffer, (uint32_t)&htim->Instance->DMAR, ((BurstLength) >> 8) + 1);
3434  }
3435  break;
3436  case TIM_DMA_CC2:
3437  {
3438  /* Set the DMA Period elapsed callback */
3440 
3441  /* Set the DMA error callback */
3443 
3444  /* Enable the DMA Stream */
3445  HAL_DMA_Start_IT(htim->hdma[TIM_DMA_ID_CC2], (uint32_t)BurstBuffer, (uint32_t)&htim->Instance->DMAR, ((BurstLength) >> 8) + 1);
3446  }
3447  break;
3448  case TIM_DMA_CC3:
3449  {
3450  /* Set the DMA Period elapsed callback */
3452 
3453  /* Set the DMA error callback */
3455 
3456  /* Enable the DMA Stream */
3457  HAL_DMA_Start_IT(htim->hdma[TIM_DMA_ID_CC3], (uint32_t)BurstBuffer, (uint32_t)&htim->Instance->DMAR, ((BurstLength) >> 8) + 1);
3458  }
3459  break;
3460  case TIM_DMA_CC4:
3461  {
3462  /* Set the DMA Period elapsed callback */
3464 
3465  /* Set the DMA error callback */
3467 
3468  /* Enable the DMA Stream */
3469  HAL_DMA_Start_IT(htim->hdma[TIM_DMA_ID_CC4], (uint32_t)BurstBuffer, (uint32_t)&htim->Instance->DMAR, ((BurstLength) >> 8) + 1);
3470  }
3471  break;
3472  case TIM_DMA_COM:
3473  {
3474  /* Set the DMA Period elapsed callback */
3476 
3477  /* Set the DMA error callback */
3479 
3480  /* Enable the DMA Stream */
3481  HAL_DMA_Start_IT(htim->hdma[TIM_DMA_ID_COMMUTATION], (uint32_t)BurstBuffer, (uint32_t)&htim->Instance->DMAR, ((BurstLength) >> 8) + 1);
3482  }
3483  break;
3484  case TIM_DMA_TRIGGER:
3485  {
3486  /* Set the DMA Period elapsed callback */
3487  htim->hdma[TIM_DMA_ID_TRIGGER]->XferCpltCallback = TIM_DMATriggerCplt;
3488 
3489  /* Set the DMA error callback */
3491 
3492  /* Enable the DMA Stream */
3493  HAL_DMA_Start_IT(htim->hdma[TIM_DMA_ID_TRIGGER], (uint32_t)BurstBuffer, (uint32_t)&htim->Instance->DMAR, ((BurstLength) >> 8) + 1);
3494  }
3495  break;
3496  default:
3497  break;
3498  }
3499  /* configure the DMA Burst Mode */
3500  htim->Instance->DCR = BurstBaseAddress | BurstLength;
3501 
3502  /* Enable the TIM DMA Request */
3503  __HAL_TIM_ENABLE_DMA(htim, BurstRequestSrc);
3504 
3505  htim->State = HAL_TIM_STATE_READY;
3506 
3507  /* Return function status */
3508  return HAL_OK;
3509 }
3510 
3518 HAL_StatusTypeDef HAL_TIM_DMABurst_WriteStop(TIM_HandleTypeDef *htim, uint32_t BurstRequestSrc)
3519 {
3520  /* Check the parameters */
3521  assert_param(IS_TIM_DMA_SOURCE(BurstRequestSrc));
3522 
3523  /* Abort the DMA transfer (at least disable the DMA channel) */
3524  switch(BurstRequestSrc)
3525  {
3526  case TIM_DMA_UPDATE:
3527  {
3529  }
3530  break;
3531  case TIM_DMA_CC1:
3532  {
3534  }
3535  break;
3536  case TIM_DMA_CC2:
3537  {
3539  }
3540  break;
3541  case TIM_DMA_CC3:
3542  {
3544  }
3545  break;
3546  case TIM_DMA_CC4:
3547  {
3549  }
3550  break;
3551  case TIM_DMA_COM:
3552  {
3554  }
3555  break;
3556  case TIM_DMA_TRIGGER:
3557  {
3559  }
3560  break;
3561  default:
3562  break;
3563  }
3564 
3565  /* Disable the TIM Update DMA request */
3566  __HAL_TIM_DISABLE_DMA(htim, BurstRequestSrc);
3567 
3568  /* Return function status */
3569  return HAL_OK;
3570 }
3571 
3611 HAL_StatusTypeDef HAL_TIM_DMABurst_ReadStart(TIM_HandleTypeDef *htim, uint32_t BurstBaseAddress, uint32_t BurstRequestSrc,
3612  uint32_t *BurstBuffer, uint32_t BurstLength)
3613 {
3614  /* Check the parameters */
3616  assert_param(IS_TIM_DMA_BASE(BurstBaseAddress));
3617  assert_param(IS_TIM_DMA_SOURCE(BurstRequestSrc));
3618  assert_param(IS_TIM_DMA_LENGTH(BurstLength));
3619 
3620  if((htim->State == HAL_TIM_STATE_BUSY))
3621  {
3622  return HAL_BUSY;
3623  }
3624  else if((htim->State == HAL_TIM_STATE_READY))
3625  {
3626  if((BurstBuffer == 0 ) && (BurstLength > 0))
3627  {
3628  return HAL_ERROR;
3629  }
3630  else
3631  {
3632  htim->State = HAL_TIM_STATE_BUSY;
3633  }
3634  }
3635  switch(BurstRequestSrc)
3636  {
3637  case TIM_DMA_UPDATE:
3638  {
3639  /* Set the DMA Period elapsed callback */
3640  htim->hdma[TIM_DMA_ID_UPDATE]->XferCpltCallback = TIM_DMAPeriodElapsedCplt;
3641 
3642  /* Set the DMA error callback */
3644 
3645  /* Enable the DMA Stream */
3646  HAL_DMA_Start_IT(htim->hdma[TIM_DMA_ID_UPDATE], (uint32_t)&htim->Instance->DMAR, (uint32_t)BurstBuffer, ((BurstLength) >> 8) + 1);
3647  }
3648  break;
3649  case TIM_DMA_CC1:
3650  {
3651  /* Set the DMA Period elapsed callback */
3653 
3654  /* Set the DMA error callback */
3656 
3657  /* Enable the DMA Stream */
3658  HAL_DMA_Start_IT(htim->hdma[TIM_DMA_ID_CC1], (uint32_t)&htim->Instance->DMAR, (uint32_t)BurstBuffer, ((BurstLength) >> 8) + 1);
3659  }
3660  break;
3661  case TIM_DMA_CC2:
3662  {
3663  /* Set the DMA Period elapsed callback */
3665 
3666  /* Set the DMA error callback */
3668 
3669  /* Enable the DMA Stream */
3670  HAL_DMA_Start_IT(htim->hdma[TIM_DMA_ID_CC2], (uint32_t)&htim->Instance->DMAR, (uint32_t)BurstBuffer, ((BurstLength) >> 8) + 1);
3671  }
3672  break;
3673  case TIM_DMA_CC3:
3674  {
3675  /* Set the DMA Period elapsed callback */
3677 
3678  /* Set the DMA error callback */
3680 
3681  /* Enable the DMA Stream */
3682  HAL_DMA_Start_IT(htim->hdma[TIM_DMA_ID_CC3], (uint32_t)&htim->Instance->DMAR, (uint32_t)BurstBuffer, ((BurstLength) >> 8) + 1);
3683  }
3684  break;
3685  case TIM_DMA_CC4:
3686  {
3687  /* Set the DMA Period elapsed callback */
3689 
3690  /* Set the DMA error callback */
3692 
3693  /* Enable the DMA Stream */
3694  HAL_DMA_Start_IT(htim->hdma[TIM_DMA_ID_CC4], (uint32_t)&htim->Instance->DMAR, (uint32_t)BurstBuffer, ((BurstLength) >> 8) + 1);
3695  }
3696  break;
3697  case TIM_DMA_COM:
3698  {
3699  /* Set the DMA Period elapsed callback */
3701 
3702  /* Set the DMA error callback */
3704 
3705  /* Enable the DMA Stream */
3706  HAL_DMA_Start_IT(htim->hdma[TIM_DMA_ID_COMMUTATION], (uint32_t)&htim->Instance->DMAR, (uint32_t)BurstBuffer, ((BurstLength) >> 8) + 1);
3707  }
3708  break;
3709  case TIM_DMA_TRIGGER:
3710  {
3711  /* Set the DMA Period elapsed callback */
3712  htim->hdma[TIM_DMA_ID_TRIGGER]->XferCpltCallback = TIM_DMATriggerCplt;
3713 
3714  /* Set the DMA error callback */
3716 
3717  /* Enable the DMA Stream */
3718  HAL_DMA_Start_IT(htim->hdma[TIM_DMA_ID_TRIGGER], (uint32_t)&htim->Instance->DMAR, (uint32_t)BurstBuffer, ((BurstLength) >> 8) + 1);
3719  }
3720  break;
3721  default:
3722  break;
3723  }
3724 
3725  /* configure the DMA Burst Mode */
3726  htim->Instance->DCR = BurstBaseAddress | BurstLength;
3727 
3728  /* Enable the TIM DMA Request */
3729  __HAL_TIM_ENABLE_DMA(htim, BurstRequestSrc);
3730 
3731  htim->State = HAL_TIM_STATE_READY;
3732 
3733  /* Return function status */
3734  return HAL_OK;
3735 }
3736 
3744 HAL_StatusTypeDef HAL_TIM_DMABurst_ReadStop(TIM_HandleTypeDef *htim, uint32_t BurstRequestSrc)
3745 {
3746  /* Check the parameters */
3747  assert_param(IS_TIM_DMA_SOURCE(BurstRequestSrc));
3748 
3749  /* Abort the DMA transfer (at least disable the DMA channel) */
3750  switch(BurstRequestSrc)
3751  {
3752  case TIM_DMA_UPDATE:
3753  {
3755  }
3756  break;
3757  case TIM_DMA_CC1:
3758  {
3760  }
3761  break;
3762  case TIM_DMA_CC2:
3763  {
3765  }
3766  break;
3767  case TIM_DMA_CC3:
3768  {
3770  }
3771  break;
3772  case TIM_DMA_CC4:
3773  {
3775  }
3776  break;
3777  case TIM_DMA_COM:
3778  {
3780  }
3781  break;
3782  case TIM_DMA_TRIGGER:
3783  {
3785  }
3786  break;
3787  default:
3788  break;
3789  }
3790 
3791  /* Disable the TIM Update DMA request */
3792  __HAL_TIM_DISABLE_DMA(htim, BurstRequestSrc);
3793 
3794  /* Return function status */
3795  return HAL_OK;
3796 }
3797 
3818 HAL_StatusTypeDef HAL_TIM_GenerateEvent(TIM_HandleTypeDef *htim, uint32_t EventSource)
3819 {
3820  /* Check the parameters */
3822  assert_param(IS_TIM_EVENT_SOURCE(EventSource));
3823 
3824  /* Process Locked */
3825  __HAL_LOCK(htim);
3826 
3827  /* Change the TIM state */
3828  htim->State = HAL_TIM_STATE_BUSY;
3829 
3830  /* Set the event sources */
3831  htim->Instance->EGR = EventSource;
3832 
3833  /* Change the TIM state */
3834  htim->State = HAL_TIM_STATE_READY;
3835 
3836  __HAL_UNLOCK(htim);
3837 
3838  /* Return function status */
3839  return HAL_OK;
3840 }
3841 
3856 __weak HAL_StatusTypeDef HAL_TIM_ConfigOCrefClear(TIM_HandleTypeDef *htim, TIM_ClearInputConfigTypeDef * sClearInputConfig, uint32_t Channel)
3857 {
3858  /* Check the parameters */
3860  assert_param(IS_TIM_CHANNELS(Channel));
3862 
3863  /* Process Locked */
3864  __HAL_LOCK(htim);
3865 
3866  htim->State = HAL_TIM_STATE_BUSY;
3867 
3868  if(sClearInputConfig->ClearInputSource == TIM_CLEARINPUTSOURCE_ETR)
3869  {
3873 
3874  TIM_ETR_SetConfig(htim->Instance,
3875  sClearInputConfig->ClearInputPrescaler,
3876  sClearInputConfig->ClearInputPolarity,
3877  sClearInputConfig->ClearInputFilter);
3878  }
3879 
3880  switch (Channel)
3881  {
3882  case TIM_CHANNEL_1:
3883  {
3884  if(sClearInputConfig->ClearInputState != RESET)
3885  {
3886  /* Enable the Ocref clear feature for Channel 1 */
3887  htim->Instance->CCMR1 |= TIM_CCMR1_OC1CE;
3888  }
3889  else
3890  {
3891  /* Disable the Ocref clear feature for Channel 1 */
3892  htim->Instance->CCMR1 &= ~TIM_CCMR1_OC1CE;
3893  }
3894  }
3895  break;
3896  case TIM_CHANNEL_2:
3897  {
3899  if(sClearInputConfig->ClearInputState != RESET)
3900  {
3901  /* Enable the Ocref clear feature for Channel 2 */
3902  htim->Instance->CCMR1 |= TIM_CCMR1_OC2CE;
3903  }
3904  else
3905  {
3906  /* Disable the Ocref clear feature for Channel 2 */
3907  htim->Instance->CCMR1 &= ~TIM_CCMR1_OC2CE;
3908  }
3909  }
3910  break;
3911  case TIM_CHANNEL_3:
3912  {
3914  if(sClearInputConfig->ClearInputState != RESET)
3915  {
3916  /* Enable the Ocref clear feature for Channel 3 */
3917  htim->Instance->CCMR2 |= TIM_CCMR2_OC3CE;
3918  }
3919  else
3920  {
3921  /* Disable the Ocref clear feature for Channel 3 */
3922  htim->Instance->CCMR2 &= ~TIM_CCMR2_OC3CE;
3923  }
3924  }
3925  break;
3926  case TIM_CHANNEL_4:
3927  {
3929  if(sClearInputConfig->ClearInputState != RESET)
3930  {
3931  /* Enable the Ocref clear feature for Channel 4 */
3932  htim->Instance->CCMR2 |= TIM_CCMR2_OC4CE;
3933  }
3934  else
3935  {
3936  /* Disable the Ocref clear feature for Channel 4 */
3937  htim->Instance->CCMR2 &= ~TIM_CCMR2_OC4CE;
3938  }
3939  }
3940  break;
3941  default:
3942  break;
3943  }
3944 
3945  htim->State = HAL_TIM_STATE_READY;
3946 
3947  __HAL_UNLOCK(htim);
3948 
3949  return HAL_OK;
3950 }
3951 
3961 {
3962  uint32_t tmpsmcr = 0;
3963 
3964  /* Process Locked */
3965  __HAL_LOCK(htim);
3966 
3967  htim->State = HAL_TIM_STATE_BUSY;
3968 
3969  /* Check the parameters */
3970  assert_param(IS_TIM_CLOCKSOURCE(sClockSourceConfig->ClockSource));
3971 
3972  /* Reset the SMS, TS, ECE, ETPS and ETRF bits */
3973  tmpsmcr = htim->Instance->SMCR;
3974  tmpsmcr &= ~(TIM_SMCR_SMS | TIM_SMCR_TS);
3976  htim->Instance->SMCR = tmpsmcr;
3977 
3978  switch (sClockSourceConfig->ClockSource)
3979  {
3981  {
3983  /* Disable slave mode to clock the prescaler directly with the internal clock */
3984  htim->Instance->SMCR &= ~TIM_SMCR_SMS;
3985  }
3986  break;
3987 
3989  {
3991  assert_param(IS_TIM_CLOCKPOLARITY(sClockSourceConfig->ClockPolarity));
3992  assert_param(IS_TIM_CLOCKPRESCALER(sClockSourceConfig->ClockPrescaler));
3993  assert_param(IS_TIM_CLOCKFILTER(sClockSourceConfig->ClockFilter));
3994  /* Configure the ETR Clock source */
3995  TIM_ETR_SetConfig(htim->Instance,
3996  sClockSourceConfig->ClockPrescaler,
3997  sClockSourceConfig->ClockPolarity,
3998  sClockSourceConfig->ClockFilter);
3999  /* Get the TIMx SMCR register value */
4000  tmpsmcr = htim->Instance->SMCR;
4001  /* Reset the SMS and TS Bits */
4002  tmpsmcr &= ~(TIM_SMCR_SMS | TIM_SMCR_TS);
4003  /* Select the External clock mode1 and the ETRF trigger */
4005  /* Write to TIMx SMCR */
4006  htim->Instance->SMCR = tmpsmcr;
4007  }
4008  break;
4009 
4011  {
4013  assert_param(IS_TIM_CLOCKPOLARITY(sClockSourceConfig->ClockPolarity));
4014  assert_param(IS_TIM_CLOCKPRESCALER(sClockSourceConfig->ClockPrescaler));
4015  assert_param(IS_TIM_CLOCKFILTER(sClockSourceConfig->ClockFilter));
4016 
4017  /* Configure the ETR Clock source */
4018  TIM_ETR_SetConfig(htim->Instance,
4019  sClockSourceConfig->ClockPrescaler,
4020  sClockSourceConfig->ClockPolarity,
4021  sClockSourceConfig->ClockFilter);
4022  /* Enable the External clock mode2 */
4023  htim->Instance->SMCR |= TIM_SMCR_ECE;
4024  }
4025  break;
4026 
4027  case TIM_CLOCKSOURCE_TI1:
4028  {
4030 
4031  /* Check TI1 input conditioning related parameters */
4032  assert_param(IS_TIM_CLOCKPOLARITY(sClockSourceConfig->ClockPolarity));
4033  assert_param(IS_TIM_CLOCKFILTER(sClockSourceConfig->ClockFilter));
4034 
4035  TIM_TI1_ConfigInputStage(htim->Instance,
4036  sClockSourceConfig->ClockPolarity,
4037  sClockSourceConfig->ClockFilter);
4038  TIM_ITRx_SetConfig(htim->Instance, TIM_CLOCKSOURCE_TI1);
4039  }
4040  break;
4041  case TIM_CLOCKSOURCE_TI2:
4042  {
4044 
4045  /* Check TI1 input conditioning related parameters */
4046  assert_param(IS_TIM_CLOCKPOLARITY(sClockSourceConfig->ClockPolarity));
4047  assert_param(IS_TIM_CLOCKFILTER(sClockSourceConfig->ClockFilter));
4048 
4049  TIM_TI2_ConfigInputStage(htim->Instance,
4050  sClockSourceConfig->ClockPolarity,
4051  sClockSourceConfig->ClockFilter);
4052  TIM_ITRx_SetConfig(htim->Instance, TIM_CLOCKSOURCE_TI2);
4053  }
4054  break;
4055  case TIM_CLOCKSOURCE_TI1ED:
4056  {
4058  /* Check TI1 input conditioning related parameters */
4059  assert_param(IS_TIM_CLOCKPOLARITY(sClockSourceConfig->ClockPolarity));
4060  assert_param(IS_TIM_CLOCKFILTER(sClockSourceConfig->ClockFilter));
4061 
4062  TIM_TI1_ConfigInputStage(htim->Instance,
4063  sClockSourceConfig->ClockPolarity,
4064  sClockSourceConfig->ClockFilter);
4065  TIM_ITRx_SetConfig(htim->Instance, TIM_CLOCKSOURCE_TI1ED);
4066  }
4067  break;
4068  case TIM_CLOCKSOURCE_ITR0:
4069  {
4071  TIM_ITRx_SetConfig(htim->Instance, TIM_CLOCKSOURCE_ITR0);
4072  }
4073  break;
4074  case TIM_CLOCKSOURCE_ITR1:
4075  {
4077  TIM_ITRx_SetConfig(htim->Instance, TIM_CLOCKSOURCE_ITR1);
4078  }
4079  break;
4080  case TIM_CLOCKSOURCE_ITR2:
4081  {
4083  TIM_ITRx_SetConfig(htim->Instance, TIM_CLOCKSOURCE_ITR2);
4084  }
4085  break;
4086  case TIM_CLOCKSOURCE_ITR3:
4087  {
4089  TIM_ITRx_SetConfig(htim->Instance, TIM_CLOCKSOURCE_ITR3);
4090  }
4091  break;
4092 
4093  default:
4094  break;
4095  }
4096  htim->State = HAL_TIM_STATE_READY;
4097 
4098  __HAL_UNLOCK(htim);
4099 
4100  return HAL_OK;
4101 }
4102 
4116 HAL_StatusTypeDef HAL_TIM_ConfigTI1Input(TIM_HandleTypeDef *htim, uint32_t TI1_Selection)
4117 {
4118  uint32_t tmpcr2 = 0;
4119 
4120  /* Check the parameters */
4122  assert_param(IS_TIM_TI1SELECTION(TI1_Selection));
4123 
4124  /* Get the TIMx CR2 register value */
4125  tmpcr2 = htim->Instance->CR2;
4126 
4127  /* Reset the TI1 selection */
4128  tmpcr2 &= ~TIM_CR2_TI1S;
4129 
4130  /* Set the TI1 selection */
4131  tmpcr2 |= TI1_Selection;
4132 
4133  /* Write to TIMxCR2 */
4134  htim->Instance->CR2 = tmpcr2;
4135 
4136  return HAL_OK;
4137 }
4138 
4150 {
4151  uint32_t tmpsmcr = 0;
4152  uint32_t tmpccmr1 = 0;
4153  uint32_t tmpccer = 0;
4154 
4155  /* Check the parameters */
4157  assert_param(IS_TIM_SLAVE_MODE(sSlaveConfig->SlaveMode));
4159 
4160  __HAL_LOCK(htim);
4161 
4162  htim->State = HAL_TIM_STATE_BUSY;
4163 
4164  /* Get the TIMx SMCR register value */
4165  tmpsmcr = htim->Instance->SMCR;
4166 
4167  /* Reset the Trigger Selection Bits */
4168  tmpsmcr &= ~TIM_SMCR_TS;
4169  /* Set the Input Trigger source */
4170  tmpsmcr |= sSlaveConfig->InputTrigger;
4171 
4172  /* Reset the slave mode Bits */
4173  tmpsmcr &= ~TIM_SMCR_SMS;
4174  /* Set the slave mode */
4175  tmpsmcr |= sSlaveConfig->SlaveMode;
4176 
4177  /* Write to TIMx SMCR */
4178  htim->Instance->SMCR = tmpsmcr;
4179 
4180  /* Configure the trigger prescaler, filter, and polarity */
4181  switch (sSlaveConfig->InputTrigger)
4182  {
4183  case TIM_TS_ETRF:
4184  {
4185  /* Check the parameters */
4190  /* Configure the ETR Trigger source */
4191  TIM_ETR_SetConfig(htim->Instance,
4192  sSlaveConfig->TriggerPrescaler,
4193  sSlaveConfig->TriggerPolarity,
4194  sSlaveConfig->TriggerFilter);
4195  }
4196  break;
4197 
4198  case TIM_TS_TI1F_ED:
4199  {
4200  /* Check the parameters */
4203 
4204  /* Disable the Channel 1: Reset the CC1E Bit */
4205  tmpccer = htim->Instance->CCER;
4206  htim->Instance->CCER &= ~TIM_CCER_CC1E;
4207  tmpccmr1 = htim->Instance->CCMR1;
4208 
4209  /* Set the filter */
4210  tmpccmr1 &= ~TIM_CCMR1_IC1F;
4211  tmpccmr1 |= ((sSlaveConfig->TriggerFilter) << 4);
4212 
4213  /* Write to TIMx CCMR1 and CCER registers */
4214  htim->Instance->CCMR1 = tmpccmr1;
4215  htim->Instance->CCER = tmpccer;
4216 
4217  }
4218  break;
4219 
4220  case TIM_TS_TI1FP1:
4221  {
4222  /* Check the parameters */
4226 
4227  /* Configure TI1 Filter and Polarity */
4228  TIM_TI1_ConfigInputStage(htim->Instance,
4229  sSlaveConfig->TriggerPolarity,
4230  sSlaveConfig->TriggerFilter);
4231  }
4232  break;
4233 
4234  case TIM_TS_TI2FP2:
4235  {
4236  /* Check the parameters */
4240 
4241  /* Configure TI2 Filter and Polarity */
4242  TIM_TI2_ConfigInputStage(htim->Instance,
4243  sSlaveConfig->TriggerPolarity,
4244  sSlaveConfig->TriggerFilter);
4245  }
4246  break;
4247 
4248  case TIM_TS_ITR0:
4249  {
4250  /* Check the parameter */
4252  }
4253  break;
4254 
4255  case TIM_TS_ITR1:
4256  {
4257  /* Check the parameter */
4259  }
4260  break;
4261 
4262  case TIM_TS_ITR2:
4263  {
4264  /* Check the parameter */
4266  }
4267  break;
4268 
4269  case TIM_TS_ITR3:
4270  {
4271  /* Check the parameter */
4273  }
4274  break;
4275 
4276  default:
4277  break;
4278  }
4279 
4280  htim->State = HAL_TIM_STATE_READY;
4281 
4282  __HAL_UNLOCK(htim);
4283 
4284  return HAL_OK;
4285 }
4286 
4297  TIM_SlaveConfigTypeDef * sSlaveConfig)
4298 {
4299  /* Check the parameters */
4301  assert_param(IS_TIM_SLAVE_MODE(sSlaveConfig->SlaveMode));
4303 
4304  __HAL_LOCK(htim);
4305 
4306  htim->State = HAL_TIM_STATE_BUSY;
4307 
4308  TIM_SlaveTimer_SetConfig(htim, sSlaveConfig);
4309 
4310  /* Enable Trigger Interrupt */
4312 
4313  /* Disable Trigger DMA request */
4315 
4316  htim->State = HAL_TIM_STATE_READY;
4317 
4318  __HAL_UNLOCK(htim);
4319 
4320  return HAL_OK;
4321 }
4322 
4335 uint32_t HAL_TIM_ReadCapturedValue(TIM_HandleTypeDef *htim, uint32_t Channel)
4336 {
4337  uint32_t tmpreg = 0;
4338 
4339  __HAL_LOCK(htim);
4340 
4341  switch (Channel)
4342  {
4343  case TIM_CHANNEL_1:
4344  {
4345  /* Check the parameters */
4347 
4348  /* Return the capture 1 value */
4349  tmpreg = htim->Instance->CCR1;
4350 
4351  break;
4352  }
4353  case TIM_CHANNEL_2:
4354  {
4355  /* Check the parameters */
4357 
4358  /* Return the capture 2 value */
4359  tmpreg = htim->Instance->CCR2;
4360 
4361  break;
4362  }
4363 
4364  case TIM_CHANNEL_3:
4365  {
4366  /* Check the parameters */
4368 
4369  /* Return the capture 3 value */
4370  tmpreg = htim->Instance->CCR3;
4371 
4372  break;
4373  }
4374 
4375  case TIM_CHANNEL_4:
4376  {
4377  /* Check the parameters */
4379 
4380  /* Return the capture 4 value */
4381  tmpreg = htim->Instance->CCR4;
4382 
4383  break;
4384  }
4385 
4386  default:
4387  break;
4388  }
4389 
4390  __HAL_UNLOCK(htim);
4391  return tmpreg;
4392 }
4393 
4424 {
4425  /* Prevent unused argument(s) compilation warning */
4426  UNUSED(htim);
4427 
4428  /* NOTE : This function Should not be modified, when the callback is needed,
4429  the __HAL_TIM_PeriodElapsedCallback could be implemented in the user file
4430  */
4431 
4432 }
4440 {
4441  /* Prevent unused argument(s) compilation warning */
4442  UNUSED(htim);
4443 
4444  /* NOTE : This function Should not be modified, when the callback is needed,
4445  the __HAL_TIM_OC_DelayElapsedCallback could be implemented in the user file
4446  */
4447 }
4455 {
4456  /* Prevent unused argument(s) compilation warning */
4457  UNUSED(htim);
4458 
4459  /* NOTE : This function Should not be modified, when the callback is needed,
4460  the __HAL_TIM_IC_CaptureCallback could be implemented in the user file
4461  */
4462 }
4463 
4471 {
4472  /* Prevent unused argument(s) compilation warning */
4473  UNUSED(htim);
4474 
4475  /* NOTE : This function Should not be modified, when the callback is needed,
4476  the __HAL_TIM_PWM_PulseFinishedCallback could be implemented in the user file
4477  */
4478 }
4479 
4486 __weak void HAL_TIM_TriggerCallback(TIM_HandleTypeDef *htim)
4487 {
4488  /* Prevent unused argument(s) compilation warning */
4489  UNUSED(htim);
4490 
4491  /* NOTE : This function Should not be modified, when the callback is needed,
4492  the HAL_TIM_TriggerCallback could be implemented in the user file
4493  */
4494 }
4495 
4502 __weak void HAL_TIM_ErrorCallback(TIM_HandleTypeDef *htim)
4503 {
4504  /* Prevent unused argument(s) compilation warning */
4505  UNUSED(htim);
4506 
4507  /* NOTE : This function Should not be modified, when the callback is needed,
4508  the HAL_TIM_ErrorCallback could be implemented in the user file
4509  */
4510 }
4511 
4538 {
4539  return htim->State;
4540 }
4541 
4549 {
4550  return htim->State;
4551 }
4552 
4560 {
4561  return htim->State;
4562 }
4563 
4571 {
4572  return htim->State;
4573 }
4574 
4582 {
4583  return htim->State;
4584 }
4585 
4593 {
4594  return htim->State;
4595 }
4596 
4608 {
4609  TIM_HandleTypeDef* htim = ( TIM_HandleTypeDef* )((DMA_HandleTypeDef* )hdma)->Parent;
4610 
4611  htim->State= HAL_TIM_STATE_READY;
4612 
4613  HAL_TIM_ErrorCallback(htim);
4614 }
4615 
4623 {
4624  TIM_HandleTypeDef* htim = ( TIM_HandleTypeDef* )((DMA_HandleTypeDef* )hdma)->Parent;
4625 
4626  htim->State= HAL_TIM_STATE_READY;
4627 
4628  if (hdma == htim->hdma[TIM_DMA_ID_CC1])
4629  {
4631  }
4632  else if (hdma == htim->hdma[TIM_DMA_ID_CC2])
4633  {
4635  }
4636  else if (hdma == htim->hdma[TIM_DMA_ID_CC3])
4637  {
4639  }
4640  else if (hdma == htim->hdma[TIM_DMA_ID_CC4])
4641  {
4643  }
4644 
4646 
4648 }
4656 {
4657  TIM_HandleTypeDef* htim = ( TIM_HandleTypeDef* )((DMA_HandleTypeDef* )hdma)->Parent;
4658 
4659  htim->State= HAL_TIM_STATE_READY;
4660 
4661  if (hdma == htim->hdma[TIM_DMA_ID_CC1])
4662  {
4664  }
4665  else if (hdma == htim->hdma[TIM_DMA_ID_CC2])
4666  {
4668  }
4669  else if (hdma == htim->hdma[TIM_DMA_ID_CC3])
4670  {
4672  }
4673  else if (hdma == htim->hdma[TIM_DMA_ID_CC4])
4674  {
4676  }
4677 
4679 
4681 
4682 }
4683 
4690 static void TIM_DMAPeriodElapsedCplt(DMA_HandleTypeDef *hdma)
4691 {
4692  TIM_HandleTypeDef* htim = ( TIM_HandleTypeDef* )((DMA_HandleTypeDef* )hdma)->Parent;
4693 
4694  htim->State= HAL_TIM_STATE_READY;
4695 
4697 }
4698 
4705 static void TIM_DMATriggerCplt(DMA_HandleTypeDef *hdma)
4706 {
4707  TIM_HandleTypeDef* htim = ( TIM_HandleTypeDef* )((DMA_HandleTypeDef* )hdma)->Parent;
4708 
4709  htim->State= HAL_TIM_STATE_READY;
4710 
4712 }
4713 
4720 void TIM_Base_SetConfig(TIM_TypeDef *TIMx, TIM_Base_InitTypeDef *Structure)
4721 {
4722  uint32_t tmpcr1 = 0;
4723  tmpcr1 = TIMx->CR1;
4724 
4725  /* Set TIM Time Base Unit parameters ---------------------------------------*/
4726  if(IS_TIM_CC3_INSTANCE(TIMx) != RESET)
4727  {
4728  /* Select the Counter Mode */
4729  tmpcr1 &= ~(TIM_CR1_DIR | TIM_CR1_CMS);
4730  tmpcr1 |= Structure->CounterMode;
4731  }
4732 
4733  if(IS_TIM_CC1_INSTANCE(TIMx) != RESET)
4734  {
4735  /* Set the clock division */
4736  tmpcr1 &= ~TIM_CR1_CKD;
4737  tmpcr1 |= (uint32_t)Structure->ClockDivision;
4738  }
4739 
4740  TIMx->CR1 = tmpcr1;
4741 
4742  /* Set the Auto-reload value */
4743  TIMx->ARR = (uint32_t)Structure->Period ;
4744 
4745  /* Set the Prescaler value */
4746  TIMx->PSC = (uint32_t)Structure->Prescaler;
4747 
4748  if(IS_TIM_ADVANCED_INSTANCE(TIMx) != RESET)
4749  {
4750  /* Set the Repetition Counter value */
4751  TIMx->RCR = Structure->RepetitionCounter;
4752  }
4753 
4754  /* Generate an update event to reload the Prescaler
4755  and the repetition counter(only for TIM1 and TIM8) value immediately */
4756  TIMx->EGR = TIM_EGR_UG;
4757 }
4758 
4765 void TIM_OC1_SetConfig(TIM_TypeDef *TIMx, TIM_OC_InitTypeDef *OC_Config)
4766 {
4767  uint32_t tmpccmrx = 0;
4768  uint32_t tmpccer = 0;
4769  uint32_t tmpcr2 = 0;
4770 
4771  /* Disable the Channel 1: Reset the CC1E Bit */
4772  TIMx->CCER &= ~TIM_CCER_CC1E;
4773 
4774  /* Get the TIMx CCER register value */
4775  tmpccer = TIMx->CCER;
4776  /* Get the TIMx CR2 register value */
4777  tmpcr2 = TIMx->CR2;
4778 
4779  /* Get the TIMx CCMR1 register value */
4780  tmpccmrx = TIMx->CCMR1;
4781 
4782  /* Reset the Output Compare Mode Bits */
4783  tmpccmrx &= ~TIM_CCMR1_OC1M;
4784  tmpccmrx &= ~TIM_CCMR1_CC1S;
4785  /* Select the Output Compare Mode */
4786  tmpccmrx |= OC_Config->OCMode;
4787 
4788  /* Reset the Output Polarity level */
4789  tmpccer &= ~TIM_CCER_CC1P;
4790  /* Set the Output Compare Polarity */
4791  tmpccer |= OC_Config->OCPolarity;
4792 
4793 
4794  if(IS_TIM_ADVANCED_INSTANCE(TIMx) != RESET)
4795  {
4796  /* Reset the Output N Polarity level */
4797  tmpccer &= ~TIM_CCER_CC1NP;
4798  /* Set the Output N Polarity */
4799  tmpccer |= OC_Config->OCNPolarity;
4800  /* Reset the Output N State */
4801  tmpccer &= ~TIM_CCER_CC1NE;
4802 
4803  /* Reset the Output Compare and Output Compare N IDLE State */
4804  tmpcr2 &= ~TIM_CR2_OIS1;
4805  tmpcr2 &= ~TIM_CR2_OIS1N;
4806  /* Set the Output Idle state */
4807  tmpcr2 |= OC_Config->OCIdleState;
4808  /* Set the Output N Idle state */
4809  tmpcr2 |= OC_Config->OCNIdleState;
4810  }
4811  /* Write to TIMx CR2 */
4812  TIMx->CR2 = tmpcr2;
4813 
4814  /* Write to TIMx CCMR1 */
4815  TIMx->CCMR1 = tmpccmrx;
4816 
4817  /* Set the Capture Compare Register value */
4818  TIMx->CCR1 = OC_Config->Pulse;
4819 
4820  /* Write to TIMx CCER */
4821  TIMx->CCER = tmpccer;
4822 }
4823 
4830 void TIM_OC2_SetConfig(TIM_TypeDef *TIMx, TIM_OC_InitTypeDef *OC_Config)
4831 {
4832  uint32_t tmpccmrx = 0;
4833  uint32_t tmpccer = 0;
4834  uint32_t tmpcr2 = 0;
4835 
4836  /* Disable the Channel 2: Reset the CC2E Bit */
4837  TIMx->CCER &= ~TIM_CCER_CC2E;
4838 
4839  /* Get the TIMx CCER register value */
4840  tmpccer = TIMx->CCER;
4841  /* Get the TIMx CR2 register value */
4842  tmpcr2 = TIMx->CR2;
4843 
4844  /* Get the TIMx CCMR1 register value */
4845  tmpccmrx = TIMx->CCMR1;
4846 
4847  /* Reset the Output Compare mode and Capture/Compare selection Bits */
4848  tmpccmrx &= ~TIM_CCMR1_OC2M;
4849  tmpccmrx &= ~TIM_CCMR1_CC2S;
4850 
4851  /* Select the Output Compare Mode */
4852  tmpccmrx |= (OC_Config->OCMode << 8);
4853 
4854  /* Reset the Output Polarity level */
4855  tmpccer &= ~TIM_CCER_CC2P;
4856  /* Set the Output Compare Polarity */
4857  tmpccer |= (OC_Config->OCPolarity << 4);
4858 
4859  if(IS_TIM_ADVANCED_INSTANCE(TIMx) != RESET)
4860  {
4862 
4863  /* Reset the Output N Polarity level */
4864  tmpccer &= ~TIM_CCER_CC2NP;
4865  /* Set the Output N Polarity */
4866  tmpccer |= (OC_Config->OCNPolarity << 4);
4867  /* Reset the Output N State */
4868  tmpccer &= ~TIM_CCER_CC2NE;
4869 
4870  /* Reset the Output Compare and Output Compare N IDLE State */
4871  tmpcr2 &= ~TIM_CR2_OIS2;
4872  tmpcr2 &= ~TIM_CR2_OIS2N;
4873  /* Set the Output Idle state */
4874  tmpcr2 |= (OC_Config->OCIdleState << 2);
4875  /* Set the Output N Idle state */
4876  tmpcr2 |= (OC_Config->OCNIdleState << 2);
4877  }
4878  /* Write to TIMx CR2 */
4879  TIMx->CR2 = tmpcr2;
4880 
4881  /* Write to TIMx CCMR1 */
4882  TIMx->CCMR1 = tmpccmrx;
4883 
4884  /* Set the Capture Compare Register value */
4885  TIMx->CCR2 = OC_Config->Pulse;
4886 
4887  /* Write to TIMx CCER */
4888  TIMx->CCER = tmpccer;
4889 }
4890 
4897 void TIM_OC3_SetConfig(TIM_TypeDef *TIMx, TIM_OC_InitTypeDef *OC_Config)
4898 {
4899  uint32_t tmpccmrx = 0;
4900  uint32_t tmpccer = 0;
4901  uint32_t tmpcr2 = 0;
4902 
4903  /* Disable the Channel 3: Reset the CC2E Bit */
4904  TIMx->CCER &= ~TIM_CCER_CC3E;
4905 
4906  /* Get the TIMx CCER register value */
4907  tmpccer = TIMx->CCER;
4908  /* Get the TIMx CR2 register value */
4909  tmpcr2 = TIMx->CR2;
4910 
4911  /* Get the TIMx CCMR2 register value */
4912  tmpccmrx = TIMx->CCMR2;
4913 
4914  /* Reset the Output Compare mode and Capture/Compare selection Bits */
4915  tmpccmrx &= ~TIM_CCMR2_OC3M;
4916  tmpccmrx &= ~TIM_CCMR2_CC3S;
4917  /* Select the Output Compare Mode */
4918  tmpccmrx |= OC_Config->OCMode;
4919 
4920  /* Reset the Output Polarity level */
4921  tmpccer &= ~TIM_CCER_CC3P;
4922  /* Set the Output Compare Polarity */
4923  tmpccer |= (OC_Config->OCPolarity << 8);
4924 
4925  if(IS_TIM_ADVANCED_INSTANCE(TIMx) != RESET)
4926  {
4928 
4929  /* Reset the Output N Polarity level */
4930  tmpccer &= ~TIM_CCER_CC3NP;
4931  /* Set the Output N Polarity */
4932  tmpccer |= (OC_Config->OCNPolarity << 8);
4933  /* Reset the Output N State */
4934  tmpccer &= ~TIM_CCER_CC3NE;
4935 
4936  /* Reset the Output Compare and Output Compare N IDLE State */
4937  tmpcr2 &= ~TIM_CR2_OIS3;
4938  tmpcr2 &= ~TIM_CR2_OIS3N;
4939  /* Set the Output Idle state */
4940  tmpcr2 |= (OC_Config->OCIdleState << 4);
4941  /* Set the Output N Idle state */
4942  tmpcr2 |= (OC_Config->OCNIdleState << 4);
4943  }
4944  /* Write to TIMx CR2 */
4945  TIMx->CR2 = tmpcr2;
4946 
4947  /* Write to TIMx CCMR2 */
4948  TIMx->CCMR2 = tmpccmrx;
4949 
4950  /* Set the Capture Compare Register value */
4951  TIMx->CCR3 = OC_Config->Pulse;
4952 
4953  /* Write to TIMx CCER */
4954  TIMx->CCER = tmpccer;
4955 }
4956 
4963 void TIM_OC4_SetConfig(TIM_TypeDef *TIMx, TIM_OC_InitTypeDef *OC_Config)
4964 {
4965  uint32_t tmpccmrx = 0;
4966  uint32_t tmpccer = 0;
4967  uint32_t tmpcr2 = 0;
4968 
4969  /* Disable the Channel 4: Reset the CC4E Bit */
4970  TIMx->CCER &= ~TIM_CCER_CC4E;
4971 
4972  /* Get the TIMx CCER register value */
4973  tmpccer = TIMx->CCER;
4974  /* Get the TIMx CR2 register value */
4975  tmpcr2 = TIMx->CR2;
4976 
4977  /* Get the TIMx CCMR2 register value */
4978  tmpccmrx = TIMx->CCMR2;
4979 
4980  /* Reset the Output Compare mode and Capture/Compare selection Bits */
4981  tmpccmrx &= ~TIM_CCMR2_OC4M;
4982  tmpccmrx &= ~TIM_CCMR2_CC4S;
4983 
4984  /* Select the Output Compare Mode */
4985  tmpccmrx |= (OC_Config->OCMode << 8);
4986 
4987  /* Reset the Output Polarity level */
4988  tmpccer &= ~TIM_CCER_CC4P;
4989  /* Set the Output Compare Polarity */
4990  tmpccer |= (OC_Config->OCPolarity << 12);
4991 
4992  /*if((TIMx == TIM1) || (TIMx == TIM8))*/
4993  if(IS_TIM_ADVANCED_INSTANCE(TIMx) != RESET)
4994  {
4996  /* Reset the Output Compare IDLE State */
4997  tmpcr2 &= ~TIM_CR2_OIS4;
4998  /* Set the Output Idle state */
4999  tmpcr2 |= (OC_Config->OCIdleState << 6);
5000  }
5001  /* Write to TIMx CR2 */
5002  TIMx->CR2 = tmpcr2;
5003 
5004  /* Write to TIMx CCMR2 */
5005  TIMx->CCMR2 = tmpccmrx;
5006 
5007  /* Set the Capture Compare Register value */
5008  TIMx->CCR4 = OC_Config->Pulse;
5009 
5010  /* Write to TIMx CCER */
5011  TIMx->CCER = tmpccer;
5012 }
5013 
5021 static void TIM_SlaveTimer_SetConfig(TIM_HandleTypeDef *htim,
5022  TIM_SlaveConfigTypeDef * sSlaveConfig)
5023 {
5024  uint32_t tmpsmcr = 0;
5025  uint32_t tmpccmr1 = 0;
5026  uint32_t tmpccer = 0;
5027 
5028  /* Get the TIMx SMCR register value */
5029  tmpsmcr = htim->Instance->SMCR;
5030 
5031  /* Reset the Trigger Selection Bits */
5032  tmpsmcr &= ~TIM_SMCR_TS;
5033  /* Set the Input Trigger source */
5034  tmpsmcr |= sSlaveConfig->InputTrigger;
5035 
5036  /* Reset the slave mode Bits */
5037  tmpsmcr &= ~TIM_SMCR_SMS;
5038  /* Set the slave mode */
5039  tmpsmcr |= sSlaveConfig->SlaveMode;
5040 
5041  /* Write to TIMx SMCR */
5042  htim->Instance->SMCR = tmpsmcr;
5043 
5044  /* Configure the trigger prescaler, filter, and polarity */
5045  switch (sSlaveConfig->InputTrigger)
5046  {
5047  case TIM_TS_ETRF:
5048  {
5049  /* Check the parameters */
5054  /* Configure the ETR Trigger source */
5055  TIM_ETR_SetConfig(htim->Instance,
5056  sSlaveConfig->TriggerPrescaler,
5057  sSlaveConfig->TriggerPolarity,
5058  sSlaveConfig->TriggerFilter);
5059  }
5060  break;
5061 
5062  case TIM_TS_TI1F_ED:
5063  {
5064  /* Check the parameters */
5068 
5069  /* Disable the Channel 1: Reset the CC1E Bit */
5070  tmpccer = htim->Instance->CCER;
5071  htim->Instance->CCER &= ~TIM_CCER_CC1E;
5072  tmpccmr1 = htim->Instance->CCMR1;
5073 
5074  /* Set the filter */
5075  tmpccmr1 &= ~TIM_CCMR1_IC1F;
5076  tmpccmr1 |= ((sSlaveConfig->TriggerFilter) << 4);
5077 
5078  /* Write to TIMx CCMR1 and CCER registers */
5079  htim->Instance->CCMR1 = tmpccmr1;
5080  htim->Instance->CCER = tmpccer;
5081 
5082  }
5083  break;
5084 
5085  case TIM_TS_TI1FP1:
5086  {
5087  /* Check the parameters */
5091 
5092  /* Configure TI1 Filter and Polarity */
5093  TIM_TI1_ConfigInputStage(htim->Instance,
5094  sSlaveConfig->TriggerPolarity,
5095  sSlaveConfig->TriggerFilter);
5096  }
5097  break;
5098 
5099  case TIM_TS_TI2FP2:
5100  {
5101  /* Check the parameters */
5105 
5106  /* Configure TI2 Filter and Polarity */
5107  TIM_TI2_ConfigInputStage(htim->Instance,
5108  sSlaveConfig->TriggerPolarity,
5109  sSlaveConfig->TriggerFilter);
5110  }
5111  break;
5112 
5113  case TIM_TS_ITR0:
5114  {
5115  /* Check the parameter */
5117  }
5118  break;
5119 
5120  case TIM_TS_ITR1:
5121  {
5122  /* Check the parameter */
5124  }
5125  break;
5126 
5127  case TIM_TS_ITR2:
5128  {
5129  /* Check the parameter */
5131  }
5132  break;
5133 
5134  case TIM_TS_ITR3:
5135  {
5136  /* Check the parameter */
5138  }
5139  break;
5140 
5141  default:
5142  break;
5143  }
5144 }
5145 
5166 void TIM_TI1_SetConfig(TIM_TypeDef *TIMx, uint32_t TIM_ICPolarity, uint32_t TIM_ICSelection,
5167  uint32_t TIM_ICFilter)
5168 {
5169  uint32_t tmpccmr1 = 0;
5170  uint32_t tmpccer = 0;
5171 
5172  /* Disable the Channel 1: Reset the CC1E Bit */
5173  TIMx->CCER &= ~TIM_CCER_CC1E;
5174  tmpccmr1 = TIMx->CCMR1;
5175  tmpccer = TIMx->CCER;
5176 
5177  /* Select the Input */
5178  if(IS_TIM_CC2_INSTANCE(TIMx) != RESET)
5179  {
5180  tmpccmr1 &= ~TIM_CCMR1_CC1S;
5181  tmpccmr1 |= TIM_ICSelection;
5182  }
5183  else
5184  {
5185  tmpccmr1 |= TIM_CCMR1_CC1S_0;
5186  }
5187 
5188  /* Set the filter */
5189  tmpccmr1 &= ~TIM_CCMR1_IC1F;
5190  tmpccmr1 |= ((TIM_ICFilter << 4) & TIM_CCMR1_IC1F);
5191 
5192  /* Select the Polarity and set the CC1E Bit */
5193  tmpccer &= ~(TIM_CCER_CC1P | TIM_CCER_CC1NP);
5194  tmpccer |= (TIM_ICPolarity & (TIM_CCER_CC1P | TIM_CCER_CC1NP));
5195 
5196  /* Write to TIMx CCMR1 and CCER registers */
5197  TIMx->CCMR1 = tmpccmr1;
5198  TIMx->CCER = tmpccer;
5199 }
5200 
5213 static void TIM_TI1_ConfigInputStage(TIM_TypeDef *TIMx, uint32_t TIM_ICPolarity, uint32_t TIM_ICFilter)
5214 {
5215  uint32_t tmpccmr1 = 0;
5216  uint32_t tmpccer = 0;
5217 
5218  /* Disable the Channel 1: Reset the CC1E Bit */
5219  tmpccer = TIMx->CCER;
5220  TIMx->CCER &= ~TIM_CCER_CC1E;
5221  tmpccmr1 = TIMx->CCMR1;
5222 
5223  /* Set the filter */
5224  tmpccmr1 &= ~TIM_CCMR1_IC1F;
5225  tmpccmr1 |= (TIM_ICFilter << 4);
5226 
5227  /* Select the Polarity and set the CC1E Bit */
5228  tmpccer &= ~(TIM_CCER_CC1P | TIM_CCER_CC1NP);
5229  tmpccer |= TIM_ICPolarity;
5230 
5231  /* Write to TIMx CCMR1 and CCER registers */
5232  TIMx->CCMR1 = tmpccmr1;
5233  TIMx->CCER = tmpccer;
5234 }
5235 
5256 static void TIM_TI2_SetConfig(TIM_TypeDef *TIMx, uint32_t TIM_ICPolarity, uint32_t TIM_ICSelection,
5257  uint32_t TIM_ICFilter)
5258 {
5259  uint32_t tmpccmr1 = 0;
5260  uint32_t tmpccer = 0;
5261 
5262  /* Disable the Channel 2: Reset the CC2E Bit */
5263  TIMx->CCER &= ~TIM_CCER_CC2E;
5264  tmpccmr1 = TIMx->CCMR1;
5265  tmpccer = TIMx->CCER;
5266 
5267  /* Select the Input */
5268  tmpccmr1 &= ~TIM_CCMR1_CC2S;
5269  tmpccmr1 |= (TIM_ICSelection << 8);
5270 
5271  /* Set the filter */
5272  tmpccmr1 &= ~TIM_CCMR1_IC2F;
5273  tmpccmr1 |= ((TIM_ICFilter << 12) & TIM_CCMR1_IC2F);
5274 
5275  /* Select the Polarity and set the CC2E Bit */
5276  tmpccer &= ~(TIM_CCER_CC2P | TIM_CCER_CC2NP);
5277  tmpccer |= ((TIM_ICPolarity << 4) & (TIM_CCER_CC2P | TIM_CCER_CC2NP));
5278 
5279  /* Write to TIMx CCMR1 and CCER registers */
5280  TIMx->CCMR1 = tmpccmr1 ;
5281  TIMx->CCER = tmpccer;
5282 }
5283 
5296 static void TIM_TI2_ConfigInputStage(TIM_TypeDef *TIMx, uint32_t TIM_ICPolarity, uint32_t TIM_ICFilter)
5297 {
5298 uint32_t tmpccmr1 = 0;
5299  uint32_t tmpccer = 0;
5300 
5301  /* Disable the Channel 2: Reset the CC2E Bit */
5302  TIMx->CCER &= ~TIM_CCER_CC2E;
5303  tmpccmr1 = TIMx->CCMR1;
5304  tmpccer = TIMx->CCER;
5305 
5306  /* Set the filter */
5307  tmpccmr1 &= ~TIM_CCMR1_IC2F;
5308  tmpccmr1 |= (TIM_ICFilter << 12);
5309 
5310  /* Select the Polarity and set the CC2E Bit */
5311  tmpccer &= ~(TIM_CCER_CC2P | TIM_CCER_CC2NP);
5312  tmpccer |= (TIM_ICPolarity << 4);
5313 
5314  /* Write to TIMx CCMR1 and CCER registers */
5315  TIMx->CCMR1 = tmpccmr1 ;
5316  TIMx->CCER = tmpccer;
5317 }
5318 
5339 static void TIM_TI3_SetConfig(TIM_TypeDef *TIMx, uint32_t TIM_ICPolarity, uint32_t TIM_ICSelection,
5340  uint32_t TIM_ICFilter)
5341 {
5342  uint32_t tmpccmr2 = 0;
5343  uint32_t tmpccer = 0;
5344 
5345  /* Disable the Channel 3: Reset the CC3E Bit */
5346  TIMx->CCER &= ~TIM_CCER_CC3E;
5347  tmpccmr2 = TIMx->CCMR2;
5348  tmpccer = TIMx->CCER;
5349 
5350  /* Select the Input */
5351  tmpccmr2 &= ~TIM_CCMR2_CC3S;
5352  tmpccmr2 |= TIM_ICSelection;
5353 
5354  /* Set the filter */
5355  tmpccmr2 &= ~TIM_CCMR2_IC3F;
5356  tmpccmr2 |= ((TIM_ICFilter << 4) & TIM_CCMR2_IC3F);
5357 
5358  /* Select the Polarity and set the CC3E Bit */
5359  tmpccer &= ~(TIM_CCER_CC3P | TIM_CCER_CC3NP);
5360  tmpccer |= ((TIM_ICPolarity << 8) & (TIM_CCER_CC3P | TIM_CCER_CC3NP));
5361 
5362  /* Write to TIMx CCMR2 and CCER registers */
5363  TIMx->CCMR2 = tmpccmr2;
5364  TIMx->CCER = tmpccer;
5365 }
5366 
5387 static void TIM_TI4_SetConfig(TIM_TypeDef *TIMx, uint32_t TIM_ICPolarity, uint32_t TIM_ICSelection,
5388  uint32_t TIM_ICFilter)
5389 {
5390  uint32_t tmpccmr2 = 0;
5391  uint32_t tmpccer = 0;
5392 
5393  /* Disable the Channel 4: Reset the CC4E Bit */
5394  TIMx->CCER &= ~TIM_CCER_CC4E;
5395  tmpccmr2 = TIMx->CCMR2;
5396  tmpccer = TIMx->CCER;
5397 
5398  /* Select the Input */
5399  tmpccmr2 &= ~TIM_CCMR2_CC4S;
5400  tmpccmr2 |= (TIM_ICSelection << 8);
5401 
5402  /* Set the filter */
5403  tmpccmr2 &= ~TIM_CCMR2_IC4F;
5404  tmpccmr2 |= ((TIM_ICFilter << 12) & TIM_CCMR2_IC4F);
5405 
5406  /* Select the Polarity and set the CC4E Bit */
5407  tmpccer &= ~(TIM_CCER_CC4P | TIM_CCER_CC4NP);
5408  tmpccer |= ((TIM_ICPolarity << 12) & (TIM_CCER_CC4P | TIM_CCER_CC4NP));
5409 
5410  /* Write to TIMx CCMR2 and CCER registers */
5411  TIMx->CCMR2 = tmpccmr2;
5412  TIMx->CCER = tmpccer ;
5413 }
5414 
5430 static void TIM_ITRx_SetConfig(TIM_TypeDef *TIMx, uint16_t TIM_ITRx)
5431 {
5432  uint32_t tmpsmcr = 0;
5433 
5434  /* Get the TIMx SMCR register value */
5435  tmpsmcr = TIMx->SMCR;
5436  /* Reset the TS Bits */
5437  tmpsmcr &= ~TIM_SMCR_TS;
5438  /* Set the Input Trigger source and the slave mode*/
5439  tmpsmcr |= TIM_ITRx | TIM_SLAVEMODE_EXTERNAL1;
5440  /* Write to TIMx SMCR */
5441  TIMx->SMCR = tmpsmcr;
5442 }
5443 
5461 void TIM_ETR_SetConfig(TIM_TypeDef* TIMx, uint32_t TIM_ExtTRGPrescaler,
5462  uint32_t TIM_ExtTRGPolarity, uint32_t ExtTRGFilter)
5463 {
5464  uint32_t tmpsmcr = 0;
5465 
5466  tmpsmcr = TIMx->SMCR;
5467 
5468  /* Reset the ETR Bits */
5470 
5471  /* Set the Prescaler, the Filter value and the Polarity */
5472  tmpsmcr |= (uint32_t)(TIM_ExtTRGPrescaler | (TIM_ExtTRGPolarity | (ExtTRGFilter << 8)));
5473 
5474  /* Write to TIMx SMCR */
5475  TIMx->SMCR = tmpsmcr;
5476 }
5477 
5491 void TIM_CCxChannelCmd(TIM_TypeDef* TIMx, uint32_t Channel, uint32_t ChannelState)
5492 {
5493  uint32_t tmp = 0;
5494 
5495  /* Check the parameters */
5497  assert_param(IS_TIM_CHANNELS(Channel));
5498 
5499  tmp = TIM_CCER_CC1E << Channel;
5500 
5501  /* Reset the CCxE Bit */
5502  TIMx->CCER &= ~tmp;
5503 
5504  /* Set or reset the CCxE Bit */
5505  TIMx->CCER |= (uint32_t)(ChannelState << Channel);
5506 }
5507 
5508 
5513 #endif /* HAL_TIM_MODULE_ENABLED */
5514 
5521 /************************ (C) COPYRIGHT STMicroelectronics *****END OF FILE****/
HAL_StatusTypeDef HAL_TIM_OnePulse_Init(TIM_HandleTypeDef *htim, uint32_t OnePulseMode)
#define TIM_DMA_CC4
void HAL_TIM_PWM_PulseFinishedCallback(TIM_HandleTypeDef *htim)
HAL_TIM_StateTypeDef
HAL State structures definition.
#define TIM_CHANNEL_4
#define TIM_DMA_ID_TRIGGER
#define TIM_CLOCKSOURCE_ITR3
HAL_TIM_StateTypeDef HAL_TIM_OnePulse_GetState(TIM_HandleTypeDef *htim)
HAL_StatusTypeDef HAL_TIM_IC_Start_IT(TIM_HandleTypeDef *htim, uint32_t Channel)
#define TIM_DMA_UPDATE
#define __HAL_TIM_DISABLE_DMA(__HANDLE__, __DMA__)
HAL_StatusTypeDef HAL_TIM_ConfigOCrefClear(TIM_HandleTypeDef *htim, TIM_ClearInputConfigTypeDef *sClearInputConfig, uint32_t Channel)
#define TIM_CCMR1_IC1F
Definition: stm32f745xx.h:7118
void HAL_TIM_OC_MspDeInit(TIM_HandleTypeDef *htim)
#define TIM_EGR_UG
Definition: stm32f745xx.h:7071
#define TIM_CR1_CKD
Definition: stm32f745xx.h:6977
#define TIM_CCER_CC3E
Definition: stm32f745xx.h:7198
HAL_StatusTypeDef HAL_TIM_IC_Stop(TIM_HandleTypeDef *htim, uint32_t Channel)
#define TIM_TS_ITR0
#define TIM_DMA_CC3
#define IS_TIM_DMA_SOURCE(__SOURCE__)
HAL_StatusTypeDef HAL_DMA_Abort(DMA_HandleTypeDef *hdma)
#define TIM_CCMR1_IC2F
Definition: stm32f745xx.h:7128
DMA_HandleTypeDef * hdma[7]
#define TIM_DMA_ID_CC3
HAL_TIM_StateTypeDef HAL_TIM_IC_GetState(TIM_HandleTypeDef *htim)
#define TIM_CLOCKSOURCE_TI1
#define TIM_IT_CC1
#define TIM_CCER_CC1NE
Definition: stm32f745xx.h:7192
HAL_StatusTypeDef HAL_TIM_IC_DeInit(TIM_HandleTypeDef *htim)
#define TIM_FLAG_COM
#define TIM_CHANNEL_1
#define assert_param(expr)
Include module&#39;s header file.
Clock Configuration Handle Structure definition.
TIM Output Compare Configuration Structure definition.
__IO uint32_t RCR
Definition: stm32f745xx.h:893
#define IS_TIM_ADVANCED_INSTANCE(__INSTANCE__)
Definition: stm32f745xx.h:8995
#define IS_TIM_CLOCKSOURCE(__CLOCK__)
#define IS_TIM_CC3_INSTANCE(__INSTANCE__)
Definition: stm32f745xx.h:8938
#define TIM_CCMR1_OC1M
Definition: stm32f745xx.h:7089
void HAL_TIM_DMAError(DMA_HandleTypeDef *hdma)
#define TIM_CCER_CC2NE
Definition: stm32f745xx.h:7196
#define TIM_CR2_OIS1N
Definition: stm32f745xx.h:7003
#define TIM_CCx_DISABLE
__IO uint32_t DMAR
Definition: stm32f745xx.h:900
#define TIM_CCER_CC2E
Definition: stm32f745xx.h:7194
TIM Encoder Configuration Structure definition.
#define TIM_CCMR1_OC2M
Definition: stm32f745xx.h:7104
void HAL_TIM_TriggerCallback(TIM_HandleTypeDef *htim)
TIM Slave configuration Structure definition.
void HAL_TIM_OC_MspInit(TIM_HandleTypeDef *htim)
#define IS_TIM_OPM_CHANNELS(CHANNEL)
#define TIM_IT_CC3
HAL_StatusTypeDef HAL_TIM_SlaveConfigSynchronization(TIM_HandleTypeDef *htim, TIM_SlaveConfigTypeDef *sSlaveConfig)
#define IS_TIM_SLAVE_INSTANCE(__INSTANCE__)
Definition: stm32f745xx.h:9058
HAL_StatusTypeDef HAL_TIM_Base_Stop(TIM_HandleTypeDef *htim)
#define IS_TIM_DMA_LENGTH(__LENGTH__)
HAL_StatusTypeDef HAL_TIM_Base_Start_DMA(TIM_HandleTypeDef *htim, uint32_t *pData, uint16_t Length)
#define TIM_DMA_ID_UPDATE
__IO uint32_t CCR1
Definition: stm32f745xx.h:894
#define TIM_CLOCKSOURCE_ITR1
void HAL_TIM_OnePulse_MspInit(TIM_HandleTypeDef *htim)
#define TIM_CLOCKSOURCE_ETRMODE2
void TIM_CCxChannelCmd(TIM_TypeDef *TIMx, uint32_t Channel, uint32_t ChannelState)
__IO uint32_t ARR
Definition: stm32f745xx.h:892
void TIM_OC3_SetConfig(TIM_TypeDef *TIMx, TIM_OC_InitTypeDef *OC_Config)
#define __HAL_UNLOCK(__HANDLE__)
TIM Time base Configuration Structure definition.
#define TIM_CCER_CC1E
Definition: stm32f745xx.h:7190
void HAL_TIMEx_BreakCallback(TIM_HandleTypeDef *htim)
void HAL_TIM_PWM_MspInit(TIM_HandleTypeDef *htim)
#define TIM_IT_UPDATE
#define IS_TIM_COUNTER_MODE(__MODE__)
void HAL_TIM_Encoder_MspInit(TIM_HandleTypeDef *htim)
#define IS_TIM_CCX_INSTANCE(__INSTANCE__, __CHANNEL__)
Definition: stm32f745xx.h:9085
HAL_StatusTypeDef HAL_DMA_Start_IT(DMA_HandleTypeDef *hdma, uint32_t SrcAddress, uint32_t DstAddress, uint32_t DataLength)
#define TIM_CCMR1_OC2FE
Definition: stm32f745xx.h:7101
HAL_StatusTypeDef HAL_TIM_Encoder_Init(TIM_HandleTypeDef *htim, TIM_Encoder_InitTypeDef *sConfig)
HAL_StatusTypeDef HAL_TIM_Base_DeInit(TIM_HandleTypeDef *htim)
HAL_StatusTypeDef HAL_TIM_Encoder_Stop_IT(TIM_HandleTypeDef *htim, uint32_t Channel)
HAL_TIM_StateTypeDef HAL_TIM_Encoder_GetState(TIM_HandleTypeDef *htim)
#define TIM_DMA_ID_CC2
void TIM_OC1_SetConfig(TIM_TypeDef *TIMx, TIM_OC_InitTypeDef *OC_Config)
#define TIM_CCER_CC1NP
Definition: stm32f745xx.h:7193
#define TIM_DMA_COM
#define __HAL_TIM_DISABLE(__HANDLE__)
Disable the TIM peripheral.
#define TIM_TS_TI1FP1
__IO uint32_t CCR4
Definition: stm32f745xx.h:897
HAL_StatusTypeDef HAL_TIM_PWM_DeInit(TIM_HandleTypeDef *htim)
#define TIM_DMA_ID_CC4
void HAL_TIM_OnePulse_MspDeInit(TIM_HandleTypeDef *htim)
#define TIM_CCMR2_CC4S
Definition: stm32f745xx.h:7152
HAL_StatusTypeDef HAL_TIM_DMABurst_ReadStart(TIM_HandleTypeDef *htim, uint32_t BurstBaseAddress, uint32_t BurstRequestSrc, uint32_t *BurstBuffer, uint32_t BurstLength)
HAL_StatusTypeDef HAL_TIM_Encoder_DeInit(TIM_HandleTypeDef *htim)
#define TIM_CCMR2_OC4CE
Definition: stm32f745xx.h:7165
void HAL_TIM_IC_CaptureCallback(TIM_HandleTypeDef *htim)
HAL_StatusTypeDef HAL_TIM_PWM_ConfigChannel(TIM_HandleTypeDef *htim, TIM_OC_InitTypeDef *sConfig, uint32_t Channel)
#define TIM_CCMR2_OC4M
Definition: stm32f745xx.h:7159
#define TIM_CCMR1_OC1FE
Definition: stm32f745xx.h:7086
#define TIM_CCMR2_OC3M
Definition: stm32f745xx.h:7142
void HAL_TIM_DMADelayPulseCplt(DMA_HandleTypeDef *hdma)
#define IS_TIM_CLEARINPUT_FILTER(__ICFILTER__)
#define IS_TIM_XOR_INSTANCE(__INSTANCE__)
Definition: stm32f745xx.h:9004
HAL_StatusTypeDef HAL_TIM_OC_ConfigChannel(TIM_HandleTypeDef *htim, TIM_OC_InitTypeDef *sConfig, uint32_t Channel)
#define TIM_FLAG_BREAK
#define TIM_CHANNEL_3
#define TIM_SLAVEMODE_EXTERNAL1
#define TIM_DMA_TRIGGER
#define TIM_CCER_CC4P
Definition: stm32f745xx.h:7203
HAL_StatusTypeDef HAL_TIM_OnePulse_Stop_IT(TIM_HandleTypeDef *htim, uint32_t OutputChannel)
#define TIM_CCMR2_OC3CE
Definition: stm32f745xx.h:7150
#define TIM_CLOCKSOURCE_ETRMODE1
__IO uint32_t SMCR
Definition: stm32f745xx.h:883
#define IS_TIM_OCIDLE_STATE(__STATE__)
HAL_StatusTypeDef HAL_TIM_Encoder_Start(TIM_HandleTypeDef *htim, uint32_t Channel)
HAL_StatusTypeDef HAL_TIM_Base_Start_IT(TIM_HandleTypeDef *htim)
HAL_StatusTypeDef HAL_TIM_IC_ConfigChannel(TIM_HandleTypeDef *htim, TIM_IC_InitTypeDef *sConfig, uint32_t Channel)
#define TIM_SMCR_ETPS
Definition: stm32f745xx.h:7031
#define TIM_CCMR2_IC4PSC
Definition: stm32f745xx.h:7179
HAL_StatusTypeDef HAL_TIM_OnePulse_Start(TIM_HandleTypeDef *htim, uint32_t OutputChannel)
#define IS_TIM_IC_SELECTION(__SELECTION__)
#define IS_TIM_CLEARINPUT_SOURCE(MODE)
HAL_StatusTypeDef HAL_TIM_Base_Init(TIM_HandleTypeDef *htim)
void HAL_TIM_Encoder_MspDeInit(TIM_HandleTypeDef *htim)
#define TIM_CCMR1_OC2PE
Definition: stm32f745xx.h:7102
#define TIM_CCMR1_CC1S_0
Definition: stm32f745xx.h:7083
HAL_StatusTypeDef HAL_TIM_OnePulse_Start_IT(TIM_HandleTypeDef *htim, uint32_t OutputChannel)
#define TIM_CCER_CC2NP
Definition: stm32f745xx.h:7197
HAL_StatusTypeDef HAL_TIM_OC_Init(TIM_HandleTypeDef *htim)
void HAL_TIMEx_CommutationCallback(TIM_HandleTypeDef *htim)
__IO HAL_TIM_StateTypeDef State
#define __HAL_TIM_ENABLE_DMA(__HANDLE__, __DMA__)
#define IS_TIM_IC_POLARITY(__POLARITY__)
#define TIM_CCMR2_IC4F
Definition: stm32f745xx.h:7183
#define TIM_DMA_ID_CC1
void TIM_ETR_SetConfig(TIM_TypeDef *TIMx, uint32_t TIM_ExtTRGPrescaler, uint32_t TIM_ExtTRGPolarity, uint32_t ExtTRGFilter)
HAL_StatusTypeDef HAL_TIM_OC_Stop(TIM_HandleTypeDef *htim, uint32_t Channel)
void TIM_OC4_SetConfig(TIM_TypeDef *TIMx, TIM_OC_InitTypeDef *OC_Config)
void(* XferCpltCallback)(struct __DMA_HandleTypeDef *hdma)
#define __HAL_LOCK(__HANDLE__)
#define TIM_SMCR_TS
Definition: stm32f745xx.h:7018
#define TIM_CCER_CC4E
Definition: stm32f745xx.h:7202
void HAL_TIM_DMACaptureCplt(DMA_HandleTypeDef *hdma)
#define TIM_CR2_OIS2
Definition: stm32f745xx.h:7004
#define IS_TIM_FAST_STATE(__STATE__)
#define NULL
Definition: usbd_def.h:53
HAL_StatusTypeDef HAL_TIM_OC_Start(TIM_HandleTypeDef *htim, uint32_t Channel)
#define TIM_SMCR_ECE
Definition: stm32f745xx.h:7035
#define TIM_CCER_CC2P
Definition: stm32f745xx.h:7195
#define TIM_DMA_CC1
#define TIM_CR1_CMS
Definition: stm32f745xx.h:6971
#define __HAL_TIM_MOE_DISABLE(__HANDLE__)
Disable the TIM main Output.
HAL_StatusTypeDef HAL_TIM_Base_Stop_IT(TIM_HandleTypeDef *htim)
#define TIM_FLAG_CC1
#define TIM_CCMR1_OC2CE
Definition: stm32f745xx.h:7110
HAL_StatusTypeDef HAL_TIM_GenerateEvent(TIM_HandleTypeDef *htim, uint32_t EventSource)
#define TIM_CHANNEL_2
#define IS_TIM_DMA_CC_INSTANCE(__INSTANCE__)
Definition: stm32f745xx.h:9022
HAL_StatusTypeDef HAL_TIM_SlaveConfigSynchronization_IT(TIM_HandleTypeDef *htim, TIM_SlaveConfigTypeDef *sSlaveConfig)
#define TIM_TS_ITR3
#define IS_TIM_CLOCKSOURCE_TIX_INSTANCE(__INSTANCE__)
Definition: stm32f745xx.h:8967
#define TIM_CCMR2_OC3PE
Definition: stm32f745xx.h:7140
Clear Input Configuration Handle Structure definition.
HAL_StatusTypeDef HAL_TIM_Encoder_Start_DMA(TIM_HandleTypeDef *htim, uint32_t Channel, uint32_t *pData1, uint32_t *pData2, uint16_t Length)
#define IS_TIM_OCN_POLARITY(__POLARITY__)
__IO uint32_t CR2
Definition: stm32f745xx.h:882
HAL_StatusTypeDef HAL_TIM_IC_Start_DMA(TIM_HandleTypeDef *htim, uint32_t Channel, uint32_t *pData, uint16_t Length)
#define TIM_CCx_ENABLE
HAL_StatusTypeDef HAL_TIM_OC_Start_IT(TIM_HandleTypeDef *htim, uint32_t Channel)
#define TIM_FLAG_CC4
__IO uint32_t CCMR1
Definition: stm32f745xx.h:887
HAL_StatusTypeDef HAL_TIM_DMABurst_WriteStart(TIM_HandleTypeDef *htim, uint32_t BurstBaseAddress, uint32_t BurstRequestSrc, uint32_t *BurstBuffer, uint32_t BurstLength)
#define TIM_CR2_OIS3N
Definition: stm32f745xx.h:7007
#define __HAL_TIM_MOE_ENABLE(__HANDLE__)
Enable the TIM main Output.
#define TIM_CR2_OIS3
Definition: stm32f745xx.h:7006
#define TIM_TS_ETRF
HAL_StatusTypeDef HAL_TIM_ConfigTI1Input(TIM_HandleTypeDef *htim, uint32_t TI1_Selection)
#define TIM_CCER_CC4NP
Definition: stm32f745xx.h:7204
This file contains all the functions prototypes for the HAL module driver.
#define IS_TIM_OC_POLARITY(__POLARITY__)
#define __HAL_TIM_GET_IT_SOURCE(__HANDLE__, __INTERRUPT__)
#define TIM_CR1_OPM
Definition: stm32f745xx.h:6968
__IO uint32_t CCER
Definition: stm32f745xx.h:889
HAL_TIM_StateTypeDef HAL_TIM_OC_GetState(TIM_HandleTypeDef *htim)
HAL_StatusTypeDef HAL_TIM_Encoder_Start_IT(TIM_HandleTypeDef *htim, uint32_t Channel)
HAL_TIM_StateTypeDef HAL_TIM_Base_GetState(TIM_HandleTypeDef *htim)
#define TIM_CHANNEL_ALL
#define TIM_IT_TRIGGER
#define TIM_CLOCKSOURCE_INTERNAL
#define TIM_IT_BREAK
HAL_StatusTypeDef HAL_TIM_OC_DeInit(TIM_HandleTypeDef *htim)
HAL_StatusTypeDef HAL_TIM_ConfigClockSource(TIM_HandleTypeDef *htim, TIM_ClockConfigTypeDef *sClockSourceConfig)
HAL_StatusTypeDef HAL_TIM_OnePulse_ConfigChannel(TIM_HandleTypeDef *htim, TIM_OnePulse_InitTypeDef *sConfig, uint32_t OutputChannel, uint32_t InputChannel)
#define TIM_FLAG_BREAK2
void HAL_TIM_ErrorCallback(TIM_HandleTypeDef *htim)
#define __HAL_TIM_CLEAR_IT(__HANDLE__, __INTERRUPT__)
#define IS_TIM_CLOCKSOURCE_ITRX_INSTANCE(__INSTANCE__)
Definition: stm32f745xx.h:8976
#define IS_TIM_OC_MODE(MODE)
#define IS_TIM_SLAVE_MODE(MODE)
#define IS_TIM_CLOCKPRESCALER(__PRESCALER__)
#define IS_TIM_EVENT_SOURCE(__SOURCE__)
#define TIM_DMA_CC2
#define TIM_CLEARINPUTSOURCE_ETR
#define TIM_IT_CC4
#define IS_TIM_CC2_INSTANCE(__INSTANCE__)
Definition: stm32f745xx.h:8928
#define TIM_CR2_OIS1
Definition: stm32f745xx.h:7002
#define IS_TIM_TRIGGERFILTER(__ICFILTER__)
HAL_StatusTypeDef HAL_TIM_OnePulse_DeInit(TIM_HandleTypeDef *htim)
uint32_t HAL_TIM_ReadCapturedValue(TIM_HandleTypeDef *htim, uint32_t Channel)
#define TIM_IT_CC2
void HAL_TIM_Base_MspInit(TIM_HandleTypeDef *htim)
HAL_StatusTypeDef HAL_TIM_PWM_Stop_IT(TIM_HandleTypeDef *htim, uint32_t Channel)
#define TIM_CCMR1_OC1CE
Definition: stm32f745xx.h:7095
#define TIM_SMCR_ETF
Definition: stm32f745xx.h:7025
#define TIM_SMCR_ETP
Definition: stm32f745xx.h:7036
#define IS_TIM_CLOCKDIVISION_DIV(__DIV__)
#define TIM_TS_TI2FP2
#define IS_TIM_DMA_INSTANCE(__INSTANCE__)
Definition: stm32f745xx.h:9012
HAL_StatusTypeDef HAL_TIM_DMABurst_ReadStop(TIM_HandleTypeDef *htim, uint32_t BurstRequestSrc)
#define TIM_FLAG_CC2
#define TIM_CCER_CC3NP
Definition: stm32f745xx.h:7201
#define UNUSED(x)
void HAL_TIM_OC_DelayElapsedCallback(TIM_HandleTypeDef *htim)
HAL_StatusTypeDef HAL_TIM_PWM_Start_DMA(TIM_HandleTypeDef *htim, uint32_t Channel, uint32_t *pData, uint16_t Length)
#define TIM_CCMR2_OC4PE
Definition: stm32f745xx.h:7157
HAL_StatusTypeDef HAL_TIM_OC_Stop_IT(TIM_HandleTypeDef *htim, uint32_t Channel)
#define __HAL_TIM_GET_FLAG(__HANDLE__, __FLAG__)
TIM Time Base Handle Structure definition.
#define TIM_CCER_CC3NE
Definition: stm32f745xx.h:7200
#define TIM_FLAG_TRIGGER
void TIM_Base_SetConfig(TIM_TypeDef *TIMx, TIM_Base_InitTypeDef *Structure)
__IO uint32_t CCR3
Definition: stm32f745xx.h:896
void HAL_TIM_IC_MspDeInit(TIM_HandleTypeDef *htim)
HAL_StatusTypeDef HAL_TIM_PWM_Start(TIM_HandleTypeDef *htim, uint32_t Channel)
#define IS_TIM_ENCODER_MODE(__MODE__)
void HAL_TIM_Base_MspDeInit(TIM_HandleTypeDef *htim)
__IO uint32_t CR1
Definition: stm32f745xx.h:881
#define TIM_CR2_TI1S
Definition: stm32f745xx.h:7001
#define IS_TIM_INSTANCE(__INSTANCE__)
Definition: stm32f745xx.h:8898
HAL_TIM_ActiveChannel Channel
#define IS_TIM_CLEARINPUT_POLARITY(__POLARITY__)
#define IS_TIM_IC_FILTER(ICFILTER)
__IO uint32_t PSC
Definition: stm32f745xx.h:891
#define TIM_IT_COM
HAL_StatusTypeDef HAL_TIM_PWM_Start_IT(TIM_HandleTypeDef *htim, uint32_t Channel)
#define IS_TIM_DMA_BASE(__BASE__)
void HAL_TIM_IC_MspInit(TIM_HandleTypeDef *htim)
HAL_StatusTypeDef HAL_TIM_IC_Stop_IT(TIM_HandleTypeDef *htim, uint32_t Channel)
TIM_TypeDef * Instance
DMA handle Structure definition.
HAL_LockTypeDef Lock
#define TIM_FLAG_CC3
HAL_TIM_StateTypeDef HAL_TIM_PWM_GetState(TIM_HandleTypeDef *htim)
#define IS_TIM_CC4_INSTANCE(__INSTANCE__)
Definition: stm32f745xx.h:8946
#define TIM_TS_ITR2
#define TIM_CCMR2_IC3PSC
Definition: stm32f745xx.h:7169
__IO uint32_t CCR2
Definition: stm32f745xx.h:895
#define TIM_SMCR_SMS
Definition: stm32f745xx.h:7011
#define TIM_CCER_CC3P
Definition: stm32f745xx.h:7199
#define TIM_CCMR1_IC2PSC
Definition: stm32f745xx.h:7124
void HAL_TIM_PWM_MspDeInit(TIM_HandleTypeDef *htim)
#define TIM_TS_TI1F_ED
#define TIM_CR2_OIS4
Definition: stm32f745xx.h:7008
#define TIM_CCMR2_IC3F
Definition: stm32f745xx.h:7173
#define IS_TIM_DMABURST_INSTANCE(__INSTANCE__)
Definition: stm32f745xx.h:9038
#define IS_TIM_CLEARINPUT_PRESCALER(__PRESCALER__)
TIM Input Capture Configuration Structure definition.
HAL_StatusTypeDef HAL_TIM_OC_Start_DMA(TIM_HandleTypeDef *htim, uint32_t Channel, uint32_t *pData, uint16_t Length)
HAL_StatusTypeDef HAL_TIM_IC_Stop_DMA(TIM_HandleTypeDef *htim, uint32_t Channel)
HAL_StatusTypeDef HAL_TIM_IC_Init(TIM_HandleTypeDef *htim)
HAL_StatusTypeDef HAL_TIM_PWM_Init(TIM_HandleTypeDef *htim)
#define TIM_SLAVEMODE_TRIGGER
#define TIM_CCMR1_CC1S
Definition: stm32f745xx.h:7082
#define IS_TIM_TI1SELECTION(__TI1SELECTION__)
#define IS_TIM_CHANNELS(CHANNEL)
#define TIM_TS_ITR1
TIM_Base_InitTypeDef Init
#define IS_TIM_OPM_MODE(__MODE__)
HAL_StatusTypeDef HAL_TIM_Encoder_Stop(TIM_HandleTypeDef *htim, uint32_t Channel)
#define __HAL_TIM_DISABLE_IT(__HANDLE__, __INTERRUPT__)
#define TIM_CCMR2_CC3S
Definition: stm32f745xx.h:7135
#define TIM_CR1_DIR
Definition: stm32f745xx.h:6969
#define IS_TIM_ETR_INSTANCE(__INSTANCE__)
Definition: stm32f745xx.h:9072
HAL_StatusTypeDef HAL_TIM_DMABurst_WriteStop(TIM_HandleTypeDef *htim, uint32_t BurstRequestSrc)
#define TIM_CLOCKSOURCE_ITR0
#define TIM_CLOCKSOURCE_TI1ED
#define TIM_CLOCKSOURCE_ITR2
#define IS_TIM_CLOCKFILTER(__ICFILTER__)
HAL_StatusTypeDef
HAL Status structures definition.
HAL_StatusTypeDef HAL_TIM_Base_Stop_DMA(TIM_HandleTypeDef *htim)
#define TIM_CCMR1_OC1PE
Definition: stm32f745xx.h:7087
HAL_StatusTypeDef HAL_TIM_OnePulse_Stop(TIM_HandleTypeDef *htim, uint32_t OutputChannel)
#define TIM_FLAG_UPDATE
#define TIM_CCMR2_OC3FE
Definition: stm32f745xx.h:7139
#define __HAL_TIM_ENABLE_IT(__HANDLE__, __INTERRUPT__)
void TIM_OC2_SetConfig(TIM_TypeDef *TIMx, TIM_OC_InitTypeDef *OC_Config)
void(* XferErrorCallback)(struct __DMA_HandleTypeDef *hdma)
#define TIM_CR2_OIS2N
Definition: stm32f745xx.h:7005
#define TIM_CCMR2_OC4FE
Definition: stm32f745xx.h:7156
HAL_StatusTypeDef HAL_TIM_PWM_Stop(TIM_HandleTypeDef *htim, uint32_t Channel)
void HAL_TIM_IRQHandler(TIM_HandleTypeDef *htim)
#define TIM_CCMR1_IC1PSC
Definition: stm32f745xx.h:7114
#define __HAL_TIM_ENABLE(__HANDLE__)
Enable the TIM peripheral.
HAL_StatusTypeDef HAL_TIM_PWM_Stop_DMA(TIM_HandleTypeDef *htim, uint32_t Channel)
void TIM_TI1_SetConfig(TIM_TypeDef *TIMx, uint32_t TIM_ICPolarity, uint32_t TIM_ICSelection, uint32_t TIM_ICFilter)
#define IS_TIM_PWM_MODE(MODE)
#define IS_TIM_TRIGGERPRESCALER(__PRESCALER__)
#define IS_TIM_TRIGGERPOLARITY(__POLARITY__)
TIM One Pulse Mode Configuration Structure definition.
__IO uint32_t DCR
Definition: stm32f745xx.h:899
#define TIM_DMA_ID_COMMUTATION
void HAL_TIMEx_DMACommutationCplt(DMA_HandleTypeDef *hdma)
HAL_StatusTypeDef HAL_TIM_Base_Start(TIM_HandleTypeDef *htim)
void HAL_TIM_PeriodElapsedCallback(TIM_HandleTypeDef *htim)
Period elapsed callback in non blocking mode.
__IO uint32_t EGR
Definition: stm32f745xx.h:886
#define IS_TIM_TRIGGER_SELECTION(__SELECTION__)
#define IS_TIM_IC_PRESCALER(__PRESCALER__)
#define IS_TIM_CC1_INSTANCE(__INSTANCE__)
Definition: stm32f745xx.h:8914
__IO uint32_t CCMR2
Definition: stm32f745xx.h:888
HAL_StatusTypeDef HAL_TIM_Encoder_Stop_DMA(TIM_HandleTypeDef *htim, uint32_t Channel)
#define TIM_CCER_CC1P
Definition: stm32f745xx.h:7191
HAL_StatusTypeDef HAL_TIM_OC_Stop_DMA(TIM_HandleTypeDef *htim, uint32_t Channel)
#define IS_TIM_CLOCKPOLARITY(__POLARITY__)
#define TIM_CCMR1_CC2S
Definition: stm32f745xx.h:7097
HAL_StatusTypeDef HAL_TIM_IC_Start(TIM_HandleTypeDef *htim, uint32_t Channel)
#define TIM_CLOCKSOURCE_TI2