25#ifndef PERIPH_CPU_COMMON_H
26#define PERIPH_CPU_COMMON_H
47typedef uint8_t gpio_t;
54#define GPIO_UNDEF (0xff)
59#define GPIO_PIN(x, y) ((x << 4) | y)
66#if (defined(OCF1A) && defined(OCF1B) && (OCF1A > OCF1B)) \
67 || (defined(PUD) && (PUD != 4)) || (defined(INT0) && (INT0 == 6))
70#define GPIO_PORT_DESCENDENT
73#ifdef GPIO_PORT_DESCENDENT
74#ifdef _AVR_ATTINY1634_H_INCLUDED
76#define ATMEGA_GPIO_BASE_A 0x2F
82#define ATMEGA_GPIO_BASE_A 0x39
85#define ATMEGA_GPIO_BASE_A 0x20
92#define ATMEGA_GPIO_BASE_G (ATMEGA_GPIO_BASE_A + ATMEGA_GPIO_SIZE * ('G' - 'A'))
98#define ATMEGA_GPIO_BASE_H (0x100)
102#define ATMEGA_GPIO_SIZE (0x03)
108#define GPIO_EXT_INT_NUMOF <CPU_SPECIFIC>
109#elif defined(INT7_vect)
110#define GPIO_EXT_INT_NUMOF (8U)
111#elif defined(INT6_vect)
112#define GPIO_EXT_INT_NUMOF (7U)
113#elif defined(INT5_vect)
114#define GPIO_EXT_INT_NUMOF (6U)
115#elif defined(INT4_vect)
116#define GPIO_EXT_INT_NUMOF (5U)
117#elif defined(INT3_vect)
118#define GPIO_EXT_INT_NUMOF (4U)
119#elif defined(INT2_vect)
120#define GPIO_EXT_INT_NUMOF (3U)
122#define GPIO_EXT_INT_NUMOF (2U)
162#ifdef GPIO_PORT_DESCENDENT
171 if (port_num >
'G'-
'A') {
190#define HAVE_GPIO_FLANK_T
201#define HAVE_GPIO_SLEW_T
209#define HAVE_GPIO_PULL_STRENGTH_T
217#define HAVE_GPIO_DRIVE_STRENGTH_T
225#define HAVE_GPIO_IRQ_TRIG_T
234#define HAVE_GPIO_STATE_T
244#define HAVE_GPIO_LL_PREPARE_WRITE_ALL_PINS
245#define HAVE_GPIO_LL_PREPARE_WRITE
253#define PERIPH_SPI_NEEDS_INIT_CS
254#define PERIPH_SPI_NEEDS_TRANSFER_BYTE
255#define PERIPH_SPI_NEEDS_TRANSFER_REG
256#define PERIPH_SPI_NEEDS_TRANSFER_REGS
266#define SPI_MODE_SEL(pol, pha) ((pol << 3) | (pha << 2))
275#define HAVE_SPI_MODE_T
290#define SPI_CLK_SEL(s2x, pr1, pr0) ((s2x << 2) | (pr1 << 1) | pr0)
298#define HAVE_SPI_CLK_T
333#define PERIPH_TIMER_PROVIDES_SET
338#define EEPROM_CLEAR_BYTE (0xff)
344#define NWDT_TIME_LOWER_LIMIT (1)
345#define NWDT_TIME_UPPER_LIMIT (8192U)
351#define WDT_HAS_STOP (1)
357#if defined(SCCR0) && !defined(RTT_BACKEND_SC)
358#define RTT_BACKEND_SC (1)
364#define RTT_MAX_VALUE (0xFFFFFFFFUL)
368#define RTT_FREQUENCY (62500UL)
374#define RTT_MAX_VALUE (0x00FFFFFF)
378#define RTT_FREQUENCY (1024U)
static atmega_gpio_port_t * atmega_gpio_port(uint8_t port_num)
Get the GPIO PORT registers of the given GPIO PORT.
#define ATMEGA_GPIO_BASE_H
Base of the GPIO registers of the second memory region (port >= H)
#define ATMEGA_GPIO_BASE_A
Base of the GPIO registers as memory address.
@ TIMER_DIV1_8_32_64_128_256_1024
1/{1,8,32,64,128,256,1024}
@ TIMER_DIV1_8_64_128_1024
1/{1,8,64,128,1024}
#define ATMEGA_GPIO_BASE_G
Base of the GPIO port G register as memory address.
@ SPI_CLK_10MHZ
drive the SPI bus with 10MHz
@ SPI_CLK_5MHZ
drive the SPI bus with 5MHz
@ SPI_CLK_400KHZ
drive the SPI bus with 400KHz
@ SPI_CLK_1MHZ
drive the SPI bus with 1MHz
@ SPI_CLK_100KHZ
drive the SPI bus with 100KHz
gpio_irq_trig_t
Definition of possible IRQ triggers.
@ GPIO_TRIGGER_EDGE_FALLING
edge triggered IRQ on falling flanks only
@ GPIO_TRIGGER_LEVEL_HIGH
level triggered IRQ on high input
@ GPIO_TRIGGER_EDGE_RISING
edge triggered IRQ on rising flanks only
@ GPIO_TRIGGER_EDGE_BOTH
edge triggered IRQ on falling AND rising flanks
@ GPIO_TRIGGER_LEVEL_LOW
level triggered IRQ on low input
gpio_pull_strength_t
Enumeration of pull resistor values.
gpio_state_t
Enumeration of GPIO states (direction)
gpio_slew_t
Enumeration of slew rate settings.
gpio_drive_strength_t
Enumeration of drive strength options.
@ GPIO_PULL_WEAKEST
Use the weakest (highest Ohm value) resistor.
@ GPIO_PULL_WEAK
Use a weak pull resistor.
@ GPIO_PULL_STRONG
Use a strong pull resistor.
@ GPIO_PULL_STRONGEST
Use the strongest pull resistor.
@ GPIO_OUTPUT_OPEN_SOURCE
Use pin as output in open emitter configuration.
@ GPIO_USED_BY_PERIPHERAL
The GPIO pin is used by a peripheral.
@ GPIO_OUTPUT_OPEN_DRAIN
Use pin as output in open collector configuration.
@ GPIO_OUTPUT_PUSH_PULL
Use pin as output in push-pull configuration.
@ GPIO_DISCONNECT
Disconnect pin from all peripherals.
@ GPIO_INPUT
Use pin as input.
@ GPIO_SLEW_SLOWEST
let the output voltage level rise/fall as slow as possible
@ GPIO_SLEW_FAST
let the output voltage level rise/fall fast
@ GPIO_SLEW_SLOW
let the output voltage level rise/fall slowly
@ GPIO_SLEW_FASTEST
let the output voltage level rise/fall as fast as possible
@ GPIO_DRIVE_STRONG
Use a strong drive strength.
@ GPIO_DRIVE_WEAK
Use a weak drive strength.
@ GPIO_DRIVE_STRONGEST
Use the strongest drive strength.
@ GPIO_DRIVE_WEAKEST
Use the weakest drive strength.
spi_mode_t
Support SPI modes.
@ SPI_MODE_0
CPOL=0, CPHA=0.
@ SPI_MODE_2
CPOL=1, CPHA=0.
@ SPI_MODE_1
CPOL=0, CPHA=1.
@ SPI_MODE_3
CPOL=1, CPHA=1.
Structure describing the memory layout of the registers of a GPIO port on ATmega MCUs.
volatile uint8_t port
Read/write the state of GPIO pins using the Port Data Register.
volatile uint8_t pin
Toggle bits in the port register.
volatile uint8_t ddr
Configure pins as output (1) or input (0) using the Data Direction Register.
PWM device configuration.
timer_div_t div
Timer divider mask.
mini_timer_t * dev
Timer used.