libnds
|
DSP general utilities. More...
#include <nds/ndstypes.h>
Macros | |
#define | REG_DSP_CMD0 (*(vu16 *)0x4004320) |
DSP Command Register 0 (R/W) (ARM9 to DSP) | |
#define | REG_DSP_CMD1 (*(vu16 *)0x4004328) |
DSP Command Register 1 (R/W) (ARM9 to DSP) | |
#define | REG_DSP_CMD2 (*(vu16 *)0x4004330) |
DSP Command Register 2 (R/W) (ARM9 to DSP) | |
#define | REG_DSP_PADR (*(vu16 *)(0x04004304)) |
DSP Transfer Address (W) | |
#define | REG_DSP_PCFG (*(vu16 *)0x4004308) |
DSP Configuration (R/W) | |
#define | REG_DSP_PCLEAR (*(vu16 *)0x4004318) |
DSP-to-ARM9 Semaphore Clear (W) | |
#define | REG_DSP_PDATA (*(vu16 *)(0x04004300)) |
DSP Transfer Data Read FIFO (R/W) | |
#define | REG_DSP_PMASK (*(vu16 *)0x4004314) |
DSP-to-ARM9 Semaphore Mask (R/W) | |
#define | REG_DSP_PSEM (*(vu16 *)0x4004310) |
ARM9-to-DSP Semaphore (R/W) | |
#define | REG_DSP_PSTS (*(vu16 *)0x400430C) |
DSP Status (R) | |
#define | REG_DSP_REP0 (*(vu16 *)0x4004324) |
DSP Reply Register 0 (R) (DSP to ARM9) | |
#define | REG_DSP_REP1 (*(vu16 *)0x400432C) |
DSP Reply Register 1 (R) (DSP to ARM9) | |
#define | REG_DSP_REP2 (*(vu16 *)0x4004334) |
DSP Reply Register 2 (R) (DSP to ARM9) | |
#define | REG_DSP_SEM (*(vu16 *)0x400431C) |
DSP-to-ARM9 Semaphore Data (R) | |
Enumerations | |
enum | DSPExecResult { DSP_EXEC_OK = 0 , DSP_NOT_AVAILABLE = -1 , DSP_TLF_BAD_MAGIC = -2 , DSP_TLF_BAD_VERSION = -3 } |
Possible error codes returned by dspExecuteTLF() and dspExecuteDefaultTLF(). More... | |
Functions | |
static void | apbpClearSemaphore (uint16_t mask) |
Clears semaphore flags to be seen by the DSP in REG_APBP_SEM. | |
static void | dspAckSemaphore (u16 mask) |
Clears semaphore bits that the DSP has set in REG_APBP_PSEM. | |
DSPExecResult | dspExecuteDefaultTLF (const void *tlf) |
This sets up NWRAM, powers on the DSP, loads a TLF file and executes it. | |
DSPExecResult | dspExecuteTLF (const void *tlf) |
This powers on the DSP, loads a TLF file and executes it. | |
static u16 | dspGetSemaphore (void) |
Gets semaphore bits that the DSP has set in REG_APBP_PSEM. | |
u16 | dspReceiveData (int id) |
Receives data from one of the REP registers. | |
bool | dspReceiveDataReady (int id) |
Checks if a REP register has any data available. | |
void | dspSendData (int id, u16 data) |
Sends data using one of the CMD registers. | |
bool | dspSendDataReady (int id) |
Checks if a CMD register is available to receive new data. | |
static void | dspSetSemaphore (u16 mask) |
Sets semaphore flags to be seen by the DSP in REG_APBP_SEM. | |
static void | dspSetSemaphoreMask (u16 mask) |
Masks interrupts caused by DSP-to-ARM semaphores. | |
void | dspSpinWait (void) |
Function that executes a delay of a few cycles. | |
DSP general utilities.
This file contains general definitions and helpers to use the DSP of the DSi.
enum DSPExecResult |
Possible error codes returned by dspExecuteTLF() and dspExecuteDefaultTLF().
Enumerator | |
---|---|
DSP_EXEC_OK | No error. |
DSP_NOT_AVAILABLE | DSP or NWRAM not available in SCFG_EXT or MBK9. |
DSP_TLF_BAD_MAGIC | Invalid TLF magic value. |
DSP_TLF_BAD_VERSION | Invalid TLF version. |
|
inlinestatic |
Clears semaphore flags to be seen by the DSP in REG_APBP_SEM.
mask | Bits to clear. |
|
inlinestatic |
Clears semaphore bits that the DSP has set in REG_APBP_PSEM.
mask | Bits to clear. |
DSPExecResult dspExecuteDefaultTLF | ( | const void * | tlf | ) |
This sets up NWRAM, powers on the DSP, loads a TLF file and executes it.
This function uses a sensible default NWRAM mapping. If you prefer to define it manually, use dspExecuteTLF() instead.
tlf | Pointer to the TLF data in RAM. |
DSPExecResult dspExecuteTLF | ( | const void * | tlf | ) |
This powers on the DSP, loads a TLF file and executes it.
The user must allocate NWRAM to the ARM9 before calling this function by using nwramSetBlockMapping(). Remember that the default MPU setup only allows mapping it to the range 0x03000000 - 0x03800000. If you prefer to use a sensible default mapping without doing it manually, use dspExecuteDefaultTLF() instead.
tlf | Pointer to the TLF data in RAM. |
|
inlinestatic |
Gets semaphore bits that the DSP has set in REG_APBP_PSEM.
u16 dspReceiveData | ( | int | id | ) |
Receives data from one of the REP registers.
This function waits until there is a value to be read.
id | ID of the REP register (0 to 2). |
bool dspReceiveDataReady | ( | int | id | ) |
Checks if a REP register has any data available.
id | ID of the REP register (0 to 2). |
void dspSendData | ( | int | id, |
u16 | data | ||
) |
Sends data using one of the CMD registers.
This function waits until the previous value has been read by the DSP.
id | ID of the CMD register (0 to 2). |
data | Data to send. |
bool dspSendDataReady | ( | int | id | ) |
Checks if a CMD register is available to receive new data.
id | ID of the CMD register (0 to 2). |
|
inlinestatic |
Sets semaphore flags to be seen by the DSP in REG_APBP_SEM.
mask | Bits to set on top of the currently set bits. |
|
inlinestatic |
Masks interrupts caused by DSP-to-ARM semaphores.
mask | Bits set to 1 will disable interrupts for that semaphore. |