48 #include "event_groups.h" 51 #include "fsl_debug_console.h" 55 #include "clock_config.h" 59 #include "fsl_i2c_cmsis.h" 60 #include "fsl_dspi_cmsis.h" 71 .functionParam = NULL,
94 static void read_task(
void *pvParameters);
95 static void fusion_task(
void *pvParameters);
110 I2Cdrv->PowerControl(ARM_POWER_FULL);
111 I2Cdrv->Control(ARM_I2C_BUS_SPEED, ARM_I2C_BUS_SPEED_FAST);
123 xTaskCreate(read_task,
"READ", configMINIMAL_STACK_SIZE, NULL, tskIDLE_PRIORITY + 2, NULL);
124 xTaskCreate(fusion_task,
"FUSION", configMINIMAL_STACK_SIZE, NULL, tskIDLE_PRIORITY + 1, NULL);
127 vTaskStartScheduler();
132 static void read_task(
void *pvParameters)
135 portTickType lastWakeTime;
136 const portTickType frequency = 1;
137 lastWakeTime = xTaskGetTickCount();
141 vTaskDelayUntil(&lastWakeTime, frequency);
148 static void fusion_task(
void *pvParameters)
151 float motion_baseline[3] = {0.0, 0.0, 0.0};
153 static bool lastStationary;
154 uint32_t stationaryCount = 0;
175 if (!lastStationary) {
181 if (lastStationary) {
203 lastStationary = stationary;
void initSensorFusionGlobals(SensorFusionGlobals *sfg, StatusSubsystem *pStatusSubsystem, ControlSubsystem *pControlSubsystem)
utility function to insert default values in the top level structure
The register_io_i2c.h file declares low-level interface functions for reading and writing sensor regi...
void vApplicationIdleHook(void)
int8_t FXAS21002_Read(struct PhysicalSensor *sensor, SensorFusionGlobals *sfg)
int8_t MAG3110_Idle(struct PhysicalSensor *sensor, SensorFusionGlobals *sfg)
int8_t FXLS8952_Read(struct PhysicalSensor *sensor, SensorFusionGlobals *sfg)
#define BOARD_BootClockRUN
Lower level sensor fusion interface.
int main(void)
This is a FreeRTOS (dual task) implementation of the NXP sensor fusion demo build.
bool motionCheck(float sample[3], float baseline[3], float tolerance, uint32_t winLength, uint32_t *count)
#define FXLS8952C_I2C_ADDR
struct PhysicalSensor sensors[3]
This implementation uses three physical sensors.
void initializeStatusSubsystem(StatusSubsystem *pStatus)
installSensor_t * installSensor
function for installing a new sensor into t
EventGroupHandle_t event_group
void BOARD_InitDebugConsole(void)
SensorFusionGlobals sfg
This is the primary sensor fusion data structure.
updateStatus_t * updateStatus
status=next status
int8_t FXAS21002_Idle(struct PhysicalSensor *sensor, SensorFusionGlobals *sfg)
he ControlSubsystem encapsulates command and data streaming functions.
void vApplicationTickHook(void)
StatusSubsystem() provides an object-like interface for communicating status to the user...
The top level fusion structure.
int8_t MAG3110_Read(struct PhysicalSensor *sensor, SensorFusionGlobals *sfg)
applyPerturbation_t * applyPerturbation
apply step function for testing purposes
int8_t FXAS21002_Init(struct PhysicalSensor *sensor, SensorFusionGlobals *sfg)
initializeFusionEngine_t * initializeFusionEngine
set sensor fusion structures to initial values
setStatus_t * setStatus
change status indicator immediately
The sensor_fusion.h file implements the top level programming interface.
registerDeviceInfo_t i2cBusInfo
Running in reduced power mode.
Provides function prototypes for driver level interfaces.
uint8_t sUARTOutputBuffer[256]
main output buffer defined in control.c
clearFIFOs_t * clearFIFOs
clear sensor FIFOs
#define I2C_S_DEVICE_INDEX
#define FXAS21002_I2C_ADDR
runFusion_t * runFusion
run the fusion routines
ControlSubsystem controlSubsystem
used for serial communications
int8_t initializeControlPort(ControlSubsystem *pComm)
Initialize the control subsystem and all related hardware.
streamData_t * stream
function to create packets for serial stream
Non-recoverable FAULT = something went very wrong.
Application-specific status subsystem.
readSensors_t * readSensors
read all physical sensors
conditionSensorReadings_t * conditionSensorReadings
preprocessing step for sensor fusion
Defines control sub-system.
struct ControlSubsystem * pControlSubsystem
This structure defines the device specific info required by register I/O.
void BOARD_InitPins(void)
Configures pin routing and optionally pin electrical features.
setStatus_t * queueStatus
queue status change for next regular interval
int8_t MAG3110_Init(struct PhysicalSensor *sensor, SensorFusionGlobals *sfg)
An instance of PhysicalSensor structure type should be allocated for each physical sensors (combo dev...
int8_t FXLS8952_Init(struct PhysicalSensor *sensor, SensorFusionGlobals *sfg)
int32_t loopcounter
counter incrementing each iteration of sensor fusion (typically 25Hz)
#define I2C_S_SIGNAL_EVENT
StatusSubsystem statusSubsystem
provides visual (usually LED) status indicator