yangsong8-a1 opened a new pull request, #21849:
URL: https://github.com/apache/nuttx/pull/21849
## Summary
Add a driver for the ARM SP804 dual timer (`CONFIG_TIMER_SP804`):
- `sp804_initialize()` returns a oneshot lower half that uses timer 1 as
the free-running counter and timer 2 as the alarm.
- `sp804_timer_initialize()` returns a timer lower half (periodic
`/dev/timerN`) on one timer, built when `CONFIG_TIMER` is set.
The board code calls them with the base address, the IRQ and the input
clock.
## Impact
New driver, off by default. No board enables it yet.
## Testing
Ubuntu 22.04, arm-none-eabi-gcc 10.3, QEMU 6.2.
| Config | Result |
|---|---|
| qemu-armv7a:nsh + TIMER_SP804 + TIMER + ONESHOT (Make and CMake) | builds,
0 warnings |
| mps2-an500:nsh + TIMER_SP804 + TIMER + ONESHOT | builds, 0 warnings |
| each commit, qemu-armv7a:nsh + TIMER_SP804 + ONESHOT | builds, 0 warnings
in sp804*.c from the second commit on (the first one warns about
`up_enable_irq`, fixed by the second) |
Runtime on QEMU mps2-an500, whose CMSDK APB dual timer at 0x40002000
(IRQ 10, 25 MHz) has the SP804 programming model. A test program registers
the driver, then the apps examples run on it (`...` marks elided status
lines):
```
nsh> hello t
hello t: register ret=0
nsh> timer
Open /dev/timer0
Set timer interval to 1000000
Attach timer handler
Start the timer
flags: 00000003 timeout: 1000000 timeleft: 870789 nsignals: 0
...
flags: 00000003 timeout: 1000000 timeleft: 95876 nsignals: 0
flags: 00000003 timeout: 1000000 timeleft: 992803 nsignals: 1
...
flags: 00000003 timeout: 1000000 timeleft: 998360 nsignals: 2
Stop the timer
Finished
```
```
nsh> hello o
hello o: register ret=0
nsh> oneshot
Opening /dev/oneshot
Maximum delay is 171798691
Starting oneshot timer with delay 2000000 microseconds
Waiting...
Finished
nsh> oneshot -d 500000
Opening /dev/oneshot
Maximum delay is 171798691
Starting oneshot timer with delay 500000 microseconds
Waiting...
Finished
```
--
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
To unsubscribe, e-mail: [email protected]
For queries about this service, please contact Infrastructure at:
[email protected]