gba.h 10 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241
  1. #ifndef _ARCH_GBA_H_
  2. #define _ARCH_GBA_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. * $Log: gba.h,v $
  36. * Revision 1.1 2005/10/24 10:31:13 haraldkipp
  37. * Moved from parent directory.
  38. *
  39. * Revision 1.2 2005/04/05 17:50:47 haraldkipp
  40. * Use register names in gba.h.
  41. *
  42. * Revision 1.1 2004/11/24 15:26:34 haraldkipp
  43. * Will fill this later
  44. *
  45. */
  46. /*!
  47. * \brief Internal work RAM
  48. */
  49. #define WRAM_START 0x03000000 /* Start of internal work RAM */
  50. #define WRAM_END (WRAM_START + 0x8000) /* End of internal work RAM */
  51. #define INT_VECTOR (WRAM_END - 4) /* Interrupt vector address. */
  52. /*!
  53. * \brief Display control
  54. */
  55. #define REG_DISPCNT 0x04000000 /* Display control */
  56. #define REG_STAT 0x04000004 /* Display status */
  57. #define REG_VCOUNT 0x04000006 /* Vertical counter */
  58. #define REG_BG0CNT 0x04000008 /* BG 0 control */
  59. #define REG_BG1CNT 0x0400000a /* BG 1 control */
  60. #define REG_BG2CNT 0x0400000c /* BG 2 control */
  61. #define REG_BG3CNT 0x0400000e /* BG 3 control */
  62. #define REG_BG0HOFS 0x04000010 /* BG 0 horizontal offset */
  63. #define REG_BG0VOFS 0x04000012 /* BG 0 vertical offset */
  64. #define REG_BG1HOFS 0x04000014 /* BG 1 horizontal offset */
  65. #define REG_BG1VOFS 0x04000016 /* BG 1 vertical offset */
  66. #define REG_BG2HOFS 0x04000018 /* BG 2 horizontal offset */
  67. #define REG_BG2VOFS 0x0400001a /* BG 2 vertical offset */
  68. #define REG_BG3HOFS 0x0400001c /* BG 3 horizontal offset */
  69. #define REG_BG3VOFS 0x0400001e /* BG 3 vertical offset */
  70. #define REG_BG2PA 0x04000020 /* BG 2 Rotation/scaling parameter A */
  71. #define REG_BG2PB 0x04000022 /* BG 2 Rotation/scaling parameter B */
  72. #define REG_BG2PC 0x04000024 /* BG 2 Rotation/scaling parameter C */
  73. #define REG_BG2PD 0x04000026 /* BG 2 Rotation/scaling parameter D */
  74. #define REG_BG2X 0x04000028 /* BG 2 Reference point X coordinate */
  75. #define REG_BG2Y 0x0400002c /* BG 2 Reference point Y coordinate */
  76. #define REG_BG3PA 0x04000030 /* BG 3 Rotation/scaling parameter A */
  77. #define REG_BG3PB 0x04000032 /* BG 3 Rotation/scaling parameter B */
  78. #define REG_BG3PC 0x04000034 /* BG 3 Rotation/scaling parameter C */
  79. #define REG_BG3PD 0x04000036 /* BG 3 Rotation/scaling parameter D */
  80. #define REG_BG3X 0x04000038 /* BG 3 Reference point X coordinate */
  81. #define REG_BG3Y 0x0400003c /* BG 3 Reference point Y coordinate */
  82. #define REG_WINCNT 0x04000040 /* Window control */
  83. #define REG_WININ 0x04000048 /* Inside window control */
  84. #define REG_WINOUT 0x0400004a /* Outside window control */
  85. #define REG_MOSAIC 0x0400004c /* Mosaic size */
  86. #define REG_BLDCNT 0x04000050 /* Blending control */
  87. #define REG_BLDALPHA 0x04000052 /* Alpha blending */
  88. #define REG_BLDY 0x04000054 /* Brightness fading */
  89. /*!
  90. * \brief Sound control
  91. */
  92. #define REG_SOUND1CNT 0x04000060 /* Channel 1 control */
  93. #define REG_SOUND2CNT 0x04000068 /* Channel 2 control */
  94. #define REG_SOUND3CNT 0x04000070 /* Channel 3 control */
  95. #define REG_SOUND4CNT 0x04000078 /* Channel 4 control */
  96. #define REG_SOUNDCNT 0x04000080 /* Sound control */
  97. #define REG_SOUNDBIAS 0x04000088 /* Sound PWM control */
  98. #define REG_WAVE_RAM0 0x04000090 /* Channel 3 wave pattern RAM bank 0 */
  99. #define REG_WAVE_RAM1 0x04000094 /* Channel 3 wave pattern RAM bank 1 */
  100. #define REG_WAVE_RAM2 0x04000098 /* Channel 3 wave pattern RAM bank 2 */
  101. #define REG_WAVE_RAM3 0x0400009c /* Channel 3 wave pattern RAM bank 3 */
  102. #define REG_FIFO_A 0x040000a0 /* Channel A FIFO */
  103. #define REG_FIFO_B 0x040000a4 /* Channel B FIFO */
  104. /*!
  105. * \brief DMA control
  106. */
  107. #define REG_DMA0SAD 0x040000b0 /* DMA 0 source address */
  108. #define REG_DMA0DAD 0x040000b4 /* DMA 0 destination address */
  109. #define REG_DMA0CNT 0x040000b8 /* DMA 0 word count */
  110. #define REG_DMA1SAD 0x040000bc /* DMA 1 source address */
  111. #define REG_DMA1DAD 0x040000c0 /* DMA 1 destination address */
  112. #define REG_DMA1CNT 0x040000c4 /* DMA 1 word count */
  113. #define REG_DMA2SAD 0x040000c8 /* DMA 2 source address */
  114. #define REG_DMA2DAD 0x040000cc /* DMA 2 destination address */
  115. #define REG_DMA2CNT 0x040000d0 /* DMA 2 word count */
  116. #define REG_DMA3SAD 0x040000d4 /* DMA 3 source address */
  117. #define REG_DMA3DAD 0x040000d8 /* DMA 3 destination address */
  118. #define REG_DMA3CNT 0x040000dc /* DMA 3 word count */
  119. /*!
  120. * \brief Timer control
  121. */
  122. #define REG_TMR0CNT 0x04000100 /* Timer 0 control */
  123. #define REG_TMR1CNT 0x04000104 /* Timer 1 control */
  124. #define REG_TMR2CNT 0x04000108 /* Timer 2 control */
  125. #define REG_TMR3CNT 0x0400010c /* Timer 3 control */
  126. /*!
  127. * \brief Serial communication control
  128. */
  129. #define REG_SIODATA32 0x04000120 /* 32-bit serial data */
  130. #define REG_SIOCNT 0x04000128 /* Serial communication control */
  131. #define REG_SIODATA8 0x0400012a /* 8-bit serial data */
  132. /*!
  133. * \brief Keyboard control
  134. */
  135. #define REG_KEYINPUT 0x04000130 /* Key status */
  136. #define REG_KEYCNT 0x04000132 /* Key control */
  137. /*!
  138. * \brief General I/O control
  139. */
  140. #define REG_RCNT 0x04000134 /* General I/O control */
  141. /*!
  142. * \brief JOY Bus control
  143. */
  144. #define REG_JOYCNT 0x04000140 /* JOY Bus control */
  145. #define REG_JOYSTAT 0x04000158 /* JOY Bus status */
  146. #define REG_JOY_RECV 0x04000150 /* JOY Bus receive data */
  147. #define REG_JOY_TRANS 0x04000154 /* JOY Bus transmit data */
  148. /*!
  149. * \brief Interrupt control
  150. */
  151. #define REG_IE 0x04000200 /* Interrupt enable */
  152. #define REG_IF 0x04000202 /* Interrupt flags */
  153. #define REG_WAITCNT 0x04000204 /* Game Pak wait state control */
  154. #define REG_IME 0x04000208 /* Interrupt master enable */
  155. /*!
  156. * \brief Interrupt flags.
  157. */
  158. #define INT_VBLANK 0x0001 /* V blank interrupt flag. */
  159. #define INT_HBLANK 0x0002 /* H blank interrupt flag. */
  160. #define INT_VCOUNT 0x0004 /* V counter interrupt flag. */
  161. #define INT_TMR0 0x0008 /* Timer 0 interrupt flag. */
  162. #define INT_TMR1 0x0010 /* Timer 1 interrupt flag. */
  163. #define INT_TMR2 0x0020 /* Timer 2 interrupt flag. */
  164. #define INT_TMR3 0x0040 /* Timer 3 interrupt flag. */
  165. #define INT_SIO 0x0080 /* Serial communication interrupt flag. */
  166. #define INT_DMA0 0x0100 /* DMA 0 interrupt flag. */
  167. #define INT_DMA1 0x0200 /* DMA 1 interrupt flag. */
  168. #define INT_DMA2 0x0400 /* DMA 2 interrupt flag. */
  169. #define INT_DMA3 0x0800 /* DMA 3 interrupt flag. */
  170. #define INT_KEYPAD 0x1000 /* Key Pad interrupt flag. */
  171. #define INT_GAMEPAK 0x2000 /* Game Pak interrupt flag. */
  172. /*!
  173. * \brief Power management control
  174. */
  175. #define REG_HALTCNT 0x04000300 /* Power down control */
  176. #define outw(_reg, _val) (*((volatile unsigned short *)(_reg)) = (_val))
  177. #define outdw(_reg, _val) (*((volatile unsigned long *)(_reg)) = (_val))
  178. #define inw(_reg) (*((volatile unsigned short *)(_reg)))
  179. #define indw(_reg) (*((volatile unsigned long *)(_reg)))
  180. #define GBAKEY_A 0x0001
  181. #define GBAKEY_B 0x0002
  182. #define GBAKEY_SELECT 0x0003
  183. #define GBAKEY_START 0x0008
  184. #define GBAKEY_RIGHT 0x0010
  185. #define GBAKEY_LEFT 0x0020
  186. #define GBAKEY_UP 0x0040
  187. #define GBAKEY_DOWN 0x0080
  188. #define GBAKEY_R 0x0100
  189. #define GBAKEY_L 0x0200
  190. /*!
  191. * \brief Timer control.
  192. */
  193. #define TMR_PRE_64 0x00010000 /* Prescaler 64 */
  194. #define TMR_PRE_256 0x00020000 /* Prescaler 256 */
  195. #define TMR_PRE_1024 0x00030000 /* Prescaler 1024 */
  196. #define TMR_IRQ_ENA 0x00400000 /* Interrupt request enable */
  197. #define TMR_ENA 0x00800000 /* Timer enable. */
  198. /*!
  199. * \brief SIO control.
  200. */
  201. #define SIO_BAUD_9600 0x0000
  202. #define SIO_BAUD_38400 0x0001
  203. #define SIO_BAUD_57600 0x0002
  204. #define SIO_BAUD_115200 0x0003
  205. #define SIO_CTS_ENA 0x0004
  206. #define SIO_PARITY_ODD 0x0008
  207. #define SIO_TX_FULL 0x0010
  208. #define SIO_RX_EMPTY 0x0020
  209. #define SIO_ERROR 0x0040
  210. #define SIO_DATA_8BIT 0x0080
  211. #define SIO_FIFO_ENA 0x0100
  212. #define SIO_PARITY_ENA 0x0200
  213. #define SIO_SEND_ENA 0x0400
  214. #define SIO_RECV_ENA 0x0800
  215. #define SIO_MODE_32BIT 0x1000
  216. #define SIO_MODE_MULTI 0x2000
  217. #define SIO_MODE_UART 0x3000
  218. #define SIO_IRQ_ENA 0x4000
  219. #endif