fsl_tsc.h 23 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548
  1. /*
  2. * The Clear BSD License
  3. * Copyright (c) 2016, Freescale Semiconductor, Inc.
  4. * Copyright 2016-2017 NXP
  5. * All rights reserved.
  6. *
  7. * Redistribution and use in source and binary forms, with or without modification,
  8. * are permitted (subject to the limitations in the disclaimer below) provided
  9. * that the following conditions are met:
  10. *
  11. * o Redistributions of source code must retain the above copyright notice, this list
  12. * of conditions and the following disclaimer.
  13. *
  14. * o Redistributions in binary form must reproduce the above copyright notice, this
  15. * list of conditions and the following disclaimer in the documentation and/or
  16. * other materials provided with the distribution.
  17. *
  18. * o Neither the name of the copyright holder nor the names of its
  19. * contributors may be used to endorse or promote products derived from this
  20. * software without specific prior written permission.
  21. *
  22. * NO EXPRESS OR IMPLIED LICENSES TO ANY PARTY'S PATENT RIGHTS ARE GRANTED BY THIS LICENSE.
  23. * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND
  24. * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
  25. * WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
  26. * DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE FOR
  27. * ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
  28. * (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
  29. * LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON
  30. * ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
  31. * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
  32. * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
  33. */
  34. #ifndef _FSL_TSC_H_
  35. #define _FSL_TSC_H_
  36. #include "fsl_common.h"
  37. /*!
  38. * @addtogroup tsc
  39. * @{
  40. */
  41. /*******************************************************************************
  42. * Definitions
  43. ******************************************************************************/
  44. /*! @brief TSC driver version */
  45. #define FSL_TSC_DRIVER_VERSION (MAKE_VERSION(2, 0, 0)) /*!< Version 2.0.0. */
  46. /*!
  47. * @ Controller detection mode.
  48. */
  49. typedef enum _tsc_detection_mode
  50. {
  51. kTSC_Detection4WireMode = 0U, /*!< 4-Wire Detection Mode. */
  52. kTSC_Detection5WireMode = 1U, /*!< 5-Wire Detection Mode. */
  53. } tsc_detection_mode_t;
  54. /*!
  55. * @ Coordinate value mask.
  56. */
  57. typedef enum _tsc_corrdinate_value_selection
  58. {
  59. kTSC_XCoordinateValueSelection = 0U, /*!< X coordinate value is selected. */
  60. kTSC_YCoordinateValueSelection = 1U, /*!< Y coordinate value is selected. */
  61. } tsc_corrdinate_value_selection_t;
  62. /*!
  63. * @ Interrupt signal enable/disable mask.
  64. */
  65. enum _tsc_interrupt_signal_mask
  66. {
  67. kTSC_IdleSoftwareSignalEnable = TSC_INT_SIG_EN_IDLE_SW_SIG_EN_MASK, /*!< Enable the interrupt signal when the
  68. controller has return to idle status.
  69. The signal is only valid after using
  70. TSC_ReturnToIdleStatus API. */
  71. kTSC_ValidSignalEnable =
  72. TSC_INT_SIG_EN_VALID_SIG_EN_MASK, /*!< Enable the interrupt signal when controller receives a detect signal
  73. after measurement. */
  74. kTSC_DetectSignalEnable =
  75. TSC_INT_SIG_EN_DETECT_SIG_EN_MASK, /*!< Enable the interrupt signal when controller receives a detect signal. */
  76. kTSC_MeasureSignalEnable = TSC_INT_SIG_EN_MEASURE_SIG_EN_MASK, /*!< Enable the interrupt signal after the touch
  77. detection which follows measurement. */
  78. };
  79. /*!
  80. * @ Interrupt enable/disable mask.
  81. */
  82. enum _tsc_interrupt_mask
  83. {
  84. kTSC_IdleSoftwareInterruptEnable =
  85. TSC_INT_EN_IDLE_SW_INT_EN_MASK, /*!< Enable the interrupt when the controller has return to idle status.
  86. The interrupt is only valid after using TSC_ReturnToIdleStatus API. */
  87. kTSC_DetectInterruptEnable =
  88. TSC_INT_EN_DETECT_INT_EN_MASK, /*!< Enable the interrupt when controller receive a detect signal. */
  89. kTSC_MeasureInterruptEnable = TSC_INT_EN_MEASURE_INT_EN_MASK, /*!< Enable the interrupt after the touch detection
  90. which follows measurement. */
  91. };
  92. /*!
  93. * @ Interrupt Status flag mask.
  94. */
  95. enum _tsc_interrupt_status_flag_mask
  96. {
  97. kTSC_IdleSoftwareFlag =
  98. TSC_INT_STATUS_IDLE_SW_MASK, /*!< This flag is set if the controller has return to idle status.
  99. The flag is only valid after using TSC_ReturnToIdleStatus API. */
  100. kTSC_ValidSignalFlag =
  101. TSC_INT_STATUS_VALID_MASK, /*!< This flag is set if controller receives a detect signal after measurement. */
  102. kTSC_DetectSignalFlag = TSC_INT_STATUS_DETECT_MASK, /*!< This flag is set if controller receives a detect signal. */
  103. kTSC_MeasureSignalFlag =
  104. TSC_INT_STATUS_MEASURE_MASK, /*!< This flag is set after the touch detection which follows measurement.
  105. Note: Valid signal falg will be cleared along with measure signal flag. */
  106. };
  107. /*!
  108. * @ ADC status flag mask.
  109. */
  110. enum _tsc_adc_status_flag_mask
  111. {
  112. kTSC_ADCCOCOSignalFlag =
  113. TSC_DEBUG_MODE_ADC_COCO_MASK, /*!< This signal is generated by ADC when a conversion is completed. */
  114. kTSC_ADCConversionValueFlag =
  115. TSC_DEBUG_MODE_ADC_CONV_VALUE_MASK, /*!< This signal is generated by ADC and indicates the result of an ADC
  116. conversion. */
  117. };
  118. /*!
  119. * @ TSC status flag mask.
  120. */
  121. enum _tsc_status_flag_mask
  122. {
  123. kTSC_IntermediateStateFlag = TSC_DEBUG_MODE2_INTERMEDIATE_MASK, /*!< This flag is set if TSC is in intermediate
  124. state, between two state machine states. */
  125. kTSC_DetectFiveWireFlag = TSC_DEBUG_MODE2_DETECT_FIVE_WIRE_MASK, /*!< This flag is set if TSC receives a 5-wire
  126. detect signal. It is only valid when the TSC in
  127. detect state and DETECT_ENABLE_FIVE_WIRE bit is
  128. set. */
  129. kTSC_DetectFourWireFlag = TSC_DEBUG_MODE2_DETECT_FOUR_WIRE_MASK, /*!< This flag is set if TSC receives a 4-wire
  130. detect signal. It is only valid when the TSC in
  131. detect state and DETECT_ENABLE_FOUR_WIRE bit is
  132. set. */
  133. kTSC_GlitchThresholdFlag = TSC_DEBUG_MODE2_DE_GLITCH_MASK, /*!< This field indicates glitch threshold.The threshold
  134. is defined by number of clock cycles. See
  135. "tsc_glitch_threshold_t".
  136. If value = 00, Normal function: 0x1fff ipg clock
  137. cycles, Low power mode: 0x9 low power clock cycles.
  138. If value = 01, Normal function: 0xfff ipg clock
  139. cycles, Low power mode: :0x7 low power clock cycles.
  140. If value = 10, Normal function: 0x7ff ipg clock
  141. cycles, Low power mode:0x5 low power clock cycles.
  142. If value = 11, Normal function: 0x3 ipg clock
  143. cycles, Low power mode:0x3 low power clock cycles. */
  144. kTSC_StateMachineFlag =
  145. TSC_DEBUG_MODE2_STATE_MACHINE_MASK, /*!< This field indicates the state of TSC. See "tsc_state_machine_t";
  146. if value = 000, Controller is in idle state.
  147. if value = 001, Controller is in 1st-Pre-charge state.
  148. if value = 010, Controller is in 1st-detect state.
  149. if value = 011, Controller is in x-measure state.
  150. if value = 100, Controller is in y-measure state.
  151. if value = 101, Controller is in 2nd-Pre-charge state.
  152. if value = 110, Controller is in 2nd-detect state. */
  153. };
  154. /*!
  155. * @brief TSC state machine. These seven states are TSC complete workflow.
  156. */
  157. typedef enum _tsc_state_machine
  158. {
  159. kTSC_IdleState = 0U << TSC_DEBUG_MODE2_STATE_MACHINE_SHIFT, /*!< Controller is in idle state. */
  160. kTSC_1stPreChargeState = 1U << TSC_DEBUG_MODE2_STATE_MACHINE_SHIFT, /*!< Controller is in 1st-Pre-charge state. */
  161. kTSC_1stDetectState = 2U << TSC_DEBUG_MODE2_STATE_MACHINE_SHIFT, /*!< Controller is in 1st-detect state. */
  162. kTSC_XMeasureState = 3U << TSC_DEBUG_MODE2_STATE_MACHINE_SHIFT, /*!< Controller is in x-measure state. */
  163. kTSC_YMeasureState = 4U << TSC_DEBUG_MODE2_STATE_MACHINE_SHIFT, /*!< Controller is in y-measure state. */
  164. kTSC_2ndPreChargeState = 5U << TSC_DEBUG_MODE2_STATE_MACHINE_SHIFT, /*!< Controller is in 2nd-Pre-charge state. */
  165. kTSC_2ndDetectState = 6U << TSC_DEBUG_MODE2_STATE_MACHINE_SHIFT, /*!< Controller is in 2nd-detect state. */
  166. } tsc_state_machine_t;
  167. /*!
  168. * @brief TSC glitch threshold.
  169. */
  170. typedef enum _tsc_glitch_threshold
  171. {
  172. kTSC_glitchThresholdALT0 =
  173. 0U << TSC_DEBUG_MODE2_DE_GLITCH_SHIFT, /*!< Normal function: 0x1fff ipg clock cycles, Low power mode: 0x9 low
  174. power clock cycles. */
  175. kTSC_glitchThresholdALT1 =
  176. 1U << TSC_DEBUG_MODE2_DE_GLITCH_SHIFT, /*!< Normal function: 0xfff ipg clock cycles, Low power mode: :0x7 low
  177. power clock cycles. */
  178. kTSC_glitchThresholdALT2 =
  179. 2U << TSC_DEBUG_MODE2_DE_GLITCH_SHIFT, /*!< Normal function: 0x7ff ipg clock cycles, Low power mode: :0x5 low
  180. power clock cycles. */
  181. kTSC_glitchThresholdALT3 =
  182. 3U << TSC_DEBUG_MODE2_DE_GLITCH_SHIFT, /*!< Normal function: 0x3 ipg clock cycles, Low
  183. power mode: :0x3 low power clock cycles. */
  184. } tsc_glitch_threshold_t;
  185. /*!
  186. * @ Hardware trigger select signal, select which ADC channel to start conversion.
  187. */
  188. typedef enum _tsc_trigger_signal
  189. {
  190. kTSC_TriggerToChannel0 = 1U << 0U, /*!< Trigger to ADC channel0. ADC_HC0 register will be used to conversion. */
  191. kTSC_TriggerToChannel1 = 1U << 1U, /*!< Trigger to ADC channel1. ADC_HC1 register will be used to conversion. */
  192. kTSC_TriggerToChannel2 = 1U << 2U, /*!< Trigger to ADC channel2. ADC_HC2 register will be used to conversion. */
  193. kTSC_TriggerToChannel3 = 1U << 3U, /*!< Trigger to ADC channel3. ADC_HC3 register will be used to conversion. */
  194. kTSC_TriggerToChannel4 = 1U << 4U, /*!< Trigger to ADC channel4. ADC_HC4 register will be used to conversion. */
  195. } tsc_trigger_signal_t;
  196. /*!
  197. * @ TSC controller ports.
  198. */
  199. typedef enum _tsc_port_source
  200. {
  201. kTSC_WiperPortSource = 0U, /*!< TSC controller wiper port. */
  202. kTSC_YnlrPortSource = 1U, /*!< TSC controller ynlr port. */
  203. kTSC_YpllPortSource = 2U, /*!< TSC controller ypll port. */
  204. kTSC_XnurPortSource = 3U, /*!< TSC controller xnur port. */
  205. kTSC_XpulPortSource = 4U, /*!< TSC controller xpul port. */
  206. } tsc_port_source_t;
  207. /*!
  208. * @ TSC port mode.
  209. */
  210. typedef enum _tsc_port_mode
  211. {
  212. kTSC_PortOffMode = 0U, /*!< Disable pull up/down mode. */
  213. kTSC_Port200k_PullUpMode = 1U << 2U, /*!< 200k-pull up mode. */
  214. kTSC_PortPullUpMode = 1U << 1U, /*!< Pull up mode. */
  215. kTSC_PortPullDownMode = 1U << 0U, /*!< Pull down mode. */
  216. } tsc_port_mode_t;
  217. /*!
  218. * @ Controller configuration.
  219. */
  220. typedef struct _tsc_config
  221. {
  222. bool enableAutoMeasure; /*!< Enable the auto-measure. It indicates after detect touch, whether automatic start
  223. measurement */
  224. uint32_t measureDelayTime; /*!< Set delay time(0U~0xFFFFFFU) to even potential distribution ready.It is a
  225. preparation for measure stage. If measure dalay time is too short, maybe it would
  226. have an undesired effect on measure value. */
  227. uint32_t prechargeTime; /*!< Set pre-charge time(1U~0xFFFFFFFFU) to make the upper layer of
  228. screen to charge to positive high. It is a preparation for detection stage.
  229. Pre-charge time must is greater than 0U, otherwise TSC could not work normally.
  230. If pre-charge dalay time is too short, maybe it would have an undesired effect on
  231. generation of valid signal(kTSC_ValidSignalFlag).*/
  232. tsc_detection_mode_t detectionMode; /*!< Select the detection mode. See "tsc_detection_mode_t". */
  233. } tsc_config_t;
  234. /*******************************************************************************
  235. * API
  236. ******************************************************************************/
  237. #if defined(__cplusplus)
  238. extern "C" {
  239. #endif
  240. /*!
  241. * @brief Initialize the TSC module.
  242. *
  243. * @param base TSC peripheral base address.
  244. * @param config Pointer to "tsc_config_t" structure.
  245. */
  246. void TSC_Init(TSC_Type *base, const tsc_config_t *config);
  247. /*!
  248. * @brief De-initializes the TSC module.
  249. *
  250. * @param base TSC peripheral base address.
  251. */
  252. void TSC_Deinit(TSC_Type *base);
  253. /*!
  254. * @brief Gets an available pre-defined settings for the controller's configuration.
  255. *
  256. * This function initializes the converter configuration structure with available settings.
  257. * The default values of measureDelayTime and prechargeTime is tested on LCD8000-43T screen and work normally.
  258. * The default values are:
  259. * @code
  260. * config->enableAutoMeausre = false;
  261. * config->measureDelayTime = 0xFFFFU;
  262. * config->prechargeTime = 0xFFFFU;
  263. * config->detectionMode = kTSC_4WireDetectionMode;
  264. * @endCode
  265. * @param config Pointer to "tsc_config_t" structure.
  266. */
  267. void TSC_GetDefaultConfig(tsc_config_t *config);
  268. /*!
  269. * @brief Make the TSC module return to idle status after finish the current state operation.
  270. * Application could check TSC status to confirm that the controller has return to idle status.
  271. *
  272. * @param base TSC peripheral base address.
  273. */
  274. static inline void TSC_ReturnToIdleStatus(TSC_Type *base)
  275. {
  276. /* TSC_FLOW_CONTROL_DISABLE_MASK is a HW self-clean bit. */
  277. base->FLOW_CONTROL |= TSC_FLOW_CONTROL_DISABLE_MASK;
  278. }
  279. /*!
  280. * @brief Start sense detection and (if work in auto-measure mode) measure after detect a touch.
  281. *
  282. * @param base TSC peripheral base address.
  283. */
  284. static inline void TSC_StartSenseDetection(TSC_Type *base)
  285. {
  286. /* TSC_FLOW_CONTROL_START_SENSE_MASK is a HW self-clean bit. */
  287. base->FLOW_CONTROL |= TSC_FLOW_CONTROL_START_SENSE_MASK;
  288. }
  289. /*!
  290. * @brief start measure X/Y coordinate value after detect a touch.
  291. *
  292. * @param base TSC peripheral base address.
  293. */
  294. static inline void TSC_StartMeasure(TSC_Type *base)
  295. {
  296. /* TSC_FLOW_CONTROL_START_MEASURE_MASK is a HW self-clean bit. */
  297. base->FLOW_CONTROL |= TSC_FLOW_CONTROL_START_MEASURE_MASK;
  298. }
  299. /*!
  300. * @brief Drop measure X/Y coordinate value after detect a touch and controller return to idle status.
  301. *
  302. * @param base TSC peripheral base address.
  303. */
  304. static inline void TSC_DropMeasure(TSC_Type *base)
  305. {
  306. /* TSC_FLOW_CONTROL_DROP_MEASURE_MASK is a HW self-clean bit. */
  307. base->FLOW_CONTROL |= TSC_FLOW_CONTROL_DROP_MEASURE_MASK;
  308. }
  309. /*!
  310. * @brief This is a synchronization reset, which resets every register except IPS directly access ones.
  311. *
  312. * @param base TSC peripheral base address.
  313. */
  314. static inline void TSC_SoftwareReset(TSC_Type *base)
  315. {
  316. /* TSC_FLOW_CONTROL_SW_RST_MASK is a HW self-clean bit. */
  317. base->FLOW_CONTROL |= TSC_FLOW_CONTROL_SW_RST_MASK;
  318. }
  319. /*!
  320. * @brief Get Y coordinate value or X coordinate value. The value is an ADC conversion value.
  321. *
  322. * @param base TSC peripheral base address.
  323. * @param selection Select alternative measure value which is Y coordinate value or X coordinate value.
  324. * See "tsc_corrdinate_value_selection_t".
  325. * @return If selection is "kTSC_XCoordinateValueSelection", the API returns x-coordinate vlaue.
  326. * If selection is "kTSC_YCoordinateValueSelection", the API returns y-coordinate vlaue.
  327. */
  328. uint32_t TSC_GetMeasureValue(TSC_Type *base, tsc_corrdinate_value_selection_t selection);
  329. /*!
  330. * @brief Enable the interrupt signals. Interrupt signal will be set when corresponding event happens.
  331. * Specific events point to "_tsc_interrupt_signal_mask" .
  332. * Specific interrupt signal point to "_tsc_interrupt_status_flag_mask";
  333. *
  334. * @param base TSC peripheral base address.
  335. * @param mask Interrupt signals mask. See "_tsc_interrupt_signal_mask".
  336. */
  337. static inline void TSC_EnableInterruptSignals(TSC_Type *base, uint32_t mask)
  338. {
  339. base->INT_SIG_EN |= mask;
  340. }
  341. /*!
  342. * @brief Disable the interrupt signals. Interrupt signal will be set when corresponding event happens.
  343. * Specific events point to "_tsc_interrupt_signal_mask".
  344. * Specific interrupt signal point to "_tsc_interrupt_status_flag_mask";
  345. *
  346. * @param base TSC peripheral base address.
  347. * @param mask Interrupt signals mask. See "_tsc_interrupt_signal_mask".
  348. */
  349. static inline void TSC_DisableInterruptSignals(TSC_Type *base, uint32_t mask)
  350. {
  351. base->INT_SIG_EN &= ~mask;
  352. }
  353. /*!
  354. * @brief Enable the interrupts. Notice: Only interrupts and signals are all enabled, interrupts
  355. * could work normally.
  356. *
  357. * @param base TSC peripheral base address.
  358. * @param mask Interrupts mask. See "_tsc_interrupt_mask".
  359. */
  360. static inline void TSC_EnableInterrupts(TSC_Type *base, uint32_t mask)
  361. {
  362. base->INT_EN |= mask;
  363. }
  364. /*!
  365. * @brief Disable the interrupts.
  366. *
  367. * @param base TSC peripheral base address.
  368. * @param mask Interrupts mask. See "_tsc_interrupt_mask".
  369. */
  370. static inline void TSC_DisableInterrupts(TSC_Type *base, uint32_t mask)
  371. {
  372. base->INT_EN &= ~mask;
  373. }
  374. /*!
  375. * @brief Get interrupt status flags. Interrupt status falgs are valid when corresponding
  376. * interrupt signals are enabled.
  377. *
  378. * @param base TSC peripheral base address.
  379. * @return Status flags asserted mask. See "_tsc_interrupt_status_flag_mask".
  380. */
  381. static inline uint32_t TSC_GetInterruptStatusFlags(TSC_Type *base)
  382. {
  383. return base->INT_STATUS;
  384. }
  385. /*!
  386. * @brief Clear interrupt status flags. Interrupt status falgs are valid when corresponding
  387. * interrupt signals are enabled.
  388. *
  389. * @param base TSC peripheral base address.
  390. * @param mask Status flags mask. See "_tsc_interrupt_status_flag_mask".
  391. */
  392. static inline void TSC_ClearInterruptStatusFlags(TSC_Type *base, uint32_t mask)
  393. {
  394. base->INT_STATUS = mask;
  395. }
  396. /*!
  397. * @brief Get the status flags of ADC working with TSC.
  398. *
  399. * @param base TSC peripheral base address.
  400. * @return Status flags asserted mask. See "_tsc_adc_status_flag_mask".
  401. */
  402. static inline uint32_t TSC_GetADCStatusFlags(TSC_Type *base)
  403. {
  404. return base->DEBUG_MODE;
  405. }
  406. /*!
  407. * @brief Get the status flags of TSC.
  408. *
  409. * @param base TSC peripheral base address.
  410. * @return Status flags asserted mask. See "_tsc_status_flag_mask".
  411. */
  412. static inline uint32_t TSC_GetStatusFlags(TSC_Type *base)
  413. {
  414. return base->DEBUG_MODE2;
  415. }
  416. /*!
  417. *@}
  418. */
  419. /*******************************************************************************
  420. * Debug API
  421. ******************************************************************************/
  422. /*!
  423. * @brief Enable/Disable debug mode. Once work in debug mode, then all
  424. * TSC outputs will be controlled by software. Software can also observe all TSC inputs
  425. * through debug interface. Furthermore, the debug registers also provides current state
  426. * machine states. Software can always check the current hardware state.
  427. *
  428. * @param base TSC peripheral base address.
  429. * @param enable Switcher of the debug mode. "true" means debug mode,"false" means non-debug mode.
  430. */
  431. static inline void TSC_EnableDebugMode(TSC_Type *base, bool enable)
  432. {
  433. if (enable)
  434. {
  435. base->DEBUG_MODE |= TSC_DEBUG_MODE_DEBUG_EN_MASK;
  436. }
  437. else
  438. {
  439. base->DEBUG_MODE &= ~TSC_DEBUG_MODE_DEBUG_EN_MASK;
  440. }
  441. }
  442. /*!
  443. * @brief Send hardware trigger signal to ADC in debug mode. The trigger signal must last at least 1 ips clock period.
  444. *
  445. * @param base TSC peripheral base address.
  446. * @param hwts Hardware trigger select signal, select which channel to start conversion. See "tsc_trigger_signal_t".
  447. * On ADC side, HWTS = 1 << x indicates the x logic channel is selected to start hardware ADC conversion.
  448. * @param enable Switcher of the trigger signal. "true" means generate trigger signal, "false" means don't generate
  449. * trigger signal.
  450. */
  451. void TSC_DebugTriggerSignalToADC(TSC_Type *base, tsc_trigger_signal_t hwts, bool enable);
  452. /*!
  453. * @brief Enable/Disable hardware generates an ADC COCO clear signal in debug mode.
  454. *
  455. * @param base TSC peripheral base address.
  456. * @param enable Switcher of the function of hardware generating an ADC COCO clear signal.
  457. * "true" means prevent TSC from generate ADC COCO clear signal.
  458. * "false" means allow TSC hardware generates ADC COCO clear.
  459. */
  460. static inline void TSC_DebugDisableHWClear(TSC_Type *base, bool enable)
  461. {
  462. if (enable)
  463. {
  464. base->DEBUG_MODE |= TSC_DEBUG_MODE_ADC_COCO_CLEAR_DISABLE_MASK;
  465. }
  466. else
  467. {
  468. base->DEBUG_MODE &= ~TSC_DEBUG_MODE_ADC_COCO_CLEAR_DISABLE_MASK;
  469. }
  470. }
  471. /*!
  472. * @brief Send clear ADC COCO signal to ADC in debug mode. The signal must hold a while.
  473. *
  474. * @param base TSC peripheral base address.
  475. * @param enable Switcher of the clear signal."true" means generate clear signal, "false" means don't generate
  476. * clear signal.
  477. */
  478. static inline void TSC_DebugClearSignalToADC(TSC_Type *base, bool enable)
  479. {
  480. if (enable)
  481. {
  482. base->DEBUG_MODE |= TSC_DEBUG_MODE_ADC_COCO_CLEAR_MASK;
  483. }
  484. else
  485. {
  486. base->DEBUG_MODE &= ~TSC_DEBUG_MODE_ADC_COCO_CLEAR_MASK;
  487. }
  488. }
  489. /*!
  490. * @brief Enable/Disable detection in debug mode.
  491. *
  492. * @param base TSC peripheral base address.
  493. * @param detectionMode Set detect mode. See "tsc_detection_mode_t"
  494. * @param enable Switcher of detect enable. "true" means enable detection, "false" means disable detection.
  495. */
  496. void TSC_DebugEnableDetection(TSC_Type *base, tsc_detection_mode_t detectionMode, bool enable);
  497. /*!
  498. * @brief Set TSC port mode in debug mode.(pull down, pull up and 200k-pull up)
  499. *
  500. * @param base TSC peripheral base address.
  501. * @param port TSC controller ports.
  502. * @param mode TSC port mode.(pull down, pull up and 200k-pull up)
  503. */
  504. void TSC_DebugSetPortMode(TSC_Type *base, tsc_port_source_t port, tsc_port_mode_t mode);
  505. #endif /* _FSL_TSC_H_ */