Battery function prototypes

Discuss the development of new homebrew software, tools and libraries.

Moderators: cheriff, TyRaNiD

Post Reply
pspwill
Posts: 51
Joined: Thu Nov 17, 2005 8:07 am

Battery function prototypes

Post by pspwill »

Does anyone have a header file with the prototypes for sceSysconBatteryReadNVM and sceSysconBatteryWriteNVM?
SilverSpring
Posts: 110
Joined: Tue Feb 27, 2007 9:43 pm
Contact:

Post by SilverSpring »

Code: Select all

// Addresses valid from 0x00-0x7F
// returns < 0 on error
int sceSysconBatteryReadNVM&#40;u32 addr&#41;;
int sceSysconBatteryWriteNVM&#40;u32 addr, u16 data&#41;;
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: Select all

int pspSysconBatteryReadNVM&#40;u32 addr&#41;
&#123;
    u32 k1 = pspSdkSetK1&#40;0&#41;;

    if &#40;addr > 0x7F&#41;
        return&#40;0x80000102&#41;;
	
    u8 param&#91;0x60&#93;;
    param&#91;0x0C&#93; = 0x74; // read battery eeprom command
    param&#91;0x0D&#93; = 3;	// tx packet length

    // tx data
    param&#91;0x0E&#93; = addr;
		
    int res = sceSysconCmdExec&#40;param, 0&#41;;
    if &#40;res < 0&#41;
        return&#40;res&#41;;

    // rx data
    u16 data = &#40;param&#91;0x21&#93;<<8&#41; | param&#91;0x20&#93;;

    pspSdkSetK1&#40;k1&#41;;

    return&#40;data&#41;;
&#125;

int pspSysconBatteryWriteNVM&#40;u32 addr, u16 data&#41;
&#123;
    u32 k1 = pspSdkSetK1&#40;0&#41;;

    if &#40;addr > 0x7F&#41;
        return&#40;0x80000102&#41;;

    u8 param&#91;0x60&#93;;
    param&#91;0x0C&#93; = 0x73; // write battery eeprom command
    param&#91;0x0D&#93; = 5;	// tx packet length

    // tx data
    param&#91;0x0E&#93; = addr;
    param&#91;0x0F&#93; = data;
    param&#91;0x10&#93; = data>>8;
	
    int res = sceSysconCmdExec&#40;param, 0&#41;;
    if &#40;res < 0&#41;
        return&#40;res&#41;;

    pspSdkSetK1&#40;k1&#41;;

    return 0;
&#125;
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.
Post Reply