Being able to send data out in LSB format can be useful, and having support
in the low-level driver is much better than requiring Python code to
reorder the bits before sending them / after receiving them. In particular
if the hardware does not support the LSB format (eg RP2040) then one needs
to use the SoftSPI in LSB mode.
For this change a default definition of `MICROPY_PY_MACHINE_SPI_MSB/_LSB`
was added to `py/mpconfig.h`, making them available to all ports. The
identical defines in `esp32/mpconfigport.h` were deleted.
Resolves issues #5340, #11404.
Signed-off-by: robert-hh <robert@hammelrath.com>
The only AP security mode supported is actually WPA/WPA2 not WEP. The
firmware command `0x19` starts the AP using `WIFI_AUTH_WPA_WPA2_PSK`
mode.
There are no functional changes in this commit, it just fixes the constant
names and removes the useless sanity checks for WEP.
Signed-off-by: iabdalkader <i.abdalkader@gmail.com>
The STATIC macro was introduced a very long time ago in commit
d5df6cd44a. The original reason for this was
to have the option to define it to nothing so that all static functions
become global functions and therefore visible to certain debug tools, so
one could do function size comparison and other things.
This STATIC feature is rarely (if ever) used. And with the use of LTO and
heavy inline optimisation, analysing the size of individual functions when
they are not static is not a good representation of the size of code when
fully optimised.
So the macro does not have much use and it's simpler to just remove it.
Then you know exactly what it's doing. For example, newcomers don't have
to learn what the STATIC macro is and why it exists. Reading the code is
also less "loud" with a lowercase static.
One other minor point in favour of removing it, is that it stops bugs with
`STATIC inline`, which should always be `static inline`.
Methodology for this commit was:
1) git ls-files | egrep '\.[ch]$' | \
xargs sed -Ei "s/(^| )STATIC($| )/\1static\2/"
2) Do some manual cleanup in the diff by searching for the word STATIC in
comments and changing those back.
3) "git-grep STATIC docs/", manually fixed those cases.
4) "rg -t python STATIC", manually fixed codegen lines that used STATIC.
This work was funded through GitHub Sponsors.
Signed-off-by: Angus Gratton <angus@redyak.com.au>
This commit changes all uses in the rp2 port, and drivers that are
optionally supported by that port.
The old MICROPY_EVENT_POLL_HOOK and MICROPY_EVENT_POLL_HOOK_FAST macros are
no longer used for rp2 builds and are removed (C user code will need to be
changed to suit).
Also take the opportunity to change some timeouts that used 64-bit
arithmetic to 32-bit, to hopefully claw back a little code size.
This work was funded through GitHub Sponsors.
Signed-off-by: Angus Gratton <angus@redyak.com.au>
The contents of machine_mem.h, machine_i2c.h and machine_spi.h have been
moved into extmod/modmachine.h.
Signed-off-by: Damien George <damien@micropython.org>
The contents of machine_bitstream.h, machine_pinbase.h, machine_pulse.h and
machine_signal.h have been moved into extmod/modmachine.h.
Signed-off-by: Damien George <damien@micropython.org>
The machine_i2c_type, machine_spi_type and machine_timer_type symbols are
already declared in extmod/modmachine.h and should not be declared anywhere
else.
Also move declarations of machine_pin_type and machine_rtc_type to the
common header in extmod.
Signed-off-by: Damien George <damien@micropython.org>
This is a code factoring to have the Python bindings in one location, and
all the ports use those same bindings. For all ports except the two listed
below there is no functional change.
The nrf port has UART.sendbreak() removed, but this method previously did
nothing.
The zephyr port has the following methods added:
- UART.init(): supports setting timeout and timeout_char.
- UART.deinit(): does nothing, just returns None.
- UART.flush(): raises OSError(EINVAL) because it's not implemented.
- UART.any() and UART.txdone(): raise NotImplementedError.
Signed-off-by: Damien George <damien@micropython.org>
This patch reinstalls the pin IRQ handler on WiFi init, as some
ports disable/remove pin IRQs on soft-reboot, or deinit the pins.
Signed-off-by: iabdalkader <i.abdalkader@gmail.com>
Fixes are:
- Reset the module first before changing GPIO1 direction.
- Skip spurious bytes received after reset.
- Use HCI UART ID and baudrate when reinitializing UART.
- Disable all printf output which causes unit-tests to fail.
Signed-off-by: iabdalkader <i.abdalkader@gmail.com>
This is a host driver for ESP32 chips running the esp-hosted firmware,
which turns ESP32s into a WLAN/BT co-processor.
Signed-off-by: iabdalkader <i.abdalkader@gmail.com>
This commit allows other ports to reuse the CYW43 HCI driver, by replacing
all Bluetooth UART and control named pins with defines in config files and
using `mpbthci` abstract functions (i.e. `mp_bluetooth_hci_*`) instead of
the STM32 specific UART functions.
Note: the function `cywbt_wait_cts_low` does not need to switch the CTS
pin from alternate function to GPIO to read it. At least on stm32, mimxrt
it's possible to just read the pin input. For example, see the STM32F7
RM0410 section 6.3.11, and the `SION` for IMXRT. So this function can
also be available for other ports if the pin mode switching is removed.
Signed-off-by: iabdalkader <i.abdalkader@gmail.com>
The QSPI driver provides the interface for using an on-board QSPI flash for
the filesystem. It provides the same methods as the driver for the
internal flash and uses the same name. Therefore, only one of the drivers
for internal flash, SPI flash and QSPI flash must be enabled at a time.
Signed-off-by: robert-hh <robert@hammelrath.com>
This removes the previous WiFi driver from drivers/cyw43 (but leaves behind
the BT driver), and makes the stm32 port (i.e. PYBD and Portenta) use the
new "lib/cyw43-driver" open-source driver already in use by the rp2 port.
Signed-off-by: Jim Mussared <jim.mussared@gmail.com>
This changes the signatures of QSPI write_cmd_data, write_cmd_addr_data and
read_cmd_qaddr_qdata so they return an error code. The softqspi and stm32
hardware qspi driver are updated to follow this new signature. Also the
spiflash driver is updated to use these new return values.
Signed-off-by: Damien George <damien@micropython.org>
Before this patch, WiFi connection was blocking, and could raise exceptions
if the connection failed for any reason (including timeouts). This doesn't
match the behavior of other WiFi modules, which connect asynchronously, and
requires handling of exceptions on connect. This change makes `connect()`
work asynchronously by scheduling code to poll connection status, and
handle reconnects (if needed), and return immediately without blocking.
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>
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>
Fixes:
- Should read `definitions` rather than `defintions`.
- Should read `resolution` rather than `resoultion`.
- Should read `inefficient` rather than `inefficent`.
- Should read `closed` rather than `closded`.
Signed-off-by: Tim Gates <tim.gates@iress.com>
1. Add -Wno-array-bounds to avoid false positive on gcc 12.1; see related
issue #8685.
2. Remove always-true not-NULL-check (Msg.Rsp.Args.Common.Bssid is an array
not a pointer).
3. Fix pointer-to-freed-stack in wlan_set_security.
Signed-off-by: Jim Mussared <jim.mussared@gmail.com>
Originally in drivers/ninaw10/nina_wifi_bsp.c but that isn't a QSTR source.
Also remove outdated commment about root pointers in mpconfigport.h.
Signed-off-by: Jim Mussared <jim.mussared@gmail.com>
This uses MP_REGISTER_ROOT_POINTER() to register mp_wifi_spi, mp_wifi_timer
and mp_wifi_sockpoll_list and removes the same from all mpconfigport.h.
Signed-off-by: David Lechner <david@pybricks.com>
For v2 cards that are standard capacity the read/write/erase commands take
byte address values. Use the result of CMD58 to distinguish SDSC from
SDHC/SDXC.
Signed-off-by: Damien George <damien@micropython.org>
For CSD v1.0 the computed size is in bytes, so convert it to number of
512-byte blocks, and then ioctl(4) will return the correct value.
Also implement ioctl(5) to return the block size, which is always 512.
Signed-off-by: Damien George <damien@micropython.org>