AM65x MCU+ SDK  09.01.00
led.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 
45 #ifndef LED_H_
46 #define LED_H_
47 
48 /* ========================================================================== */
49 /* Include Files */
50 /* ========================================================================== */
51 
52 #include <stdint.h>
53 #include <kernel/dpl/SystemP.h>
54 #include <drivers/i2c.h>
55 #include <drivers/gpio.h>
56 
57 #ifdef __cplusplus
58 extern "C" {
59 #endif
60 
61 /* ========================================================================== */
62 /* Macros & Typedefs */
63 /* ========================================================================== */
64 
66 typedef void *LED_Handle;
68 typedef struct LED_Config_s LED_Config;
70 typedef struct LED_Params_s LED_Params;
71 
88 typedef int32_t (*LED_OpenFxn)(LED_Config *config, const LED_Params *params);
89 
100 typedef void (*LED_CloseFxn)(LED_Config *config);
101 
113 typedef int32_t (*LED_OnFxn)(LED_Config *config, uint32_t index);
114 
126 typedef int32_t (*LED_OffFxn)(LED_Config *config, uint32_t index);
127 
139 typedef int32_t (*LED_SetMaskFxn)(LED_Config *config, uint32_t mask);
142 /* ========================================================================== */
143 /* Structure Declarations */
144 /* ========================================================================== */
145 
150 {
151  uint32_t gpioBaseAddr;
154  uint32_t gpioPinNum;
156  uint32_t i2cInstance;
159  uint32_t i2cAddress;
161  uint32_t ioIndex;
164 };
165 
169 typedef struct LED_Fxns_s
170 {
181 } LED_Fxns;
182 
187 typedef struct
188 {
189  uint32_t numLedPerGroup;
191 } LED_Attrs;
192 
198 {
203  void *object;
205 };
206 
207 /* ========================================================================== */
208 /* Function Declarations */
209 /* ========================================================================== */
210 
219 void LED_Params_init(LED_Params *params);
220 
239 LED_Handle LED_open(uint32_t instanceId, const LED_Params *params);
240 
246 void LED_close(LED_Handle handle);
247 
257 int32_t LED_on(LED_Handle handle, uint32_t index);
258 
268 int32_t LED_off(LED_Handle handle, uint32_t index);
269 
283 int32_t LED_setMask(LED_Handle handle, uint32_t mask);
284 
292 const LED_Attrs *LED_getAttrs(uint32_t instanceId);
293 
294 /* ========================================================================== */
295 /* Static Function Definitions */
296 /* ========================================================================== */
297 
298 /* None */
299 
300 /* ========================================================================== */
301 /* Internal/Private Structure Declarations */
302 /* ========================================================================== */
303 
307 typedef struct
308 {
311  uint32_t gpioBaseAddr;
314  uint32_t gpioPinNum;
316  uint32_t i2cInstance;
319  uint32_t i2cAddress;
321  uint32_t ioIndex;
324 } LED_Object;
325 
326 #ifdef __cplusplus
327 }
328 #endif
329 
330 #endif /* #ifndef LED_H_ */
331 
LED_Params_s::i2cAddress
uint32_t i2cAddress
Definition: led.h:159
LED_Params_s
Parameters passed during LED_open()
Definition: led.h:150
LED_Params_init
void LED_Params_init(LED_Params *params)
Set default parameters in the LED_Params_s structure.
LED_Object::i2cAddress
uint32_t i2cAddress
Definition: led.h:319
LED_on
int32_t LED_on(LED_Handle handle, uint32_t index)
API to power on the LED.
LED_Fxns::onFxn
LED_OnFxn onFxn
Definition: led.h:175
index
uint16_t index
Definition: tisci_rm_proxy.h:3
SystemP.h
LED_SetMaskFxn
int32_t(* LED_SetMaskFxn)(LED_Config *config, uint32_t mask)
Driver implementation to set group mask using a specific LED driver.
Definition: led.h:139
LED_Config_s::fxns
LED_Fxns * fxns
Definition: led.h:201
LED_OnFxn
int32_t(* LED_OnFxn)(LED_Config *config, uint32_t index)
Driver implementation to power on an LED using a specific LED driver.
Definition: led.h:113
LED_setMask
int32_t LED_setMask(LED_Handle handle, uint32_t mask)
API to set the group mask incase of I2C controlled LED having more than one LED connected to the cont...
LED_Params_s::i2cInstance
uint32_t i2cInstance
Definition: led.h:156
LED_Config_s::object
void * object
Definition: led.h:203
LED_Attrs
LED device attributes, these are filled by SysCfg based on the device that is selected.
Definition: led.h:188
LED_off
int32_t LED_off(LED_Handle handle, uint32_t index)
API to power off the LED.
LED_Fxns
Driver implementation callbacks.
Definition: led.h:170
LED_Object::gpioBaseAddr
uint32_t gpioBaseAddr
Definition: led.h:311
LED_close
void LED_close(LED_Handle handle)
Open LED driver.
LED_Fxns::setMaskFxn
LED_SetMaskFxn setMaskFxn
Definition: led.h:179
LED_Params_s::gpioBaseAddr
uint32_t gpioBaseAddr
Definition: led.h:151
LED_Config_s
LED driver configuration, these are filled by SysCfg based on the device that is selected.
Definition: led.h:198
LED_Attrs::numLedPerGroup
uint32_t numLedPerGroup
Definition: led.h:189
LED_Object::i2cInstance
uint32_t i2cInstance
Definition: led.h:316
I2C_Handle
struct I2C_Config_s * I2C_Handle
A handle that is returned from a I2C_open() call.
Definition: i2c/v0/i2c.h:175
LED_Object::i2cHandle
I2C_Handle i2cHandle
Definition: led.h:309
LED_Params_s::gpioPinNum
uint32_t gpioPinNum
Definition: led.h:154
LED_OpenFxn
int32_t(* LED_OpenFxn)(LED_Config *config, const LED_Params *params)
Driver implementation to open a specific LED driver.
Definition: led.h:88
LED_getAttrs
const LED_Attrs * LED_getAttrs(uint32_t instanceId)
Return LED attributes.
LED_Object
LED driver object - not to be used by application.
Definition: led.h:308
LED_Fxns::openFxn
LED_OpenFxn openFxn
Definition: led.h:171
gpio.h
LED_CloseFxn
void(* LED_CloseFxn)(LED_Config *config)
Driver implementation to close a specific LED driver.
Definition: led.h:100
LED_Fxns::closeFxn
LED_CloseFxn closeFxn
Definition: led.h:173
LED_Object::gpioPinNum
uint32_t gpioPinNum
Definition: led.h:314
LED_OffFxn
int32_t(* LED_OffFxn)(LED_Config *config, uint32_t index)
Driver implementation to power off an LED using a specific LED driver.
Definition: led.h:126
LED_Handle
void * LED_Handle
Handle to the LED driver returned by LED_open()
Definition: led.h:66
LED_Config_s::attrs
LED_Attrs * attrs
Definition: led.h:199
LED_open
LED_Handle LED_open(uint32_t instanceId, const LED_Params *params)
Open LED driver.
LED_Fxns::offFxn
LED_OffFxn offFxn
Definition: led.h:177
LED_Object::ioIndex
uint32_t ioIndex
Definition: led.h:321
LED_Params_s::ioIndex
uint32_t ioIndex
Definition: led.h:161
i2c.h