Copied from STs implementation.

Dependents:   teensyIMU

Committer:
bclaus
Date:
Thu Oct 06 23:28:08 2016 +0000
Revision:
1:898554a35638
Parent:
0:32f3441153b5
functional;

Who changed what in which revision?

UserRevisionLine numberNew contents of line
bclaus 0:32f3441153b5 1 /**
bclaus 0:32f3441153b5 2 ******************************************************************************
bclaus 0:32f3441153b5 3 * @file LIS3MDL.H
bclaus 0:32f3441153b5 4 * @author BCC
bclaus 0:32f3441153b5 5 * @version V0.0.1
bclaus 0:32f3441153b5 6 * @date 6-OCT-2016
bclaus 0:32f3441153b5 7 * @brief Header file for component LIS3MDL
bclaus 0:32f3441153b5 8 ******************************************************************************
bclaus 0:32f3441153b5 9 * @attention
bclaus 0:32f3441153b5 10 *
bclaus 0:32f3441153b5 11 * <h2><center>&copy; COPYRIGHT(c) 2014 STMicroelectronics</center></h2>
bclaus 0:32f3441153b5 12 *
bclaus 0:32f3441153b5 13 * Redistribution and use in source and binary forms, with or without modification,
bclaus 0:32f3441153b5 14 * are permitted provided that the following conditions are met:
bclaus 0:32f3441153b5 15 * 1. Redistributions of source code must retain the above copyright notice,
bclaus 0:32f3441153b5 16 * this list of conditions and the following disclaimer.
bclaus 0:32f3441153b5 17 * 2. Redistributions in binary form must reproduce the above copyright notice,
bclaus 0:32f3441153b5 18 * this list of conditions and the following disclaimer in the documentation
bclaus 0:32f3441153b5 19 * and/or other materials provided with the distribution.
bclaus 0:32f3441153b5 20 * 3. Neither the name of STMicroelectronics nor the names of its contributors
bclaus 0:32f3441153b5 21 * may be used to endorse or promote products derived from this software
bclaus 0:32f3441153b5 22 * without specific prior written permission.
bclaus 0:32f3441153b5 23 *
bclaus 0:32f3441153b5 24 * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
bclaus 0:32f3441153b5 25 * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
bclaus 0:32f3441153b5 26 * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
bclaus 0:32f3441153b5 27 * DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE
bclaus 0:32f3441153b5 28 * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
bclaus 0:32f3441153b5 29 * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR
bclaus 0:32f3441153b5 30 * SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER
bclaus 0:32f3441153b5 31 * CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY,
bclaus 0:32f3441153b5 32 * OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
bclaus 0:32f3441153b5 33 * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
bclaus 0:32f3441153b5 34 *
bclaus 0:32f3441153b5 35 ******************************************************************************
bclaus 0:32f3441153b5 36 *
bclaus 0:32f3441153b5 37 * v0.0.1 - copied from https://github.com/vzaccaria/stm32l053/tree/master/example2/lib/nucleo-sensor-shield/Components/LIS3MDL
bclaus 0:32f3441153b5 38 *
bclaus 0:32f3441153b5 39 */
bclaus 0:32f3441153b5 40
bclaus 0:32f3441153b5 41 #ifndef __LIS3MDL_H
bclaus 0:32f3441153b5 42 #define __LIS3MDL_H
bclaus 0:32f3441153b5 43
bclaus 0:32f3441153b5 44 /* Includes ------------------------------------------------------------------*/
bclaus 0:32f3441153b5 45 #include "mbed.h"
bclaus 0:32f3441153b5 46
bclaus 0:32f3441153b5 47
bclaus 0:32f3441153b5 48 /* Classes -------------------------------------------------------------------*/
bclaus 0:32f3441153b5 49
bclaus 0:32f3441153b5 50 class LIS3MDL
bclaus 0:32f3441153b5 51 {
bclaus 0:32f3441153b5 52 public:
bclaus 0:32f3441153b5 53 /** Constructor
bclaus 0:32f3441153b5 54 * @param
bclaus 0:32f3441153b5 55 */
bclaus 0:32f3441153b5 56 LIS3MDL (PinName sda, PinName scl);
bclaus 1:898554a35638 57 float mx, my, mz;
bclaus 1:898554a35638 58 int16_t mx_raw, my_raw, mz_raw;
bclaus 0:32f3441153b5 59
bclaus 1:898554a35638 60 void readMag();
bclaus 1:898554a35638 61 void GetAxesRaw();
bclaus 0:32f3441153b5 62 void Init();
bclaus 0:32f3441153b5 63 uint8_t ReadID(void);
bclaus 0:32f3441153b5 64 void RebootCmd(void);
bclaus 0:32f3441153b5 65
bclaus 0:32f3441153b5 66 private:
bclaus 0:32f3441153b5 67
bclaus 0:32f3441153b5 68 uint8_t isInitialized(void)
bclaus 0:32f3441153b5 69 {
bclaus 0:32f3441153b5 70 return LIS3MDLInitialized;
bclaus 0:32f3441153b5 71 }
bclaus 0:32f3441153b5 72
bclaus 0:32f3441153b5 73 I2C _i2c;
bclaus 0:32f3441153b5 74 uint8_t LIS3MDLInitialized;
bclaus 0:32f3441153b5 75 };
bclaus 0:32f3441153b5 76
bclaus 0:32f3441153b5 77 #endif
bclaus 0:32f3441153b5 78