am243x : add configuration of pulse per revolution - #162
Conversation
PR Summary by QodoAdd configurable PPR-based QPOS wraparound for AM243x PRU eQEP
AI Description
Diagram
High-Level Assessment
Files changed (7)
|
Code Review by Qodo
1.
|
|
/agentic_review |
|
Code review by qodo was updated up to the latest commit f8618ff |
f8618ff to
2ba57e6
Compare
|
/agentic_review |
|
Code review by qodo was updated up to the latest commit 2ba57e6 |
2ba57e6 to
90136a2
Compare
|
Code review by qodo was updated up to the latest commit 90136a2 |
90136a2 to
a3ee65e
Compare
|
/agentic_review |
|
Code review by qodo was updated up to the latest commit a3ee65e |
signed-off by Ayushman <a-ayushman@ti.com>
a3ee65e to
496e405
Compare
|
Code review by qodo was updated up to the latest commit 496e405 |
| no_increment0: | ||
| qbbc no_decrement0, qpos_update, 1 | ||
| sub QPOS, QPOS, 1 | ||
| ldi32 scratch2, 0xFFFFFFFF |
There was a problem hiding this comment.
Use fill &scratch2, 4 to save 1 cycle
|
|
||
| ; Cache QPOSMAX in a dedicated register once at boot, so the hot-path | ||
| ; overflow compares below don't pay for an ldi32 reload on every edge. | ||
| ldi32 qposmax_reg, QPOSMAX |
There was a problem hiding this comment.
ldi is sufficient since QPOSMAX < 16-bit
| sub QPOS, QPOS, 1 | ||
| ldi32 scratch2, 0xFFFFFFFF | ||
| qbne no_qpos_underflow0, QPOS, scratch2 ; only reload if result is exactly 0xFFFFFFFF (true underflow) | ||
| ldi32 QPOS, QPOSMAX |
There was a problem hiding this comment.
ldi is sufficient since QPOSMAX < 16-bit
| no_increment: | ||
| qbbc no_decrement, qpos_update, 1 | ||
| sub QPOS, QPOS, 1 | ||
| ldi32 scratch2, 0xFFFFFFFF |
| sub QPOS, QPOS, 1 | ||
| ldi32 scratch2, 0xFFFFFFFF | ||
| qbne no_qpos_underflow, QPOS, scratch2 ; only reload if result is exactly 0xFFFFFFFF (true underflow) | ||
| ldi32 QPOS, QPOSMAX |
| uint32_t phase_err_count_last_seen; | ||
| uint32_t phase_error_flag; | ||
|
|
||
| // Counter modulus published once by firmware at boot (PRU-write-once, R5F-read-once) |
There was a problem hiding this comment.
Use C style comments for consistency
| uint32_t *qposmax_base; | ||
| uint32_t qposmax; | ||
|
|
||
| // Direction of the last processed edge, published by firmware every edge |
| #define CH4_QPOSMAX_OFFSET 0x5C | ||
| #define CH5_QPOSMAX_OFFSET 0x60 | ||
|
|
||
| // Define last-direction offsets for each channel (PRU-write-every-edge, R5F-read-only) |
| ABZHandle[i]->qposmax = HW_RD_REG32((uint32_t)ABZHandle[i]->qposmax_base); | ||
| } | ||
|
|
||
| // Log messages |
signed-off by Ayushman a-ayushman@ti.com