Concerns were self-test and performance, particularly the removal of busy-waiting.
When testing the AK8963, it's important if you're testing against the 16-bit resolution values to actually put the device into 16-bit mode when requesting the self-test. Doing this (and allowing up to 5 retries, as in this Samsung code) works, both on the AdaRacer board and on a breakout board connected to an STM32F407-Disco.
The main problem is the lengthy time (more than a milliseond of CPU) to read the AK8963 data. Possible approaches include
- decreasing the Ada tick rate to 100 μs
- using one of the MCU's timers to manage short intervals
- using the MPU9250 FIFO
Of these, the least intrusive would probably be using the FIFO, but it seems that (in spite of the extensive if opaque description in the Register Map) it's not possible to get magnetometer data into the FIFO unless you're using the (proprietary) Digital Motion Processor firmware.
- The MCU has 14 timers, but they aren't as independent as you'd like; TIM14 shares an interrupt with (some aspects of) TIM8.
- This code isn't task-safe; some way would need to be found to ensure that only one task at a time tries to use it.