Forked from Jose R. Padron and Aaron Berk's library, customized for my specific application using 9DoF-Stick by Sparkfun.
Fork of HMC5843 by
HMC5843 is triple axis, digital interface compass (geomagnetic sensor).
This library is forked from Jose R. Padron and Aaron Berk's work.
This library is for specific application using 9DoF-Stick.
Datasheet:
http://www.sparkfun.com/datasheets/Sensors/Magneto/HMC5843.pdf
HMC5843 は3軸のデジタルインターフェースを備えたコンパス(地磁気センサ)です。
このライブラリは 9DoF-Stick を使用した特定の企画のために保守しています。
mbed IDEが日本語をサポートするまでは英語でコメントを書いていきますが、サポートした後もきっと英語で書いていくでしょう。
Diff: HMC5843.cpp
- Revision:
- 2:fdab96fc6fff
- Parent:
- 1:65e41eb3c291
- Child:
- 3:69f24a492b69
--- a/HMC5843.cpp Sat Oct 23 23:39:03 2010 +0000 +++ b/HMC5843.cpp Tue Nov 09 23:18:46 2010 +0000 @@ -1,6 +1,6 @@ /** * @author Jose R. Padron - *@author Used HMCHMC6352 library developed by Aaron Berk as template + * @author Used HMC6352 library developed by Aaron Berk as template * @section LICENSE * * Copyright (c) 2010 ARM Limited @@ -74,12 +74,6 @@ wait_ms(100); } -//void HMC5843::SelfTest() { - - //Future - -//} - void HMC5843::getAddress(char *buffer) { @@ -137,5 +131,46 @@ i2c_->read(HMC5843_I2C_READ,rx,2); readings[2]= (int)rx[0]<<8|(int)rx[1]; +} + +int HMC5843::getMx() { + + char tx[1]; + char rx[2]; + + + tx[0]=HMC5843_X_MSB; + i2c_->write(HMC5843_I2C_READ,tx,1); + i2c_->read(HMC5843_I2C_READ,rx,2); + return ((int)rx[0]<<8|(int)rx[1]); } + +int HMC5843::getMy() { + + char tx[1]; + char rx[2]; + + + tx[0]=HMC5843_Y_MSB; + i2c_->write(HMC5843_I2C_READ,tx,1); + i2c_->read(HMC5843_I2C_READ,rx,2); + return ((int)rx[0]<<8|(int)rx[1]); + +} + + +int HMC5843::getMz(){ + + char tx[1]; + char rx[2]; + + + tx[0]=HMC5843_Z_MSB; + i2c_->write(HMC5843_I2C_READ,tx,1); + i2c_->read(HMC5843_I2C_READ,rx,2); + return ((int)rx[0]<<8|(int)rx[1]); + +} + +