Microchip® Advanced Software Framework

bno055_example.c File Reference

BNO055 extension board example for SAME70.

Copyright (c) 2015-2018 Microchip Technology Inc. and its subsidiaries.

#include "asf.h"
#include "conf_board.h"
#include "conf_bno055.h"
#include "bno055_port.h"

Macros

#define STRING_EOL   "\r"
 
#define STRING_HEADER
 

Functions

Function Prototype Declaration
static void sensor_init (void)
 
static void sensors_data_print (void)
 Reads output data of the sensor and sends them data via USART. More...
 
static void bno055_interrupt_handler_no_motion (void)
 No motion interrupt handler. More...
 
static void bno055_interrupt_handler_any_motion (void)
 Any motion interrupt handler. More...
 
static void bno055_interrupt_handler (void)
 Sensor general interrupt handler, calls specific handlers. More...
 
void SysTick_Handler (void)
 Handler for System Tick interrupt. More...
 
static void configure_console (void)
 Configure UART console. More...
 
int main (void)
 Initializes the whole system and runs the desired application. More...
 

Variables

bool read_sensor_data = false
 
bool sensor_data_changed = false
 
uint8_t sleep_state
 
uint32_t systick_count = 0
 

#define STRING_EOL   "\r"
#define STRING_HEADER
Value:
"-- BNO055 Example --\r\n" \
"-- "BOARD_NAME" --\r\n" \
"-- Compiled: "__DATE__" "__TIME__" --"STRING_EOL
#define BOARD_NAME
Name of the board.
Definition: same70_xplained.h:75
#define STRING_EOL
Definition: bno055_example.c:95

Referenced by main().

static void bno055_interrupt_handler ( void  )
static

Sensor general interrupt handler, calls specific handlers.

This function is called when an external interrupt is triggered by the sensor, checks interrupt registers of BNO055 to determine the source and type of interrupt and calls the specific interrupt handler accordingly.

Parameters
[in]NULL
[out]NULL
Returns
NULL

References bno055_get_intr_stat_accel_any_motion(), bno055_get_intr_stat_accel_no_motion(), bno055_get_intr_stat_gyro_any_motion(), bno055_interrupt_handler_any_motion(), bno055_interrupt_handler_no_motion(), bno055_set_intr_rst(), ENABLED, SLEEP_STATE_AWAKE, and SLEEP_STATE_SLEEP.

Referenced by main().

static void bno055_interrupt_handler_any_motion ( void  )
static

Any motion interrupt handler.

This function is called when an any-motion interrupt is triggered by the accelerometer or gyroscope in BNO055, turns off the green light, sends a message to the terminal window and starts data stream.

References ioport_set_pin_level(), RGB_LED_G, and RGB_LED_G_OFF.

Referenced by bno055_interrupt_handler().

static void bno055_interrupt_handler_no_motion ( void  )
static

No motion interrupt handler.

This function is called when a no-motion interrupt is triggered by the accelerometer in BNO055, turns the LED color to green, stops data stream and sends a message to the terminal window.

References ioport_set_pin_level(), RGB_LED_G, and RGB_LED_G_ON.

Referenced by bno055_interrupt_handler().

static void configure_console ( void  )
static
int main ( void  )

Initializes the whole system and runs the desired application.

This is the main function of the project. It calls initialization functions of the main board and the sensor. It initializes the host microcontroller unit and all its required modules such as clock sources, I2C, TC, USART, PINMUX and interrupt controllers. It also initializes the global variables.

References bno055_gpio_config(), bno055_i2c_bus_init(), bno055_interrupt_handler(), board_init(), BUTTON_0_ACTIVE, BUTTON_0_PIN, configure_console(), extint_initialize(), ioport_get_pin_level(), ioport_set_pin_level(), LED_0_ACTIVE, LED_0_PIN, RGB_LED_G, RGB_LED_G_OFF, sensor_init(), sensors_data_print(), SLEEP_STATE_AWAKE, STRING_HEADER, sysclk_get_cpu_hz(), and sysclk_init().

static void sensors_data_print ( void  )
static

Reads output data of the sensor and sends them data via USART.

This function reads output data of BNO055 (Three Euler angles) using sensor API functions and sends sensor data in ASCII Format via USART.

Parameters
[in]NULL
[out]NULL
Returns
NULL

References bno055_read_accel_xyz(), bno055_read_euler_hrp(), bno055_read_gravity_xyz(), bno055_read_gyro_xyz(), bno055_read_linear_accel_xyz(), bno055_read_mag_xyz(), bno055_euler_t::h, bno055_euler_t::p, bno055_euler_t::r, bno055_accel_t::x, bno055_mag_t::x, bno055_gyro_t::x, bno055_linear_accel_t::x, bno055_gravity_t::x, bno055_accel_t::y, bno055_mag_t::y, bno055_gyro_t::y, bno055_linear_accel_t::y, bno055_gravity_t::y, bno055_accel_t::z, bno055_mag_t::z, bno055_gyro_t::z, bno055_linear_accel_t::z, and bno055_gravity_t::z.

Referenced by main().

void SysTick_Handler ( void  )

Handler for System Tick interrupt.

bool read_sensor_data = false

the flag is set by the external interrupt callback function

bool sensor_data_changed = false
uint8_t sleep_state

Holds sleep state of the system

uint32_t systick_count = 0