Beispiel #1
0
    def ChipErase(self):
        """Erase all memory on target chip"""

        s = PicKit2ScriptBuilder()

        s += SpiUtils.CSLowScript()
        s.SpiWriteByte(0x60)
        s += SpiUtils.CSHighScript()

        self.__pickit.RunScriptImmediate(s)
Beispiel #2
0
    def WriteDisable(self):
        """Send the write disable command"""

        s = PicKit2ScriptBuilder()

        s += SpiUtils.CSLowScript()
        s.SpiWriteByte(0x04)
        s += SpiUtils.CSHighScript()

        self.__pickit.RunScriptImmediate(s)
Beispiel #3
0
    def StartReadData(self, address=0):
        """Issue the continuous data read instruction (leaves CS# low)"""

        s = PicKit2ScriptBuilder()

        s += SpiUtils.CSLowScript()
        s.SpiWriteByte(0x03)
        s.SpiWriteByte((address >> 16) & 0xff)
        s.SpiWriteByte((address >> 8) & 0xff)
        s.SpiWriteByte(address & 0xff)

        self.__pickit.RunScriptImmediate(s)
Beispiel #4
0
    def ReadDecodedStatus(self):
        """Read and decode the status register"""

        s = PicKit2ScriptBuilder()

        s += SpiUtils.CSLowScript()
        s.SpiWriteByte(0x05)
        s.SpiReadByteBuffer()
        s += SpiUtils.CSHighScript()

        self.__pickit.RunScriptImmediate(s)
        return self.DecodeStatus(self.__pickit.ReadData()[0])
Beispiel #5
0
    def ReadJedecId(self):
        """Read the JEDEC ID from the flash chip"""

        s = PicKit2ScriptBuilder()

        s += SpiUtils.CSLowScript()
        s.SpiWriteByte(0x9f)
        s.SpiReadByteBuffer()
        s.SpiReadByteBuffer()
        s.SpiReadByteBuffer()
        s += SpiUtils.CSHighScript()

        self.__pickit.RunScriptImmediate(s)
        return self.__pickit.ReadData()
Beispiel #6
0
    def WritePage(self, address):
        """Issue the page program instruction for the given address, reading 256 bytes from the writebuffer"""

        s = PicKit2ScriptBuilder()

        s += SpiUtils.CSLowScript()
        s.SpiWriteByte(0x02)
        s.SpiWriteByte(address >> 16)
        s.SpiWriteByte(address >> 8)
        s.SpiWriteByte(address)

        s.SetLabel('loop')
        s.SpiWriteByteBuffer()
        s.Repeat('loop', 256)

        s += SpiUtils.CSHighScript()

        self.__pickit.RunScriptImmediate(s)