ahdlc.h 5.1 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184
  1. #ifndef _DEV_AHDLC_H_
  2. #define _DEV_AHDLC_H_
  3. /*
  4. * Copyright (C) 2001-2003 by egnite Software GmbH. All rights reserved.
  5. *
  6. * Redistribution and use in source and binary forms, with or without
  7. * modification, are permitted provided that the following conditions
  8. * are met:
  9. *
  10. * 1. Redistributions of source code must retain the above copyright
  11. * notice, this list of conditions and the following disclaimer.
  12. * 2. Redistributions in binary form must reproduce the above copyright
  13. * notice, this list of conditions and the following disclaimer in the
  14. * documentation and/or other materials provided with the distribution.
  15. * 3. Neither the name of the copyright holders nor the names of
  16. * contributors may be used to endorse or promote products derived
  17. * from this software without specific prior written permission.
  18. *
  19. * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
  20. * ``AS IS'' AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
  21. * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS
  22. * FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE
  23. * COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT,
  24. * INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING,
  25. * BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS
  26. * OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED
  27. * AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY,
  28. * OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF
  29. * THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
  30. * SUCH DAMAGE.
  31. *
  32. * For additional information see http://www.ethernut.de/
  33. */
  34. /*
  35. * $Log$
  36. * Revision 1.2 2008/08/11 06:59:59 haraldkipp
  37. * BSD types replaced by stdint types (feature request #1282721).
  38. *
  39. * Revision 1.1.1.1 2003/05/09 14:41:05 haraldkipp
  40. * Initial using 3.2.1
  41. *
  42. * Revision 1.2 2003/05/06 18:40:28 harald
  43. * Unused items removed
  44. *
  45. * Revision 1.1 2003/03/31 14:53:23 harald
  46. * Prepare release 3.1
  47. *
  48. */
  49. #include <dev/netbuf.h>
  50. #include <net/if_var.h>
  51. /*!
  52. * \file dev/ahdlc.h
  53. * \brief Asynchronous HDLC device definitions.
  54. */
  55. /*
  56. * Significant octet values.
  57. */
  58. #define AHDLC_ALLSTATIONS 0xff /*!< \brief All-Stations broadcast address */
  59. #define AHDLC_UI 0x03 /*!< \brief Unnumbered Information */
  60. #define AHDLC_FLAG 0x7e /*!< \brief Flag Sequence */
  61. #define AHDLC_ESCAPE 0x7d /*!< \brief Asynchronous Control Escape */
  62. #define AHDLC_TRANS 0x20 /*!< \brief Asynchronous transparency modifier */
  63. /*
  64. * Values for FCS calculations.
  65. */
  66. #define AHDLC_INITFCS 0xffff /*!< \brief Initial FCS value */
  67. #define AHDLC_GOODFCS 0xf0b8 /*!< \brief Good final FCS value */
  68. /*!
  69. * \struct _AHDLCDCB ahdlc.h dev/ahdlc.h
  70. * \brief Asynchronous HDLC device information structure.
  71. *
  72. * The start of this structure is equal to the UARTDCB structure.
  73. */
  74. struct _AHDLCDCB {
  75. /*! \brief Mode flags.
  76. */
  77. uint32_t dcb_modeflags;
  78. /*! \brief Status flags.
  79. */
  80. uint32_t dcb_statusflags;
  81. /*! \brief Read timeout.
  82. */
  83. uint32_t dcb_rtimeout;
  84. /*! \brief Write timeout.
  85. */
  86. uint32_t dcb_wtimeout;
  87. /*! \brief Queue of threads waiting for output buffer empty.
  88. *
  89. * Threads are added to this queue when the output buffer
  90. * is full or when flushing the output buffer.
  91. */
  92. HANDLE dcb_tx_rdy;
  93. /*! \brief Queue of threads waiting for a character in the input buffer.
  94. *
  95. * Threads are added to this queue when the output buffer is
  96. * empty.
  97. */
  98. HANDLE dcb_rx_rdy;
  99. /*! \brief Hardware base address.
  100. *
  101. * This is a copy of the base address in the NUTDEVICE structure
  102. * and required by the interrupt routine.
  103. */
  104. uint8_t dcb_base;
  105. /*! \brief Input buffer.
  106. *
  107. * This buffer is filled by the the receiver interrupt, so the
  108. * contents of the buffer is volatile.
  109. */
  110. volatile uint8_t *dcb_rx_buf;
  111. /*! \brief Input buffer index for next incoming byte.
  112. *
  113. * This volatile index is incremented by the receiver interrupt.
  114. */
  115. volatile uint8_t dcb_rx_idx;
  116. /*! \brief Input buffer index for next byte to read.
  117. */
  118. uint8_t dcb_rd_idx;
  119. /*! \brief Output buffer.
  120. */
  121. uint8_t *dcb_tx_buf;
  122. /*! \brief Output buffer index for next outgoing byte.
  123. *
  124. * This volatile index is incremented by the transmit interrupt.
  125. */
  126. volatile uint8_t dcb_tx_idx;
  127. /*! \brief Output buffer index for next byte to write.
  128. */
  129. uint8_t dcb_wr_idx;
  130. /*! \brief HDLC mode change event queue.
  131. *
  132. * The frame receiver thread is waiting on this queue until
  133. * the device is switched to HDLC mode.
  134. */
  135. HANDLE dcb_mf_evt;
  136. /*! \brief 32-bit receive ACCM.
  137. */
  138. uint32_t dcb_rx_accm;
  139. /*! \brief 256-bit transmit ACCM.
  140. */
  141. uint32_t dcb_tx_accm;
  142. /*! \brief Maximum receive MRU.
  143. */
  144. uint16_t dcb_rx_mru;
  145. /*! \brief Maximum transmit MRU.
  146. */
  147. uint16_t dcb_tx_mru;
  148. };
  149. /*!
  150. * \brief Asynchronous HDLC device information type.
  151. */
  152. typedef struct _AHDLCDCB AHDLCDCB;
  153. #endif