AVR Bootloader (avrboot cleanup)
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.
 
 
 
 
 

50 lines
1.2 KiB

  1. #ifndef _MEGA644_H_
  2. #define _MEGA644_H_
  3. /* I (M. Thomas) could not find an official Boot-ID
  4. for the ATmega644 so pretend it's an ATmega64 */
  5. /* Part-Code ISP */
  6. #define DEVTYPE_ISP 0x45
  7. /* Part-Code Boot */
  8. #define DEVTYPE_BOOT 0x46
  9. #define SIG_BYTE1 0x1E
  10. #define SIG_BYTE2 0x96
  11. #define SIG_BYTE3 0x09
  12. #ifdef UART_DOUBLESPEED
  13. #define UART_CALC_BAUDRATE(baudRate) ((uint32_t)(F_CPU) / ((uint32_t)(baudRate) *8) -1)
  14. #else
  15. #define UART_CALC_BAUDRATE(baudRate) ((uint32_t)(F_CPU) / ((uint32_t)(baudRate)*16) -1)
  16. #endif
  17. #define UART_BAUD_HIGH UBRR0H
  18. #define UART_BAUD_LOW UBRR0L
  19. #define UART_STATUS UCSR0A
  20. #define UART_TXREADY UDRE0
  21. #define UART_RXREADY RXC0
  22. #define UART_DOUBLE U2X0
  23. #define UART_CTRL UCSR0B
  24. #define UART_CTRL_DATA ((1<<TXEN0) | (1<<RXEN0))
  25. #define UART_CTRL2 UCSR0C
  26. #define UART_CTRL2_DATA ( (1<<UCSZ01) | (1<<UCSZ00))
  27. #define UART_DATA UDR0
  28. #define WDT_OFF_SPECIAL
  29. static inline void bootloader_wdt_off(void)
  30. {
  31. cli();
  32. wdt_reset();
  33. /* Clear WDRF in MCUSR */
  34. MCUSR &= ~(1<<WDRF);
  35. /* Write logical one to WDCE and WDE */
  36. /* Keep old prescaler setting to prevent unintentional time-out */
  37. WDTCSR |= (1<<WDCE) | (1<<WDE);
  38. /* Turn off WDT */
  39. WDTCSR = 0x00;
  40. }
  41. #endif // #ifndef _MEGA644_H_