# HG changeset patch # User Windel Bouwman # Date 1359191072 -3600 # Node ID 14e739ed03aba43e12f385a06ea6cdd596925acc # Parent 0a540ce31cd5bb967fb442b6b36e9ca3ee517dbb Added halt stub diff -r 0a540ce31cd5 -r 14e739ed03ab python/st-util.py --- 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() diff -r 0a540ce31cd5 -r 14e739ed03ab python/stlink.py --- 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): diff -r 0a540ce31cd5 -r 14e739ed03ab python/stm32.py --- 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