Loading...
Searching...
No Matches
periph_cpu.h
Go to the documentation of this file.
1/*
2 * SPDX-FileCopyrightText: 2019 Gunar Schorcht
3 * SPDX-License-Identifier: LGPL-2.1-only
4 */
5
6#pragma once
7
17
18#include <stdbool.h>
19#include <stdint.h>
20#include <limits.h>
21
22#include "eagle_soc.h"
23#include "cpu_conf.h"
24#include "macros/units.h"
25
26#ifdef __cplusplus
27extern "C" {
28#endif
29
33#define CPUID_LEN (4U)
34
38#define CPU_CYCLES_PER_LOOP (5)
39
44
51#define HAVE_GPIO_T
52typedef unsigned int gpio_t;
54
58#define GPIO_UNDEF ((gpio_t)(UINT_MAX))
59
63#define GPIO_PIN(x, y) ((x & 0) | y)
64
68#define PORT_GPIO (0)
69
73#define GPIO_PIN_NUMOF (17)
74
75#ifndef DOXYGEN
80#define HAVE_GPIO_FLANK_T
81typedef enum {
82 GPIO_NONE = 0,
83 GPIO_RISING = 1,
84 GPIO_FALLING = 2,
85 GPIO_BOTH = 3,
86 GPIO_LOW = 4,
87 GPIO_HIGH = 5
90#endif /* ndef DOXYGEN */
91
96#define GPIO0 (GPIO_PIN(PORT_GPIO, 0))
97#define GPIO1 (GPIO_PIN(PORT_GPIO, 1))
98#define GPIO2 (GPIO_PIN(PORT_GPIO, 2))
99#define GPIO3 (GPIO_PIN(PORT_GPIO, 3))
100#define GPIO4 (GPIO_PIN(PORT_GPIO, 4))
101#define GPIO5 (GPIO_PIN(PORT_GPIO, 5))
102#define GPIO6 (GPIO_PIN(PORT_GPIO, 6))
103#define GPIO7 (GPIO_PIN(PORT_GPIO, 7))
104#define GPIO8 (GPIO_PIN(PORT_GPIO, 8))
105#define GPIO9 (GPIO_PIN(PORT_GPIO, 9))
106#define GPIO10 (GPIO_PIN(PORT_GPIO, 10))
107#define GPIO11 (GPIO_PIN(PORT_GPIO, 11))
108#define GPIO12 (GPIO_PIN(PORT_GPIO, 12))
109#define GPIO13 (GPIO_PIN(PORT_GPIO, 13))
110#define GPIO14 (GPIO_PIN(PORT_GPIO, 14))
111#define GPIO15 (GPIO_PIN(PORT_GPIO, 15))
112#define GPIO16 (GPIO_PIN(PORT_GPIO, 16))
114
116
140#ifndef DOXYGEN
147#define HAVE_I2C_SPEED_T
148typedef enum {
149 I2C_SPEED_LOW = 0,
156#endif /* ndef DOXYGEN */
160typedef struct {
161 i2c_speed_t speed;
162 gpio_t scl;
163 gpio_t sda;
164} i2c_conf_t;
165
169#define I2C_NUMOF_MAX (2)
170
171#define PERIPH_I2C_NEED_READ_REG
172#define PERIPH_I2C_NEED_READ_REGS
173#define PERIPH_I2C_NEED_WRITE_REG
174#define PERIPH_I2C_NEED_WRITE_REGS
176
181#define PROVIDES_PM_SET_LOWEST
182#define PROVIDES_PM_RESTART
183#define PROVIDES_PM_OFF
185
202
206#define PWM_NUMOF_MAX (1)
207
211#define PWM_CHANNEL_NUM_MAX (8)
212
214
219
223#define RNG_DATA_REG_ADDR (0x3ff20e44)
225
230#define RTT_FREQUENCY (312500UL)
231#define RTT_MAX_VALUE (0xFFFFFFFFUL)
233
258
262typedef enum {
263 HSPI = 1,
264} spi_ctrl_t;
265
270#define HAVE_SPI_CLK_T
278
282typedef struct {
283 spi_ctrl_t ctrl;
284 gpio_t sck;
285 gpio_t mosi;
286 gpio_t miso;
287 gpio_t cs;
288} spi_conf_t;
289
293#define SPI_NUMOF_MAX (1)
294
295#define PERIPH_SPI_NEEDS_TRANSFER_BYTE
296#define PERIPH_SPI_NEEDS_TRANSFER_REG
297#define PERIPH_SPI_NEEDS_TRANSFER_REGS
299
301
305#define PERIPH_TIMER_PROVIDES_SET
306
314
318typedef struct {
319 gpio_t txd;
320 gpio_t rxd;
322
326#define UART_NUMOF_MAX (2)
328
333
334#ifdef __cplusplus
335}
336#endif
337
gpio_flank_t
Definition periph_cpu.h:176
i2c_speed_t
Definition periph_cpu.h:272
@ I2C_SPEED_NORMAL
normal mode: ~100 kbit/s
Definition periph_cpu.h:274
@ I2C_SPEED_FAST_PLUS
fast plus mode: ~1000 kbit/s
Definition periph_cpu.h:276
@ I2C_SPEED_LOW
low speed mode: ~10 kbit/s
Definition periph_cpu.h:273
@ I2C_SPEED_HIGH
high speed mode: ~3400 kbit/s
Definition periph_cpu.h:278
@ I2C_SPEED_FAST
fast mode: ~400 kbit/s
Definition periph_cpu.h:275
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
CPU specific configuration options.
spi_ctrl_t
SPI controllers that can be used for peripheral interfaces.
Definition periph_cpu.h:262
@ HSPI
HSPI interface controller.
Definition periph_cpu.h:263
bool cpu_woke_from_backup(void)
Returns true if the CPU woke up from deep sleep.
I2C configuration structure.
Definition periph_cpu.h:295
SPI device configuration.
Definition periph_cpu.h:333
UART device configuration.
Definition periph_cpu.h:214
Unit helper macros.
#define MHZ(x)
A macro to return the Hz in x MHz.
Definition units.h:45
#define KHZ(x)
A macro to return the Hz in x kHz.
Definition units.h:40