periph_cpu.h
Go to the documentation of this file.
1 /*
2  * SPDX-FileCopyrightText: 2017 Josua Arndt, Steffen Robertz, RWTH Aachen
3  * SPDX-License-Identifier: LGPL-2.1-only
4  */
5 
6 #pragma once
7 
19 #include "periph_cpu_common.h"
20 #include "atmega_regs_common.h"
21 
22 #ifdef __cplusplus
23 extern "C" {
24 #endif
25 
30 #define PM_NUM_MODES (5)
31 #define AVR8_PM_SLEEP_MODE_0 SLEEP_MODE_PWR_DOWN
32 #define AVR8_PM_SLEEP_MODE_1 SLEEP_MODE_PWR_SAVE
33 #define AVR8_PM_SLEEP_MODE_2 SLEEP_MODE_STANDBY
34 #define AVR8_PM_SLEEP_MODE_3 SLEEP_MODE_ADC
41 enum {
42  PORT_B = 1,
43  PORT_D = 3,
44  PORT_E = 4,
45  PORT_F = 5,
46  PORT_G = 6,
47 };
55 #define CPU_ATMEGA_EXT_INTS { GPIO_PIN(PORT_D, 0), \
56  GPIO_PIN(PORT_D, 1), \
57  GPIO_PIN(PORT_D, 2), \
58  GPIO_PIN(PORT_D, 3), \
59  GPIO_PIN(PORT_E, 4), \
60  GPIO_PIN(PORT_E, 5), \
61  GPIO_PIN(PORT_E, 6), \
62  GPIO_PIN(PORT_E, 7) }
63 
67 static inline uint8_t atmega_pin2exti(uint8_t port_num, uint8_t pin_num)
68 {
69  (void)port_num;
70  return pin_num;
71 }
72 
76 static inline bool atmega_has_pin_exti(uint8_t port_num, uint8_t pin_num)
77 {
78  if (pin_num < 4) {
79  return port_num == PORT_D;
80  }
81 
82  return port_num == PORT_E;
83 }
84 
89 #define I2C_PORT_REG PORTD
90 #define I2C_PIN_MASK (1 << PORTD1) | (1 << PORTD0)
97 #define EEPROM_SIZE (8192U) /* 8kB */
100 #ifdef __cplusplus
101 }
102 #endif
103 
104 #include "periph_conf.h"
105 #include "default_timer_config.h"
106 
@ PORT_B
port B
Definition: periph_cpu.h:44
@ PORT_G
port G
Definition: periph_cpu.h:49
@ PORT_F
port F
Definition: periph_cpu.h:48
@ PORT_E
port E
Definition: periph_cpu.h:47
@ PORT_D
port D
Definition: periph_cpu.h:46
static bool atmega_has_pin_exti(uint8_t port_num, uint8_t pin_num)
Check if the given pin can be used as external interrupt.
Definition: periph_cpu.h:76
static uint8_t atmega_pin2exti(uint8_t port_num, uint8_t pin_num)
Get the interrupt vector number of the given GPIO pin.
Definition: periph_cpu.h:67
Default timer configuration.
CMSIS style register definitions for the atmega family.