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 
9 #pragma once
10 
21 #include <inttypes.h>
22 
23 #include "periph_cpu_common.h"
24 #include "cpu.h"
25 
26 #ifdef __cplusplus
27 extern "C" {
28 #endif
29 
30 #ifndef DOXYGEN
34 #define HAVE_GPIO_T
35 typedef uint8_t gpio_t;
36 #endif
37 
41 #define CPUID_LEN (12U)
42 
46 #define GPIO_UNDEF (0xff)
47 
51 #define GPIO_PIN(x, y) (x | y)
52 
56 #define GPIO_INTR_PRIORITY (3)
57 
61 typedef struct {
62  uint32_t addr;
63  gpio_t rx;
64  gpio_t tx;
66 } uart_conf_t;
67 
71 #define UART_ISR_PRIO (2)
72 
77 #define PERIPH_SPI_NEEDS_TRANSFER_BYTE 1
78 #define PERIPH_SPI_NEEDS_TRANSFER_REG 1
79 #define PERIPH_SPI_NEEDS_TRANSFER_REGS 1
85 typedef struct {
86  uint32_t addr;
87  gpio_t mosi;
88  gpio_t miso;
89  gpio_t sclk;
90 } spi_conf_t;
91 
95 #define PERIPH_TIMER_PROVIDES_SET
96 
102 #define PERIPH_I2C_NEED_READ_REG
104 #define PERIPH_I2C_NEED_WRITE_REG
106 #define PERIPH_I2C_NEED_READ_REGS
108 #define PERIPH_I2C_NEED_WRITE_REGS
111 #ifndef DOXYGEN
116 #define HAVE_I2C_SPEED_T
117 typedef enum {
120 } i2c_speed_t;
122 #endif /* ndef DOXYGEN */
123 
127 typedef struct {
128  uint32_t addr;
129  gpio_t scl;
130  gpio_t sda;
131  i2c_speed_t speed;
132 } i2c_conf_t;
133 
138 #define NWDT_TIME_LOWER_LIMIT (1)
139 /* Ensure the internal "count" variable stays within the uint32 bounds.
140  This variable corresponds to max_time * RTC_FREQ / MS_PER_SEC. On fe310,
141  RTC_FREQ is 32768Hz. The 15 right shift is equivalent to a division by RTC_FREQ.
142  */
143 #define NWDT_TIME_UPPER_LIMIT ((UINT32_MAX >> 15) * MS_PER_SEC + 1)
149 #define WDT_INTR_PRIORITY (PLIC_NUM_PRIORITIES)
150 
154 #define WDT_HAS_STOP (1)
155 
161 #define RTT_INTR_PRIORITY (2)
162 
163 #define RTT_MAX_VALUE (0xffffffff)
164 #define RTT_CLOCK_FREQUENCY (32768U) /* in Hz */
165 #define RTT_MAX_FREQUENCY (RTT_CLOCK_FREQUENCY) /* in Hz */
166 #define RTT_MIN_FREQUENCY (1U) /* in Hz */
167 
168 #ifndef RTT_FREQUENCY
169 #define RTT_FREQUENCY (RTT_MAX_FREQUENCY) /* in Hz */
170 #endif
171 
175 void fe310_clock_init(void);
176 
179 #ifdef __cplusplus
180 }
181 #endif
182 
i2c_speed_t
Definition: periph_cpu.h:275
void fe310_clock_init(void)
Initialization of the clock.
unsigned int gpio_t
GPIO type identifier.
Definition: gpio.h:91
@ I2C_SPEED_NORMAL
normal mode: ~100 kbit/s
Definition: periph_cpu.h:277
@ I2C_SPEED_FAST
fast mode: ~400 kbit/s
Definition: periph_cpu.h:278
Adds include for missing inttype definitions.
Native CPU header.
unsigned irqn_t
Convenience typedef for interrupt lines.
I2C configuration structure.
Definition: periph_cpu.h:298
uint32_t addr
device base address
Definition: periph_cpu.h:128
SPI device configuration.
Definition: periph_cpu.h:336
uint32_t addr
SPI control register address.
Definition: periph_cpu.h:86
gpio_t sclk
SCLK pin.
Definition: periph_cpu.h:89
UART device configuration.
Definition: periph_cpu.h:217
uint32_t addr
UART control register address.
Definition: periph_cpu.h:62
gpio_t tx
TX pin.
Definition: periph_cpu.h:64
irqn_t isr_num
ISR source number.
Definition: periph_cpu.h:65
gpio_t rx
RX pin.
Definition: periph_cpu.h:63