periph_cpu.h
Go to the documentation of this file.
1 /*
2  * Copyright (C) 2015 HAW Hamburg
3  * 2016 Freie Universit├Ąt Berlin
4  * 2018 Matthew Blue
5  *
6  * This file is subject to the terms and conditions of the GNU Lesser
7  * General Public License v2.1. See the file LICENSE in the top level
8  * directory for more details.
9  */
10 
23 #ifndef PERIPH_CPU_H
24 #define PERIPH_CPU_H
25 
26 #include "periph_cpu_common.h"
27 
28 #ifdef __cplusplus
29 extern "C" {
30 #endif
31 
35 #define GPIO_PIN(x, y) ((x << 4) | y)
36 
40 enum {
41  PORT_A = 0,
42  PORT_B = 1,
43  PORT_C = 2,
44  PORT_D = 3
45 };
46 
52 #define CPU_ATMEGA_EXT_INTS { GPIO_PIN(PORT_D, 2), \
53  GPIO_PIN(PORT_D, 3), \
54  GPIO_PIN(PORT_B, 2) }
55 
59 static inline uint8_t atmega_pin2exti(uint8_t port_num, uint8_t pin_num)
60 {
61  if (port_num == PORT_B) {
62  return 2;
63  }
64 
65  return pin_num - 2;
66 }
67 
71 static inline bool atmega_has_pin_exti(uint8_t port_num, uint8_t pin_num)
72 {
73  switch (port_num) {
74  default:
75  return false;
76  case PORT_D:
77  return ((pin_num == 2) || (pin_num == 3));
78  case PORT_B:
79  return pin_num == 2;
80  }
81 }
82 
87 #define I2C_PORT_REG PORTC
88 #define I2C_PIN_MASK (1 << PORTC0) | (1 << PORTC1)
95 #define EEPROM_SIZE (4096U) /* 4kB */
98 #ifdef __cplusplus
99 }
100 #endif
101 
102 #include "periph_conf.h"
103 #include "default_timer_config.h"
104 
105 #endif /* PERIPH_CPU_H */
@ PORT_B
port B
Definition: periph_cpu.h:37
@ PORT_C
port C
Definition: periph_cpu.h:38
@ PORT_A
port A
Definition: periph_cpu.h:36
@ PORT_D
port D
Definition: periph_cpu.h:39
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:71
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:59
Default ATmega32U4 Timer Config.