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 MODULE_PERIPH_CAN
160 #include "candev_linux.h"
161 #endif
162 
163 #ifdef __cplusplus
164 }
165 #endif
166 
167 #endif /* PERIPH_CPU_H */
168 
SPI_CLK_400KHZ
@ SPI_CLK_400KHZ
drive the SPI bus with 400KHz
Definition: periph_cpu.h:653
SPI_CLK_100KHZ
@ SPI_CLK_100KHZ
drive the SPI bus with 100KHz
Definition: periph_cpu.h:652
periph_conf.h
Native CPU peripheral configuration.
GPIO_IN_PD
@ GPIO_IN_PD
configure as input with pull-down resistor
Definition: gpio.h:120
GPIO_OD
@ GPIO_OD
configure as output in open-drain mode without pull resistor
Definition: gpio.h:123
GPIO_OUT
@ GPIO_OUT
configure as output in push-pull mode
Definition: gpio.h:122
GPIO_FALLING
@ GPIO_FALLING
emit interrupt on falling flank
Definition: periph_cpu.h:81
GPIO_IN_PU
@ GPIO_IN_PU
configure as input with pull-up resistor
Definition: gpio.h:121
candev_linux.h
Implementation of simulated CAN controller driver using SocketCAN on Linux.
GPIO_RISING
@ GPIO_RISING
emit interrupt on rising flank
Definition: periph_cpu.h:82
SPI_CLK_10MHZ
@ SPI_CLK_10MHZ
drive the SPI bus with 10MHz
Definition: periph_cpu.h:656
spi_clk_t
uint32_t spi_clk_t
SPI clock type.
Definition: periph_cpu.h:662
GPIO_IN
@ GPIO_IN
configure as input without pull resistor
Definition: gpio.h:119
SPI_CLK_5MHZ
@ SPI_CLK_5MHZ
drive the SPI bus with 5MHz
Definition: periph_cpu.h:655
gpio_flank_t
gpio_flank_t
Definition: periph_cpu.h:80
GPIO_OD_PU
@ GPIO_OD_PU
configure as output in open-drain mode with pull resistor enabled
Definition: gpio.h:125
GPIO_BOTH
@ GPIO_BOTH
emit interrupt on both flanks
Definition: periph_cpu.h:83
gpio_mode_t
gpio_mode_t
Available pin modes.
Definition: periph_cpu.h:70
SPI_CLK_1MHZ
@ SPI_CLK_1MHZ
drive the SPI bus with 1MHz
Definition: periph_cpu.h:654