Nut/OS  4.10.3
API Reference
gba.h
Go to the documentation of this file.
00001 #ifndef _ARCH_GBA_H_
00002 #define _ARCH_GBA_H_
00003 
00004 /*
00005  * Copyright (C) 2005 by egnite Software GmbH. All rights reserved.
00006  *
00007  * Redistribution and use in source and binary forms, with or without
00008  * modification, are permitted provided that the following conditions
00009  * are met:
00010  *
00011  * 1. Redistributions of source code must retain the above copyright
00012  *    notice, this list of conditions and the following disclaimer.
00013  * 2. Redistributions in binary form must reproduce the above copyright
00014  *    notice, this list of conditions and the following disclaimer in the
00015  *    documentation and/or other materials provided with the distribution.
00016  * 3. Neither the name of the copyright holders nor the names of
00017  *    contributors may be used to endorse or promote products derived
00018  *    from this software without specific prior written permission.
00019  *
00020  * THIS SOFTWARE IS PROVIDED BY EGNITE SOFTWARE GMBH AND CONTRIBUTORS
00021  * ``AS IS'' AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
00022  * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS
00023  * FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL EGNITE
00024  * SOFTWARE GMBH OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT,
00025  * INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING,
00026  * BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS
00027  * OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED
00028  * AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY,
00029  * OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF
00030  * THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
00031  * SUCH DAMAGE.
00032  *
00033  * For additional information see http://www.ethernut.de/
00034  */
00035 
00036 /*
00037  * $Log$
00038  * Revision 1.1  2005/10/24 10:31:13  haraldkipp
00039  * Moved from parent directory.
00040  *
00041  * Revision 1.2  2005/04/05 17:50:47  haraldkipp
00042  * Use register names in gba.h.
00043  *
00044  * Revision 1.1  2004/11/24 15:26:34  haraldkipp
00045  * Will fill this later
00046  *
00047  */
00048 
00049 
00053 #define WRAM_START      0x03000000      /* Start of internal work RAM */
00054 #define WRAM_END        (WRAM_START + 0x8000)   /* End of internal work RAM */
00055 #define INT_VECTOR      (WRAM_END - 4)  /* Interrupt vector address. */
00056 
00060 #define REG_DISPCNT     0x04000000      /* Display control */
00061 #define REG_STAT        0x04000004      /* Display status */
00062 #define REG_VCOUNT      0x04000006      /* Vertical counter */
00063 #define REG_BG0CNT      0x04000008      /* BG 0 control */
00064 #define REG_BG1CNT      0x0400000a      /* BG 1 control */
00065 #define REG_BG2CNT      0x0400000c      /* BG 2 control */
00066 #define REG_BG3CNT      0x0400000e      /* BG 3 control */
00067 #define REG_BG0HOFS     0x04000010      /* BG 0 horizontal offset */
00068 #define REG_BG0VOFS     0x04000012      /* BG 0 vertical offset */
00069 #define REG_BG1HOFS     0x04000014      /* BG 1 horizontal offset */
00070 #define REG_BG1VOFS     0x04000016      /* BG 1 vertical offset */
00071 #define REG_BG2HOFS     0x04000018      /* BG 2 horizontal offset */
00072 #define REG_BG2VOFS     0x0400001a      /* BG 2 vertical offset */
00073 #define REG_BG3HOFS     0x0400001c      /* BG 3 horizontal offset */
00074 #define REG_BG3VOFS     0x0400001e      /* BG 3 vertical offset */
00075 #define REG_BG2PA       0x04000020      /* BG 2 Rotation/scaling parameter A */
00076 #define REG_BG2PB       0x04000022      /* BG 2 Rotation/scaling parameter B */
00077 #define REG_BG2PC       0x04000024      /* BG 2 Rotation/scaling parameter C */
00078 #define REG_BG2PD       0x04000026      /* BG 2 Rotation/scaling parameter D */
00079 #define REG_BG2X        0x04000028      /* BG 2 Reference point X coordinate */
00080 #define REG_BG2Y        0x0400002c      /* BG 2 Reference point Y coordinate */
00081 #define REG_BG3PA       0x04000030      /* BG 3 Rotation/scaling parameter A */
00082 #define REG_BG3PB       0x04000032      /* BG 3 Rotation/scaling parameter B */
00083 #define REG_BG3PC       0x04000034      /* BG 3 Rotation/scaling parameter C */
00084 #define REG_BG3PD       0x04000036      /* BG 3 Rotation/scaling parameter D */
00085 #define REG_BG3X        0x04000038      /* BG 3 Reference point X coordinate */
00086 #define REG_BG3Y        0x0400003c      /* BG 3 Reference point Y coordinate */
00087 #define REG_WINCNT      0x04000040      /* Window control */
00088 #define REG_WININ       0x04000048      /* Inside window control */
00089 #define REG_WINOUT      0x0400004a      /* Outside window control */
00090 #define REG_MOSAIC      0x0400004c      /* Mosaic size */
00091 #define REG_BLDCNT      0x04000050      /* Blending control */
00092 #define REG_BLDALPHA    0x04000052      /* Alpha blending */
00093 #define REG_BLDY        0x04000054      /* Brightness fading */
00094 
00098 #define REG_SOUND1CNT   0x04000060      /* Channel 1 control */
00099 #define REG_SOUND2CNT   0x04000068      /* Channel 2 control */
00100 #define REG_SOUND3CNT   0x04000070      /* Channel 3 control */
00101 #define REG_SOUND4CNT   0x04000078      /* Channel 4 control */
00102 #define REG_SOUNDCNT    0x04000080      /* Sound control */
00103 #define REG_SOUNDBIAS   0x04000088      /* Sound PWM control */
00104 #define REG_WAVE_RAM0   0x04000090      /* Channel 3 wave pattern RAM bank 0 */
00105 #define REG_WAVE_RAM1   0x04000094      /* Channel 3 wave pattern RAM bank 1 */
00106 #define REG_WAVE_RAM2   0x04000098      /* Channel 3 wave pattern RAM bank 2 */
00107 #define REG_WAVE_RAM3   0x0400009c      /* Channel 3 wave pattern RAM bank 3 */
00108 #define REG_FIFO_A      0x040000a0      /* Channel A FIFO */
00109 #define REG_FIFO_B      0x040000a4      /* Channel B FIFO */
00110 
00114 #define REG_DMA0SAD     0x040000b0      /* DMA 0 source address */
00115 #define REG_DMA0DAD     0x040000b4      /* DMA 0 destination address */
00116 #define REG_DMA0CNT     0x040000b8      /* DMA 0 word count */
00117 #define REG_DMA1SAD     0x040000bc      /* DMA 1 source address */
00118 #define REG_DMA1DAD     0x040000c0      /* DMA 1 destination address */
00119 #define REG_DMA1CNT     0x040000c4      /* DMA 1 word count */
00120 #define REG_DMA2SAD     0x040000c8      /* DMA 2 source address */
00121 #define REG_DMA2DAD     0x040000cc      /* DMA 2 destination address */
00122 #define REG_DMA2CNT     0x040000d0      /* DMA 2 word count */
00123 #define REG_DMA3SAD     0x040000d4      /* DMA 3 source address */
00124 #define REG_DMA3DAD     0x040000d8      /* DMA 3 destination address */
00125 #define REG_DMA3CNT     0x040000dc      /* DMA 3 word count */
00126 
00130 #define REG_TMR0CNT     0x04000100      /* Timer 0 control */
00131 #define REG_TMR1CNT     0x04000104      /* Timer 1 control */
00132 #define REG_TMR2CNT     0x04000108      /* Timer 2 control */
00133 #define REG_TMR3CNT     0x0400010c      /* Timer 3 control */
00134 
00138 #define REG_SIODATA32   0x04000120      /* 32-bit serial data */
00139 #define REG_SIOCNT      0x04000128      /* Serial communication control */
00140 #define REG_SIODATA8    0x0400012a      /* 8-bit serial data */
00141 
00145 #define REG_KEYINPUT    0x04000130      /* Key status */
00146 #define REG_KEYCNT      0x04000132      /* Key control */
00147 
00151 #define REG_RCNT        0x04000134      /* General I/O control */
00152 
00156 #define REG_JOYCNT      0x04000140      /* JOY Bus control */
00157 #define REG_JOYSTAT     0x04000158      /* JOY Bus status */
00158 #define REG_JOY_RECV    0x04000150      /* JOY Bus receive data */
00159 #define REG_JOY_TRANS   0x04000154      /* JOY Bus transmit data */
00160 
00164 #define REG_IE          0x04000200      /* Interrupt enable */
00165 #define REG_IF          0x04000202      /* Interrupt flags */
00166 #define REG_WAITCNT     0x04000204      /* Game Pak wait state control */
00167 #define REG_IME         0x04000208      /* Interrupt master enable */
00168 
00172 #define INT_VBLANK      0x0001      /* V blank interrupt flag. */
00173 #define INT_HBLANK      0x0002      /* H blank interrupt flag. */
00174 #define INT_VCOUNT      0x0004      /* V counter interrupt flag. */
00175 #define INT_TMR0        0x0008      /* Timer 0 interrupt flag. */
00176 #define INT_TMR1        0x0010      /* Timer 1 interrupt flag. */
00177 #define INT_TMR2        0x0020      /* Timer 2 interrupt flag. */
00178 #define INT_TMR3        0x0040      /* Timer 3 interrupt flag. */
00179 #define INT_SIO         0x0080      /* Serial communication interrupt flag. */
00180 #define INT_DMA0        0x0100      /* DMA 0 interrupt flag. */
00181 #define INT_DMA1        0x0200      /* DMA 1 interrupt flag. */
00182 #define INT_DMA2        0x0400      /* DMA 2 interrupt flag. */
00183 #define INT_DMA3        0x0800      /* DMA 3 interrupt flag. */
00184 #define INT_KEYPAD      0x1000      /* Key Pad interrupt flag. */
00185 #define INT_GAMEPAK     0x2000      /* Game Pak interrupt flag. */
00186 
00190 #define REG_HALTCNT     0x04000300      /* Power down control */
00191 
00192 
00193 #define outw(_reg, _val)    (*((volatile unsigned short *)(_reg)) = (_val))
00194 #define outdw(_reg, _val)   (*((volatile unsigned long *)(_reg)) = (_val))
00195 #define inw(_reg)           (*((volatile unsigned short *)(_reg)))
00196 #define indw(_reg)          (*((volatile unsigned long *)(_reg)))
00197 
00198 
00199 #define GBAKEY_A        0x0001
00200 #define GBAKEY_B        0x0002
00201 #define GBAKEY_SELECT   0x0003
00202 #define GBAKEY_START    0x0008
00203 #define GBAKEY_RIGHT    0x0010
00204 #define GBAKEY_LEFT     0x0020
00205 #define GBAKEY_UP       0x0040
00206 #define GBAKEY_DOWN     0x0080
00207 #define GBAKEY_R        0x0100
00208 #define GBAKEY_L        0x0200
00209 
00213 #define TMR_PRE_64      0x00010000  /* Prescaler 64 */
00214 #define TMR_PRE_256     0x00020000  /* Prescaler 256 */
00215 #define TMR_PRE_1024    0x00030000  /* Prescaler 1024 */
00216 #define TMR_IRQ_ENA     0x00400000  /* Interrupt request enable */
00217 #define TMR_ENA         0x00800000  /* Timer enable. */
00218 
00222 #define SIO_BAUD_9600     0x0000
00223 #define SIO_BAUD_38400    0x0001
00224 #define SIO_BAUD_57600    0x0002
00225 #define SIO_BAUD_115200   0x0003
00226 #define SIO_CTS_ENA       0x0004
00227 #define SIO_PARITY_ODD    0x0008
00228 #define SIO_TX_FULL       0x0010
00229 #define SIO_RX_EMPTY      0x0020
00230 #define SIO_ERROR         0x0040
00231 #define SIO_DATA_8BIT     0x0080
00232 #define SIO_FIFO_ENA      0x0100
00233 #define SIO_PARITY_ENA    0x0200
00234 #define SIO_SEND_ENA      0x0400
00235 #define SIO_RECV_ENA      0x0800
00236 #define SIO_MODE_32BIT    0x1000
00237 #define SIO_MODE_MULTI    0x2000
00238 #define SIO_MODE_UART     0x3000
00239 #define SIO_IRQ_ENA       0x4000
00240 
00241 #endif