ok
Fork of HMC5843 by
Diff: HMC5843.cpp
- Revision:
- 2:fdab96fc6fff
- Parent:
- 1:65e41eb3c291
--- 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]); + +} + +