[riot-notifications] [RIOT-OS/RIOT] cpu/rpx0xx: add periph timer (#16627)

Marian Buschsieweke notifications at github.com
Fri Aug 6 16:24:08 CEST 2021


@maribu approved this pull request.

ACK. One variable naming suggestion. Please squash right in, if you take it.

### `$ make BOARD=rpi-pico -C tests/periph_timer flash test`:

```
READY
s
START
main(): This is RIOT! (Version: 2021.10-devel-254-gee535f-fabian)

Test for peripheral TIMERs

Available timers: 1

Testing TIMER_0:
TIMER_0: initialization successful
TIMER_0: stopped
TIMER_0: set channel 0 to 5000
TIMER_0: set channel 1 to 10000
TIMER_0: set channel 2 to 15000
TIMER_0: set channel 3 to 20000
TIMER_0: starting
TIMER_0: channel 0 fired at SW count    59908 - init:    59908
TIMER_0: channel 1 fired at SW count   119659 - diff:    59751
TIMER_0: channel 2 fired at SW count   179561 - diff:    59902
TIMER_0: channel 3 fired at SW count   239467 - diff:    59906

TEST SUCCEEDED
```

### `$ make BOARD=rpi-pico -C tests/periph_timer_periodic flash test`

```
READY
s
START
main(): This is RIOT! (Version: 2021.10-devel-254-gee535f-fabian)

Running Timer 0 at 1000000 Hz.
One counter cycle is 25000 ticks or 25 ms
Will print 'tick' every cycle.

TEST START
[0] tick
[0] tick
[0] tick
[0] tick
[0] tick
[0] tick
[0] tick
[0] tick
[0] tick
[0] tick
[0] tick
[0] tick

Cycles:
channel 0 = 12	[OK]
TEST SUCCEEDED
```


### `$ make BOARD=rpi-pico -C tests/periph_timer_short_relative_set flash test`

```
READY
s
START
main(): This is RIOT! (Version: 2021.10-devel-254-gee535f-fabian)

Test for peripheral TIMER short timer_set()

This test tries timer_set() with decreasing intervals down to 0.
You should see lines like 'interval <n> ok', followed by a success message.
On failure, this test prints an error message.

testing periph_timer 0, freq 1000000
interval 99 ok
interval 98 ok
interval 97 ok
interval 96 ok
interval 95 ok
interval 94 ok
interval 93 ok
interval 92 ok
interval 91 ok
interval 90 ok
interval 89 ok
interval 88 ok
interval 87 ok
interval 86 ok
interval 85 ok
interval 84 ok
interval 83 ok
interval 82 ok
interval 81 ok
interval 80 ok
interval 79 ok
interval 78 ok
interval 77 ok
interval 76 ok
interval 75 ok
interval 74 ok
interval 73 ok
interval 72 ok
interval 71 ok
interval 70 ok
interval 69 ok
interval 68 ok
interval 67 ok
interval 66 ok
interval 65 ok
interval 64 ok
interval 63 ok
interval 62 ok
interval 61 ok
interval 60 ok
interval 59 ok
interval 58 ok
interval 57 ok
interval 56 ok
interval 55 ok
interval 54 ok
interval 53 ok
interval 52 ok
interval 51 ok
interval 50 ok
interval 49 ok
interval 48 ok
interval 47 ok
interval 46 ok
interval 45 ok
interval 44 ok
interval 43 ok
interval 42 ok
interval 41 ok
interval 40 ok
interval 39 ok
interval 38 ok
interval 37 ok
interval 36 ok
interval 35 ok
interval 34 ok
interval 33 ok
interval 32 ok
interval 31 ok
interval 30 ok
interval 29 ok
interval 28 ok
interval 27 ok
interval 26 ok
interval 25 ok
interval 24 ok
interval 23 ok
interval 22 ok
interval 21 ok
interval 20 ok
interval 19 ok
interval 18 ok
interval 17 ok
interval 16 ok
interval 15 ok
interval 14 ok
interval 13 ok
interval 12 ok
interval 11 ok
interval 10 ok
interval 9 ok
interval 8 ok
interval 7 ok
interval 6 ok
interval 5 ok
interval 4 ok
interval 3 ok
interval 2 ok
interval 1 ok
interval 0 ok

TEST SUCCEEDED
```

I ran the last test 33 times as this one has a stochastic element with 100% success rate.

> +/**
+ * @brief   Configuration type of a timer channel
+ */
+typedef struct {
+    IRQn_Type irqn;                 /**< timer channel interrupt number */
+} timer_channel_conf_t;
+
+/**
+ * @brief   Configuration type of a timer device @ref timer_conf_t::dev,
+ *          having @ref timer_conf_t::chn number of channels,
+ *          each one modeled as @ref timer_channel_conf_t
+ */
+typedef struct {
+    TIMER_Type *dev;                /**< pointer to timer base address */
+    const timer_channel_conf_t *ch; /**< pointer to timer channel configuration */
+    uint8_t chn;                    /**< number of timer channels */

```suggestion
    uint8_t ch_numof;               /**< number of timer channels */
```

The postfix `numof` is commonly used within RIOT's code base, maybe use it here as well for consistency?

-- 
You are receiving this because you are subscribed to this thread.
Reply to this email directly or view it on GitHub:
https://github.com/RIOT-OS/RIOT/pull/16627#pullrequestreview-724396003
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.riot-os.org/pipermail/notifications/attachments/20210806/14aeec04/attachment-0001.htm>


More information about the notifications mailing list