[riot-notifications] [RIOT-OS/RIOT] Atmega PWM implementation (#7542)

lebrush notifications at github.com
Fri Sep 15 10:04:41 CEST 2017


I thought how to integrate them and finally decided to create a new timer definition called `mini_timer_t` instead of `mega_timer_t` since they are 8-bit timers and registers are also different. Defining it within the same struct might lead some future developer to fiddle for a while because "xtimer won't work" as it requires at least 16-bit timers. This was the reasoning behind it.

On the other hand 16-bit timers could be used for the PWM... one possibility that comes to my mind is the following:

```C
typedef struct {
    uint8_t len;
    union {
         mini_timer_t mini;
         mega_time_t mega;
    };
} atmega_timer_t
```

Then per CPU to define how the timer layout looks like. e.g.:

```C
/* 328p */
const atmega_timer_t timer_conf[] = {
    { 8, MINI_TIMER0 },
    { 16, MEGA_TIMER1 },
    { 8, MINI_TIMER2 }
}
#define TIMER_NUMOF (sizeof(...)/sizeof(...))
```
Every component which uses the timers (timer.c, rtt.c, pwm.c) can access them with a convenience macro such as

```C
#define ATMEGA_TIMER(x) (x)
```
and identify which is the timer length/bits and how to interact with it. 

In any case I would leave PWM and RTT as they are right now, and start working on a timer refactorization afterwards since it's a major change. 

Opinions @roberthartung @haukepetersen @smlng ?

(let's keep the PRR discussion on the other thread)

-- 
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/7542#issuecomment-329711830
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.riot-os.org/pipermail/notifications/attachments/20170915/a07de2d3/attachment.html>


More information about the notifications mailing list