Atmel Software Framework

common/applications/sensors/lightprox_wake/main.c File Reference

Common Sensor Service Light/Proximity Sensor Wake Event Example.

Copyright (C) 2012-2015 Atmel Corporation. All rights reserved.

#include <stdio.h>
#include <asf.h>
#include <led.h>

Macros

#define ACTIVITY_LED   LED4 /* LED to show awake/operating */
 
#define LIGHT_LED   LED1 /* LED to indicate light sensor interrupt */
 
#define LIGHT_SAMPLE_RATE   (10) /* Light sensor sample rate (Hz) */
 
#define LIGHT_THRESH   (300) /* Light threshold (lux) */
 
#define LIGHT_WAKE   (true) /* If true, use light level to wake up */
 
#define PROX_CURRENT_mA   (50) /* Prox sensor LED current value (mA) */
 
#define PROX_LED   LED0 /* LED to indicate proximity sensor interrupt */
 
#define PROX_SAMPLE_RATE   (10) /* proximity sensor sample rate (Hz) */
 
#define PROX_THRESH   (100) /* Set "near" proximity threshold (counts) */
 
#define PROX_THRESHOLD   (100) /* Manual prox. sensor threshold for "near" */
 
#define PROX_WAKE   (true) /* If true, use near proximity to wake up */
 
#define SCALED_DATA   (true)
 
#define SET_PROX_CURRENT   (true) /* If true, manually set proximity current */
 
#define SET_PROX_THRESHOLD
 
#define USE_PRINTF   (true)
 

Functions

static void light_event (volatile sensor_event_data_t *event_data, volatile void *in)
 
int main (void)
 Inertial sensor demo application entry. More...
 
static void prox_event (volatile sensor_event_data_t *event_data, volatile void *in)
 

Variables

volatile sensor_data_t light_data = { .scaled = SCALED_DATA }
 
sensor_t light_dev
 
bool light_event_occurred = false
 
volatile int16_t prox_channel
 
volatile sensor_data_t prox_data = { .scaled = SCALED_DATA }
 
sensor_t prox_dev
 
bool prox_event_occurred = false
 
static const char *const prox_labels [4]
 Strings to display based on proximity values. More...
 

#define ACTIVITY_LED   LED4 /* LED to show awake/operating */

Referenced by main().

#define LIGHT_LED   LED1 /* LED to indicate light sensor interrupt */

Referenced by light_event().

#define LIGHT_SAMPLE_RATE   (10) /* Light sensor sample rate (Hz) */

Referenced by main().

#define LIGHT_THRESH   (300) /* Light threshold (lux) */

Referenced by main().

#define LIGHT_WAKE   (true) /* If true, use light level to wake up */
#define PROX_CURRENT_mA   (50) /* Prox sensor LED current value (mA) */

Referenced by main().

#define PROX_LED   LED0 /* LED to indicate proximity sensor interrupt */

Referenced by prox_event().

#define PROX_SAMPLE_RATE   (10) /* proximity sensor sample rate (Hz) */

Referenced by main().

#define PROX_THRESH   (100) /* Set "near" proximity threshold (counts) */
#define PROX_THRESHOLD   (100) /* Manual prox. sensor threshold for "near" */

Referenced by main().

#define PROX_WAKE   (true) /* If true, use near proximity to wake up */
#define SCALED_DATA   (true)

Referenced by main().

#define SET_PROX_CURRENT   (true) /* If true, manually set proximity current */
#define SET_PROX_THRESHOLD
Value:
(true) /* If true, manually set proximity
* threshold */
#define USE_PRINTF   (true)

static void light_event ( volatile sensor_event_data_t event_data,
volatile void *  in 
)
static

Light Sensor Event Callback Routine

References sensor_event_data_t::data, light_event_occurred, and LIGHT_LED.

Referenced by main().

int main ( void  )
static void prox_event ( volatile sensor_event_data_t event_data,
volatile void *  in 
)
static

Proximity Sensor Event Callback Routine

References sensor_event_data_t::channel, sensor_event_data_t::data, prox_channel, prox_event_occurred, and PROX_LED.

Referenced by main().

volatile sensor_data_t light_data = { .scaled = SCALED_DATA }
sensor_t light_dev

Referenced by main().

bool light_event_occurred = false

Referenced by light_event(), and main().

volatile int16_t prox_channel

Referenced by main(), and prox_event().

volatile sensor_data_t prox_data = { .scaled = SCALED_DATA }

Referenced by main(), and sfh7770_calibrate().

sensor_t prox_dev

Referenced by main().

bool prox_event_occurred = false

Referenced by main(), and prox_event().

const char* const prox_labels[4]
static
Initial value:
= {
"none ",
"FAR ",
"MEDIUM",
"NEAR "
}

Strings to display based on proximity values.

Referenced by main().