Declarations of helper functions.
Definition in file helper_functions.h.
#include <stdint.h>
#include <stdbool.h>
#include <stdio.h>
#include <stdlib.h>
Go to the source code of this file.
|
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...
|
|
◆ 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
-
arr1 | The first of the 2 arrays to be compared. |
arr2 | The second array to be compared. |
arrLength | The length of both arrays. |
- Return values
-
bool | Returns 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
-
byteArray | The byte array to be printed. |
numBytes | The number of bytes in the array to be printed. |
- Return values
-
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
-
byteArray | The byte array to be filled. |
numBytes | The number of bytes in the array to be filled. |
constantNum | The value to be stored at each element of the array. |
- Return values
-
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
-
byteArray | The byte array to be filled. |
numBytes | The number of bytes in the array to be filled. |
seedNumber | The byte stored at first index. |
- Return values
-
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
-
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
-
txBuffer | Pointer to the txBuffer byte array that will be printed. Must have at least bytesTx elements. |
txNumBytes | The number of txBuffer bytes to be printed. The txBuffer byte array must have at least this many elements. |
rxBuffer | Pointer to the rx byte array that will be printed. Must have at least bytesRx elements. |
rxNumBytes | The number of rx bytes to be printed. The rx byte array must have at least this many elements. |
- Return values
-
Definition at line 89 of file helper_functions.c.