CanSat-C 2021 / HMC

Dependents:   CanSat-C_test test AvoidTest Run-Avoid

Files at this revision

API Documentation at this revision

Comitter:
miyajitakenari
Date:
Sat Nov 06 03:07:09 2021 +0000
Parent:
1:c1e543f15817
Commit message:
a

Changed in this revision

HMC6352.cpp Show annotated file Show diff for this revision Revisions of this file
HMC6352.h Show annotated file Show diff for this revision Revisions of this file
--- a/HMC6352.cpp	Thu Oct 28 09:33:50 2021 +0000
+++ b/HMC6352.cpp	Sat Nov 06 03:07:09 2021 +0000
@@ -1,40 +1,3 @@
-/**
- * @author Aaron Berk
- * 
- * @section LICENSE
- *
- * Copyright (c) 2010 ARM Limited
- *
- * Permission is hereby granted, free of charge, to any person obtaining a copy
- * of this software and associated documentation files (the "Software"), to deal
- * in the Software without restriction, including without limitation the rights
- * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
- * copies of the Software, and to permit persons to whom the Software is
- * furnished to do so, subject to the following conditions:
- *
- * The above copyright notice and this permission notice shall be included in
- * all copies or substantial portions of the Software.
- *
- * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
- * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
- * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
- * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
- * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
- * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
- * THE SOFTWARE.
- *
- * @section DESCRIPTION
- *
- * Honeywell HMC6352 digital compass.
- *
- * Datasheet:
- *
- * http://www.ssec.honeywell.com/magnetic/datasheets/HMC6352.pdf
- */
-
-/**
- * Includes
- */
 #include "HMC6352.h"
 
 HMC6352::HMC6352(PinName sda, PinName scl) {
@@ -66,28 +29,6 @@
 
 }
 
-void HMC6352::setSleepMode(int exitOrEnter) {
-
-    char tx[1];
-
-    tx[0] = exitOrEnter;
-
-    i2c_->write((HMC6352_I2C_ADDRESS << 1) & 0xFE, tx, 1);
-    wait_ms(1);
-
-}
-
-void HMC6352::setReset(void) {
-
-    char tx[1];
-
-    tx[0] = HMC6352_SET_RESET;
-
-    i2c_->write((HMC6352_I2C_ADDRESS << 1) & 0xFE, tx, 1);
-    wait_ms(7);
-
-}
-
 void HMC6352::setCalibrationMode(int exitOrEnter) {
 
     char tx[1];
@@ -106,94 +47,6 @@
 
 }
 
-void HMC6352::saveOpMode(void) {
-
-    char tx[1];
-
-    tx[0] = HMC6352_SAVE_OPMODE;
-
-    i2c_->write((HMC6352_I2C_ADDRESS << 1) & 0xFE, tx, 1);
-    wait_ms(1);
-
-}
-
-int HMC6352::getSlaveAddress(void) {
-
-    return read(HMC6352_EEPROM_READ, HMC6352_SLAVE_ADDR);
-
-}
-
-int HMC6352::getOffset(int axis) {
-
-    char rx[2] = {0x00, 0x00};
-
-    if (axis == HMC6352_MX_OFFSET) {
-
-        rx[0] = read(HMC6352_EEPROM_READ, HMC6352_MX_OFF_MSB);
-        rx[1] = read(HMC6352_EEPROM_READ, HMC6352_MX_OFF_LSB);
-
-    } else if (axis == HMC6352_MY_OFFSET) {
-
-        rx[0] = read(HMC6352_EEPROM_READ, HMC6352_MY_OFF_MSB);
-        rx[1] = read(HMC6352_EEPROM_READ, HMC6352_MY_OFF_LSB);
-
-    }
-
-    return ((rx[0] << 8) | (rx[1]));
-
-}
-
-void HMC6352::setOffset(int axis, int offset) {
-
-    char tx[2] = {0x00, 0x00};
-
-    tx[0] = (offset & 0x0000FF00) >> 8;
-    tx[1] = (offset & 0x000000FF);
-
-    if (axis == HMC6352_MX_OFFSET) {
-
-        write(HMC6352_EEPROM_WRITE, HMC6352_MX_OFF_MSB, tx[0]);
-        write(HMC6352_EEPROM_WRITE, HMC6352_MX_OFF_MSB, tx[1]);
-
-    } else if (axis == HMC6352_MY_OFFSET) {
-
-        write(HMC6352_EEPROM_WRITE, HMC6352_MY_OFF_MSB, tx[0]);
-        write(HMC6352_EEPROM_WRITE, HMC6352_MY_OFF_MSB, tx[1]);
-
-    }
-
-}
-
-int HMC6352::getTimeDelay(void) {
-
-    return read(HMC6352_EEPROM_READ, HMC6352_TIME_DELAY);
-
-}
-
-void HMC6352::setTimeDelay(int delay) {
-
-    write(HMC6352_EEPROM_WRITE, HMC6352_TIME_DELAY, delay);
-
-}
-
-int HMC6352::getSumNumber(void) {
-
-    return read(HMC6352_EEPROM_READ, HMC6352_SUMMED);
-
-}
-
-void HMC6352::setSumNumber(int sum) {
-
-    write(HMC6352_EEPROM_WRITE, HMC6352_SUMMED, sum);
-
-}
-
-int HMC6352::getSoftwareVersion(void) {
-
-    return read(HMC6352_EEPROM_READ, HMC6352_SOFT_VER);
-
-}
-
 int HMC6352::getOpMode(void) {
 
     int response = 0;
@@ -227,18 +80,6 @@
 
 }
 
-int HMC6352::getOutputMode(void) {
-
-    return read(HMC6352_RAM_READ, HMC6352_RAM_OUTPUT);
-
-}
-
-void HMC6352::setOutputMode(int mode) {
-
-    write(HMC6352_RAM_WRITE, HMC6352_RAM_OUTPUT, mode);
-
-}
-
 void HMC6352::write(int EepromOrRam, int address, int data) {
 
     char tx[3];
--- a/HMC6352.h	Thu Oct 28 09:33:50 2021 +0000
+++ b/HMC6352.h	Sat Nov 06 03:07:09 2021 +0000
@@ -1,37 +1,3 @@
-/**
- * @author Aaron Berk
- * 
- * @section LICENSE
- *
- * Copyright (c) 2010 ARM Limited
- *
- * Permission is hereby granted, free of charge, to any person obtaining a copy
- * of this software and associated documentation files (the "Software"), to deal
- * in the Software without restriction, including without limitation the rights
- * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
- * copies of the Software, and to permit persons to whom the Software is
- * furnished to do so, subject to the following conditions:
- *
- * The above copyright notice and this permission notice shall be included in
- * all copies or substantial portions of the Software.
- *
- * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
- * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
- * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
- * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
- * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
- * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
- * THE SOFTWARE.
- *
- * @section DESCRIPTION
- *
- * Honeywell HMC6352 digital compass.
- *
- * Datasheet:
- *
- * http://www.ssec.honeywell.com/magnetic/datasheets/HMC6352.pdf
- */
-
 #ifndef HMC6352_H
 #define HMC6352_H
 
@@ -43,44 +9,21 @@
 /**
  * Defines
  */
-#define HMC6352_I2C_ADDRESS  (0x21<<1) //7-bit address. 0x43 write, 0x42 read.
+#define HMC6352_I2C_ADDRESS  (0x42>>1) //7-bit address. 0x43 write, 0x42 read.
 
 //Commands.
 #define HMC6352_EEPROM_WRITE 0x77
-#define HMC6352_EEPROM_READ  0x72
 #define HMC6352_RAM_WRITE    0x47
 #define HMC6352_RAM_READ     0x67
-#define HMC6352_ENTER_SLEEP  0x53
-#define HMC6352_EXIT_SLEEP   0x57
-#define HMC6352_SET_RESET    0x4F
 #define HMC6352_ENTER_CALIB  0x43
 #define HMC6352_EXIT_CALIB   0x45
-#define HMC6352_SAVE_OPMODE  0x4C
 #define HMC6352_GET_DATA     0x41
 
 //EEPROM locations.
-#define HMC6352_SLAVE_ADDR   0x00
-#define HMC6352_MX_OFF_MSB   0x01
-#define HMC6352_MX_OFF_LSB   0x02
-#define HMC6352_MY_OFF_MSB   0x03
-#define HMC6352_MY_OFF_LSB   0x04
-#define HMC6352_TIME_DELAY   0x05
-#define HMC6352_SUMMED       0x06
-#define HMC6352_SOFT_VER     0x07
 #define HMC6352_OPMODE       0x08
 
 //RAM registers.
 #define HMC6352_RAM_OPMODE   0x74
-#define HMC6352_RAM_OUTPUT   0x4E
-
-#define HMC6352_MX_OFFSET    0x00
-#define HMC6352_MY_OFFSET    0x01
-
-#define HMC6352_HEADING_MODE 0x00
-#define HMC6352_RAWMAGX_MODE 0x01
-#define HMC6352_RAWMAGY_MODE 0x02
-#define HMC6352_MAGX_MODE    0x03
-#define HMC6352_MAGY_MODE    0x04
 
 //Operational mode register masks.
 #define HMC6352_CM_MR_1HZ    0x00
@@ -125,20 +68,6 @@
      */
     int sample(void);
 
-    /**
-     * Enter into or exit from sleep mode.
-     *
-     * @param enterOrExit 0x57 -> Exit sleep mode
-     *                    0x53 -> Enter
-     */
-    void setSleepMode(int enterOrExit);
-
-    /**
-     * Update bridge offsets.
-     *
-     * Performs a set/reset immediately.
-     */
-    void setReset(void);
 
     /**
      * Enter into or exit from calibration mode.
@@ -149,71 +78,6 @@
     void setCalibrationMode(int enterOrExit);
 
     /**
-     * Save the current operation mode byte to EEPROM.
-     */
-    void saveOpMode(void);
-
-    /**
-     * Read the memory location on the device which contains the slave address.
-     *
-     * @return The slave address of the device.
-     */
-    int getSlaveAddress(void);
-
-    /**
-     * Read the current offset for X or Y axis magnetometer.
-     *
-     * @param axis 0x00 -> X-axis
-     *             0x01 -> Y-axis
-     * @return The current offset for the axis as a 16-bit number.
-     */
-    int getOffset(int axis);
-
-    /**
-     * Set the offset for X or Y axis magnetometer.
-     *
-     * @param axis 0x00 -> X-axis
-     *             0x01 -> Y-axis
-     * @param offset The offset to set for the axis (set to a 16-bit number).
-     */
-    void setOffset(int axis, int offset);
-
-    /**
-     * Get the current time delay.
-     *
-     * @return The time delay in milliseconds.
-     */
-    int getTimeDelay(void);
-
-    /**
-     * Set the time delay of the device.
-     *
-     * @param delay The time delay to set in milliseconds (between 0-255);
-     */
-    void setTimeDelay(int delay);
-
-    /**
-     * Get the number of measurements being summed each sample.
-     *
-     * @return The number of summed measurement.
-     */
-    int getSumNumber(void);
-
-    /**
-     * Set the number of measurements being summed each sample.
-     *
-     * @param sum The number of measurements to be summed (between 0-16);
-     */
-    void setSumNumber(int sum);
-
-    /**
-     * Get the software version on the device.
-     *
-     * @return The software version number.
-     */
-    int getSoftwareVersion(void);
-
-    /**
      * Get the current operation mode.
      *
      * @return 0x00 -> Standby mode
@@ -235,24 +99,6 @@
      */
     void setOpMode(int mode, int periodicSetReset, int measurementRate = 0);
 
-    /**
-     * Get the current output mode of the device.
-     *
-     * @return The current output mode.
-     */
-    int getOutputMode(void);
-
-    /**
-     * Set the output mode of the device.
-     *
-     * @param mode 0x00 -> Heading mode
-     *             0x01 -> Raw magnetometer X mode
-     *             0x02 -> Raw magnetometer Y mode
-     *             0x03 -> Magnetometer X mode
-     *             0x04 -> Magnetometer Y mode
-     */
-    void setOutputMode(int mode);
-
 private:
 
     I2C* i2c_;