at91.h 5.5 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166
  1. #ifndef _ARCH_ARM_AT91_H_
  2. #define _ARCH_ARM_AT91_H_
  3. /*
  4. * Copyright (C) 2005 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 EGNITE SOFTWARE GMBH 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 EGNITE
  23. * SOFTWARE GMBH 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. * \file arch/arm/at91.h
  36. * \brief AT91 peripherals.
  37. *
  38. * \verbatim
  39. *
  40. * $Log: at91.h,v $
  41. * Revision 1.10 2006/08/31 19:04:08 haraldkipp
  42. * Added support for the AT91SAM9260 and Atmel's AT91SAM9260 Evaluation Kit.
  43. *
  44. * Revision 1.9 2006/08/01 07:35:59 haraldkipp
  45. * Exclude function prototypes when included by assembler.
  46. *
  47. * Revision 1.8 2006/07/05 07:45:25 haraldkipp
  48. * Split on-chip interface definitions.
  49. *
  50. * Revision 1.7 2006/06/28 17:22:34 haraldkipp
  51. * Make it compile for AT91SAM7X256.
  52. *
  53. * Revision 1.6 2006/05/25 09:09:57 haraldkipp
  54. * API documentation updated and corrected.
  55. *
  56. * Revision 1.5 2006/04/07 12:57:00 haraldkipp
  57. * Fast interrupt doesn't require to store R8-R12.
  58. *
  59. * Revision 1.4 2006/03/02 20:02:56 haraldkipp
  60. * Added ICCARM interrupt entry code. Probably not working, because I
  61. * excluded an immediate load.
  62. *
  63. * Revision 1.3 2006/01/05 16:52:49 haraldkipp
  64. * Baudrate calculation is now based on NutGetCpuClock().
  65. * The AT91_US_BAUD macro had been marked deprecated.
  66. *
  67. * Revision 1.2 2005/11/20 14:44:14 haraldkipp
  68. * Register offsets added.
  69. *
  70. * Revision 1.1 2005/10/24 10:31:13 haraldkipp
  71. * Moved from parent directory.
  72. *
  73. *
  74. * \endverbatim
  75. */
  76. #if defined (MCU_AT91R40008)
  77. #include <arch/arm/at91x40.h>
  78. #elif defined (MCU_AT91SAM7X256)
  79. #include <arch/arm/at91sam7x.h>
  80. #elif defined (MCU_AT91SAM9260)
  81. #include <arch/arm/at91sam9260.h>
  82. #endif
  83. /*! \addtogroup xgNutArchArmAt91 */
  84. /*@{*/
  85. #ifdef __GNUC__
  86. /*!
  87. * \brief Interrupt entry.
  88. */
  89. #define IRQ_ENTRY() \
  90. asm volatile("sub lr, lr,#4" "\n\t" /* Adjust LR */ \
  91. "stmfd sp!,{r0-r12,lr}" "\n\t" /* Save registers on IRQ stack. */ \
  92. "mrs r1, spsr" "\n\t" /* Save SPSR */ \
  93. "stmfd sp!,{r1}" "\n\t") /* */
  94. /*!
  95. * \brief Interrupt exit.
  96. */
  97. #define IRQ_EXIT() \
  98. asm volatile("ldmfd sp!, {r1}" "\n\t" /* Restore SPSR */ \
  99. "msr spsr_c, r1" "\n\t" /* */ \
  100. "ldr r0, =0xFFFFF000" "\n\t" /* End of interrupt. */ \
  101. "str r0, [r0, #0x130]" "\n\t" /* */ \
  102. "ldmfd sp!, {r0-r12, pc}^" "\n\t") /* Restore registers and return. */
  103. /*!
  104. * \brief Fast interrupt entry.
  105. */
  106. #define FIQ_ENTRY() \
  107. asm volatile("sub lr, lr,#4" "\n\t" /* Adjust LR */ \
  108. "stmfd sp!,{r0-r7,lr}" "\n\t" /* Save registers on IRQ stack. */ \
  109. "mrs r1, spsr" "\n\t" /* Save SPSR */ \
  110. "stmfd sp!,{r1}" "\n\t") /* */
  111. /*!
  112. * \brief Fast interrupt exit.
  113. */
  114. #define FIQ_EXIT() \
  115. asm volatile("ldmfd sp!, {r1}" "\n\t" /* Restore SPSR */ \
  116. "msr spsr_c, r1" "\n\t" /* */ \
  117. "ldr r0, =0xFFFFF000" "\n\t" /* End of interrupt. */ \
  118. "str r0, [r0, #0x130]" "\n\t" /* */ \
  119. "ldmfd sp!, {r0-r7, pc}^" "\n\t") /* Restore registers and return. */
  120. #else /* __IMAGECRAFT__ */
  121. #define IRQ_ENTRY() \
  122. asm("sub lr, lr,#4\n" \
  123. "stmfd sp!,{r0-r12,lr}\n" \
  124. "mrs r1, spsr\n" \
  125. "stmfd sp!,{r1}\n")
  126. #define IRQ_EXIT() \
  127. asm("ldmfd sp!, {r1}\n" \
  128. "msr spsr_c, r1\n" \
  129. ";ldr r0, =0xFFFFF000\n" /* ICCARM: FIXME! */ \
  130. "str r0, [r0, #0x130]\n" \
  131. "ldmfd sp!, {r0-r12, pc}^")
  132. #define FIQ_ENTRY() \
  133. asm("sub lr, lr,#4\n" \
  134. "stmfd sp!,{r0-r7,lr}\n" \
  135. "mrs r1, spsr\n" \
  136. "stmfd sp!,{r1}\n")
  137. #define FIQ_EXIT() \
  138. asm("ldmfd sp!, {r1}\n" \
  139. "msr spsr_c, r1\n" \
  140. ";ldr r0, =0xFFFFF000\n" /* ICCARM: FIXME! */ \
  141. "str r0, [r0, #0x130]\n" \
  142. "ldmfd sp!, {r0-r7, pc}^")
  143. #endif
  144. /*@} xgNutArchArmAt91 */
  145. #ifndef __ASSEMBLER__
  146. extern void McuInit(void);
  147. #endif
  148. #endif /* _ARCH_ARM_AT91_H_ */