I am porting my WMB host over to the DS and therefore need to be able to send and receive raw 802.11 frames. I tried using the raw send and receive functions from the Wifi lib but did not have any luck (does the DS have to be associated with an AP for these to work?). So a'hacking I went to do some experimenting.
I have removed the arm9 side of the wifi lib.
The ARM7 initialises the hardware with a call to Wifi_Init (using a local Wifi_MainStruct structure) and calls Wifi_Start.
The Wifi_Update function is not called from the VBlank handler on the ARM7.
Frames are transmitted by the ARM7 calling Wifi_TxQueue directly. This works fine and I can capture the beacons sent out on a PC.
An external (to the library) received processor function (rxFrameProcessor) is installed by the Wifi_Init.
The receive side does not fare so well. For testing I have reduced Wifi_Intr_RxEnd to the following.
CODE
void Wifi_Intr_RxEnd() {
#define BUF_START 0x4c00
#define BUF_END 0x5F60
#define BUF_SIZE (BUF_END - BUF_START)
#define BUF_CONTENTS_SIZE( write, read) ( (read) > (write) ? \
(BUF_SIZE - ((read) - (write))) : ( (write) - (read)))
int base;
int packetlen;
int full_packetlen;
int dest_offset;
int i, cut, temp;
int tIME;
int max_read_size;
tIME = REG_IME;
REG_IME = 0;
cut = 0;
int write_ptr = WIFI_REG(0x54) << 1;
int read_ptr = WIFI_REG(0x5A) << 1;
max_read_size = BUF_CONTENTS_SIZE( write_ptr, read_ptr);
if ( rxFrameProcessor != NULL) {
rxFrameProcessor( 0);
}
rxFrameProcessor( write_ptr);
WIFI_REG( 0x5a) = write_ptr >> 1;
REG_IME = tIME;
return;
}
#define BUF_START 0x4c00
#define BUF_END 0x5F60
#define BUF_SIZE (BUF_END - BUF_START)
#define BUF_CONTENTS_SIZE( write, read) ( (read) > (write) ? \
(BUF_SIZE - ((read) - (write))) : ( (write) - (read)))
int base;
int packetlen;
int full_packetlen;
int dest_offset;
int i, cut, temp;
int tIME;
int max_read_size;
tIME = REG_IME;
REG_IME = 0;
cut = 0;
int write_ptr = WIFI_REG(0x54) << 1;
int read_ptr = WIFI_REG(0x5A) << 1;
max_read_size = BUF_CONTENTS_SIZE( write_ptr, read_ptr);
if ( rxFrameProcessor != NULL) {
rxFrameProcessor( 0);
}
rxFrameProcessor( write_ptr);
WIFI_REG( 0x5a) = write_ptr >> 1;
REG_IME = tIME;
return;
}
The code simply points the the read pointer to the current value of the write pointer (most of the other stuff is from previous experiments).
Now I would have thought this would happily sit there receiving frames forever but the interrupt appears to occur 128 times and then stop happening.
Does anybody know why this would happen? Is there something that I need to clear/reset that is not happening as I am not calling Wifi_Update?
Edit: the source has been removed from my webserver.
Any help much appreciated.
Ben
