1<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
2<html xmlns="http://www.w3.org/1999/xhtml">
3<head>
4<meta http-equiv="Content-Type" content="text/xhtml;charset=UTF-8"/>
5<meta http-equiv="X-UA-Compatible" content="IE=9"/>
6<meta name="generator" content="Doxygen 1.8.13"/>
7<meta name="viewport" content="width=device-width, initial-scale=1"/>
8<title>ISSDK: algorithms/sensorfusion/sources/driver_MMA8652.c Source File</title>
9<link href="tabs.css" rel="stylesheet" type="text/css"/>
10<script type="text/javascript" src="jquery.js"></script>
11<script type="text/javascript" src="dynsections.js"></script>
12<link href="issdk_stylesheet.css" rel="stylesheet" type="text/css" />
13</head>
14<body>
15<div id="top"><!-- do not remove this div, it is closed by doxygen! -->
16<div id="titlearea">
17<table cellspacing="0" cellpadding="0">
18 <tbody>
19 <tr style="height: 56px;">
20  <td id="projectlogo"><img alt="Logo" src="nxp_logo_small.png"/></td>
21  <td id="projectalign" style="padding-left: 0.5em;">
22   <div id="projectname">ISSDK
23   &#160;<span id="projectnumber">1.8</span>
24   </div>
25   <div id="projectbrief">IoT Sensing Software Development Kit</div>
26  </td>
27 </tr>
28 </tbody>
29</table>
30</div>
31<!-- end header part -->
32<!-- Generated by Doxygen 1.8.13 -->
33<script type="text/javascript" src="menudata.js"></script>
34<script type="text/javascript" src="menu.js"></script>
35<script type="text/javascript">
36$(function() {
37  initMenu('',false,false,'search.php','Search');
38});
39</script>
40<div id="main-nav"></div>
41<div id="nav-path" class="navpath">
42  <ul>
43<li class="navelem"><a class="el" href="dir_c0ce462e37efe0a8d60c01d75f78f8a0.html">algorithms</a></li><li class="navelem"><a class="el" href="dir_cb8ed5ffd1f20a5af7e420f81f312621.html">sensorfusion</a></li><li class="navelem"><a class="el" href="dir_c60867674b20e7d761cd401b87ce879d.html">sources</a></li>  </ul>
44</div>
45</div><!-- top -->
46<div class="header">
47  <div class="headertitle">
48<div class="title">driver_MMA8652.c</div>  </div>
49</div><!--header-->
50<div class="contents">
51<a href="a00827.html">Go to the documentation of this file.</a><div class="fragment"><div class="line"><a name="l00001"></a><span class="lineno">    1</span>&#160;<span class="comment">/*</span></div><div class="line"><a name="l00002"></a><span class="lineno">    2</span>&#160;<span class="comment"> * Copyright (c) 2015, Freescale Semiconductor, Inc.</span></div><div class="line"><a name="l00003"></a><span class="lineno">    3</span>&#160;<span class="comment"> * Copyright 2016-2017 NXP</span></div><div class="line"><a name="l00004"></a><span class="lineno">    4</span>&#160;<span class="comment"> * All rights reserved.</span></div><div class="line"><a name="l00005"></a><span class="lineno">    5</span>&#160;<span class="comment"> *</span></div><div class="line"><a name="l00006"></a><span class="lineno">    6</span>&#160;<span class="comment"> * SPDX-License-Identifier: BSD-3-Clause</span></div><div class="line"><a name="l00007"></a><span class="lineno">    7</span>&#160;<span class="comment"> */</span></div><div class="line"><a name="l00008"></a><span class="lineno">    8</span>&#160;<span class="comment"></span></div><div class="line"><a name="l00009"></a><span class="lineno">    9</span>&#160;<span class="comment">/*! \file driver_MMA8652.c</span></div><div class="line"><a name="l00010"></a><span class="lineno">   10</span>&#160;<span class="comment">    \brief Provides init() and read() functions for the MMA8652 3-axis accel family.</span></div><div class="line"><a name="l00011"></a><span class="lineno">   11</span>&#160;<span class="comment"></span></div><div class="line"><a name="l00012"></a><span class="lineno">   12</span>&#160;<span class="comment">1G*/</span></div><div class="line"><a name="l00013"></a><span class="lineno">   13</span>&#160;</div><div class="line"><a name="l00014"></a><span class="lineno">   14</span>&#160;<span class="preprocessor">#include &quot;board.h&quot;</span>                      <span class="comment">// generated by Kinetis Expert.  Long term - merge sensor_board.h into this file</span></div><div class="line"><a name="l00015"></a><span class="lineno">   15</span>&#160;<span class="preprocessor">#include &quot;<a class="code" href="a00914.html">sensor_fusion.h</a>&quot;</span>              <span class="comment">// Sensor fusion structures and types</span></div><div class="line"><a name="l00016"></a><span class="lineno">   16</span>&#160;<span class="preprocessor">#include &quot;<a class="code" href="a00179.html">sensor_drv.h</a>&quot;</span></div><div class="line"><a name="l00017"></a><span class="lineno">   17</span>&#160;<span class="preprocessor">#include &quot;<a class="code" href="a00185.html">sensor_io_i2c.h</a>&quot;</span>              <span class="comment">// Required for registerreadlist_t / registerwritelist_t declarations</span></div><div class="line"><a name="l00018"></a><span class="lineno">   18</span>&#160;<span class="preprocessor">#include &quot;<a class="code" href="a00140.html">mma865x.h</a>&quot;</span></div><div class="line"><a name="l00019"></a><span class="lineno">   19</span>&#160;<span class="preprocessor">#include &quot;<a class="code" href="a00842.html">drivers.h</a>&quot;</span>                    <span class="comment">// Device specific drivers supplied by NXP (can be replaced with user drivers)</span></div><div class="line"><a name="l00020"></a><span class="lineno"><a class="line" href="a00827.html#a5102c19894b1a3264dde9c0687402978">   20</a></span>&#160;<span class="preprocessor">#define MMA8652_COUNTSPERG     8192.0</span></div><div class="line"><a name="l00021"></a><span class="lineno"><a class="line" href="a00827.html#aec02b963dc94a1a6ef8a0fb03abdf295">   21</a></span>&#160;<span class="preprocessor">#define MMA8652_ACCEL_FIFO_SIZE 32</span></div><div class="line"><a name="l00022"></a><span class="lineno">   22</span>&#160;</div><div class="line"><a name="l00023"></a><span class="lineno">   23</span>&#160;<span class="preprocessor">#if F_USING_ACCEL</span></div><div class="line"><a name="l00024"></a><span class="lineno">   24</span>&#160;</div><div class="line"><a name="l00025"></a><span class="lineno">   25</span>&#160;<span class="comment">// Command definition to read the WHO_AM_I value.</span></div><div class="line"><a name="l00026"></a><span class="lineno">   26</span>&#160;<span class="keyword">const</span> <a class="code" href="a03811.html">registerreadlist_t</a>    MMA8652_WHO_AM_I_READ[] =</div><div class="line"><a name="l00027"></a><span class="lineno">   27</span>&#160;{</div><div class="line"><a name="l00028"></a><span class="lineno">   28</span>&#160;    { .<a class="code" href="a03811.html#a5fe82375de174c0511ca301fec78e441">readFrom</a> = <a class="code" href="a00140.html#a3ee4e9f70475f3c684c23241163781abaf81b085731966d679dd38ae64123a94c">MMA865x_WHO_AM_I</a>, .numBytes = 1 }, <a class="code" href="a00179.html#aebb58a1bb3df30b7df4f6f14d0f1a81d">__END_READ_DATA__</a></div><div class="line"><a name="l00029"></a><span class="lineno">   29</span>&#160;};</div><div class="line"><a name="l00030"></a><span class="lineno">   30</span>&#160;</div><div class="line"><a name="l00031"></a><span class="lineno">   31</span>&#160;<span class="comment">// Command definition to read the number of entries in the accel FIFO.</span></div><div class="line"><a name="l00032"></a><span class="lineno">   32</span>&#160;<span class="keyword">const</span> <a class="code" href="a03811.html">registerreadlist_t</a>    MMA8652_F_STATUS_READ[] =</div><div class="line"><a name="l00033"></a><span class="lineno">   33</span>&#160;{</div><div class="line"><a name="l00034"></a><span class="lineno">   34</span>&#160;    { .<a class="code" href="a03811.html#a5fe82375de174c0511ca301fec78e441">readFrom</a> = <a class="code" href="a00140.html#a3ee4e9f70475f3c684c23241163781aba96d2ceb4e9501ebadd172e35f6af8a29">MMA865x_STATUS</a>, .numBytes = 1 }, <a class="code" href="a00179.html#aebb58a1bb3df30b7df4f6f14d0f1a81d">__END_READ_DATA__</a></div><div class="line"><a name="l00035"></a><span class="lineno">   35</span>&#160;};</div><div class="line"><a name="l00036"></a><span class="lineno">   36</span>&#160;</div><div class="line"><a name="l00037"></a><span class="lineno">   37</span>&#160;<span class="comment">// Command definition to read the number of entries in the accel FIFO.</span></div><div class="line"><a name="l00038"></a><span class="lineno">   38</span>&#160;<a class="code" href="a03811.html">registerreadlist_t</a>          MMA8652_DATA_READ[] =</div><div class="line"><a name="l00039"></a><span class="lineno">   39</span>&#160;{</div><div class="line"><a name="l00040"></a><span class="lineno">   40</span>&#160;    { .<a class="code" href="a03811.html#a5fe82375de174c0511ca301fec78e441">readFrom</a> = <a class="code" href="a00140.html#a3ee4e9f70475f3c684c23241163781aba961d9357ec20c1ae3fc6a7c375dc4815">MMA865x_OUT_X_MSB</a>, .numBytes = 6 }, <a class="code" href="a00179.html#aebb58a1bb3df30b7df4f6f14d0f1a81d">__END_READ_DATA__</a></div><div class="line"><a name="l00041"></a><span class="lineno">   41</span>&#160;};</div><div class="line"><a name="l00042"></a><span class="lineno">   42</span>&#160;</div><div class="line"><a name="l00043"></a><span class="lineno">   43</span>&#160;<span class="comment">// Each entry in a RegisterWriteList is composed of: register address, value to write, bit-mask to apply to write (0 enables)</span></div><div class="line"><a name="l00044"></a><span class="lineno">   44</span>&#160;<span class="keyword">const</span> <a class="code" href="a03807.html">registerwritelist_t</a>   MMA8652_Initialization[] =</div><div class="line"><a name="l00045"></a><span class="lineno">   45</span>&#160;{</div><div class="line"><a name="l00046"></a><span class="lineno">   46</span>&#160;    <span class="comment">// write 0000 0000 = 0x00 to CTRL_REG1 to place MMA8652 into standby</span></div><div class="line"><a name="l00047"></a><span class="lineno">   47</span>&#160;    <span class="comment">// [7-1] = 0000 000</span></div><div class="line"><a name="l00048"></a><span class="lineno">   48</span>&#160;    <span class="comment">// [0]: active=0</span></div><div class="line"><a name="l00049"></a><span class="lineno">   49</span>&#160;    { <a class="code" href="a00140.html#a3ee4e9f70475f3c684c23241163781aba8e8c5a7a258169848329a0efc7f7624f">MMA865x_CTRL_REG1</a>, 0x00, 0x00 },</div><div class="line"><a name="l00050"></a><span class="lineno">   50</span>&#160;</div><div class="line"><a name="l00051"></a><span class="lineno">   51</span>&#160;    <span class="comment">// write 0000 0000 = 0x00 to CTRL_REG1 to place MMA8652 into standby</span></div><div class="line"><a name="l00052"></a><span class="lineno">   52</span>&#160;    <span class="comment">// [7-1] = 0000 000</span></div><div class="line"><a name="l00053"></a><span class="lineno">   53</span>&#160;    <span class="comment">// [0]: active=0</span></div><div class="line"><a name="l00054"></a><span class="lineno">   54</span>&#160;    { <a class="code" href="a00140.html#a3ee4e9f70475f3c684c23241163781aba67770cf051b084bf5d7eac3724b28249">MMA865x_F_SETUP</a>, 0x40, 0x00 },</div><div class="line"><a name="l00055"></a><span class="lineno">   55</span>&#160;</div><div class="line"><a name="l00056"></a><span class="lineno">   56</span>&#160;    <span class="comment">// OK: write 0000 0001 = 0x01 to XYZ_DATA_CFG register to set g range</span></div><div class="line"><a name="l00057"></a><span class="lineno">   57</span>&#160;    <span class="comment">// [7-5]: reserved=000</span></div><div class="line"><a name="l00058"></a><span class="lineno">   58</span>&#160;    <span class="comment">// [4]: HPF_OUT=0</span></div><div class="line"><a name="l00059"></a><span class="lineno">   59</span>&#160;    <span class="comment">// [3-2]: reserved=00</span></div><div class="line"><a name="l00060"></a><span class="lineno">   60</span>&#160;    <span class="comment">// [1-0]: FS=01 for +/-4g: 512 counts / g = 8192 counts / g after 4 bit left shift</span></div><div class="line"><a name="l00061"></a><span class="lineno">   61</span>&#160;    { <a class="code" href="a00140.html#a3ee4e9f70475f3c684c23241163781abae6d7316e12f2946651c85717ada82c4a">MMA865x_XYZ_DATA_CFG</a>, 0x01, 0x00 },</div><div class="line"><a name="l00062"></a><span class="lineno">   62</span>&#160;</div><div class="line"><a name="l00063"></a><span class="lineno">   63</span>&#160;    <span class="comment">// OK: write 0000 0010 = 0x02 to CTRL_REG2 to set MODS bits</span></div><div class="line"><a name="l00064"></a><span class="lineno">   64</span>&#160;    <span class="comment">// [7]: ST=0: self test disabled</span></div><div class="line"><a name="l00065"></a><span class="lineno">   65</span>&#160;    <span class="comment">// [6]: RST=0: reset disabled</span></div><div class="line"><a name="l00066"></a><span class="lineno">   66</span>&#160;    <span class="comment">// [5]: unused</span></div><div class="line"><a name="l00067"></a><span class="lineno">   67</span>&#160;    <span class="comment">// [4-3]: SMODS=00</span></div><div class="line"><a name="l00068"></a><span class="lineno">   68</span>&#160;    <span class="comment">// [2]: SLPE=0: auto sleep disabled</span></div><div class="line"><a name="l00069"></a><span class="lineno">   69</span>&#160;    <span class="comment">// [1-0]: mods=10 for high resolution (maximum over sampling)</span></div><div class="line"><a name="l00070"></a><span class="lineno">   70</span>&#160;    { <a class="code" href="a00140.html#a3ee4e9f70475f3c684c23241163781abaa946eeab2a594d2126b1f25295a5fabf">MMA865x_CTRL_REG2</a>, 0x02, 0x00 },</div><div class="line"><a name="l00071"></a><span class="lineno">   71</span>&#160;</div><div class="line"><a name="l00072"></a><span class="lineno">   72</span>&#160;    <span class="comment">// write 00XX X001 to CTRL_REG1 to set data rate and exit standby</span></div><div class="line"><a name="l00073"></a><span class="lineno">   73</span>&#160;    <span class="comment">// [7-6]: aslp_rate=00</span></div><div class="line"><a name="l00074"></a><span class="lineno">   74</span>&#160;    <span class="comment">// [5-3]: dr=111 for 1.56Hz data rate giving 0x39</span></div><div class="line"><a name="l00075"></a><span class="lineno">   75</span>&#160;    <span class="comment">// [5-3]: dr=110 for 6.25Hz data rate giving 0x31</span></div><div class="line"><a name="l00076"></a><span class="lineno">   76</span>&#160;    <span class="comment">// [5-3]: dr=101 for 12.5Hz data rate giving 0x29</span></div><div class="line"><a name="l00077"></a><span class="lineno">   77</span>&#160;    <span class="comment">// [5-3]: dr=100 for 50Hz data rate giving 0x21</span></div><div class="line"><a name="l00078"></a><span class="lineno">   78</span>&#160;    <span class="comment">// [5-3]: dr=011 for 100Hz data rate giving 0x19</span></div><div class="line"><a name="l00079"></a><span class="lineno">   79</span>&#160;    <span class="comment">// [5-3]: dr=010 for 200Hz data rate giving 0x11</span></div><div class="line"><a name="l00080"></a><span class="lineno">   80</span>&#160;    <span class="comment">// [5-3]: dr=001 for 400Hz data rate giving 0x09</span></div><div class="line"><a name="l00081"></a><span class="lineno">   81</span>&#160;    <span class="comment">// [5-3]: dr=000 for 800Hz data rate giving 0x01</span></div><div class="line"><a name="l00082"></a><span class="lineno">   82</span>&#160;    <span class="comment">// [2]: unused=0</span></div><div class="line"><a name="l00083"></a><span class="lineno">   83</span>&#160;    <span class="comment">// [1]: f_read=0 for normal 16 bit reads</span></div><div class="line"><a name="l00084"></a><span class="lineno">   84</span>&#160;    <span class="comment">// [0]: active=1 to take the part out of standby and enable sampling</span></div><div class="line"><a name="l00085"></a><span class="lineno">   85</span>&#160;<span class="preprocessor">#if (ACCEL_ODR_HZ &lt;= 1)</span></div><div class="line"><a name="l00086"></a><span class="lineno">   86</span>&#160;    { <a class="code" href="a00140.html#a3ee4e9f70475f3c684c23241163781aba8e8c5a7a258169848329a0efc7f7624f">MMA865x_CTRL_REG1</a>, 0x39, 0x00 }, <span class="comment">// select 1.5625Hz ODR,</span></div><div class="line"><a name="l00087"></a><span class="lineno">   87</span>&#160;<span class="preprocessor">#elif (ACCEL_ODR_HZ &lt;= 6)</span></div><div class="line"><a name="l00088"></a><span class="lineno">   88</span>&#160;    { <a class="code" href="a00140.html#a3ee4e9f70475f3c684c23241163781aba8e8c5a7a258169848329a0efc7f7624f">MMA865x_CTRL_REG1</a>, 0x31, 0x00 }, <span class="comment">// select 6.25Hz ODR</span></div><div class="line"><a name="l00089"></a><span class="lineno">   89</span>&#160;<span class="preprocessor">#elif (ACCEL_ODR_HZ &lt;= 12)</span></div><div class="line"><a name="l00090"></a><span class="lineno">   90</span>&#160;    { <a class="code" href="a00140.html#a3ee4e9f70475f3c684c23241163781aba8e8c5a7a258169848329a0efc7f7624f">MMA865x_CTRL_REG1</a>, 0x29, 0x00 }, <span class="comment">// select 12.5Hz ODR</span></div><div class="line"><a name="l00091"></a><span class="lineno">   91</span>&#160;<span class="preprocessor">#elif (ACCEL_ODR_HZ &lt;= 50)</span></div><div class="line"><a name="l00092"></a><span class="lineno">   92</span>&#160;    { <a class="code" href="a00140.html#a3ee4e9f70475f3c684c23241163781aba8e8c5a7a258169848329a0efc7f7624f">MMA865x_CTRL_REG1</a>, 0x21, 0x00 }, <span class="comment">// select 50Hz ODR</span></div><div class="line"><a name="l00093"></a><span class="lineno">   93</span>&#160;<span class="preprocessor">#elif (ACCEL_ODR_HZ &lt;= 100)</span></div><div class="line"><a name="l00094"></a><span class="lineno">   94</span>&#160;    { <a class="code" href="a00140.html#a3ee4e9f70475f3c684c23241163781aba8e8c5a7a258169848329a0efc7f7624f">MMA865x_CTRL_REG1</a>, 0x19, 0x00 }, <span class="comment">// select 100Hz ODR</span></div><div class="line"><a name="l00095"></a><span class="lineno">   95</span>&#160;<span class="preprocessor">#elif (ACCEL_ODR_HZ &lt;= 200)</span></div><div class="line"><a name="l00096"></a><span class="lineno">   96</span>&#160;    { <a class="code" href="a00140.html#a3ee4e9f70475f3c684c23241163781aba8e8c5a7a258169848329a0efc7f7624f">MMA865x_CTRL_REG1</a>, 0x11, 0x00 }, <span class="comment">// select 200Hz ODR</span></div><div class="line"><a name="l00097"></a><span class="lineno">   97</span>&#160;<span class="preprocessor">#elif (ACCEL_ODR_HZ &lt;= 400)</span></div><div class="line"><a name="l00098"></a><span class="lineno">   98</span>&#160;    { <a class="code" href="a00140.html#a3ee4e9f70475f3c684c23241163781aba8e8c5a7a258169848329a0efc7f7624f">MMA865x_CTRL_REG1</a>, 0x09, 0x00 }, <span class="comment">// select 400Hz ODR</span></div><div class="line"><a name="l00099"></a><span class="lineno">   99</span>&#160;<span class="preprocessor">#else</span></div><div class="line"><a name="l00100"></a><span class="lineno">  100</span>&#160;    { <a class="code" href="a00140.html#a3ee4e9f70475f3c684c23241163781aba8e8c5a7a258169848329a0efc7f7624f">MMA865x_CTRL_REG1</a>, 0x01, 0x00 }, <span class="comment">// select 800Hz ODR</span></div><div class="line"><a name="l00101"></a><span class="lineno">  101</span>&#160;<span class="preprocessor">#endif</span></div><div class="line"><a name="l00102"></a><span class="lineno">  102</span>&#160;    <a class="code" href="a00179.html#a2cedde333a6373a3ee274bde6af145d0">__END_WRITE_DATA__</a></div><div class="line"><a name="l00103"></a><span class="lineno">  103</span>&#160;};</div><div class="line"><a name="l00104"></a><span class="lineno">  104</span>&#160;</div><div class="line"><a name="l00105"></a><span class="lineno">  105</span>&#160;<span class="comment">// All sensor drivers and initialization functions have the same prototype.</span></div><div class="line"><a name="l00106"></a><span class="lineno">  106</span>&#160;<span class="comment">// sfg is a pointer to the master &quot;global&quot; sensor fusion structure.</span></div><div class="line"><a name="l00107"></a><span class="lineno">  107</span>&#160;<span class="comment">// sensor = pointer to linked list element used by the sensor fusion subsystem to specify required sensors</span></div><div class="line"><a name="l00108"></a><span class="lineno">  108</span>&#160;</div><div class="line"><a name="l00109"></a><span class="lineno">  109</span>&#160;<span class="comment">// sfg = pointer to top level (generally global) data structure for sensor fusion</span></div><div class="line"><a name="l00110"></a><span class="lineno">  110</span>&#160;int8_t <a class="code" href="a00842.html#a9df61be7e9e0b946a28705f09bb319c0">MMA8652_Init</a>(<span class="keyword">struct</span> <a class="code" href="a03991.html">PhysicalSensor</a> *sensor, <a class="code" href="a04047.html">SensorFusionGlobals</a> *<a class="code" href="a00470.html#afa81c629d378fe700f351a1bce411ad5">sfg</a>)</div><div class="line"><a name="l00111"></a><span class="lineno">  111</span>&#160;{</div><div class="line"><a name="l00112"></a><span class="lineno">  112</span>&#160;    <a class="code" href="a00521.html#a5d7069350a7d7e65686c77a8038f462f">int32_t</a> <a class="code" href="a00359.html#a369536ebfe385731562c0b55dd6f3a7c">status</a>;</div><div class="line"><a name="l00113"></a><span class="lineno">  113</span>&#160;    uint8_t reg;</div><div class="line"><a name="l00114"></a><span class="lineno">  114</span>&#160;    status = <a class="code" href="a00167.html#ac8a60c799d9dbc84531b4680762eb8dc">Register_I2C_Read</a>(sensor-&gt;<a class="code" href="a03991.html#aa7b3c47e2be4d604bc40157d590d09b2">bus_driver</a>, &amp;sensor-&gt;<a class="code" href="a03991.html#ae75b47fd9e098d6bd3b28f6be6586998">deviceInfo</a>, sensor-&gt;<a class="code" href="a03991.html#a41a6aad09727eb120338c35535a652a6">addr</a>, <a class="code" href="a00140.html#a3ee4e9f70475f3c684c23241163781abaf81b085731966d679dd38ae64123a94c">MMA865x_WHO_AM_I</a>, 1, &amp;reg);</div><div class="line"><a name="l00115"></a><span class="lineno">  115</span>&#160;    <span class="keywordflow">if</span> (status==<a class="code" href="a00179.html#a18a00cbfd8ad83c7fd229cd0d5fad5aca961b6871536a27c9e4718100e0024274">SENSOR_ERROR_NONE</a>) {</div><div class="line"><a name="l00116"></a><span class="lineno">  116</span>&#160;        sfg-&gt;Accel.iWhoAmI = reg;</div><div class="line"><a name="l00117"></a><span class="lineno">  117</span>&#160;        <span class="keywordflow">if</span> (reg != <a class="code" href="a00140.html#a073411344592aee73bcd637972375e00">MMA8652_WHOAMI_VALUE</a>) <span class="keywordflow">return</span>(<a class="code" href="a00179.html#a18a00cbfd8ad83c7fd229cd0d5fad5aca7f5031b1497c3a8a4bcb78cce879dedd">SENSOR_ERROR_INIT</a>);</div><div class="line"><a name="l00118"></a><span class="lineno">  118</span>&#160;    } <span class="keywordflow">else</span> {</div><div class="line"><a name="l00119"></a><span class="lineno">  119</span>&#160;        <span class="keywordflow">return</span>(status);</div><div class="line"><a name="l00120"></a><span class="lineno">  120</span>&#160;    }</div><div class="line"><a name="l00121"></a><span class="lineno">  121</span>&#160;</div><div class="line"><a name="l00122"></a><span class="lineno">  122</span>&#160;    status = <a class="code" href="a00182.html#aaac4c4f34b4dd37d3f202a1dbb4b000b">Sensor_I2C_Write</a>(sensor-&gt;<a class="code" href="a03991.html#aa7b3c47e2be4d604bc40157d590d09b2">bus_driver</a>, &amp;sensor-&gt;<a class="code" href="a03991.html#ae75b47fd9e098d6bd3b28f6be6586998">deviceInfo</a>, sensor-&gt;<a class="code" href="a03991.html#a41a6aad09727eb120338c35535a652a6">addr</a>, MMA8652_Initialization );</div><div class="line"><a name="l00123"></a><span class="lineno">  123</span>&#160;    <span class="comment">// Stash some needed constants in the SF data structure for this sensor</span></div><div class="line"><a name="l00124"></a><span class="lineno">  124</span>&#160;    sfg-&gt;Accel.iCountsPerg = <a class="code" href="a00827.html#a5102c19894b1a3264dde9c0687402978">MMA8652_COUNTSPERG</a>;</div><div class="line"><a name="l00125"></a><span class="lineno">  125</span>&#160;    sfg-&gt;Accel.fgPerCount = 1.0F / <a class="code" href="a00827.html#a5102c19894b1a3264dde9c0687402978">MMA8652_COUNTSPERG</a>;</div><div class="line"><a name="l00126"></a><span class="lineno">  126</span>&#160;    sfg-&gt;Accel.fgPerCount = 1.0F / <a class="code" href="a00827.html#a5102c19894b1a3264dde9c0687402978">MMA8652_COUNTSPERG</a>;</div><div class="line"><a name="l00127"></a><span class="lineno">  127</span>&#160;</div><div class="line"><a name="l00128"></a><span class="lineno">  128</span>&#160;    sensor-&gt;<a class="code" href="a03991.html#a87223885ad859bb82fdc45644bc1f0b2">isInitialized</a> = <a class="code" href="a00917.html#a8f284d04ec459633d30dc85cf0a32a0d">F_USING_ACCEL</a>;</div><div class="line"><a name="l00129"></a><span class="lineno">  129</span>&#160;    sfg-&gt;Accel.isEnabled = <span class="keyword">true</span>;</div><div class="line"><a name="l00130"></a><span class="lineno">  130</span>&#160;</div><div class="line"><a name="l00131"></a><span class="lineno">  131</span>&#160;    <span class="keywordflow">return</span> (status);</div><div class="line"><a name="l00132"></a><span class="lineno">  132</span>&#160;}</div><div class="line"><a name="l00133"></a><span class="lineno">  133</span>&#160;</div><div class="line"><a name="l00134"></a><span class="lineno">  134</span>&#160;int8_t <a class="code" href="a00842.html#a7f301dd1df3c367b45aa8e85d9872521">MMA8652_Read</a>(<span class="keyword">struct</span> <a class="code" href="a03991.html">PhysicalSensor</a> *sensor, <a class="code" href="a04047.html">SensorFusionGlobals</a> *sfg)</div><div class="line"><a name="l00135"></a><span class="lineno">  135</span>&#160;{</div><div class="line"><a name="l00136"></a><span class="lineno">  136</span>&#160;    uint8_t                     I2C_Buffer[6 * <a class="code" href="a00827.html#aec02b963dc94a1a6ef8a0fb03abdf295">MMA8652_ACCEL_FIFO_SIZE</a>];    <span class="comment">// I2C read buffer</span></div><div class="line"><a name="l00137"></a><span class="lineno">  137</span>&#160;    int8_t                      <a class="code" href="a00359.html#a369536ebfe385731562c0b55dd6f3a7c">status</a>;         <span class="comment">// I2C transaction status</span></div><div class="line"><a name="l00138"></a><span class="lineno">  138</span>&#160;    int8_t                      j;              <span class="comment">// scratch</span></div><div class="line"><a name="l00139"></a><span class="lineno">  139</span>&#160;    uint8_t                     sensor_fifo_count = 1;</div><div class="line"><a name="l00140"></a><span class="lineno">  140</span>&#160;    int16_t                     sample[3];</div><div class="line"><a name="l00141"></a><span class="lineno">  141</span>&#160;</div><div class="line"><a name="l00142"></a><span class="lineno">  142</span>&#160;    <span class="keywordflow">if</span>(sensor-&gt;<a class="code" href="a03991.html#a87223885ad859bb82fdc45644bc1f0b2">isInitialized</a> != <a class="code" href="a00917.html#a8f284d04ec459633d30dc85cf0a32a0d">F_USING_ACCEL</a>)</div><div class="line"><a name="l00143"></a><span class="lineno">  143</span>&#160;    {</div><div class="line"><a name="l00144"></a><span class="lineno">  144</span>&#160;        <span class="keywordflow">return</span> <a class="code" href="a00179.html#a18a00cbfd8ad83c7fd229cd0d5fad5aca7f5031b1497c3a8a4bcb78cce879dedd">SENSOR_ERROR_INIT</a>;</div><div class="line"><a name="l00145"></a><span class="lineno">  145</span>&#160;    }</div><div class="line"><a name="l00146"></a><span class="lineno">  146</span>&#160;</div><div class="line"><a name="l00147"></a><span class="lineno">  147</span>&#160;    <span class="comment">// read the F_STATUS register (mapped to STATUS) and extract number of measurements available (lower 6 bits)</span></div><div class="line"><a name="l00148"></a><span class="lineno">  148</span>&#160;    status =  <a class="code" href="a00182.html#aa75349faed7c77807cb88d9224aa2636">Sensor_I2C_Read</a>(sensor-&gt;<a class="code" href="a03991.html#aa7b3c47e2be4d604bc40157d590d09b2">bus_driver</a>, &amp;sensor-&gt;<a class="code" href="a03991.html#ae75b47fd9e098d6bd3b28f6be6586998">deviceInfo</a>, sensor-&gt;<a class="code" href="a03991.html#a41a6aad09727eb120338c35535a652a6">addr</a>, MMA8652_F_STATUS_READ, I2C_Buffer );</div><div class="line"><a name="l00149"></a><span class="lineno">  149</span>&#160;    <span class="keywordflow">if</span> (status==<a class="code" href="a00179.html#a18a00cbfd8ad83c7fd229cd0d5fad5aca961b6871536a27c9e4718100e0024274">SENSOR_ERROR_NONE</a>) {</div><div class="line"><a name="l00150"></a><span class="lineno">  150</span>&#160;        sensor_fifo_count = I2C_Buffer[0] &amp; 0x3F;</div><div class="line"><a name="l00151"></a><span class="lineno">  151</span>&#160;        <span class="comment">// return if there are no measurements in the sensor FIFO.</span></div><div class="line"><a name="l00152"></a><span class="lineno">  152</span>&#160;        <span class="comment">// this will only occur when the FAST_LOOP_HZ equals or exceeds ACCEL_ODR_HZ</span></div><div class="line"><a name="l00153"></a><span class="lineno">  153</span>&#160;        <span class="keywordflow">if</span>  (sensor_fifo_count == 0) <span class="keywordflow">return</span> <a class="code" href="a00179.html#a18a00cbfd8ad83c7fd229cd0d5fad5acab93ad77156e08d1bebe52bf46936cccc">SENSOR_ERROR_READ</a>;</div><div class="line"><a name="l00154"></a><span class="lineno">  154</span>&#160;    } <span class="keywordflow">else</span> {</div><div class="line"><a name="l00155"></a><span class="lineno">  155</span>&#160;        <span class="keywordflow">return</span>(status);</div><div class="line"><a name="l00156"></a><span class="lineno">  156</span>&#160;    }</div><div class="line"><a name="l00157"></a><span class="lineno">  157</span>&#160;</div><div class="line"><a name="l00158"></a><span class="lineno">  158</span>&#160;    MMA8652_DATA_READ[0].<a class="code" href="a03811.html#a5fe82375de174c0511ca301fec78e441">readFrom</a> = <a class="code" href="a00140.html#a3ee4e9f70475f3c684c23241163781aba961d9357ec20c1ae3fc6a7c375dc4815">MMA865x_OUT_X_MSB</a>;</div><div class="line"><a name="l00159"></a><span class="lineno">  159</span>&#160;    MMA8652_DATA_READ[0].<a class="code" href="a03811.html#a1440a8efa2f56cded09ced3ff687d32a">numBytes</a> = 6 * sensor_fifo_count;</div><div class="line"><a name="l00160"></a><span class="lineno">  160</span>&#160;    status =  <a class="code" href="a00182.html#aa75349faed7c77807cb88d9224aa2636">Sensor_I2C_Read</a>(sensor-&gt;<a class="code" href="a03991.html#aa7b3c47e2be4d604bc40157d590d09b2">bus_driver</a>, &amp;sensor-&gt;<a class="code" href="a03991.html#ae75b47fd9e098d6bd3b28f6be6586998">deviceInfo</a>, sensor-&gt;<a class="code" href="a03991.html#a41a6aad09727eb120338c35535a652a6">addr</a>, MMA8652_DATA_READ, I2C_Buffer );</div><div class="line"><a name="l00161"></a><span class="lineno">  161</span>&#160;</div><div class="line"><a name="l00162"></a><span class="lineno">  162</span>&#160;    <span class="keywordflow">if</span> (status==<a class="code" href="a00179.html#a18a00cbfd8ad83c7fd229cd0d5fad5aca961b6871536a27c9e4718100e0024274">SENSOR_ERROR_NONE</a>) {</div><div class="line"><a name="l00163"></a><span class="lineno">  163</span>&#160;        <span class="keywordflow">for</span> (j = 0; j &lt; sensor_fifo_count; j++)</div><div class="line"><a name="l00164"></a><span class="lineno">  164</span>&#160;        {</div><div class="line"><a name="l00165"></a><span class="lineno">  165</span>&#160;            sample[<a class="code" href="a00914.html#a48bbd27e913de8d7749dff9dec2fe816">CHX</a>] = (I2C_Buffer[6 * j    ] &lt;&lt; 8) | I2C_Buffer[6 * j + 1];</div><div class="line"><a name="l00166"></a><span class="lineno">  166</span>&#160;            sample[<a class="code" href="a00914.html#a6a25024f52cc6bea13d19f8b68456cea">CHY</a>] = (I2C_Buffer[6 * j + 2] &lt;&lt; 8) | I2C_Buffer[6 * j + 3];</div><div class="line"><a name="l00167"></a><span class="lineno">  167</span>&#160;            sample[<a class="code" href="a00914.html#a76143891435bdd7248857e45b93521ed">CHZ</a>] = (I2C_Buffer[6 * j + 4] &lt;&lt; 8) | I2C_Buffer[6 * j + 5];</div><div class="line"><a name="l00168"></a><span class="lineno">  168</span>&#160;            <a class="code" href="a00911.html#a2686eeb8ae44e588362478db1f757a0e">conditionSample</a>(sample);  <span class="comment">// truncate negative values to -32767</span></div><div class="line"><a name="l00169"></a><span class="lineno">  169</span>&#160;            <a class="code" href="a00911.html#ae7d2343e9a63bd3879ae477ec4536f6a">addToFifo</a>((<span class="keyword">union</span> <a class="code" href="a04011.html">FifoSensor</a>*) &amp;(sfg-&gt;Accel), <a class="code" href="a00917.html#a4c185218ef46ba2991d62b28e1620539">ACCEL_FIFO_SIZE</a>, sample);</div><div class="line"><a name="l00170"></a><span class="lineno">  170</span>&#160;        }</div><div class="line"><a name="l00171"></a><span class="lineno">  171</span>&#160;    }</div><div class="line"><a name="l00172"></a><span class="lineno">  172</span>&#160;</div><div class="line"><a name="l00173"></a><span class="lineno">  173</span>&#160;    <span class="keywordflow">return</span> (status);</div><div class="line"><a name="l00174"></a><span class="lineno">  174</span>&#160;}</div><div class="line"><a name="l00175"></a><span class="lineno">  175</span>&#160;</div><div class="line"><a name="l00176"></a><span class="lineno">  176</span>&#160;</div><div class="line"><a name="l00177"></a><span class="lineno">  177</span>&#160;<span class="comment">// Each entry in a RegisterWriteList is composed of: register address, value to write, bit-mask to apply to write (0 enables)</span></div><div class="line"><a name="l00178"></a><span class="lineno">  178</span>&#160;<span class="keyword">const</span> <a class="code" href="a03807.html">registerwritelist_t</a>   MMA8652_IDLE[] =</div><div class="line"><a name="l00179"></a><span class="lineno">  179</span>&#160;{</div><div class="line"><a name="l00180"></a><span class="lineno">  180</span>&#160;  <span class="comment">// Set ACTIVE = other bits unchanged</span></div><div class="line"><a name="l00181"></a><span class="lineno">  181</span>&#160;  { <a class="code" href="a00140.html#a3ee4e9f70475f3c684c23241163781aba8e8c5a7a258169848329a0efc7f7624f">MMA865x_CTRL_REG1</a>, 0x00, 0x01 },</div><div class="line"><a name="l00182"></a><span class="lineno">  182</span>&#160;    <a class="code" href="a00179.html#a2cedde333a6373a3ee274bde6af145d0">__END_WRITE_DATA__</a></div><div class="line"><a name="l00183"></a><span class="lineno">  183</span>&#160;};</div><div class="line"><a name="l00184"></a><span class="lineno">  184</span>&#160;</div><div class="line"><a name="l00185"></a><span class="lineno">  185</span>&#160;<span class="comment">// MMA8652_Idle places the sensor into SLEEP mode (wakeup time = 2/ODR+1ms)</span></div><div class="line"><a name="l00186"></a><span class="lineno">  186</span>&#160;int8_t <a class="code" href="a00842.html#a546ddd32be5ab1f1d259a1217eb4ca4d">MMA8652_Idle</a>(<span class="keyword">struct</span> <a class="code" href="a03991.html">PhysicalSensor</a> *sensor, <a class="code" href="a04047.html">SensorFusionGlobals</a> *sfg)</div><div class="line"><a name="l00187"></a><span class="lineno">  187</span>&#160;{</div><div class="line"><a name="l00188"></a><span class="lineno">  188</span>&#160;    <a class="code" href="a00521.html#a5d7069350a7d7e65686c77a8038f462f">int32_t</a>     <a class="code" href="a00359.html#a369536ebfe385731562c0b55dd6f3a7c">status</a>;</div><div class="line"><a name="l00189"></a><span class="lineno">  189</span>&#160;    <span class="keywordflow">if</span>(sensor-&gt;<a class="code" href="a03991.html#a87223885ad859bb82fdc45644bc1f0b2">isInitialized</a> == <a class="code" href="a00917.html#a8f284d04ec459633d30dc85cf0a32a0d">F_USING_ACCEL</a>) {</div><div class="line"><a name="l00190"></a><span class="lineno">  190</span>&#160;        status = <a class="code" href="a00182.html#aaac4c4f34b4dd37d3f202a1dbb4b000b">Sensor_I2C_Write</a>(sensor-&gt;<a class="code" href="a03991.html#aa7b3c47e2be4d604bc40157d590d09b2">bus_driver</a>, &amp;sensor-&gt;<a class="code" href="a03991.html#ae75b47fd9e098d6bd3b28f6be6586998">deviceInfo</a>, sensor-&gt;<a class="code" href="a03991.html#a41a6aad09727eb120338c35535a652a6">addr</a>, MMA8652_IDLE );</div><div class="line"><a name="l00191"></a><span class="lineno">  191</span>&#160;        sensor-&gt;<a class="code" href="a03991.html#a87223885ad859bb82fdc45644bc1f0b2">isInitialized</a> = 0;</div><div class="line"><a name="l00192"></a><span class="lineno">  192</span>&#160;        sfg-&gt;Accel.isEnabled = <span class="keyword">false</span>;</div><div class="line"><a name="l00193"></a><span class="lineno">  193</span>&#160;    } <span class="keywordflow">else</span> {</div><div class="line"><a name="l00194"></a><span class="lineno">  194</span>&#160;      <span class="keywordflow">return</span> <a class="code" href="a00179.html#a18a00cbfd8ad83c7fd229cd0d5fad5aca7f5031b1497c3a8a4bcb78cce879dedd">SENSOR_ERROR_INIT</a>;</div><div class="line"><a name="l00195"></a><span class="lineno">  195</span>&#160;    }</div><div class="line"><a name="l00196"></a><span class="lineno">  196</span>&#160;    <span class="keywordflow">return</span> <a class="code" href="a00359.html#a369536ebfe385731562c0b55dd6f3a7c">status</a>;</div><div class="line"><a name="l00197"></a><span class="lineno">  197</span>&#160;}</div><div class="line"><a name="l00198"></a><span class="lineno">  198</span>&#160;</div><div class="line"><a name="l00199"></a><span class="lineno">  199</span>&#160;<span class="preprocessor">#endif  // F_USING_ACCEL</span></div><div class="ttc" id="a00140_html_a3ee4e9f70475f3c684c23241163781abaa946eeab2a594d2126b1f25295a5fabf"><div class="ttname"><a href="a00140.html#a3ee4e9f70475f3c684c23241163781abaa946eeab2a594d2126b1f25295a5fabf">MMA865x_CTRL_REG2</a></div><div class="ttdef"><b>Definition:</b> <a href="a00140_source.html#l00054">mma865x.h:54</a></div></div>
52<div class="ttc" id="a00182_html_aa75349faed7c77807cb88d9224aa2636"><div class="ttname"><a href="a00182.html#aa75349faed7c77807cb88d9224aa2636">Sensor_I2C_Read</a></div><div class="ttdeci">int32_t Sensor_I2C_Read(ARM_DRIVER_I2C *pCommDrv, registerDeviceInfo_t *devInfo, uint16_t slaveAddress, const registerreadlist_t *pReadList, uint8_t *pOutBuffer)</div><div class="ttdoc">Read register data from a sensor. </div><div class="ttdef"><b>Definition:</b> <a href="a00182_source.html#l00105">sensor_io_i2c.c:105</a></div></div>
53<div class="ttc" id="a03991_html_aa7b3c47e2be4d604bc40157d590d09b2"><div class="ttname"><a href="a03991.html#aa7b3c47e2be4d604bc40157d590d09b2">PhysicalSensor::bus_driver</a></div><div class="ttdeci">void * bus_driver</div><div class="ttdoc">should be of type (ARM_DRIVER_I2C* for I2C-based sensors, ARM_DRIVER_SPI* for SPI) ...</div><div class="ttdef"><b>Definition:</b> <a href="a00914_source.html#l00157">sensor_fusion.h:157</a></div></div>
54<div class="ttc" id="a03807_html"><div class="ttname"><a href="a03807.html">registerwritelist_t</a></div><div class="ttdoc">This structure defines the Write command List. </div><div class="ttdef"><b>Definition:</b> <a href="a00179_source.html#l00068">sensor_drv.h:68</a></div></div>
55<div class="ttc" id="a00359_html_a369536ebfe385731562c0b55dd6f3a7c"><div class="ttname"><a href="a00359.html#a369536ebfe385731562c0b55dd6f3a7c">status</a></div><div class="ttdeci">int32_t status</div><div class="ttdef"><b>Definition:</b> <a href="a00359_source.html#l00248">fxls896xaf_freemaster_demo.c:248</a></div></div>
56<div class="ttc" id="a00917_html_a8f284d04ec459633d30dc85cf0a32a0d"><div class="ttname"><a href="a00917.html#a8f284d04ec459633d30dc85cf0a32a0d">F_USING_ACCEL</a></div><div class="ttdeci">#define F_USING_ACCEL</div><div class="ttdoc">nominally 0x0001 if an accelerometer is to be used, 0x0000 otherwise </div><div class="ttdef"><b>Definition:</b> <a href="a00917_source.html#l00038">standard_build.h:38</a></div></div>
57<div class="ttc" id="a00179_html_a18a00cbfd8ad83c7fd229cd0d5fad5aca961b6871536a27c9e4718100e0024274"><div class="ttname"><a href="a00179.html#a18a00cbfd8ad83c7fd229cd0d5fad5aca961b6871536a27c9e4718100e0024274">SENSOR_ERROR_NONE</a></div><div class="ttdef"><b>Definition:</b> <a href="a00179_source.html#l00033">sensor_drv.h:33</a></div></div>
58<div class="ttc" id="a00842_html_a546ddd32be5ab1f1d259a1217eb4ca4d"><div class="ttname"><a href="a00842.html#a546ddd32be5ab1f1d259a1217eb4ca4d">MMA8652_Idle</a></div><div class="ttdeci">int8_t MMA8652_Idle(struct PhysicalSensor *sensor, SensorFusionGlobals *sfg)</div></div>
59<div class="ttc" id="a00842_html"><div class="ttname"><a href="a00842.html">drivers.h</a></div><div class="ttdoc">Provides function prototypes for driver level interfaces. </div></div>
60<div class="ttc" id="a00167_html_ac8a60c799d9dbc84531b4680762eb8dc"><div class="ttname"><a href="a00167.html#ac8a60c799d9dbc84531b4680762eb8dc">Register_I2C_Read</a></div><div class="ttdeci">int32_t Register_I2C_Read(ARM_DRIVER_I2C *pCommDrv, registerDeviceInfo_t *devInfo, uint16_t slaveAddress, uint8_t offset, uint8_t length, uint8_t *pOutBuffer)</div><div class="ttdoc">The interface function to read a sensor register. </div><div class="ttdef"><b>Definition:</b> <a href="a00167_source.html#l00310">register_io_i2c.c:310</a></div></div>
61<div class="ttc" id="a00179_html_a18a00cbfd8ad83c7fd229cd0d5fad5aca7f5031b1497c3a8a4bcb78cce879dedd"><div class="ttname"><a href="a00179.html#a18a00cbfd8ad83c7fd229cd0d5fad5aca7f5031b1497c3a8a4bcb78cce879dedd">SENSOR_ERROR_INIT</a></div><div class="ttdef"><b>Definition:</b> <a href="a00179_source.html#l00036">sensor_drv.h:36</a></div></div>
62<div class="ttc" id="a00140_html_a3ee4e9f70475f3c684c23241163781aba961d9357ec20c1ae3fc6a7c375dc4815"><div class="ttname"><a href="a00140.html#a3ee4e9f70475f3c684c23241163781aba961d9357ec20c1ae3fc6a7c375dc4815">MMA865x_OUT_X_MSB</a></div><div class="ttdef"><b>Definition:</b> <a href="a00140_source.html#l00018">mma865x.h:18</a></div></div>
63<div class="ttc" id="a03991_html"><div class="ttname"><a href="a03991.html">PhysicalSensor</a></div><div class="ttdoc">An instance of PhysicalSensor structure type should be allocated for each physical sensors (combo dev...</div><div class="ttdef"><b>Definition:</b> <a href="a00914_source.html#l00155">sensor_fusion.h:155</a></div></div>
64<div class="ttc" id="a00842_html_a9df61be7e9e0b946a28705f09bb319c0"><div class="ttname"><a href="a00842.html#a9df61be7e9e0b946a28705f09bb319c0">MMA8652_Init</a></div><div class="ttdeci">int8_t MMA8652_Init(struct PhysicalSensor *sensor, SensorFusionGlobals *sfg)</div></div>
65<div class="ttc" id="a00911_html_a2686eeb8ae44e588362478db1f757a0e"><div class="ttname"><a href="a00911.html#a2686eeb8ae44e588362478db1f757a0e">conditionSample</a></div><div class="ttdeci">void conditionSample(int16_t sample[3])</div><div class="ttdoc">conditionSample ensures that we never encounter the maximum negative two&amp;#39;s complement value for a 16-...</div><div class="ttdef"><b>Definition:</b> <a href="a00911_source.html#l00510">sensor_fusion.c:510</a></div></div>
66<div class="ttc" id="a00914_html_a76143891435bdd7248857e45b93521ed"><div class="ttname"><a href="a00914.html#a76143891435bdd7248857e45b93521ed">CHZ</a></div><div class="ttdeci">#define CHZ</div><div class="ttdoc">Used to access Z-channel entries in various data data structures. </div><div class="ttdef"><b>Definition:</b> <a href="a00914_source.html#l00062">sensor_fusion.h:62</a></div></div>
67<div class="ttc" id="a00911_html_ae7d2343e9a63bd3879ae477ec4536f6a"><div class="ttname"><a href="a00911.html#ae7d2343e9a63bd3879ae477ec4536f6a">addToFifo</a></div><div class="ttdeci">void addToFifo(union FifoSensor *sensor, uint16_t maxFifoSize, int16_t sample[3])</div><div class="ttdoc">addToFifo is called from within sensor driver read functions </div><div class="ttdef"><b>Definition:</b> <a href="a00911_source.html#l00522">sensor_fusion.c:522</a></div></div>
68<div class="ttc" id="a00179_html"><div class="ttname"><a href="a00179.html">sensor_drv.h</a></div><div class="ttdoc">The sensor_drv.h file contains sensor state and error definitions. </div></div>
69<div class="ttc" id="a00179_html_a2cedde333a6373a3ee274bde6af145d0"><div class="ttname"><a href="a00179.html#a2cedde333a6373a3ee274bde6af145d0">__END_WRITE_DATA__</a></div><div class="ttdeci">#define __END_WRITE_DATA__</div><div class="ttdef"><b>Definition:</b> <a href="a00179_source.html#l00045">sensor_drv.h:45</a></div></div>
70<div class="ttc" id="a04047_html"><div class="ttname"><a href="a04047.html">SensorFusionGlobals</a></div><div class="ttdoc">The top level fusion structure. </div><div class="ttdef"><b>Definition:</b> <a href="a00914_source.html#l00454">sensor_fusion.h:454</a></div></div>
71<div class="ttc" id="a00914_html_a6a25024f52cc6bea13d19f8b68456cea"><div class="ttname"><a href="a00914.html#a6a25024f52cc6bea13d19f8b68456cea">CHY</a></div><div class="ttdeci">#define CHY</div><div class="ttdoc">Used to access Y-channel entries in various data data structures. </div><div class="ttdef"><b>Definition:</b> <a href="a00914_source.html#l00061">sensor_fusion.h:61</a></div></div>
72<div class="ttc" id="a00521_html_a5d7069350a7d7e65686c77a8038f462f"><div class="ttname"><a href="a00521.html#a5d7069350a7d7e65686c77a8038f462f">int32_t</a></div><div class="ttdeci">typedef int32_t(DATA_FORMAT_Append_t))(void *pData</div><div class="ttdoc">The interface function to append the data on the formated stream. </div></div>
73<div class="ttc" id="a00827_html_aec02b963dc94a1a6ef8a0fb03abdf295"><div class="ttname"><a href="a00827.html#aec02b963dc94a1a6ef8a0fb03abdf295">MMA8652_ACCEL_FIFO_SIZE</a></div><div class="ttdeci">#define MMA8652_ACCEL_FIFO_SIZE</div><div class="ttdef"><b>Definition:</b> <a href="a00827_source.html#l00021">driver_MMA8652.c:21</a></div></div>
74<div class="ttc" id="a00917_html_a4c185218ef46ba2991d62b28e1620539"><div class="ttname"><a href="a00917.html#a4c185218ef46ba2991d62b28e1620539">ACCEL_FIFO_SIZE</a></div><div class="ttdeci">#define ACCEL_FIFO_SIZE</div><div class="ttdoc">FXOS8700 (accel), MMA8652, FXLS8952 all have 32 element FIFO. </div><div class="ttdef"><b>Definition:</b> <a href="a00917_source.html#l00062">standard_build.h:62</a></div></div>
75<div class="ttc" id="a00182_html_aaac4c4f34b4dd37d3f202a1dbb4b000b"><div class="ttname"><a href="a00182.html#aaac4c4f34b4dd37d3f202a1dbb4b000b">Sensor_I2C_Write</a></div><div class="ttdeci">int32_t Sensor_I2C_Write(ARM_DRIVER_I2C *pCommDrv, registerDeviceInfo_t *devInfo, uint16_t slaveAddress, const registerwritelist_t *pRegWriteList)</div><div class="ttdoc">Write register data to a sensor. </div><div class="ttdef"><b>Definition:</b> <a href="a00182_source.html#l00071">sensor_io_i2c.c:71</a></div></div>
76<div class="ttc" id="a03991_html_ae75b47fd9e098d6bd3b28f6be6586998"><div class="ttname"><a href="a03991.html#ae75b47fd9e098d6bd3b28f6be6586998">PhysicalSensor::deviceInfo</a></div><div class="ttdeci">registerDeviceInfo_t deviceInfo</div><div class="ttdoc">I2C device context. </div><div class="ttdef"><b>Definition:</b> <a href="a00914_source.html#l00156">sensor_fusion.h:156</a></div></div>
77<div class="ttc" id="a00140_html_a3ee4e9f70475f3c684c23241163781aba96d2ceb4e9501ebadd172e35f6af8a29"><div class="ttname"><a href="a00140.html#a3ee4e9f70475f3c684c23241163781aba96d2ceb4e9501ebadd172e35f6af8a29">MMA865x_STATUS</a></div><div class="ttdef"><b>Definition:</b> <a href="a00140_source.html#l00016">mma865x.h:16</a></div></div>
78<div class="ttc" id="a03811_html_a1440a8efa2f56cded09ced3ff687d32a"><div class="ttname"><a href="a03811.html#a1440a8efa2f56cded09ced3ff687d32a">registerreadlist_t::numBytes</a></div><div class="ttdeci">uint8_t numBytes</div><div class="ttdef"><b>Definition:</b> <a href="a00179_source.html#l00081">sensor_drv.h:81</a></div></div>
79<div class="ttc" id="a00140_html_a3ee4e9f70475f3c684c23241163781aba67770cf051b084bf5d7eac3724b28249"><div class="ttname"><a href="a00140.html#a3ee4e9f70475f3c684c23241163781aba67770cf051b084bf5d7eac3724b28249">MMA865x_F_SETUP</a></div><div class="ttdef"><b>Definition:</b> <a href="a00140_source.html#l00024">mma865x.h:24</a></div></div>
80<div class="ttc" id="a00842_html_a7f301dd1df3c367b45aa8e85d9872521"><div class="ttname"><a href="a00842.html#a7f301dd1df3c367b45aa8e85d9872521">MMA8652_Read</a></div><div class="ttdeci">int8_t MMA8652_Read(struct PhysicalSensor *sensor, SensorFusionGlobals *sfg)</div></div>
81<div class="ttc" id="a00179_html_a18a00cbfd8ad83c7fd229cd0d5fad5acab93ad77156e08d1bebe52bf46936cccc"><div class="ttname"><a href="a00179.html#a18a00cbfd8ad83c7fd229cd0d5fad5acab93ad77156e08d1bebe52bf46936cccc">SENSOR_ERROR_READ</a></div><div class="ttdef"><b>Definition:</b> <a href="a00179_source.html#l00038">sensor_drv.h:38</a></div></div>
82<div class="ttc" id="a00140_html_a3ee4e9f70475f3c684c23241163781aba8e8c5a7a258169848329a0efc7f7624f"><div class="ttname"><a href="a00140.html#a3ee4e9f70475f3c684c23241163781aba8e8c5a7a258169848329a0efc7f7624f">MMA865x_CTRL_REG1</a></div><div class="ttdef"><b>Definition:</b> <a href="a00140_source.html#l00053">mma865x.h:53</a></div></div>
83<div class="ttc" id="a00914_html"><div class="ttname"><a href="a00914.html">sensor_fusion.h</a></div><div class="ttdoc">The sensor_fusion.h file implements the top level programming interface. </div></div>
84<div class="ttc" id="a00140_html_a3ee4e9f70475f3c684c23241163781abae6d7316e12f2946651c85717ada82c4a"><div class="ttname"><a href="a00140.html#a3ee4e9f70475f3c684c23241163781abae6d7316e12f2946651c85717ada82c4a">MMA865x_XYZ_DATA_CFG</a></div><div class="ttdef"><b>Definition:</b> <a href="a00140_source.html#l00029">mma865x.h:29</a></div></div>
85<div class="ttc" id="a00179_html_aebb58a1bb3df30b7df4f6f14d0f1a81d"><div class="ttname"><a href="a00179.html#aebb58a1bb3df30b7df4f6f14d0f1a81d">__END_READ_DATA__</a></div><div class="ttdeci">#define __END_READ_DATA__</div><div class="ttdef"><b>Definition:</b> <a href="a00179_source.html#l00051">sensor_drv.h:51</a></div></div>
86<div class="ttc" id="a00470_html_afa81c629d378fe700f351a1bce411ad5"><div class="ttname"><a href="a00470.html#afa81c629d378fe700f351a1bce411ad5">sfg</a></div><div class="ttdeci">SensorFusionGlobals sfg</div><div class="ttdef"><b>Definition:</b> <a href="a00470_source.html#l00075">orientaion_application_baremetal_agm01.c:75</a></div></div>
87<div class="ttc" id="a03811_html_a5fe82375de174c0511ca301fec78e441"><div class="ttname"><a href="a03811.html#a5fe82375de174c0511ca301fec78e441">registerreadlist_t::readFrom</a></div><div class="ttdeci">uint16_t readFrom</div><div class="ttdef"><b>Definition:</b> <a href="a00179_source.html#l00080">sensor_drv.h:80</a></div></div>
88<div class="ttc" id="a00140_html"><div class="ttname"><a href="a00140.html">mma865x.h</a></div></div>
89<div class="ttc" id="a03991_html_a87223885ad859bb82fdc45644bc1f0b2"><div class="ttname"><a href="a03991.html#a87223885ad859bb82fdc45644bc1f0b2">PhysicalSensor::isInitialized</a></div><div class="ttdeci">uint16_t isInitialized</div><div class="ttdoc">Bitfields to indicate sensor is active (use SensorBitFields from build.h) </div><div class="ttdef"><b>Definition:</b> <a href="a00914_source.html#l00160">sensor_fusion.h:160</a></div></div>
90<div class="ttc" id="a03811_html"><div class="ttname"><a href="a03811.html">registerreadlist_t</a></div><div class="ttdoc">This structure defines the Read command List. </div><div class="ttdef"><b>Definition:</b> <a href="a00179_source.html#l00078">sensor_drv.h:78</a></div></div>
91<div class="ttc" id="a00914_html_a48bbd27e913de8d7749dff9dec2fe816"><div class="ttname"><a href="a00914.html#a48bbd27e913de8d7749dff9dec2fe816">CHX</a></div><div class="ttdeci">#define CHX</div><div class="ttdoc">Used to access X-channel entries in various data data structures. </div><div class="ttdef"><b>Definition:</b> <a href="a00914_source.html#l00060">sensor_fusion.h:60</a></div></div>
92<div class="ttc" id="a04011_html"><div class="ttname"><a href="a04011.html">FifoSensor</a></div><div class="ttdoc">The FifoSensor union allows us to use common pointers for Accel, Mag &amp; Gyro logical sensor structures...</div><div class="ttdef"><b>Definition:</b> <a href="a00914_source.html#l00253">sensor_fusion.h:253</a></div></div>
93<div class="ttc" id="a03991_html_a41a6aad09727eb120338c35535a652a6"><div class="ttname"><a href="a03991.html#a41a6aad09727eb120338c35535a652a6">PhysicalSensor::addr</a></div><div class="ttdeci">uint16_t addr</div><div class="ttdoc">I2C address if applicable. </div><div class="ttdef"><b>Definition:</b> <a href="a00914_source.html#l00159">sensor_fusion.h:159</a></div></div>
94<div class="ttc" id="a00827_html_a5102c19894b1a3264dde9c0687402978"><div class="ttname"><a href="a00827.html#a5102c19894b1a3264dde9c0687402978">MMA8652_COUNTSPERG</a></div><div class="ttdeci">#define MMA8652_COUNTSPERG</div><div class="ttdef"><b>Definition:</b> <a href="a00827_source.html#l00020">driver_MMA8652.c:20</a></div></div>
95<div class="ttc" id="a00140_html_a3ee4e9f70475f3c684c23241163781abaf81b085731966d679dd38ae64123a94c"><div class="ttname"><a href="a00140.html#a3ee4e9f70475f3c684c23241163781abaf81b085731966d679dd38ae64123a94c">MMA865x_WHO_AM_I</a></div><div class="ttdef"><b>Definition:</b> <a href="a00140_source.html#l00028">mma865x.h:28</a></div></div>
96<div class="ttc" id="a00140_html_a073411344592aee73bcd637972375e00"><div class="ttname"><a href="a00140.html#a073411344592aee73bcd637972375e00">MMA8652_WHOAMI_VALUE</a></div><div class="ttdeci">#define MMA8652_WHOAMI_VALUE</div><div class="ttdef"><b>Definition:</b> <a href="a00140_source.html#l00065">mma865x.h:65</a></div></div>
97<div class="ttc" id="a00185_html"><div class="ttname"><a href="a00185.html">sensor_io_i2c.h</a></div><div class="ttdoc">The sensor_io_i2c.h file declares low-level interface functions for reading and writing sensor regist...</div></div>
98</div><!-- fragment --></div><!-- contents -->
99
100<hr class="footer"/><address class="footer"><small>
101&copy; Copyright 2016-2022 NXP. All Rights Reserved. SPDX-License-Identifier: BSD-3-Clause
102</small></address>
103</body>
104</html>
105