Zephyr API Documentation  2.7.0-rc2
A Scalable Open Source RTOS
pinmux.h
Go to the documentation of this file.
1/*
2 * Copyright (c) 2015 Intel Corporation
3 *
4 * SPDX-License-Identifier: Apache-2.0
5 */
6
12#ifndef ZEPHYR_INCLUDE_DRIVERS_PINMUX_H_
13#define ZEPHYR_INCLUDE_DRIVERS_PINMUX_H_
14
22#include <zephyr/types.h>
23#include <device.h>
24
25#ifdef __cplusplus
26extern "C" {
27#endif
28
29#define PINMUX_FUNC_A 0
30#define PINMUX_FUNC_B 1
31#define PINMUX_FUNC_C 2
32#define PINMUX_FUNC_D 3
33#define PINMUX_FUNC_E 4
34#define PINMUX_FUNC_F 5
35#define PINMUX_FUNC_G 6
36#define PINMUX_FUNC_H 7
37#define PINMUX_FUNC_I 8
38#define PINMUX_FUNC_J 9
39#define PINMUX_FUNC_K 10
40#define PINMUX_FUNC_L 11
41#define PINMUX_FUNC_M 12
42#define PINMUX_FUNC_N 13
43#define PINMUX_FUNC_O 14
44#define PINMUX_FUNC_P 15
45#define PINMUX_FUNC_Q 16
46#define PINMUX_FUNC_R 17
47#define PINMUX_FUNC_S 18
48#define PINMUX_FUNC_T 19
49
50#define PINMUX_PULLUP_ENABLE (0x1)
51#define PINMUX_PULLUP_DISABLE (0x0)
52
53#define PINMUX_INPUT_ENABLED (0x1)
54#define PINMUX_OUTPUT_ENABLED (0x0)
55
61typedef int (*pmux_set)(const struct device *dev, uint32_t pin, uint32_t func);
67typedef int (*pmux_get)(const struct device *dev, uint32_t pin,
68 uint32_t *func);
74typedef int (*pmux_pullup)(const struct device *dev, uint32_t pin,
75 uint8_t func);
81typedef int (*pmux_input)(const struct device *dev, uint32_t pin,
82 uint8_t func);
83
84__subsystem struct pinmux_driver_api {
89};
90
91static inline int pinmux_pin_set(const struct device *dev, uint32_t pin,
92 uint32_t func)
93{
94 const struct pinmux_driver_api *api =
95 (const struct pinmux_driver_api *)dev->api;
96
97 return api->set(dev, pin, func);
98}
99
100static inline int pinmux_pin_get(const struct device *dev, uint32_t pin,
101 uint32_t *func)
102{
103 const struct pinmux_driver_api *api =
104 (const struct pinmux_driver_api *)dev->api;
105
106 return api->get(dev, pin, func);
107}
108
109static inline int pinmux_pin_pullup(const struct device *dev, uint32_t pin,
110 uint8_t func)
111{
112 const struct pinmux_driver_api *api =
113 (const struct pinmux_driver_api *)dev->api;
114
115 return api->pullup(dev, pin, func);
116}
117
118static inline int pinmux_pin_input_enable(const struct device *dev,
119 uint32_t pin,
120 uint8_t func)
121{
122 const struct pinmux_driver_api *api =
123 (const struct pinmux_driver_api *)dev->api;
124
125 return api->input(dev, pin, func);
126}
127
128#ifdef __cplusplus
129}
130#endif
131
137#endif /* ZEPHYR_INCLUDE_DRIVERS_PINMUX_H_ */
static int pinmux_pin_input_enable(const struct device *dev, uint32_t pin, uint8_t func)
Definition: pinmux.h:118
int(* pmux_set)(const struct device *dev, uint32_t pin, uint32_t func)
Callback API upon setting a PIN's function See pinmux_pin_set() for argument description.
Definition: pinmux.h:61
int(* pmux_get)(const struct device *dev, uint32_t pin, uint32_t *func)
Callback API upon getting a PIN's function See pinmux_pin_get() for argument description.
Definition: pinmux.h:67
int(* pmux_input)(const struct device *dev, uint32_t pin, uint8_t func)
Callback API upon setting a PIN's input function See pinmux_input() for argument description.
Definition: pinmux.h:81
static int pinmux_pin_get(const struct device *dev, uint32_t pin, uint32_t *func)
Definition: pinmux.h:100
static int pinmux_pin_set(const struct device *dev, uint32_t pin, uint32_t func)
Definition: pinmux.h:91
static int pinmux_pin_pullup(const struct device *dev, uint32_t pin, uint8_t func)
Definition: pinmux.h:109
int(* pmux_pullup)(const struct device *dev, uint32_t pin, uint8_t func)
Callback API upon setting a PIN's pullup See pinmix_pin_pullup() for argument description.
Definition: pinmux.h:74
__UINT32_TYPE__ uint32_t
Definition: stdint.h:60
__UINT8_TYPE__ uint8_t
Definition: stdint.h:58
Runtime device structure (in ROM) per driver instance.
Definition: device.h:367
const void * api
Definition: device.h:373
Definition: pinmux.h:84
pmux_set set
Definition: pinmux.h:85
pmux_input input
Definition: pinmux.h:88
pmux_get get
Definition: pinmux.h:86
pmux_pullup pullup
Definition: pinmux.h:87