Shop OBEX P1 Docs P2 Docs Learn Events
Javelin interfacing to a PS/2 mouse using the PAK-XI - Need some help — Parallax Forums

Javelin interfacing to a PS/2 mouse using the PAK-XI - Need some help

HueyHuey Posts: 23
edited 2008-03-05 12:38 in General Discussion
The PAK-XI sounds like a great little coprossessor as i have researched it for part of my senior project.·However the site that i found it at only supplies BS2 code for it and i am having a little difficultyconfused.gif translating it to Javelin, more specificly the SERIN part.
I know that i am going to need two Uarts: rxUart and txUart.· As of right now, the code i have is suppose to, in theory, initialize the PAK-XI and then go into an endless loop and display bursts of 5 bytes (raw), wait awhile and do again.

shocked.gif·/Main class

import stamp.core.*;
import stamp.peripheral.hid.PAK_XI;

public class MightyMouse{
· public static PAK_XI theMouse;
· public static void main(){
··· System.out.println("Hello.");
··· theMouse = new PAK_XI(CPU.pin0, CPU.pin1);
··· System.out.println("Hello. Again.");
··· while(true){
····· System.out.println("In while...");
····· theMouse.displayNextFive();
····· CPU.delay(20000);
··· }
· }
}
//==============================
//PAK_XI class file
package stamp.peripheral.hid;
import stamp.core.*;
public class PAK_XI{
· private Uart commTx;
· private Uart commRx;
· private int getpkt = 5;
· private int pakrst = 255;
· private int rxPin;
· private int txPin;
· private int flowPin;
· private int xRawHigh;
· private int xRawLow;
· private int yRawHigh;
· private int yRawLow;
· private int status;
· public PAK_XI(int txPin, int rxPin){
··· System.out.println("Hello. from constructor.");
··· //create the transmitter
··· commTx = new Uart(Uart.dirTransmit, txPin, Uart.dontInvert, Uart.speed9600, Uart.stop1);
··· //create the receiver
··· commRx = new Uart(Uart.dirReceive, rxPin, Uart.dontInvert, Uart.speed9600, Uart.stop1);
··· //wait for the PAK to initialize w/ the mouse
··· System.out.println("waiting to initialize.");
··· CPU.delay(1500);

··· do {
····· System.out.println("Tx Buffer is full.");
··· }while(commTx.sendBufferFull());
··· //reset the PAK
··· System.out.println("Reseting PAK");
··· commTx.sendByte(pakrst);
··· CPU.delay(500);
· }
· /**
· * This function will not return until it has obtained 5 bytes.
· * Each byte it gets it will display in the debug screen.
· */
· public void displayNextFive(){
··· do{
····· System.out.println("Send buffer not empty.");
··· }while(!commTx.sendBufferEmpty());
··· commTx.sendByte(getpkt);
··· int counter = 0;
··· CPU.writePin(CPU.pin2, false);
··· while(counter<5){
····· if(commRx.byteAvailable()){
······· System.out.println(commRx.receiveByte());
······· counter++;
····· }
····· System.out.println("Looping...");
··· }
··· CPU.writePin(CPU.pin2, true);
· }
}

I've also attached the manual for the PAK-XI
Like always, all help is greatly appreciated.
As it is my Senior Project

thanx in advance,
Micro

(edit)
Forgot to include the file that PAK-XI includes for the BS2.

▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔
Huey


Double Bachelor of Science
CPET - Computer Engineering Technologies
CIS - Computer Information Systems
MSU-Northern
Chair of MSU-Northern IEEE Student Branch

Post Edited (Huey) : 3/7/2008 3:58:10 AM GMT
Sign In or Register to comment.