npl.h 7.0 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171
  1. #ifndef _DEV_NPL_H_
  2. #define _DEV_NPL_H_
  3. /*
  4. * Copyright (C) 2005 by egnite Software GmbH
  5. * Copyright (C) 2009 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. */
  37. #include <dev/irqreg.h>
  38. /*!
  39. * \file dev/npl.h
  40. * \brief Nut Programmable Logic Header File
  41. *
  42. * \verbatim
  43. * $Id: npl.h 4477 2012-08-20 17:50:01Z haraldkipp $
  44. * \endverbatim
  45. */
  46. /*!
  47. * \addtogroup xgNpl
  48. */
  49. /*@{*/
  50. /*!
  51. * \brief CPLD register base address.
  52. *
  53. * On Ethernut 3 the CPLD is selected via NCS2 (GPIO 27), which
  54. * is configured to 0x21000000 - 0x210FFFFF in the CRT initialization
  55. * startup file.
  56. */
  57. #ifndef NPL_BASE
  58. #if defined(ETHERNUT3)
  59. #define NPL_BASE 0x21000000
  60. #else
  61. #define NPL_BASE 0xFF00
  62. #endif
  63. #endif
  64. /*! \brief RS232 command register.
  65. */
  66. #define NPL_RSCR _SFR_MEM8(NPL_BASE + 0x00)
  67. #define NPL_RSFON_BIT 0 /*!< \brief Force on bit. */
  68. #define NPL_RSFON (1 << NPL_RSFON_BIT) /*!< \brief Force on mask. */
  69. #define NPL_RSFOFF_BIT 1 /*!< \brief Force off bit. */
  70. #define NPL_RSFOFF (1 << NPL_RSFOFF_BIT) /*!< \brief Force off mask. */
  71. #define NPL_RSDTR_BIT 2 /*!< \brief DTR handshake bit. */
  72. #define NPL_RSDTR (1 << NPL_RSDTR_BIT) /*!< \brief DTR handshake mask. */
  73. #define NPL_RSRTS_BIT 3 /*!< \brief RTS handshake bit. */
  74. #define NPL_RSRTS (1 << NPL_RSRTS_BIT) /*!< \brief RTS handshake mask. */
  75. #define NPL_RSUS0E_BIT 5 /*!< \brief USART0 select bit. */
  76. #define NPL_RSUS0E (1 << NPL_RSUS0E_BIT) /*!< \brief USART0 select mask. */
  77. #define NPL_RSUS1E_BIT 6 /*!< \brief USART1 select bit. */
  78. #define NPL_RSUS1E (1 << NPL_RSUS1E_BIT) /*!< \brief USART1 select mask. */
  79. #define NPL_RSUS1P_BIT 7 /*!< \brief USART1 primary bit. */
  80. #define NPL_RSUS1P (1 << NPL_RSUS1P_BIT) /*!< \brief USART1 primary mask. */
  81. /*! \brief Interrupt mask register.
  82. */
  83. #define NPL_IMR _SFR_MEM16(NPL_BASE + 0x04)
  84. /*! \brief SPI clock divider register.
  85. */
  86. #define NPL_SPICTRL _SFR_MEM8(NPL_BASE + 0x08)
  87. /*! \brief Signal latch register.
  88. */
  89. #define NPL_SLR _SFR_MEM16(NPL_BASE + 0x0C)
  90. /*! \brief Signal clear register.
  91. */
  92. #define NPL_SCR _SFR_MEM16(NPL_BASE + 0x10)
  93. /*! \brief Status register.
  94. */
  95. #define NPL_STATUS _SFR_MEM16(NPL_BASE + 0x10)
  96. #define NPL_RSCTS_BIT 0 /*!< \brief RS232 CTS interrupt bit. */
  97. #define NPL_RSCTS (1 << NPL_RSCTS_BIT) /*!< \brief RS232 CTS interrupt mask. */
  98. #define NPL_RSDSR_BIT 1 /*!< \brief RS232 DSR interrupt bit. */
  99. #define NPL_RSDSR (1 << NPL_RSDSR_BIT) /*!< \brief RS232 DSR interrupt mask. */
  100. #define NPL_RSDCD_BIT 2 /*!< \brief RS232 DCD interrupt bit. */
  101. #define NPL_RSDCD (1 << NPL_RSDCD_BIT) /*!< \brief RS232 DCD interrupt mask. */
  102. #define NPL_RSRI_BIT 3 /*!< \brief RS232 RI interrupt bit. */
  103. #define NPL_RSRI (1 << NPL_RSRI_BIT) /*!< \brief RS232 RI interrupt mask. */
  104. #define NPL_RTCALARM_BIT 4 /*!< \brief RTC alarm interrupt bit. */
  105. #define NPL_RTCALARM (1 << NPL_RTCALARM_BIT) /*!< \brief RTC alarm interrupt mask. */
  106. #define NPL_LANWAKEUP_BIT 5 /*!< \brief NIC wakeup interrupt bit. */
  107. #define NPL_LANWAKEUP (1 << NPL_LANWAKEUP_BIT)/*!< \brief NIC wakeup interrupt mask. */
  108. #define NPL_FMBUSY_BIT 6 /*!< \brief FLASH ready interrupt bit. */
  109. #define NPL_FMBUSY (1 << NPL_FMBUSY_BIT) /*!< \brief FLASH ready interrupt mask. */
  110. #define NPL_MMCREADY_BIT 7 /*!< \brief MMC shift register ready bit. */
  111. #define NPL_MMCREADY (1 << NPL_MMCREADY_BIT) /*!< \brief MMC shift register ready mask. */
  112. #define NPL_RSINVAL_BIT 8 /*!< \brief RS232 invalid interrupt bit. */
  113. #define NPL_RSINVAL (1 << NPL_RSINVAL_BIT) /*!< \brief RS232 invalid interrupt mask. */
  114. #define NPL_NRSINVAL_BIT 9 /*!< \brief RS232 valid interrupt bit. */
  115. #define NPL_NRSINVAL (1 << NPL_NRSINVAL_BIT) /*!< \brief RS232 valid interrupt mask. */
  116. #define NPL_MMCD_BIT 10 /*!< \brief MMC insert interrupt bit. */
  117. #define NPL_MMCD (1 << NPL_MMCD_BIT) /*!< \brief MMC insert interrupt mask. */
  118. #define NPL_NMMCD_BIT 11 /*!< \brief MMC remove interrupt bit. */
  119. #define NPL_NMMCD (1 << NPL_NMMCD_BIT) /*!< \brief MMC remove interrupt mask. */
  120. /*! \brief MMC data register.
  121. */
  122. #define NPL_MMCDR _SFR_MEM8(NPL_BASE + 0x14)
  123. /*! \brief External enable register.
  124. */
  125. #define NPL_XER _SFR_MEM8(NPL_BASE + 0x18)
  126. #define NPL_MMCS 0x0001 /*!< \brief MMC select. */
  127. #define NPL_PANCS 0x0002 /*!< \brief Panel select. */
  128. #define NPL_USRLED 0x0004 /*!< \brief User LED. */
  129. #define NPL_NPCS0 0x0008 /*!< \brief DataFlash CS. */
  130. /*! \brief Version identifier register.
  131. */
  132. #define NPL_VIDR _SFR_MEM8(NPL_BASE + 0x1C)
  133. extern IRQ_HANDLER sig_RSCTS;
  134. extern IRQ_HANDLER sig_RSDSR;
  135. extern IRQ_HANDLER sig_RSDCD;
  136. extern IRQ_HANDLER sig_RSRI;
  137. extern IRQ_HANDLER sig_RTCALARM;
  138. extern IRQ_HANDLER sig_LANWAKEUP;
  139. extern IRQ_HANDLER sig_FMBUSY;
  140. extern IRQ_HANDLER sig_MMCREADY;
  141. extern IRQ_HANDLER sig_RSINVAL;
  142. extern IRQ_HANDLER sig_NRSINVAL;
  143. extern IRQ_HANDLER sig_MMCD;
  144. extern IRQ_HANDLER sig_NMMCD;
  145. extern int NplRegisterIrqHandler(IRQ_HANDLER * irq, void (*handler) (void *), void *arg);
  146. extern int NplIrqEnable(IRQ_HANDLER * irq);
  147. extern int NplIrqDisable(IRQ_HANDLER * irq);
  148. /*@}*/
  149. #endif