Loading...
Searching...
No Matches
gpio_mux.h
Go to the documentation of this file.
1/*
2 * Copyright (C) 2020 iosabi
3 *
4 * This file is subject to the terms and conditions of the GNU Lesser General
5 * Public License v2.1. See the file LICENSE in the top level directory for more
6 * details.
7 */
8
9#pragma once
10
24
25#include <stdint.h>
26#include "periph_cpu.h"
27
28#ifdef __cplusplus
29extern "C" {
30#endif
31
35#define GPIO_T_ADDR_BASE(pin) (GPIOA_BASE + ((pin) & 0xf000u))
36
40#define GPIO_T_ADDR(pin) ((GPIO_Type *)(GPIO_T_ADDR_BASE(pin)))
41
47#define GPIO_T_PORT(pin) ((gpio_t)(pin) >> 12u)
48
52#define GPIO_T_PIN(pin) ((pin) & 0x00ffu)
53
54#if defined(GPIOB_BASE) && (GPIO_T_ADDR_BASE(GPIO_PIN(1, 1)) != GPIOB_BASE)
55#error "GPIO_T_ADDR(GPIO_PIN(1, x)) must be the GPIOB address"
56#endif
57
61#define GPIO_T_IS_HWCS(pin) (((pin) & 0xff00u) == 0x8000)
62
66#define GPIO_T_HWCS(pin) ((pin) & 0x0003u)
67
73void gpio_init_mux(gpio_t pin, uint32_t func);
74
75#ifdef __cplusplus
76}
77#endif
78
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.