cpu_def.h 10 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185
  1. /*
  2. *********************************************************************************************************
  3. * uC/CPU
  4. * CPU CONFIGURATION & PORT LAYER
  5. *
  6. * (c) Copyright 2004-2011; Micrium, Inc.; Weston, FL
  7. *
  8. * All rights reserved. Protected by international copyright laws.
  9. *
  10. * uC/CPU is provided in source form to registered licensees ONLY. It is
  11. * illegal to distribute this source code to any third party unless you receive
  12. * written permission by an authorized Micrium representative. Knowledge of
  13. * the source code may NOT be used to develop a similar product.
  14. *
  15. * Please help us continue to provide the Embedded community with the finest
  16. * software available. Your honesty is greatly appreciated.
  17. *
  18. * You can contact us at www.micrium.com.
  19. *********************************************************************************************************
  20. */
  21. /*
  22. *********************************************************************************************************
  23. *
  24. * CPU CONFIGURATION DEFINES
  25. *
  26. * Filename : cpu_def.h
  27. * Version : V1.28.01
  28. * Programmer(s) : ITJ
  29. *********************************************************************************************************
  30. */
  31. /*
  32. *********************************************************************************************************
  33. * MODULE
  34. *********************************************************************************************************
  35. */
  36. #ifndef CPU_DEF_MODULE_PRESENT
  37. #define CPU_DEF_MODULE_PRESENT
  38. /*
  39. *********************************************************************************************************
  40. * CPU WORD CONFIGURATION
  41. *
  42. * Note(s) : (1) Configure CPU_CFG_ADDR_SIZE & CPU_CFG_DATA_SIZE in 'cpu.h' with CPU's word sizes :
  43. *
  44. * CPU_WORD_SIZE_08 8-bit word size
  45. * CPU_WORD_SIZE_16 16-bit word size
  46. * CPU_WORD_SIZE_32 32-bit word size
  47. * CPU_WORD_SIZE_64 64-bit word size
  48. *
  49. * (2) Configure CPU_CFG_ENDIAN_TYPE in 'cpu.h' with CPU's data-word-memory order :
  50. *
  51. * (a) CPU_ENDIAN_TYPE_BIG Big- endian word order (CPU words' most significant
  52. * octet @ lowest memory address)
  53. * (b) CPU_ENDIAN_TYPE_LITTLE Little-endian word order (CPU words' least significant
  54. * octet @ lowest memory address)
  55. *********************************************************************************************************
  56. */
  57. /* ---------------------- CPU WORD SIZE ----------------------- */
  58. #define CPU_WORD_SIZE_08 1u /* 8-bit word size (in octets). */
  59. #define CPU_WORD_SIZE_16 2u /* 16-bit word size (in octets). */
  60. #define CPU_WORD_SIZE_32 4u /* 32-bit word size (in octets). */
  61. #define CPU_WORD_SIZE_64 8u /* 64-bit word size (in octets). */
  62. /* ------------------ CPU WORD-ENDIAN ORDER ------------------- */
  63. #define CPU_ENDIAN_TYPE_NONE 0u
  64. #define CPU_ENDIAN_TYPE_BIG 1u /* Big- endian word order (see Note #1a). */
  65. #define CPU_ENDIAN_TYPE_LITTLE 2u /* Little-endian word order (see Note #1b). */
  66. /*
  67. *********************************************************************************************************
  68. * CPU STACK CONFIGURATION
  69. *
  70. * Note(s) : (1) Configure CPU_CFG_STK_GROWTH in 'cpu.h' with CPU's stack growth order :
  71. *
  72. * (a) CPU_STK_GROWTH_LO_TO_HI CPU stack pointer increments to the next higher stack
  73. * memory address after data is pushed onto the stack
  74. * (b) CPU_STK_GROWTH_HI_TO_LO CPU stack pointer decrements to the next lower stack
  75. * memory address after data is pushed onto the stack
  76. *********************************************************************************************************
  77. */
  78. /* ------------------ CPU STACK GROWTH ORDER ------------------ */
  79. #define CPU_STK_GROWTH_NONE 0u
  80. #define CPU_STK_GROWTH_LO_TO_HI 1u /* CPU stk incs towards higher mem addrs (see Note #1a). */
  81. #define CPU_STK_GROWTH_HI_TO_LO 2u /* CPU stk decs towards lower mem addrs (see Note #1b). */
  82. /*$PAGE*/
  83. /*
  84. *********************************************************************************************************
  85. * CRITICAL SECTION CONFIGURATION
  86. *
  87. * Note(s) : (1) Configure CPU_CFG_CRITICAL_METHOD with CPU's/compiler's critical section method :
  88. *
  89. * Enter/Exit critical sections by ...
  90. *
  91. * CPU_CRITICAL_METHOD_INT_DIS_EN Disable/Enable interrupts
  92. * CPU_CRITICAL_METHOD_STATUS_STK Push/Pop interrupt status onto stack
  93. * CPU_CRITICAL_METHOD_STATUS_LOCAL Save/Restore interrupt status to local variable
  94. *
  95. * (a) CPU_CRITICAL_METHOD_INT_DIS_EN is NOT a preferred method since it does NOT support
  96. * multiple levels of interrupts. However, with some CPUs/compilers, this is the only
  97. * available method.
  98. *
  99. * (b) CPU_CRITICAL_METHOD_STATUS_STK is one preferred method since it supports multiple
  100. * levels of interrupts. However, this method assumes that the compiler provides C-level
  101. * &/or assembly-level functionality for the following :
  102. *
  103. * ENTER CRITICAL SECTION :
  104. * (1) Push/save interrupt status onto a local stack
  105. * (2) Disable interrupts
  106. *
  107. * EXIT CRITICAL SECTION :
  108. * (3) Pop/restore interrupt status from a local stack
  109. *
  110. * (c) CPU_CRITICAL_METHOD_STATUS_LOCAL is one preferred method since it supports multiple
  111. * levels of interrupts. However, this method assumes that the compiler provides C-level
  112. * &/or assembly-level functionality for the following :
  113. *
  114. * ENTER CRITICAL SECTION :
  115. * (1) Save interrupt status into a local variable
  116. * (2) Disable interrupts
  117. *
  118. * EXIT CRITICAL SECTION :
  119. * (3) Restore interrupt status from a local variable
  120. *
  121. * (2) Critical section macro's most likely require inline assembly. If the compiler does NOT
  122. * allow inline assembly in C source files, critical section macro's MUST call an assembly
  123. * subroutine defined in a 'cpu_a.asm' file located in the following software directory :
  124. *
  125. * \<CPU-Compiler Directory>\<cpu>\<compiler>\
  126. *
  127. * where
  128. * <CPU-Compiler Directory> directory path for common CPU-compiler software
  129. * <cpu> directory name for specific CPU
  130. * <compiler> directory name for specific compiler
  131. *
  132. * (3) (a) To save/restore interrupt status, a local variable 'cpu_sr' of type 'CPU_SR' MAY need
  133. * to be declared (e.g. if 'CPU_CRITICAL_METHOD_STATUS_LOCAL' method is configured).
  134. *
  135. * (1) 'cpu_sr' local variable SHOULD be declared via the CPU_SR_ALLOC() macro which,
  136. * if used, MUST be declared following ALL other local variables (see any 'cpu.h
  137. * CRITICAL SECTION CONFIGURATION Note #3a1').
  138. *
  139. * Example :
  140. *
  141. * void Fnct (void)
  142. * {
  143. * CPU_INT08U val_08;
  144. * CPU_INT16U val_16;
  145. * CPU_INT32U val_32;
  146. * CPU_SR_ALLOC(); MUST be declared after ALL other local variables
  147. * :
  148. * :
  149. * }
  150. *
  151. * (b) Configure 'CPU_SR' data type with the appropriate-sized CPU data type large enough to
  152. * completely store the CPU's/compiler's status word.
  153. *********************************************************************************************************
  154. */
  155. /* --------------- CPU CRITICAL SECTION METHODS --------------- */
  156. #define CPU_CRITICAL_METHOD_NONE 0u /* */
  157. #define CPU_CRITICAL_METHOD_INT_DIS_EN 1u /* DIS/EN ints (see Note #1a). */
  158. #define CPU_CRITICAL_METHOD_STATUS_STK 2u /* Push/Pop int status onto stk (see Note #1b). */
  159. #define CPU_CRITICAL_METHOD_STATUS_LOCAL 3u /* Save/Restore int status to local var (see Note #1c). */
  160. /*$PAGE*/
  161. /*
  162. *********************************************************************************************************
  163. * MODULE END
  164. *********************************************************************************************************
  165. */
  166. #endif /* End of CPU definition module include. */