Atmel AVR4016
field contains a sensor_data_t structure, which holds the actual sensor data
obtained during the event.
An event handler can be defined to be called only when a single, specific event
occurs, or a common handler can be defined which is called when any one of a set of
events occurs. To determine the actual event which initiated the call to the handler,
examine the event field within the sensor_event_desc_t structure, which will contain
a sensor_event_t type code indicating the event.
NOTE
Your event handler routine will be called as part of the interrupt processing,
asynchronously from the normal execution of your application. Because the handler
executes at interrupt level, other interrupts will be masked (prevented from being
serviced) while your handler is running. Therefore, you should structure your handler
and application to require a minimum of processing in the handler itself, and perform
subsequent work in your regular application code. This can be done by having the
handler set flags or state variables, which are checked during the regular cyclic
execution of your main program, to initiate additional actions to be taken.
8.3 Enabling and disabling events
After an event has been added, it can be dynamically enabled by calling the
sensor_enable_event()
function, or it can be disabled by calling the
sensor_disable_event() function. The event handler routine remains defined even
if the event is disabled, but the sensor device settings are changed so that the event
interrupt will not be generated.
8.4 Events with no handler routine
Normally, you will define a handler routine to be called when a specified sensor event
occurs so that it may process the sensor data or take other special action. However, it
is possible to add and enable a sensor event without providing your own handler
routine. This might be done when the simple act of the sensor generating an event
interrupt provides the required effect. For example, if the microcontroller is placed into
a low-power sleep mode, a motion detection interrupt from an accelerometer might be
used to wake up the system, with no further processing required.
To set up event handling without providing your own handler, call the
sensor_add_event() function as usual, but set the handler field to 0 (NULL).
8.5 Event types
There are many types of sensor events that might be generated, depending on the
specific sensor device. See the device driver descriptions in Chapter 9 , page 27 for
more information on the events that can be generated by each individual sensor.
Possible event types include:
? SENSOR_EVENT_NEW_DATA – new sensor data are available
? SENSOR_EVENT_MOTION – device motion has been detected, often used with
a programmable threshold for motion detection
? SENSOR_EVENT_LOW_G – low gravity (that is, free fall) detected
? SENSOR_EVENT_HIGH_G – high gravity (acceleration) detected
? SENSOR_EVENT_TAP – physical tap(s) on device detected
? SENSOR_EVENT_TILT – device tilt detected
23
8367B-AVR-06/11
相关PDF资料
ATAVRSBIN2 INERTIAL TWO SENSOR BOARD
ATAVRSBLP1 LIGHT AND PROXIMITY SENSOR BOARD
ATAVRSBPR1 BAROMETRIC PRESSURE ONE SNSR BRD
ATQT600 KIT EVAL TOUCH FOR QT600
ATU6-P305T-R CABLE CAT6 FULL-BOX 305M GRAY
ATUP-P305T-R CABLE CAT5E PULL-BOX 305M GRAY
ATUP-V305T-R CABLE CAT5E REEL 305M GRAY
AWG28-05/F-1/300-R CABLE 5 COND MULTI 300' RIBBON
相关代理商/技术参数
ATAVRSBIN2 功能描述:多功能传感器开发工具 9DOF Inertial Sensor Board 2 RoHS:否 制造商:Texas Instruments 工具用于评估:LMP91200 接口类型:SPI 工作电压:1.8 V to 5.5 V 最大工作温度:
ATAVRSBLP1 功能描述:光学传感器开发工具 Ambient Light and Proximity Snsr Brd RoHS:否 制造商:ams 工具用于评估: 接口类型: 最大工作温度:
ATAVRSBPR1 功能描述:压力传感器开发工具 Barometric Pressure Sensor Board 1 RoHS:否 制造商:Freescale Semiconductor 工具用于评估:MPL3115A2 接口类型:USB 最大工作温度:
ATAVRSECURITYX 功能描述:安全/ 验证开发工具 Security Module Kit for Xplain Series RoHS:否 制造商:Digi International 产品:Development Kits 工具用于评估:XEB-AW140 接口类型:SPI, USB 工作电源电压:3.1 V to 3.6 V
ATAVRSMD 功能描述:ADAPTER KIT SMD ICE200 RoHS:否 类别:编程器,开发系统 >> 过时/停产零件编号 系列:- 标准包装:1 系列:- 类型:MCU 适用于相关产品:Freescale MC68HC908LJ/LK(80-QFP ZIF 插口) 所含物品:面板、缆线、软件、数据表和用户手册 其它名称:520-1035
ATAVR-SOAKIT 功能描述:插座和适配器 Standoff Adapter Kit for JTAG debuggers RoHS:否 制造商:Silicon Labs 产品:Adapter 用于:EM35x
ATAVRTEMPSENSORX 功能描述:温度传感器开发工具 Temp Sensor kit for Xplain Series RoHS:否 制造商:Texas Instruments 产品类型:Temperature Sensors and Control ICs 工具用于评估:MSP430G2553 接口类型:USB 工作电源电压: 工作电源电流:
ATAVRTS2080A 功能描述:开发板和工具包 - AVR ATmega88 QTouch QTch kit w/SW librar RoHS:否 制造商:Arduino 产品:Evaluation Boards 工具用于评估:ATMega32U4 核心:AVR 接口类型:I2C, UART, USB 工作电源电压:6 V to 20 V