1 /**
2   ******************************************************************************
3   * @file    stm32l4xx_hal_dfsdm_ex.c
4   * @author  MCD Application Team
5   * @brief   DFSDM Extended HAL module driver.
6   *          This file provides firmware functions to manage the following
7   *          functionality of the DFSDM Peripheral Controller:
8   *           + Set and get pulses skipping on channel.
9   *
10   ******************************************************************************
11   * @attention
12   *
13   * Copyright (c) 2017 STMicroelectronics.
14   * All rights reserved.
15   *
16   * This software is licensed under terms that can be found in the LICENSE file
17   * in the root directory of this software component.
18   * If no LICENSE file comes with this software, it is provided AS-IS.
19   *
20   ******************************************************************************
21   */
22 
23 /* Includes ------------------------------------------------------------------*/
24 #include "stm32l4xx_hal.h"
25 
26 /** @addtogroup STM32L4xx_HAL_Driver
27   * @{
28   */
29 
30 #ifdef HAL_DFSDM_MODULE_ENABLED
31 
32 #if defined(STM32L4R5xx) || defined(STM32L4R7xx) || defined(STM32L4R9xx) || defined(STM32L4S5xx) || defined(STM32L4S7xx) || defined(STM32L4S9xx) || \
33     defined(STM32L4P5xx) || defined(STM32L4Q5xx)
34 
35 /** @defgroup DFSDMEx DFSDMEx
36   * @brief DFSDM Extended HAL module driver
37   * @{
38   */
39 
40 /* Private types -------------------------------------------------------------*/
41 /* Private variables ---------------------------------------------------------*/
42 /* Private constants ---------------------------------------------------------*/
43 /* Private macros ------------------------------------------------------------*/
44 /* Private functions ---------------------------------------------------------*/
45 /* Exported functions --------------------------------------------------------*/
46 
47 /** @defgroup DFSDMEx_Exported_Functions DFSDM Extended Exported Functions
48   * @{
49   */
50 
51 /** @defgroup DFSDMEx_Exported_Functions_Group1_Channel Extended channel operation functions
52   * @brief    DFSDM extended channel operation functions
53  *
54 @verbatim
55  ===============================================================================
56                ##### Extended channel operation functions #####
57  ===============================================================================
58     [..]  This section provides functions allowing to:
59       (+) Set and get value of pulses skipping on channel
60 
61 @endverbatim
62   * @{
63   */
64 
65 /**
66   * @brief  Set value of pulses skipping.
67   * @param  hdfsdm_channel DFSDM channel handle.
68   * @param  PulsesValue Value of pulses to be skipped.
69   *         This parameter must be a number between Min_Data = 0 and Max_Data = 63.
70   * @retval HAL status.
71   */
HAL_DFDSMEx_ChannelSetPulsesSkipping(DFSDM_Channel_HandleTypeDef * hdfsdm_channel,uint32_t PulsesValue)72 HAL_StatusTypeDef HAL_DFDSMEx_ChannelSetPulsesSkipping(DFSDM_Channel_HandleTypeDef *hdfsdm_channel, uint32_t PulsesValue)
73 {
74   HAL_StatusTypeDef status = HAL_OK;
75 
76   /* Check pulses value */
77   assert_param(IS_DFSDM_CHANNEL_SKIPPING_VALUE(PulsesValue));
78 
79   /* Check DFSDM channel state */
80   if (hdfsdm_channel->State == HAL_DFSDM_CHANNEL_STATE_READY)
81   {
82     /* Set new value of pulses skipping */
83     hdfsdm_channel->Instance->CHDLYR = (PulsesValue & DFSDM_CHDLYR_PLSSKP);
84   }
85   else
86   {
87     status = HAL_ERROR;
88   }
89   return status;
90 }
91 
92 /**
93   * @brief  Get value of pulses skipping.
94   * @param  hdfsdm_channel DFSDM channel handle.
95   * @param  PulsesValue Value of pulses to be skipped.
96   * @retval HAL status.
97   */
HAL_DFDSMEx_ChannelGetPulsesSkipping(const DFSDM_Channel_HandleTypeDef * hdfsdm_channel,uint32_t * PulsesValue)98 HAL_StatusTypeDef HAL_DFDSMEx_ChannelGetPulsesSkipping(const DFSDM_Channel_HandleTypeDef *hdfsdm_channel, uint32_t *PulsesValue)
99 {
100   HAL_StatusTypeDef status = HAL_OK;
101 
102   /* Check DFSDM channel state */
103   if (hdfsdm_channel->State == HAL_DFSDM_CHANNEL_STATE_READY)
104   {
105     /* Get value of remaining pulses to be skipped */
106     *PulsesValue = (hdfsdm_channel->Instance->CHDLYR & DFSDM_CHDLYR_PLSSKP);
107   }
108   else
109   {
110     status = HAL_ERROR;
111   }
112   return status;
113 }
114 
115 /**
116   * @}
117   */
118 
119 /**
120   * @}
121   */
122 
123 /**
124   * @}
125   */
126 
127 #endif /* STM32L4R5xx || STM32L4R7xx || STM32L4R9xx || STM32L4S5xx || STM32L4S7xx || STM32L4S9xx || STM32L4P5xx || STM32L4Q5xx */
128 
129 #endif /* HAL_DFSDM_MODULE_ENABLED */
130 
131 /**
132   * @}
133   */
134