AVR ISP adapter (avr109/910 compatible, using ATmega16)
You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

72 lines
2.5 KiB

  1. #ifndef SPI_ISP_H_
  2. #define SPI_ISP_H_
  3. #include <stdint.h>
  4. #include "avrdevice.h"
  5. /* *********************************************************************** */
  6. #define SPI_SET_CLK_MAX 0
  7. #define SPI_SET_CLK_DEC 1
  8. #define CMD_PROG_ENABLE_1 0xAC
  9. #define CMD_PROG_ENABLE_2 0x53
  10. #define CMD_CHIP_ERASE_1 0xAC
  11. #define CMD_CHIP_ERASE_2 0x80
  12. #define CMD_POLL_BUSY_1 0xF0 /* not used */
  13. #define CMD_POLL_BUSY_2 0x00 /* not used */
  14. #define CMD_LOAD_EADDR_1 0x4D /* not used */
  15. #define CMD_LOAD_EADDR_2 0x00 /* not used */
  16. #define CMD_LOAD_FLASH_HI 0x48
  17. #define CMD_LOAD_FLASH_LO 0x40
  18. #define CMD_LOAD_EEPROM_PAGE 0xC1 /* not used */
  19. #define CMD_READ_FLASH_LO 0x20
  20. #define CMD_READ_FLASH_HI 0x28
  21. #define CMD_READ_EEPROM 0xA0
  22. #define CMD_READ_LOCK_1 0x58
  23. #define CMD_READ_LOCK_2 0x00
  24. #define CMD_READ_SIG_1 0x30
  25. #define CMD_READ_SIG_2 0x00
  26. #define CMD_READ_FUSE_1 0x50
  27. #define CMD_READ_FUSE_2 0x00
  28. #define CMD_READ_FUSE_H_1 0x58
  29. #define CMD_READ_FUSE_H_2 0x08
  30. #define CMD_READ_FUSE_E_1 0x50
  31. #define CMD_READ_FUSE_E_2 0x08
  32. #define CMD_READ_CAL 0x38 /* not used */
  33. #define CMD_WRITE_FLASH_PAGE 0x4C
  34. #define CMD_WRITE_EEPROM 0xC0
  35. #define CMD_WRITE_EEPROM_PAGE 0xC2 /* not used */
  36. #define CMD_WRITE_LOCK_1 0xAC
  37. #define CMD_WRITE_LOCK_2 0xE0
  38. #define CMD_WRITE_FUSE_1 0xAC
  39. #define CMD_WRITE_FUSE_2 0xA0
  40. #define CMD_WRITE_FUSE_H_1 0xAC /* not used */
  41. #define CMD_WRITE_FUSE_H_2 0xA8 /* not used */
  42. #define CMD_WRITE_FUSE_E_1 0xAC /* not used */
  43. #define CMD_WRITE_FUSE_E_2 0xA4 /* not used */
  44. /* *********************************************************************** */
  45. void spi_set_clk (uint8_t mode);
  46. void spi_init (uint8_t enable);
  47. uint8_t isp_enter_progmode (void);
  48. void isp_mem_write (uint8_t cmd, uint16_t addr, uint8_t val);
  49. uint8_t isp_mem_read (uint8_t cmd, uint16_t addr);
  50. void isp_mem_poll (const avr_device_t * p_device);
  51. void isp_mem_pagewrite (void);
  52. void isp_read_signature (uint8_t * p_signature);
  53. uint8_t isp_cmd3 (uint8_t cmd1, uint8_t cmd2,
  54. uint8_t cmd3);
  55. uint8_t isp_cmd4 (uint8_t cmd1, uint8_t cmd2,
  56. uint8_t cmd3, uint8_t cmd4);
  57. /* *********************************************************************** */
  58. #endif /* SPI_ISP_H_ */