periph_conf.h
Go to the documentation of this file.
1 /*
2  * SPDX-FileCopyrightText: 2021 Gerson Fernando Budke
3  * SPDX-License-Identifier: LGPL-2.1-only
4  */
5 
6 #pragma once
7 
17 #include "mutex.h"
18 
19 #ifdef __cplusplus
20 extern "C" {
21 #endif
22 
23 #include <stdint.h>
24 #include <avr/io.h>
25 
26 #include "periph_cpu.h"
27 
32 static const timer_conf_t timer_config[] = {
33  {
34  .dev = (void *)&TCC1,
35  .pwr = PWR_RED_REG(PWR_PORT_C, PR_TC1_bm),
36  .type = TC_TYPE_1,
37  .int_lvl = { CPU_INT_LVL_LOW,
41  },
42  {
43  .dev = (void *)&TCC0,
44  .pwr = PWR_RED_REG(PWR_PORT_C, PR_TC0_bm),
45  .type = TC_TYPE_0,
46  .int_lvl = { CPU_INT_LVL_LOW,
50  }
51 };
52 
53 #define TIMER_0_ISRA TCC1_CCA_vect
54 
55 #define TIMER_1_ISRA TCC0_CCA_vect
56 #define TIMER_1_ISRB TCC0_CCB_vect
57 #define TIMER_1_ISRC TCC0_CCC_vect
58 #define TIMER_1_ISRD TCC0_CCD_vect
59 
60 #define TIMER_NUMOF ARRAY_SIZE(timer_config)
67 static const uart_conf_t uart_config[] = {
68  { /* J1 */
69  .dev = &USARTF0,
70  .pwr = PWR_RED_REG(PWR_PORT_F, PR_USART0_bm),
71  .rx_pin = GPIO_PIN(PORT_F, 2),
72  .tx_pin = GPIO_PIN(PORT_F, 3),
73 #ifdef MODULE_PERIPH_UART_HW_FC
74  .rts_pin = GPIO_UNDEF,
75  .cts_pin = GPIO_UNDEF,
76 #endif
77  .rx_int_lvl = CPU_INT_LVL_LOW,
78  .tx_int_lvl = CPU_INT_LVL_LOW,
79  .dre_int_lvl = CPU_INT_LVL_OFF,
80  },
81  { /* J3 - Shared with SAUL */
82  .dev = &USARTD0,
83  .pwr = PWR_RED_REG(PWR_PORT_D, PR_USART0_bm),
84  .rx_pin = GPIO_PIN(PORT_D, 2),
85  .tx_pin = GPIO_PIN(PORT_D, 3),
86 #ifdef MODULE_PERIPH_UART_HW_FC
87  .rts_pin = GPIO_UNDEF,
88  .cts_pin = GPIO_UNDEF,
89 #endif
90  .rx_int_lvl = CPU_INT_LVL_LOW,
91  .tx_int_lvl = CPU_INT_LVL_LOW,
92  .dre_int_lvl = CPU_INT_LVL_OFF,
93  },
94  { /* J4 */
95  .dev = &USARTC0,
96  .pwr = PWR_RED_REG(PWR_PORT_C, PR_USART0_bm),
97  .rx_pin = GPIO_PIN(PORT_C, 2),
98  .tx_pin = GPIO_PIN(PORT_C, 3),
99 #ifdef MODULE_PERIPH_UART_HW_FC
100  .rts_pin = GPIO_UNDEF,
101  .cts_pin = GPIO_UNDEF,
102 #endif
103  .rx_int_lvl = CPU_INT_LVL_LOW,
104  .tx_int_lvl = CPU_INT_LVL_LOW,
105  .dre_int_lvl = CPU_INT_LVL_OFF,
106  },
107 };
108 
109 /* interrupt function name mapping */
110 #define UART_0_RXC_ISR USARTF0_RXC_vect /* Reception Complete Interrupt */
111 #define UART_0_DRE_ISR USARTF0_DRE_vect /* Data Register Empty Interrupt */
112 #define UART_0_TXC_ISR USARTF0_TXC_vect /* Transmission Complete Interrupt */
113 
114 #define UART_1_RXC_ISR USARTD0_RXC_vect
115 #define UART_1_DRE_ISR USARTD0_DRE_vect
116 #define UART_1_TXC_ISR USARTD0_TXC_vect
117 
118 #define UART_2_RXC_ISR USARTC0_RXC_vect
119 #define UART_2_DRE_ISR USARTC0_DRE_vect
120 #define UART_2_TXC_ISR USARTC0_TXC_vect
121 
122 #define UART_NUMOF ARRAY_SIZE(uart_config)
129 static const i2c_conf_t i2c_config[] = {
130  {
131  .dev = &TWIF,
132  .pwr = PWR_RED_REG(PWR_PORT_F, PR_TWI_bm),
133  .sda_pin = GPIO_PIN(PORT_F, 0),
134  .scl_pin = GPIO_PIN(PORT_F, 1),
135  .speed = I2C_SPEED_NORMAL,
136  .int_lvl = CPU_INT_LVL_LOW,
137  },
138  {
139  .dev = &TWIC,
140  .pwr = PWR_RED_REG(PWR_PORT_C, PR_TWI_bm),
141  .sda_pin = GPIO_PIN(PORT_C, 0),
142  .scl_pin = GPIO_PIN(PORT_C, 1),
143  .speed = I2C_SPEED_NORMAL,
144  .int_lvl = CPU_INT_LVL_LOW,
145  },
146 };
147 
148 #define I2C_0_ISR TWIF_TWIM_vect
149 #define I2C_1_ISR TWIC_TWIM_vect
150 
151 #define I2C_NUMOF ARRAY_SIZE(i2c_config)
158 static const spi_conf_t spi_config[] = {
159  {
160  .dev = &SPIF,
161  .pwr = PWR_RED_REG(PWR_PORT_F, PR_SPI_bm),
162  .sck_pin = GPIO_PIN(PORT_F, 7),
163  .miso_pin = GPIO_PIN(PORT_F, 6),
164  .mosi_pin = GPIO_PIN(PORT_F, 5),
165  .ss_pin = GPIO_PIN(PORT_F, 4),
166  },
167  {
168  .dev = &SPIC,
169  .pwr = PWR_RED_REG(PWR_PORT_C, PR_SPI_bm),
170  .sck_pin = GPIO_PIN(PORT_C, 7),
171  .miso_pin = GPIO_PIN(PORT_C, 6),
172  .mosi_pin = GPIO_PIN(PORT_C, 5),
173  .ss_pin = GPIO_PIN(PORT_C, 4),
174  },
175 };
176 
177 #define SPI_NUMOF ARRAY_SIZE(spi_config)
187 static const ebi_conf_t ebi_config = {
188  .addr_bits = 12,
189  .flags = (EBI_PORT_SDRAM | EBI_PORT_3PORT),
190  .sram_ale = 0,
191  .lpc_ale = 0,
192  .sdram = {
193  0,
194  1024,
195  6400,
196  EBI_CS_SDMODE_NORMAL_gc,
197  EBI_SDRAM_CAS_LAT_3CLK,
198  EBI_SDRAM_ROW_BITS_12,
199  EBI_SDCOL_10BIT_gc,
200  EBI_MRDLY_2CLK_gc,
201  EBI_ROWCYCDLY_7CLK_gc,
202  EBI_RPDLY_7CLK_gc,
203  EBI_WRDLY_1CLK_gc,
204  EBI_ESRDLY_7CLK_gc,
205  EBI_ROWCOLDLY_7CLK_gc,
206  },
207  .cs = { { EBI_CS_MODE_DISABLED_gc,
208  0,
209  EBI_CS_SRWS_0CLK_gc,
210  0x0UL,
211  },
212  { EBI_CS_MODE_DISABLED_gc,
213  0,
214  EBI_CS_SRWS_0CLK_gc,
215  0x0UL,
216  },
217  { EBI_CS_MODE_DISABLED_gc,
218  0,
219  EBI_CS_SRWS_0CLK_gc,
220  0x0UL,
221  },
222  { EBI_CS_MODE_SDRAM_gc,
223  EBI_CS_ASIZE_8MB_gc,
224  EBI_CS_SRWS_0CLK_gc,
225  0x0UL,
226  },
227  },
228 };
231 #ifdef __cplusplus
232 }
233 #endif
234 
235 #include "periph_conf_common.h"
236 
@ PORT_C
port C
Definition: periph_cpu.h:48
@ PORT_F
port F
Definition: periph_cpu.h:51
@ PORT_D
port D
Definition: periph_cpu.h:49
#define GPIO_PIN(x, y)
Define a CPU specific GPIO pin generator macro.
Definition: periph_cpu.h:45
#define GPIO_UNDEF
Definition of a fitting UNDEF value.
#define PWR_RED_REG(reg, dev)
Define a CPU specific Power Reduction index macro.
Definition: periph_cpu.h:78
@ CPU_INT_LVL_OFF
Interrupt Disabled
Definition: periph_cpu.h:39
@ CPU_INT_LVL_LOW
Interrupt Low Level
Definition: periph_cpu.h:40
static const uart_conf_t uart_config[]
UART configuration.
Definition: periph_conf.h:35
static const spi_conf_t spi_config[]
SPI configuration.
Definition: periph_conf.h:93
static const i2c_conf_t i2c_config[]
I2C configuration.
Definition: periph_conf.h:65
static const timer_conf_t timer_config[]
All timers on board.
Definition: periph_conf.h:36
@ I2C_SPEED_NORMAL
normal mode: ~100 kbit/s
Definition: periph_cpu.h:277
Mutex for thread synchronization.
I2C configuration structure.
Definition: periph_cpu.h:298
TWI_t * dev
Pointer to hardware module registers.
Definition: periph_cpu.h:299
SPI device configuration.
Definition: periph_cpu.h:336
SPI_t * dev
pointer to the used SPI device
Definition: periph_cpu.h:337
Timer device configuration.
Definition: periph_cpu.h:263
TC0_t * dev
Pointer to the used as Timer device.
Definition: periph_cpu.h:264
UART device configuration.
Definition: periph_cpu.h:217
USART_t * dev
pointer to the used UART device
Definition: periph_cpu.h:218