Skip to content
Snippets Groups Projects
Commit 417be96f authored by Michael DM Dryden's avatar Michael DM Dryden
Browse files

Add automatic software reboot when USB port closed.

parent 7592c15f
Branches
No related merge requests found
Pipeline #98 passed with stage
in 35 seconds
......@@ -9,11 +9,22 @@
#include "leds.h"
#include "config/conf_board.h"
#include <ioport.h>
#include <util/atomic.h>
void my_callback_cdc_set_rts(uint8_t port, uint8_t b_enable){
static uint8_t connected = 0;
#if BOARD_VER_MAJOR >= 1 && BOARD_VER_MINOR >= 2 && BOARD_VER_MICRO >=3
ioport_set_pin_level(LED2, b_enable);
#endif
if (connected && !b_enable){
ATOMIC_BLOCK(ATOMIC_RESTORESTATE){
CCP = 0xD8; // Configuration change protection: allow protected IO regiser write
RST.CTRL = RST_SWRST_bm; // Request software reset by writing to protected IO register
}
}
connected = b_enable;
}
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment