Reads/writes multiple blocks in EEPRom
#include <ultra64.h> /* os.h */ s32 osEepromLongRead(OSMesgQueue *mq, u8 address, u8 *buffer, int nbytes); s32 osEepromLongWrite(OSMesgQueue *mq, u8 address, u8 *buffer, int nbytes);
The osEepromLongRead function issues a read command to EEProm and reads nbytes of data from the address specified by address. The osEepromLongWritefunction issues a write command to EEPRom and writes nbytes of data to the address specified by address.
The size of buffer, which is used for storing the data, must be large enough to hold nbytes of data. Also, due to hardware restrictions, the transfer byte size (nbytes) must be a multiple of 8. Note that address is an EEPROM block address. Because blocks are in units of 8 bytes, you must specify a value that is divisible by 8 for the actual address.
"mq" is the initialized message queue associated with OS_EVENT_SI events. For details, see the osSetEventMesg function in the N64 Online Function Reference Manual. Since mq is used inside the function to wait for messages, the application does not need to use mq to wait for an end-of-function message.
It can take as long as 15 milliseconds for the EEPROM write command to complete a data transfer. The osEepromWrite function is called numerous times inside the osEepromLongWrite function, and the CPU timer is used to wait 15 milliseconds every time data is written with osEepromWrite. The returned values are the same as for osEepromWrite. That is to say, the returned value is 0 if all write commands (the amount for "length" (=nbytes/8) number of times) have been properly sent to the interface circuit. The returned value is -1 if the value of "address" is not within the proper range. The returned value is 8 (CONT_NO_RESPONSE_ERROR) if no EEPROM exists or if the interface circuit does not respond.
The osEepromLongRead function internally calls osEepromRead the length number of times. The returned values are the same as for the osEepromRead function. A 0 is returned if all data (the amount for "length" number of times) is properly read. A -1 is returned if the value of address is not within the proper range. An 8 is returned (CONT_NO_RESPONSE_ERROR) if no EEPROM exists or if the interface circuit does not respond.
osContInit, osEepromProbe, osEepromRead, osEepromWrite, and osSetEventMesg
1999/02/01 Revised entirely
1999/04/30 Changed format