SilverSpring
Joined: 27 Feb 2007 Posts: 115
|
Posted: Sat Jul 19, 2008 11:52 am Post subject: |
|
|
| Code: |
// Addresses valid from 0x00-0x7F
// returns < 0 on error
int sceSysconBatteryReadNVM(u32 addr);
int sceSysconBatteryWriteNVM(u32 addr, u16 data);
|
However, this API was taken out of the firmware starting from 3.80 so if you're on 3.80+ cfw you can't use these functions.
Here's a compatible replacement to use on 3.80+ cfw:
| Code: |
int pspSysconBatteryReadNVM(u32 addr)
{
u32 k1 = pspSdkSetK1(0);
if (addr > 0x7F)
return(0x80000102);
u8 param[0x60];
param[0x0C] = 0x74; // read battery eeprom command
param[0x0D] = 3; // tx packet length
// tx data
param[0x0E] = addr;
int res = sceSysconCmdExec(param, 0);
if (res < 0)
return(res);
// rx data
u16 data = (param[0x21]<<8) | param[0x20];
pspSdkSetK1(k1);
return(data);
}
int pspSysconBatteryWriteNVM(u32 addr, u16 data)
{
u32 k1 = pspSdkSetK1(0);
if (addr > 0x7F)
return(0x80000102);
u8 param[0x60];
param[0x0C] = 0x73; // write battery eeprom command
param[0x0D] = 5; // tx packet length
// tx data
param[0x0E] = addr;
param[0x0F] = data;
param[0x10] = data>>8;
int res = sceSysconCmdExec(param, 0);
if (res < 0)
return(res);
pspSdkSetK1(k1);
return 0;
}
|
However, the read/write eeprom commands (0x73/0x74) have also been taken out of the SYSCON µC on newer slim models (TA-085v2 and TA-088) so even the above will no longer work. Also newer battery µC's have also removed this eeprom read/write interface. |
|