Previously they used historical "pyb" affix causing confusion and
inconsistency (there's no "pyb" module in modern ports; but people
took esp8266 port as an example, and "pyb" naming kept proliferating,
while other people complained that source structure is not clear).
machine.POWER_ON is renamed to machine.PWRON_RESET to match other
reset-cause constants that all end in _RESET. The cc3200 port keeps a
legacy definition of POWER_ON for backwards compatibility.
When dealing with a board which controls chip reset with UART's DTR/RTS,
we never see REASON_DEFAULT_RST (0), only REASON_EXT_SYS_RST (6). However,
trying a "raw" module with with just TXD/RXD UART connection, on power up
it has REASON_DEFAULT_RST as a reset reason.
modpybhspi now does the needed multiplexing, calling out to modpybspi
(bitbanging SPI) for suitable peripheral ID's. modmachinespi (previous
multiplexer class) thus not needed and removed.
modpybhspi also updated to following standard SPI peripheral naming:
SPI0 is used for FlashROM and thus not supported so far. SPI1 is available
for users, and thus needs to be instantiated as:
spi = machine.SPI(1, ...)
By design, at wake up from deepsleep, the RTC timer will be reset, but
the data stored in RTC memory will not [1]. Therefore, we have to adjust
delta in RTC memory before going into deepsleep to get almost correct
time after waking up.
[1] http://bbs.espressif.com/viewtopic.php?t=1184#p4082
Use the machine.deepsleep() function to enter the sleep mode. Use the
RTC to configure the alarm to wake the device.
Basic use is the following:
import machine
# configure RTC's ALARM0 to wake device from deep sleep
rtc = machine.RTC()
rtc.irq(trigger=rtc.ALARM0, wake=machine.DEEPSLEEP)
# do other things
# ...
# set ALARM0's alarm to wake after 10 seconds
rtc.alarm(rtc.ALARM0, 10000)
# enter deep-sleep state (system is reset upon waking)
machine.deepsleep()
To detect if the system woke from a deep sleep use:
if machine.reset_cause() == machine.DEEPSLEEP_RESET:
print('woke from deep sleep')
PWM implementation uses a timer and interrupts (FRC1), taken from
Espressif's/NodeMCU's implementation and adapted for our use.
8 channels are supported, on pins 0, 2, 4, 5, 12, 13, 14, 15.
Usage:
import machine
pwm0 = machine.PWM(machine.Pin(0))
pwm0.freq(1000)
pwm0.duty(500)
Frequency is shared (ie the same) for all channels. Frequency is
between 1 and 1000. Duty is between 0 and 1023.
This cleans up vstr so that it's a pure "variable buffer", and the user
can decide whether they need to add a terminating null byte. In most
places where vstr is used, the vstr did not need to be null terminated
and so this patch saves code size, a tiny bit of RAM, and makes vstr
usage more efficient. When null termination is needed it must be
done explicitly using vstr_null_terminate.
Blanket wide to all .c and .h files. Some files originating from ST are
difficult to deal with (license wise) so it was left out of those.
Also merged modpyb.h, modos.h, modstm.h and modtime.h in stmhal/.