periph_cpu.h
Go to the documentation of this file.
1 /*
2  * Copyright (C) 2017 Ken Rabold
3  *
4  * This file is subject to the terms and conditions of the GNU Lesser General
5  * Public License v2.1. See the file LICENSE in the top level directory for more
6  * details.
7  */
8 
19 #ifndef PERIPH_CPU_H
20 #define PERIPH_CPU_H
21 
22 #include <inttypes.h>
23 
24 #include "cpu.h"
25 
26 #ifdef __cplusplus
27 extern "C" {
28 #endif
29 
34 #define PROVIDES_PM_SET_LOWEST
35 
40 #define CPUID_LEN (12U)
41 
42 #ifndef DOXYGEN
43 
46 #define HAVE_GPIO_T
47 typedef uint8_t gpio_t;
48 #endif
49 
53 #define GPIO_UNDEF (0xff)
54 
58 #define GPIO_PIN(x, y) (x | y)
59 
63 #define GPIO_INTR_PRIORITY (3)
64 
68 typedef struct {
69  uint32_t addr;
70  gpio_t rx;
71  gpio_t tx;
72  plic_source isr_num;
73 } uart_conf_t;
74 
78 #define UART_ISR_PRIO (2)
79 
84 #define PERIPH_SPI_NEEDS_TRANSFER_BYTE 1
85 #define PERIPH_SPI_NEEDS_TRANSFER_REG 1
86 #define PERIPH_SPI_NEEDS_TRANSFER_REGS 1
87 
92 typedef struct {
93  uint32_t addr;
94  gpio_t mosi;
95  gpio_t miso;
96  gpio_t sclk;
97 } spi_conf_t;
98 
102 #define PERIPH_TIMER_PROVIDES_SET
103 
109 #define PERIPH_I2C_NEED_READ_REG
110 
111 #define PERIPH_I2C_NEED_WRITE_REG
112 
113 #define PERIPH_I2C_NEED_READ_REGS
114 
115 #define PERIPH_I2C_NEED_WRITE_REGS
116 
118 #ifndef DOXYGEN
119 
123 #define HAVE_I2C_SPEED_T
124 typedef enum {
127 } i2c_speed_t;
129 #endif /* ndef DOXYGEN */
130 
134 typedef struct {
135  uint32_t addr;
136  gpio_t scl;
137  gpio_t sda;
138  i2c_speed_t speed;
139 } i2c_conf_t;
140 
145 #define NWDT_TIME_LOWER_LIMIT (1)
146 /* Ensure the internal "count" variable stays within the uint32 bounds.
147  This variable corresponds to max_time * RTC_FREQ / MS_PER_SEC. On fe310,
148  RTC_FREQ is 32768Hz. The 15 right shift is equivalent to a division by RTC_FREQ.
149  */
150 #define NWDT_TIME_UPPER_LIMIT ((UINT32_MAX >> 15) * MS_PER_SEC + 1)
151 
156 #define WDT_INTR_PRIORITY (PLIC_NUM_PRIORITIES)
157 
161 #define WDT_HAS_STOP (1)
162 
168 #define RTT_INTR_PRIORITY (2)
169 
170 #define RTT_MAX_VALUE (0xffffffff)
171 #define RTT_CLOCK_FREQUENCY (32768U) /* in Hz */
172 #define RTT_MAX_FREQUENCY (RTT_CLOCK_FREQUENCY) /* in Hz */
173 #define RTT_MIN_FREQUENCY (1U) /* in Hz */
174 
175 #ifndef RTT_FREQUENCY
176 #ifdef MODULE_PERIPH_RTC
177 #define RTT_FREQUENCY (RTT_MIN_FREQUENCY) /* in Hz */
178 #else
179 #define RTT_FREQUENCY (RTT_MAX_FREQUENCY) /* in Hz */
180 #endif
181 #endif
182 
183 
186 #ifdef __cplusplus
187 }
188 #endif
189 
190 #endif /* PERIPH_CPU_H */
191 
i2c_conf_t::addr
uint32_t addr
device base address
Definition: periph_cpu.h:135
uart_conf_t::isr_num
plic_source isr_num
ISR source number.
Definition: periph_cpu.h:72
uart_conf_t::addr
uint32_t addr
UART control register address.
Definition: periph_cpu.h:69
I2C_SPEED_NORMAL
@ I2C_SPEED_NORMAL
normal mode: ~100 kbit/s
Definition: i2c.h:177
spi_conf_t::sclk
gpio_t sclk
SCLK pin.
Definition: periph_cpu.h:96
i2c_speed_t
i2c_speed_t
Default mapping of I2C bus speed values.
Definition: i2c.h:175
uart_conf_t
UART device configuration.
Definition: periph_cpu.h:166
uart_conf_t::rx
gpio_t rx
RX pin.
Definition: periph_cpu.h:70
spi_conf_t::addr
uint32_t addr
SPI control register address.
Definition: periph_cpu.h:93
uart_conf_t::tx
gpio_t tx
TX pin.
Definition: periph_cpu.h:71
gpio_t
unsigned int gpio_t
GPIO type identifier.
Definition: gpio.h:91
i2c_conf_t
I2C configuration options.
Definition: periph_cpu.h:128
I2C_SPEED_FAST
@ I2C_SPEED_FAST
fast mode: ~400 kbit/s
Definition: i2c.h:178
inttypes.h
Adds include for missing inttype definitions.
spi_conf_t
SPI configuration structure type.
Definition: periph_cpu.h:273