QSpiFlash class

class QSpiFlash

Initialize a a QspiFlash peripheral (external flash memory handled by qspi). This peripheral is available only for stm32l4 family chip and for Polaris Tracker device the auto_init is implemented (pins and memory data already configured).

To initialize a custom external memory qspi flash several params must be passed to the init method:

Parameters:
  • d0 – D0 pin of the Qspi peripheral
  • d1 – D1 pin of the Qspi peripheral
  • d2 – D2 pin of the Qspi peripheral
  • d3 – D3 pin of the Qspi peripheral
  • clk – CLK pin of the Qspi peripheral
  • cs – CS pin of the Qspi peripheral
  • flash_size – Flash size of the qspi flash
  • block_size – Block size of the qspi flash
  • subblock_size – Sub-block size of the qspi flash

:param sector_size Sector size of the qspi flash :param page_size: Page size of the qspi flash :param dummy_cycles_read: Dummy cycles simple read :param dummy_cycles_read_dual: Dummy cycles Dual flash read :param dummy_cycles_read_quad: Dummy cicles Quad Flash read :param dummy_cycles_2read: Dummy cycles 2read :param dummy_cycles_4read: Dummy Cycles 4read :param alt_bytes_pe_mode: Alternate Bytes for PE mode :param alt_bytes_no_pe_mode: Alternate Bytes for NO PE mode :param sr_wip: Write in progress of the flash mamory status register :param sr_wel: Write enable latch of the flash mamory status register :param sr_bp: Block protect of the flash mamory status register :param sr_srwd: Write disable of the flash mamory status register :param sr1_qe: Quad enable of the flash mamory status register1 :param sr1_sus: Suspend status of the flash mamory status register1

write_data(addr, data)

Write data data starting from address addr. data can be a bytearray or a list of integers less than 256.

erase_sector() MUST be called before writing data in a sector.

Writing is also allowed via bracket notation. The following is valid syntax:

my_flash[addr] = data
erase_sector(addr)

Erase a whole sector passing the addr address of any byte contained in it. All sector bytes set to 0xff.

erase_block(addr)

Erase a memory block passing the addr address of any byte contained in it. All block bytes set to 0xff.

read_data(addr, n=1)

Read n bytes of data starting from address addr.

Reading is also allowed via bracket notation. The following is valid syntax:

my_data = my_flash[addr:addr+n]
chip_erase()

Erase the whole memory. All memory bytes set to 0xff.

done()

Close the QspiFlash peripheral.

wakeup()

Wake Up the QspiFlash peripheral from sleep mode.

sleep()

Put the QspiFlash peripheral in sleep mode.