changeset 143:1cc59ac80950

Fixed halt button
author Windel Bouwman
date Sun, 27 Jan 2013 13:18:53 +0100
parents 982ddb5f786d
children 59a9a499e518
files python/ide.py python/st-util.py python/stlink.py
diffstat 3 files changed, 38 insertions(+), 17 deletions(-) [+]
line wrap: on
line diff
--- a/python/ide.py	Sun Jan 27 12:18:28 2013 +0100
+++ b/python/ide.py	Sun Jan 27 13:18:53 2013 +0100
@@ -157,6 +157,7 @@
     self.devxplr.deviceSelected.connect(self.regview.mdl.setDevice)
     self.devxplr.deviceSelected.connect(self.memview.setDevice)
     self.devxplr.deviceSelected.connect(self.ctrlToolbar.setDevice)
+    self.ctrlToolbar.statusChange.connect(self.regview.refresh)
 
     # About dialog:
     self.aboutDialog = AboutDialog()
--- a/python/st-util.py	Sun Jan 27 12:18:28 2013 +0100
+++ b/python/st-util.py	Sun Jan 27 13:18:53 2013 +0100
@@ -52,7 +52,6 @@
          col = index.column()
          if role == Qt.EditRole and col == 1:
             value = int(value, 16)
-            print(row, value, type(row), type(value))
             self.device.iface.write_reg(row, value)
             return True
       return False
@@ -63,14 +62,22 @@
          if col == 1:
             return super().flags(index) | Qt.ItemIsEditable
       return super().flags(index)
+   def refresh(self):
+      if self.device:
+         fromIndex = self.index(0, 1)
+         toIndex = self.index(21, 1)
+         self.dataChanged.emit(fromIndex, toIndex)
 
 class RegisterView(QTableView):
    def __init__(self):
       super().__init__()
       self.mdl = RegisterModel()
       self.setModel(self.mdl)
+   def refresh(self):
+      self.mdl.refresh()
 
 class MemoryView(QWidget):
+   BlockSize = 0x100
    def __init__(self):
       super().__init__()
       l = QVBoxLayout(self)
@@ -78,30 +85,44 @@
       l2.addWidget(QLabel('Address'))
       self.addressLine = QLineEdit()
       self.addressLine.setInputMask('Hhhhhhhh')
-      self.addressLine.setText('08000000')
       l2.addWidget(self.addressLine)
+      upButton = QPushButton('up')
+      l2.addWidget(upButton)
+      upButton.clicked.connect(self.doUp)
+      downButton = QPushButton('down')
+      downButton.clicked.connect(self.doDown)
+      l2.addWidget(downButton)
       l.addLayout(l2)
       self.device = None
       self.hexEdit = HexEdit()
-      self.loadAddress(0x8000000)
+      self.Address = 0x8000000
       l.addWidget(self.hexEdit)
       self.addressLine.returnPressed.connect(self.doLoad)
    def doLoad(self):
       txt = self.addressLine.text()
       self.loadAddress(int(txt, 16))
-   def loadAddress(self, address):
-      size = 512
+   def getAddress(self):
+      txt = self.addressLine.text()
+      return int(txt, 16)
+   def doUp(self):
+      self.Address -= self.BlockSize
+   def doDown(self):
+      self.Address += self.BlockSize
+   def setAddress(self, address):
       if self.device:
-         data = self.device.iface.read_mem32(address, size)
+         data = self.device.iface.read_mem32(address, self.BlockSize)
       else:
-         data = bytearray(size)
+         data = bytearray(self.BlockSize)
       self.hexEdit.bv.Data = data
       self.hexEdit.bv.Offset = address
+      self.addressLine.setText('{0:08X}'.format(address))
+   Address = property(getAddress, setAddress)
    def setDevice(self, dev):
       self.device = dev
-      self.loadAddress(0x8000000)
+      self.Address = 0x8000000
 
 class DebugToolbar(QToolBar):
+   statusChange = pyqtSignal()
    def __init__(self):
       super().__init__()
       self.device = None
@@ -119,14 +140,10 @@
    def updateEnables(self):
       if self.device:
          self.resetAction.setEnabled(True)
-         if self.device.Running:
-            self.runAction.setEnabled(False)
-            self.stepAction.setEnabled(False)
-            self.stopAction.setEnabled(True)
-         else:
-            self.runAction.setEnabled(True)
-            self.stepAction.setEnabled(True)
-            self.stopAction.setEnabled(False)
+         self.runAction.setEnabled(not self.device.Running)
+         self.stepAction.setEnabled(not self.device.Running)
+         self.stopAction.setEnabled(self.device.Running)
+         self.statusChange.emit()
       else:
          self.resetAction.setEnabled(False)
          self.runAction.setEnabled(False)
--- a/python/stlink.py	Sun Jan 27 12:18:28 2013 +0100
+++ b/python/stlink.py	Sun Jan 27 13:18:53 2013 +0100
@@ -26,6 +26,7 @@
 DEBUG_EXIT = 0x21
 DEBUG_ENTER_SWD = 0xa3
 DEBUG_GETSTATUS = 0x01
+DEBUG_FORCEDEBUG = 0x02
 DEBUG_RESETSYS = 0x03
 DEBUG_READALLREGS = 0x04
 DEBUG_READREG = 0x5
@@ -167,7 +168,9 @@
       cmd[0:2] = DEBUG_COMMAND, DEBUG_RUNCORE
       self.send_recv(cmd, 2)
    def halt(self):
-      pass
+      cmd = bytearray(16)
+      cmd[0:2] = DEBUG_COMMAND, DEBUG_FORCEDEBUG
+      self.send_recv(cmd, 2)
 
    # Helper 1 functions:
    def write_debug32(self, address, value):