You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

181 lines
7.4 KiB

5 years ago
  1. /*******************************************************************************
  2. *
  3. * structure.c
  4. *
  5. * Copyright (C) 2011 Texas Instruments Incorporated - http://www.ti.com/
  6. *
  7. * Redistribution and use in source and binary forms, with or without
  8. * modification, are permitted provided that the following conditions
  9. * are met:
  10. *
  11. * Redistributions of source code must retain the above copyright
  12. * notice, this list of conditions and the following disclaimer.
  13. *
  14. * Redistributions in binary form must reproduce the above copyright
  15. * notice, this list of conditions and the following disclaimer in the
  16. * documentation and/or other materials provided with the
  17. * distribution.
  18. *
  19. * Neither the name of Texas Instruments Incorporated nor the names of
  20. * its contributors may be used to endorse or promote products derived
  21. * from this software without specific prior written permission.
  22. *
  23. * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
  24. * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
  25. * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
  26. * A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
  27. * OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
  28. * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
  29. * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
  30. * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
  31. * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
  32. * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
  33. * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
  34. *
  35. *
  36. ******************************************************************************/
  37. //******************************************************************************
  38. // structure.c
  39. //
  40. // 4 elements configured as a wheel.
  41. // 1 element configured as a button. [Center Button]
  42. // 1 element configured as a proximity sensor.
  43. // This file contains the structure names and the variable assingments.
  44. //
  45. // Revision 1.00 Baseline
  46. // Developed with IAR 5.10.4 [Kickstart] (5.10.4.30168)
  47. //
  48. // 09/24/10 Rev1.00 Pre-Alpha Version. Added "max_cnts" slider variable in
  49. // CT_Handler object.
  50. //
  51. // 09/29/10 0.02 Update naming convention for elements and sensors.
  52. //
  53. // 10/11/10 0.03 Update
  54. //
  55. //******************************************************************************
  56. #include "structure.h"
  57. //PinOsc Volume down P2.2
  58. const struct Element volume_down = {
  59. .inputPxselRegister = (uint8_t *)&P2SEL,
  60. .inputPxsel2Register = (uint8_t *)&P2SEL2,
  61. .inputBits = BIT2,
  62. // measured for a 1Mhz SMCLK
  63. .maxResponse = 121+655, // actual measure was 980
  64. .threshold = 121
  65. };
  66. //PinOsc forward right P2.3
  67. const struct Element right = {
  68. .inputPxselRegister = (uint8_t *)&P2SEL,
  69. .inputPxsel2Register = (uint8_t *)&P2SEL2,
  70. .inputBits = BIT3,
  71. // 1Mhz SMCLK
  72. .maxResponse = 113+655,
  73. .threshold = 113
  74. };
  75. //PinOsc Volume up, P2.4
  76. const struct Element volume_up = {
  77. .inputPxselRegister = (uint8_t *)&P2SEL,
  78. .inputPxsel2Register = (uint8_t *)&P2SEL2,
  79. .inputBits = BIT4,
  80. // 1Mhz SMCLK
  81. .maxResponse = 118+655,
  82. .threshold = 118
  83. };
  84. //PinOsc reverse left P2.1
  85. const struct Element left = {
  86. .inputPxselRegister = (uint8_t *)&P2SEL,
  87. .inputPxsel2Register = (uint8_t *)&P2SEL2,
  88. .inputBits = BIT1,
  89. // 1Mhz SMCLK
  90. .maxResponse = 111+655,
  91. .threshold = 111
  92. };
  93. //PinOsc Wheel: middle button P2.5
  94. const struct Element middle_element = {
  95. .inputPxselRegister = (uint8_t *)&P2SEL,
  96. .inputPxsel2Register = (uint8_t *)&P2SEL2,
  97. .inputBits = BIT5,
  98. // When using an abstracted function to measure the element
  99. // the 100*(maxResponse - threshold) < 0xFFFF
  100. // ie maxResponse - threshold < 655
  101. .maxResponse = 350+655,
  102. .threshold = 350
  103. };
  104. //PinOsc proximity: P2.0
  105. const struct Element proximity_element = {
  106. .inputPxselRegister = (uint8_t *)&P2SEL,
  107. .inputPxsel2Register = (uint8_t *)&P2SEL2,
  108. .inputBits = BIT0,
  109. .maxResponse = 200,
  110. .threshold = 130
  111. };
  112. //*** CAP TOUCH HANDLER *******************************************************/
  113. // This defines the grouping of sensors, the method to measure change in
  114. // capacitance, and the function of the group
  115. const struct Sensor wheel =
  116. {
  117. //.halDefinition = fRO_PINOSC_TA0_SW,
  118. .halDefinition = RO_PINOSC_TA0_WDTp,
  119. .numElements = 4,
  120. .points = 64,
  121. .sensorThreshold = 75,
  122. .baseOffset = 0,
  123. // Pointer to elements
  124. .arrayPtr[0] = &volume_up, // point to first element
  125. .arrayPtr[1] = &right,
  126. .arrayPtr[2] = &volume_down,
  127. .arrayPtr[3] = &left,
  128. // Timer Information
  129. //.measGateSource= GATE_WDT_SMCLK, // 0->SMCLK, 1-> ACLK
  130. //.accumulationCycles= WDTp_GATE_32768 //32768
  131. .accumulationCycles= WDTp_GATE_8192 // 8192
  132. //.accumulationCycles= WDTp_GATE_512 //512
  133. //.accumulationCycles= WDTp_GATE_64 //64
  134. //.accumulationCycles = 32
  135. };
  136. const struct Sensor middle_button =
  137. {
  138. .halDefinition = RO_PINOSC_TA0_WDTp,
  139. .numElements = 1,
  140. .baseOffset = 4,
  141. // Pointer to elements
  142. .arrayPtr[0] = &middle_element, // point to first element
  143. // Timer Information
  144. .measGateSource= GATE_WDT_SMCLK, // 0->SMCLK, 1-> ACLK
  145. //.accumulationCycles= WDTp_GATE_32768 //32768
  146. .accumulationCycles= WDTp_GATE_8192 // 8192
  147. //.accumulationCycles= WDTp_GATE_512 //512
  148. //.accumulationCycles= WDTp_GATE_64 //64
  149. };
  150. const struct Sensor proximity_sensor =
  151. {
  152. .halDefinition = RO_PINOSC_TA0_WDTp,
  153. .numElements = 1,
  154. .baseOffset = 5,
  155. // Pointer to elements
  156. .arrayPtr[0] = &proximity_element, // point to first element
  157. // Timer Information
  158. .measGateSource= GATE_WDT_SMCLK, // 0->SMCLK, 1-> ACLK
  159. //.accumulationCycles= WDTp_GATE_32768 //32768
  160. .accumulationCycles= WDTp_GATE_8192 // 8192
  161. //.accumulationCycles= WDTp_GATE_512 //512
  162. //.accumulationCycles= WDTp_GATE_64 //64
  163. };