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_i2c_master.h"
52#include "drv_spi_master.h"
75#define ACCEL30_REG_EXT_STAT_1 0x00
76#define ACCEL30_REG_EXT_STAT_2 0x01
77#define ACCEL30_REG_XOUT_LSB 0x02
78#define ACCEL30_REG_XOUT_MSB 0x03
79#define ACCEL30_REG_YOUT_LSB 0x04
80#define ACCEL30_REG_YOUT_MSB 0x05
81#define ACCEL30_REG_ZOUT_LSB 0x06
82#define ACCEL30_REG_ZOUT_MSB 0x07
83#define ACCEL30_REG_STATUS_1 0x08
84#define ACCEL30_REG_STATUS_2 0x09
85#define ACCEL30_REG_FREG_1 0x0D
86#define ACCEL30_REG_FREG_2 0x0E
87#define ACCEL30_REG_INIT_1 0x0F
88#define ACCEL30_REG_MODE_C 0x10
89#define ACCEL30_REG_WAKE_C 0x11
90#define ACCEL30_REG_SNIFF_C 0x12
91#define ACCEL30_REG_SNIFFTH_C 0x13
92#define ACCEL30_REG_SNIFFCF_C 0x14
93#define ACCEL30_REG_RANGE_C 0x15
94#define ACCEL30_REG_FIFO_C 0x16
95#define ACCEL30_REG_INTR_C 0x17
96#define ACCEL30_REG_INIT_3 0x1A
97#define ACCEL30_REG_SCRATCH 0x1B
98#define ACCEL30_REG_POWER_MODE 0x1C
99#define ACCEL30_REG_DMX 0x20
100#define ACCEL30_REG_DMY 0x21
101#define ACCEL30_REG_DMZ 0x22
102#define ACCEL30_REG_RESET 0x24
103#define ACCEL30_REG_INIT_2 0x28
104#define ACCEL30_REG_TRIGC 0x29
105#define ACCEL30_REG_XOFFL 0x2A
106#define ACCEL30_REG_XOFFH 0x2B
107#define ACCEL30_REG_YOFFL 0x2C
108#define ACCEL30_REG_YOFFH 0x2D
109#define ACCEL30_REG_ZOFFL 0x2E
110#define ACCEL30_REG_ZOFFH 0x2F
111#define ACCEL30_REG_XGAIN 0x30
112#define ACCEL30_REG_YGAIN 0x31
113#define ACCEL30_REG_ZGAIN 0x32
114#define ACCEL30_REG_OPT 0x3B
115#define ACCEL30_REG_GAIN 0x21
134#define ACCEL30_MODE_BIT_MASK 0xF0
135#define ACCEL30_RANGE_BIT_MASK 0x07
136#define ACCEL30_GAIN_BIT_MASK 0x3F
137#define ACCEL30_RESOLUTION_BIT_MASK 0x70
138#define ACCEL30_DMX_PN_DISABLE 0x00
139#define ACCEL30_DMX_RES_BIT_MASK 0x01
140#define ACCEL30_ENABLE_XYZ_AXIS_PD 0x00
141#define ACCEL30_TRIG_CMD_CONTINUOUS 0x00
142#define ACCEL30_TRIG_CMD_ONE_SHOT 0x01
143#define ACCEL30_FORCE_RESET 0x40
144#define ACCEL30_I2C_ENABLE 0x40
145#define ACCEL30_SPI_ENABLE 0x80
146#define ACCEL30_MODE_BIT_MASK 0xF0
153#define ACCEL30_DEVICE_ADDRESS_GND 0x4C
154#define ACCEL30_DEVICE_ADDRESS_VCC 0x6C
164#define ACCEL30_SET_DATA_SAMPLE_EDGE SET_SPI_DATA_SAMPLE_EDGE
165#define ACCEL30_SET_DATA_SAMPLE_MIDDLE SET_SPI_DATA_SAMPLE_MIDDLE
183#define ACCEL30_MAP_MIKROBUS( cfg, mikrobus ) \
184 cfg.scl = MIKROBUS( mikrobus, MIKROBUS_SCL ); \
185 cfg.sda = MIKROBUS( mikrobus, MIKROBUS_SDA ); \
186 cfg.miso = MIKROBUS( mikrobus, MIKROBUS_MISO ); \
187 cfg.mosi = MIKROBUS( mikrobus, MIKROBUS_MOSI ); \
188 cfg.sck = MIKROBUS( mikrobus, MIKROBUS_SCK ); \
189 cfg.cs = MIKROBUS( mikrobus, MIKROBUS_CS ); \
190 cfg.rst = MIKROBUS( mikrobus, MIKROBUS_RST ); \
191 cfg.int_pin = MIKROBUS( mikrobus, MIKROBUS_INT )
struct accel30_s accel30_t
Accel 30 Click context object.
accel30_range_t
Accel 30 Click range value data.
Definition accel30.h:307
@ ACCEL30_RANGE_8G
Definition accel30.h:310
@ ACCEL30_RANGE_16G
Definition accel30.h:312
@ ACCEL30_RANGE_2G
Definition accel30.h:308
@ ACCEL30_RANGE_4G
Definition accel30.h:309
@ ACCEL30_RANGE_12G
Definition accel30.h:311
@ ACCEL30_RANGE_END
Definition accel30.h:313
accel30_return_value_t
Accel 30 Click return value data.
Definition accel30.h:269
@ ACCEL30_ERROR
Definition accel30.h:271
@ ACCEL30_OK
Definition accel30.h:270
accel30_drv_t
Accel 30 Click driver selector.
Definition accel30.h:201
@ ACCEL30_DRV_SEL_I2C
Definition accel30.h:203
@ ACCEL30_DRV_SEL_SPI
Definition accel30.h:202
accel30_sniff_sr_t
Accel 30 Click SNIFF sampling value data.
Definition accel30.h:364
@ ACCEL30_SNIFF_SR_200Hz
Definition accel30.h:374
@ ACCEL30_SNIFF_SR_13Hz
Definition accel30.h:370
@ ACCEL30_SNIFF_SR_2Hz
Definition accel30.h:368
@ ACCEL30_SNIFF_SR_25Hz
Definition accel30.h:371
@ ACCEL30_SNIFF_SR_50Hz
Definition accel30.h:372
@ ACCEL30_SNIFF_SR_DEFAULT_6Hz
Definition accel30.h:365
@ ACCEL30_SNIFF_SR_0p4Hz
Definition accel30.h:366
@ ACCEL30_SNIFF_SR_END
Definition accel30.h:376
@ ACCEL30_SNIFF_SR_6Hz
Definition accel30.h:369
@ ACCEL30_SNIFF_SR_0p8Hz
Definition accel30.h:367
@ ACCEL30_SNIFF_SR_400Hz
Definition accel30.h:375
@ ACCEL30_SNIFF_SR_100Hz
Definition accel30.h:373
accel30_cwake_t
Accel 30 Click CWAKE sampling value data.
Definition accel30.h:338
@ ACCEL30_CWAKE_400Hz
Definition accel30.h:349
@ ACCEL30_CWAKE_750Hz
Definition accel30.h:354
@ ACCEL30_CWAKE_RESER2
Definition accel30.h:353
@ ACCEL30_CWAKE_100Hz
Definition accel30.h:347
@ ACCEL30_CWAKE_0p4Hz
Definition accel30.h:340
@ ACCEL30_CWAKE_210Hz
Definition accel30.h:348
@ ACCEL30_CWAKE_2Hz
Definition accel30.h:342
@ ACCEL30_CWAKE_0p8Hz
Definition accel30.h:341
@ ACCEL30_CWAKE_RESER0
Definition accel30.h:351
@ ACCEL30_CWAKE_RESER1
Definition accel30.h:352
@ ACCEL30_CWAKE_28Hz
Definition accel30.h:345
@ ACCEL30_CWAKE_END
Definition accel30.h:355
@ ACCEL30_CWAKE_14Hz
Definition accel30.h:344
@ ACCEL30_CWAKE_6Hz
Definition accel30.h:343
@ ACCEL30_CWAKE_DEFAULT_50Hz
Definition accel30.h:339
@ ACCEL30_CWAKE_600Hz
Definition accel30.h:350
@ ACCEL30_CWAKE_54Hz
Definition accel30.h:346
accel30_fifo_mode_t
Accel 30 Click FIFO mode value data.
Definition accel30.h:385
@ ACCEL30_FIFO_MODE_NORMAL
Definition accel30.h:386
@ ACCEL30_FIFO_MODE_WATERMARK
Definition accel30.h:387
@ ACCEL30_FIFO_MODE_END
Definition accel30.h:388
accel30_resolution_t
Accel 30 Click resolution value data.
Definition accel30.h:322
@ ACCEL30_RESOLUTION_10BIT
Definition accel30.h:326
@ ACCEL30_RESOLUTION_8BIT
Definition accel30.h:325
@ ACCEL30_RESOLUTION_14BIT
Definition accel30.h:328
@ ACCEL30_RESOLUTION_END
Definition accel30.h:329
@ ACCEL30_RESOLUTION_7BIT
Definition accel30.h:324
@ ACCEL30_RESOLUTION_12BIT
Definition accel30.h:327
@ ACCEL30_RESOLUTION_6BIT
Definition accel30.h:323
accel30_op_mode_t
Accel 30 Click operating mode value data.
Definition accel30.h:293
@ ACCEL30_MODE_STANDBY
Definition accel30.h:295
@ ACCEL30_MODE_CWAKE
Definition accel30.h:297
@ ACCEL30_MODE_SNIFF
Definition accel30.h:296
@ ACCEL30_MODE_TRIG
Definition accel30.h:298
@ ACCEL30_MODE_SLEEP
Definition accel30.h:294
accel30_gain_t
Accel 30 Click gain value data.
Definition accel30.h:280
@ ACCEL30_GAIN_NOT_USED
Definition accel30.h:284
@ ACCEL30_GAIN_1X
Definition accel30.h:283
@ ACCEL30_GAIN_4X
Definition accel30.h:282
@ ACCEL30_GAIN_DEFAULT
Definition accel30.h:281
accel30_power_mode_t
Accel 30 Click power mode value data.
Definition accel30.h:397
@ ACCEL30_LOW_POWER
Definition accel30.h:398
@ ACCEL30_RESERVED_1
Definition accel30.h:399
@ ACCEL30_ULOW_POWER
Definition accel30.h:401
@ ACCEL30_RESERVED_2
Definition accel30.h:400
@ ACCEL30_PRE_POWER
Definition accel30.h:402
err_t(* accel30_master_io_t)(struct accel30_s *, uint8_t, uint8_t *, uint8_t)
Accel 30 Click driver interface.
Definition accel30.h:211
err_t accel30_default_cfg(accel30_t *ctx)
Accel 30 default configuration function.
err_t accel30_set_sniff_gain(accel30_t *ctx, accel30_gain_t gain)
Accel 30 set sniff gain function.
err_t accel30_get_avg_axes(accel30_t *ctx, accel30_avg_axis_t *acc_avg_axis)
Accel 30 get accel averaged data function.
err_t accel30_set_sample_rate(accel30_t *ctx, accel30_cwake_t sample_rate)
Accel 30 set sampling rate function.
uint8_t accel30_get_int_pin(accel30_t *ctx)
Accel 30 get interrupt function.
err_t accel30_init(accel30_t *ctx, accel30_cfg_t *cfg)
Accel 30 initialization function.
err_t accel30_get_axis(accel30_t *ctx, accel30_axis_t *acc_axis)
Accel 30 get accel data function.
err_t accel30_set_resolution_ctrl(accel30_t *ctx, accel30_resolution_t resolution)
Accel 30 set resolution control function.
err_t accel30_set_range_ctrl(accel30_t *ctx, accel30_range_t range)
Accel 30 set range control function.
err_t accel30_set_wake_gain(accel30_t *ctx, accel30_gain_t gain)
Accel 30 set wake gain function.
err_t accel30_set_pwr_mode(accel30_t *ctx, accel30_power_mode_t pwr_mode)
Accel 30 set power mode function.
err_t accel30_generic_read(accel30_t *ctx, uint8_t reg, uint8_t *data_out, uint8_t len)
Accel 30 data reading function.
err_t accel30_set_sniff_sample_rate(accel30_t *ctx, accel30_sniff_sr_t sample_rate)
Accel 30 set sniff sampling rate function.
void accel30_cfg_setup(accel30_cfg_t *cfg)
Accel 30 configuration object setup function.
err_t accel30_generic_write(accel30_t *ctx, uint8_t reg, uint8_t *data_in, uint8_t len)
Accel 30 data writing function.
void accel30_drv_interface_selection(accel30_cfg_t *cfg, accel30_drv_t drv_sel)
Accel 30 driver interface setup function.
err_t accel30_soft_reset(accel30_t *ctx)
Accel 30 soft reset function.
err_t accel30_set_mode(accel30_t *ctx, accel30_op_mode_t mode)
Accel 30 set operating mode function.
This file contains SPI specific macros, functions, etc.
Accel 30 Click Axis averaged structure object.
Definition accel30.h:423
float y
Definition accel30.h:425
float x
Definition accel30.h:424
float z
Definition accel30.h:426
Accel 30 Click Axis structure object.
Definition accel30.h:411
int16_t z
Definition accel30.h:414
int16_t x
Definition accel30.h:412
int16_t y
Definition accel30.h:413
Accel 30 Click configuration object.
Definition accel30.h:243
accel30_drv_t drv_sel
Definition accel30.h:260
uint32_t i2c_speed
Definition accel30.h:253
spi_master_chip_select_polarity_t cs_polarity
Definition accel30.h:258
pin_name_t sck
Definition accel30.h:248
spi_master_mode_t spi_mode
Definition accel30.h:257
pin_name_t mosi
Definition accel30.h:247
uint32_t spi_speed
Definition accel30.h:256
pin_name_t scl
Definition accel30.h:244
pin_name_t int_pin
Definition accel30.h:251
pin_name_t miso
Definition accel30.h:246
pin_name_t sda
Definition accel30.h:245
pin_name_t rst
Definition accel30.h:250
pin_name_t cs
Definition accel30.h:249
uint8_t i2c_address
Definition accel30.h:254
Accel 30 Click context object.
Definition accel30.h:218
spi_master_t spi
Definition accel30.h:224
accel30_drv_t drv_sel
Definition accel30.h:228
accel30_master_io_t read_f
Definition accel30.h:231
uint8_t resolution_cfg
Definition accel30.h:234
digital_in_t int_pin
Definition accel30.h:221
uint8_t range_cfg
Definition accel30.h:233
i2c_master_t i2c
Definition accel30.h:223
accel30_master_io_t write_f
Definition accel30.h:230
digital_out_t rst
Definition accel30.h:219
uint8_t slave_address
Definition accel30.h:226
pin_name_t chip_select
Definition accel30.h:227