Icm20948AuxTransport.h 5.0 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113
  1. /*
  2. * ________________________________________________________________________________________________________
  3. * Copyright © 2014-2015 InvenSense Inc. Portions Copyright © 2014-2015 Movea. All rights reserved.
  4. * This software, related documentation and any modifications thereto (collectively “Software”) is subject
  5. * to InvenSense and its licensors' intellectual property rights under U.S. and international copyright and
  6. * other intellectual property rights laws.
  7. * InvenSense and its licensors retain all intellectual property and proprietary rights in and to the Software
  8. * and any use, reproduction, disclosure or distribution of the Software without an express license
  9. * agreement from InvenSense is strictly prohibited.
  10. * ________________________________________________________________________________________________________
  11. */
  12. /** @defgroup inv_icm20948_secondary_transport inv_secondary_transport
  13. @ingroup SmartSensor_driver
  14. @{
  15. */
  16. #ifndef INV_ICM20948_SECONDARY_TRANSPORT_H__
  17. #define INV_ICM20948_SECONDARY_TRANSPORT_H__
  18. #ifdef __cplusplus
  19. extern "C" {
  20. #endif
  21. /* forward declaration */
  22. struct inv_icm20948;
  23. /** @brief I2C from secondary device can stand on up to 4 channels. To perform automatic read and feed DMP :
  24. - channel 0 is reserved for compass reading data
  25. - channel 1 is reserved for compass writing one-shot acquisition register
  26. - channel 2 is reserved for als reading data */
  27. #define COMPASS_I2C_SLV_READ 0
  28. #define COMPASS_I2C_SLV_WRITE 1
  29. #define ALS_I2C_SLV 2
  30. /** @brief Initializes the register for the i2c communication*/
  31. void INV_EXPORT inv_icm20948_init_secondary(struct inv_icm20948 * s);
  32. /** @brief Reads data in i2c a secondary device
  33. * @param[in] index The i2c slave what you would use
  34. * @param[in] addr i2c address slave of the secondary slave
  35. * @param[in] reg the register to be read on the secondary device
  36. * @param[in] len Size of data to be read
  37. * @return 0 in case of success, -1 for any error
  38. */
  39. int INV_EXPORT inv_icm20948_read_secondary(struct inv_icm20948 * s, int index, unsigned char addr, unsigned char reg, char len);
  40. /** @brief Reads data in i2c a secondary device directly
  41. * @param[in] index The i2c slave what you would use
  42. * @param[in] addr i2c address slave of the secondary slave
  43. * @param[in] reg the register to be read on the secondary device
  44. * @param[in] len Size of data to be read
  45. * @param[out] d pointer to the data to be read
  46. * @return 0 in case of success, -1 for any error
  47. */
  48. int INV_EXPORT inv_icm20948_execute_read_secondary(struct inv_icm20948 * s, int index, unsigned char addr, int reg, int len, uint8_t *d);
  49. /** @brief Writes data in i2c a secondary device
  50. * @param[in] index The i2c slave what you would use
  51. * @param[in] addr i2c address slave of the secondary slave
  52. * @param[in] reg the register to be write on the secondary device
  53. * @param[in] v the data to be written
  54. * @return 0 in case of success, -1 for any error
  55. */
  56. int INV_EXPORT inv_icm20948_write_secondary(struct inv_icm20948 * s, int index, unsigned char addr, unsigned char reg, char v);
  57. /** @brief Writes data in i2c a secondary device directly
  58. * @param[in] index The i2c slave what you would use
  59. * @param[in] addr i2c address slave of the secondary slave
  60. * @param[in] reg the register to be write on the secondary device
  61. * @param[in] v the data to be written
  62. * @return 0 in case of success, -1 for any error
  63. */
  64. int INV_EXPORT inv_icm20948_execute_write_secondary(struct inv_icm20948 * s, int index, unsigned char addr, int reg, uint8_t v);
  65. /** @brief Save current secondary I2C ODR configured
  66. */
  67. void INV_EXPORT inv_icm20948_secondary_saveI2cOdr(struct inv_icm20948 * s);
  68. /** @brief Restore secondary I2C ODR configured based on the one saved with inv_icm20948_secondary_saveI2cOdr()
  69. */
  70. void INV_EXPORT inv_icm20948_secondary_restoreI2cOdr(struct inv_icm20948 * s);
  71. /** @brief Stop one secondary I2C channel by writing 0 in its control register
  72. * @param[in] index the channel id to be stopped
  73. * @return 0 in case of success, -1 for any error
  74. * @warning It does not stop I2C secondary interface, just one channel
  75. */
  76. int INV_EXPORT inv_icm20948_secondary_stop_channel(struct inv_icm20948 * s, int index);
  77. /** @brief Enable secondary I2C interface
  78. * @return 0 in case of success, -1 for any error
  79. */
  80. int INV_EXPORT inv_icm20948_secondary_enable_i2c(struct inv_icm20948 * s);
  81. /** @brief Stop secondary I2C interface
  82. * @return 0 in case of success, -1 for any error
  83. * @warning It stops all I2C transactions, whatever the channel status
  84. */
  85. int INV_EXPORT inv_icm20948_secondary_disable_i2c(struct inv_icm20948 * s);
  86. /** @brief Changes the odr of the I2C master
  87. * @param[in] divider frequency divider to BASE_SAMPLE_RATE
  88. * @param[out] effectiveDivider divider finally applied to base sample rate, at which data will be actually read on I2C bus
  89. * @return 0 in case of success, -1 for any error
  90. */
  91. int INV_EXPORT inv_icm20948_secondary_set_odr(struct inv_icm20948 * s, int divider, unsigned int* effectiveDivider);
  92. #ifdef __cplusplus
  93. }
  94. #endif
  95. #endif // INV_ICM20948_SECONDARY_TRANSPORT_H__
  96. /** @} */