stm32l4xx_hal_dfsdm_ex.c 5.5 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151
  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</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. /* Includes ------------------------------------------------------------------*/
  40. #include "stm32l4xx_hal.h"
  41. /** @addtogroup STM32L4xx_HAL_Driver
  42. * @{
  43. */
  44. #ifdef HAL_DFSDM_MODULE_ENABLED
  45. #if defined(STM32L4R5xx) || defined(STM32L4R7xx) || defined(STM32L4R9xx) || defined(STM32L4S5xx) || defined(STM32L4S7xx) || defined(STM32L4S9xx)
  46. /** @defgroup DFSDMEx DFSDMEx
  47. * @brief DFSDM Extended HAL module driver
  48. * @{
  49. */
  50. /* Private types -------------------------------------------------------------*/
  51. /* Private variables ---------------------------------------------------------*/
  52. /* Private constants ---------------------------------------------------------*/
  53. /* Private macros ------------------------------------------------------------*/
  54. /* Private functions ---------------------------------------------------------*/
  55. /* Exported functions --------------------------------------------------------*/
  56. /** @defgroup DFSDMEx_Exported_Functions DFSDM Extended Exported Functions
  57. * @{
  58. */
  59. /** @defgroup DFSDMEx_Exported_Functions_Group1_Channel Extended channel operation functions
  60. * @brief DFSDM extended channel operation functions
  61. *
  62. @verbatim
  63. ===============================================================================
  64. ##### Extended channel operation functions #####
  65. ===============================================================================
  66. [..] This section provides functions allowing to:
  67. (+) Set and get value of pulses skipping on channel
  68. @endverbatim
  69. * @{
  70. */
  71. /**
  72. * @brief Set value of pulses skipping.
  73. * @param hdfsdm_channel DFSDM channel handle.
  74. * @param PulsesValue Value of pulses to be skipped.
  75. * This parameter must be a number between Min_Data = 0 and Max_Data = 63.
  76. * @retval HAL status.
  77. */
  78. HAL_StatusTypeDef HAL_DFDSMEx_ChannelSetPulsesSkipping(DFSDM_Channel_HandleTypeDef *hdfsdm_channel, uint32_t PulsesValue)
  79. {
  80. HAL_StatusTypeDef status = HAL_OK;
  81. /* Check pulses value */
  82. assert_param(IS_DFSDM_CHANNEL_SKIPPING_VALUE(PulsesValue));
  83. /* Check DFSDM channel state */
  84. if(hdfsdm_channel->State == HAL_DFSDM_CHANNEL_STATE_READY)
  85. {
  86. /* Set new value of pulses skipping */
  87. hdfsdm_channel->Instance->CHDLYR = (PulsesValue & DFSDM_CHDLYR_PLSSKP);
  88. }
  89. else
  90. {
  91. status = HAL_ERROR;
  92. }
  93. return status;
  94. }
  95. /**
  96. * @brief Get value of pulses skipping.
  97. * @param hdfsdm_channel DFSDM channel handle.
  98. * @param PulsesValue Value of pulses to be skipped.
  99. * @retval HAL status.
  100. */
  101. HAL_StatusTypeDef HAL_DFDSMEx_ChannelGetPulsesSkipping(DFSDM_Channel_HandleTypeDef *hdfsdm_channel, uint32_t *PulsesValue)
  102. {
  103. HAL_StatusTypeDef status = HAL_OK;
  104. /* Check DFSDM channel state */
  105. if(hdfsdm_channel->State == HAL_DFSDM_CHANNEL_STATE_READY)
  106. {
  107. /* Get value of remaining pulses to be skipped */
  108. *PulsesValue = (hdfsdm_channel->Instance->CHDLYR & DFSDM_CHDLYR_PLSSKP);
  109. }
  110. else
  111. {
  112. status = HAL_ERROR;
  113. }
  114. return status;
  115. }
  116. /**
  117. * @}
  118. */
  119. /**
  120. * @}
  121. */
  122. /**
  123. * @}
  124. */
  125. #endif /* STM32L4R5xx || STM32L4R7xx || STM32L4R9xx || STM32L4S5xx || STM32L4S7xx || STM32L4S9xx */
  126. #endif /* HAL_DFSDM_MODULE_ENABLED */
  127. /**
  128. * @}
  129. */
  130. /************************ (C) COPYRIGHT STMicroelectronics *****END OF FILE****/