analogin_api.h 1.7 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071
  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_ANALOGIN_API_H
  19. #define MBED_ANALOGIN_API_H
  20. #include "device.h"
  21. #if DEVICE_ANALOGIN
  22. #ifdef __cplusplus
  23. extern "C" {
  24. #endif
  25. /** Analogin hal structure. analogin_s is declared in the target's hal
  26. */
  27. typedef struct analogin_s analogin_t;
  28. /**
  29. * \defgroup hal_analogin Analogin hal functions
  30. * @{
  31. */
  32. /** Initialize the analogin peripheral
  33. *
  34. * Configures the pin used by analogin.
  35. * @param obj The analogin object to initialize
  36. * @param pin The analogin pin name
  37. */
  38. void analogin_init(analogin_t *obj, PinName pin);
  39. /** Read the input voltage, represented as a float in the range [0.0, 1.0]
  40. *
  41. * @param obj The analogin object
  42. * @return A floating value representing the current input voltage
  43. */
  44. float analogin_read(analogin_t *obj);
  45. /** Read the value from analogin pin, represented as an unsigned 16bit value
  46. *
  47. * @param obj The analogin object
  48. * @return An unsigned 16bit value representing the current input voltage
  49. */
  50. uint16_t analogin_read_u16(analogin_t *obj);
  51. /**@}*/
  52. #ifdef __cplusplus
  53. }
  54. #endif
  55. #endif
  56. #endif
  57. /** @}*/