source: rtems/c/src/lib/libbsp/arm/nds/libnds/include/nds/system.h @ 49a40165

4.104.114.9
Last change on this file since 49a40165 was 49a40165, checked in by Joel Sherrill <joel.sherrill@…>, on Aug 19, 2008 at 3:47:14 PM

2008-08-19 Joel Sherrill <joel.sherrill@…>

  • dswifi/arm7/makefile, dswifi/include/netinet/in.h, libnds/basicARM7/source/defaultARM7.c, libnds/include/gbfs.h, libnds/include/nds/bios.h, libnds/include/nds/card.h, libnds/include/nds/dma.h, libnds/include/nds/interrupts.h, libnds/include/nds/ipc.h, libnds/include/nds/jtypes.h, libnds/include/nds/registers_alt.h, libnds/include/nds/system.h, libnds/include/nds/timers.h, libnds/include/nds/arm7/audio.h, libnds/include/nds/arm7/clock.h, libnds/include/nds/arm7/serial.h, libnds/include/nds/arm7/touch.h, libnds/include/nds/arm9/boxtest.h, libnds/include/nds/arm9/cache.h, libnds/include/nds/arm9/console.h, libnds/include/nds/arm9/ndsmotion.h, libnds/include/nds/arm9/video.h, libnds/include/nds/arm9/videoGL.h, libnds/source/arm7/audio.c, libnds/source/arm7/clock.c, libnds/source/arm7/microphone.c, libnds/source/arm7/touch.c, libnds/source/arm7/userSettings.c, libnds/source/arm9/boxtest.c, libnds/source/arm9/gurumeditation.c, libnds/source/arm9/ndsmotion.c, libnds/source/arm9/videoGL.c, libnds/source/common/card.c, libnds/source/common/interruptDispatcher.S, touchscreen/reco.c: Fix various warnings by fixing prototypes. Remove unused .bin files. Convert all files to UNIX CF/LF.
  • libnds/source/arm9/COS.bin, libnds/source/arm9/SIN.bin, libnds/source/arm9/TAN.bin, libnds/source/arm9/default_font.bin: Removed.
  • Property mode set to 100644
File size: 7.7 KB
Line 
1/*---------------------------------------------------------------------------------
2        $Id$
3
4        Power control, keys, and HV clock registers
5
6        Copyright (C) 2005
7                Jason Rogers (dovoto)
8                Dave Murphy (WinterMute)
9
10        This software is provided 'as-is', without any express or implied
11        warranty.  In no event will the authors be held liable for any
12        damages arising from the use of this software.
13
14        Permission is granted to anyone to use this software for any
15        purpose, including commercial applications, and to alter it and
16        redistribute it freely, subject to the following restrictions:
17
18        1.      The origin of this software must not be misrepresented; you
19                must not claim that you wrote the original software. If you use
20                this software in a product, an acknowledgment in the product
21                documentation would be appreciated but is not required.
22
23        2.      Altered source versions must be plainly marked as such, and
24                must not be misrepresented as being the original software.
25
26        3.      This notice may not be removed or altered from any source
27                distribution.
28
29---------------------------------------------------------------------------------*/
30
31//!     NDS hardware definitions.
32/*!     \file system.h
33
34        These definitions are usually only touched during
35        the initialization of the program.
36*/
37
38#ifndef NDS_SYSTEM_INCLUDE
39#define NDS_SYSTEM_INCLUDE
40
41//!     LCD status register.
42#define REG_DISPSTAT    (*(vu16*)0x04000004)
43
44//!     The display currently in a vertical blank.
45#define DISP_IN_VBLANK     BIT(0)
46
47//!     The display currently in a horizontal blank.
48#define DISP_IN_HBLANK     BIT(1)
49
50//!     Current scanline and %DISP_Y match.
51#define DISP_YTRIGGERED    BIT(2)
52
53//!     Interrupt on vertical blank.
54#define DISP_VBLANK_IRQ    BIT(3)
55
56//!     Interrupt on horizontal blank.
57#define DISP_HBLANK_IRQ    BIT(4)
58
59//!     Interrupt when current scanline and %DISP_Y match.
60#define DISP_YTRIGGER_IRQ  BIT(5)
61
62static inline
63void SetYtrigger(int Yvalue) {
64        REG_DISPSTAT = (REG_DISPSTAT & 0x007F ) | (Yvalue << 8) | (( Yvalue & 0x100 ) >> 2) ;
65}
66
67//!     Current display scanline.
68#define REG_VCOUNT              (*(vu16*)0x4000006)
69
70
71//!     Halt control register.
72/*!     Writing 0x40 to HALT_CR activates GBA mode.
73        %HALT_CR can only be accessed via the BIOS.
74*/
75#define HALT_CR       (*(vuint16*)0x04000300)
76
77//!     Power control register.
78/*!     This register controls what hardware should
79        be turned on or off.
80*/
81#define REG_POWERCNT    *(vu16*)0x4000304
82
83//!     Turns on specified hardware.
84/*!     This function should only be called after %powerSET.
85
86        \param on What to power on.
87*/
88static inline
89void powerON(int on) { REG_POWERCNT |= on;}
90
91//!     Turns on only the specified hardware.
92/*!     Use this function to power on basic hardware types you
93        wish to use throughout your program.
94
95        \param on What to power on.
96*/
97static inline void powerSET(int on) { REG_POWERCNT = on;}
98
99//!     Turns off the specified hardware.
100/*!     \param off What to power off.
101*/
102static inline void powerOFF(int off) { REG_POWERCNT &= ~off;}
103
104#ifdef ARM9
105#ifdef DOXYGEN
106//!     Power-controlled hardware devices accessable to the ARM9.
107/*!     Used with %powerON, %powerSET, and %powerOFF functions.
108        Note that these should only be used when programming for
109        the ARM9.  Trying to boot up these hardware devices via
110        the ARM7 would lead to unexpected results.
111*/
112enum ARM9_power
113{
114        POWER_LCD,                      //!<    Controls the power for both LCD screens.
115        POWER_2D_A,                     //!<    Controls the power for the main 2D core.
116        POWER_MATRIX,           //!<    Controls the power for the 3D matrix.
117        POWER_3D_CORE,          //!<    Controls the power for the main 3D core.
118        POWER_2D_B,                     //!<    Controls the power for the sub 2D core.
119        POWER_SWAP_LCDS,        //!<    Controls which screen should use the main core.
120};
121#else
122#define POWER_LCD                       BIT(0)
123#define POWER_2D_A                      BIT(1)
124#define POWER_MATRIX            BIT(2)
125#define POWER_3D_CORE           BIT(3)
126#define POWER_2D_B                      BIT(9)
127#define POWER_SWAP_LCDS         BIT(15)
128#endif /* DOXYGEN */
129
130//!     Enables power to all hardware required for 2D video.
131#define POWER_ALL_2D     (POWER_LCD |POWER_2D_A |POWER_2D_B)
132
133//!     Enables power to all hardware required for 3D video.
134#define POWER_ALL                (POWER_ALL_2D | POWER_3D_CORE | POWER_MATRIX)
135
136//!     Switches the screens.
137static inline void lcdSwap(void) { REG_POWERCNT ^= POWER_SWAP_LCDS; }
138
139//!     Forces the main core to display on the top.
140static inline void lcdMainOnTop(void) { REG_POWERCNT |= POWER_SWAP_LCDS; }
141
142//!     Forces the main core to display on the bottom.
143static inline void lcdMainOnBottom(void) { REG_POWERCNT &= ~POWER_SWAP_LCDS; }
144#endif
145
146#ifdef ARM7
147#ifdef DOXYGEN
148//!     Power-controlled hardware devices accessable to the ARM7.
149/*!     Note that these should only be used when programming for
150        the ARM7.  Trying to boot up these hardware devices via
151        the ARM9 would lead to unexpected results.
152*/
153enum ARM7_power
154{
155        POWER_SOUND,    //!<    Controls the power for the sound controller.
156        POWER_UNKNOWN,  //!<    Controls the power for an unknown device.
157};
158#else
159#define POWER_SOUND       BIT(0)
160#define POWER_UNKNOWN     BIT(1)
161#endif /* DOXYGEN */
162
163void readUserSettings(void);
164
165#endif /* ARM7 */
166
167//!     User's DS settings.
168/*!     \struct tPERSONAL_DATA
169
170        Defines the structure the DS firmware uses for transfer
171        of the user's settings to the booted program.
172*/
173typedef struct tPERSONAL_DATA {
174  u8 RESERVED0[2];                      //!<    ??? (0x05 0x00).
175
176  u8 theme;                                     //!<    The user's theme color (0-15).
177  u8 birthMonth;                        //!<    The user's birth month (1-12).
178  u8 birthDay;                          //!<    The user's birth day (1-31).
179
180  u8 RESERVED1[1];                      //!<    ???
181
182  s16 name[10];                         //!<    The user's name in UTF-16 format.
183  u16 nameLen;                          //!<    The length of the user's name in characters.
184
185  s16 message[26];                      //!<    The user's message.
186  u16 messageLen;                       //!<    The length of the user's message in characters.
187
188  u8 alarmHour;                         //!<    What hour the alarm clock is set to (0-23).
189  u8 alarmMinute;                       //!<    What minute the alarm clock is set to (0-59).
190            //0x027FFCD3  alarm minute
191
192  u8 RESERVED2[4];                      //!<    ???
193           //0x027FFCD4  ??
194
195  u16 calX1;                            //!<    Touchscreen calibration: first X touch
196  u16 calY1;                            //!<    Touchscreen calibration: first Y touch
197  u8 calX1px;                           //!<    Touchscreen calibration: first X touch pixel
198  u8 calY1px;                           //!<    Touchscreen calibration: first X touch pixel
199
200  u16 calX2;                            //!<    Touchscreen calibration: second X touch
201  u16 calY2;                            //!<    Touchscreen calibration: second Y touch
202  u8 calX2px;                           //!<    Touchscreen calibration: second X touch pixel
203  u8 calY2px;                           //!<    Touchscreen calibration: second Y touch pixel
204
205  packed_struct {
206    unsigned language                   : 3;    //!<    User's language.
207    unsigned gbaScreen                  : 1;    //!<    GBA screen selection (lower screen if set, otherwise upper screen).
208    unsigned defaultBrightness  : 2;    //!<    Brightness level at power on, dslite.
209    unsigned autoMode                   : 1;    //!<    The DS should boot from the DS cart or GBA cart automatically if one is inserted.
210    unsigned RESERVED1                  : 2;    //!<    ???
211        unsigned settingsLost           : 1;    //!<    User Settings Lost (0=Normal, 1=Prompt/Settings Lost)
212        unsigned RESERVED2                      : 6;    //!<    ???
213  } _user_data;
214 
215  u16   RESERVED3;
216  u32   rtcOffset;
217  u32   RESERVED4;
218} PACKED PERSONAL_DATA ;
219
220//!     Key input register.
221/*!     On the ARM9, the hinge "button," the touch status, and the
222        X and Y buttons cannot be accessed directly.
223*/
224#define REG_KEYINPUT    (*(vuint16*)0x04000130)
225
226//!     Key input control register.
227#define REG_KEYCNT              (*(vuint16*)0x04000132)
228
229//!     Default location for the user's personal data (see %PERSONAL_DATA).
230#define PersonalData ((PERSONAL_DATA*)0x27FFC80)
231
232//!     argv structure
233/*!     \struct __argv
234
235        structure used to set up argc/argv on the DS
236
237*/
238struct __argv {
239        int argvMagic;          //!< argv magic number, set to 0x5f617267 ('_arg') if valid
240        char *commandLine;      //!< base address of command line, set of null terminated strings
241        int length;                     //!< total length of command line
242};
243
244//!     Default location for the libnds argv structure.
245#define libnds_argv             ((struct __argv *)0x027FFF70)
246
247// argv struct magic number
248#define argvMagic 0x5f617267
249
250#endif
Note: See TracBrowser for help on using the repository browser.