STM32L4xx_HAL_Driver  1.14.0
stm32l4xx_hal_dfsdm.c
Go to the documentation of this file.
1 
267 /* Includes ------------------------------------------------------------------*/
268 #include "stm32l4xx_hal.h"
269 
273 #ifdef HAL_DFSDM_MODULE_ENABLED
274 
275 #if defined(STM32L451xx) || defined(STM32L452xx) || defined(STM32L462xx) || \
276  defined(STM32L471xx) || defined(STM32L475xx) || defined(STM32L476xx) || defined(STM32L485xx) || defined(STM32L486xx) || \
277  defined(STM32L496xx) || defined(STM32L4A6xx) || \
278  defined(STM32L4R5xx) || defined(STM32L4R7xx) || defined(STM32L4R9xx) || defined(STM32L4S5xx) || defined(STM32L4S7xx) || defined(STM32L4S9xx)
279 
285 /* Private typedef -----------------------------------------------------------*/
286 /* Private define ------------------------------------------------------------*/
290 #define DFSDM_FLTCR1_MSB_RCH_OFFSET 8
291 #define DFSDM_MSB_MASK 0xFFFF0000U
292 #define DFSDM_LSB_MASK 0x0000FFFFU
293 #define DFSDM_CKAB_TIMEOUT 5000U
294 #if defined(STM32L451xx) || defined(STM32L452xx) || defined(STM32L462xx)
295 #define DFSDM1_CHANNEL_NUMBER 4U
296 #else /* STM32L451xx || STM32L452xx || STM32L462xx */
297 #define DFSDM1_CHANNEL_NUMBER 8U
298 #endif /* STM32L451xx || STM32L452xx || STM32L462xx */
299 
303 /* Private macro -------------------------------------------------------------*/
304 /* Private variables ---------------------------------------------------------*/
308 static __IO uint32_t v_dfsdm1ChannelCounter = 0;
309 static DFSDM_Channel_HandleTypeDef *a_dfsdm1ChannelHandle[DFSDM1_CHANNEL_NUMBER] = {NULL};
314 /* Private function prototypes -----------------------------------------------*/
318 static uint32_t DFSDM_GetInjChannelsNbr(uint32_t Channels);
319 static uint32_t DFSDM_GetChannelFromInstance(const DFSDM_Channel_TypeDef *Instance);
320 static void DFSDM_RegConvStart(DFSDM_Filter_HandleTypeDef *hdfsdm_filter);
321 static void DFSDM_RegConvStop(DFSDM_Filter_HandleTypeDef *hdfsdm_filter);
322 static void DFSDM_InjConvStart(DFSDM_Filter_HandleTypeDef *hdfsdm_filter);
323 static void DFSDM_InjConvStop(DFSDM_Filter_HandleTypeDef *hdfsdm_filter);
328 static void DFSDM_DMAError(DMA_HandleTypeDef *hdma);
333 /* Exported functions --------------------------------------------------------*/
358 HAL_StatusTypeDef HAL_DFSDM_ChannelInit(DFSDM_Channel_HandleTypeDef *hdfsdm_channel)
359 {
360  /* Check DFSDM Channel handle */
361  if (hdfsdm_channel == NULL)
362  {
363  return HAL_ERROR;
364  }
365 
366  /* Check parameters */
367  assert_param(IS_DFSDM_CHANNEL_ALL_INSTANCE(hdfsdm_channel->Instance));
368  assert_param(IS_FUNCTIONAL_STATE(hdfsdm_channel->Init.OutputClock.Activation));
369  assert_param(IS_DFSDM_CHANNEL_INPUT(hdfsdm_channel->Init.Input.Multiplexer));
370  assert_param(IS_DFSDM_CHANNEL_DATA_PACKING(hdfsdm_channel->Init.Input.DataPacking));
371  assert_param(IS_DFSDM_CHANNEL_INPUT_PINS(hdfsdm_channel->Init.Input.Pins));
372  assert_param(IS_DFSDM_CHANNEL_SERIAL_INTERFACE_TYPE(hdfsdm_channel->Init.SerialInterface.Type));
373  assert_param(IS_DFSDM_CHANNEL_SPI_CLOCK(hdfsdm_channel->Init.SerialInterface.SpiClock));
374  assert_param(IS_DFSDM_CHANNEL_FILTER_ORDER(hdfsdm_channel->Init.Awd.FilterOrder));
375  assert_param(IS_DFSDM_CHANNEL_FILTER_OVS_RATIO(hdfsdm_channel->Init.Awd.Oversampling));
376  assert_param(IS_DFSDM_CHANNEL_OFFSET(hdfsdm_channel->Init.Offset));
377  assert_param(IS_DFSDM_CHANNEL_RIGHT_BIT_SHIFT(hdfsdm_channel->Init.RightBitShift));
378 
379  /* Check that channel has not been already initialized */
380  if (a_dfsdm1ChannelHandle[DFSDM_GetChannelFromInstance(hdfsdm_channel->Instance)] != NULL)
381  {
382  return HAL_ERROR;
383  }
384 
385 #if (USE_HAL_DFSDM_REGISTER_CALLBACKS == 1)
386  /* Reset callback pointers to the weak predefined callbacks */
387  hdfsdm_channel->CkabCallback = HAL_DFSDM_ChannelCkabCallback;
388  hdfsdm_channel->ScdCallback = HAL_DFSDM_ChannelScdCallback;
389 
390  /* Call MSP init function */
391  if (hdfsdm_channel->MspInitCallback == NULL)
392  {
393  hdfsdm_channel->MspInitCallback = HAL_DFSDM_ChannelMspInit;
394  }
395  hdfsdm_channel->MspInitCallback(hdfsdm_channel);
396 #else
397  /* Call MSP init function */
398  HAL_DFSDM_ChannelMspInit(hdfsdm_channel);
399 #endif
400 
401  /* Update the channel counter */
403 
404  /* Configure output serial clock and enable global DFSDM interface only for first channel */
405  if (v_dfsdm1ChannelCounter == 1U)
406  {
407  assert_param(IS_DFSDM_CHANNEL_OUTPUT_CLOCK(hdfsdm_channel->Init.OutputClock.Selection));
408  /* Set the output serial clock source */
409  DFSDM1_Channel0->CHCFGR1 &= ~(DFSDM_CHCFGR1_CKOUTSRC);
410  DFSDM1_Channel0->CHCFGR1 |= hdfsdm_channel->Init.OutputClock.Selection;
411 
412  /* Reset clock divider */
413  DFSDM1_Channel0->CHCFGR1 &= ~(DFSDM_CHCFGR1_CKOUTDIV);
414  if (hdfsdm_channel->Init.OutputClock.Activation == ENABLE)
415  {
416  assert_param(IS_DFSDM_CHANNEL_OUTPUT_CLOCK_DIVIDER(hdfsdm_channel->Init.OutputClock.Divider));
417  /* Set the output clock divider */
418  DFSDM1_Channel0->CHCFGR1 |= (uint32_t)((hdfsdm_channel->Init.OutputClock.Divider - 1U) <<
419  DFSDM_CHCFGR1_CKOUTDIV_Pos);
420  }
421 
422  /* enable the DFSDM global interface */
423  DFSDM1_Channel0->CHCFGR1 |= DFSDM_CHCFGR1_DFSDMEN;
424  }
425 
426  /* Set channel input parameters */
427  hdfsdm_channel->Instance->CHCFGR1 &= ~(DFSDM_CHCFGR1_DATPACK | DFSDM_CHCFGR1_DATMPX |
428  DFSDM_CHCFGR1_CHINSEL);
429  hdfsdm_channel->Instance->CHCFGR1 |= (hdfsdm_channel->Init.Input.Multiplexer |
430  hdfsdm_channel->Init.Input.DataPacking |
431  hdfsdm_channel->Init.Input.Pins);
432 
433  /* Set serial interface parameters */
434  hdfsdm_channel->Instance->CHCFGR1 &= ~(DFSDM_CHCFGR1_SITP | DFSDM_CHCFGR1_SPICKSEL);
435  hdfsdm_channel->Instance->CHCFGR1 |= (hdfsdm_channel->Init.SerialInterface.Type |
436  hdfsdm_channel->Init.SerialInterface.SpiClock);
437 
438  /* Set analog watchdog parameters */
439  hdfsdm_channel->Instance->CHAWSCDR &= ~(DFSDM_CHAWSCDR_AWFORD | DFSDM_CHAWSCDR_AWFOSR);
440  hdfsdm_channel->Instance->CHAWSCDR |= (hdfsdm_channel->Init.Awd.FilterOrder |
441  ((hdfsdm_channel->Init.Awd.Oversampling - 1U) << DFSDM_CHAWSCDR_AWFOSR_Pos));
442 
443  /* Set channel offset and right bit shift */
444  hdfsdm_channel->Instance->CHCFGR2 &= ~(DFSDM_CHCFGR2_OFFSET | DFSDM_CHCFGR2_DTRBS);
445  hdfsdm_channel->Instance->CHCFGR2 |= (((uint32_t) hdfsdm_channel->Init.Offset << DFSDM_CHCFGR2_OFFSET_Pos) |
446  (hdfsdm_channel->Init.RightBitShift << DFSDM_CHCFGR2_DTRBS_Pos));
447 
448  /* Enable DFSDM channel */
449  hdfsdm_channel->Instance->CHCFGR1 |= DFSDM_CHCFGR1_CHEN;
450 
451  /* Set DFSDM Channel to ready state */
452  hdfsdm_channel->State = HAL_DFSDM_CHANNEL_STATE_READY;
453 
454  /* Store channel handle in DFSDM channel handle table */
455  a_dfsdm1ChannelHandle[DFSDM_GetChannelFromInstance(hdfsdm_channel->Instance)] = hdfsdm_channel;
456 
457  return HAL_OK;
458 }
459 
465 HAL_StatusTypeDef HAL_DFSDM_ChannelDeInit(DFSDM_Channel_HandleTypeDef *hdfsdm_channel)
466 {
467  /* Check DFSDM Channel handle */
468  if (hdfsdm_channel == NULL)
469  {
470  return HAL_ERROR;
471  }
472 
473  /* Check parameters */
474  assert_param(IS_DFSDM_CHANNEL_ALL_INSTANCE(hdfsdm_channel->Instance));
475 
476  /* Check that channel has not been already deinitialized */
477  if (a_dfsdm1ChannelHandle[DFSDM_GetChannelFromInstance(hdfsdm_channel->Instance)] == NULL)
478  {
479  return HAL_ERROR;
480  }
481 
482  /* Disable the DFSDM channel */
483  hdfsdm_channel->Instance->CHCFGR1 &= ~(DFSDM_CHCFGR1_CHEN);
484 
485  /* Update the channel counter */
487 
488  /* Disable global DFSDM at deinit of last channel */
489  if (v_dfsdm1ChannelCounter == 0U)
490  {
491  DFSDM1_Channel0->CHCFGR1 &= ~(DFSDM_CHCFGR1_DFSDMEN);
492  }
493 
494  /* Call MSP deinit function */
495 #if (USE_HAL_DFSDM_REGISTER_CALLBACKS == 1)
496  if (hdfsdm_channel->MspDeInitCallback == NULL)
497  {
498  hdfsdm_channel->MspDeInitCallback = HAL_DFSDM_ChannelMspDeInit;
499  }
500  hdfsdm_channel->MspDeInitCallback(hdfsdm_channel);
501 #else
502  HAL_DFSDM_ChannelMspDeInit(hdfsdm_channel);
503 #endif
504 
505  /* Set DFSDM Channel in reset state */
506  hdfsdm_channel->State = HAL_DFSDM_CHANNEL_STATE_RESET;
507 
508  /* Reset channel handle in DFSDM channel handle table */
510 
511  return HAL_OK;
512 }
513 
520 {
521  /* Prevent unused argument(s) compilation warning */
522  UNUSED(hdfsdm_channel);
523 
524  /* NOTE : This function should not be modified, when the function is needed,
525  the HAL_DFSDM_ChannelMspInit could be implemented in the user file.
526  */
527 }
528 
535 {
536  /* Prevent unused argument(s) compilation warning */
537  UNUSED(hdfsdm_channel);
538 
539  /* NOTE : This function should not be modified, when the function is needed,
540  the HAL_DFSDM_ChannelMspDeInit could be implemented in the user file.
541  */
542 }
543 
544 #if (USE_HAL_DFSDM_REGISTER_CALLBACKS == 1)
545 
561 {
562  HAL_StatusTypeDef status = HAL_OK;
563 
564  if (pCallback == NULL)
565  {
566  /* update return status */
567  status = HAL_ERROR;
568  }
569  else
570  {
571  if (HAL_DFSDM_CHANNEL_STATE_READY == hdfsdm_channel->State)
572  {
573  switch (CallbackID)
574  {
576  hdfsdm_channel->CkabCallback = pCallback;
577  break;
579  hdfsdm_channel->ScdCallback = pCallback;
580  break;
582  hdfsdm_channel->MspInitCallback = pCallback;
583  break;
585  hdfsdm_channel->MspDeInitCallback = pCallback;
586  break;
587  default :
588  /* update return status */
589  status = HAL_ERROR;
590  break;
591  }
592  }
593  else if (HAL_DFSDM_CHANNEL_STATE_RESET == hdfsdm_channel->State)
594  {
595  switch (CallbackID)
596  {
598  hdfsdm_channel->MspInitCallback = pCallback;
599  break;
601  hdfsdm_channel->MspDeInitCallback = pCallback;
602  break;
603  default :
604  /* update return status */
605  status = HAL_ERROR;
606  break;
607  }
608  }
609  else
610  {
611  /* update return status */
612  status = HAL_ERROR;
613  }
614  }
615  return status;
616 }
617 
632 {
633  HAL_StatusTypeDef status = HAL_OK;
634 
635  if (HAL_DFSDM_CHANNEL_STATE_READY == hdfsdm_channel->State)
636  {
637  switch (CallbackID)
638  {
640  hdfsdm_channel->CkabCallback = HAL_DFSDM_ChannelCkabCallback;
641  break;
643  hdfsdm_channel->ScdCallback = HAL_DFSDM_ChannelScdCallback;
644  break;
646  hdfsdm_channel->MspInitCallback = HAL_DFSDM_ChannelMspInit;
647  break;
649  hdfsdm_channel->MspDeInitCallback = HAL_DFSDM_ChannelMspDeInit;
650  break;
651  default :
652  /* update return status */
653  status = HAL_ERROR;
654  break;
655  }
656  }
657  else if (HAL_DFSDM_CHANNEL_STATE_RESET == hdfsdm_channel->State)
658  {
659  switch (CallbackID)
660  {
662  hdfsdm_channel->MspInitCallback = HAL_DFSDM_ChannelMspInit;
663  break;
665  hdfsdm_channel->MspDeInitCallback = HAL_DFSDM_ChannelMspDeInit;
666  break;
667  default :
668  /* update return status */
669  status = HAL_ERROR;
670  break;
671  }
672  }
673  else
674  {
675  /* update return status */
676  status = HAL_ERROR;
677  }
678  return status;
679 }
680 #endif /* USE_HAL_DFSDM_REGISTER_CALLBACKS */
681 
711 HAL_StatusTypeDef HAL_DFSDM_ChannelCkabStart(DFSDM_Channel_HandleTypeDef *hdfsdm_channel)
712 {
713  HAL_StatusTypeDef status = HAL_OK;
714  uint32_t channel;
715  uint32_t tickstart;
716 
717  /* Check parameters */
718  assert_param(IS_DFSDM_CHANNEL_ALL_INSTANCE(hdfsdm_channel->Instance));
719 
720  /* Check DFSDM channel state */
721  if (hdfsdm_channel->State != HAL_DFSDM_CHANNEL_STATE_READY)
722  {
723  /* Return error status */
724  status = HAL_ERROR;
725  }
726  else
727  {
728  /* Get channel number from channel instance */
729  channel = DFSDM_GetChannelFromInstance(hdfsdm_channel->Instance);
730 
731  /* Get timeout */
732  tickstart = HAL_GetTick();
733 
734  /* Clear clock absence flag */
735  while ((((DFSDM1_Filter0->FLTISR & DFSDM_FLTISR_CKABF) >> (DFSDM_FLTISR_CKABF_Pos + channel)) & 1U) != 0U)
736  {
737  DFSDM1_Filter0->FLTICR = (1UL << (DFSDM_FLTICR_CLRCKABF_Pos + channel));
738 
739  /* Check the Timeout */
740  if ((HAL_GetTick() - tickstart) > DFSDM_CKAB_TIMEOUT)
741  {
742  /* Set timeout status */
743  status = HAL_TIMEOUT;
744  break;
745  }
746  }
747 
748  if (status == HAL_OK)
749  {
750  /* Start clock absence detection */
751  hdfsdm_channel->Instance->CHCFGR1 |= DFSDM_CHCFGR1_CKABEN;
752  }
753  }
754  /* Return function status */
755  return status;
756 }
757 
765  uint32_t Timeout)
766 {
767  uint32_t tickstart;
768  uint32_t channel;
769 
770  /* Check parameters */
771  assert_param(IS_DFSDM_CHANNEL_ALL_INSTANCE(hdfsdm_channel->Instance));
772 
773  /* Check DFSDM channel state */
774  if (hdfsdm_channel->State != HAL_DFSDM_CHANNEL_STATE_READY)
775  {
776  /* Return error status */
777  return HAL_ERROR;
778  }
779  else
780  {
781  /* Get channel number from channel instance */
782  channel = DFSDM_GetChannelFromInstance(hdfsdm_channel->Instance);
783 
784  /* Get timeout */
785  tickstart = HAL_GetTick();
786 
787  /* Wait clock absence detection */
788  while ((((DFSDM1_Filter0->FLTISR & DFSDM_FLTISR_CKABF) >> (DFSDM_FLTISR_CKABF_Pos + channel)) & 1U) == 0U)
789  {
790  /* Check the Timeout */
791  if (Timeout != HAL_MAX_DELAY)
792  {
793  if (((HAL_GetTick() - tickstart) > Timeout) || (Timeout == 0U))
794  {
795  /* Return timeout status */
796  return HAL_TIMEOUT;
797  }
798  }
799  }
800 
801  /* Clear clock absence detection flag */
802  DFSDM1_Filter0->FLTICR = (1UL << (DFSDM_FLTICR_CLRCKABF_Pos + channel));
803 
804  /* Return function status */
805  return HAL_OK;
806  }
807 }
808 
814 HAL_StatusTypeDef HAL_DFSDM_ChannelCkabStop(DFSDM_Channel_HandleTypeDef *hdfsdm_channel)
815 {
816  HAL_StatusTypeDef status = HAL_OK;
817  uint32_t channel;
818 
819  /* Check parameters */
820  assert_param(IS_DFSDM_CHANNEL_ALL_INSTANCE(hdfsdm_channel->Instance));
821 
822  /* Check DFSDM channel state */
823  if (hdfsdm_channel->State != HAL_DFSDM_CHANNEL_STATE_READY)
824  {
825  /* Return error status */
826  status = HAL_ERROR;
827  }
828  else
829  {
830  /* Stop clock absence detection */
831  hdfsdm_channel->Instance->CHCFGR1 &= ~(DFSDM_CHCFGR1_CKABEN);
832 
833  /* Clear clock absence flag */
834  channel = DFSDM_GetChannelFromInstance(hdfsdm_channel->Instance);
835  DFSDM1_Filter0->FLTICR = (1UL << (DFSDM_FLTICR_CLRCKABF_Pos + channel));
836  }
837  /* Return function status */
838  return status;
839 }
840 
851 {
852  HAL_StatusTypeDef status = HAL_OK;
853  uint32_t channel;
854  uint32_t tickstart;
855 
856  /* Check parameters */
857  assert_param(IS_DFSDM_CHANNEL_ALL_INSTANCE(hdfsdm_channel->Instance));
858 
859  /* Check DFSDM channel state */
860  if (hdfsdm_channel->State != HAL_DFSDM_CHANNEL_STATE_READY)
861  {
862  /* Return error status */
863  status = HAL_ERROR;
864  }
865  else
866  {
867  /* Get channel number from channel instance */
868  channel = DFSDM_GetChannelFromInstance(hdfsdm_channel->Instance);
869 
870  /* Get timeout */
871  tickstart = HAL_GetTick();
872 
873  /* Clear clock absence flag */
874  while ((((DFSDM1_Filter0->FLTISR & DFSDM_FLTISR_CKABF) >> (DFSDM_FLTISR_CKABF_Pos + channel)) & 1U) != 0U)
875  {
876  DFSDM1_Filter0->FLTICR = (1UL << (DFSDM_FLTICR_CLRCKABF_Pos + channel));
877 
878  /* Check the Timeout */
879  if ((HAL_GetTick() - tickstart) > DFSDM_CKAB_TIMEOUT)
880  {
881  /* Set timeout status */
882  status = HAL_TIMEOUT;
883  break;
884  }
885  }
886 
887  if (status == HAL_OK)
888  {
889  /* Activate clock absence detection interrupt */
890  DFSDM1_Filter0->FLTCR2 |= DFSDM_FLTCR2_CKABIE;
891 
892  /* Start clock absence detection */
893  hdfsdm_channel->Instance->CHCFGR1 |= DFSDM_CHCFGR1_CKABEN;
894  }
895  }
896  /* Return function status */
897  return status;
898 }
899 
906 {
907  /* Prevent unused argument(s) compilation warning */
908  UNUSED(hdfsdm_channel);
909 
910  /* NOTE : This function should not be modified, when the callback is needed,
911  the HAL_DFSDM_ChannelCkabCallback could be implemented in the user file
912  */
913 }
914 
922 {
923  HAL_StatusTypeDef status = HAL_OK;
924  uint32_t channel;
925 
926  /* Check parameters */
927  assert_param(IS_DFSDM_CHANNEL_ALL_INSTANCE(hdfsdm_channel->Instance));
928 
929  /* Check DFSDM channel state */
930  if (hdfsdm_channel->State != HAL_DFSDM_CHANNEL_STATE_READY)
931  {
932  /* Return error status */
933  status = HAL_ERROR;
934  }
935  else
936  {
937  /* Stop clock absence detection */
938  hdfsdm_channel->Instance->CHCFGR1 &= ~(DFSDM_CHCFGR1_CKABEN);
939 
940  /* Clear clock absence flag */
941  channel = DFSDM_GetChannelFromInstance(hdfsdm_channel->Instance);
942  DFSDM1_Filter0->FLTICR = (1UL << (DFSDM_FLTICR_CLRCKABF_Pos + channel));
943 
944  /* Disable clock absence detection interrupt */
945  DFSDM1_Filter0->FLTCR2 &= ~(DFSDM_FLTCR2_CKABIE);
946  }
947  /* Return function status */
948  return status;
949 }
950 
961 HAL_StatusTypeDef HAL_DFSDM_ChannelScdStart(DFSDM_Channel_HandleTypeDef *hdfsdm_channel,
962  uint32_t Threshold,
963  uint32_t BreakSignal)
964 {
965  HAL_StatusTypeDef status = HAL_OK;
966 
967  /* Check parameters */
968  assert_param(IS_DFSDM_CHANNEL_ALL_INSTANCE(hdfsdm_channel->Instance));
969  assert_param(IS_DFSDM_CHANNEL_SCD_THRESHOLD(Threshold));
970  assert_param(IS_DFSDM_BREAK_SIGNALS(BreakSignal));
971 
972  /* Check DFSDM channel state */
973  if (hdfsdm_channel->State != HAL_DFSDM_CHANNEL_STATE_READY)
974  {
975  /* Return error status */
976  status = HAL_ERROR;
977  }
978  else
979  {
980  /* Configure threshold and break signals */
981  hdfsdm_channel->Instance->CHAWSCDR &= ~(DFSDM_CHAWSCDR_BKSCD | DFSDM_CHAWSCDR_SCDT);
982  hdfsdm_channel->Instance->CHAWSCDR |= ((BreakSignal << DFSDM_CHAWSCDR_BKSCD_Pos) | \
983  Threshold);
984 
985  /* Start short circuit detection */
986  hdfsdm_channel->Instance->CHCFGR1 |= DFSDM_CHCFGR1_SCDEN;
987  }
988  /* Return function status */
989  return status;
990 }
991 
999  uint32_t Timeout)
1000 {
1001  uint32_t tickstart;
1002  uint32_t channel;
1003 
1004  /* Check parameters */
1005  assert_param(IS_DFSDM_CHANNEL_ALL_INSTANCE(hdfsdm_channel->Instance));
1006 
1007  /* Check DFSDM channel state */
1008  if (hdfsdm_channel->State != HAL_DFSDM_CHANNEL_STATE_READY)
1009  {
1010  /* Return error status */
1011  return HAL_ERROR;
1012  }
1013  else
1014  {
1015  /* Get channel number from channel instance */
1016  channel = DFSDM_GetChannelFromInstance(hdfsdm_channel->Instance);
1017 
1018  /* Get timeout */
1019  tickstart = HAL_GetTick();
1020 
1021  /* Wait short circuit detection */
1022  while (((DFSDM1_Filter0->FLTISR & DFSDM_FLTISR_SCDF) >> (DFSDM_FLTISR_SCDF_Pos + channel)) == 0U)
1023  {
1024  /* Check the Timeout */
1025  if (Timeout != HAL_MAX_DELAY)
1026  {
1027  if (((HAL_GetTick() - tickstart) > Timeout) || (Timeout == 0U))
1028  {
1029  /* Return timeout status */
1030  return HAL_TIMEOUT;
1031  }
1032  }
1033  }
1034 
1035  /* Clear short circuit detection flag */
1036  DFSDM1_Filter0->FLTICR = (1UL << (DFSDM_FLTICR_CLRSCDF_Pos + channel));
1037 
1038  /* Return function status */
1039  return HAL_OK;
1040  }
1041 }
1042 
1048 HAL_StatusTypeDef HAL_DFSDM_ChannelScdStop(DFSDM_Channel_HandleTypeDef *hdfsdm_channel)
1049 {
1050  HAL_StatusTypeDef status = HAL_OK;
1051  uint32_t channel;
1052 
1053  /* Check parameters */
1054  assert_param(IS_DFSDM_CHANNEL_ALL_INSTANCE(hdfsdm_channel->Instance));
1055 
1056  /* Check DFSDM channel state */
1057  if (hdfsdm_channel->State != HAL_DFSDM_CHANNEL_STATE_READY)
1058  {
1059  /* Return error status */
1060  status = HAL_ERROR;
1061  }
1062  else
1063  {
1064  /* Stop short circuit detection */
1065  hdfsdm_channel->Instance->CHCFGR1 &= ~(DFSDM_CHCFGR1_SCDEN);
1066 
1067  /* Clear short circuit detection flag */
1068  channel = DFSDM_GetChannelFromInstance(hdfsdm_channel->Instance);
1069  DFSDM1_Filter0->FLTICR = (1UL << (DFSDM_FLTICR_CLRSCDF_Pos + channel));
1070  }
1071  /* Return function status */
1072  return status;
1073 }
1074 
1086  uint32_t Threshold,
1087  uint32_t BreakSignal)
1088 {
1089  HAL_StatusTypeDef status = HAL_OK;
1090 
1091  /* Check parameters */
1092  assert_param(IS_DFSDM_CHANNEL_ALL_INSTANCE(hdfsdm_channel->Instance));
1093  assert_param(IS_DFSDM_CHANNEL_SCD_THRESHOLD(Threshold));
1094  assert_param(IS_DFSDM_BREAK_SIGNALS(BreakSignal));
1095 
1096  /* Check DFSDM channel state */
1097  if (hdfsdm_channel->State != HAL_DFSDM_CHANNEL_STATE_READY)
1098  {
1099  /* Return error status */
1100  status = HAL_ERROR;
1101  }
1102  else
1103  {
1104  /* Activate short circuit detection interrupt */
1105  DFSDM1_Filter0->FLTCR2 |= DFSDM_FLTCR2_SCDIE;
1106 
1107  /* Configure threshold and break signals */
1108  hdfsdm_channel->Instance->CHAWSCDR &= ~(DFSDM_CHAWSCDR_BKSCD | DFSDM_CHAWSCDR_SCDT);
1109  hdfsdm_channel->Instance->CHAWSCDR |= ((BreakSignal << DFSDM_CHAWSCDR_BKSCD_Pos) | \
1110  Threshold);
1111 
1112  /* Start short circuit detection */
1113  hdfsdm_channel->Instance->CHCFGR1 |= DFSDM_CHCFGR1_SCDEN;
1114  }
1115  /* Return function status */
1116  return status;
1117 }
1118 
1125 {
1126  /* Prevent unused argument(s) compilation warning */
1127  UNUSED(hdfsdm_channel);
1128 
1129  /* NOTE : This function should not be modified, when the callback is needed,
1130  the HAL_DFSDM_ChannelScdCallback could be implemented in the user file
1131  */
1132 }
1133 
1141 {
1142  HAL_StatusTypeDef status = HAL_OK;
1143  uint32_t channel;
1144 
1145  /* Check parameters */
1146  assert_param(IS_DFSDM_CHANNEL_ALL_INSTANCE(hdfsdm_channel->Instance));
1147 
1148  /* Check DFSDM channel state */
1149  if (hdfsdm_channel->State != HAL_DFSDM_CHANNEL_STATE_READY)
1150  {
1151  /* Return error status */
1152  status = HAL_ERROR;
1153  }
1154  else
1155  {
1156  /* Stop short circuit detection */
1157  hdfsdm_channel->Instance->CHCFGR1 &= ~(DFSDM_CHCFGR1_SCDEN);
1158 
1159  /* Clear short circuit detection flag */
1160  channel = DFSDM_GetChannelFromInstance(hdfsdm_channel->Instance);
1161  DFSDM1_Filter0->FLTICR = (1UL << (DFSDM_FLTICR_CLRSCDF_Pos + channel));
1162 
1163  /* Disable short circuit detection interrupt */
1164  DFSDM1_Filter0->FLTCR2 &= ~(DFSDM_FLTCR2_SCDIE);
1165  }
1166  /* Return function status */
1167  return status;
1168 }
1169 
1176 {
1177  return (int16_t) hdfsdm_channel->Instance->CHWDATAR;
1178 }
1179 
1188  int32_t Offset)
1189 {
1190  HAL_StatusTypeDef status = HAL_OK;
1191 
1192  /* Check parameters */
1193  assert_param(IS_DFSDM_CHANNEL_ALL_INSTANCE(hdfsdm_channel->Instance));
1194  assert_param(IS_DFSDM_CHANNEL_OFFSET(Offset));
1195 
1196  /* Check DFSDM channel state */
1197  if (hdfsdm_channel->State != HAL_DFSDM_CHANNEL_STATE_READY)
1198  {
1199  /* Return error status */
1200  status = HAL_ERROR;
1201  }
1202  else
1203  {
1204  /* Modify channel offset */
1205  hdfsdm_channel->Instance->CHCFGR2 &= ~(DFSDM_CHCFGR2_OFFSET);
1206  hdfsdm_channel->Instance->CHCFGR2 |= ((uint32_t) Offset << DFSDM_CHCFGR2_OFFSET_Pos);
1207  }
1208  /* Return function status */
1209  return status;
1210 }
1211 
1235 {
1236  /* Return DFSDM channel handle state */
1237  return hdfsdm_channel->State;
1238 }
1239 
1264 HAL_StatusTypeDef HAL_DFSDM_FilterInit(DFSDM_Filter_HandleTypeDef *hdfsdm_filter)
1265 {
1266  /* Check DFSDM Channel handle */
1267  if (hdfsdm_filter == NULL)
1268  {
1269  return HAL_ERROR;
1270  }
1271 
1272  /* Check parameters */
1273  assert_param(IS_DFSDM_FILTER_ALL_INSTANCE(hdfsdm_filter->Instance));
1274  assert_param(IS_DFSDM_FILTER_REG_TRIGGER(hdfsdm_filter->Init.RegularParam.Trigger));
1275  assert_param(IS_FUNCTIONAL_STATE(hdfsdm_filter->Init.RegularParam.FastMode));
1276  assert_param(IS_FUNCTIONAL_STATE(hdfsdm_filter->Init.RegularParam.DmaMode));
1277  assert_param(IS_DFSDM_FILTER_INJ_TRIGGER(hdfsdm_filter->Init.InjectedParam.Trigger));
1278  assert_param(IS_FUNCTIONAL_STATE(hdfsdm_filter->Init.InjectedParam.ScanMode));
1279  assert_param(IS_FUNCTIONAL_STATE(hdfsdm_filter->Init.InjectedParam.DmaMode));
1280  assert_param(IS_DFSDM_FILTER_SINC_ORDER(hdfsdm_filter->Init.FilterParam.SincOrder));
1281  assert_param(IS_DFSDM_FILTER_OVS_RATIO(hdfsdm_filter->Init.FilterParam.Oversampling));
1282  assert_param(IS_DFSDM_FILTER_INTEGRATOR_OVS_RATIO(hdfsdm_filter->Init.FilterParam.IntOversampling));
1283 
1284  /* Check parameters compatibility */
1285  if ((hdfsdm_filter->Instance == DFSDM1_Filter0) &&
1286  ((hdfsdm_filter->Init.RegularParam.Trigger == DFSDM_FILTER_SYNC_TRIGGER) ||
1287  (hdfsdm_filter->Init.InjectedParam.Trigger == DFSDM_FILTER_SYNC_TRIGGER)))
1288  {
1289  return HAL_ERROR;
1290  }
1291 
1292  /* Initialize DFSDM filter variables with default values */
1293  hdfsdm_filter->RegularContMode = DFSDM_CONTINUOUS_CONV_OFF;
1294  hdfsdm_filter->InjectedChannelsNbr = 1;
1295  hdfsdm_filter->InjConvRemaining = 1;
1296  hdfsdm_filter->ErrorCode = DFSDM_FILTER_ERROR_NONE;
1297 
1298 #if (USE_HAL_DFSDM_REGISTER_CALLBACKS == 1)
1299  /* Reset callback pointers to the weak predefined callbacks */
1300  hdfsdm_filter->AwdCallback = HAL_DFSDM_FilterAwdCallback;
1301  hdfsdm_filter->RegConvCpltCallback = HAL_DFSDM_FilterRegConvCpltCallback;
1302  hdfsdm_filter->RegConvHalfCpltCallback = HAL_DFSDM_FilterRegConvHalfCpltCallback;
1303  hdfsdm_filter->InjConvCpltCallback = HAL_DFSDM_FilterInjConvCpltCallback;
1304  hdfsdm_filter->InjConvHalfCpltCallback = HAL_DFSDM_FilterInjConvHalfCpltCallback;
1305  hdfsdm_filter->ErrorCallback = HAL_DFSDM_FilterErrorCallback;
1306 
1307  /* Call MSP init function */
1308  if (hdfsdm_filter->MspInitCallback == NULL)
1309  {
1310  hdfsdm_filter->MspInitCallback = HAL_DFSDM_FilterMspInit;
1311  }
1312  hdfsdm_filter->MspInitCallback(hdfsdm_filter);
1313 #else
1314  /* Call MSP init function */
1315  HAL_DFSDM_FilterMspInit(hdfsdm_filter);
1316 #endif
1317 
1318  /* Set regular parameters */
1319  hdfsdm_filter->Instance->FLTCR1 &= ~(DFSDM_FLTCR1_RSYNC);
1320  if (hdfsdm_filter->Init.RegularParam.FastMode == ENABLE)
1321  {
1322  hdfsdm_filter->Instance->FLTCR1 |= DFSDM_FLTCR1_FAST;
1323  }
1324  else
1325  {
1326  hdfsdm_filter->Instance->FLTCR1 &= ~(DFSDM_FLTCR1_FAST);
1327  }
1328 
1329  if (hdfsdm_filter->Init.RegularParam.DmaMode == ENABLE)
1330  {
1331  hdfsdm_filter->Instance->FLTCR1 |= DFSDM_FLTCR1_RDMAEN;
1332  }
1333  else
1334  {
1335  hdfsdm_filter->Instance->FLTCR1 &= ~(DFSDM_FLTCR1_RDMAEN);
1336  }
1337 
1338  /* Set injected parameters */
1339  hdfsdm_filter->Instance->FLTCR1 &= ~(DFSDM_FLTCR1_JSYNC | DFSDM_FLTCR1_JEXTEN | DFSDM_FLTCR1_JEXTSEL);
1340  if (hdfsdm_filter->Init.InjectedParam.Trigger == DFSDM_FILTER_EXT_TRIGGER)
1341  {
1342  assert_param(IS_DFSDM_FILTER_EXT_TRIG(hdfsdm_filter->Init.InjectedParam.ExtTrigger));
1343  assert_param(IS_DFSDM_FILTER_EXT_TRIG_EDGE(hdfsdm_filter->Init.InjectedParam.ExtTriggerEdge));
1344  hdfsdm_filter->Instance->FLTCR1 |= (hdfsdm_filter->Init.InjectedParam.ExtTrigger);
1345  }
1346 
1347  if (hdfsdm_filter->Init.InjectedParam.ScanMode == ENABLE)
1348  {
1349  hdfsdm_filter->Instance->FLTCR1 |= DFSDM_FLTCR1_JSCAN;
1350  }
1351  else
1352  {
1353  hdfsdm_filter->Instance->FLTCR1 &= ~(DFSDM_FLTCR1_JSCAN);
1354  }
1355 
1356  if (hdfsdm_filter->Init.InjectedParam.DmaMode == ENABLE)
1357  {
1358  hdfsdm_filter->Instance->FLTCR1 |= DFSDM_FLTCR1_JDMAEN;
1359  }
1360  else
1361  {
1362  hdfsdm_filter->Instance->FLTCR1 &= ~(DFSDM_FLTCR1_JDMAEN);
1363  }
1364 
1365  /* Set filter parameters */
1366  hdfsdm_filter->Instance->FLTFCR &= ~(DFSDM_FLTFCR_FORD | DFSDM_FLTFCR_FOSR | DFSDM_FLTFCR_IOSR);
1367  hdfsdm_filter->Instance->FLTFCR |= (hdfsdm_filter->Init.FilterParam.SincOrder |
1368  ((hdfsdm_filter->Init.FilterParam.Oversampling - 1U) << DFSDM_FLTFCR_FOSR_Pos) |
1369  (hdfsdm_filter->Init.FilterParam.IntOversampling - 1U));
1370 
1371  /* Store regular and injected triggers and injected scan mode*/
1372  hdfsdm_filter->RegularTrigger = hdfsdm_filter->Init.RegularParam.Trigger;
1373  hdfsdm_filter->InjectedTrigger = hdfsdm_filter->Init.InjectedParam.Trigger;
1374  hdfsdm_filter->ExtTriggerEdge = hdfsdm_filter->Init.InjectedParam.ExtTriggerEdge;
1375  hdfsdm_filter->InjectedScanMode = hdfsdm_filter->Init.InjectedParam.ScanMode;
1376 
1377  /* Enable DFSDM filter */
1378  hdfsdm_filter->Instance->FLTCR1 |= DFSDM_FLTCR1_DFEN;
1379 
1380  /* Set DFSDM filter to ready state */
1381  hdfsdm_filter->State = HAL_DFSDM_FILTER_STATE_READY;
1382 
1383  return HAL_OK;
1384 }
1385 
1391 HAL_StatusTypeDef HAL_DFSDM_FilterDeInit(DFSDM_Filter_HandleTypeDef *hdfsdm_filter)
1392 {
1393  /* Check DFSDM filter handle */
1394  if (hdfsdm_filter == NULL)
1395  {
1396  return HAL_ERROR;
1397  }
1398 
1399  /* Check parameters */
1400  assert_param(IS_DFSDM_FILTER_ALL_INSTANCE(hdfsdm_filter->Instance));
1401 
1402  /* Disable the DFSDM filter */
1403  hdfsdm_filter->Instance->FLTCR1 &= ~(DFSDM_FLTCR1_DFEN);
1404 
1405  /* Call MSP deinit function */
1406 #if (USE_HAL_DFSDM_REGISTER_CALLBACKS == 1)
1407  if (hdfsdm_filter->MspDeInitCallback == NULL)
1408  {
1409  hdfsdm_filter->MspDeInitCallback = HAL_DFSDM_FilterMspDeInit;
1410  }
1411  hdfsdm_filter->MspDeInitCallback(hdfsdm_filter);
1412 #else
1413  HAL_DFSDM_FilterMspDeInit(hdfsdm_filter);
1414 #endif
1415 
1416  /* Set DFSDM filter in reset state */
1417  hdfsdm_filter->State = HAL_DFSDM_FILTER_STATE_RESET;
1418 
1419  return HAL_OK;
1420 }
1421 
1428 {
1429  /* Prevent unused argument(s) compilation warning */
1430  UNUSED(hdfsdm_filter);
1431 
1432  /* NOTE : This function should not be modified, when the function is needed,
1433  the HAL_DFSDM_FilterMspInit could be implemented in the user file.
1434  */
1435 }
1436 
1443 {
1444  /* Prevent unused argument(s) compilation warning */
1445  UNUSED(hdfsdm_filter);
1446 
1447  /* NOTE : This function should not be modified, when the function is needed,
1448  the HAL_DFSDM_FilterMspDeInit could be implemented in the user file.
1449  */
1450 }
1451 
1452 #if (USE_HAL_DFSDM_REGISTER_CALLBACKS == 1)
1453 
1472 {
1473  HAL_StatusTypeDef status = HAL_OK;
1474 
1475  if (pCallback == NULL)
1476  {
1477  /* update the error code */
1478  hdfsdm_filter->ErrorCode = DFSDM_FILTER_ERROR_INVALID_CALLBACK;
1479  /* update return status */
1480  status = HAL_ERROR;
1481  }
1482  else
1483  {
1484  if (HAL_DFSDM_FILTER_STATE_READY == hdfsdm_filter->State)
1485  {
1486  switch (CallbackID)
1487  {
1489  hdfsdm_filter->RegConvCpltCallback = pCallback;
1490  break;
1492  hdfsdm_filter->RegConvHalfCpltCallback = pCallback;
1493  break;
1495  hdfsdm_filter->InjConvCpltCallback = pCallback;
1496  break;
1498  hdfsdm_filter->InjConvHalfCpltCallback = pCallback;
1499  break;
1501  hdfsdm_filter->ErrorCallback = pCallback;
1502  break;
1504  hdfsdm_filter->MspInitCallback = pCallback;
1505  break;
1507  hdfsdm_filter->MspDeInitCallback = pCallback;
1508  break;
1509  default :
1510  /* update the error code */
1511  hdfsdm_filter->ErrorCode = DFSDM_FILTER_ERROR_INVALID_CALLBACK;
1512  /* update return status */
1513  status = HAL_ERROR;
1514  break;
1515  }
1516  }
1517  else if (HAL_DFSDM_FILTER_STATE_RESET == hdfsdm_filter->State)
1518  {
1519  switch (CallbackID)
1520  {
1522  hdfsdm_filter->MspInitCallback = pCallback;
1523  break;
1525  hdfsdm_filter->MspDeInitCallback = pCallback;
1526  break;
1527  default :
1528  /* update the error code */
1529  hdfsdm_filter->ErrorCode = DFSDM_FILTER_ERROR_INVALID_CALLBACK;
1530  /* update return status */
1531  status = HAL_ERROR;
1532  break;
1533  }
1534  }
1535  else
1536  {
1537  /* update the error code */
1538  hdfsdm_filter->ErrorCode = DFSDM_FILTER_ERROR_INVALID_CALLBACK;
1539  /* update return status */
1540  status = HAL_ERROR;
1541  }
1542  }
1543  return status;
1544 }
1545 
1563 {
1564  HAL_StatusTypeDef status = HAL_OK;
1565 
1566  if (HAL_DFSDM_FILTER_STATE_READY == hdfsdm_filter->State)
1567  {
1568  switch (CallbackID)
1569  {
1571  hdfsdm_filter->RegConvCpltCallback = HAL_DFSDM_FilterRegConvCpltCallback;
1572  break;
1574  hdfsdm_filter->RegConvHalfCpltCallback = HAL_DFSDM_FilterRegConvHalfCpltCallback;
1575  break;
1577  hdfsdm_filter->InjConvCpltCallback = HAL_DFSDM_FilterInjConvCpltCallback;
1578  break;
1580  hdfsdm_filter->InjConvHalfCpltCallback = HAL_DFSDM_FilterInjConvHalfCpltCallback;
1581  break;
1583  hdfsdm_filter->ErrorCallback = HAL_DFSDM_FilterErrorCallback;
1584  break;
1586  hdfsdm_filter->MspInitCallback = HAL_DFSDM_FilterMspInit;
1587  break;
1589  hdfsdm_filter->MspDeInitCallback = HAL_DFSDM_FilterMspDeInit;
1590  break;
1591  default :
1592  /* update the error code */
1593  hdfsdm_filter->ErrorCode = DFSDM_FILTER_ERROR_INVALID_CALLBACK;
1594  /* update return status */
1595  status = HAL_ERROR;
1596  break;
1597  }
1598  }
1599  else if (HAL_DFSDM_FILTER_STATE_RESET == hdfsdm_filter->State)
1600  {
1601  switch (CallbackID)
1602  {
1604  hdfsdm_filter->MspInitCallback = HAL_DFSDM_FilterMspInit;
1605  break;
1607  hdfsdm_filter->MspDeInitCallback = HAL_DFSDM_FilterMspDeInit;
1608  break;
1609  default :
1610  /* update the error code */
1611  hdfsdm_filter->ErrorCode = DFSDM_FILTER_ERROR_INVALID_CALLBACK;
1612  /* update return status */
1613  status = HAL_ERROR;
1614  break;
1615  }
1616  }
1617  else
1618  {
1619  /* update the error code */
1620  hdfsdm_filter->ErrorCode = DFSDM_FILTER_ERROR_INVALID_CALLBACK;
1621  /* update return status */
1622  status = HAL_ERROR;
1623  }
1624  return status;
1625 }
1626 
1636 {
1637  HAL_StatusTypeDef status = HAL_OK;
1638 
1639  if (pCallback == NULL)
1640  {
1641  /* update the error code */
1642  hdfsdm_filter->ErrorCode = DFSDM_FILTER_ERROR_INVALID_CALLBACK;
1643  /* update return status */
1644  status = HAL_ERROR;
1645  }
1646  else
1647  {
1648  if (HAL_DFSDM_FILTER_STATE_READY == hdfsdm_filter->State)
1649  {
1650  hdfsdm_filter->AwdCallback = pCallback;
1651  }
1652  else
1653  {
1654  /* update the error code */
1655  hdfsdm_filter->ErrorCode = DFSDM_FILTER_ERROR_INVALID_CALLBACK;
1656  /* update return status */
1657  status = HAL_ERROR;
1658  }
1659  }
1660  return status;
1661 }
1662 
1670 {
1671  HAL_StatusTypeDef status = HAL_OK;
1672 
1673  if (HAL_DFSDM_FILTER_STATE_READY == hdfsdm_filter->State)
1674  {
1675  hdfsdm_filter->AwdCallback = HAL_DFSDM_FilterAwdCallback;
1676  }
1677  else
1678  {
1679  /* update the error code */
1680  hdfsdm_filter->ErrorCode = DFSDM_FILTER_ERROR_INVALID_CALLBACK;
1681  /* update return status */
1682  status = HAL_ERROR;
1683  }
1684  return status;
1685 }
1686 #endif /* USE_HAL_DFSDM_REGISTER_CALLBACKS */
1687 
1717  uint32_t Channel,
1718  uint32_t ContinuousMode)
1719 {
1720  HAL_StatusTypeDef status = HAL_OK;
1721 
1722  /* Check parameters */
1723  assert_param(IS_DFSDM_FILTER_ALL_INSTANCE(hdfsdm_filter->Instance));
1724  assert_param(IS_DFSDM_REGULAR_CHANNEL(Channel));
1725  assert_param(IS_DFSDM_CONTINUOUS_MODE(ContinuousMode));
1726 
1727  /* Check DFSDM filter state */
1728  if ((hdfsdm_filter->State != HAL_DFSDM_FILTER_STATE_RESET) &&
1729  (hdfsdm_filter->State != HAL_DFSDM_FILTER_STATE_ERROR))
1730  {
1731  /* Configure channel and continuous mode for regular conversion */
1732  hdfsdm_filter->Instance->FLTCR1 &= ~(DFSDM_FLTCR1_RCH | DFSDM_FLTCR1_RCONT);
1733  if (ContinuousMode == DFSDM_CONTINUOUS_CONV_ON)
1734  {
1735  hdfsdm_filter->Instance->FLTCR1 |= (uint32_t)(((Channel & DFSDM_MSB_MASK) << DFSDM_FLTCR1_MSB_RCH_OFFSET) |
1736  DFSDM_FLTCR1_RCONT);
1737  }
1738  else
1739  {
1740  hdfsdm_filter->Instance->FLTCR1 |= (uint32_t)((Channel & DFSDM_MSB_MASK) << DFSDM_FLTCR1_MSB_RCH_OFFSET);
1741  }
1742  /* Store continuous mode information */
1743  hdfsdm_filter->RegularContMode = ContinuousMode;
1744  }
1745  else
1746  {
1747  status = HAL_ERROR;
1748  }
1749 
1750  /* Return function status */
1751  return status;
1752 }
1753 
1762  uint32_t Channel)
1763 {
1764  HAL_StatusTypeDef status = HAL_OK;
1765 
1766  /* Check parameters */
1767  assert_param(IS_DFSDM_FILTER_ALL_INSTANCE(hdfsdm_filter->Instance));
1768  assert_param(IS_DFSDM_INJECTED_CHANNEL(Channel));
1769 
1770  /* Check DFSDM filter state */
1771  if ((hdfsdm_filter->State != HAL_DFSDM_FILTER_STATE_RESET) &&
1772  (hdfsdm_filter->State != HAL_DFSDM_FILTER_STATE_ERROR))
1773  {
1774  /* Configure channel for injected conversion */
1775  hdfsdm_filter->Instance->FLTJCHGR = (uint32_t)(Channel & DFSDM_LSB_MASK);
1776  /* Store number of injected channels */
1777  hdfsdm_filter->InjectedChannelsNbr = DFSDM_GetInjChannelsNbr(Channel);
1778  /* Update number of injected channels remaining */
1779  hdfsdm_filter->InjConvRemaining = (hdfsdm_filter->InjectedScanMode == ENABLE) ? \
1780  hdfsdm_filter->InjectedChannelsNbr : 1U;
1781  }
1782  else
1783  {
1784  status = HAL_ERROR;
1785  }
1786  /* Return function status */
1787  return status;
1788 }
1789 
1832 {
1833  HAL_StatusTypeDef status = HAL_OK;
1834 
1835  /* Check parameters */
1836  assert_param(IS_DFSDM_FILTER_ALL_INSTANCE(hdfsdm_filter->Instance));
1837 
1838  /* Check DFSDM filter state */
1839  if ((hdfsdm_filter->State == HAL_DFSDM_FILTER_STATE_READY) || \
1840  (hdfsdm_filter->State == HAL_DFSDM_FILTER_STATE_INJ))
1841  {
1842  /* Start regular conversion */
1843  DFSDM_RegConvStart(hdfsdm_filter);
1844  }
1845  else
1846  {
1847  status = HAL_ERROR;
1848  }
1849  /* Return function status */
1850  return status;
1851 }
1852 
1861  uint32_t Timeout)
1862 {
1863  uint32_t tickstart;
1864 
1865  /* Check parameters */
1866  assert_param(IS_DFSDM_FILTER_ALL_INSTANCE(hdfsdm_filter->Instance));
1867 
1868  /* Check DFSDM filter state */
1869  if ((hdfsdm_filter->State != HAL_DFSDM_FILTER_STATE_REG) && \
1870  (hdfsdm_filter->State != HAL_DFSDM_FILTER_STATE_REG_INJ))
1871  {
1872  /* Return error status */
1873  return HAL_ERROR;
1874  }
1875  else
1876  {
1877  /* Get timeout */
1878  tickstart = HAL_GetTick();
1879 
1880  /* Wait end of regular conversion */
1881  while ((hdfsdm_filter->Instance->FLTISR & DFSDM_FLTISR_REOCF) != DFSDM_FLTISR_REOCF)
1882  {
1883  /* Check the Timeout */
1884  if (Timeout != HAL_MAX_DELAY)
1885  {
1886  if (((HAL_GetTick() - tickstart) > Timeout) || (Timeout == 0U))
1887  {
1888  /* Return timeout status */
1889  return HAL_TIMEOUT;
1890  }
1891  }
1892  }
1893  /* Check if overrun occurs */
1894  if ((hdfsdm_filter->Instance->FLTISR & DFSDM_FLTISR_ROVRF) == DFSDM_FLTISR_ROVRF)
1895  {
1896  /* Update error code and call error callback */
1897  hdfsdm_filter->ErrorCode = DFSDM_FILTER_ERROR_REGULAR_OVERRUN;
1898 #if (USE_HAL_DFSDM_REGISTER_CALLBACKS == 1)
1899  hdfsdm_filter->ErrorCallback(hdfsdm_filter);
1900 #else
1901  HAL_DFSDM_FilterErrorCallback(hdfsdm_filter);
1902 #endif
1903 
1904  /* Clear regular overrun flag */
1905  hdfsdm_filter->Instance->FLTICR = DFSDM_FLTICR_CLRROVRF;
1906  }
1907  /* Update DFSDM filter state only if not continuous conversion and SW trigger */
1908  if ((hdfsdm_filter->RegularContMode == DFSDM_CONTINUOUS_CONV_OFF) && \
1909  (hdfsdm_filter->RegularTrigger == DFSDM_FILTER_SW_TRIGGER))
1910  {
1911  hdfsdm_filter->State = (hdfsdm_filter->State == HAL_DFSDM_FILTER_STATE_REG) ? \
1913  }
1914  /* Return function status */
1915  return HAL_OK;
1916  }
1917 }
1918 
1926 {
1927  HAL_StatusTypeDef status = HAL_OK;
1928 
1929  /* Check parameters */
1930  assert_param(IS_DFSDM_FILTER_ALL_INSTANCE(hdfsdm_filter->Instance));
1931 
1932  /* Check DFSDM filter state */
1933  if ((hdfsdm_filter->State != HAL_DFSDM_FILTER_STATE_REG) && \
1934  (hdfsdm_filter->State != HAL_DFSDM_FILTER_STATE_REG_INJ))
1935  {
1936  /* Return error status */
1937  status = HAL_ERROR;
1938  }
1939  else
1940  {
1941  /* Stop regular conversion */
1942  DFSDM_RegConvStop(hdfsdm_filter);
1943  }
1944  /* Return function status */
1945  return status;
1946 }
1947 
1956 {
1957  HAL_StatusTypeDef status = HAL_OK;
1958 
1959  /* Check parameters */
1960  assert_param(IS_DFSDM_FILTER_ALL_INSTANCE(hdfsdm_filter->Instance));
1961 
1962  /* Check DFSDM filter state */
1963  if ((hdfsdm_filter->State == HAL_DFSDM_FILTER_STATE_READY) || \
1964  (hdfsdm_filter->State == HAL_DFSDM_FILTER_STATE_INJ))
1965  {
1966  /* Enable interrupts for regular conversions */
1967  hdfsdm_filter->Instance->FLTCR2 |= (DFSDM_FLTCR2_REOCIE | DFSDM_FLTCR2_ROVRIE);
1968 
1969  /* Start regular conversion */
1970  DFSDM_RegConvStart(hdfsdm_filter);
1971  }
1972  else
1973  {
1974  status = HAL_ERROR;
1975  }
1976  /* Return function status */
1977  return status;
1978 }
1979 
1987 {
1988  HAL_StatusTypeDef status = HAL_OK;
1989 
1990  /* Check parameters */
1991  assert_param(IS_DFSDM_FILTER_ALL_INSTANCE(hdfsdm_filter->Instance));
1992 
1993  /* Check DFSDM filter state */
1994  if ((hdfsdm_filter->State != HAL_DFSDM_FILTER_STATE_REG) && \
1995  (hdfsdm_filter->State != HAL_DFSDM_FILTER_STATE_REG_INJ))
1996  {
1997  /* Return error status */
1998  status = HAL_ERROR;
1999  }
2000  else
2001  {
2002  /* Disable interrupts for regular conversions */
2003  hdfsdm_filter->Instance->FLTCR2 &= ~(DFSDM_FLTCR2_REOCIE | DFSDM_FLTCR2_ROVRIE);
2004 
2005  /* Stop regular conversion */
2006  DFSDM_RegConvStop(hdfsdm_filter);
2007  }
2008  /* Return function status */
2009  return status;
2010 }
2011 
2025  int32_t *pData,
2026  uint32_t Length)
2027 {
2028  HAL_StatusTypeDef status = HAL_OK;
2029 
2030  /* Check parameters */
2031  assert_param(IS_DFSDM_FILTER_ALL_INSTANCE(hdfsdm_filter->Instance));
2032 
2033  /* Check destination address and length */
2034  if ((pData == NULL) || (Length == 0U))
2035  {
2036  status = HAL_ERROR;
2037  }
2038  /* Check that DMA is enabled for regular conversion */
2039  else if ((hdfsdm_filter->Instance->FLTCR1 & DFSDM_FLTCR1_RDMAEN) != DFSDM_FLTCR1_RDMAEN)
2040  {
2041  status = HAL_ERROR;
2042  }
2043  /* Check parameters compatibility */
2044  else if ((hdfsdm_filter->RegularTrigger == DFSDM_FILTER_SW_TRIGGER) && \
2045  (hdfsdm_filter->RegularContMode == DFSDM_CONTINUOUS_CONV_OFF) && \
2046  (hdfsdm_filter->hdmaReg->Init.Mode == DMA_NORMAL) && \
2047  (Length != 1U))
2048  {
2049  status = HAL_ERROR;
2050  }
2051  else if ((hdfsdm_filter->RegularTrigger == DFSDM_FILTER_SW_TRIGGER) && \
2052  (hdfsdm_filter->RegularContMode == DFSDM_CONTINUOUS_CONV_OFF) && \
2053  (hdfsdm_filter->hdmaReg->Init.Mode == DMA_CIRCULAR))
2054  {
2055  status = HAL_ERROR;
2056  }
2057  /* Check DFSDM filter state */
2058  else if ((hdfsdm_filter->State == HAL_DFSDM_FILTER_STATE_READY) || \
2059  (hdfsdm_filter->State == HAL_DFSDM_FILTER_STATE_INJ))
2060  {
2061  /* Set callbacks on DMA handler */
2062  hdfsdm_filter->hdmaReg->XferCpltCallback = DFSDM_DMARegularConvCplt;
2063  hdfsdm_filter->hdmaReg->XferErrorCallback = DFSDM_DMAError;
2064  hdfsdm_filter->hdmaReg->XferHalfCpltCallback = (hdfsdm_filter->hdmaReg->Init.Mode == DMA_CIRCULAR) ? \
2066 
2067  /* Start DMA in interrupt mode */
2068  if (HAL_DMA_Start_IT(hdfsdm_filter->hdmaReg, (uint32_t)&hdfsdm_filter->Instance->FLTRDATAR, \
2069  (uint32_t) pData, Length) != HAL_OK)
2070  {
2071  /* Set DFSDM filter in error state */
2072  hdfsdm_filter->State = HAL_DFSDM_FILTER_STATE_ERROR;
2073  status = HAL_ERROR;
2074  }
2075  else
2076  {
2077  /* Start regular conversion */
2078  DFSDM_RegConvStart(hdfsdm_filter);
2079  }
2080  }
2081  else
2082  {
2083  status = HAL_ERROR;
2084  }
2085  /* Return function status */
2086  return status;
2087 }
2088 
2102  int16_t *pData,
2103  uint32_t Length)
2104 {
2105  HAL_StatusTypeDef status = HAL_OK;
2106 
2107  /* Check parameters */
2108  assert_param(IS_DFSDM_FILTER_ALL_INSTANCE(hdfsdm_filter->Instance));
2109 
2110  /* Check destination address and length */
2111  if ((pData == NULL) || (Length == 0U))
2112  {
2113  status = HAL_ERROR;
2114  }
2115  /* Check that DMA is enabled for regular conversion */
2116  else if ((hdfsdm_filter->Instance->FLTCR1 & DFSDM_FLTCR1_RDMAEN) != DFSDM_FLTCR1_RDMAEN)
2117  {
2118  status = HAL_ERROR;
2119  }
2120  /* Check parameters compatibility */
2121  else if ((hdfsdm_filter->RegularTrigger == DFSDM_FILTER_SW_TRIGGER) && \
2122  (hdfsdm_filter->RegularContMode == DFSDM_CONTINUOUS_CONV_OFF) && \
2123  (hdfsdm_filter->hdmaReg->Init.Mode == DMA_NORMAL) && \
2124  (Length != 1U))
2125  {
2126  status = HAL_ERROR;
2127  }
2128  else if ((hdfsdm_filter->RegularTrigger == DFSDM_FILTER_SW_TRIGGER) && \
2129  (hdfsdm_filter->RegularContMode == DFSDM_CONTINUOUS_CONV_OFF) && \
2130  (hdfsdm_filter->hdmaReg->Init.Mode == DMA_CIRCULAR))
2131  {
2132  status = HAL_ERROR;
2133  }
2134  /* Check DFSDM filter state */
2135  else if ((hdfsdm_filter->State == HAL_DFSDM_FILTER_STATE_READY) || \
2136  (hdfsdm_filter->State == HAL_DFSDM_FILTER_STATE_INJ))
2137  {
2138  /* Set callbacks on DMA handler */
2139  hdfsdm_filter->hdmaReg->XferCpltCallback = DFSDM_DMARegularConvCplt;
2140  hdfsdm_filter->hdmaReg->XferErrorCallback = DFSDM_DMAError;
2141  hdfsdm_filter->hdmaReg->XferHalfCpltCallback = (hdfsdm_filter->hdmaReg->Init.Mode == DMA_CIRCULAR) ? \
2143 
2144  /* Start DMA in interrupt mode */
2145  if (HAL_DMA_Start_IT(hdfsdm_filter->hdmaReg, (uint32_t)(&hdfsdm_filter->Instance->FLTRDATAR) + 2U, \
2146  (uint32_t) pData, Length) != HAL_OK)
2147  {
2148  /* Set DFSDM filter in error state */
2149  hdfsdm_filter->State = HAL_DFSDM_FILTER_STATE_ERROR;
2150  status = HAL_ERROR;
2151  }
2152  else
2153  {
2154  /* Start regular conversion */
2155  DFSDM_RegConvStart(hdfsdm_filter);
2156  }
2157  }
2158  else
2159  {
2160  status = HAL_ERROR;
2161  }
2162  /* Return function status */
2163  return status;
2164 }
2165 
2173 {
2174  HAL_StatusTypeDef status = HAL_OK;
2175 
2176  /* Check parameters */
2177  assert_param(IS_DFSDM_FILTER_ALL_INSTANCE(hdfsdm_filter->Instance));
2178 
2179  /* Check DFSDM filter state */
2180  if ((hdfsdm_filter->State != HAL_DFSDM_FILTER_STATE_REG) && \
2181  (hdfsdm_filter->State != HAL_DFSDM_FILTER_STATE_REG_INJ))
2182  {
2183  /* Return error status */
2184  status = HAL_ERROR;
2185  }
2186  else
2187  {
2188  /* Stop current DMA transfer */
2189  if (HAL_DMA_Abort(hdfsdm_filter->hdmaReg) != HAL_OK)
2190  {
2191  /* Set DFSDM filter in error state */
2192  hdfsdm_filter->State = HAL_DFSDM_FILTER_STATE_ERROR;
2193  status = HAL_ERROR;
2194  }
2195  else
2196  {
2197  /* Stop regular conversion */
2198  DFSDM_RegConvStop(hdfsdm_filter);
2199  }
2200  }
2201  /* Return function status */
2202  return status;
2203 }
2204 
2212  uint32_t *Channel)
2213 {
2214  uint32_t reg;
2215  int32_t value;
2216 
2217  /* Check parameters */
2218  assert_param(IS_DFSDM_FILTER_ALL_INSTANCE(hdfsdm_filter->Instance));
2219  assert_param(Channel != (void *)0);
2220 
2221  /* Get value of data register for regular channel */
2222  reg = hdfsdm_filter->Instance->FLTRDATAR;
2223 
2224  /* Extract channel and regular conversion value */
2225  *Channel = (reg & DFSDM_FLTRDATAR_RDATACH);
2226  /* Regular conversion value is a signed value located on 24 MSB of register */
2227  /* So after applying a mask on these bits we have to perform a division by 256 (2 raised to the power of 8) */
2228  reg &= DFSDM_FLTRDATAR_RDATA;
2229  value = ((int32_t)reg) / 256;
2230 
2231  /* return regular conversion value */
2232  return value;
2233 }
2234 
2243 {
2244  HAL_StatusTypeDef status = HAL_OK;
2245 
2246  /* Check parameters */
2247  assert_param(IS_DFSDM_FILTER_ALL_INSTANCE(hdfsdm_filter->Instance));
2248 
2249  /* Check DFSDM filter state */
2250  if ((hdfsdm_filter->State == HAL_DFSDM_FILTER_STATE_READY) || \
2251  (hdfsdm_filter->State == HAL_DFSDM_FILTER_STATE_REG))
2252  {
2253  /* Start injected conversion */
2254  DFSDM_InjConvStart(hdfsdm_filter);
2255  }
2256  else
2257  {
2258  status = HAL_ERROR;
2259  }
2260  /* Return function status */
2261  return status;
2262 }
2263 
2272  uint32_t Timeout)
2273 {
2274  uint32_t tickstart;
2275 
2276  /* Check parameters */
2277  assert_param(IS_DFSDM_FILTER_ALL_INSTANCE(hdfsdm_filter->Instance));
2278 
2279  /* Check DFSDM filter state */
2280  if ((hdfsdm_filter->State != HAL_DFSDM_FILTER_STATE_INJ) && \
2281  (hdfsdm_filter->State != HAL_DFSDM_FILTER_STATE_REG_INJ))
2282  {
2283  /* Return error status */
2284  return HAL_ERROR;
2285  }
2286  else
2287  {
2288  /* Get timeout */
2289  tickstart = HAL_GetTick();
2290 
2291  /* Wait end of injected conversions */
2292  while ((hdfsdm_filter->Instance->FLTISR & DFSDM_FLTISR_JEOCF) != DFSDM_FLTISR_JEOCF)
2293  {
2294  /* Check the Timeout */
2295  if (Timeout != HAL_MAX_DELAY)
2296  {
2297  if (((HAL_GetTick() - tickstart) > Timeout) || (Timeout == 0U))
2298  {
2299  /* Return timeout status */
2300  return HAL_TIMEOUT;
2301  }
2302  }
2303  }
2304  /* Check if overrun occurs */
2305  if ((hdfsdm_filter->Instance->FLTISR & DFSDM_FLTISR_JOVRF) == DFSDM_FLTISR_JOVRF)
2306  {
2307  /* Update error code and call error callback */
2308  hdfsdm_filter->ErrorCode = DFSDM_FILTER_ERROR_INJECTED_OVERRUN;
2309 #if (USE_HAL_DFSDM_REGISTER_CALLBACKS == 1)
2310  hdfsdm_filter->ErrorCallback(hdfsdm_filter);
2311 #else
2312  HAL_DFSDM_FilterErrorCallback(hdfsdm_filter);
2313 #endif
2314 
2315  /* Clear injected overrun flag */
2316  hdfsdm_filter->Instance->FLTICR = DFSDM_FLTICR_CLRJOVRF;
2317  }
2318 
2319  /* Update remaining injected conversions */
2320  hdfsdm_filter->InjConvRemaining--;
2321  if (hdfsdm_filter->InjConvRemaining == 0U)
2322  {
2323  /* Update DFSDM filter state only if trigger is software */
2324  if (hdfsdm_filter->InjectedTrigger == DFSDM_FILTER_SW_TRIGGER)
2325  {
2326  hdfsdm_filter->State = (hdfsdm_filter->State == HAL_DFSDM_FILTER_STATE_INJ) ? \
2328  }
2329 
2330  /* end of injected sequence, reset the value */
2331  hdfsdm_filter->InjConvRemaining = (hdfsdm_filter->InjectedScanMode == ENABLE) ? \
2332  hdfsdm_filter->InjectedChannelsNbr : 1U;
2333  }
2334 
2335  /* Return function status */
2336  return HAL_OK;
2337  }
2338 }
2339 
2347 {
2348  HAL_StatusTypeDef status = HAL_OK;
2349 
2350  /* Check parameters */
2351  assert_param(IS_DFSDM_FILTER_ALL_INSTANCE(hdfsdm_filter->Instance));
2352 
2353  /* Check DFSDM filter state */
2354  if ((hdfsdm_filter->State != HAL_DFSDM_FILTER_STATE_INJ) && \
2355  (hdfsdm_filter->State != HAL_DFSDM_FILTER_STATE_REG_INJ))
2356  {
2357  /* Return error status */
2358  status = HAL_ERROR;
2359  }
2360  else
2361  {
2362  /* Stop injected conversion */
2363  DFSDM_InjConvStop(hdfsdm_filter);
2364  }
2365  /* Return function status */
2366  return status;
2367 }
2368 
2377 {
2378  HAL_StatusTypeDef status = HAL_OK;
2379 
2380  /* Check parameters */
2381  assert_param(IS_DFSDM_FILTER_ALL_INSTANCE(hdfsdm_filter->Instance));
2382 
2383  /* Check DFSDM filter state */
2384  if ((hdfsdm_filter->State == HAL_DFSDM_FILTER_STATE_READY) || \
2385  (hdfsdm_filter->State == HAL_DFSDM_FILTER_STATE_REG))
2386  {
2387  /* Enable interrupts for injected conversions */
2388  hdfsdm_filter->Instance->FLTCR2 |= (DFSDM_FLTCR2_JEOCIE | DFSDM_FLTCR2_JOVRIE);
2389 
2390  /* Start injected conversion */
2391  DFSDM_InjConvStart(hdfsdm_filter);
2392  }
2393  else
2394  {
2395  status = HAL_ERROR;
2396  }
2397  /* Return function status */
2398  return status;
2399 }
2400 
2408 {
2409  HAL_StatusTypeDef status = HAL_OK;
2410 
2411  /* Check parameters */
2412  assert_param(IS_DFSDM_FILTER_ALL_INSTANCE(hdfsdm_filter->Instance));
2413 
2414  /* Check DFSDM filter state */
2415  if ((hdfsdm_filter->State != HAL_DFSDM_FILTER_STATE_INJ) && \
2416  (hdfsdm_filter->State != HAL_DFSDM_FILTER_STATE_REG_INJ))
2417  {
2418  /* Return error status */
2419  status = HAL_ERROR;
2420  }
2421  else
2422  {
2423  /* Disable interrupts for injected conversions */
2424  hdfsdm_filter->Instance->FLTCR2 &= ~(DFSDM_FLTCR2_JEOCIE | DFSDM_FLTCR2_JOVRIE);
2425 
2426  /* Stop injected conversion */
2427  DFSDM_InjConvStop(hdfsdm_filter);
2428  }
2429  /* Return function status */
2430  return status;
2431 }
2432 
2446  int32_t *pData,
2447  uint32_t Length)
2448 {
2449  HAL_StatusTypeDef status = HAL_OK;
2450 
2451  /* Check parameters */
2452  assert_param(IS_DFSDM_FILTER_ALL_INSTANCE(hdfsdm_filter->Instance));
2453 
2454  /* Check destination address and length */
2455  if ((pData == NULL) || (Length == 0U))
2456  {
2457  status = HAL_ERROR;
2458  }
2459  /* Check that DMA is enabled for injected conversion */
2460  else if ((hdfsdm_filter->Instance->FLTCR1 & DFSDM_FLTCR1_JDMAEN) != DFSDM_FLTCR1_JDMAEN)
2461  {
2462  status = HAL_ERROR;
2463  }
2464  /* Check parameters compatibility */
2465  else if ((hdfsdm_filter->InjectedTrigger == DFSDM_FILTER_SW_TRIGGER) && \
2466  (hdfsdm_filter->hdmaInj->Init.Mode == DMA_NORMAL) && \
2467  (Length > hdfsdm_filter->InjConvRemaining))
2468  {
2469  status = HAL_ERROR;
2470  }
2471  else if ((hdfsdm_filter->InjectedTrigger == DFSDM_FILTER_SW_TRIGGER) && \
2472  (hdfsdm_filter->hdmaInj->Init.Mode == DMA_CIRCULAR))
2473  {
2474  status = HAL_ERROR;
2475  }
2476  /* Check DFSDM filter state */
2477  else if ((hdfsdm_filter->State == HAL_DFSDM_FILTER_STATE_READY) || \
2478  (hdfsdm_filter->State == HAL_DFSDM_FILTER_STATE_REG))
2479  {
2480  /* Set callbacks on DMA handler */
2481  hdfsdm_filter->hdmaInj->XferCpltCallback = DFSDM_DMAInjectedConvCplt;
2482  hdfsdm_filter->hdmaInj->XferErrorCallback = DFSDM_DMAError;
2483  hdfsdm_filter->hdmaInj->XferHalfCpltCallback = (hdfsdm_filter->hdmaInj->Init.Mode == DMA_CIRCULAR) ? \
2485 
2486  /* Start DMA in interrupt mode */
2487  if (HAL_DMA_Start_IT(hdfsdm_filter->hdmaInj, (uint32_t)&hdfsdm_filter->Instance->FLTJDATAR, \
2488  (uint32_t) pData, Length) != HAL_OK)
2489  {
2490  /* Set DFSDM filter in error state */
2491  hdfsdm_filter->State = HAL_DFSDM_FILTER_STATE_ERROR;
2492  status = HAL_ERROR;
2493  }
2494  else
2495  {
2496  /* Start injected conversion */
2497  DFSDM_InjConvStart(hdfsdm_filter);
2498  }
2499  }
2500  else
2501  {
2502  status = HAL_ERROR;
2503  }
2504  /* Return function status */
2505  return status;
2506 }
2507 
2521  int16_t *pData,
2522  uint32_t Length)
2523 {
2524  HAL_StatusTypeDef status = HAL_OK;
2525 
2526  /* Check parameters */
2527  assert_param(IS_DFSDM_FILTER_ALL_INSTANCE(hdfsdm_filter->Instance));
2528 
2529  /* Check destination address and length */
2530  if ((pData == NULL) || (Length == 0U))
2531  {
2532  status = HAL_ERROR;
2533  }
2534  /* Check that DMA is enabled for injected conversion */
2535  else if ((hdfsdm_filter->Instance->FLTCR1 & DFSDM_FLTCR1_JDMAEN) != DFSDM_FLTCR1_JDMAEN)
2536  {
2537  status = HAL_ERROR;
2538  }
2539  /* Check parameters compatibility */
2540  else if ((hdfsdm_filter->InjectedTrigger == DFSDM_FILTER_SW_TRIGGER) && \
2541  (hdfsdm_filter->hdmaInj->Init.Mode == DMA_NORMAL) && \
2542  (Length > hdfsdm_filter->InjConvRemaining))
2543  {
2544  status = HAL_ERROR;
2545  }
2546  else if ((hdfsdm_filter->InjectedTrigger == DFSDM_FILTER_SW_TRIGGER) && \
2547  (hdfsdm_filter->hdmaInj->Init.Mode == DMA_CIRCULAR))
2548  {
2549  status = HAL_ERROR;
2550  }
2551  /* Check DFSDM filter state */
2552  else if ((hdfsdm_filter->State == HAL_DFSDM_FILTER_STATE_READY) || \
2553  (hdfsdm_filter->State == HAL_DFSDM_FILTER_STATE_REG))
2554  {
2555  /* Set callbacks on DMA handler */
2556  hdfsdm_filter->hdmaInj->XferCpltCallback = DFSDM_DMAInjectedConvCplt;
2557  hdfsdm_filter->hdmaInj->XferErrorCallback = DFSDM_DMAError;
2558  hdfsdm_filter->hdmaInj->XferHalfCpltCallback = (hdfsdm_filter->hdmaInj->Init.Mode == DMA_CIRCULAR) ? \
2560 
2561  /* Start DMA in interrupt mode */
2562  if (HAL_DMA_Start_IT(hdfsdm_filter->hdmaInj, (uint32_t)(&hdfsdm_filter->Instance->FLTJDATAR) + 2U, \
2563  (uint32_t) pData, Length) != HAL_OK)
2564  {
2565  /* Set DFSDM filter in error state */
2566  hdfsdm_filter->State = HAL_DFSDM_FILTER_STATE_ERROR;
2567  status = HAL_ERROR;
2568  }
2569  else
2570  {
2571  /* Start injected conversion */
2572  DFSDM_InjConvStart(hdfsdm_filter);
2573  }
2574  }
2575  else
2576  {
2577  status = HAL_ERROR;
2578  }
2579  /* Return function status */
2580  return status;
2581 }
2582 
2590 {
2591  HAL_StatusTypeDef status = HAL_OK;
2592 
2593  /* Check parameters */
2594  assert_param(IS_DFSDM_FILTER_ALL_INSTANCE(hdfsdm_filter->Instance));
2595 
2596  /* Check DFSDM filter state */
2597  if ((hdfsdm_filter->State != HAL_DFSDM_FILTER_STATE_INJ) && \
2598  (hdfsdm_filter->State != HAL_DFSDM_FILTER_STATE_REG_INJ))
2599  {
2600  /* Return error status */
2601  status = HAL_ERROR;
2602  }
2603  else
2604  {
2605  /* Stop current DMA transfer */
2606  if (HAL_DMA_Abort(hdfsdm_filter->hdmaInj) != HAL_OK)
2607  {
2608  /* Set DFSDM filter in error state */
2609  hdfsdm_filter->State = HAL_DFSDM_FILTER_STATE_ERROR;
2610  status = HAL_ERROR;
2611  }
2612  else
2613  {
2614  /* Stop regular conversion */
2615  DFSDM_InjConvStop(hdfsdm_filter);
2616  }
2617  }
2618  /* Return function status */
2619  return status;
2620 }
2621 
2629  uint32_t *Channel)
2630 {
2631  uint32_t reg;
2632  int32_t value;
2633 
2634  /* Check parameters */
2635  assert_param(IS_DFSDM_FILTER_ALL_INSTANCE(hdfsdm_filter->Instance));
2636  assert_param(Channel != (void *)0);
2637 
2638  /* Get value of data register for injected channel */
2639  reg = hdfsdm_filter->Instance->FLTJDATAR;
2640 
2641  /* Extract channel and injected conversion value */
2642  *Channel = (reg & DFSDM_FLTJDATAR_JDATACH);
2643  /* Injected conversion value is a signed value located on 24 MSB of register */
2644  /* So after applying a mask on these bits we have to perform a division by 256 (2 raised to the power of 8) */
2645  reg &= DFSDM_FLTJDATAR_JDATA;
2646  value = ((int32_t)reg) / 256;
2647 
2648  /* return regular conversion value */
2649  return value;
2650 }
2651 
2659  DFSDM_Filter_AwdParamTypeDef *awdParam)
2660 {
2661  HAL_StatusTypeDef status = HAL_OK;
2662 
2663  /* Check parameters */
2664  assert_param(IS_DFSDM_FILTER_ALL_INSTANCE(hdfsdm_filter->Instance));
2665  assert_param(IS_DFSDM_FILTER_AWD_DATA_SOURCE(awdParam->DataSource));
2666  assert_param(IS_DFSDM_INJECTED_CHANNEL(awdParam->Channel));
2667  assert_param(IS_DFSDM_FILTER_AWD_THRESHOLD(awdParam->HighThreshold));
2668  assert_param(IS_DFSDM_FILTER_AWD_THRESHOLD(awdParam->LowThreshold));
2669  assert_param(IS_DFSDM_BREAK_SIGNALS(awdParam->HighBreakSignal));
2670  assert_param(IS_DFSDM_BREAK_SIGNALS(awdParam->LowBreakSignal));
2671 
2672  /* Check DFSDM filter state */
2673  if ((hdfsdm_filter->State == HAL_DFSDM_FILTER_STATE_RESET) || \
2674  (hdfsdm_filter->State == HAL_DFSDM_FILTER_STATE_ERROR))
2675  {
2676  /* Return error status */
2677  status = HAL_ERROR;
2678  }
2679  else
2680  {
2681  /* Set analog watchdog data source */
2682  hdfsdm_filter->Instance->FLTCR1 &= ~(DFSDM_FLTCR1_AWFSEL);
2683  hdfsdm_filter->Instance->FLTCR1 |= awdParam->DataSource;
2684 
2685  /* Set thresholds and break signals */
2686  hdfsdm_filter->Instance->FLTAWHTR &= ~(DFSDM_FLTAWHTR_AWHT | DFSDM_FLTAWHTR_BKAWH);
2687  hdfsdm_filter->Instance->FLTAWHTR |= (((uint32_t) awdParam->HighThreshold << DFSDM_FLTAWHTR_AWHT_Pos) | \
2688  awdParam->HighBreakSignal);
2689  hdfsdm_filter->Instance->FLTAWLTR &= ~(DFSDM_FLTAWLTR_AWLT | DFSDM_FLTAWLTR_BKAWL);
2690  hdfsdm_filter->Instance->FLTAWLTR |= (((uint32_t) awdParam->LowThreshold << DFSDM_FLTAWLTR_AWLT_Pos) | \
2691  awdParam->LowBreakSignal);
2692 
2693  /* Set channels and interrupt for analog watchdog */
2694  hdfsdm_filter->Instance->FLTCR2 &= ~(DFSDM_FLTCR2_AWDCH);
2695  hdfsdm_filter->Instance->FLTCR2 |= (((awdParam->Channel & DFSDM_LSB_MASK) << DFSDM_FLTCR2_AWDCH_Pos) | \
2696  DFSDM_FLTCR2_AWDIE);
2697  }
2698  /* Return function status */
2699  return status;
2700 }
2701 
2708 {
2709  HAL_StatusTypeDef status = HAL_OK;
2710 
2711  /* Check parameters */
2712  assert_param(IS_DFSDM_FILTER_ALL_INSTANCE(hdfsdm_filter->Instance));
2713 
2714  /* Check DFSDM filter state */
2715  if ((hdfsdm_filter->State == HAL_DFSDM_FILTER_STATE_RESET) || \
2716  (hdfsdm_filter->State == HAL_DFSDM_FILTER_STATE_ERROR))
2717  {
2718  /* Return error status */
2719  status = HAL_ERROR;
2720  }
2721  else
2722  {
2723  /* Reset channels for analog watchdog and deactivate interrupt */
2724  hdfsdm_filter->Instance->FLTCR2 &= ~(DFSDM_FLTCR2_AWDCH | DFSDM_FLTCR2_AWDIE);
2725 
2726  /* Clear all analog watchdog flags */
2727  hdfsdm_filter->Instance->FLTAWCFR = (DFSDM_FLTAWCFR_CLRAWHTF | DFSDM_FLTAWCFR_CLRAWLTF);
2728 
2729  /* Reset thresholds and break signals */
2730  hdfsdm_filter->Instance->FLTAWHTR &= ~(DFSDM_FLTAWHTR_AWHT | DFSDM_FLTAWHTR_BKAWH);
2731  hdfsdm_filter->Instance->FLTAWLTR &= ~(DFSDM_FLTAWLTR_AWLT | DFSDM_FLTAWLTR_BKAWL);
2732 
2733  /* Reset analog watchdog data source */
2734  hdfsdm_filter->Instance->FLTCR1 &= ~(DFSDM_FLTCR1_AWFSEL);
2735  }
2736  /* Return function status */
2737  return status;
2738 }
2739 
2747 HAL_StatusTypeDef HAL_DFSDM_FilterExdStart(DFSDM_Filter_HandleTypeDef *hdfsdm_filter,
2748  uint32_t Channel)
2749 {
2750  HAL_StatusTypeDef status = HAL_OK;
2751 
2752  /* Check parameters */
2753  assert_param(IS_DFSDM_FILTER_ALL_INSTANCE(hdfsdm_filter->Instance));
2754  assert_param(IS_DFSDM_INJECTED_CHANNEL(Channel));
2755 
2756  /* Check DFSDM filter state */
2757  if ((hdfsdm_filter->State == HAL_DFSDM_FILTER_STATE_RESET) || \
2758  (hdfsdm_filter->State == HAL_DFSDM_FILTER_STATE_ERROR))
2759  {
2760  /* Return error status */
2761  status = HAL_ERROR;
2762  }
2763  else
2764  {
2765  /* Set channels for extreme detector */
2766  hdfsdm_filter->Instance->FLTCR2 &= ~(DFSDM_FLTCR2_EXCH);
2767  hdfsdm_filter->Instance->FLTCR2 |= ((Channel & DFSDM_LSB_MASK) << DFSDM_FLTCR2_EXCH_Pos);
2768  }
2769  /* Return function status */
2770  return status;
2771 }
2772 
2778 HAL_StatusTypeDef HAL_DFSDM_FilterExdStop(DFSDM_Filter_HandleTypeDef *hdfsdm_filter)
2779 {
2780  HAL_StatusTypeDef status = HAL_OK;
2781  __IO uint32_t reg1;
2782  __IO uint32_t reg2;
2783 
2784  /* Check parameters */
2785  assert_param(IS_DFSDM_FILTER_ALL_INSTANCE(hdfsdm_filter->Instance));
2786 
2787  /* Check DFSDM filter state */
2788  if ((hdfsdm_filter->State == HAL_DFSDM_FILTER_STATE_RESET) || \
2789  (hdfsdm_filter->State == HAL_DFSDM_FILTER_STATE_ERROR))
2790  {
2791  /* Return error status */
2792  status = HAL_ERROR;
2793  }
2794  else
2795  {
2796  /* Reset channels for extreme detector */
2797  hdfsdm_filter->Instance->FLTCR2 &= ~(DFSDM_FLTCR2_EXCH);
2798 
2799  /* Clear extreme detector values */
2800  reg1 = hdfsdm_filter->Instance->FLTEXMAX;
2801  reg2 = hdfsdm_filter->Instance->FLTEXMIN;
2802  UNUSED(reg1); /* To avoid GCC warning */
2803  UNUSED(reg2); /* To avoid GCC warning */
2804  }
2805  /* Return function status */
2806  return status;
2807 }
2808 
2817  uint32_t *Channel)
2818 {
2819  uint32_t reg;
2820  int32_t value;
2821 
2822  /* Check parameters */
2823  assert_param(IS_DFSDM_FILTER_ALL_INSTANCE(hdfsdm_filter->Instance));
2824  assert_param(Channel != (void *)0);
2825 
2826  /* Get value of extreme detector maximum register */
2827  reg = hdfsdm_filter->Instance->FLTEXMAX;
2828 
2829  /* Extract channel and extreme detector maximum value */
2830  *Channel = (reg & DFSDM_FLTEXMAX_EXMAXCH);
2831  /* Extreme detector maximum value is a signed value located on 24 MSB of register */
2832  /* So after applying a mask on these bits we have to perform a division by 256 (2 raised to the power of 8) */
2833  reg &= DFSDM_FLTEXMAX_EXMAX;
2834  value = ((int32_t)reg) / 256;
2835 
2836  /* return extreme detector maximum value */
2837  return value;
2838 }
2839 
2848  uint32_t *Channel)
2849 {
2850  uint32_t reg;
2851  int32_t value;
2852 
2853  /* Check parameters */
2854  assert_param(IS_DFSDM_FILTER_ALL_INSTANCE(hdfsdm_filter->Instance));
2855  assert_param(Channel != (void *)0);
2856 
2857  /* Get value of extreme detector minimum register */
2858  reg = hdfsdm_filter->Instance->FLTEXMIN;
2859 
2860  /* Extract channel and extreme detector minimum value */
2861  *Channel = (reg & DFSDM_FLTEXMIN_EXMINCH);
2862  /* Extreme detector minimum value is a signed value located on 24 MSB of register */
2863  /* So after applying a mask on these bits we have to perform a division by 256 (2 raised to the power of 8) */
2864  reg &= DFSDM_FLTEXMIN_EXMIN;
2865  value = ((int32_t)reg) / 256;
2866 
2867  /* return extreme detector minimum value */
2868  return value;
2869 }
2870 
2878 {
2879  uint32_t reg;
2880  uint32_t value;
2881 
2882  /* Check parameters */
2883  assert_param(IS_DFSDM_FILTER_ALL_INSTANCE(hdfsdm_filter->Instance));
2884 
2885  /* Get value of conversion timer register */
2886  reg = hdfsdm_filter->Instance->FLTCNVTIMR;
2887 
2888  /* Extract conversion time value */
2889  value = ((reg & DFSDM_FLTCNVTIMR_CNVCNT) >> DFSDM_FLTCNVTIMR_CNVCNT_Pos);
2890 
2891  /* return extreme detector minimum value */
2892  return value;
2893 }
2894 
2901 {
2902  /* Get FTLISR and FLTCR2 register values */
2903  const uint32_t temp_fltisr = hdfsdm_filter->Instance->FLTISR;
2904  const uint32_t temp_fltcr2 = hdfsdm_filter->Instance->FLTCR2;
2905 
2906  /* Check if overrun occurs during regular conversion */
2907  if (((temp_fltisr & DFSDM_FLTISR_ROVRF) != 0U) && \
2908  ((temp_fltcr2 & DFSDM_FLTCR2_ROVRIE) != 0U))
2909  {
2910  /* Clear regular overrun flag */
2911  hdfsdm_filter->Instance->FLTICR = DFSDM_FLTICR_CLRROVRF;
2912 
2913  /* Update error code */
2914  hdfsdm_filter->ErrorCode = DFSDM_FILTER_ERROR_REGULAR_OVERRUN;
2915 
2916  /* Call error callback */
2917 #if (USE_HAL_DFSDM_REGISTER_CALLBACKS == 1)
2918  hdfsdm_filter->ErrorCallback(hdfsdm_filter);
2919 #else
2920  HAL_DFSDM_FilterErrorCallback(hdfsdm_filter);
2921 #endif
2922  }
2923  /* Check if overrun occurs during injected conversion */
2924  else if (((temp_fltisr & DFSDM_FLTISR_JOVRF) != 0U) && \
2925  ((temp_fltcr2 & DFSDM_FLTCR2_JOVRIE) != 0U))
2926  {
2927  /* Clear injected overrun flag */
2928  hdfsdm_filter->Instance->FLTICR = DFSDM_FLTICR_CLRJOVRF;
2929 
2930  /* Update error code */
2931  hdfsdm_filter->ErrorCode = DFSDM_FILTER_ERROR_INJECTED_OVERRUN;
2932 
2933  /* Call error callback */
2934 #if (USE_HAL_DFSDM_REGISTER_CALLBACKS == 1)
2935  hdfsdm_filter->ErrorCallback(hdfsdm_filter);
2936 #else
2937  HAL_DFSDM_FilterErrorCallback(hdfsdm_filter);
2938 #endif
2939  }
2940  /* Check if end of regular conversion */
2941  else if (((temp_fltisr & DFSDM_FLTISR_REOCF) != 0U) && \
2942  ((temp_fltcr2 & DFSDM_FLTCR2_REOCIE) != 0U))
2943  {
2944  /* Call regular conversion complete callback */
2945 #if (USE_HAL_DFSDM_REGISTER_CALLBACKS == 1)
2946  hdfsdm_filter->RegConvCpltCallback(hdfsdm_filter);
2947 #else
2948  HAL_DFSDM_FilterRegConvCpltCallback(hdfsdm_filter);
2949 #endif
2950 
2951  /* End of conversion if mode is not continuous and software trigger */
2952  if ((hdfsdm_filter->RegularContMode == DFSDM_CONTINUOUS_CONV_OFF) && \
2953  (hdfsdm_filter->RegularTrigger == DFSDM_FILTER_SW_TRIGGER))
2954  {
2955  /* Disable interrupts for regular conversions */
2956  hdfsdm_filter->Instance->FLTCR2 &= ~(DFSDM_FLTCR2_REOCIE);
2957 
2958  /* Update DFSDM filter state */
2959  hdfsdm_filter->State = (hdfsdm_filter->State == HAL_DFSDM_FILTER_STATE_REG) ? \
2961  }
2962  }
2963  /* Check if end of injected conversion */
2964  else if (((temp_fltisr & DFSDM_FLTISR_JEOCF) != 0U) && \
2965  ((temp_fltcr2 & DFSDM_FLTCR2_JEOCIE) != 0U))
2966  {
2967  /* Call injected conversion complete callback */
2968 #if (USE_HAL_DFSDM_REGISTER_CALLBACKS == 1)
2969  hdfsdm_filter->InjConvCpltCallback(hdfsdm_filter);
2970 #else
2971  HAL_DFSDM_FilterInjConvCpltCallback(hdfsdm_filter);
2972 #endif
2973 
2974  /* Update remaining injected conversions */
2975  hdfsdm_filter->InjConvRemaining--;
2976  if (hdfsdm_filter->InjConvRemaining == 0U)
2977  {
2978  /* End of conversion if trigger is software */
2979  if (hdfsdm_filter->InjectedTrigger == DFSDM_FILTER_SW_TRIGGER)
2980  {
2981  /* Disable interrupts for injected conversions */
2982  hdfsdm_filter->Instance->FLTCR2 &= ~(DFSDM_FLTCR2_JEOCIE);
2983 
2984  /* Update DFSDM filter state */
2985  hdfsdm_filter->State = (hdfsdm_filter->State == HAL_DFSDM_FILTER_STATE_INJ) ? \
2987  }
2988  /* end of injected sequence, reset the value */
2989  hdfsdm_filter->InjConvRemaining = (hdfsdm_filter->InjectedScanMode == ENABLE) ? \
2990  hdfsdm_filter->InjectedChannelsNbr : 1U;
2991  }
2992  }
2993  /* Check if analog watchdog occurs */
2994  else if (((temp_fltisr & DFSDM_FLTISR_AWDF) != 0U) && \
2995  ((temp_fltcr2 & DFSDM_FLTCR2_AWDIE) != 0U))
2996  {
2997  uint32_t reg;
2998  uint32_t threshold;
2999  uint32_t channel = 0;
3000 
3001  /* Get channel and threshold */
3002  reg = hdfsdm_filter->Instance->FLTAWSR;
3003  threshold = ((reg & DFSDM_FLTAWSR_AWLTF) != 0U) ? DFSDM_AWD_LOW_THRESHOLD : DFSDM_AWD_HIGH_THRESHOLD;
3004  if (threshold == DFSDM_AWD_HIGH_THRESHOLD)
3005  {
3006  reg = reg >> DFSDM_FLTAWSR_AWHTF_Pos;
3007  }
3008  while (((reg & 1U) == 0U) && (channel < (DFSDM1_CHANNEL_NUMBER - 1U)))
3009  {
3010  channel++;
3011  reg = reg >> 1;
3012  }
3013  /* Clear analog watchdog flag */
3014  hdfsdm_filter->Instance->FLTAWCFR = (threshold == DFSDM_AWD_HIGH_THRESHOLD) ? \
3015  (1UL << (DFSDM_FLTAWSR_AWHTF_Pos + channel)) : \
3016  (1UL << channel);
3017 
3018  /* Call analog watchdog callback */
3019 #if (USE_HAL_DFSDM_REGISTER_CALLBACKS == 1)
3020  hdfsdm_filter->AwdCallback(hdfsdm_filter, channel, threshold);
3021 #else
3022  HAL_DFSDM_FilterAwdCallback(hdfsdm_filter, channel, threshold);
3023 #endif
3024  }
3025  /* Check if clock absence occurs */
3026  else if ((hdfsdm_filter->Instance == DFSDM1_Filter0) && \
3027  ((temp_fltisr & DFSDM_FLTISR_CKABF) != 0U) && \
3028  ((temp_fltcr2 & DFSDM_FLTCR2_CKABIE) != 0U))
3029  {
3030  uint32_t reg;
3031  uint32_t channel = 0;
3032 
3033  reg = ((hdfsdm_filter->Instance->FLTISR & DFSDM_FLTISR_CKABF) >> DFSDM_FLTISR_CKABF_Pos);
3034 
3035  while (channel < DFSDM1_CHANNEL_NUMBER)
3036  {
3037  /* Check if flag is set and corresponding channel is enabled */
3038  if (((reg & 1U) != 0U) && (a_dfsdm1ChannelHandle[channel] != NULL))
3039  {
3040  /* Check clock absence has been enabled for this channel */
3041  if ((a_dfsdm1ChannelHandle[channel]->Instance->CHCFGR1 & DFSDM_CHCFGR1_CKABEN) != 0U)
3042  {
3043  /* Clear clock absence flag */
3044  hdfsdm_filter->Instance->FLTICR = (1UL << (DFSDM_FLTICR_CLRCKABF_Pos + channel));
3045 
3046  /* Call clock absence callback */
3047 #if (USE_HAL_DFSDM_REGISTER_CALLBACKS == 1)
3048  a_dfsdm1ChannelHandle[channel]->CkabCallback(a_dfsdm1ChannelHandle[channel]);
3049 #else
3051 #endif
3052  }
3053  }
3054  channel++;
3055  reg = reg >> 1;
3056  }
3057  }
3058  /* Check if short circuit detection occurs */
3059  else if ((hdfsdm_filter->Instance == DFSDM1_Filter0) && \
3060  ((temp_fltisr & DFSDM_FLTISR_SCDF) != 0U) && \
3061  ((temp_fltcr2 & DFSDM_FLTCR2_SCDIE) != 0U))
3062  {
3063  uint32_t reg;
3064  uint32_t channel = 0;
3065 
3066  /* Get channel */
3067  reg = ((hdfsdm_filter->Instance->FLTISR & DFSDM_FLTISR_SCDF) >> DFSDM_FLTISR_SCDF_Pos);
3068  while (((reg & 1U) == 0U) && (channel < (DFSDM1_CHANNEL_NUMBER - 1U)))
3069  {
3070  channel++;
3071  reg = reg >> 1;
3072  }
3073 
3074  /* Clear short circuit detection flag */
3075  hdfsdm_filter->Instance->FLTICR = (1UL << (DFSDM_FLTICR_CLRSCDF_Pos + channel));
3076 
3077  /* Call short circuit detection callback */
3078 #if (USE_HAL_DFSDM_REGISTER_CALLBACKS == 1)
3079  a_dfsdm1ChannelHandle[channel]->ScdCallback(a_dfsdm1ChannelHandle[channel]);
3080 #else
3082 #endif
3083  }
3084 }
3085 
3094 {
3095  /* Prevent unused argument(s) compilation warning */
3096  UNUSED(hdfsdm_filter);
3097 
3098  /* NOTE : This function should not be modified, when the callback is needed,
3099  the HAL_DFSDM_FilterRegConvCpltCallback could be implemented in the user file.
3100  */
3101 }
3102 
3109 {
3110  /* Prevent unused argument(s) compilation warning */
3111  UNUSED(hdfsdm_filter);
3112 
3113  /* NOTE : This function should not be modified, when the callback is needed,
3114  the HAL_DFSDM_FilterRegConvHalfCpltCallback could be implemented in the user file.
3115  */
3116 }
3117 
3126 {
3127  /* Prevent unused argument(s) compilation warning */
3128  UNUSED(hdfsdm_filter);
3129 
3130  /* NOTE : This function should not be modified, when the callback is needed,
3131  the HAL_DFSDM_FilterInjConvCpltCallback could be implemented in the user file.
3132  */
3133 }
3134 
3141 {
3142  /* Prevent unused argument(s) compilation warning */
3143  UNUSED(hdfsdm_filter);
3144 
3145  /* NOTE : This function should not be modified, when the callback is needed,
3146  the HAL_DFSDM_FilterInjConvHalfCpltCallback could be implemented in the user file.
3147  */
3148 }
3149 
3158  uint32_t Channel, uint32_t Threshold)
3159 {
3160  /* Prevent unused argument(s) compilation warning */
3161  UNUSED(hdfsdm_filter);
3162  UNUSED(Channel);
3163  UNUSED(Threshold);
3164 
3165  /* NOTE : This function should not be modified, when the callback is needed,
3166  the HAL_DFSDM_FilterAwdCallback could be implemented in the user file.
3167  */
3168 }
3169 
3176 {
3177  /* Prevent unused argument(s) compilation warning */
3178  UNUSED(hdfsdm_filter);
3179 
3180  /* NOTE : This function should not be modified, when the callback is needed,
3181  the HAL_DFSDM_FilterErrorCallback could be implemented in the user file.
3182  */
3183 }
3184 
3209 {
3210  /* Return DFSDM filter handle state */
3211  return hdfsdm_filter->State;
3212 }
3213 
3220 {
3221  return hdfsdm_filter->ErrorCode;
3222 }
3223 
3231 /* End of exported functions -------------------------------------------------*/
3232 
3233 /* Private functions ---------------------------------------------------------*/
3244 {
3245  /* Get DFSDM filter handle */
3246  DFSDM_Filter_HandleTypeDef *hdfsdm_filter = (DFSDM_Filter_HandleTypeDef *)((DMA_HandleTypeDef *)hdma)->Parent;
3247 
3248  /* Call regular half conversion complete callback */
3249 #if (USE_HAL_DFSDM_REGISTER_CALLBACKS == 1)
3250  hdfsdm_filter->RegConvHalfCpltCallback(hdfsdm_filter);
3251 #else
3253 #endif
3254 }
3255 
3262 {
3263  /* Get DFSDM filter handle */
3264  DFSDM_Filter_HandleTypeDef *hdfsdm_filter = (DFSDM_Filter_HandleTypeDef *)((DMA_HandleTypeDef *)hdma)->Parent;
3265 
3266  /* Call regular conversion complete callback */
3267 #if (USE_HAL_DFSDM_REGISTER_CALLBACKS == 1)
3268  hdfsdm_filter->RegConvCpltCallback(hdfsdm_filter);
3269 #else
3270  HAL_DFSDM_FilterRegConvCpltCallback(hdfsdm_filter);
3271 #endif
3272 }
3273 
3280 {
3281  /* Get DFSDM filter handle */
3282  DFSDM_Filter_HandleTypeDef *hdfsdm_filter = (DFSDM_Filter_HandleTypeDef *)((DMA_HandleTypeDef *)hdma)->Parent;
3283 
3284  /* Call injected half conversion complete callback */
3285 #if (USE_HAL_DFSDM_REGISTER_CALLBACKS == 1)
3286  hdfsdm_filter->InjConvHalfCpltCallback(hdfsdm_filter);
3287 #else
3289 #endif
3290 }
3291 
3298 {
3299  /* Get DFSDM filter handle */
3300  DFSDM_Filter_HandleTypeDef *hdfsdm_filter = (DFSDM_Filter_HandleTypeDef *)((DMA_HandleTypeDef *)hdma)->Parent;
3301 
3302  /* Call injected conversion complete callback */
3303 #if (USE_HAL_DFSDM_REGISTER_CALLBACKS == 1)
3304  hdfsdm_filter->InjConvCpltCallback(hdfsdm_filter);
3305 #else
3306  HAL_DFSDM_FilterInjConvCpltCallback(hdfsdm_filter);
3307 #endif
3308 }
3309 
3316 {
3317  /* Get DFSDM filter handle */
3318  DFSDM_Filter_HandleTypeDef *hdfsdm_filter = (DFSDM_Filter_HandleTypeDef *)((DMA_HandleTypeDef *)hdma)->Parent;
3319 
3320  /* Update error code */
3321  hdfsdm_filter->ErrorCode = DFSDM_FILTER_ERROR_DMA;
3322 
3323  /* Call error callback */
3324 #if (USE_HAL_DFSDM_REGISTER_CALLBACKS == 1)
3325  hdfsdm_filter->ErrorCallback(hdfsdm_filter);
3326 #else
3327  HAL_DFSDM_FilterErrorCallback(hdfsdm_filter);
3328 #endif
3329 }
3330 
3336 static uint32_t DFSDM_GetInjChannelsNbr(uint32_t Channels)
3337 {
3338  uint32_t nbChannels = 0;
3339  uint32_t tmp;
3340 
3341  /* Get the number of channels from bitfield */
3342  tmp = (uint32_t)(Channels & DFSDM_LSB_MASK);
3343  while (tmp != 0U)
3344  {
3345  if ((tmp & 1U) != 0U)
3346  {
3347  nbChannels++;
3348  }
3349  tmp = (uint32_t)(tmp >> 1);
3350  }
3351  return nbChannels;
3352 }
3353 
3359 static uint32_t DFSDM_GetChannelFromInstance(const DFSDM_Channel_TypeDef *Instance)
3360 {
3361  uint32_t channel;
3362 
3363  /* Get channel from instance */
3364  if (Instance == DFSDM1_Channel0)
3365  {
3366  channel = 0;
3367  }
3368  else if (Instance == DFSDM1_Channel1)
3369  {
3370  channel = 1;
3371  }
3372  else if (Instance == DFSDM1_Channel2)
3373  {
3374  channel = 2;
3375  }
3376  else if (Instance == DFSDM1_Channel3)
3377  {
3378  channel = 3;
3379  }
3380 #if defined(STM32L471xx) || defined(STM32L475xx) || defined(STM32L476xx) || defined(STM32L485xx) || defined(STM32L486xx) || \
3381  defined(STM32L496xx) || defined(STM32L4A6xx) || \
3382  defined(STM32L4R5xx) || defined(STM32L4R7xx) || defined(STM32L4R9xx) || defined(STM32L4S5xx) || defined(STM32L4S7xx) || defined(STM32L4S9xx)
3383  else if (Instance == DFSDM1_Channel4)
3384  {
3385  channel = 4;
3386  }
3387  else if (Instance == DFSDM1_Channel5)
3388  {
3389  channel = 5;
3390  }
3391  else if (Instance == DFSDM1_Channel6)
3392  {
3393  channel = 6;
3394  }
3395  else if (Instance == DFSDM1_Channel7)
3396  {
3397  channel = 7;
3398  }
3399 #endif /* STM32L471xx || STM32L475xx || STM32L476xx || STM32L485xx || STM32L486xx || STM32L496xx || STM32L4A6xx || STM32L4R5xx || STM32L4R7xx || STM32L4R9xx || STM32L4S5xx || STM32L4S7xx || STM32L4S9xx */
3400  else
3401  {
3402  channel = 0;
3403  }
3404 
3405  return channel;
3406 }
3407 
3414 {
3415  /* Check regular trigger */
3416  if (hdfsdm_filter->RegularTrigger == DFSDM_FILTER_SW_TRIGGER)
3417  {
3418  /* Software start of regular conversion */
3419  hdfsdm_filter->Instance->FLTCR1 |= DFSDM_FLTCR1_RSWSTART;
3420  }
3421  else /* synchronous trigger */
3422  {
3423  /* Disable DFSDM filter */
3424  hdfsdm_filter->Instance->FLTCR1 &= ~(DFSDM_FLTCR1_DFEN);
3425 
3426  /* Set RSYNC bit in DFSDM_FLTCR1 register */
3427  hdfsdm_filter->Instance->FLTCR1 |= DFSDM_FLTCR1_RSYNC;
3428 
3429  /* Enable DFSDM filter */
3430  hdfsdm_filter->Instance->FLTCR1 |= DFSDM_FLTCR1_DFEN;
3431 
3432  /* If injected conversion was in progress, restart it */
3433  if (hdfsdm_filter->State == HAL_DFSDM_FILTER_STATE_INJ)
3434  {
3435  if (hdfsdm_filter->InjectedTrigger == DFSDM_FILTER_SW_TRIGGER)
3436  {
3437  hdfsdm_filter->Instance->FLTCR1 |= DFSDM_FLTCR1_JSWSTART;
3438  }
3439  /* Update remaining injected conversions */
3440  hdfsdm_filter->InjConvRemaining = (hdfsdm_filter->InjectedScanMode == ENABLE) ? \
3441  hdfsdm_filter->InjectedChannelsNbr : 1U;
3442  }
3443  }
3444  /* Update DFSDM filter state */
3445  hdfsdm_filter->State = (hdfsdm_filter->State == HAL_DFSDM_FILTER_STATE_READY) ? \
3447 }
3448 
3455 {
3456  /* Disable DFSDM filter */
3457  hdfsdm_filter->Instance->FLTCR1 &= ~(DFSDM_FLTCR1_DFEN);
3458 
3459  /* If regular trigger was synchronous, reset RSYNC bit in DFSDM_FLTCR1 register */
3460  if (hdfsdm_filter->RegularTrigger == DFSDM_FILTER_SYNC_TRIGGER)
3461  {
3462  hdfsdm_filter->Instance->FLTCR1 &= ~(DFSDM_FLTCR1_RSYNC);
3463  }
3464 
3465  /* Enable DFSDM filter */
3466  hdfsdm_filter->Instance->FLTCR1 |= DFSDM_FLTCR1_DFEN;
3467 
3468  /* If injected conversion was in progress, restart it */
3469  if (hdfsdm_filter->State == HAL_DFSDM_FILTER_STATE_REG_INJ)
3470  {
3471  if (hdfsdm_filter->InjectedTrigger == DFSDM_FILTER_SW_TRIGGER)
3472  {
3473  hdfsdm_filter->Instance->FLTCR1 |= DFSDM_FLTCR1_JSWSTART;
3474  }
3475  /* Update remaining injected conversions */
3476  hdfsdm_filter->InjConvRemaining = (hdfsdm_filter->InjectedScanMode == ENABLE) ? \
3477  hdfsdm_filter->InjectedChannelsNbr : 1U;
3478  }
3479 
3480  /* Update DFSDM filter state */
3481  hdfsdm_filter->State = (hdfsdm_filter->State == HAL_DFSDM_FILTER_STATE_REG) ? \
3483 }
3484 
3491 {
3492  /* Check injected trigger */
3493  if (hdfsdm_filter->InjectedTrigger == DFSDM_FILTER_SW_TRIGGER)
3494  {
3495  /* Software start of injected conversion */
3496  hdfsdm_filter->Instance->FLTCR1 |= DFSDM_FLTCR1_JSWSTART;
3497  }
3498  else /* external or synchronous trigger */
3499  {
3500  /* Disable DFSDM filter */
3501  hdfsdm_filter->Instance->FLTCR1 &= ~(DFSDM_FLTCR1_DFEN);
3502 
3503  if (hdfsdm_filter->InjectedTrigger == DFSDM_FILTER_SYNC_TRIGGER)
3504  {
3505  /* Set JSYNC bit in DFSDM_FLTCR1 register */
3506  hdfsdm_filter->Instance->FLTCR1 |= DFSDM_FLTCR1_JSYNC;
3507  }
3508  else /* external trigger */
3509  {
3510  /* Set JEXTEN[1:0] bits in DFSDM_FLTCR1 register */
3511  hdfsdm_filter->Instance->FLTCR1 |= hdfsdm_filter->ExtTriggerEdge;
3512  }
3513 
3514  /* Enable DFSDM filter */
3515  hdfsdm_filter->Instance->FLTCR1 |= DFSDM_FLTCR1_DFEN;
3516 
3517  /* If regular conversion was in progress, restart it */
3518  if ((hdfsdm_filter->State == HAL_DFSDM_FILTER_STATE_REG) && \
3519  (hdfsdm_filter->RegularTrigger == DFSDM_FILTER_SW_TRIGGER))
3520  {
3521  hdfsdm_filter->Instance->FLTCR1 |= DFSDM_FLTCR1_RSWSTART;
3522  }
3523  }
3524  /* Update DFSDM filter state */
3525  hdfsdm_filter->State = (hdfsdm_filter->State == HAL_DFSDM_FILTER_STATE_READY) ? \
3527 }
3528 
3535 {
3536  /* Disable DFSDM filter */
3537  hdfsdm_filter->Instance->FLTCR1 &= ~(DFSDM_FLTCR1_DFEN);
3538 
3539  /* If injected trigger was synchronous, reset JSYNC bit in DFSDM_FLTCR1 register */
3540  if (hdfsdm_filter->InjectedTrigger == DFSDM_FILTER_SYNC_TRIGGER)
3541  {
3542  hdfsdm_filter->Instance->FLTCR1 &= ~(DFSDM_FLTCR1_JSYNC);
3543  }
3544  else if (hdfsdm_filter->InjectedTrigger == DFSDM_FILTER_EXT_TRIGGER)
3545  {
3546  /* Reset JEXTEN[1:0] bits in DFSDM_FLTCR1 register */
3547  hdfsdm_filter->Instance->FLTCR1 &= ~(DFSDM_FLTCR1_JEXTEN);
3548  }
3549  else
3550  {
3551  /* Nothing to do */
3552  }
3553 
3554  /* Enable DFSDM filter */
3555  hdfsdm_filter->Instance->FLTCR1 |= DFSDM_FLTCR1_DFEN;
3556 
3557  /* If regular conversion was in progress, restart it */
3558  if ((hdfsdm_filter->State == HAL_DFSDM_FILTER_STATE_REG_INJ) && \
3559  (hdfsdm_filter->RegularTrigger == DFSDM_FILTER_SW_TRIGGER))
3560  {
3561  hdfsdm_filter->Instance->FLTCR1 |= DFSDM_FLTCR1_RSWSTART;
3562  }
3563 
3564  /* Update remaining injected conversions */
3565  hdfsdm_filter->InjConvRemaining = (hdfsdm_filter->InjectedScanMode == ENABLE) ? \
3566  hdfsdm_filter->InjectedChannelsNbr : 1U;
3567 
3568  /* Update DFSDM filter state */
3569  hdfsdm_filter->State = (hdfsdm_filter->State == HAL_DFSDM_FILTER_STATE_INJ) ? \
3570  HAL_DFSDM_FILTER_STATE_READY : HAL_DFSDM_FILTER_STATE_REG;
3571 }
3572 
3576 /* End of private functions --------------------------------------------------*/
3577 
3582 #endif /* STM32L451xx || STM32L452xx || STM32L462xx || STM32L471xx || STM32L475xx || STM32L476xx || STM32L485xx || STM32L486xx || STM32L496xx || STM32L4A6xx || STM32L4R5xx || STM32L4R7xx || STM32L4R9xx || STM32L4S5xx || STM32L4S7xx || STM32L4S9xx */
3583 
3584 #endif /* HAL_DFSDM_MODULE_ENABLED */
3585 
3590 /************************ (C) COPYRIGHT STMicroelectronics *****END OF FILE****/
HAL_StatusTypeDef HAL_DFSDM_FilterRegularStop(DFSDM_Filter_HandleTypeDef *hdfsdm_filter)
This function allows to stop regular conversion in polling mode.
static DFSDM_Channel_HandleTypeDef * a_dfsdm1ChannelHandle[DFSDM1_CHANNEL_NUMBER]
HAL_DFSDM_Filter_StateTypeDef
HAL DFSDM Filter states definition.
HAL_StatusTypeDef HAL_DFSDM_FilterDeInit(DFSDM_Filter_HandleTypeDef *hdfsdm_filter)
De-initializes the DFSDM filter.
struct __DFSDM_Channel_HandleTypeDef else typedef struct endif DFSDM_Channel_HandleTypeDef
DFSDM channel handle structure definition.
int32_t HAL_DFSDM_FilterGetInjectedValue(DFSDM_Filter_HandleTypeDef *hdfsdm_filter, uint32_t *Channel)
This function allows to get injected conversion value.
HAL_StatusTypeDef HAL_DFSDM_FilterPollForRegConversion(DFSDM_Filter_HandleTypeDef *hdfsdm_filter, uint32_t Timeout)
This function allows to poll for the end of regular conversion.
static void DFSDM_RegConvStop(DFSDM_Filter_HandleTypeDef *hdfsdm_filter)
This function allows to really stop regular conversion.
HAL_StatusTypeDef HAL_DFSDM_Filter_UnRegisterCallback(DFSDM_Filter_HandleTypeDef *hdfsdm_filter, HAL_DFSDM_Filter_CallbackIDTypeDef CallbackID)
Unregister a user DFSDM filter callback. DFSDM filter callback is redirected to the weak predefined c...
static void DFSDM_DMARegularConvCplt(DMA_HandleTypeDef *hdma)
DMA transfer complete callback for regular conversion.
int16_t HAL_DFSDM_ChannelGetAwdValue(DFSDM_Channel_HandleTypeDef *hdfsdm_channel)
This function allows to get channel analog watchdog value.
void HAL_DFSDM_ChannelScdCallback(DFSDM_Channel_HandleTypeDef *hdfsdm_channel)
Short circuit detection callback.
void HAL_DFSDM_FilterErrorCallback(DFSDM_Filter_HandleTypeDef *hdfsdm_filter)
Error callback.
HAL_StatusTypeDef HAL_DFSDM_ChannelScdStop(DFSDM_Channel_HandleTypeDef *hdfsdm_channel)
This function allows to stop short circuit detection in polling mode.
DMA handle Structure definition.
static void DFSDM_DMARegularHalfConvCplt(DMA_HandleTypeDef *hdma)
DMA half transfer complete callback for regular conversion.
int32_t HAL_DFSDM_FilterGetExdMaxValue(DFSDM_Filter_HandleTypeDef *hdfsdm_filter, uint32_t *Channel)
This function allows to get extreme detector maximum value.
HAL_StatusTypeDef HAL_DFSDM_FilterRegularStart_DMA(DFSDM_Filter_HandleTypeDef *hdfsdm_filter, int32_t *pData, uint32_t Length)
This function allows to start regular conversion in DMA mode.
HAL_StatusTypeDef HAL_DFSDM_Filter_RegisterCallback(DFSDM_Filter_HandleTypeDef *hdfsdm_filter, HAL_DFSDM_Filter_CallbackIDTypeDef CallbackID, pDFSDM_Filter_CallbackTypeDef pCallback)
Register a user DFSDM filter callback to be used instead of the weak predefined callback.
This file contains all the functions prototypes for the HAL module driver.
int32_t HAL_DFSDM_FilterGetExdMinValue(DFSDM_Filter_HandleTypeDef *hdfsdm_filter, uint32_t *Channel)
This function allows to get extreme detector minimum value.
HAL_StatusTypeDef HAL_DFSDM_FilterExdStart(DFSDM_Filter_HandleTypeDef *hdfsdm_filter, uint32_t Channel)
This function allows to start extreme detector feature.
void HAL_DFSDM_ChannelMspDeInit(DFSDM_Channel_HandleTypeDef *hdfsdm_channel)
De-initialize the DFSDM channel MSP.
HAL_StatusTypeDef HAL_DFSDM_FilterInjectedStop(DFSDM_Filter_HandleTypeDef *hdfsdm_filter)
This function allows to stop injected conversion in polling mode.
HAL_StatusTypeDef HAL_DFSDM_Channel_UnRegisterCallback(DFSDM_Channel_HandleTypeDef *hdfsdm_channel, HAL_DFSDM_Channel_CallbackIDTypeDef CallbackID)
Unregister a user DFSDM channel callback. DFSDM channel callback is redirected to the weak predefined...
static void DFSDM_DMAError(DMA_HandleTypeDef *hdma)
DMA error callback.
static void DFSDM_InjConvStop(DFSDM_Filter_HandleTypeDef *hdfsdm_filter)
This function allows to really stop injected conversion.
HAL_StatusTypeDef HAL_DFSDM_FilterRegularStop_IT(DFSDM_Filter_HandleTypeDef *hdfsdm_filter)
This function allows to stop regular conversion in interrupt mode.
int32_t HAL_DFSDM_FilterGetRegularValue(DFSDM_Filter_HandleTypeDef *hdfsdm_filter, uint32_t *Channel)
This function allows to get regular conversion value.
HAL_StatusTypeDef HAL_DFSDM_FilterInjectedStart_IT(DFSDM_Filter_HandleTypeDef *hdfsdm_filter)
This function allows to start injected conversion in interrupt mode.
HAL_StatusTypeDef HAL_DFSDM_ChannelScdStop_IT(DFSDM_Channel_HandleTypeDef *hdfsdm_channel)
This function allows to stop short circuit detection in interrupt mode.
uint32_t HAL_GetTick(void)
Provide a tick value in millisecond.
HAL_StatusTypeDef HAL_DFSDM_ChannelCkabStart(DFSDM_Channel_HandleTypeDef *hdfsdm_channel)
This function allows to start clock absence detection in polling mode.
struct __DFSDM_Filter_HandleTypeDef else typedef struct endif DFSDM_Filter_HandleTypeDef
DFSDM filter handle structure definition.
void HAL_DFSDM_FilterRegConvHalfCpltCallback(DFSDM_Filter_HandleTypeDef *hdfsdm_filter)
Half regular conversion complete callback.
HAL_StatusTypeDef HAL_DFSDM_FilterPollForInjConversion(DFSDM_Filter_HandleTypeDef *hdfsdm_filter, uint32_t Timeout)
This function allows to poll for the end of injected conversion.
HAL_DFSDM_Filter_StateTypeDef HAL_DFSDM_FilterGetState(DFSDM_Filter_HandleTypeDef *hdfsdm_filter)
This function allows to get the current DFSDM filter handle state.
static uint32_t DFSDM_GetInjChannelsNbr(uint32_t Channels)
This function allows to get the number of injected channels.
static __IO uint32_t v_dfsdm1ChannelCounter
void HAL_DFSDM_ChannelCkabCallback(DFSDM_Channel_HandleTypeDef *hdfsdm_channel)
Clock absence detection callback.
HAL_StatusTypeDef HAL_DFSDM_FilterRegularStart(DFSDM_Filter_HandleTypeDef *hdfsdm_filter)
This function allows to start regular conversion in polling mode.
HAL_StatusTypeDef HAL_DMA_Start_IT(DMA_HandleTypeDef *hdma, uint32_t SrcAddress, uint32_t DstAddress, uint32_t DataLength)
Start the DMA Transfer with interrupt enabled.
HAL_StatusTypeDef HAL_DFSDM_FilterConfigInjChannel(DFSDM_Filter_HandleTypeDef *hdfsdm_filter, uint32_t Channel)
This function allows to select channels for injected conversion.
HAL_StatusTypeDef HAL_DFSDM_ChannelCkabStop(DFSDM_Channel_HandleTypeDef *hdfsdm_channel)
This function allows to stop clock absence detection in polling mode.
uint32_t HAL_DFSDM_FilterGetError(DFSDM_Filter_HandleTypeDef *hdfsdm_filter)
This function allows to get the current DFSDM filter error.
return HAL_OK
void HAL_DFSDM_FilterRegConvCpltCallback(DFSDM_Filter_HandleTypeDef *hdfsdm_filter)
Regular conversion complete callback.
HAL_StatusTypeDef HAL_DFSDM_FilterInjectedStop_IT(DFSDM_Filter_HandleTypeDef *hdfsdm_filter)
This function allows to stop injected conversion in interrupt mode.
DFSDM filter analog watchdog parameters structure definition.
static void DFSDM_DMAInjectedHalfConvCplt(DMA_HandleTypeDef *hdma)
DMA half transfer complete callback for injected conversion.
HAL_StatusTypeDef HAL_DFSDM_ChannelCkabStart_IT(DFSDM_Channel_HandleTypeDef *hdfsdm_channel)
This function allows to start clock absence detection in interrupt mode.
HAL_StatusTypeDef HAL_DFSDM_FilterAwdStop_IT(DFSDM_Filter_HandleTypeDef *hdfsdm_filter)
This function allows to stop filter analog watchdog in interrupt mode.
void HAL_DFSDM_FilterInjConvHalfCpltCallback(DFSDM_Filter_HandleTypeDef *hdfsdm_filter)
Half injected conversion complete callback.
uint32_t HAL_DFSDM_FilterGetConvTimeValue(DFSDM_Filter_HandleTypeDef *hdfsdm_filter)
This function allows to get conversion time value.
HAL_StatusTypeDef HAL_DFSDM_FilterAwdStart_IT(DFSDM_Filter_HandleTypeDef *hdfsdm_filter, DFSDM_Filter_AwdParamTypeDef *awdParam)
This function allows to start filter analog watchdog in interrupt mode.
HAL_StatusTypeDef HAL_DMA_Abort(DMA_HandleTypeDef *hdma)
Abort the DMA Transfer.
HAL_StatusTypeDef HAL_DFSDM_FilterExdStop(DFSDM_Filter_HandleTypeDef *hdfsdm_filter)
This function allows to stop extreme detector feature.
HAL_StatusTypeDef HAL_DFSDM_ChannelScdStart_IT(DFSDM_Channel_HandleTypeDef *hdfsdm_channel, uint32_t Threshold, uint32_t BreakSignal)
This function allows to start short circuit detection in interrupt mode.
void(* pDFSDM_Filter_AwdCallbackTypeDef)(DFSDM_Filter_HandleTypeDef *hdfsdm_filter, uint32_t Channel, uint32_t Threshold)
HAL_StatusTypeDef HAL_DFSDM_FilterInit(DFSDM_Filter_HandleTypeDef *hdfsdm_filter)
Initialize the DFSDM filter according to the specified parameters in the DFSDM_FilterInitTypeDef stru...
HAL_StatusTypeDef HAL_DFSDM_ChannelPollForScd(DFSDM_Channel_HandleTypeDef *hdfsdm_channel, uint32_t Timeout)
This function allows to poll for the short circuit detection.
void HAL_DFSDM_IRQHandler(DFSDM_Filter_HandleTypeDef *hdfsdm_filter)
This function handles the DFSDM interrupts.
static void DFSDM_RegConvStart(DFSDM_Filter_HandleTypeDef *hdfsdm_filter)
This function allows to really start regular conversion.
HAL_StatusTypeDef HAL_DFSDM_Channel_RegisterCallback(DFSDM_Channel_HandleTypeDef *hdfsdm_channel, HAL_DFSDM_Channel_CallbackIDTypeDef CallbackID, pDFSDM_Channel_CallbackTypeDef pCallback)
Register a user DFSDM channel callback to be used instead of the weak predefined callback.
HAL_DFSDM_Channel_StateTypeDef HAL_DFSDM_ChannelGetState(DFSDM_Channel_HandleTypeDef *hdfsdm_channel)
This function allows to get the current DFSDM channel handle state.
HAL_StatusTypeDef HAL_DFSDM_ChannelPollForCkab(DFSDM_Channel_HandleTypeDef *hdfsdm_channel, uint32_t Timeout)
This function allows to poll for the clock absence detection.
static uint32_t DFSDM_GetChannelFromInstance(const DFSDM_Channel_TypeDef *Instance)
This function allows to get the channel number from channel instance.
void HAL_DFSDM_FilterAwdCallback(DFSDM_Filter_HandleTypeDef *hdfsdm_filter, uint32_t Channel, uint32_t Threshold)
Filter analog watchdog callback.
HAL_StatusTypeDef HAL_DFSDM_FilterInjectedStart(DFSDM_Filter_HandleTypeDef *hdfsdm_filter)
This function allows to start injected conversion in polling mode.
HAL_StatusTypeDef HAL_DFSDM_FilterInjectedMsbStart_DMA(DFSDM_Filter_HandleTypeDef *hdfsdm_filter, int16_t *pData, uint32_t Length)
This function allows to start injected conversion in DMA mode and to get only the 16 most significant...
HAL_StatusTypeDef HAL_DFSDM_ChannelDeInit(DFSDM_Channel_HandleTypeDef *hdfsdm_channel)
De-initialize the DFSDM channel.
void(* pDFSDM_Channel_CallbackTypeDef)(DFSDM_Channel_HandleTypeDef *hdfsdm_channel)
DFSDM channel callback pointer definition.
HAL_StatusTypeDef HAL_DFSDM_FilterInjectedStart_DMA(DFSDM_Filter_HandleTypeDef *hdfsdm_filter, int32_t *pData, uint32_t Length)
This function allows to start injected conversion in DMA mode.
HAL_StatusTypeDef HAL_DFSDM_FilterConfigRegChannel(DFSDM_Filter_HandleTypeDef *hdfsdm_filter, uint32_t Channel, uint32_t ContinuousMode)
This function allows to select channel and to enable/disable continuous mode for regular conversion...
static void DFSDM_DMAInjectedConvCplt(DMA_HandleTypeDef *hdma)
DMA transfer complete callback for injected conversion.
HAL_DFSDM_Channel_StateTypeDef
HAL DFSDM Channel states definition.
void HAL_DFSDM_ChannelMspInit(DFSDM_Channel_HandleTypeDef *hdfsdm_channel)
Initialize the DFSDM channel MSP.
HAL_StatusTypeDef HAL_DFSDM_FilterRegularMsbStart_DMA(DFSDM_Filter_HandleTypeDef *hdfsdm_filter, int16_t *pData, uint32_t Length)
This function allows to start regular conversion in DMA mode and to get only the 16 most significant ...
static void DFSDM_InjConvStart(DFSDM_Filter_HandleTypeDef *hdfsdm_filter)
This function allows to really start injected conversion.
void(* pDFSDM_Filter_CallbackTypeDef)(DFSDM_Filter_HandleTypeDef *hdfsdm_filter)
DFSDM filter callback pointer definition.
HAL_StatusTypeDef HAL_DFSDM_Filter_RegisterAwdCallback(DFSDM_Filter_HandleTypeDef *hdfsdm_filter, pDFSDM_Filter_AwdCallbackTypeDef pCallback)
Register a user DFSDM filter analog watchdog callback to be used instead of the weak predefined callb...
HAL_StatusTypeDef HAL_DFSDM_ChannelCkabStop_IT(DFSDM_Channel_HandleTypeDef *hdfsdm_channel)
This function allows to stop clock absence detection in interrupt mode.
HAL_StatusTypeDef HAL_DFSDM_FilterRegularStop_DMA(DFSDM_Filter_HandleTypeDef *hdfsdm_filter)
This function allows to stop regular conversion in DMA mode.
HAL_StatusTypeDef HAL_DFSDM_ChannelScdStart(DFSDM_Channel_HandleTypeDef *hdfsdm_channel, uint32_t Threshold, uint32_t BreakSignal)
This function allows to start short circuit detection in polling mode.
HAL_StatusTypeDef HAL_DFSDM_Filter_UnRegisterAwdCallback(DFSDM_Filter_HandleTypeDef *hdfsdm_filter)
Unregister a user DFSDM filter analog watchdog callback. DFSDM filter AWD callback is redirected to t...
HAL_StatusTypeDef HAL_DFSDM_ChannelModifyOffset(DFSDM_Channel_HandleTypeDef *hdfsdm_channel, int32_t Offset)
This function allows to modify channel offset value.
HAL_StatusTypeDef HAL_DFSDM_FilterRegularStart_IT(DFSDM_Filter_HandleTypeDef *hdfsdm_filter)
This function allows to start regular conversion in interrupt mode.
HAL_StatusTypeDef HAL_DFSDM_ChannelInit(DFSDM_Channel_HandleTypeDef *hdfsdm_channel)
Initialize the DFSDM channel according to the specified parameters in the DFSDM_ChannelInitTypeDef st...
void HAL_DFSDM_FilterInjConvCpltCallback(DFSDM_Filter_HandleTypeDef *hdfsdm_filter)
Injected conversion complete callback.
void HAL_DFSDM_FilterMspDeInit(DFSDM_Filter_HandleTypeDef *hdfsdm_filter)
De-initializes the DFSDM filter MSP.
void HAL_DFSDM_FilterMspInit(DFSDM_Filter_HandleTypeDef *hdfsdm_filter)
Initializes the DFSDM filter MSP.
assert_param(IS_RTC_WAKEUP_CLOCK(WakeUpClock))
HAL_StatusTypeDef HAL_DFSDM_FilterInjectedStop_DMA(DFSDM_Filter_HandleTypeDef *hdfsdm_filter)
This function allows to stop injected conversion in DMA mode.
HAL_DFSDM_Filter_CallbackIDTypeDef
DFSDM filter callback ID enumeration definition.
HAL_DFSDM_Channel_CallbackIDTypeDef
DFSDM channel callback ID enumeration definition.