drv_qmc6310.h 1.9 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081
  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. int qmc6310_01_init(void);
  53. int qmc6310_01_enable(void);
  54. int qmc6310_01_disable(void);
  55. uint8_t qmc6310_01_read_mag_xyz(float *data);
  56. int qmc6310_02_init(void);
  57. int qmc6310_02_enable(void);
  58. int qmc6310_02_disable(void);
  59. uint8_t qmc6310_02_read_mag_xyz(float *data);
  60. int qmc6310_03_init(void);
  61. int qmc6310_03_enable(void);
  62. int qmc6310_03_disable(void);
  63. uint8_t qmc6310_03_read_mag_xyz(float *data);
  64. #endif