+ // MCHCK Kiibohd Variant
+ // Check to see if PTA3 (has a pull-up) is connected to GND (usually via jumper)
+ // Only allow reload if the jumper is present (security)
+ GPIOA_PDDR &= ~(1<<3); // Input
+ PORTA_PCR3 = PORT_PCR_PFE | PORT_PCR_MUX(1); // Internal pull-up
+
+ // Check for jumper
+ if ( GPIOA_PDIR & (1<<3) )
+ {
+ print( NL );
+ warn_print("Security jumper not present, cancelling firmware reload...");
+ info_msg("Replace jumper on middle 2 pins, or manually press the firmware reload button.");
+ }
+ else
+ {
+ // This line must be exactly the same in the bootloader
+ const uint8_t sys_reset_to_loader_magic[] = "\xff\x00\x7fRESET TO LOADER\x7f\x00\xff";
+ for ( int pos = 0; pos < sizeof(sys_reset_to_loader_magic); pos++ )(&VBAT)[pos] = sys_reset_to_loader_magic[ pos ];
+ SOFTWARE_RESET();
+ }
+