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>© COPYRIGHT(c) 2017 STMicroelectronics</center></h2>
14 *
15 * Redistribution and use in source and binary forms, with or without modification,
16 * are permitted provided that the following conditions are met:
17 * 1. Redistributions of source code must retain the above copyright notice,
18 * this list of conditions and the following disclaimer.
19 * 2. Redistributions in binary form must reproduce the above copyright notice,
20 * this list of conditions and the following disclaimer in the documentation
21 * and/or other materials provided with the distribution.
22 * 3. Neither the name of STMicroelectronics nor the names of its contributors
23 * may be used to endorse or promote products derived from this software
24 * without specific prior written permission.
25 *
26 * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
27 * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
28 * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
29 * DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE
30 * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
31 * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR
32 * SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER
33 * CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY,
34 * OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
35 * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
36 *
37 ******************************************************************************
38 */
39
40 /* Includes ------------------------------------------------------------------*/
41 #include "stm32l4xx_hal.h"
42
43 /** @addtogroup STM32L4xx_HAL_Driver
44 * @{
45 */
46
47 #ifdef HAL_DFSDM_MODULE_ENABLED
48
49 #if defined(STM32L4R5xx) || defined(STM32L4R7xx) || defined(STM32L4R9xx) || defined(STM32L4S5xx) || defined(STM32L4S7xx) || defined(STM32L4S9xx)
50
51 /** @defgroup DFSDMEx DFSDMEx
52 * @brief DFSDM Extended HAL module driver
53 * @{
54 */
55
56 /* Private types -------------------------------------------------------------*/
57 /* Private variables ---------------------------------------------------------*/
58 /* Private constants ---------------------------------------------------------*/
59 /* Private macros ------------------------------------------------------------*/
60 /* Private functions ---------------------------------------------------------*/
61 /* Exported functions --------------------------------------------------------*/
62
63 /** @defgroup DFSDMEx_Exported_Functions DFSDM Extended Exported Functions
64 * @{
65 */
66
67 /** @defgroup DFSDMEx_Exported_Functions_Group1_Channel Extended channel operation functions
68 * @brief DFSDM extended channel operation functions
69 *
70 @verbatim
71 ===============================================================================
72 ##### Extended channel operation functions #####
73 ===============================================================================
74 [..] This section provides functions allowing to:
75 (+) Set and get value of pulses skipping on channel
76
77 @endverbatim
78 * @{
79 */
80
81 /**
82 * @brief Set value of pulses skipping.
83 * @param hdfsdm_channel DFSDM channel handle.
84 * @param PulsesValue Value of pulses to be skipped.
85 * This parameter must be a number between Min_Data = 0 and Max_Data = 63.
86 * @retval HAL status.
87 */
HAL_DFDSMEx_ChannelSetPulsesSkipping(DFSDM_Channel_HandleTypeDef * hdfsdm_channel,uint32_t PulsesValue)88 HAL_StatusTypeDef HAL_DFDSMEx_ChannelSetPulsesSkipping(DFSDM_Channel_HandleTypeDef *hdfsdm_channel, uint32_t PulsesValue)
89 {
90 HAL_StatusTypeDef status = HAL_OK;
91
92 /* Check pulses value */
93 assert_param(IS_DFSDM_CHANNEL_SKIPPING_VALUE(PulsesValue));
94
95 /* Check DFSDM channel state */
96 if (hdfsdm_channel->State == HAL_DFSDM_CHANNEL_STATE_READY)
97 {
98 /* Set new value of pulses skipping */
99 hdfsdm_channel->Instance->CHDLYR = (PulsesValue & DFSDM_CHDLYR_PLSSKP);
100 }
101 else
102 {
103 status = HAL_ERROR;
104 }
105 return status;
106 }
107
108 /**
109 * @brief Get value of pulses skipping.
110 * @param hdfsdm_channel DFSDM channel handle.
111 * @param PulsesValue Value of pulses to be skipped.
112 * @retval HAL status.
113 */
HAL_DFDSMEx_ChannelGetPulsesSkipping(DFSDM_Channel_HandleTypeDef * hdfsdm_channel,uint32_t * PulsesValue)114 HAL_StatusTypeDef HAL_DFDSMEx_ChannelGetPulsesSkipping(DFSDM_Channel_HandleTypeDef *hdfsdm_channel, uint32_t *PulsesValue)
115 {
116 HAL_StatusTypeDef status = HAL_OK;
117
118 /* Check DFSDM channel state */
119 if (hdfsdm_channel->State == HAL_DFSDM_CHANNEL_STATE_READY)
120 {
121 /* Get value of remaining pulses to be skipped */
122 *PulsesValue = (hdfsdm_channel->Instance->CHDLYR & DFSDM_CHDLYR_PLSSKP);
123 }
124 else
125 {
126 status = HAL_ERROR;
127 }
128 return status;
129 }
130
131 /**
132 * @}
133 */
134
135 /**
136 * @}
137 */
138
139 /**
140 * @}
141 */
142
143 #endif /* STM32L4R5xx || STM32L4R7xx || STM32L4R9xx || STM32L4S5xx || STM32L4S7xx || STM32L4S9xx */
144
145 #endif /* HAL_DFSDM_MODULE_ENABLED */
146
147 /**
148 * @}
149 */
150
151 /************************ (C) COPYRIGHT STMicroelectronics *****END OF FILE****/
152