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 = &USARTC0,
73  .pwr = PWR_RED_REG(PWR_PORT_C, PR_USART0_bm),
74  .rx_pin = GPIO_PIN(PORT_C, 2),
75  .tx_pin = GPIO_PIN(PORT_C, 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  { /* J4 */
85  .dev = &USARTE0,
86  .pwr = PWR_RED_REG(PWR_PORT_E, PR_USART0_bm),
87  .rx_pin = GPIO_PIN(PORT_E, 2),
88  .tx_pin = GPIO_PIN(PORT_E, 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 };
98 
99 /* interrupt function name mapping */
100 #define UART_0_RXC_ISR USARTC0_RXC_vect /* Reception Complete Interrupt */
101 #define UART_0_DRE_ISR USARTC0_DRE_vect /* Data Register Empty Interrupt */
102 #define UART_0_TXC_ISR USARTC0_TXC_vect /* Transmission Complete Interrupt */
103 
104 #define UART_1_RXC_ISR USARTE0_RXC_vect
105 #define UART_1_DRE_ISR USARTE0_DRE_vect
106 #define UART_1_TXC_ISR USARTE0_TXC_vect
107 
108 #define UART_NUMOF ARRAY_SIZE(uart_config)
115 static const i2c_conf_t i2c_config[] = {
116  { /* J1 */
117  .dev = &TWIC,
118  .pwr = PWR_RED_REG(PWR_PORT_C, PR_TWI_bm),
119  .sda_pin = GPIO_PIN(PORT_C, 0),
120  .scl_pin = GPIO_PIN(PORT_C, 1),
121  .speed = I2C_SPEED_NORMAL,
122  .int_lvl = CPU_INT_LVL_LOW,
123  },
124 };
125 
126 #define I2C_0_ISR TWIC_TWIM_vect
127 
128 #define I2C_NUMOF ARRAY_SIZE(i2c_config)
135 static const spi_conf_t spi_config[] = {
136  {
137  .dev = &SPIC,
138  .pwr = PWR_RED_REG(PWR_PORT_C, PR_SPI_bm),
139  .sck_pin = GPIO_PIN(PORT_C, 7),
140  .miso_pin = GPIO_PIN(PORT_C, 6),
141  .mosi_pin = GPIO_PIN(PORT_C, 5),
142  .ss_pin = GPIO_PIN(PORT_C, 4),
143  },
144 };
145 
146 #define SPI_NUMOF ARRAY_SIZE(spi_config)
149 #ifdef __cplusplus
150 }
151 #endif
152 
153 #include "periph_conf_common.h"
154 
@ 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
@ 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