fsl_tsc.h 23 KB

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