summaryrefslogtreecommitdiff
path: root/lib/ultralib/src/io/conteeplongwrite.c
blob: c5668e15bd8e459803d4cd9e21397f16fdbb01f7 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
#include "PR/os_internal.h"
#include "controller.h"

s32 osEepromLongWrite(OSMesgQueue* mq, u8 address, u8* buffer, int length) {
    s32 ret = 0;

    while (length > 0) {
        ERRCK(osEepromWrite(mq, address, buffer));
        length -= EEPROM_BLOCK_SIZE;
        address++;
        buffer += EEPROM_BLOCK_SIZE;
        osSetTimer(&__osEepromTimer, OS_USEC_TO_CYCLES(12000), 0, &__osEepromTimerQ, &__osEepromTimerMsg);
        osRecvMesg(&__osEepromTimerQ, NULL, OS_MESG_BLOCK);
    }

    return ret;
}