1 2{$ifdef NDS_INTERFACE} 3 4type 5 FifoChannels = integer; 6const 7 FIFO_PM : FifoChannels = 0; 8 FIFO_SOUND : FifoChannels = 1; 9 FIFO_SYSTEM : FifoChannels = 2; 10 FIFO_MAXMOD : FifoChannels = 3; 11 FIFO_DSWIFI : FifoChannels = 4; 12 FIFO_SDMMC : FifoChannels = 5; 13 FIFO_FIRMWARE: FifoChannels = 6; 14 FIFO_RSVD_01 : FifoChannels = 7; 15 FIFO_USER_01 : FifoChannels = 8; 16 FIFO_USER_02 : FifoChannels = 9; 17 FIFO_USER_03 : FifoChannels = 10; 18 FIFO_USER_04 : FifoChannels = 11; 19 FIFO_USER_05 : FifoChannels = 12; 20 FIFO_USER_06 : FifoChannels = 13; 21 FIFO_USER_07 : FifoChannels = 14; 22 FIFO_USER_08 : FifoChannels = 15; 23 24 25type 26 FifoSoundCommand = integer; 27const 28 SOUND_SET_PAN : FifoSoundCommand = ( 0 shl 20); 29 SOUND_SET_VOLUME : FifoSoundCommand = ( 1 shl 20); 30 SOUND_SET_FREQ : FifoSoundCommand = ( 2 shl 20); 31 SOUND_SET_WAVEDUTY : FifoSoundCommand = ( 3 shl 20); 32 SOUND_MASTER_ENABLE : FifoSoundCommand = ( 4 shl 20); 33 SOUND_MASTER_DISABLE : FifoSoundCommand = ( 5 shl 20); 34 SOUND_PAUSE : FifoSoundCommand = ( 6 shl 20); 35 SOUND_RESUME : FifoSoundCommand = ( 7 shl 20); 36 SOUND_KILL : FifoSoundCommand = ( 8 shl 20); 37 SET_MASTER_VOL : FifoSoundCommand = ( 9 shl 20); 38 MIC_STOP : FifoSoundCommand = (10 shl 20); 39 40type 41 FifoSystemCommands = integer; 42const 43 SYS_REQ_TOUCH : FifoSystemCommands = 0; 44 SYS_REQ_KEYS : FifoSystemCommands = 1; 45 SYS_REQ_TIME : FifoSystemCommands = 2; 46 SYS_SET_TIME : FifoSystemCommands = 3; 47 SDMMC_INSERT : FifoSystemCommands = 4; 48 SDMMC_REMOVE : FifoSystemCommands = 5; 49 50type 51 FifoSdmmcCommands = integer; 52const 53 SDMMC_HAVE_SD : FifoSystemCommands = 0; 54 SDMMC_SD_START : FifoSystemCommands = 1; 55 SDMMC_SD_IS_INSERTED : FifoSystemCommands = 2; 56 SDMMC_SD_STOP : FifoSystemCommands = 3; 57 SDMMC_NAND_START : FifoSystemCommands = 4; 58 SDMMC_NAND_STOP : FifoSystemCommands = 5; 59 60type 61 FifoFirmwareCommands = integer; 62const 63 FW_READ = 0; 64 FW_WRITE = 1; 65 66type 67 FifoPMCommands = integer; 68const 69 PM_REQ_ON : FifoPMCommands = (1 shl 16); 70 PM_REQ_OFF : FifoPMCommands = (2 shl 16); 71 PM_REQ_LED : FifoPMCommands = (3 shl 16); 72 PM_REQ_SLEEP : FifoPMCommands = (4 shl 16); 73 PM_REQ_SLEEP_DISABLE : FifoPMCommands = (5 shl 16); 74 PM_REQ_SLEEP_ENABLE : FifoPMCommands = (6 shl 16); 75 PM_REQ_BATTERY : FifoPMCommands = (7 shl 16); 76 PM_DSI_HACK : FifoPMCommands = (8 shl 16); 77 78type 79 FifoWifiCommands = integer; 80const 81 WIFI_ENABLE : FifoWifiCommands = 0; 82 WIFI_DISABLE : FifoWifiCommands = 1; 83 WIFI_SYNC : FifoWifiCommands = 2; 84 WIFI_STARTUP : FifoWifiCommands = 3; 85 86type 87 PM_LedBlinkMode = integer; 88const 89 PM_LED_ON : PM_LedBlinkMode = 0; 90 PM_LED_SLEEP: PM_LedBlinkMode = 1; 91 PM_LED_BLINK: PM_LedBlinkMode = 3; 92 93//var 94// fifo_buffer: array [0..FIFO_BUFFER_ENTRIES*2-1] of cuint32; cvar; external; 95 96 97{$ifdef FIFO_RIGOROUS_ERROR_CHECKING} 98 function fifoError(value: pchar; array of const): integer; cdecl; external;// expected to be defined externally. 99{$endif} 100 101type // FUNCTION(...):POINTER or PROCEDURE?!? 102 FifoAddressHandlerFunc = function(address, userdata: pointer): pointer; 103 FifoValue32HandlerFunc = function(value32: cuint32; userdata: pointer): pointer; 104 FifoDatamsgHandlerFunc = function(num_bytes: integer; userdata: pointer): pointer; 105 106function fifoInit(): cbool; cdecl; external; 107function fifoSendAddress(channel: integer; address: pointer): cbool; cdecl; external; 108function fifoSendValue32(channel: integer; value32: cuint32): cbool; cdecl; external; 109 110function fifoSendDatamsg(channel, num_bytes: integer; data_array: pcuint8): cbool; cdecl; external; 111 112function fifoSetAddressHandler(channel: integer; newhandler: FifoAddressHandlerFunc; userdata: pointer): cbool; cdecl; external; 113function fifoSetValue32Handler(channel: integer; newhandler: FifoValue32HandlerFunc; userdata: pointer): cbool; cdecl; external; 114function fifoSetDatamsgHandler(channel: integer; newhandler: FifoDatamsgHandlerFunc; userdata: pointer): cbool; cdecl; external; 115 116function fifoCheckAddress(channel: integer): cbool; cdecl; external; 117function fifoCheckValue32(channel: integer): cbool; cdecl; external; 118function fifoCheckDatamsg(channel: integer): cbool; cdecl; external; 119 120function fifoCheckDatamsgLength(channel: integer): cint; cdecl; external; 121 122function fifoGetAddress(channel: integer): pointer; cdecl; external; 123 124function fifoGetValue32(channel: integer): cuint32; cdecl; external; 125 126function fifoGetDatamsg(channel, buffersize: cint; destbuffer: pcuint8): cint; cdecl; external; 127 128procedure fifoWaitValue32(channel: cint); inline; 129 130{$endif NDS_INTERFACE} 131 132 133 134{$ifdef NDS_IMPLEMENTATION} 135 136procedure fifoWaitValue32(channel: cint); inline; 137begin 138 139 while (not fifoCheckValue32(channel)) do 140 begin 141 swiIntrWait(1, IRQ_FIFO_NOT_EMPTY); 142 end; 143 144end; 145 146 147{$endif NDS_IMPLEMENTATION} 148