periph_conf.h
Go to the documentation of this file.
1 /*
2  * Copyright (C) 2021 Gerson Fernando Budke
3  *
4  * This file is subject to the terms and conditions of the GNU Lesser
5  * General Public License v2.1. See the file LICENSE in the top level
6  * directory for more details.
7  */
8 
9 #pragma once
10 
20 #include "mutex.h"
21 
22 #ifdef __cplusplus
23 extern "C" {
24 #endif
25 
26 #include <stdint.h>
27 #include <avr/io.h>
28 
29 #include "periph_cpu.h"
30 
35 static const timer_conf_t timer_config[] = {
36  {
37  .dev = (void *)&TCC1,
38  .pwr = PWR_RED_REG(PWR_PORT_C, PR_TC1_bm),
39  .type = TC_TYPE_1,
40  .int_lvl = { CPU_INT_LVL_LOW,
44  },
45  {
46  .dev = (void *)&TCC0,
47  .pwr = PWR_RED_REG(PWR_PORT_C, PR_TC0_bm),
48  .type = TC_TYPE_0,
49  .int_lvl = { CPU_INT_LVL_LOW,
53  }
54 };
55 
56 #define TIMER_0_ISRA TCC1_CCA_vect
57 
58 #define TIMER_1_ISRA TCC0_CCA_vect
59 #define TIMER_1_ISRB TCC0_CCB_vect
60 #define TIMER_1_ISRC TCC0_CCC_vect
61 #define TIMER_1_ISRD TCC0_CCD_vect
62 
63 #define TIMER_NUMOF ARRAY_SIZE(timer_config)
70 static const uart_conf_t uart_config[] = {
71  { /* J1 */
72  .dev = &USARTF0,
73  .pwr = PWR_RED_REG(PWR_PORT_F, PR_USART0_bm),
74  .rx_pin = GPIO_PIN(PORT_F, 2),
75  .tx_pin = GPIO_PIN(PORT_F, 3),
76 #ifdef MODULE_PERIPH_UART_HW_FC
77  .rts_pin = GPIO_UNDEF,
78  .cts_pin = GPIO_UNDEF,
79 #endif
80  .rx_int_lvl = CPU_INT_LVL_LOW,
81  .tx_int_lvl = CPU_INT_LVL_LOW,
82  .dre_int_lvl = CPU_INT_LVL_OFF,
83  },
84  { /* J3 - Shared with SAUL */
85  .dev = &USARTD0,
86  .pwr = PWR_RED_REG(PWR_PORT_D, PR_USART0_bm),
87  .rx_pin = GPIO_PIN(PORT_D, 2),
88  .tx_pin = GPIO_PIN(PORT_D, 3),
89 #ifdef MODULE_PERIPH_UART_HW_FC
90  .rts_pin = GPIO_UNDEF,
91  .cts_pin = GPIO_UNDEF,
92 #endif
93  .rx_int_lvl = CPU_INT_LVL_LOW,
94  .tx_int_lvl = CPU_INT_LVL_LOW,
95  .dre_int_lvl = CPU_INT_LVL_OFF,
96  },
97  { /* J4 */
98  .dev = &USARTC0,
99  .pwr = PWR_RED_REG(PWR_PORT_C, PR_USART0_bm),
100  .rx_pin = GPIO_PIN(PORT_C, 2),
101  .tx_pin = GPIO_PIN(PORT_C, 3),
102 #ifdef MODULE_PERIPH_UART_HW_FC
103  .rts_pin = GPIO_UNDEF,
104  .cts_pin = GPIO_UNDEF,
105 #endif
106  .rx_int_lvl = CPU_INT_LVL_LOW,
107  .tx_int_lvl = CPU_INT_LVL_LOW,
108  .dre_int_lvl = CPU_INT_LVL_OFF,
109  },
110 };
111 
112 /* interrupt function name mapping */
113 #define UART_0_RXC_ISR USARTF0_RXC_vect /* Reception Complete Interrupt */
114 #define UART_0_DRE_ISR USARTF0_DRE_vect /* Data Register Empty Interrupt */
115 #define UART_0_TXC_ISR USARTF0_TXC_vect /* Transmission Complete Interrupt */
116 
117 #define UART_1_RXC_ISR USARTD0_RXC_vect
118 #define UART_1_DRE_ISR USARTD0_DRE_vect
119 #define UART_1_TXC_ISR USARTD0_TXC_vect
120 
121 #define UART_2_RXC_ISR USARTC0_RXC_vect
122 #define UART_2_DRE_ISR USARTC0_DRE_vect
123 #define UART_2_TXC_ISR USARTC0_TXC_vect
124 
125 #define UART_NUMOF ARRAY_SIZE(uart_config)
132 static const i2c_conf_t i2c_config[] = {
133  {
134  .dev = &TWIF,
135  .pwr = PWR_RED_REG(PWR_PORT_F, PR_TWI_bm),
136  .sda_pin = GPIO_PIN(PORT_F, 0),
137  .scl_pin = GPIO_PIN(PORT_F, 1),
138  .speed = I2C_SPEED_NORMAL,
139  .int_lvl = CPU_INT_LVL_LOW,
140  },
141  {
142  .dev = &TWIC,
143  .pwr = PWR_RED_REG(PWR_PORT_C, PR_TWI_bm),
144  .sda_pin = GPIO_PIN(PORT_C, 0),
145  .scl_pin = GPIO_PIN(PORT_C, 1),
146  .speed = I2C_SPEED_NORMAL,
147  .int_lvl = CPU_INT_LVL_LOW,
148  },
149 };
150 
151 #define I2C_0_ISR TWIF_TWIM_vect
152 #define I2C_1_ISR TWIC_TWIM_vect
153 
154 #define I2C_NUMOF ARRAY_SIZE(i2c_config)
161 static const spi_conf_t spi_config[] = {
162  {
163  .dev = &SPIF,
164  .pwr = PWR_RED_REG(PWR_PORT_F, PR_SPI_bm),
165  .sck_pin = GPIO_PIN(PORT_F, 7),
166  .miso_pin = GPIO_PIN(PORT_F, 6),
167  .mosi_pin = GPIO_PIN(PORT_F, 5),
168  .ss_pin = GPIO_PIN(PORT_F, 4),
169  },
170  {
171  .dev = &SPIC,
172  .pwr = PWR_RED_REG(PWR_PORT_C, PR_SPI_bm),
173  .sck_pin = GPIO_PIN(PORT_C, 7),
174  .miso_pin = GPIO_PIN(PORT_C, 6),
175  .mosi_pin = GPIO_PIN(PORT_C, 5),
176  .ss_pin = GPIO_PIN(PORT_C, 4),
177  },
178 };
179 
180 #define SPI_NUMOF ARRAY_SIZE(spi_config)
190 static const ebi_conf_t ebi_config = {
191  .addr_bits = 12,
192  .flags = (EBI_PORT_SDRAM | EBI_PORT_3PORT),
193  .sram_ale = 0,
194  .lpc_ale = 0,
195  .sdram = {
196  0,
197  1024,
198  6400,
199  EBI_CS_SDMODE_NORMAL_gc,
200  EBI_SDRAM_CAS_LAT_3CLK,
201  EBI_SDRAM_ROW_BITS_12,
202  EBI_SDCOL_10BIT_gc,
203  EBI_MRDLY_2CLK_gc,
204  EBI_ROWCYCDLY_7CLK_gc,
205  EBI_RPDLY_7CLK_gc,
206  EBI_WRDLY_1CLK_gc,
207  EBI_ESRDLY_7CLK_gc,
208  EBI_ROWCOLDLY_7CLK_gc,
209  },
210  .cs = { { EBI_CS_MODE_DISABLED_gc,
211  0,
212  EBI_CS_SRWS_0CLK_gc,
213  0x0UL,
214  },
215  { EBI_CS_MODE_DISABLED_gc,
216  0,
217  EBI_CS_SRWS_0CLK_gc,
218  0x0UL,
219  },
220  { EBI_CS_MODE_DISABLED_gc,
221  0,
222  EBI_CS_SRWS_0CLK_gc,
223  0x0UL,
224  },
225  { EBI_CS_MODE_SDRAM_gc,
226  EBI_CS_ASIZE_8MB_gc,
227  EBI_CS_SRWS_0CLK_gc,
228  0x0UL,
229  },
230  },
231 };
234 #ifdef __cplusplus
235 }
236 #endif
237 
238 #include "periph_conf_common.h"
239 
@ 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:38
static const spi_conf_t spi_config[]
SPI configuration.
Definition: periph_conf.h:96
static const i2c_conf_t i2c_config[]
I2C configuration.
Definition: periph_conf.h:68
static const timer_conf_t timer_config[]
All timers on board.
Definition: periph_conf.h:39
@ 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