Direct access of PSP remote control UART

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

Moderators: cheriff, TyRaNiD

Post Reply
chrismulhearn
Posts: 80
Joined: Wed Feb 22, 2006 4:43 am

Direct access of PSP remote control UART

Post by chrismulhearn »

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
User avatar
groepaz
Posts: 305
Joined: Thu Sep 01, 2005 7:44 am
Contact:

Post by groepaz »

doesnt the debug stuff in the pspsdk do it exactly like that? (minus the systemcalls that are abused to shut down the hprm driver)
chrismulhearn
Posts: 80
Joined: Wed Feb 22, 2006 4:43 am

Post by chrismulhearn »

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!
/*
* 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
/*
* 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!
Post Reply