CCS C Software and Maintenance Offers
FAQFAQ   FAQForum Help   FAQOfficial CCS Support   SearchSearch  RegisterRegister 

ProfileProfile   Log in to check your private messagesLog in to check your private messages   Log inLog in 

CCS does not monitor this forum on a regular basis.

Please do not post bug reports on this forum. Send them to CCS Technical Support

Playstation 2 Controller SPI Interface, Help!

 
Post new topic   Reply to topic    CCS Forum Index -> General CCS C Discussion
View previous topic :: View next topic  
Author Message
gwg_1313



Joined: 01 Dec 2004
Posts: 1

View user's profile Send private message

Playstation 2 Controller SPI Interface, Help!
PostPosted: Wed Dec 01, 2004 9:14 pm     Reply with quote

Hello All --

Has anyone successfully interfaced with a Playstation 2 Controller with the built in CCS SPI functionality? I'm having problems establishing communications.. Any comments, sample code, interface schematics would be greatly appreciated.

Thanks,
Gary
[email protected]
Mark



Joined: 07 Sep 2003
Posts: 2838
Location: Atlanta, GA

View user's profile Send private message Send e-mail

PostPosted: Wed Dec 01, 2004 11:27 pm     Reply with quote

http://www.gamesx.com/controldata/psxcont/psxcont.htm
Guest








PostPosted: Sat Dec 04, 2004 5:15 pm     Reply with quote

I already found that website... I was hoping someone had experince doing it via CCS SPI.

Thanks,
Gary
[email protected]
new
Guest







PostPosted: Tue Sep 27, 2005 8:29 pm     Reply with quote

i have the same problem can anyone help??
vinicius.mecatronica



Joined: 25 Apr 2013
Posts: 1
Location: Brazil

View user's profile Send private message

Solved
PostPosted: Wed Sep 04, 2013 11:04 am     Reply with quote

Hi friend,
I needed the same project. I was trying to use the spi but it just got me mad. I reproduced the spi behavior moving bits and it worked. Cool

Code:

#include <main.h>

#define lcd_rs         pin_a0      // pino rs do LCD
#define lcd_enable     pin_a1      // pino enable do LCD
#define lcd_d4         pin_a2      // pino de dados d4 do LCD
#define lcd_d5         pin_a3      // pino de dados d5 do LCD
#define lcd_d6         pin_a4      // pino de dados d6 do LCD
#define lcd_d7         pin_a5      // pino de dados d7 do LCD

#include "mod_lcd.c"

#define clk_ps         pin_b7
#define comm_ps        pin_b6
#define data_ps        pin_b5
#define att_ps         pin_b4
#define ack_ps         pin_b3

int play (int ps_out)
{
int ps_in = 0;

   delay_us(2);
   output_low(clk_ps);
   output_bit(comm_ps,bit_test(ps_out,0));  // envia saída
   delay_us(2);
   output_high(clk_ps);
   if(input(data_ps)){bit_set(ps_in,0); } else {bit_clear(ps_in,0); } // lendo entrada

   delay_us(2);
   output_low(clk_ps);
   output_bit(comm_ps,bit_test(ps_out,1));  // envia saída
   delay_us(2);
   output_high(clk_ps);
   if(input(data_ps)){bit_set(ps_in,1); } else {bit_clear(ps_in,1); } // lendo entrada

   delay_us(2);
   output_low(clk_ps);
   output_bit(comm_ps,bit_test(ps_out,2));  // envia saída
   delay_us(2);
   output_high(clk_ps);
   if(input(data_ps)){bit_set(ps_in,2); } else {bit_clear(ps_in,2); } // lendo entrada

   delay_us(2);
   output_low(clk_ps);
   output_bit(comm_ps,bit_test(ps_out,3));  // envia saída
   delay_us(2);
   output_high(clk_ps);
   if(input(data_ps)){bit_set(ps_in,3); } else {bit_clear(ps_in,3); } // lendo entrada

   delay_us(2);
   output_low(clk_ps);
   output_bit(comm_ps,bit_test(ps_out,4));  // envia saída
   delay_us(2);
   output_high(clk_ps);
   if(input(data_ps)){bit_set(ps_in,4); } else {bit_clear(ps_in,4); } // lendo entrada

   delay_us(2);
   output_low(clk_ps);
   output_bit(comm_ps,bit_test(ps_out,5));  // envia saída
   delay_us(2);
   output_high(clk_ps);
   if(input(data_ps)){bit_set(ps_in,5); } else {bit_clear(ps_in,5); } // lendo entrada

   delay_us(2);
   output_low(clk_ps);
   output_bit(comm_ps,bit_test(ps_out,6));  // envia saída
   delay_us(2);
   output_high(clk_ps);
   if(input(data_ps)){bit_set(ps_in,6); } else {bit_clear(ps_in,6); } // lendo entrada

   delay_us(2);
   output_low(clk_ps);
   output_bit(comm_ps,bit_test(ps_out,7));  // envia saída
   delay_us(2);
   output_high(clk_ps);
   if(input(data_ps)){bit_set(ps_in,7); } else {bit_clear(ps_in,7); } // lendo entrada

   delay_us(200);

return ps_in;
}


void main()
{
//!int x=0,y=0,z=0,ang1 = 0,ang2 = 0,ang3 = 0;
int ps_in = 0, ps_out=0x01;
int ps_in2 = 0, ps_out2=0x42;
int ps_in3 = 0, ps_out3=0x00;
int ps_in4 = 0, ps_out4=0x00;
int ps_in5 = 0, ps_out5=0x00;
delay_ms(500);
output_high(clk_ps);
output_high(att_ps);

lcd_ini();

   while(true)
   {
   output_low(att_ps);
   ps_in = play(ps_out);
   ps_in2 = play(ps_out2);   
   ps_in3 = play(ps_out3);
   ps_in4 = play(ps_out4);   
   ps_in5 = play(ps_out5);
   output_high(att_ps);

   lcd_escreve ('\f'); // limpa o display   
   lcd_pos_xy (1, 1); // Posiciona cursor no LCD
   printf (lcd_escreve, "%2X %2X %2X %2X ",ps_out,ps_in,ps_out2,ps_in2);
   lcd_pos_xy (1, 2); // Posiciona cursor no LCD
   printf (lcd_escreve, "%2X%2X %2X%2X %2X%2X",ps_out3,ps_in3,ps_out4,ps_in4,ps_out5,ps_in5);
   delay_ms(100);
   
//!   break;
}

}



The right values to ps_out you can find in here http://store.curiousinventor.com/guides/PS2/#hardware

in this code, the values of ps_in4 and ps_in5 are the data from the buttons.

I hope I have helped.

Cheers!
Display posts from previous:   
Post new topic   Reply to topic    CCS Forum Index -> General CCS C Discussion All times are GMT - 6 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