RDCM-802 Compass Module

Committer:
tosihisa
Date:
Fri Aug 06 06:49:16 2010 +0000
Revision:
3:95ffff059a20
Parent:
2:f472eda658ec

        

Who changed what in which revision?

UserRevisionLine numberNew contents of line
tosihisa 2:f472eda658ec 1 /**
tosihisa 2:f472eda658ec 2 * @section LICENSE
tosihisa 2:f472eda658ec 3 *
tosihisa 2:f472eda658ec 4 * This source code is "zlib" license.
tosihisa 2:f472eda658ec 5 * Of course, this is not a part of the zlib software.
tosihisa 2:f472eda658ec 6 * The license is zlib license.
tosihisa 2:f472eda658ec 7 *
tosihisa 3:95ffff059a20 8 * Copyright (C) 2010 tosihisa <tosihisa _at_ netfort.gr.jp>
tosihisa 2:f472eda658ec 9 *
tosihisa 2:f472eda658ec 10 * This software is provided 'as-is', without any express or implied
tosihisa 2:f472eda658ec 11 * warranty. In no event will the authors be held liable for any damages
tosihisa 2:f472eda658ec 12 * arising from the use of this software.
tosihisa 2:f472eda658ec 13 *
tosihisa 2:f472eda658ec 14 * Permission is granted to anyone to use this software for any purpose,
tosihisa 2:f472eda658ec 15 * including commercial applications, and to alter it and redistribute it
tosihisa 2:f472eda658ec 16 * freely, subject to the following restrictions:
tosihisa 2:f472eda658ec 17 *
tosihisa 2:f472eda658ec 18 * 1. The origin of this software must not be misrepresented; you must not
tosihisa 2:f472eda658ec 19 * claim that you wrote the original software. If you use this software
tosihisa 2:f472eda658ec 20 * in a product, an acknowledgment in the product documentation would be
tosihisa 2:f472eda658ec 21 * appreciated but is not required.
tosihisa 2:f472eda658ec 22 * 2. Altered source versions must be plainly marked as such, and must not be
tosihisa 2:f472eda658ec 23 * misrepresented as being the original software.
tosihisa 2:f472eda658ec 24 * 3. This notice may not be removed or altered from any source distribution.
tosihisa 2:f472eda658ec 25 *
tosihisa 2:f472eda658ec 26 * @section DESCRIPTION
tosihisa 2:f472eda658ec 27 *
tosihisa 2:f472eda658ec 28 */
tosihisa 0:def4240d9105 29 #include "mbed.h"
tosihisa 0:def4240d9105 30 #include "RDCM802.h"
tosihisa 0:def4240d9105 31
tosihisa 0:def4240d9105 32 RDCM802::RDCM802( PinName d0, PinName d1 ,PinName d2 ) : _d0(d0) , _d1(d1) , _d2(d2)
tosihisa 0:def4240d9105 33 {
tosihisa 0:def4240d9105 34 }
tosihisa 0:def4240d9105 35
tosihisa 0:def4240d9105 36 int RDCM802::read()
tosihisa 0:def4240d9105 37 {
tosihisa 0:def4240d9105 38 int retval = 0;
tosihisa 0:def4240d9105 39 retval = (_d2 != 0) ? 0x04 : 0;
tosihisa 0:def4240d9105 40 retval |= (_d1 != 0) ? 0x02 : 0;
tosihisa 0:def4240d9105 41 retval |= (_d0 != 0) ? 0x01 : 0;
tosihisa 0:def4240d9105 42 return retval;
tosihisa 0:def4240d9105 43 }
tosihisa 0:def4240d9105 44
tosihisa 0:def4240d9105 45 char *RDCM802::toString()
tosihisa 0:def4240d9105 46 {
tosihisa 0:def4240d9105 47 char *retval[8] = { "S ","SW","NE","N ","SE","W ","E ","NW" };
tosihisa 0:def4240d9105 48 return retval[read()];
tosihisa 0:def4240d9105 49 }
tosihisa 0:def4240d9105 50