Loading...
Searching...
No Matches
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
23extern "C" {
24#endif
25
26#include <stdint.h>
27#include <avr/io.h>
28
29#include "periph_cpu.h"
30
35static 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)
65
70static const uart_conf_t uart_config[] = {
71 { /* CDC-ACM */
72 .dev = &USARTE0,
73 .pwr = PWR_RED_REG(PWR_PORT_E, PR_USART0_bm),
74 .rx_pin = GPIO_PIN(PORT_E, 2),
75 .tx_pin = GPIO_PIN(PORT_E, 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};
85
86/* interrupt function name mapping */
87#define UART_0_RXC_ISR USARTE0_RXC_vect /* Reception Complete Interrupt */
88#define UART_0_DRE_ISR USARTE0_DRE_vect /* Data Register Empty Interrupt */
89#define UART_0_TXC_ISR USARTE0_TXC_vect /* Transmission Complete Interrupt */
90
91#define UART_NUMOF ARRAY_SIZE(uart_config)
93
98static const i2c_conf_t i2c_config[] = {
99 {
100 .dev = &TWIC,
101 .pwr = PWR_RED_REG(PWR_PORT_C, PR_TWI_bm),
102 .sda_pin = GPIO_PIN(PORT_C, 0),
103 .scl_pin = GPIO_PIN(PORT_C, 1),
104 .speed = I2C_SPEED_NORMAL,
105 .int_lvl = CPU_INT_LVL_LOW,
106 },
107};
108
109#define I2C_0_ISR TWIC_TWIM_vect
110
111#define I2C_NUMOF ARRAY_SIZE(i2c_config)
113
118static const spi_conf_t spi_config[] = {
119 {
120 .dev = &SPIC,
121 .pwr = PWR_RED_REG(PWR_PORT_C, PR_SPI_bm),
122 .sck_pin = GPIO_PIN(PORT_C, 7),
123 .miso_pin = GPIO_PIN(PORT_C, 6),
124 .mosi_pin = GPIO_PIN(PORT_C, 5),
125 .ss_pin = GPIO_PIN(PORT_C, 4),
126 },
127};
128
129#define SPI_NUMOF ARRAY_SIZE(spi_config)
131
139static const ebi_conf_t ebi_config = {
140 .addr_bits = 18, /* A0-A17 */
141 .flags = (EBI_PORT_LPC | EBI_PORT_CS2),
142 .sram_ale = 0,
143 .lpc_ale = 2,
144 .sdram = { 0 },
145 .cs = { /* Reserved A16 */
146 { EBI_CS_MODE_DISABLED_gc,
147 0,
148 EBI_CS_SRWS_0CLK_gc,
149 0x0UL,
150 }, /* Reserved A17 */
151 { EBI_CS_MODE_DISABLED_gc,
152 0,
153 EBI_CS_SRWS_0CLK_gc,
154 0x0UL,
155 }, /* CS2 - 256K SRAM */
156 { EBI_CS_MODE_LPC_gc,
157 EBI_CS_ASIZE_256KB_gc,
158 EBI_CS_SRWS_1CLK_gc,
159 0x0UL,
160 }, /* Reserved LCD */
161 { EBI_CS_MODE_DISABLED_gc,
162 0,
163 EBI_CS_SRWS_0CLK_gc,
164 0x0UL,
165 },
166 },
167};
169
170#ifdef __cplusplus
171}
172#endif
173
174#include "periph_conf_common.h"
175
@ PORT_C
port C
Definition periph_cpu.h:48
@ PORT_E
port E
Definition periph_cpu.h:50
#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
@ I2C_SPEED_NORMAL
normal mode: ~100 kbit/s
Definition periph_cpu.h:277
@ CPU_INT_LVL_OFF
Interrupt Disabled.
Definition periph_cpu.h:39
@ CPU_INT_LVL_LOW
Interrupt Low Level.
Definition periph_cpu.h:40
Mutex for thread synchronization.
I2C configuration structure.
Definition periph_cpu.h:298
SPI device configuration.
Definition periph_cpu.h:336
Timer device configuration.
Definition periph_cpu.h:263
UART device configuration.
Definition periph_cpu.h:217