Loading...
Searching...
No Matches
gpio_mux.h
Go to the documentation of this file.
1/*
2 * SPDX-FileCopyrightText: 2020 iosabi
3 * SPDX-License-Identifier: LGPL-2.1-only
4 */
5
6#pragma once
7
21
22#include <stdint.h>
23#include "periph_cpu.h"
24
25#ifdef __cplusplus
26extern "C" {
27#endif
28
32#define GPIO_T_ADDR_BASE(pin) (GPIOA_BASE + ((pin) & 0xf000u))
33
37#define GPIO_T_ADDR(pin) ((GPIO_Type *)(GPIO_T_ADDR_BASE(pin)))
38
44#define GPIO_T_PORT(pin) ((gpio_t)(pin) >> 12u)
45
49#define GPIO_T_PIN(pin) ((pin) & 0x00ffu)
50
51#if defined(GPIOB_BASE) && (GPIO_T_ADDR_BASE(GPIO_PIN(1, 1)) != GPIOB_BASE)
52#error "GPIO_T_ADDR(GPIO_PIN(1, x)) must be the GPIOB address"
53#endif
54
58#define GPIO_T_IS_HWCS(pin) (((pin) & 0xff00u) == 0x8000)
59
63#define GPIO_T_HWCS(pin) ((pin) & 0x0003u)
64
70void gpio_init_mux(gpio_t pin, uint32_t func);
71
72#ifdef __cplusplus
73}
74#endif
75
void gpio_init_mux(gpio_t pin, uint32_t func)
Configure the pin mux to the given function.
CPU specific definitions for internal peripheral handling.