avrtarget.h 4.3 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118
  1. #ifndef _DEV_AVRTARGET_H_
  2. #define _DEV_AVRTARGET_H_
  3. /*
  4. * Copyright (C) 2007 by egnite Software GmbH. All rights reserved.
  5. *
  6. * Redistribution and use in source and binary forms, with or without
  7. * modification, are permitted provided that the following conditions
  8. * are met:
  9. *
  10. * 1. Redistributions of source code must retain the above copyright
  11. * notice, this list of conditions and the following disclaimer.
  12. * 2. Redistributions in binary form must reproduce the above copyright
  13. * notice, this list of conditions and the following disclaimer in the
  14. * documentation and/or other materials provided with the distribution.
  15. * 3. Neither the name of the copyright holders nor the names of
  16. * contributors may be used to endorse or promote products derived
  17. * from this software without specific prior written permission.
  18. *
  19. * THIS SOFTWARE IS PROVIDED BY EGNITE SOFTWARE GMBH AND CONTRIBUTORS
  20. * ``AS IS'' AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
  21. * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS
  22. * FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL EGNITE
  23. * SOFTWARE GMBH OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT,
  24. * INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING,
  25. * BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS
  26. * OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED
  27. * AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY,
  28. * OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF
  29. * THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
  30. * SUCH DAMAGE.
  31. *
  32. * For additional information see http://www.ethernut.de/
  33. */
  34. #include <cfg/progif.h>
  35. /*!
  36. * \file avrtarget.h
  37. * \brief External AVR device programming.
  38. *
  39. * \verbatim
  40. *
  41. * $Log: avrtarget.h,v $
  42. * Revision 1.1 2007/04/12 09:01:41 haraldkipp
  43. * New API allows to program external AVR devices.
  44. *
  45. *
  46. * \endverbatim
  47. */
  48. #ifndef AVRTARGET_PAGESIZE
  49. /*!
  50. * \brief Target's page size.
  51. *
  52. * Hardcoded for now.
  53. */
  54. #define AVRTARGET_PAGESIZE 128
  55. #endif
  56. /*
  57. * AVR target device signatures.
  58. */
  59. #define AVRSIGNATURE_MEGA8 0x001E9307UL
  60. #define AVRSIGNATURE_MEGA168 0x001E9406UL
  61. #define AVRSIGNATURE_MEGA103 0x001E9701UL
  62. #define AVRSIGNATURE_MEGA128 0x001E9702UL
  63. #define AVRSIGNATURE_MEGA1280 0x001E9703UL
  64. #define AVRSIGNATURE_MEGA1281 0x001E9704UL
  65. #define AVRSIGNATURE_90CAN128 0x001E9781UL
  66. #define AVRSIGNATURE_MEGA2560 0x001E9801UL
  67. #define AVRSIGNATURE_MEGA2561 0x001E9802UL
  68. /*
  69. * AVR device programming commands.
  70. */
  71. #define AVRCMD_PROG_ENABLE 0xAC530000UL
  72. #define AVRCMD_CHIP_ERASE 0xAC800000UL
  73. #define AVRCMD_READ_PROG_MEM_LO 0x20000000UL
  74. #define AVRCMD_READ_PROG_MEM_HI 0x28000000UL
  75. #define AVRCMD_LOAD_PROG_MEM_PAGE_LO 0x40000000UL
  76. #define AVRCMD_LOAD_PROG_MEM_PAGE_HI 0x48000000UL
  77. #define AVRCMD_WRITE_PROG_MEM_PAGE 0x4c000000UL
  78. #define AVRCMD_READ_EEPROM_MEM 0xA0000000UL
  79. #define AVRCMD_WRITE_EEPROM_MEM 0xC0000000UL
  80. #define AVRCMD_LOAD_EEPROM_MEM_PAGE 0xC1000000UL
  81. #define AVRCMD_WRITE_EEPROM_MEM_PAGE 0xC2000000UL
  82. #define AVRCMD_READ_LOCK_BITS 0x58000000UL
  83. #define AVRCMD_WRITE_LOCK_BITS 0xACE00000UL
  84. #define AVRCMD_READ_SIGNATURE_BYTE 0x30000000UL
  85. #define AVRCMD_WRITE_FUSE_BITS 0xACA00000UL
  86. #define AVRCMD_WRITE_FUSE_HI_BITS 0xACA80000UL
  87. #define AVRCMD_WRITE_FUSE_EXT_BITS 0xACA40000UL
  88. #define AVRCMD_READ_FUSE_BITS 0x50000000UL
  89. #define AVRCMD_READ_FUSE_HI_BITS 0x58080000UL
  90. #define AVRCMD_READ_FUSE_EXT_BITS 0x50080000UL
  91. #define AVRCMD_READ_CALIBRATION_BYTE 0x38000000UL
  92. #define AVRCMD_POLL_READY 0xF0000000UL
  93. __BEGIN_DECLS
  94. /* Prototypes */
  95. extern int AvrTargetInit(void);
  96. extern void AvrTargetSelect(ureg_t act);
  97. extern void AvrTargetReset(ureg_t on);
  98. extern u_long AvrTargetCmd(u_long cmd);
  99. extern u_long AvrTargetSignature(void);
  100. extern u_long AvrTargetFusesRead(void);
  101. extern u_long AvrTargetFusesWriteSafe(u_long fuses);
  102. extern int AvrTargetProgEnable(void);
  103. extern int AvrTargetPollReady(u_int tmo);
  104. extern int AvrTargetChipErase(void);
  105. extern void AvrTargetPageLoad(u_long page, CONST u_char * data);
  106. extern int AvrTargetPageWrite(u_long page);
  107. extern int AvrTargetPageVerify(u_long page, CONST u_char * data);
  108. __END_DECLS
  109. /* End of prototypes */
  110. #endif