Atmel Software Framework

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

Common Sensor Service Data Visualizer.

Copyright (c) 2011-2015 Atmel Corporation. All rights reserved.

#include <asf.h>
#include <led.h>
#include "data_visualizer.h"

Macros

#define ACCEL_INTERVAL   1 /* Loops per accel meas/xmit */
 
#define ACCEL_STREAM_NUM   1 /* Accelerometer data stream number */
 
#define ALL_LEDS   (LED1 | LED2 | LED3 | LED4)
 
#define COMPASS_INTERVAL   5 /* Loops per compass meas/xmit */
 
#define COMPASS_STREAM_NUM   3 /* Compass/magnetometer data stream number */
 
#define GYRO_INTERVAL   3 /* Loops per gyro meas/xmit */
 
#define GYRO_STREAM_NUM   2 /* Gyroscope data stream number */
 
#define NUM_ACCEL_FIELDS   3 /* Accelerometer data fields in data packet */
 
#define NUM_BLINK_LEDS   (LED_COUNT - 1) /* Don't blink LED0 (shared gpio) */
 
#define NUM_COMPASS_FIELDS   3 /* Compass data fields in data packet */
 
#define NUM_GYRO_FIELDS   3 /* Gyroscope data fields in data packet */
 
#define NUM_TEMP_FIELDS   1 /* Temperature data fields in data packet */
 
#define PROMPT_LED   LED4 /* Blink while waiting for user input */
 
#define SWITCH_PRESSED   gpio_pin_is_low(GPIO_PUSH_BUTTON_0)
 
#define TEMP_INTERVAL   10 /* Loops per temperature meas/xmit */
 
#define TEMP_STREAM_NUM   4 /* Temperature data stream number */
 
#define TIMESTAMP_RES   1000000 /* Timestamp resolution (1 per usec) */
 

Functions

int main (void)
 Inertial sensor data visualizer demo application entry. More...
 
void visual_stream_init (void)
 Initialize sensor data output streams for Atmel Data Visualizer. More...
 

Variables

static const uint32_t led_array [LED_COUNT-1] = {LED1, LED2, LED3, LED4}
 

#define ACCEL_INTERVAL   1 /* Loops per accel meas/xmit */

Referenced by main().

#define ACCEL_STREAM_NUM   1 /* Accelerometer data stream number */

Referenced by main(), and visual_stream_init().

#define ALL_LEDS   (LED1 | LED2 | LED3 | LED4)

Referenced by main().

#define COMPASS_INTERVAL   5 /* Loops per compass meas/xmit */

Referenced by main().

#define COMPASS_STREAM_NUM   3 /* Compass/magnetometer data stream number */

Referenced by main(), and visual_stream_init().

#define GYRO_INTERVAL   3 /* Loops per gyro meas/xmit */

Referenced by main().

#define GYRO_STREAM_NUM   2 /* Gyroscope data stream number */

Referenced by main(), and visual_stream_init().

#define NUM_ACCEL_FIELDS   3 /* Accelerometer data fields in data packet */

Referenced by visual_stream_init().

#define NUM_BLINK_LEDS   (LED_COUNT - 1) /* Don't blink LED0 (shared gpio) */

Referenced by main().

#define NUM_COMPASS_FIELDS   3 /* Compass data fields in data packet */

Referenced by visual_stream_init().

#define NUM_GYRO_FIELDS   3 /* Gyroscope data fields in data packet */

Referenced by visual_stream_init().

#define NUM_TEMP_FIELDS   1 /* Temperature data fields in data packet */

Referenced by visual_stream_init().

#define PROMPT_LED   LED4 /* Blink while waiting for user input */

Referenced by main().

#define SWITCH_PRESSED   gpio_pin_is_low(GPIO_PUSH_BUTTON_0)

Referenced by main().

#define TEMP_INTERVAL   10 /* Loops per temperature meas/xmit */

Referenced by main().

#define TEMP_STREAM_NUM   4 /* Temperature data stream number */

Referenced by main(), and visual_stream_init().

#define TIMESTAMP_RES   1000000 /* Timestamp resolution (1 per usec) */

Referenced by visual_stream_init().

int main ( void  )

Inertial sensor data visualizer demo application entry.

This application uses a serial connection to transmit sensor data. The data is formatted for use by the Atmel Data Visualizer application running on a remote host.

Upon entry, the hardware (including processor and sensor board) are initialized, and the sensor interfaces are established. The application then transmits a series of special data stream configuration packets, which tell the remote application the number, type, and labels for data streams that will subsequently be used.

After this initialization, the application enters a continuous loop in which it periodically samples the sensors that are defined and sends the obtained data values to the remote host in stream data packets. Each type of sensor measurement uses an interval counter to determine how often the measurement should be performed and transmitted.

References ACCEL_INTERVAL, ACCEL_STREAM_NUM, adv_data_send_1(), adv_data_send_3(), ALL_LEDS, sensor_data_t::axis, COMPASS_INTERVAL, COMPASS_STREAM_NUM, delay_ms, GYRO_INTERVAL, GYRO_STREAM_NUM, sensor_data_t::heading, led_array, NUM_BLINK_LEDS, PROMPT_LED, sensor_data_t::scaled, sensor_attach(), sensor_get_acceleration(), sensor_get_heading(), sensor_get_rotation(), sensor_get_temperature(), sensor_platform_init(), SENSOR_TYPE_ACCELEROMETER, SENSOR_TYPE_COMPASS, SENSOR_TYPE_GYROSCOPE, SWITCH_PRESSED, TEMP_INTERVAL, TEMP_STREAM_NUM, sensor_data_t::temperature, sensor_data_t::timestamp, and visual_stream_init().

void visual_stream_init ( void  )

Initialize sensor data output streams for Atmel Data Visualizer.

This routine initializes the data streams used in this application for the Atmel Data Visualizer (ADV) tool. First, a start-of-configuration packet is constructed and sent. Next, each data stream is described with a stream descriptor packet and either one or three field descriptor packets (depending on how many data fields are used to report a single set of data from that device). After all streams and data fields have been described, an end-of-configuration packet is sent.

References ACCEL_STREAM_NUM, adv_config_start_t, ADV_PKT_CONFIG_END, ADV_PKT_CONFIG_FIELD, ADV_PKT_CONFIG_START, ADV_PKT_CONFIG_STREAM, ADV_PKT_END, ADV_PKT_HEADER_1, ADV_PKT_HEADER_2, COMPASS_STREAM_NUM, cpu_to_le16, cpu_to_le32, adv_config_stream_t::crc, adv_config_field_t::crc, adv_config_end_t::crc, FIELD_FORMAT_SIGNED, adv_config_field_t::field_length, adv_config_field_t::field_num, adv_config_field_t::format, GYRO_STREAM_NUM, adv_config_stream_t::header1, adv_config_field_t::header1, adv_config_end_t::header1, adv_config_stream_t::header2, adv_config_field_t::header2, adv_config_end_t::header2, adv_config_stream_t::length, adv_config_field_t::length, adv_config_end_t::length, adv_config_stream_t::mark, adv_config_field_t::mark, adv_config_end_t::mark, adv_config_field_t::max, adv_config_field_t::min, adv_config_field_t::name, NUM_ACCEL_FIELDS, NUM_COMPASS_FIELDS, adv_config_stream_t::num_fields, NUM_GYRO_FIELDS, adv_config_end_t::num_streams, NUM_TEMP_FIELDS, adv_config_stream_t::stream_name, adv_config_stream_t::stream_num, adv_config_field_t::stream_num, TEMP_STREAM_NUM, adv_config_stream_t::tick_res, TIMESTAMP_RES, adv_config_stream_t::type, adv_config_field_t::type, adv_config_end_t::type, and adv_config_field_t::units.

Referenced by main().

const uint32_t led_array[LED_COUNT-1] = {LED1, LED2, LED3, LED4}
static

Referenced by main().