libnds
|
NDS hardware definitions. More...
Data Structures | |
struct | RTCtime |
Struct containing time and day of the real time clock. More... | |
struct | rtcTime |
Struct containing time of the real time clock. More... | |
struct | rtcTimeAndDate |
Struct containing time and day of the real time clock. More... | |
struct | sysVectors |
Structure of function pointers corresponding to ARM CPU interrupts. Each member contains an ARM instuction that will be executed when an exeption occurs. More... | |
struct | tPERSONAL_DATA |
User's DS settings. More... | |
Macros | |
#define | PersonalData ((PERSONAL_DATA *)0x2FFFC80) |
Default location for the user's personal data (see PERSONAL_DATA). | |
#define | PM_LED_CONTROL_MASK (3 << 4) |
PM control register bits - LED control. | |
#define | REG_DISPSTAT (*(vu16*)0x04000004) |
LCD status register. | |
#define | REG_HALTCNT (*(vu16*)0x04000300) |
Halt control register. | |
#define | REG_POWERCNT *(vu16 *)0x4000304 |
Power control register. | |
#define | REG_VCOUNT (*(vu16*)0x4000006) |
Current display scanline. | |
#define | SCREEN_HEIGHT 192 |
Screen height in pixels. | |
#define | SCREEN_WIDTH 256 |
Screen width in pixels. | |
Typedefs | |
typedef struct tPERSONAL_DATA | PERSONAL_DATA |
User's DS settings. | |
typedef struct sysVectors | sysVectors_t |
Structure of function pointers corresponding to ARM CPU interrupts. Each member contains an ARM instuction that will be executed when an exeption occurs. | |
Enumerations | |
enum | ARM7_power { POWER_SOUND = BIT(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. More... | |
enum | DISP_BITS { DISP_IN_VBLANK = BIT(0) , DISP_IN_HBLANK = BIT(1) , DISP_YTRIGGERED = BIT(2) , DISP_VBLANK_IRQ = BIT(3) , DISP_HBLANK_IRQ = BIT(4) , DISP_YTRIGGER_IRQ = BIT(5) } |
LCD Status register defines. More... | |
enum | PM_Bits { PM_SOUND_AMP = BIT(0) , PM_SOUND_MUTE = BIT(1) , PM_BACKLIGHT_BOTTOM = BIT(2) , PM_BACKLIGHT_TOP = BIT(3) , PM_SYSTEM_PWR = BIT(6) , PM_ARM9_DIRECT = BIT(16) , POWER_LCD = PM_ARM9_DIRECT | BIT(0) , POWER_2D_A = PM_ARM9_DIRECT | BIT(1) , POWER_MATRIX = PM_ARM9_DIRECT | BIT(2) , POWER_3D_CORE = PM_ARM9_DIRECT | BIT(3) , POWER_2D_B = PM_ARM9_DIRECT | BIT(9) , POWER_SWAP_LCDS = PM_ARM9_DIRECT | BIT(15) , POWER_ALL_2D = PM_ARM9_DIRECT | POWER_LCD | POWER_2D_A | POWER_2D_B , POWER_ALL = PM_ARM9_DIRECT | POWER_ALL_2D | POWER_3D_CORE | POWER_MATRIX } |
Power Management control bits for powerOn() and powerOff(). More... | |
Functions | |
void | disableSleep (void) |
Disables sleep mode from ARM9. | |
void | enableSleep (void) |
Enables sleep mode from ARM9. | |
u32 | getBatteryLevel (void) |
Gets the DS battery level. | |
u8 * | getHeapEnd (void) |
Returns current end of heap space. | |
u8 * | getHeapLimit (void) |
Returns current heap limit. | |
u8 * | getHeapStart (void) |
Returns current start of heap space. | |
void | installSystemFIFO (void) |
Install the system FIFO handlers. | |
static bool | isDSiMode (void) |
Checks whether the application is running in DSi mode. | |
static bool | isHwDebugger (void) |
Checks whether the application is running in a debugger or retail console. | |
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 | peripheralSlot2DisableCache (void) |
Disable data cache for the DS slot-2 memory region. If write-back was enabled, additionally clear and flush the data cache. | |
void | peripheralSlot2EnableCache (bool write_back) |
Enable data cache for the DS slot-2 memory region. | |
void | powerOff (uint32_t bits) |
Turns off specified hardware. | |
void | powerOn (uint32_t bits) |
Turns on specified hardware. | |
void | readFirmware (u32 address, void *buffer, u32 length) |
Read bytes at a specified address from firmware flash. | |
static int | readPowerManagement (int reg) |
Read from a power management register. | |
bool | readUserSettings (void) |
Read user settings/personal data from firmware flash to a shared memory location. | |
bool | setCpuClock (bool speed) |
Sets the ARM9 clock speed, only possible in DSi mode. | |
void | setVectorBase (int base) |
Set the ARM9 interrupt vector base to one of two locations: | |
static void | SetYtrigger (int Yvalue) |
Sets the LCD refresh scanline Y trigger. | |
static void | systemShutDown (void) |
Powers down the DS. | |
void | systemSleep (void) |
Causes the NDS to go to sleep. | |
int | writeFirmware (u32 address, void *buffer, u32 length) |
Write bytes at a specified address to firmware flash. | |
int | writePowerManagement (int reg, int command) |
Write to a power management register. | |
Variables | |
sysVectors_t | SystemVectors |
Function pointers to user-provided interrupt handlers, used in the alternate interrupt vector mode in place of BIOS interrupt handlers. | |
NDS hardware definitions.
These definitions are usually only touched during the initialization of the program.
#define REG_HALTCNT (*(vu16*)0x04000300) |
Halt control register.
Writing 0x40 to REG_HALTCNT activates GBA mode. REG_HALTCNT 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 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:
Language values:
typedef struct sysVectors sysVectors_t |
Structure of function pointers corresponding to ARM CPU interrupts. Each member contains an ARM instuction that will be executed when an exeption occurs.
See GBATEK for more information on each interrupt.
enum ARM7_power |
Power-controlled hardware devices accessable to the ARM7.
enum BACKLIGHT_LEVELS |
enum DISP_BITS |
LCD Status register defines.
enum PM_Bits |
Power Management control bits for powerOn() and powerOff().
u32 getBatteryLevel | ( | void | ) |
Gets the DS battery level.
This returns a value with two fields. Bits 0 to 3 are the battery level, and bit 7 is set to 1 if an external power source is connected to the DS.
On DSi the battery level is the one reported by the hardware. On DS, the battery level is only "high" or "low", and libnds returns 15 or 3 respectively as the equivalent DSi battery level.
u8 * getHeapEnd | ( | void | ) |
Returns current end of heap space.
u8 * getHeapLimit | ( | void | ) |
Returns current heap limit.
u8 * getHeapStart | ( | void | ) |
Returns current start of heap space.
void installSystemFIFO | ( | void | ) |
Install the system FIFO handlers.
This handles power management, DSi SD card access, and firmware flash access.
|
inlinestatic |
Checks whether the application is running in DSi mode.
|
inlinestatic |
Checks whether the application is running in a debugger or retail console.
It works on DS and DSi consoles.
void ledBlink | ( | int | bm | ) |
Set the LED blink mode.
bm | What to power on. |
void * memCached | ( | void * | address | ) |
Returns a cached mirror of an address.
address | An address. |
void * memUncached | ( | void * | address | ) |
Returns an uncached mirror of an address.
address | An address. |
void peripheralSlot2DisableCache | ( | void | ) |
Disable data cache for the DS slot-2 memory region. If write-back was enabled, additionally clear and flush the data cache.
Note that flushing the data cache may still be required to remove stale "read" pages, such as if you write to external RAM uncached and then re-enable cache.
void peripheralSlot2EnableCache | ( | bool | write_back | ) |
Enable data cache for the DS slot-2 memory region.
Note that this is not safe to enable if you're using Slot-2 memory for purposes other than external RAM, such as rumble or other I/O.
write_back | Set as write-back. This allows writes to skip the slow Slot-2 bus, at the expense of requiring a full memory flush when calling peripheralSlot2DisableCache(). |
|
inline |
Turns off specified hardware.
It may be called from the ARM7 or ARM9 (ARM9 power bits will be ignored by the ARM7, ARM7 power bits will be passed to the ARM7 from the ARM9).
bits | What to power OFF (PM_Bits). |
|
inline |
Turns on specified hardware.
It may be called from the ARM7 or ARM9 (ARM9 power bits will be ignored by the ARM7, ARM7 power bits will be passed to the ARM7 from the ARM9).
bits | What to power ON (PM_Bits). |
Read bytes at a specified address from firmware flash.
address | Address in the firmware to read from. |
buffer | Pointer to the buffer to use as destination. |
length | Size of the buffer to read. |
|
inlinestatic |
Read from a power management register.
reg | The register to read from. |
bool readUserSettings | ( | void | ) |
Read user settings/personal data from firmware flash to a shared memory location.
bool setCpuClock | ( | bool | speed | ) |
Sets the ARM9 clock speed, only possible in DSi mode.
speed | CPU speed (false = 67.03MHz, true = 134.06MHz) |
void setVectorBase | ( | int | base | ) |
Set the ARM9 interrupt vector base to one of two locations:
To initialize function pointers for the alternate vector base, set the relevant values in the SystemVectors structure before calling this function.
Note that it is recommended to call this function with interrupts disabled (REG_IME = 0).
base | Vector base. Setting it to any non-zero value will use the default vector base (0xFFFF0000); setting it to zero will use the alternate vector base (0x00000000). |
|
inlinestatic |
Sets the LCD refresh scanline Y trigger.
Yvalue | The value for the Y trigger. |
|
inlinestatic |
Powers down the DS.
This function shutds down the console.
void systemSleep | ( | void | ) |
Causes the NDS to go to sleep.
The NDS will be reawakened when the lid is opened.
Write bytes at a specified address to firmware flash.
address | Address in the firmware to write to. |
buffer | Pointer to the buffer to write. |
length | Size of the buffer to write. |
int writePowerManagement | ( | int | reg, |
int | command | ||
) |
Write to a power management register.
reg | Register address. |
command | Command to send to the register. |
|
extern |
Function pointers to user-provided interrupt handlers, used in the alternate interrupt vector mode in place of BIOS interrupt handlers.