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/main_baremetal_agm04.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  <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">main_baremetal_agm04.c</div> </div> 49</div><!--header--> 50<div class="contents"> 51<a href="a00872.html">Go to the documentation of this file.</a><div class="fragment"><div class="line"><a name="l00001"></a><span class="lineno"> 1</span> <span class="comment">/*</span></div><div class="line"><a name="l00002"></a><span class="lineno"> 2</span> <span class="comment"> * Copyright (c) 2016, Freescale Semiconductor, Inc.</span></div><div class="line"><a name="l00003"></a><span class="lineno"> 3</span> <span class="comment"> * Copyright 2016-2017 NXP</span></div><div class="line"><a name="l00004"></a><span class="lineno"> 4</span> <span class="comment"> * All rights reserved.</span></div><div class="line"><a name="l00005"></a><span class="lineno"> 5</span> <span class="comment"> *</span></div><div class="line"><a name="l00006"></a><span class="lineno"> 6</span> <span class="comment"> * SPDX-License-Identifier: BSD-3-Clause</span></div><div class="line"><a name="l00007"></a><span class="lineno"> 7</span> <span class="comment"> */</span></div><div class="line"><a name="l00008"></a><span class="lineno"> 8</span> <span class="comment"></span></div><div class="line"><a name="l00009"></a><span class="lineno"> 9</span> <span class="comment">/*! \file main_baremetal_agm04.c</span></div><div class="line"><a name="l00010"></a><span class="lineno"> 10</span> <span class="comment"> \brief Bare metal implementation of sensor fusion on FRDM-K64F/FRDM-STBC-AGM04</span></div><div class="line"><a name="l00011"></a><span class="lineno"> 11</span> <span class="comment"> using MMA8652 (Accel), FXAS21002 (Gyro) and MAG3110 (Mag).</span></div><div class="line"><a name="l00012"></a><span class="lineno"> 12</span> <span class="comment"></span></div><div class="line"><a name="l00013"></a><span class="lineno"> 13</span> <span class="comment"> \note This file shows one recommended way to incorporate sensor fusion capabilities</span></div><div class="line"><a name="l00014"></a><span class="lineno"> 14</span> <span class="comment"> into a bare metal project.</span></div><div class="line"><a name="l00015"></a><span class="lineno"> 15</span> <span class="comment">*/</span></div><div class="line"><a name="l00016"></a><span class="lineno"> 16</span> </div><div class="line"><a name="l00017"></a><span class="lineno"> 17</span> <span class="comment">// SDK and ISSDK Headers</span></div><div class="line"><a name="l00018"></a><span class="lineno"> 18</span> <span class="preprocessor">#include "fsl_debug_console.h"</span> <span class="comment">// SDK header file for the debug interface</span></div><div class="line"><a name="l00019"></a><span class="lineno"> 19</span> <span class="preprocessor">#include "board.h"</span> <span class="comment">// SDK header file to define board configuration</span></div><div class="line"><a name="l00020"></a><span class="lineno"> 20</span> <span class="preprocessor">#include "pin_mux.h"</span> <span class="comment">// SDK header file for pin mux initialization functions</span></div><div class="line"><a name="l00021"></a><span class="lineno"> 21</span> <span class="preprocessor">#include "clock_config.h"</span> <span class="comment">// SDK header file for clock configuration</span></div><div class="line"><a name="l00022"></a><span class="lineno"> 22</span> <span class="preprocessor">#include "fsl_port.h"</span> <span class="comment">// SDK header file for Port I/O control</span></div><div class="line"><a name="l00023"></a><span class="lineno"> 23</span> <span class="preprocessor">#include "fsl_i2c.h"</span> <span class="comment">// SDK header file for I2C interfaces</span></div><div class="line"><a name="l00024"></a><span class="lineno"> 24</span> <span class="preprocessor">#include "fsl_i2c_cmsis.h"</span></div><div class="line"><a name="l00025"></a><span class="lineno"> 25</span> <span class="preprocessor">#include "fsl_dspi_cmsis.h"</span></div><div class="line"><a name="l00026"></a><span class="lineno"> 26</span> <span class="preprocessor">#include "<a class="code" href="a00170.html">register_io_i2c.h</a>"</span></div><div class="line"><a name="l00027"></a><span class="lineno"> 27</span> <span class="preprocessor">#include "fsl_pit.h"</span> <span class="comment">// SDK header for the Periodic Interval Timer</span></div><div class="line"><a name="l00028"></a><span class="lineno"> 28</span> </div><div class="line"><a name="l00029"></a><span class="lineno"> 29</span> <span class="comment">// Sensor Fusion Headers</span></div><div class="line"><a name="l00030"></a><span class="lineno"> 30</span> <span class="preprocessor">#include "<a class="code" href="a00914.html">sensor_fusion.h</a>"</span> <span class="comment">// top level magCal and sensor fusion interfaces</span></div><div class="line"><a name="l00031"></a><span class="lineno"> 31</span> <span class="preprocessor">#include "<a class="code" href="a00779.html">control.h</a>"</span> <span class="comment">// Command/Streaming interface - application specific</span></div><div class="line"><a name="l00032"></a><span class="lineno"> 32</span> <span class="preprocessor">#include "<a class="code" href="a00923.html">status.h</a>"</span> <span class="comment">// Status indicator interface - application specific</span></div><div class="line"><a name="l00033"></a><span class="lineno"> 33</span> <span class="preprocessor">#include "<a class="code" href="a00842.html">drivers.h</a>"</span> <span class="comment">// NXP sensor drivers OR customer-supplied drivers</span></div><div class="line"><a name="l00034"></a><span class="lineno"> 34</span> <span class="preprocessor">#include "<a class="code" href="a00836.html">driver_pit.h</a>"</span> <span class="comment">// Project-specific - PIT is used to control main() timing loop</span></div><div class="line"><a name="l00035"></a><span class="lineno"> 35</span> </div><div class="line"><a name="l00036"></a><span class="lineno"> 36</span> <span class="comment">// Global data structures</span></div><div class="line"><a name="l00037"></a><span class="lineno"><a class="line" href="a00872.html#afa81c629d378fe700f351a1bce411ad5"> 37</a></span> <a class="code" href="a04047.html">SensorFusionGlobals</a> <a class="code" href="a00872.html#afa81c629d378fe700f351a1bce411ad5">sfg</a>; <span class="comment">///< This is the primary sensor fusion data structure</span></div><div class="line"><a name="l00038"></a><span class="lineno"><a class="line" href="a00872.html#a641b380af068b4004bc5b9dff5e5a6db"> 38</a></span> <span class="comment"></span><a class="code" href="a03967.html">ControlSubsystem</a> <a class="code" href="a00872.html#a641b380af068b4004bc5b9dff5e5a6db">controlSubsystem</a>; <span class="comment">///< used for serial communications</span></div><div class="line"><a name="l00039"></a><span class="lineno"><a class="line" href="a00872.html#a875f795e25aaef1b828061bbfae4764a"> 39</a></span> <span class="comment"></span><a class="code" href="a04051.html">StatusSubsystem</a> <a class="code" href="a00872.html#a875f795e25aaef1b828061bbfae4764a">statusSubsystem</a>; <span class="comment">///< provides visual (usually LED) status indicator</span></div><div class="line"><a name="l00040"></a><span class="lineno"><a class="line" href="a00872.html#a84786a835b4ead54496764473c994db5"> 40</a></span> <span class="comment"></span><span class="keyword">struct </span><a class="code" href="a03991.html">PhysicalSensor</a> <a class="code" href="a00872.html#a84786a835b4ead54496764473c994db5">sensors</a>[3]; <span class="comment">///< This implementation uses three physical sensors</span></div><div class="line"><a name="l00041"></a><span class="lineno"> 41</span> <span class="comment"></span></div><div class="line"><a name="l00042"></a><span class="lineno"><a class="line" href="a00872.html#a75f40af5caf43ce58b7a18015c210e4a"> 42</a></span> <a class="code" href="a03819.html">registerDeviceInfo_t</a> <a class="code" href="a00872.html#a75f40af5caf43ce58b7a18015c210e4a">i2cBusInfo</a> = {</div><div class="line"><a name="l00043"></a><span class="lineno"> 43</span>  .<a class="code" href="a03819.html#a693f84e28d48677a73cd40d7e5fc79ed">deviceInstance</a> = <a class="code" href="a04343.html#ab0c7969a7fffaabe78d43db2b12ad840">I2C_S_DEVICE_INDEX</a>,</div><div class="line"><a name="l00044"></a><span class="lineno"> 44</span>  .functionParam = NULL,</div><div class="line"><a name="l00045"></a><span class="lineno"> 45</span>  .idleFunction = NULL</div><div class="line"><a name="l00046"></a><span class="lineno"> 46</span> };</div><div class="line"><a name="l00047"></a><span class="lineno"> 47</span> <span class="comment"></span></div><div class="line"><a name="l00048"></a><span class="lineno"> 48</span> <span class="comment">/// This is a FreeRTOS (dual task) implementation of the NXP sensor fusion demo build.</span></div><div class="line"><a name="l00049"></a><span class="lineno"><a class="line" href="a00872.html#a840291bc02cba5474a4cb46a9b9566fe"> 49</a></span> <span class="comment"></span><span class="keywordtype">int</span> <a class="code" href="a00872.html#a840291bc02cba5474a4cb46a9b9566fe">main</a>(<span class="keywordtype">void</span>)</div><div class="line"><a name="l00050"></a><span class="lineno"> 50</span> {</div><div class="line"><a name="l00051"></a><span class="lineno"> 51</span>  <span class="keywordtype">int</span> i; <span class="comment">// loop index</span></div><div class="line"><a name="l00052"></a><span class="lineno"> 52</span>  ARM_DRIVER_I2C* <a class="code" href="a00368.html#a3c22bed16a7c769894081222aa6107d8">I2Cdrv</a> = &<a class="code" href="a04343.html#ad6a14737695a4218d07182b86b21f570">I2C_S_DRIVER</a>; <span class="comment">// defined in the <shield>.h file</span></div><div class="line"><a name="l00053"></a><span class="lineno"> 53</span>  <a class="code" href="a00959.html#ga2c9fe54b6b84723fbaa590a6f4576966">BOARD_InitPins</a>(); <span class="comment">// defined in pin_mux.c, initializes pkg pins</span></div><div class="line"><a name="l00054"></a><span class="lineno"> 54</span>  <a class="code" href="a04292.html#a8d81431cbbc4b01da56afbff0f766379">BOARD_BootClockRUN</a>(); <span class="comment">// defined in clock_config.c, initializes clocks</span></div><div class="line"><a name="l00055"></a><span class="lineno"> 55</span>  <a class="code" href="a04109.html#a4c84ccb952cb083367d7040cf9de3db8">BOARD_InitDebugConsole</a>(); <span class="comment">// defined in board.c, initializes the OpenSDA port</span></div><div class="line"><a name="l00056"></a><span class="lineno"> 56</span> </div><div class="line"><a name="l00057"></a><span class="lineno"> 57</span>  I2Cdrv->Initialize(<a class="code" href="a04343.html#a60ac2e3bb32ae33e2fd542f607a58ac4">I2C_S_SIGNAL_EVENT</a>); <span class="comment">// Initialize the SDK driver for the I2C port</span></div><div class="line"><a name="l00058"></a><span class="lineno"> 58</span>  I2Cdrv->PowerControl(ARM_POWER_FULL); <span class="comment">// Set the I2C Power mode.</span></div><div class="line"><a name="l00059"></a><span class="lineno"> 59</span>  I2Cdrv->Control(ARM_I2C_BUS_SPEED, ARM_I2C_BUS_SPEED_FAST); <span class="comment">// Configure the I2C bus speed</span></div><div class="line"><a name="l00060"></a><span class="lineno"> 60</span> </div><div class="line"><a name="l00061"></a><span class="lineno"> 61</span>  <a class="code" href="a00776.html#a67029acf1be9712c5d30c625132ad958">initializeControlPort</a>(&controlSubsystem); <span class="comment">// configure pins and ports for the control sub-system</span></div><div class="line"><a name="l00062"></a><span class="lineno"> 62</span>  <a class="code" href="a00920.html#a01619741119cf3432f8cfff23334c793">initializeStatusSubsystem</a>(&statusSubsystem); <span class="comment">// configure pins and ports for the status sub-system</span></div><div class="line"><a name="l00063"></a><span class="lineno"> 63</span>  <a class="code" href="a00911.html#a43b44018042fabb5179c2e62277cc942">initSensorFusionGlobals</a>(&sfg, &statusSubsystem, &controlSubsystem); <span class="comment">// Initialize sensor fusion structures</span></div><div class="line"><a name="l00064"></a><span class="lineno"> 64</span>  <span class="comment">// "install" the sensors we will be using</span></div><div class="line"><a name="l00065"></a><span class="lineno"> 65</span> <span class="preprocessor">#if F_USING_ACCEL</span></div><div class="line"><a name="l00066"></a><span class="lineno"> 66</span>  sfg.<a class="code" href="a04047.html#a22ddc1cea4daa0d93be0fe7d48365dbb">installSensor</a>(&sfg, &<a class="code" href="a00872.html#a84786a835b4ead54496764473c994db5">sensors</a>[0], <a class="code" href="a00545.html#a8988e99259e07194918336da18dd35e9">MMA8652_I2C_ADDR</a>, 1, (<span class="keywordtype">void</span>*) I2Cdrv, &i2cBusInfo, <a class="code" href="a00842.html#a9df61be7e9e0b946a28705f09bb319c0">MMA8652_Init</a>, <a class="code" href="a00842.html#a7f301dd1df3c367b45aa8e85d9872521">MMA8652_Read</a>);</div><div class="line"><a name="l00067"></a><span class="lineno"> 67</span> <span class="preprocessor">#endif</span></div><div class="line"><a name="l00068"></a><span class="lineno"> 68</span> <span class="preprocessor">#if F_USING_GYRO</span></div><div class="line"><a name="l00069"></a><span class="lineno"> 69</span>  sfg.<a class="code" href="a04047.html#a22ddc1cea4daa0d93be0fe7d48365dbb">installSensor</a>(&sfg, &<a class="code" href="a00872.html#a84786a835b4ead54496764473c994db5">sensors</a>[1], <a class="code" href="a00545.html#a16a56b988ac0de778585d40fdada58f0">FXAS21002_I2C_ADDR</a>, 1, (<span class="keywordtype">void</span>*) I2Cdrv, &i2cBusInfo, <a class="code" href="a00842.html#a81c5b987e709b3991bc7c1bc1e659c1f">FXAS21002_Init</a>, <a class="code" href="a00842.html#a1e2a1a192ed7f150fc24fc11df8d4c1e">FXAS21002_Read</a>);</div><div class="line"><a name="l00070"></a><span class="lineno"> 70</span> <span class="preprocessor">#endif</span></div><div class="line"><a name="l00071"></a><span class="lineno"> 71</span> <span class="preprocessor">#if F_USING_MAG</span></div><div class="line"><a name="l00072"></a><span class="lineno"> 72</span>  sfg.<a class="code" href="a04047.html#a22ddc1cea4daa0d93be0fe7d48365dbb">installSensor</a>(&sfg, &<a class="code" href="a00872.html#a84786a835b4ead54496764473c994db5">sensors</a>[2], <a class="code" href="a00545.html#a4860aad19aa4ea956e2ea937fb175847">MAG3110_I2C_ADDR</a>, 1, (<span class="keywordtype">void</span>*) I2Cdrv, &i2cBusInfo, <a class="code" href="a00821.html#a20b118514f14ce008825433f72527ecd">MAG3110_Init</a>, <a class="code" href="a00821.html#a2592117f3e2fed5f61ff029cb18fa556">MAG3110_Read</a>);</div><div class="line"><a name="l00073"></a><span class="lineno"> 73</span> <span class="preprocessor">#endif</span></div><div class="line"><a name="l00074"></a><span class="lineno"> 74</span>  sfg.<a class="code" href="a04047.html#a4c9ce90c92e284691468585f6a55d79e">initializeFusionEngine</a>(&sfg); <span class="comment">// This will initialize sensors and magnetic calibration</span></div><div class="line"><a name="l00075"></a><span class="lineno"> 75</span> </div><div class="line"><a name="l00076"></a><span class="lineno"> 76</span>  <a class="code" href="a00797.html#aa9242caadd99e8ac4fdce86681b61740">pit_init</a>(1000000/<a class="code" href="a00917.html#a470d8d33fe0efafcc0c0835fbea14f5e">FUSION_HZ</a>); <span class="comment">// pitIsrFlag will be set true at FUSION_HZ periodic intervals</span></div><div class="line"><a name="l00077"></a><span class="lineno"> 77</span> </div><div class="line"><a name="l00078"></a><span class="lineno"> 78</span>  sfg.<a class="code" href="a04047.html#aa22f9fd7adaca53616ef6bfb6cb051b4">setStatus</a>(&sfg, <a class="code" href="a00914.html#a69ee883e1c22b117df163c0bd83f66dda50d1448013c6f17125caee18aa418af7">NORMAL</a>); <span class="comment">// If we got this far, let's set status state to NORMAL</span></div><div class="line"><a name="l00079"></a><span class="lineno"> 79</span>  <span class="keywordflow">while</span> (<span class="keyword">true</span>)</div><div class="line"><a name="l00080"></a><span class="lineno"> 80</span>  {</div><div class="line"><a name="l00081"></a><span class="lineno"> 81</span>  <span class="keywordflow">if</span> (<span class="keyword">true</span> == <a class="code" href="a00797.html#a4bd7666380e01cee8eb7cd5f0df5e3bf">pitIsrFlag</a>) { <span class="comment">// Check whether occur interupt and toggle LED</span></div><div class="line"><a name="l00082"></a><span class="lineno"> 82</span>  sfg.<a class="code" href="a04047.html#a15e66ae3ad63ad091317ad0aefa53ce7">readSensors</a>(&sfg, 1); <span class="comment">// Reads sensors, applies HAL and does averaging (if applicable)</span></div><div class="line"><a name="l00083"></a><span class="lineno"> 83</span>  sfg.<a class="code" href="a04047.html#a7466779558c661297ca6dc36d829605c">conditionSensorReadings</a>(&sfg); <span class="comment">// magCal is run as part of this</span></div><div class="line"><a name="l00084"></a><span class="lineno"> 84</span>  sfg.<a class="code" href="a04047.html#afc72aca0c3842cde4aa4bb0dcdfb4237">runFusion</a>(&sfg); <span class="comment">// Run the actual fusion algorithms</span></div><div class="line"><a name="l00085"></a><span class="lineno"> 85</span>  sfg.<a class="code" href="a04047.html#ac01270fc7330df24acd1cd888397ef07">applyPerturbation</a>(&sfg); <span class="comment">// apply debug perturbation (testing only)</span></div><div class="line"><a name="l00086"></a><span class="lineno"> 86</span>  sfg.<a class="code" href="a04047.html#a0e90feae26cd26ab80bc78cfd9364512">loopcounter</a>++; <span class="comment">// The loop counter is used to "serialize" mag cal operations</span></div><div class="line"><a name="l00087"></a><span class="lineno"> 87</span>  i=i+1;</div><div class="line"><a name="l00088"></a><span class="lineno"> 88</span>  <span class="keywordflow">if</span> (i>=4) { <span class="comment">// Some status codes include a "blink" feature. This loop</span></div><div class="line"><a name="l00089"></a><span class="lineno"> 89</span>  i=0; <span class="comment">// should cycle at least four times for that to operate correctly.</span></div><div class="line"><a name="l00090"></a><span class="lineno"> 90</span>  sfg.<a class="code" href="a04047.html#a186a484bdd7f6c3210a2ee6d2763c6a2">updateStatus</a>(&sfg); <span class="comment">// This is where pending status updates are made visible</span></div><div class="line"><a name="l00091"></a><span class="lineno"> 91</span>  }</div><div class="line"><a name="l00092"></a><span class="lineno"> 92</span> </div><div class="line"><a name="l00093"></a><span class="lineno"> 93</span>  sfg.<a class="code" href="a04047.html#af6a232c7866a9093f9a5cb51372d4f97">queueStatus</a>(&sfg, <a class="code" href="a00914.html#a69ee883e1c22b117df163c0bd83f66dda50d1448013c6f17125caee18aa418af7">NORMAL</a>); <span class="comment">// assume NORMAL status for next pass through the loop</span></div><div class="line"><a name="l00094"></a><span class="lineno"> 94</span>  sfg.<a class="code" href="a04047.html#a51cbe943cdee0fd0a2ff72d2a04fad9a">pControlSubsystem</a>-><a class="code" href="a03967.html#a2fc3f3736130dec532bf7f12d4091e55">stream</a>(&sfg, <a class="code" href="a00776.html#a3b6c71dda245dccb73352c7264176527">sUARTOutputBuffer</a>); <span class="comment">// Send stream data to the Sensor Fusion Toolbox</span></div><div class="line"><a name="l00095"></a><span class="lineno"> 95</span>  <a class="code" href="a00797.html#a4bd7666380e01cee8eb7cd5f0df5e3bf">pitIsrFlag</a> = <span class="keyword">false</span>; <span class="comment">// Reset the flag for the next cycle</span></div><div class="line"><a name="l00096"></a><span class="lineno"> 96</span>  }</div><div class="line"><a name="l00097"></a><span class="lineno"> 97</span>  }</div><div class="line"><a name="l00098"></a><span class="lineno"> 98</span> }</div><div class="line"><a name="l00099"></a><span class="lineno"> 99</span> <span class="comment">/// \endcode</span></div><div class="ttc" id="a04047_html_a15e66ae3ad63ad091317ad0aefa53ce7"><div class="ttname"><a href="a04047.html#a15e66ae3ad63ad091317ad0aefa53ce7">SensorFusionGlobals::readSensors</a></div><div class="ttdeci">readSensors_t * readSensors</div><div class="ttdoc">read all physical sensors </div><div class="ttdef"><b>Definition:</b> <a href="a00914_source.html#l00527">sensor_fusion.h:527</a></div></div> 52<div class="ttc" id="a03819_html"><div class="ttname"><a href="a03819.html">registerDeviceInfo_t</a></div><div class="ttdoc">This structure defines the device specific info required by register I/O. </div><div class="ttdef"><b>Definition:</b> <a href="a00179_source.html#l00102">sensor_drv.h:102</a></div></div> 53<div class="ttc" id="a00872_html_a875f795e25aaef1b828061bbfae4764a"><div class="ttname"><a href="a00872.html#a875f795e25aaef1b828061bbfae4764a">statusSubsystem</a></div><div class="ttdeci">StatusSubsystem statusSubsystem</div><div class="ttdoc">provides visual (usually LED) status indicator </div><div class="ttdef"><b>Definition:</b> <a href="a00872_source.html#l00039">main_baremetal_agm04.c:39</a></div></div> 54<div class="ttc" id="a04047_html_a4c9ce90c92e284691468585f6a55d79e"><div class="ttname"><a href="a04047.html#a4c9ce90c92e284691468585f6a55d79e">SensorFusionGlobals::initializeFusionEngine</a></div><div class="ttdeci">initializeFusionEngine_t * initializeFusionEngine</div><div class="ttdoc">set sensor fusion structures to initial values </div><div class="ttdef"><b>Definition:</b> <a href="a00914_source.html#l00525">sensor_fusion.h:525</a></div></div> 55<div class="ttc" id="a04343_html_a60ac2e3bb32ae33e2fd542f607a58ac4"><div class="ttname"><a href="a04343.html#a60ac2e3bb32ae33e2fd542f607a58ac4">I2C_S_SIGNAL_EVENT</a></div><div class="ttdeci">#define I2C_S_SIGNAL_EVENT</div><div class="ttdef"><b>Definition:</b> <a href="a04343_source.html#l00034">issdk_hal.h:34</a></div></div> 56<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> 57<div class="ttc" id="a00872_html_a75f40af5caf43ce58b7a18015c210e4a"><div class="ttname"><a href="a00872.html#a75f40af5caf43ce58b7a18015c210e4a">i2cBusInfo</a></div><div class="ttdeci">registerDeviceInfo_t i2cBusInfo</div><div class="ttdef"><b>Definition:</b> <a href="a00872_source.html#l00042">main_baremetal_agm04.c:42</a></div></div> 58<div class="ttc" id="a00545_html_a4860aad19aa4ea956e2ea937fb175847"><div class="ttname"><a href="a00545.html#a4860aad19aa4ea956e2ea937fb175847">MAG3110_I2C_ADDR</a></div><div class="ttdeci">#define MAG3110_I2C_ADDR</div><div class="ttdef"><b>Definition:</b> <a href="a00545_source.html#l00039">auto_detection_shield.h:39</a></div></div> 59<div class="ttc" id="a00914_html_a69ee883e1c22b117df163c0bd83f66dda50d1448013c6f17125caee18aa418af7"><div class="ttname"><a href="a00914.html#a69ee883e1c22b117df163c0bd83f66dda50d1448013c6f17125caee18aa418af7">NORMAL</a></div><div class="ttdoc">Operation is Nominal. </div><div class="ttdef"><b>Definition:</b> <a href="a00914_source.html#l00108">sensor_fusion.h:108</a></div></div> 60<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> 61<div class="ttc" id="a04047_html_af6a232c7866a9093f9a5cb51372d4f97"><div class="ttname"><a href="a04047.html#af6a232c7866a9093f9a5cb51372d4f97">SensorFusionGlobals::queueStatus</a></div><div class="ttdeci">setStatus_t * queueStatus</div><div class="ttdoc">queue status change for next regular interval </div><div class="ttdef"><b>Definition:</b> <a href="a00914_source.html#l00532">sensor_fusion.h:532</a></div></div> 62<div class="ttc" id="a00821_html_a2592117f3e2fed5f61ff029cb18fa556"><div class="ttname"><a href="a00821.html#a2592117f3e2fed5f61ff029cb18fa556">MAG3110_Read</a></div><div class="ttdeci">int8_t MAG3110_Read(struct PhysicalSensor *sensor, SensorFusionGlobals *sfg)</div><div class="ttdef"><b>Definition:</b> <a href="a00821_source.html#l00113">driver_MAG3110.c:113</a></div></div> 63<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> 64<div class="ttc" id="a04292_html_a8d81431cbbc4b01da56afbff0f766379"><div class="ttname"><a href="a04292.html#a8d81431cbbc4b01da56afbff0f766379">BOARD_BootClockRUN</a></div><div class="ttdeci">#define BOARD_BootClockRUN</div><div class="ttdef"><b>Definition:</b> <a href="a04292_source.html#l00019">clock_config.h:19</a></div></div> 65<div class="ttc" id="a00821_html_a20b118514f14ce008825433f72527ecd"><div class="ttname"><a href="a00821.html#a20b118514f14ce008825433f72527ecd">MAG3110_Init</a></div><div class="ttdeci">int8_t MAG3110_Init(struct PhysicalSensor *sensor, SensorFusionGlobals *sfg)</div><div class="ttdef"><b>Definition:</b> <a href="a00821_source.html#l00082">driver_MAG3110.c:82</a></div></div> 66<div class="ttc" id="a03819_html_a693f84e28d48677a73cd40d7e5fc79ed"><div class="ttname"><a href="a03819.html#a693f84e28d48677a73cd40d7e5fc79ed">registerDeviceInfo_t::deviceInstance</a></div><div class="ttdeci">uint8_t deviceInstance</div><div class="ttdef"><b>Definition:</b> <a href="a00179_source.html#l00106">sensor_drv.h:106</a></div></div> 67<div class="ttc" id="a00923_html"><div class="ttname"><a href="a00923.html">status.h</a></div><div class="ttdoc">Application-specific status subsystem. </div></div> 68<div class="ttc" id="a04047_html_a7466779558c661297ca6dc36d829605c"><div class="ttname"><a href="a04047.html#a7466779558c661297ca6dc36d829605c">SensorFusionGlobals::conditionSensorReadings</a></div><div class="ttdeci">conditionSensorReadings_t * conditionSensorReadings</div><div class="ttdoc">preprocessing step for sensor fusion </div><div class="ttdef"><b>Definition:</b> <a href="a00914_source.html#l00529">sensor_fusion.h:529</a></div></div> 69<div class="ttc" id="a00779_html"><div class="ttname"><a href="a00779.html">control.h</a></div><div class="ttdoc">Defines control sub-system. </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="a00872_html_a84786a835b4ead54496764473c994db5"><div class="ttname"><a href="a00872.html#a84786a835b4ead54496764473c994db5">sensors</a></div><div class="ttdeci">struct PhysicalSensor sensors[3]</div><div class="ttdoc">This implementation uses three physical sensors. </div><div class="ttdef"><b>Definition:</b> <a href="a00872_source.html#l00040">main_baremetal_agm04.c:40</a></div></div> 72<div class="ttc" id="a04109_html_a4c84ccb952cb083367d7040cf9de3db8"><div class="ttname"><a href="a04109.html#a4c84ccb952cb083367d7040cf9de3db8">BOARD_InitDebugConsole</a></div><div class="ttdeci">void BOARD_InitDebugConsole(void)</div><div class="ttdef"><b>Definition:</b> <a href="a04109_source.html#l00015">board.c:15</a></div></div> 73<div class="ttc" id="a00911_html_a43b44018042fabb5179c2e62277cc942"><div class="ttname"><a href="a00911.html#a43b44018042fabb5179c2e62277cc942">initSensorFusionGlobals</a></div><div class="ttdeci">void initSensorFusionGlobals(SensorFusionGlobals *sfg, StatusSubsystem *pStatusSubsystem, ControlSubsystem *pControlSubsystem)</div><div class="ttdoc">utility function to insert default values in the top level structure </div><div class="ttdef"><b>Definition:</b> <a href="a00911_source.html#l00051">sensor_fusion.c:51</a></div></div> 74<div class="ttc" id="a00842_html_a81c5b987e709b3991bc7c1bc1e659c1f"><div class="ttname"><a href="a00842.html#a81c5b987e709b3991bc7c1bc1e659c1f">FXAS21002_Init</a></div><div class="ttdeci">int8_t FXAS21002_Init(struct PhysicalSensor *sensor, SensorFusionGlobals *sfg)</div></div> 75<div class="ttc" id="a00170_html"><div class="ttname"><a href="a00170.html">register_io_i2c.h</a></div><div class="ttdoc">The register_io_i2c.h file declares low-level interface functions for reading and writing sensor regi...</div></div> 76<div class="ttc" id="a03967_html"><div class="ttname"><a href="a03967.html">ControlSubsystem</a></div><div class="ttdoc">he ControlSubsystem encapsulates command and data streaming functions. </div><div class="ttdef"><b>Definition:</b> <a href="a00779_source.html#l00042">control.h:42</a></div></div> 77<div class="ttc" id="a00872_html_a840291bc02cba5474a4cb46a9b9566fe"><div class="ttname"><a href="a00872.html#a840291bc02cba5474a4cb46a9b9566fe">main</a></div><div class="ttdeci">int main(void)</div><div class="ttdoc">This is a FreeRTOS (dual task) implementation of the NXP sensor fusion demo build. </div><div class="ttdef"><b>Definition:</b> <a href="a00872_source.html#l00049">main_baremetal_agm04.c:49</a></div></div> 78<div class="ttc" id="a04047_html_afc72aca0c3842cde4aa4bb0dcdfb4237"><div class="ttname"><a href="a04047.html#afc72aca0c3842cde4aa4bb0dcdfb4237">SensorFusionGlobals::runFusion</a></div><div class="ttdeci">runFusion_t * runFusion</div><div class="ttdoc">run the fusion routines </div><div class="ttdef"><b>Definition:</b> <a href="a00914_source.html#l00528">sensor_fusion.h:528</a></div></div> 79<div class="ttc" id="a00872_html_a641b380af068b4004bc5b9dff5e5a6db"><div class="ttname"><a href="a00872.html#a641b380af068b4004bc5b9dff5e5a6db">controlSubsystem</a></div><div class="ttdeci">ControlSubsystem controlSubsystem</div><div class="ttdoc">used for serial communications </div><div class="ttdef"><b>Definition:</b> <a href="a00872_source.html#l00038">main_baremetal_agm04.c:38</a></div></div> 80<div class="ttc" id="a00545_html_a16a56b988ac0de778585d40fdada58f0"><div class="ttname"><a href="a00545.html#a16a56b988ac0de778585d40fdada58f0">FXAS21002_I2C_ADDR</a></div><div class="ttdeci">#define FXAS21002_I2C_ADDR</div><div class="ttdef"><b>Definition:</b> <a href="a00545_source.html#l00032">auto_detection_shield.h:32</a></div></div> 81<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> 82<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> 83<div class="ttc" id="a00797_html_aa9242caadd99e8ac4fdce86681b61740"><div class="ttname"><a href="a00797.html#aa9242caadd99e8ac4fdce86681b61740">pit_init</a></div><div class="ttdeci">void pit_init(uint32_t microseconds)</div><div class="ttdef"><b>Definition:</b> <a href="a00797_source.html#l00064">driver_ctimer.c:64</a></div></div> 84<div class="ttc" id="a04047_html_aa22f9fd7adaca53616ef6bfb6cb051b4"><div class="ttname"><a href="a04047.html#aa22f9fd7adaca53616ef6bfb6cb051b4">SensorFusionGlobals::setStatus</a></div><div class="ttdeci">setStatus_t * setStatus</div><div class="ttdoc">change status indicator immediately </div><div class="ttdef"><b>Definition:</b> <a href="a00914_source.html#l00531">sensor_fusion.h:531</a></div></div> 85<div class="ttc" id="a04343_html_ad6a14737695a4218d07182b86b21f570"><div class="ttname"><a href="a04343.html#ad6a14737695a4218d07182b86b21f570">I2C_S_DRIVER</a></div><div class="ttdeci">#define I2C_S_DRIVER</div><div class="ttdef"><b>Definition:</b> <a href="a04343_source.html#l00033">issdk_hal.h:33</a></div></div> 86<div class="ttc" id="a00368_html_a3c22bed16a7c769894081222aa6107d8"><div class="ttname"><a href="a00368.html#a3c22bed16a7c769894081222aa6107d8">I2Cdrv</a></div><div class="ttdeci">ARM_DRIVER_I2C * I2Cdrv</div><div class="ttdef"><b>Definition:</b> <a href="a00368_source.html#l00083">fxls896xaf_motion_wakeup.c:83</a></div></div> 87<div class="ttc" id="a00776_html_a3b6c71dda245dccb73352c7264176527"><div class="ttname"><a href="a00776.html#a3b6c71dda245dccb73352c7264176527">sUARTOutputBuffer</a></div><div class="ttdeci">uint8_t sUARTOutputBuffer[256]</div><div class="ttdoc">main output buffer defined in control.c </div><div class="ttdef"><b>Definition:</b> <a href="a00776_source.html#l00037">control.c:37</a></div></div> 88<div class="ttc" id="a04047_html_a186a484bdd7f6c3210a2ee6d2763c6a2"><div class="ttname"><a href="a04047.html#a186a484bdd7f6c3210a2ee6d2763c6a2">SensorFusionGlobals::updateStatus</a></div><div class="ttdeci">updateStatus_t * updateStatus</div><div class="ttdoc">status=next status </div><div class="ttdef"><b>Definition:</b> <a href="a00914_source.html#l00533">sensor_fusion.h:533</a></div></div> 89<div class="ttc" id="a00917_html_a470d8d33fe0efafcc0c0835fbea14f5e"><div class="ttname"><a href="a00917.html#a470d8d33fe0efafcc0c0835fbea14f5e">FUSION_HZ</a></div><div class="ttdeci">#define FUSION_HZ</div><div class="ttdoc">(int) actual rate of fusion algorithm execution and sensor FIFO reads </div><div class="ttdef"><b>Definition:</b> <a href="a00917_source.html#l00068">standard_build.h:68</a></div></div> 90<div class="ttc" id="a04047_html_a22ddc1cea4daa0d93be0fe7d48365dbb"><div class="ttname"><a href="a04047.html#a22ddc1cea4daa0d93be0fe7d48365dbb">SensorFusionGlobals::installSensor</a></div><div class="ttdeci">installSensor_t * installSensor</div><div class="ttdoc">function for installing a new sensor into t </div><div class="ttdef"><b>Definition:</b> <a href="a00914_source.html#l00524">sensor_fusion.h:524</a></div></div> 91<div class="ttc" id="a04047_html_a51cbe943cdee0fd0a2ff72d2a04fad9a"><div class="ttname"><a href="a04047.html#a51cbe943cdee0fd0a2ff72d2a04fad9a">SensorFusionGlobals::pControlSubsystem</a></div><div class="ttdeci">struct ControlSubsystem * pControlSubsystem</div><div class="ttdef"><b>Definition:</b> <a href="a00914_source.html#l00462">sensor_fusion.h:462</a></div></div> 92<div class="ttc" id="a00776_html_a67029acf1be9712c5d30c625132ad958"><div class="ttname"><a href="a00776.html#a67029acf1be9712c5d30c625132ad958">initializeControlPort</a></div><div class="ttdeci">int8_t initializeControlPort(ControlSubsystem *pComm)</div><div class="ttdoc">Initialize the control subsystem and all related hardware. </div><div class="ttdef"><b>Definition:</b> <a href="a00776_source.html#l00160">control.c:160</a></div></div> 93<div class="ttc" id="a00545_html_a8988e99259e07194918336da18dd35e9"><div class="ttname"><a href="a00545.html#a8988e99259e07194918336da18dd35e9">MMA8652_I2C_ADDR</a></div><div class="ttdeci">#define MMA8652_I2C_ADDR</div><div class="ttdef"><b>Definition:</b> <a href="a00545_source.html#l00056">auto_detection_shield.h:56</a></div></div> 94<div class="ttc" id="a00842_html_a1e2a1a192ed7f150fc24fc11df8d4c1e"><div class="ttname"><a href="a00842.html#a1e2a1a192ed7f150fc24fc11df8d4c1e">FXAS21002_Read</a></div><div class="ttdeci">int8_t FXAS21002_Read(struct PhysicalSensor *sensor, SensorFusionGlobals *sfg)</div></div> 95<div class="ttc" id="a00872_html_afa81c629d378fe700f351a1bce411ad5"><div class="ttname"><a href="a00872.html#afa81c629d378fe700f351a1bce411ad5">sfg</a></div><div class="ttdeci">SensorFusionGlobals sfg</div><div class="ttdoc">This is the primary sensor fusion data structure. </div><div class="ttdef"><b>Definition:</b> <a href="a00872_source.html#l00037">main_baremetal_agm04.c:37</a></div></div> 96<div class="ttc" id="a00797_html_a4bd7666380e01cee8eb7cd5f0df5e3bf"><div class="ttname"><a href="a00797.html#a4bd7666380e01cee8eb7cd5f0df5e3bf">pitIsrFlag</a></div><div class="ttdeci">volatile bool pitIsrFlag</div><div class="ttdef"><b>Definition:</b> <a href="a00797_source.html#l00049">driver_ctimer.c:49</a></div></div> 97<div class="ttc" id="a00920_html_a01619741119cf3432f8cfff23334c793"><div class="ttname"><a href="a00920.html#a01619741119cf3432f8cfff23334c793">initializeStatusSubsystem</a></div><div class="ttdeci">void initializeStatusSubsystem(StatusSubsystem *pStatus)</div><div class="ttdef"><b>Definition:</b> <a href="a00920_source.html#l00165">status.c:165</a></div></div> 98<div class="ttc" id="a04343_html_ab0c7969a7fffaabe78d43db2b12ad840"><div class="ttname"><a href="a04343.html#ab0c7969a7fffaabe78d43db2b12ad840">I2C_S_DEVICE_INDEX</a></div><div class="ttdeci">#define I2C_S_DEVICE_INDEX</div><div class="ttdef"><b>Definition:</b> <a href="a04343_source.html#l00035">issdk_hal.h:35</a></div></div> 99<div class="ttc" id="a00959_html_ga2c9fe54b6b84723fbaa590a6f4576966"><div class="ttname"><a href="a00959.html#ga2c9fe54b6b84723fbaa590a6f4576966">BOARD_InitPins</a></div><div class="ttdeci">void BOARD_InitPins(void)</div><div class="ttdoc">Configures pin routing and optionally pin electrical features. </div><div class="ttdef"><b>Definition:</b> <a href="a04541_source.html#l00047">pin_mux.c:47</a></div></div> 100<div class="ttc" id="a03967_html_a2fc3f3736130dec532bf7f12d4091e55"><div class="ttname"><a href="a03967.html#a2fc3f3736130dec532bf7f12d4091e55">ControlSubsystem::stream</a></div><div class="ttdeci">streamData_t * stream</div><div class="ttdoc">function to create packets for serial stream </div><div class="ttdef"><b>Definition:</b> <a href="a00779_source.html#l00051">control.h:51</a></div></div> 101<div class="ttc" id="a04047_html_ac01270fc7330df24acd1cd888397ef07"><div class="ttname"><a href="a04047.html#ac01270fc7330df24acd1cd888397ef07">SensorFusionGlobals::applyPerturbation</a></div><div class="ttdeci">applyPerturbation_t * applyPerturbation</div><div class="ttdoc">apply step function for testing purposes </div><div class="ttdef"><b>Definition:</b> <a href="a00914_source.html#l00526">sensor_fusion.h:526</a></div></div> 102<div class="ttc" id="a04051_html"><div class="ttname"><a href="a04051.html">StatusSubsystem</a></div><div class="ttdoc">StatusSubsystem() provides an object-like interface for communicating status to the user...</div><div class="ttdef"><b>Definition:</b> <a href="a00923_source.html#l00022">status.h:22</a></div></div> 103<div class="ttc" id="a04047_html_a0e90feae26cd26ab80bc78cfd9364512"><div class="ttname"><a href="a04047.html#a0e90feae26cd26ab80bc78cfd9364512">SensorFusionGlobals::loopcounter</a></div><div class="ttdeci">int32_t loopcounter</div><div class="ttdoc">counter incrementing each iteration of sensor fusion (typically 25Hz) </div><div class="ttdef"><b>Definition:</b> <a href="a00914_source.html#l00471">sensor_fusion.h:471</a></div></div> 104<div class="ttc" id="a00836_html"><div class="ttname"><a href="a00836.html">driver_pit.h</a></div><div class="ttdoc">Provides a simple abstraction for a periodic interval timer. </div></div> 105</div><!-- fragment --></div><!-- contents --> 106 107<hr class="footer"/><address class="footer"><small> 108© Copyright 2016-2022 NXP. All Rights Reserved. SPDX-License-Identifier: BSD-3-Clause 109</small></address> 110</body> 111</html> 112