stm32l4xx_hal_dfsdm_ex.c 4.0 KB

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