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) 2017 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
20
#ifndef PERIPH_CONF_H
21
#define PERIPH_CONF_H
22
23
#include "periph_cpu.h"
24
25
#ifdef __cplusplus
26
extern
"C"
{
27
#endif
28
33
#ifndef CONFIG_USE_CLOCK_HFXOSC_PLL
34
#if IS_ACTIVE(CONFIG_USE_CLOCK_HFXOSC) || IS_ACTIVE(CONFIG_USE_CLOCK_HFROSC_PLL) || \
35
IS_ACTIVE(CONFIG_USE_CLOCK_HFROSC)
36
#define CONFIG_USE_CLOCK_HFXOSC_PLL 0
37
#else
38
#define CONFIG_USE_CLOCK_HFXOSC_PLL 1
/* Use PLL clocked by HFXOSC by default */
39
#endif
40
#endif
/* CONFIG_USE_CLOCK_HFXOSC_PLL */
41
42
#ifndef CONFIG_USE_CLOCK_HFXOSC
43
#define CONFIG_USE_CLOCK_HFXOSC 0
44
#endif
/* CONFIG_USE_CLOCK_HFXOSC */
45
46
#ifndef CONFIG_USE_CLOCK_HFROSC_PLL
47
#define CONFIG_USE_CLOCK_HFROSC_PLL 0
48
#endif
/* CONFIG_USE_CLOCK_HFROSC_PLL */
49
50
#ifndef CONFIG_USE_CLOCK_HFROSC
51
#define CONFIG_USE_CLOCK_HFROSC 0
52
#endif
/* CONFIG_USE_CLOCK_HFROSC */
53
54
#if CONFIG_USE_CLOCK_HFXOSC_PLL && \
55
(CONFIG_USE_CLOCK_HFROSC_PLL || CONFIG_USE_CLOCK_HFROSC || CONFIG_USE_CLOCK_HFXOSC)
56
#error "Cannot use HFXOSC_PLL with other clock configurations"
57
#endif
58
59
#if CONFIG_USE_CLOCK_HFXOSC && \
60
(CONFIG_USE_CLOCK_HFROSC_PLL || CONFIG_USE_CLOCK_HFROSC || CONFIG_USE_CLOCK_HFXOSC_PLL)
61
#error "Cannot use HFXOSC with other clock configurations"
62
#endif
63
64
#if CONFIG_USE_CLOCK_HFROSC_PLL && \
65
(CONFIG_USE_CLOCK_HFXOSC_PLL || CONFIG_USE_CLOCK_HFXOSC || CONFIG_USE_CLOCK_HFROSC)
66
#error "Cannot use HFROSC_PLL with other clock configurations"
67
#endif
68
69
#if CONFIG_USE_CLOCK_HFROSC && \
70
(CONFIG_USE_CLOCK_HFXOSC_PLL || CONFIG_USE_CLOCK_HFXOSC || CONFIG_USE_CLOCK_HFROSC_PLL)
71
#error "Cannot use HFROSC with other clock configurations"
72
#endif
73
74
#define CONFIG_CLOCK_PLL_R (1)
/* Divide input clock by 2, mandatory with HFXOSC */
75
#ifndef CONFIG_CLOCK_PLL_F
76
#define CONFIG_CLOCK_PLL_F (39)
/* Multiply REFR by 80, e.g 2 * (39 + 1) */
77
#endif
78
#ifndef CONFIG_CLOCK_PLL_Q
79
#define CONFIG_CLOCK_PLL_Q (1)
/* Divide VCO by 2, e.g 2^1 */
80
#endif
81
82
#if CONFIG_USE_CLOCK_HFXOSC_PLL
83
#define CLOCK_PLL_INPUT_CLOCK MHZ(16)
84
#define CLOCK_PLL_REFR (CLOCK_PLL_INPUT_CLOCK / (CONFIG_CLOCK_PLL_R + 1))
85
#define CLOCK_PLL_VCO (CLOCK_PLL_REFR * (2 * (CONFIG_CLOCK_PLL_F + 1)))
86
#define CLOCK_PLL_OUT (CLOCK_PLL_VCO / (1 << CONFIG_CLOCK_PLL_Q))
87
#define CLOCK_CORECLOCK (CLOCK_PLL_OUT)
/* 320000000Hz with the values used above */
88
89
/* Check PLL settings */
90
#if CLOCK_PLL_REFR != MHZ(8)
91
#error "Only R=2 can be used when using HFXOSC"
92
#endif
93
#if (CLOCK_PLL_VCO < MHZ(384)) || (CLOCK_PLL_VCO > MHZ(768))
94
#error "VCO frequency must be in the range [384MHz - 768MHz], check the CLOCK_PLL_F value"
95
#endif
96
#if (CLOCK_PLL_OUT < MHZ(48)) || (CLOCK_PLL_OUT > MHZ(384))
97
#error "PLL output frequency must be in the range [48MHz - 384MHz], check the CLOCK_PLL_Q value"
98
#endif
99
100
#elif CONFIG_USE_CLOCK_HFXOSC
101
#define CLOCK_CORECLOCK MHZ(16)
102
#endif
103
104
/*
105
When using HFROSC input clock, the core clock cannot be computed from settings,
106
call cpu_freq() to get the configured CPU frequency.
107
*/
108
#ifndef CONFIG_CLOCK_DESIRED_FREQUENCY
109
#define CONFIG_CLOCK_DESIRED_FREQUENCY MHZ(320)
110
#endif
111
112
#ifndef CONFIG_CLOCK_HFROSC_TRIM
113
#define CONFIG_CLOCK_HFROSC_TRIM (6)
/* ~72000000Hz input freq */
114
#endif
115
#ifndef CONFIG_CLOCK_HFROSC_DIV
116
#define CONFIG_CLOCK_HFROSC_DIV (1)
/* Divide by 2 */
117
#endif
118
125
#define TIMER_NUMOF (1)
126
132
static
const
uart_conf_t
uart_config[] = {
133
{
134
.
addr
= UART0_CTRL_ADDR,
135
.rx =
GPIO_PIN
(0, 16),
136
.tx =
GPIO_PIN
(0, 17),
137
.isr_num = INT_UART0_BASE,
138
},
139
{
140
.addr = UART1_CTRL_ADDR,
141
.rx =
GPIO_PIN
(0, 18),
142
.tx =
GPIO_PIN
(0, 23),
143
.isr_num = INT_UART1_BASE,
144
},
145
};
146
147
#define UART_NUMOF ARRAY_SIZE(uart_config)
148
155
static
const
spi_conf_t
spi_config[] = {
156
{
157
.
addr
= SPI1_CTRL_ADDR,
158
.mosi =
GPIO_PIN
(0, 3),
/* D11 */
159
.miso =
GPIO_PIN
(0, 4),
/* D12 */
160
.sclk =
GPIO_PIN
(0, 5),
/* D13 */
161
},
162
};
163
164
#define SPI_NUMOF ARRAY_SIZE(spi_config)
165
172
#define PWM_NUMOF (3)
173
175
#ifdef __cplusplus
176
}
177
#endif
178
179
#endif
/* PERIPH_CONF_H */
180
uart_conf_t::addr
uint32_t addr
UART control register address.
Definition:
periph_cpu.h:69
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
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