periph_cpu.h
Go to the documentation of this file.
1 /*
2  * Copyright (C) 2015 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 PERIPH_CPU_H
20 #define PERIPH_CPU_H
21 
22 #include "periph_conf.h"
23 
24 #ifdef __cplusplus
25 extern "C" {
26 #endif
27 
31 #ifndef CPUID_LEN
32 #define CPUID_LEN (4U)
33 #endif
34 
35 /* GPIO configuration only if the module is available (=Linux) */
36 #if defined(MODULE_PERIPH_GPIO_LINUX) || defined(DOXYGEN)
37 #include <linux/gpio.h>
38 
47 #define GPIO_PORT_SHIFT (24)
48 
52 #define GPIO_PIN(port, pin) (gpio_t)((port << GPIO_PORT_SHIFT) | pin)
53 
54 #define HAVE_GPIO_MODE_T
55 #ifndef GPIOHANDLE_REQUEST_PULL_DOWN
56 #define GPIOHANDLE_REQUEST_PULL_DOWN (0xFF)
57 #endif
58 #ifndef GPIOHANDLE_REQUEST_PULL_UP
59 #define GPIOHANDLE_REQUEST_PULL_UP (0xFF)
60 #endif
61 
70 typedef enum {
71  GPIO_IN = GPIOHANDLE_REQUEST_INPUT,
72  GPIO_IN_PD = GPIOHANDLE_REQUEST_INPUT | GPIOHANDLE_REQUEST_PULL_DOWN,
73  GPIO_IN_PU = GPIOHANDLE_REQUEST_INPUT | GPIOHANDLE_REQUEST_PULL_UP,
74  GPIO_OUT = GPIOHANDLE_REQUEST_OUTPUT,
75  GPIO_OD = GPIOHANDLE_REQUEST_OPEN_DRAIN,
76  GPIO_OD_PU = GPIOHANDLE_REQUEST_OPEN_DRAIN | GPIOHANDLE_REQUEST_PULL_UP
77 } gpio_mode_t;
78 
79 #define HAVE_GPIO_FLANK_T
80 typedef enum {
81  GPIO_FALLING = GPIOEVENT_EVENT_FALLING_EDGE,
82  GPIO_RISING = GPIOEVENT_EVENT_RISING_EDGE,
84 } gpio_flank_t;
85 
88 #endif /* MODULE_PERIPH_GPIO_LINUX | DOXYGEN */
89 
93 #define PERIPH_TIMER_PROVIDES_SET
94 
99 #define PROVIDES_PM_OFF
100 #define PROVIDES_PM_SET_LOWEST
101 
103 /* Configuration for the wrapper around the Linux SPI API (periph_spidev_linux)
104  *
105  * Needs to go here, otherwise the SPI_NEEDS_ are defined after inclusion of
106  * spi.h.
107  */
108 #if defined(MODULE_PERIPH_SPIDEV_LINUX) || defined(DOXYGEN)
109 
117 #define PERIPH_SPI_NEEDS_TRANSFER_BYTE
118 
121 #define PERIPH_SPI_NEEDS_TRANSFER_REG
122 
125 #define PERIPH_SPI_NEEDS_TRANSFER_REGS
126 
127 #ifndef DOXYGEN
128 
131 #define HAVE_SPI_CLK_T
132 
139 typedef enum {
140  SPI_CLK_100KHZ = (100000U),
141  SPI_CLK_400KHZ = (400000U),
142  SPI_CLK_1MHZ = (1000000U),
143  SPI_CLK_5MHZ = (5000000U),
144  SPI_CLK_10MHZ = (10000000U)
145 } spi_clk_t;
147 #endif /* ndef DOXYGEN */
148 #endif /* MODULE_PERIPH_SPI | DOXYGEN */
149 
154 #ifndef EEPROM_SIZE
155 #define EEPROM_SIZE (1024U) /* 1kB */
156 #endif
157 
159 #ifdef __cplusplus
160 }
161 #endif
162 
163 #endif /* PERIPH_CPU_H */
164 
configure as output in push-pull mode
Definition: gpio.h:122
emit interrupt on rising flank
Definition: periph_cpu.h:82
drive the SPI bus with 100KHz
Definition: periph_cpu.h:636
drive the SPI bus with 400KHz
Definition: periph_cpu.h:637
drive the SPI bus with 1MHz
Definition: periph_cpu.h:638
gpio_flank_t
Definition: periph_cpu.h:80
drive the SPI bus with 5MHz
Definition: periph_cpu.h:639
emit interrupt on both flanks
Definition: periph_cpu.h:83
spi_clk_t
Available SPI clock speeds.
Definition: spi.h:173
Native CPU peripheral configuration.
emit interrupt on falling flank
Definition: periph_cpu.h:81
configure as input with pull-up resistor
Definition: gpio.h:121
configure as input without pull resistor
Definition: gpio.h:119
drive the SPI bus with 10MHz
Definition: periph_cpu.h:640
configure as output in open-drain mode without pull resistor
Definition: gpio.h:123
gpio_mode_t
Available pin modes.
Definition: periph_cpu.h:70
configure as input with pull-down resistor
Definition: gpio.h:120
configure as output in open-drain mode with pull resistor enabled
Definition: gpio.h:125