AVRISP-MKII Clone Programmer Project

Functions
XMEGANVM.c File Reference
`#include "XMEGANVM.h"`

## Functions

static void | XMEGANVM_SendAddress (const uint32_t AbsoluteAddress)
static void | XMEGANVM_SendNVMRegAddress (const uint8_t Register)
bool | XMEGANVM_WaitWhileNVMBusBusy (void)
bool | XMEGANVM_WaitWhileNVMControllerBusy (void)
bool | XMEGANVM_EnablePDI (void)
void | XMEGANVM_DisablePDI (void)
bool | XMEGANVM_GetMemoryCRC (const uint8_t CRCCommand, uint32_t *const CRCDest)
bool | XMEGANVM_ReadMemory (const uint32_t ReadAddress, uint8_t *ReadBuffer, uint16_t ReadSize)
bool | XMEGANVM_WriteByteMemory (const uint8_t WriteCommand, const uint32_t WriteAddress, const uint8_t Byte)
bool | XMEGANVM_WritePageMemory (const uint8_t WriteBuffCommand, const uint8_t EraseBuffCommand, const uint8_t WritePageCommand, const uint8_t PageMode, const uint32_t WriteAddress, const uint8_t *WriteBuffer, uint16_t WriteSize)
bool | XMEGANVM_EraseMemory (const uint8_t EraseCommand, const uint32_t Address)

## Detailed Description

Target-related functions for the XMEGA target's NVM module.

## Function Documentation

## § XMEGANVM_DisablePDI()

void XMEGANVM_DisablePDI | ( | void |  | ) |

Removes access to the target's NVM controller and physically disables the target's physical PDI interface.

## § XMEGANVM_EnablePDI()

bool XMEGANVM_EnablePDI | ( | void |  | ) |

Enables the physical PDI interface on the target and enables access to the internal NVM controller.

Returns
  Boolean `true` if the PDI interface was enabled successfully, `false` otherwise

## § XMEGANVM_EraseMemory()

bool XMEGANVM_EraseMemory | ( | const uint8_t | EraseCommand,
|  | const uint32_t | Address
| ) |  |

Erases a specific memory space of the target.

Parameters

  [in] | EraseCommand | NVM erase command to send to the device
  [in] | Address | Address inside the memory space to erase

Returns
  Boolean `true` if the command sequence complete successfully

## § XMEGANVM_GetMemoryCRC()

bool XMEGANVM_GetMemoryCRC | ( | const uint8_t | CRCCommand,
|  | uint32_t *const | CRCDest
| ) |  |

Retrieves the CRC value of the given memory space.

Parameters

  [in] | CRCCommand | NVM CRC command to issue to the target
  [out] | CRCDest | CRC Destination when read from the target

Returns
  Boolean `true` if the command sequence complete successfully

## § XMEGANVM_ReadMemory()

bool XMEGANVM_ReadMemory | ( | const uint32_t | ReadAddress,
|  | uint8_t * | ReadBuffer,
|  | uint16_t | ReadSize
| ) |  |

Reads memory from the target's memory spaces.

Parameters

  [in] | ReadAddress | Start address to read from within the target's address space
  [out] | ReadBuffer | Buffer to store read data into
  [in] | ReadSize | Number of bytes to read

Returns
  Boolean `true` if the command sequence complete successfully

## § XMEGANVM_SendAddress()

static void XMEGANVM_SendAddress | ( | const uint32_t | AbsoluteAddress | ) |

static

Sends the given 32-bit absolute address to the target.

Parameters

  [in] | AbsoluteAddress | Absolute address to send to the target

## § XMEGANVM_SendNVMRegAddress()

static void XMEGANVM_SendNVMRegAddress | ( | const uint8_t | Register | ) |

static

Sends the given NVM register address to the target.

Parameters

  [in] | Register | NVM register whose absolute address is to be sent

## § XMEGANVM_WaitWhileNVMBusBusy()

bool XMEGANVM_WaitWhileNVMBusBusy | ( | void |  | ) |

Busy-waits while the NVM controller is busy performing a NVM operation, such as a FLASH page read or CRC calculation.

Returns
  Boolean `true` if the NVM controller became ready within the timeout period, `false` otherwise

## § XMEGANVM_WaitWhileNVMControllerBusy()

bool XMEGANVM_WaitWhileNVMControllerBusy | ( | void |  | ) |

Waits while the target's NVM controller is busy performing an operation, exiting if the timeout period expires.

Returns
  Boolean `true` if the NVM controller became ready within the timeout period, `false` otherwise

## § XMEGANVM_WriteByteMemory()

bool XMEGANVM_WriteByteMemory | ( | const uint8_t | WriteCommand,
|  | const uint32_t | WriteAddress,
|  | const uint8_t | Byte
| ) |  |

Writes byte addressed memory to the target's memory spaces.

Parameters

  [in] | WriteCommand | Command to send to the device to write each memory byte
  [in] | WriteAddress | Address to write to within the target's address space
  [in] | Byte | Byte to write to the target

Returns
  Boolean `true` if the command sequence complete successfully

## § XMEGANVM_WritePageMemory()

bool XMEGANVM_WritePageMemory | ( | const uint8_t | WriteBuffCommand,
|  | const uint8_t | EraseBuffCommand,
|  | const uint8_t | WritePageCommand,
|  | const uint8_t | PageMode,
|  | const uint32_t | WriteAddress,
|  | const uint8_t * | WriteBuffer,
|  | uint16_t | WriteSize
| ) |  |

Writes page addressed memory to the target's memory spaces.

Parameters

  [in] | WriteBuffCommand | Command to send to the device to write a byte to the memory page buffer
  [in] | EraseBuffCommand | Command to send to the device to erase the memory page buffer
  [in] | WritePageCommand | Command to send to the device to write the page buffer to the destination memory
  [in] | PageMode | Bitfield indicating what operations need to be executed on the specified page
  [in] | WriteAddress | Start address to write the page data to within the target's address space
  [in] | WriteBuffer | Buffer to source data from
  [in] | WriteSize | Number of bytes to write

Returns
  Boolean `true` if the command sequence complete successfully