The original ESP32 only supports timer source clock APB so it doesn't need
and doesn't have a clk_src field.
The ESP32C3 supports timer source clock APB and XTAL so it does have a
clk_src field, and this needs to be configured to get the correct period.
Fixes#8084.
Follow up to 8a91c719 to no longer explicitly disable BLE in
mpconfigport.h.
This work was funded through GitHub Sponsors.
Signed-off-by: Jim Mussared <jim.mussared@gmail.com>
Instead of defining `MICROPY_PY_BTREE` in `mpconfigport.h` we can define
it via CMake similar to how other ports that use Makefiles define it in
`mpconfigport.mk`.
Signed-off-by: David Lechner <david@pybricks.com>
If USB CDC is connected and the board sends data, but the host does not
receive the data, the device locks up. This is fixed in this commit by
having a timeout of 500ms, after which time the transmission is skipped.
Checks are added for pwm.freq(), pwm_duty(), pwm_duty_u10() and
pwm.duty_u16(). This avoids a core dump on ESP32C3, and misleading error
messages on Xtensa ESP32 devices.
Set the size of machine_pin_irq_handler array to GPIO_NUM_MAX:
- Min GPIO_NUM_MAX is 22 for IDF_TARGET_ESP32C3.
- Max GPIO_NUM_MAX is 49 for IDF_TARGET_ESP32S3.
The MP_REGISTER_ROOT_POINTER entry must be hard-coded, because the location
that it's evaluated by the compiler does not include the relevant IDF
header to get a definition of GPIO_NUM_MAX.
Each SoC family has its own clocks and timings/timeouts. For I2C, the
default source clock is either APB (ESP32, ESP32-S2) or XTAL (ESP32-S3,
ESP32-C3) as shown in the datasheets. Since
machine_i2c.c/machine_hw_i2c_init() uses the default clk_flags (0), the
alternate low-power clock source is never selected in ESP-IDF
i2c.c/i2c_param_config(). There is not an API in i2c.c to get the source
clock frequency, so a compile-time value is used based on SoC family.
Also, the maximum timeout is different across the SoC families, so use the
I2C_LL_MAX_TIMEOUT constant to eliminate the warning from
i2c_set_timeout().
With these changes, the following results were obtained. The I2C SCL
frequencies were measured with a Saleae logic analyzer.
ESP32 (TTGO T Dislay)
I2C(0, scl=22, sda=21, freq=101781) Measured: 100KHz
I2C(0, scl=22, sda=21, freq=430107) Measured: 400KHz
I2C(0, scl=22, sda=21, freq=1212121) Measured: 941KHz
ESP32-S3 (TTGO T-QT)
I2C(0, scl=34, sda=33, freq=111111) Measured: 107KHz
I2C(0, scl=34, sda=33, freq=444444) Measured: 400KHz
I2C(0, scl=34, sda=33, freq=1111111) Measured: 842KHz
ESP32-C3 (XIAO ESP32C3)
I2C(0, scl=7, sda=6, freq=107816) Measured: 103KHz
I2C(0, scl=7, sda=6, freq=444444) Measured: 380KHz
I2C(0, scl=7, sda=6, freq=1176470) Measured: 800KHz
(ESP32-S2 board was not available for testing.)
Auto DMA channel is supported in IDF v4.4, and is required to be used on S3
chips, so use this simpler configuration option where possible.
Fixes issue #8634.
Signed-off-by: Damien George <damien@micropython.org>
Updates all README.md and docs, and manifests to `require("mip")`.
Also extend and improve the documentation on freezing and packaging.
This work was funded through GitHub Sponsors.
Signed-off-by: Jim Mussared <jim.mussared@gmail.com>
Instead of being an explicit field, it's now a slot like all the other
methods.
This is a marginal code size improvement because most types have a make_new
(100/138 on PYBV11), however it improves consistency in how types are
declared, removing the special case for make_new.
Signed-off-by: Jim Mussared <jim.mussared@gmail.com>
The goal here is to remove a slot (making way to turn make_new into a slot)
as well as reduce code size by the ~40 references to mp_identity_getiter
and mp_stream_unbuffered_iter.
This introduces two new type flags:
- MP_TYPE_FLAG_ITER_IS_ITERNEXT: This means that the "iter" slot in the
type is "iternext", and should use the identity getiter.
- MP_TYPE_FLAG_ITER_IS_CUSTOM: This means that the "iter" slot is a pointer
to a mp_getiter_iternext_custom_t instance, which then defines both
getiter and iternext.
And a third flag that is the OR of both, MP_TYPE_FLAG_ITER_IS_STREAM: This
means that the type should use the identity getiter, and
mp_stream_unbuffered_iter as iternext.
Finally, MP_TYPE_FLAG_ITER_IS_GETITER is defined as a no-op flag to give
the default case where "iter" is "getiter".
Signed-off-by: Jim Mussared <jim.mussared@gmail.com>
Changes in this commit:
- Manifest include's now use the directory path where possible (no longer
necessary to include the manifest.py file explicitly).
- Add manifest.py for all drivers and components that are referenced by
port/board manifests.
- Replace all uses of freeze() with package()/module(), except for port and
board modules.
- Use opt=3 everywhere, for consistency and to reduce code size.
- Use require() instead of include() for all micropython-lib references.
- Remove support for optional board-level manifest.py in mimxrt port, to
make it behave the same as other ports (the board must set
FROZEN_MANIFEST to a custom manifest.py, which can optionally include the
default, port-level manifest).
- Also reinstates modules that were accidentally removed from the esp8266
512k build in fbe9417b90.
Signed-off-by: Jim Mussared <jim.mussared@gmail.com>
Signed-off-by: Damien George <damien@micropython.org>
uart.flush()
flush() will wait until all characters have been sent.To
avoid a permanent lock, a timeout applies depending on the
size of txbuf and the baud rate.
ret = uart.txdone()
ret is True if no transfer is in progress.
ret is False otherwise.
So that everything is reset and the SD card can be created again after
calling SDCard.deinit() (and after a soft reset).
Fixes issue #8949.
Signed-off-by: Damien George <damien@micropython.org>
Having two separate manifests is confusing. It's simpler to have the daily
builds use the same configuration as the stable, release builds.
Signed-off-by: Damien George <damien@micropython.org>
Previously the desired output type was specified. Now make the type part
of the function name. Because this function is used in a few places this
saves code size due to smaller call-site.
This makes `mp_obj_new_str_type_from_vstr` a private function of objstr.c
(which is almost the only place where the output type isn't a compile-time
constant).
This saves ~140 bytes on PYBV11.
Signed-off-by: Jim Mussared <jim.mussared@gmail.com>
It used to be 10 bit times, which is too short. The break state must be
longer than a regular character time, at least 13 bit times. This is now
implemented by reducing the baudrate while sending the "0". The break time
will now vary with data length and parity setting, but will at least be 15
bit times.
Tested with a GENERIC_SPIRAM, GENERIC_C3 and UM_TINYS2 board.
Set the channel with esp_wifi_set_channel(), which adds support for setting
the channel of the STA interface
Get the channel with esp_wifi_get_channel() which returns the actual wifi
channel of the radio, rather than the configured channel.
The ntptime module was previously only included in the ESP8266 port. This
commit factors that module out into the extmod directory, makes it support
different epochs, and includes it in the rp2 port.
Also use mkrules.mk's submodule target rather than duplicating the call to
`submodule sync`.
Until we can find a way to use idf.py/cmake to discover submodules we have
no way to discover optional or board-specific submodules so need to err on
the side of including everything.
Signed-off-by: Jim Mussared <jim.mussared@gmail.com>
This uses MP_REGISTER_ROOT_POINTER() to register bluetooth_nimble_memory
and bluetooth_nimble_root_pointers and removes the same from all
mpconfigport.h.
Signed-off-by: David Lechner <david@pybricks.com>
This uses MP_REGISTER_ROOT_POINTER() to register the readline_history root
pointer array used by shared/readline.c and removes the registration from
all mpconfigport.h files.
This also required adding a new MICROPY_READLINE_HISTORY_SIZE config option
since not all ports used the same sized array.
Signed-off-by: David Lechner <david@pybricks.com>
Prior to this commit, running scan() without any APs available would give:
>>> wl.scan()
Traceback (most recent call last):
File "<stdin>", line 1, in <module>
RuntimeError: Wifi Unknown Error 0x0102
Signed-off-by: Damien George <damien@micropython.org>
Add esp32.wake_on_ulp() to give access to esp_sleep_enable_ulp_wakeup(),
which is needed to allow the ULP co-processor to wake the main CPU from
deep sleep.
Allow esp32.ULP.load_binary() to use the maximum amount of memory available
again, which is 2040 bytes unless MICROPY_HW_RTC_USER_MEM_MAX is
customized.
This value regressed in 3d49b157b8
Using it for the rx-timeout. The value is given as ms, which is then
converted to character times. A value of less than a character time will
cause the rx call to return immediately after 1 character, which may be
inefficient at high transmission rates.
Addresses #8778.
The WLAN.config() method now supports "ssid", "security" and "key" as
aliases to the existing "essid", "authmode" and "password", which are now
deprecated.
Addresses issue #8083.
When MICROPY_PY_MACHINE_I2C_TRANSFER_WRITE1 is enabled the port's hardware
I2C transfer functions should support the MP_MACHINE_I2C_FLAG_WRITE1
option, but software I2C will not. So add a flag to the I2C protocol
struct so each individual protocol can indicate whether it supports this
option or not.
Fixes issue #8765.
Signed-off-by: Damien George <damien@micropython.org>