39#ifdef PREINIT_SUPPORTED
43#ifdef MikroCCoreVersion
44 #if MikroCCoreVersion >= 1
49#include "drv_digital_out.h"
50#include "drv_digital_in.h"
51#include "drv_spi_master.h"
73#define INCLINOMETER_REG_ACC_X 0x01
74#define INCLINOMETER_REG_ACC_Y 0x02
75#define INCLINOMETER_REG_ACC_Z 0x03
76#define INCLINOMETER_REG_STO 0x04
77#define INCLINOMETER_REG_TEMP 0x05
78#define INCLINOMETER_REG_STATUS 0x06
79#define INCLINOMETER_REG_ERR_FLAG1 0x07
80#define INCLINOMETER_REG_ERR_FLAG2 0x08
81#define INCLINOMETER_REG_ANG_X 0x09
82#define INCLINOMETER_REG_ANG_Y 0x0A
83#define INCLINOMETER_REG_ANG_Z 0x0B
84#define INCLINOMETER_REG_ANG_CTRL 0x0C
85#define INCLINOMETER_REG_MODE 0x0D
86#define INCLINOMETER_REG_WHOAMI 0x10
87#define INCLINOMETER_REG_SERIAL1 0x19
88#define INCLINOMETER_REG_SERIAL2 0x1A
89#define INCLINOMETER_REG_SELBANK 0x1F
107#define INCLINOMETER_CMD_READ_ACC_X 0x040000F7
108#define INCLINOMETER_CMD_READ_ACC_Y 0x080000FD
109#define INCLINOMETER_CMD_READ_ACC_Z 0x0C0000FB
110#define INCLINOMETER_CMD_READ_STO 0x100000E9
111#define INCLINOMETER_CMD_EN_ANGLE_OUT 0xB0001F6F
112#define INCLINOMETER_CMD_READ_ANG_X 0x240000C7
113#define INCLINOMETER_CMD_READ_ANG_Y 0x280000CD
114#define INCLINOMETER_CMD_READ_ANG_Z 0x2C0000CB
115#define INCLINOMETER_CMD_READ_TEMP 0x140000EF
116#define INCLINOMETER_CMD_READ_STATUS 0x180000E5
117#define INCLINOMETER_CMD_READ_ERR_FLAG1 0x1C0000E3
118#define INCLINOMETER_CMD_READ_ERR_FLAG2 0x200000C1
119#define INCLINOMETER_CMD_READ_MODE 0x340000DF
120#define INCLINOMETER_CMD_CHANGE_TO_MODE1 0xB400001F
121#define INCLINOMETER_CMD_CHANGE_TO_MODE2 0xB4000102
122#define INCLINOMETER_CMD_CHANGE_TO_MODE3 0xB4000225
123#define INCLINOMETER_CMD_CHANGE_TO_MODE4 0xB4000338
124#define INCLINOMETER_CMD_POWER_DOWN 0xB400046B
125#define INCLINOMETER_CMD_WAKE_UP 0xB400001F
126#define INCLINOMETER_CMD_SW_RESET 0xB4002098
127#define INCLINOMETER_CMD_READ_WHOAMI 0x40000091
128#define INCLINOMETER_CMD_READ_SERIAL1 0x640000A7
129#define INCLINOMETER_CMD_READ_SERIAL2 0x680000AD
130#define INCLINOMETER_CMD_READ_CURRENT_BANK 0x7C0000B3
131#define INCLINOMETER_CMD_SWITCH_TO_BANK0 0xFC000073
132#define INCLINOMETER_CMD_SWITCH_TO_BANK1 0xFC00016E
150#define INCLINOMETER_MAP_MIKROBUS( cfg, mikrobus ) \
151 cfg.miso = MIKROBUS( mikrobus, MIKROBUS_MISO ); \
152 cfg.mosi = MIKROBUS( mikrobus, MIKROBUS_MOSI ); \
153 cfg.sck = MIKROBUS( mikrobus, MIKROBUS_SCK ); \
154 cfg.cs = MIKROBUS( mikrobus, MIKROBUS_CS );
err_t inclinometer_cmd_write(inclinometer_t *ctx, uint32_t cmd)
CMD writing function.
err_t inclinometer_init(inclinometer_t *ctx, inclinometer_cfg_t *cfg)
Inclinometer initialization function.
err_t inclinometer_get_angle(inclinometer_t *ctx, inclinometer_accel_t *angle_data)
Angle reading.
err_t inclinometer_generic_read(inclinometer_t *ctx, uint8_t reg, uint16_t *data_out)
Data reading function.
err_t inclinometer_default_cfg(inclinometer_t *ctx)
Inclinometer default configuration function.
err_t inclinometer_generic_write(inclinometer_t *ctx, uint8_t reg, uint16_t data_in)
Data writing function.
void inclinometer_cfg_setup(inclinometer_cfg_t *cfg)
Inclinometer configuration object setup function.
err_t inclinometer_cmd_read(inclinometer_t *ctx, uint32_t cmd, uint16_t *cmd_data)
CMD reading function.
err_t inclinometer_get_temperature(inclinometer_t *ctx, float *temperature)
Temperature reading.
err_t inclinometer_get_axes(inclinometer_t *ctx, inclinometer_accel_t *axes_data)
Axes reading.
inclinometer_return_value_t
Inclinometer Click return value data.
Definition inclinometer.h:211
@ INCLINOMETER_CRC_ERROR
Definition inclinometer.h:214
@ INCLINOMETER_ERROR
Definition inclinometer.h:213
@ INCLINOMETER_OK
Definition inclinometer.h:212
Inclinometer Click axis/angle data object.
Definition inclinometer.h:199
float y
Definition inclinometer.h:201
float x
Definition inclinometer.h:200
float z
Definition inclinometer.h:202
Inclinometer Click configuration object.
Definition inclinometer.h:180
spi_master_chip_select_polarity_t cs_polarity
Definition inclinometer.h:190
pin_name_t sck
Definition inclinometer.h:184
spi_master_mode_t spi_mode
Definition inclinometer.h:189
pin_name_t mosi
Definition inclinometer.h:183
uint32_t spi_speed
Definition inclinometer.h:188
pin_name_t miso
Definition inclinometer.h:182
pin_name_t cs
Definition inclinometer.h:185
Inclinometer Click context object.
Definition inclinometer.h:164
spi_master_t spi
Definition inclinometer.h:166
uint8_t rs
Definition inclinometer.h:170
float resolution
Definition inclinometer.h:171
pin_name_t chip_select
Definition inclinometer.h:168