libnds
Data Structures | Defines | Typedefs | Enumerations | Functions | Variables

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...

Defines

#define HALT_CR   (*(vu16*)0x04000300)
 Halt control register.
#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.
#define REG_VCOUNT   (*(vu16*)0x4000006)
 Current display scanline.

Typedefs

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.

Enumerations

enum  ARM7_power {
  POWER_SOUND = (1 << ( 0 )),
  PM_CONTROL_REG = 0,
  PM_BATTERY_REG = 1,
  PM_AMPLIFIER_REG = 2,
  PM_READ_REGISTER = (1<<7),
  PM_AMP_OFFSET = 2,
  PM_GAIN_OFFSET = 3,
  PM_BACKLIGHT_LEVEL = 4,
  PM_GAIN_20 = 0,
  PM_GAIN_40 = 1,
  PM_GAIN_80 = 2,
  PM_GAIN_160 = 3,
  PM_AMP_ON = 1,
  PM_AMP_OFF = 0
}
 

Power-controlled hardware devices accessable to the ARM7.

More...
enum  BACKLIGHT_LEVELS {
  BACKLIGHT_LOW,
  BACKLIGHT_MED,
  BACKLIGHT_HIGH,
  BACKLIGHT_MAX
}
 

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

More...
enum  DISP_BITS {
  DISP_IN_VBLANK = (1 << ( 0 )),
  DISP_IN_HBLANK = (1 << ( 1 )),
  DISP_YTRIGGERED = (1 << ( 2 )),
  DISP_VBLANK_IRQ = (1 << ( 3 )),
  DISP_HBLANK_IRQ = (1 << ( 4 )),
  DISP_YTRIGGER_IRQ = (1 << ( 5 ))
}
 

LCD Status register bitdefines.

More...
enum  PM_Bits {
  PM_SOUND_AMP = (1 << ( 0 )),
  PM_SOUND_MUTE = (1 << ( 1 )),
  PM_BACKLIGHT_BOTTOM = (1 << ( 2 )),
  PM_BACKLIGHT_TOP = (1 << ( 3 )),
  PM_SYSTEM_PWR = (1 << ( 6 )),
  POWER_LCD = (1 << ( 16 )) | (1 << ( 0 )),
  POWER_2D_A = (1 << ( 16 )) | (1 << ( 1 )),
  POWER_MATRIX = (1 << ( 16 )) | (1 << ( 2 )),
  POWER_3D_CORE = (1 << ( 16 )) | (1 << ( 3 )),
  POWER_2D_B = (1 << ( 16 )) | (1 << ( 9 )),
  POWER_SWAP_LCDS = (1 << ( 16 )) | (1 << ( 15 )),
  POWER_ALL_2D = (1 << ( 16 )) | POWER_LCD | POWER_2D_A | POWER_2D_B,
  POWER_ALL = (1 << ( 16 )) | POWER_ALL_2D | POWER_3D_CORE | POWER_MATRIX
}
 

Power Management control bits.

More...

Functions

struct tPERSONAL_DATA __attribute__ ((packed)) PERSONAL_DATA
 User's DS settings. Defines the structure the DS firmware uses for transfer of the user's settings to the booted program.
u32 getBatteryLevel ()
 gets the DS Battery level
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)
 Set the LED blink mode.
void * memCached (void *address)
 returns a cached mirror of an address.
void * memUncached (void *address)
 returns an uncached mirror of an address.
void powerOff (int bits)
 Turns off specified hardware.
void powerOn (int bits)
 Turns on specified hardware.
void setVectorBase (int highVector)
 Set the arm9 vector base.
static void SetYtrigger (int Yvalue)
 sets the Y trigger(?)
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.

Variables

u8 alarmHour
 What hour the alarm clock is set to (0-23).
u8 alarmMinute
 What minute the alarm clock is set to (0-59).
u8 birthDay
 The user's birth day (1-31).
u8 birthMonth
 The user's birth month (1-12).
u16 calX1
 Touchscreen calibration: first X touch.
u8 calX1px
 Touchscreen calibration: first X touch pixel.
u16 calX2
 Touchscreen calibration: second X touch.
u8 calX2px
 Touchscreen calibration: second X touch pixel.
u16 calY1
 Touchscreen calibration: first Y touch.
u8 calY1px
 Touchscreen calibration: first X touch pixel.
u16 calY2
 Touchscreen calibration: second Y touch.
u8 calY2px
 Touchscreen calibration: second Y touch pixel.
s16 message [26]
 The user's message.
u16 messageLen
 The length of the user's message in characters.
s16 name [10]
 The user's name in UTF-16 format.
u16 nameLen
 The length of the user's name in characters.
u32 rtcOffset
 Real Time Clock offset.
u8 theme
 The user's theme color (0-15).

Detailed Description

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


Define 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 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 top backlight if set.

PM_BACKLIGHT_TOP 

Enable the bottom 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

struct tPERSONAL_DATA __attribute__ ( (packed)  )

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

holds a red green blue triplet

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

< User's language.

< GBA screen selection (lower screen if set, otherwise upper screen).

< Brightness level at power on, dslite.

< The DS should boot from the DS cart or GBA cart automatically if one is inserted.

< User Settings Lost (0=Normal, 1=Prompt/Settings Lost)

void ledBlink ( int  bm)

Set the LED blink mode.

Arm9 only

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.
void setVectorBase ( int  highVector)

Set the arm9 vector base.

Arm9 only

Parameters:
highVectorhigh vector
static void SetYtrigger ( int  Yvalue) [inline, static]

sets the Y trigger(?)

Parameters:
Yvaluethe value for the Y trigger.
Examples:
audio/maxmod/streaming/source/main.c.
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.
 All Data Structures Files Functions Variables Typedefs Enumerations Enumerator Defines