In this post I will show you how you can access I2C devices with iMX233-OLinuXino and how to read WII-NUNCHUCK info.
WII is popular game console, the NUNCHUCK accessory contain two buttons, accelerometer and joystick combo, as it’s mass produced the price is incredible low. You can read more about it at Wikipedia http://en.wikipedia.org/wiki/Wii_Remote
Olimex offers MOD-WII-UEXT-NUNCHUCK which contains WII-NUNCHUCK coupled to UEXT connector, so you can directly connect it to any of our boards with UEXT connector like our Arduino, Pinguino, Maple, Energia etc boards and of course iMX233/A13-OLinuXino.
Before you start working with I2C you have to check if your iMX233-OLinuXino board is with UEXT connected to the hardware I2C ports.
Why? When we designed the iMX233 we wanted to keep the LCD port complete and the hardware I2C was multiplexed with the LCD ports.
So we put triple jumper on UEXT I2C signals which cold be soldered to software and hardware I2C ports. By default we made them to the software I2C.
Later we found that software defined I2C is bad idea on RTOS as on heavy load I2C may not timing correctly and that it’s recommended to use just the hardware I2C so from the beginning of September we soart producing iMX233-OLinuXino with jumpers wired to the hardware I2C.
As there are still many iMX233 on stock at our distributors we described in the user manual how one could do this himself.
So to work with the code below you should make sure your iMX233-OLinuXino have wired hardware I2C to UEXT.
Download the code from GitHub https://github.com/OLIMEX/OLINUXINO/blob/master/SOFTWARE/iMX233/I2C/MOD-Wii-UEXT-NUNCHUCK.c
and write it to the SD card by SSH or flash dongle.
then you need to compile it
$ cc MOD-Wii-UEXT-NUNCHUCK.c -o wii
$ chmod +x wii
now on the console connected to terminal you should see picture like this:
when you move the joystick, push the buttons or shake the Nunchuck you can see these numbers change.
Here is video of iMX233-OLinuXino running above code: http://www.youtube.com/watch?v=pSVG3LF7uqA