87 lines
2.2 KiB
C
87 lines
2.2 KiB
C
//
|
|
// Created by cfif on 28.09.22.
|
|
//
|
|
|
|
#ifndef ACCEL_QMA6100P_H
|
|
#define ACCEL_QMA6100P_H
|
|
|
|
#include "SpiPort.h"
|
|
#include "vector.h"
|
|
|
|
#define QMA6100P_TIMEOUT 10
|
|
#define QMA6100P_RESET 0xB6
|
|
#define QMA6100P_ENABLE_ACTIVE_MODE 0b10000000
|
|
#define QMA6100P_CIC_MULT8 0b00110000
|
|
#define QMA6100P_ENABLE_INT1 0b10000
|
|
#define QMA6100P_DATA_READY_ENABLE_INT1 0b10000
|
|
#define QMA6100P_FULL_SCALE_RAGE 0b0001
|
|
#define QMA6100P_DEFAULT 0b1000
|
|
#define QMA6100P_DEFAULT_INT_CFG_VALUE 0b01001100
|
|
#define QMA6100P_DEFAULT_MOT_CONF3_VALUE 0b01000000
|
|
|
|
|
|
#define QMA6100P_REG_FSR 0x0F
|
|
#define QMA6100P_REG_BW 0x10
|
|
#define QMA6100P_REG_PM 0x11
|
|
#define QMA6100P_REG_INT_MAP1 0x1A
|
|
#define QMA6100P_REG_INT_EN1 0x17
|
|
#define QMA6100P_REG_INT_CFG 0x21
|
|
#define QMA6100P_REG_MOT_CONF3 0x2F
|
|
#define QMA6100P_REG_RESET 0x36
|
|
#define QMA6100P_REG_INTERNAL 0x33
|
|
|
|
|
|
#define QMA6100P_REG_ACC_X_L 0x01
|
|
#define QMA6100P_REG_ACC_X_H 0x02
|
|
#define QMA6100P_REG_ACC_Y_L 0x03
|
|
#define QMA6100P_REG_ACC_Y_H 0x04
|
|
#define QMA6100P_REG_ACC_Z_L 0x05
|
|
#define QMA6100P_REG_ACC_Z_H 0x06
|
|
|
|
|
|
//Значения это LSB в микро g
|
|
//Values is LSB in micro g
|
|
typedef enum {
|
|
ACCEL_QMA6100P_RANGE_2G = 244,
|
|
ACCEL_QMA6100P_RANGE_4G = 488,
|
|
ACCEL_QMA6100P_RANGE_8G = 977,
|
|
ACCEL_QMA6100P_RANGE_16G = 1950,
|
|
ACCEL_QMA6100P_RANGE_32G = 3910
|
|
} eAccelQma6100pRanges;
|
|
|
|
typedef enum {
|
|
ACCEL_QMA6100P_RANGE_REG_2G = 0b0001,
|
|
ACCEL_QMA6100P_RANGE_REG_4G = 0b0010,
|
|
ACCEL_QMA6100P_RANGE_REG_8G = 0b0100,
|
|
ACCEL_QMA6100P_RANGE_REG_16G = 0b1000,
|
|
ACCEL_QMA6100P_RANGE_REG_32G = 0b1111,
|
|
} eAccelQma6100pRangesReg;
|
|
|
|
typedef struct {
|
|
int32_t x;
|
|
int32_t y;
|
|
int32_t z;
|
|
} tAccelCoor;
|
|
|
|
typedef struct {
|
|
tSpiPortIO *port;
|
|
|
|
//нельзя задавать ниже описанные значения напрямую
|
|
//только через setter
|
|
//private
|
|
eAccelQma6100pRanges range;
|
|
|
|
tAccelCoor xyz;
|
|
} tAccelQma6100P;
|
|
|
|
void AccelQma6100P_Init(tAccelQma6100P *env, tSpiPortIO *accelIO);
|
|
|
|
bool AccelQma6100P_ConfigureDefaults(tAccelQma6100P *env);
|
|
|
|
bool AccelQma6100P_SetRange(tAccelQma6100P *env, eAccelQma6100pRanges value);
|
|
|
|
bool AccelQma6100P_Read(tAccelQma6100P *env, vector3 *value);
|
|
|
|
|
|
#endif //ACCEL_QMA6100P_H
|