STM32L4xx_HAL_Driver  1.14.0
DFSDM Private Functions

Functions

static uint32_t DFSDM_GetInjChannelsNbr (uint32_t Channels)
 This function allows to get the number of injected channels. More...
 
static uint32_t DFSDM_GetChannelFromInstance (const DFSDM_Channel_TypeDef *Instance)
 This function allows to get the channel number from channel instance. More...
 
static void DFSDM_RegConvStart (DFSDM_Filter_HandleTypeDef *hdfsdm_filter)
 This function allows to really start regular conversion. More...
 
static void DFSDM_RegConvStop (DFSDM_Filter_HandleTypeDef *hdfsdm_filter)
 This function allows to really stop regular conversion. More...
 
static void DFSDM_InjConvStart (DFSDM_Filter_HandleTypeDef *hdfsdm_filter)
 This function allows to really start injected conversion. More...
 
static void DFSDM_InjConvStop (DFSDM_Filter_HandleTypeDef *hdfsdm_filter)
 This function allows to really stop injected conversion. More...
 
static void DFSDM_DMARegularHalfConvCplt (DMA_HandleTypeDef *hdma)
 DMA half transfer complete callback for regular conversion. More...
 
static void DFSDM_DMARegularConvCplt (DMA_HandleTypeDef *hdma)
 DMA transfer complete callback for regular conversion. More...
 
static void DFSDM_DMAInjectedHalfConvCplt (DMA_HandleTypeDef *hdma)
 DMA half transfer complete callback for injected conversion. More...
 
static void DFSDM_DMAInjectedConvCplt (DMA_HandleTypeDef *hdma)
 DMA transfer complete callback for injected conversion. More...
 
static void DFSDM_DMAError (DMA_HandleTypeDef *hdma)
 DMA error callback. More...
 

Detailed Description

Function Documentation

◆ DFSDM_DMAError()

static void DFSDM_DMAError ( DMA_HandleTypeDef hdma)
static

DMA error callback.

Parameters
hdmaDMA handle.
Return values
None

Definition at line 3315 of file stm32l4xx_hal_dfsdm.c.

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 }
void HAL_DFSDM_FilterErrorCallback(DFSDM_Filter_HandleTypeDef *hdfsdm_filter)
Error callback.
DMA handle Structure definition.
struct __DFSDM_Filter_HandleTypeDef else typedef struct endif DFSDM_Filter_HandleTypeDef
DFSDM filter handle structure definition.

◆ DFSDM_DMAInjectedConvCplt()

static void DFSDM_DMAInjectedConvCplt ( DMA_HandleTypeDef hdma)
static

DMA transfer complete callback for injected conversion.

Parameters
hdmaDMA handle.
Return values
None

Definition at line 3297 of file stm32l4xx_hal_dfsdm.c.

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 }
DMA handle Structure definition.
struct __DFSDM_Filter_HandleTypeDef else typedef struct endif DFSDM_Filter_HandleTypeDef
DFSDM filter handle structure definition.
void HAL_DFSDM_FilterInjConvCpltCallback(DFSDM_Filter_HandleTypeDef *hdfsdm_filter)
Injected conversion complete callback.

◆ DFSDM_DMAInjectedHalfConvCplt()

static void DFSDM_DMAInjectedHalfConvCplt ( DMA_HandleTypeDef hdma)
static

DMA half transfer complete callback for injected conversion.

Parameters
hdmaDMA handle.
Return values
None

Definition at line 3279 of file stm32l4xx_hal_dfsdm.c.

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 }
DMA handle Structure definition.
struct __DFSDM_Filter_HandleTypeDef else typedef struct endif DFSDM_Filter_HandleTypeDef
DFSDM filter handle structure definition.
void HAL_DFSDM_FilterInjConvHalfCpltCallback(DFSDM_Filter_HandleTypeDef *hdfsdm_filter)
Half injected conversion complete callback.

◆ DFSDM_DMARegularConvCplt()

static void DFSDM_DMARegularConvCplt ( DMA_HandleTypeDef hdma)
static

DMA transfer complete callback for regular conversion.

Parameters
hdmaDMA handle.
Return values
None

Definition at line 3261 of file stm32l4xx_hal_dfsdm.c.

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 }
DMA handle Structure definition.
struct __DFSDM_Filter_HandleTypeDef else typedef struct endif DFSDM_Filter_HandleTypeDef
DFSDM filter handle structure definition.
void HAL_DFSDM_FilterRegConvCpltCallback(DFSDM_Filter_HandleTypeDef *hdfsdm_filter)
Regular conversion complete callback.

◆ DFSDM_DMARegularHalfConvCplt()

static void DFSDM_DMARegularHalfConvCplt ( DMA_HandleTypeDef hdma)
static

DMA half transfer complete callback for regular conversion.

Parameters
hdmaDMA handle.
Return values
None

Definition at line 3243 of file stm32l4xx_hal_dfsdm.c.

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 }
DMA handle Structure definition.
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.

◆ DFSDM_GetChannelFromInstance()

static uint32_t DFSDM_GetChannelFromInstance ( const DFSDM_Channel_TypeDef *  Instance)
static

This function allows to get the channel number from channel instance.

Parameters
InstanceDFSDM channel instance.
Return values
Channelnumber.

Definition at line 3359 of file stm32l4xx_hal_dfsdm.c.

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 }

◆ DFSDM_GetInjChannelsNbr()

static uint32_t DFSDM_GetInjChannelsNbr ( uint32_t  Channels)
static

This function allows to get the number of injected channels.

Parameters
Channelsbitfield of injected channels.
Return values
Numberof injected channels.

Definition at line 3336 of file stm32l4xx_hal_dfsdm.c.

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 }

◆ DFSDM_InjConvStart()

static void DFSDM_InjConvStart ( DFSDM_Filter_HandleTypeDef hdfsdm_filter)
static

This function allows to really start injected conversion.

Parameters
hdfsdm_filterDFSDM filter handle.
Return values
None

Definition at line 3490 of file stm32l4xx_hal_dfsdm.c.

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 }

◆ DFSDM_InjConvStop()

static void DFSDM_InjConvStop ( DFSDM_Filter_HandleTypeDef hdfsdm_filter)
static

This function allows to really stop injected conversion.

Parameters
hdfsdm_filterDFSDM filter handle.
Return values
None

Definition at line 3534 of file stm32l4xx_hal_dfsdm.c.

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 }

◆ DFSDM_RegConvStart()

static void DFSDM_RegConvStart ( DFSDM_Filter_HandleTypeDef hdfsdm_filter)
static

This function allows to really start regular conversion.

Parameters
hdfsdm_filterDFSDM filter handle.
Return values
None

Definition at line 3413 of file stm32l4xx_hal_dfsdm.c.

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 }

◆ DFSDM_RegConvStop()

static void DFSDM_RegConvStop ( DFSDM_Filter_HandleTypeDef hdfsdm_filter)
static

This function allows to really stop regular conversion.

Parameters
hdfsdm_filterDFSDM filter handle.
Return values
None

Definition at line 3454 of file stm32l4xx_hal_dfsdm.c.

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 }