hal_dac_lld.h 4.5 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138
  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.h
  15. * @brief PLATFORM DAC subsystem low level driver header.
  16. *
  17. * @addtogroup DAC
  18. * @{
  19. */
  20. #ifndef HAL_DAC_LLD_H
  21. #define HAL_DAC_LLD_H
  22. #if (HAL_USE_DAC == TRUE) || defined(__DOXYGEN__)
  23. /*===========================================================================*/
  24. /* Driver constants. */
  25. /*===========================================================================*/
  26. /**
  27. * @brief Maximum number of DAC channels per unit.
  28. */
  29. #define DAC_MAX_CHANNELS 2
  30. /*===========================================================================*/
  31. /* Driver pre-compile time settings. */
  32. /*===========================================================================*/
  33. /**
  34. * @name Configuration options
  35. * @{
  36. */
  37. /**
  38. * @brief DAC1 CH1 driver enable switch.
  39. * @details If set to @p TRUE the support for DAC1 channel 1 is included.
  40. * @note The default is @p FALSE.
  41. */
  42. #if !defined(PLATFORM_DAC_USE_DAC1) || defined(__DOXYGEN__)
  43. #define PLATFORM_DAC_USE_DAC1 FALSE
  44. #endif
  45. /** @} */
  46. /*===========================================================================*/
  47. /* Derived constants and error checks. */
  48. /*===========================================================================*/
  49. /*===========================================================================*/
  50. /* Driver data structures and types. */
  51. /*===========================================================================*/
  52. /**
  53. * @brief Type of a DAC channel index.
  54. */
  55. typedef uint32_t dacchannel_t;
  56. /**
  57. * @brief Type representing a DAC sample.
  58. */
  59. typedef uint16_t dacsample_t;
  60. /**
  61. * @brief Possible DAC failure causes.
  62. * @note Error codes are architecture dependent and should not relied
  63. * upon.
  64. */
  65. typedef enum {
  66. DAC_ERR_DMAFAILURE = 0, /**< DMA operations failure. */
  67. DAC_ERR_UNDERFLOW = 1 /**< DAC overflow condition. */
  68. } dacerror_t;
  69. /*===========================================================================*/
  70. /* Driver macros. */
  71. /*===========================================================================*/
  72. /**
  73. * @brief Low level fields of the DAC driver structure.
  74. */
  75. #define dac_lld_driver_fields \
  76. /* Dummy field, it is not needed.*/ \
  77. uint32_t dummy
  78. /**
  79. * @brief Low level fields of the DAC configuration structure.
  80. */
  81. #define dac_lld_config_fields \
  82. /* Dummy configuration, it is not needed.*/ \
  83. uint32_t dummy
  84. /**
  85. * @brief Low level fields of the DAC group configuration structure.
  86. */
  87. #define dac_lld_conversion_group_fields \
  88. /* Dummy configuration, it is not needed.*/ \
  89. uint32_t dummy
  90. /*===========================================================================*/
  91. /* External declarations. */
  92. /*===========================================================================*/
  93. #if (PLATFORM_DAC_USE_DAC1 == TRUE) && !defined(__DOXYGEN__)
  94. extern DACDriver DACD1;
  95. #endif
  96. #ifdef __cplusplus
  97. extern "C" {
  98. #endif
  99. void dac_lld_init(void);
  100. void dac_lld_start(DACDriver *dacp);
  101. void dac_lld_stop(DACDriver *dacp);
  102. void dac_lld_put_channel(DACDriver *dacp,
  103. dacchannel_t channel,
  104. dacsample_t sample);
  105. void dac_lld_start_conversion(DACDriver *dacp);
  106. void dac_lld_stop_conversion(DACDriver *dacp);
  107. #ifdef __cplusplus
  108. }
  109. #endif
  110. #endif /* HAL_USE_DAC == TRUE */
  111. #endif /* HAL_DAC_LLD_H */
  112. /** @} */