Connect to a Wii Motion Plus (compatible) unit with no pass through or other controllers connected. The Motion Plus is a 3-axis gyroscope add-on w/Invensense IDG655 & IXZ650 MEMS gyros communicating via I2C @ 100KHz clock (some may do 400KHz)

Committer:
gbrush
Date:
Mon Mar 14 23:43:50 2011 +0000
Revision:
1:727906cb5051
Parent:
0:506079387c48
Removed decryption of returned data (^ 0x17), apparently not needed?

Who changed what in which revision?

UserRevisionLine numberNew contents of line
gbrush 0:506079387c48 1 /* Copyright (c) 2011 Greg Brush
gbrush 0:506079387c48 2 *
gbrush 0:506079387c48 3 * Permission is hereby granted, free of charge, to any person obtaining a copy
gbrush 0:506079387c48 4 * of this software and associated documentation files (the "Software"), to deal
gbrush 0:506079387c48 5 * in the Software without restriction, including without limitation the rights
gbrush 0:506079387c48 6 * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
gbrush 0:506079387c48 7 * copies of the Software, and to permit persons to whom the Software is
gbrush 0:506079387c48 8 * furnished to do so, subject to the following conditions:
gbrush 0:506079387c48 9 *
gbrush 0:506079387c48 10 * The above copyright notice and this permission notice shall be included in
gbrush 0:506079387c48 11 * all copies or substantial portions of the Software.
gbrush 0:506079387c48 12 *
gbrush 0:506079387c48 13 * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
gbrush 0:506079387c48 14 * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
gbrush 0:506079387c48 15 * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
gbrush 0:506079387c48 16 * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
gbrush 0:506079387c48 17 * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
gbrush 0:506079387c48 18 * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
gbrush 0:506079387c48 19 * THE SOFTWARE.
gbrush 0:506079387c48 20 *
gbrush 0:506079387c48 21 * This code based on:
gbrush 0:506079387c48 22 * WiiChuck
gbrush 0:506079387c48 23 * http://mbed.org/users/FrankWeissenborn/libraries/WiiChuck/lnae1a
gbrush 0:506079387c48 24 *
gbrush 0:506079387c48 25 * 2011-03-14
gbrush 0:506079387c48 26 * Interface with 3rd Party Wii Motion Plus (alone)
gbrush 0:506079387c48 27 * This has not been tried with WiiMP plugged into Wii controller or Nunchuck
gbrush 0:506079387c48 28 */
gbrush 0:506079387c48 29
gbrush 0:506079387c48 30 #ifndef __WIIMP_H
gbrush 0:506079387c48 31 #define __WIICMP_H
gbrush 0:506079387c48 32
gbrush 0:506079387c48 33 #include "mbed.h"
gbrush 0:506079387c48 34
gbrush 0:506079387c48 35 #define WMP_ADDR 0xA6 // pre-init WM+ address
gbrush 0:506079387c48 36 #define WIIEXT_ADDR 0xA4 // normal address for Wii Extensions
gbrush 0:506079387c48 37 #define WIIMP_READLEN 0x06 //
gbrush 0:506079387c48 38 #define I2C_ACK 0
gbrush 0:506079387c48 39 #define I2C_READ_DELAY 1 // delay in millisec
gbrush 0:506079387c48 40
gbrush 0:506079387c48 41 #define YawL 0
gbrush 0:506079387c48 42 #define RollL 1
gbrush 0:506079387c48 43 #define PitchL 2
gbrush 0:506079387c48 44 #define YawH 3
gbrush 0:506079387c48 45 #define RollH 4
gbrush 0:506079387c48 46 #define PitchH 5
gbrush 0:506079387c48 47
gbrush 0:506079387c48 48 class WiiMP {
gbrush 0:506079387c48 49 public:
gbrush 0:506079387c48 50 bool Error;
gbrush 0:506079387c48 51 WiiMP(PinName data, PinName clk);
gbrush 0:506079387c48 52 bool Read(int* Yaw,int* Roll,int* Pitch);
gbrush 0:506079387c48 53 private:
gbrush 0:506079387c48 54 I2C _i2c;
gbrush 0:506079387c48 55 };
gbrush 0:506079387c48 56
gbrush 0:506079387c48 57 #endif