forums.ps2dev.org Forum Index forums.ps2dev.org
Homebrew PS2, PSP & PS3 Development Discussions
 
 FAQFAQ   SearchSearch   MemberlistMemberlist   UsergroupsUsergroups   RegisterRegister 
 ProfileProfile   Log in to check your private messagesLog in to check your private messages   Log inLog in 

Battery function prototypes

 
Post new topic   Reply to topic    forums.ps2dev.org Forum Index -> PSP Development
View previous topic :: View next topic  
Author Message
pspwill



Joined: 17 Nov 2005
Posts: 51

PostPosted: Fri Jul 18, 2008 12:48 am    Post subject: Battery function prototypes Reply with quote

Does anyone have a header file with the prototypes for sceSysconBatteryReadNVM and sceSysconBatteryWriteNVM?
Back to top
View user's profile Send private message
SilverSpring



Joined: 27 Feb 2007
Posts: 115

PostPosted: Sat Jul 19, 2008 11:52 am    Post subject: Reply with quote

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.
Back to top
View user's profile Send private message Visit poster's website
Display posts from previous:   
Post new topic   Reply to topic    forums.ps2dev.org Forum Index -> PSP Development All times are GMT + 10 Hours
Page 1 of 1

 
Jump to:  
You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum
You cannot vote in polls in this forum


Powered by phpBB © 2001, 2005 phpBB Group