Linduino  1.3.0
Linear Technology Arduino-Compatible Demonstration Board
LT_CommandPlusFaultLog.h
Go to the documentation of this file.
1 /*!
2 LTC PMBus Support: Implementation for a LTC Controller Fault Log
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_FaultLog
48  Library Header File for LT_CommandPlusFaultLog
49 */
50 
51 #ifndef LT_CommandPlusFaultLog_H_
52 #define LT_CommandPlusFaultLog_H_
53 
54 #include "LT_FaultLog.h"
55 
56 
58 {
59  public:
60 
62  {
63 
64  }
65 
66  void getNvmBlock(uint8_t address, uint16_t offset, uint16_t numWords, uint8_t command, uint8_t *data)
67  {
68  // Get device ready to give data using command plus
69  pmbus_->smbus()->writeWord(address, command, 0x00EE);
70  while ((pmbus_->smbus()->readByte(address, 0xEF) & 0x60) != 0x60); // Wait until not busy
71 
72  // Consume the size word.
73  uint16_t w = pmbus_->smbus()->readWord(address, command + 1);
74  while ((pmbus_->smbus()->readByte(address, 0xEF) & 0x60) != 0x60); // Wait until not busy
75 
76  // Consume words we need to ignore
77  for (uint16_t i = 0; i < offset; i++)
78  {
79  while ((pmbus_->smbus()->readByte(address, 0xEF) & 0x60) != 0x60); // Wait until not busy
80  pmbus_->smbus()->readWord(address, command + 1);
81  }
82  // Consume words of the fault log
83  int pos = 0;
84  for (uint16_t i = 0; i < numWords; i++)
85  {
86  while ((pmbus_->smbus()->readByte(address, 0xEF) & 0x60) != 0x60); // Wait until not busy
87  w = pmbus_->smbus()->readWord(address, command + 1);
88  // Endianess matters here
89  data[pos] = 0xFF & w;
90  pos++;
91  data[pos] = 0xFF & (w >> 8);
92  pos++;
93  }
94  }
95 };
96 
97 #endif /* LT_CommandPlusFaultLog_H_ */
void getNvmBlock(uint8_t address, uint16_t offset, uint16_t numWords, uint8_t command, uint8_t *data)
static LT_PMBus * pmbus
Definition: DC2875A.ino:82
virtual void writeWord(uint8_t address, uint8_t command, uint16_t data)=0
SMBus write word command.
LT_PMBus * pmbus_
Definition: LT_FaultLog.h:129
static uint8_t address
Definition: DC2091A.ino:83
union LT_union_int32_4bytes data
Definition: DC2094A.ino:138
static int16_t pos
LTC PMBus Support: Implementation for a LTC Fault Log.
virtual uint8_t readByte(uint8_t address, uint8_t command)=0
SMBus read byte command.
LT_SMBus * smbus()
Definition: LT_PMBus.h:401
static int i
Definition: DC2430A.ino:184
virtual uint16_t readWord(uint8_t address, uint8_t command)=0
SMBus read word command.
LT_CommandPlusFaultLog(LT_PMBus *pmbus)
PMBus communication.
Definition: LT_PMBus.h:370