hal_dac_lld.c 4.8 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167
  1. /*
  2. ChibiOS - Copyright (C) 2006..2018 Giovanni Di Sirio
  3. Licensed under the Apache License, Version 2.0 (the "License");
  4. you may not use this file except in compliance with the License.
  5. You may obtain a copy of the License at
  6. http://www.apache.org/licenses/LICENSE-2.0
  7. Unless required by applicable law or agreed to in writing, software
  8. distributed under the License is distributed on an "AS IS" BASIS,
  9. WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
  10. See the License for the specific language governing permissions and
  11. limitations under the License.
  12. */
  13. /**
  14. * @file hal_dac_lld.c
  15. * @brief PLATFORM DAC subsystem low level driver source.
  16. *
  17. * @addtogroup DAC
  18. * @{
  19. */
  20. #include "hal.h"
  21. #if (HAL_USE_DAC == TRUE) || defined(__DOXYGEN__)
  22. /*===========================================================================*/
  23. /* Driver local definitions. */
  24. /*===========================================================================*/
  25. /*===========================================================================*/
  26. /* Driver exported variables. */
  27. /*===========================================================================*/
  28. /** @brief DAC1 driver identifier.*/
  29. #if (PLATFORM_DAC_USE_DAC1 == TRUE) || defined(__DOXYGEN__)
  30. DACDriver DACD1;
  31. #endif
  32. /*===========================================================================*/
  33. /* Driver local variables. */
  34. /*===========================================================================*/
  35. /*===========================================================================*/
  36. /* Driver local functions. */
  37. /*===========================================================================*/
  38. /*===========================================================================*/
  39. /* Driver interrupt handlers. */
  40. /*===========================================================================*/
  41. /*===========================================================================*/
  42. /* Driver exported functions. */
  43. /*===========================================================================*/
  44. /**
  45. * @brief Low level DAC driver initialization.
  46. *
  47. * @notapi
  48. */
  49. void dac_lld_init(void) {
  50. #if PLATFORM_DAC_USE_DAC1 == TRUE
  51. dacObjectInit(&DACD1);
  52. #endif
  53. }
  54. /**
  55. * @brief Configures and activates the DAC peripheral.
  56. *
  57. * @param[in] dacp pointer to the @p DACDriver object
  58. *
  59. * @notapi
  60. */
  61. void dac_lld_start(DACDriver *dacp) {
  62. /* If the driver is in DAC_STOP state then a full initialization is
  63. required.*/
  64. if (dacp->state == DAC_STOP) {
  65. /* Enabling the clock source.*/
  66. #if PLATFORM_DAC_USE_DAC1 == TRUE
  67. if (&DACD1 == dacp) {
  68. }
  69. #endif
  70. }
  71. }
  72. /**
  73. * @brief Deactivates the DAC peripheral.
  74. *
  75. * @param[in] dacp pointer to the @p DACDriver object
  76. *
  77. * @notapi
  78. */
  79. void dac_lld_stop(DACDriver *dacp) {
  80. /* If in ready state then disables the DAC clock.*/
  81. if (dacp->state == DAC_READY) {
  82. #if PLATFORM_DAC_USE_DAC1 == TRUE
  83. if (&DACD1 == dacp) {
  84. }
  85. #endif
  86. }
  87. }
  88. /**
  89. * @brief Outputs a value directly on a DAC channel.
  90. *
  91. * @param[in] dacp pointer to the @p DACDriver object
  92. * @param[in] channel DAC channel number
  93. * @param[in] sample value to be output
  94. *
  95. * @api
  96. */
  97. void dac_lld_put_channel(DACDriver *dacp,
  98. dacchannel_t channel,
  99. dacsample_t sample) {
  100. (void)dacp;
  101. (void)channel;
  102. (void)sample;
  103. }
  104. /**
  105. * @brief Starts a DAC conversion.
  106. * @details Starts an asynchronous conversion operation.
  107. * @note In @p DAC_DHRM_8BIT_RIGHT mode the parameters passed to the
  108. * callback are wrong because two samples are packed in a single
  109. * dacsample_t element. This will not be corrected, do not rely
  110. * on those parameters.
  111. * @note In @p DAC_DHRM_8BIT_RIGHT_DUAL mode two samples are treated
  112. * as a single 16 bits sample and packed into a single dacsample_t
  113. * element. The num_channels must be set to one in the group
  114. * conversion configuration structure.
  115. *
  116. * @param[in] dacp pointer to the @p DACDriver object
  117. *
  118. * @notapi
  119. */
  120. void dac_lld_start_conversion(DACDriver *dacp) {
  121. (void)dacp;
  122. }
  123. /**
  124. * @brief Stops an ongoing conversion.
  125. * @details This function stops the currently ongoing conversion and returns
  126. * the driver in the @p DAC_READY state. If there was no conversion
  127. * being processed then the function does nothing.
  128. *
  129. * @param[in] dacp pointer to the @p DACDriver object
  130. *
  131. * @iclass
  132. */
  133. void dac_lld_stop_conversion(DACDriver *dacp) {
  134. (void)dacp;
  135. }
  136. #endif /* HAL_USE_DAC == TRUE */
  137. /** @} */