Author Topic: Function to reboot digispark in to bootloader from your program  (Read 2932 times)

Bluebie

  • Sr. Member
  • ****
  • Posts: 486
Function to reboot digispark in to bootloader from your program
« on: February 07, 2013, 06:31:35 pm »
If you're installing a digispark in some odd place and it's going to be a hassle to unplug it and plug it back in to do a software upgrade, you might like to add a feature to your program to reboot it in to the bootloader on demand. Here's a function you can use to do this!

Code: [Select]
void reboot(void) {
  void (*ptrToFunction)(); // function pointer
  ptrToFunction = 0x0000; // set pointer to go to chip reset vector
  (*ptrToFunction)(); // jump to reset, which bounces in to bootloader
}

I think it'd be pretty cool if this code was built in to the DigiUSB library so we could have a 'reboot digispark' button appear in the digispark arduino program for digiusb-based projects, allowing it to automatically reboot to take program uploads. Whatcha think, digistump?