/*
 * lis2dw.c
 *
 *  Created on: Oct 11, 2024
 *      Author: true
 */


#include "lis2dw_i2c.h"

#include <stdint.h>



void lis2dw_init()
{
    uint8_t buf[2];

    /*
    buf[0] = ADXL345_REG_DATAX0 | ADXL345_MODE_RD | ADXL345_MODE_MB;
    memset(&buf[1], 0x00, 6);
    lis2dw_i2c_write(LIS2DW_I2C_ADDR);
    adxl_spi_xfer(ADXL345_SPI_DEV, buf, buf, 7);
    */
}

void lis2dw_set_power_mode(uint8_t mode)
{

}

void lis2dw_read_axes(uint16_t *x, uint16_t *y, uint16_t *z)
{
    uint8_t buf[6];

    buf[0] = LIS2DW_REG_OUT_X_L;
    lis2dw_i2c_write(LIS2DW_I2C_ADDR, buf, 1);
    lis2dw_i2c_read(LIS2DW_I2C_ADDR, buf, 6);

    *x = buf[0] | buf[1] << 8;
    *y = buf[2] | buf[3] << 8;
    *z = buf[4] | buf[5] << 8;
}
