chipKIT® Development Platform

Inspired by Arduino™

PS2_X library for Uno32...

Created Wed, 30 Nov 2011 17:24:03 +0000 by KurtE


KurtE

Wed, 30 Nov 2011 17:24:03 +0000

I have mentioned this in some other threads, but thought I would create it's own thread. A few weeks ago I became interested in playing with an UNO32 after I heard about through an Arduino Library I was playing with for a 4D Systems touch display... Thought it would be fun to try porting some of my Arduino Robots over to it and see how it does. My robots are all built with Lynxmotion parts and as most of their kits use a PS2 controller, I decided that I should try to get one of them working on the UNO32.

On Arduinos, I am using the Arduino PS2 library by Bill Porter. http://www.billporter.info/arduino-playstation-2-controller-library-troubleshooting-guide/

Which can be downloaded from GitHub: https://github.com/madsci1016/Arduino-PS2X

The Arduino Code did not use standard digitalWrite/Read functions as they were too slow, insted it converted the Arduino pins to port/mask and used them. I had to modify this for Uno32.

Likewise it used the digitalWrite high on the data line to enable PU resistor. I had to conditionalize that out for UNO32 and currently using external PU. Still would like way to see if you can enable internal PU resistors that I believe are on some of the UNO32 pins...

Also had to fix a fault that happened with data misalignment, when the code did something like: w = ((word)(PS2Data +3)), where PS2Data is a byte array.

The test program did compile and I believe I was getting valid data. Still need to test it more, but that will wait until I finish porting my 3 or 4 DOF hexapod code. When that is done I may try to figure out how to use GIT and merge the code (with owners permission) back up to github. But until then, I thought I would upload it here to see if anyone else would like to try it out.

Kurt

Note: I only tested my changes with UNO32, did not test with Arduino. Also tested on the released IDE, but did make a few changes to make it compile on the 1123 test build. Needed to enable internal header file to do the mapping for Pins to ports... Noticed some new structures defined in that release the digitalRead/Write use and wondering if I should convert to these...


YOBE.

Tue, 29 Oct 2013 04:27:54 +0000

Hi,

I use MPIDE 20120903, but when I try to compile I always receive errors and have no clue what is wrong. Can you help?

Do you have any idea what this could be?

This is the error code (part of it)

In file included from c:\yorick home\google drive\mpide-0023-windows-20120903\mpide-0023-windows-20120903\hardware\pic32\compiler\pic32-tools\bin../lib/gcc/pic32mx/4.5.1/../../../../pic32mx/include/peripheral/i2c.h:50:0, from c:\yorick home\google drive\mpide-0023-windows-20120903\mpide-0023-windows-20120903\hardware\pic32\compiler\pic32-tools\bin../lib/gcc/pic32mx/4.5.1/../../../../pic32mx/include/PLIB.h:54, from C:\Yorick Home\Google Drive\mpide-0023-windows-20120903\mpide-0023-windows-20120903.\hardware\pic32\libraries\PS2Xlib\PS2X_lib.cpp:12:

c:\yorick home\google drive\mpide-0023-windows-20120903\mpide-0023-windows-20120903\hardware\pic32\compiler\pic32-tools\bin../lib/gcc/pic32mx/4.5.1/../../../../pic32mx/include/GenericTypeDefs.h:342:33: error: expected unqualified-id before numeric constant

c:\yorick home\google drive\mpide-0023-windows-20120903\mpide-0023-windows-20120903\hardware\pic32\compiler\pic32-tools\bin../lib/gcc/pic32mx/4.5.1/../../../../pic32mx/include/GenericTypeDefs.h:360:5: error: expected unqualified-id before numeric constant

c:\yorick home\google drive\mpide-0023-windows-20120903\mpide-0023-windows-20120903\hardware\pic32\compiler\pic32-tools\bin../lib/gcc/pic32mx/4.5.1/../../../../pic32mx/include/GenericTypeDefs.h:363:21: error: expected unqualified-id before numeric constant

c:\yorick home\google drive\mpide-0023-windows-20120903\mpide-0023-windows-20120903\hardware\pic32\compiler\pic32-tools\bin../lib/gcc/pic32mx/4.5.1/../../../../pic32mx/include/GenericTypeDefs.h:364:21: error: expected unqualified-id before numeric constant

c:\yorick home\google drive\mpide-0023-windows-20120903\mpide-0023-windows-20120903\hardware\pic32\compiler\pic32-tools\bin../lib/gcc/pic32mx/4.5.1/../../../../pic32mx/include/GenericTypeDefs.h:365:21: error: expected unqualified-id before numeric constant

c:\yorick home\google drive\mpide-0023-windows-20120903\mpide-0023-windows-20120903\hardware\pic32\compiler\pic32-tools\bin../lib/gcc/pic32mx/4.5.1/../../../../pic32mx/include/GenericTypeDefs.h:366:21: error: expected unqualified-id before numeric constant

At the end but I think it is related to previous errors:

C:\Yorick Home\Google Drive\mpide-0023-windows-20120903\mpide-0023-windows-20120903.\hardware\pic32\libraries\PS2Xlib\PS2X_lib.cpp: In member function 'unsigned char PS2X::_gamepad_shiftinout(char)': C:\Yorick Home\Google Drive\mpide-0023-windows-20120903\mpide-0023-windows-20120903.\hardware\pic32\libraries\PS2Xlib\PS2X_lib.cpp:57:24: error: expected primary-expression before '>' token C:\Yorick Home\Google Drive\mpide-0023-windows-20120903\mpide-0023-windows-20120903.\hardware\pic32\libraries\PS2Xlib\PS2X_lib.cpp: In member function 'byte PS2X::config_gamepad(uint8_t, uint8_t, uint8_t, uint8_t, bool, bool)': C:\Yorick Home\Google Drive\mpide-0023-windows-20120903\mpide-0023-windows-20120903.\hardware\pic32\libraries\PS2Xlib\PS2X_lib.cpp:141:14: error: invalid conversion from 'volatile uint32_t*' to 'volatile __uint32_t*' C:\Yorick Home\Google Drive\mpide-0023-windows-20120903\mpide-0023-windows-20120903.\hardware\pic32\libraries\PS2Xlib\PS2X_lib.cpp:143:14: error: invalid conversion from 'volatile uint32_t*' to 'volatile __uint32_t*' C:\Yorick Home\Google Drive\mpide-0023-windows-20120903\mpide-0023-windows-20120903.\hardware\pic32\libraries\PS2Xlib\PS2X_lib.cpp:145:14: error: invalid conversion from 'volatile uint32_t*' to 'volatile __uint32_t*' C:\Yorick Home\Google Drive\mpide-0023-windows-20120903\mpide-0023-windows-20120903.\hardware\pic32\libraries\PS2Xlib\PS2X_lib.cpp:147:14: error: invalid conversion from 'volatile uint32_t*' to 'volatile __uint32_t*'