Merge branch 'adafruit:main' into main

This commit is contained in:
BrainBoardz 2023-03-10 09:50:27 -05:00 committed by GitHub
commit 838450643e
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
8 changed files with 71 additions and 49 deletions

3
.gitmodules vendored
View File

@ -309,8 +309,7 @@
branch = circuitpython
[submodule "ports/raspberrypi/lib/cyw43-driver"]
path = ports/raspberrypi/lib/cyw43-driver
url = https://github.com/adafruit/cyw43-driver.git
branch = circuitpython8
url = https://github.com/georgerobotics/cyw43-driver.git
[submodule "ports/raspberrypi/lib/lwip"]
path = ports/raspberrypi/lib/lwip
url = https://github.com/adafruit/lwip.git

View File

@ -8,15 +8,15 @@ msgstr ""
"Project-Id-Version: \n"
"Report-Msgid-Bugs-To: \n"
"POT-Creation-Date: 2021-01-04 12:55-0600\n"
"PO-Revision-Date: 2023-02-24 23:20+0000\n"
"Last-Translator: Luis Ruiz San Segundo <luisan00@hotmail.com>\n"
"PO-Revision-Date: 2023-03-09 10:38+0000\n"
"Last-Translator: Jose David M <jquintana202020@gmail.com>\n"
"Language-Team: \n"
"Language: es\n"
"MIME-Version: 1.0\n"
"Content-Type: text/plain; charset=UTF-8\n"
"Content-Transfer-Encoding: 8bit\n"
"Plural-Forms: nplurals=2; plural=n != 1;\n"
"X-Generator: Weblate 4.16-dev\n"
"X-Generator: Weblate 4.16.2-dev\n"
#: main.c
msgid ""
@ -848,11 +848,11 @@ msgstr ""
#: shared-bindings/bitmaptools/__init__.c
msgid "Coordinate arrays have different lengths"
msgstr ""
msgstr "Las matrices de coordenadas tienen diferentes longitudes"
#: shared-bindings/bitmaptools/__init__.c
msgid "Coordinate arrays types have different sizes"
msgstr ""
msgstr "Las matrices de coordenadas tienen diferentes tamaños"
#: py/persistentcode.c
msgid "Corrupt .mpy file"

View File

@ -271,10 +271,17 @@ bool common_hal_busio_spi_write(busio_spi_obj_t *self,
size_t bytes_remaining = len;
// Maximum DMA transfer is 65535
while (bytes_remaining > 0) {
while (1) {
size_t to_send = (bytes_remaining > 65535) ? 65535 : bytes_remaining;
status = sercom_dma_write(self->spi_desc.dev.prvt, data + (len - bytes_remaining), to_send);
bytes_remaining -= to_send;
if (bytes_remaining > 0) {
// Multi-part transfer; let other things run before doing the next chunk.
RUN_BACKGROUND_TASKS;
} else {
// All done.
break;
}
}
} else {
struct io_descriptor *spi_io;

View File

@ -33,6 +33,7 @@
#include "driver/spi_common_internal.h"
#define SPI_MAX_DMA_BITS (SPI_MAX_DMA_LEN * 8)
#define MAX_SPI_TRANSACTIONS 10
static bool spi_never_reset[SOC_SPI_PERIPH_NUM];
static spi_device_handle_t spi_handle[SOC_SPI_PERIPH_NUM];
@ -59,7 +60,7 @@ static void set_spi_config(busio_spi_obj_t *self,
.clock_speed_hz = baudrate,
.mode = phase | (polarity << 1),
.spics_io_num = -1, // No CS pin
.queue_size = 1,
.queue_size = MAX_SPI_TRANSACTIONS,
.pre_cb = NULL
};
esp_err_t result = spi_bus_add_device(self->host_id, &device_config, &spi_handle[self->host_id]);
@ -213,47 +214,61 @@ bool common_hal_busio_spi_transfer(busio_spi_obj_t *self,
mp_raise_ValueError(translate("No MISO Pin"));
}
spi_transaction_t transaction = { 0 };
spi_transaction_t transactions[MAX_SPI_TRANSACTIONS];
// Round to nearest whole set of bits
int bits_to_send = len * 8 / self->bits * self->bits;
if (len <= 4) {
memset(&transactions[0], 0, sizeof(spi_transaction_t));
if (data_out != NULL) {
memcpy(&transaction.tx_data, data_out, len);
memcpy(&transactions[0].tx_data, data_out, len);
}
transaction.flags = SPI_TRANS_USE_TXDATA | SPI_TRANS_USE_RXDATA;
transaction.length = bits_to_send;
spi_device_transmit(spi_handle[self->host_id], &transaction);
transactions[0].flags = SPI_TRANS_USE_TXDATA | SPI_TRANS_USE_RXDATA;
transactions[0].length = bits_to_send;
spi_device_transmit(spi_handle[self->host_id], &transactions[0]);
if (data_in != NULL) {
memcpy(data_in, &transaction.rx_data, len);
memcpy(data_in, &transactions[0].rx_data, len);
}
} else {
int offset = 0;
int bits_remaining = bits_to_send;
int cur_trans = 0;
while (bits_remaining && !mp_hal_is_interrupted()) {
memset(&transaction, 0, sizeof(transaction));
transaction.length =
bits_remaining > SPI_MAX_DMA_BITS ? SPI_MAX_DMA_BITS : bits_remaining;
cur_trans = 0;
while (bits_remaining && (cur_trans != MAX_SPI_TRANSACTIONS)) {
memset(&transactions[cur_trans], 0, sizeof(spi_transaction_t));
if (data_out != NULL) {
transaction.tx_buffer = data_out + offset;
}
if (data_in != NULL) {
transaction.rx_buffer = data_in + offset;
transactions[cur_trans].length =
bits_remaining > SPI_MAX_DMA_BITS ? SPI_MAX_DMA_BITS : bits_remaining;
if (data_out != NULL) {
transactions[cur_trans].tx_buffer = data_out + offset;
}
if (data_in != NULL) {
transactions[cur_trans].rx_buffer = data_in + offset;
}
bits_remaining -= transactions[cur_trans].length;
// doesn't need ceil(); loop ends when bits_remaining is 0
offset += transactions[cur_trans].length / 8;
cur_trans++;
}
spi_device_transmit(spi_handle[self->host_id], &transaction);
bits_remaining -= transaction.length;
for (int i = 0; i < cur_trans; i++) {
spi_device_queue_trans(spi_handle[self->host_id], &transactions[i], portMAX_DELAY);
}
// doesn't need ceil(); loop ends when bits_remaining is 0
offset += transaction.length / 8;
RUN_BACKGROUND_TASKS;
spi_transaction_t *rtrans;
for (int x = 0; x < cur_trans; x++) {
RUN_BACKGROUND_TASKS;
spi_device_get_trans_result(spi_handle[self->host_id], &rtrans, portMAX_DELAY);
}
}
}
return true;

View File

@ -33,17 +33,23 @@ INC_CYW43 := \
-isystem lib/cyw43-driver/firmware \
-isystem lib/cyw43-driver/src \
-isystem lib/lwip/src/include \
-isystem sdk/src/rp2_common/pico_async_context/include/ \
-isystem sdk/src/rp2_common/pico_cyw43_arch/include/ \
-isystem sdk/src/rp2_common/pico_cyw43_driver/include/ \
-isystem sdk/src/rp2_common/pico_lwip/include/ \
-isystem sdk/src/rp2_common/pico_rand/include/ \
CFLAGS_CYW43 := -DCYW43_LWIP=1 -DPICO_CYW43_ARCH_THREADSAFE_BACKGROUND=1 -DCYW43_USE_SPI -DIGNORE_GPIO25 -DIGNORE_GPIO23 -DIGNORE_GPIO24 -DCYW43_LOGIC_DEBUG=0 -DCYW43_NETUTILS=1
SRC_SDK_CYW43 := \
src/common/pico_sync/sem.c \
src/rp2_common/cyw43_driver/cyw43_bus_pio_spi.c \
src/rp2_common/pico_async_context/async_context_base.c \
src/rp2_common/pico_async_context/async_context_threadsafe_background.c \
src/rp2_common/pico_cyw43_arch/cyw43_arch.c \
src/rp2_common/pico_cyw43_arch/cyw43_arch_threadsafe_background.c \
src/rp2_common/pico_lwip/nosys.c \
src/rp2_common/pico_lwip/random.c \
src/rp2_common/pico_cyw43_driver/cyw43_driver.c \
src/rp2_common/pico_cyw43_driver/cyw43_bus_pio_spi.c \
src/rp2_common/pico_lwip/lwip_nosys.c \
src/rp2_common/pico_rand/rand.c \
SRC_LWIP := \
shared/netutils/netutils.c \
@ -69,27 +75,15 @@ $(PIOASM):
$(Q)cmake -S pioasm -B $(BUILD)/pioasm
$(Q)$(MAKE) -C $(BUILD)/pioasm PioasmBuild
$(BUILD)/cyw43_bus_pio_spi.pio.h: sdk/src/rp2_common/cyw43_driver/cyw43_bus_pio_spi.pio $(PIOASM)
$(BUILD)/cyw43_bus_pio_spi.pio.h: sdk/src/rp2_common/pico_cyw43_driver/cyw43_bus_pio_spi.pio $(PIOASM)
$(Q)$(PIOASM) -o c-sdk $< $@
$(BUILD)/sdk/src/rp2_common/cyw43_driver/cyw43_bus_pio_spi.o: $(BUILD)/cyw43_bus_pio_spi.pio.h
$(BUILD)/sdk/src/rp2_common/pico_cyw43_driver/cyw43_bus_pio_spi.o: $(BUILD)/cyw43_bus_pio_spi.pio.h
CYW43_FIRMWARE_BIN = 43439A0-7.95.49.00.combined
$(BUILD)/cyw43_resource.o: lib/cyw43-driver/firmware/$(CYW43_FIRMWARE_BIN)
$(Q)$(OBJCOPY) -I binary -O elf32-littlearm -B arm \
--readonly-text \
--rename-section .data=.big_const,contents,alloc,load,readonly,data \
--redefine-sym _binary_lib_cyw43_driver_firmware_43439A0_7_95_49_00_combined_start=fw_43439A0_7_95_49_00_start \
--redefine-sym _binary_lib_cyw43_driver_firmware_43439A0_7_95_49_00_combined_size=fw_43439A0_7_95_49_00_size \
--redefine-sym _binary_lib_cyw43_driver_firmware_43439A0_7_95_49_00_combined_end=fw_43439A0_7_95_49_00_end \
$< $@
OBJ_CYW43 := $(BUILD)/cyw43_resource.o
else
INC_CYW43 :=
CFLAGS_CYW43 :=
SRC_SDK_CYW43 :=
SRC_CYW43 :=
OBJ_CYW43 :=
SRC_LWIP :=
endif
@ -377,7 +371,7 @@ OBJ += $(addprefix $(BUILD)/, $(SRC_S:.s=.o))
OBJ += $(addprefix $(BUILD)/, $(SRC_S_UPPER:.S=.o))
OBJ += $(addprefix $(BUILD)/, $(SRC_MOD:.c=.o))
OBJ += $(BUILD)/boot2_padded_checksummed.o
OBJ += $(OBJ_CYW43) $(OBJ_MBEDTLS)
OBJ += $(OBJ_MBEDTLS)
$(BUILD)/%.o: $(BUILD)/%.S
$(STEPECHO) "CC $<"

@ -1 +1 @@
Subproject commit 2cf328d9e41603405a037a29e081a7d30dd519e6
Subproject commit e52dd14a15e6a53e6263840704470246aa77c5ce

@ -1 +1 @@
Subproject commit 2e6142b15b8a75c1227dd3edbe839193b2bf9041
Subproject commit 2ccab115de0d42d31d6611cca19ef0cd0d2ccaa7

View File

@ -52,6 +52,8 @@ typedef struct {
// interrupt character.
STATIC ringbuf_t _incoming_ringbuf;
STATIC uint8_t _buf[16];
// make sure background is not called recursively
STATIC bool in_web_background = false;
static _websocket cp_serial;
@ -244,6 +246,10 @@ void websocket_background(void) {
if (!websocket_connected()) {
return;
}
if (in_web_background) {
return;
}
in_web_background = true;
uint8_t c;
while (ringbuf_num_empty(&_incoming_ringbuf) > 0 &&
_read_next_payload_byte(&c)) {
@ -253,4 +259,5 @@ void websocket_background(void) {
}
ringbuf_put(&_incoming_ringbuf, c);
}
in_web_background = false;
}