ieee802154_radio.h 6.4 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169
  1. /****************************************************************************
  2. * include/nuttx/wireless/ieee802154/ieee802154_radio.h
  3. *
  4. * Copyright (C) 2014-2016 Sebastien Lorquet. All rights reserved.
  5. * Copyright (C) 2017 Verge Inc. All rights reserved.
  6. * Author: Sebastien Lorquet <sebastien@lorquet.fr>
  7. * Author: Anthony Merlino <anthony@vergeaero.com>
  8. *
  9. * Redistribution and use in source and binary forms, with or without
  10. * modification, are permitted provided that the following conditions
  11. * are met:
  12. *
  13. * 1. Redistributions of source code must retain the above copyright
  14. * notice, this list of conditions and the following disclaimer.
  15. * 2. Redistributions in binary form must reproduce the above copyright
  16. * notice, this list of conditions and the following disclaimer in
  17. * the documentation and/or other materials provided with the
  18. * distribution.
  19. * 3. Neither the name NuttX nor the names of its contributors may be
  20. * used to endorse or promote products derived from this software
  21. * without specific prior written permission.
  22. *
  23. * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
  24. * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
  25. * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS
  26. * FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE
  27. * COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT,
  28. * INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING,
  29. * BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS
  30. * OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED
  31. * AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
  32. * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN
  33. * ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
  34. * POSSIBILITY OF SUCH DAMAGE.
  35. *
  36. ****************************************************************************/
  37. #ifndef __INCLUDE_NUTTX_WIRELESS_IEEE802154_IEEE802154_RADIO_H
  38. #define __INCLUDE_NUTTX_WIRELESS_IEEE802154_IEEE802154_RADIO_H
  39. /****************************************************************************
  40. * Included Files
  41. ****************************************************************************/
  42. #include <nuttx/config.h>
  43. #include <stdint.h>
  44. #include <stdbool.h>
  45. #include <nuttx/wireless/ieee802154/ieee802154_mac.h>
  46. /****************************************************************************
  47. * Pre-Processor Definitions
  48. ****************************************************************************/
  49. /****************************************************************************
  50. * Public Types
  51. ****************************************************************************/
  52. /* Data only used between radio and MAC layer */
  53. struct ieee802154_txdesc_s
  54. {
  55. /* Support a singly linked list of tx descriptors */
  56. FAR struct ieee802154_txdesc_s *flink;
  57. /* Destination Address */
  58. struct ieee802154_addr_s destaddr; /* Only used for indirect transactions */
  59. /* Pointer to the frame IOB */
  60. FAR struct iob_s *frame;
  61. /* Pointer to the data confirmation structure to be populated upon
  62. * success/failure of the transmission.
  63. */
  64. FAR struct ieee802154_data_conf_s *conf;
  65. /* Frame type. Used by MAC layer to control how tx done is handled */
  66. enum ieee802154_frametype_e frametype;
  67. bool ackreq; /* Are we requesting an ACK? */
  68. bool framepending; /* Did the ACK have the frame pending bit set */
  69. uint32_t purgetime; /* Time to purge transaction */
  70. uint8_t retrycount; /* Number of remaining retries. Set to macMaxFrameRetries
  71. * when txdescriptor is allocated
  72. */
  73. /* TODO: Add slotting information for GTS transactions */
  74. };
  75. struct ieee802154_beaconframe_s
  76. {
  77. uint8_t bf_data[IEEE802154_MAX_PHY_PACKET_SIZE];
  78. uint8_t bf_len;
  79. uint8_t bf_offset;
  80. };
  81. enum ieee802154_sfevent_e
  82. {
  83. IEEE802154_SFEVENT_ENDOFACTIVE,
  84. };
  85. /* IEEE802.15.4 Radio Interface Operations **********************************/
  86. struct ieee802154_radiocb_s
  87. {
  88. CODE int (*poll) (FAR const struct ieee802154_radiocb_s *radiocb,
  89. bool gts, FAR struct ieee802154_txdesc_s **tx_desc);
  90. CODE void (*txdone) (FAR const struct ieee802154_radiocb_s *radiocb,
  91. FAR struct ieee802154_txdesc_s *tx_desc);
  92. CODE void (*rxframe) (FAR const struct ieee802154_radiocb_s *radiocb,
  93. FAR struct ieee802154_data_ind_s *ind);
  94. CODE void (*sfevent) (FAR const struct ieee802154_radiocb_s *radiocb,
  95. enum ieee802154_sfevent_e sfevent);
  96. CODE void (*edresult) (FAR const struct ieee802154_radiocb_s *radiocb,
  97. uint8_t edval);
  98. };
  99. struct ieee802154_radio_s
  100. {
  101. CODE int (*bind) (FAR struct ieee802154_radio_s *radio,
  102. FAR struct ieee802154_radiocb_s *radiocb);
  103. CODE int (*reset) (FAR struct ieee802154_radio_s *radio);
  104. CODE int (*getattr) (FAR struct ieee802154_radio_s *radio,
  105. enum ieee802154_attr_e ,
  106. FAR union ieee802154_attr_u *attrval);
  107. CODE int (*setattr) (FAR struct ieee802154_radio_s *radio,
  108. enum ieee802154_attr_e ,
  109. FAR const union ieee802154_attr_u *attrval);
  110. CODE int (*txnotify)(FAR struct ieee802154_radio_s *radio, bool gts);
  111. CODE int (*txdelayed)(FAR struct ieee802154_radio_s *radio,
  112. FAR struct ieee802154_txdesc_s *txdesc,
  113. uint32_t symboldelay);
  114. CODE int (*rxenable) (FAR struct ieee802154_radio_s *radio, bool enable);
  115. CODE int (*energydetect) (FAR struct ieee802154_radio_s *radio,
  116. uint32_t symboldelay);
  117. CODE int (*beaconstart)(FAR struct ieee802154_radio_s *radio,
  118. FAR const struct ieee802154_superframespec_s *sfspec,
  119. FAR struct ieee802154_beaconframe_s *beacon);
  120. CODE int (*beaconupdate)(FAR struct ieee802154_radio_s *radio,
  121. FAR struct ieee802154_beaconframe_s *beacon);
  122. CODE int (*beaconstop)(FAR struct ieee802154_radio_s *radio);
  123. CODE int (*sfupdate)(FAR struct ieee802154_radio_s *radio,
  124. FAR const struct ieee802154_superframespec_s *sfspec);
  125. };
  126. #ifdef __cplusplus
  127. #define EXTERN extern "C"
  128. extern "C"
  129. {
  130. #else
  131. #define EXTERN extern
  132. #endif
  133. /****************************************************************************
  134. * Public Function Prototypes
  135. ****************************************************************************/
  136. #undef EXTERN
  137. #ifdef __cplusplus
  138. }
  139. #endif
  140. #endif /* __INCLUDE_NUTTX_WIRELESS_IEEE802154_IEEE802154_RADIO_H */