TI-RTOS Drivers  tidrivers_full_2_20_00_08
SensorMpu9250.h
Go to the documentation of this file.
1 /*
2  * Copyright (c) 2015-2016, Texas Instruments Incorporated
3  * All rights reserved.
4  *
5  * Redistribution and use in source and binary forms, with or without
6  * modification, are permitted provided that the following conditions
7  * are met:
8  *
9  * * Redistributions of source code must retain the above copyright
10  * notice, this list of conditions and the following disclaimer.
11  *
12  * * Redistributions in binary form must reproduce the above copyright
13  * notice, this list of conditions and the following disclaimer in the
14  * documentation and/or other materials provided with the distribution.
15  *
16  * * Neither the name of Texas Instruments Incorporated nor the names of
17  * its contributors may be used to endorse or promote products derived
18  * from this software without specific prior written permission.
19  *
20  * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
21  * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO,
22  * THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
23  * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR
24  * CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
25  * EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
26  * PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS;
27  * OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY,
28  * WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR
29  * OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE,
30  * EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
31  */
32 
40 #ifndef SENSOR_MPU9250_H
41 #define SENSOR_MPU9250_H
42 
43 #ifdef __cplusplus
44 extern "C" {
45 #endif
46 
47 /* -----------------------------------------------------------------------------
48  * Includes
49  * -----------------------------------------------------------------------------
50  */
51 #include "stdint.h"
52 #include "stdbool.h"
53 
54 /* -----------------------------------------------------------------------------
55  * Constants
56  * -----------------------------------------------------------------------------
57  */
58 // Accelerometer ranges
59 #define ACC_RANGE_2G 0
60 #define ACC_RANGE_4G 1
61 #define ACC_RANGE_8G 2
62 #define ACC_RANGE_16G 3
63 #define ACC_RANGE_INVALID 0xFF
64 
65 // Axis bitmaps
66 #define MPU_AX_GYR 0x07
67 #define MPU_AX_ACC 0x38
68 #define MPU_AX_MAG 0x40
69 #define MPU_AX_ALL 0x7F
70 
71 // Interrupt status bit
72 #define MPU_DATA_READY 0x01
73 #define MPU_MOVEMENT 0x40
74 
75 // Magnetometer status
76 #define MAG_STATUS_OK 0x00
77 #define MAG_READ_ST_ERR 0x01
78 #define MAG_DATA_NOT_RDY 0x02
79 #define MAG_OVERFLOW 0x03
80 #define MAG_READ_DATA_ERR 0x04
81 #define MAG_BYPASS_FAIL 0x05
82 #define MAG_NO_POWER 0x06
83 
84 /* ----------------------------------------------------------------------------
85  * Typedefs
86  * -----------------------------------------------------------------------------
87 */
88 typedef void (*SensorMpu9250CallbackFn_t)(void);
89 
90 /* -----------------------------------------------------------------------------
91  * Functions
92  * -----------------------------------------------------------------------------
93  */
94 bool SensorMpu9250_init(void);
95 bool SensorMpu9250_reset(void);
97 bool SensorMpu9250_test(void);
98 void SensorMpu9250_powerOn(void);
99 void SensorMpu9250_powerOff(void);
100 bool SensorMpu9250_powerIsOn(void);
101 
102 void SensorMpu9250_enable(uint16_t config);
103 bool SensorMpu9250_enableWom(uint8_t threshold);
104 uint8_t SensorMpu9250_irqStatus(void);
105 
106 bool SensorMpu9250_accSetRange(uint8_t range);
107 uint8_t SensorMpu9250_accReadRange(void);
108 bool SensorMpu9250_accRead(uint16_t *rawData);
109 float SensorMpu9250_accConvert(int16_t rawValue);
110 
111 bool SensorMpu9250_gyroRead(uint16_t *rawData);
112 float SensorMpu9250_gyroConvert(int16_t rawValue);
113 
114 bool SensorMpu9250_magTest(void);
115 uint8_t SensorMpu9250_magRead(int16_t *pRawData);
116 uint8_t SensorMpu9250_magStatus(void);
117 void SensorMpu9250_magReset(void);
118 
119 /*******************************************************************************
120 */
121 
122 #ifdef __cplusplus
123 };
124 #endif
125 
126 #endif
bool SensorMpu9250_gyroRead(uint16_t *rawData)
uint8_t SensorMpu9250_magRead(int16_t *pRawData)
void SensorMpu9250_registerCallback(SensorMpu9250CallbackFn_t)
bool SensorMpu9250_accRead(uint16_t *rawData)
bool SensorMpu9250_magTest(void)
bool SensorMpu9250_test(void)
void SensorMpu9250_magReset(void)
void SensorMpu9250_enable(uint16_t config)
uint8_t SensorMpu9250_accReadRange(void)
void(* SensorMpu9250CallbackFn_t)(void)
Definition: SensorMpu9250.h:88
bool SensorMpu9250_accSetRange(uint8_t range)
bool SensorMpu9250_powerIsOn(void)
bool SensorMpu9250_init(void)
void SensorMpu9250_powerOff(void)
void SensorMpu9250_powerOn(void)
float SensorMpu9250_accConvert(int16_t rawValue)
uint8_t SensorMpu9250_magStatus(void)
bool SensorMpu9250_reset(void)
uint8_t SensorMpu9250_irqStatus(void)
bool SensorMpu9250_enableWom(uint8_t threshold)
float SensorMpu9250_gyroConvert(int16_t rawValue)
Copyright 2016, Texas Instruments Incorporated