33#define ADXL345_DATA_FORMAT ((adxl->config.int_invert<<5)|(adxl->config.full_res<<3)|(adxl->config.justify_msb<<2)|(adxl->config.range))
41 adxl->i2c_trans.slave_addr = addr;
45 adxl->initialized =
false;
52 adxl->i2c_trans.buf[0] = reg;
54 adxl->i2c_trans.len_r = 0;
55 adxl->i2c_trans.len_w = 2;
62 switch (
adxl->init_status) {
81 adxl->initialized =
true;
106 adxl->i2c_trans.len_r = 6;
107 adxl->i2c_trans.len_w = 1;
112#define Int16FromBuf(_buf,_idx) ((int16_t)((_buf[_idx+1]<<8) | _buf[_idx]))
116 if (
adxl->initialized) {
124 adxl->data_available =
true;
static void adxl345_set_default_config(struct Adxl345Config *c)
void adxl345_i2c_start_configure(struct Adxl345_I2c *adxl)
Start configuration if not already done.
void adxl345_i2c_read(struct Adxl345_I2c *adxl)
static void adxl345_i2c_tx_reg(struct Adxl345_I2c *adxl, uint8_t reg, uint8_t val)
#define ADXL345_DATA_FORMAT
static void adxl345_i2c_send_config(struct Adxl345_I2c *adxl)
void adxl345_i2c_init(struct Adxl345_I2c *adxl, struct i2c_periph *i2c_p, uint8_t addr)
void adxl345_i2c_event(struct Adxl345_I2c *adxl)
#define Int16FromBuf(_buf, _idx)
Driver for the accelerometer ADXL345 from Analog Devices using I2C.
#define ADXL345_REG_DATA_X0
#define ADXL345_REG_BW_RATE
#define ADXL345_REG_DATA_FORMAT
#define ADXL345_REG_POWER_CTL
#define ADXL345_REG_INT_ENABLE
static bool i2c_submit(struct i2c_periph *p, struct i2c_transaction *t)
Submit a I2C transaction.
@ I2CTransSuccess
transaction successfully finished by I2C driver
@ I2CTransFailed
transaction failed
@ I2CTransDone
transaction set to done by user level
@ I2CTransTx
transmit only transaction
@ I2CTransTxRx
transmit and receive transaction
unsigned char uint8_t
Typedef defining 8 bit unsigned char type.