smartsens  2.0.0.0
Data Structures | Macros | Functions | Variables
main.c File Reference

SmartSens Click example. More...

#include "board.h"
#include "log.h"
#include "smartsens.h"

Data Structures

struct  smartsens_data_xyz
 Vector3 data. More...
 
struct  parse_ref
 Parse reference. More...
 

Macros

#define EULAR   0
 Example parser selector. More...
 
#define QUATERNION   0
 
#define VECTOR   1
 
#define ACCELEROMETER   1
 Vector3 sensor selector. More...
 
#define GYROSCOPE   0
 
#define MAGNOMETER   0
 
#define WORK_BUFFER_SIZE   2048
 

Functions

void application_init (void)
 
void application_task (void)
 
void main (void)
 

Variables

uint8_t work_buffer [WORK_BUFFER_SIZE] = { 0 }
 
uint16_t work_buffer_fill
 
uint16_t cmd
 
uint8_t status
 
struct parse_ref parse_table
 
uint8_t accuracy
 

Detailed Description

SmartSens Click example.

Description

This example showcases the ability of the Smart Sens click board. It has multiple examples that you can easily select with the defines at top of the main. There are 5 examples Euler, Quaternion, and Vector examples for Accelerometer, Gyroscope, and Magnetometer.

The demo application is composed of two sections :

Application Init

Initialization of communication modules(SPI/I2C, UART) and additional pins(int_pin, rst). Then after going through reset sequence and checking device and product IDs, interrupt mask, and host control is set to 0, so every interrupt enabled. IF boot status is OK boot sequence is initiated, depending on the defines from the library header it will use RAM or Flash type of the boot. If RAM is selected firmware image first needs to be uploaded to RAM and then it will be booted. If Flash example is selected it will try to boot firmware first if it fails it will then write firmware image to flash and then try to boot it again. When firmware boot is finished Kernel version and Feature registers will be read to check if the firmware is loaded. Then all the callback function will be registered(meta event callback and whatever type of example parser you set), and driver will update its the list of virtual sensors present, and finally will configure virtual sensor that will be used in the selected example.

Application Task

Wait for an interrupt to occur. When occurred read wake-up, non-weak-up, and status FIFO. Parse received that and run the callback parsers to show received data.

Note
You need to select one of the examples to use this application. You can choose one of 3 type of parsers: Eular, Quaternion, Vector. If Vector example is selected you need to choose one of the 3 sensors to show x,y,z values: Accelerometer, Gyroscope, or Magnetometer.
Author
Luka Filipovic

Macro Definition Documentation

◆ ACCELEROMETER

#define ACCELEROMETER   1

Vector3 sensor selector.

Macros for selecting vector3's sensor.

◆ EULAR

#define EULAR   0

Example parser selector.

Macros for selecting example and it's parser.

◆ GYROSCOPE

#define GYROSCOPE   0

◆ MAGNOMETER

#define MAGNOMETER   0

◆ QUATERNION

#define QUATERNION   0

◆ VECTOR

#define VECTOR   1

◆ WORK_BUFFER_SIZE

#define WORK_BUFFER_SIZE   2048

Function Documentation

◆ application_init()

void application_init ( void  )

< Logger config object.

< Click config object.

Logger initialization. Default baud rate: 115200 Default log level: LOG_LEVEL_DEBUG

Note
If USB_UART_RX and USB_UART_TX are defined as HAL_PIN_NC, you will need to define them manually for log to work. See LOG_MAP_USB_UART macro definition for detailed explanation.

◆ application_task()

void application_task ( void  )

◆ main()

void main ( void  )

Variable Documentation

◆ accuracy

uint8_t accuracy

◆ cmd

uint16_t cmd

◆ parse_table

struct parse_ref parse_table

◆ status

uint8_t status

◆ work_buffer

uint8_t work_buffer[WORK_BUFFER_SIZE] = { 0 }

◆ work_buffer_fill

uint16_t work_buffer_fill