[riot-notifications] [RIOT] cpu/samd21: added peripheral PWM driver (#3127)

Hauke Petersen notifications at github.com
Mon Jun 1 19:48:09 CEST 2015


> +
> +#include <stdint.h>
> +#include <string.h>
> +
> +#include "log.h"
> +#include "cpu.h"
> +#include "board.h"
> +#include "periph/pwm.h"
> +#include "periph_conf.h"
> +
> +/* ignore file in case no PWM devices are defined */
> +#if PWM_NUMOF
> +
> +static inline int _num(pwm_t dev)
> +{
> +    return ((int)(pwm_config[dev].dev) & 0xc00) >> 10;

simple: if you compare the bases address of all available TCC devices and look for their differences, youll see that they differ only in bits 10 and 11. So masking these bits and shifting them to the LSB positions, youll have upcounting integers 0, 1, 2 for the three TCC devices.

---
Reply to this email directly or view it on GitHub:
https://github.com/RIOT-OS/RIOT/pull/3127/files#r31450632
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.riot-os.org/pipermail/notifications/attachments/20150601/3b50b54e/attachment.html>


More information about the notifications mailing list