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 "periph_cpu_common.h"
25 #include "cpu.h"
26 
27 #ifdef __cplusplus
28 extern "C" {
29 #endif
30 
31 #ifndef DOXYGEN
35 #define HAVE_GPIO_T
36 typedef uint8_t gpio_t;
37 #endif
38 
42 #define CPUID_LEN (12U)
43 
47 #define GPIO_UNDEF (0xff)
48 
52 #define GPIO_PIN(x, y) (x | y)
53 
57 #define GPIO_INTR_PRIORITY (3)
58 
62 typedef struct {
63  uint32_t addr;
64  gpio_t rx;
65  gpio_t tx;
67 } uart_conf_t;
68 
72 #define UART_ISR_PRIO (2)
73 
78 #define PERIPH_SPI_NEEDS_TRANSFER_BYTE 1
79 #define PERIPH_SPI_NEEDS_TRANSFER_REG 1
80 #define PERIPH_SPI_NEEDS_TRANSFER_REGS 1
86 typedef struct {
87  uint32_t addr;
88  gpio_t mosi;
89  gpio_t miso;
90  gpio_t sclk;
91 } spi_conf_t;
92 
96 #define PERIPH_TIMER_PROVIDES_SET
97 
103 #define PERIPH_I2C_NEED_READ_REG
105 #define PERIPH_I2C_NEED_WRITE_REG
107 #define PERIPH_I2C_NEED_READ_REGS
109 #define PERIPH_I2C_NEED_WRITE_REGS
112 #ifndef DOXYGEN
117 #define HAVE_I2C_SPEED_T
118 typedef enum {
121 } i2c_speed_t;
123 #endif /* ndef DOXYGEN */
124 
128 typedef struct {
129  uint32_t addr;
130  gpio_t scl;
131  gpio_t sda;
132  i2c_speed_t speed;
133 } i2c_conf_t;
134 
139 #define NWDT_TIME_LOWER_LIMIT (1)
140 /* Ensure the internal "count" variable stays within the uint32 bounds.
141  This variable corresponds to max_time * RTC_FREQ / MS_PER_SEC. On fe310,
142  RTC_FREQ is 32768Hz. The 15 right shift is equivalent to a division by RTC_FREQ.
143  */
144 #define NWDT_TIME_UPPER_LIMIT ((UINT32_MAX >> 15) * MS_PER_SEC + 1)
150 #define WDT_INTR_PRIORITY (PLIC_NUM_PRIORITIES)
151 
155 #define WDT_HAS_STOP (1)
156 
162 #define RTT_INTR_PRIORITY (2)
163 
164 #define RTT_MAX_VALUE (0xffffffff)
165 #define RTT_CLOCK_FREQUENCY (32768U) /* in Hz */
166 #define RTT_MAX_FREQUENCY (RTT_CLOCK_FREQUENCY) /* in Hz */
167 #define RTT_MIN_FREQUENCY (1U) /* in Hz */
168 
169 #ifndef RTT_FREQUENCY
170 #define RTT_FREQUENCY (RTT_MAX_FREQUENCY) /* in Hz */
171 #endif
172 
176 void fe310_clock_init(void);
177 
180 #ifdef __cplusplus
181 }
182 #endif
183 
184 #endif /* PERIPH_CPU_H */
i2c_speed_t
Definition: periph_cpu.h:276
void fe310_clock_init(void)
Initialization of the clock.
unsigned int gpio_t
GPIO type identifier.
Definition: gpio.h:92
@ I2C_SPEED_NORMAL
normal mode: ~100 kbit/s
Definition: periph_cpu.h:278
@ I2C_SPEED_FAST
fast mode: ~400 kbit/s
Definition: periph_cpu.h:279
Adds include for missing inttype definitions.
Native CPU header.
unsigned irqn_t
Convenience typedef for interrupt lines.
I2C configuration structure.
Definition: periph_cpu.h:299
uint32_t addr
device base address
Definition: periph_cpu.h:129
SPI device configuration.
Definition: periph_cpu.h:337
uint32_t addr
SPI control register address.
Definition: periph_cpu.h:87
gpio_t sclk
SCLK pin.
Definition: periph_cpu.h:90
UART device configuration.
Definition: periph_cpu.h:218
uint32_t addr
UART control register address.
Definition: periph_cpu.h:63
gpio_t tx
TX pin.
Definition: periph_cpu.h:65
irqn_t isr_num
ISR source number.
Definition: periph_cpu.h:66
gpio_t rx
RX pin.
Definition: periph_cpu.h:64