Sample SPI drivers for a number of the Adesto Technologies flash devices.
Functions
helper_functions.c File Reference

Detailed Description

Definitions of helper functions.

Definition in file helper_functions.c.

#include "helper_functions.h"

Go to the source code of this file.

Functions

void displayByteArray (uint8_t *byteArray, uint32_t numBytes)
 Helper function to display a byte array/buffer. This function uses the printSPIExchange() function internally, but only displays one byte array. More...
 
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. More...
 
void fillArrayConst (uint8_t *byteArray, uint32_t numBytes, int constantNum)
 Helper function to display fill a byte array/buffer with a constant number. More...
 
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. More...
 
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 4 bytes. More...
 
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, what was received, and outputs the data in a grid. More...
 

Function Documentation

◆ compareByteArrays()

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.

Parameters
arr1The first of the 2 arrays to be compared.
arr2The second array to be compared.
arrLengthThe length of both arrays.
Return values
boolReturns 1 if equivalent, 0 if non equivalent
Warning
The 2 arrays must both be a minimum of arrLength bytes.

Definition at line 65 of file helper_functions.c.

◆ displayByteArray()

void displayByteArray ( uint8_t *  byteArray,
uint32_t  numBytes 
)

Helper function to display a byte array/buffer. This function uses the printSPIExchange() function internally, but only displays one byte array.

Parameters
byteArrayThe byte array to be printed.
numBytesThe number of bytes in the array to be printed.
Return values
void

Definition at line 44 of file helper_functions.c.

◆ fillArrayConst()

void fillArrayConst ( uint8_t *  byteArray,
uint32_t  numBytes,
int  constantNum 
)

Helper function to display fill a byte array/buffer with a constant number.

Parameters
byteArrayThe byte array to be filled.
numBytesThe number of bytes in the array to be filled.
constantNumThe value to be stored at each element of the array.
Return values
void

Definition at line 57 of file helper_functions.c.

◆ fillArrayPattern()

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.

Parameters
byteArrayThe byte array to be filled.
numBytesThe number of bytes in the array to be filled.
seedNumberThe byte stored at first index.
Return values
void

Definition at line 49 of file helper_functions.c.

◆ load4BytesToTxBuffer()

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 4 bytes.

Return values
void

Definition at line 80 of file helper_functions.c.

◆ printSPIExchange()

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, what was received, and outputs the data in a grid.

Parameters
txBufferPointer to the txBuffer byte array that will be printed. Must have at least bytesTx elements.
txNumBytesThe number of txBuffer bytes to be printed. The txBuffer byte array must have at least this many elements.
rxBufferPointer to the rx byte array that will be printed. Must have at least bytesRx elements.
rxNumBytesThe number of rx bytes to be printed. The rx byte array must have at least this many elements.
Return values
void

Definition at line 89 of file helper_functions.c.