drivers/qma6100p: add QST QMA6100P 3-axis accelerometer driver#22352
drivers/qma6100p: add QST QMA6100P 3-axis accelerometer driver#22352leduclean wants to merge 1 commit into
Conversation
Add a driver for the QST QMA6100P 3-axis accelerometer over I2C. Features: - Configurable full-scale range, output data rate and power mode - Acceleration readout on all three axes - Data-ready interrupt support - SAUL integration - Kconfig configuration Includes a test application under tests/drivers/qma6100p covering basic readout and the data-ready interrupt. Co-authored-by: Léandre Le Duc <leandre.leduc38@gmail.com> Signed-off-by: Baptiste Le Duc <baptiste.leduc@etik.com>
|
Hey @leduclean, thank you for your first contribution! We really appreciate it! If you haven't already, please take a look at our contributing guidelines before the review process starts. Also, due to how the GitHub review system works, please avoid force-pushing or squashing your commits unless asked to by a maintainer (or unless your commit is still in "draft commit" stage). Your pull request will be reviewed as soon as possible. |
|
First Sanji and now Foxy, seems like there is a theme here 😛 Thank you for your PR, it seems like there are still some issues you need to fix to get through our CI, see here: https://ci.riot-os.org/details/b17c1a96704744cbb4adb7763282d497 I'd presume that @baptleduc can vouch for the functionality of this? |
Ahah brothers fans of one piece 😄 Yes I will fix it but @leduclean already took a look and he struggled to find what was the real issue |
|
It is weird because the murdock error indicates it is because of map_regs variable that could be used uninitialized in qma6100p_set_data_ready_interrupt() while there are no branches where it could be the case. Could you please help us to understand this ? Thanks ! |
|
Hmmm does this also happen when you run the test locally or only on murdock? |
|
The compiler complains about the use of It is possible that the compiler can't resolve the In general, I think the use of |
You are right, but where do you see such usage ? You mean that we shouldn't pass the |
| (void)args; | ||
| irq_count++; | ||
| if (reader_pid != KERNEL_PID_UNDEF) { | ||
| thread_flags_set(thread_get(reader_pid), FLAG_DATA_READY); |
| * @param[in] dev device descriptor of accelerometer | ||
| * @param[out] data raw ADC counts per axis | ||
| * | ||
| * @return QMA6100P_NODATA if nothing has changed and keep data unchanged. |
There was a problem hiding this comment.
QMA6100P_NODATA is not defined
| if (res == -ENXIO) { | ||
| return QMA6100P_NODEV; | ||
| } | ||
| if (res == -EINVAL) { | ||
| return QMA6100P_INVALID_ARG; |
There was a problem hiding this comment.
Why use custom error codes here?
There was a problem hiding this comment.
It is a wrapper as one of the maintainer suggest when I did the ads1x1x driver
| /* Wait for OTP to load */ | ||
| do { | ||
| READ_REG(QMA6100P_REG_NVM, nvm_status, out); | ||
| } while ((nvm_status & (QMA6100P_NVM_LOAD_DONE | QMA6100P_NVM_RDY)) != |
There was a problem hiding this comment.
better add a limit on the number of retries
| * @brief Interrupt configuration parameters | ||
| */ | ||
| typedef struct { | ||
| gpio_t interrupt_pin; /**< MCU GPIO connected to the QMA6100P INT pin */ |
There was a problem hiding this comment.
This should be part of qma6100p_params_t
| typedef struct { | ||
| gpio_t interrupt_pin; /**< MCU GPIO connected to the QMA6100P INT pin */ | ||
| qma6100p_int_active_level_t active_level_int; /**< active level of INT pin */ | ||
| qma6100p_int_pin_mode_t pin_mode_int; /**< INT pin output mode */ |
There was a problem hiding this comment.
Why would you need this to be configurable?
| gpio_t interrupt_pin; /**< MCU GPIO connected to the QMA6100P INT pin */ | ||
| qma6100p_int_active_level_t active_level_int; /**< active level of INT pin */ | ||
| qma6100p_int_pin_mode_t pin_mode_int; /**< INT pin output mode */ | ||
| qma6100p_int_shadow_t interrupt_shadow; /**< shadow mode */ |
| qma6100p_int_active_level_t active_level_int; /**< active level of INT pin */ | ||
| qma6100p_int_pin_mode_t pin_mode_int; /**< INT pin output mode */ | ||
| qma6100p_int_shadow_t interrupt_shadow; /**< shadow mode */ | ||
| qma6100p_int_pin_num_t interrupt_pin_num; /**< QMA6100P INT pin routed on the board */ |
There was a problem hiding this comment.
I guess that means you can have multiple interrupt pins for different events?
| * | ||
| * Work mode is controlled by PM_REGISTER (0x11) and can be set through I2C commands | ||
| * | ||
| * @warning By default, QMA6100P is in intermediate state after power on but it shouldn't be keep for any applications |
There was a problem hiding this comment.
Then there should only be a qma6100p_set_low_power(bool) right?
| * | ||
| * @warning The callback is invoked from interrupt context, keep it short | ||
| */ | ||
| int qma6100p_set_data_ready_int(qma6100p_t *dev, const qma6100p_int_t *interrupt); |
There was a problem hiding this comment.
I guess the more idiomatic way would be
| int qma6100p_set_data_ready_int(qma6100p_t *dev, const qma6100p_int_t *interrupt); | |
| int qma6100p_set_data_ready_int(qma6100p_t *dev, const qma6100p_int_params_t *config, qma6100p_int_cb_t cb, void *arg); |
| */ | ||
| typedef enum { | ||
| QMA6100P_INT_CFG_SHADOW_EN = 0, /**< shadowing enabled (default) */ | ||
| QMA6100P_INT_CFG_SHADOW_DIS = 1, /**< shadowing disabled */ |

Add a driver for the QST QMA6100P 3-axis accelerometer over I2C.
This driver was needed to support the Seeed Studio SenseCAP T1000-E tracker,
which embeds a QMA6100P as its motion sensor.
Features:
Includes a test application under
tests/drivers/qma6100pcovering basicreadout and the data-ready interrupt.
Testing procedure
Wire a QMA6100P to a board exposing an I2C bus (e.g. the Seeed Studio SenseCAP
T1000-E), then build and flash the test application (adjust
BOARDand the I2Cparameters as needed):
The test:
ISR frequency and asserting it matches the configured ODR.
sample over I2C.
Expected output:
Issues/PRs references
#22267
Useful link
Declaration of AI Tools / LLMs usage
Co-authored-by: Baptiste Le Duc baptiste.leduc@etik.com
Signed-off-by: Léandre Le Duc leandre.leduc38@gmail.com