From a6e8d7e0337571a181cb2c0ccefb8ca219d3df62 Mon Sep 17 00:00:00 2001 From: optixx Date: Wed, 2 Sep 2009 21:34:10 +0200 Subject: [PATCH] check bootloader enalbe io line --- avr/bootloader/bootloader.c | 20 ++++++++++++++++++++ 1 file changed, 20 insertions(+) diff --git a/avr/bootloader/bootloader.c b/avr/bootloader/bootloader.c index b09a1f6..874e184 100644 --- a/avr/bootloader/bootloader.c +++ b/avr/bootloader/bootloader.c @@ -33,6 +33,10 @@ #include "config.h" #include "usbdrv/usbdrv.c" + + + + /* * USBasp requests, taken from the original USBasp sourcecode */ @@ -74,6 +78,10 @@ (LED_DIR ^= (1 << LED_PIN)));} +#define AVR_BTLDR_EN_PORT PORTC +#define AVR_BTLDR_EN_DIR DDRC +#define AVR_BTLDR_EN_PIN PC1 +#define AVR_BTLDR_EN_IN PINC /* @@ -449,6 +457,18 @@ int __attribute__ ((noreturn, OS_main)) main(void) uint16_t delay = 0; timeout = TIMEOUT; + DDRC &= ~(1 << AVR_BTLDR_EN_PIN); + PORTC &= ~(1 << AVR_BTLDR_EN_PIN); + + if ((AVR_BTLDR_EN_IN & ( 1 << AVR_BTLDR_EN_PIN)) == 0){ + banner(); + uart_puts("Bootloader flashing is disabled\n\r"); + MCUSR = 0; + leave_bootloader(); + + } + + /* * if power-on reset, quit bootloader via watchdog reset