123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596 |
- #ifndef __QMC6310_H
- #define __QMC6310_H
- #include <stdbool.h>
- #include <stdint.h>
- #include <string.h>
- #include "sdk_common.h"
- #include "SEGGER_RTT.h"
- #include "usr_config.h"
- /* vendor chip id*/
- #define QMC6310U_IIC_ADDR (0x1c<<1)
- #define QMC6310N_IIC_ADDR (0x3c<<1)
- #define QMC6310_CHIP_ID_REG 0x00
- /*data output register*/
- #define QMC6310_DATA_OUT_X_LSB_REG 0x01
- #define QMC6310_DATA_OUT_X_MSB_REG 0x02
- #define QMC6310_DATA_OUT_Y_LSB_REG 0x03
- #define QMC6310_DATA_OUT_Y_MSB_REG 0x04
- #define QMC6310_DATA_OUT_Z_LSB_REG 0x05
- #define QMC6310_DATA_OUT_Z_MSB_REG 0x06
- /*Status registers */
- #define QMC6310_STATUS_REG 0x09
- /* configuration registers */
- #define QMC6310_CTL_REG_ONE 0x0A /* Contrl register one */
- #define QMC6310_CTL_REG_TWO 0x0B /* Contrl register two */
- /* Magnetic Sensor Operating Mode MODE[1:0]*/
- #define QMC6310_SUSPEND_MODE 0x00
- #define QMC6310_NORMAL_MODE 0x01
- #define QMC6310_SINGLE_MODE 0x02
- #define QMC6310_H_PFM_MODE 0x03
- /*data output rate OSR2[2:0]*/
- #define OUTPUT_DATA_RATE_800HZ 0x00
- #define OUTPUT_DATA_RATE_400HZ 0x01
- #define OUTPUT_DATA_RATE_200HZ 0x02
- #define OUTPUT_DATA_RATE_100HZ 0x03
- /*oversample Ratio OSR[1]*/
- #define OVERSAMPLE_RATE_256 0x01
- #define OVERSAMPLE_RATE_128 0x00
- #define SET_RESET_ON 0x00
- #define SET_ONLY_ON 0x01
- #define SET_RESET_OFF 0x02
- #define QMC6310_DEFAULT_DELAY 200
- enum{
- AXIS_X = 0,
- AXIS_Y = 1,
- AXIS_Z = 2,
- AXIS_TOTAL
- };
- typedef struct{
- signed char sign[3];
- unsigned char map[3];
- } QMC6310_map;
- //#define QMC6310_02_POWER_UP nrf_gpio_pin_write(PIN_ADC_MEMBRANEPRESSURE1_IN,1)
- //#define QMC6310_02_POWER_DOWN nrf_gpio_pin_write(PIN_ADC_MEMBRANEPRESSURE1_IN,0)
- //#define QMC6310_03_POWER_UP nrf_gpio_pin_write(PIN_ADC_MEMBRANEPRESSURE2_IN,1)
- //#define QMC6310_03_POWER_DOWN nrf_gpio_pin_write(PIN_ADC_MEMBRANEPRESSURE2_IN,0)
- #define QMC6310_MAXHZ 0xC3
- #define QMC6310_200HZ 0x3D
- #define QMC6310_100HZ 0x39 //161ua
- #define QMC6310_10HZ 0x31
- int qmc6310_front_Init(uint8_t hz);//1ms
- int qmc6310_front_ReConfigure(uint8_t hz); // qmc6310_01_Suspend + qmc6310_01_ReConfigure = 885us
- int qmc6310_front_Suspend(void);
- int qmc6310_front_CheckIsConfigure(uint8_t hz);
- uint8_t qmc6310_front_read_mag_xyz(int16_t *data);//457us
- QMC6310_map qmc6310_front_GetMap(void);
- int qmc6310_center_Init(uint8_t hz);
- int qmc6310_center_ReConfigure(uint8_t hz);
- int qmc6310_center_Suspend(void);
- int qmc6310_center_CheckIsConfigure(uint8_t hz);
- uint8_t qmc6310_center_read_mag_xyz(int16_t *data);
- QMC6310_map qmc6310_center_GetMap(void);
- int qmc6310_back_Init(uint8_t hz);
- int qmc6310_back_ReConfigure(uint8_t hz);
- int qmc6310_back_Suspend(void);
- int qmc6310_back_CheckIsConfigure(uint8_t hz);
- uint8_t qmc6310_back_read_mag_xyz(int16_t *data);
- #endif
|