Hello Peter,
24.01.2016 08:25, Peter Crosthwaite пишет:
[snip]
+ timerblock_run(tb->timer, control, (value != 0) && (control & 1));
break;
case 8: /* Control. */
- old = tb->control;
- tb->control = value;
- if (value & 1) {
- if ((old & 1) && (tb->count != 0)) {
- /* Do nothing if timer is ticking right now. */
- break;
+ if ((value & 1) && (control & 3) != (value & 3)) {
+ uint64_t count = (value & 0xff00) ? 1 :
ptimer_get_count(tb->timer);
+ if ((count == 0) && (value & 2)) {
+ timerblock_set_count(tb->timer, value, &count);
This looks like a weird corner-case, what does it do exactly? I can't
follow it so it needs a comment :)
It does the following:
mode | prescaler | reload if counter == 0 | tick immediately if counter == 0
--------------------------------------------------------------------------------
oneshot == 0 0 0
oneshot != 0 0 1
periodic == 0 1 0
periodic != 0 0 1
If writing control register with prescaler = 0, then for one-shot timer with
counter == 0 or periodic timer with load = counter == 0 this is NOP. Will add a
comment.
Thanks for review!
--
Dmitry