ISSDK  1.8
IoT Sensing Software Development Kit
Functions | Variables
main_freertos_agm02_power_cycling.c File Reference

FreeRTOS (two task) implementation of sensor fusion on FRDM-K64F/FRDM-FXS-AGM02 with smart power-cycling support. More...

#include "FreeRTOS.h"
#include "task.h"
#include "queue.h"
#include "timers.h"
#include "event_groups.h"
#include "fsl_debug_console.h"
#include "FSL_SMC.H"
#include "board.h"
#include "pin_mux.h"
#include "clock_config.h"
#include "fsl_port.h"
#include "fsl_i2c.h"
#include "register_io_i2c.h"
#include "fsl_i2c_cmsis.h"
#include "fsl_dspi_cmsis.h"
#include "sensor_fusion.h"
#include "control.h"
#include "status.h"
#include "drivers.h"
#include "fusion.h"
Include dependency graph for main_freertos_agm02_power_cycling.c:

Go to the source code of this file.

Functions

void vApplicationIdleHook (void)
 
void vApplicationTickHook (void)
 
bool motionCheck (float sample[3], float baseline[3], float tolerance, uint32_t winLength, uint32_t *count)
 
int main (void)
 This is a FreeRTOS (dual task) implementation of the NXP sensor fusion demo build. More...
 

Variables

registerDeviceInfo_t i2cBusInfo
 
SensorFusionGlobals sfg
 This is the primary sensor fusion data structure. More...
 
ControlSubsystem controlSubsystem
 used for serial communications More...
 
StatusSubsystem statusSubsystem
 provides visual (usually LED) status indicator More...
 
struct PhysicalSensor sensors [3]
 This implementation uses three physical sensors. More...
 
EventGroupHandle_t event_group = NULL
 

Detailed Description

FreeRTOS (two task) implementation of sensor fusion on FRDM-K64F/FRDM-FXS-AGM02 with smart power-cycling support.

This file shows one recommended way to incorporate sensor fusion capabilities into a FreeRTOS project AND adds intelligent power down of sensors when the DUT is stationary.

Definition in file main_freertos_agm02_power_cycling.c.

Function Documentation

◆ main()

int main ( void  )

◆ motionCheck()

bool motionCheck ( float  sample[3],
float  baseline[3],
float  tolerance,
uint32_t  winLength,
uint32_t *  count 
)

The motionCheck() function is not a sensor fusion function. It is a function that simply monitors an accelerometer or magnetometer tri-axial sensor output, returning Boolean true if the sensor appears to be stationary, and false otherwise. This function would normally be called from your fusion_tasks in your main().

Parameters
sampleprocessed triaxial sensor sample (accel or mag)
baselineprevious value to compare to
tolerancehow much tolerance you can stand
winLengthhow many samples need to be stable to assert "noMotion"
counthow many samples so far we've been not moving

Definition at line 23 of file motionCheck.c.

References CHX, CHY, and CHZ.

◆ vApplicationIdleHook()

void vApplicationIdleHook ( void  )

Definition at line 55 of file main_freertos_agm02_power_cycling.c.

◆ vApplicationTickHook()

void vApplicationTickHook ( void  )

Definition at line 63 of file main_freertos_agm02_power_cycling.c.

References NORMAL, and SensorFusionGlobals::queueStatus.

Variable Documentation

◆ controlSubsystem

ControlSubsystem controlSubsystem

used for serial communications

Definition at line 51 of file main_freertos_agm02_power_cycling.c.

◆ event_group

EventGroupHandle_t event_group = NULL

Definition at line 54 of file main_freertos_agm02_power_cycling.c.

Referenced by main().

◆ i2cBusInfo

Initial value:
= {
.deviceInstance = I2C_S_DEVICE_INDEX,
.functionParam = NULL,
.idleFunction = NULL
}
#define I2C_S_DEVICE_INDEX
Definition: issdk_hal.h:35

Definition at line 43 of file main_freertos_agm02_power_cycling.c.

◆ sensors

struct PhysicalSensor sensors[3]

This implementation uses three physical sensors.

Definition at line 53 of file main_freertos_agm02_power_cycling.c.

Referenced by main().

◆ sfg

This is the primary sensor fusion data structure.

Definition at line 50 of file main_freertos_agm02_power_cycling.c.

◆ statusSubsystem

StatusSubsystem statusSubsystem

provides visual (usually LED) status indicator

Definition at line 52 of file main_freertos_agm02_power_cycling.c.