hw_soc_adc.h 16 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267
  1. /******************************************************************************
  2. * Filename: hw_soc_adc.h
  3. * Revised: $Date: 2013-04-30 17:13:44 +0200 (Tue, 30 Apr 2013) $
  4. * Revision: $Revision: 9943 $
  5. *
  6. * Copyright (C) 2013 Texas Instruments Incorporated - http://www.ti.com/
  7. *
  8. *
  9. * Redistribution and use in source and binary forms, with or without
  10. * modification, are permitted provided that the following conditions
  11. * are met:
  12. *
  13. * Redistributions of source code must retain the above copyright
  14. * notice, this list of conditions and the following disclaimer.
  15. *
  16. * Redistributions in binary form must reproduce the above copyright
  17. * notice, this list of conditions and the following disclaimer in the
  18. * documentation and/or other materials provided with the distribution.
  19. *
  20. * Neither the name of Texas Instruments Incorporated nor the names of
  21. * its contributors may be used to endorse or promote products derived
  22. * from this software without specific prior written permission.
  23. *
  24. * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
  25. * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
  26. * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
  27. * A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
  28. * OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
  29. * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
  30. * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
  31. * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
  32. * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
  33. * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
  34. * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
  35. *
  36. ******************************************************************************/
  37. #ifndef __HW_SOC_ADC_H__
  38. #define __HW_SOC_ADC_H__
  39. //*****************************************************************************
  40. //
  41. // The following are defines for the SOC_ADC register offsets.
  42. //
  43. //*****************************************************************************
  44. #define SOC_ADC_ADCCON1 0x400D7000 // This register controls the ADC.
  45. #define SOC_ADC_ADCCON2 0x400D7004 // This register controls the ADC.
  46. #define SOC_ADC_ADCCON3 0x400D7008 // This register controls the ADC.
  47. #define SOC_ADC_ADCL 0x400D700C // This register contains the
  48. // least-significant part of ADC
  49. // conversion result.
  50. #define SOC_ADC_ADCH 0x400D7010 // This register contains the
  51. // most-significant part of ADC
  52. // conversion result.
  53. #define SOC_ADC_RNDL 0x400D7014 // This registers contains
  54. // random-number-generator data;
  55. // low byte.
  56. #define SOC_ADC_RNDH 0x400D7018 // This register contains
  57. // random-number-generator data;
  58. // high byte.
  59. #define SOC_ADC_CMPCTL 0x400D7024 // Analog comparator control and
  60. // status register.
  61. //*****************************************************************************
  62. //
  63. // The following are defines for the bit fields in the
  64. // SOC_ADC_ADCCON1 register.
  65. //
  66. //*****************************************************************************
  67. #define SOC_ADC_ADCCON1_EOC 0x00000080 // End of conversion. Cleared when
  68. // ADCH has been read. If a new
  69. // conversion is completed before
  70. // the previous data has been read,
  71. // the EOC bit remains high. 0:
  72. // Conversion not complete 1:
  73. // Conversion completed
  74. #define SOC_ADC_ADCCON1_EOC_M 0x00000080
  75. #define SOC_ADC_ADCCON1_EOC_S 7
  76. #define SOC_ADC_ADCCON1_ST 0x00000040 // Start conversion Read as 1
  77. // until conversion completes 0: No
  78. // conversion in progress. 1: Start
  79. // a conversion sequence if
  80. // ADCCON1.STSEL = 11 and no
  81. // sequence is running.
  82. #define SOC_ADC_ADCCON1_ST_M 0x00000040
  83. #define SOC_ADC_ADCCON1_ST_S 6
  84. #define SOC_ADC_ADCCON1_STSEL_M 0x00000030 // Start select Selects the event
  85. // that starts a new conversion
  86. // sequence 00: Not implemented 01:
  87. // Full speed. Do not wait for
  88. // triggers 10: Timer 1 channel 0
  89. // compare event 11: ADCCON1.ST = 1
  90. #define SOC_ADC_ADCCON1_STSEL_S 4
  91. #define SOC_ADC_ADCCON1_RCTRL_M 0x0000000C // Controls the 16-bit
  92. // random-number generator (see
  93. // User Guide Chapter 16) When 01
  94. // is written, the setting
  95. // automatically returns to 00 when
  96. // the operation completes. 00:
  97. // Normal operation (13x unrolling)
  98. // 01: Clock the LFSR once (13x
  99. // unrolling) 10: Reserved 11:
  100. // Stopped. The random-number
  101. // generator is turned off.
  102. #define SOC_ADC_ADCCON1_RCTRL_S 2
  103. //*****************************************************************************
  104. //
  105. // The following are defines for the bit fields in the
  106. // SOC_ADC_ADCCON2 register.
  107. //
  108. //*****************************************************************************
  109. #define SOC_ADC_ADCCON2_SREF_M 0x000000C0 // Selects reference voltage used
  110. // for the sequence of conversions
  111. // 00: Internal reference 01:
  112. // External reference on AIN7 pin
  113. // 10: AVDD5 pin 11: External
  114. // reference on AIN6-AIN7
  115. // differential input
  116. #define SOC_ADC_ADCCON2_SREF_S 6
  117. #define SOC_ADC_ADCCON2_SDIV_M 0x00000030 // Sets the decimation rate for
  118. // channels included in the
  119. // sequence of conversions. The
  120. // decimation rate also determines
  121. // the resolution and time required
  122. // to complete a conversion. 00: 64
  123. // decimation rate (7 bits ENOB
  124. // setting) 01: 128 decimation rate
  125. // (9 bits ENOB setting) 10: 256
  126. // decimation rate (10 bits ENOB
  127. // setting) 11: 512 decimation rate
  128. // (12 bits ENOB setting)
  129. #define SOC_ADC_ADCCON2_SDIV_S 4
  130. #define SOC_ADC_ADCCON2_SCH_M 0x0000000F // Sequence channel select Selects
  131. // the end of the sequence A
  132. // sequence can either be from AIN0
  133. // to AIN7 (SCH <= 7) or from
  134. // differential input AIN0-AIN1 to
  135. // AIN6-AIN7 (8 <= SCH <= 11). For
  136. // other settings, only one
  137. // conversions is performed. When
  138. // read, these bits indicate the
  139. // channel number on which a
  140. // conversion is ongoing: 0000:
  141. // AIN0 0001: AIN1 0010: AIN2 0011:
  142. // AIN3 0100: AIN4 0101: AIN5 0110:
  143. // AIN6 0111: AIN7 1000: AIN0-AIN1
  144. // 1001: AIN2-AIN3 1010: AIN4-AIN5
  145. // 1011: AIN6-AIN7 1100: GND 1101:
  146. // Reserved 1110: Temperature
  147. // sensor 1111: VDD/3
  148. #define SOC_ADC_ADCCON2_SCH_S 0
  149. //*****************************************************************************
  150. //
  151. // The following are defines for the bit fields in the
  152. // SOC_ADC_ADCCON3 register.
  153. //
  154. //*****************************************************************************
  155. #define SOC_ADC_ADCCON3_EREF_M 0x000000C0 // Selects reference voltage used
  156. // for the extra conversion 00:
  157. // Internal reference 01: External
  158. // reference on AIN7 pin 10: AVDD5
  159. // pin 11: External reference on
  160. // AIN6-AIN7 differential input
  161. #define SOC_ADC_ADCCON3_EREF_S 6
  162. #define SOC_ADC_ADCCON3_EDIV_M 0x00000030 // Sets the decimation rate used
  163. // for the extra conversion The
  164. // decimation rate also determines
  165. // the resolution and the time
  166. // required to complete the
  167. // conversion. 00: 64 decimation
  168. // rate (7 bits ENOB) 01: 128
  169. // decimation rate (9 bits ENOB)
  170. // 10: 256 decimation rate (10 bits
  171. // ENOB) 11: 512 decimation rate
  172. // (12 bits ENOB)
  173. #define SOC_ADC_ADCCON3_EDIV_S 4
  174. #define SOC_ADC_ADCCON3_ECH_M 0x0000000F // Single channel select. Selects
  175. // the channel number of the single
  176. // conversion that is triggered by
  177. // writing to ADCCON3. 0000: AIN0
  178. // 0001: AIN1 0010: AIN2 0011: AIN3
  179. // 0100: AIN4 0101: AIN5 0110: AIN6
  180. // 0111: AIN7 1000: AIN0-AIN1 1001:
  181. // AIN2-AIN3 1010: AIN4-AIN5 1011:
  182. // AIN6-AIN7 1100: GND 1101:
  183. // Reserved 1110: Temperature
  184. // sensor 1111: VDD/3
  185. #define SOC_ADC_ADCCON3_ECH_S 0
  186. //*****************************************************************************
  187. //
  188. // The following are defines for the bit fields in the SOC_ADC_ADCL register.
  189. //
  190. //*****************************************************************************
  191. #define SOC_ADC_ADCL_ADC_M 0x000000FC // Least-significant part of ADC
  192. // conversion result
  193. #define SOC_ADC_ADCL_ADC_S 2
  194. //*****************************************************************************
  195. //
  196. // The following are defines for the bit fields in the SOC_ADC_ADCH register.
  197. //
  198. //*****************************************************************************
  199. #define SOC_ADC_ADCH_ADC_M 0x000000FF // Most-significant part of ADC
  200. // conversion result
  201. #define SOC_ADC_ADCH_ADC_S 0
  202. //*****************************************************************************
  203. //
  204. // The following are defines for the bit fields in the SOC_ADC_RNDL register.
  205. //
  206. //*****************************************************************************
  207. #define SOC_ADC_RNDL_RNDL_M 0x000000FF // Random value/seed or CRC
  208. // result, low byte When used for
  209. // random-number generation,
  210. // writing to this register twice
  211. // seeds the random-number
  212. // generator. Writing to this
  213. // register copies the 8 LSBs of
  214. // the LFSR to the 8 MSBs and
  215. // replaces the 8 LSBs with the
  216. // data value written. The value
  217. // returned when reading from this
  218. // register is the 8 LSBs of the
  219. // LFSR. When used for
  220. // random-number generation,
  221. // reading this register returns
  222. // the 8 LSBs of the random number.
  223. // When used for CRC calculations,
  224. // reading this register returns
  225. // the 8 LSBs of the CRC result.
  226. #define SOC_ADC_RNDL_RNDL_S 0
  227. //*****************************************************************************
  228. //
  229. // The following are defines for the bit fields in the SOC_ADC_RNDH register.
  230. //
  231. //*****************************************************************************
  232. #define SOC_ADC_RNDH_RNDH_M 0x000000FF // Random value or CRC
  233. // result/input data, high byte
  234. // When written, a CRC16
  235. // calculation is triggered, and
  236. // the data value written is
  237. // processed starting with the MSB.
  238. // The value returned when reading
  239. // from this register is the 8 MSBs
  240. // of the LFSR. When used for
  241. // random-number generation,
  242. // reading this register returns
  243. // the 8 MSBs of the random number.
  244. // When used for CRC calculations,
  245. // reading this register returns
  246. // the 8 MSBs of the CRC result.
  247. #define SOC_ADC_RNDH_RNDH_S 0
  248. //*****************************************************************************
  249. //
  250. // The following are defines for the bit fields in the
  251. // SOC_ADC_CMPCTL register.
  252. //
  253. //*****************************************************************************
  254. #define SOC_ADC_CMPCTL_EN 0x00000002 // Comparator enable
  255. #define SOC_ADC_CMPCTL_EN_M 0x00000002
  256. #define SOC_ADC_CMPCTL_EN_S 1
  257. #define SOC_ADC_CMPCTL_OUTPUT 0x00000001 // Comparator output
  258. #define SOC_ADC_CMPCTL_OUTPUT_M 0x00000001
  259. #define SOC_ADC_CMPCTL_OUTPUT_S 0
  260. #endif // __HW_SOC_ADC_H__