Open Ximidar opened 7 years ago
In the teensy we can use the following code to reset the board.
// Should restart Teensy 3, will also disconnect USB during restart
// From http://infocenter.arm.com/help/index.jsp?topic=/com.arm.doc.ddi0337e/Cihcbadd.html
// Search for "0xE000ED0C"
// Original question http://forum.pjrc.com/threads/24304-_reboot_Teensyduino%28%29-vs-_restart_Teensyduino%28%29?p=35981#post35981
#define RESTART_ADDR 0xE000ED0C
#define READ_RESTART() (*(volatile uint32_t *)RESTART_ADDR)
#define WRITE_RESTART(val) ((*(volatile uint32_t *)RESTART_ADDR) = (val))
void setup(){
// startup routine
pinMode(13, OUTPUT);
digitalWrite(13, HIGH);
for(int i = 0; i < 10; i++){
digitalWrite(13, !digitalRead(13));
delay(200);
}
delay(1000);
// 0000101111110100000000000000100
// Assert [2]SYSRESETREQ
WRITE_RESTART(0x5FA0004);
}
// Should never get here.
void loop(){}
We can bind this to a registry and have ARDI2C write to the registry on startup.
We need to make code to restart the teensy on ArdI2C startup.