Skip to content

Commit

Permalink
Merge pull request #72 from VOGL-electronic/spiflash_add_module
Browse files Browse the repository at this point in the history
spi_nor_flash_module.py: fix read_cmds array
  • Loading branch information
enjoy-digital committed Sep 11, 2024
2 parents 283e053 + 097c23e commit e4fa736
Show file tree
Hide file tree
Showing 2 changed files with 11 additions and 2 deletions.
7 changes: 7 additions & 0 deletions litespi/modules/generated_modules.py
Original file line number Diff line number Diff line change
Expand Up @@ -8121,9 +8121,16 @@ class W25Q128JV(SpiNorFlashModule):
SpiNorFlashOpCodes.PP_1_1_2,
SpiNorFlashOpCodes.READ_1_1_4,
SpiNorFlashOpCodes.PP_1_1_4,
SpiNorFlashOpCodes.READ_1_2_2,
SpiNorFlashOpCodes.READ_1_4_4,
]
dummy_bits = 8

dummy_cycles = {
SpiNorFlashOpCodes.READ_1_2_2: 0,
SpiNorFlashOpCodes.READ_1_4_4: 4,
}


class W25Q16DW(SpiNorFlashModule):

Expand Down
6 changes: 4 additions & 2 deletions litespi/spi_nor_flash_module.py
Original file line number Diff line number Diff line change
Expand Up @@ -146,15 +146,15 @@ def _configure_chip(self, default_read_cmd,

# Check if program command is supported
if program_cmd not in self.supported_opcodes:
raise ValueError("Read command (%s) not supported in chip %s!" % (str(read_cmd), self.name))
raise ValueError("Programm command (%s) not supported in chip %s!" % (str(program_cmd), self.name))

# Set commands
self.read_opcode = default_read_cmd
self.program_opcode = program_cmd
self.erase_opcode = erase_cmd

def __init__(self, default_read_cmd,
read_cmds=[],
read_cmds=None,
program_cmd=SpiNorFlashOpCodes.PP_1_1_1,
erase_cmd=SpiNorFlashOpCodes.SE):
# Check if mandatory attributes are set by an inheritor
Expand All @@ -167,6 +167,8 @@ def __init__(self, default_read_cmd,
assert hasattr(self, 'supported_opcodes')
assert hasattr(self, 'dummy_bits') or hasattr(self, 'dummy_cycles')

if read_cmds is None:
read_cmds = []
# Make sure default read command is on the list
if default_read_cmd not in read_cmds:
read_cmds.append(default_read_cmd)
Expand Down

0 comments on commit e4fa736

Please sign in to comment.