Driver for the HSCDTD008A Geomagnetic Sensor.

Dependents:   HSCDTD008A_Hello

Files at this revision

API Documentation at this revision

Comitter:
hudakz
Date:
Sun Jun 20 14:18:02 2021 +0000
Parent:
0:ccf912737de7
Commit message:
Driver for the HSCDTD008A Geomagnetic Sensor.

Changed in this revision

HSCDTD008A.cpp Show annotated file Show diff for this revision Revisions of this file
HSCDTD008A.h Show annotated file Show diff for this revision Revisions of this file
diff -r ccf912737de7 -r b90695c17177 HSCDTD008A.cpp
--- a/HSCDTD008A.cpp	Sun Jun 20 13:55:42 2021 +0000
+++ b/HSCDTD008A.cpp	Sun Jun 20 14:18:02 2021 +0000
@@ -69,9 +69,8 @@
  * @param
  * @retval
  */
-HSCDTD008A::HSCDTD008A(PinName sda, PinName scl, PinName drdy /*= NC*/, uint8_t addr /*= 0x0C*/ ) :
+HSCDTD008A::HSCDTD008A(PinName sda, PinName scl, uint8_t addr /*= 0x0C*/ ) :
     _i2c(new I2C(sda, scl)),
-    _drdy(drdy),
     _addr(addr << 1),           // convert to 8bit address
     _x(0),
     _y(0),
@@ -126,7 +125,7 @@
  * @param
  * @retval
  */
-uint8_t HSCDTD008A::selftest()
+uint8_t HSCDTD008A::selfTest()
 {
     const char  start_selftest[] = { CTRL3, (1 << STC) };
     char        ret;
@@ -239,7 +238,7 @@
     while (true) {
         ThisThread::sleep_for(1ms);
 
-        // read the Status register
+        // read Status register
         _i2c->write(_addr, &STAT, 1);
         _i2c->read(_addr, &ret, 1);
 
@@ -287,7 +286,7 @@
 {
     char    ret;
 
-    // read the FIFO pointer register
+    // read FIFO pointer register
     _i2c->write(_addr, &FFPT, 1);
     _i2c->read(_addr, &ret, 1);
 
diff -r ccf912737de7 -r b90695c17177 HSCDTD008A.h
--- a/HSCDTD008A.h	Sun Jun 20 13:55:42 2021 +0000
+++ b/HSCDTD008A.h	Sun Jun 20 14:18:02 2021 +0000
@@ -1,21 +1,3 @@
-/*
- * Copyright (c) 2020 Zoltan Hudak <hudakz@outlook.com>
- * All rights reserved.
- *
- * This program is free software: you can redistribute it and/or modify
- * it under the terms of the GNU General Public License as published by
- * the Free Software Foundation, either version 3 of the License, or
- * (at your option) any later version.
- *
- * This program is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
- * GNU General Public License for more details.
- *
- * You should have received a copy of the GNU General Public License
- * along with this program.  If not, see <http://www.gnu.org/licenses/>.
- */
-
 #ifndef HSCDTD008A_H
 #define HSCDTD008A_H
 
@@ -100,13 +82,13 @@
 class   HSCDTD008A
 {
 public:
-    HSCDTD008A(PinName sda, PinName scl, PinName drdy = NC, uint8_t addr = 0x0C);
+    HSCDTD008A(PinName sda, PinName scl, uint8_t addr = 0x0C);
     int16_t toInt16(uint16_t word);
     void    standbyMode();
     void    normalMode(uint8_t odr = 0b01, bool enableDataReady = false);
     void    forcedMode();
     void    softReset();
-    uint8_t selftest();
+    uint8_t selfTest();
     void    calibrateOffsets();
     void    setDriftOffsetX(uint16_t val);
     void    setDriftOffsetY(uint16_t val);
@@ -125,15 +107,11 @@
     float   x();
     float   y();
     float   z();
-    float   bearing();
 private:
     I2C*            _i2c;
-    InterruptIn     _drdy;
     const uint8_t   _addr;
     uint16_t        _x;
     uint16_t        _y;
     uint16_t        _z;
-    Thread          _thread;
-    EventQueue      _eventQueue;
 };
 #endif // HSCDTD008A_H