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   * <h2><center>&copy; Copyright (c) 2017 STMicroelectronics.
14   * All rights reserved.</center></h2>
15   *
16   * This software component is licensed by ST under BSD 3-Clause license,
17   * the "License"; You may not use this file except in compliance with the
18   * License. You may obtain a copy of the License at:
19   *                        opensource.org/licenses/BSD-3-Clause
20   *
21   ******************************************************************************
22   */
23 
24 /* Includes ------------------------------------------------------------------*/
25 #include "stm32l4xx_hal.h"
26 
27 /** @addtogroup STM32L4xx_HAL_Driver
28   * @{
29   */
30 
31 #ifdef HAL_DFSDM_MODULE_ENABLED
32 
33 #if defined(STM32L4R5xx) || defined(STM32L4R7xx) || defined(STM32L4R9xx) || defined(STM32L4S5xx) || defined(STM32L4S7xx) || defined(STM32L4S9xx) || \
34     defined(STM32L4P5xx) || defined(STM32L4Q5xx)
35 
36 /** @defgroup DFSDMEx DFSDMEx
37   * @brief DFSDM Extended HAL module driver
38   * @{
39   */
40 
41 /* Private types -------------------------------------------------------------*/
42 /* Private variables ---------------------------------------------------------*/
43 /* Private constants ---------------------------------------------------------*/
44 /* Private macros ------------------------------------------------------------*/
45 /* Private functions ---------------------------------------------------------*/
46 /* Exported functions --------------------------------------------------------*/
47 
48 /** @defgroup DFSDMEx_Exported_Functions DFSDM Extended Exported Functions
49   * @{
50   */
51 
52 /** @defgroup DFSDMEx_Exported_Functions_Group1_Channel Extended channel operation functions
53   * @brief    DFSDM extended channel operation functions
54  *
55 @verbatim
56  ===============================================================================
57                ##### Extended channel operation functions #####
58  ===============================================================================
59     [..]  This section provides functions allowing to:
60       (+) Set and get value of pulses skipping on channel
61 
62 @endverbatim
63   * @{
64   */
65 
66 /**
67   * @brief  Set value of pulses skipping.
68   * @param  hdfsdm_channel DFSDM channel handle.
69   * @param  PulsesValue Value of pulses to be skipped.
70   *         This parameter must be a number between Min_Data = 0 and Max_Data = 63.
71   * @retval HAL status.
72   */
HAL_DFDSMEx_ChannelSetPulsesSkipping(DFSDM_Channel_HandleTypeDef * hdfsdm_channel,uint32_t PulsesValue)73 HAL_StatusTypeDef HAL_DFDSMEx_ChannelSetPulsesSkipping(DFSDM_Channel_HandleTypeDef *hdfsdm_channel, uint32_t PulsesValue)
74 {
75   HAL_StatusTypeDef status = HAL_OK;
76 
77   /* Check pulses value */
78   assert_param(IS_DFSDM_CHANNEL_SKIPPING_VALUE(PulsesValue));
79 
80   /* Check DFSDM channel state */
81   if (hdfsdm_channel->State == HAL_DFSDM_CHANNEL_STATE_READY)
82   {
83     /* Set new value of pulses skipping */
84     hdfsdm_channel->Instance->CHDLYR = (PulsesValue & DFSDM_CHDLYR_PLSSKP);
85   }
86   else
87   {
88     status = HAL_ERROR;
89   }
90   return status;
91 }
92 
93 /**
94   * @brief  Get value of pulses skipping.
95   * @param  hdfsdm_channel DFSDM channel handle.
96   * @param  PulsesValue Value of pulses to be skipped.
97   * @retval HAL status.
98   */
HAL_DFDSMEx_ChannelGetPulsesSkipping(DFSDM_Channel_HandleTypeDef * hdfsdm_channel,uint32_t * PulsesValue)99 HAL_StatusTypeDef HAL_DFDSMEx_ChannelGetPulsesSkipping(DFSDM_Channel_HandleTypeDef *hdfsdm_channel, uint32_t *PulsesValue)
100 {
101   HAL_StatusTypeDef status = HAL_OK;
102 
103   /* Check DFSDM channel state */
104   if (hdfsdm_channel->State == HAL_DFSDM_CHANNEL_STATE_READY)
105   {
106     /* Get value of remaining pulses to be skipped */
107     *PulsesValue = (hdfsdm_channel->Instance->CHDLYR & DFSDM_CHDLYR_PLSSKP);
108   }
109   else
110   {
111     status = HAL_ERROR;
112   }
113   return status;
114 }
115 
116 /**
117   * @}
118   */
119 
120 /**
121   * @}
122   */
123 
124 /**
125   * @}
126   */
127 
128 #endif /* STM32L4R5xx || STM32L4R7xx || STM32L4R9xx || STM32L4S5xx || STM32L4S7xx || STM32L4S9xx || STM32L4P5xx || STM32L4Q5xx */
129 
130 #endif /* HAL_DFSDM_MODULE_ENABLED */
131 
132 /**
133   * @}
134   */
135 
136 /************************ (C) COPYRIGHT STMicroelectronics *****END OF FILE****/
137