If raw registers are usied in config, write the registers to the chip after setting...
authorJim Morris <morris@wolfman.com>
Thu, 31 Mar 2016 20:31:05 +0000 (13:31 -0700)
committerJim Morris <morris@wolfman.com>
Thu, 31 Mar 2016 20:31:05 +0000 (13:31 -0700)
src/modules/utils/motordrivercontrol/MotorDriverControl.cpp
src/modules/utils/motordrivercontrol/drivers/TMC26X/TMC26X.cpp

index 2ed27a6..b09bc71 100644 (file)
@@ -147,13 +147,23 @@ bool MotorDriverControl::config_module(uint16_t cs)
     if(!str.empty()) {
         rawreg= true;
         std::vector<uint32_t> regs= parse_number_list(str.c_str(), 16);
-        uint32_t reg= 0;
-        for(auto i : regs) {
+        if(!regs.empty()) {
+            uint32_t reg= 0;
+            for(auto i : regs) {
+                // this just sets the local storage, it does not write to the chip
+                switch(chip) {
+                    case DRV8711: drv8711->set_raw_register(&StreamOutput::NullStream, ++reg, i); break;
+                    case TMC2660: tmc26x->setRawRegister(&StreamOutput::NullStream, ++reg, i); break;
+                }
+            }
+
+            // write the stored registers
             switch(chip) {
-                case DRV8711: drv8711->set_raw_register(&StreamOutput::NullStream, ++reg, i); break;
-                case TMC2660: tmc26x->setRawRegister(&StreamOutput::NullStream, ++reg, i); break;
+                case DRV8711: drv8711->set_raw_register(&StreamOutput::NullStream, 255, 0); break;
+                case TMC2660: tmc26x->setRawRegister(&StreamOutput::NullStream, 255, 0); break;
             }
         }
+
     }else{
         rawreg= false;
     }
index a20bd6d..caab5b8 100644 (file)
@@ -1026,7 +1026,7 @@ bool TMC26X::checkAlarm()
 }
 
 // sets a raw register to the value specified, for advanced settings
-// register 0 writes them, 255 displays what registers are mapped to what
+// register 255 writes them, 0 displays what registers are mapped to what
 // FIXME status registers not reading back correctly, check docs
 bool TMC26X::setRawRegister(StreamOutput *stream, uint32_t reg, uint32_t val)
 {