3      Copyright (C) Dean Camera, 2013. 
   5   dean [at] fourwalledcubicle [dot] com 
  10   Copyright 2013  Dean Camera (dean [at] fourwalledcubicle [dot] com) 
  12   Permission to use, copy, modify, distribute, and sell this 
  13   software and its documentation for any purpose is hereby granted 
  14   without fee, provided that the above copyright notice appear in 
  15   all copies and that both that the copyright notice and this 
  16   permission notice and warranty disclaimer appear in supporting 
  17   documentation, and that the name of the author not be used in 
  18   advertising or publicity pertaining to distribution of the 
  19   software without specific, written prior permission. 
  21   The author disclaims all warranties with regard to this 
  22   software, including all implied warranties of merchantability 
  23   and fitness.  In no event shall the author be liable for any 
  24   special, indirect or consequential damages or any damages 
  25   whatsoever resulting from loss of use, data or profits, whether 
  26   in an action of contract, negligence or other tortious action, 
  27   arising out of or in connection with the use or performance of 
  33  *  Header file for XPROGTarget.c. 
  36 #ifndef _XPROG_TARGET_ 
  37 #define _XPROG_TARGET_ 
  41                 #include <avr/interrupt.h> 
  44                 #include <LUFA/Common/Common.h> 
  46                 #include "../V2Protocol.h" 
  47                 #include "XPROGProtocol.h" 
  48                 #include "Config/AppConfig.h" 
  50         /* Preprocessor Checks: */ 
  51                 #if ((BOARD == BOARD_XPLAIN) || (BOARD == BOARD_XPLAIN_REV1)) 
  52                         #undef ENABLE_ISP_PROTOCOL 
  54                         #if !defined(ENABLE_XPROG_PROTOCOL) 
  55                                 #define ENABLE_XPROG_PROTOCOL 
  59                 /** Serial carrier TPI/PDI speed in Hz, when hardware TPI/PDI mode is used. */ 
  60                 #define XPROG_HARDWARE_SPEED       250000 
  62                 /** Total number of bits in a single USART frame. */ 
  63                 #define BITS_IN_USART_FRAME        12 
  65                 #define PDI_CMD_LDS                0x00 
  66                 #define PDI_CMD_LD                 0x20 
  67                 #define PDI_CMD_STS                0x40 
  68                 #define PDI_CMD_ST                 0x60 
  69                 #define PDI_CMD_LDCS               0x80 
  70                 #define PDI_CMD_REPEAT             0xA0 
  71                 #define PDI_CMD_STCS               0xC0 
  72                 #define PDI_CMD_KEY                0xE0 
  74                 #define PDI_STATUS_REG             0 
  75                 #define PDI_RESET_REG              1 
  76                 #define PDI_CTRL_REG               2 
  78                 #define PDI_STATUS_NVM             (1 << 1) 
  80                 #define PDI_RESET_KEY              0x59 
  81                 #define PDI_NVMENABLE_KEY          (uint8_t[]){0x12, 0x89, 0xAB, 0x45, 0xCD, 0xD8, 0x88, 0xFF} 
  83                 #define PDI_DATSIZE_1BYTE          0 
  84                 #define PDI_DATSIZE_2BYTES         1 
  85                 #define PDI_DATSIZE_3BYTES         2 
  86                 #define PDI_DATSIZE_4BYTES         3 
  88                 #define PDI_POINTER_INDIRECT       0 
  89                 #define PDI_POINTER_INDIRECT_PI    1 
  90                 #define PDI_POINTER_DIRECT         2 
  92                 #define TPI_CMD_SLD                0x20 
  93                 #define TPI_CMD_SST                0x60 
  94                 #define TPI_CMD_SSTPR              0x68 
  95                 #define TPI_CMD_SIN                0x10 
  96                 #define TPI_CMD_SOUT               0x90 
  97                 #define TPI_CMD_SLDCS              0x80 
  98                 #define TPI_CMD_SSTCS              0xC0 
  99                 #define TPI_CMD_SKEY               0xE0 
 101                 #define TPI_STATUS_REG             0x00 
 102                 #define TPI_CTRL_REG               0x02 
 103                 #define TPI_ID_REG                 0x0F 
 105                 #define TPI_STATUS_NVM             (1 << 1) 
 107                 #define TPI_NVMENABLE_KEY          (uint8_t[]){0x12, 0x89, 0xAB, 0x45, 0xCD, 0xD8, 0x88, 0xFF} 
 109                 #define TPI_POINTER_INDIRECT       0 
 110                 #define TPI_POINTER_INDIRECT_PI    4 
 112         /* Function Prototypes: */ 
 113                 void    XPROGTarget_EnableTargetPDI(void); 
 114                 void    XPROGTarget_EnableTargetTPI(void); 
 115                 void    XPROGTarget_DisableTargetPDI(void); 
 116                 void    XPROGTarget_DisableTargetTPI(void); 
 117                 void    XPROGTarget_SendByte(const uint8_t Byte
); 
 118                 uint8_t XPROGTarget_ReceiveByte(void); 
 119                 void    XPROGTarget_SendIdle(void); 
 120                 bool    XPROGTarget_WaitWhileNVMBusBusy(void); 
 122                 #if (defined(INCLUDE_FROM_XPROGTARGET_C) && defined(ENABLE_XPROG_PROTOCOL)) 
 123                         static void XPROGTarget_SetTxMode(void); 
 124                         static void XPROGTarget_SetRxMode(void);