diff --git a/README.md b/README.md index 0217bf6..bfd6c43 100644 --- a/README.md +++ b/README.md @@ -63,16 +63,14 @@ python setup.py install ``` Open the Python interpreter and connect nRF5 device to PC: ``` -from pynrfjprog import API - -api = API.API('NRF52') -api.open() -api.enum_emu_snr() -api.connect_to_emu_without_snr() -api.erase_all() -api.write_u32(ADDRESS, DATA, IS_FLASH) -api.disconnect_from_emu() -api.close() +from pynrfjprog import LowLevel + +with LowLevel.API('NRF52') as api: + api.enum_emu_snr() + api.connect_to_emu_without_snr() + api.erase_all() + api.write_u32(ADDRESS, DATA, IS_FLASH) + api.disconnect_from_emu() ``` To work with multiple nRF5 devices at once: @@ -98,25 +96,20 @@ To program hex files using the HighLevel API: ``` from pynrfjprog import HighLevel -api = HighLevel.API() -api.open() - -# To program J-Link probe at snr : -probe = HighLevel.DebugProbe(api, ) -probe.program() -probe.close() +with HighLevel.API() as api: + snrs = api.get_connected_probes() -# To program MCUBoot target at serial port : -probe = HighLevel.MCUBootDFUProbe(api, ) -probe.program() -probe.close() + # To program J-Link probe at snr : + with HighLevel.DebugProbe(api, ) as probe: + probe.program() -# To update LTE modem connected to J-Link prbe at snr : -probe = HighLevel.IPCDFUProbe(api, ) -probe.program() -probe.close() + # To program MCUBoot target at serial port : + with HighLevel.MCUBootDFUProbe(api, ) as probe: + probe.program() -api.close() + # To update LTE modem connected to J-Link probe at snr : + with HighLevel.IPCDFUProbe(api, , HighLevel.CoProcessor.CP_MODEM) as probe: + probe.program(, HighLevel.ProgramOptions(verify = HighLevel.VerifyAction.VERIFY_HASH)) ``` Note: Only one HighLevel API can be instantiated and opened at a time. But, several HighLevel probes can be opened from the same API at the same time, as long as you don't open two probes to the same target.