The friendly Operating System for the Internet of Things
samd21/include/periph_cpu.h
Go to the documentation of this file.
1 /*
2  * Copyright (C) 2015-2016 Freie Universit├Ąt Berlin
3  *
4  * This file is subject to the terms and conditions of the GNU Lesser
5  * General Public License v2.1. See the file LICENSE in the top level
6  * directory for more details.
7  */
8 
19 #ifndef CPU_PERIPH_H
20 #define CPU_PERIPH_H
21 
22 #include <limits.h>
23 
24 #include "periph_cpu_common.h"
25 
26 #ifdef __cplusplus
27 extern "C" {
28 #endif
29 
33 enum {
34  PA = 0,
35  PB = 1,
36  PC = 2,
37 };
38 
47 #define GPIO_MODE(pr, ie, pe) (pr | (ie << 1) | (pe << 2))
48 
54 #define SPI_HWCS(x) (UINT_MAX - 1)
55 
56 #ifndef DOXYGEN
57 
61 #define HAVE_GPIO_MODE_T
62 typedef enum {
63  GPIO_IN = GPIO_MODE(0, 1, 0),
64  GPIO_IN_PD = GPIO_MODE(0, 1, 1),
65  GPIO_IN_PU = GPIO_MODE(1, 1, 1),
66  GPIO_OUT = GPIO_MODE(0, 0, 0),
67  GPIO_OD = 0xfe,
68  GPIO_OD_PU = 0xff
69 } gpio_mode_t;
71 #endif /* ndef DOXYGEN */
72 
76 typedef struct {
77  gpio_t pin;
79  uint8_t chan;
81 
85 typedef struct {
86  Tcc *dev;
87  pwm_conf_chan_t chan[3];
88 } pwm_conf_t;
89 
93 typedef struct {
94  SercomUsart *dev;
95  gpio_t rx_pin;
96  gpio_t tx_pin;
97  gpio_mux_t mux;
100 } uart_conf_t;
101 
109 static inline int _sercom_id(SercomUsart *sercom)
110 {
111  return ((((uint32_t)sercom) >> 10) & 0x7) - 2;
112 }
113 
114 #define PM_NUM_MODES (3)
115 
116 #ifdef __cplusplus
117 }
118 #endif
119 
120 #endif /* CPU_PERIPH_H */
121 
uart_txpad_t
Available values for SERCOM UART TX pad selection.
gpio_mux_t mux
pin function multiplex value
PWM configuration structure.
SercomUsart * dev
pointer to the used UART device
uart_txpad_t tx_pad
pad selection for TX line
uart_rxpad_t
Available values for SERCOM UART RX pad selection.
gpio_mux_t
Available MUX values for configuring a pin's alternate function.
uart_rxpad_t rx_pad
pad selection for RX line
PWM channel configuration data structure.
input, pull-up
static int _sercom_id(SercomUsart *sercom)
Return the numeric id of a SERCOM device derived from its address.
Tcc * dev
TCC device to use.
UART device configuration.
input, no pull
#define GPIO_MODE(pr, ie, pe)
Generate GPIO mode bitfields.
not supported
input, pull-down
uint8_t chan
TCC channel to use.