Motion and Environmental sensor reader application connected via BLE to ST BlueMS iOS/Android application.
Dependencies: HTS221 LIS3MDL LPS22HB LSM303AGR LSM6DSL
Fork of MOTENV_Mbed by
main.h
00001 /** 00002 ****************************************************************************** 00003 * @file main.h 00004 * @author Central Labs / AST 00005 * @version V0.9.0 00006 * @date 23-Dec-2015 00007 * @brief Main program body 00008 ****************************************************************************** 00009 * @attention 00010 * 00011 * <h2><center>© COPYRIGHT(c) 2015 STMicroelectronics</center></h2> 00012 * 00013 * Redistribution and use in source and binary forms, with or without modification, 00014 * are permitted provided that the following conditions are met: 00015 * 1. Redistributions of source code must retain the above copyright notice, 00016 * this list of conditions and the following disclaimer. 00017 * 2. Redistributions in binary form must reproduce the above copyright notice, 00018 * this list of conditions and the following disclaimer in the documentation 00019 * and/or other materials provided with the distribution. 00020 * 3. Neither the name of STMicroelectronics nor the names of its contributors 00021 * may be used to endorse or promote products derived from this software 00022 * without specific prior written permission. 00023 * 00024 * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" 00025 * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE 00026 * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE 00027 * DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE 00028 * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL 00029 * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR 00030 * SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER 00031 * CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, 00032 * OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE 00033 * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. 00034 * 00035 ****************************************************************************** 00036 */ 00037 00038 #ifndef __MAIN_H__ 00039 #define __MAIN_H__ 00040 00041 /* Enable the following define for printout the calibration value 00042 read/written from/to Memory */ 00043 //#define BLUEMSYS_DEBUG_CALIB 00044 #define CUST_CONS_SERV // Uncomment to enable console service 00045 //#define CUST_BATT_SERV // Uncomment to enable battery service /** FIXME tb implemented **/ 00046 00047 #define CUST_SENS_SERV // Uncomment to enable env/MEMS sensor service 00048 #define DS3_ONBOARD false // deft DS3 module NOT plugged onto MEMS exp board 00049 //#define DS3_ONBOARD true // Uncomment if DS3 module is plugged onto MEMS exp board 00050 00051 #ifdef USE_SENSOR_FUSION_LIB // if sensor fusion lib present enable calibration service and quaternion service 00052 #define USE_IKS01A2 // this MotionFX porting is for IKS01A2 only (sensor orientation) 00053 #define CUST_CONFIG_SERV // enable magnetometer calibration service 00054 //#define BLUEMSYS_STORE_CALIB_FLASH // enable flash storage of calibration data only for 401RE 00055 #define CUST_SW_SERV // enable quaternion service 00056 #endif 00057 00058 /*************** Debug Defines ******************/ 00059 /* For enabling connection and notification subscriptions debug */ 00060 //#define BLUEMSYS_DEBUG_CONNECTION 00061 00062 /* For enabling trasmission for notified services (except for quaternions) */ 00063 //#define BLUEMSYS_DEBUG_NOTIFY_TRAMISSION 00064 00065 #define MAX_I2C_SPEED 400000 00066 #define NUCLEO_I2C_SHIELDS_SPEED MAX_I2C_SPEED // I2C speed in Hz 00067 00068 #define ENV_TIMER 500 // 500 mSec 00069 #define CALIB_TIMER 400 // 40mS 00070 #define MEMS_TIMER 10 // 10mS 00071 00072 #define FROM_MG_TO_G 0.001f 00073 #define FROM_G_TO_MG 1000.0f 00074 #define FROM_MDPS_TO_DPS 0.001f 00075 #define FROM_DPS_TO_MDPS 1000.0f 00076 #define FROM_MGAUSS_TO_UT50 (0.1f/50.0f) 00077 #define FROM_UT50_TO_MGAUSS 500.0f 00078 00079 #define MOTIONFX_ENGINE_DELTATIME 0.01f 00080 #define SAMPLE_PERIOD ((uint8_t)10) /* [ms] */ 00081 00082 /*************** Don't Change the following defines *************/ 00083 /* Calibration mask for Sensor fusion short precision */ 00084 #define MASK_CALIB_SENSORFUSION_SHORT 0x00000100 00085 /* Calibration mask for Sensor fusion float precision */ 00086 #define MASK_CALIB_SENSORFUSION_FLOAT 0x00000080 00087 /* W2ST command for asking the calibration status */ 00088 #define W2ST_COMMAND_CAL_STATUS 0xFF 00089 /* W2ST command for resetting the calibration */ 00090 #define W2ST_COMMAND_CAL_RESET 0x00 00091 /* W2ST command for stopping the calibration process */ 00092 #define W2ST_COMMAND_CAL_STOP 0x01 00093 /****************************************************************/ 00094 00095 #define BLE_DEV_NAME "MotEnvMbedOS" 00096 #define BLE_DEV_MAC 0xFF,0x00,0x25,0xAA,0x02,0x04 00097 #define QUAT_FLOAT_UPDATE_MUL_10MS 2 00098 #define ACC_GYRO_MAG_UPDATE_MUL_10MS 10 00099 00100 #define BLUEMSYS_CHECK_CALIBRATION ((uint32_t)0x12345678) 00101 00102 #define BUTTON_TIME 1.0 // 1.0Sec 00103 #define BLUEMSYS_N_BUTTON_PRESS 3 // n push button in BUTTON_TIME 00104 00105 /** Valid only for F401RE **/ 00106 #ifdef BLUEMSYS_STORE_CALIB_FLASH 00107 #define BLUEMSYS_FLASH_ADD ((uint32_t)0x08060000) 00108 #define BLUEMSYS_FLASH_SECTOR FLASH_SECTOR_7 00109 #endif /* BLUEMSYS_STORE_CALIB_FLASH */ 00110 00111 #define BLE_TX_SKIP_NUM 30 00112 #define BLE_ADVERTISING_INTERVAL 1000 00113 //#define BLE_ADVERTISING_INTERVAL 160 /* 100ms; in multiples of 0.625ms. */ 00114 00115 #define BLE_HANDLE_EN_DIS_OFFSET 2 // Offset from En/Dis UUID 2902 to UUID 2803 (Characteristic UUID) 00116 #define BLE_HANDLE_VALUE_OFFSET 1 // Offset from Value UUID xxx to to UUID 2803 (Characteristic UUID) 00117 00118 #if defined (SENSOR_TILE) && !defined(MINI_CRADLE) 00119 #include <stdio.h> 00120 /* redirect printf on the Sensor Tile UART5 allowing printf throgh the Nucleo USB connector 00121 (close the cradle and the Nucleo solder bridges to re-route the UART) */ 00122 static Serial ser(PC_12,PD_2); 00123 #define printf(...) ser.printf(__VA_ARGS__) 00124 #else 00125 #if defined (SENSOR_TILE) && defined(MINI_CRADLE) 00126 #define printf(...) 00127 #endif 00128 #endif 00129 00130 00131 00132 typedef struct 00133 { 00134 int32_t AXIS_X; 00135 int32_t AXIS_Y; 00136 int32_t AXIS_Z; 00137 } SensorAxes_t; 00138 00139 typedef enum ConnectionStatus_t { 00140 DISCONNECTED =0, 00141 CONNECTED =1 00142 }cns_t; 00143 00144 const unsigned LENGTH_OF_LONG_UUID = 16; 00145 typedef uint16_t ShortUUIDBytes_t; 00146 //typedef uint8_t LongUUIDBytes_t[LENGTH_OF_LONG_UUID]; 00147 00148 #ifdef __cplusplus 00149 extern "C" { 00150 #endif 00151 00152 #ifdef __cplusplus 00153 } 00154 #endif 00155 00156 #endif // ifndef __MAIN_H__
Generated on Tue Jul 12 2022 21:01:59 by 1.7.2