My application firmware enumerates as a keyboard USB device, or as a BusPal protocol translator USB device. I must be able to switch between the two. I could reenumerate from the application software as the other USB device without resetting the MCU, but there is a lot of state involved in the firmware, and I'd rather not maintain the state upon switches.
Instead, I'd much rather reset the MCU to clean its state, and enumerate as the desired device. But for this to work, I have to store some state, so that the application firmware can branch to the USB keyboard routine vs the BusPal routine.
Is there any way to save state across resets? For example by using a register, SRAM or any other means? I used to use AVR microcontrollers and this was possible with AVRs. What about the K22? Also, what kind of reset should I use? Software reset, watchdog reset, or anything else?
Thank you for your help!