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

Embed: (wiki syntax)

« Back to documentation index

Show/hide line numbers main.h Source File

main.h

Go to the documentation of this file.
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>&copy; 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  
00044 //#define BLUEMSYS_DEBUG_CALIB
00045 
00046 #define CUST_CONS_SERV          // Uncomment to enable console service 
00047 
00048 //#define CUST_BATT_SERV        // Uncomment to enable battery service /** FIXME tb implemented **/
00049 
00050 #define CUST_SENS_SERV          // Uncomment to enable env/MEMS sensor service 
00051 #define DS3_ONBOARD  false      // deft DS3 module NOT plugged onto MEMS exp board
00052 //#define DS3_ONBOARD  true     // Uncomment if DS3 module is plugged onto MEMS exp board
00053 
00054 #ifdef USE_SENSOR_FUSION_LIB    // if sensor fusion lib present enable calibration service and quaternion service
00055 #define CUST_CONFIG_SERV        // enable magnetometer calibration service
00056 #define BLUEMSYS_STORE_CALIB_FLASH  // enable flash storage of calibration data
00057 #define CUST_SW_SERV            // enable quaternion service
00058 #endif
00059 
00060 /*************** Debug Defines ******************/
00061 /* For enabling connection and notification subscriptions debug */
00062 //#define BLUEMSYS_DEBUG_CONNECTION
00063 
00064 /* For enabling trasmission for notified services (except for quaternions) */
00065 //#define BLUEMSYS_DEBUG_NOTIFY_TRAMISSION
00066 
00067 #define MAX_I2C_SPEED               400000  
00068 #define NUCLEO_I2C_SHIELDS_SPEED    MAX_I2C_SPEED   // I2C speed in Hz
00069 
00070 #define ENV_TIMER       500000      // 500 mSec 
00071 #define CALIB_TIMER      40000      // 40mS
00072 #define MEMS_TIMER       10000      // 10mS
00073 
00074 /*************** Don't Change the following defines *************/
00075 /* Calibration mask for Sensor fusion short precision */
00076 #define MASK_CALIB_SENSORFUSION_SHORT 0x00000100
00077 /* Calibration mask for Sensor fusion float precision */
00078 #define MASK_CALIB_SENSORFUSION_FLOAT 0x00000080
00079 /* W2ST command for asking the calibration status */
00080 #define W2ST_COMMAND_CAL_STATUS 0xFF
00081 /* W2ST command for resetting the calibration */
00082 #define W2ST_COMMAND_CAL_RESET  0x00
00083 /* W2ST command for stopping the calibration process */
00084 #define W2ST_COMMAND_CAL_STOP   0x01
00085 /****************************************************************/
00086 
00087 #define BLE_DEV_NAME "BlueMbed"
00088 #define BLE_DEV_MAC 0xFF,0x00,0x25,0xAA,0x02,0x04
00089 #define QUAT_FLOAT_UPDATE_MUL_10MS 2
00090 #define ACC_GYRO_MAG_UPDATE_MUL_10MS 10
00091 
00092 #define BLUEMSYS_CHECK_CALIBRATION ((uint32_t)0x12345678)
00093 
00094 #define BUTTON_TIME 1.0        // 1.0Sec
00095 #define BLUEMSYS_N_BUTTON_PRESS  3  // n push button in BUTTON_TIME
00096 
00097 #ifdef BLUEMSYS_STORE_CALIB_FLASH
00098 #define BLUEMSYS_FLASH_ADD ((uint32_t)0x08060000)
00099 #define BLUEMSYS_FLASH_SECTOR FLASH_SECTOR_7
00100 #else /* BLUEMSYS_STORE_CALIB_FLASH */
00101 #if defined (__IAR_SYSTEMS_ICC__)
00102 __no_init uint32_t CalibrationStructureRAM[8];
00103 #elif defined (__CC_ARM) 
00104 uint32_t *CalibrationStructureRAM=(uint32_t *)0x20017FC0;
00105 #elif defined (__GNUC__)
00106 uint32_t CalibrationStructureRAM[8] __attribute__ ((section (".noinit")));
00107 #else
00108 #error "Toolchain not supported"
00109 #endif
00110 #endif /* BLUEMSYS_STORE_CALIB_FLASH */
00111 
00112 #define BLE_TX_SKIP_NUM   30
00113 #define BLE_ADVERTISING_INTERVAL    1000
00114 //#define BLE_ADVERTISING_INTERVAL  160 /* 100ms; in multiples of 0.625ms. */
00115 
00116 #define BLE_HANDLE_EN_DIS_OFFSET  2  // Offset from En/Dis UUID 2902 to UUID 2803  (Characteristic UUID)
00117 #define BLE_HANDLE_VALUE_OFFSET   1  // Offset from Value UUID xxx to to UUID 2803 (Characteristic UUID) 
00118 
00119 
00120 typedef enum ConnectionStatus_t {
00121     DISCONNECTED    =0,
00122     CONNECTED       =1
00123 }cns_t;
00124 
00125 const unsigned   LENGTH_OF_LONG_UUID = 16;
00126 typedef uint16_t ShortUUIDBytes_t;
00127 typedef uint8_t  LongUUIDBytes_t[LENGTH_OF_LONG_UUID];
00128 
00129 #ifdef __cplusplus
00130 extern "C" {
00131 #endif
00132 
00133 #ifdef __cplusplus
00134 }
00135 #endif
00136 
00137 #endif // ifndef __MAIN_H__