This section includes the header file defining the different command, response and event IDs for the AVR8 protocol. It also defines the different possible failure codes.

enum Avr8GenericCommands {
    CMD_AVR8_QUERY                      = 0x00, //! Capability discovery 
    CMD_AVR8_SET                        = 0x01, //! Set parameters
    CMD_AVR8_GET                        = 0x02, //! Get parameters
    CMD_AVR8_ACTIVATE_PHYSICAL          = 0x10, //! Connect physically
    CMD_AVR8_DEACTIVATE_PHYSICAL        = 0x11, //! Disconnect physically
    CMD_AVR8_GET_ID                     = 0x12, //! Read the ID
    CMD_AVR8_ATTACH                     = 0x13, //! Attach to OCD module
    CMD_AVR8_DETACH                     = 0x14, //! Detach from OCD module
    CMD_AVR8_PROG_MODE_ENTER            = 0x15, //! Enter programming mode
    CMD_AVR8_PROG_MODE_LEAVE            = 0x16, //! Leave programming mode
    CMD_AVR8_DISABLE_DEBUGWIRE          = 0x17, //! Disable debugWIRE interface
    CMD_AVR8_ERASE                      = 0x20, //! Erase the chip
    CMD_AVR8_MEMORY_READ                = 0x21, //! Read memory
    CMD_AVR8_MEMORY_READ_MASKED         = 0x22, //! Read memory while via a mask
    CMD_AVR8_MEMORY_WRITE               = 0x23, //! Write memory
    CMD_AVR8_CRC                        = 0x24, //! Calculate CRC
    CMD_AVR8_RESET                      = 0x30, //! Reset the MCU
    CMD_AVR8_STOP                       = 0x31, //! Stop the MCU
    CMD_AVR8_RUN                        = 0x32, //! Resume execution
    CMD_AVR8_RUN_TO_ADDRESS             = 0x33, //! Resume with breakpoint 
    CMD_AVR8_STEP                       = 0x34, //! Single step
    CMD_AVR8_PC_READ                    = 0x35, //! Read PC
    CMD_AVR8_PC_WRITE                   = 0x36, //! Write PC
    CMD_AVR8_HW_BREAK_SET               = 0x40, //! Set breakpoints
    CMD_AVR8_HW_BREAK_CLEAR             = 0x41, //! Clear breakpoints
    CMD_AVR8_SW_BREAK_SET               = 0x43, //! Set software breakpoints
    CMD_AVR8_SW_BREAK_CLEAR             = 0x44, //! Clear software breakpoints
    CMD_AVR8_SW_BREAK_CLEAR_ALL         = 0x45, //! Clear all software breakpoints
    CMD_AVR8_PAGE_ERASE                 = 0x50  //! Erase page
};

// Protocol responses
enum Avr8GenericResponses {
    RSP_AVR8_OK                         = 0x80, //! All OK
    RSP_AVR8_LIST                       = 0x81, //! List of items returned
    RSP_AVR8_DATA                       = 0x84, //! Data returned
    RSP_AVR8_PC                         = 0x83, //! PC value returned
    RSP_AVR8_FAILED                     = 0xA0  //! Command failed to execute
};

// Protocol events
enum Avr8GenericEvents {
    EVT_AVR8_BREAK                      = 0x40, //! Break message
    EVT_AVR8_IDR                        = 0x41  //! IO Data Register message
};

// Failure response codes (RSP_FAILED)
enum Avr8GenericFailureCodes {
    AVR8_FAILURE_OK                      = 0x00, //! All OK
    AVR8_FAILURE_DW_PHY_ERROR            = 0x10, //! debugWIRE physical error
    AVR8_FAILURE_JTAGM_INIT_ERROR        = 0x11, //! JTAGM failed to initialise
    AVR8_FAILURE_JTAGM_ERROR             = 0x12, //! JTAGM did something strange
    AVR8_FAILURE_JTAG_ERROR              = 0x13, //! JTAG low level error
    AVR8_FAILURE_JTAGM_VERSION           = 0x14, //! Unsupported version of JTAGM
    AVR8_FAILURE_JTAGM_TIMEOUT           = 0x15, //! JTAG master timed out
    AVR8_FAILURE_JTAG_BIT_BANGER_TIMEOUT = 0x16, //! JTAG bit banger timed out
    AVR8_FAILURE_PARITY_ERROR            = 0x17, //! Parity error in received data
    AVR8_FAILURE_EB_ERROR                = 0x18, //! Did not receive EMPTY byte
    AVR8_FAILURE_PDI_TIMEOUT             = 0x19, //! PDI physical timed out
    AVR8_FAILURE_COLLISION               = 0x1A, //! Collision on physical level
    AVR8_FAILURE_PDI_ENABLE              = 0x1B, //! PDI enable failed
    AVR8_FAILURE_NO_DEVICE_FOUND         = 0x20, //! devices == 0!
    AVR8_FAILURE_CLOCK_ERROR             = 0x21, //! Failure when increasing baud
    AVR8_FAILURE_NO_TARGET_POWER         = 0x22, //! Target power not detected
    AVR8_FAILURE_NOT_ATTACHED            = 0x23, //! Must run attach command first
    AVR8_FAILURE_INVALID_PHYSICAL_STATE  = 0x31, //! Physical not activated
    AVR8_FAILURE_ILLEGAL_STATE           = 0x32, //! Illegal run / stopped state
    AVR8_FAILURE_INVALID_CONFIG          = 0x33, //! Invalid config for activate phy
    AVR8_FAILURE_INVALID_MEMTYPE         = 0x34, //! Not a valid memtype
    AVR8_FAILURE_INVALID_SIZE            = 0x35, //! Too many or too few bytes
    AVR8_FAILURE_INVALID_ADDRESS         = 0x36, //! Asked for a bad address
    AVR8_FAILURE_INVALID_ALIGNMENT       = 0x37, //! Asked for badly aligned data
    AVR8_FAILURE_ILLEGAL_MEMORY_RANGE    = 0x38, //! Address not within legal range
    AVR8_FAILURE_ILLEGAL_VALUE           = 0x39, //! Illegal value given
    AVR8_FAILURE_ILLEGAL_ID              = 0x3A, //! Illegal target ID
    AVR8_FAILURE_INVALID_CLOCK_SPEED     = 0x3B, //! Clock value out of range
    AVR8_FAILURE_TIMEOUT                 = 0x3C, //! A timeout occurred
    AVR8_FAILURE_ILLEGAL_OCD_STATUS      = 0x3D, //! Read an illegal OCD status 
    AVR8_FAILURE_NVM_ENABLE              = 0x40, //! NVM failed to be enabled
    AVR8_FAILURE_NVM_DISABLE             = 0x41, //! NVM failed to be disabled
    AVR8_FAILURE_CS_ERROR                = 0x42, //! Illegal control/status bits 
    AVR8_FAILURE_CRC_FAILURE             = 0x43, //! CRC mismatch
    AVR8_FAILURE_OCD_LOCKED              = 0x44, //! Failed to enable OCD
    AVR8_FAILURE_NO_OCD_CONTROL          = 0x50, //! Device is not under control
    AVR8_FAILURE_PC_READ_FAILED          = 0x60, //! Error when reading PC
    AVR8_FAILURE_REGISTER_READ_FAILED    = 0x61, //! Error when reading register
    AVR8_FAILURE_READ_ERROR              = 0x70, //! Error while reading
    AVR8_FAILURE_WRITE_ERROR             = 0x71, //! Error while writing
    AVR8_FAILURE_WRITE_TIMEOUT           = 0x72, //! Timeout while reading
    AVR8_FAILURE_ILLEGAL_BREAKPOINT      = 0x80, //! Invalid breakpoint configuration
    AVR8_FAILURE_TOO_MANY_BREAKPOINTS    = 0x81, //! Not enough available resources
    AVR8_FAILURE_NOT_SUPPORTED           = 0x90, //! This feature is not available
    AVR8_FAILURE_NOT_IMPLEMENTED         = 0x91, //! Command has not been implemented
    AVR8_FAILURE_UNKNOWN                 = 0xFF  //! Disaster.
};

// QUERY types on this protocol
enum Avr8GenericQueryContexts {
    AVR8_QUERY_COMMANDS                 = 0x00, //! Supported command list
    AVR8_QUERY_CONFIGURATION            = 0x05, //! Supported configuration list
    AVR8_QUERY_READ_MEMTYPES            = 0x07, //! Supported read memtypes list
    AVR8_QUERY_WRITE_MEMTYPES           = 0x08  //! Supported write memtypes list
};

// Context definitions 
enum Avr8GenericSetGetContexts {
    AVR8_CTXT_CONFIG                    = 0x00, //! Configuration
    AVR8_CTXT_PHYSICAL                  = 0x01, //! Physical interface related
    AVR8_CTXT_DEVICE                    = 0x02, //! Device specific settings
    AVR8_CTXT_OPTIONS                   = 0x03, //! Option-related settings
    AVR8_CTXT_SESSION                   = 0x04, //! Session-related settings
};

enum Avr8GenericConfigContextParameters {
    AVR8_CONFIG_VARIANT                 = 0x00, //! Device family/variant
    AVR8_CONFIG_FUNCTION                = 0x01  //! Functional intent
};

enum Avr8GenericPhysicalContextParameters {
    AVR8_PHY_INTERFACE                  = 0x00, //! Physical interface selector
    AVR8_PHY_JTAG_DAISY                 = 0x01, //! JTAG daisy chain settings
    AVR8_PHY_DW_CLK_DIV                 = 0x10, //! debugWIRE clock divide ratio
    AVR8_PHY_MEGA_PRG_CLK               = 0x20, //! Clock for programming megaAVR
    AVR8_PHY_MEGA_DBG_CLK               = 0x21, //! Clock for debugging megaAVR
    AVR8_PHY_XM_JTAG_CLK                = 0x30, //! JTAG clock for AVR XMEGA
    AVR8_PHY_XM_PDI_CLK                 = 0x31  //! PDI clock for AVR XMEGA
};

enum Avr8GenericOptionsContextParameters {
    AVR8_OPT_RUN_TIMERS                 = 0x00, //! Keep timers running when stopped
    AVR8_OPT_DISABLE_DBP                = 0x01, //! No data breaks during reset
    AVR8_OPT_ENABLE_IDR                 = 0x03, //! Relay IDR messages
    AVR8_OPT_POLL_INT                   = 0x04  //! Configure polling speed
};

enum Avr8GenericSessionContextParameters {
    AVR8_SESS_MAIN_PC                   = 0x00  //! Address of main() function
};

enum Avr8GenericConfigTestParameters {
    AVR8_TEST_TGT_RUNNING               = 0x00  //! Is target running?
};

enum Avr8GenericVariantValues {
    AVR8_VARIANT_LOOPBACK               = 0x00, //! Dummy device
    AVR8_VARIANT_TINYOCD                = 0x01, //! tinyAVR or megaAVR with debugWIRE
    AVR8_VARIANT_MEGAOCD                = 0x02, //! megaAVR with JTAG
    AVR8_VARIANT_XMEGA                  = 0x03, //! AVR XMEGA
    AVR8_VARIANT_NONE                   = 0xFF  //! No device
};

enum Avr8GenericFunctionValues {
    AVR8_FUNC_NONE                      = 0x00, //! Not configured
    AVR8_FUNC_PROGRAMMING               = 0x01, //! I want to program only
    AVR8_FUNC_DEBUGGING                 = 0x02  //! I want a debug session
};

// Physical modes
enum Avr8GenericPhysicalInterfaces {
    AVR8_PHY_INTF_NONE                  = 0x00, //! Not configured
    AVR8_PHY_INTF_JTAG                  = 0x04, //! JTAG
    AVR8_PHY_INTF_DW                    = 0x05, //! debugWIRE
    AVR8_PHY_INTF_PDI                   = 0x06  //! PDI
};


enum Avr8GenericMegaBreakpointTypes {        
    AVR8_HWBP_PROG_BP               = 0x01  //! Program breaks

};

enum Avr8GenericMegaBreakCauses {
    AVR8_BREAK_CAUSE_UNKNOWN        = 0x00, //! Unspecified
    AVR8_BREAK_CAUSE_PROGRAM        = 0x01  //! Program break

};

    
enum Avr8GenericXmegaEraseModes {
    XMEGA_ERASE_CHIP                = 0x00, //! Erase entire chip 
    XMEGA_ERASE_APP                 = 0x01, //! Erase application section only
    XMEGA_ERASE_BOOT                = 0x02, //! Erase boot section only
    XMEGA_ERASE_EEPROM              = 0x03, //! Erase EEPROM section only
    XMEGA_ERASE_APP_PAGE            = 0x04, //! Erase a single app section page
    XMEGA_ERASE_BOOT_PAGE           = 0x05, //! Erase a single boot section page
    XMEGA_ERASE_EEPROM_PAGE         = 0x06, //! Erase a single EEPROM page
    XMEGA_ERASE_USERSIG             = 0x07  //! Erase the user signature section
};

// Memory types
enum Avr8GenericMemtypes {
    MEMTYPE_SRAM                    = 0x20, //! SRAM
    MEMTYPE_EEPROM                  = 0x22, //! EEPROM memory
    MEMTYPE_SPM                     = 0xA0, //! Flash memory in a debug session
    MEMTYPE_FLASH_PAGE              = 0xB0, //! Flash memory programming
    MEMTYPE_EEPROM_PAGE             = 0xB1, //! EEPROM memory pages
    MEMTYPE_FUSES                   = 0xB2, //! Fuse memory
    MEMTYPE_LOCKBITS                = 0xB3, //! Lock bits
    MEMTYPE_SIGNATURE               = 0xB4, //! Device signature
    MEMTYPE_OSCCAL                  = 0xB5, //! Oscillator calibration values
    MEMTYPE_REGFILE                 = 0xB8, //! Register file
    MEMTYPE_APPL_FLASH              = 0xC0, //! Application section flash
    MEMTYPE_BOOT_FLASH              = 0xC1, //! Boot section flash
    MEMTYPE_APPL_FLASH_ATOMIC       = 0xC2, //! Application page with auto-erase
    MEMTYPE_BOOT_FLASH_ATOMIC       = 0xC3, //! Boot page with auto-erase
    MEMTYPE_EEPROM_ATOMIC           = 0xC4, //! EEPROM page with auto-erase
    MEMTYPE_USER_SIGNATURE          = 0xC5, //! User signature secion
    MEMTYPE_CALIBRATION_SIGNATURE   = 0xC6  //! Calibration section
    };