bmi160_support.h 7.4 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218
  1. /*
  2. *
  3. ****************************************************************************
  4. * Copyright (C) 2016 Bosch Sensortec GmbH
  5. *
  6. * File : bmi160_support.h
  7. *
  8. * Date : 2016/06/22
  9. *
  10. * Revision : 1.1.2 $
  11. *
  12. * Usage: Sensor Driver support file for BMI160 sensor
  13. *
  14. ****************************************************************************
  15. *
  16. * \section License
  17. *
  18. * Redistribution and use in source and binary forms, with or without
  19. * modification, are permitted provided that the following conditions are met:
  20. *
  21. * Redistributions of source code must retain the above copyright
  22. * notice, this list of conditions and the following disclaimer.
  23. *
  24. * Redistributions in binary form must reproduce the above copyright
  25. * notice, this list of conditions and the following disclaimer in the
  26. * documentation and/or other materials provided with the distribution.
  27. *
  28. * Neither the name of the copyright holder nor the names of the
  29. * contributors may be used to endorse or promote products derived from
  30. * this software without specific prior written permission.
  31. *
  32. * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND
  33. * CONTRIBUTORS "AS IS" AND ANY EXPRESS OR
  34. * IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
  35. * WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
  36. * DISCLAIMED. IN NO EVENT SHALL COPYRIGHT HOLDER
  37. * OR CONTRIBUTORS BE LIABLE FOR ANY
  38. * DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY,
  39. * OR CONSEQUENTIAL DAMAGES(INCLUDING, BUT NOT LIMITED TO,
  40. * PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
  41. * LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
  42. * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY,
  43. * WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
  44. * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN
  45. * ANY WAY OUT OF THE USE OF THIS
  46. * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE
  47. *
  48. * The information provided is believed to be accurate and reliable.
  49. * The copyright holder assumes no responsibility
  50. * for the consequences of use
  51. * of such information nor for any infringement of patents or
  52. * other rights of third parties which may result from its use.
  53. * No license is granted by implication or otherwise under any patent or
  54. * patent rights of the copyright holder.
  55. **************************************************************************/
  56. /*! \file bmi160_support.h
  57. \brief BMI160 Sensor Driver Support Header File */
  58. /* user defined code to be added here ... */
  59. #ifndef __BMI160_SUPPORT_H__
  60. #define __BMI160_SUPPORT_H__
  61. #include "bmi160.h"
  62. /*!
  63. * @brief struct used for assign the value for
  64. * gyro sleep configuration
  65. */
  66. struct gyro_sleep_setting {
  67. u8 sleep_trigger;/**< gyro sleep trigger configuration*/
  68. u8 wakeup_trigger;/**< gyro wakeup trigger configuration*/
  69. u8 sleep_state;/**< gyro sleep state configuration*/
  70. u8 wakeup_int;/**< gyro wakeup interrupt configuration*/
  71. };
  72. /********************************/
  73. /**\name POWER MODES DEFINITION */
  74. /*******************************/
  75. #define ACCEL_MODE_NORMAL (0x11)
  76. #define GYRO_MODE_NORMAL (0x15)
  77. #define ACCEL_LOWPOWER (0X12)
  78. #define MAG_SUSPEND_MODE (1)
  79. #define BMI160_MODE_SWITCHING_DELAY (30)
  80. /********************************/
  81. /**\name RETURN TYPE */
  82. /*******************************/
  83. /* return type of communication routine*/
  84. #define BMI160_RETURN_FUNCTION_TYPE s8
  85. /********************************/
  86. /**\name RUNNING MODE DEFINITIONS */
  87. /*******************************/
  88. #define STANDARD_UI_9DOF_FIFO (0)
  89. #define STANDARD_UI_IMU_FIFO (1)
  90. #define STANDARD_UI_IMU (2)
  91. #define STANDARD_UI_ADVANCEPOWERSAVE (3)
  92. #define ACCEL_PEDOMETER (4)
  93. #define APPLICATION_HEAD_TRACKING (5)
  94. #define APPLICATION_NAVIGATION (6)
  95. #define APPLICATION_REMOTE_CONTROL (7)
  96. #define APPLICATION_INDOOR_NAVIGATION (8)
  97. /********************************/
  98. /**\name MAG INTERFACE */
  99. /*******************************/
  100. #define C_BMI160_BYTE_COUNT (2)
  101. #define BMI160_SLEEP_STATE (0x00)
  102. #define BMI160_WAKEUP_INTR (0x00)
  103. #define BMI160_SLEEP_TRIGGER (0x04)
  104. #define BMI160_WAKEUP_TRIGGER (0x02)
  105. #define BMI160_ENABLE_FIFO_WM (0x02)
  106. #define BMI160_MAG_INTERFACE_OFF_PRIMARY_ON (0x00)
  107. #define BMI160_MAG_INTERFACE_ON_PRIMARY_ON (0x02)
  108. /*!
  109. * @brief This function used for initialize the sensor
  110. *
  111. *
  112. * @return results of bus communication function
  113. * @retval 0 -> Success
  114. * @retval 1 -> Error
  115. *
  116. *
  117. */
  118. BMI160_RETURN_FUNCTION_TYPE bmi160_initialize_sensor(void);
  119. /*!
  120. * @brief This Function used to read the sensor data using
  121. * different running mode
  122. * @param v_running_mode_u8 : The value of running mode
  123. * Description | value
  124. * --------------------------------|----------
  125. * STANDARD_UI_9DOF_FIFO | 0
  126. * STANDARD_UI_IMU_FIFO | 1
  127. * STANDARD_UI_IMU | 2
  128. * STANDARD_UI_ADVANCEPOWERSAVE | 3
  129. * ACCEL_PEDOMETER | 4
  130. * APPLICATION_HEAD_TRACKING | 5
  131. * APPLICATION_NAVIGATION | 6
  132. * APPLICATION_REMOTE_CONTROL | 7
  133. * APPLICATION_INDOOR_NAVIGATION | 8
  134. *
  135. *
  136. * @return results of bus communication function
  137. * @retval 0 -> Success
  138. * @retval 1 -> Error
  139. *
  140. *
  141. */
  142. BMI160_RETURN_FUNCTION_TYPE bmi160_config_running_mode(u8 v_running_mode_u8);
  143. /*!
  144. * @brief This function used for interrupt configuration
  145. *
  146. *
  147. * @return results of bus communication function
  148. * @retval 0 -> Success
  149. * @retval 1 -> Error
  150. *
  151. *
  152. */
  153. BMI160_RETURN_FUNCTION_TYPE bmi160_interrupt_configuration(void);
  154. /*!
  155. * @brief This function is an example for delay
  156. * @param msec: delay in milli seconds
  157. * @return : communication result
  158. */
  159. void bmi160_delay_ms(u32 msec);
  160. #ifdef INCLUDE_BMI160API
  161. /*!
  162. * @brief Used for I2C initialization
  163. */
  164. s8 i2c_routine(void);
  165. /*!
  166. * @brief Used for SPI initialization
  167. */
  168. s8 spi_routine(void);
  169. /*!
  170. * @brief : The function is used as I2C bus read
  171. * @return : Status of the I2C read
  172. * @param dev_addr : The device address of the sensor
  173. * @param reg_addr : Address of the first register,
  174. * will data is going to be read
  175. * @param reg_data : This data read from the sensor,
  176. * which is hold in an array
  177. * @param cnt : The no of byte of data to be read
  178. */
  179. s8 bmi160_i2c_bus_read(u8 dev_addr, u8 reg_addr, u8 *reg_data, u8 cnt);
  180. /*!
  181. * @brief : The function is used as I2C bus write
  182. * @return : Status of the I2C write
  183. * @param dev_addr : The device address of the sensor
  184. * @param reg_addr : Address of the first register,
  185. * will data is going to be written
  186. * @param reg_data : It is a value hold in the array,
  187. * will be used for write the value into the register
  188. * @param cnt : The no of byte of data to be write
  189. */
  190. s8 bmi160_i2c_bus_write(u8 dev_addr, u8 reg_addr, u8 *reg_data, u8 cnt);
  191. /*!
  192. * @brief : The function is used as SPI bus read
  193. * @return : Status of the SPI read
  194. * @param dev_addr : The device address of the sensor
  195. * @param reg_addr : Address of the first register,
  196. * will data is going to be read
  197. * @param reg_data : This data read from the sensor,
  198. * which is hold in an array
  199. * @param cnt : The no of byte of data to be read
  200. */
  201. s8 bmi160_spi_bus_read(u8 dev_addr, u8 reg_addr, u8 *reg_data, u8 cnt);
  202. /*!
  203. * @brief : The function is used as SPI bus write
  204. * @return : Status of the SPI write
  205. * @param dev_addr : The device address of the sensor
  206. * @param reg_addr : Address of the first register,
  207. * will data is going to be written
  208. * @param reg_data : It is a value hold in the array,
  209. * will be used for write the value into the register
  210. * @param cnt : The no of byte of data to be write
  211. */
  212. s8 bmi160_spi_bus_write(u8 dev_addr, u8 reg_addr, u8 *reg_data, u8 cnt);
  213. #endif
  214. #endif