Declaration of the Adapter functions used in the Adapter Pattern. More...
#include <stdbool.h>#include <stdint.h>

Go to the source code of this file.
Macros | |
| #define | __ADAPTER_FUNCTIONS_H__ |
Enumerations | |
| enum | MemoryBlockNumber { Memory_Block_0 = 0 , Memory_Block_1 = 1 , Memory_Block_2 = 2 } |
| Represents the memory blocks that can be accessed. Hides how memory blocks are actually identified. More... | |
Functions | |
| bool | Adapter_OpenMemory (MemoryBlockNumber blockNumber, int *dataHandle) |
| Open a memory block for access. | |
| bool | Adapter_CloseMemory (int dataHandle) |
| Closes a memory block from access. | |
| bool | Adapter_GetMemorySize (int dataHandle, int *sizeInBytes) |
| Retrieve the number of bytes in the memory block associated with the specified data handle. | |
| bool | Adapter_ReadMemory (int dataHandle, int byteOffset, uint8_t *buffer, int maxBytes, int *bytesRead) |
| Read a requested number of bytes from the memory block associated with the given handle. | |
| bool | Adapter_WriteMemory (int dataHandle, int byteOffset, const uint8_t *buffer, int maxBytes, int *bytesWritten) |
| Write a requested number of bytes to the memory block associated with the given handle. | |
| const char * | Adapter_GetLastErrorMessage (void) |
| Retrieve a string describing the last error that occurred in the Adapter. | |
| const char * | Adapter_BufferToString (const uint8_t *data, uint32_t maxBytes, int indent) |
| Convert the specified data up to the specified number of bytes into a string by performing a "hex dump" on the data. | |
Declaration of the Adapter functions used in the Adapter Pattern.
Definition in file Adapter_Functions.h.
| #define __ADAPTER_FUNCTIONS_H__ |
Definition at line 8 of file Adapter_Functions.h.
| enum MemoryBlockNumber |
Represents the memory blocks that can be accessed. Hides how memory blocks are actually identified.
| Enumerator | |
|---|---|
| Memory_Block_0 | First block. |
| Memory_Block_1 | Second block. |
| Memory_Block_2 | Third block. |
Definition at line 17 of file Adapter_Functions.h.
| const char * Adapter_BufferToString | ( | const uint8_t * | data, |
| uint32_t | maxBytes, | ||
| int | indent | ||
| ) |
Convert the specified data up to the specified number of bytes into a string by performing a "hex dump" on the data.
| data | The data to process. |
| maxBytes | The number of bytes from the data to process. |
| indent | Number of spaces to indent each line. |
Definition at line 400 of file Adapter_Functions.c.
References _countof, _hexdump, and _ReportErrorMessage().
Referenced by Adapter_Exercise().
| bool Adapter_CloseMemory | ( | int | dataHandle | ) |
Closes a memory block from access.
| dataHandle | The handle returned from Adapter_OpenMemory() to be closed. |
Definition at line 173 of file Adapter_Functions.c.
References _ReportDDRError(), _ResetLastError(), DDR_CloseMemoryBlock(), and DDR_ErrorCode_Success.
Referenced by Adapter_Exercise().
| const char * Adapter_GetLastErrorMessage | ( | void | ) |
Retrieve a string describing the last error that occurred in the Adapter.
Definition at line 391 of file Adapter_Functions.c.
References _lastError.
Referenced by Adapter_Exercise().
| bool Adapter_GetMemorySize | ( | int | dataHandle, |
| int * | sizeInBytes | ||
| ) |
Retrieve the number of bytes in the memory block associated with the specified data handle.
| dataHandle | The handle returned from Adapter_OpenMemory() to access. |
| sizeInBytes | Returns the number of bytes available to access. |
Definition at line 191 of file Adapter_Functions.c.
References _ReportDDRError(), _ReportErrorMessage(), _ResetLastError(), DDR_ErrorCode_Success, and DDR_GetMemorySize().
Referenced by Adapter_Exercise().
| bool Adapter_OpenMemory | ( | MemoryBlockNumber | blockNumber, |
| int * | dataHandle | ||
| ) |
Open a memory block for access.
| blockNumber | A value from the MemoryBlockNumber enumeration indicating which memory block to access. |
| dataHandle | Returns the handle to the memory block to access. |
Definition at line 142 of file Adapter_Functions.c.
References _GetBlockNameForBlockNumber(), _ReportDDRError(), _ReportErrorMessage(), _ResetLastError(), DDR_ErrorCode_Success, and DDR_OpenMemoryBlock().
Referenced by Adapter_Exercise().
| bool Adapter_ReadMemory | ( | int | dataHandle, |
| int | byteOffset, | ||
| uint8_t * | buffer, | ||
| int | maxBytes, | ||
| int * | bytesRead | ||
| ) |
Read a requested number of bytes from the memory block associated with the given handle.
| dataHandle | The handle returned from Adapter_OpenMemory() to access. |
| byteOffset | Byte offset into the memory block from which to start reading. |
| buffer | Buffer to fill with bytes from the memory block. |
| maxBytes | The number of bytes to read. |
| bytesRead | if not NULL, returns the number of bytes actually read. |
Definition at line 223 of file Adapter_Functions.c.
References _ReportDDRError(), _ReportErrorMessage(), _ResetLastError(), DDR_ErrorCode_Success, DDR_GetDataChunk(), and DDR_MAX_OFFSET.
Referenced by Adapter_Exercise().
| bool Adapter_WriteMemory | ( | int | dataHandle, |
| int | byteOffset, | ||
| const uint8_t * | buffer, | ||
| int | maxBytes, | ||
| int * | bytesWritten | ||
| ) |
Write a requested number of bytes to the memory block associated with the given handle.
| dataHandle | The handle returned from Adapter_OpenMemory() to access. |
| byteOffset | Byte offset into the memory block to which to start writing. |
| buffer | Buffer of bytes to write to the memory block. |
| maxBytes | The number of bytes to write. |
| bytesWritten | If not NULL, returns the number of bytes actually written. |
Definition at line 294 of file Adapter_Functions.c.
References _ReportDDRError(), _ReportErrorMessage(), _ResetLastError(), DDR_ErrorCode_Success, DDR_GetDataChunk(), DDR_MAX_OFFSET, and DDR_SetDataChunk().
Referenced by Adapter_Exercise().