phy_pd_data.h 6.6 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187
  1. /**
  2. * Copyright (c) 2016 - 2020 Nordic Semiconductor ASA and Luxoft Global Operations Gmbh.
  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. *
  10. * 1. Redistributions of source code must retain the above copyright notice, this
  11. * list of conditions and the following disclaimer.
  12. *
  13. * 2. Redistributions in binary form, except as embedded into a Nordic
  14. * Semiconductor ASA integrated circuit in a product or a software update for
  15. * such product, must reproduce the above copyright notice, this list of
  16. * conditions and the following disclaimer in the documentation and/or other
  17. * materials provided with the distribution.
  18. *
  19. * 3. Neither the name of Nordic Semiconductor ASA nor the names of its
  20. * contributors may be used to endorse or promote products derived from this
  21. * software without specific prior written permission.
  22. *
  23. * 4. This software, with or without modification, must only be used with a
  24. * Nordic Semiconductor ASA integrated circuit.
  25. *
  26. * 5. Any software provided in binary form under this license must not be reverse
  27. * engineered, decompiled, modified and/or disassembled.
  28. *
  29. *
  30. * THIS SOFTWARE IS PROVIDED BY NORDIC SEMICONDUCTOR ASA "AS IS" AND ANY EXPRESS
  31. * OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES
  32. * OF MERCHANTABILITY, NONINFRINGEMENT, AND FITNESS FOR A PARTICULAR PURPOSE ARE
  33. * DISCLAIMED. IN NO EVENT SHALL NORDIC SEMICONDUCTOR ASA OR CONTRIBUTORS BE
  34. * LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
  35. * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE
  36. * GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
  37. * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
  38. * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT
  39. * OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
  40. *
  41. */
  42. #ifndef PHY_PD_DATA_H_INCLUDED
  43. #define PHY_PD_DATA_H_INCLUDED
  44. #include <stdint.h>
  45. #include <stdbool.h>
  46. #include "sys_utils.h"
  47. #include "sys_time.h"
  48. #include "phy_common.h"
  49. #include "mac_time.h"
  50. #include "sys_queue.h"
  51. /** @file
  52. * This file contains declarations of PHY Data transmission routines and necessary types.
  53. *
  54. * @defgroup phy_data PHY Data API
  55. * @ingroup phy_15_4
  56. * @{
  57. * @brief Module to declare PHY Data API
  58. * @details The PHY Data module declares the PHY Data transmission routines and necessary types according to
  59. * the PHY specification. More specifically, PHY data request pd_data_req(), PHY data confirm
  60. * pd_data_conf(), and PHY Data indication pd_data_ind() primitives are declared.
  61. */
  62. /**@brief PD-DATA.request parameters.
  63. *
  64. * @details See 6.2.1.1 PD-DATA.request.
  65. * See Table 6 - PD-DATA.request parameters.
  66. */
  67. typedef struct
  68. {
  69. /** The set of octets forming the PSDU to be transmitted by the PHY entity. */
  70. uint8_t * psdu;
  71. /** The number of octets contained in the PSDU to be transmitted by the PHY entity.
  72. Valid range: less or equal to @ref PHY_MAX_PACKET_SIZE. */
  73. uint8_t psdu_length;
  74. } pd_data_req_t;
  75. /**@brief Private information which is passed with PD-DATA.confirm.
  76. * Not covered by standard.
  77. */
  78. typedef struct
  79. {
  80. /** pending value to store pending bit value if frame was acknowledged. */
  81. bool pending;
  82. } pd_data_conf_private_t;
  83. /**@brief PD-DATA.confirm parameters.
  84. *
  85. * @details See 6.2.1.2 PD-DATA.confirm.
  86. * See Table 7 - PD-DATA.confirm parameters.
  87. */
  88. typedef struct
  89. {
  90. /** Service field. */
  91. pd_data_conf_private_t service;
  92. /** The result of the request to transmit a packet.
  93. * Valid range: PHY_SUCCESS, PHY_RX_ON, PHY_TRX_OFF, PHY_BUSY_TX.
  94. * See @ref phy_enum_t.
  95. *
  96. * When radio chip successfully transmits data, but cannot receive
  97. * ACK in FAST_ACK mode, the result is PHY_TX_ON.
  98. */
  99. phy_enum_t status;
  100. } pd_data_conf_t;
  101. /**@brief Private information which is passed with PD-DATA.indication.
  102. * Not covered by standard.
  103. */
  104. typedef struct
  105. {
  106. /** RSSI value, which corresponds to packet that caused this indication. */
  107. int8_t rssi;
  108. /** Buffer to store incoming frame. */
  109. uint8_t frame_buffer[PHY_MAX_PACKET_SIZE + PHY_MAX_HEADER_SIZE];
  110. /** Timestamp of the moment when PHY header octet reception has been started. */
  111. mac_timestamp_t timestamp;
  112. /** This field allows storing instances of this structure in a queue. */
  113. sys_queue_item_t queue_item;
  114. #ifdef CONFIG_PHY_CERT_CRC_HOOK
  115. bool crc_status;
  116. #endif
  117. } pd_data_ind_private_t;
  118. /**@brief PD-DATA.indication parameters.
  119. *
  120. * @details See 6.2.1.3 PD-DATA.indication.
  121. * See Table 8 - PD-DATA.indication parameters.
  122. */
  123. typedef struct
  124. {
  125. /** Service field. */
  126. pd_data_ind_private_t service;
  127. /** The set of octets forming the PSDU received by the PHY entity. */
  128. uint8_t * psdu;
  129. /** The number of octets contained in the PSDU received by the PHY entity.
  130. Valid range: less or equal to @ref PHY_MAX_PACKET_SIZE. */
  131. uint8_t psdu_length;
  132. /** Link quality (LQI) value measured during reception of the PPDU (see 6.9.8).
  133. Valid range: 0x00 - 0xFF. */
  134. uint8_t ppdu_link_quality;
  135. } pd_data_ind_t;
  136. /**@brief PD-DATA.request primitive.
  137. *
  138. * @details The PD-DATA.request primitive requests the transfer of an MPDU (i.e., PSDU)
  139. * from the MAC sublayer to the local PHY entity.
  140. * See 6.2.1.1 PD-DATA.request.
  141. *
  142. * @param[in] req Pointer to PD-DATA.request parameters. See @ref pd_data_req_t.
  143. */
  144. void pd_data_req(pd_data_req_t * req);
  145. /**@brief PD-DATA.confirm primitive.
  146. *
  147. * @details Callback function, implemented by the next higher layer,
  148. * which handles the PD-DATA.confirm primitive.
  149. * See 6.2.1.2 PD-DATA.confirm.
  150. *
  151. * @param[out] conf Pointer to PD-DATA.confirm parameters. See @ref pd_data_conf_t.
  152. */
  153. void pd_data_conf(pd_data_conf_t * conf);
  154. /**@brief PD-DATA.indication primitive.
  155. *
  156. * @details The PD-DATA.indication primitive indicates the transfer of an MPDU (i.e., PSDU)
  157. * from the PHY to the local MAC sublayer entity.
  158. * See 6.2.1.3 PD-DATA.indication.
  159. * This function must be implemented by the next higher layer.
  160. *
  161. * @param[out] ind Pointer to PD-DATA.indication parameters. See @ref pd_data_ind_t.
  162. * Data are valid until next fully received packet.
  163. */
  164. void pd_data_ind(pd_data_ind_t * ind);
  165. /** @} */
  166. #endif // PHY_PD_DATA_H_INCLUDED