sdcityrobotics / Scarborough_ROS

This is the Scarborough software in the ROS environment
0 stars 0 forks source link

When ARDI2C is started up it chokes on reading the I2C bus #26

Open Ximidar opened 7 years ago

Ximidar commented 7 years ago
killed: 0

Failed to write reg: Connection timed out
Failed to write reg: Connection timed out
depth: 0

killed: 1

Failed to write reg: Connection timed out
Failed to write reg: Connection timed out
depth: 0

killed: 1

^CFailed to write reg: Connection timed out
Failed to write reg: Connection timed out
depth: 0

killed: 1

We need to make code to restart the teensy on ArdI2C startup.

Ximidar commented 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.