From 90e07c00e275e90d0b0a0aec735e781a1c9adf2b Mon Sep 17 00:00:00 2001
From: =?UTF-8?q?Sergi=20Hern=C3=A1ndez?= <shernand@iri.upc.edu>
Date: Wed, 28 May 2014 17:59:08 +0000
Subject: [PATCH] Corrected the motion manager period register address at
 initialization. Changed the conversion function of the compass.

---
 src/HMC5843_compass.c | 2 +-
 src/bioloid_stm32.c   | 4 ++--
 2 files changed, 3 insertions(+), 3 deletions(-)

diff --git a/src/HMC5843_compass.c b/src/HMC5843_compass.c
index da5b65f..8440be8 100644
--- a/src/HMC5843_compass.c
+++ b/src/HMC5843_compass.c
@@ -172,7 +172,7 @@ void imu_compass_process_data(void)
 
   for(i=0;i<3;i++)
   {
-    value=(((int16_t)(i2c_compass_data[i*2]+(i2c_compass_data[i*2+1]<<8)))<<4)/1300;
+    value=(((int16_t)(i2c_compass_data[i*2+1]+(i2c_compass_data[i*2]<<8)))<<4)/1300;
     ram_data[BIOLOID_IMU_COMPASS_X_L+i*2]=value&0xFF;
     ram_data[BIOLOID_IMU_COMPASS_X_H+i*2]=(value>>8);
   }
diff --git a/src/bioloid_stm32.c b/src/bioloid_stm32.c
index d7f18f8..cdd23d8 100644
--- a/src/bioloid_stm32.c
+++ b/src/bioloid_stm32.c
@@ -151,9 +151,9 @@ int32_t main(void)
   // initialize the Analog to digital converter
 //  adc_init();
   // initialize motion manager
-  EE_ReadVariable(DEVICE_ID_OFFSET,&eeprom_data);
+  EE_ReadVariable(MM_PERIOD_OFFSET,&eeprom_data);
   action_period=eeprom_data&0x00FF;
-  EE_ReadVariable(DEVICE_ID_OFFSET+1,&eeprom_data);
+  EE_ReadVariable(MM_PERIOD_OFFSET+1,&eeprom_data);
   action_period+=((eeprom_data&0x00FF)<<8);
   mm_period=(action_period*1000000)>>16;
   manager_init(mm_period);
-- 
GitLab