Loading...
Searching...
No Matches
mcp23x17_params.h
Go to the documentation of this file.
1/*
2 * Copyright (C) 2021 Gunar Schorcht
3 *
4 * This file is subject to the terms and conditions of the GNU Lesser
5 * General Public License v2.1. See the file LICENSE in the top level
6 * directory for more details.
7 */
8
9#pragma once
10
20
21#include "board.h"
22#include "mcp23x17.h"
23#include "saul_reg.h"
24
25#ifdef __cplusplus
26extern "C" {
27#endif
28
33
34#if IS_USED(MODULE_MCP23X17_SPI) || DOXYGEN
35
36#ifndef MCP23X17_PARAM_SPI_ADDR
42#define MCP23X17_PARAM_SPI_ADDR (0)
43#endif
44
45#ifndef MCP23X17_PARAM_SPI_DEV
47#define MCP23X17_PARAM_SPI_DEV (SPI_DEV(0))
48#endif
49
50#ifndef MCP23X17_PARAM_SPI_CLK
52#define MCP23X17_PARAM_SPI_CLK (SPI_CLK_10MHZ)
53#endif
54
55#ifndef MCP23X17_PARAM_SPI_CS
57#define MCP23X17_PARAM_SPI_CS (GPIO_PIN(0, 0))
58#endif
59
60#ifndef MCP23X17_PARAM_SPI_INT
62#define MCP23X17_PARAM_SPI_INT (GPIO_PIN(0, 1))
63#endif
64
65#endif /* MODULE_MCP23X17_SPI || DOXYGEN */
66
67#if IS_USED(MODULE_MCP23X17_I2C) || DOXYGEN
68
69#ifndef MCP23X17_PARAM_I2C_ADDR
71#define MCP23X17_PARAM_I2C_ADDR (0)
72#endif
73
74#ifndef MCP23X17_PARAM_I2C_DEV
76#define MCP23X17_PARAM_I2C_DEV (I2C_DEV(0))
77#endif
78
79#ifndef MCP23X17_PARAM_I2C_INT
81#define MCP23X17_PARAM_I2C_INT (GPIO_PIN(0, 2))
82#endif
83
84#endif /* MODULE_MCP23X17_I2C || DOXYGEN */
85
86#ifndef MCP23X17_PARAM_RESET_PIN
88#define MCP23X17_PARAM_RESET_PIN (GPIO_UNDEF)
89#endif
90
91#if IS_USED(MODULE_MCP23X17_SPI) || DOXYGEN
92#ifndef MCP23X17_SPI_PARAMS
94#define MCP23X17_SPI_PARAMS { \
95 .addr = MCP23X17_PARAM_SPI_ADDR, \
96 .int_pin = MCP23X17_PARAM_SPI_INT, \
97 .reset_pin = MCP23X17_PARAM_RESET_PIN, \
98 .if_params.type = MCP23X17_SPI, \
99 .if_params.spi.dev = MCP23X17_PARAM_SPI_DEV, \
100 .if_params.spi.cs = MCP23X17_PARAM_SPI_CS, \
101 .if_params.spi.clk = MCP23X17_PARAM_SPI_CLK, \
102 }
103#endif /* MCP23X17_SPI_PARAMS */
104#endif /* MODULE_MCP23X17_SPI || DOXYGEN */
105
106#if IS_USED(MODULE_MCP23X17_I2C) || DOXYGEN
107#ifndef MCP23X17_I2C_PARAMS
109#define MCP23X17_I2C_PARAMS { \
110 .addr = MCP23X17_PARAM_I2C_ADDR, \
111 .int_pin = MCP23X17_PARAM_I2C_INT, \
112 .reset_pin = MCP23X17_PARAM_RESET_PIN, \
113 .if_params.type = MCP23X17_I2C, \
114 .if_params.i2c.dev = MCP23X17_PARAM_I2C_DEV, \
115 }
116#endif /* MCP23X17_I2C_PARAMS */
117#endif /* MODULE_MCP23X17_I2C || DOXYGEN */
118
119#if IS_USED(MODULE_SAUL_GPIO) || DOXYGEN
120
121#ifndef MCP23X17_SAUL_GPIO_PARAMS
123#define MCP23X17_SAUL_GPIO_PARAMS { \
124 .dev = 0, \
125 .gpio = { \
126 .name = "MCP23x17_0 PA0 Input", \
127 .pin = MCP23X17_GPIO_PIN(0, 0), \
128 .mode = GPIO_IN, \
129 .flags = 0, \
130 } \
131 }, \
132 { \
133 .dev = 0, \
134 .gpio = { \
135 .name = "MCP23x17_0 PB5 Output", \
136 .pin = MCP23X17_GPIO_PIN(1, 5), \
137 .mode = GPIO_OUT, \
138 .flags = SAUL_GPIO_INIT_CLEAR, \
139 } \
140 },
141#endif /* MCP23X17_SAUL_GPIO_PARAMS */
142#endif /* MODULE_SAUL_GPIO || DOXYGEN */
144
149{
150#if IS_USED(MODULE_MCP23X17_SPI) || DOXYGEN
152#endif
153#if IS_USED(MODULE_MCP23X17_I2C) || DOXYGEN
155#endif
156};
157
158#if IS_USED(MODULE_SAUL_GPIO) || DOXYGEN
166#endif /* MODULE_SAUL_GPIO || DOXYGEN */
167
168#ifdef __cplusplus
169}
170#endif
171
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:464
MCP23x17 configuration structure for mapping expander pins to SAUL.
Definition mcp23x17.h:539