analogout_api.h 2.3 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293
  1. /** \addtogroup hal */
  2. /** @{*/
  3. /* mbed Microcontroller Library
  4. * Copyright (c) 2006-2013 ARM Limited
  5. *
  6. * Licensed under the Apache License, Version 2.0 (the "License");
  7. * you may not use this file except in compliance with the License.
  8. * You may obtain a copy of the License at
  9. *
  10. * http://www.apache.org/licenses/LICENSE-2.0
  11. *
  12. * Unless required by applicable law or agreed to in writing, software
  13. * distributed under the License is distributed on an "AS IS" BASIS,
  14. * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
  15. * See the License for the specific language governing permissions and
  16. * limitations under the License.
  17. */
  18. #ifndef MBED_ANALOGOUT_API_H
  19. #define MBED_ANALOGOUT_API_H
  20. #include "device.h"
  21. #if DEVICE_ANALOGOUT
  22. #ifdef __cplusplus
  23. extern "C" {
  24. #endif
  25. /** Analogout hal structure. dac_s is declared in the target's hal
  26. */
  27. typedef struct dac_s dac_t;
  28. /**
  29. * \defgroup hal_analogout Analogout hal functions
  30. * @{
  31. */
  32. /** Initialize the analogout peripheral
  33. *
  34. * Configures the pin used by analogout.
  35. * @param obj The analogout object to initialize
  36. * @param pin The analogout pin name
  37. */
  38. void analogout_init(dac_t *obj, PinName pin);
  39. /** Release the analogout object
  40. *
  41. * Note: This is not currently used in the mbed-drivers
  42. * @param obj The analogout object
  43. */
  44. void analogout_free(dac_t *obj);
  45. /** Set the output voltage, specified as a percentage (float)
  46. *
  47. * @param obj The analogin object
  48. * @param value The floating-point output voltage to be set
  49. */
  50. void analogout_write(dac_t *obj, float value);
  51. /** Set the output voltage, specified as unsigned 16-bit
  52. *
  53. * @param obj The analogin object
  54. * @param value The unsigned 16-bit output voltage to be set
  55. */
  56. void analogout_write_u16(dac_t *obj, uint16_t value);
  57. /** Read the current voltage value on the pin
  58. *
  59. * @param obj The analogin object
  60. * @return A floating-point value representing the current voltage on the pin,
  61. * measured as a percentage
  62. */
  63. float analogout_read(dac_t *obj);
  64. /** Read the current voltage value on the pin, as a normalized unsigned 16bit value
  65. *
  66. * @param obj The analogin object
  67. * @return An unsigned 16-bit value representing the current voltage on the pin
  68. */
  69. uint16_t analogout_read_u16(dac_t *obj);
  70. /**@}*/
  71. #ifdef __cplusplus
  72. }
  73. #endif
  74. #endif
  75. #endif
  76. /** @}*/