libnds
Data Structures | Macros | Typedefs | Enumerations | Functions
system.h File Reference

NDS hardware definitions. These definitions are usually only touched during the initialization of the program. More...

#include "ndstypes.h"

Data Structures

struct  RTCtime
 struct containing time and day of the real time clock. More...
 
struct  sysVectors_t
 A struct with all the CPU exeption vectors. each member contains an ARM instuction that will be executed when an exeption occured. More...
 
struct  tPERSONAL_DATA
 User's DS settings. Defines the structure the DS firmware uses for transfer of the user's settings to the booted program. More...
 

Macros

#define HALT_CR   (*(vu16*)0x04000300)
 Halt control register. More...
 
#define PersonalData   ((PERSONAL_DATA*)0x2FFFC80)
 Default location for the user's personal data (see PERSONAL_DATA).
 
#define REG_DISPSTAT   (*(vu16*)0x04000004)
 LCD status register.
 
#define REG_POWERCNT   *(vu16*)0x4000304
 Power control register. More...
 
#define REG_VCOUNT   (*(vu16*)0x4000006)
 Current display scanline.
 

Typedefs

typedef struct tPERSONAL_DATA PERSONAL_DATA
 User's DS settings. Defines the structure the DS firmware uses for transfer of the user's settings to the booted program. More...
 
typedef struct sysVectors_t sysVectors
 A struct with all the CPU exeption vectors. each member contains an ARM instuction that will be executed when an exeption occured. More...
 

Enumerations

Functions

u32 getBatteryLevel ()
 gets the DS Battery level
 
u8getHeapEnd ()
 returns current end of heap space
 
u8getHeapLimit ()
 returns current heap limit
 
u8getHeapStart ()
 returns current start of heap space
 
static bool isDSiMode ()
 Checks whether the application is running in DSi mode.
 
static void lcdMainOnBottom (void)
 Forces the main core to display on the bottom.
 
static void lcdMainOnTop (void)
 Forces the main core to display on the top.
 
static void lcdSwap (void)
 Switches the screens.
 
void ledBlink (int bm)
 
void * memCached (void *address)
 returns a cached mirror of an address. More...
 
void * memUncached (void *address)
 returns an uncached mirror of an address. More...
 
void powerOff (int bits)
 Turns off specified hardware. More...
 
void powerOn (int bits)
 Turns on specified hardware. More...
 
bool setCpuClock (bool speed)
 Sets the ARM9 clock speed, only possible in DSi mode. More...
 
void setVectorBase (int highVector)
 Set the arm9 vector base. More...
 
static void SetYtrigger (int Yvalue)
 sets the Y trigger(?) More...
 
static void systemShutDown (void)
 Powers down the DS.
 
void systemSleep (void)
 Causes the nds to go to sleep. The nds will be reawakened when the lid is opened. More...
 

Detailed Description

NDS hardware definitions. These definitions are usually only touched during the initialization of the program.

Macro Definition Documentation

#define HALT_CR   (*(vu16*)0x04000300)

Halt control register.

Writing 0x40 to HALT_CR activates GBA mode. HALT_CR can only be accessed via the BIOS.

#define REG_POWERCNT   *(vu16*)0x4000304

Power control register.

This register controls what hardware should be turned on or off.

Typedef Documentation

typedef struct tPERSONAL_DATA PERSONAL_DATA

User's DS settings. Defines the structure the DS firmware uses for transfer of the user's settings to the booted program.

Theme/Color values:

  • 0 = Gray
  • 1 = Brown
  • 2 = Red
  • 3 = Pink
  • 4 = Orange
  • 5 = Yellow
  • 6 = Yellow/Green-ish
  • 7 = Green
  • 8 = Dark Green
  • 9 = Green/Blue-ish
  • 10 = Light Blue
  • 11 = Blue
  • 12 = Dark Blue
  • 13 = Dark Purple
  • 14 = Purple
  • 15 = Purple/Red-ish

Language values:

  • 0 = Japanese
  • 1 = English
  • 2 = French
  • 3 = German
  • 4 = Italian
  • 5 = Spanish
  • 6 = Chinese(?)
  • 7 = Unknown/Reserved
typedef struct sysVectors_t sysVectors

A struct with all the CPU exeption vectors. each member contains an ARM instuction that will be executed when an exeption occured.

See gbatek for more information.

Enumeration Type Documentation

enum ARM7_power

Power-controlled hardware devices accessable to the ARM7.

Note that these should only be used when programming for the ARM7. Trying to boot up these hardware devices via the ARM9 would lead to unexpected results. ARM7 only.

Enumerator
POWER_SOUND 

Controls the power for the sound controller.

PM_CONTROL_REG 

Selects the PM control register.

PM_BATTERY_REG 

Selects the PM battery register.

PM_AMPLIFIER_REG 

Selects the PM amplifier register.

PM_READ_REGISTER 

Selects the PM read register.

PM_AMP_OFFSET 

Selects the PM amp register.

PM_GAIN_OFFSET 

Selects the PM gain register.

PM_BACKLIGHT_LEVEL 

Selects the DS Lite backlight register.

PM_GAIN_20 

Sets the mic gain to 20db.

PM_GAIN_40 

Sets the mic gain to 40db.

PM_GAIN_80 

Sets the mic gain to 80db.

PM_GAIN_160 

Sets the mic gain to 160db.

PM_AMP_ON 

Turns the sound amp on.

PM_AMP_OFF 

Turns the sound amp off.

Backlight level settings. Note, these are only available on DS Lite.

Enumerator
BACKLIGHT_LOW 

low backlight setting.

BACKLIGHT_MED 

medium backlight setting.

BACKLIGHT_HIGH 

high backlight setting.

BACKLIGHT_MAX 

max backlight setting.

enum DISP_BITS

LCD Status register bitdefines.

Enumerator
DISP_IN_VBLANK 

The display currently in a vertical blank.

DISP_IN_HBLANK 

The display currently in a horizontal blank.

DISP_YTRIGGERED 

Current scanline and DISP_Y match.

DISP_VBLANK_IRQ 

Interrupt on vertical blank.

DISP_HBLANK_IRQ 

Interrupt on horizontal blank.

DISP_YTRIGGER_IRQ 

Interrupt when current scanline and DISP_Y match.

enum PM_Bits

Power Management control bits.

Enumerator
PM_SOUND_AMP 

Power the sound hardware (needed to hear stuff in GBA mode too).

PM_SOUND_MUTE 

Mute the main speakers, headphone output will still work.

PM_BACKLIGHT_BOTTOM 

Enable the bottom backlight if set.

PM_BACKLIGHT_TOP 

Enable the top backlight if set.

PM_SYSTEM_PWR 

Turn the power off if set.

POWER_LCD 

Controls the power for both LCD screens.

POWER_2D_A 

Controls the power for the main 2D core.

POWER_MATRIX 

Controls the power for the 3D matrix.

POWER_3D_CORE 

Controls the power for the main 3D core.

POWER_2D_B 

Controls the power for the sub 2D core.

POWER_SWAP_LCDS 

Controls which screen should use the main core.

POWER_ALL_2D 

power just 2D hardware.

POWER_ALL 

power everything.

Function Documentation

void ledBlink ( int  bm)

Set the LED blink mode

Parameters
bmWhat to power on.
void* memCached ( void *  address)

returns a cached mirror of an address.

Parameters
addressan address.
Returns
a pointer to the cached mirror of that address.
void* memUncached ( void *  address)

returns an uncached mirror of an address.

Parameters
addressan address.
Returns
a pointer to the uncached mirror of that address.
void powerOff ( int  bits)

Turns off specified hardware.

May be called from arm7 or arm9 (arm9 power bits will be ignored by arm7, arm7 power bits will be passed to the arm7 from the arm9).

Parameters
bitsWhat to power on.
static void powerOn ( int  bits)
inline

Turns on specified hardware.

May be called from arm7 or arm9 (arm9 power bits will be ignored by arm7, arm7 power bits will be passed to the arm7 from the arm9).

Parameters
bitsWhat to power on.
bool setCpuClock ( bool  speed)

Sets the ARM9 clock speed, only possible in DSi mode.

Parameters
speedCPU speed (false = 67.03MHz, true = 134.06MHz)
Returns
The old CPU speed value
void setVectorBase ( int  highVector)

Set the arm9 vector base.

Arm9 only

Parameters
highVectorhigh vector
static void SetYtrigger ( int  Yvalue)
inlinestatic

sets the Y trigger(?)

Parameters
Yvaluethe value for the Y trigger.
void systemSleep ( void  )

Causes the nds to go to sleep. The nds will be reawakened when the lid is opened.

Note
By default, this is automatically called when closing the lid.