blob: 0134203eb5b79d7ef11faa4ffbf497c11a6301e9 [file] [log] [blame]
lh9ed821d2023-04-07 01:36:19 -07001/*******************************************************************************
2 * Copyright (C) 2010, ZTE Corporation.
3 *
4 * File Name: drvs_led.h
5 * File Mark:
6 * Description:
7 * Others:
8 * Version: V1.0
9 * Author: yuxiang
10 * Date: 2014-07-07
11 * History 1:
12 * Date:
13 * Version:
14 * Author:
15 * Modification:
16 * History 2:
17 ********************************************************************************/
18
19#ifndef _DRVS_LED_H
20#define _DRVS_LED_H
21
22
23/****************************************************************************
24* Include files
25****************************************************************************/
26
27/****************************************************************************
28* Macros
29****************************************************************************/
30/* */
31#define SN3216_REG_MODE_CONFIG 0x00 /* D7=SSD, D6:D5=MODE, D4=AE */
32#define SN3216_REG_OUT_STATUS1 0x01 /* out16:out9 led on/off, default all on */
33#define SN3216_REG_OUT_STATUS2 0x02 /* out8:out1 led on/off, default all off */
34
35#define SN3216_REG_CURRENT 0x03 /* D7=CM, D6:D4=CS, D3=AGCE, D2:D0=AGS */
36#define SN3216_REG_GPIO_CONFIG 0x04 /* */
37#define SN3216_REG_GPIO_DIRECT 0x05 /* */
38#define SN3216_REG_GPIO_VALUE 0x06 /* */
39
40#define SN3216_REG_OUT16_PWM 0x10 /* out16~out1 pwm level 10h~1fh */
41
42#define SN3216_REG_UPDATE_PWM 0xB0 /* update pwm regs */
43
44/*00h*/
45#define SN3216_REG_MODE_CONFIG_AE_LSH (4)
46#define SN3216_REG_MODE_CONFIG_MODE_LSH (5)
47#define SN3216_REG_MODE_CONFIG_SSD_LSH (7)
48
49/*03h*/
50#define SN3216_REG_CURRENT_CS_LSH (4)
51
52
53#define SN3216_BITFVAL(var, lsh) ( (var) << (lsh) )
54#define SN3216_BITFMASK(wid, lsh) ( ((1U << (wid)) - 1) << (lsh) )
55#define SN3216_BITFEXT(var, wid, lsh) ((var & SN3216_BITFMASK(wid, lsh)) >> (lsh))
56/****************************************************************************
57* Types
58****************************************************************************/
59#if 1
60typedef enum sn3216_channel {
61 SN3216_LED1 =0x0,
62 SN3216_LED2,
63 SN3216_LED3,
64 SN3216_LED4,
65 SN3216_LED5,
66 SN3216_LED6,
67 SN3216_LED7,
68 SN3216_LED8,
69
70 SN3216_LED9,
71 SN3216_LED10,
72 SN3216_LED11,
73 SN3216_LED12,
74 SN3216_LED13,
75 SN3216_LED14,
76 SN3216_LED15,
77 SN3216_LED16,
78
79 SN3216_LED_MAX
80}sn3216_channel;
81#else
82
83typedef enum sn3216_channel {
84
85 SN3216_LED16 = 0x0,
86 SN3216_LED15,
87 SN3216_LED14,
88 SN3216_LED13,
89 SN3216_LED12,
90 SN3216_LED11,
91 SN3216_LED10,
92 SN3216_LED9,
93
94 SN3216_LED8,
95 SN3216_LED7,
96 SN3216_LED6,
97 SN3216_LED5,
98 SN3216_LED4,
99 SN3216_LED3,
100 SN3216_LED2,
101 SN3216_LED1,
102
103 SN3216_LED_MAX
104}sn3216_channel;
105#endif
106typedef enum sn3216_current {
107 SN3216_CURRENT_20 =0x0,
108 SN3216_CURRENT_15,
109 SN3216_CURRENT_10,
110 SN3216_CURRENT_5,
111 SN3216_CURRENT_40,
112 SN3216_CURRENT_35,
113 SN3216_CURRENT_30,
114 SN3216_CURRENT_25,
115
116 SN3216_CURRENT_MAX
117}sn3216_current;
118
119typedef enum sn3216_status {
120 SN3216_LED_STATUS_OFF = 0x0,
121 SN3216_LED_STATUS_ON = 0x1,
122
123 SN3216_LED_STATUS_MAX,
124}sn3216_status;
125
126typedef enum sn3216_sleep {
127 SN3216_SLEEP_OFF = 0x0,
128 SN3216_SLEEP_ON = 0x1,
129 SN3216_SLEEP_MAX,
130}sn3216_sleep;
131
132/****************************************************************************
133* Constants
134****************************************************************************/
135
136/****************************************************************************
137* Global Variables
138****************************************************************************/
139
140/****************************************************************************
141* Function Prototypes
142****************************************************************************/
143SINT32 sn3216_I2cRead(UINT8 reg_addr, UINT8 *reg_val);
144SINT32 sn3216_I2cRead(UINT8 reg_addr, UINT8 *reg_val);
145SINT32 sn3216_GetRegister(UINT8 addr, UINT8* data);
146SINT32 sn3216_SetRegister(UINT8 addr, UINT8 data, UINT8 mask);
147SINT32 sn3216_SetStatus(sn3216_channel channel, sn3216_status status);
148SINT32 sn3216_SetBlink(sn3216_channel channel, UINT32 delay_on, UINT32 delay_off);
149SINT32 sn3216_SetCurrent(sn3216_current sn_current);
150SINT32 sn3216_SetPwm(sn3216_channel channel, UINT16 level);
151SINT32 sn3216_SetSleep(sn3216_sleep sleep);
152#endif/*_DRVS_LED_H*/
153