| Linduino 1.3.0 Linear Technology Arduino-Compatible Demonstration Board

main_record_processor.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 /*! @file
37 @ingroup LTPSM_InFlightUpdate
38 Library File
39 */
40
41 #include "main_record_processor.h"
42 #include "hex_file_parser.h"
43
44 #define DEBUG_SILENT 0
45 #define DEBUG_PROCESSING 0
46 #define DEBUG_PRINT 0
47
48 /** PRIVATE PROTOTYPES RELATING TO RECORD TYPE PARSING ************/
49 uint8_t recordProcessor___0x01___processWriteByteOptionalPEC(t_RECORD_PMBUS_WRITE_BYTE *);
50 uint8_t recordProcessor___0x02___processWriteWordOptionalPEC(t_RECORD_PMBUS_WRITE_WORD *);
51 uint8_t recordProcessor___0x04___processReadByteExpectOptionalPEC(t_RECORD_PMBUS_READ_BYTE_EXPECT *);
52 uint8_t recordProcessor___0x05___processReadWordExpectOptionalPEC(t_RECORD_PMBUS_READ_WORD_EXPECT *);
53 uint8_t recordProcessor___0x09___bufferNVMData(t_RECORD_NVM_DATA *);
54 uint8_t recordProcessor___0x0A___processReadByteLoopMaskOptionalPEC(t_RECORD_PMBUS_READ_BYTE_LOOP_MASK *);
55 uint8_t recordProcessor___0x0B___processReadWordLoopMaskOptionalPEC(t_RECORD_PMBUS_READ_WORD_LOOP_MASK *);
56 uint8_t recordProcessor___0x0C___processPollReadByteUntilAckNoPEC(t_RECORD_PMBUS_POLL_READ_BYTE_UNTIL_ACK *);
57 uint8_t recordProcessor___0x0D___processDelayMs(t_RECORD_DELAY_MS *);
58 uint8_t recordProcessor___0x0E___processSendByteOptionalPEC(t_RECORD_PMBUS_SEND_BYTE *);
59 uint8_t recordProcessor___0x0F___processWriteByteNoPEC(t_RECORD_PMBUS_WRITE_BYTE_NOPEC *);
60 uint8_t recordProcessor___0x10___processWriteWordNoPEC(t_RECORD_PMBUS_WRITE_WORD_NOPEC *);
61 uint8_t recordProcessor___0x12___processReadByteExpectNoPEC(t_RECORD_PMBUS_READ_BYTE_EXPECT_NOPEC *);
62 uint8_t recordProcessor___0x13___processReadWordExpectNoPEC(t_RECORD_PMBUS_READ_WORD_EXPECT_NOPEC *);
63 uint8_t recordProcessor___0x15___processReadByteLoopMaskNoPEC(t_RECORD_PMBUS_READ_BYTE_LOOP_MASK_NOPEC *);
64 uint8_t recordProcessor___0x16___processReadWordLoopMaskNoPEC(t_RECORD_PMBUS_READ_WORD_LOOP_MASK_NOPEC *);
65 uint8_t recordProcessor___0x17___processSendByteNoPEC(t_RECORD_PMBUS_SEND_BYTE_NOPEC *);
66 uint8_t recordProcessor___0x18___processEvent(t_RECORD_EVENT *);
67 uint8_t recordProcessor___0x19___processReadByteExpectMaskNoPEC(t_RECORD_PMBUS_READ_BYTE_EXPECT_MASK_NOPEC *);
68 uint8_t recordProcessor___0x1A___processReadWordExpectMaskNoPEC(t_RECORD_PMBUS_READ_WORD_EXPECT_MASK_NOPEC *);
69 uint8_t recordProcessor___0x1B___processVariableMetaData(t_RECORD_VARIABLE_META_DATA *);
70 uint8_t recordProcessor___0x1C___modifyWordNoPEC(t_RECORD_PMBUS_MODIFY_WORD_NO_PEC *);
71 uint8_t recordProcessor___0x1D___modifyByteNoPEC(t_RECORD_PMBUS_MODIFY_BYTE_NO_PEC *);
72 uint8_t recordProcessor___0x1E___writeNvmData(t_RECORD_NVM_DATA *);
73 uint8_t recordProcessor___0x1F___read_then_verifyNvmData(t_RECORD_NVM_DATA *);
74 uint8_t recordProcessor___0x20___modifyByteOptionalPEC(t_RECORD_PMBUS_MODIFY_BYTE *);
75 uint8_t recordProcessor___0x21___modifyWordOptionalPEC(t_RECORD_PMBUS_MODIFY_WORD *);
76
77 /** VARIABLES ******************************************************/
78 static bool verification_in_progress = false;
79 static bool ignore_records = false;
80
81 /********************************************************************
82 * Function: uint8_t processRecordsOnDemand(_InCircuitProgrammingRecordTypeListItem_p node, uint16_t length);
83 *
84 * PreCondition: None
85 * Input: Function to get records one by one
86 * Output: Returns SUCCESS (1) or FAILURE (0) depending on the status of parsing ALL the record types
87 * Overview: Processes all the records until the function to get records returns null
88 * Records are freed as processed.
89 * Note: None
90 *******************************************************************/
91 uint8_t processRecordsOnDemand(pRecordHeaderLengthAndType (*getRecord)(void))
92 {
93 pRecordHeaderLengthAndType record_to_process;
94
95 uint16_t recordType_of_record_to_process;
96 uint8_t successful_parse_of_record_type = SUCCESS;
97
98 while ((record_to_process = getRecord()) != NULL && successful_parse_of_record_type == SUCCESS)
99 {
100 recordType_of_record_to_process = record_to_process->RecordType;
101
102 switch (recordType_of_record_to_process)
103 {
104 case RECORD_TYPE_PMBUS_WRITE_BYTE: // 0x01
105 successful_parse_of_record_type = recordProcessor___0x01___processWriteByteOptionalPEC( (t_RECORD_PMBUS_WRITE_BYTE *) record_to_process);
106 break;
107 case RECORD_TYPE_PMBUS_WRITE_WORD: // 0x02
108 successful_parse_of_record_type = recordProcessor___0x02___processWriteWordOptionalPEC( (t_RECORD_PMBUS_WRITE_WORD *) record_to_process);
109 break;
110 case RECORD_TYPE_PMBUS_WRITE_BLOCK: // 0x03
111 successful_parse_of_record_type = FAILURE; // Unsupported Record Type
112 break;
113 case RECORD_TYPE_PMBUS_READ_BYTE_EXPECT: // 0x04
114 successful_parse_of_record_type = recordProcessor___0x04___processReadByteExpectOptionalPEC( (t_RECORD_PMBUS_READ_BYTE_EXPECT *) record_to_process);
115 break;
116 case RECORD_TYPE_PMBUS_READ_WORD_EXPECT: // 0x05
117 successful_parse_of_record_type = recordProcessor___0x05___processReadWordExpectOptionalPEC( (t_RECORD_PMBUS_READ_WORD_EXPECT *) record_to_process);
118 break;
119 case RECORD_TYPE_PMBUS_READ_BLOCK_EXPECT: // 0x06
120 successful_parse_of_record_type = FAILURE; // Unsupported Record Type
121 break;
122 case RECORD_TYPE_DEVICE_ADDRESS: // 0x07 -- OBSOLETED
123 successful_parse_of_record_type = SUCCESS; // Do nothing for this record type, but do not fail
124 break;
125 case RECORD_TYPE_PACKING_CODE: // 0x08 -- OBSOLETED
126 successful_parse_of_record_type = SUCCESS; // Do nothing for this record type, but do not fail
127 break;
128 case RECORD_TYPE_NVM_DATA: // 0x09 -- FUNCTIONALITY CHANGED 25/01/2011
129 successful_parse_of_record_type = recordProcessor___0x09___bufferNVMData( (t_RECORD_NVM_DATA *) record_to_process);
130 break;
131 case RECORD_TYPE_PMBUS_READ_BYTE_LOOP_MASK: // 0x0A
132 successful_parse_of_record_type = recordProcessor___0x0A___processReadByteLoopMaskOptionalPEC( (t_RECORD_PMBUS_READ_BYTE_LOOP_MASK *) record_to_process);
133 break;
134 case RECORD_TYPE_PMBUS_READ_WORD_LOOP_MASK: //0x0B
135 successful_parse_of_record_type = recordProcessor___0x0B___processReadWordLoopMaskOptionalPEC( (t_RECORD_PMBUS_READ_WORD_LOOP_MASK *) record_to_process);
136 break;
137 case RECORD_TYPE_PMBUS_POLL_UNTIL_ACK_NOPEC: // 0x0C
138 successful_parse_of_record_type = recordProcessor___0x0C___processPollReadByteUntilAckNoPEC( (t_RECORD_PMBUS_POLL_READ_BYTE_UNTIL_ACK *) record_to_process);
139 break;
140 case RECORD_TYPE_DELAY_MS: // 0x0D
141 successful_parse_of_record_type = recordProcessor___0x0D___processDelayMs( (t_RECORD_DELAY_MS *) record_to_process);
142 break;
143 case RECORD_TYPE_PMBUS_SEND_BYTE: //0x0E
144 successful_parse_of_record_type = recordProcessor___0x0E___processSendByteOptionalPEC( (t_RECORD_PMBUS_SEND_BYTE *) record_to_process);
145 break;
146 case RECORD_TYPE_PMBUS_WRITE_BYTE_NOPEC: // 0x0F
147 successful_parse_of_record_type = recordProcessor___0x0F___processWriteByteNoPEC( (t_RECORD_PMBUS_WRITE_BYTE_NOPEC *) record_to_process);
148 break;
149 case RECORD_TYPE_PMBUS_WRITE_WORD_NOPEC: // 0x10
150 successful_parse_of_record_type = recordProcessor___0x10___processWriteWordNoPEC( (t_RECORD_PMBUS_WRITE_WORD_NOPEC *) record_to_process);
151 break;
152 case RECORD_TYPE_PMBUS_WRITE_BLOCK_NOPEC: // 0x11
153 successful_parse_of_record_type = FAILURE; // Unsupported Record Type
154 break;
155 case RECORD_TYPE_PMBUS_READ_BYTE_EXPECT_NOPEC: // 0x12
156 successful_parse_of_record_type = recordProcessor___0x12___processReadByteExpectNoPEC( (t_RECORD_PMBUS_READ_BYTE_EXPECT_NOPEC *) record_to_process);
157 break;
158 case RECORD_TYPE_PMBUS_READ_WORD_EXPECT_NOPEC: // 0x13
159 successful_parse_of_record_type = recordProcessor___0x13___processReadWordExpectNoPEC( (t_RECORD_PMBUS_READ_WORD_EXPECT_NOPEC *) record_to_process);
160 break;
161 case RECORD_TYPE_PMBUS_READ_BLOCK_EXPECT_NOPEC: // 0x14
162 successful_parse_of_record_type = FAILURE; // Unsupported Record Type
163 break;
164 case RECORD_TYPE_PMBUS_READ_BYTE_LOOP_MASK_NOPEC: // 0x15
165 successful_parse_of_record_type = recordProcessor___0x15___processReadByteLoopMaskNoPEC( (t_RECORD_PMBUS_READ_BYTE_LOOP_MASK_NOPEC *) record_to_process);
166 break;
167 case RECORD_TYPE_PMBUS_READ_WORD_LOOP_MASK_NOPEC: // 0x16
168 successful_parse_of_record_type = recordProcessor___0x16___processReadWordLoopMaskNoPEC( (t_RECORD_PMBUS_READ_WORD_LOOP_MASK_NOPEC *) record_to_process);
169 break;
170 case RECORD_TYPE_PMBUS_SEND_BYTE_NOPEC: // 0x17
171 successful_parse_of_record_type = recordProcessor___0x17___processSendByteNoPEC( (t_RECORD_PMBUS_SEND_BYTE_NOPEC *) record_to_process);
172 break;
173 case RECORD_TYPE_EVENT: // 0x18
174 successful_parse_of_record_type = recordProcessor___0x18___processEvent( (t_RECORD_EVENT *) record_to_process);
175 break;
176 case RECORD_TYPE_PMBUS_READ_BYTE_EXPECT_MASK_NOPEC: // 0x19
177 successful_parse_of_record_type = recordProcessor___0x19___processReadByteExpectMaskNoPEC( (t_RECORD_PMBUS_READ_BYTE_EXPECT_MASK_NOPEC *) record_to_process);
178 break;
179 case RECORD_TYPE_PMBUS_READ_WORD_EXPECT_MASK_NOPEC: //0x1A
180 successful_parse_of_record_type = recordProcessor___0x1A___processReadWordExpectMaskNoPEC( (t_RECORD_PMBUS_READ_WORD_EXPECT_MASK_NOPEC *) record_to_process);
181 break;
182 case RECORD_TYPE_VARIABLE_META_DATA: // 0x1B
183 successful_parse_of_record_type = recordProcessor___0x1B___processVariableMetaData( (t_RECORD_VARIABLE_META_DATA *) record_to_process);
184 break;
185 case RECORD_TYPE_MODIFY_WORD_NOPEC: // 0x1C
186 successful_parse_of_record_type = recordProcessor___0x1C___modifyWordNoPEC( (t_RECORD_PMBUS_MODIFY_WORD_NO_PEC *) record_to_process);
187 break;
188 case RECORD_TYPE_MODIFY_BYTE_NOPEC: // 0x1D
189 successful_parse_of_record_type = recordProcessor___0x1D___modifyByteNoPEC( (t_RECORD_PMBUS_MODIFY_BYTE_NO_PEC *) record_to_process);
190 break;
191 case RECORD_TYPE_PMBUS_WRITE_EE_DATA: // 0x1E
192 successful_parse_of_record_type = recordProcessor___0x1E___writeNvmData( (t_RECORD_NVM_DATA *) record_to_process);
193 break;
194 case RECORD_TYPE_PMBUS_READ_AND_VERIFY_EE_DATA: // 0x1F
195 successful_parse_of_record_type = recordProcessor___0x1F___read_then_verifyNvmData( (t_RECORD_NVM_DATA *) record_to_process);
196 break;
197 case RECORD_TYPE_PMBUS_MODIFY_BYTE: // 0x20
198 successful_parse_of_record_type = recordProcessor___0x20___modifyByteOptionalPEC( (t_RECORD_PMBUS_MODIFY_BYTE *) record_to_process);
199 break;
200 case RECORD_TYPE_PMBUS_MODIFY_WORD: // 0x21
201 successful_parse_of_record_type = recordProcessor___0x21___modifyWordOptionalPEC( (t_RECORD_PMBUS_MODIFY_WORD *) record_to_process);
202 break;
203 case RECORD_TYPE_END_OF_RECORDS: // 0x22
204 return SUCCESS;
205 default:
206 successful_parse_of_record_type = FAILURE; // Unknown Instruction, report a failure
207 break;
208 }
209 }
210
211 return successful_parse_of_record_type;
212 }
213
214 /********************************************************************
215 * Function: uint8_t verifyRecordsOnDemand(_InCircuitProgrammingRecordTypeListItem_p node, uint16_t length);
216 *
217 * PreCondition: None
218 * Input: Function to get records one by one, skips writes
219 * Output: Returns SUCCESS (1) or FAILURE (0) depending on the status of parsing ALL the record types
220 * Overview: Processes all the records until the function to get records returns null
221 * Records are freed as processed.
222 * Note: None
223 *******************************************************************/
224 uint8_t verifyRecordsOnDemand(pRecordHeaderLengthAndType (*getRecord)(void))
225 {
226 pRecordHeaderLengthAndType record_to_process;
227
228 uint16_t recordType_of_record_to_process;
229 uint8_t successful_parse_of_record_type = SUCCESS;
230 verification_in_progress = true;
231
232 while ((record_to_process = getRecord()) != NULL && successful_parse_of_record_type == SUCCESS)
233 {
234 recordType_of_record_to_process = record_to_process->RecordType;
235
236 if (!ignore_records)
237 switch (recordType_of_record_to_process)
238 {
239 case RECORD_TYPE_PMBUS_WRITE_BYTE: // 0x01
240 if (((t_RECORD_PMBUS_WRITE_BYTE *) record_to_process)->detailedRecordHeader.CommandCode != 0xBE)
241 successful_parse_of_record_type = recordProcessor___0x01___processWriteByteOptionalPEC( (t_RECORD_PMBUS_WRITE_BYTE *) record_to_process);
242 else
243 smbusPec__->writeByte((uint8_t) ((t_RECORD_PMBUS_WRITE_BYTE *)record_to_process)->detailedRecordHeader.DeviceAddress, 0xBD, 0);
244 break;
245 case RECORD_TYPE_PMBUS_WRITE_WORD: // 0x02
246 successful_parse_of_record_type = recordProcessor___0x02___processWriteWordOptionalPEC( (t_RECORD_PMBUS_WRITE_WORD *) record_to_process);
247 break;
248 case RECORD_TYPE_PMBUS_WRITE_BLOCK: // 0x03
249 successful_parse_of_record_type = FAILURE; // Unsupported Record Type
250 break;
251 case RECORD_TYPE_PMBUS_READ_BYTE_EXPECT: // 0x04
252 successful_parse_of_record_type = recordProcessor___0x04___processReadByteExpectOptionalPEC( (t_RECORD_PMBUS_READ_BYTE_EXPECT *) record_to_process);
253 break;
254 case RECORD_TYPE_PMBUS_READ_WORD_EXPECT: // 0x05
255 successful_parse_of_record_type = recordProcessor___0x05___processReadWordExpectOptionalPEC( (t_RECORD_PMBUS_READ_WORD_EXPECT *) record_to_process);
256 break;
257 case RECORD_TYPE_PMBUS_READ_BLOCK_EXPECT: // 0x06
258 successful_parse_of_record_type = FAILURE; // Unsupported Record Type
259 break;
260 case RECORD_TYPE_DEVICE_ADDRESS: // 0x07 -- OBSOLETED
261 successful_parse_of_record_type = SUCCESS; // Do nothing for this record type, but do not fail
262 break;
263 case RECORD_TYPE_PACKING_CODE: // 0x08 -- OBSOLETED
264 successful_parse_of_record_type = SUCCESS; // Do nothing for this record type, but do not fail
265 break;
266 case RECORD_TYPE_PMBUS_READ_BYTE_LOOP_MASK: // 0x0A
267 successful_parse_of_record_type = recordProcessor___0x0A___processReadByteLoopMaskOptionalPEC( (t_RECORD_PMBUS_READ_BYTE_LOOP_MASK *) record_to_process);
268 break;
269 case RECORD_TYPE_PMBUS_READ_WORD_LOOP_MASK: //0x0B
270 successful_parse_of_record_type = recordProcessor___0x0B___processReadWordLoopMaskOptionalPEC( (t_RECORD_PMBUS_READ_WORD_LOOP_MASK *) record_to_process);
271 break;
272 case RECORD_TYPE_PMBUS_POLL_UNTIL_ACK_NOPEC: // 0x0C
273 successful_parse_of_record_type = recordProcessor___0x0C___processPollReadByteUntilAckNoPEC( (t_RECORD_PMBUS_POLL_READ_BYTE_UNTIL_ACK *) record_to_process);
274 break;
275 case RECORD_TYPE_DELAY_MS: // 0x0D
276 successful_parse_of_record_type = recordProcessor___0x0D___processDelayMs( (t_RECORD_DELAY_MS *) record_to_process);
277 break;
278 case RECORD_TYPE_PMBUS_SEND_BYTE: //0x0E
279 successful_parse_of_record_type = recordProcessor___0x0E___processSendByteOptionalPEC( (t_RECORD_PMBUS_SEND_BYTE *) record_to_process);
280 break;
281 case RECORD_TYPE_PMBUS_WRITE_BYTE_NOPEC: // 0x0F
282 successful_parse_of_record_type = recordProcessor___0x0F___processWriteByteNoPEC( (t_RECORD_PMBUS_WRITE_BYTE_NOPEC *) record_to_process);
283 break;
284 case RECORD_TYPE_PMBUS_WRITE_WORD_NOPEC: // 0x10
285 successful_parse_of_record_type = recordProcessor___0x10___processWriteWordNoPEC( (t_RECORD_PMBUS_WRITE_WORD_NOPEC *) record_to_process);
286 break;
287 case RECORD_TYPE_PMBUS_WRITE_BLOCK_NOPEC: // 0x11
288 successful_parse_of_record_type = FAILURE; // Unsupported Record Type
289 break;
290 case RECORD_TYPE_PMBUS_READ_BYTE_EXPECT_NOPEC: // 0x12
291 successful_parse_of_record_type = recordProcessor___0x12___processReadByteExpectNoPEC( (t_RECORD_PMBUS_READ_BYTE_EXPECT_NOPEC *) record_to_process);
292 break;
293 case RECORD_TYPE_PMBUS_READ_WORD_EXPECT_NOPEC: // 0x13
294 successful_parse_of_record_type = recordProcessor___0x13___processReadWordExpectNoPEC( (t_RECORD_PMBUS_READ_WORD_EXPECT_NOPEC *) record_to_process);
295 break;
296 case RECORD_TYPE_PMBUS_READ_BLOCK_EXPECT_NOPEC: // 0x14
297 successful_parse_of_record_type = FAILURE; // Unsupported Record Type
298 break;
299 case RECORD_TYPE_PMBUS_READ_BYTE_LOOP_MASK_NOPEC: // 0x15
300 successful_parse_of_record_type = recordProcessor___0x15___processReadByteLoopMaskNoPEC( (t_RECORD_PMBUS_READ_BYTE_LOOP_MASK_NOPEC *) record_to_process);
301 break;
302 case RECORD_TYPE_PMBUS_READ_WORD_LOOP_MASK_NOPEC: // 0x16
303 successful_parse_of_record_type = recordProcessor___0x16___processReadWordLoopMaskNoPEC( (t_RECORD_PMBUS_READ_WORD_LOOP_MASK_NOPEC *) record_to_process);
304 break;
305 case RECORD_TYPE_PMBUS_SEND_BYTE_NOPEC: // 0x17
306 successful_parse_of_record_type = recordProcessor___0x17___processSendByteNoPEC( (t_RECORD_PMBUS_SEND_BYTE_NOPEC *) record_to_process);
307 break;
308 case RECORD_TYPE_PMBUS_READ_BYTE_EXPECT_MASK_NOPEC: // 0x19
309 successful_parse_of_record_type = recordProcessor___0x19___processReadByteExpectMaskNoPEC( (t_RECORD_PMBUS_READ_BYTE_EXPECT_MASK_NOPEC *) record_to_process);
310 break;
311 case RECORD_TYPE_PMBUS_READ_WORD_EXPECT_MASK_NOPEC: //0x1A
312 successful_parse_of_record_type = recordProcessor___0x1A___processReadWordExpectMaskNoPEC( (t_RECORD_PMBUS_READ_WORD_EXPECT_MASK_NOPEC *) record_to_process);
313 break;
314 case RECORD_TYPE_VARIABLE_META_DATA: // 0x1B
315 successful_parse_of_record_type = recordProcessor___0x1B___processVariableMetaData( (t_RECORD_VARIABLE_META_DATA *) record_to_process);
316 break;
317 case RECORD_TYPE_MODIFY_WORD_NOPEC: // 0x1C
318 successful_parse_of_record_type = recordProcessor___0x1C___modifyWordNoPEC( (t_RECORD_PMBUS_MODIFY_WORD_NO_PEC *) record_to_process);
319 break;
320 case RECORD_TYPE_MODIFY_BYTE_NOPEC: // 0x1D
321 successful_parse_of_record_type = recordProcessor___0x1D___modifyByteNoPEC( (t_RECORD_PMBUS_MODIFY_BYTE_NO_PEC *) record_to_process);
322 break;
323 case RECORD_TYPE_PMBUS_WRITE_EE_DATA: // 0x1E
324 //successful_parse_of_record_type = recordProcessor___0x1E___writeNvmData( (t_RECORD_NVM_DATA *) record_to_process);
325 smbusPec__->writeByte((uint8_t) ((t_RECORD_NVM_DATA *)record_to_process)->detailedRecordHeader.DeviceAddress, 0xBD, 0);
326 break;
327 case RECORD_TYPE_PMBUS_READ_AND_VERIFY_EE_DATA: // 0x1F
328 successful_parse_of_record_type = recordProcessor___0x1F___read_then_verifyNvmData( (t_RECORD_NVM_DATA *) record_to_process);
329 break;
330 case RECORD_TYPE_PMBUS_MODIFY_BYTE: // 0x20
331 successful_parse_of_record_type = recordProcessor___0x20___modifyByteOptionalPEC( (t_RECORD_PMBUS_MODIFY_BYTE *) record_to_process);
332 break;
333 case RECORD_TYPE_PMBUS_MODIFY_WORD: // 0x21
334 successful_parse_of_record_type = recordProcessor___0x21___modifyWordOptionalPEC( (t_RECORD_PMBUS_MODIFY_WORD *) record_to_process);
335 break;
336 default:
337 successful_parse_of_record_type = FAILURE; // Unknown Instruction, report a failure
338 break;
339 }
340
341 // This logic is outside of ignore_records
342 if (recordType_of_record_to_process == RECORD_TYPE_NVM_DATA) // 0x09 -- FUNCTIONALITY CHANGED 25/01/2011
343 {
344 successful_parse_of_record_type = recordProcessor___0x09___bufferNVMData( (t_RECORD_NVM_DATA *) record_to_process);
345 }
346 else if (recordType_of_record_to_process == RECORD_TYPE_EVENT) // 0x18
347 successful_parse_of_record_type = recordProcessor___0x18___processEvent( (t_RECORD_EVENT *) record_to_process);
348 else if (recordType_of_record_to_process == RECORD_TYPE_END_OF_RECORDS) // 0x22
349 {
350 verification_in_progress = false;
351 return SUCCESS;
352 }
353 }
354
355 return successful_parse_of_record_type;
356 }
357
358 /********************************************************************
359 * Function: uint8_t recordProcessor___0x01___processWriteByteOptionalPEC(t_RECORD_PMBUS_WRITE_BYTE*);
360 *
361 * PreCondition: None
362 * Input: A t_RECORD_PMBUS_WRITE_BYTE pointer reference
363 * Output: A 1 is returned on success and a 0 is returned on failure
364 * Overview: Processes the t_RECORD_PMBUS_WRITE_BYTE record type
365 * Note: More detailed information may be available in the PDF
366 *******************************************************************/
367 uint8_t recordProcessor___0x01___processWriteByteOptionalPEC(t_RECORD_PMBUS_WRITE_BYTE *pRecord)
368 {
369 #if DEBUG_SILENT == 1
370 return SUCCESS;
371 #else
372 #if DEBUG_PROCESSING == 1
373 Serial.print(F("WriteByteOptionalPEC "));
374 Serial.print(pRecord->detailedRecordHeader.DeviceAddress, HEX);
375 Serial.print(F(" "));
376 Serial.print(pRecord->detailedRecordHeader.CommandCode, HEX);
377 Serial.print(F(" "));
378 Serial.println(pRecord->dataByte, HEX);
379 #else
380 #if DEBUG_PRINT == 1
381 Serial.print(F("WriteByteOptionalPEC "));
382 Serial.print(pRecord->detailedRecordHeader.DeviceAddress, HEX);
383 Serial.print(" ");
384 Serial.print(pRecord->detailedRecordHeader.CommandCode, HEX);
385 Serial.print(F(" "));
386 Serial.println(pRecord->dataByte, HEX);
387 #endif
388
389
390 if (pRecord->detailedRecordHeader.UsePec)
391 smbusPec__->writeByte((uint8_t) pRecord->detailedRecordHeader.DeviceAddress,
392 pRecord->detailedRecordHeader.CommandCode,
393 pRecord->dataByte);
394 else
395 smbusNoPec__->writeByte((uint8_t) pRecord->detailedRecordHeader.DeviceAddress,
396 pRecord->detailedRecordHeader.CommandCode,
397 pRecord->dataByte);
398 #endif
399 #endif
400 return SUCCESS;
401 }
402
403 /********************************************************************
404 * Function: uint8_t recordProcessor___0x02___processWriteWordOptionalPEC(t_RECORD_PMBUS_WRITE_WORD*);
405 *
406 * PreCondition: None
407 * Input: A t_RECORD_PMBUS_WRITE_WORD pointer reference
408 * Output: A 1 is returned on success and a 0 is returned on failure
409 * Overview: Processes the t_RECORD_PMBUS_WRITE_WORD record type
410 * Note: More detailed information may be available in the PDF
411 *******************************************************************/
412 uint8_t recordProcessor___0x02___processWriteWordOptionalPEC(t_RECORD_PMBUS_WRITE_WORD *pRecord)
413 {
414 #if DEBUG_SILENT
415 return SUCCESS;
416 #else
417 #if DEBUG_PROCESSING
418 Serial.print(F("WriteWordOptionalPEC "));
419 Serial.print(pRecord->detailedRecordHeader.DeviceAddress, HEX);
420 Serial.print(F(" "));
421 Serial.print(pRecord->detailedRecordHeader.CommandCode, HEX);
422 Serial.print(F(" "));
423 Serial.println(pRecord->dataWord, HEX);
424 #else
425 #if DEBUG_PRINT
426 Serial.print(F("WriteWordOptionalPEC "));
427 Serial.print(pRecord->detailedRecordHeader.DeviceAddress, HEX);
428 Serial.print(F(" "));
429 Serial.print(pRecord->detailedRecordHeader.CommandCode, HEX);
430 Serial.print(F(" "));
431 Serial.println(pRecord->dataWord, HEX);
432 #endif
433 if (pRecord->detailedRecordHeader.UsePec)
434 smbusPec__->writeWord((uint8_t) pRecord->detailedRecordHeader.DeviceAddress,
435 pRecord->detailedRecordHeader.CommandCode,
436 pRecord->dataWord);
437 else
438 smbusNoPec__->writeWord((uint8_t) pRecord->detailedRecordHeader.DeviceAddress,
439 pRecord->detailedRecordHeader.CommandCode,
440 pRecord->dataWord);
441 #endif
442 #endif
443 return SUCCESS;
444 }
445
446 /********************************************************************
447 * Function: uint8_t recordProcessor___0x04___processReadByteExpectOptionalPEC(t_RECORD_smbus_read_byte_EXPECT*);
448 *
449 * PreCondition: None
450 * Input: A t_RECORD_smbus_read_byte_EXPECT pointer reference
451 * Output: A 1 is returned on success and a 0 is returned on failure
452 * Overview: Processes the t_RECORD_smbus_read_byte_EXPECT record type
453 * Note: More detailed information may be available in the PDF
454 *******************************************************************/
455 uint8_t recordProcessor___0x04___processReadByteExpectOptionalPEC(t_RECORD_PMBUS_READ_BYTE_EXPECT *pRecord)
456 {
457 #if DEBUG_SILENT
458 return SUCCESS;
459 #else
460 #if DEBUG_PROCESSING
461 Serial.print(F("ReadByteExpectOptionalPEC "));
462 Serial.print(pRecord->detailedRecordHeader.DeviceAddress, HEX);
463 Serial.print(F(" "));
464 Serial.println(pRecord->detailedRecordHeader.CommandCode, HEX);
465 return SUCCESS;
466 #else
467 uint8_t actualByteValue;
468 if (pRecord->detailedRecordHeader.UsePec)
469 actualByteValue = smbusPec__->readByte((uint8_t) pRecord->detailedRecordHeader.DeviceAddress,
470 pRecord->detailedRecordHeader.CommandCode);
471 else
472 actualByteValue = smbusNoPec__->readByte((uint8_t) pRecord->detailedRecordHeader.DeviceAddress,
473 pRecord->detailedRecordHeader.CommandCode);
474
475 #if DEBUG_PRINT
476 Serial.print(F("ReadByteExpectOptionalPEC "));
477 Serial.print(pRecord->detailedRecordHeader.DeviceAddress, HEX);
478 Serial.print(F(" "));
479 Serial.print(pRecord->detailedRecordHeader.CommandCode, HEX);
480 Serial.print(F(" "));
481 Serial.print(actualByteValue, HEX);
482 Serial.print(F(" "));
483 Serial.println(pRecord->expectedDataByte, HEX);
484 #endif
485
486 return (actualByteValue != pRecord->expectedDataByte) ? FAILURE : SUCCESS;
487 #endif
488 #endif
489 }
490
491 /********************************************************************
492 * Function: uint8_t recordProcessor___0x05___processReadWordExpectOptionalPEC(t_RECORD_PMBUS_READ_WORD_EXPECT*);
493 *
494 * PreCondition: None
495 * Input: A t_RECORD_PMBUS_READ_WORD_EXPECT pointer reference
496 * Output: A 1 is returned on success and a 0 is returned on failure
497 * Overview: Processes the t_RECORD_PMBUS_READ_WORD_EXPECT record type
498 * Note: More detailed information may be available in the PDF
499 *******************************************************************/
500 uint8_t recordProcessor___0x05___processReadWordExpectOptionalPEC(t_RECORD_PMBUS_READ_WORD_EXPECT *pRecord)
501 {
502 #if DEBUG_SILENT
503 return SUCCESS;
504 #else
505 #if DEBUG_PROCESSING
506 Serial.print(F("ReadWordExpectOptionalPEC "));
507 Serial.print(pRecord->detailedRecordHeader.DeviceAddress, HEX);
508 Serial.print(F(" "));
509 Serial.println(pRecord->detailedRecordHeader.CommandCode, HEX);
510 return SUCCESS;
511 #else
512 uint16_t actualWordValue;
513 if (pRecord->detailedRecordHeader.UsePec)
514 actualWordValue = smbusPec__->readWord((uint8_t) pRecord->detailedRecordHeader.DeviceAddress,
515 pRecord->detailedRecordHeader.CommandCode);
516 else
517 actualWordValue = smbusNoPec__->readWord((uint8_t) pRecord->detailedRecordHeader.DeviceAddress,
518 pRecord->detailedRecordHeader.CommandCode);
519
520 #if DEBUG_PRINT
521 Serial.print(F("ReadWordExpectOptionalPEC "));
522 Serial.print(pRecord->detailedRecordHeader.DeviceAddress, HEX);
523 Serial.print(F(" "));
524 Serial.print(pRecord->detailedRecordHeader.CommandCode, HEX);
525 Serial.print(F(" "));
526 Serial.print(actualWordValue, HEX);
527 Serial.print(F(" "));
528 Serial.println(pRecord->expectedDataWord, HEX);
529 #endif
530
531 return (actualWordValue != pRecord->expectedDataWord) ? FAILURE : SUCCESS;
532 #endif
533 #endif
534 }
535
536 /********************************************************************
537 * Function: uint8_t recordProcessor___0x09___bufferNVMData(t_RECORD_NVM_DATA*);
538 *
539 * PreCondition: None
540 * Input: A t_RECORD_NVM_DATA pointer reference
541 * Output: A 1 is returned on success and a 0 is returned on failure
542 * Overview: Processes the t_RECORD_NVM_DATA record type
543 * Note: More detailed information may be available in the PDF
544 *******************************************************************/
545 uint8_t recordProcessor___0x09___bufferNVMData(t_RECORD_NVM_DATA *pRecord)
546 {
547 #if DEBUG_SILENT
548 return SUCCESS;
549 #else
550 #if DEBUG_PROCESSING
551 Serial.print(F("NVMData "));
552 Serial.print(pRecord->detailedRecordHeader.DeviceAddress, HEX);
553 Serial.print(F(" "));
554 Serial.print(pRecord->detailedRecordHeader.CommandCode, HEX);
555 Serial.print(F(" "));
556 Serial.println(pRecord->baseRecordHeader.Length, HEX);
557
558 uint16_t nWords = (uint16_t)((pRecord->baseRecordHeader.Length-8)/2);
559 uint16_t *words = (uint16_t *) ((uint16_t)pRecord+8); // Change (UINT16) to the size of an address on the target machine.
560
561 for (int i = 0; i < nWords; i++)
562 Serial.println(words[i], HEX); // Change (UINT16) to the size of an address on the target machine.
563
564 return SUCCESS;
565 #endif
566 #if DEBUG_PRINT
567 Serial.print(F("NVMData "));
568 Serial.print(pRecord->detailedRecordHeader.DeviceAddress, HEX);
569 Serial.print(F(" "));
570 Serial.print(pRecord->detailedRecordHeader.CommandCode, HEX);
571 Serial.print(F(" "));
572 Serial.println(pRecord->baseRecordHeader.Length, HEX);
573 #endif
574 #endif
575 return bufferNvmData(pRecord);
576 }
577
578 /********************************************************************
579 * Function: uint8_t recordProcessor___0x0A___processReadByteLoopMaskOptionalPEC(t_RECORD_smbus_read_byte_LOOP_MASK*);
580 *
581 * PreCondition: None
582 * Input: A t_RECORD_smbus_read_byte_LOOP_MASK pointer reference
583 * Output: A 1 is returned on success and a 0 is returned on failure
584 * Overview: Processes the t_RECORD_smbus_read_byte_LOOP_MASK record type
585 * Note: More detailed information may be available in the PDF
586 *******************************************************************/
587 uint8_t recordProcessor___0x0A___processReadByteLoopMaskOptionalPEC(t_RECORD_PMBUS_READ_BYTE_LOOP_MASK *pRecord)
588 {
589 #if DEBUG_SILENT
590 return SUCCESS;
591 #else
592 #if DEBUG_PROCESSING
593 Serial.print(F("ReadByteLoopMaskOptionalPEC "));
594 Serial.print(pRecord->detailedRecordHeader.DeviceAddress, HEX);
595 Serial.print(F(" "));
596 Serial.print(pRecord->detailedRecordHeader.CommandCode, HEX);
597 Serial.print(F(" "));
598 Serial.println(pRecord->byteMask, HEX);
599 #else
600 uint8_t actualByteValue;
601 uint8_t actualByteValueWithMask;
602 uint8_t expectedByteValueWithMask;
603 uint8_t success = FAILURE;
604 do
605 {
606 if (pRecord->detailedRecordHeader.UsePec)
607 actualByteValue = smbusPec__->readByte((uint8_t) pRecord->detailedRecordHeader.DeviceAddress,
608 pRecord->detailedRecordHeader.CommandCode);
609 else
610 actualByteValue = smbusNoPec__->readByte((uint8_t) pRecord->detailedRecordHeader.DeviceAddress,
611 pRecord->detailedRecordHeader.CommandCode);
612
613 actualByteValueWithMask = (actualByteValue & pRecord->byteMask);
614 expectedByteValueWithMask = (pRecord->expectedDataByte & pRecord->byteMask);
615 success = (actualByteValueWithMask == expectedByteValueWithMask);
616 #if DEBUG_PRINT
617 Serial.print(F("ReadByteLoopMaskOptionalPEC "));
618 Serial.print(pRecord->detailedRecordHeader.DeviceAddress, HEX);
619 Serial.print(F(" "));
620 Serial.print(pRecord->detailedRecordHeader.CommandCode, HEX);
621 Serial.print(F(" "));
622 Serial.print(pRecord->byteMask, HEX);
623 Serial.print(F(" "));
624 Serial.print(actualByteValueWithMask, HEX);
625 Serial.print(F(" "));
626 Serial.println(expectedByteValueWithMask, HEX);
627 #endif
628 }
629 while (success == FAILURE);
630 #endif
631 #endif
632
633 return SUCCESS;
634
635 }
636
637 /********************************************************************
638 * Function: uint8_t recordProcessor___0x0B___processReadWordLoopMaskOptionalPEC(t_RECORD_PMBUS_READ_WORD_LOOP_MASK*);
639 *
640 * PreCondition: None
641 * Input: A t_RECORD_PMBUS_READ_WORD_LOOP_MASK pointer reference
642 * Output: A 1 is returned on success and a 0 is returned on failure
643 * Overview: Processes the t_RECORD_PMBUS_READ_WORD_LOOP_MASK record type
644 * Note: More detailed information may be available in the PDF
645 *******************************************************************/
646 uint8_t recordProcessor___0x0B___processReadWordLoopMaskOptionalPEC(t_RECORD_PMBUS_READ_WORD_LOOP_MASK *pRecord)
647 {
648 #if DEBUG_SILENT
649 return SUCCESS;
650 #else
651 #if DEBUG_PROCESSING
652 Serial.print(F("WriteWordLoopMaskOptionalPEC %x "));
653 Serial.print(pRecord->detailedRecordHeader.DeviceAddress, HEX);
654 Serial.print(F(" "));
655 Serial.print(pRecord->detailedRecordHeader.CommandCode, HEX);
656 Serial.print(F(" "));
657 Serial.println(pRecord->wordMask, HEX);
658 #else
659 uint16_t actualWordValue;
660 uint16_t actualWordValueWithMask;
661 uint16_t expectedWordValueWithMask;
662 uint8_t success = FAILURE;
663 do
664 {
665 if (pRecord->detailedRecordHeader.UsePec)
666 actualWordValue = smbusPec__->readWord((uint8_t) pRecord->detailedRecordHeader.DeviceAddress,
667 pRecord->detailedRecordHeader.CommandCode);
668 else
669 actualWordValue = smbusNoPec__->readWord((uint8_t) pRecord->detailedRecordHeader.DeviceAddress,
670 pRecord->detailedRecordHeader.CommandCode);
671
672 actualWordValueWithMask = (actualWordValue & pRecord->wordMask);
673 expectedWordValueWithMask = (pRecord->expectedDataWord & pRecord->wordMask);
674 success = (actualWordValueWithMask == expectedWordValueWithMask);
675 #if DEBUG_PRINT
676 Serial.print(F("WriteWordLoopMaskOptionalPEC "));
677 Serial.print(pRecord->detailedRecordHeader.DeviceAddress, HEX);
678 Serial.print(F(" "));
679 Serial.print(pRecord->detailedRecordHeader.CommandCode, HEX);
680 Serial.print(F(" "));
681 Serial.print(pRecord->wordMask, HEX);
682 Serial.print(F(" "));
683 Serial.print(actualWordValueWithMask, HEX);
684 Serial.print(F(" "));
685 Serial.println(expectedWordValueWithMask, HEX);
686 #endif
687 }
688 while (success == FAILURE);
689 #endif
690 #endif
691 return SUCCESS;
692 }
693
694 /********************************************************************
695 * Function: uint8_t recordProcessor___0x0C___processPollReadByteUntilAckNoPEC(t_RECORD_PMBUS_POLL_READ_BYTE_UNTIL_ACK*);
696 *
697 * PreCondition: None
698 * Input: A t_RECORD_PMBUS_POLL_READ_BYTE_UNTIL_ACK pointer reference
699 * Output: A 1 is returned on success and a 0 is returned on failure
700 * Overview: Processes the t_RECORD_PMBUS_POLL_READ_BYTE_UNTIL_ACK record type
701 * Note: More detailed information may be available in the PDF
702 *******************************************************************/
703 uint8_t recordProcessor___0x0C___processPollReadByteUntilAckNoPEC(t_RECORD_PMBUS_POLL_READ_BYTE_UNTIL_ACK *pRecord)
704 {
705 #if DEBUG_SILENT
706 return SUCCESS;
707 #else
708 #if DEBUG_PROCESSING
709 Serial.print(F("PollReadByteUntilAckNoPEC "));
710 Serial.print(pRecord->detailedRecordHeader.DeviceAddress, HEX);
711 Serial.print(F(" "));
712 Serial.println(pRecord->detailedRecordHeader.CommandCode, HEX);
713 #else
714 #if DEBUG_PRINT
715 Serial.print(F("PollReadByteUntilAckNoPEC "));
716 Serial.print(pRecord->detailedRecordHeader.DeviceAddress, HEX);
717 Serial.print(F(" "));
718 Serial.println(pRecord->detailedRecordHeader.CommandCode, HEX);
719 #endif
720 return smbusNoPec__->waitForAck((uint8_t) pRecord->detailedRecordHeader.DeviceAddress,
721 pRecord->detailedRecordHeader.CommandCode);
722 #endif
723 #endif
724 return SUCCESS;
725 }
726
727 /********************************************************************
728 * Function: uint8_t recordProcessor___0x0D___processDelayMs(t_RECORD_DELAY_MS*);
729 *
730 * PreCondition: None
731 * Input: A t_RECORD_DELAY_MS pointer reference
732 * Output: A 1 is returned on success and a 0 is returned on failure
733 * Overview: Processes the t_RECORD_DELAY_MS record type
734 * Note:
735 * Clock Frequency = 80MHZ
736 * Clock Period = 12.5 nano-seconds
737 * Disregarding the ~12 cycles to enter function, this delay is approximate and weighted to be longer with uncertainty
738 * So 1ms of delay is 80,000 clocks
739 * Each inner for loop iteration is 3 cycles + inside for loop, so 4 clocks per Nop() for-loop
740 * 20K iterations of a 4 clock cycle loop at 80MHz is 1ms
741 * Do that inner 1ms delay loop as many times as specified in the t_RECORD_DELAY_MS Record Header
742 *******************************************************************/
743 uint8_t recordProcessor___0x0D___processDelayMs(t_RECORD_DELAY_MS *pRecord)
744 {
745 #if DEBUG_SILENT
746 return SUCCESS;
747 #else
748 #if DEBUG_PROCESSING
749 Serial.print(F("DelayMs "));
750 Serial.println(pRecord->numMs);
751 #else
752 uint16_t number_of_milliseconds_to_delay = pRecord->numMs;
753 uint16_t ms_count_i;
754 uint16_t delay_i;
755 #if DEBUG_PRINT
756 Serial.print(F("DelayMs "));
757 Serial.println(pRecord->numMs);
758 #endif
759
760 // Do n number of millisecond delays
761 for (ms_count_i=0; ms_count_i < number_of_milliseconds_to_delay; ms_count_i++)
762 {
763 for (delay_i=0; delay_i < 20000; delay_i++)
764 {
765 asm("nop"); // This takes 4 clock cycles * 20,000 at 80MHz which is 1 millisecond
766 }
767 }
768 #endif
769 #endif
770 return SUCCESS;
771 }
772
773 /********************************************************************
774 * Function: uint8_t recordProcessor___0x0E___processSendByteOptionalPEC(t_RECORD_PMBUS_SEND_BYTE*);
775 *
776 * PreCondition: None
777 * Input: A t_RECORD_PMBUS_SEND_BYTE pointer reference
778 * Output: A 1 is returned on success and a 0 is returned on failure
779 * Overview: Processes the t_RECORD_PMBUS_SEND_BYTE record type
780 * Note: More detailed information may be available in the PDF
781 *******************************************************************/
782 uint8_t recordProcessor___0x0E___processSendByteOptionalPEC(t_RECORD_PMBUS_SEND_BYTE *pRecord)
783 {
784 #if DEBUG_SILENT
785 return SUCCESS;
786 #else
787 #if DEBUG_PROCESSING
788 Serial.print(F("SendByteOptionalPEC "));
789 Serial.print(pRecord->detailedRecordHeader.DeviceAddress, HEX);
790 Serial.print(F(" "));
791 Serial.println(pRecord->detailedRecordHeader.CommandCode, HEX);
792 #else
793 #if DEBUG_PRINT
794 Serial.print(F("SendByteOptionalPEC "));
795 Serial.print(pRecord->detailedRecordHeader.DeviceAddress, HEX);
796 Serial.print(F(" "));
797 Serial.println(pRecord->detailedRecordHeader.CommandCode, HEX);
798 #endif
799 if (pRecord->detailedRecordHeader.UsePec)
800 smbusPec__->sendByte((uint8_t) pRecord->detailedRecordHeader.DeviceAddress,
801 pRecord->detailedRecordHeader.CommandCode);
802 else
803 smbusNoPec__->sendByte((uint8_t) pRecord->detailedRecordHeader.DeviceAddress,
804 pRecord->detailedRecordHeader.CommandCode);
805 #endif
806 #endif
807 return SUCCESS;
808 }
809
810 /********************************************************************
811 * Function: uint8_t recordProcessor___0x0F___processWriteByteNoPEC(t_RECORD_PMBUS_WRITE_BYTE_NOPEC*);
812 *
813 * PreCondition: None
814 * Input: A t_RECORD_PMBUS_WRITE_BYTE_NOPEC pointer reference
815 * Output: A 1 is returned on success and a 0 is returned on failure
816 * Overview: Processes the t_RECORD_PMBUS_WRITE_BYTE_NOPEC record type
817 * Note: More detailed information may be available in the PDF
818 *******************************************************************/
819 uint8_t recordProcessor___0x0F___processWriteByteNoPEC(t_RECORD_PMBUS_WRITE_BYTE_NOPEC *pRecord)
820 {
821 #if DEBUG_SILENT
822 return SUCCESS;
823 #else
824 #if DEBUG_PROCESSING
825 Serial.print(F("WriteByteNoPec "));
826 Serial.print(pRecord->detailedRecordHeader.DeviceAddress, HEX);
827 Serial.print(F(" "));
828 Serial.print(pRecord->detailedRecordHeader.CommandCode, HEX);
829 Serial.print(F(" "));
830 Serial.println(pRecord->dataByte, HEX);
831 #else
832 #if DEBUG_PRINT
833 Serial.print(F("WriteByteNoPec %x "));
834 Serial.print(pRecord->detailedRecordHeader.DeviceAddress, HEX);
835 Serial.print(F(" "));
836 Serial.print(pRecord->detailedRecordHeader.CommandCode, HEX);
837 Serial.print(F(" "));
838 Serial.println(pRecord->dataByte, HEX);
839 #endif
840 smbusNoPec__->writeByte((uint8_t) pRecord->detailedRecordHeader.DeviceAddress,
841 pRecord->detailedRecordHeader.CommandCode,
842 pRecord->dataByte);
843 #endif
844 #endif
845 return SUCCESS;
846 }
847
848 /********************************************************************
849 * Function: uint8_t recordProcessor___0x10___processWriteWordNoPEC(t_RECORD_PMBUS_WRITE_WORD_NOPEC*);
850 *
851 * PreCondition: None
852 * Input: A t_RECORD_PMBUS_WRITE_WORD_NOPEC pointer reference
853 * Output: A 1 is returned on success and a 0 is returned on failure
854 * Overview: Processes the t_RECORD_PMBUS_WRITE_WORD_NOPEC record type
855 * Note: More detailed information may be available in the PDF
856 *******************************************************************/
857 uint8_t recordProcessor___0x10___processWriteWordNoPEC(t_RECORD_PMBUS_WRITE_WORD_NOPEC *pRecord)
858 {
859 #if DEBUG_SILENT
860 return SUCCESS;
861 #else
862 #if DEBUG_PROCESSING
863 Serial.print(F("WriteWordNoPec "));
864 Serial.print(pRecord->detailedRecordHeader.DeviceAddress, HEX);
865 Serial.print(F(" "));
866 Serial.print(pRecord->detailedRecordHeader.CommandCode, HEX);
867 Serial.print(F(" "));
868 Serial.println(pRecord->dataWord, HEX);
869 #else
870 #if DEBUG_PRINT
871 Serial.print(F("WriteWordNoPec %x "));
872 Serial.print(pRecord->detailedRecordHeader.DeviceAddress, HEX);
873 Serial.print(F(" "));
874 Serial.print(pRecord->detailedRecordHeader.CommandCode, HEX);
875 Serial.print(F(" "));
876 Serial.println(pRecord->dataWord, HEX);
877 #endif
878 smbusNoPec__->writeWord((uint8_t) pRecord->detailedRecordHeader.DeviceAddress,
879 pRecord->detailedRecordHeader.CommandCode,
880 pRecord->dataWord);
881 #endif
882 #endif
883 return SUCCESS;
884 }
885
886 /********************************************************************
887 * Function: uint8_t recordProcessor___0x12___processReadByteExpectNoPEC(t_RECORD_smbus_read_byte_EXPECT_NOPEC*);
888 *
889 * PreCondition: None
890 * Input: A t_RECORD_smbus_read_byte_EXPECT_NOPEC pointer reference
891 * Output: A 1 is returned on success and a 0 is returned on failure
892 * Overview: Processes the t_RECORD_smbus_read_byte_EXPECT_NOPEC record type
893 * Note: More detailed information may be available in the PDF
894 *******************************************************************/
895 uint8_t recordProcessor___0x12___processReadByteExpectNoPEC(t_RECORD_PMBUS_READ_BYTE_EXPECT_NOPEC *pRecord)
896 {
897 #if DEBUG_SILENT
898 return SUCCESS;
899 #else
900 #if DEBUG_PROCESSING
901 Serial.print(F("ReadByteExpectNoPEC "));
902 Serial.print(pRecord->detailedRecordHeader.DeviceAddress, HEX);
903 Serial.print(F(" "));
904 Serial.println(pRecord->detailedRecordHeader.CommandCode, HEX);
905 return SUCCESS;
906 #else
907 uint8_t actualByteValue;
908 actualByteValue = smbusNoPec__->readByte((uint8_t) pRecord->detailedRecordHeader.DeviceAddress,
909 pRecord->detailedRecordHeader.CommandCode);
910 #if DEBUG_PRINT
911 Serial.print(F("ReadByteExpectNoPEC "));
912 Serial.print(pRecord->detailedRecordHeader.DeviceAddress, HEX);
913 Serial.print(F(" "));
914 Serial.print(pRecord->detailedRecordHeader.CommandCode, HEX);
915 Serial.print(F(" "));
916 Serial.print(actualByteValue, HEX);
917 Serial.print(F(" "));
918 Serial.println(pRecord->expectedDataByte, HEX);
919 #endif
920 return (actualByteValue != pRecord->expectedDataByte) ? FAILURE : SUCCESS;
921 #endif
922 #endif
923 }
924
925 /********************************************************************
926 * Function: uint8_t recordProcessor___0x13___processReadWordExpectNoPEC(t_RECORD_PMBUS_READ_WORD_EXPECT_NOPEC*);
927 *
928 * PreCondition: None
929 * Input: A t_RECORD_PMBUS_READ_WORD_EXPECT_NOPEC pointer reference
930 * Output: A 1 is returned on success and a 0 is returned on failure
931 * Overview: Processes the t_RECORD_PMBUS_READ_WORD_EXPECT_NOPEC record type
932 * Note: More detailed information may be available in the PDF
933 *******************************************************************/
934 uint8_t recordProcessor___0x13___processReadWordExpectNoPEC(t_RECORD_PMBUS_READ_WORD_EXPECT_NOPEC *pRecord)
935 {
936 #if DEBUG_SILENT
937 return SUCCESS;
938 #else
939 #if DEBUG_PROCESSING
940 Serial.print(F("ReadWordEx[ectNoPEC "));
941 Serial.print(pRecord->detailedRecordHeader.DeviceAddress, HEX);
942 Serial.print(F(" "));
943 Serial.println(pRecord->detailedRecordHeader.CommandCode, HEX);
944 return SUCCESS;
945 #else
946 uint16_t actualWordValue;
947 actualWordValue = smbusNoPec__->readWord((uint8_t) pRecord->detailedRecordHeader.DeviceAddress,
948 pRecord->detailedRecordHeader.CommandCode);
949
950 #if DEBUG_PRINT
951 Serial.print(F("ReadWordExpectNoPEC "));
952 Serial.print(pRecord->detailedRecordHeader.DeviceAddress, HEX);
953 Serial.print(F(" "));
954 Serial.print(pRecord->detailedRecordHeader.CommandCode, HEX);
955 Serial.print(F(" "));
956 Serial.print(actualWordValue, HEX);
957 Serial.print(F(" "));
958 Serial.println(pRecord->expectedDataWord, HEX);
959 #endif
960 return (actualWordValue != pRecord->expectedDataWord) ? FAILURE : SUCCESS;
961 #endif
962 #endif
963 }
964
965 /********************************************************************
966 * Function: uint8_t recordProcessor___0x15___processReadByteLoopMaskNoPEC(t_RECORD_smbus_read_byte_LOOP_MASK_NOPEC*);
967 *
968 * PreCondition: None
969 * Input: A t_RECORD_smbus_read_byte_LOOP_MASK_NOPEC pointer reference
970 * Output: A 1 is returned on success and a 0 is returned on failure
971 * Overview: Processes the t_RECORD_smbus_read_byte_LOOP_MASK_NOPEC record type
972 * Note: More detailed information may be available in the PDF
973 *******************************************************************/
974 uint8_t recordProcessor___0x15___processReadByteLoopMaskNoPEC(t_RECORD_PMBUS_READ_BYTE_LOOP_MASK_NOPEC *pRecord)
975 {
976 #if DEBUG_SILENT
977 return SUCCESS;
978 #else
979 #if DEBUG_PROCESSING
980 Serial.print(F("ReadByteLoopMaskNoPEC "));
981 Serial.print(pRecord->detailedRecordHeader.DeviceAddress, HEX);
982 Serial.print(F(" "));
983 Serial.print(pRecord->detailedRecordHeader.CommandCode, HEX);
984 Serial.print(F(" "));
985 Serial.println(pRecord->byteMask, HEX);
986 #else
987 uint8_t actualByteValue;
988 uint8_t actualByteValueWithMask;
989 uint8_t expectedByteValueWithMask;
990 uint8_t success = FAILURE;
991 do
992 {
993 actualByteValue = smbusNoPec__->readByte((uint8_t) pRecord->detailedRecordHeader.DeviceAddress,
994 pRecord->detailedRecordHeader.CommandCode);
995
996 actualByteValueWithMask = (actualByteValue & pRecord->byteMask);
997 expectedByteValueWithMask = (pRecord->expectedDataByte & pRecord->byteMask);
998 success = (actualByteValueWithMask == expectedByteValueWithMask);
999 #if DEBUG_PRINT
1000 Serial.print(F("ReadByteLoopMaskNoPEC "));
1001 Serial.print(pRecord->detailedRecordHeader.DeviceAddress, HEX);
1002 Serial.print(F(" "));
1003 Serial.print(pRecord->detailedRecordHeader.CommandCode, HEX);
1004 Serial.print(F(" "));
1005 Serial.print(pRecord->byteMask, HEX);
1006 Serial.print(F(" "));
1007 Serial.print(actualByteValueWithMask, HEX);
1008 Serial.print(F(" "));
1009 Serial.println(expectedByteValueWithMask, HEX);
1010 #endif
1011 }
1012 while (success == FAILURE);
1013 #endif
1014 #endif
1015 return SUCCESS;
1016 }
1017
1018 /********************************************************************
1019 * Function: uint8_t recordProcessor___0x16___processReadWordLoopMaskNoPEC(t_RECORD_PMBUS_READ_WORD_LOOP_MASK_NOPEC*);
1020 *
1021 * PreCondition: None
1022 * Input: A t_RECORD_PMBUS_READ_WORD_LOOP_MASK_NOPEC pointer reference
1023 * Output: A 1 is returned on success and a 0 is returned on failure
1024 * Overview: Processes the t_RECORD_PMBUS_READ_WORD_LOOP_MASK_NOPEC record type
1025 * Note: More detailed information may be available in the PDF
1026 *******************************************************************/
1027 uint8_t recordProcessor___0x16___processReadWordLoopMaskNoPEC(t_RECORD_PMBUS_READ_WORD_LOOP_MASK_NOPEC *pRecord)
1028 {
1029 #if DEBUG_SILENT
1030 return SUCCESS;
1031 #else
1032 #if DEBUG_PROCESSING
1033 Serial.print(F("ReadWordLoopMaskNoPEC "));
1034 Serial.print(pRecord->detailedRecordHeader.DeviceAddress, HEX);
1035 Serial.print(F(" "));
1036 Serial.print(pRecord->detailedRecordHeader.CommandCode, HEX);
1037 Serial.print(F(" "));
1038 Serial.println(pRecord->wordMask, HEX);
1039 #else
1040 uint16_t actualWordValue;
1041 uint16_t actualWordValueWithMask;
1042 uint16_t expectedWordValueWithMask;
1043 uint8_t success = FAILURE;
1044 do
1045 {
1046 actualWordValue = smbusNoPec__->readWord((uint8_t) pRecord->detailedRecordHeader.DeviceAddress,
1047 pRecord->detailedRecordHeader.CommandCode);
1048
1049
1050 actualWordValueWithMask = (actualWordValue & pRecord->wordMask);
1051 expectedWordValueWithMask = (pRecord->expectedDataWord & pRecord->wordMask);
1052 success = (actualWordValueWithMask == expectedWordValueWithMask);
1053 #if DEBUG_PRINT
1054 Serial.print(F("ReadWordLoopMaskNoPEC "));
1055 Serial.print(pRecord->detailedRecordHeader.DeviceAddress, HEX);
1056 Serial.print(F(" "));
1057 Serial.print(pRecord->detailedRecordHeader.CommandCode, HEX);
1058 Serial.print(F(" "));
1059 Serial.print(pRecord->wordMask, HEX);
1060 Serial.print(F(" "));
1061 Serial.print(actualWordValueWithMask, HEX);
1062 Serial.print(F(" "));
1063 Serial.println(expectedWordValueWithMask, HEX);
1064 #endif
1065 }
1066 while (success == FAILURE);
1067 #endif
1068 #endif
1069 return SUCCESS;
1070 }
1071
1072 /********************************************************************
1073 * Function: uint8_t recordProcessor___0x17___processSendByteNoPEC(t_RECORD_PMBUS_SEND_BYTE_NOPEC*);
1074 *
1075 * PreCondition: None
1076 * Input: A t_RECORD_PMBUS_SEND_BYTE_NOPEC pointer reference
1077 * Output: A 1 is returned on success and a 0 is returned on failure
1078 * Overview: Processes the t_RECORD_PMBUS_SEND_BYTE_NOPEC record type
1079 * Note: More detailed information may be available in the PDF
1080 *******************************************************************/
1081 uint8_t recordProcessor___0x17___processSendByteNoPEC(t_RECORD_PMBUS_SEND_BYTE_NOPEC *pRecord)
1082 {
1083 #if DEBUG_SILENT
1084 return SUCCESS;
1085 #else
1086 #if DEBUG_PROCESSING
1087 Serial.print(F("SendByteNoPEC "));
1088 Serial.print(pRecord->detailedRecordHeader.DeviceAddress, HEX);
1089 Serial.print(F(" "));
1090 Serial.println(pRecord->detailedRecordHeader.CommandCode, HEX);
1091 #else
1092 #if DEBUG_PRINT
1093 Serial.print(F("SendByteNoPEC "));
1094 Serial.print(pRecord->detailedRecordHeader.DeviceAddress, HEX);
1095 Serial.print(F(" "));
1096 Serial.println(pRecord->detailedRecordHeader.CommandCode, HEX);
1097 #endif
1098 smbusNoPec__->sendByte((uint8_t) pRecord->detailedRecordHeader.DeviceAddress,
1099 pRecord->detailedRecordHeader.CommandCode);
1100 #endif
1101 #endif
1102 return SUCCESS;
1103 }
1104
1105 /********************************************************************
1106 * Function: uint8_t recordProcessor___0x18___processEvent(t_RECORD_EVENT*);
1107 *
1108 * PreCondition: None
1109 * Input: A t_RECORD_EVENT pointer reference
1110 * Output: A 1 is returned on success and a 0 is returned on failure
1111 * Overview: Processes the t_RECORD_EVENT record type
1112 * Note: More detailed information may be available in the PDF
1113 *******************************************************************/
1114 uint8_t recordProcessor___0x18___processEvent(t_RECORD_EVENT *pRecord)
1115 {
1116 switch (pRecord->eventId)
1117 {
1118 case BEFORE_BEGIN:
1119 if (verification_in_progress)
1120 ignore_records = true;
1121 // This event is fired before any commands are issued to program the NVM
1122 // Potentially do something in your system that needs doing before anything has started
1123 // Turn on power to the DUT? Confirm user wants to program? Release Write Protect pins?
1124 #if (DEBUG_PRINT || DEBUG_PROCESSING)
1125 Serial.print(F("META DATA EVENT: The system is about to begin executing the programming recipe\n"));
1126 #endif
1127 return SUCCESS;
1128 case BEFORE_INSYSTEM_PROGRAMMING_BEGIN :
1129 if (verification_in_progress)
1130 ignore_records = true;
1131 #if (DEBUG_PRINT || DEBUG_PROCESSING)
1132 Serial.print(F("META DATA EVENT: The system is about to begin in system programming\n"));
1133 #endif
1134 return SUCCESS;
1135 case SYSTEM_BEFORE_PROGRAM:
1136 if (verification_in_progress)
1137 ignore_records = true;
1138 // This event is fired before any commands are issued to program the NVM
1139 // Potentially do something in your system that needs doing before any programming has started
1140 // Confirm user wants to program?
1141 #if (DEBUG_PRINT || DEBUG_PROCESSING)
1142 Serial.print(F("META DATA EVENT: The system is about to begin writing to the DUT Non-Volatile Memory\n"));
1143 #endif
1144 return SUCCESS;
1145 case INSYSTEM_CHIP_BEFORE_PROGRAM :
1146 if (verification_in_progress)
1147 ignore_records = true;
1148 #if (DEBUG_PRINT || DEBUG_PROCESSING)
1149 Serial.print(F("META DATA EVENT: The system is about to begin programming a chip\n"));
1150 #endif
1151 return SUCCESS;
1152 case SYSTEM_BEFORE_VERIFY:
1153 if (verification_in_progress)
1154 ignore_records = true;
1155 // This event is fired after programming the system before any commands are issued to verify the NVM
1156 // Potentially do something in your system that needs doing before any programming has started
1157 // Tell the user the chip was programmed without error and now it needs verification?
1158 #if (DEBUG_PRINT || DEBUG_PROCESSING)
1159 Serial.print(F("META DATA EVENT: The system is about to begin reading from the DUT's Non-Volatile Memory and verifying the contents match what is expected\n"));
1160 #endif
1161 return SUCCESS;
1162 case INSYSTEM_CHIP_BEFORE_VERIFY :
1163 if (verification_in_progress)
1164 ignore_records = false;
1165 #if (DEBUG_PRINT || DEBUG_PROCESSING)
1166 Serial.print(F("META DATA EVENT: The system is about to verify a chip\n"));
1167 #endif
1168 return SUCCESS;
1169 case INSYSTEM_CHIP_AFTER_VERIFY:
1170 if (verification_in_progress)
1171 ignore_records = true;
1172 #if (DEBUG_PRINT || DEBUG_PROCESSING)
1173 Serial.print(F("META DATA EVENT: The system has finished verifying a chip\n"));
1174 #endif
1175 return SUCCESS;
1176 case SYSTEM_AFTER_VERIFY:
1177 if (verification_in_progress)
1178 ignore_records = true;
1179 #if (DEBUG_PRINT || DEBUG_PROCESSING)
1180 Serial.print(F("META DATA EVENT: The system has finished verification\n"));
1181 #endif
1182 return SUCCESS;
1183 case AFTER_DONE:
1184 // This event is fired after the end of the entire programming and verification sequence is complete
1185 // Potentially do something in your system that needs doing before any programming has started
1186 // Turn off power to the DUT? Tell the user the outcome of the verification?
1187 #if (DEBUG_PRINT || DEBUG_PROCESSING)
1188 Serial.print(F("META DATA EVENT: The system is done programming. If you reach this point without error, your device has been programmed and verified successfully\n"));
1189 #endif
1190 return SUCCESS;
1191 default:
1192 // This point should never be reached
1193 #if (DEBUG_PRINT || DEBUG_PROCESSING)
1194 Serial.print(F("The META DATA EVENT type is not supported in your firmware. You will need to update your programming algorithms\n"));
1195 #endif
1196 return FAILURE;
1197 }
1198 }
1199
1200 /********************************************************************
1201 * Function: uint8_t recordProcessor___0x19___processReadByteExpectMaskNoPEC(t_RECORD_smbus_read_byte_EXPECT_MASK_NOPEC*);
1202 *
1203 * PreCondition: None
1204 * Input: A t_RECORD_smbus_read_byte_EXPECT_MASK_NOPEC pointer reference
1205 * Output: A 1 is returned on success and a 0 is returned on failure
1206 * Overview: Processes the t_RECORD_smbus_read_byte_EXPECT_MASK_NOPEC record type
1207 * Note: More detailed information may be available in the PDF
1208 *******************************************************************/
1209 uint8_t recordProcessor___0x19___processReadByteExpectMaskNoPEC(t_RECORD_PMBUS_READ_BYTE_EXPECT_MASK_NOPEC *pRecord)
1210 {
1211 #if DEBUG_SILENT
1212 return SUCCESS;
1213 #else
1214 #if DEBUG_PROCESSING
1215 Serial.print(F("ReadByteExpectMaskNoPEC "));
1216 Serial.print(pRecord->detailedRecordHeader.DeviceAddress, HEX);
1217 Serial.print(F(" "));
1218 Serial.print(pRecord->detailedRecordHeader.CommandCode, HEX);
1219 Serial.print(F(" "));
1220 Serial.println(pRecord->byteMask, HEX);
1221 return SUCCESS;
1222 #else
1223 uint8_t actualByteValue;
1224 uint8_t actualByteValueWithMask;
1225 uint8_t expectedByteValueWithMask;
1226 actualByteValue = smbusNoPec__->readByte((uint8_t) pRecord->detailedRecordHeader.DeviceAddress,
1227 pRecord->detailedRecordHeader.CommandCode);
1228 actualByteValueWithMask = (actualByteValue & pRecord->byteMask);
1229 expectedByteValueWithMask = (pRecord->expectedDataByte & pRecord->byteMask);
1230 #if DEBUG_PRINT
1231 Serial.print(F("ReadByteExpectMaskNoPEC "));
1232 Serial.print(pRecord->detailedRecordHeader.DeviceAddress, HEX);
1233 Serial.print(F(" "));
1234 Serial.print(pRecord->detailedRecordHeader.CommandCode, HEX);
1235 Serial.print(F(" "));
1236 Serial.print(pRecord->byteMask, HEX);
1237 Serial.print(F(" "));
1238 Serial.print(actualByteValueWithMask, HEX);
1239 Serial.print(F(" "));
1240 Serial.println(expectedByteValueWithMask, HEX);
1241 #endif
1242 return (actualByteValueWithMask != expectedByteValueWithMask) ? FAILURE : SUCCESS;
1243 #endif
1244 #endif
1245 }
1246
1247 /********************************************************************
1248 * Function: uint8_t recordProcessor___0x1A___processReadWordExpectMaskNoPEC(t_RECORD_PMBUS_READ_WORD_EXPECT_MASK_NOPEC*);
1249 *
1250 * PreCondition: None
1251 * Input: A t_RECORD_PMBUS_READ_WORD_EXPECT_MASK_NOPEC pointer reference
1252 * Output: A 1 is returned on success and a 0 is returned on failure
1253 * Overview: Processes the t_RECORD_PMBUS_READ_WORD_EXPECT_MASK_NOPEC record type
1254 * Note: More detailed information may be available in the PDF
1255 *******************************************************************/
1256 uint8_t recordProcessor___0x1A___processReadWordExpectMaskNoPEC(t_RECORD_PMBUS_READ_WORD_EXPECT_MASK_NOPEC *pRecord)
1257 {
1258 #if DEBUG_SILENT
1259 return SUCCESS;
1260 #else
1261 #if DEBUG_PROCESSING
1262 Serial.print(F("ReadWordExpectMaskNoPEC "));
1263 Serial.print(pRecord->detailedRecordHeader.DeviceAddress, HEX);
1264 Serial.print(F(" "));
1265 Serial.print(pRecord->detailedRecordHeader.CommandCode, HEX);
1266 Serial.print(F(" "));
1267 Serial.print(pRecord->expectedDataWord, HEX);
1268 Serial.print(F(" "));
1269 Serial.println(pRecord->wordMask, HEX);
1270 return SUCCESS;
1271 #else
1272 uint16_t actualWordValue;
1273 uint16_t actualWordValueWithMask;
1274 uint16_t expectedWordValueWithMask;
1275 actualWordValue = smbusNoPec__->readWord((uint8_t) pRecord->detailedRecordHeader.DeviceAddress,
1276 pRecord->detailedRecordHeader.CommandCode);
1277
1278 actualWordValueWithMask = (actualWordValue & pRecord->wordMask);
1279 expectedWordValueWithMask = (pRecord->expectedDataWord & pRecord->wordMask);
1280 #if DEBUG_PRINT
1281 Serial.print(F("ReadWordExpectMaskNoPEC "));
1282 Serial.print(pRecord->detailedRecordHeader.DeviceAddress, HEX);
1283 Serial.print(F(" "));
1284 Serial.print(pRecord->detailedRecordHeader.CommandCode, HEX);
1285 Serial.print(F(" "));
1286 Serial.print(pRecord->expectedDataWord, HEX);
1287 Serial.print(F(" "));
1288 Serial.print(pRecord->wordMask, HEX);
1289 Serial.print(F(" "));
1290 Serial.print(actualWordValue, HEX);
1291 Serial.print(F(" "));
1292 Serial.print(actualWordValueWithMask, HEX);
1293 Serial.print(F(" "));
1294 Serial.println(expectedWordValueWithMask, HEX);
1295 #endif
1296 return (actualWordValueWithMask != expectedWordValueWithMask) ? FAILURE : SUCCESS;
1297 #endif
1298 #endif
1299 }
1300
1301 /********************************************************************
1302 * Function: uint8_t recordProcessor___0x1B___processVariableMetaData(t_RECORD_VARIABLE_META_DATA*);
1303 *
1304 * PreCondition: None
1305 * Input: A t_RECORD_VARIABLE_META_DATA pointer reference
1306 * Output: A 1 is returned on success and a 0 is returned on failure
1307 * Overview: Processes the t_RECORD_VARIABLE_META_DATA record type
1308 * Note: More detailed information may be available in the PDF
1309 *******************************************************************/
1310 uint8_t recordProcessor___0x1B___processVariableMetaData(t_RECORD_VARIABLE_META_DATA *pRecord)
1311 {
1312 #if DEBUG_SILENT
1313 return SUCCESS;
1314 #else
1315 #if DEBUG_PROCESSING
1316 Serial.print(F("WriteByteOptionalPEC\n"));
1317 return SUCCESS;
1318 #else
1319 uint16_t newGlobalBaseAddress;
1320 uint16_t serialNumberToWrite;
1321 uint16_t readBackValueOfSerialNumber;
1322 #if DEBUG_PRINT
1323 Serial.print(F("WriteByteOptionalPEC\n"));
1324 #endif
1325
1326 switch (pRecord->metaDataType)
1327 {
1328 case META_SET_GLOBAL_BASE_ADDRESS:
1329 // Set the base address that will be used to talk to the system
1330 //print_debug_string("Setting the Global Base Address");
1331
1332 // Ensure that the device is responding
1333 smbusNoPec__->waitForAck(0x5B, 0x00);
1334
1335 // Un Write-Protect the device
1336 // This is a shorthand way of writing 0x00 [Write Protect Disabled] to register 0x10 [PMBus WRITE_PROTECT command register] of the device at address 0x5B with a PEC byte of 0xC0
1337 // This will work even if the device at 0x5B has PEC_REQUIRED enabled
1338 smbusNoPec__->writeWord(0x5B, 0x10, 0xC000);
1339
1340 // Write MFR_I2C_BASE_ADDRESS with supplied 16-bit word new global base address
1341 newGlobalBaseAddress = ((t_RECORD_META_SET_GLOBAL_BASE_ADDRESS *)pRecord)->globalBaseAddressInWordFormat;
1342 smbusNoPec__->writeWord(0x5B, 0xE6, newGlobalBaseAddress);
1343 return SUCCESS;
1344
1345 case META_OEM_SERIAL_NUMBER:
1346 // Serialization is not supported by any device other than the LTC2978 at this time
1347 // You should not execute this code unless your device supports serialization
1348 //print_debug_string("Setting the Serial Number for the Device [Only supported for the LTC2978");
1349
1350 // pSerialNumberDetails = (t_RECORD_META_OEM_SERIAL_NUMBER*) pRecord;
1351
1352 // Ensure the device is responding;
1353 // smbus_wait_for_ack(0x5B, 0x00);
1354
1355 // Un Write-Protect the device
1356 // This is a shorthand way of writing 0x00 [Write Protect Disabled] to register 0x10 [PMBus WRITE_PROTECT command register] of the device at address 0x5B with a PEC byte of 0xC0
1357 // This will work even if the device at 0x5B has PEC_REQUIRED enabled
1358 // smbus_write_word(0x5B, 0x10, 0xC000);
1359
1360 // Set the serial number details to the current device serial number, and increment the variable for the next device to be programmed
1361 // pSerialNumberDetails->serialNumber = device_serial_number++;
1362
1363 // Write serial number value (16bit word) to command code 0xF8 with PEC
1364 // serialNumberToWrite = pSerialNumberDetails->serialNumber;
1365 // smbus_write_word_with_pec(0x5B, 0xF8, serialNumberToWrite);
1366
1367 // Read back the serial number value (16bit word) from register 0xF8. PEC is not required for the read
1368 // readBackValueOfSerialNumber = smbus_read_word(0x5B, 0xF8);
1369
1370 // if(serialNumberToWrite != readBackValueOfSerialNumber)
1371 // {
1372 // return FAILURE; // What was written does not match what was read back
1373 // }
1374
1375 // If the code execution reaches this point, then the serial number has been written and verified successfully
1376 return SUCCESS;
1377 default:
1378 // This point should never be reached
1379 //print_debug_string("The META DATA type is not supported in your firmware. You will need to update your programming algorithms");
1380 return FAILURE;
1381 }
1382 #endif
1383 #endif
1384 }
1385
1386 /********************************************************************
1387 * Function: uint8_t recordProcessor___0x1C___modifyWordNoPEC(t_RECORD_PMBUS_MODIFY_BYTE_NO_PEC*);
1388 *
1389 * PreCondition: None
1390 * Input: A t_RECORD_PMBUS_MODIFY_BYTE_NO_PEC pointer reference
1391 * Output: A 1 is returned on success and a 0 is returned on failure
1392 * Overview: Processes the t_RECORD_PMBUS_MODIFY_BYTE_NO_PEC record type
1393 * Note: More detailed information may be available in the PDF
1394 *******************************************************************/
1395 uint8_t recordProcessor___0x1C___modifyWordNoPEC(t_RECORD_PMBUS_MODIFY_WORD_NO_PEC *pRecord)
1396 {
1397 #if DEBUG_SILENT
1398 return SUCCESS;
1399 #else
1400 #if DEBUG_PROCESSING
1401 Serial.print(F("modifyWordNoPec "));
1402 Serial.print(pRecord->detailedRecordHeader.DeviceAddress, HEX);
1403 Serial.print(F(" "));
1404 Serial.print(pRecord->detailedRecordHeader.CommandCode, HEX);
1405 Serial.print(F(" "));
1406 Serial.println(pRecord->desiredDataWord, HEX);
1407 #else
1408 uint16_t actualWordValue;
1409 uint16_t modifiedWordValue;
1410 #if DEBUG_PRINT
1411 Serial.print(F("modifyWordNoPec %x "));
1412 Serial.print(pRecord->detailedRecordHeader.DeviceAddress, HEX);
1413 Serial.print(F(" "));
1414 Serial.print(pRecord->detailedRecordHeader.CommandCode, HEX);
1415 Serial.print(F(" "));
1416 Serial.println(pRecord->desiredDataWord, HEX);
1417 #endif
1418 actualWordValue = smbusNoPec__->readWord((uint8_t) pRecord->detailedRecordHeader.DeviceAddress,
1419 pRecord->detailedRecordHeader.CommandCode);
1420
1421 modifiedWordValue = (actualWordValue & (~pRecord->wordMask));
1422 smbusNoPec__->writeWord((uint8_t) pRecord->detailedRecordHeader.DeviceAddress,
1423 pRecord->detailedRecordHeader.CommandCode,
1424 modifiedWordValue | (pRecord->desiredDataWord & pRecord->wordMask));
1425 #endif
1426 #endif
1427 return SUCCESS;
1428 }
1429
1430 /********************************************************************
1431 * Function: uint8_t recordProcessor___0x1D___modifyByteNoPEC(t_RECORD_PMBUS_MODIFY_BYTE*);
1432 *
1433 * PreCondition: None
1434 * Input: A t_RECORD_PMBUS_MODIFY_BYTE pointer reference
1435 * Output: A 1 is returned on success and a 0 is returned on failure
1436 * Overview: Processes the t_RECORD_PMBUS_MODIFY_BYTE record type
1437 * Note: More detailed information may be available in the PDF
1438 *******************************************************************/
1439 uint8_t recordProcessor___0x1D___modifyByteNoPEC(t_RECORD_PMBUS_MODIFY_BYTE_NO_PEC *pRecord)
1440 {
1441 #if DEBUG_SILENT
1442 return SUCCESS;
1443 #else
1444 #if DEBUG_PROCESSING
1445 Serial.print(F("modifyByteNoPEC "));
1446 Serial.print(pRecord->detailedRecordHeader.DeviceAddress, HEX);
1447 Serial.print(F(" "));
1448 Serial.print(pRecord->detailedRecordHeader.CommandCode, HEX);
1449 Serial.print(F(" "));
1450 Serial.println(pRecord->desiredDataByte, HEX);
1451 #else
1452 uint8_t actualByteValue;
1453 uint8_t modifiedByteValue;
1454 #if DEBUG_PRINT
1455 Serial.print(F("modifyByteNoPEC %x "));
1456 Serial.print(pRecord->detailedRecordHeader.DeviceAddress, HEX);
1457 Serial.print(F(" "));
1458 Serial.print(pRecord->detailedRecordHeader.CommandCode, HEX);
1459 Serial.print(F(" "));
1460 Serial.println(pRecord->desiredDataByte, HEX);
1461 #endif
1462 actualByteValue = smbusNoPec__->readByte((uint8_t) pRecord->detailedRecordHeader.DeviceAddress,
1463 pRecord->detailedRecordHeader.CommandCode);
1464
1465 modifiedByteValue = (actualByteValue & (~pRecord->byteMask));
1466 smbusNoPec__->writeByte((uint8_t) pRecord->detailedRecordHeader.DeviceAddress,
1467 pRecord->detailedRecordHeader.CommandCode,
1468 modifiedByteValue | (pRecord->desiredDataByte & pRecord->byteMask));
1469 #endif
1470 #endif
1471 return SUCCESS;
1472 }
1473
1474 /********************************************************************
1475 * Function: uint8_t recordProcessor___0x1E___writeNvmData(t_RECORD_NVM_DATA*);
1476 *
1477 * PreCondition: None
1478 * Input: A t_RECORD_NVM_DATA pointer reference
1479 * Output: A 1 is returned on success and a 0 is returned on failure
1480 * Overview: Processes the t_RECORD_NVM_DATA record type
1481 * Note: More detailed information may be available in the PDF
1482 *******************************************************************/
1483 uint8_t recordProcessor___0x1E___writeNvmData(t_RECORD_NVM_DATA *pRecord)
1484 {
1485 #if DEBUG_SILENT
1486 return SUCCESS;
1487 #else
1488 #if DEBUG_PROCESSING
1489 Serial.print(F("WriteNvmData\n"));
1490 return SUCCESS;
1491 #else
1492 #if DEBUG_PRINT
1493 Serial.print(F("WriteNvmData\n"));
1494 #endif
1495 return writeNvmData(pRecord);
1496 #endif
1497 #endif
1498 }
1499
1500 /********************************************************************
1501 * Function: uint8_t recordProcessor___0x1F___read_then_verifyNvmData(t_RECORD_NVM_DATA*);
1502 *
1503 * PreCondition: None
1504 * Input: A t_RECORD_NVM_DATA pointer reference
1505 * Output: A 1 is returned on success and a 0 is returned on failure
1506 * Overview: Processes the t_RECORD_NVM_DATA record type
1507 * Note: More detailed information may be available in the PDF
1508 *******************************************************************/
1509 uint8_t recordProcessor___0x1F___read_then_verifyNvmData(t_RECORD_NVM_DATA *pRecord)
1510 {
1511 #if DEBUG_SILENT
1512 return SUCCESS;
1513 #else
1514 #if DEBUG_PROCESSING
1515 Serial.print(F("read_then_verifyNvmData \n"));
1516 return SUCCESS;
1517 #else
1518 #if DEBUG_PRINT
1519 Serial.print(F("read_then_verifyNvmData \n"));
1520 #endif
1521 return readThenVerifyNvmData(pRecord);
1522 #endif
1523 #endif
1524 }
1525
1526 /********************************************************************
1527 * Function: uint8_t recordProcessor___0x20___modifyByteOptionalPEC(t_RECORD_PMBUS_MODIFY_BYTE*);
1528 *
1529 * PreCondition: None
1530 * Input: A t_RECORD_PMBUS_MODIFY_BYTE pointer reference
1531 * Output: A 1 is returned on success and a 0 is returned on failure
1532 * Overview: Processes the t_RECORD_PMBUS_MODIFY_BYTE record type
1533 * Note: More detailed information may be available in the PDF
1534 *******************************************************************/
1535 uint8_t recordProcessor___0x20___modifyByteOptionalPEC(t_RECORD_PMBUS_MODIFY_BYTE *pRecord)
1536 {
1537 #if DEBUG_SILENT
1538 return SUCCESS;
1539 #else
1540 #if DEBUG_PROCESSING
1541 Serial.print(F("modifyByteOptionalPEC "));
1542 Serial.print(pRecord->detailedRecordHeader.DeviceAddress, HEX);
1543 Serial.print(F(" "));
1544 Serial.print(pRecord->detailedRecordHeader.CommandCode, HEX);
1545 Serial.print(F(" "));
1546 Serial.println(pRecord->desiredDataByte, HEX);
1547 #else
1548 uint8_t actualByteValue;
1549 uint8_t modifiedByteValue;
1550 #if DEBUG_PRINT
1551 Serial.print(F("modifyByteOptionalPEC "));
1552 Serial.print(pRecord->detailedRecordHeader.DeviceAddress, HEX);
1553 Serial.print(F(" "));
1554 Serial.print(pRecord->detailedRecordHeader.CommandCode, HEX);
1555 Serial.print(F(" "));
1556 Serial.println(pRecord->desiredDataByte, HEX);
1557 #endif
1558 if (pRecord->detailedRecordHeader.UsePec)
1559 actualByteValue = smbusPec__->readByte((uint8_t) pRecord->detailedRecordHeader.DeviceAddress,
1560 pRecord->detailedRecordHeader.CommandCode);
1561 else
1562 actualByteValue = smbusNoPec__->readByte((uint8_t) pRecord->detailedRecordHeader.DeviceAddress,
1563 pRecord->detailedRecordHeader.CommandCode);
1564
1565 modifiedByteValue = (actualByteValue & (~pRecord->byteMask));
1566 if (pRecord->detailedRecordHeader.UsePec)
1567 smbusPec__->writeByte((uint8_t) pRecord->detailedRecordHeader.DeviceAddress,
1568 pRecord->detailedRecordHeader.CommandCode,
1569 modifiedByteValue | (pRecord->desiredDataByte & pRecord->byteMask));
1570 else
1571 smbusNoPec__->writeByte((uint8_t) pRecord->detailedRecordHeader.DeviceAddress,
1572 pRecord->detailedRecordHeader.CommandCode,
1573 modifiedByteValue | (pRecord->desiredDataByte & modifiedByteValue));
1574 #endif
1575 #endif
1576 return SUCCESS;
1577 }
1578
1579 /********************************************************************
1580 * Function: uint8_t recordProcessor___0x21___modifyWordOptionalPEC(t_RECORD_PMBUS_MODIFY_WORD*);
1581 *
1582 * PreCondition: None
1583 * Input: A t_RECORD_PMBUS_MODIFY_WORD pointer reference
1584 * Output: A 1 is returned on success and a 0 is returned on failure
1585 * Overview: Processes the t_RECORD_PMBUS_MODIFY_WORD record type
1586 * Note: More detailed information may be available in the PDF
1587 *******************************************************************/
1588 uint8_t recordProcessor___0x21___modifyWordOptionalPEC(t_RECORD_PMBUS_MODIFY_WORD *pRecord)
1589 {
1590 #if DEBUG_SILENT
1591 return SUCCESS;
1592 #else
1593 #if DEBUG_PROCESSING
1594 Serial.print(F("modifyWordOptionalPEC "));
1595 Serial.print(pRecord->detailedRecordHeader.DeviceAddress, HEX);
1596 Serial.print(F(" "));
1597 Serial.print(pRecord->detailedRecordHeader.CommandCode, HEX);
1598 Serial.print(F(" "));
1599 Serial.println(pRecord->desiredDataWord, HEX);
1600 #else
1601 uint16_t actualWordValue;
1602 uint16_t modifiedWordValue;
1603 #if DEBUG_PRINT
1604 Serial.print(F("modifyWordOptionalPEC %x "));
1605 Serial.print(pRecord->detailedRecordHeader.DeviceAddress, HEX);
1606 Serial.print(F(" "));
1607 Serial.print(pRecord->detailedRecordHeader.CommandCode, HEX);
1608 Serial.print(F(" "));
1609 Serial.println(pRecord->desiredDataWord, HEX);
1610 #endif
1611 if (pRecord->detailedRecordHeader.UsePec)
1612 actualWordValue = smbusPec__->readWord((uint8_t) pRecord->detailedRecordHeader.DeviceAddress,
1613 pRecord->detailedRecordHeader.CommandCode);
1614 else
1615 actualWordValue = smbusNoPec__->readWord((uint8_t) pRecord->detailedRecordHeader.DeviceAddress,
1616 pRecord->detailedRecordHeader.CommandCode);
1617
1618 modifiedWordValue = (actualWordValue & (~pRecord->wordMask));
1619 if (pRecord->detailedRecordHeader.UsePec)
1620 smbusPec__->writeWord((uint8_t) pRecord->detailedRecordHeader.DeviceAddress,
1621 pRecord->detailedRecordHeader.CommandCode,
1622 modifiedWordValue | (pRecord->desiredDataWord & pRecord->wordMask));
1623 else
1624 smbusNoPec__->writeWord((uint8_t) pRecord->detailedRecordHeader.DeviceAddress,
1625 pRecord->detailedRecordHeader.CommandCode,
1626 modifiedWordValue | (pRecord->desiredDataWord & pRecord->wordMask));
1627 #endif
1628 #endif
1629 return SUCCESS;
1630 }
t_RECORD_PMBUS_SEND_BYTE_NOPEC
Definition: record_type_definitions.h:492
recordProcessor___0x01___processWriteByteOptionalPEC
uint8_t recordProcessor___0x01___processWriteByteOptionalPEC(t_RECORD_PMBUS_WRITE_BYTE *)
PRIVATE PROTOTYPES RELATING TO RECORD TYPE PARSING.
Definition: main_record_processor.cpp:367
t_RECORD_PMBUS_POLL_READ_BYTE_UNTIL_ACK::detailedRecordHeader
tRecordHeaderAddressAndCommandWithoutPEC detailedRecordHeader
Definition: record_type_definitions.h:296
t_RECORD_PMBUS_POLL_READ_BYTE_UNTIL_ACK
Definition: record_type_definitions.h:293
t_RECORD_VARIABLE_META_DATA
Definition: record_type_definitions.h:597
tRecordHeader::Length
uint16_t Length
Definition: record_type_basic_definitions.h:54
t_RECORD_EVENT
Definition: record_type_definitions.h:512
t_RECORD_PMBUS_READ_WORD_EXPECT_NOPEC
Definition: record_type_definitions.h:419
recordProcessor___0x02___processWriteWordOptionalPEC
uint8_t recordProcessor___0x02___processWriteWordOptionalPEC(t_RECORD_PMBUS_WRITE_WORD *)
Definition: main_record_processor.cpp:412
SYSTEM_AFTER_VERIFY
#define SYSTEM_AFTER_VERIFY
Definition: record_type_definitions.h:540
RECORD_TYPE_PMBUS_SEND_BYTE_NOPEC
#define RECORD_TYPE_PMBUS_SEND_BYTE_NOPEC
Definition: record_type_definitions.h:491
t_RECORD_PMBUS_MODIFY_WORD::desiredDataWord
uint16_t desiredDataWord
Definition: record_type_definitions.h:759
LT_SMBusBase::sendByte
void sendByte(uint8_t address, uint8_t command)
SMBus send byte command.
Definition: LT_SMBusBase.cpp:508
recordProcessor___0x0A___processReadByteLoopMaskOptionalPEC
uint8_t recordProcessor___0x0A___processReadByteLoopMaskOptionalPEC(t_RECORD_PMBUS_READ_BYTE_LOOP_MASK *)
Definition: main_record_processor.cpp:587
tRecordHeaderAddressAndCommandWithoutPEC::DeviceAddress
uint16_t DeviceAddress
Definition: record_type_basic_definitions.h:67
recordProcessor___0x0F___processWriteByteNoPEC
uint8_t recordProcessor___0x0F___processWriteByteNoPEC(t_RECORD_PMBUS_WRITE_BYTE_NOPEC *)
Definition: main_record_processor.cpp:819
t_RECORD_PMBUS_READ_BYTE_EXPECT_NOPEC::expectedDataByte
uint8_t expectedDataByte
Definition: record_type_definitions.h:405
t_RECORD_PMBUS_READ_WORD_EXPECT::detailedRecordHeader
tRecordHeaderAddressAndCommandWithOptionalPEC detailedRecordHeader
Definition: record_type_definitions.h:173
RECORD_TYPE_PMBUS_WRITE_WORD_NOPEC
#define RECORD_TYPE_PMBUS_WRITE_WORD_NOPEC
Definition: record_type_definitions.h:368
recordProcessor___0x10___processWriteWordNoPEC
uint8_t recordProcessor___0x10___processWriteWordNoPEC(t_RECORD_PMBUS_WRITE_WORD_NOPEC *)
Definition: main_record_processor.cpp:857
t_RECORD_PMBUS_READ_WORD_LOOP_MASK_NOPEC::detailedRecordHeader
tRecordHeaderAddressAndCommandWithoutPEC detailedRecordHeader
Definition: record_type_definitions.h:476
t_RECORD_PMBUS_READ_BYTE_LOOP_MASK
Definition: record_type_definitions.h:248
LT_SMBusBase::writeWord
void writeWord(uint8_t address, uint8_t command, uint16_t data)
SMBus write word command.
Definition: LT_SMBusBase.cpp:265
t_RECORD_META_SET_GLOBAL_BASE_ADDRESS
Definition: record_type_definitions.h:608
t_RECORD_PMBUS_READ_BYTE_EXPECT_NOPEC
Definition: record_type_definitions.h:401
tRecordHeaderAddressAndCommandWithOptionalPEC::DeviceAddress
uint16_t DeviceAddress
Definition: record_type_basic_definitions.h:60
t_RECORD_PMBUS_READ_WORD_LOOP_MASK::detailedRecordHeader
tRecordHeaderAddressAndCommandWithOptionalPEC detailedRecordHeader
Definition: record_type_definitions.h:270
nWords
static uint16_t nWords
Definition: nvm_data_helpers.cpp:48
main_record_processor.h
Copyright 2018(c) Analog Devices, Inc.
t_RECORD_PMBUS_READ_WORD_LOOP_MASK::expectedDataWord
uint16_t expectedDataWord
Definition: record_type_definitions.h:272
t_RECORD_PMBUS_READ_BYTE_EXPECT_MASK_NOPEC
Definition: record_type_definitions.h:553
t_RECORD_PMBUS_MODIFY_BYTE
Definition: record_type_definitions.h:730
t_RECORD_PMBUS_MODIFY_WORD::wordMask
uint16_t wordMask
Definition: record_type_definitions.h:758
t_RECORD_PMBUS_READ_BYTE_LOOP_MASK::byteMask
uint8_t byteMask
Definition: record_type_definitions.h:252
t_RECORD_PMBUS_SEND_BYTE::detailedRecordHeader
tRecordHeaderAddressAndCommandWithOptionalPEC detailedRecordHeader
Definition: record_type_definitions.h:337
t_RECORD_PMBUS_READ_WORD_EXPECT
Definition: record_type_definitions.h:170
t_RECORD_PMBUS_MODIFY_BYTE_NO_PEC::detailedRecordHeader
tRecordHeaderAddressAndCommandWithOptionalPEC detailedRecordHeader
Definition: record_type_definitions.h:669
t_RECORD_PMBUS_READ_WORD_LOOP_MASK_NOPEC::wordMask
uint16_t wordMask
Definition: record_type_definitions.h:477
t_RECORD_PMBUS_SEND_BYTE
Definition: record_type_definitions.h:334
FAILURE
#define FAILURE
Definition: LT_PMBus.h:63
RECORD_TYPE_PMBUS_READ_BLOCK_EXPECT_NOPEC
#define RECORD_TYPE_PMBUS_READ_BLOCK_EXPECT_NOPEC
Definition: record_type_definitions.h:437
t_RECORD_PMBUS_MODIFY_BYTE::detailedRecordHeader
tRecordHeaderAddressAndCommandWithOptionalPEC detailedRecordHeader
Definition: record_type_definitions.h:733
LT_SMBusBase::writeByte
void writeByte(uint8_t address, uint8_t command, uint8_t data)
SMBus write byte command.
Definition: LT_SMBusBase.cpp:177
RECORD_TYPE_PMBUS_MODIFY_BYTE
#define RECORD_TYPE_PMBUS_MODIFY_BYTE
Definition: record_type_definitions.h:729
tRecordHeader::RecordType
uint16_t RecordType
Definition: record_type_basic_definitions.h:55
t_RECORD_NVM_DATA::baseRecordHeader
tRecordHeaderLengthAndType baseRecordHeader
Definition: record_type_definitions.h:236
RECORD_TYPE_EVENT
#define RECORD_TYPE_EVENT
Definition: record_type_definitions.h:511
RECORD_TYPE_PMBUS_READ_WORD_EXPECT
#define RECORD_TYPE_PMBUS_READ_WORD_EXPECT
Definition: record_type_definitions.h:169
t_RECORD_PMBUS_READ_BYTE_EXPECT
Definition: record_type_definitions.h:152
t_RECORD_PMBUS_READ_BYTE_LOOP_MASK::expectedDataByte
uint8_t expectedDataByte
Definition: record_type_definitions.h:253
verifyRecordsOnDemand
uint8_t verifyRecordsOnDemand(pRecordHeaderLengthAndType(*getRecord)(void))
Definition: main_record_processor.cpp:224
BEFORE_INSYSTEM_PROGRAMMING_BEGIN
#define BEFORE_INSYSTEM_PROGRAMMING_BEGIN
Definition: record_type_definitions.h:534
recordProcessor___0x0E___processSendByteOptionalPEC
uint8_t recordProcessor___0x0E___processSendByteOptionalPEC(t_RECORD_PMBUS_SEND_BYTE *)
Definition: main_record_processor.cpp:782
RECORD_TYPE_DELAY_MS
#define RECORD_TYPE_DELAY_MS
Definition: record_type_definitions.h:314
t_RECORD_PMBUS_READ_WORD_LOOP_MASK
Definition: record_type_definitions.h:267
t_RECORD_PMBUS_WRITE_WORD_NOPEC::detailedRecordHeader
tRecordHeaderAddressAndCommandWithoutPEC detailedRecordHeader
Definition: record_type_definitions.h:372
recordProcessor___0x18___processEvent
uint8_t recordProcessor___0x18___processEvent(t_RECORD_EVENT *)
Definition: main_record_processor.cpp:1114
RECORD_TYPE_PMBUS_READ_BYTE_EXPECT
#define RECORD_TYPE_PMBUS_READ_BYTE_EXPECT
Definition: record_type_definitions.h:151
RECORD_TYPE_PMBUS_READ_BYTE_EXPECT_MASK_NOPEC
#define RECORD_TYPE_PMBUS_READ_BYTE_EXPECT_MASK_NOPEC
Definition: record_type_definitions.h:552
RECORD_TYPE_PMBUS_MODIFY_WORD
#define RECORD_TYPE_PMBUS_MODIFY_WORD
Definition: record_type_definitions.h:753
ignore_records
static bool ignore_records
Definition: main_record_processor.cpp:79
bufferNvmData
uint8_t bufferNvmData(t_RECORD_NVM_DATA *pRecord)
Definition: nvm_data_helpers.cpp:120
recordProcessor___0x1E___writeNvmData
uint8_t recordProcessor___0x1E___writeNvmData(t_RECORD_NVM_DATA *)
Definition: main_record_processor.cpp:1483
t_RECORD_PMBUS_MODIFY_WORD_NO_PEC::detailedRecordHeader
tRecordHeaderAddressAndCommandWithOptionalPEC detailedRecordHeader
Definition: record_type_definitions.h:645
RECORD_TYPE_PMBUS_READ_BYTE_LOOP_MASK
#define RECORD_TYPE_PMBUS_READ_BYTE_LOOP_MASK
Definition: record_type_definitions.h:247
t_RECORD_PMBUS_WRITE_WORD_NOPEC::dataWord
uint16_t dataWord
Definition: record_type_definitions.h:373
RECORD_TYPE_PMBUS_READ_AND_VERIFY_EE_DATA
#define RECORD_TYPE_PMBUS_READ_AND_VERIFY_EE_DATA
Definition: record_type_definitions.h:705
recordProcessor___0x1D___modifyByteNoPEC
uint8_t recordProcessor___0x1D___modifyByteNoPEC(t_RECORD_PMBUS_MODIFY_BYTE_NO_PEC *)
Definition: main_record_processor.cpp:1439
META_SET_GLOBAL_BASE_ADDRESS
#define META_SET_GLOBAL_BASE_ADDRESS
Definition: record_type_definitions.h:607
INSYSTEM_CHIP_BEFORE_VERIFY
#define INSYSTEM_CHIP_BEFORE_VERIFY
Definition: record_type_definitions.h:538
recordProcessor___0x0B___processReadWordLoopMaskOptionalPEC
uint8_t recordProcessor___0x0B___processReadWordLoopMaskOptionalPEC(t_RECORD_PMBUS_READ_WORD_LOOP_MASK *)
Definition: main_record_processor.cpp:646
t_RECORD_DELAY_MS::numMs
uint16_t numMs
Definition: record_type_definitions.h:318
RECORD_TYPE_PACKING_CODE
#define RECORD_TYPE_PACKING_CODE
Definition: record_type_definitions.h:214
t_RECORD_PMBUS_WRITE_BYTE::dataByte
uint8_t dataByte
Definition: record_type_definitions.h:107
t_RECORD_PMBUS_MODIFY_WORD_NO_PEC::desiredDataWord
uint16_t desiredDataWord
Definition: record_type_definitions.h:647
RECORD_TYPE_PMBUS_READ_BLOCK_EXPECT
#define RECORD_TYPE_PMBUS_READ_BLOCK_EXPECT
Definition: record_type_definitions.h:188
recordProcessor___0x09___bufferNVMData
uint8_t recordProcessor___0x09___bufferNVMData(t_RECORD_NVM_DATA *)
Definition: main_record_processor.cpp:545
RECORD_TYPE_PMBUS_SEND_BYTE
#define RECORD_TYPE_PMBUS_SEND_BYTE
Definition: record_type_definitions.h:333
t_RECORD_PMBUS_WRITE_WORD::detailedRecordHeader
tRecordHeaderAddressAndCommandWithOptionalPEC detailedRecordHeader
Definition: record_type_definitions.h:124
recordProcessor___0x19___processReadByteExpectMaskNoPEC
uint8_t recordProcessor___0x19___processReadByteExpectMaskNoPEC(t_RECORD_PMBUS_READ_BYTE_EXPECT_MASK_NOPEC *)
Definition: main_record_processor.cpp:1209
t_RECORD_PMBUS_SEND_BYTE_NOPEC::detailedRecordHeader
tRecordHeaderAddressAndCommandWithoutPEC detailedRecordHeader
Definition: record_type_definitions.h:495
tRecordHeaderAddressAndCommandWithOptionalPEC::CommandCode
uint8_t CommandCode
Definition: record_type_basic_definitions.h:61
t_RECORD_PMBUS_WRITE_WORD::dataWord
uint16_t dataWord
Definition: record_type_definitions.h:125
recordProcessor___0x1A___processReadWordExpectMaskNoPEC
uint8_t recordProcessor___0x1A___processReadWordExpectMaskNoPEC(t_RECORD_PMBUS_READ_WORD_EXPECT_MASK_NOPEC *)
Definition: main_record_processor.cpp:1256
t_RECORD_PMBUS_MODIFY_BYTE::desiredDataByte
uint8_t desiredDataByte
Definition: record_type_definitions.h:735
RECORD_TYPE_PMBUS_WRITE_BLOCK_NOPEC
#define RECORD_TYPE_PMBUS_WRITE_BLOCK_NOPEC
Definition: record_type_definitions.h:388
RECORD_TYPE_NVM_DATA
#define RECORD_TYPE_NVM_DATA
Definition: record_type_definitions.h:233
t_RECORD_PMBUS_MODIFY_WORD
Definition: record_type_definitions.h:754
t_RECORD_PMBUS_MODIFY_BYTE_NO_PEC
Definition: record_type_definitions.h:666
RECORD_TYPE_PMBUS_WRITE_BLOCK
#define RECORD_TYPE_PMBUS_WRITE_BLOCK
Definition: record_type_definitions.h:139
INSYSTEM_CHIP_AFTER_VERIFY
#define INSYSTEM_CHIP_AFTER_VERIFY
Definition: record_type_definitions.h:539
t_RECORD_PMBUS_WRITE_BYTE_NOPEC::dataByte
uint8_t dataByte
Definition: record_type_definitions.h:355
LT_SMBusBase::readByte
uint8_t readByte(uint8_t address, uint8_t command)
SMBus read byte command.
Definition: LT_SMBusBase.cpp:234
recordProcessor___0x0D___processDelayMs
uint8_t recordProcessor___0x0D___processDelayMs(t_RECORD_DELAY_MS *)
Definition: main_record_processor.cpp:743
t_RECORD_PMBUS_READ_BYTE_LOOP_MASK_NOPEC::detailedRecordHeader
tRecordHeaderAddressAndCommandWithoutPEC detailedRecordHeader
Definition: record_type_definitions.h:455
tRecordHeaderAddressAndCommandWithoutPEC::CommandCode
uint8_t CommandCode
Definition: record_type_basic_definitions.h:68
recordProcessor___0x1F___read_then_verifyNvmData
uint8_t recordProcessor___0x1F___read_then_verifyNvmData(t_RECORD_NVM_DATA *)
Definition: main_record_processor.cpp:1509
t_RECORD_PMBUS_READ_BYTE_EXPECT_MASK_NOPEC::detailedRecordHeader
tRecordHeaderAddressAndCommandWithoutPEC detailedRecordHeader
Definition: record_type_definitions.h:556
RECORD_TYPE_PMBUS_WRITE_WORD
#define RECORD_TYPE_PMBUS_WRITE_WORD
Definition: record_type_definitions.h:120
RECORD_TYPE_PMBUS_WRITE_BYTE
#define RECORD_TYPE_PMBUS_WRITE_BYTE
Definition: record_type_definitions.h:102
t_RECORD_PMBUS_READ_BYTE_LOOP_MASK_NOPEC
Definition: record_type_definitions.h:452
RECORD_TYPE_PMBUS_WRITE_EE_DATA
#define RECORD_TYPE_PMBUS_WRITE_EE_DATA
Definition: record_type_definitions.h:687
recordProcessor___0x15___processReadByteLoopMaskNoPEC
uint8_t recordProcessor___0x15___processReadByteLoopMaskNoPEC(t_RECORD_PMBUS_READ_BYTE_LOOP_MASK_NOPEC *)
Definition: main_record_processor.cpp:974
t_RECORD_PMBUS_READ_WORD_EXPECT_MASK_NOPEC::expectedDataWord
uint16_t expectedDataWord
Definition: record_type_definitions.h:579
RECORD_TYPE_PMBUS_POLL_UNTIL_ACK_NOPEC
#define RECORD_TYPE_PMBUS_POLL_UNTIL_ACK_NOPEC
Definition: record_type_definitions.h:292
t_RECORD_PMBUS_READ_BYTE_LOOP_MASK::detailedRecordHeader
tRecordHeaderAddressAndCommandWithOptionalPEC detailedRecordHeader
Definition: record_type_definitions.h:251
RECORD_TYPE_MODIFY_WORD_NOPEC
#define RECORD_TYPE_MODIFY_WORD_NOPEC
Definition: record_type_definitions.h:641
t_RECORD_PMBUS_READ_BYTE_LOOP_MASK_NOPEC::byteMask
uint8_t byteMask
Definition: record_type_definitions.h:456
recordProcessor___0x1B___processVariableMetaData
uint8_t recordProcessor___0x1B___processVariableMetaData(t_RECORD_VARIABLE_META_DATA *)
Definition: main_record_processor.cpp:1310
SYSTEM_BEFORE_VERIFY
#define SYSTEM_BEFORE_VERIFY
Definition: record_type_definitions.h:537
words
static uint16_t * words
Definition: nvm_data_helpers.cpp:47
hex_file_parser.h
Copyright 2018(c) Analog Devices, Inc.
t_RECORD_DELAY_MS
Definition: record_type_definitions.h:315
t_RECORD_PMBUS_MODIFY_WORD_NO_PEC
Definition: record_type_definitions.h:642
t_RECORD_PMBUS_READ_WORD_EXPECT_MASK_NOPEC::wordMask
uint16_t wordMask
Definition: record_type_definitions.h:580
t_RECORD_PMBUS_READ_BYTE_LOOP_MASK_NOPEC::expectedDataByte
uint8_t expectedDataByte
Definition: record_type_definitions.h:457
recordProcessor___0x05___processReadWordExpectOptionalPEC
uint8_t recordProcessor___0x05___processReadWordExpectOptionalPEC(t_RECORD_PMBUS_READ_WORD_EXPECT *)
Definition: main_record_processor.cpp:500
smbusPec__
LT_SMBusPec * smbusPec__
Definition: nvm.cpp:55
recordProcessor___0x04___processReadByteExpectOptionalPEC
uint8_t recordProcessor___0x04___processReadByteExpectOptionalPEC(t_RECORD_PMBUS_READ_BYTE_EXPECT *)
Definition: main_record_processor.cpp:455
recordProcessor___0x1C___modifyWordNoPEC
uint8_t recordProcessor___0x1C___modifyWordNoPEC(t_RECORD_PMBUS_MODIFY_WORD_NO_PEC *)
Definition: main_record_processor.cpp:1395
t_RECORD_PMBUS_READ_WORD_EXPECT_NOPEC::detailedRecordHeader
tRecordHeaderAddressAndCommandWithoutPEC detailedRecordHeader
Definition: record_type_definitions.h:422
RECORD_TYPE_PMBUS_READ_WORD_LOOP_MASK_NOPEC
#define RECORD_TYPE_PMBUS_READ_WORD_LOOP_MASK_NOPEC
Definition: record_type_definitions.h:472
processRecordsOnDemand
uint8_t processRecordsOnDemand(pRecordHeaderLengthAndType(*getRecord)(void))
Definition: main_record_processor.cpp:91
RECORD_TYPE_PMBUS_READ_WORD_EXPECT_MASK_NOPEC
#define RECORD_TYPE_PMBUS_READ_WORD_EXPECT_MASK_NOPEC
Definition: record_type_definitions.h:574
RECORD_TYPE_PMBUS_READ_WORD_EXPECT_NOPEC
#define RECORD_TYPE_PMBUS_READ_WORD_EXPECT_NOPEC
Definition: record_type_definitions.h:418
t_RECORD_PMBUS_READ_WORD_EXPECT_NOPEC::expectedDataWord
uint16_t expectedDataWord
Definition: record_type_definitions.h:423
SYSTEM_BEFORE_PROGRAM
#define SYSTEM_BEFORE_PROGRAM
Definition: record_type_definitions.h:535
t_RECORD_PMBUS_MODIFY_BYTE_NO_PEC::byteMask
uint8_t byteMask
Definition: record_type_definitions.h:670
t_RECORD_PMBUS_READ_WORD_LOOP_MASK_NOPEC
Definition: record_type_definitions.h:473
recordProcessor___0x12___processReadByteExpectNoPEC
uint8_t recordProcessor___0x12___processReadByteExpectNoPEC(t_RECORD_PMBUS_READ_BYTE_EXPECT_NOPEC *)
Definition: main_record_processor.cpp:895
t_RECORD_PMBUS_READ_BYTE_EXPECT::detailedRecordHeader
tRecordHeaderAddressAndCommandWithOptionalPEC detailedRecordHeader
Definition: record_type_definitions.h:155
t_RECORD_PMBUS_MODIFY_WORD::detailedRecordHeader
tRecordHeaderAddressAndCommandWithOptionalPEC detailedRecordHeader
Definition: record_type_definitions.h:757
BEFORE_BEGIN
#define BEFORE_BEGIN
Definition: record_type_definitions.h:533
t_RECORD_NVM_DATA
Definition: record_type_definitions.h:234
RECORD_TYPE_PMBUS_READ_BYTE_EXPECT_NOPEC
#define RECORD_TYPE_PMBUS_READ_BYTE_EXPECT_NOPEC
Definition: record_type_definitions.h:400
t_RECORD_PMBUS_READ_BYTE_EXPECT_MASK_NOPEC::expectedDataByte
uint8_t expectedDataByte
Definition: record_type_definitions.h:557
recordProcessor___0x0C___processPollReadByteUntilAckNoPEC
uint8_t recordProcessor___0x0C___processPollReadByteUntilAckNoPEC(t_RECORD_PMBUS_POLL_READ_BYTE_UNTIL_ACK *)
Definition: main_record_processor.cpp:703
RECORD_TYPE_DEVICE_ADDRESS
#define RECORD_TYPE_DEVICE_ADDRESS
Definition: record_type_definitions.h:201
t_RECORD_NVM_DATA::detailedRecordHeader
tRecordHeaderAddressAndCommandWithOptionalPEC detailedRecordHeader
Definition: record_type_definitions.h:237
t_RECORD_PMBUS_READ_WORD_EXPECT::expectedDataWord
uint16_t expectedDataWord
Definition: record_type_definitions.h:174
t_RECORD_PMBUS_READ_BYTE_EXPECT_MASK_NOPEC::byteMask
uint8_t byteMask
Definition: record_type_definitions.h:558
INSYSTEM_CHIP_BEFORE_PROGRAM
#define INSYSTEM_CHIP_BEFORE_PROGRAM
Definition: record_type_definitions.h:536
recordProcessor___0x20___modifyByteOptionalPEC
uint8_t recordProcessor___0x20___modifyByteOptionalPEC(t_RECORD_PMBUS_MODIFY_BYTE *)
Definition: main_record_processor.cpp:1535
writeNvmData
uint8_t writeNvmData(t_RECORD_NVM_DATA *pRecord)
Definition: nvm_data_helpers.cpp:76
t_RECORD_PMBUS_MODIFY_BYTE_NO_PEC::desiredDataByte
uint8_t desiredDataByte
Definition: record_type_definitions.h:671
RECORD_TYPE_PMBUS_READ_WORD_LOOP_MASK
#define RECORD_TYPE_PMBUS_READ_WORD_LOOP_MASK
Definition: record_type_definitions.h:266
t_RECORD_PMBUS_READ_WORD_LOOP_MASK::wordMask
uint16_t wordMask
Definition: record_type_definitions.h:271
t_RECORD_PMBUS_WRITE_WORD_NOPEC
Definition: record_type_definitions.h:369
SUCCESS
#define SUCCESS
Definition: LT_PMBus.h:62
t_RECORD_EVENT::eventId
uint16_t eventId
Definition: record_type_definitions.h:515
tRecordHeader
Basic Record Type Definitions.
Definition: record_type_basic_definitions.h:52
recordProcessor___0x16___processReadWordLoopMaskNoPEC
uint8_t recordProcessor___0x16___processReadWordLoopMaskNoPEC(t_RECORD_PMBUS_READ_WORD_LOOP_MASK_NOPEC *)
Definition: main_record_processor.cpp:1027
t_RECORD_PMBUS_MODIFY_WORD_NO_PEC::wordMask
uint16_t wordMask
Definition: record_type_definitions.h:646
t_RECORD_PMBUS_MODIFY_BYTE::byteMask
uint8_t byteMask
Definition: record_type_definitions.h:734
RECORD_TYPE_PMBUS_WRITE_BYTE_NOPEC
#define RECORD_TYPE_PMBUS_WRITE_BYTE_NOPEC
Definition: record_type_definitions.h:350
t_RECORD_PMBUS_READ_WORD_LOOP_MASK_NOPEC::expectedDataWord
uint16_t expectedDataWord
Definition: record_type_definitions.h:478
RECORD_TYPE_MODIFY_BYTE_NOPEC
#define RECORD_TYPE_MODIFY_BYTE_NOPEC
Definition: record_type_definitions.h:665
t_RECORD_PMBUS_READ_WORD_EXPECT_MASK_NOPEC::detailedRecordHeader
tRecordHeaderAddressAndCommandWithoutPEC detailedRecordHeader
Definition: record_type_definitions.h:578
t_RECORD_PMBUS_WRITE_BYTE_NOPEC
Definition: record_type_definitions.h:351
i
static int i
Definition: DC2430A.ino:184
t_RECORD_PMBUS_WRITE_BYTE_NOPEC::detailedRecordHeader
tRecordHeaderAddressAndCommandWithoutPEC detailedRecordHeader
Definition: record_type_definitions.h:354
t_RECORD_PMBUS_READ_WORD_EXPECT_MASK_NOPEC
Definition: record_type_definitions.h:575
t_RECORD_PMBUS_WRITE_BYTE::detailedRecordHeader
tRecordHeaderAddressAndCommandWithOptionalPEC detailedRecordHeader
Definition: record_type_definitions.h:106
RECORD_TYPE_VARIABLE_META_DATA
#define RECORD_TYPE_VARIABLE_META_DATA
Definition: record_type_definitions.h:596
t_RECORD_PMBUS_WRITE_BYTE
Definition: record_type_definitions.h:103
t_RECORD_VARIABLE_META_DATA::metaDataType
uint16_t metaDataType
Definition: record_type_definitions.h:600
t_RECORD_PMBUS_READ_BYTE_EXPECT_NOPEC::detailedRecordHeader
tRecordHeaderAddressAndCommandWithoutPEC detailedRecordHeader
Definition: record_type_definitions.h:404
t_RECORD_PMBUS_READ_BYTE_EXPECT::expectedDataByte
uint8_t expectedDataByte
Definition: record_type_definitions.h:156
t_RECORD_PMBUS_WRITE_WORD
Definition: record_type_definitions.h:121
smbusNoPec__
LT_SMBusNoPec * smbusNoPec__
Definition: nvm.cpp:54
AFTER_DONE
#define AFTER_DONE
Definition: record_type_definitions.h:541
RECORD_TYPE_PMBUS_READ_BYTE_LOOP_MASK_NOPEC
#define RECORD_TYPE_PMBUS_READ_BYTE_LOOP_MASK_NOPEC
Definition: record_type_definitions.h:451
readThenVerifyNvmData
uint8_t readThenVerifyNvmData(t_RECORD_NVM_DATA *pRecord)
Definition: nvm_data_helpers.cpp:132
META_OEM_SERIAL_NUMBER
#define META_OEM_SERIAL_NUMBER
Definition: record_type_definitions.h:619
recordProcessor___0x17___processSendByteNoPEC
uint8_t recordProcessor___0x17___processSendByteNoPEC(t_RECORD_PMBUS_SEND_BYTE_NOPEC *)
Definition: main_record_processor.cpp:1081
tRecordHeaderAddressAndCommandWithOptionalPEC::UsePec
uint8_t UsePec
Definition: record_type_basic_definitions.h:62
recordProcessor___0x21___modifyWordOptionalPEC
uint8_t recordProcessor___0x21___modifyWordOptionalPEC(t_RECORD_PMBUS_MODIFY_WORD *)
Definition: main_record_processor.cpp:1588
recordProcessor___0x13___processReadWordExpectNoPEC
uint8_t recordProcessor___0x13___processReadWordExpectNoPEC(t_RECORD_PMBUS_READ_WORD_EXPECT_NOPEC *)
Definition: main_record_processor.cpp:934
verification_in_progress
static bool verification_in_progress
VARIABLES.
Definition: main_record_processor.cpp:78
RECORD_TYPE_END_OF_RECORDS
#define RECORD_TYPE_END_OF_RECORDS
Definition: record_type_definitions.h:768
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