The friendly Operating System for the Internet of Things
periph_conf_common.h
Go to the documentation of this file.
1 /*
2  * Copyright (C) 2014 Freie Universit├Ąt Berlin
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 
20 #ifndef PERIPH_CONF_COMMON_H
21 #define PERIPH_CONF_COMMON_H
22 
23 #include "periph_cpu.h"
24 
25 #ifdef __cplusplus
26 extern "C" {
27 #endif
28 
33 #define CLOCK_HSE (16000000U) /* frequency of external oscillator */
34 #define CLOCK_CORECLOCK (72000000U) /* targeted core clock frequency */
35 /* configuration of PLL prescaler and multiply values */
36 /* CORECLOCK := CLOCK_SOURCE / PLL_DIV * PLL_MUL */
37 #define CLOCK_PLL_DIV (2)
38 #define CLOCK_PLL_MUL (9)
39 /* configuration of peripheral bus clock prescalers */
40 #define CLOCK_AHB_DIV RCC_CFGR_HPRE_DIV1 /* AHB clock -> 72MHz */
41 #define CLOCK_APB2_DIV RCC_CFGR_PPRE2_DIV1 /* APB2 clock -> 72MHz */
42 #define CLOCK_APB1_DIV RCC_CFGR_PPRE1_DIV2 /* APB1 clock -> 36MHz */
43 
44 /* bus clocks for simplified peripheral initialization, UPDATE MANUALLY! */
45 #define CLOCK_AHB (CLOCK_CORECLOCK / 1)
46 #define CLOCK_APB2 (CLOCK_CORECLOCK / 1)
47 #define CLOCK_APB1 (CLOCK_CORECLOCK / 2)
48 
54 #define ADC_CONFIG { \
55  { GPIO_PIN(PORT_A,3), 0, 3 }, \
56  { GPIO_UNDEF , 0, 16 }, \
57  { GPIO_UNDEF , 0, 17 } }
58 
59 #define ADC_NUMOF (3)
60 
66 static const timer_conf_t timer_config[] = {
67  {
68  .dev = TIM2,
69  .max = 0x0000ffff,
70  .rcc_mask = RCC_APB1ENR_TIM2EN,
71  .bus = APB1,
72  .irqn = TIM2_IRQn
73  },
74  {
75  .dev = TIM3,
76  .max = 0x0000ffff,
77  .rcc_mask = RCC_APB1ENR_TIM3EN,
78  .bus = APB1,
79  .irqn = TIM3_IRQn
80  }
81 };
82 
83 #define TIMER_0_ISR isr_tim2
84 #define TIMER_1_ISR isr_tim3
85 
86 #define TIMER_NUMOF (sizeof(timer_config) / sizeof(timer_config[0]))
87 
93 static const uart_conf_t uart_config[] = {
94  {
95  .dev = USART1,
96  .rcc_mask = RCC_APB2ENR_USART1EN,
97  .rx_pin = GPIO_PIN(PORT_A, 10),
98  .tx_pin = GPIO_PIN(PORT_A, 9),
99  .bus = APB2,
100  .irqn = USART1_IRQn
101  },
102  {
103  .dev = USART2,
104  .rcc_mask = RCC_APB1ENR_USART2EN,
105  .rx_pin = GPIO_PIN(PORT_A, 3),
106  .tx_pin = GPIO_PIN(PORT_A, 2),
107  .bus = APB1,
108  .irqn = USART2_IRQn
109  }
110 };
111 
112 #define UART_0_ISR (isr_usart1)
113 #define UART_1_ISR (isr_usart2)
114 
115 #define UART_NUMOF (sizeof(uart_config) / sizeof(uart_config[0]))
116 
122 #define DAC_NUMOF (0)
123 
129 #define RTT_NUMOF (1U)
130 #define RTT_IRQ_PRIO 1
131 
132 #define RTT_DEV RTC
133 #define RTT_IRQ RTC_IRQn
134 #define RTT_ISR isr_rtc
135 #define RTT_MAX_VALUE (0xffffffff)
136 #define RTT_FREQUENCY (1) /* in Hz */
137 #define RTT_PRESCALER (0x7fff) /* run with 1 Hz */
138 
144 #define I2C_NUMOF (1U)
145 #define I2C_0_EN 1
146 #define I2C_IRQ_PRIO 1
147 #define I2C_APBCLK (36000000U)
148 
149 /* I2C 0 device configuration */
150 #define I2C_0_DEV I2C1
151 #define I2C_0_CLKEN() (periph_clk_en(APB1, RCC_APB1ENR_I2C1EN))
152 #define I2C_0_CLKDIS() (periph_clk_dis(APB1, RCC_APB1ENR_I2C1EN))
153 #define I2C_0_EVT_IRQ I2C1_EV_IRQn
154 #define I2C_0_EVT_ISR isr_i2c1_ev
155 #define I2C_0_ERR_IRQ I2C1_ER_IRQn
156 #define I2C_0_ERR_ISR isr_i2c1_er
157 /* I2C 0 pin configuration */
158 #define I2C_0_SCL_PIN GPIO_PIN(PORT_B,6)
159 #define I2C_0_SDA_PIN GPIO_PIN(PORT_B,7)
160 
168 static const uint8_t spi_divtable[2][5] = {
169  { /* for APB1 @ 36000000Hz */
170  7, /* -> 140625Hz */
171  6, /* -> 281250Hz */
172  4, /* -> 1125000Hz */
173  2, /* -> 4500000Hz */
174  1 /* -> 9000000Hz */
175  },
176  { /* for APB2 @ 72000000Hz */
177  7, /* -> 281250Hz */
178  7, /* -> 281250Hz */
179  5, /* -> 1125000Hz */
180  3, /* -> 4500000Hz */
181  2 /* -> 9000000Hz */
182  }
183 };
184 
185 #ifdef __cplusplus
186 }
187 #endif
188 
189 #endif /* PERIPH_CONF_COMMON_H */
190 
USART_TypeDef * dev
USART device used.
#define GPIO_PIN(x, y)
Define a CPU specific GPIO pin generator macro.
static const uart_conf_t uart_config[]
UART configuration.
static const uint8_t spi_divtable[2][5]
Shared SPI clock div table.
UART device configuration.
static const timer_conf_t timer_config[]
Timer configuration.
cc2538_gptimer_t * dev
timer device
Timer configuration data.