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: 2018 Matthew Blue
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_A = 0,
49  PORT_B = 1,
50  PORT_C = 2,
51  PORT_D = 3
52 };
53 
59 #define CPU_ATMEGA_EXT_INTS { GPIO_PIN(PORT_D, 2), \
60  GPIO_PIN(PORT_D, 3), \
61  GPIO_PIN(PORT_B, 2) }
62 
66 static inline uint8_t atmega_pin2exti(uint8_t port_num, uint8_t pin_num)
67 {
68  if (port_num == PORT_B) {
69  return 2;
70  }
71 
72  return pin_num - 2;
73 }
74 
78 static inline bool atmega_has_pin_exti(uint8_t port_num, uint8_t pin_num)
79 {
80  switch (port_num) {
81  default:
82  return false;
83  case PORT_D:
84  return ((pin_num == 2) || (pin_num == 3));
85  case PORT_B:
86  return pin_num == 2;
87  }
88 }
89 
94 #define I2C_PORT_REG PORTC
95 #define I2C_PIN_MASK (1 << PORTC0) | (1 << PORTC1)
102 #define EEPROM_SIZE (4096U) /* 4kB */
105 #ifdef __cplusplus
106 }
107 #endif
108 
109 #include "periph_conf.h"
110 #include "default_timer_config.h"
111 
@ PORT_B
port B
Definition: periph_cpu.h:44
@ PORT_C
port C
Definition: periph_cpu.h:45
@ PORT_A
port A
Definition: periph_cpu.h:43
@ 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:78
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:66
Default timer configuration.