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 
18 #include "mutex.h"
19 
20 #ifndef PERIPH_CONF_H
21 #define PERIPH_CONF_H
22 
23 #ifdef __cplusplus
24 extern "C" {
25 #endif
26 
27 #include <stdint.h>
28 #include <avr/io.h>
29 
30 #include "periph_cpu.h"
31 
36 static const timer_conf_t timer_config[] = {
37  {
38  .dev = (void *)&TCC1,
39  .pwr = PWR_RED_REG(PWR_PORT_C, PR_TC1_bm),
40  .type = TC_TYPE_1,
41  .int_lvl = { CPU_INT_LVL_LOW,
45  },
46  {
47  .dev = (void *)&TCC0,
48  .pwr = PWR_RED_REG(PWR_PORT_C, PR_TC0_bm),
49  .type = TC_TYPE_0,
50  .int_lvl = { CPU_INT_LVL_LOW,
54  }
55 };
56 
57 #define TIMER_0_ISRA TCC1_CCA_vect
58 
59 #define TIMER_1_ISRA TCC0_CCA_vect
60 #define TIMER_1_ISRB TCC0_CCB_vect
61 #define TIMER_1_ISRC TCC0_CCC_vect
62 #define TIMER_1_ISRD TCC0_CCD_vect
63 
64 #define TIMER_NUMOF ARRAY_SIZE(timer_config)
71 static const uart_conf_t uart_config[] = {
72  { /* CDC-ACM */
73  .dev = &USARTE0,
74  .pwr = PWR_RED_REG(PWR_PORT_E, PR_USART0_bm),
75  .rx_pin = GPIO_PIN(PORT_E, 2),
76  .tx_pin = GPIO_PIN(PORT_E, 3),
77 #ifdef MODULE_PERIPH_UART_HW_FC
78  .rts_pin = GPIO_UNDEF,
79  .cts_pin = GPIO_UNDEF,
80 #endif
81  .rx_int_lvl = CPU_INT_LVL_LOW,
82  .tx_int_lvl = CPU_INT_LVL_LOW,
83  .dre_int_lvl = CPU_INT_LVL_OFF,
84  },
85 };
86 
87 /* interrupt function name mapping */
88 #define UART_0_RXC_ISR USARTE0_RXC_vect /* Reception Complete Interrupt */
89 #define UART_0_DRE_ISR USARTE0_DRE_vect /* Data Register Empty Interrupt */
90 #define UART_0_TXC_ISR USARTE0_TXC_vect /* Transmission Complete Interrupt */
91 
92 #define UART_NUMOF ARRAY_SIZE(uart_config)
99 static const i2c_conf_t i2c_config[] = {
100  {
101  .dev = &TWIC,
102  .pwr = PWR_RED_REG(PWR_PORT_C, PR_TWI_bm),
103  .sda_pin = GPIO_PIN(PORT_C, 0),
104  .scl_pin = GPIO_PIN(PORT_C, 1),
105  .speed = I2C_SPEED_NORMAL,
106  .int_lvl = CPU_INT_LVL_LOW,
107  },
108 };
109 
110 #define I2C_0_ISR TWIC_TWIM_vect
111 
112 #define I2C_NUMOF ARRAY_SIZE(i2c_config)
119 static const spi_conf_t spi_config[] = {
120  {
121  .dev = &SPIC,
122  .pwr = PWR_RED_REG(PWR_PORT_C, PR_SPI_bm),
123  .sck_pin = GPIO_PIN(PORT_C, 7),
124  .miso_pin = GPIO_PIN(PORT_C, 6),
125  .mosi_pin = GPIO_PIN(PORT_C, 5),
126  .ss_pin = GPIO_PIN(PORT_C, 4),
127  },
128 };
129 
130 #define SPI_NUMOF ARRAY_SIZE(spi_config)
140 static const ebi_conf_t ebi_config = {
141  .addr_bits = 18, /* A0-A17 */
142  .flags = (EBI_PORT_LPC | EBI_PORT_CS2),
143  .sram_ale = 0,
144  .lpc_ale = 2,
145  .sdram = { 0 },
146  .cs = { /* Reserved A16 */
147  { EBI_CS_MODE_DISABLED_gc,
148  0,
149  EBI_CS_SRWS_0CLK_gc,
150  0x0UL,
151  }, /* Reserved A17 */
152  { EBI_CS_MODE_DISABLED_gc,
153  0,
154  EBI_CS_SRWS_0CLK_gc,
155  0x0UL,
156  }, /* CS2 - 256K SRAM */
157  { EBI_CS_MODE_LPC_gc,
158  EBI_CS_ASIZE_256KB_gc,
159  EBI_CS_SRWS_1CLK_gc,
160  0x0UL,
161  }, /* Reserved LCD */
162  { EBI_CS_MODE_DISABLED_gc,
163  0,
164  EBI_CS_SRWS_0CLK_gc,
165  0x0UL,
166  },
167  },
168 };
171 #ifdef __cplusplus
172 }
173 #endif
174 
175 #include "periph_conf_common.h"
176 
177 #endif /* PERIPH_CONF_H */
@ PORT_C
port C
Definition: periph_cpu.h:49
@ PORT_E
port E
Definition: periph_cpu.h:51
#define GPIO_PIN(x, y)
Define a CPU specific GPIO pin generator macro.
Definition: periph_cpu.h:46
#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:79
@ CPU_INT_LVL_OFF
Interrupt Disabled
Definition: periph_cpu.h:40
@ CPU_INT_LVL_LOW
Interrupt Low Level
Definition: periph_cpu.h:41
static const uart_conf_t uart_config[]
UART configuration.
Definition: periph_conf.h:39
static const spi_conf_t spi_config[]
SPI configuration.
Definition: periph_conf.h:97
static const i2c_conf_t i2c_config[]
I2C configuration.
Definition: periph_conf.h:69
static const timer_conf_t timer_config[]
All timers on board.
Definition: periph_conf.h:40
@ I2C_SPEED_NORMAL
normal mode: ~100 kbit/s
Definition: periph_cpu.h:278
Mutex for thread synchronization.
I2C configuration structure.
Definition: periph_cpu.h:299
TWI_t * dev
Pointer to hardware module registers.
Definition: periph_cpu.h:300
SPI device configuration.
Definition: periph_cpu.h:337
SPI_t * dev
pointer to the used SPI device
Definition: periph_cpu.h:338
Timer device configuration.
Definition: periph_cpu.h:264
TC0_t * dev
Pointer to the used as Timer device.
Definition: periph_cpu.h:265
UART device configuration.
Definition: periph_cpu.h:218
USART_t * dev
pointer to the used UART device
Definition: periph_cpu.h:219