All Data Structures Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Modules Pages
Loading...
Searching...
No Matches
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
25extern "C" {
26#endif
27
31#if !defined(CPUID_LEN) || defined(DOXYGEN)
32# define CPUID_LEN (4U)
33#endif
34
38#if !defined(PM_NUM_MODES) || defined(DOXYGEN)
39# define PM_NUM_MODES (1U)
40#endif
41
45#define PROVIDES_PM_LAYERED_OFF
46
47/* GPIO configuration only if the module is available (=Linux) */
48#if defined(MODULE_PERIPH_GPIO_LINUX) || defined(DOXYGEN)
49# include <linux/gpio.h>
50
51/* MARK: - GPIO Configuration */
59# define GPIO_PORT_SHIFT (24)
60
64# define GPIO_PIN(port, pin) (gpio_t)((port << GPIO_PORT_SHIFT) | pin)
65
69# define HAVE_GPIO_MODE_T
73# if !defined(GPIOHANDLE_REQUEST_PULL_DOWN) || defined(DOXYGEN)
74# define GPIOHANDLE_REQUEST_PULL_DOWN (0xFF)
75# endif
79# if !defined(GPIOHANDLE_REQUEST_PULL_UP) || defined(DOXYGEN)
80# define GPIOHANDLE_REQUEST_PULL_UP (0xFF)
81# endif
82
91typedef enum {
92 GPIO_IN = GPIOHANDLE_REQUEST_INPUT,
93 GPIO_IN_PD = GPIOHANDLE_REQUEST_INPUT | GPIOHANDLE_REQUEST_PULL_DOWN,
94 GPIO_IN_PU = GPIOHANDLE_REQUEST_INPUT | GPIOHANDLE_REQUEST_PULL_UP,
95 GPIO_OUT = GPIOHANDLE_REQUEST_OUTPUT,
96 GPIO_OD = GPIOHANDLE_REQUEST_OPEN_DRAIN,
97 GPIO_OD_PU = GPIOHANDLE_REQUEST_OPEN_DRAIN | GPIOHANDLE_REQUEST_PULL_UP
99
103# define HAVE_GPIO_FLANK_T
104
108typedef enum {
109 GPIO_FALLING = GPIOEVENT_EVENT_FALLING_EDGE,
110 GPIO_RISING = GPIOEVENT_EVENT_RISING_EDGE,
111 GPIO_BOTH = GPIO_FALLING | GPIO_RISING
115#elif defined(MODULE_PERIPH_GPIO_MOCK)
116
122typedef struct {
123 int value;
124 int mode;
125 int flank;
126 void (*cb)(void *arg);
127 void *arg;
128} gpio_mock_t;
129
130# define GPIO_UNDEF 0
131
132# if !defined(GPIO_PORT_MAX) || defined(DOXYGEN)
133# define GPIO_PORT_MAX (16)
134# endif
135
136# if !defined(GPIO_PIN_MAX) || defined(DOXYGEN)
137# define GPIO_PIN_MAX (32)
138# endif
139
143extern gpio_mock_t gpio_mock[GPIO_PORT_MAX][GPIO_PIN_MAX];
144
145# define HAVE_GPIO_T
149typedef gpio_mock_t* gpio_t;
150
155# define GPIO_PIN(port, pin) \
156 (((port >= 0) && (pin >= 0) && (port < GPIO_PORT_MAX) && (pin < GPIO_PIN_MAX)) \
157 ? &gpio_mock[port][pin] \
158 : GPIO_UNDEF)
159
160#endif /* MODULE_PERIPH_GPIO_LINUX | DOXYGEN */
161
165#define PERIPH_TIMER_PROVIDES_SET
166
167/* MARK: - Power management configuration*/
172#define PROVIDES_PM_OFF
173#define PROVIDES_PM_SET_LOWEST
176/* Configuration for the wrapper around the Linux SPI API (periph_spidev_linux)
177 *
178 * Needs to go here, otherwise the SPI_NEEDS_ are defined after inclusion of
179 * spi.h.
180 */
181#if defined(MODULE_PERIPH_SPIDEV_LINUX) || defined(DOXYGEN)
182/* MARK: - SPI Configuration */
190# define PERIPH_SPI_NEEDS_TRANSFER_BYTE
194# define PERIPH_SPI_NEEDS_TRANSFER_REG
198# define PERIPH_SPI_NEEDS_TRANSFER_REGS
199
200# ifndef DOXYGEN
204# define HAVE_SPI_CLK_T
211typedef enum {
212 SPI_CLK_100KHZ = (100000U),
213 SPI_CLK_400KHZ = (400000U),
214 SPI_CLK_1MHZ = (1000000U),
215 SPI_CLK_5MHZ = (5000000U),
216 SPI_CLK_10MHZ = (10000000U)
217} spi_clk_t;
218# endif /* ndef DOXYGEN */
220#endif /* MODULE_PERIPH_SPI | DOXYGEN */
221
225#if !defined(EEPROM_SIZE) || defined(DOXYGEN)
226# define EEPROM_SIZE (1024U) /* 1kB */
227#endif
228
229#ifdef MODULE_PERIPH_CAN
230# include "candev_linux.h"
231#endif
232
233#ifdef __cplusplus
234}
235#endif
236
237#endif /* PERIPH_CPU_H */
gpio_flank_t
Definition periph_cpu.h:180
spi_clk_t
SPI clock type.
Definition periph_cpu.h:352
@ SPI_CLK_10MHZ
drive the SPI bus with 10MHz
Definition periph_cpu.h:357
@ SPI_CLK_5MHZ
drive the SPI bus with 5MHz
Definition periph_cpu.h:356
@ SPI_CLK_400KHZ
drive the SPI bus with 400KHz
Definition periph_cpu.h:354
@ SPI_CLK_1MHZ
drive the SPI bus with 1MHz
Definition periph_cpu.h:355
@ SPI_CLK_100KHZ
drive the SPI bus with 100KHz
Definition periph_cpu.h:353
@ GPIO_OUT
select GPIO MASK as output
Definition periph_cpu.h:165
@ GPIO_IN
select GPIO MASK as input
Definition periph_cpu.h:164
Implementation of simulated CAN controller driver using SocketCAN on Linux.
Native CPU peripheral configuration.
gpio_mode_t
Available pin modes.
Definition periph_cpu.h:91
#define GPIOHANDLE_REQUEST_PULL_UP
Pull-up.
Definition periph_cpu.h:80
#define GPIOHANDLE_REQUEST_PULL_DOWN
Pull-down.
Definition periph_cpu.h:74
uint16_t gpio_t
GPIO type identifier.
Definition periph_cpu.h:117