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

// TPI commands
#define TPI_CMD_ENTER_PROGMODE     0x01
#define TPI_CMD_LEAVE_PROGMODE     0x02
#define TPI_CMD_ERASE              0x03
#define TPI_CMD_WRITE_MEM          0x04
#define TPI_CMD_READ_MEM           0x05
#define TPI_CMD_SET_PARAM          0x07

// Memory types
#define TPI_MEM_TYPE_APPL          1
#define TPI_MEM_TYPE_FUSE          4
#define TPI_MEM_TYPE_LOCKBITS      5

// Erase modes
#define TPI_ERASE_CHIP             1
#define TPI_ERASE_APP              2
#define TPI_ERASE_CONFIG           9

// Error codes
#define TPI_RSP_ERR_OK                 0
#define TPI_RSP_ERR_FAILED             1
#define TPI_RSP_ERR_COLLISION          2
#define TPI_RSP_ERR_TIMEOUT            3
#define TPI_RSP_ERR_ILLEGAL_PARAM      4

// TPI parameters 
#define TPI_PARAM_NVMCMD_ADDR      0x03
#define TPI_PARAM_NVMCSR_ADDR      0x04