osEepromLongWrite.c (769B)
1 #include "libultra_internal.h" 2 #include "controller.h" 3 4 #ifdef VERSION_CN 5 #define CLOCK_RATE (62500000ULL * 3 / 4) 6 #else 7 #define CLOCK_RATE osClockRate 8 #endif 9 10 s32 osEepromLongWrite(OSMesgQueue *mq, u8 address, u8 *buffer, int nbytes) { 11 s32 result = 0; 12 #ifndef VERSION_CN 13 if (address > 0x40) { 14 return -1; 15 } 16 #endif 17 18 while (nbytes > 0) { 19 result = osEepromWrite(mq, address, buffer); 20 if (result != 0) { 21 return result; 22 } 23 24 nbytes -= EEPROM_BLOCK_SIZE; 25 address++; 26 buffer += EEPROM_BLOCK_SIZE; 27 osSetTimer(&__osEepromTimer, 12000 * CLOCK_RATE / 1000000, 0, &__osEepromTimerQ, __osEepromTimerMsg); 28 osRecvMesg(&__osEepromTimerQ, NULL, OS_MESG_BLOCK); 29 } 30 31 return result; 32 }