 |
forums.ps2dev.org Homebrew PS2, PSP & PS3 Development Discussions
|
| View previous topic :: View next topic |
| Author |
Message |
chrismulhearn
Joined: 22 Feb 2006 Posts: 80
|
Posted: Thu Mar 02, 2006 2:44 am Post subject: Direct access of PSP remote control UART |
|
|
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 |
|
 |
groepaz

Joined: 01 Sep 2005 Posts: 305
|
|
| Back to top |
|
 |
chrismulhearn
Joined: 22 Feb 2006 Posts: 80
|
Posted: Tue Mar 07, 2006 2:44 am Post subject: |
|
|
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 |
|
 |
|
|
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
|