Loading...
Searching...
No Matches
mcp23x17_params.h
Go to the documentation of this file.
1/*
2 * SPDX-FileCopyrightText: 2021 Gunar Schorcht
3 * SPDX-License-Identifier: LGPL-2.1-only
4 */
5
6#pragma once
7
17
18#include "board.h"
19#include "mcp23x17.h"
20#include "saul_reg.h"
21
22#ifdef __cplusplus
23extern "C" {
24#endif
25
30
31#if IS_USED(MODULE_MCP23X17_SPI) || DOXYGEN
32
33#ifndef MCP23X17_PARAM_SPI_ADDR
39#define MCP23X17_PARAM_SPI_ADDR (0)
40#endif
41
42#ifndef MCP23X17_PARAM_SPI_DEV
44#define MCP23X17_PARAM_SPI_DEV (SPI_DEV(0))
45#endif
46
47#ifndef MCP23X17_PARAM_SPI_CLK
49#define MCP23X17_PARAM_SPI_CLK (SPI_CLK_10MHZ)
50#endif
51
52#ifndef MCP23X17_PARAM_SPI_CS
54#define MCP23X17_PARAM_SPI_CS (GPIO_PIN(0, 0))
55#endif
56
57#ifndef MCP23X17_PARAM_SPI_INT
59#define MCP23X17_PARAM_SPI_INT (GPIO_PIN(0, 1))
60#endif
61
62#endif /* MODULE_MCP23X17_SPI || DOXYGEN */
63
64#if IS_USED(MODULE_MCP23X17_I2C) || DOXYGEN
65
66#ifndef MCP23X17_PARAM_I2C_ADDR
68#define MCP23X17_PARAM_I2C_ADDR (0)
69#endif
70
71#ifndef MCP23X17_PARAM_I2C_DEV
73#define MCP23X17_PARAM_I2C_DEV (I2C_DEV(0))
74#endif
75
76#ifndef MCP23X17_PARAM_I2C_INT
78#define MCP23X17_PARAM_I2C_INT (GPIO_PIN(0, 2))
79#endif
80
81#endif /* MODULE_MCP23X17_I2C || DOXYGEN */
82
83#ifndef MCP23X17_PARAM_RESET_PIN
85#define MCP23X17_PARAM_RESET_PIN (GPIO_UNDEF)
86#endif
87
88#if IS_USED(MODULE_MCP23X17_SPI) || DOXYGEN
89#ifndef MCP23X17_SPI_PARAMS
91#define MCP23X17_SPI_PARAMS { \
92 .addr = MCP23X17_PARAM_SPI_ADDR, \
93 .int_pin = MCP23X17_PARAM_SPI_INT, \
94 .reset_pin = MCP23X17_PARAM_RESET_PIN, \
95 .if_params.type = MCP23X17_SPI, \
96 .if_params.spi.dev = MCP23X17_PARAM_SPI_DEV, \
97 .if_params.spi.cs = MCP23X17_PARAM_SPI_CS, \
98 .if_params.spi.clk = MCP23X17_PARAM_SPI_CLK, \
99 }
100#endif /* MCP23X17_SPI_PARAMS */
101#endif /* MODULE_MCP23X17_SPI || DOXYGEN */
102
103#if IS_USED(MODULE_MCP23X17_I2C) || DOXYGEN
104#ifndef MCP23X17_I2C_PARAMS
106#define MCP23X17_I2C_PARAMS { \
107 .addr = MCP23X17_PARAM_I2C_ADDR, \
108 .int_pin = MCP23X17_PARAM_I2C_INT, \
109 .reset_pin = MCP23X17_PARAM_RESET_PIN, \
110 .if_params.type = MCP23X17_I2C, \
111 .if_params.i2c.dev = MCP23X17_PARAM_I2C_DEV, \
112 }
113#endif /* MCP23X17_I2C_PARAMS */
114#endif /* MODULE_MCP23X17_I2C || DOXYGEN */
115
116#if IS_USED(MODULE_SAUL_GPIO) || DOXYGEN
117
118#ifndef MCP23X17_SAUL_GPIO_PARAMS
120#define MCP23X17_SAUL_GPIO_PARAMS { \
121 .dev = 0, \
122 .gpio = { \
123 .name = "MCP23x17_0 PA0 Input", \
124 .pin = MCP23X17_GPIO_PIN(0, 0), \
125 .mode = GPIO_IN, \
126 .flags = 0, \
127 } \
128 }, \
129 { \
130 .dev = 0, \
131 .gpio = { \
132 .name = "MCP23x17_0 PB5 Output", \
133 .pin = MCP23X17_GPIO_PIN(1, 5), \
134 .mode = GPIO_OUT, \
135 .flags = SAUL_GPIO_INIT_CLEAR, \
136 } \
137 },
138#endif /* MCP23X17_SAUL_GPIO_PARAMS */
139#endif /* MODULE_SAUL_GPIO || DOXYGEN */
141
146{
147#if IS_USED(MODULE_MCP23X17_SPI) || DOXYGEN
149#endif
150#if IS_USED(MODULE_MCP23X17_I2C) || DOXYGEN
152#endif
153};
154
155#if IS_USED(MODULE_SAUL_GPIO) || DOXYGEN
163#endif /* MODULE_SAUL_GPIO || DOXYGEN */
164
165#ifdef __cplusplus
166}
167#endif
168
Device driver interface for Microchip MCP23x17 I/O expanders.
static const mcp23x17_params_t mcp23x17_params[]
Allocation of MCP23x17 configuration.
#define MCP23X17_I2C_PARAMS
Default device parameters, if I2C interface is used.
static const mcp23x17_saul_gpio_params_t mcp23x17_saul_gpio_params[]
Additional meta information to keep in the SAUL registry.
#define MCP23X17_SPI_PARAMS
Default device parameters, if SPI interface is used.
#define MCP23X17_SAUL_GPIO_PARAMS
Example for mapping expander pins to SAUL.
SAUL registry interface definition.
Struct containing the peripheral configuration.
Definition mcp23x17.h:462
MCP23x17 configuration structure for mapping expander pins to SAUL.
Definition mcp23x17.h:537