changeset 138:14e739ed03ab

Added halt stub
author Windel Bouwman
date Sat, 26 Jan 2013 10:04:32 +0100
parents 0a540ce31cd5
children 2ec4d4332b7a
files python/st-util.py python/stlink.py python/stm32.py
diffstat 3 files changed, 35 insertions(+), 7 deletions(-) [+]
line wrap: on
line diff
--- a/python/st-util.py	Fri Jan 25 23:47:34 2013 +0100
+++ b/python/st-util.py	Sat Jan 26 10:04:32 2013 +0100
@@ -46,6 +46,23 @@
             elif col == 1:
                v = self.device.iface.read_reg(row)
                return '0x{0:X}'.format(v)
+   def setData(self, index, value, role):
+      if index.isValid():
+         row = index.row()
+         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
+   def flags(self, index):
+      if index.isValid():
+         row = index.row()
+         col = index.column()
+         if col == 1:
+            return super().flags(index) | Qt.ItemIsEditable
+      return super().flags(index)
 
 class RegisterView(QTableView):
    def __init__(self):
@@ -96,31 +113,37 @@
          return a
       self.stepAction = genAction('Step', self.doStep)
       self.runAction = genAction('Run', self.doRun)
-      self.stopAction = genAction('Stop', self.doStop)
+      self.stopAction = genAction('Stop', self.doHalt)
       self.resetAction = genAction('Reset', self.doReset)
       self.updateEnables()
    def updateEnables(self):
       if self.device:
          self.resetAction.setEnabled(True)
-         if running:
+         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)
       else:
          self.resetAction.setEnabled(False)
-         self.runAction.setEnabled(True)
+         self.runAction.setEnabled(False)
          self.stepAction.setEnabled(False)
+         self.stopAction.setEnabled(False)
    def doStep(self):
       self.device.iface.step()
+      self.updateEnables()
    def doReset(self):
       self.device.iface.reset()
+      self.updateEnables()
    def doRun(self):
       self.device.iface.run()
-   def doStop(self):
-      pass
-      # TODO: self.device.iface.halt()
+      self.updateEnables()
+   def doHalt(self):
+      self.device.iface.halt()
+      self.updateEnables()
    def setDevice(self, dev):
       self.device = dev
       self.updateEnables()
--- a/python/stlink.py	Fri Jan 25 23:47:34 2013 +0100
+++ b/python/stlink.py	Sat Jan 26 10:04:32 2013 +0100
@@ -138,7 +138,6 @@
       part = (u32 >> 4) & 0xfff
       revision = u32 & 0xf
       return implementer_id, variant, part, revision
-
    def getStatus(self):
       cmd = bytearray(16)
       cmd[0:2] = DEBUG_COMMAND, DEBUG_GETSTATUS
@@ -167,6 +166,8 @@
       cmd = bytearray(16)
       cmd[0:2] = DEBUG_COMMAND, DEBUG_RUNCORE
       self.send_recv(cmd, 2)
+   def halt(self):
+      pass
 
    # Helper 1 functions:
    def write_debug32(self, address, value):
--- a/python/stm32.py	Fri Jan 25 23:47:34 2013 +0100
+++ b/python/stm32.py	Sat Jan 26 10:04:32 2013 +0100
@@ -1,5 +1,6 @@
 import time
 from devices import Device, registerDevice, STLinkException, Interface
+import stlink
 
 # F4 specifics:
 STM32_FLASH_BASE = 0x08000000
@@ -63,6 +64,9 @@
       f_id = self.iface.read_debug32(0x1FFF7A22)
       f_id = f_id >> 16
       return f_id * 1024
+   @property
+   def Running(self):
+      return self.iface.Status == stlink.CORE_RUNNING
    # flashing commands:
    def writeFlash(self, address, content):
       flashsize = self.FlashSize