Common Sensor Service Inertial Sensor Wake Event Example.
Copyright (c) 2011-2018 Microchip Technology Inc. and its subsidiaries.
#include <stdio.h>
#include <asf.h>
#include <led.h>
Macros | |
#define | ACCEL_LED LED1 /* LED to indicate accel interrupt */ |
#define | ACCEL_MOT_THRESH (250) /* Accel any-motion threshold (milli-g) */ |
#define | ACCEL_WAKE (true) /* If true, use accel any-motion to wake up */ |
#define | ACTIVITY_LED LED4 /* LED to show awake/operating */ |
#define | GYRO_LED LED3 /* LED to indicate gyro interrupt */ |
#define | GYRO_RESTART_DELAY (50) /* Gyro restart (after sleep) delay (msec) */ |
#define | GYRO_SAMPLE_RATE (100) /* Gyro sample rate (Hz) */ |
#define | GYRO_SLEEP (false) /* If true, put gyro in sleep mode */ |
#define | GYRO_WAKE (false) /* If true, use gyro new data to wake up */ |
#define | SCALED_DATA (true) |
#define | USE_ACCEL (true) /* If true, init & read accel */ |
#define | USE_GYRO (false) /* If true, init & read gyro */ |
#define | USE_PRINTF (false) |
Functions | |
static void | acceleration_event (volatile sensor_event_data_t *event_data, volatile void *arg) |
int | main (void) |
Inertial sensor demo application entry. More... | |
static void | rotation_event (volatile sensor_event_data_t *event_data, volatile void *arg) |
Variables | |
volatile sensor_data_t | acceleration = { .scaled = SCALED_DATA } |
sensor_t | accelerometer |
sensor_t | gyroscope |
volatile sensor_data_t | rotation = { .scaled = SCALED_DATA } |
#define ACCEL_LED LED1 /* LED to indicate accel interrupt */ |
Referenced by acceleration_event().
#define ACCEL_MOT_THRESH (250) /* Accel any-motion threshold (milli-g) */ |
Referenced by main().
#define ACTIVITY_LED LED4 /* LED to show awake/operating */ |
Referenced by main().
#define GYRO_LED LED3 /* LED to indicate gyro interrupt */ |
Referenced by rotation_event().
#define GYRO_RESTART_DELAY (50) /* Gyro restart (after sleep) delay (msec) */ |
Referenced by main().
#define GYRO_SAMPLE_RATE (100) /* Gyro sample rate (Hz) */ |
Referenced by main().
#define USE_PRINTF (false) |
|
static |
Accelerometer Event Callback Routine
References ACCEL_LED, and sensor_event_data_t::data.
Referenced by main().
int main | ( | void | ) |
Inertial sensor demo application entry.
After initializing the Xplained platform and sensor boards, this application attaches descriptors to the accelerometer and gyroscope devices on an Xplained inertial sensor board. The sensor data, which is formatted and printed via printf() after being read, can be viewed with a serial terminal application on a machine attached to the USB interface on the Xplained board.
References ACCEL_MOT_THRESH, acceleration_event(), ACTIVITY_LED, sensor_data_t::axis, delay_ms, sensor_desc::err, GYRO_RESTART_DELAY, GYRO_SAMPLE_RATE, rotation_event(), SCALED_DATA, sensor_add_event(), sensor_attach(), SENSOR_EVENT_MOTION, SENSOR_EVENT_NEW_DATA, sensor_get_rotation(), sensor_platform_init(), sensor_set_sample_rate(), sensor_set_state(), sensor_set_threshold(), SENSOR_STATE_LOW_POWER, SENSOR_STATE_NORMAL, SENSOR_STATE_SLEEP, SENSOR_THRESHOLD_MOTION, SENSOR_TYPE_ACCELEROMETER, SENSOR_TYPE_GYROSCOPE, sleepmgr_enter_sleep(), sleepmgr_init(), and sleepmgr_lock_mode().
|
static |
Gyroscope Event Callback Routine
References sensor_event_data_t::data, and GYRO_LED.
Referenced by main().
volatile sensor_data_t acceleration = { .scaled = SCALED_DATA } |
sensor_t accelerometer |
sensor_t gyroscope |
volatile sensor_data_t rotation = { .scaled = SCALED_DATA } |