Mercurial > louis > kiibohd-controller
comparison Output/uartOut/arm/uart_serial.c @ 370:39e338a6733d
Fixing default ErgoDox layout and adding FlashMode button
- Adds proper flashMode support for all keyboards and microcontrollers (usb and serial)
- flashModeEnabled must be set to 1 otherwise it will only show an error
* This is on purpose (somewhat dangerous feature as it allows remote flashing)
- Capability cleanup
author | Jacob Alexander <haata@kiibohd.com> |
---|---|
date | Fri, 21 Aug 2015 19:43:45 -0700 |
parents | e8841d3c6db5 |
children |
comparison
equal
deleted
inserted
replaced
369:ce9720634c15 | 370:39e338a6733d |
---|---|
25 #include <string.h> // For memcpy | 25 #include <string.h> // For memcpy |
26 | 26 |
27 // Project Includes | 27 // Project Includes |
28 #include <Lib/OutputLib.h> | 28 #include <Lib/OutputLib.h> |
29 #include <Lib/Interrupts.h> | 29 #include <Lib/Interrupts.h> |
30 #include <print.h> | |
31 #include <kll_defs.h> | |
30 | 32 |
31 // Local Includes | 33 // Local Includes |
32 #include "uart_serial.h" | 34 #include "uart_serial.h" |
33 | 35 |
34 | 36 |
323 } | 325 } |
324 | 326 |
325 | 327 |
326 void uart_device_reload() | 328 void uart_device_reload() |
327 { | 329 { |
330 if ( flashModeEnabled_define == 0 ) | |
331 { | |
332 print( NL ); | |
333 warn_print("flashModeEnabled not set, cancelling firmware reload..."); | |
334 info_msg("Set flashModeEnabled to 1 in your kll configuration."); | |
335 return; | |
336 } | |
337 | |
338 // MCHCK | |
339 #if defined(_mk20dx128vlf5_) | |
340 | |
341 // MCHCK Kiibohd Variant | |
342 // Check to see if PTA3 (has a pull-up) is connected to GND (usually via jumper) | |
343 // Only allow reload if the jumper is present (security) | |
344 GPIOA_PDDR &= ~(1<<3); // Input | |
345 PORTA_PCR3 = PORT_PCR_PFE | PORT_PCR_MUX(1); // Internal pull-up | |
346 | |
347 // Check for jumper | |
348 if ( GPIOA_PDIR & (1<<3) && flashModeEnabled_define != 0 ) | |
349 { | |
350 print( NL ); | |
351 warn_print("Security jumper not present, cancelling firmware reload..."); | |
352 info_msg("Replace jumper on middle 2 pins, or manually press the firmware reload button."); | |
353 } | |
354 else | |
355 { | |
356 // Copies variable into the VBAT register, must be identical to the variable in the bootloader to jump to the bootloader flash mode | |
357 for ( int pos = 0; pos < sizeof(sys_reset_to_loader_magic); pos++ ) | |
358 (&VBAT)[ pos ] = sys_reset_to_loader_magic[ pos ]; | |
359 SOFTWARE_RESET(); | |
360 } | |
361 | |
362 // Kiibohd mk20dx256vlh7 | |
363 #elif defined(_mk20dx256vlh7_) | |
364 // Copies variable into the VBAT register, must be identical to the variable in the bootloader to jump to the bootloader flash mode | |
365 for ( int pos = 0; pos < sizeof(sys_reset_to_loader_magic); pos++ ) | |
366 (&VBAT)[ pos ] = sys_reset_to_loader_magic[ pos ]; | |
367 SOFTWARE_RESET(); | |
368 | |
369 // Teensy 3.0 and 3.1 | |
370 #else | |
328 asm volatile("bkpt"); | 371 asm volatile("bkpt"); |
329 } | 372 #endif |
330 | 373 } |
374 |