Toggle navigation
Documentation
The friendly Operating System for the Internet of Things
periph_conf.h
Go to the documentation of this file.
1
/*
2
* Copyright (C) 2019 Ken Rabold
3
* 2019 Inria
4
*
5
* This file is subject to the terms and conditions of the GNU Lesser General
6
* Public License v2.1. See the file LICENSE in the top level directory for more
7
* details.
8
*/
9
21
#ifndef PERIPH_CONF_H
22
#define PERIPH_CONF_H
23
24
#include "periph_cpu.h"
25
26
#ifdef __cplusplus
27
extern
"C"
{
28
#endif
29
34
#ifndef CONFIG_USE_CLOCK_HFXOSC_PLL
35
#if IS_ACTIVE(CONFIG_USE_CLOCK_HFXOSC) || IS_ACTIVE(CONFIG_USE_CLOCK_HFROSC_PLL) || \
36
IS_ACTIVE(CONFIG_USE_CLOCK_HFROSC)
37
#define CONFIG_USE_CLOCK_HFXOSC_PLL 0
38
#else
39
#define CONFIG_USE_CLOCK_HFXOSC_PLL 1
/* Use PLL clocked by HFXOSC by default */
40
#endif
41
#endif
/* CONFIG_USE_CLOCK_HFXOSC_PLL */
42
43
#ifndef CONFIG_USE_CLOCK_HFXOSC
44
#define CONFIG_USE_CLOCK_HFXOSC 0
45
#endif
/* CONFIG_USE_CLOCK_HFXOSC */
46
47
#ifndef CONFIG_USE_CLOCK_HFROSC_PLL
48
#define CONFIG_USE_CLOCK_HFROSC_PLL 0
49
#endif
/* CONFIG_USE_CLOCK_HFROSC_PLL */
50
51
#ifndef CONFIG_USE_CLOCK_HFROSC
52
#define CONFIG_USE_CLOCK_HFROSC 0
53
#endif
/* CONFIG_USE_CLOCK_HFROSC */
54
55
#if CONFIG_USE_CLOCK_HFXOSC_PLL && \
56
(CONFIG_USE_CLOCK_HFROSC_PLL || CONFIG_USE_CLOCK_HFROSC || CONFIG_USE_CLOCK_HFXOSC)
57
#error "Cannot use HFXOSC_PLL with other clock configurations"
58
#endif
59
60
#if CONFIG_USE_CLOCK_HFXOSC && \
61
(CONFIG_USE_CLOCK_HFROSC_PLL || CONFIG_USE_CLOCK_HFROSC || CONFIG_USE_CLOCK_HFXOSC_PLL)
62
#error "Cannot use HFXOSC with other clock configurations"
63
#endif
64
65
#if CONFIG_USE_CLOCK_HFROSC_PLL && \
66
(CONFIG_USE_CLOCK_HFXOSC_PLL || CONFIG_USE_CLOCK_HFXOSC || CONFIG_USE_CLOCK_HFROSC)
67
#error "Cannot use HFROSC_PLL with other clock configurations"
68
#endif
69
70
#if CONFIG_USE_CLOCK_HFROSC && \
71
(CONFIG_USE_CLOCK_HFXOSC_PLL || CONFIG_USE_CLOCK_HFXOSC || CONFIG_USE_CLOCK_HFROSC_PLL)
72
#error "Cannot use HFROSC with other clock configurations"
73
#endif
74
75
#define CONFIG_CLOCK_PLL_R (1)
/* Divide input clock by 2, mandatory with HFXOSC */
76
#ifndef CONFIG_CLOCK_PLL_F
77
#define CONFIG_CLOCK_PLL_F (39)
/* Multiply REFR by 80, e.g 2 * (39 + 1) */
78
#endif
79
#ifndef CONFIG_CLOCK_PLL_Q
80
#define CONFIG_CLOCK_PLL_Q (1)
/* Divide VCO by 2, e.g 2^1 */
81
#endif
82
83
#if CONFIG_USE_CLOCK_HFXOSC_PLL
84
#define CLOCK_PLL_INPUT_CLOCK MHZ(16)
85
#define CLOCK_PLL_REFR (CLOCK_PLL_INPUT_CLOCK / (CONFIG_CLOCK_PLL_R + 1))
86
#define CLOCK_PLL_VCO (CLOCK_PLL_REFR * (2 * (CONFIG_CLOCK_PLL_F + 1)))
87
#define CLOCK_PLL_OUT (CLOCK_PLL_VCO / (1 << CONFIG_CLOCK_PLL_Q))
88
#define CLOCK_CORECLOCK (CLOCK_PLL_OUT)
/* 320000000Hz with the values used above */
89
90
/* Check PLL settings */
91
#if CLOCK_PLL_REFR != MHZ(8)
92
#error "Only R=2 can be used when using HFXOSC"
93
#endif
94
#if (CLOCK_PLL_VCO < MHZ(384)) || (CLOCK_PLL_VCO > MHZ(768))
95
#error "VCO frequency must be in the range [384MHz - 768MHz], check the CLOCK_PLL_F value"
96
#endif
97
#if (CLOCK_PLL_OUT < MHZ(48)) || (CLOCK_PLL_OUT > MHZ(384))
98
#error "PLL output frequency must be in the range [48MHz - 384MHz], check the CLOCK_PLL_Q value"
99
#endif
100
101
#elif CONFIG_USE_CLOCK_HFXOSC
102
#define CLOCK_CORECLOCK MHZ(16)
103
#endif
104
105
/*
106
When using HFROSC input clock, the core clock cannot be computed from settings,
107
call cpu_freq() to get the configured CPU frequency.
108
*/
109
#ifndef CONFIG_CLOCK_DESIRED_FREQUENCY
110
#define CONFIG_CLOCK_DESIRED_FREQUENCY MHZ(320)
111
#endif
112
113
#ifndef CONFIG_CLOCK_HFROSC_TRIM
114
#define CONFIG_CLOCK_HFROSC_TRIM (6)
/* ~72000000Hz input freq */
115
#endif
116
#ifndef CONFIG_CLOCK_HFROSC_DIV
117
#define CONFIG_CLOCK_HFROSC_DIV (1)
/* Divide by 2 */
118
#endif
119
126
#define TIMER_NUMOF (1)
127
133
static
const
uart_conf_t
uart_config[] = {
134
{
135
.
addr
= UART0_CTRL_ADDR,
136
.rx =
GPIO_PIN
(0, 16),
137
.tx =
GPIO_PIN
(0, 17),
138
.isr_num = INT_UART0_BASE,
139
},
140
{
141
.addr = UART1_CTRL_ADDR,
142
.rx =
GPIO_PIN
(0, 18),
143
.tx =
GPIO_PIN
(0, 23),
144
.isr_num = INT_UART1_BASE,
145
},
146
};
147
148
#define UART_NUMOF ARRAY_SIZE(uart_config)
149
156
static
const
spi_conf_t
spi_config[] = {
157
{
158
.
addr
= SPI1_CTRL_ADDR,
159
.mosi =
GPIO_PIN
(0, 3),
/* D11 */
160
.miso =
GPIO_PIN
(0, 4),
/* D12 */
161
.sclk =
GPIO_PIN
(0, 5),
/* D13 */
162
},
163
};
164
165
#define SPI_NUMOF ARRAY_SIZE(spi_config)
166
173
#define PWM_NUMOF (3)
174
180
static
const
i2c_conf_t
i2c_config[] = {
181
{
182
.
addr
= I2C0_CTRL_ADDR,
183
.scl =
GPIO_PIN
(0, 13),
184
.sda =
GPIO_PIN
(0, 12),
185
.speed =
I2C_SPEED_NORMAL
,
186
},
187
};
188
189
#define I2C_NUMOF ARRAY_SIZE(i2c_config)
190
192
#ifdef __cplusplus
193
}
194
#endif
195
196
#endif
/* PERIPH_CONF_H */
197
i2c_conf_t::addr
uint32_t addr
device base address
Definition:
periph_cpu.h:135
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
uart_conf_t
UART device configuration.
Definition:
periph_cpu.h:166
GPIO_PIN
#define GPIO_PIN(x, y)
Define a CPU specific GPIO pin generator macro.
Definition:
periph_cpu.h:35
spi_conf_t::addr
uint32_t addr
SPI control register address.
Definition:
periph_cpu.h:93
i2c_conf_t
I2C configuration options.
Definition:
periph_cpu.h:128
spi_conf_t
SPI configuration structure type.
Definition:
periph_cpu.h:273
Generated on Tue Nov 24 2020 19:46:50 by
1.8.17