host.h 4.7 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192
  1. #ifndef XSVFEXEC_HOST_H_
  2. #define XSVFEXEC_HOST_H_
  3. /*
  4. * Copyright (C) 2004-2007 by egnite Software GmbH
  5. * Copyright (C) 2008 by egnite GmbH
  6. *
  7. * All rights reserved.
  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 the
  17. * documentation and/or other materials provided with the distribution.
  18. * 3. Neither the name of the copyright holders nor the names of
  19. * contributors may be used to endorse or promote products derived
  20. * from this software 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 LIABILITY,
  31. * OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF
  32. * THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
  33. * SUCH DAMAGE.
  34. *
  35. * For additional information see http://www.ethernut.de/
  36. * and Xilinx Application Note XAPP058.
  37. */
  38. /*
  39. * $Log$
  40. * Revision 1.1 2008/10/20 13:10:05 haraldkipp
  41. * Checked in.
  42. *
  43. */
  44. /*!
  45. * \file host.h
  46. * \brief Platform header file.
  47. */
  48. /*!
  49. * \addtogroup xgXEDefs
  50. */
  51. /*@{*/
  52. #ifndef XSVFNAME
  53. #if defined(ETHERNUT2)
  54. /*! \brief The XSVF file is expected in the UROM file system. */
  55. #define XSVFNAME "UROM:enut202.xsvf"
  56. #elif defined(ETHERNUT3)
  57. #define XSVFNAME "UROM:enut30e.xsvf"
  58. #else
  59. #define XSVFNAME "cpld/enut202.xsvf"
  60. #endif
  61. #endif /* XSVFNAME */
  62. /*@}*/
  63. /*!
  64. * \addtogroup xgHost
  65. */
  66. /*@{*/
  67. /*! \brief Executor version string. */
  68. #define XSVFEXEC_VERSION "1.2.0"
  69. /* Uncomment to enable debug output */
  70. //#define XSVF_DEBUG
  71. #ifdef ETHERNUT2
  72. #include <sys/types.h>
  73. /*! \brief Set TMS high on Ethernut 2. */
  74. #define SET_TMS() sbi(PORTF, 5)
  75. /*! \brief Set TMS low on Ethernut 2. */
  76. #define CLR_TMS() cbi(PORTF, 5)
  77. /*! \brief Set TDI high on Ethernut 2. */
  78. #define SET_TDI() sbi(PORTF, 6)
  79. /*! \brief Set TDI low on Ethernut 2. */
  80. #define CLR_TDI() cbi(PORTF, 6)
  81. /*! \brief Set TCK high on Ethernut 2. */
  82. #define SET_TCK() sbi(PORTF, 4)
  83. /*! \brief Set TCK low on Ethernut 2. */
  84. #define CLR_TCK() cbi(PORTF, 4)
  85. /*! \brief Get TDO status on Ethernut 2. */
  86. #define GET_TDO() bit_is_set(PINF, 7)
  87. #elif defined(ETHERNUT3)
  88. #include <sys/types.h>
  89. /*! \brief Set TMS high on Ethernut 3. */
  90. #define SET_TMS() { \
  91. outr(PIO_OER, _BV(16)); \
  92. outr(PIO_SODR, _BV(16)); \
  93. _NOP(); _NOP(); \
  94. }
  95. /*! \brief Set TMS low on Ethernut 3. */
  96. #define CLR_TMS() { \
  97. outr(PIO_OER, _BV(16)); \
  98. outr(PIO_CODR, _BV(16)); \
  99. _NOP(); _NOP(); \
  100. }
  101. /*! \brief Set TDI high on Ethernut 3. */
  102. #define SET_TDI() { \
  103. outr(PIO_SODR, _BV(23)); \
  104. _NOP(); _NOP(); \
  105. }
  106. /*! \brief Set TDI low on Ethernut 3. */
  107. #define CLR_TDI() { \
  108. outr(PIO_CODR, _BV(23)); \
  109. _NOP(); _NOP(); \
  110. }
  111. /*! \brief Set TCK high on Ethernut 3. */
  112. #define SET_TCK() { \
  113. outr(PIO_SODR, _BV(18)); \
  114. _NOP(); _NOP(); \
  115. }
  116. /*! \brief Set TCK low on Ethernut 3. */
  117. #define CLR_TCK() { \
  118. outr(PIO_OER, _BV(16) | _BV(18) | _BV(23)); \
  119. outr(PIO_ODR, _BV(19)); \
  120. outr(PIO_CODR, _BV(18)); \
  121. _NOP(); _NOP(); \
  122. }
  123. /*! \brief Get TDO status on Ethernut 3. */
  124. #define GET_TDO() (inr(PIO_PDSR) & _BV(19))
  125. #else
  126. /* Generic routines, do nothing. */
  127. #define SET_TMS()
  128. #define CLR_TMS()
  129. #define SET_TDI()
  130. #define CLR_TDI()
  131. #define SET_TCK()
  132. #define CLR_TCK()
  133. #define GET_TDO() (0)
  134. #endif
  135. /*! \brief Set TMS high and toggle TCK. */
  136. #define SET_TMS_TCK() { SET_TMS(); CLR_TCK(); SET_TCK(); }
  137. /*! \brief Set TMS low and toggle TCK. */
  138. #define CLR_TMS_TCK() { CLR_TMS(); CLR_TCK(); SET_TCK(); }
  139. extern int XsvfInit(void);
  140. extern void XsvfExit(int rc);
  141. extern int XsvfGetError(void);
  142. extern uint8_t XsvfGetCmd(void);
  143. extern uint8_t XsvfGetState(uint8_t state0, uint8_t state1);
  144. extern uint8_t XsvfGetByte(void);
  145. extern short XsvfGetShort(void);
  146. extern long XsvfGetLong(void);
  147. extern int XsvfReadBitString(void *buf, int num);
  148. extern int XsvfSkipComment(void);
  149. extern void XsvfDelay(long usecs);
  150. /*@}*/
  151. #endif