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.

48 lines
1.2KB

  1. #ifndef _MEGAxx4_H_
  2. #define _MEGAxx4_H_
  3. #ifndef UART_USE_SECOND
  4. /* UART 0 */
  5. #define UART_BAUD_HIGH UBRR0H
  6. #define UART_BAUD_LOW UBRR0L
  7. #define UART_STATUS UCSR0A
  8. #define UART_TXREADY UDRE0
  9. #define UART_RXREADY RXC0
  10. #define UART_DOUBLE U2X0
  11. #define UART_CTRL UCSR0B
  12. #define UART_CTRL_DATA ((1<<TXEN0) | (1<<RXEN0))
  13. #define UART_CTRL2 UCSR0C
  14. #define UART_CTRL2_DATA ( (1<<UCSZ01) | (1<<UCSZ00))
  15. #define UART_DATA UDR0
  16. #else
  17. /* UART 1 */
  18. #define UART_BAUD_HIGH UBRR1H
  19. #define UART_BAUD_LOW UBRR1L
  20. #define UART_STATUS UCSR1A
  21. #define UART_TXREADY UDRE1
  22. #define UART_RXREADY RXC1
  23. #define UART_DOUBLE U2X1
  24. #define UART_CTRL UCSR1B
  25. #define UART_CTRL_DATA ((1<<TXEN1) | (1<<RXEN1))
  26. #define UART_CTRL2 UCSR1C
  27. #define UART_CTRL2_DATA ( (1<<UCSZ11) | (1<<UCSZ10))
  28. #define UART_DATA UDR1
  29. #endif
  30. #define WDT_OFF_SPECIAL
  31. static inline void bootloader_wdt_off(void)
  32. {
  33. cli();
  34. wdt_reset();
  35. /* Clear WDRF in MCUSR */
  36. MCUSR &= ~(1<<WDRF);
  37. /* Write logical one to WDCE and WDE */
  38. /* Keep old prescaler setting to prevent unintentional time-out */
  39. WDTCSR |= (1<<WDCE) | (1<<WDE);
  40. /* Turn off WDT */
  41. WDTCSR = 0x00;
  42. }
  43. #endif // #ifndef _MEGA644_H_