X-NUCLEO-IKS01A1 Environmental/Motion sensors data transmitted via X-NUCLEO-IDB04A1 BLE board. Compatible with iOS/Android ST BlueMS V2.1 application.

Dependencies:   BLE_API X_NUCLEO_IDB0XA1 X_NUCLEO_IKS01A1 mbed

Fork of Bluemicrosystem1 by ST Expansion SW Team

BlueMicrosystem application

This application is the mbed equivalent of ST BlueMicrosystem1 and provides an example of motion and environmental data exported via Bluetooth Low Energy to an Android or IOS device.
It runs on a ST NUCLEO-F401RE board connected with a X-NUCLEO-IKS01A1 and a X-NUCLEO-IDB04A1 expansion boards and is compatible with Android and iOS ST BlueMS smartphone applications (based on Android and iOS BlueST SDKs).
By default the application is not providing sensor fusion and activity recognition features. However sensor fusion can be enabled following the steps below:

  • Download and install osxMotionFX library on your PC.
  • Obtain the free license for your board following the instructions
  • Copy the correct license into Middlewares/ST/STM32_OSX_MotionFX_Library/osx_license.h of your mbed program folder
  • Copy Middlewares/ST/STM32_OSX_MotionFX_Library/Inc/osx_motion_fx.h file
  • Rename the provided .lib Keil binary library giving it a .ar extension, then copy it into Middlewares/ST/STM32_OSX_MotionFX_Library/Lib of your mbed program folder
  • Enable USE_SENSOR_FUSION_LIB macro into MotionFX_Manager.h file and recompile.
Committer:
mapellil
Date:
Tue Jun 21 13:04:42 2016 +0000
Revision:
13:d00147d01d4e
Parent:
9:2693f9ef8ff7
updated BLE lib link, defined BLE offsets as #define

Who changed what in which revision?

UserRevisionLine numberNew contents of line
mapellil 0:e93a11b4e044 1 /**
mapellil 0:e93a11b4e044 2 ******************************************************************************
mapellil 0:e93a11b4e044 3 * @file MotionFX_Manager.h
mapellil 0:e93a11b4e044 4 * @author Central Lab
mapellil 0:e93a11b4e044 5 * @version V1.1.0
mapellil 9:2693f9ef8ff7 6 * @date 20-January-2015
mapellil 0:e93a11b4e044 7 * @brief This file includes sensor fusion interface functions
mapellil 0:e93a11b4e044 8 ******************************************************************************
mapellil 0:e93a11b4e044 9 * @attention
mapellil 0:e93a11b4e044 10 *
mapellil 0:e93a11b4e044 11 * <h2><center>&copy; COPYRIGHT(c) 2015 STMicroelectronics</center></h2>
mapellil 0:e93a11b4e044 12 *
mapellil 0:e93a11b4e044 13 * Licensed under MCD-ST Liberty SW License Agreement V2, (the "License");
mapellil 0:e93a11b4e044 14 * You may not use this file except in compliance with the License.
mapellil 0:e93a11b4e044 15 * You may obtain a copy of the License at:
mapellil 0:e93a11b4e044 16 *
mapellil 0:e93a11b4e044 17 * http://www.st.com/software_license_agreement_liberty_v2
mapellil 0:e93a11b4e044 18 *
mapellil 0:e93a11b4e044 19 * Redistribution and use in source and binary forms, with or without modification,
mapellil 0:e93a11b4e044 20 * are permitted provided that the following conditions are met:
mapellil 0:e93a11b4e044 21 * 1. Redistributions of source code must retain the above copyright notice,
mapellil 0:e93a11b4e044 22 * this list of conditions and the following disclaimer.
mapellil 0:e93a11b4e044 23 * 2. Redistributions in binary form must reproduce the above copyright notice,
mapellil 0:e93a11b4e044 24 * this list of conditions and the following disclaimer in the documentation
mapellil 0:e93a11b4e044 25 * and/or other materials provided with the distribution.
mapellil 0:e93a11b4e044 26 * 3. Neither the name of STMicroelectronics nor the names of its contributors
mapellil 0:e93a11b4e044 27 * may be used to endorse or promote products derived from this software
mapellil 0:e93a11b4e044 28 * without specific prior written permission.
mapellil 0:e93a11b4e044 29 *
mapellil 0:e93a11b4e044 30 * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
mapellil 0:e93a11b4e044 31 * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
mapellil 0:e93a11b4e044 32 * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
mapellil 0:e93a11b4e044 33 * DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE
mapellil 0:e93a11b4e044 34 * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
mapellil 0:e93a11b4e044 35 * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR
mapellil 0:e93a11b4e044 36 * SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER
mapellil 0:e93a11b4e044 37 * CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY,
mapellil 0:e93a11b4e044 38 * OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
mapellil 0:e93a11b4e044 39 * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
mapellil 0:e93a11b4e044 40 *
mapellil 0:e93a11b4e044 41 ******************************************************************************
mapellil 0:e93a11b4e044 42 */
mapellil 0:e93a11b4e044 43
mapellil 0:e93a11b4e044 44 #ifndef _MOTIONFX_MANAGER_H_
mapellil 0:e93a11b4e044 45 #define _MOTIONFX_MANAGER_H_
mapellil 0:e93a11b4e044 46
mapellil 0:e93a11b4e044 47 #ifdef __cplusplus
mapellil 0:e93a11b4e044 48 extern "C" {
mapellil 0:e93a11b4e044 49 #endif
mapellil 0:e93a11b4e044 50
mapellil 0:e93a11b4e044 51 //#define USE_SENSOR_FUSION_LIB /** uncomment only if STM32_OSX_MotionFX_Library is linked and licensed **/
mapellil 0:e93a11b4e044 52
mapellil 0:e93a11b4e044 53 #include <cstdio>
mapellil 0:e93a11b4e044 54 #include <stdint.h>
mapellil 0:e93a11b4e044 55 #include <stdio.h>
mapellil 0:e93a11b4e044 56
mapellil 0:e93a11b4e044 57 #ifdef USE_SENSOR_FUSION_LIB
mapellil 0:e93a11b4e044 58 #include "osx_motion_fx.h"
mapellil 0:e93a11b4e044 59 #else
mapellil 0:e93a11b4e044 60
mapellil 0:e93a11b4e044 61 #define NUM_AXES 3
mapellil 0:e93a11b4e044 62 #define QNUM_AXES 4
mapellil 0:e93a11b4e044 63
mapellil 0:e93a11b4e044 64 typedef struct
mapellil 0:e93a11b4e044 65 {
mapellil 0:e93a11b4e044 66 float mag[NUM_AXES]; /* calibrated mag [uT]/50 */
mapellil 0:e93a11b4e044 67 float acc[NUM_AXES]; /* acc [g] */
mapellil 0:e93a11b4e044 68 float gyro[NUM_AXES]; /* gyro [dps] */
mapellil 0:e93a11b4e044 69 } osxMFX_input;
mapellil 0:e93a11b4e044 70
mapellil 0:e93a11b4e044 71 typedef struct
mapellil 0:e93a11b4e044 72 {
mapellil 0:e93a11b4e044 73 float rotation_9X[NUM_AXES]; /* 9 axes yaw, pitch and roll */
mapellil 0:e93a11b4e044 74 float quaternion_9X[QNUM_AXES]; /* 9 axes quaternion */
mapellil 0:e93a11b4e044 75 float gravity_9X[NUM_AXES]; /* 9 axes device frame gravity */
mapellil 0:e93a11b4e044 76 float linear_acceleration_9X[NUM_AXES]; /* 9 axes device frame linear acceleration */
mapellil 0:e93a11b4e044 77 float heading_9X; /* 9 axes heading */
mapellil 0:e93a11b4e044 78 float rotation_6X[NUM_AXES]; /* 6 axes yaw, pitch and roll */
mapellil 0:e93a11b4e044 79 float quaternion_6X[QNUM_AXES]; /* 6 axes quaternion */
mapellil 0:e93a11b4e044 80 float gravity_6X[NUM_AXES]; /* 6 axes device frame gravity */
mapellil 0:e93a11b4e044 81 float linear_acceleration_6X[NUM_AXES]; /* 6 axes device frame linear acceleration */
mapellil 0:e93a11b4e044 82 float heading_6X; /* 6 axes heading */
mapellil 0:e93a11b4e044 83 } osxMFX_output;
mapellil 0:e93a11b4e044 84
mapellil 0:e93a11b4e044 85 typedef struct
mapellil 0:e93a11b4e044 86 {
mapellil 0:e93a11b4e044 87 signed short magOffX; /* X axis Offset */
mapellil 0:e93a11b4e044 88 signed short magOffY; /* Y axis Offset */
mapellil 0:e93a11b4e044 89 signed short magOffZ; /* Z axis Offset */
mapellil 0:e93a11b4e044 90 float magGainX; /* X axis Gain */
mapellil 0:e93a11b4e044 91 float magGainY; /* Y axis Gain */
mapellil 0:e93a11b4e044 92 float magGainZ; /* Z axis Gain */
mapellil 0:e93a11b4e044 93 float expMagVect; /* expected magnetic field */
mapellil 0:e93a11b4e044 94 } osxMFX_calibFactor;
mapellil 0:e93a11b4e044 95
mapellil 0:e93a11b4e044 96 unsigned char osx_MotionFX_compass_isCalibrated(void);
mapellil 0:e93a11b4e044 97 void osx_MotionFX_compass_forceReCalibration(void);
mapellil 0:e93a11b4e044 98 void osx_MotionFX_compass_saveAcc(int acc_x, int acc_y, int acc_z);
mapellil 0:e93a11b4e044 99 void osx_MotionFX_compass_saveMag(int mag_x, int mag_y, int mag_z);
mapellil 0:e93a11b4e044 100 int osx_MotionFX_compass_run(void);
mapellil 0:e93a11b4e044 101 void osx_MotionFX_setCalibrationData(osxMFX_calibFactor* CalibrationData);
mapellil 0:e93a11b4e044 102 void osx_MotionFX_getCalibrationData(osxMFX_calibFactor* CalibrationData);
mapellil 0:e93a11b4e044 103
mapellil 0:e93a11b4e044 104 #endif
mapellil 0:e93a11b4e044 105
mapellil 0:e93a11b4e044 106
mapellil 0:e93a11b4e044 107 typedef struct {
mapellil 0:e93a11b4e044 108 int32_t AXIS_X;
mapellil 0:e93a11b4e044 109 int32_t AXIS_Y;
mapellil 0:e93a11b4e044 110 int32_t AXIS_Z;
mapellil 0:e93a11b4e044 111 } AxesRaw_t;
mapellil 0:e93a11b4e044 112
mapellil 0:e93a11b4e044 113 /* Exported functions ------------------------------------------------------- */
mapellil 0:e93a11b4e044 114
mapellil 0:e93a11b4e044 115 bool MotionFX_manager_init(bool DS3_OnBoard, osxMFX_calibFactor & magOffset);
mapellil 0:e93a11b4e044 116 void MotionFX_manager_run(AxesRaw_t *ACC_Value, AxesRaw_t *GYR_Value, AxesRaw_t *MAG_Value, osxMFX_calibFactor & magOffset);
mapellil 0:e93a11b4e044 117 void MotionFX_manager_start_6X(void);
mapellil 0:e93a11b4e044 118 void MotionFX_manager_stop_6X(void);
mapellil 0:e93a11b4e044 119 void MotionFX_manager_start_9X(void);
mapellil 0:e93a11b4e044 120 void MotionFX_manager_stop_9X(void);
mapellil 0:e93a11b4e044 121
mapellil 0:e93a11b4e044 122 void MotionFX_manager_setDependencies(uint8_t sf, int32_t sensorMask);
mapellil 0:e93a11b4e044 123 void MotionFX_manager_resetDependencies(uint8_t sf, int32_t sensorMask);
mapellil 0:e93a11b4e044 124 uint32_t MotionFX_manager_getDependencies(uint8_t sf);
mapellil 0:e93a11b4e044 125
mapellil 0:e93a11b4e044 126 osxMFX_output* MotionFX_manager_getDataOUT(void);
mapellil 0:e93a11b4e044 127 osxMFX_input* MotionFX_manager_getDataIN(void);
mapellil 0:e93a11b4e044 128
mapellil 0:e93a11b4e044 129 /* Exported constants --------------------------------------------------------*/
mapellil 0:e93a11b4e044 130
mapellil 0:e93a11b4e044 131 /* Delta time mSec for Deltafusion */
mapellil 0:e93a11b4e044 132 #define DELTATIMESENSORFUSION 0.01
mapellil 0:e93a11b4e044 133
mapellil 0:e93a11b4e044 134 #ifdef __cplusplus
mapellil 0:e93a11b4e044 135 }
mapellil 0:e93a11b4e044 136 #endif
mapellil 0:e93a11b4e044 137
mapellil 0:e93a11b4e044 138 #endif //_MOTIONFX_MANAGER_H_
mapellil 0:e93a11b4e044 139
mapellil 0:e93a11b4e044 140 /******************* (C) COPYRIGHT 2015 STMicroelectronics *****END OF FILE****/