FelipeMdeO opened a new pull request, #19997:
URL: https://github.com/apache/nuttx/pull/19997

   ## Summary
   
   No driver exists for the LSM6DS3TR-C. `lsm6dsl.c` is the closest
   register-compatible match (same WHO_AM_I, same CTRL1_XL/CTRL2_G layout)
   but is the deprecated legacy char-device style; `lsm6dso32_uorb.c` is the
   closest uORB-style match but is for a different chip variant. The new
   driver borrows `lsm6dso32_uorb.c`'s structure (dual `sensor_lowerhalf_s`,
   raw `I2C_TRANSFER` helpers) and `lsm6dsl.h`'s register map -- fixing a bug
   in the header it was ported from along the way: `LSM6DSL_FIFO_CTRL2_SHIFT`
   is defined as `255` instead of `0`.
   
   Delivery mode is chosen the same way mpu6050 does: kthread polling by
   default, or interrupt-driven if the board supplies `attach()`. 
   
   On the XIAO ESP32-S3 with Seeed's IMU Breakout Board, INT1/INT2 route to
   GPIO3/GPIO4 (confirmed from the breakout board's schematic, not guessed).
   Only INT1/GPIO3 is wired up, since one pin is now enough; GPIO4/INT2 is
   documented as available but unused.
   
   Also: `CTRL1_XL`'s FS_XL bits were never actually written to match the
   driver's own software default (4g) -- registration set the in-memory
   value but the chip stayed at its 2g reset default until a caller issued
   an explicit `SNIOC_SETFULLSCALE`. `register()` now writes it.
   
   Getting a full build for this board's console needed two unrelated fixes
   in `hal.mk`: esp-hal-3rdparty's `sleep_uart.c` and `bootloader_console.c`
   reference the ESP-IDF-style `CONFIG_ESP_CONSOLE_UART_NUM` /
   `CONFIG_ESP_CONSOLE_ROM_SERIAL_PORT_NUM` / 
`CONFIG_ESP_CONSOLE_USB_SERIAL_JTAG`
   macros directly. Only `Bootloader.mk` ever defined any of them, only for
   the bootloader build, and only for a UART console -- the main firmware
   build never defined them for any console, so linking failed with
   `bootloader_console_init` undefined as soon as a board actually used
   `CONFIG_ESP32S3_USBSERIAL` (this board's native USB Serial/JTAG console).
   
   ## Impact
   
   New optional driver (`CONFIG_SENSORS_LSM6DS3TRC`, default `n`), no impact
   on boards that don't enable it. The `hal.mk` fix only adds `CFLAGS`
   definitions gated on the board's console choice 
(`CONFIG_UART0/1_SERIAL_CONSOLE`,
   `CONFIG_ESP32S3_USBSERIAL`); boards already using a UART console are
   unaffected, boards using the native USB Serial/JTOG console (previously
   unable to link at all) now build.
   
   ## Testing
   
   Host: Ubuntu 24.04.4 LTS. `xtensa-esp-elf-gcc` (crosstool-NG
   esp-14.2.0_20241119) 14.2.0. `checkpatch.sh` (style + `-m` commit message)
   clean.
   
   **Compiles clean** for the XIAO ESP32-S3 target, rebased onto current
   master with no conflicts.
   
   **On hardware** -- Seeed XIAO ESP32-S3 Sense + IMU Breakout Board
   (LSM6DS3TR-C @ 0x6A, I2C0 SDA=GPIO5/SCL=GPIO6, INT1=GPIO3), native USB
   Serial/JTAG console:
   
   - `i2c dev 0 0x7f` finds the IMU at `0x6a` and the board's OLED at `0x3c`,
     matching the breakout board schematic.
   - `i2c get -a 0x6a -r 0x0f` reads `WHO_AM_I = 0x6a`.
   - Polling mode: `sensor_accel0`/`sensor_gyro0` stream continuously for
     minutes with no read errors, reproduced across multiple reboots.
   - Interrupt mode: reproduced across multiple fresh reboots, ~300 samples
     of each topic per 6s window (matching the configured 52 Hz ODR), with
     **shared timestamps down to the microsecond** between the two topics
     per event -- confirming both come from the same burst read:
   
     ```
     nsh> uorb_listener sensor_accel0,sensor_gyro0
     Monitor objects num:2
     object_name:sensor_gyro, object_instance:0
     object_name:sensor_accel, object_instance:0
     sensor_gyro(now:34860000):0x3fc96ae4B
     sensor_accel(now:34860000):0x3fc96ae4B
     sensor_gyro(now:34870000):0x3fc96ae4B
     sensor_accel(now:34870000):0x3fc96ae4B
     sensor_gyro(now:34890000):0x3fc96ae4B
     sensor_accel(now:34890000):0x3fc96ae4B
     ```
   
     (`%pB` prints as a raw pointer here because the bench defconfig didn't
     have `CONFIG_LIBC_PRINT_EXTENSION` on -- a `uorb_listener` display
     option, unrelated to this driver. The `now:` timestamps and the 1:1
     gyro/accel pairing are the real signal being verified.)


-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: [email protected]

For queries about this service, please contact Infrastructure at:
[email protected]

Reply via email to