cy_capsense_tuner.h 5.3 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143
  1. /***************************************************************************//**
  2. * \file cy_capsense_tuner.h
  3. * \version 3.0
  4. *
  5. * \brief
  6. * This file provides CAPSENSE™ MW Tuner module function prototypes.
  7. *
  8. ********************************************************************************
  9. * \copyright
  10. * Copyright 2018-2021, Cypress Semiconductor Corporation (an Infineon company)
  11. * or an affiliate of Cypress Semiconductor Corporation. All rights reserved.
  12. * You may use this file only in accordance with the license, terms, conditions,
  13. * disclaimers, and limitations in the end user license agreement accompanying
  14. * the software package with which this file was provided.
  15. *******************************************************************************/
  16. #if !defined(CY_CAPSENSE_TUNER_H)
  17. #define CY_CAPSENSE_TUNER_H
  18. #include "cy_syslib.h"
  19. #include "cy_capsense_structure.h"
  20. #if (defined(CY_IP_MXCSDV2) || defined(CY_IP_M0S8CSDV2) || defined(CY_IP_M0S8MSCV3))
  21. #if defined(__cplusplus)
  22. extern "C" {
  23. #endif
  24. /*******************************************************************************
  25. * Macros Definitions
  26. *******************************************************************************/
  27. #define CY_CAPSENSE_COMMAND_PACKET_SIZE (16u)
  28. #define CY_CAPSENSE_COMMAND_CRC_DATA_SIZE (11u)
  29. #define CY_CAPSENSE_COMMAND_HEAD_0_IDX (0u)
  30. #define CY_CAPSENSE_COMMAND_HEAD_1_IDX (1u)
  31. #define CY_CAPSENSE_COMMAND_CODE_0_IDX (2u)
  32. #define CY_CAPSENSE_COMMAND_CNTR_0_IDX (3u)
  33. #define CY_CAPSENSE_COMMAND_SIZE_0_IDX (4u)
  34. #define CY_CAPSENSE_COMMAND_OFFS_0_IDX (5u)
  35. #define CY_CAPSENSE_COMMAND_OFFS_1_IDX (6u)
  36. #define CY_CAPSENSE_COMMAND_DATA_0_IDX (7u)
  37. #define CY_CAPSENSE_COMMAND_DATA_1_IDX (8u)
  38. #define CY_CAPSENSE_COMMAND_DATA_2_IDX (9u)
  39. #define CY_CAPSENSE_COMMAND_DATA_3_IDX (10u)
  40. #define CY_CAPSENSE_COMMAND_CRC_0_IDX (11u)
  41. #define CY_CAPSENSE_COMMAND_CRC_1_IDX (12u)
  42. #define CY_CAPSENSE_COMMAND_TAIL_0_IDX (13u)
  43. #define CY_CAPSENSE_COMMAND_TAIL_1_IDX (14u)
  44. #define CY_CAPSENSE_COMMAND_TAIL_2_IDX (15u)
  45. #define CY_CAPSENSE_COMMAND_HEAD_0 (0x0Du)
  46. #define CY_CAPSENSE_COMMAND_HEAD_1 (0x0Au)
  47. #define CY_CAPSENSE_COMMAND_TAIL_0 (0x00u)
  48. #define CY_CAPSENSE_COMMAND_TAIL_1 (0xFFu)
  49. #define CY_CAPSENSE_COMMAND_TAIL_2 (0xFFu)
  50. #define CY_CAPSENSE_COMMAND_OK (0u)
  51. #define CY_CAPSENSE_WRONG_HEADER (1u)
  52. #define CY_CAPSENSE_WRONG_CRC (2u)
  53. #define CY_CAPSENSE_WRONG_TAIL (3u)
  54. #define CY_CAPSENSE_WRONG_CODE (4u)
  55. #define CY_CAPSENSE_MSB_SHIFT (8u)
  56. /*******************************************************************************
  57. * Function Prototypes
  58. *******************************************************************************/
  59. /******************************************************************************/
  60. /** \addtogroup group_capsense_high_level *//** \{ */
  61. /******************************************************************************/
  62. uint32_t Cy_CapSense_RunTuner(cy_stc_capsense_context_t * context);
  63. uint32_t Cy_CapSense_CheckTunerCmdIntegrity(const uint8_t * commandPacket);
  64. /** \} */
  65. /******************************************************************************/
  66. /** \cond SECTION_CAPSENSE_INTERNAL */
  67. /** \addtogroup group_capsense_internal *//** \{ */
  68. /******************************************************************************/
  69. void Cy_CapSense_TuInitialize(cy_stc_capsense_context_t * context);
  70. /*******************************************************************************
  71. * Function Name: Cy_CapSense_CheckCommandIntegrity
  72. ****************************************************************************//**
  73. *
  74. * \deprecated This function is obsolete and kept for backward compatibility only.
  75. * The Cy_CapSense_CheckTunerCmdIntegrity() function should be used instead.
  76. *
  77. * \param commandPacket
  78. * The pointer to the data packet that should be verified.
  79. *
  80. * \return
  81. * Returns the result of the command verification.
  82. *
  83. *******************************************************************************/
  84. __STATIC_INLINE uint32_t Cy_CapSense_CheckCommandIntegrity(const uint8_t * commandPacket)
  85. {
  86. return(Cy_CapSense_CheckTunerCmdIntegrity(commandPacket));
  87. }
  88. /*******************************************************************************
  89. * Function Name: Cy_CapSense_CalculateCrc16
  90. ****************************************************************************//**
  91. *
  92. * \deprecated This function is obsolete and kept for backward compatibility only.
  93. * The Cy_CapSense_GetCRC() function should be used instead.
  94. *
  95. * \param ptrData
  96. * The pointer to the data.
  97. *
  98. * \param len
  99. * The length of the data in bytes.
  100. *
  101. * \return
  102. * Returns a calculated CRC-16 value.
  103. *
  104. *******************************************************************************/
  105. __STATIC_INLINE uint16_t Cy_CapSense_CalculateCrc16(const uint8_t *ptrData, uint32_t len)
  106. {
  107. return(Cy_CapSense_GetCRC(ptrData, len));
  108. }
  109. /** \} \endcond */
  110. #if defined(__cplusplus)
  111. }
  112. #endif
  113. #endif /* (defined(CY_IP_MXCSDV2) || defined(CY_IP_M0S8CSDV2) || defined(CY_IP_M0S8MSCV3)) */
  114. #endif /* CY_CAPSENSE_TUNER_H */
  115. /* [] END OF FILE */