Greg Brush / WiiMP
Embed: (wiki syntax)

« Back to documentation index

Show/hide line numbers WiiMP.h Source File

WiiMP.h

00001  /* Copyright (c) 2011 Greg Brush
00002  *
00003  * Permission is hereby granted, free of charge, to any person obtaining a copy
00004  * of this software and associated documentation files (the "Software"), to deal
00005  * in the Software without restriction, including without limitation the rights
00006  * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
00007  * copies of the Software, and to permit persons to whom the Software is
00008  * furnished to do so, subject to the following conditions:
00009  *
00010  * The above copyright notice and this permission notice shall be included in
00011  * all copies or substantial portions of the Software.
00012  *
00013  * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
00014  * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
00015  * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
00016  * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
00017  * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
00018  * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
00019  * THE SOFTWARE.
00020  *
00021  *  This code based on:
00022  *  WiiChuck
00023  *  http://mbed.org/users/FrankWeissenborn/libraries/WiiChuck/lnae1a
00024  *
00025  *  2011-03-14
00026  *  Interface with 3rd Party Wii Motion Plus (alone)
00027  *  This has not been tried with WiiMP plugged into Wii controller or Nunchuck
00028  */
00029  
00030 #ifndef __WIIMP_H
00031 #define __WIICMP_H
00032 
00033 #include "mbed.h"
00034 
00035 #define WMP_ADDR        0xA6  // pre-init WM+ address
00036 #define WIIEXT_ADDR     0xA4  // normal address for Wii Extensions
00037 #define WIIMP_READLEN   0x06  //
00038 #define I2C_ACK 0
00039 #define I2C_READ_DELAY  1     // delay in millisec
00040 
00041 #define YawL    0
00042 #define RollL   1
00043 #define PitchL  2
00044 #define YawH    3
00045 #define RollH   4
00046 #define PitchH  5
00047 
00048 class WiiMP {
00049 public:
00050     bool Error;
00051     WiiMP(PinName data, PinName clk);
00052     bool Read(int* Yaw,int* Roll,int* Pitch);
00053 private: 
00054     I2C _i2c;
00055 };
00056 
00057 #endif