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 

Direct access of PSP remote control UART

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



Joined: 22 Feb 2006
Posts: 80

PostPosted: Thu Mar 02, 2006 2:44 am    Post subject: Direct access of PSP remote control UART Reply with quote

Has anyone directly accessed the PSP remote control's uart? By direct access, I mean completely avoiding system calls, and only using the memory-mapped config registers.

If so, could you give me some sample code?

Thanks!!!

-Chris
Back to top
View user's profile Send private message
groepaz



Joined: 01 Sep 2005
Posts: 305

PostPosted: Mon Mar 06, 2006 11:10 am    Post subject: Reply with quote

doesnt the debug stuff in the pspsdk do it exactly like that? (minus the systemcalls that are abused to shut down the hprm driver)
_________________
http://www.hitmen-console.org
http://hitmen.c02.at/files/yapspd/
Back to top
View user's profile Send private message Visit poster's website
chrismulhearn



Joined: 22 Feb 2006
Posts: 80

PostPosted: Tue Mar 07, 2006 2:44 am    Post subject: Reply with quote

I'm not sure, I'm trying to not use the SDK.

Well, here is some nice simple code to read and write from the serial port, assuming you are in kernel mode!

Quote:

/*
* Chris Mulhearn
*
* PSP Serial port IO defs
*/
#ifndef SERIALPORT_H
#define SERIALPORT_H

struct serialport {
int * txbuf; // tx + rx same on psp, 0xbe50 0000, bits 7..0
int * rxbuf;
int * status;
#define serialport_txfull ((int)0x00000020)
#define serialport_rxempty ((int)0x00000010)
};

int serialport_write(struct serialport * port, char * buffer, int length, int timeout);
int serialport_read(struct serialport * port, char * buffer, int length, int timeout);

extern struct serialport psprc_serialport; // instantiated in serialport.c

#endif


Quote:

/*
* Chris Mulhearn
*
* PSP serial port IO routines
*/
#include "serialport.h"


/* instantiate "serialport" that points to psp remote control serial port */
struct serialport psprc_serialport = {
.txbuf = (int*)0xbe500000,
.rxbuf = (int*)0xbe500000,
.status = (int*)0xbe500018,
};

int serialport_write(struct serialport * port, char * buffer, int length, int timeout) {
int tcnt, bcnt;
if(length <= 0) return 0;
bcnt = 0;
while(1) {
tcnt = 0;
while( (*(port->status)) & serialport_txfull) {
tcnt++;
if(tcnt > timeout) break;
}
if(tcnt > timeout) break;
/*if(buffer[bcnt])*/ *(port->txbuf) = buffer[bcnt];
/*else *(port->txbuf) = '.'; */
bcnt++;
if(bcnt == length) break;
}
return bcnt;
}

int serialport_read(struct serialport * port, char * buffer, int length, int timeout) {
int tcnt, bcnt;
if(length <= 0) return 0;
bcnt = 0;
while(1) {
tcnt = 0;
while(( (*(port->status)) & serialport_rxempty)) {
tcnt++;
if(tcnt > timeout) break;
}
if(tcnt > timeout) break;
buffer[bcnt] = *((char*)port->rxbuf);
bcnt++;
if(bcnt == length) break;
}
return bcnt;
}



Let me know if this is useful to anyone!
Back to top
View user's profile Send private message
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