You are here
Home > Download > Document > [ePSC] Example C code

[ePSC] Example C code

unsigned char big_motor; //Small vibration motor value of DualShock2
unsigned char small_motor; //Big vibration motor value of DualShock2
unsigned char DS2_data[17]; //Buffer to receive DualShock2’s Data
//Pin definition of Enbedded PsJoyCon
#define SEL P3_2
#define CLK P3_3
#define RDY P3_4
//Data order of Enbedded PsJoyCon
#define DS2_LX 0
#define DS2_LY 1
#define DS2_RX 2
#define DS2_RY 3
#define DS2_X 4
#define DS2_S 5
#define DS2_T 6
#define DS2_O 7
#define DS2_L 8
#define DS2_R 9
#define DS2_U 10
#define DS2_D 11
#define DS2_L1 12
#define DS2_L2 13
#define DS2_R1 14
#define DS2_R2 15
#define DS2_StR3L3Sel 16
void PollDS2()
{
unsigned char i;
P1 = small_motor; //Small vibration motor value of DualShock2
SEL = 0; //Select Embedded PsJoyCon module
while(RDY){RDY = 1;} //Wait RDY low
P1 = 0xFF; DS2_data[0] = P1; //Read Data[0]
P1 = big_motor; //Big vibration motor value of DualShock2
CLK = 0; //CLK low
while(!RDY){RDY = 1;CLK = 0;} //Wait RDY high
for(i=1 ; i<17 ; i+=2)
{
P1 = 0xFF; DS2_data[i] = P1; //Read Data[i]
CLK = 1; //CLK high
while(RDY){RDY = 1;CLK = 1;} //Wait RDY low

P1 = 0xFF; DS2_data[i+1] = P1; //Read Data[i+1]
CLK = 0; //CLK low
while(!RDY){RDY = 1;CLK = 0;} //Wait RDY high
}
CLK = 1;
SEL = 1; //Unselect Embedded PsJoyCon module
}

https://www.exinterface.com/d/man/epsc/ePSC_Code_eng.pdf

 

Share with:


Similar Articles

Leave a Reply

Top