38 #include "drv_digital_out.h" 39 #include "drv_digital_in.h" 40 #include "drv_i2c_master.h" 41 #include "drv_spi_master.h" 54 #define ACCEL6_MAP_MIKROBUS( cfg, mikrobus ) \ 55 cfg.scl = MIKROBUS( mikrobus, MIKROBUS_SCL ); \ 56 cfg.sda = MIKROBUS( mikrobus, MIKROBUS_SDA ); \ 57 cfg.miso = MIKROBUS( mikrobus, MIKROBUS_MISO ); \ 58 cfg.mosi = MIKROBUS( mikrobus, MIKROBUS_MOSI ); \ 59 cfg.sck = MIKROBUS( mikrobus, MIKROBUS_SCK ); \ 60 cfg.cs = MIKROBUS( mikrobus, MIKROBUS_CS ); 67 #define ACCEL6_MASTER_I2C 0 68 #define ACCEL6_MASTER_SPI 1 75 #define ACCEL6_RETVAL uint8_t 77 #define ACCEL6_OK 0x00 78 #define ACCEL6_INIT_ERROR 0xFF 85 #define ACCEL6_CHIP_ID 0xFB 86 #define ACCEL6_SOFT_RESET 0xB6 93 #define ACCEL6_AXIS_X 0x02 94 #define ACCEL6_AXIS_Y 0x04 95 #define ACCEL6_AXIS_Z 0x06 102 #define ACCEL6_REG_CHIP_ID 0x00 103 #define ACCEL6_REG_AXIS_X_LSB 0x02 104 #define ACCEL6_REG_AXIS_X_MSB 0x03 105 #define ACCEL6_REG_AXIS_Y_LSB 0x04 106 #define ACCEL6_REG_AXIS_Y_MSB 0x05 107 #define ACCEL6_REG_AXIS_Z_LSB 0x06 108 #define ACCEL6_REG_AXIS_Z_MSB 0x07 109 #define ACCEL6_REG_TEMPERATURE 0x08 110 #define ACCEL6_REG_INT_STATUS_0 0x09 111 #define ACCEL6_REG_INT_STATUS_1 0x0A 112 #define ACCEL6_REG_INT_STATUS_2 0x0B 113 #define ACCEL6_REG_INT_STATUS_3 0x0C 114 #define ACCEL6_REG_FIFO_STATUS 0x0E 115 #define ACCEL6_REG_PMU_RANGE 0x0F 116 #define ACCEL6_REG_PMU_BW 0x10 117 #define ACCEL6_REG_PMU_LPW 0x11 118 #define ACCEL6_REG_PMU_LOW_POWER 0x12 119 #define ACCEL6_REG_ACCD_HBW 0x13 120 #define ACCEL6_REG_BGW_SOFTRESET 0x14 121 #define ACCEL6_REG_INT_EN_0 0x16 122 #define ACCEL6_REG_INT_EN_1 0x17 123 #define ACCEL6_REG_INT_EN_2 0x18 124 #define ACCEL6_REG_INT_MAP_0 0x19 125 #define ACCEL6_REG_INT_MAP_1 0x1A 126 #define ACCEL6_REG_INT_MAP_2 0x1B 127 #define ACCEL6_REG_INT_SRC 0x1E 128 #define ACCEL6_REG_INT_OUT_CTRL 0x20 129 #define ACCEL6_REG_INT_RST_LATCH 0x21 130 #define ACCEL6_REG_INT1 0x23 131 #define ACCEL6_REG_INT2 0x24 132 #define ACCEL6_REG_INT3 0x25 133 #define ACCEL6_REG_INT4 0x26 134 #define ACCEL6_REG_INT5 0x27 135 #define ACCEL6_REG_INT6 0x28 136 #define ACCEL6_REG_INT7 0x29 137 #define ACCEL6_REG_INT8 0x2A 138 #define ACCEL6_REG_INT9 0x2B 139 #define ACCEL6_REG_INT_A 0x2C 140 #define ACCEL6_REG_INT_B 0x2D 141 #define ACCEL6_REG_INT_C 0x2E 142 #define ACCEL6_REG_INT_D 0x2F 143 #define ACCEL6_REG_FIFO_CONFIG_0 0x30 144 #define ACCEL6_REG_PMU_SELF_TEST 0x32 145 #define ACCEL6_REG_TRIM_NVM_CTRL 0x33 146 #define ACCEL6_REG_BGW_SPI3_WDT 0x34 147 #define ACCEL6_REG_OFC_CTRL 0x36 148 #define ACCEL6_REG_OFC_SETTINGS 0x37 149 #define ACCEL6_REG_OFC_OFFSET_X 0x38 150 #define ACCEL6_REG_OFC_OFFSET_Y 0x39 151 #define ACCEL6_REG_OFC_OFFSET_Z 0x3A 152 #define ACCEL6_REG_TRIM_GP_0 0x3B 153 #define ACCEL6_REG_TRIM_GP_1 0x3C 154 #define ACCEL6_REG_FIFO_CONFIG_1 0x3E 155 #define ACCEL6_REG_FIFO_DATA 0x3F 162 #define ACCEL6_STATUS_0_FLAT_INT 0x80 163 #define ACCEL6_STATUS_0_ORIENT_INT 0x40 164 #define ACCEL6_STATUS_0_SINGLE_TAP_INT 0x20 165 #define ACCEL6_STATUS_0_DOUBLE_TAP_INT 0x10 166 #define ACCEL6_STATUS_0_MOTION_INT 0x08 167 #define ACCEL6_STATUS_0_SLOPE_INT 0x04 168 #define ACCEL6_STATUS_0_HIGH_INT 0x02 169 #define ACCEL6_STATUS_0_LOW_INT 0x01 176 #define ACCEL6_STATUS_1_DATA_INT 0x80 177 #define ACCEL6_STATUS_1_FIFO_WM_INT 0x40 178 #define ACCEL6_STATUS_1_FIFO_FULL_INT 0x20 185 #define ACCEL6_STATUS_2_TAP_SING 0x80 186 #define ACCEL6_STATUS_2_TAP_FIRST_Z 0x40 187 #define ACCEL6_STATUS_2_TAP_FIRST_Y 0x20 188 #define ACCEL6_STATUS_2_TAP_FIRST_X 0x10 189 #define ACCEL6_STATUS_2_SLOPE_SING 0x08 190 #define ACCEL6_STATUS_2_SLOPE_FIRST_Z 0x04 191 #define ACCEL6_STATUS_2_SLOPE_FIRST_Y 0x02 192 #define ACCEL6_STATUS_2_SLOPE_FIRST_X 0x01 199 #define ACCEL6_STATUS_3_FLAT_POSITION 0x80 200 #define ACCEL6_STATUS_3_ORIENT_Z_UPWARD 0x00 201 #define ACCEL6_STATUS_3_ORIENT_Z_DOWNWARD 0x40 202 #define ACCEL6_STATUS_3_ORIENT_XY_UPRIGHT 0x00 203 #define ACCEL6_STATUS_3_ORIENT_XY_UPSIDE 0x10 204 #define ACCEL6_STATUS_3_ORIENT_XY_LANDSCAPE_LEFT 0x20 205 #define ACCEL6_STATUS_3_ORIENT_XY_LANDSCAPE_RIGHT 0x30 206 #define ACCEL6_STATUS_3_HIGH_SING_POSITIVE 0x00 207 #define ACCEL6_STATUS_3_HIGH_SING_NEGATIVE 0x08 208 #define ACCEL6_STATUS_3_HIGH_FIRST_Z 0x04 209 #define ACCEL6_STATUS_3_HIGH_FIRST_Y 0x02 210 #define ACCEL6_STATUS_3_HIGH_FIRST_X 0x01 217 #define ACCEL6_PMU_RANGE_2g 0x03 218 #define ACCEL6_PMU_RANGE_4g 0x05 219 #define ACCEL6_PMU_RANGE_8g 0x08 220 #define ACCEL6_PMU_RANGE_16g 0x0C 227 #define ACCEL6_PMU_BW_7_81Hz 0x08 228 #define ACCEL6_PMU_BW_15_63Hz 0x09 229 #define ACCEL6_PMU_BW_31_25Hz 0x0A 230 #define ACCEL6_PMU_BW_62_5Hz 0x0B 231 #define ACCEL6_PMU_BW_125Hz 0x0C 232 #define ACCEL6_PMU_BW_250Hz 0x0D 233 #define ACCEL6_PMU_BW_500Hz 0x0E 240 #define ACCEL6_PMU_LPW_NORMAL_MODE 0x00 241 #define ACCEL6_PMU_LPW_DEEP_SUSPEND_MODE 0x20 242 #define ACCEL6_PMU_LPW_LOW_POWER_MODE 0x40 243 #define ACCEL6_PMU_LPW_SUSPEND_MODE 0x80 244 #define ACCEL6_PMU_LPW_SLEEP_0_5ms 0x05 245 #define ACCEL6_PMU_LPW_SLEEP_1ms 0x06 246 #define ACCEL6_PMU_LPW_SLEEP_2ms 0x07 247 #define ACCEL6_PMU_LPW_SLEEP_4ms 0x08 248 #define ACCEL6_PMU_LPW_SLEEP_6ms 0x09 249 #define ACCEL6_PMU_LPW_SLEEP_10ms 0x0A 250 #define ACCEL6_PMU_LPW_SLEEP_25ms 0x0B 251 #define ACCEL6_PMU_LPW_SLEEP_50ms 0x0C 252 #define ACCEL6_PMU_LPW_SLEEP_100ms 0x0D 253 #define ACCEL6_PMU_LPW_SLEEP_500ms 0x0E 260 #define ACCEL6_INT_EN_0_FLAT_ENABLE 0x80 261 #define ACCEL6_INT_EN_0_ORIENT_ENABLE 0x40 262 #define ACCEL6_INT_EN_0_SINGLE_TAP_ENABLE 0x20 263 #define ACCEL6_INT_EN_0_DOUBLE_TAP_ENABLE 0x10 264 #define ACCEL6_INT_EN_0_SLOPE_Z_ENABLE 0x04 265 #define ACCEL6_INT_EN_0_SLOPE_Y_ENABLE 0x02 266 #define ACCEL6_INT_EN_0_SLOPE_X_ENABLE 0x01 273 #define ACCEL6_INT_EN_1_FIFO_WM_ENABLE 0x40 274 #define ACCEL6_INT_EN_1_FIFO_FULL_ENABLE 0x20 275 #define ACCEL6_INT_EN_1_DATA_ENABLE 0x10 276 #define ACCEL6_INT_EN_1_LOW_ENABLE 0x08 277 #define ACCEL6_INT_EN_1_HIGH_Z_ENABLE 0x04 278 #define ACCEL6_INT_EN_1_HIGH_Y_ENABLE 0x02 279 #define ACCEL6_INT_EN_1_HIGH_X_ENABLE 0x01 286 #define ACCEL6_INT_EN_2_MOTION_ENABLE 0x08 287 #define ACCEL6_INT_EN_2_MOTION_Z_ENABLE 0x04 288 #define ACCEL6_INT_EN_2_MOTION_Y_ENABLE 0x02 289 #define ACCEL6_INT_EN_2_MOTION_X_ENABLE 0x01 296 #define ACCEL6_INT1_MAP_FLAT_ENABLE 0x80 297 #define ACCEL6_INT1_MAP_ORIENT_ENABLE 0x40 298 #define ACCEL6_INT1_MAP_SINGLE_TAP_ENABLE 0x20 299 #define ACCEL6_INT1_MAP_DOUBLE_TAP_ENABLE 0x10 300 #define ACCEL6_INT1_MAP_MOTION_ENABLE 0x08 301 #define ACCEL6_INT1_MAP_SLOPE_ENABLE 0x04 302 #define ACCEL6_INT1_MAP_HIGH_ENABLE 0x02 303 #define ACCEL6_INT1_MAP_LOW_ENABLE 0x01 310 #define ACCEL6_INT2_MAP_DATA_ENABLE 0x80 311 #define ACCEL6_INT2_MAP_FIFO_WM_ENABLE 0x40 312 #define ACCEL6_INT2_MAP_FIFO_FULL_ENABLE 0x20 313 #define ACCEL6_INT1_MAP_DATA_ENABLE 0x01 314 #define ACCEL6_INT1_MAP_FIFO_WM_ENABLE 0x02 315 #define ACCEL6_INT1_MAP_FIFO_FULL_ENABLE 0x04 322 #define ACCEL6_INT2_MAP_FLAT_ENABLE 0x80 323 #define ACCEL6_INT2_MAP_ORIENT_ENABLE 0x40 324 #define ACCEL6_INT2_MAP_SINGLE_TAP_ENABLE 0x20 325 #define ACCEL6_INT2_MAP_DOUBLE_TAP_ENABLE 0x10 326 #define ACCEL6_INT2_MAP_MOTION_ENABLE 0x08 327 #define ACCEL6_INT2_MAP_SLOPE_ENABLE 0x04 328 #define ACCEL6_INT2_MAP_HIGH_ENABLE 0x02 329 #define ACCEL6_INT2_MAP_LOW_ENABLE 0x01 336 #define ACCEL6_INT_SRC_DATA 0x20 337 #define ACCEL6_INT_SRC_TAP 0x10 338 #define ACCEL6_INT_SRC_MOTION 0x08 339 #define ACCEL6_INT_SRC_SLOPE 0x04 340 #define ACCEL6_INT_SRC_HIGH 0x02 341 #define ACCEL6_INT_SRC_LOW 0x01 348 #define ACCEL6_INT2_CTRL_OPEN_DRAIN 0x08 349 #define ACCEL6_INT1_CTRL_OPEN_DRAIN 0x02 350 #define ACCEL6_INT2_CTRL_ACTIVE_HIGH_LEVEL 0x04 351 #define ACCEL6_INT1_CTRL_ACTIVE_HIGH_LEVEL 0x01 358 #define ACCEL6_LATCH_RESET_INT 0x80 359 #define ACCEL6_LATCH_INT_250ms 0x01 360 #define ACCEL6_LATCH_INT_500ms 0x02 361 #define ACCEL6_LATCH_INT_1sec 0x03 362 #define ACCEL6_LATCH_INT_2sec 0x04 363 #define ACCEL6_LATCH_INT_4sec 0x05 364 #define ACCEL6_LATCH_INT_8sec 0x06 365 #define ACCEL6_LATCH_INT_250us 0x09 366 #define ACCEL6_LATCH_INT_500us 0x0A 367 #define ACCEL6_LATCH_INT_1ms 0x0B 368 #define ACCEL6_LATCH_INT_12_5ms 0x0C 369 #define ACCEL6_LATCH_INT_25ms 0x0D 370 #define ACCEL6_LATCH_INT_50ms 0x0E 377 #define ACCEL6_TAP_QUIET_30ms 0x00 378 #define ACCEL6_TAP_QUIET_20ms 0x80 379 #define ACCEL6_TAP_SHOCK_50ms 0x00 380 #define ACCEL6_TAP_SHOCK_75ms 0x40 381 #define ACCEL6_TAP_DUR_50ms 0x00 382 #define ACCEL6_TAP_DUR_100ms 0x01 383 #define ACCEL6_TAP_DUR_150ms 0x02 384 #define ACCEL6_TAP_DUR_200ms 0x03 385 #define ACCEL6_TAP_DUR_250ms 0x04 386 #define ACCEL6_TAP_DUR_375ms 0x05 387 #define ACCEL6_TAP_DUR_500ms 0x06 388 #define ACCEL6_TAP_DUR_700ms 0x07 395 #define ACCEL6_TAP_2_SAMPLES 0x00 396 #define ACCEL6_TAP_4_SAMPLES 0x40 397 #define ACCEL6_TAP_8_SAMPLES 0x80 398 #define ACCEL6_TAP_16_SAMPLES 0xC0 405 #define ACCEL6_SELF_TEST_SING_POSITIVE 0x40 406 #define ACCEL6_SELF_TEST_SING_NEGATIVE 0x00 407 #define ACCEL6_SELF_TEST_DISABLE 0x00 408 #define ACCEL6_SELF_TEST_X_AXIS 0x01 409 #define ACCEL6_SELF_TEST_Y_AXIS 0x02 410 #define ACCEL6_SELF_TEST_Z_AXIS 0x03 417 #define ACCEL6_I2C_ENABLE 0x04 418 #define ACCEL6_I2C_DISABLE 0x00 419 #define ACCEL6_I2C_WTD_1ms 0x00 420 #define ACCEL6_I2C_WTD_50ms 0x02 421 #define ACCEL6_SPI_4_WIRE 0x00 422 #define ACCEL6_SPI_3_WIRE 0x01 429 #define ACCEL6_OFFSET_RESET 0x80 430 #define ACCEL6_OFFSET_TRIGGER_X_AXIS 0x20 431 #define ACCEL6_OFFSET_TRIGGER_Y_AXIS 0x40 432 #define ACCEL6_OFFSET_TRIGGER_Z_AXIS 0x60 433 #define ACCEL6_OFFSET_NOT_TRIGGER 0x00 434 #define ACCEL6_OFC_HP_X_ENABLE 0x04 435 #define ACCEL6_OFC_HP_Y_ENABLE 0x02 436 #define ACCEL6_OFC_HP_Z_ENABLE 0x01 443 #define ACCEL6_OFFSET_TARGET_Z_0g 0x00 444 #define ACCEL6_OFFSET_TARGET_Z_PLUS_1g 0x20 445 #define ACCEL6_OFFSET_TARGET_Z_MINUS_1g 0x40 446 #define ACCEL6_OFFSET_TARGET_Y_PLUS_1g 0x08 447 #define ACCEL6_OFFSET_TARGET_Y_MINUS_1g 0x10 448 #define ACCEL6_OFFSET_TARGET_X_PLUS_1g 0x02 449 #define ACCEL6_OFFSET_TARGET_X_MINUS_1g 0x04 450 #define ACCEL6_OFFSET_CUT_OFF_1Hz 0x00 451 #define ACCEL6_OFFSET_CUT_OFF_10Hz 0x01 458 #define ACCEL6_FIFO_MODE_BYPASS 0x00 459 #define ACCEL6_FIFO_MODE_FIFO 0x40 460 #define ACCEL6_FIFO_MODE_STREAM 0x80 461 #define ACCEL6_FIFO_SELECT_XYZ_AXIS 0x00 462 #define ACCEL6_FIFO_SELECT_X_AXIS 0x01 463 #define ACCEL6_FIFO_SELECT_Y_AXIS 0x02 464 #define ACCEL6_FIFO_SELECT_Z_AXIS 0x03 472 #define DEVICE_ERROR 0x04 473 #define DEVICE_OK 0x00 480 #define TAP_X_NEGATIVE 0x01 481 #define TAP_Y_NEGATIVE 0x02 482 #define TAP_Z_NEGATIVE 0x03 483 #define TAP_X_POSITIVE 0x04 484 #define TAP_Y_POSITIVE 0x05 485 #define TAP_Z_POSITIVE 0x06 493 #define SLOPE_X_NEGATIVE 0x01 494 #define SLOPE_Y_NEGATIVE 0x02 495 #define SLOPE_Z_NEGATIVE 0x03 496 #define SLOPE_X_POSITIVE 0x04 497 #define SLOPE_Y_POSITIVE 0x05 498 #define SLOPE_Z_POSITIVE 0x06 499 #define NON_SLOPE 0x00 506 #define Z_ORIENT_UPWARD_LOOKING 0x01 507 #define Z_ORIENT_DOWNWARD_LOOKING 0x02 508 #define XY_ORIENT_UPSIDE_DOWN 0x01 509 #define XY_ORIENT_LANDSCAPE_LEFT 0x02 510 #define XY_ORIENT_LANDSCAPE_RIGHT 0x03 511 #define XY_ORIENT_UPRIGHT 0x04 float dev_freq
Definition: accel6.h:577
float dev_gaus
Definition: accel6.h:576
void accel6_default_cfg(accel6_t *ctx, uint8_t range_data, uint8_t bw_data, uint8_t lpw_data)
Click Default Configuration function.
hal_i2c_speed_t i2c_speed
Definition: accel6.h:569
void accel6_soft_reset(accel6_t *ctx)
Functions for software reset.
accel6_master_io_t write_f
Definition: accel6.h:544
Click configuration structure definition.
Definition: accel6.h:556
hal_i2c_address_t i2c_address
Definition: accel6.h:570
spi_master_t spi
Definition: accel6.h:539
void(* accel6_master_io_t)(struct accel6_s *, uint8_t, uint8_t *, uint8_t)
Master Input/Output type.
Definition: accel6.h:529
pin_name_t sck
Definition: accel6.h:564
pin_name_t cs
Definition: accel6.h:565
float accel6_get_temperature(accel6_t *ctx)
Functions for read temperature.
accel6_select_t sel
Definition: accel6.h:574
void accel6_data_offset(accel6_t *ctx, uint8_t set_offset, float *offset_data)
Functions for set offset.
i2c_master_t i2c
Definition: accel6.h:538
hal_i2c_address_t slave_address
Definition: accel6.h:543
pin_name_t scl
Definition: accel6.h:560
float device_freq
Definition: accel6.h:549
Click ctx object definition.
Definition: accel6.h:534
ACCEL6_RETVAL accel6_init(accel6_t *ctx, accel6_cfg_t *cfg)
Initialization function.
struct accel6_s accel6_t
Click ctx object definition.
float device_gaus
Definition: accel6.h:548
pin_name_t mosi
Definition: accel6.h:563
hal_spi_speed_t spi_speed
Definition: accel6.h:571
uint8_t accel6_select_t
Communication type.
Definition: accel6.h:524
accel6_select_t master_sel
Definition: accel6.h:546
void accel6_generic_read(accel6_t *ctx, uint8_t reg, uint8_t *data_buf, uint8_t len)
Generic read function.
hal_spi_mode_t spi_mode
Definition: accel6.h:572
#define ACCEL6_RETVAL
Definition: accel6.h:75
void accel6_get_orient(accel6_t *ctx, uint8_t *z_orient, uint8_t *xy_orient)
Functions for read orient.
pin_name_t sda
Definition: accel6.h:561
uint8_t accel6_get_tap_status(accel6_t *ctx)
Functions for detect tap on the x/y/z axis.
uint8_t accel6_get_slope_status(accel6_t *ctx)
Functions for detect slope on the x/y/z axis.
accel6_master_io_t read_f
Definition: accel6.h:545
pin_name_t miso
Definition: accel6.h:562
float accel6_get_axis(accel6_t *ctx, uint8_t axis)
Functions for read axis data.
void accel6_generic_write(accel6_t *ctx, uint8_t reg, uint8_t *data_buf, uint8_t len)
Generic write function.
void accel6_cfg_setup(accel6_cfg_t *cfg)
Config Object Initialization function.