diff --git a/bootloader/Makefile b/bootloader/Makefile index c98fa34..a7a38fa 100644 --- a/bootloader/Makefile +++ b/bootloader/Makefile @@ -25,6 +25,7 @@ CC = avr-gcc DEFINES = -DMODELIBMMODELM #DEFINES = -DMODELMAYHEM #DEFINES = -DMODELSUNTYPE5 +#DEFINES = -DMODELIBMHOST CFLAGS = -Wall -Os -I. -mmcu=$(DEVICE) -DF_CPU=$(F_CPU) $(DEFINES) LDFLAGS = -Wl,--section-start=.text=$(BOOTLOADER_ADDRESS) diff --git a/bootloader/bootloaderconfig.h b/bootloader/bootloaderconfig.h index 8884efb..4350f08 100644 --- a/bootloader/bootloaderconfig.h +++ b/bootloader/bootloaderconfig.h @@ -194,6 +194,20 @@ static inline void bootLoaderInit(void) { SRSTROBEON; SRSTROBEOFF; } #endif +#ifdef MODELIBMHOST +static inline void bootLoaderInit(void) { + // choose matrix position for hotkey. we use KEY_D, so we set row 13 + DDRA = 0x00; + PORTA = 0xff; + DDRC = (1 << DDC2); + PORTC = ~(1 << PINC2); + DDRD &= ~((1 << PIND4) | (1 << PIND5) | (1 << PIND6) | (1 << PIND7)); + PORTD |= ((1 << PIND4) | (1 << PIND5) | (1 << PIND6) | (1 << PIND7)); + // and later look for column 6 + DDRB &= ~(1 << PB6); + PORTB |= (1 << PB6); +} +#endif /** * Clean up after boot loader action. In this case: switch off all LEDs. @@ -216,6 +230,11 @@ static inline void bootLoaderExit(void) { PORTB |= (1 << PB4) | (1 << PB5) | (1 << PB6) | (1 << PB7); } #endif +#ifdef MODELIBMHOST +static inline void bootLoaderExit(void) { + // do nothing +} +#endif /** * Check if conditions for boot loader are met. This function is called in an @@ -307,6 +326,18 @@ static inline uint8_t bootLoaderCondition() { } } #endif +#ifdef MODELIBMHOST +static inline uint8_t bootLoaderCondition() { + // look for pin 6 + if (!(PINB & (1 << PINB6))) { + // boot loader active + return 1; + } else { + // no boot loader + return 0; + } +} +#endif #endif /* __ASSEMBLER__ */