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_freertos_agm02_power_cycling.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_freertos_agm02_power_cycling.c</div> </div> 49</div><!--header--> 50<div class="contents"> 51<a href="a00881.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) 2015, 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_freertos_agm02_power_cycling.c</span></div><div class="line"><a name="l00010"></a><span class="lineno"> 10</span> <span class="comment"> \brief FreeRTOS (two task) implementation of sensor fusion on FRDM-K64F/FRDM-FXS-AGM02 with smart power-cycling support.</span></div><div class="line"><a name="l00011"></a><span class="lineno"> 11</span> <span class="comment"></span></div><div class="line"><a name="l00012"></a><span class="lineno"> 12</span> <span class="comment"> This file shows one recommended way to incorporate sensor fusion capabilities</span></div><div class="line"><a name="l00013"></a><span class="lineno"> 13</span> <span class="comment"> into a FreeRTOS project AND adds intelligent power down of sensors when</span></div><div class="line"><a name="l00014"></a><span class="lineno"> 14</span> <span class="comment"> the DUT is stationary.</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">/* FreeRTOS kernel includes. */</span></div><div class="line"><a name="l00018"></a><span class="lineno"> 18</span> <span class="preprocessor">#include "FreeRTOS.h"</span></div><div class="line"><a name="l00019"></a><span class="lineno"> 19</span> <span class="preprocessor">#include "task.h"</span></div><div class="line"><a name="l00020"></a><span class="lineno"> 20</span> <span class="preprocessor">#include "queue.h"</span></div><div class="line"><a name="l00021"></a><span class="lineno"> 21</span> <span class="preprocessor">#include "timers.h"</span></div><div class="line"><a name="l00022"></a><span class="lineno"> 22</span> <span class="preprocessor">#include "event_groups.h"</span></div><div class="line"><a name="l00023"></a><span class="lineno"> 23</span> </div><div class="line"><a name="l00024"></a><span class="lineno"> 24</span> <span class="comment">// KSDK and ISSDK Headers</span></div><div class="line"><a name="l00025"></a><span class="lineno"> 25</span> <span class="preprocessor">#include "fsl_debug_console.h"</span> <span class="comment">// KSDK header file for the debug interface</span></div><div class="line"><a name="l00026"></a><span class="lineno"> 26</span> <span class="preprocessor">#include "FSL_SMC.H"</span> <span class="comment">// KDSK header file for the System Mode Controller Driver</span></div><div class="line"><a name="l00027"></a><span class="lineno"> 27</span> <span class="preprocessor">#include "board.h"</span> <span class="comment">// KSDK header file to define board configuration</span></div><div class="line"><a name="l00028"></a><span class="lineno"> 28</span> <span class="preprocessor">#include "pin_mux.h"</span> <span class="comment">// KSDK header file for pin mux initialization functions</span></div><div class="line"><a name="l00029"></a><span class="lineno"> 29</span> <span class="preprocessor">#include "clock_config.h"</span> <span class="comment">// KSDK header file for clock configuration</span></div><div class="line"><a name="l00030"></a><span class="lineno"> 30</span> <span class="preprocessor">#include "fsl_port.h"</span> <span class="comment">// KSDK header file for Port I/O control</span></div><div class="line"><a name="l00031"></a><span class="lineno"> 31</span> <span class="preprocessor">#include "fsl_i2c.h"</span> <span class="comment">// KSDK header file for I2C interfaces</span></div><div class="line"><a name="l00032"></a><span class="lineno"> 32</span> <span class="preprocessor">#include "<a class="code" href="a00170.html">register_io_i2c.h</a>"</span></div><div class="line"><a name="l00033"></a><span class="lineno"> 33</span> <span class="preprocessor">#include "fsl_i2c_cmsis.h"</span></div><div class="line"><a name="l00034"></a><span class="lineno"> 34</span> <span class="preprocessor">#include "fsl_dspi_cmsis.h"</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">// Sensor Fusion Headers</span></div><div class="line"><a name="l00037"></a><span class="lineno"> 37</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="l00038"></a><span class="lineno"> 38</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="l00039"></a><span class="lineno"> 39</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="l00040"></a><span class="lineno"> 40</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="l00041"></a><span class="lineno"> 41</span> <span class="preprocessor">#include "<a class="code" href="a00848.html">fusion.h</a>"</span> <span class="comment">// Need lower level function for power management</span></div><div class="line"><a name="l00042"></a><span class="lineno"> 42</span> </div><div class="line"><a name="l00043"></a><span class="lineno"><a class="line" href="a00881.html#a75f40af5caf43ce58b7a18015c210e4a"> 43</a></span> <a class="code" href="a03819.html">registerDeviceInfo_t</a> <a class="code" href="a00881.html#a75f40af5caf43ce58b7a18015c210e4a">i2cBusInfo</a> = {</div><div class="line"><a name="l00044"></a><span class="lineno"> 44</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="l00045"></a><span class="lineno"> 45</span>  .functionParam = NULL,</div><div class="line"><a name="l00046"></a><span class="lineno"> 46</span>  .idleFunction = NULL</div><div class="line"><a name="l00047"></a><span class="lineno"> 47</span> };</div><div class="line"><a name="l00048"></a><span class="lineno"> 48</span> </div><div class="line"><a name="l00049"></a><span class="lineno"> 49</span> <span class="comment">// Global data structures</span></div><div class="line"><a name="l00050"></a><span class="lineno"><a class="line" href="a00881.html#afa81c629d378fe700f351a1bce411ad5"> 50</a></span> <a class="code" href="a04047.html">SensorFusionGlobals</a> <a class="code" href="a00881.html#afa81c629d378fe700f351a1bce411ad5">sfg</a>; <span class="comment">///< This is the primary sensor fusion data structure</span></div><div class="line"><a name="l00051"></a><span class="lineno"><a class="line" href="a00881.html#a641b380af068b4004bc5b9dff5e5a6db"> 51</a></span> <span class="comment"></span><a class="code" href="a03967.html">ControlSubsystem</a> <a class="code" href="a00881.html#a641b380af068b4004bc5b9dff5e5a6db">controlSubsystem</a>; <span class="comment">///< used for serial communications</span></div><div class="line"><a name="l00052"></a><span class="lineno"><a class="line" href="a00881.html#a875f795e25aaef1b828061bbfae4764a"> 52</a></span> <span class="comment"></span><a class="code" href="a04051.html">StatusSubsystem</a> <a class="code" href="a00881.html#a875f795e25aaef1b828061bbfae4764a">statusSubsystem</a>; <span class="comment">///< provides visual (usually LED) status indicator</span></div><div class="line"><a name="l00053"></a><span class="lineno"><a class="line" href="a00881.html#a84786a835b4ead54496764473c994db5"> 53</a></span> <span class="comment"></span><span class="keyword">struct </span><a class="code" href="a03991.html">PhysicalSensor</a> <a class="code" href="a00881.html#a84786a835b4ead54496764473c994db5">sensors</a>[3]; <span class="comment">///< This implementation uses three physical sensors</span></div><div class="line"><a name="l00054"></a><span class="lineno"><a class="line" href="a00881.html#a729bc9c4006e68fecea92342c3c3700b"> 54</a></span> <span class="comment"></span>EventGroupHandle_t <a class="code" href="a00881.html#a729bc9c4006e68fecea92342c3c3700b">event_group</a> = NULL;</div><div class="line"><a name="l00055"></a><span class="lineno"><a class="line" href="a00881.html#a97fd430f36f8b065226e2bff9bad1de5"> 55</a></span> <span class="keywordtype">void</span> <a class="code" href="a00881.html#a97fd430f36f8b065226e2bff9bad1de5">vApplicationIdleHook</a>( <span class="keywordtype">void</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>  <span class="comment">// MCU low power modes are not debugged at this point in time</span></div><div class="line"><a name="l00058"></a><span class="lineno"> 58</span>  <span class="comment">//volatile smc_power_state_t state;</span></div><div class="line"><a name="l00059"></a><span class="lineno"> 59</span>  <span class="comment">//SMC_SetPowerModeStop(SMC, kSMC_PartialStop );</span></div><div class="line"><a name="l00060"></a><span class="lineno"> 60</span>  <span class="comment">//state = SMC_GetPowerModeState(SMC);</span></div><div class="line"><a name="l00061"></a><span class="lineno"> 61</span>  <span class="comment">//asm("wfi");</span></div><div class="line"><a name="l00062"></a><span class="lineno"> 62</span> }</div><div class="line"><a name="l00063"></a><span class="lineno"><a class="line" href="a00881.html#a9ca051aa77e17583aa5a85d5de5c199a"> 63</a></span> <span class="keywordtype">void</span> <a class="code" href="a00881.html#a9ca051aa77e17583aa5a85d5de5c199a">vApplicationTickHook</a>( <span class="keywordtype">void</span> )</div><div class="line"><a name="l00064"></a><span class="lineno"> 64</span> {</div><div class="line"><a name="l00065"></a><span class="lineno"> 65</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="l00066"></a><span class="lineno"> 66</span> }</div><div class="line"><a name="l00067"></a><span class="lineno"> 67</span> </div><div class="line"><a name="l00068"></a><span class="lineno"> 68</span> <span class="keyword">static</span> <span class="keywordtype">void</span> read_task(<span class="keywordtype">void</span> *pvParameters);</div><div class="line"><a name="l00069"></a><span class="lineno"> 69</span> <span class="keyword">static</span> <span class="keywordtype">void</span> fusion_task(<span class="keywordtype">void</span> *pvParameters);</div><div class="line"><a name="l00070"></a><span class="lineno"> 70</span> <span class="keywordtype">bool</span> <a class="code" href="a00881.html#a9bc3ff19e01b5212420dbe5bd004b40a">motionCheck</a>( <span class="keywordtype">float</span> sample[3],</div><div class="line"><a name="l00071"></a><span class="lineno"> 71</span>  <span class="keywordtype">float</span> baseline[3],</div><div class="line"><a name="l00072"></a><span class="lineno"> 72</span>  <span class="keywordtype">float</span> tolerance,</div><div class="line"><a name="l00073"></a><span class="lineno"> 73</span>  uint32_t winLength,</div><div class="line"><a name="l00074"></a><span class="lineno"> 74</span>  uint32_t *count); <span class="comment">// defined in motionCheck.c</span><span class="comment"></span></div><div class="line"><a name="l00075"></a><span class="lineno"> 75</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="l00076"></a><span class="lineno"><a class="line" href="a00881.html#a840291bc02cba5474a4cb46a9b9566fe"> 76</a></span> <span class="comment"></span><span class="keywordtype">int</span> <a class="code" href="a00881.html#a840291bc02cba5474a4cb46a9b9566fe">main</a>(<span class="keywordtype">void</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>  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="l00079"></a><span class="lineno"> 79</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="l00080"></a><span class="lineno"> 80</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="l00081"></a><span class="lineno"> 81</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="l00082"></a><span class="lineno"> 82</span> </div><div class="line"><a name="l00083"></a><span class="lineno"> 83</span>  I2Cdrv->Initialize(<a class="code" href="a04343.html#a60ac2e3bb32ae33e2fd542f607a58ac4">I2C_S_SIGNAL_EVENT</a>); <span class="comment">// Initialize the KSDK driver for the I2C port</span></div><div class="line"><a name="l00084"></a><span class="lineno"> 84</span>  I2Cdrv->PowerControl(ARM_POWER_FULL); <span class="comment">// Set the I2C Power mode.</span></div><div class="line"><a name="l00085"></a><span class="lineno"> 85</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="l00086"></a><span class="lineno"> 86</span> </div><div class="line"><a name="l00087"></a><span class="lineno"> 87</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="l00088"></a><span class="lineno"> 88</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="l00089"></a><span class="lineno"> 89</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="l00090"></a><span class="lineno"> 90</span>  <span class="comment">// "install" the sensors we will be using</span></div><div class="line"><a name="l00091"></a><span class="lineno"> 91</span>  sfg.<a class="code" href="a04047.html#a22ddc1cea4daa0d93be0fe7d48365dbb">installSensor</a>(&sfg, &<a class="code" href="a00881.html#a84786a835b4ead54496764473c994db5">sensors</a>[0], <a class="code" href="a00569.html#a1cf25792e81104804c33e88ac78b503c">FXLS8952C_I2C_ADDR</a>, 1, (<span class="keywordtype">void</span>*) I2Cdrv, &i2cBusInfo, <a class="code" href="a00842.html#ae47d028795d19902358ad6644c2995f7">FXLS8952_Init</a>, <a class="code" href="a00842.html#aed1eb4f64f11c00b221a14839b996d1e">FXLS8952_Read</a>);</div><div class="line"><a name="l00092"></a><span class="lineno"> 92</span>  sfg.<a class="code" href="a04047.html#a22ddc1cea4daa0d93be0fe7d48365dbb">installSensor</a>(&sfg, &<a class="code" href="a00881.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="l00093"></a><span class="lineno"> 93</span>  sfg.<a class="code" href="a04047.html#a22ddc1cea4daa0d93be0fe7d48365dbb">installSensor</a>(&sfg, &<a class="code" href="a00881.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="l00094"></a><span class="lineno"> 94</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="l00095"></a><span class="lineno"> 95</span> </div><div class="line"><a name="l00096"></a><span class="lineno"> 96</span>  <a class="code" href="a00881.html#a729bc9c4006e68fecea92342c3c3700b">event_group</a> = xEventGroupCreate();</div><div class="line"><a name="l00097"></a><span class="lineno"> 97</span>  xTaskCreate(read_task, <span class="stringliteral">"READ"</span>, configMINIMAL_STACK_SIZE, NULL, tskIDLE_PRIORITY + 2, NULL);</div><div class="line"><a name="l00098"></a><span class="lineno"> 98</span>  xTaskCreate(fusion_task, <span class="stringliteral">"FUSION"</span>, configMINIMAL_STACK_SIZE, NULL, tskIDLE_PRIORITY + 1, NULL);</div><div class="line"><a name="l00099"></a><span class="lineno"> 99</span> </div><div class="line"><a name="l00100"></a><span class="lineno"> 100</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="l00101"></a><span class="lineno"> 101</span>  vTaskStartScheduler(); <span class="comment">// Start the RTOS scheduler</span></div><div class="line"><a name="l00102"></a><span class="lineno"> 102</span>  sfg.<a class="code" href="a04047.html#aa22f9fd7adaca53616ef6bfb6cb051b4">setStatus</a>(&sfg, <a class="code" href="a00914.html#a69ee883e1c22b117df163c0bd83f66dda2142c7e506bbaf9dba4175fee014862f">HARD_FAULT</a>); <span class="comment">// If we got this far, FreeRTOS does not have enough memory allocated</span></div><div class="line"><a name="l00103"></a><span class="lineno"> 103</span>  <span class="keywordflow">for</span> (;;) ;</div><div class="line"><a name="l00104"></a><span class="lineno"> 104</span> }</div><div class="line"><a name="l00105"></a><span class="lineno"> 105</span> </div><div class="line"><a name="l00106"></a><span class="lineno"> 106</span> <span class="keyword">static</span> <span class="keywordtype">void</span> read_task(<span class="keywordtype">void</span> *pvParameters)</div><div class="line"><a name="l00107"></a><span class="lineno"> 107</span> {</div><div class="line"><a name="l00108"></a><span class="lineno"> 108</span>  uint16_t i=0; <span class="comment">// general counter variable</span></div><div class="line"><a name="l00109"></a><span class="lineno"> 109</span>  portTickType lastWakeTime;</div><div class="line"><a name="l00110"></a><span class="lineno"> 110</span>  <span class="keyword">const</span> portTickType frequency = 1; <span class="comment">// tick counter runs at the read rate</span></div><div class="line"><a name="l00111"></a><span class="lineno"> 111</span>  lastWakeTime = xTaskGetTickCount();</div><div class="line"><a name="l00112"></a><span class="lineno"> 112</span>  <span class="keywordflow">while</span> (1)</div><div class="line"><a name="l00113"></a><span class="lineno"> 113</span>  {</div><div class="line"><a name="l00114"></a><span class="lineno"> 114</span>  <span class="keywordflow">for</span> (i=1; i<=<a class="code" href="a00917.html#aeb731cd530cb2f5c3d2bc08e2a9c358a">OVERSAMPLE_RATE</a>; i++) {</div><div class="line"><a name="l00115"></a><span class="lineno"> 115</span>  vTaskDelayUntil(&lastWakeTime, frequency);</div><div class="line"><a name="l00116"></a><span class="lineno"> 116</span>  sfg.<a class="code" href="a04047.html#a15e66ae3ad63ad091317ad0aefa53ce7">readSensors</a>(&sfg, i); <span class="comment">// Reads sensors, applies HAL and does averaging (if applicable)</span></div><div class="line"><a name="l00117"></a><span class="lineno"> 117</span>  }</div><div class="line"><a name="l00118"></a><span class="lineno"> 118</span>  xEventGroupSetBits(<a class="code" href="a00881.html#a729bc9c4006e68fecea92342c3c3700b">event_group</a>, <a class="code" href="a00914.html#a8a03ef52aa4926d1d75cb647ac768622">B0</a>);</div><div class="line"><a name="l00119"></a><span class="lineno"> 119</span>  }</div><div class="line"><a name="l00120"></a><span class="lineno"> 120</span> }</div><div class="line"><a name="l00121"></a><span class="lineno"> 121</span> </div><div class="line"><a name="l00122"></a><span class="lineno"> 122</span> <span class="keyword">static</span> <span class="keywordtype">void</span> fusion_task(<span class="keywordtype">void</span> *pvParameters)</div><div class="line"><a name="l00123"></a><span class="lineno"> 123</span> {</div><div class="line"><a name="l00124"></a><span class="lineno"> 124</span>  uint16_t i=0; <span class="comment">// general counter variable</span></div><div class="line"><a name="l00125"></a><span class="lineno"> 125</span>  <span class="keywordtype">float</span> motion_baseline[3] = {0.0, 0.0, 0.0};</div><div class="line"><a name="l00126"></a><span class="lineno"> 126</span>  <span class="keywordtype">bool</span> stationary;</div><div class="line"><a name="l00127"></a><span class="lineno"> 127</span>  <span class="keyword">static</span> <span class="keywordtype">bool</span> lastStationary;</div><div class="line"><a name="l00128"></a><span class="lineno"> 128</span>  uint32_t stationaryCount = 0;</div><div class="line"><a name="l00129"></a><span class="lineno"> 129</span>  <span class="keywordflow">while</span> (1)</div><div class="line"><a name="l00130"></a><span class="lineno"> 130</span>  {</div><div class="line"><a name="l00131"></a><span class="lineno"> 131</span>  xEventGroupWaitBits(<a class="code" href="a00881.html#a729bc9c4006e68fecea92342c3c3700b">event_group</a>, <span class="comment">/* The event group handle. */</span></div><div class="line"><a name="l00132"></a><span class="lineno"> 132</span>  <a class="code" href="a00914.html#a8a03ef52aa4926d1d75cb647ac768622">B0</a>, <span class="comment">/* The bit pattern the event group is waiting for. */</span></div><div class="line"><a name="l00133"></a><span class="lineno"> 133</span>  pdTRUE, <span class="comment">/* BIT_0 and BIT_4 will be cleared automatically. */</span></div><div class="line"><a name="l00134"></a><span class="lineno"> 134</span>  pdFALSE, <span class="comment">/* Don't wait for both bits, either bit unblock task. */</span></div><div class="line"><a name="l00135"></a><span class="lineno"> 135</span>  portMAX_DELAY); <span class="comment">/* Block indefinitely to wait for the condition to be met. */</span></div><div class="line"><a name="l00136"></a><span class="lineno"> 136</span> </div><div class="line"><a name="l00137"></a><span class="lineno"> 137</span>  <span class="comment">// sfg.runFusion(&sfg); // Run the actual fusion algorithms</span></div><div class="line"><a name="l00138"></a><span class="lineno"> 138</span>  <span class="comment">// Rather than call runFusion directly, this example invokes the lower level</span></div><div class="line"><a name="l00139"></a><span class="lineno"> 139</span>  <span class="comment">// calls here. This allows us to check to see if the board is stationary,</span></div><div class="line"><a name="l00140"></a><span class="lineno"> 140</span>  <span class="comment">// and if so, transition to a lower power state.</span></div><div class="line"><a name="l00141"></a><span class="lineno"> 141</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="l00142"></a><span class="lineno"> 142</span>  stationary = <a class="code" href="a00881.html#a9bc3ff19e01b5212420dbe5bd004b40a">motionCheck</a>(</div><div class="line"><a name="l00143"></a><span class="lineno"> 143</span>  sfg.Accel.fGc, <span class="comment">// calibrated accelerometer reading</span></div><div class="line"><a name="l00144"></a><span class="lineno"> 144</span>  motion_baseline, <span class="comment">// baseline to check new values against</span></div><div class="line"><a name="l00145"></a><span class="lineno"> 145</span>  0.01, <span class="comment">// changes less than this are ignored</span></div><div class="line"><a name="l00146"></a><span class="lineno"> 146</span>  120, <span class="comment">// three seconds at 40Hz rate</span></div><div class="line"><a name="l00147"></a><span class="lineno"> 147</span>  &stationaryCount);</div><div class="line"><a name="l00148"></a><span class="lineno"> 148</span>  <span class="keywordflow">if</span> (stationary) {</div><div class="line"><a name="l00149"></a><span class="lineno"> 149</span>  <span class="keywordflow">if</span> (!lastStationary) { <span class="comment">// suspend some operations</span></div><div class="line"><a name="l00150"></a><span class="lineno"> 150</span>  <a class="code" href="a00842.html#ab2b8fae18f293a3068dc83760454401d">FXAS21002_Idle</a>(&(<a class="code" href="a00881.html#a84786a835b4ead54496764473c994db5">sensors</a>[1]), &sfg);</div><div class="line"><a name="l00151"></a><span class="lineno"> 151</span>  <a class="code" href="a00821.html#a8b3e60cfe3482a21af1efd34d3e31cc2">MAG3110_Idle</a>(&(<a class="code" href="a00881.html#a84786a835b4ead54496764473c994db5">sensors</a>[2]), &sfg);</div><div class="line"><a name="l00152"></a><span class="lineno"> 152</span>  }</div><div class="line"><a name="l00153"></a><span class="lineno"> 153</span>  sfg.<a class="code" href="a04047.html#a12c0ab8f62e2281359a41bb5d3d64999">clearFIFOs</a>(&sfg);</div><div class="line"><a name="l00154"></a><span class="lineno"> 154</span>  } <span class="keywordflow">else</span> {</div><div class="line"><a name="l00155"></a><span class="lineno"> 155</span>  <span class="keywordflow">if</span> (lastStationary) { <span class="comment">// restart operations</span></div><div class="line"><a name="l00156"></a><span class="lineno"> 156</span>  <a class="code" href="a00842.html#a81c5b987e709b3991bc7c1bc1e659c1f">FXAS21002_Init</a>(&(<a class="code" href="a00881.html#a84786a835b4ead54496764473c994db5">sensors</a>[1]), &sfg);</div><div class="line"><a name="l00157"></a><span class="lineno"> 157</span>  <a class="code" href="a00821.html#a20b118514f14ce008825433f72527ecd">MAG3110_Init</a>(&(<a class="code" href="a00881.html#a84786a835b4ead54496764473c994db5">sensors</a>[2]), &sfg);</div><div class="line"><a name="l00158"></a><span class="lineno"> 158</span>  }</div><div class="line"><a name="l00159"></a><span class="lineno"> 159</span>  <span class="comment">// fuse the sensor data</span></div><div class="line"><a name="l00160"></a><span class="lineno"> 160</span>  sfg.<a class="code" href="a04047.html#afc72aca0c3842cde4aa4bb0dcdfb4237">runFusion</a>(&sfg);</div><div class="line"><a name="l00161"></a><span class="lineno"> 161</span>  }</div><div class="line"><a name="l00162"></a><span class="lineno"> 162</span> </div><div class="line"><a name="l00163"></a><span class="lineno"> 163</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="l00164"></a><span class="lineno"> 164</span> </div><div class="line"><a name="l00165"></a><span class="lineno"> 165</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="l00166"></a><span class="lineno"> 166</span>  i=i+1;</div><div class="line"><a name="l00167"></a><span class="lineno"> 167</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="l00168"></a><span class="lineno"> 168</span>  i=0; <span class="comment">// should cycle at least four times for that to operate correctly.</span></div><div class="line"><a name="l00169"></a><span class="lineno"> 169</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="l00170"></a><span class="lineno"> 170</span>  }</div><div class="line"><a name="l00171"></a><span class="lineno"> 171</span>  <span class="keywordflow">if</span> (stationary) {</div><div class="line"><a name="l00172"></a><span class="lineno"> 172</span>  sfg.<a class="code" href="a04047.html#af6a232c7866a9093f9a5cb51372d4f97">queueStatus</a>(&sfg, <a class="code" href="a00914.html#a69ee883e1c22b117df163c0bd83f66dda3443484ca1aa8edccfe37956838d8737">LOWPOWER</a>); <span class="comment">// assume LOWPOWER status for next pass through the loop</span></div><div class="line"><a name="l00173"></a><span class="lineno"> 173</span>  } <span class="keywordflow">else</span> {</div><div class="line"><a name="l00174"></a><span class="lineno"> 174</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="l00175"></a><span class="lineno"> 175</span>  }</div><div class="line"><a name="l00176"></a><span class="lineno"> 176</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="l00177"></a><span class="lineno"> 177</span>  lastStationary = stationary;</div><div class="line"><a name="l00178"></a><span class="lineno"> 178</span>  }</div><div class="line"><a name="l00179"></a><span class="lineno"> 179</span> }</div><div class="line"><a name="l00180"></a><span class="lineno"> 180</span> <span class="comment"></span></div><div class="line"><a name="l00181"></a><span class="lineno"> 181</span> <span class="comment">/// \endcode</span></div><div class="ttc" id="a00881_html_a641b380af068b4004bc5b9dff5e5a6db"><div class="ttname"><a href="a00881.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="a00881_source.html#l00051">main_freertos_agm02_power_cycling.c:51</a></div></div> 52<div class="ttc" id="a00914_html_a8a03ef52aa4926d1d75cb647ac768622"><div class="ttname"><a href="a00914.html#a8a03ef52aa4926d1d75cb647ac768622">B0</a></div><div class="ttdeci">#define B0</div><div class="ttdef"><b>Definition:</b> <a href="a00914_source.html#l00072">sensor_fusion.h:72</a></div></div> 53<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> 54<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> 55<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> 56<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> 57<div class="ttc" id="a00917_html_aeb731cd530cb2f5c3d2bc08e2a9c358a"><div class="ttname"><a href="a00917.html#aeb731cd530cb2f5c3d2bc08e2a9c358a">OVERSAMPLE_RATE</a></div><div class="ttdeci">#define OVERSAMPLE_RATE</div><div class="ttdef"><b>Definition:</b> <a href="a00917_source.html#l00070">standard_build.h:70</a></div></div> 58<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> 59<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> 60<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> 61<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> 62<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> 63<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> 64<div class="ttc" id="a00842_html_aed1eb4f64f11c00b221a14839b996d1e"><div class="ttname"><a href="a00842.html#aed1eb4f64f11c00b221a14839b996d1e">FXLS8952_Read</a></div><div class="ttdeci">int8_t FXLS8952_Read(struct PhysicalSensor *sensor, SensorFusionGlobals *sfg)</div></div> 65<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> 66<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> 67<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> 68<div class="ttc" id="a00881_html_a840291bc02cba5474a4cb46a9b9566fe"><div class="ttname"><a href="a00881.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="a00881_source.html#l00076">main_freertos_agm02_power_cycling.c:76</a></div></div> 69<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> 70<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> 71<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> 72<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> 73<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> 74<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> 75<div class="ttc" id="a00881_html_a84786a835b4ead54496764473c994db5"><div class="ttname"><a href="a00881.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="a00881_source.html#l00053">main_freertos_agm02_power_cycling.c:53</a></div></div> 76<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> 77<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> 78<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> 79<div class="ttc" id="a00881_html_a875f795e25aaef1b828061bbfae4764a"><div class="ttname"><a href="a00881.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="a00881_source.html#l00052">main_freertos_agm02_power_cycling.c:52</a></div></div> 80<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> 81<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> 82<div class="ttc" id="a00914_html_a69ee883e1c22b117df163c0bd83f66dda2142c7e506bbaf9dba4175fee014862f"><div class="ttname"><a href="a00914.html#a69ee883e1c22b117df163c0bd83f66dda2142c7e506bbaf9dba4175fee014862f">HARD_FAULT</a></div><div class="ttdoc">Non-recoverable FAULT = something went very wrong. </div><div class="ttdef"><b>Definition:</b> <a href="a00914_source.html#l00111">sensor_fusion.h:111</a></div></div> 83<div class="ttc" id="a00881_html_a75f40af5caf43ce58b7a18015c210e4a"><div class="ttname"><a href="a00881.html#a75f40af5caf43ce58b7a18015c210e4a">i2cBusInfo</a></div><div class="ttdeci">registerDeviceInfo_t i2cBusInfo</div><div class="ttdef"><b>Definition:</b> <a href="a00881_source.html#l00043">main_freertos_agm02_power_cycling.c:43</a></div></div> 84<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> 85<div class="ttc" id="a00881_html_afa81c629d378fe700f351a1bce411ad5"><div class="ttname"><a href="a00881.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="a00881_source.html#l00050">main_freertos_agm02_power_cycling.c:50</a></div></div> 86<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> 87<div class="ttc" id="a00842_html_ab2b8fae18f293a3068dc83760454401d"><div class="ttname"><a href="a00842.html#ab2b8fae18f293a3068dc83760454401d">FXAS21002_Idle</a></div><div class="ttdeci">int8_t FXAS21002_Idle(struct PhysicalSensor *sensor, SensorFusionGlobals *sfg)</div></div> 88<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> 89<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> 90<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> 91<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> 92<div class="ttc" id="a00881_html_a9bc3ff19e01b5212420dbe5bd004b40a"><div class="ttname"><a href="a00881.html#a9bc3ff19e01b5212420dbe5bd004b40a">motionCheck</a></div><div class="ttdeci">bool motionCheck(float sample[3], float baseline[3], float tolerance, uint32_t winLength, uint32_t *count)</div><div class="ttdef"><b>Definition:</b> <a href="a00893_source.html#l00023">motionCheck.c:23</a></div></div> 93<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> 94<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> 95<div class="ttc" id="a00842_html_ae47d028795d19902358ad6644c2995f7"><div class="ttname"><a href="a00842.html#ae47d028795d19902358ad6644c2995f7">FXLS8952_Init</a></div><div class="ttdeci">int8_t FXLS8952_Init(struct PhysicalSensor *sensor, SensorFusionGlobals *sfg)</div></div> 96<div class="ttc" id="a00881_html_a729bc9c4006e68fecea92342c3c3700b"><div class="ttname"><a href="a00881.html#a729bc9c4006e68fecea92342c3c3700b">event_group</a></div><div class="ttdeci">EventGroupHandle_t event_group</div><div class="ttdef"><b>Definition:</b> <a href="a00881_source.html#l00054">main_freertos_agm02_power_cycling.c:54</a></div></div> 97<div class="ttc" id="a00881_html_a9ca051aa77e17583aa5a85d5de5c199a"><div class="ttname"><a href="a00881.html#a9ca051aa77e17583aa5a85d5de5c199a">vApplicationTickHook</a></div><div class="ttdeci">void vApplicationTickHook(void)</div><div class="ttdef"><b>Definition:</b> <a href="a00881_source.html#l00063">main_freertos_agm02_power_cycling.c:63</a></div></div> 98<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> 99<div class="ttc" id="a00914_html_a69ee883e1c22b117df163c0bd83f66dda3443484ca1aa8edccfe37956838d8737"><div class="ttname"><a href="a00914.html#a69ee883e1c22b117df163c0bd83f66dda3443484ca1aa8edccfe37956838d8737">LOWPOWER</a></div><div class="ttdoc">Running in reduced power mode. </div><div class="ttdef"><b>Definition:</b> <a href="a00914_source.html#l00107">sensor_fusion.h:107</a></div></div> 100<div class="ttc" id="a00881_html_a97fd430f36f8b065226e2bff9bad1de5"><div class="ttname"><a href="a00881.html#a97fd430f36f8b065226e2bff9bad1de5">vApplicationIdleHook</a></div><div class="ttdeci">void vApplicationIdleHook(void)</div><div class="ttdef"><b>Definition:</b> <a href="a00881_source.html#l00055">main_freertos_agm02_power_cycling.c:55</a></div></div> 101<div class="ttc" id="a04047_html_a12c0ab8f62e2281359a41bb5d3d64999"><div class="ttname"><a href="a04047.html#a12c0ab8f62e2281359a41bb5d3d64999">SensorFusionGlobals::clearFIFOs</a></div><div class="ttdeci">clearFIFOs_t * clearFIFOs</div><div class="ttdoc">clear sensor FIFOs </div><div class="ttdef"><b>Definition:</b> <a href="a00914_source.html#l00530">sensor_fusion.h:530</a></div></div> 102<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> 103<div class="ttc" id="a00569_html_a1cf25792e81104804c33e88ac78b503c"><div class="ttname"><a href="a00569.html#a1cf25792e81104804c33e88ac78b503c">FXLS8952C_I2C_ADDR</a></div><div class="ttdeci">#define FXLS8952C_I2C_ADDR</div><div class="ttdef"><b>Definition:</b> <a href="a00569_source.html#l00025">frdm_stbc_agm02_shield.h:25</a></div></div> 104<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> 105<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> 106<div class="ttc" id="a00821_html_a8b3e60cfe3482a21af1efd34d3e31cc2"><div class="ttname"><a href="a00821.html#a8b3e60cfe3482a21af1efd34d3e31cc2">MAG3110_Idle</a></div><div class="ttdeci">int8_t MAG3110_Idle(struct PhysicalSensor *sensor, SensorFusionGlobals *sfg)</div><div class="ttdef"><b>Definition:</b> <a href="a00821_source.html#l00147">driver_MAG3110.c:147</a></div></div> 107<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> 108<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> 109<div class="ttc" id="a00848_html"><div class="ttname"><a href="a00848.html">fusion.h</a></div><div class="ttdoc">Lower level sensor fusion interface. </div></div> 110<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> 111<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> 112<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> 113</div><!-- fragment --></div><!-- contents --> 114 115<hr class="footer"/><address class="footer"><small> 116© Copyright 2016-2022 NXP. All Rights Reserved. SPDX-License-Identifier: BSD-3-Clause 117</small></address> 118</body> 119</html> 120