Nut/OS  4.10.3
API Reference
avrtarget.h
Go to the documentation of this file.
00001 #ifndef _DEV_AVRTARGET_H_
00002 #define _DEV_AVRTARGET_H_
00003 
00004 /*
00005  * Copyright (C) 2007 by egnite Software GmbH. All rights reserved.
00006  *
00007  * Redistribution and use in source and binary forms, with or without
00008  * modification, are permitted provided that the following conditions
00009  * are met:
00010  *
00011  * 1. Redistributions of source code must retain the above copyright
00012  *    notice, this list of conditions and the following disclaimer.
00013  * 2. Redistributions in binary form must reproduce the above copyright
00014  *    notice, this list of conditions and the following disclaimer in the
00015  *    documentation and/or other materials provided with the distribution.
00016  * 3. Neither the name of the copyright holders nor the names of
00017  *    contributors may be used to endorse or promote products derived
00018  *    from this software without specific prior written permission.
00019  *
00020  * THIS SOFTWARE IS PROVIDED BY EGNITE SOFTWARE GMBH AND CONTRIBUTORS
00021  * ``AS IS'' AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
00022  * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS
00023  * FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL EGNITE
00024  * SOFTWARE GMBH OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT,
00025  * INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING,
00026  * BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS
00027  * OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED
00028  * AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY,
00029  * OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF
00030  * THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
00031  * SUCH DAMAGE.
00032  *
00033  * For additional information see http://www.ethernut.de/
00034  */
00035 
00036 #include <cfg/progif.h>
00037 #include <stdint.h>
00038 
00060 #ifndef AVRTARGET_PAGESIZE
00061 
00066 #define AVRTARGET_PAGESIZE      128
00067 #endif
00068 
00069 /*
00070  * AVR target device signatures.
00071  */
00072 #define AVRSIGNATURE_MEGA8      0x001E9307UL
00073 #define AVRSIGNATURE_MEGA168    0x001E9406UL
00074 #define AVRSIGNATURE_MEGA103    0x001E9701UL
00075 #define AVRSIGNATURE_MEGA128    0x001E9702UL
00076 #define AVRSIGNATURE_MEGA1280   0x001E9703UL
00077 #define AVRSIGNATURE_MEGA1281   0x001E9704UL
00078 #define AVRSIGNATURE_90CAN128   0x001E9781UL
00079 #define AVRSIGNATURE_MEGA2560   0x001E9801UL
00080 #define AVRSIGNATURE_MEGA2561   0x001E9802UL
00081 
00082 /*
00083  * AVR device programming commands.
00084  */
00085 #define AVRCMD_PROG_ENABLE              0xAC530000UL
00086 #define AVRCMD_CHIP_ERASE               0xAC800000UL
00087 #define AVRCMD_READ_PROG_MEM_LO         0x20000000UL
00088 #define AVRCMD_READ_PROG_MEM_HI         0x28000000UL
00089 #define AVRCMD_LOAD_PROG_MEM_PAGE_LO    0x40000000UL
00090 #define AVRCMD_LOAD_PROG_MEM_PAGE_HI    0x48000000UL
00091 #define AVRCMD_WRITE_PROG_MEM_PAGE      0x4c000000UL
00092 #define AVRCMD_LOAD_EXT_ADDR_BYTE       0x4d000000UL
00093 #define AVRCMD_READ_EEPROM_MEM          0xA0000000UL
00094 #define AVRCMD_WRITE_EEPROM_MEM         0xC0000000UL
00095 #define AVRCMD_LOAD_EEPROM_MEM_PAGE     0xC1000000UL
00096 #define AVRCMD_WRITE_EEPROM_MEM_PAGE    0xC2000000UL
00097 #define AVRCMD_READ_LOCK_BITS           0x58000000UL
00098 #define AVRCMD_WRITE_LOCK_BITS          0xACE00000UL
00099 #define AVRCMD_READ_SIGNATURE_BYTE      0x30000000UL
00100 #define AVRCMD_WRITE_FUSE_BITS          0xACA00000UL
00101 #define AVRCMD_WRITE_FUSE_HI_BITS       0xACA80000UL
00102 #define AVRCMD_WRITE_FUSE_EXT_BITS      0xACA40000UL
00103 #define AVRCMD_READ_FUSE_BITS           0x50000000UL
00104 #define AVRCMD_READ_FUSE_HI_BITS        0x58080000UL
00105 #define AVRCMD_READ_FUSE_EXT_BITS       0x50080000UL
00106 #define AVRCMD_READ_CALIBRATION_BYTE    0x38000000UL
00107 #define AVRCMD_POLL_READY               0xF0000000UL
00108 
00109 __BEGIN_DECLS
00110 /* Prototypes */
00111 extern int AvrTargetInit(void);
00112 extern void AvrTargetSelect(ureg_t act);
00113 extern void AvrTargetReset(ureg_t on);
00114 extern uint32_t AvrTargetCmd(uint32_t cmd);
00115 extern uint32_t AvrTargetSignature(void);
00116 extern uint32_t AvrTargetFusesRead(void);
00117 extern uint32_t AvrTargetFusesWriteSafe(uint32_t fuses);
00118 extern int AvrTargetProgEnable(void);
00119 extern int AvrTargetPollReady(unsigned int tmo);
00120 extern int AvrTargetChipErase(void);
00121 extern void AvrTargetPageLoad(uint32_t page, CONST uint8_t * data);
00122 extern int AvrTargetPageWrite(uint32_t page);
00123 extern int AvrTargetPageVerify(uint32_t page, CONST uint8_t * data);
00124 
00125 __END_DECLS
00126 /* End of prototypes */
00127 #endif