These have by default FAT support. The SAMD21 build does not support FAT.
The nrf port also implements os.sync(), but has it's own copy of moduos.c.
Code size increases seen: 40 to 56 bytes.
Signed-off-by: robert-hh <robert@hammelrath.com>
Avoiding code duplication. To enable it, set MICROPY_PY_UOS_SYNC in the
port's mpconfigport.h. It is operational only for FAT file system. For
other filesystems it's a no-op.
Signed-off-by: robert-hh <robert@hammelrath.com>
The hal_entry.c code is duplicated across all boards, so consolidate it to
a common ra_hal.c file. And remove the hal_entry() function because it
simply calls main().
Signed-off-by: Damien George <damien@micropython.org>
Also fix MAX_ENDPOINT definition for G0, which follows G4.
This work was funded through GitHub Sponsors.
Signed-off-by: Jim Mussared <jim.mussared@gmail.com>
By specifying rts=pin(x) and/or cts=Pin(x) in the constructor. The pad
numbers for the UART pins are fix in this case: TX must be at pad 0, RX at
pad 1, RTS at pad 2 and CTS at pad 3.
repr(uart) shows the pin names for rts and cts, if set. In case of a RX
overflow, the rx interrupt will be disabled instead of just discarding the
data. That allows RTS to act.
If RTS is inactive, still 2 bytes can be buffered in the FIFO.
Signed-off-by: robert-hh <robert@hammelrath.com>
With Crystal: set the crystal startup wait time to 1 second. It was 2
seconds before, and that seeemed too long.
With USB-Sync: scan for up to 1 second for the USB to be registered and
carry on with boot as soon as it it. Before, the code just waited for
500ms.
Side change: improve related comments.
Signed-off-by: robert-hh <robert@hammelrath.com>
These include ADC, DAC, I2C, SoftI2C, SPI, SoftI2C, PWM, UART, pulse. This
is useful for devices like the Adafruit Trinket series which have almost no
accessible GPIO pins.
Signed-off-by: robert-hh <robert@hammelrath.com>
If sockets were open when calling soft reset, gc_sweep_all() would try to
close them. In case of e.g. the NINA WiFi handler, connected through SPI,
spi_transfer() would be called for command exchange with the NINA module.
But at that time SerCom was already disabled.
Moving sercom_deinit_all() behind gc_sweep_all() solves this issue.
Signed-off-by: robert-hh <robert@hammelrath.com>
Such that they are easier to adapt. The maximum code size is set by:
MICROPY_HW_CODESIZE=xxxK
in mpconfigmcu.mk for the MCU family as default or in mpconfigboard.mk for
a specific board. Setting the maximum code size allows the loader to error
out if the code gets larger than the space dedicated for it.
Signed-off-by: robert-hh <robert@hammelrath.com>
This commit adds the "--escape-non-printable" option to the repl command.
When specified the REPL console will escape non-printable characters,
printing them as their hex value in square brackets.
This escaping behaviour was previously the default and only behaviour, but
it is now opt-in.
As part of this change, the speed of echoing device data to the console is
improved by by reading and writing in chunks.
Signed-off-by: Damien George <damien@micropython.org>
Change UART clock source on S3/C3 so the UART can operate when CPU
frequency is below 80MHz. This allows the UART to remain operational when
using Dynamic Frequency Scaling (DFS).
Signed-off-by: Patrick Joy <patrick@joytech.com.au>
This commit enables the ULP for the S2 and S3 chips.
Note this is the FSM (Finite State Machine) ULP.
Signed-off-by: Patrick Joy <patrick@joytech.com.au>
Once all the firmware has been flashed and the final signatures checked,
mboot writes the "all good" byte into the header of the application. This
step uses the buffer firmware_head which, if unaligned in the build, fails
when cast to a uint64_t* in flash.c.
Signed-off-by: Andrew Leech <andrew.leech@planetinnovation.com.au>
These were incorrectly added in d995c01042.
The fix here includes the full differential ADC definitions.
Signed-off-by: brave ulysses <brave_ulysses@email.com>
Update docs/library/espnow.rst to add:
- guidance on using WLAN.config(pm=WLAN.PM_NONE) for reliable
espnow performance while also connected to a wifi access point;
- guidance on receiving encrypted messages;
- correction for default value of "encrypt" parameter (add_peer());
- guidance on use of ESPNow.irq(): recommand users readout all messages
in the buffer each time the callback is called.
Signed-off-by: Glenn Moloney <glenn.moloney@gmail.com>
The code that handles inplace-operator to normal-binary-operator fallback
is moved in this commit from py/objtype.c to py/runtime.c, making it apply
to all types, not just user classes.
Signed-off-by: Damien George <damien@micropython.org>
So that user types can implement reverse operators and have them work with
str on the left-hand-side, eg `"a" + UserType()`.
Signed-off-by: Damien George <damien@micropython.org>
This adds a unary_op implementation for the dict_view type that makes
the implementation of `hash()` for these types compatible with CPython.
Signed-off-by: David Lechner <david@pybricks.com>
As per https://bugs.python.org/issue408326, the slice object should not be
hashable. Since MicroPython has an implicit fallback when the unary_op
slot is empty, we need to fill this slot.
Signed-off-by: David Lechner <david@pybricks.com>
Since converting to variable sized slots in mp_obj_type_t, we can now
reduce the code size a bit by removing mp_generic_unary_op() and the
corresponding slots where it is used. Instead we just implement the
generic `__hash__` operation in the runtime.
Signed-off-by: David Lechner <david@pybricks.com>
When the network module was first introduced in the esp8266 port in
ee3fec3167 there was only one interface (STA)
and, to save flash, the WLAN object was aliased to the network module,
which had just static methods for WLAN operations. This was subsequently
changed in 9e8396accb when the AP interface
was introduced, and the WLAN object became a true class.
But, network.WLAN remained a function that returned either the STA or AP
object and was never upgraded to the type itself. This scheme was then
copied over to the esp32 port when it was first introduced.
This commit changes network.WLAN from a function to a reference to the WLAN
type. This makes it consistent with other ports and network objects, and
allows accessing constants of network.WLAN without creating an instance.
Signed-off-by: Damien George <damien@micropython.org>
Previously when using --via-mpy, the file was compiled to tests/<tmp>.mpy
and then run using `micropython -m <tmp>` in the current cwd
(usually tests/). This meant that an import in the test would be resolved
relative to tests/.
This is different to regular (non-via-mpy) tests, where we run (for
example) `micropython basics/test.py` which means that an import would be
resolved relative to basics/.
Now --via-mpy matches the .py behavior. This is important because:
a) It makes it so import tests do the right thing.
b) There are directory names in tests/ that match built-in module names.
Furthermore, it always ensures the cwd (for both micropython and cpython)
is the test directory (e.g. basics/) rather than being left unset. This
also makes it clearer inside the test that e.g. file access is relative to
the Python file.
Updated tests with file paths to match.
This work was funded through GitHub Sponsors.
Signed-off-by: Jim Mussared <jim.mussared@gmail.com>