hal_adc.h 5.9 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142
  1. /**************************************************************************************************
  2. Filename: hal_adc.h
  3. Revised: $Date: 2010-02-25 15:22:29 -0800 (Thu, 25 Feb 2010) $
  4. Revision: $Revision: 21800 $
  5. Description: This file contains the interface to the ADC Service.
  6. Copyright 2005-2010 Texas Instruments Incorporated. All rights reserved.
  7. IMPORTANT: Your use of this Software is limited to those specific rights
  8. granted under the terms of a software license agreement between the user
  9. who downloaded the software, his/her employer (which must be your employer)
  10. and Texas Instruments Incorporated (the "License"). You may not use this
  11. Software unless you agree to abide by the terms of the License. The License
  12. limits your use, and you acknowledge, that the Software may not be modified,
  13. copied or distributed unless embedded on a Texas Instruments microcontroller
  14. or used solely and exclusively in conjunction with a Texas Instruments radio
  15. frequency transceiver, which is integrated into your product. Other than for
  16. the foregoing purpose, you may not use, reproduce, copy, prepare derivative
  17. works of, modify, distribute, perform, display or sell this Software and/or
  18. its documentation for any purpose.
  19. YOU FURTHER ACKNOWLEDGE AND AGREE THAT THE SOFTWARE AND DOCUMENTATION ARE
  20. PROVIDED “AS IS” WITHOUT WARRANTY OF ANY KIND, EITHER EXPRESS OR IMPLIED,
  21. INCLUDING WITHOUT LIMITATION, ANY WARRANTY OF MERCHANTABILITY, TITLE,
  22. NON-INFRINGEMENT AND FITNESS FOR A PARTICULAR PURPOSE. IN NO EVENT SHALL
  23. TEXAS INSTRUMENTS OR ITS LICENSORS BE LIABLE OR OBLIGATED UNDER CONTRACT,
  24. NEGLIGENCE, STRICT LIABILITY, CONTRIBUTION, BREACH OF WARRANTY, OR OTHER
  25. LEGAL EQUITABLE THEORY ANY DIRECT OR INDIRECT DAMAGES OR EXPENSES
  26. INCLUDING BUT NOT LIMITED TO ANY INCIDENTAL, SPECIAL, INDIRECT, PUNITIVE
  27. OR CONSEQUENTIAL DAMAGES, LOST PROFITS OR LOST DATA, COST OF PROCUREMENT
  28. OF SUBSTITUTE GOODS, TECHNOLOGY, SERVICES, OR ANY CLAIMS BY THIRD PARTIES
  29. (INCLUDING BUT NOT LIMITED TO ANY DEFENSE THEREOF), OR OTHER SIMILAR COSTS.
  30. Should you have any questions regarding your right to use this Software,
  31. contact Texas Instruments Incorporated at www.TI.com.
  32. **************************************************************************************************/
  33. #ifndef HAL_ADC_H
  34. #define HAL_ADC_H
  35. #ifdef __cplusplus
  36. extern "C"
  37. {
  38. #endif
  39. /**************************************************************************************************
  40. * INCLUDES
  41. **************************************************************************************************/
  42. #include "hal_board.h"
  43. /**************************************************************************************************
  44. * CONSTANTS
  45. **************************************************************************************************/
  46. /* Resolution */
  47. #define HAL_ADC_RESOLUTION_8 0x01
  48. #define HAL_ADC_RESOLUTION_10 0x02
  49. #define HAL_ADC_RESOLUTION_12 0x03
  50. #define HAL_ADC_RESOLUTION_14 0x04
  51. /* Channels */
  52. #define HAL_ADC_CHANNEL_0 0x00
  53. #define HAL_ADC_CHANNEL_1 0x01
  54. #define HAL_ADC_CHANNEL_2 0x02
  55. #define HAL_ADC_CHANNEL_3 0x03
  56. #define HAL_ADC_CHANNEL_4 0x04
  57. #define HAL_ADC_CHANNEL_5 0x05
  58. #define HAL_ADC_CHANNEL_6 0x06
  59. #define HAL_ADC_CHANNEL_7 0x07
  60. #define HAL_ADC_CHN_AIN0 0x00 /* AIN0 */
  61. #define HAL_ADC_CHN_AIN1 0x01 /* AIN1 */
  62. #define HAL_ADC_CHN_AIN2 0x02 /* AIN2 */
  63. #define HAL_ADC_CHN_AIN3 0x03 /* AIN3 */
  64. #define HAL_ADC_CHN_AIN4 0x04 /* AIN4 */
  65. #define HAL_ADC_CHN_AIN5 0x05 /* AIN5 */
  66. #define HAL_ADC_CHN_AIN6 0x06 /* AIN6 */
  67. #define HAL_ADC_CHN_AIN7 0x07 /* AIN7 */
  68. #define HAL_ADC_CHN_A0A1 0x08 /* AIN0,AIN1 */
  69. #define HAL_ADC_CHN_A2A3 0x09 /* AIN2,AIN3 */
  70. #define HAL_ADC_CHN_A4A5 0x0a /* AIN4,AIN5 */
  71. #define HAL_ADC_CHN_A6A7 0x0b /* AIN6,AIN7 */
  72. #define HAL_ADC_CHN_GND 0x0c /* GND */
  73. #define HAL_ADC_CHN_VREF 0x0d /* Positive voltage reference */
  74. #define HAL_ADC_CHN_TEMP 0x0e /* Temperature sensor */
  75. #define HAL_ADC_CHN_VDD3 0x0f /* VDD/3 */
  76. #define HAL_ADC_CHN_BITS 0x0f /* Bits [3:0] */
  77. #define HAL_ADC_CHANNEL_TEMP HAL_ADC_CHN_TEMP
  78. #define HAL_ADC_CHANNEL_VDD HAL_ADC_CHN_VDD3 /* channel VDD divided by 3 */
  79. /* Vdd Limits */
  80. #define HAL_ADC_VDD_LIMIT_0 0x00
  81. #define HAL_ADC_VDD_LIMIT_1 0x01
  82. #define HAL_ADC_VDD_LIMIT_2 0x02
  83. #define HAL_ADC_VDD_LIMIT_3 0x03
  84. #define HAL_ADC_VDD_LIMIT_4 0x04
  85. #define HAL_ADC_VDD_LIMIT_5 0x05
  86. #define HAL_ADC_VDD_LIMIT_6 0x06
  87. #define HAL_ADC_VDD_LIMIT_7 0x07
  88. /* Reference Voltages */
  89. #define HAL_ADC_REF_125V 0x00 /* Internal Reference (1.25V-CC2430)(1.15V-CC2530) */
  90. #define HAL_ADC_REF_AIN7 0x40 /* AIN7 Reference */
  91. #define HAL_ADC_REF_AVDD 0x80 /* AVDD_SOC Pin Reference */
  92. #define HAL_ADC_REF_DIFF 0xc0 /* AIN7,AIN6 Differential Reference */
  93. #define HAL_ADC_REF_BITS 0xc0 /* Bits [7:6] */
  94. /**************************************************************************************************
  95. * FUNCTIONS - API
  96. **************************************************************************************************/
  97. /*
  98. * Initialize ADC Service with reference set to default value
  99. */
  100. extern void HalAdcInit ( void );
  101. /*
  102. * Read value from a specified ADC Channel at the given resolution
  103. */
  104. extern uint16 HalAdcRead ( uint8 channel, uint8 resolution );
  105. /*
  106. * Set the reference voltage for the ADC
  107. */
  108. extern void HalAdcSetReference ( uint8 reference );
  109. /*
  110. * Check for minimum Vdd specified.
  111. */
  112. extern bool HalAdcCheckVdd(uint8 vdd);
  113. /**************************************************************************************************
  114. **************************************************************************************************/
  115. #ifdef __cplusplus
  116. }
  117. #endif
  118. #endif