Skip to content

Instantly share code, notes, and snippets.

@GXTX
Last active July 19, 2020 18:52
Show Gist options
  • Save GXTX/109bcdd4d6aaf7c27099fc53a3c73f05 to your computer and use it in GitHub Desktop.
Save GXTX/109bcdd4d6aaf7c27099fc53a3c73f05 to your computer and use it in GitHub Desktop.
/*
write_eeprom.c
----------------
Copyright (C) 2020 wutno (https://github.com/GXTX)
This program is free software; you can redistribute it and/or modify
it under the terms of the GNU General Public License as published by
the Free Software Foundation; either version 2 of the License, or
(at your option) any later version.
This program is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
GNU General Public License for more details.
You should have received a copy of the GNU General Public License along
with this program; if not, write to the Free Software Foundation, Inc.,
51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
*/
#include <hal/debug.h>
#include <hal/video.h>
#include <windows.h>
#include <nxdk/mount.h>
#include <stdio.h>
int main(void)
{
XVideoSetMode(640, 480, 32, REFRESH_DEFAULT);
if (!nxMountDrive('E', "\\Device\\Harddisk0\\Partition1\\")) {
debugPrint("Failed to mount E: drive!\n");
return 1;
}
const char* eeprom_name = "E:\\eeprom.bin";
unsigned char eeprom_buffer[256];
FILE *file;
file = fopen(eeprom_name, "r");
int count = fread(&eeprom_buffer, 1, 256, file);
fclose(file);
if (count != 256) {
debugPrint("Something bad happened.\n");
Sleep(1000);
return 1;
}
for (int i = 0; i < 256; i++) {
HalWriteSMBusValue(0xA8, i, 0, eeprom_buffer[i]);
}
debugPrint("Wrote eeprom.");
Sleep(1000);
return 0;
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment