Implement ErgoDox.resetDevice()

Can be used to reset the device, and put it into programmable mode, from within
the firmware.

Signed-off-by: Gergely Nagy <algernon@keyboard.io>
pull/427/head^2
Gergely Nagy 6 years ago
parent bd913cde2b
commit 39763abbb5

@ -125,6 +125,39 @@ void ErgoDox::setStatusLEDBrightness(uint8_t led, uint8_t brightness) {
(OCR1C = brightness);
}
void ErgoDox::resetDevice() {
cli();
UDCON = 1;
USBCON = (1 << FRZCLK);
UCSR1B = 0;
_delay_ms(5);
EIMSK = 0;
PCICR = 0;
SPCR = 0;
ACSR = 0;
EECR = 0;
ADCSRA = 0;
TIMSK0 = 0;
TIMSK1 = 0;
TIMSK3 = 0;
TIMSK4 = 0;
UCSR1B = 0;
TWCR = 0;
DDRB = 0;
DDRC = 0;
DDRD = 0;
DDRE = 0;
DDRF = 0;
TWCR = 0;
PORTB = 0;
PORTC = 0;
PORTD = 0;
PORTE = 0;
PORTF = 0;
asm volatile("jmp 0x7E00");
}
}
}

@ -73,6 +73,8 @@ class ErgoDox {
void setStatusLED(uint8_t led, bool state = true);
void setStatusLEDBrightness(uint8_t led, uint8_t brightness);
void resetDevice();
private:
static ErgoDoxScanner scanner_;
static uint8_t previousKeyState_[ROWS];

Loading…
Cancel
Save