51 for(
int i = 0; i < numBytes; i++)
53 byteArray[i] = (uint8_t)(seedNumber+i);
59 for(
int i = 0; i < numBytes; i++)
61 byteArray[i] = (uint8_t)(constantNum);
67 uint32_t numErrors = 0;
68 for(
int i = 0; i < arrLength; i++)
70 if(arr1[i] != arr2[i])
72 printf(
"Mismatch @ index: %d - Array 1: 0x%02X | Array 2: 0x%02X\n", i, arr1[i], arr2[i]);
76 printf(
"Byte comparison total mismatches: %d\n", numErrors);
77 return (numErrors == 0) ? 1 : 0;
83 txBuffer[1] = (uint8_t) (address >> 16);
84 txBuffer[2] = (uint8_t) (address >> 8);
85 txBuffer[3] = (uint8_t) address;
96 printf(
"\nSent bytes (0x):");
97 for(uint32_t i = 0; i < txNumBytes; i++)
108 printf(
"%02X", txBuffer[i]);
113 printf(
"\nReceived bytes (0x):");
114 for(uint32_t i = 0; i < rxNumBytes; i++)
125 printf(
"%02X", rxBuffer[i]);
void displayByteArray(uint8_t *byteArray, uint32_t numBytes)
Helper function to display a byte array/buffer. This function uses the printSPIExchange() function in...
void printSPIExchange(uint8_t *txBuffer, uint32_t txNumBytes, uint8_t *rxBuffer, uint32_t rxNumBytes)
Prints the byte array in hexadecimal with a formatted output. Indicates what bytes were sent...
bool compareByteArrays(uint8_t *arr1, uint8_t *arr2, uint32_t arrLength)
Helper function to compare 2 byte arrays and print an error message if they do not match...
void load4BytesToTxBuffer(uint8_t *txBuffer, uint8_t opcode, uint32_t address)
Loads 1 byte of opcode followed by 3 address bytes into the txBuffer. The data is stored at the first...
void fillArrayPattern(uint8_t *byteArray, uint32_t numBytes, int seedNumber)
Helper function to display fill a byte array/buffer with a pattern based on a seedNumber. The seed will be incremented by the index of the array.
Declarations of helper functions.
void fillArrayConst(uint8_t *byteArray, uint32_t numBytes, int constantNum)
Helper function to display fill a byte array/buffer with a constant number.