AM261x MCU+ SDK: ioexp_tca6424.h Source File

| AM261x MCU+ SDK 26.00.00 |

ioexp_tca6424.h
Go to the documentation of this file.
1 /*
2 * Copyright (C) 2021 Texas Instruments Incorporated
3 *
4 * Redistribution and use in source and binary forms, with or without
5 * modification, are permitted provided that the following conditions
6 * are met:
7 *
8 * Redistributions of source code must retain the above copyright
9 * notice, this list of conditions and the following disclaimer.
10 *
11 * Redistributions in binary form must reproduce the above copyright
12 * notice, this list of conditions and the following disclaimer in the
13 * documentation and/or other materials provided with the
14 * distribution.
15 *
16 * Neither the name of Texas Instruments Incorporated nor the names of
17 * its contributors may be used to endorse or promote products derived
18 * from this software without specific prior written permission.
19 *
20 * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
21 * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
22 * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
23 * A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
24 * OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
25 * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
26 * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
27 * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
28 * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
29 * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
30 * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
31 */
32
43 #ifndef IO_EXP_TCA6424_H_
44 #define IO_EXP_TCA6424_H_
45
46 /* ========================================================================== */
47 /* Include Files */
48 /* ========================================================================== */
49
50 #include <stdint.h>
51 #include <kernel/dpl/SystemP.h>
52 #include <kernel/dpl/SemaphoreP.h>
53 #include <drivers/i2c.h>
54
55 #ifdef __cplusplus
56 extern "C" {
57 #endif
58
59 /* ========================================================================== */
60 /* Macros & Typedefs */
61 /* ========================================================================== */
62
69 #define TCA6424_MODE_INPUT (0U)
70
71 #define TCA6424_MODE_OUTPUT (1U)
72
80 #define TCA6424_OUT_STATE_LOW (0U)
81
82 #define TCA6424_OUT_STATE_HIGH (1U)
83
85 /* ========================================================================== */
86 /* Structure Declarations */
87 /* ========================================================================== */
88
92 typedef struct TCA6424_Params_s
93 {
94 uint32_t i2cInstance;
97 uint32_t i2cAddress;
99 } TCA6424_Params;
100
104 typedef struct TCA6424_Attrs_s
105 {
106 uint32_t numIo;
108 } TCA6424_Attrs;
109
114 typedef struct TCA6424_Config_s
115 {
116 TCA6424_Params params;
118 TCA6424_Attrs attrs;
120 I2C_Handle i2cHandle;
122 void *lock;
124 SemaphoreP_Object lockObj;
126 } TCA6424_Config;
127
128 /* ========================================================================== */
129 /* Function Declarations */
130 /* ========================================================================== */
131
142 int32_t TCA6424_open(TCA6424_Config *config, const TCA6424_Params *params);
143
149 void TCA6424_close(TCA6424_Config *config);
150
160 int32_t TCA6424_config(TCA6424_Config *config, uint32_t ioIndex, uint32_t mode);
161
171 int32_t TCA6424_setOutput(TCA6424_Config *config, uint32_t ioIndex, uint32_t state);
172
180 void TCA6424_getAttrs(TCA6424_Config *config, TCA6424_Attrs *attrs);
181
190 void TCA6424_Params_init(TCA6424_Params *params);
191
192 /* ========================================================================== */
193 /* Static Function Definitions */
194 /* ========================================================================== */
195
196 /* None */
197
198 /* ========================================================================== */
199 /* Internal/Private Structure Declarations */
200 /* ========================================================================== */
201
202 /* None */
203
204 #ifdef __cplusplus
205 }
206 #endif
207
208 #endif /* #ifndef TCA6424_H_ */
209
TCA6424_Config::params
TCA6424_Params params
Definition: ioexp_tca6424.h:116
TCA6424_Params::i2cAddress
uint32_t i2cAddress
Definition: ioexp_tca6424.h:97
TCA6424_config
int32_t TCA6424_config(TCA6424_Config *config, uint32_t ioIndex, uint32_t mode)
API to set a IO pin of TCA6424 as input or output.
TCA6424_Config::lockObj
SemaphoreP_Object lockObj
Definition: ioexp_tca6424.h:124
SystemP.h
TCA6424_Config::attrs
TCA6424_Attrs attrs
Definition: ioexp_tca6424.h:118
TCA6424_Config::lock
void * lock
Definition: ioexp_tca6424.h:122
SemaphoreP.h
I2C_Handle
struct I2C_Config_s * I2C_Handle
A handle that is returned from a I2C_open() call.
Definition: i2c.h:165
TCA6424_Params
Parameters passed during TCA6424_open()
Definition: ioexp_tca6424.h:93
TCA6424_Attrs::numIo
uint32_t numIo
Definition: ioexp_tca6424.h:106
TCA6424_setOutput
int32_t TCA6424_setOutput(TCA6424_Config *config, uint32_t ioIndex, uint32_t state)
API to set a IO pin of TCA6424 to either HIGH or LOW.
TCA6424_Params::i2cInstance
uint32_t i2cInstance
Definition: ioexp_tca6424.h:94
TCA6424_Attrs
IO Expander device attributes.
Definition: ioexp_tca6424.h:105
TCA6424_Config::i2cHandle
I2C_Handle i2cHandle
Definition: ioexp_tca6424.h:120
TCA6424_Config
IO Expander driver configuration. This is the driver object used to store state variables.
Definition: ioexp_tca6424.h:115
TCA6424_close
void TCA6424_close(TCA6424_Config *config)
Close TCA6424 driver.
TCA6424_open
int32_t TCA6424_open(TCA6424_Config *config, const TCA6424_Params *params)
Open TCA6424 driver.
TCA6424_getAttrs
void TCA6424_getAttrs(TCA6424_Config *config, TCA6424_Attrs *attrs)
Returns TCA6424 attributes.
TCA6424_Params_init
void TCA6424_Params_init(TCA6424_Params *params)
Set default parameters in the TCA6424_Params structure.