Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

arch/arm/src/samv7/sam_qencoder.c: add support for GETINDEX ioctl call #12081

Merged
merged 1 commit into from
Apr 17, 2024

Conversation

zdebanos
Copy link
Contributor

@zdebanos zdebanos commented Apr 6, 2024

The SAMV7's qencoder driver now supports the GETINDEX ioctl call which does not reset the internal Timer/Counter and returns the current position, position of the last index and the number of captured indexes to a struct qe_index_s pointer. Because the SAMV7's timers are 16bit, the extension to 32 bits must be done.

Select CONFIG_SAMV7_QENCODER_ENABLE_GETINDEX in the Kconfig to enable this functionality.

This driver does not obey the instructions given in the ATSAMV7 2023 datasheet because the recommended trigger resets the internal counter which is not desired. Instead, a capture into capture A and capture B registers is used. This way if an event happens (the rising edge of the index signal), the current counter's value is captured.

arch/arm/src/samv7/sam_qencoder.c Outdated Show resolved Hide resolved
arch/arm/src/samv7/sam_qencoder.c Outdated Show resolved Hide resolved
arch/arm/src/samv7/sam_qencoder.c Outdated Show resolved Hide resolved
arch/arm/src/samv7/sam_qencoder.c Outdated Show resolved Hide resolved
arch/arm/src/samv7/sam_qencoder.c Outdated Show resolved Hide resolved
arch/arm/src/samv7/sam_qencoder.c Outdated Show resolved Hide resolved
arch/arm/src/samv7/sam_qencoder.c Outdated Show resolved Hide resolved
Comment on lines +273 to +254
uint32_t new_pos;
new_pos = sam_tc_getcounter(priv->tch);
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
uint32_t new_pos;
new_pos = sam_tc_getcounter(priv->tch);
uint16_t new_pos = sam_tc_getcounter(priv->tch);

Copy link
Contributor

@ppisa ppisa Apr 14, 2024

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Gain the use of uint32_t is based on the above described overhead with 16-bit operations on ARM and x86.

arch/arm/src/samv7/sam_qencoder.c Outdated Show resolved Hide resolved
arch/arm/src/samv7/sam_qencoder.c Outdated Show resolved Hide resolved
arch/arm/src/samv7/sam_qencoder.c Outdated Show resolved Hide resolved
arch/arm/src/samv7/sam_qencoder.c Outdated Show resolved Hide resolved
****************************************************************************/

static inline int32_t sam_qe_pos_16to32b(struct qe_lowerhalf_s *lower,
uint32_t current_pos)
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
uint32_t current_pos)
uint16_t current_pos)

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Gain, I expect no gain there

****************************************************************************/

static inline int32_t sam_qe_indx_pos_16to32b(struct qe_lowerhalf_s *lower,
uint32_t current_indx_pos)
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
uint32_t current_indx_pos)
uint16_t current_indx_pos)

arch/arm/src/samv7/sam_qencoder.c Outdated Show resolved Hide resolved
@zdebanos
Copy link
Contributor Author

zdebanos commented Apr 9, 2024

I'm sorry for my inactivity, however I'm considering everything and I'll look into it further at the end of this week. Thanks for feedback.

@acassis
Copy link
Contributor

acassis commented Apr 12, 2024

I'm sorry for my inactivity, however I'm considering everything and I'll look into it further at the end of this week. Thanks for feedback.

Don't worry! The most important is getting it working correctly!

arch/arm/src/samv7/sam_qencoder.c Outdated Show resolved Hide resolved
arch/arm/src/samv7/sam_qencoder.c Outdated Show resolved Hide resolved
The SAMV7's qencoder driver now supports the GETINDEX ioctl call
which does not reset the internal Timer/Counter and returns
the current position, position of the last index and the number
of captured indexes to a struct qe_index_s pointer. Because the
SAMV7's timers are 16bit, the extension to 32 bits must be done.

Select CONFIG_SAMV7_QENCODER_ENABLE_GETINDEX in the Kconfig to
enable this functionality.

This driver does not obey the instructions given in the ATSAMV7
2023 datasheet because the recommended trigger resets the internal
counter which is not desired. Instead, a capture into capture A
and capture B registers is used. This way if an event happens
(the rising edge of the index signal), the current counter's value
is captured.

Signed-off-by: Stepan Pressl <pressste@fel.cvut.cz>
@xiaoxiang781216 xiaoxiang781216 merged commit 1a2e752 into apache:master Apr 17, 2024
26 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

5 participants