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
11#pragma once
12
24
25#include "periph_cpu_common.h"
26
27#ifdef __cplusplus
28extern "C" {
29#endif
30
35#define PM_NUM_MODES (5)
36#define AVR8_PM_SLEEP_MODE_0 SLEEP_MODE_PWR_DOWN
37#define AVR8_PM_SLEEP_MODE_1 SLEEP_MODE_PWR_SAVE
38#define AVR8_PM_SLEEP_MODE_2 SLEEP_MODE_STANDBY
39#define AVR8_PM_SLEEP_MODE_3 SLEEP_MODE_ADC
41
45#define GPIO_PIN(x, y) ((x << 4) | y)
46
50enum {
51 PORT_A = 0,
52 PORT_B = 1,
53 PORT_C = 2,
54 PORT_D = 3
55};
56
62#define CPU_ATMEGA_EXT_INTS { GPIO_PIN(PORT_D, 2), \
63 GPIO_PIN(PORT_D, 3), \
64 GPIO_PIN(PORT_B, 2) }
65
69static inline uint8_t atmega_pin2exti(uint8_t port_num, uint8_t pin_num)
70{
71 if (port_num == PORT_B) {
72 return 2;
73 }
74
75 return pin_num - 2;
76}
77
81static inline bool atmega_has_pin_exti(uint8_t port_num, uint8_t pin_num)
82{
83 switch (port_num) {
84 default:
85 return false;
86 case PORT_D:
87 return ((pin_num == 2) || (pin_num == 3));
88 case PORT_B:
89 return pin_num == 2;
90 }
91}
92
97#define I2C_PORT_REG PORTC
98#define I2C_PIN_MASK (1 << PORTC0) | (1 << PORTC1)
100
105#define EEPROM_SIZE (4096U) /* 4kB */
107
108#ifdef __cplusplus
109}
110#endif
111
112#include "periph_conf.h"
113#include "default_timer_config.h"
114
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:81
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:72
@ PORT_B
port B
Definition periph_cpu.h:47
@ PORT_C
port C
Definition periph_cpu.h:48
@ PORT_A
port A
Definition periph_cpu.h:46
@ PORT_D
port D
Definition periph_cpu.h:49
Default timer configuration.