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.
 
 
 
 
 

54 lines
1.4 KiB

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