comparison python/stm32.py @ 131:04e45faafd1d

Added register view
author Windel Bouwman
date Sat, 19 Jan 2013 18:41:49 +0100
parents 654093a9a1e3
children 14e739ed03ab
comparison
equal deleted inserted replaced
130:654093a9a1e3 131:04e45faafd1d
18 FLASH_CR_MER = 2 18 FLASH_CR_MER = 2
19 FLASH_F4_CR_SNB = 3 19 FLASH_F4_CR_SNB = 3
20 FLASH_F4_CR_SNB_MASK = 0x38 20 FLASH_F4_CR_SNB_MASK = 0x38
21 FLASH_F4_SR_BSY = 16 21 FLASH_F4_SR_BSY = 16
22 22
23 @registerDevice(0x10016413)
24 class Stm32F4(Device): 23 class Stm32F4(Device):
25 """ 24 """
26 Implementation of the specifics of the STM32F4xx device series. 25 Implementation of the specifics of the STM32F4xx device series.
27 """ 26 """
28 def __init__(self, iface): 27 def __init__(self, iface):
29 super().__init__(iface) 28 super().__init__(iface)
30 # Assert the proper size for this device:
31 assert self.FlashSize == 0x100000
32 """
33 from 0x8000000 to 0x80FFFFF
34 4 sectors of 0x4000 (16 kB)
35 1 sector of 0x10000 (64 kB)
36 7 of 0x20000 (128 kB)
37 """
38 self.sectorsizes = [0x4000] * 4 + [0x10000] + [0x20000] * 7
39 def __str__(self): 29 def __str__(self):
40 return 'STM32F4 device size=0x{1:X} id=0x{0:X}'.format(\ 30 return 'STM32F4 device size=0x{1:X} id=0x{0:X}'.format(\
41 self.UID, self.FlashSize) 31 self.UID, self.FlashSize)
42 def calculate_F4_sector(self, address): 32 def calculate_F4_sector(self, address):
43 sectorstarts = [] 33 sectorstarts = []
234 for bit, msg in errorbits.items(): 224 for bit, msg in errorbits.items():
235 if sr & (1 << bit) == (1 << bit): 225 if sr & (1 << bit) == (1 << bit):
236 raise STLinkException(msg) 226 raise STLinkException(msg)
237 return sr & mask == mask 227 return sr & mask == mask
238 228
229 @registerDevice(0x10016413)
230 class Stm32F40x(Stm32F4):
231 """ STM32F40x and STM32F41x device series """
232 def __init__(self, iface):
233 super().__init__(iface)
234 # Assert the proper size for this device:
235 assert self.FlashSize == 0x100000
236 """
237 from 0x8000000 to 0x80FFFFF
238 4 sectors of 0x4000 (16 kB)
239 1 sector of 0x10000 (64 kB)
240 7 of 0x20000 (128 kB)
241 """
242 self.sectorsizes = [0x4000] * 4 + [0x10000] + [0x20000] * 7
243