Loading...
Searching...
No Matches
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
29extern "C" {
30#endif
31
36#define PM_NUM_MODES (5)
37#define AVR8_PM_SLEEP_MODE_0 SLEEP_MODE_PWR_DOWN
38#define AVR8_PM_SLEEP_MODE_1 SLEEP_MODE_PWR_SAVE
39#define AVR8_PM_SLEEP_MODE_2 SLEEP_MODE_STANDBY
40#define AVR8_PM_SLEEP_MODE_3 SLEEP_MODE_ADC
46#define GPIO_PIN(x, y) ((x << 4) | y)
47
51enum {
52 PORT_A = 0,
53 PORT_B = 1,
54 PORT_C = 2,
55 PORT_D = 3
56};
57
63#define CPU_ATMEGA_EXT_INTS { GPIO_PIN(PORT_D, 2), \
64 GPIO_PIN(PORT_D, 3), \
65 GPIO_PIN(PORT_B, 2) }
66
70static inline uint8_t atmega_pin2exti(uint8_t port_num, uint8_t pin_num)
71{
72 if (port_num == PORT_B) {
73 return 2;
74 }
75
76 return pin_num - 2;
77}
78
82static inline bool atmega_has_pin_exti(uint8_t port_num, uint8_t pin_num)
83{
84 switch (port_num) {
85 default:
86 return false;
87 case PORT_D:
88 return ((pin_num == 2) || (pin_num == 3));
89 case PORT_B:
90 return pin_num == 2;
91 }
92}
93
98#define I2C_PORT_REG PORTC
99#define I2C_PIN_MASK (1 << PORTC0) | (1 << PORTC1)
106#define EEPROM_SIZE (4096U) /* 4kB */
109#ifdef __cplusplus
110}
111#endif
112
113#include "periph_conf.h"
114#include "default_timer_config.h"
115
116#endif /* PERIPH_CPU_H */
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:82
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:73
@ PORT_B
port B
Definition periph_cpu.h:48
@ PORT_C
port C
Definition periph_cpu.h:49
@ PORT_A
port A
Definition periph_cpu.h:47
@ PORT_D
port D
Definition periph_cpu.h:50
Default timer configuration.