nfc_fixes.h 5.2 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132
  1. /**
  2. * Copyright (c) 2015 - 2018, Nordic Semiconductor ASA
  3. *
  4. * All rights reserved.
  5. *
  6. * Redistribution and use in source and binary forms, with or without modification,
  7. * are permitted provided that the following conditions are met:
  8. *
  9. * 1. Redistributions of source code must retain the above copyright notice, this
  10. * list of conditions and the following disclaimer.
  11. *
  12. * 2. Redistributions in binary form, except as embedded into a Nordic
  13. * Semiconductor ASA integrated circuit in a product or a software update for
  14. * such product, must reproduce the above copyright notice, this list of
  15. * conditions and the following disclaimer in the documentation and/or other
  16. * materials provided with the distribution.
  17. *
  18. * 3. Neither the name of Nordic Semiconductor ASA 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. * 4. This software, with or without modification, must only be used with a
  23. * Nordic Semiconductor ASA integrated circuit.
  24. *
  25. * 5. Any software provided in binary form under this license must not be reverse
  26. * engineered, decompiled, modified and/or disassembled.
  27. *
  28. * THIS SOFTWARE IS PROVIDED BY NORDIC SEMICONDUCTOR ASA "AS IS" AND ANY EXPRESS
  29. * OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES
  30. * OF MERCHANTABILITY, NONINFRINGEMENT, AND FITNESS FOR A PARTICULAR PURPOSE ARE
  31. * DISCLAIMED. IN NO EVENT SHALL NORDIC SEMICONDUCTOR ASA OR CONTRIBUTORS BE
  32. * LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
  33. * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE
  34. * GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
  35. * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
  36. * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT
  37. * OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
  38. *
  39. */
  40. #ifndef NFC_FIXES_H__
  41. #define NFC_FIXES_H__
  42. #include <stdint.h>
  43. #include <stdbool.h>
  44. #ifdef __cplusplus
  45. extern "C" {
  46. #endif
  47. /** @file
  48. * @defgroup nfc_fixes NFC fixes and workarounds
  49. * @{
  50. * @ingroup nfc_t4t
  51. * @brief @tagAPI52 Fixes for hardware-related anomalies.
  52. *
  53. * If you are using the nRF52832 chip,
  54. * you must define the macro HAL_NFC_ENGINEERING_BC_FTPAN_WORKAROUND to apply
  55. * workarounds for the following anomalies:
  56. * - 79. NFCT: A false EVENTS_FIELDDETECTED event occurs after the field is lost.
  57. * - 116. NFCT does not release HFCLK when switching from ACTIVATED to SENSE mode.
  58. *
  59. * If you are using the IC revision Engineering A of the nRF52840 chip,
  60. * you must define the macro HAL_NFC_NRF52840_ENGINEERING_ABC_WORKAROUND to apply
  61. * workarounds for the following anomalies:
  62. * - 98. NFCT: The NFCT is not able to communicate with the peer.
  63. * - 116. NFCT does not release HFCLK when switching from ACTIVATED to SENSE mode.
  64. * - 144. NFCT: Not optimal NFC performance
  65. *
  66. * If you are using the IC revision 1, Engineering B, or Engineering C of the nRF52840 chip,
  67. * you must define the macro HAL_NFC_NRF52840_ENGINEERING_ABC_WORKAROUND to apply
  68. * workarounds for the following anomalies:
  69. * - 190. NFCT: Event FIELDDETECTED may be generated too early.
  70. *
  71. * The use of implemented workarounds for the nRF52840 chip is determined at runtime and depends
  72. * on the chip variant.
  73. *
  74. * The current code contains a patch for anomaly 25 (NFCT: Reset value of
  75. * SENSRES register is incorrect), so that it now works on Windows Phone.
  76. */
  77. #if defined (NRF52832_XXAA) || defined (NRF52832_XXAB) // assume the nRF52832 chip in IC revision Engineering B, Engineering C, 1, or 2.
  78. #define HAL_NFC_ENGINEERING_BC_FTPAN_WORKAROUND
  79. #elif defined (NRF52840_XXAA) // assume the nRF52840 chip in IC revision Engineering A, Engineering B, Engineering C, or 1.
  80. #define HAL_NFC_NRF52840_ENGINEERING_ABC_WORKAROUND
  81. #endif
  82. /**
  83. * @brief Internal auxiliary function to check if the program is running on the NRF52840 chip
  84. * @retval true It is the NRF52480 chip
  85. * @retval false It is other chip
  86. */
  87. static inline bool type_52840_check(void)
  88. {
  89. return ((((*(uint32_t *)0xF0000FE0) & 0xFF) == 0x08) &&
  90. (((*(uint32_t *)0xF0000FE4) & 0x0F) == 0x0));
  91. }
  92. /**
  93. * @brief Internal auxiliary function to check if the program is running on first sample of
  94. * NRF52840 chip
  95. * @retval true It is NRF52480 chip and it is first sample version
  96. * @retval false It is other chip
  97. */
  98. static inline bool type_52840_sample_check(void)
  99. {
  100. return ( type_52840_check() &&
  101. ( ((*(uint32_t *)0xF0000FE8) & 0xF0) == 0x00 ) &&
  102. ( ((*(uint32_t *)0xF0000FEC) & 0xF0) == 0x00 ) );
  103. }
  104. /**
  105. * @brief Internal auxiliary function to check if the program is running on final version of
  106. * NRF52840 chip
  107. * @retval true It is NRF52480 chip and it is final version
  108. * @retval false It is other chip
  109. */
  110. static inline bool type_52840_final_check(void)
  111. {
  112. return ( type_52840_check() &&
  113. ( ( ((*(uint32_t *)0xF0000FE8) & 0xF0) != 0x00 ) ||
  114. ( ((*(uint32_t *)0xF0000FEC) & 0xF0) != 0x00 ) ));
  115. }
  116. /** @} */
  117. #ifdef __cplusplus
  118. }
  119. #endif
  120. #endif /* NFC_FIXES_H__ */