Differences

This shows you the differences between two versions of the page.

Link to this comparison view

iothings:laboratoare:2025_code:lab6_1 [2025/10/28 15:18] (current)
dan.tudose created
Line 1: Line 1:
 +<code C LSM6DSL.h>​
 +#pragma once
 +#include <​Arduino.h>​
 +#include <​Wire.h>​
  
 +// Sparrow wiring / addresses
 +#define LSM6DSL_I2C_ADDR 0x6A
 +#define LSM6DSL_SDA_PIN ​ 21   // GPIO21 on Sparrow
 +#define LSM6DSL_SCL_PIN ​ 22   // GPIO22 on Sparrow
 +
 +// LSM6DSL registers we care about
 +#define LSM6DSL_CTRL1_XL ​  ​0x10 ​ // accel config
 +#define LSM6DSL_CTRL2_G ​   0x11  // gyro config
 +#define LSM6DSL_CTRL3_C ​   0x12  // IF_INC, BDU, etc.
 +#define LSM6DSL_OUTX_L_XL ​ 0x28  // accel data start (X_L, X_H, Y_L, Y_H, Z_L, Z_H)
 +
 +// Sensitivity:​ ±2g -> 0.061 mg/LSB = 0.000061 g/LSB
 +#define LSM6DSL_ACC_SENS_2G_G_PER_LSB ​ (0.061f / 1000.0f)
 +
 +class LSM6DSL {
 +public:
 +    bool begin();
 +    bool readAccelG(float &ax_g, float &ay_g, float &az_g);
 +
 +private:
 +    bool writeReg(uint8_t reg, uint8_t value);
 +    bool readBytes(uint8_t startReg, uint8_t *buffer, size_t len);
 +};
 +
 +</​code>​
iothings/laboratoare/2025_code/lab6_1.txt · Last modified: 2025/10/28 15:18 by dan.tudose
CC Attribution-Share Alike 3.0 Unported
www.chimeric.de Valid CSS Driven by DokuWiki do yourself a favour and use a real browser - get firefox!! Recent changes RSS feed Valid XHTML 1.0