periph_cpu.h
Go to the documentation of this file.
1 /*
2  * SPDX-FileCopyrightText: 2015 HAW Hamburg
3  * SPDX-FileCopyrightText: 2016 Freie Universität Berlin
4  * SPDX-FileCopyrightText: 2023 Hugues Larrive
5  * SPDX-License-Identifier: LGPL-2.1-only
6  */
7 
8 #pragma once
9 
22 #include "periph_cpu_common.h"
23 
24 #ifdef __cplusplus
25 extern "C" {
26 #endif
27 
32 #define PM_NUM_MODES (5)
33 #define AVR8_PM_SLEEP_MODE_0 SLEEP_MODE_PWR_DOWN
34 #define AVR8_PM_SLEEP_MODE_1 SLEEP_MODE_PWR_SAVE
35 #define AVR8_PM_SLEEP_MODE_2 SLEEP_MODE_STANDBY
36 #define AVR8_PM_SLEEP_MODE_3 SLEEP_MODE_ADC
42 #define GPIO_PIN(x, y) ((x << 4) | y)
43 
47 enum {
48  PORT_B = 1,
49  PORT_C = 2,
50  PORT_D = 3
51 };
52 
58 #define CPU_ATMEGA_EXT_INTS { GPIO_PIN(PORT_D, 2), \
59  GPIO_PIN(PORT_D, 3) }
60 
64 static inline uint8_t atmega_pin2exti(uint8_t port_num, uint8_t pin_num)
65 {
66  (void)port_num;
67  return pin_num - 2;
68 }
69 
73 static inline bool atmega_has_pin_exti(uint8_t port_num, uint8_t pin_num)
74 {
75  if (port_num == PORT_D) {
76  return ((pin_num == 2) || (pin_num == 3));
77  }
78 
79  return false;
80 }
81 
86 #define I2C_PORT_REG PORTC
87 #define I2C_PIN_MASK (1 << PORTC4) | (1 << PORTC5)
94 #define EEPROM_SIZE (512U) /* 512B */
97 #ifdef __cplusplus
98 }
99 #endif
100 
101 #include "periph_conf.h"
102 #include "default_timer_config.h"
103 
@ PORT_B
port B
Definition: periph_cpu.h:44
@ PORT_C
port C
Definition: periph_cpu.h:45
@ PORT_D
port D
Definition: periph_cpu.h:46
Default timer configuration.
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:73
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:64