Linduino  1.3.0
Linear Technology Arduino-Compatible Demonstration Board
LT3965.cpp
Go to the documentation of this file.
1 /*!
2 LT3965 - Octal Matrix LED Bypass Switch
3 
4 @verbatim
5 
6 The LT3965 is an LED bypass switching device for dimming indiviadual LEDs in a
7 string using a common current source. It features eight individually controlled
8 floating source N-channel MOSFET switches rated for 17V/330 mΩ. The eight
9 switches can be connected in parallel and/or in series to bypass current around
10 one or more LEDs in a string. The LT3965 as a slave uses the I2C serial interface
11 to communicate with the master. Each of eight channels can be independently
12 programmed to bypass the LED string in constant on, constant off, dimming without
13 fade transition or dimming with fade transition mode.
14 
15 @endverbatim
16 
17 http://www.linear.com/product/LT3965
18 
19 http://www.linear.com/product/LT3965#demoboards
20 
21 
22 Copyright 2018(c) Analog Devices, Inc.
23 
24 All rights reserved.
25 
26 Redistribution and use in source and binary forms, with or without
27 modification, are permitted provided that the following conditions are met:
28  - Redistributions of source code must retain the above copyright
29  notice, this list of conditions and the following disclaimer.
30  - Redistributions in binary form must reproduce the above copyright
31  notice, this list of conditions and the following disclaimer in
32  the documentation and/or other materials provided with the
33  distribution.
34  - Neither the name of Analog Devices, Inc. nor the names of its
35  contributors may be used to endorse or promote products derived
36  from this software without specific prior written permission.
37  - The use of this software may or may not infringe the patent rights
38  of one or more patent holders. This license does not release you
39  from the requirement that you obtain separate licenses from these
40  patent holders to use this software.
41  - Use of the software either in source or binary form, must be run
42  on or directly connected to an Analog Devices Inc. component.
43 
44 THIS SOFTWARE IS PROVIDED BY ANALOG DEVICES "AS IS" AND ANY EXPRESS OR
45 IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, NON-INFRINGEMENT,
46 MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED.
47 IN NO EVENT SHALL ANALOG DEVICES BE LIABLE FOR ANY DIRECT, INDIRECT,
48 INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
49 LIMITED TO, INTELLECTUAL PROPERTY RIGHTS, PROCUREMENT OF SUBSTITUTE GOODS OR
50 SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER
51 CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY,
52 OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
53 OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
54 */
55 
56 //! @ingroup Switching_Regulators
57 //! @{
58 //! @defgroup LT3965 LT3965: Octal Matrix LED Bypass Switch
59 //! @}
60 
61 /*! @file
62  @ingroup LT3965
63  Library for LT3965 Octal Matrix LED Bypass Switch
64 */
65 
66 #include <stdio.h>
67 #include "Linduino.h"
68 #include "LT_I2C.h"
69 #include "LT3965.h"
70 
71 
72 // ACMODE Write Command to write a "value" byte to device at "address"
73 int8_t i2c_acwrite(uint8_t address, uint8_t value)
74 {
75  int8_t ret = 0 ;
76  address = address | AC_ADDR_0;
77  ret |= i2c_write_byte(address, value);
78  return ret;
79 }
80 
81 
82 // ACMODE Read Command to read 3 data bytes from device at "address"
83 int8_t i2c_acread(uint8_t address, uint8_t *values)
84 {
85  int8_t ret = 0 ;
86  address = address | AC_ADDR_0;
87  ret |= i2c_read_block_data(address, 3, values);
88  return ret;
89 }
90 
91 
92 // SCMODE Write Command Short Format to write a "value" byte to device at "address"
93 int8_t i2c_scwriteshort(uint8_t address, uint8_t channel, uint8_t data_SCMREG)
94 {
95  int8_t ret = 0 ;
96  uint8_t data = 0;
97 
98  address = address | SC_ADDR_0;
99  data = (channel << 4) | data_SCMREG; //Write value
100 
101  ret |= i2c_write_byte(address, data);
102  return ret;
103 }
104 
105 
106 // SCMODE Write Command Long Format to write 2 "value" bytes to device at "address"
107 int8_t i2c_scwritelong(uint8_t address, uint8_t channel, uint8_t data_SCMREG, uint8_t dimming_value)
108 {
109  int8_t ret = 0;
110  uint8_t command = 0x80;
111 
112  address = address | SC_ADDR_0;
113  command |= ((channel << 4) | data_SCMREG);
114 
115  ret |= i2c_write_byte_data(address, command, dimming_value);
116  return ret;
117 }
118 
119 
120 // SCMODE Write Short + SCMODE Read Command
121 int8_t i2c_scwriteshort_scread(uint8_t address, uint8_t channel, uint8_t data_SCMREG, uint8_t *values)
122 {
123  int8_t ret = 0;
124  uint8_t command = 0;
125 
126  address = address | SC_ADDR_0;
127  command |= ((channel << 4) | data_SCMREG);
128 
129  ret |= i2c_read_block_data(address, command, 2, values);
130  return ret;
131 }
132 
133 
134 // BCMODE Read Command
135 int8_t i2c_bcread(uint8_t *value)
136 {
137  int8_t ret = 0 ;
138  uint8_t address = BC_ADDR;
139  ret |= i2c_read_byte(address, value);
140  return ret;
141 }
int8_t i2c_scwriteshort_scread(uint8_t address, uint8_t channel, uint8_t data_SCMREG, uint8_t *values)
SCMODE Write Short + SCMODE Read Command.
Definition: LT3965.cpp:121
long ret
int8_t i2c_write_byte(uint8_t address, uint8_t value)
Write "value" byte to device at "address".
Definition: LT_I2C.cpp:109
int8_t i2c_read_block_data(uint8_t address, uint8_t command, uint8_t length, uint8_t *values)
Read a block of data, starting at register specified by "command" and ending at (command + length - 1...
Definition: LT_I2C.cpp:244
Header File for Linduino Libraries and Demo Code.
#define BC_ADDR
Definition: LT3965.h:85
static uint8_t channel
LTC2305 Channel selection.
Definition: DC1444A.ino:127
int8_t i2c_bcread(uint8_t *value)
BCMODE Read Command.
Definition: LT3965.cpp:135
static uint8_t address
Definition: DC2091A.ino:83
union LT_union_int32_4bytes data
Definition: DC2094A.ino:138
int8_t i2c_scwriteshort(uint8_t address, uint8_t channel, uint8_t data_SCMREG)
SCMODE Write Command Short Format to write a "value" byte to device at "address". ...
Definition: LT3965.cpp:93
int8_t i2c_write_byte_data(uint8_t address, uint8_t command, uint8_t value)
Write a byte of data to register specified by "command".
Definition: LT_I2C.cpp:155
LT3965 - Octal Matrix LED Bypass Switch.
int8_t i2c_acwrite(uint8_t address, uint8_t value)
ACMODE Write Command to write a "value" byte to device at "address".
Definition: LT3965.cpp:73
LT_I2C: Routines to communicate with ATmega328P&#39;s hardware I2C port.
int8_t i2c_scwritelong(uint8_t address, uint8_t channel, uint8_t data_SCMREG, uint8_t dimming_value)
SCMODE Write Command Long Format to write 2 "value" bytes to device at "address". ...
Definition: LT3965.cpp:107
#define AC_ADDR_0
Definition: LT3965.h:83
int8_t i2c_acread(uint8_t address, uint8_t *values)
ACMODE Read Command to read 3 data bytes from device at "address".
Definition: LT3965.cpp:83
#define SC_ADDR_0
Definition: LT3965.h:84
int8_t i2c_read_byte(uint8_t address, uint8_t *value)
Read a byte, store in "value".
Definition: LT_I2C.cpp:93
static uint8_t values[4]
Definition: DC2218A.ino:117