Skip to content

drivers/sensors: Add support to mt6816 magnetic encoder#18807

Draft
acassis wants to merge 5 commits intoapache:masterfrom
acassis:mt6816_mag_encoder
Draft

drivers/sensors: Add support to mt6816 magnetic encoder#18807
acassis wants to merge 5 commits intoapache:masterfrom
acassis:mt6816_mag_encoder

Conversation

@acassis
Copy link
Copy Markdown
Contributor

@acassis acassis commented Apr 25, 2026

Summary

This PR adds support mt6816 magnetic rotary encoder.

Impact

Users will be able to use this low cost magnetic encoder with NuttX.

Testing

NuttShell (NSH) NuttX-12.13.0
nsh> qe
qe_main: Hardware initialized. Opening the encoder device: /dev/qe0
qe_main: Number of samples: 0
qe_main:   1. 6146
qe_main:   2. 6152
qe_main:   3. 6336
qe_main:   4. 6232
qe_main:   5. 6144
qe_main:   6. 6144
qe_main:   7. 6162
qe_main:   8. 6169                                                                
qe_main:   9. 6144                                                                
qe_main:  10. 6144

@github-actions github-actions Bot added Arch: arm Issues related to ARM (32-bit) architecture Area: Drivers Drivers issues Size: L The size of the change in this PR is large Board: arm labels Apr 25, 2026
Comment thread boards/arm/stm32/stm32f4discovery/src/stm32_bringup.c Outdated
Comment thread drivers/sensors/mt6816.c Outdated
Comment thread drivers/sensors/mt6816.c Outdated
@acassis acassis force-pushed the mt6816_mag_encoder branch 2 times, most recently from 42d5c5f to ababa9a Compare April 26, 2026 14:58
@acassis
Copy link
Copy Markdown
Contributor Author

acassis commented Apr 26, 2026

@simbit18 do you have some idea about this error:

  Generating Code...
sim_head.obj : error LNK2019: unresolved external symbol _host_set_timeratio referenced in function _main [D:\a\nuttx\nuttx\sources\nuttx\build\nuttx.vcxproj]
D:\a\nuttx\nuttx\sources\nuttx\build\Debug\nuttx.exe : fatal error LNK1120: 1 unresolved externals [D:\a\nuttx\nuttx\sources\nuttx\build\nuttx.vcxproj]
  An error occurred while copying files: Cannot find path 'D:\a\nuttx\nuttx\sources\nuttx\build\Debug\nuttx.exe' because it does not exist.
  Refresh completed successfully.
------------------------------------------------------------------------------------
End: 2026-04-26 15:11:52
====================================================================================
Error: Process completed with exit code 1.

@simbit18
Copy link
Copy Markdown
Contributor

simbit18 commented Apr 26, 2026

Hi @acassis It seems that this recent PR #18801 has broken the MSVC job

@LingaoM @xiaoxiang781216 Can you check?

@acassis
Copy link
Copy Markdown
Contributor Author

acassis commented Apr 26, 2026

Hi @acassis It seems that this recent PR #18801 has broken the MSVC job

@LingaoM @xiaoxiang781216 Can you check?

Thank you @simbit18 ! Do you have some idea to fix the msvc?

@acassis
Copy link
Copy Markdown
Contributor Author

acassis commented Apr 26, 2026

BTW I will convert this PR to Draft until #18798 get merge

@acassis acassis marked this pull request as draft April 26, 2026 18:51
@LingaoM
Copy link
Copy Markdown
Contributor

LingaoM commented Apr 27, 2026

oh, sorry for missing MSVC, please checkout this PR(#18809).

acassis added 5 commits April 27, 2026 12:58
NuttX uses Quadrature Encoder lower half driver to internal QE from
MCUs and also with Magnetic Rotary Encoder sensors. But when the
STM32 QE is not enabled, the board code will try to compile the
stm32_qencoder.c because Magnetic Rotary Encoders enables the
CONFIG_SENSORS_QENCODER. This patch fixes this issue.

Signed-off-by: Alan C. Assis <acassis@gmail.com>
This definition is needed to have multiplese Magnetic Sensors in the
same board.

Signed-off-by: Alan C. Assis <acassis@gmail.com>
This commit adds support to MagTek MT6816 sensor

Signed-off-by: Alan C. Assis <acassis@gmail.com>
This commit add support to use MagTek Magnetic Rotary Encoder MT6816
on STM32F4Discovery board.

Signed-off-by: Alan C. Assis <acassis@gmail.com>
This commit explain that the QE encoder driver can be used to
internal QE from microcontroller or external magnetic encoder.
Also explains how to use the mt6816 board profile to STM32F4Discovery

Signed-off-by: Alan C. Assis <acassis@gmail.com>
@acassis acassis force-pushed the mt6816_mag_encoder branch from ababa9a to b6f11d1 Compare April 27, 2026 16:02
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

Arch: arm Issues related to ARM (32-bit) architecture Area: Drivers Drivers issues Board: arm Size: L The size of the change in this PR is large

Projects

None yet

Development

Successfully merging this pull request may close these issues.

4 participants