Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
122 changes: 61 additions & 61 deletions boot/main/boot.py
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Copilot, asked why the changeset is so big:

The changed file boot/main/boot.py previously used Windows-style line endings (CRLF, shown as \r\n) and has now been updated to use Unix-style line endings (LF, shown as \n) in this pull request. This means the PR has standardized the file to LF line endings, which is typical for Python projects and avoids problems across platforms.

Original file line number Diff line number Diff line change
@@ -1,64 +1,64 @@
# boot.py -- run on boot-up
# can run arbitrary Python, but best to keep it minimal
import pyb, os, micropython, time
import sys
# Clean sys.path from qspi
# Shouldn't happen in production, but just in case.
for p in sys.path:
if "qspi" in sys.path:
sys.path.remove(p)
# power hold
pwr = pyb.Pin("B15", pyb.Pin.OUT)
pwr.on()
version = "<version:tag10>0100900099</version:tag10>"
# get i2c
i2c = pyb.I2C(1)
i2c.init()
# start measurements
if 112 in i2c.scan():
i2c.mem_write(0b00010000, 112, 0)
leds = [pyb.LED(i) for i in range(1,5)]
# poweroff on button press
def pwrcb(e):
micropython.schedule(poweroff, 0)
# callback scheduled from the interrupt
def poweroff(_):
# make sure it disables power no matter what
try:
for led in leds:
led.toggle()
# stop battery manangement
if 112 in i2c.scan():
i2c.mem_write(0, 112, 0)
# sync filesystem
os.sync()
time.sleep_ms(300)
finally:
# disable power
pwr.off()
time.sleep_ms(300)
# will never reach here
for led in leds:
led.toggle()
pyb.ExtInt(pyb.Pin('B1'), pyb.ExtInt.IRQ_FALLING, pyb.Pin.PULL_NONE, pwrcb)
# configure usb from start if you want,
# otherwise will be configured after PIN
# pyb.usb_mode("VCP+MSC") # debug mode with USB and mounted storages from start
# pyb.usb_mode("VCP") # debug mode with USB from start
# disable at start
pyb.usb_mode(None)
os.dupterm(None,0)
os.dupterm(None,1)
# inject version and i2c to platform module
# boot.py -- run on boot-up
# can run arbitrary Python, but best to keep it minimal
import pyb, os, micropython, time
import sys

# Clean sys.path from qspi
# Shouldn't happen in production, but just in case.
for p in sys.path:
if "qspi" in sys.path:
sys.path.remove(p)

# power hold
pwr = pyb.Pin("B15", pyb.Pin.OUT)
pwr.on()

version = "<version:tag10>0101000099</version:tag10>"

# get i2c
i2c = pyb.I2C(1)
i2c.init()
# start measurements
if 112 in i2c.scan():
i2c.mem_write(0b00010000, 112, 0)

leds = [pyb.LED(i) for i in range(1,5)]
# poweroff on button press
def pwrcb(e):
micropython.schedule(poweroff, 0)

# callback scheduled from the interrupt
def poweroff(_):
# make sure it disables power no matter what
try:
for led in leds:
led.toggle()
# stop battery manangement
if 112 in i2c.scan():
i2c.mem_write(0, 112, 0)
# sync filesystem
os.sync()
time.sleep_ms(300)
finally:
# disable power
pwr.off()
time.sleep_ms(300)
# will never reach here
for led in leds:
led.toggle()

pyb.ExtInt(pyb.Pin('B1'), pyb.ExtInt.IRQ_FALLING, pyb.Pin.PULL_NONE, pwrcb)

# configure usb from start if you want,
# otherwise will be configured after PIN
# pyb.usb_mode("VCP+MSC") # debug mode with USB and mounted storages from start
# pyb.usb_mode("VCP") # debug mode with USB from start
# disable at start
pyb.usb_mode(None)
os.dupterm(None,0)
os.dupterm(None,1)

# inject version and i2c to platform module
import platform
platform.version = version
platform.i2c = i2c
Expand Down
2 changes: 1 addition & 1 deletion bootloader
Loading