winIDEA SDK
test_storage_flush.py
1# This script is licensed under BSD License, see file LICENSE.txt.
2#
3# (c) TASKING Germany GmbH, 2023
4
5import isystem.connect as ic
6
7
8winidea_id = ''
9
10
11def test_flush():
12 connMgr = ic.ConnectionMgr()
13 connMgr.connect(ic.CConnectionConfig().instanceId(winidea_id))
14
15 devName = "ST STM32C0x6 (32 kB)"
16 optCtrl = ic.COptionController(connMgr, ic.CStorageDeviceFactory.DEVICES_OPT_URL)
17 devIndex = optCtrl.index_of("Name", devName)
18 print("Index of the item whose 'Name' attribute has value " + devName + f": {devIndex}")
19
20 storageCtrl = ic.CStorageDeviceFactory.makeDevice(connMgr, ic.EStorageDevice_EmbeddedFlashDevice, devIndex)
21
22 print("Create program cache data (16 bytes)...")
23 data = ic.VectorBYTE()
24 for index in range(16):
25 data.append(index)
26 storageCtrl.write(ic.IConnectUMI.wProgCache, 0x08000000, 16, data)
27
28 print(f"Flushing cache data to a device with index: {devIndex}")
29 storageCtrl.flush()
30
31
32if __name__ == "__main__":
33 test_flush()