ant_search_config.h 5.4 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129
  1. /**
  2. * Copyright (c) 2015 - 2020, 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 ANT_SEARCH_CONFIG_H__
  41. #define ANT_SEARCH_CONFIG_H__
  42. /** @file
  43. *
  44. * @defgroup ant_search_config ANT search configuration
  45. * @{
  46. * @ingroup ant_sdk_utils
  47. * @brief ANT channel search configuration module.
  48. */
  49. #include <stdint.h>
  50. #include "ant_parameters.h"
  51. #include "sdk_config.h"
  52. #ifdef __cplusplus
  53. extern "C" {
  54. #endif
  55. #define ANT_SEARCH_SHARING_CYCLES_DISABLE 0x00 ///< Disable search sharing.
  56. #define ANT_LOW_PRIORITY_SEARCH_DISABLE 0x00 ///< Disable low priority search.
  57. #define ANT_LOW_PRIORITY_TIMEOUT_DISABLE 0xFF ///< Disable low priority search time-out.
  58. #define ANT_HIGH_PRIORITY_SEARCH_DISABLE 0x00 ///< Disable high priority search.
  59. #define ANT_HIGH_PRIORITY_TIMEOUT_DISABLE 0xFF ///< Disable high priority search time-out.
  60. /**@brief Search priority. */
  61. typedef enum
  62. {
  63. ANT_SEARCH_PRIORITY_DEFAULT = 0, ///< Default search priority level.
  64. ANT_SEARCH_PRIORITY_LOWEST = ANT_SEARCH_PRIORITY_DEFAULT, ///< Lowest search priority level.
  65. ANT_SEARCH_PRIORITY_0 = ANT_SEARCH_PRIORITY_LOWEST,
  66. ANT_SEARCH_PRIORITY_1 = 1,
  67. ANT_SEARCH_PRIORITY_2 = 2,
  68. ANT_SEARCH_PRIORITY_3 = 3,
  69. ANT_SEARCH_PRIORITY_4 = 4,
  70. ANT_SEARCH_PRIORITY_5 = 5,
  71. ANT_SEARCH_PRIORITY_6 = 6,
  72. ANT_SEARCH_PRIORITY_7 = 7,
  73. ANT_SEARCH_PRIORITY_HIGHEST = ANT_SEARCH_PRIORITY_7, ///< Highest search priority level.
  74. } ant_search_priority_t;
  75. /**@brief ANT search waveform. */
  76. typedef enum
  77. {
  78. ANT_WAVEFORM_DEFAULT = 316, ///< Standard search waveform value.
  79. ANT_WAVEFORM_FAST = 97, ///< Accelerated search waveform value.
  80. } ant_waveform_t;
  81. /**@brief ANT search configuration structure. */
  82. typedef struct
  83. {
  84. uint8_t channel_number; ///< Assigned channel number.
  85. uint8_t low_priority_timeout; ///< Low priority time-out (in 2.5 second increments).
  86. uint8_t high_priority_timeout; ///< High priority time-out (in 2.5 second increments).
  87. uint8_t search_sharing_cycles; ///< Number of search cycles to run before alternating searches. Search sharing can be disabled by @ref ANT_SEARCH_SHARING_CYCLES_DISABLE.
  88. ant_search_priority_t search_priority; ///< Search priority.
  89. ant_waveform_t waveform; ///< Search waveform. Do not use custom values.
  90. } ant_search_config_t;
  91. /**@brief Initializes the default ANT search configuration structure.
  92. *
  93. * @param[in] CHANNEL_NUMBER Number of the channel.
  94. */
  95. #define DEFAULT_ANT_SEARCH_CONFIG(CHANNEL_NUMBER) \
  96. { \
  97. .channel_number = CHANNEL_NUMBER, \
  98. .low_priority_timeout = ANT_DEFAULT_LOW_PRIORITY_TIMEOUT, \
  99. .high_priority_timeout = ANT_DEFAULT_HIGH_PRIORITY_TIMEOUT, \
  100. .search_sharing_cycles = ANT_SEARCH_SHARING_CYCLES_DISABLE, \
  101. .search_priority = ANT_SEARCH_PRIORITY_DEFAULT, \
  102. .waveform = ANT_WAVEFORM_DEFAULT, \
  103. }
  104. /**@brief Function for configuring the ANT channel search.
  105. *
  106. * @param[in] p_config Pointer to the search configuration structure.
  107. *
  108. * @retval NRF_SUCCESS If the channel was successfully configured. Otherwise, an error code is returned.
  109. */
  110. uint32_t ant_search_init(ant_search_config_t const * p_config);
  111. #ifdef __cplusplus
  112. }
  113. #endif
  114. #endif // ANT_SEARCH_CONFIG_H__
  115. /** @} */