st25r3916_aat.h 3.8 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109
  1. /******************************************************************************
  2. * \attention
  3. *
  4. * <h2><center>&copy; COPYRIGHT 2020 STMicroelectronics</center></h2>
  5. *
  6. * Licensed under ST MYLIBERTY SOFTWARE LICENSE AGREEMENT (the "License");
  7. * You may not use this file except in compliance with the License.
  8. * You may obtain a copy of the License at:
  9. *
  10. * www.st.com/myliberty
  11. *
  12. * Unless required by applicable law or agreed to in writing, software
  13. * distributed under the License is distributed on an "AS IS" BASIS,
  14. * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied,
  15. * AND SPECIFICALLY DISCLAIMING THE IMPLIED WARRANTIES OF MERCHANTABILITY,
  16. * FITNESS FOR A PARTICULAR PURPOSE, AND NON-INFRINGEMENT.
  17. * See the License for the specific language governing permissions and
  18. * limitations under the License.
  19. *
  20. ******************************************************************************/
  21. /*
  22. * PROJECT: ST25R3916 firmware
  23. * Revision:
  24. * LANGUAGE: ISO C99
  25. */
  26. /*! \file st25r3916_aat.h
  27. *
  28. * \author
  29. *
  30. * \brief ST25R3916 Antenna Tuning
  31. *
  32. * The antenna tuning algorithm tries to find the optimal settings for
  33. * the AAT_A and AAT_B registers, which are connected to variable capacitors
  34. * to tune the antenna matching.
  35. *
  36. */
  37. #ifndef ST25R3916_AAT_H
  38. #define ST25R3916_AAT_H
  39. #include "platform.h"
  40. #include "st_errno.h"
  41. /*
  42. ******************************************************************************
  43. * GLOBAL DATATYPES
  44. ******************************************************************************
  45. */
  46. /*!
  47. * struct representing input parameters for the antenna tuning
  48. */
  49. struct st25r3916AatTuneParams {
  50. uint8_t aat_a_min; /*!< min value of A cap */
  51. uint8_t aat_a_max; /*!< max value of A cap */
  52. uint8_t aat_a_start; /*!< start value of A cap */
  53. uint8_t aat_a_stepWidth; /*!< increment stepWidth for A cap */
  54. uint8_t aat_b_min; /*!< min value of B cap */
  55. uint8_t aat_b_max; /*!< max value of B cap */
  56. uint8_t aat_b_start; /*!< start value of B cap */
  57. uint8_t aat_b_stepWidth; /*!< increment stepWidth for B cap */
  58. uint8_t phaTarget; /*!< target phase */
  59. uint8_t phaWeight; /*!< weight of target phase */
  60. uint8_t ampTarget; /*!< target amplitude */
  61. uint8_t ampWeight; /*!< weight of target amplitude */
  62. bool doDynamicSteps; /*!< dynamically reduce step size in algo */
  63. uint8_t measureLimit; /*!< max number of allowed steps/measurements */
  64. };
  65. /*!
  66. * struct representing out parameters for the antenna tuning
  67. */
  68. struct st25r3916AatTuneResult {
  69. uint8_t aat_a; /*!< serial cap after tuning */
  70. uint8_t aat_b; /*!< parallel cap after tuning */
  71. uint8_t pha; /*!< phase after tuning */
  72. uint8_t amp; /*!< amplitude after tuning */
  73. uint16_t measureCnt; /*!< number of measures performed */
  74. };
  75. /*!
  76. *****************************************************************************
  77. * \brief Perform antenna tuning
  78. *
  79. * This function starts an antenna tuning procedure by modifying the serial
  80. * and parallel capacitors of the antenna matching circuit via the AAT_A
  81. * and AAT_B registers.
  82. *
  83. * \param[in] tuningParams : Input parameters for the tuning algorithm. If NULL
  84. * default values will be used.
  85. * \param[out] tuningStatus : Result information of performed tuning. If NULL
  86. * no further information is returned, only registers
  87. * ST25R3916 (AAT_A,B) will be adapted.
  88. *
  89. * \return ERR_IO : Error during communication.
  90. * \return ERR_PARAM : Invalid input parameters
  91. * \return ERR_NONE : No error.
  92. *
  93. *****************************************************************************
  94. */
  95. extern ReturnCode st25r3916AatTune(
  96. const struct st25r3916AatTuneParams* tuningParams,
  97. struct st25r3916AatTuneResult* tuningStatus);
  98. #endif /* ST25R3916_AAT_H */