Zephyr Project API 3.7.0
A Scalable Open Source RTOS
Loading...
Searching...
No Matches
xmc4xxx-pinctrl.h
Go to the documentation of this file.
1/*
2 * Copyright (c) 2022 Schlumberger
3 *
4 * SPDX-License-Identifier: Apache-2.0
5 */
6
7#ifndef ZEPHYR_INCLUDE_DT_BINDINGS_PINCTRL_XMC4XXX_PINCTRL_H_
8#define ZEPHYR_INCLUDE_DT_BINDINGS_PINCTRL_XMC4XXX_PINCTRL_H_
9
10/* Bit Masks */
11
12#define XMC4XXX_PORT_POS 0
13#define XMC4XXX_PORT_MASK 0xf
14
15#define XMC4XXX_PIN_POS 4
16#define XMC4XXX_PIN_MASK 0xf
17
18#define XMC4XXX_ALT_POS 8
19#define XMC4XXX_ALT_MASK 0xf
20
21#define XMC4XXX_PULL_DOWN_POS 12
22#define XMC4XXX_PULL_DOWN_MASK 0x1
23
24#define XMC4XXX_PULL_UP_POS 13
25#define XMC4XXX_PULL_UP_MASK 0x1
26
27#define XMC4XXX_PUSH_PULL_POS 14
28#define XMC4XXX_PUSH_PULL_MASK 0x1
29
30#define XMC4XXX_OPEN_DRAIN_POS 15
31#define XMC4XXX_OPEN_DRAIN_MASK 0x1
32
33#define XMC4XXX_OUT_HIGH_POS 16
34#define XMC4XXX_OUT_HIGH_MASK 0x1
35
36#define XMC4XXX_OUT_LOW_POS 17
37#define XMC4XXX_OUT_LOW_MASK 0x1
38
39#define XMC4XXX_INV_INPUT_POS 18
40#define XMC4XXX_INV_INPUT_MASK 0x1
41
42#define XMC4XXX_DRIVE_POS 19
43#define XMC4XXX_DRIVE_MASK 0x7
44
45#define XMC4XXX_HWCTRL_POS 22
46#define XMC4XXX_HWCTRL_MASK 0x3
47
48/* Setters and getters */
49
50#define XMC4XXX_PINMUX_SET(port, pin, alt_fun) \
51 ((port) << XMC4XXX_PORT_POS | (pin) << XMC4XXX_PIN_POS | (alt_fun) << XMC4XXX_ALT_POS)
52
53#define XMC4XXX_PINMUX_GET_PORT(mx) ((mx >> XMC4XXX_PORT_POS) & XMC4XXX_PORT_MASK)
54#define XMC4XXX_PINMUX_GET_PIN(mx) ((mx >> XMC4XXX_PIN_POS) & XMC4XXX_PIN_MASK)
55#define XMC4XXX_PINMUX_GET_ALT(mx) ((mx >> XMC4XXX_ALT_POS) & XMC4XXX_ALT_MASK)
56#define XMC4XXX_PINMUX_GET_PULL_DOWN(mx) ((mx >> XMC4XXX_PULL_DOWN_POS) & XMC4XXX_PULL_DOWN_MASK)
57#define XMC4XXX_PINMUX_GET_PULL_UP(mx) ((mx >> XMC4XXX_PULL_UP_POS) & XMC4XXX_PULL_UP_MASK)
58#define XMC4XXX_PINMUX_GET_PUSH_PULL(mx) ((mx >> XMC4XXX_PUSH_PULL_POS) & XMC4XXX_PUSH_PULL_MASK)
59#define XMC4XXX_PINMUX_GET_OPEN_DRAIN(mx) ((mx >> XMC4XXX_OPEN_DRAIN_POS) & XMC4XXX_OPEN_DRAIN_MASK)
60#define XMC4XXX_PINMUX_GET_OUT_HIGH(mx) ((mx >> XMC4XXX_OUT_HIGH_POS) & XMC4XXX_OUT_HIGH_MASK)
61#define XMC4XXX_PINMUX_GET_OUT_LOW(mx) ((mx >> XMC4XXX_OUT_LOW_POS) & XMC4XXX_OUT_LOW_MASK)
62#define XMC4XXX_PINMUX_GET_INV_INPUT(mx) ((mx >> XMC4XXX_INV_INPUT_POS) & XMC4XXX_INV_INPUT_MASK)
63#define XMC4XXX_PINMUX_GET_DRIVE(mx) ((mx >> XMC4XXX_DRIVE_POS) & XMC4XXX_DRIVE_MASK)
64#define XMC4XXX_PINMUX_GET_HWCTRL(mx) ((mx >> XMC4XXX_HWCTRL_POS) & XMC4XXX_HWCTRL_MASK)
65
66#endif /* ZEPHYR_INCLUDE_DT_BINDINGS_PINCTRL_XMC4XXX_PINCTRL_H_ */