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 ************/
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  *******************************************************************/
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;
114  successful_parse_of_record_type = recordProcessor___0x04___processReadByteExpectOptionalPEC( (t_RECORD_PMBUS_READ_BYTE_EXPECT *) record_to_process);
115  break;
117  successful_parse_of_record_type = recordProcessor___0x05___processReadWordExpectOptionalPEC( (t_RECORD_PMBUS_READ_WORD_EXPECT *) record_to_process);
118  break;
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;
132  successful_parse_of_record_type = recordProcessor___0x0A___processReadByteLoopMaskOptionalPEC( (t_RECORD_PMBUS_READ_BYTE_LOOP_MASK *) record_to_process);
133  break;
135  successful_parse_of_record_type = recordProcessor___0x0B___processReadWordLoopMaskOptionalPEC( (t_RECORD_PMBUS_READ_WORD_LOOP_MASK *) record_to_process);
136  break;
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;
147  successful_parse_of_record_type = recordProcessor___0x0F___processWriteByteNoPEC( (t_RECORD_PMBUS_WRITE_BYTE_NOPEC *) record_to_process);
148  break;
150  successful_parse_of_record_type = recordProcessor___0x10___processWriteWordNoPEC( (t_RECORD_PMBUS_WRITE_WORD_NOPEC *) record_to_process);
151  break;
153  successful_parse_of_record_type = FAILURE; // Unsupported Record Type
154  break;
156  successful_parse_of_record_type = recordProcessor___0x12___processReadByteExpectNoPEC( (t_RECORD_PMBUS_READ_BYTE_EXPECT_NOPEC *) record_to_process);
157  break;
159  successful_parse_of_record_type = recordProcessor___0x13___processReadWordExpectNoPEC( (t_RECORD_PMBUS_READ_WORD_EXPECT_NOPEC *) record_to_process);
160  break;
162  successful_parse_of_record_type = FAILURE; // Unsupported Record Type
163  break;
165  successful_parse_of_record_type = recordProcessor___0x15___processReadByteLoopMaskNoPEC( (t_RECORD_PMBUS_READ_BYTE_LOOP_MASK_NOPEC *) record_to_process);
166  break;
168  successful_parse_of_record_type = recordProcessor___0x16___processReadWordLoopMaskNoPEC( (t_RECORD_PMBUS_READ_WORD_LOOP_MASK_NOPEC *) record_to_process);
169  break;
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;
177  successful_parse_of_record_type = recordProcessor___0x19___processReadByteExpectMaskNoPEC( (t_RECORD_PMBUS_READ_BYTE_EXPECT_MASK_NOPEC *) record_to_process);
178  break;
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;
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  *******************************************************************/
225 {
226  pRecordHeaderLengthAndType record_to_process;
227 
228  uint16_t recordType_of_record_to_process;
229  uint8_t successful_parse_of_record_type = SUCCESS;
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;
252  successful_parse_of_record_type = recordProcessor___0x04___processReadByteExpectOptionalPEC( (t_RECORD_PMBUS_READ_BYTE_EXPECT *) record_to_process);
253  break;
255  successful_parse_of_record_type = recordProcessor___0x05___processReadWordExpectOptionalPEC( (t_RECORD_PMBUS_READ_WORD_EXPECT *) record_to_process);
256  break;
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;
267  successful_parse_of_record_type = recordProcessor___0x0A___processReadByteLoopMaskOptionalPEC( (t_RECORD_PMBUS_READ_BYTE_LOOP_MASK *) record_to_process);
268  break;
270  successful_parse_of_record_type = recordProcessor___0x0B___processReadWordLoopMaskOptionalPEC( (t_RECORD_PMBUS_READ_WORD_LOOP_MASK *) record_to_process);
271  break;
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;
282  successful_parse_of_record_type = recordProcessor___0x0F___processWriteByteNoPEC( (t_RECORD_PMBUS_WRITE_BYTE_NOPEC *) record_to_process);
283  break;
285  successful_parse_of_record_type = recordProcessor___0x10___processWriteWordNoPEC( (t_RECORD_PMBUS_WRITE_WORD_NOPEC *) record_to_process);
286  break;
288  successful_parse_of_record_type = FAILURE; // Unsupported Record Type
289  break;
291  successful_parse_of_record_type = recordProcessor___0x12___processReadByteExpectNoPEC( (t_RECORD_PMBUS_READ_BYTE_EXPECT_NOPEC *) record_to_process);
292  break;
294  successful_parse_of_record_type = recordProcessor___0x13___processReadWordExpectNoPEC( (t_RECORD_PMBUS_READ_WORD_EXPECT_NOPEC *) record_to_process);
295  break;
297  successful_parse_of_record_type = FAILURE; // Unsupported Record Type
298  break;
300  successful_parse_of_record_type = recordProcessor___0x15___processReadByteLoopMaskNoPEC( (t_RECORD_PMBUS_READ_BYTE_LOOP_MASK_NOPEC *) record_to_process);
301  break;
303  successful_parse_of_record_type = recordProcessor___0x16___processReadWordLoopMaskNoPEC( (t_RECORD_PMBUS_READ_WORD_LOOP_MASK_NOPEC *) record_to_process);
304  break;
306  successful_parse_of_record_type = recordProcessor___0x17___processSendByteNoPEC( (t_RECORD_PMBUS_SEND_BYTE_NOPEC *) record_to_process);
307  break;
309  successful_parse_of_record_type = recordProcessor___0x19___processReadByteExpectMaskNoPEC( (t_RECORD_PMBUS_READ_BYTE_EXPECT_MASK_NOPEC *) record_to_process);
310  break;
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;
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  *******************************************************************/
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)
393  pRecord->dataByte);
394  else
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  *******************************************************************/
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)
436  pRecord->dataWord);
437  else
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  *******************************************************************/
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,
471  else
472  actualByteValue = smbusNoPec__->readByte((uint8_t) pRecord->detailedRecordHeader.DeviceAddress,
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  *******************************************************************/
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,
516  else
517  actualWordValue = smbusNoPec__->readWord((uint8_t) pRecord->detailedRecordHeader.DeviceAddress,
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  *******************************************************************/
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  *******************************************************************/
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,
609  else
610  actualByteValue = smbusNoPec__->readByte((uint8_t) pRecord->detailedRecordHeader.DeviceAddress,
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  *******************************************************************/
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,
668  else
669  actualWordValue = smbusNoPec__->readWord((uint8_t) pRecord->detailedRecordHeader.DeviceAddress,
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  *******************************************************************/
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,
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  *******************************************************************/
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  *******************************************************************/
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)
802  else
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  *******************************************************************/
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
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  *******************************************************************/
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
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  *******************************************************************/
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,
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  *******************************************************************/
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,
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  *******************************************************************/
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,
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  *******************************************************************/
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,
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  *******************************************************************/
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
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  *******************************************************************/
1115 {
1116  switch (pRecord->eventId)
1117  {
1118  case BEFORE_BEGIN:
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;
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:
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;
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:
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;
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;
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:
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  *******************************************************************/
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,
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  *******************************************************************/
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,
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  *******************************************************************/
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  {
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 
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  *******************************************************************/
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,
1420 
1421  modifiedWordValue = (actualWordValue & (~pRecord->wordMask));
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  *******************************************************************/
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,
1464 
1465  modifiedByteValue = (actualByteValue & (~pRecord->byteMask));
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  *******************************************************************/
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  *******************************************************************/
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  *******************************************************************/
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,
1561  else
1562  actualByteValue = smbusNoPec__->readByte((uint8_t) pRecord->detailedRecordHeader.DeviceAddress,
1564 
1565  modifiedByteValue = (actualByteValue & (~pRecord->byteMask));
1566  if (pRecord->detailedRecordHeader.UsePec)
1569  modifiedByteValue | (pRecord->desiredDataByte & pRecord->byteMask));
1570  else
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  *******************************************************************/
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,
1614  else
1615  actualWordValue = smbusNoPec__->readWord((uint8_t) pRecord->detailedRecordHeader.DeviceAddress,
1617 
1618  modifiedWordValue = (actualWordValue & (~pRecord->wordMask));
1619  if (pRecord->detailedRecordHeader.UsePec)
1622  modifiedWordValue | (pRecord->desiredDataWord & pRecord->wordMask));
1623  else
1626  modifiedWordValue | (pRecord->desiredDataWord & pRecord->wordMask));
1627 #endif
1628 #endif
1629  return SUCCESS;
1630 }
uint8_t recordProcessor___0x01___processWriteByteOptionalPEC(t_RECORD_PMBUS_WRITE_BYTE *)
PRIVATE PROTOTYPES RELATING TO RECORD TYPE PARSING.
tRecordHeaderAddressAndCommandWithoutPEC detailedRecordHeader
uint8_t recordProcessor___0x02___processWriteWordOptionalPEC(t_RECORD_PMBUS_WRITE_WORD *)
#define SYSTEM_AFTER_VERIFY
#define RECORD_TYPE_PMBUS_SEND_BYTE_NOPEC
void sendByte(uint8_t address, uint8_t command)
SMBus send byte command.
uint8_t recordProcessor___0x0A___processReadByteLoopMaskOptionalPEC(t_RECORD_PMBUS_READ_BYTE_LOOP_MASK *)
uint8_t recordProcessor___0x0F___processWriteByteNoPEC(t_RECORD_PMBUS_WRITE_BYTE_NOPEC *)
tRecordHeaderAddressAndCommandWithOptionalPEC detailedRecordHeader
#define RECORD_TYPE_PMBUS_WRITE_WORD_NOPEC
uint8_t recordProcessor___0x10___processWriteWordNoPEC(t_RECORD_PMBUS_WRITE_WORD_NOPEC *)
tRecordHeaderAddressAndCommandWithoutPEC detailedRecordHeader
void writeWord(uint8_t address, uint8_t command, uint16_t data)
SMBus write word command.
tRecordHeaderAddressAndCommandWithOptionalPEC detailedRecordHeader
static uint16_t nWords
Copyright 2018(c) Analog Devices, Inc.
tRecordHeaderAddressAndCommandWithOptionalPEC detailedRecordHeader
tRecordHeaderAddressAndCommandWithOptionalPEC detailedRecordHeader
#define FAILURE
Definition: LT_PMBus.h:63
#define RECORD_TYPE_PMBUS_READ_BLOCK_EXPECT_NOPEC
tRecordHeaderAddressAndCommandWithOptionalPEC detailedRecordHeader
void writeByte(uint8_t address, uint8_t command, uint8_t data)
SMBus write byte command.
#define RECORD_TYPE_PMBUS_MODIFY_BYTE
tRecordHeaderLengthAndType baseRecordHeader
#define RECORD_TYPE_EVENT
#define RECORD_TYPE_PMBUS_READ_WORD_EXPECT
uint8_t verifyRecordsOnDemand(pRecordHeaderLengthAndType(*getRecord)(void))
#define BEFORE_INSYSTEM_PROGRAMMING_BEGIN
uint8_t recordProcessor___0x0E___processSendByteOptionalPEC(t_RECORD_PMBUS_SEND_BYTE *)
#define RECORD_TYPE_DELAY_MS
tRecordHeaderAddressAndCommandWithoutPEC detailedRecordHeader
uint8_t recordProcessor___0x18___processEvent(t_RECORD_EVENT *)
#define RECORD_TYPE_PMBUS_READ_BYTE_EXPECT
#define RECORD_TYPE_PMBUS_READ_BYTE_EXPECT_MASK_NOPEC
#define RECORD_TYPE_PMBUS_MODIFY_WORD
static bool ignore_records
uint8_t bufferNvmData(t_RECORD_NVM_DATA *pRecord)
uint8_t recordProcessor___0x1E___writeNvmData(t_RECORD_NVM_DATA *)
tRecordHeaderAddressAndCommandWithOptionalPEC detailedRecordHeader
#define RECORD_TYPE_PMBUS_READ_BYTE_LOOP_MASK
#define RECORD_TYPE_PMBUS_READ_AND_VERIFY_EE_DATA
uint8_t recordProcessor___0x1D___modifyByteNoPEC(t_RECORD_PMBUS_MODIFY_BYTE_NO_PEC *)
#define META_SET_GLOBAL_BASE_ADDRESS
#define INSYSTEM_CHIP_BEFORE_VERIFY
uint8_t recordProcessor___0x0B___processReadWordLoopMaskOptionalPEC(t_RECORD_PMBUS_READ_WORD_LOOP_MASK *)
#define RECORD_TYPE_PACKING_CODE
#define RECORD_TYPE_PMBUS_READ_BLOCK_EXPECT
uint8_t recordProcessor___0x09___bufferNVMData(t_RECORD_NVM_DATA *)
#define RECORD_TYPE_PMBUS_SEND_BYTE
tRecordHeaderAddressAndCommandWithOptionalPEC detailedRecordHeader
uint8_t recordProcessor___0x19___processReadByteExpectMaskNoPEC(t_RECORD_PMBUS_READ_BYTE_EXPECT_MASK_NOPEC *)
tRecordHeaderAddressAndCommandWithoutPEC detailedRecordHeader
uint8_t recordProcessor___0x1A___processReadWordExpectMaskNoPEC(t_RECORD_PMBUS_READ_WORD_EXPECT_MASK_NOPEC *)
#define RECORD_TYPE_PMBUS_WRITE_BLOCK_NOPEC
#define RECORD_TYPE_NVM_DATA
#define RECORD_TYPE_PMBUS_WRITE_BLOCK
#define INSYSTEM_CHIP_AFTER_VERIFY
uint8_t readByte(uint8_t address, uint8_t command)
SMBus read byte command.
uint8_t recordProcessor___0x0D___processDelayMs(t_RECORD_DELAY_MS *)
tRecordHeaderAddressAndCommandWithoutPEC detailedRecordHeader
uint8_t recordProcessor___0x1F___read_then_verifyNvmData(t_RECORD_NVM_DATA *)
tRecordHeaderAddressAndCommandWithoutPEC detailedRecordHeader
#define RECORD_TYPE_PMBUS_WRITE_WORD
#define RECORD_TYPE_PMBUS_WRITE_BYTE
#define RECORD_TYPE_PMBUS_WRITE_EE_DATA
uint8_t recordProcessor___0x15___processReadByteLoopMaskNoPEC(t_RECORD_PMBUS_READ_BYTE_LOOP_MASK_NOPEC *)
#define RECORD_TYPE_PMBUS_POLL_UNTIL_ACK_NOPEC
tRecordHeaderAddressAndCommandWithOptionalPEC detailedRecordHeader
#define RECORD_TYPE_MODIFY_WORD_NOPEC
uint8_t recordProcessor___0x1B___processVariableMetaData(t_RECORD_VARIABLE_META_DATA *)
#define SYSTEM_BEFORE_VERIFY
static uint16_t * words
Copyright 2018(c) Analog Devices, Inc.
uint8_t recordProcessor___0x05___processReadWordExpectOptionalPEC(t_RECORD_PMBUS_READ_WORD_EXPECT *)
LT_SMBusPec * smbusPec__
Definition: nvm.cpp:55
uint8_t recordProcessor___0x04___processReadByteExpectOptionalPEC(t_RECORD_PMBUS_READ_BYTE_EXPECT *)
uint8_t recordProcessor___0x1C___modifyWordNoPEC(t_RECORD_PMBUS_MODIFY_WORD_NO_PEC *)
tRecordHeaderAddressAndCommandWithoutPEC detailedRecordHeader
#define RECORD_TYPE_PMBUS_READ_WORD_LOOP_MASK_NOPEC
uint8_t processRecordsOnDemand(pRecordHeaderLengthAndType(*getRecord)(void))
#define RECORD_TYPE_PMBUS_READ_WORD_EXPECT_MASK_NOPEC
#define RECORD_TYPE_PMBUS_READ_WORD_EXPECT_NOPEC
#define SYSTEM_BEFORE_PROGRAM
uint8_t recordProcessor___0x12___processReadByteExpectNoPEC(t_RECORD_PMBUS_READ_BYTE_EXPECT_NOPEC *)
tRecordHeaderAddressAndCommandWithOptionalPEC detailedRecordHeader
tRecordHeaderAddressAndCommandWithOptionalPEC detailedRecordHeader
#define BEFORE_BEGIN
#define RECORD_TYPE_PMBUS_READ_BYTE_EXPECT_NOPEC
uint8_t recordProcessor___0x0C___processPollReadByteUntilAckNoPEC(t_RECORD_PMBUS_POLL_READ_BYTE_UNTIL_ACK *)
#define RECORD_TYPE_DEVICE_ADDRESS
tRecordHeaderAddressAndCommandWithOptionalPEC detailedRecordHeader
#define INSYSTEM_CHIP_BEFORE_PROGRAM
uint8_t recordProcessor___0x20___modifyByteOptionalPEC(t_RECORD_PMBUS_MODIFY_BYTE *)
uint8_t writeNvmData(t_RECORD_NVM_DATA *pRecord)
#define RECORD_TYPE_PMBUS_READ_WORD_LOOP_MASK
#define SUCCESS
Definition: LT_PMBus.h:62
Basic Record Type Definitions.
uint8_t recordProcessor___0x16___processReadWordLoopMaskNoPEC(t_RECORD_PMBUS_READ_WORD_LOOP_MASK_NOPEC *)
#define RECORD_TYPE_PMBUS_WRITE_BYTE_NOPEC
#define RECORD_TYPE_MODIFY_BYTE_NOPEC
tRecordHeaderAddressAndCommandWithoutPEC detailedRecordHeader
static int i
Definition: DC2430A.ino:184
tRecordHeaderAddressAndCommandWithoutPEC detailedRecordHeader
tRecordHeaderAddressAndCommandWithOptionalPEC detailedRecordHeader
#define RECORD_TYPE_VARIABLE_META_DATA
tRecordHeaderAddressAndCommandWithoutPEC detailedRecordHeader
LT_SMBusNoPec * smbusNoPec__
Definition: nvm.cpp:54
#define AFTER_DONE
#define RECORD_TYPE_PMBUS_READ_BYTE_LOOP_MASK_NOPEC
uint8_t readThenVerifyNvmData(t_RECORD_NVM_DATA *pRecord)
#define META_OEM_SERIAL_NUMBER
uint8_t recordProcessor___0x17___processSendByteNoPEC(t_RECORD_PMBUS_SEND_BYTE_NOPEC *)
uint8_t recordProcessor___0x21___modifyWordOptionalPEC(t_RECORD_PMBUS_MODIFY_WORD *)
uint8_t recordProcessor___0x13___processReadWordExpectNoPEC(t_RECORD_PMBUS_READ_WORD_EXPECT_NOPEC *)
static bool verification_in_progress
VARIABLES.
#define RECORD_TYPE_END_OF_RECORDS
uint16_t readWord(uint8_t address, uint8_t command)
SMBus read word command.
uint8_t waitForAck(uint8_t address, uint8_t command)
Read with the address and command in loop until ack, then issue stop.