summaryrefslogtreecommitdiffstats
path: root/libtoprammer/chips/microchip8/microchip8_singlePMarea.py
blob: 8eea33be073283596b082ac2f33f0bb30bd0e750 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
"""
#    TOP2049 Open Source programming suite
#
#    pic8_singlePMarea - file for older 8bit PIC MCUs
#
#    Copyright (c) 2013 Pavel Stemberk <stemberk@gmail.com>
#
#    This program is free software; you can redistribute it and/or modify
#    it under the terms of the GNU General Public License as published by
#    the Free Software Foundation; either version 2 of the License, or
#    (at your option) any later version.
#
#    This program is distributed in the hope that it will be useful,
#    but WITHOUT ANY WARRANTY; without even the implied warranty of
#    MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
#    GNU General Public License for more details.
#
#    You should have received a copy of the GNU General Public License along
#    with this program; if not, write to the Free Software Foundation, Inc.,
#    51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
"""

from libtoprammer.chips.microchip8.microchip8_common import *

class microchip8_singlePMarea(Chip_Microchip8_common):
	CMD_BEGIN_PROGRAMMING = 0x08
	CMD_END_PROGRAMMING = 0x0E

	userIDLocationSize = 4

	voltageVDD = 5
	voltageVPP = 13
	defaultWord = [b'\xFF', b'\x0F']

	def __init__(self,
	    chipPackage, chipPinVCC, chipPinsVPP, chipPinGND,
	    signature,
	    flashPageSize, flashPages,
	    eepromPageSize, eepromPages,
	    fuseBytes
	    ):
		Chip_Microchip8_common.__init__(self, chipPackage, chipPinVCC, chipPinsVPP, chipPinGND, signature, flashPageSize, flashPages, eepromPageSize, eepromPages, fuseBytes)
		self.initPcValue		 = self.logicalFlashSize - 1
		self.configWordAddr = self.logicalFlashSize - 1
		self.osccalAddr = self.flashPageSize - 1
		self.userIDLocationAddr = self.flashPageSize
		self.osccalBackupAddr = self.userIDLocationAddr + self.userIDLocationSize

	def getIHexInterpreter(self):
		inter = IHexInterpreter()
		inter.progmemRanges = [ AddressRange(0, 2 * self.flashPageSize) ]
		inter.fuseRanges = [ AddressRange(2 * self.configWordAddr,
						  2 * self.configWordAddr + 1),
				     AddressRange(2 * 0xFFF,
						  2 * 0xFFF + 1) ]
		inter.uilRanges = [ AddressRange(2 * self.userIDLocationAddr,
						 2 * (self.userIDLocationAddr + self.userIDLocationSize) - 1) ]
		inter.progmemDefaultBytes = self.defaultWord[0] + self.defaultWord[1]
		inter.fuseDefaultBytes = self.defaultWord[0] + self.defaultWord[1]
		return inter

	def setPC(self, address):
		while(self.PC != address):
			self.incrementPC(1)
		
	def incrementPC(self, count):
		for address in range(0, count):
			self.sendCommand(0, 0, 0, self.CMD_INCREMENT_ADDRESS)
			self.PC += 1
			if (self.PC == self.logicalFlashSize):
				self.PC = 0
    
	def sendWriteFlashInstr(self):
		'''
		'''
		# self.loadCommand(self.PROGCMD_SENDDATA)
		# self.top.hostDelay(0.000005)
		self.sendCommand(0, 0, 0, self.CMD_BEGIN_PROGRAMMING)
		self.top.cmdDelay(self.delayTprog)  # 025) #Tprog
		self.sendCommand(0, 0, 0, self.CMD_END_PROGRAMMING)
		self.top.cmdDelay(self.delayTdis)  # Tdis
    
	def sendWriteFlashInstrDM(self):
		self.sendWriteFlashInstr()

	def sendWriteFlashInstrCW(self):
		self.sendWriteFlashInstr()	
bues.ch cgit interface