drv_qmc6310.h 2.7 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879808182838485868788899091929394
  1. #ifndef __QMC6310_H
  2. #define __QMC6310_H
  3. #include <stdbool.h>
  4. #include <stdint.h>
  5. #include <string.h>
  6. #include "sdk_common.h"
  7. #include "SEGGER_RTT.h"
  8. #include "usr_config.h"
  9. /* vendor chip id*/
  10. #define QMC6310U_IIC_ADDR (0x1c<<1)
  11. #define QMC6310N_IIC_ADDR (0x3c<<1)
  12. #define QMC6310_CHIP_ID_REG 0x00
  13. /*data output register*/
  14. #define QMC6310_DATA_OUT_X_LSB_REG 0x01
  15. #define QMC6310_DATA_OUT_X_MSB_REG 0x02
  16. #define QMC6310_DATA_OUT_Y_LSB_REG 0x03
  17. #define QMC6310_DATA_OUT_Y_MSB_REG 0x04
  18. #define QMC6310_DATA_OUT_Z_LSB_REG 0x05
  19. #define QMC6310_DATA_OUT_Z_MSB_REG 0x06
  20. /*Status registers */
  21. #define QMC6310_STATUS_REG 0x09
  22. /* configuration registers */
  23. #define QMC6310_CTL_REG_ONE 0x0A /* Contrl register one */
  24. #define QMC6310_CTL_REG_TWO 0x0B /* Contrl register two */
  25. /* Magnetic Sensor Operating Mode MODE[1:0]*/
  26. #define QMC6310_SUSPEND_MODE 0x00
  27. #define QMC6310_NORMAL_MODE 0x01
  28. #define QMC6310_SINGLE_MODE 0x02
  29. #define QMC6310_H_PFM_MODE 0x03
  30. /*data output rate OSR2[2:0]*/
  31. #define OUTPUT_DATA_RATE_800HZ 0x00
  32. #define OUTPUT_DATA_RATE_400HZ 0x01
  33. #define OUTPUT_DATA_RATE_200HZ 0x02
  34. #define OUTPUT_DATA_RATE_100HZ 0x03
  35. /*oversample Ratio OSR[1]*/
  36. #define OVERSAMPLE_RATE_256 0x01
  37. #define OVERSAMPLE_RATE_128 0x00
  38. #define SET_RESET_ON 0x00
  39. #define SET_ONLY_ON 0x01
  40. #define SET_RESET_OFF 0x02
  41. #define QMC6310_DEFAULT_DELAY 200
  42. enum{
  43. AXIS_X = 0,
  44. AXIS_Y = 1,
  45. AXIS_Z = 2,
  46. AXIS_TOTAL
  47. };
  48. typedef struct{
  49. signed char sign[3];
  50. unsigned char map[3];
  51. } QMC6310_map;
  52. //#define QMC6310_02_POWER_UP nrf_gpio_pin_write(PIN_ADC_MEMBRANEPRESSURE1_IN,1)
  53. //#define QMC6310_02_POWER_DOWN nrf_gpio_pin_write(PIN_ADC_MEMBRANEPRESSURE1_IN,0)
  54. //#define QMC6310_03_POWER_UP nrf_gpio_pin_write(PIN_ADC_MEMBRANEPRESSURE2_IN,1)
  55. //#define QMC6310_03_POWER_DOWN nrf_gpio_pin_write(PIN_ADC_MEMBRANEPRESSURE2_IN,0)
  56. #define QMC6310_100HZ 0x39 //161ua
  57. #define QMC6310_10HZ 0x31
  58. int qmc6310_front_Init(uint8_t hz);//1ms
  59. int qmc6310_front_ReConfigure(uint8_t hz); // qmc6310_01_Suspend + qmc6310_01_ReConfigure = 885us
  60. int qmc6310_front_Suspend(void);
  61. int qmc6310_front_CheckIsConfigure(uint8_t hz);
  62. uint8_t qmc6310_front_read_mag_xyz(int16_t *data);//457us
  63. QMC6310_map qmc6310_front_GetMap(void);
  64. int qmc6310_center_Init(uint8_t hz);
  65. int qmc6310_center_ReConfigure(uint8_t hz);
  66. int qmc6310_center_Suspend(void);
  67. int qmc6310_center_CheckIsConfigure(uint8_t hz);
  68. uint8_t qmc6310_center_read_mag_xyz(int16_t *data);
  69. QMC6310_map qmc6310_center_GetMap(void);
  70. int qmc6310_back_Init(uint8_t hz);
  71. int qmc6310_back_ReConfigure(uint8_t hz);
  72. int qmc6310_back_Suspend(void);
  73. int qmc6310_back_CheckIsConfigure(uint8_t hz);
  74. uint8_t qmc6310_back_read_mag_xyz(int16_t *data);
  75. #endif