at86rf23x.h 4.5 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114
  1. /****************************************************************************
  2. * include/nuttx/ieee802154/at86rf23x.h
  3. *
  4. * Copyright (C) 2014-2015 Gregory Nutt. All rights reserved.
  5. * Copyright (C) 2014-2015 Sebastien Lorquet. All rights reserved.
  6. * Author: Sebastien Lorquet <sebastien@lorquet.fr>
  7. *
  8. * Redistribution and use in source and binary forms, with or without
  9. * modification, are permitted provided that the following conditions
  10. * are met:
  11. *
  12. * 1. Redistributions of source code must retain the above copyright
  13. * notice, this list of conditions and the following disclaimer.
  14. * 2. Redistributions in binary form must reproduce the above copyright
  15. * notice, this list of conditions and the following disclaimer in
  16. * the documentation and/or other materials provided with the
  17. * distribution.
  18. * 3. Neither the name NuttX nor the names of its contributors may be
  19. * used to endorse or promote products derived from this software
  20. * without specific prior written permission.
  21. *
  22. * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
  23. * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
  24. * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS
  25. * FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE
  26. * COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT,
  27. * INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING,
  28. * BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS
  29. * OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED
  30. * AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
  31. * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN
  32. * ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
  33. * POSSIBILITY OF SUCH DAMAGE.
  34. *
  35. ****************************************************************************/
  36. #ifndef __INCLUDE_NUTTX_IEEE802154_AT86RF23X_H
  37. #define __INCLUDE_NUTTX_IEEE802154_AT86RF23X_H
  38. /****************************************************************************
  39. * Included Files
  40. ****************************************************************************/
  41. #include <nuttx/config.h>
  42. #include <stdbool.h>
  43. /****************************************************************************
  44. * Public Types
  45. ****************************************************************************/
  46. /* The at86rf23x provides interrupts to the MCU via a GPIO pin. The
  47. * following structure provides an MCU-independent mechanixm for controlling
  48. * the at86rf23x GPIO interrupt.
  49. *
  50. * The at86rf23x interrupt is an active low, *level* interrupt. From Datasheet:
  51. * "Note 1: The INTEDGE polarity defaults to: 0 = Falling Edge. Ensure that
  52. * the interrupt polarity matches the interrupt pin polarity of the host
  53. * microcontroller.
  54. * "Note 2: The INT pin will remain high or low, depending on INTEDGE polarity
  55. * setting, until INTSTAT register is read."
  56. */
  57. struct at86rf23x_lower_s
  58. {
  59. int (*attach)(FAR const struct at86rf23x_lower_s *lower, xcpt_t handler,
  60. FAR void *arg);
  61. void (*enable)(FAR const struct at86rf23x_lower_s *lower, bool state);
  62. void (*slptr)(FAR const struct at86rf23x_lower_s *lower, bool state);
  63. void (*reset)(FAR const struct at86rf23x_lower_s *lower, bool state);
  64. };
  65. #ifdef __cplusplus
  66. #define EXTERN extern "C"
  67. extern "C"
  68. {
  69. #else
  70. #define EXTERN extern
  71. #endif
  72. /****************************************************************************
  73. * Public Function Prototypes
  74. ****************************************************************************/
  75. /****************************************************************************
  76. * Function: at86rf23x_init
  77. *
  78. * Description:
  79. * Initialize the IEEE802.15.4 driver. The at86rf23x device is assumed to be
  80. * in the post-reset state upon entry to this function.
  81. *
  82. * Input Parameters:
  83. * spi - A reference to the platform's SPI driver for the at86rf23x
  84. * lower - The MCU-specific interrupt used to control low-level MCU
  85. * functions (i.e., at86rf23x GPIO interrupts).
  86. * devno - If more than one at86rf23x is supported, then this is the
  87. * zero based number that identifies the at86rf23x;
  88. *
  89. * Returned Value:
  90. * OK on success; Negated errno on failure.
  91. *
  92. * Assumptions:
  93. *
  94. ****************************************************************************/
  95. FAR struct ieee802154_radio_s *
  96. at86rf23x_init(FAR struct spi_dev_s *spi,
  97. FAR const struct at86rf23x_lower_s *lower);
  98. #undef EXTERN
  99. #ifdef __cplusplus
  100. }
  101. #endif
  102. #endif /* __INCLUDE_NUTTX_IEEE802154__AT86RF23X_H */