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#ifndef CPUID_LEN
32#define CPUID_LEN (4U)
33#endif
34
38#ifndef PM_NUM_MODES
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
59#define GPIO_PORT_SHIFT (24)
60
64#define GPIO_PIN(port, pin) (gpio_t)((port << GPIO_PORT_SHIFT) | pin)
65
66#define HAVE_GPIO_MODE_T
67#ifndef GPIOHANDLE_REQUEST_PULL_DOWN
68#define GPIOHANDLE_REQUEST_PULL_DOWN (0xFF)
69#endif
70#ifndef GPIOHANDLE_REQUEST_PULL_UP
71#define GPIOHANDLE_REQUEST_PULL_UP (0xFF)
72#endif
73
82typedef enum {
83 GPIO_IN = GPIOHANDLE_REQUEST_INPUT,
84 GPIO_IN_PD = GPIOHANDLE_REQUEST_INPUT | GPIOHANDLE_REQUEST_PULL_DOWN,
85 GPIO_IN_PU = GPIOHANDLE_REQUEST_INPUT | GPIOHANDLE_REQUEST_PULL_UP,
86 GPIO_OUT = GPIOHANDLE_REQUEST_OUTPUT,
87 GPIO_OD = GPIOHANDLE_REQUEST_OPEN_DRAIN,
88 GPIO_OD_PU = GPIOHANDLE_REQUEST_OPEN_DRAIN | GPIOHANDLE_REQUEST_PULL_UP
90
91#define HAVE_GPIO_FLANK_T
92typedef enum {
93 GPIO_FALLING = GPIOEVENT_EVENT_FALLING_EDGE,
94 GPIO_RISING = GPIOEVENT_EVENT_RISING_EDGE,
95 GPIO_BOTH = GPIO_FALLING | GPIO_RISING
97
99#elif defined(MODULE_PERIPH_GPIO_MOCK)
100
107typedef struct {
108 int value;
109 int mode;
110 int flank;
111 void (*cb)(void *arg);
112 void *arg;
113} gpio_mock_t;
116#define GPIO_UNDEF 0
117
118#ifndef GPIO_PORT_MAX
119#define GPIO_PORT_MAX (16)
120#endif
121
122#ifndef GPIO_PIN_MAX
123#define GPIO_PIN_MAX (32)
124#endif
125
129extern gpio_mock_t gpio_mock[GPIO_PORT_MAX][GPIO_PIN_MAX];
130
131#define HAVE_GPIO_T
135typedef gpio_mock_t* gpio_t;
136
141#define GPIO_PIN(port, pin) \
142 (((port >= 0) && (pin >= 0) && (port < GPIO_PORT_MAX) && (pin < GPIO_PIN_MAX)) \
143 ? &gpio_mock[port][pin] \
144 : GPIO_UNDEF)
145
146#endif /* MODULE_PERIPH_GPIO_LINUX | DOXYGEN */
147
151#define PERIPH_TIMER_PROVIDES_SET
152
157#define PROVIDES_PM_OFF
158#define PROVIDES_PM_SET_LOWEST
161/* Configuration for the wrapper around the Linux SPI API (periph_spidev_linux)
162 *
163 * Needs to go here, otherwise the SPI_NEEDS_ are defined after inclusion of
164 * spi.h.
165 */
166#if defined(MODULE_PERIPH_SPIDEV_LINUX) || defined(DOXYGEN)
167
175#define PERIPH_SPI_NEEDS_TRANSFER_BYTE
179#define PERIPH_SPI_NEEDS_TRANSFER_REG
183#define PERIPH_SPI_NEEDS_TRANSFER_REGS
184
185#ifndef DOXYGEN
189#define HAVE_SPI_CLK_T
197typedef enum {
198 SPI_CLK_100KHZ = (100000U),
199 SPI_CLK_400KHZ = (400000U),
200 SPI_CLK_1MHZ = (1000000U),
201 SPI_CLK_5MHZ = (5000000U),
202 SPI_CLK_10MHZ = (10000000U)
203} spi_clk_t;
205#endif /* ndef DOXYGEN */
206#endif /* MODULE_PERIPH_SPI | DOXYGEN */
207
212#ifndef EEPROM_SIZE
213#define EEPROM_SIZE (1024U) /* 1kB */
214#endif
217#ifdef MODULE_PERIPH_CAN
218#include "candev_linux.h"
219#endif
220
221#ifdef __cplusplus
222}
223#endif
224
225#endif /* PERIPH_CPU_H */
gpio_flank_t
Definition periph_cpu.h:180
@ GPIO_OUT
select GPIO MASK as output
Definition periph_cpu.h:165
@ GPIO_IN
select GPIO MASK as input
Definition periph_cpu.h:164
spi_clk_t
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
Implementation of simulated CAN controller driver using SocketCAN on Linux.
Native CPU peripheral configuration.
gpio_mode_t
Available pin modes.
Definition periph_cpu.h:82