/* * avrdude - A Downloader/Uploader for AVR device programmers * Copyright (C) 2006 Thomas Fischl * * This program is free software; you can redistribute it and/or modify * it under the terms of the GNU General Public License as published by * the Free Software Foundation; either version 2 of the License, or * (at your option) any later version. * * This program is distributed in the hope that it will be useful, * but WITHOUT ANY WARRANTY; without even the implied warranty of * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * GNU General Public License for more details. * * You should have received a copy of the GNU General Public License * along with this program; if not, write to the Free Software * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA */ /* $Id: usbasp.h 815 2009-02-28 13:10:47Z fischl $ */ #ifndef usbasp_h #define usbasp_h #include "avrpart.h" /* USB identifiers */ #define USBASP_SHARED_VID 0x16C0 /* VOTI */ #define USBASP_SHARED_PID 0x05DC /* Obdev's free shared PID */ #define USBASP_OLD_VID 0x03EB /* ATMEL */ #define USBASP_OLD_PID 0xC7B4 /* (unoffical) USBasp */ /* USBasp v2 defines */ #define USBASP_PROT_V2 2 #define USBASP_V2_ISP2 1 #define USBASP_V2_TPI 2 #define USBASP_V2_PDI 3 /* USB function call identifiers */ #define USBASP_FUNC_CONNECT 1 #define USBASP_FUNC_DISCONNECT 2 #define USBASP_FUNC_TRANSMIT 3 #define USBASP_FUNC_READFLASH 4 #define USBASP_FUNC_ENABLEPROG 5 #define USBASP_FUNC_WRITEFLASH 6 #define USBASP_FUNC_READEEPROM 7 #define USBASP_FUNC_WRITEEEPROM 8 #define USBASP_FUNC_SETLONGADDRESS 9 #define USBASP_FUNC_SETISPSCK 10 /* Block mode flags */ #define USBASP_BLOCKFLAG_FIRST 1 #define USBASP_BLOCKFLAG_LAST 2 /* Block mode data size */ #define USBASP_READBLOCKSIZE 200 #define USBASP_WRITEBLOCKSIZE 200 /* ISP SCK speed identifiers */ #define USBASP_ISP_SCK_AUTO 0 #define USBASP_ISP_SCK_0_5 1 /* 500 Hz */ #define USBASP_ISP_SCK_1 2 /* 1 kHz */ #define USBASP_ISP_SCK_2 3 /* 2 kHz */ #define USBASP_ISP_SCK_4 4 /* 4 kHz */ #define USBASP_ISP_SCK_8 5 /* 8 kHz */ #define USBASP_ISP_SCK_16 6 /* 16 kHz */ #define USBASP_ISP_SCK_32 7 /* 32 kHz */ #define USBASP_ISP_SCK_93_75 8 /* 93.75 kHz */ #define USBASP_ISP_SCK_187_5 9 /* 187.5 kHz */ #define USBASP_ISP_SCK_375 10 /* 375 kHz */ #define USBASP_ISP_SCK_750 11 /* 750 kHz */ #define USBASP_ISP_SCK_1500 12 /* 1.5 MHz */ /* (v2 Protocol modefied) */ #define USBASP_ISP_SCK_62_5 8 /* 62.5 kHz */ #define USBASP_ISP_SCK_125 9 /* 125 kHz */ #define USBASP_ISP_SCK_250 10 /* 250 kHz */ #define USBASP_ISP_SCK_500 11 /* 500 kHz */ #define USBASP_ISP_SCK_1000 12 /* 1.0 MHz */ #define USBASP_ISP_SCK_2000 13 /* 2.0 MHz */ #define USBASP_ISP_SCK_4000 14 /* 4.0 MHz */ #define USBASP_ISP_SCK_8000 15 /* 8.0 MHz */ typedef struct sckoptions_t { int id; double frequency; } CLOCKOPTIONS; /* USB error identifiers */ #define USB_ERROR_NOTFOUND 1 #define USB_ERROR_ACCESS 2 #define USB_ERROR_IO 3 #ifdef __cplusplus extern "C" { #endif void usbasp_initpgm (PROGRAMMER * pgm); /* USBasp v2 cmd set */ #define ISPCMD_ISP_CONF 0xac #define ISPCONF_CHIP_ERASE 0x80 #define ISPCONF_RESET 0x59 /* PDI */ #define ISPCONF_SET_SPACE 0x01 /* PDI */ #define ISPCONF_SPACE_FLASH 0 #define ISPCONF_SPACE_APP 1 #define ISPCONF_SPACE_BOOT 2 #define ISPCONF_SPACE_EEPROM 3 #define ISPCONF_SPACE_FUSE 4 #define ISPCONF_SPACE_LOCK 5 #define ISPCONF_SPACE_USERSIG 6 #define ISPCONF_SPACE_CALIB 7 #define ISPCMD_READ_SIGNATURE 0x30 #define ISPCMD_READ_EEPROM 0xa0 #define ISPCMD_WRITE_EEPROM 0xc0 #define ISPCMD_CHK_BUSY 0xf0 #define TPI_NVMCMD 0x33 #define TPI_NVM_NOP 0x00 #define TPI_NVM_CHIP_ERASE 0x10 #define TPI_NVM_SECT_ERASE 0x14 #define TPI_NVM_WRITE 0x1d #define PDI_NVM_BASE 0x01c0 #define PDI_NVM_CMD (PDI_NVM_BASE + 0xa ) #define PDI_NVM_NOP 0x00 #define PDI_NVM_READ_NVM 0x43 #define PDI_NVM_WRITE_FUSE 0x4C #define PDI_NVM_WRITE_LOCKBIT 0x08 /* for debug */ /* tpiReadCS/tpiWriteCS addressing * * SLDCS/SSTCS : addr | 0x8000 * SIN/SOUT : addr */ #define TPI_CS_TPISR 0x8000 // in CSS offset 0 #define TPI_CS_NVMEN 1 #define TPI_NVMCSR 0x32 #define TPI_NVMBSY 7 /* pdiReadCS/pdiWriteCS addressing * * LDCS/STCS : addr | 0x8000 * LDS/STS : addr - 0x01000000 */ #define PDI_CS_STATUS 0x8000 #define PDI_CS_NVMEN 1 #define PDI_CS_RESET 0x8001 #define PDI_CS_RESET_KEY 0x59 #define PDI_CS_RESET_NONE 0x00 #define PDI_CS_CTRL 0x8002 #ifdef __cplusplus } #endif #endif /* usbasp_h */