Loading...
Searching...
No Matches
periph_cpu.h
Go to the documentation of this file.
1/*
2 * SPDX-FileCopyrightText: 2015 Freie Universität Berlin
3 * SPDX-License-Identifier: LGPL-2.1-only
4 */
5
6#pragma once
7
12
18
19#include "periph_conf.h"
20
21#ifdef __cplusplus
22extern "C" {
23#endif
24
28#if !defined(CPUID_LEN) || defined(DOXYGEN)
29# define CPUID_LEN (4U)
30#endif
31
35#if !defined(PM_NUM_MODES) || defined(DOXYGEN)
36# define PM_NUM_MODES (1U)
37#endif
38
42#define PROVIDES_PM_LAYERED_OFF
43
44/* GPIO configuration only if the module is available (=Linux) */
45#if defined(MODULE_PERIPH_GPIO_LINUX) || defined(DOXYGEN)
46# include <linux/gpio.h>
47
48/* MARK: - GPIO Configuration */
56# define GPIO_PORT_SHIFT (24)
57
61# define GPIO_PIN(port, pin) (gpio_t)((port << GPIO_PORT_SHIFT) | pin)
62
66# define HAVE_GPIO_MODE_T
70# if !defined(GPIOHANDLE_REQUEST_PULL_DOWN) || defined(DOXYGEN)
71# define GPIOHANDLE_REQUEST_PULL_DOWN (0xFF)
72# endif
76# if !defined(GPIOHANDLE_REQUEST_PULL_UP) || defined(DOXYGEN)
77# define GPIOHANDLE_REQUEST_PULL_UP (0xFF)
78# endif
79
88typedef enum {
89 GPIO_IN = GPIOHANDLE_REQUEST_INPUT,
90 GPIO_IN_PD = GPIOHANDLE_REQUEST_INPUT | GPIOHANDLE_REQUEST_PULL_DOWN,
91 GPIO_IN_PU = GPIOHANDLE_REQUEST_INPUT | GPIOHANDLE_REQUEST_PULL_UP,
92 GPIO_OUT = GPIOHANDLE_REQUEST_OUTPUT,
93 GPIO_OD = GPIOHANDLE_REQUEST_OPEN_DRAIN,
94 GPIO_OD_PU = GPIOHANDLE_REQUEST_OPEN_DRAIN | GPIOHANDLE_REQUEST_PULL_UP
96
100# define HAVE_GPIO_FLANK_T
101
105typedef enum {
106 GPIO_FALLING = GPIOEVENT_EVENT_FALLING_EDGE,
107 GPIO_RISING = GPIOEVENT_EVENT_RISING_EDGE,
108 GPIO_BOTH = GPIO_FALLING | GPIO_RISING
110
111
112#elif defined(MODULE_PERIPH_GPIO_MOCK)
113
119typedef struct {
120 int value;
121 int mode;
122 int flank;
123 void (*cb)(void *arg);
124 void *arg;
125} gpio_mock_t;
126
127# define GPIO_UNDEF 0
128
129# if !defined(GPIO_PORT_MAX) || defined(DOXYGEN)
130# define GPIO_PORT_MAX (16)
131# endif
132
133# if !defined(GPIO_PIN_MAX) || defined(DOXYGEN)
134# define GPIO_PIN_MAX (32)
135# endif
136
140extern gpio_mock_t gpio_mock[GPIO_PORT_MAX][GPIO_PIN_MAX];
141
142# define HAVE_GPIO_T
146typedef gpio_mock_t* gpio_t;
147
152# define GPIO_PIN(port, pin) \
153 (((port >= 0) && (pin >= 0) && (port < GPIO_PORT_MAX) && (pin < GPIO_PIN_MAX)) \
154 ? &gpio_mock[port][pin] \
155 : GPIO_UNDEF)
156
157#endif /* MODULE_PERIPH_GPIO_LINUX | DOXYGEN */
158
162#define PERIPH_TIMER_PROVIDES_SET
163
164/* MARK: - Power management configuration*/
169#define PROVIDES_PM_OFF
170#define PROVIDES_PM_SET_LOWEST
172
173/* Configuration for the wrapper around the Linux SPI API (periph_spidev_linux)
174 *
175 * Needs to go here, otherwise the SPI_NEEDS_ are defined after inclusion of
176 * spi.h.
177 */
178#if defined(MODULE_PERIPH_SPIDEV_LINUX) || defined(DOXYGEN)
179/* MARK: - SPI Configuration */
187# define PERIPH_SPI_NEEDS_TRANSFER_BYTE
191# define PERIPH_SPI_NEEDS_TRANSFER_REG
195# define PERIPH_SPI_NEEDS_TRANSFER_REGS
196
197# ifndef DOXYGEN
201# define HAVE_SPI_CLK_T
208typedef enum {
209 SPI_CLK_100KHZ = (100000U),
210 SPI_CLK_400KHZ = (400000U),
211 SPI_CLK_1MHZ = (1000000U),
212 SPI_CLK_5MHZ = (5000000U),
213 SPI_CLK_10MHZ = (10000000U)
214} spi_clk_t;
215# endif /* ndef DOXYGEN */
217#endif /* MODULE_PERIPH_SPI | DOXYGEN */
218
222#if !defined(EEPROM_SIZE) || defined(DOXYGEN)
223# define EEPROM_SIZE (1024U) /* 1kB */
224#endif
225
226#ifdef MODULE_PERIPH_CAN
227# include "candev_linux.h"
228#endif
229
230#ifdef __cplusplus
231}
232#endif
233
gpio_flank_t
Definition periph_cpu.h:176
@ GPIO_OUT
select GPIO MASK as output
Definition periph_cpu.h:161
@ GPIO_IN
select GPIO MASK as input
Definition periph_cpu.h:160
spi_clk_t
Definition periph_cpu.h:348
@ SPI_CLK_10MHZ
drive the SPI bus with 10MHz
Definition periph_cpu.h:353
@ SPI_CLK_5MHZ
drive the SPI bus with 5MHz
Definition periph_cpu.h:352
@ SPI_CLK_400KHZ
drive the SPI bus with 400KHz
Definition periph_cpu.h:350
@ SPI_CLK_1MHZ
drive the SPI bus with 1MHz
Definition periph_cpu.h:351
@ SPI_CLK_100KHZ
drive the SPI bus with 100KHz
Definition periph_cpu.h:349
Implementation of simulated CAN controller driver using SocketCAN on Linux.
Native CPU peripheral configuration.
gpio_mode_t
Available pin modes.
Definition periph_cpu.h:88
#define GPIOHANDLE_REQUEST_PULL_UP
Pull-up.
Definition periph_cpu.h:77
#define GPIOHANDLE_REQUEST_PULL_DOWN
Pull-down.
Definition periph_cpu.h:71