Linduino  1.3.0
Linear Technology Arduino-Compatible Demonstration Board
nvm.cpp
Go to the documentation of this file.
1 /*!
2 
3 Copyright 2018(c) Analog Devices, Inc.
4 
5 All rights reserved.
6 
7 Redistribution and use in source and binary forms, with or without
8 modification, are permitted provided that the following conditions are met:
9  - Redistributions of source code must retain the above copyright
10  notice, this list of conditions and the following disclaimer.
11  - Redistributions in binary form must reproduce the above copyright
12  notice, this list of conditions and the following disclaimer in
13  the documentation and/or other materials provided with the
14  distribution.
15  - Neither the name of Analog Devices, Inc. nor the names of its
16  contributors may be used to endorse or promote products derived
17  from this software without specific prior written permission.
18  - The use of this software may or may not infringe the patent rights
19  of one or more patent holders. This license does not release you
20  from the requirement that you obtain separate licenses from these
21  patent holders to use this software.
22  - Use of the software either in source or binary form, must be run
23  on or directly connected to an Analog Devices Inc. component.
24 
25 THIS SOFTWARE IS PROVIDED BY ANALOG DEVICES "AS IS" AND ANY EXPRESS OR
26 IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, NON-INFRINGEMENT,
27 MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED.
28 IN NO EVENT SHALL ANALOG DEVICES BE LIABLE FOR ANY DIRECT, INDIRECT,
29 INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
30 LIMITED TO, INTELLECTUAL PROPERTY RIGHTS, PROCUREMENT OF SUBSTITUTE GOODS OR
31 SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER
32 CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY,
33 OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
34 OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
35 */
36 
37 //! @ingroup PMBus_SMBus
38 //! @{
39 //! @defgroup LTPSM_InFlightUpdate LTPSM_InFlightUpdate
40 //! @}
41 
42 /*! @file
43  @ingroup LTPSM_InFlightUpdate
44  Library File
45 */
46 
47 #include "nvm.h"
48 
49 #define DEBUG_FLASH 0
50 
51 const unsigned char *icpFile;
52 uint32_t flashLocation = 0;
53 
56 
57 uint8_t get_hex_data(void)
58 {
59  uint8_t c = '\0';
60 #if (DEBUG_FLASH)
61  Serial.print("Loc ");
62  Serial.println(flashLocation, HEX);
63 #endif
64  c = pgm_read_byte_near(icpFile + flashLocation++);
65 #if (DEBUG_FLASH)
66  Serial.print("Raw ");
67  Serial.println(c, HEX);
68 #endif
69  if ('\0' != c)
70  return c;
71  else
72  return 0;
73 }
74 
75 uint8_t get_filtered_hex_data(void)
76 {
78 }
79 
80 uint8_t get_record_data(void)
81 {
83 }
84 
86 {
88 }
89 
91 {
92  smbusNoPec__ = smbusNoPec;
93  smbusPec__ = smbusPec;
94 }
95 
96 bool NVM::programWithData(const unsigned char *data)
97 {
98  icpFile = data;
99  flashLocation = 0;
100 
101  reset_parse_hex();
103  {
104  reset_parse_hex();
105  return 0;
106  }
107  reset_parse_hex();
108  return 1;
109 }
110 
111 bool NVM::verifyWithData(const unsigned char *data)
112 {
113  icpFile = data;
114  flashLocation = 0;
115 
116  reset_parse_hex();
118  {
119  reset_parse_hex();
120  return 0;
121  }
122  reset_parse_hex();
123  return 1;
124 }
NVM(LT_SMBusNoPec *, LT_SMBusPec *)
Constructor.
Definition: nvm.cpp:90
const unsigned char * icpFile
Definition: nvm.cpp:51
pRecordHeaderLengthAndType parse_record(uint8_t(*get_data)(void))
LT_SMBusPec * smbusPec__
Definition: nvm.cpp:55
static LT_SMBusPec * smbusPec
uint8_t verifyRecordsOnDemand(pRecordHeaderLengthAndType(*getRecord)(void))
uint8_t get_hex_data(void)
Definition: nvm.cpp:57
bool programWithData(const unsigned char *)
Program with hex data.
Definition: nvm.cpp:96
LT_SMBusNoPec * smbusNoPec__
Definition: nvm.cpp:54
void reset_parse_hex()
Copyright 2018(c) Analog Devices, Inc.
uint8_t parse_hex(uint8_t(*get_data)(void))
union LT_union_int32_4bytes data
Definition: DC2094A.ino:138
pRecordHeaderLengthAndType get_record(void)
Definition: nvm.cpp:85
bool verifyWithData(const unsigned char *)
Verifies board NVM with hex data.
Definition: nvm.cpp:111
uint8_t processRecordsOnDemand(pRecordHeaderLengthAndType(*getRecord)(void))
uint8_t filter_terminations(uint8_t(*get_data)(void))
uint8_t get_record_data(void)
Definition: nvm.cpp:80
Basic Record Type Definitions.
static LT_SMBusNoPec * smbusNoPec
uint8_t get_filtered_hex_data(void)
Definition: nvm.cpp:75
uint32_t flashLocation
Definition: nvm.cpp:52