| Linduino 1.3.0 Linear Technology Arduino-Compatible Demonstration Board

LT_SMBusBase.h
Go to the documentation of this file.
1 /*!
2 LTC SMBus Support: Implementation for a shared SMBus layer
3
4 @verbatim
5
6 This API is shared with Linduino and RTOS code. End users should code to this
7 API to enable use of the PMBus code without modifications.
8
9 @endverbatim
10
11
12 Copyright 2018(c) Analog Devices, Inc.
13
14 All rights reserved.
15
16 Redistribution and use in source and binary forms, with or without
17 modification, are permitted provided that the following conditions are met:
18 - Redistributions of source code must retain the above copyright
19 notice, this list of conditions and the following disclaimer.
20 - Redistributions in binary form must reproduce the above copyright
21 notice, this list of conditions and the following disclaimer in
22 the documentation and/or other materials provided with the
23 distribution.
24 - Neither the name of Analog Devices, Inc. nor the names of its
25 contributors may be used to endorse or promote products derived
26 from this software without specific prior written permission.
27 - The use of this software may or may not infringe the patent rights
28 of one or more patent holders. This license does not release you
29 from the requirement that you obtain separate licenses from these
30 patent holders to use this software.
31 - Use of the software either in source or binary form, must be run
32 on or directly connected to an Analog Devices Inc. component.
33
34 THIS SOFTWARE IS PROVIDED BY ANALOG DEVICES "AS IS" AND ANY EXPRESS OR
35 IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, NON-INFRINGEMENT,
36 MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED.
37 IN NO EVENT SHALL ANALOG DEVICES BE LIABLE FOR ANY DIRECT, INDIRECT,
38 INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
39 LIMITED TO, INTELLECTUAL PROPERTY RIGHTS, PROCUREMENT OF SUBSTITUTE GOODS OR
40 SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER
41 CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY,
42 OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
43 OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
44 */
45
46 /*! @file
47 @ingroup LT_SMBusBase
48 Library Header File for LT_SMBusBase
49 */
50
51 #ifndef LT_SMBusBase_H_
52 #define LT_SMBusBase_H_
53
54 #include <Arduino.h>
55 #include "Linduino.h"
56 #include "UserInterface.h"
57 #include "LT_I2CBus.h"
58 #include "LT_SMBus.h"
59
60 class LT_SMBusBase : public LT_SMBus
61 {
62 protected:
63 static bool open_; //!< Used to ensure initialisation of i2c once
64 static uint8_t found_address_[];
65 LT_I2CBus *i2cbus_;
66
67 LT_SMBusBase();
68 LT_SMBusBase(uint32_t speed);
69 virtual ~LT_SMBusBase();
70
71 public:
72
73 LT_I2CBus *i2cbus (void)
74 {
75 return i2cbus_;
76 }
77
78 void i2cbus (LT_I2CBus *i2cbus)
79 {
80 i2cbus_ = i2cbus;
81 }
82
83 //! SMBus write byte command
84 //! @return void
85 void writeByte(uint8_t address, //!< Slave address
86 uint8_t command, //!< Command byte
87 uint8_t data //!< Data to send
88 );
89
90 //! SMBus write byte command for a list of addresses
91 //! @return void
92 void writeBytes(uint8_t *addresses, //!< Slave Addresses
93 uint8_t *commands, //!< Command bytes
94 uint8_t *data, //!< Data to send
95 uint8_t no_addresses
96 );
97
98 //! SMBus read byte command
99 //! @return byte
100 uint8_t readByte(uint8_t address, //!< Slave Address
101 uint8_t command //!< Command byte
102 );
103
104 //! SMBus write word command
105 //! @return void
106 void writeWord(uint8_t address, //!< Slave Address
107 uint8_t command, //!< Command byte
108 uint16_t data //!< Data to send
109 );
110
111 //! SMBus read word command
112 //! @return word
113 uint16_t readWord(uint8_t address, //!< Slave Address
114 uint8_t command //!< Command byte
115 );
116
117 //! SMBus write block command
118 //! @return void
119 void writeBlock(uint8_t address, //!< Slave Address
120 uint8_t command, //!< Command byte
121 uint8_t *block, //!< Data to send
122 uint16_t block_size
123 );
124
125 //! SMBus write then read block command
126 //! @return actual size
127 uint8_t writeReadBlock(uint8_t address, //!< Slave Address
128 uint8_t command, //!< Command byte
129 uint8_t *block_out, //!< Data to send
130 uint16_t block_out_size, //!< Size of data to send
131 uint8_t *block_in, //!< Memory to receive data
132 uint16_t block_in_size //!< Size of receive data memory
133 );
134
135 //! SMBus read block command
136 //! @return actual size
137 uint8_t readBlock(uint8_t address, //!< Slave Address
138 uint8_t command, //!< Command byte
139 uint8_t *block, //!< Memory to receive data
140 uint16_t block_size //!< Size of receive data memory
141 );
142
143 //! SMBus send byte command
144 //! @return void
145 void sendByte(uint8_t address, //!< Slave Address
146 uint8_t command //!< Command byte
147 );
148
149 //! Perform ARA
150 //! @return address
151 uint8_t readAlert(void);
152
153 //! Read with the address and command in loop until ack, then issue stop
154 //! @return void
155 uint8_t waitForAck(uint8_t address, //!< Slave Address
156 uint8_t command //!< Command byte
157 );
158
159 //! SMBus bus probe
160 //! @return array of addresses
161 uint8_t *probe(uint8_t command //!< Command byte
162 );
163
164 //! SMBus bus probe
165 //! @return array of unique addresses (no global addresses)
166 uint8_t *probeUnique(uint8_t command //!< Command byte
167 );
168
169 };
170
171 #endif /* LT_SMBusBase_H_ */
LT_SMBusBase::sendByte
void sendByte(uint8_t address, uint8_t command)
SMBus send byte command.
Definition: LT_SMBusBase.cpp:508
LT_SMBus.h
LTC SMBus Support: API for a shared SMBus layer.
LT_SMBusBase::found_address_
static uint8_t found_address_[]
Definition: LT_SMBusBase.h:64
LT_SMBusBase::writeWord
void writeWord(uint8_t address, uint8_t command, uint16_t data)
SMBus write word command.
Definition: LT_SMBusBase.cpp:265
LT_SMBusBase::i2cbus
LT_I2CBus * i2cbus(void)
Definition: LT_SMBusBase.h:73
LT_SMBusBase::probe
uint8_t * probe(uint8_t command)
SMBus bus probe.
Definition: LT_SMBusBase.cpp:119
LT_SMBusBase::~LT_SMBusBase
virtual ~LT_SMBusBase()
Definition: LT_SMBusBase.cpp:90
Linduino.h
Header File for Linduino Libraries and Demo Code.
LT_SMBusBase::i2cbus_
LT_I2CBus * i2cbus_
Definition: LT_SMBusBase.h:65
LT_SMBusBase::writeByte
void writeByte(uint8_t address, uint8_t command, uint8_t data)
SMBus write byte command.
Definition: LT_SMBusBase.cpp:177
LT_SMBusBase::probeUnique
uint8_t * probeUnique(uint8_t command)
SMBus bus probe.
Definition: LT_SMBusBase.cpp:145
LT_SMBusBase::readAlert
uint8_t readAlert(void)
Perform ARA.
Definition: LT_SMBusBase.cpp:95
address
static uint8_t address
Definition: DC2091A.ino:83
data
union LT_union_int32_4bytes data
Definition: DC2094A.ino:138
LT_SMBus
Definition: LT_SMBus.h:61
LT_SMBusBase::open_
static bool open_
Used to ensure initialisation of i2c once.
Definition: LT_SMBusBase.h:63
LT_SMBusBase::writeBytes
void writeBytes(uint8_t *addresses, uint8_t *commands, uint8_t *data, uint8_t no_addresses)
SMBus write byte command for a list of addresses.
Definition: LT_SMBusBase.cpp:199
LT_I2CBus.h
LT_I2CBus: Routines to communicate to I2C by Wire Library.
LT_SMBusBase::readByte
uint8_t readByte(uint8_t address, uint8_t command)
SMBus read byte command.
Definition: LT_SMBusBase.cpp:234
LT_I2CBus
Definition: LT_I2CBus.h:50
LT_SMBusBase
Definition: LT_SMBusBase.h:60
LT_SMBusBase::readBlock
uint8_t readBlock(uint8_t address, uint8_t command, uint8_t *block, uint16_t block_size)
SMBus read block command.
Definition: LT_SMBusBase.cpp:459
LT_SMBusBase::i2cbus
void i2cbus(LT_I2CBus *i2cbus)
Definition: LT_SMBusBase.h:78
UserInterface.h
LT_SMBusBase::writeBlock
void writeBlock(uint8_t address, uint8_t command, uint8_t *block, uint16_t block_size)
SMBus write block command.
Definition: LT_SMBusBase.cpp:345
LT_SMBusBase::LT_SMBusBase
LT_SMBusBase()
Definition: LT_SMBusBase.cpp:64
LT_SMBusBase::readWord
uint16_t readWord(uint8_t address, uint8_t command)
SMBus read word command.
Definition: LT_SMBusBase.cpp:301
LT_SMBusBase::waitForAck
uint8_t waitForAck(uint8_t address, uint8_t command)
Read with the address and command in loop until ack, then issue stop.
Definition: LT_SMBusBase.cpp:105
LT_SMBusBase::writeReadBlock
uint8_t writeReadBlock(uint8_t address, uint8_t command, uint8_t *block_out, uint16_t block_out_size, uint8_t *block_in, uint16_t block_in_size)
SMBus write then read block command.
Definition: LT_SMBusBase.cpp:381