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

   ## Summary
   
   This PR introduces a driver for the LIS2MDL magnetometer by ST 
Microelectronics. It is capable of being driven in interrupt mode, or use a 
kernel thread to poll the sensor in applications without an interrupt pin.
   
   The following features are supported:
   - Calibration
   - Interval selection
   - Activation/deactivation
   - Interrupt or polling driven
   - Setting of calibration values (hard iron offsets)
   - Getting sensor information
   - Custom commands for entering low-power mode/rebooting
   
   ## Impact
   
   This will add another UORB capable driver to NuttX, which allows more users 
to put it in their applications. Its interface being interrupt-driven or polled 
also gives flexibility to more applications.
   
   This magnetometer is being used on both my flight computer and InSpace's 
flight computer for rocketry applications. We hope adding a UORB driver for it 
will help other enthusiasts!
   
   ## Testing
   
   Documentation was tested by building the docs locally and verifying that 
they render properly in the browser.
   
   All hardware testing was performed on my RP2040-based flight computer.
   
   Verification of magnetometer data was done by using the ``uorb_listener`` 
application and viewing the displayed readings in NSH. I moved a small magnet 
around the magnetometer during this time and was able to see the values change 
in accordance with the positive/negative directions of each of the X, Y, Z axes.
   
   ```console
   nsh> uorb_listener
   
   Mointor objects num:1
   object_name:sensor_mag, object_instance:0
   
sensor_mag(now:59820000):timestamp:59820000,x:-54.599998,y:22.200001,z:-201.150009,temperature:23.578125,status:0
   
sensor_mag(now:59930000):timestamp:59930000,x:-24.000000,y:-5.100000,z:-233.999985,temperature:24.375000,status:0
   
sensor_mag(now:60040000):timestamp:60040000,x:-22.949999,y:-4.800000,z:-234.599991,temperature:24.402344,status:0
   
sensor_mag(now:60150000):timestamp:60150000,x:-24.000000,y:-4.500000,z:-233.250000,temperature:24.375000,status:0
   
sensor_mag(now:60260000):timestamp:60260000,x:-24.000000,y:-5.550000,z:-234.599991,temperature:24.375000,status:0
   ```
   
   I also tried selecting different measurement rates with ``uorb_listener`` to 
verify that data was properly output faster/slower depending on the rate, and 
that the data was not static but being read as fast as the ODR was set to.
   
   I tried registering the device driver in interrupt-driven mode without 
`CONFIG_SCHED_HPWORK` enabled, and verified that the driver registration 
function returned `ENOSYS` and logged an error.
   
   ```console
   nsh> dmesg
   nx_start: Entry
   nx_start_application: Starting init thread
   lis2mdl_register: LIS2MDL driver needs `CONFIG_SCHED_HPWORK` in order to be 
interrupt driven.
   Couldn't register LIS2MDL 0x1E: -38
   uart_registeconsole
   uart_register: Registering /dev/ttyACM0
   nx_start: CPU0: Beginning Idle Loop
   ```
   
   I also tried register the device driver in kernel thread polling mode 
without `CONFIG_SCHED_HPWORK` enabled and verified that it did work as expected:
   
   ```console
   nsh> dmesg
   nx_start: Entry
   nx_start_application: Starting init thread
   nxtask_activate: lis2mdl_thread pid=2,TCB=0x20005978
   lis2mdl_register: Registered driver with kernel polling thread.
   lis2mdl_register: Registered LIS2MDL driver.
   uart_register: Registering /dev/console
   uart_register: Registering /dev/ttyACM0
   nx_start: CPU0: Beginning Idle Loop
   ```


-- 
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: commits-unsubscr...@nuttx.apache.org

For queries about this service, please contact Infrastructure at:
us...@infra.apache.org

Reply via email to