From ea15a9118ad50dabc29934d7b08261ee2da51128 Mon Sep 17 00:00:00 2001 From: Dan Halbert Date: Fri, 16 Sep 2022 18:46:02 -0400 Subject: [PATCH 01/27] ringbuf cleanup --- .../common-hal/_bleio/CharacteristicBuffer.c | 1 + .../ble_hci/common-hal/_bleio/PacketBuffer.c | 5 +- ports/broadcom/common-hal/busio/UART.c | 5 +- ports/broadcom/common-hal/busio/UART.h | 4 +- .../common-hal/_bleio/CharacteristicBuffer.c | 7 +- .../common-hal/_bleio/PacketBuffer.c | 13 +- .../common-hal/_bleio/CharacteristicBuffer.c | 6 +- ports/nrf/common-hal/_bleio/PacketBuffer.c | 11 +- ports/nrf/common-hal/busio/UART.c | 22 ++-- ports/nrf/common-hal/busio/UART.h | 1 - ports/raspberrypi/common-hal/busio/UART.c | 44 ++++--- ports/stm/common-hal/busio/UART.c | 11 +- ports/unix/coverage.c | 24 ++-- py/ringbuf.c | 120 +++++++----------- py/ringbuf.h | 23 ++-- 15 files changed, 136 insertions(+), 161 deletions(-) diff --git a/devices/ble_hci/common-hal/_bleio/CharacteristicBuffer.c b/devices/ble_hci/common-hal/_bleio/CharacteristicBuffer.c index 0d87f03ae3..5c8c659e36 100644 --- a/devices/ble_hci/common-hal/_bleio/CharacteristicBuffer.c +++ b/devices/ble_hci/common-hal/_bleio/CharacteristicBuffer.c @@ -93,6 +93,7 @@ bool common_hal_bleio_characteristic_buffer_deinited(bleio_characteristic_buffer void common_hal_bleio_characteristic_buffer_deinit(bleio_characteristic_buffer_obj_t *self) { if (!common_hal_bleio_characteristic_buffer_deinited(self)) { bleio_characteristic_clear_observer(self->characteristic); + ringbuf_deinit(&self->ringbuf); } } diff --git a/devices/ble_hci/common-hal/_bleio/PacketBuffer.c b/devices/ble_hci/common-hal/_bleio/PacketBuffer.c index 7380d7ed4f..b690909029 100644 --- a/devices/ble_hci/common-hal/_bleio/PacketBuffer.c +++ b/devices/ble_hci/common-hal/_bleio/PacketBuffer.c @@ -37,13 +37,13 @@ #include "supervisor/shared/tick.h" STATIC void write_to_ringbuf(bleio_packet_buffer_obj_t *self, uint8_t *data, uint16_t len) { - if (len + sizeof(uint16_t) > ringbuf_capacity(&self->ringbuf)) { + if (len + sizeof(uint16_t) > ringbuf_size(&self->ringbuf)) { // This shouldn't happen. return; } // Push all the data onto the ring buffer. // Make room for the new value by dropping the oldest packets first. - while (ringbuf_capacity(&self->ringbuf) - ringbuf_num_filled(&self->ringbuf) < len + sizeof(uint16_t)) { + while (ringbuf_size(&self->ringbuf) - ringbuf_num_filled(&self->ringbuf) < len + sizeof(uint16_t)) { uint16_t packet_length; ringbuf_get_n(&self->ringbuf, (uint8_t *)&packet_length, sizeof(uint16_t)); for (uint16_t i = 0; i < packet_length; i++) { @@ -264,5 +264,6 @@ bool common_hal_bleio_packet_buffer_deinited(bleio_packet_buffer_obj_t *self) { void common_hal_bleio_packet_buffer_deinit(bleio_packet_buffer_obj_t *self) { if (!common_hal_bleio_packet_buffer_deinited(self)) { bleio_characteristic_clear_observer(self->characteristic); + ringbuf_deinit(&self->ringbuf); } } diff --git a/ports/broadcom/common-hal/busio/UART.c b/ports/broadcom/common-hal/busio/UART.c index 52d1b7a418..6d97b42c76 100644 --- a/ports/broadcom/common-hal/busio/UART.c +++ b/ports/broadcom/common-hal/busio/UART.c @@ -208,7 +208,9 @@ void common_hal_busio_uart_construct(busio_uart_obj_t *self, self->sigint_enabled = sigint_enabled; if (rx != NULL) { + // Use the provided buffer when given. if (receiver_buffer != NULL) { + ringbuf_init(&self->ringbuf, receiver_buffer, receiver_buffer_size); self->ringbuf = (ringbuf_t) { receiver_buffer, receiver_buffer_size }; } else { // Initially allocate the UART's buffer in the long-lived part of the @@ -217,7 +219,6 @@ void common_hal_busio_uart_construct(busio_uart_obj_t *self, // self->buffer, so do it manually. (However, as long as internal // pointers like this are NOT moved, allocating the buffer // in the long-lived pool is not strictly necessary) - // (This is a macro.) if (!ringbuf_alloc(&self->ringbuf, receiver_buffer_size, true)) { m_malloc_fail(receiver_buffer_size); } @@ -337,7 +338,7 @@ void common_hal_busio_uart_deinit(busio_uart_obj_t *self) { pl011->CR = 0; } active_uart[self->uart_id] = NULL; - ringbuf_free(&self->ringbuf); + ringbuf_deinit(&self->ringbuf); uart_status[self->uart_id] = STATUS_FREE; common_hal_reset_pin(self->tx_pin); common_hal_reset_pin(self->rx_pin); diff --git a/ports/broadcom/common-hal/busio/UART.h b/ports/broadcom/common-hal/busio/UART.h index 0590bc28b6..57926ca58b 100644 --- a/ports/broadcom/common-hal/busio/UART.h +++ b/ports/broadcom/common-hal/busio/UART.h @@ -36,11 +36,11 @@ typedef struct { const mcu_pin_obj_t *rx_pin; const mcu_pin_obj_t *cts_pin; const mcu_pin_obj_t *rts_pin; - uint8_t uart_id; uint32_t baudrate; uint32_t timeout_ms; - bool sigint_enabled; ringbuf_t ringbuf; + bool sigint_enabled; + uint8_t uart_id; } busio_uart_obj_t; extern void reset_uart(void); diff --git a/ports/espressif/common-hal/_bleio/CharacteristicBuffer.c b/ports/espressif/common-hal/_bleio/CharacteristicBuffer.c index fc3d0bbf06..48be3abd67 100644 --- a/ports/espressif/common-hal/_bleio/CharacteristicBuffer.c +++ b/ports/espressif/common-hal/_bleio/CharacteristicBuffer.c @@ -72,11 +72,7 @@ void _common_hal_bleio_characteristic_buffer_construct(bleio_characteristic_buff void *static_handler_entry) { self->characteristic = characteristic; self->timeout_ms = timeout * 1000; - - self->ringbuf.buf = (uint8_t *)buffer; - self->ringbuf.size = buffer_size; - self->ringbuf.iget = 0; - self->ringbuf.iput = 0; + ringbuf_init(&self->ringbuf, buffer, buffer_size); if (static_handler_entry != NULL) { ble_event_add_handler_entry((ble_event_handler_entry_t *)static_handler_entry, characteristic_buffer_on_ble_evt, self); @@ -131,6 +127,7 @@ void common_hal_bleio_characteristic_buffer_deinit(bleio_characteristic_buffer_o if (!common_hal_bleio_characteristic_buffer_deinited(self)) { ble_event_remove_handler(characteristic_buffer_on_ble_evt, self); self->characteristic = NULL; + ringbuf_deinit(&self->ringbuf); } } diff --git a/ports/espressif/common-hal/_bleio/PacketBuffer.c b/ports/espressif/common-hal/_bleio/PacketBuffer.c index 4e65bf309c..3b3e51df61 100644 --- a/ports/espressif/common-hal/_bleio/PacketBuffer.c +++ b/ports/espressif/common-hal/_bleio/PacketBuffer.c @@ -42,13 +42,13 @@ STATIC void write_to_ringbuf(bleio_packet_buffer_obj_t *self, const struct os_mbuf *mbuf) { size_t len = OS_MBUF_PKTLEN(mbuf); - if (len + sizeof(uint16_t) > ringbuf_capacity(&self->ringbuf)) { + if (len + sizeof(uint16_t) > ringbuf_size(&self->ringbuf)) { // This shouldn't happen but can if our buffer size was much smaller than // the writes the client actually makes. return; } // Make room for the new value by dropping the oldest packets first. - while (ringbuf_capacity(&self->ringbuf) - ringbuf_num_filled(&self->ringbuf) < len + sizeof(uint16_t)) { + while (ringbuf_size(&self->ringbuf) - ringbuf_num_filled(&self->ringbuf) < len + sizeof(uint16_t)) { uint16_t packet_length; ringbuf_get_n(&self->ringbuf, (uint8_t *)&packet_length, sizeof(uint16_t)); for (uint16_t i = 0; i < packet_length; i++) { @@ -164,10 +164,7 @@ void _common_hal_bleio_packet_buffer_construct( } if (incoming) { - self->ringbuf.buf = (uint8_t *)incoming_buffer; - self->ringbuf.size = incoming_buffer_size; - self->ringbuf.iget = 0; - self->ringbuf.iput = 0; + ringbuf_init(&self->ringbuf, (uint8_t *)incoming_buffer, incoming_buffer_size); } self->packet_queued = false; @@ -219,8 +216,7 @@ void common_hal_bleio_packet_buffer_construct( size_t incoming_buffer_size = 0; uint32_t *incoming_buffer = NULL; if (incoming) { - incoming_buffer_size = buffer_size * (sizeof(uint16_t) + max_packet_size); - incoming_buffer = m_malloc(incoming_buffer_size, false); + ringbuf_init(&self->ringbuf, (uint8_t *)incoming_buffer, incoming_buffer_size); } uint32_t *outgoing1 = NULL; @@ -414,5 +410,6 @@ bool common_hal_bleio_packet_buffer_deinited(bleio_packet_buffer_obj_t *self) { void common_hal_bleio_packet_buffer_deinit(bleio_packet_buffer_obj_t *self) { if (!common_hal_bleio_packet_buffer_deinited(self)) { ble_event_remove_handler(packet_buffer_on_ble_client_evt, self); + ringbuf_deinit(&self->ringbuf); } } diff --git a/ports/nrf/common-hal/_bleio/CharacteristicBuffer.c b/ports/nrf/common-hal/_bleio/CharacteristicBuffer.c index 5772616ee5..d13ffa1a94 100644 --- a/ports/nrf/common-hal/_bleio/CharacteristicBuffer.c +++ b/ports/nrf/common-hal/_bleio/CharacteristicBuffer.c @@ -90,10 +90,7 @@ void _common_hal_bleio_characteristic_buffer_construct(bleio_characteristic_buff self->characteristic = characteristic; self->timeout_ms = timeout * 1000; - self->ringbuf.buf = (uint8_t *)buffer; - self->ringbuf.size = buffer_size; - self->ringbuf.iget = 0; - self->ringbuf.iput = 0; + ringbuf_init(&self->ringbuf, buffer, buffer_size); if (static_handler_entry != NULL) { ble_drv_add_event_handler_entry((ble_drv_evt_handler_entry_t *)static_handler_entry, characteristic_buffer_on_ble_evt, self); @@ -159,6 +156,7 @@ void common_hal_bleio_characteristic_buffer_deinit(bleio_characteristic_buffer_o if (!common_hal_bleio_characteristic_buffer_deinited(self)) { ble_drv_remove_event_handler(characteristic_buffer_on_ble_evt, self); self->characteristic = NULL; + ringbuf_deinit(&self->ringbuf); } } diff --git a/ports/nrf/common-hal/_bleio/PacketBuffer.c b/ports/nrf/common-hal/_bleio/PacketBuffer.c index 38dcdd9041..52402a93f1 100644 --- a/ports/nrf/common-hal/_bleio/PacketBuffer.c +++ b/ports/nrf/common-hal/_bleio/PacketBuffer.c @@ -43,7 +43,7 @@ #include "supervisor/shared/bluetooth/serial.h" STATIC void write_to_ringbuf(bleio_packet_buffer_obj_t *self, uint8_t *data, uint16_t len) { - if (len + sizeof(uint16_t) > ringbuf_capacity(&self->ringbuf)) { + if (len + sizeof(uint16_t) > ringbuf_size(&self->ringbuf)) { // This shouldn't happen but can if our buffer size was much smaller than // the writes the client actually makes. return; @@ -52,7 +52,7 @@ STATIC void write_to_ringbuf(bleio_packet_buffer_obj_t *self, uint8_t *data, uin uint8_t is_nested_critical_region; sd_nvic_critical_region_enter(&is_nested_critical_region); // Make room for the new value by dropping the oldest packets first. - while (ringbuf_capacity(&self->ringbuf) - ringbuf_num_filled(&self->ringbuf) < len + sizeof(uint16_t)) { + while (ringbuf_size(&self->ringbuf) - ringbuf_num_filled(&self->ringbuf) < len + sizeof(uint16_t)) { uint16_t packet_length; ringbuf_get_n(&self->ringbuf, (uint8_t *)&packet_length, sizeof(uint16_t)); for (uint16_t i = 0; i < packet_length; i++) { @@ -233,10 +233,7 @@ void _common_hal_bleio_packet_buffer_construct( } if (incoming) { - self->ringbuf.buf = (uint8_t *)incoming_buffer; - self->ringbuf.size = incoming_buffer_size; - self->ringbuf.iget = 0; - self->ringbuf.iput = 0; + ringbuf_init(&self->ringbuf, (uint8_t *)incoming_buffer, incoming_buffer_size); } self->packet_queued = false; @@ -502,7 +499,9 @@ bool common_hal_bleio_packet_buffer_deinited(bleio_packet_buffer_obj_t *self) { } void common_hal_bleio_packet_buffer_deinit(bleio_packet_buffer_obj_t *self) { + if (!common_hal_bleio_packet_buffer_deinited(self)) { ble_drv_remove_event_handler(packet_buffer_on_ble_client_evt, self); + ringbuf_deinit(&self->ringbuf); } } diff --git a/ports/nrf/common-hal/busio/UART.c b/ports/nrf/common-hal/busio/UART.c index ae8389fd9e..df4a485999 100644 --- a/ports/nrf/common-hal/busio/UART.c +++ b/ports/nrf/common-hal/busio/UART.c @@ -213,24 +213,20 @@ void common_hal_busio_uart_construct(busio_uart_obj_t *self, // Init buffer for rx if (rx != NULL) { - self->allocated_ringbuf = true; // Use the provided buffer when given. if (receiver_buffer != NULL) { - self->ringbuf.buf = receiver_buffer; - self->ringbuf.size = receiver_buffer_size - 1; - self->ringbuf.iput = 0; - self->ringbuf.iget = 0; - self->allocated_ringbuf = false; + ringbuf_init(&self->ringbuf, receiver_buffer, receiver_buffer_size); + } else { // Initially allocate the UART's buffer in the long-lived part of the // heap. UARTs are generally long-lived objects, but the "make long- // lived" machinery is incapable of moving internal pointers like // self->buffer, so do it manually. (However, as long as internal // pointers like this are NOT moved, allocating the buffer // in the long-lived pool is not strictly necessary) - // (This is a macro.) - } else if (!ringbuf_alloc(&self->ringbuf, receiver_buffer_size, true)) { - nrfx_uarte_uninit(self->uarte); - m_malloc_fail(receiver_buffer_size); + if (!ringbuf_alloc(&self->ringbuf, receiver_buffer_size, true)) { + nrfx_uarte_uninit(self->uarte); + m_malloc_fail(receiver_buffer_size); + } } self->rx_pin_number = rx->number; @@ -282,9 +278,7 @@ void common_hal_busio_uart_deinit(busio_uart_obj_t *self) { self->rx_pin_number = NO_PIN; self->rts_pin_number = NO_PIN; self->cts_pin_number = NO_PIN; - if (self->allocated_ringbuf) { - ringbuf_free(&self->ringbuf); - } + ringbuf_deinit(&self->ringbuf); for (size_t i = 0; i < MP_ARRAY_SIZE(nrfx_uartes); i++) { if (self->uarte == &nrfx_uartes[i]) { @@ -305,7 +299,7 @@ size_t common_hal_busio_uart_read(busio_uart_obj_t *self, uint8_t *data, size_t // check removed to reduce code size /* - if (len > ringbuf_capacity(&self->ringbuf)) { + if (len > ringbuf_size(&self->ringbuf)) { mp_raise_ValueError(translate("Reading >receiver_buffer_size bytes is not supported")); } */ diff --git a/ports/nrf/common-hal/busio/UART.h b/ports/nrf/common-hal/busio/UART.h index 140f8d0c0a..2eaf584403 100644 --- a/ports/nrf/common-hal/busio/UART.h +++ b/ports/nrf/common-hal/busio/UART.h @@ -44,7 +44,6 @@ typedef struct { ringbuf_t ringbuf; uint8_t rx_char; // EasyDMA buf bool rx_paused; // set by irq if no space in rbuf - bool allocated_ringbuf; uint8_t tx_pin_number; uint8_t rx_pin_number; diff --git a/ports/raspberrypi/common-hal/busio/UART.c b/ports/raspberrypi/common-hal/busio/UART.c index c06bb21903..4212249ec9 100644 --- a/ports/raspberrypi/common-hal/busio/UART.c +++ b/ports/raspberrypi/common-hal/busio/UART.c @@ -155,27 +155,33 @@ void common_hal_busio_uart_construct(busio_uart_obj_t *self, uart_set_hw_flow(self->uart, (cts != NULL), (rts != NULL)); if (rx != NULL) { - // Initially allocate the UART's buffer in the long-lived part of the - // heap. UARTs are generally long-lived objects, but the "make long- - // lived" machinery is incapable of moving internal pointers like - // self->buffer, so do it manually. (However, as long as internal - // pointers like this are NOT moved, allocating the buffer - // in the long-lived pool is not strictly necessary) - // (This is a macro.) - if (!ringbuf_alloc(&self->ringbuf, receiver_buffer_size, true)) { - m_malloc_fail(receiver_buffer_size); - } - active_uarts[uart_id] = self; - if (uart_id == 1) { - self->uart_irq_id = UART1_IRQ; - irq_set_exclusive_handler(self->uart_irq_id, uart1_callback); + // Use the provided buffer when given. + if (receiver_buffer != NULL) { + ringbuf_init(&self->ringbuf, receiver_buffer, receiver_buffer_size); } else { - self->uart_irq_id = UART0_IRQ; - irq_set_exclusive_handler(self->uart_irq_id, uart0_callback); + // Initially allocate the UART's buffer in the long-lived part of the + // heap. UARTs are generally long-lived objects, but the "make long- + // lived" machinery is incapable of moving internal pointers like + // self->buffer, so do it manually. (However, as long as internal + // pointers like this are NOT moved, allocating the buffer + // in the long-lived pool is not strictly necessary) + if (!ringbuf_alloc(&self->ringbuf, receiver_buffer_size, true)) { + uart_deinit(self->uart); + m_malloc_fail(receiver_buffer_size); + } } - irq_set_enabled(self->uart_irq_id, true); - uart_set_irq_enables(self->uart, true /* rx has data */, false /* tx needs data */); } + + active_uarts[uart_id] = self; + if (uart_id == 1) { + self->uart_irq_id = UART1_IRQ; + irq_set_exclusive_handler(self->uart_irq_id, uart1_callback); + } else { + self->uart_irq_id = UART0_IRQ; + irq_set_exclusive_handler(self->uart_irq_id, uart0_callback); + } + irq_set_enabled(self->uart_irq_id, true); + uart_set_irq_enables(self->uart, true /* rx has data */, false /* tx needs data */); } bool common_hal_busio_uart_deinited(busio_uart_obj_t *self) { @@ -187,7 +193,7 @@ void common_hal_busio_uart_deinit(busio_uart_obj_t *self) { return; } uart_deinit(self->uart); - ringbuf_free(&self->ringbuf); + ringbuf_deinit(&self->ringbuf); active_uarts[self->uart_id] = NULL; uart_status[self->uart_id] = STATUS_FREE; reset_pin_number(self->tx_pin); diff --git a/ports/stm/common-hal/busio/UART.c b/ports/stm/common-hal/busio/UART.c index 171e915dd9..48894db5f9 100644 --- a/ports/stm/common-hal/busio/UART.c +++ b/ports/stm/common-hal/busio/UART.c @@ -214,9 +214,16 @@ void common_hal_busio_uart_construct(busio_uart_obj_t *self, // Init buffer for rx and claim pins if (self->rx != NULL) { + // Use the provided buffer when given. if (receiver_buffer != NULL) { - self->ringbuf = (ringbuf_t) { receiver_buffer, receiver_buffer_size }; + ringbuf_init(&self->ringbuf, receiver_buffer, receiver_buffer_size); } else { + // Initially allocate the UART's buffer in the long-lived part of the + // heap. UARTs are generally long-lived objects, but the "make long- + // lived" machinery is incapable of moving internal pointers like + // self->buffer, so do it manually. (However, as long as internal + // pointers like this are NOT moved, allocating the buffer + // in the long-lived pool is not strictly necessary) if (!ringbuf_alloc(&self->ringbuf, receiver_buffer_size, true)) { m_malloc_fail(receiver_buffer_size); } @@ -281,7 +288,7 @@ void common_hal_busio_uart_deinit(busio_uart_obj_t *self) { self->rx = NULL; } - ringbuf_free(&self->ringbuf); + ringbuf_deinit(&self->ringbuf); } size_t common_hal_busio_uart_read(busio_uart_obj_t *self, uint8_t *data, size_t len, int *errcode) { diff --git a/ports/unix/coverage.c b/ports/unix/coverage.c index 179181dc83..0e4c6dbd48 100644 --- a/ports/unix/coverage.c +++ b/ports/unix/coverage.c @@ -526,7 +526,9 @@ STATIC mp_obj_t extra_coverage(void) { // ringbuf { - byte buf[100]; + #define RINGBUF_SIZE 99 + + byte buf[RINGBUF_SIZE]; ringbuf_t ringbuf; ringbuf_init(&ringbuf, &buf[0], sizeof(buf)); @@ -546,7 +548,7 @@ STATIC mp_obj_t extra_coverage(void) { mp_printf(&mp_plat_print, "%d %d\n", ringbuf_num_empty(&ringbuf), ringbuf_num_filled(&ringbuf)); // Two-byte put with full ringbuf. - for (int i = 0; i < 99; ++i) { + for (int i = 0; i < RINGBUF_SIZE; ++i) { ringbuf_put(&ringbuf, i); } mp_printf(&mp_plat_print, "%d %d\n", ringbuf_num_empty(&ringbuf), ringbuf_num_filled(&ringbuf)); @@ -558,16 +560,15 @@ STATIC mp_obj_t extra_coverage(void) { ringbuf_get(&ringbuf); mp_printf(&mp_plat_print, "%d %d\n", ringbuf_num_empty(&ringbuf), ringbuf_num_filled(&ringbuf)); mp_printf(&mp_plat_print, "%d\n", ringbuf_put16(&ringbuf, 0xcc99)); - for (int i = 0; i < 97; ++i) { + for (int i = 0; i < RINGBUF_SIZE - 2; ++i) { ringbuf_get(&ringbuf); } mp_printf(&mp_plat_print, "%04x\n", ringbuf_get16(&ringbuf)); mp_printf(&mp_plat_print, "%d %d\n", ringbuf_num_empty(&ringbuf), ringbuf_num_filled(&ringbuf)); // Two-byte put with wrap around on first byte: - ringbuf.iput = 0; - ringbuf.iget = 0; - for (int i = 0; i < 99; ++i) { + ringbuf_clear(&ringbuf); + for (int i = 0; i < RINGBUF_SIZE; ++i) { ringbuf_put(&ringbuf, i); ringbuf_get(&ringbuf); } @@ -575,9 +576,8 @@ STATIC mp_obj_t extra_coverage(void) { mp_printf(&mp_plat_print, "%04x\n", ringbuf_get16(&ringbuf)); // Two-byte put with wrap around on second byte: - ringbuf.iput = 0; - ringbuf.iget = 0; - for (int i = 0; i < 98; ++i) { + ringbuf_clear(&ringbuf); + for (int i = 0; i < RINGBUF_SIZE - 1; ++i) { ringbuf_put(&ringbuf, i); ringbuf_get(&ringbuf); } @@ -585,13 +585,11 @@ STATIC mp_obj_t extra_coverage(void) { mp_printf(&mp_plat_print, "%04x\n", ringbuf_get16(&ringbuf)); // Two-byte get from empty ringbuf. - ringbuf.iput = 0; - ringbuf.iget = 0; + ringbuf_clear(&ringbuf); mp_printf(&mp_plat_print, "%d\n", ringbuf_get16(&ringbuf)); // Two-byte get from ringbuf with one byte available. - ringbuf.iput = 0; - ringbuf.iget = 0; + ringbuf_clear(&ringbuf); ringbuf_put(&ringbuf, 0xaa); mp_printf(&mp_plat_print, "%d\n", ringbuf_get16(&ringbuf)); } diff --git a/py/ringbuf.c b/py/ringbuf.c index fe47b50068..8a4cb33cbc 100644 --- a/py/ringbuf.c +++ b/py/ringbuf.c @@ -27,86 +27,85 @@ #include "ringbuf.h" -bool ringbuf_init(ringbuf_t *r, uint8_t *buf, size_t capacity) { +bool ringbuf_init(ringbuf_t *r, uint8_t *buf, size_t size) { r->buf = buf; - r->size = capacity; - r->iget = r->iput = 0; + r->size = size; + r->used = 0; + r->next_read = 0; + r->next_write = 0; return r->buf != NULL; } -// Dynamic initialization. This should be accessible from a root pointer. -// capacity is the number of bytes the ring buffer can hold. The actual -// size of the buffer is one greater than that, due to how the buffer -// handles empty and full statuses. -bool ringbuf_alloc(ringbuf_t *r, size_t capacity, bool long_lived) { - r->buf = gc_alloc(capacity + 1, false, long_lived); - r->size = capacity + 1; - r->iget = r->iput = 0; - return r->buf != NULL; +// Dynamic initialization. This should be accessible from a root pointer.. +bool ringbuf_alloc(ringbuf_t *r, size_t size, bool long_lived) { + bool result = ringbuf_init(r, gc_alloc(size, false, long_lived), size); + return result; } -void ringbuf_free(ringbuf_t *r) { - // Free buf by letting gc take care of it. If the VM has finished already, +void ringbuf_deinit(ringbuf_t *r) { + // Free buf by doing nothing and letting gc take care of it. If the VM has finished already, // this will be safe. r->buf = (uint8_t *)NULL; r->size = 0; ringbuf_clear(r); } -size_t ringbuf_capacity(ringbuf_t *r) { - return r->size - 1; +size_t ringbuf_size(ringbuf_t *r) { + return r->size; } -// Returns -1 if buffer is empty, else returns byte fetched. +// Return -1 if buffer is empty, else return byte fetched. int ringbuf_get(ringbuf_t *r) { - if (r->iget == r->iput) { + if (r->used < 1) { return -1; } - uint8_t v = r->buf[r->iget++]; - if (r->iget >= r->size) { - r->iget = 0; + uint8_t v = r->buf[r->next_read]; + r->next_read++; + if (r->next_read >= r->size) { + r->next_read = 0; } + r->used--; return v; } int ringbuf_get16(ringbuf_t *r) { - int v = ringbuf_peek16(r); - if (v == -1) { - return v; - } - r->iget += 2; - if (r->iget >= r->size) { - r->iget -= r->size; - } - return v; -} - -// Returns -1 if no room in buffer, else returns 0. -int ringbuf_put(ringbuf_t *r, uint8_t v) { - uint32_t iput_new = r->iput + 1; - if (iput_new >= r->size) { - iput_new = 0; - } - if (iput_new == r->iget) { + if (r->used < 2) { return -1; } - r->buf[r->iput] = v; - r->iput = iput_new; + + int high_byte = ringbuf_get(r); + int low_byte = ringbuf_get(r); + return (high_byte << 8) | low_byte; +} + +// Return -1 if no room in buffer, else return 0. +int ringbuf_put(ringbuf_t *r, uint8_t v) { + if (r->used >= r->size) { + return -1; + } + r->buf[r->next_write] = v; + r->next_write++; + if (r->next_write >= r->size) { + r->next_write = 0; + } + r->used++; return 0; } void ringbuf_clear(ringbuf_t *r) { - r->iput = r->iget = 0; + r->next_write = 0; + r->next_read = 0; + r->used = 0; } // Number of free slots that can be written. size_t ringbuf_num_empty(ringbuf_t *r) { - return (r->size + r->iget - r->iput - 1) % r->size; + return r->size - r->used; } // Number of bytes available to read. size_t ringbuf_num_filled(ringbuf_t *r) { - return (r->size + r->iput - r->iget) % r->size; + return r->used; } // If the ring buffer fills up, not all bytes will be written. @@ -134,37 +133,12 @@ size_t ringbuf_get_n(ringbuf_t *r, uint8_t *buf, size_t bufsize) { return bufsize; } -int ringbuf_peek16(ringbuf_t *r) { - if (r->iget == r->iput) { - return -1; - } - uint32_t iget_a = r->iget + 1; - if (iget_a == r->size) { - iget_a = 0; - } - if (iget_a == r->iput) { - return -1; - } - return (r->buf[r->iget] << 8) | (r->buf[iget_a]); -} - int ringbuf_put16(ringbuf_t *r, uint16_t v) { - uint32_t iput_a = r->iput + 1; - if (iput_a == r->size) { - iput_a = 0; - } - if (iput_a == r->iget) { + if (r->size - r->used < 2) { return -1; } - uint32_t iput_b = iput_a + 1; - if (iput_b == r->size) { - iput_b = 0; - } - if (iput_b == r->iget) { - return -1; - } - r->buf[r->iput] = (v >> 8) & 0xff; - r->buf[iput_a] = v & 0xff; - r->iput = iput_b; + + ringbuf_put(r, (v >> 8) & 0xff); + ringbuf_put(r, v & 0xff); return 0; } diff --git a/py/ringbuf.h b/py/ringbuf.h index d868eff1e4..2725bedcca 100644 --- a/py/ringbuf.h +++ b/py/ringbuf.h @@ -33,19 +33,23 @@ typedef struct _ringbuf_t { uint8_t *buf; - // Allocated size; capacity is one less. Don't reference this directly. uint32_t size; - uint32_t iget; - uint32_t iput; + uint32_t used; + uint32_t next_read; + uint32_t next_write; } ringbuf_t; -// Note that the capacity of the buffer is N-1! - -// For static initialization use ringbuf_init() +// For static initialization with an existing buffer, use ringbuf_init(). bool ringbuf_init(ringbuf_t *r, uint8_t *buf, size_t capacity); + +// For allocation of a buffer on the heap, use ringbuf_alloc(). bool ringbuf_alloc(ringbuf_t *r, size_t capacity, bool long_lived); -void ringbuf_free(ringbuf_t *r); -size_t ringbuf_capacity(ringbuf_t *r); + +// Mark ringbuf as no longer in use, and allow any heap storage to be freed by gc. +void ringbuf_deinit(ringbuf_t *r); + +// Note: Ringbuf operations are not atomic. +size_t ringbuf_size(ringbuf_t *r); int ringbuf_get(ringbuf_t *r); int ringbuf_put(ringbuf_t *r, uint8_t v); void ringbuf_clear(ringbuf_t *r); @@ -54,9 +58,8 @@ size_t ringbuf_num_filled(ringbuf_t *r); size_t ringbuf_put_n(ringbuf_t *r, const uint8_t *buf, size_t bufsize); size_t ringbuf_get_n(ringbuf_t *r, uint8_t *buf, size_t bufsize); -// Note: big-endian. No-op if not enough room available for both bytes. +// Note: big-endian. Return -1 if can't read or write two bytes. int ringbuf_get16(ringbuf_t *r); -int ringbuf_peek16(ringbuf_t *r); int ringbuf_put16(ringbuf_t *r, uint16_t v); #endif // MICROPY_INCLUDED_PY_RINGBUF_H From 267ec1dc4fd1299ce63156a1ba57fb7f903e64b7 Mon Sep 17 00:00:00 2001 From: Jeff Epler Date: Thu, 23 Jun 2022 08:25:20 -0500 Subject: [PATCH 02/27] unify some 'must/should be an int' messages --- locale/circuitpython.pot | 23 +--------------------- shared-bindings/displayio/ColorConverter.c | 5 +---- shared-bindings/displayio/Palette.c | 17 ++++------------ shared-bindings/displayio/Shape.c | 15 +++----------- shared-bindings/i2ctarget/I2CTarget.c | 5 +---- 5 files changed, 10 insertions(+), 55 deletions(-) diff --git a/locale/circuitpython.pot b/locale/circuitpython.pot index 52f1bdb5ad..52f72e8bee 100644 --- a/locale/circuitpython.pot +++ b/locale/circuitpython.pot @@ -2526,8 +2526,7 @@ msgstr "" msgid "can't cancel self" msgstr "" -#: py/obj.c py/objint.c shared-bindings/i2ctarget/I2CTarget.c -#: shared-module/adafruit_pixelbuf/PixelBuf.c +#: py/obj.c py/objint.c shared-module/adafruit_pixelbuf/PixelBuf.c msgid "can't convert %q to %q" msgstr "" @@ -2714,10 +2713,6 @@ msgstr "" msgid "color must be between 0x000000 and 0xffffff" msgstr "" -#: shared-bindings/displayio/ColorConverter.c -msgid "color should be an int" -msgstr "" - #: py/emitnative.c msgid "comparison of int and uint" msgstr "" @@ -2869,10 +2864,6 @@ msgstr "" msgid "end of format while looking for conversion specifier" msgstr "" -#: shared-bindings/displayio/Shape.c -msgid "end_x should be an int" -msgstr "" - #: shared-bindings/alarm/time/TimeAlarm.c msgid "epoch_time not supported on this board" msgstr "" @@ -3739,10 +3730,6 @@ msgstr "" msgid "palette must be 32 bytes long" msgstr "" -#: shared-bindings/displayio/Palette.c -msgid "palette_index should be an int" -msgstr "" - #: py/emitinlinextensa.c msgid "parameters must be registers in sequence a2 to a5" msgstr "" @@ -3980,10 +3967,6 @@ msgstr "" msgid "start/end indices" msgstr "" -#: shared-bindings/displayio/Shape.c -msgid "start_x should be an int" -msgstr "" - #: shared-bindings/random/__init__.c msgid "step must be non-zero" msgstr "" @@ -4328,10 +4311,6 @@ msgstr "" msgid "xTaskCreate failed" msgstr "" -#: shared-bindings/displayio/Shape.c -msgid "y should be an int" -msgstr "" - #: shared-module/displayio/Shape.c msgid "y value out of bounds" msgstr "" diff --git a/shared-bindings/displayio/ColorConverter.c b/shared-bindings/displayio/ColorConverter.c index 7b33b1ec8f..f3fd9a2ab9 100644 --- a/shared-bindings/displayio/ColorConverter.c +++ b/shared-bindings/displayio/ColorConverter.c @@ -72,10 +72,7 @@ STATIC mp_obj_t displayio_colorconverter_make_new(const mp_obj_type_t *type, siz STATIC mp_obj_t displayio_colorconverter_obj_convert(mp_obj_t self_in, mp_obj_t color_obj) { displayio_colorconverter_t *self = MP_OBJ_TO_PTR(self_in); - mp_int_t color; - if (!mp_obj_get_int_maybe(color_obj, &color)) { - mp_raise_ValueError(translate("color should be an int")); - } + mp_int_t color = mp_arg_validate_type_int(color_obj, MP_QSTR_color); _displayio_colorspace_t colorspace; colorspace.depth = 16; uint32_t output_color; diff --git a/shared-bindings/displayio/Palette.c b/shared-bindings/displayio/Palette.c index 89460bfc03..5724c9bc87 100644 --- a/shared-bindings/displayio/Palette.c +++ b/shared-bindings/displayio/Palette.c @@ -156,11 +156,8 @@ STATIC mp_obj_t palette_subscr(mp_obj_t self_in, mp_obj_t index_in, mp_obj_t val STATIC mp_obj_t displayio_palette_obj_make_transparent(mp_obj_t self_in, mp_obj_t palette_index_obj) { displayio_palette_t *self = MP_OBJ_TO_PTR(self_in); - mp_int_t palette_index; - if (!mp_obj_get_int_maybe(palette_index_obj, &palette_index)) { - mp_raise_ValueError(translate("palette_index should be an int")); - } - palette_index = mp_arg_validate_int_range(palette_index, 0, common_hal_displayio_palette_get_len(self) - 1, MP_QSTR_palette_index); + mp_int_t palette_index = mp_arg_validate_type_int(palette_index_obj, MP_QSTR_palette_index); + mp_arg_validate_int_range(palette_index, 0, common_hal_displayio_palette_get_len(self) - 1, MP_QSTR_palette_index); common_hal_displayio_palette_make_transparent(self, palette_index); return mp_const_none; @@ -173,10 +170,7 @@ MP_DEFINE_CONST_FUN_OBJ_2(displayio_palette_make_transparent_obj, displayio_pale STATIC mp_obj_t displayio_palette_obj_make_opaque(mp_obj_t self_in, mp_obj_t palette_index_obj) { displayio_palette_t *self = MP_OBJ_TO_PTR(self_in); - mp_int_t palette_index; - if (!mp_obj_get_int_maybe(palette_index_obj, &palette_index)) { - mp_raise_ValueError(translate("palette_index should be an int")); - } + mp_int_t palette_index = mp_arg_validate_type_int(palette_index_obj, MP_QSTR_palette_index); palette_index = mp_arg_validate_int_range(palette_index, 0, common_hal_displayio_palette_get_len(self) - 1, MP_QSTR_palette_index); common_hal_displayio_palette_make_opaque(self, palette_index); @@ -191,10 +185,7 @@ MP_DEFINE_CONST_FUN_OBJ_2(displayio_palette_make_opaque_obj, displayio_palette_o STATIC mp_obj_t displayio_palette_obj_is_transparent(mp_obj_t self_in, mp_obj_t palette_index_obj) { displayio_palette_t *self = MP_OBJ_TO_PTR(self_in); - mp_int_t palette_index; - if (!mp_obj_get_int_maybe(palette_index_obj, &palette_index)) { - mp_raise_ValueError(translate("palette_index should be an int")); - } + mp_int_t palette_index = mp_arg_validate_type_int(palette_index_obj, MP_QSTR_palette_index); palette_index = mp_arg_validate_int_range(palette_index, 0, common_hal_displayio_palette_get_len(self) - 1, MP_QSTR_palette_index); return mp_obj_new_bool(common_hal_displayio_palette_is_transparent(self, palette_index)); diff --git a/shared-bindings/displayio/Shape.c b/shared-bindings/displayio/Shape.c index 30a51dadce..d5e907ac38 100644 --- a/shared-bindings/displayio/Shape.c +++ b/shared-bindings/displayio/Shape.c @@ -80,18 +80,9 @@ STATIC mp_obj_t displayio_shape_make_new(const mp_obj_type_t *type, size_t n_arg STATIC mp_obj_t displayio_shape_obj_set_boundary(size_t n_args, const mp_obj_t *args) { (void)n_args; displayio_shape_t *self = MP_OBJ_TO_PTR(args[0]); - mp_int_t y; - if (!mp_obj_get_int_maybe(args[1], &y)) { - mp_raise_ValueError(translate("y should be an int")); - } - mp_int_t start_x; - if (!mp_obj_get_int_maybe(args[2], &start_x)) { - mp_raise_ValueError(translate("start_x should be an int")); - } - mp_int_t end_x; - if (!mp_obj_get_int_maybe(args[3], &end_x)) { - mp_raise_ValueError(translate("end_x should be an int")); - } + mp_int_t y = mp_arg_validate_type_int(args[1], MP_ARG_y); + mp_int_t start_x = mp_arg_validate_type_int(args[1], MP_ARG_start_x); + mp_int_t end_x = mp_arg_validate_type_int(args[1], MP_ARG_end_x); common_hal_displayio_shape_set_boundary(self, y, start_x, end_x); return mp_const_none; diff --git a/shared-bindings/i2ctarget/I2CTarget.c b/shared-bindings/i2ctarget/I2CTarget.c index 1680585ba5..f094788140 100644 --- a/shared-bindings/i2ctarget/I2CTarget.c +++ b/shared-bindings/i2ctarget/I2CTarget.c @@ -85,10 +85,7 @@ STATIC mp_obj_t i2ctarget_i2c_target_make_new(const mp_obj_type_t *type, size_t uint8_t *addresses = NULL; unsigned int i = 0; while ((item = mp_iternext(iterable)) != MP_OBJ_STOP_ITERATION) { - mp_int_t value; - if (!mp_obj_get_int_maybe(item, &value)) { - mp_raise_TypeError_varg(translate("can't convert %q to %q"), MP_QSTR_address, MP_QSTR_int); - } + mp_int_t value = mp_arg_validate_type_int(item, MP_QSTR_address); if (value < 0x00 || value > 0x7f) { mp_raise_ValueError(translate("address out of bounds")); } From ef35ca1d3ebe4f1835e32e52fbd81225485ae057 Mon Sep 17 00:00:00 2001 From: Jeff Epler Date: Thu, 23 Jun 2022 08:36:22 -0500 Subject: [PATCH 03/27] vectorio: Simplify argument checking of x/y values --- locale/circuitpython.pot | 1 - shared-bindings/displayio/Shape.c | 6 +++--- shared-module/vectorio/Polygon.c | 26 ++++++++------------------ shared-module/vectorio/VectorShape.c | 8 ++------ 4 files changed, 13 insertions(+), 28 deletions(-) diff --git a/locale/circuitpython.pot b/locale/circuitpython.pot index 52f72e8bee..9e50e4c94b 100644 --- a/locale/circuitpython.pot +++ b/locale/circuitpython.pot @@ -4181,7 +4181,6 @@ msgid "unreadable attribute" msgstr "" #: shared-bindings/displayio/TileGrid.c shared-bindings/vectorio/VectorShape.c -#: shared-module/vectorio/Polygon.c shared-module/vectorio/VectorShape.c msgid "unsupported %q type" msgstr "" diff --git a/shared-bindings/displayio/Shape.c b/shared-bindings/displayio/Shape.c index d5e907ac38..4bec17608c 100644 --- a/shared-bindings/displayio/Shape.c +++ b/shared-bindings/displayio/Shape.c @@ -80,9 +80,9 @@ STATIC mp_obj_t displayio_shape_make_new(const mp_obj_type_t *type, size_t n_arg STATIC mp_obj_t displayio_shape_obj_set_boundary(size_t n_args, const mp_obj_t *args) { (void)n_args; displayio_shape_t *self = MP_OBJ_TO_PTR(args[0]); - mp_int_t y = mp_arg_validate_type_int(args[1], MP_ARG_y); - mp_int_t start_x = mp_arg_validate_type_int(args[1], MP_ARG_start_x); - mp_int_t end_x = mp_arg_validate_type_int(args[1], MP_ARG_end_x); + mp_int_t y = mp_arg_validate_type_int(args[1], MP_QSTR_y); + mp_int_t start_x = mp_arg_validate_type_int(args[1], MP_QSTR_start_x); + mp_int_t end_x = mp_arg_validate_type_int(args[1], MP_QSTR_end_x); common_hal_displayio_shape_set_boundary(self, y, start_x, end_x); return mp_const_none; diff --git a/shared-module/vectorio/Polygon.c b/shared-module/vectorio/Polygon.c index 24eb1c501d..e24893af01 100644 --- a/shared-module/vectorio/Polygon.c +++ b/shared-module/vectorio/Polygon.c @@ -14,7 +14,8 @@ // Converts a list of points tuples to a flat list of ints for speedier internal use. -// Also validates the points. +// Also validates the points. If this fails due to invalid types or values, the +// content of the points is undefined. static void _clobber_points_list(vectorio_polygon_t *self, mp_obj_t points_tuple_list) { size_t len = 0; mp_obj_t *items; @@ -26,12 +27,8 @@ static void _clobber_points_list(vectorio_polygon_t *self, mp_obj_t points_tuple } if (self->len < 2 * len) { - if (self->points_list != NULL) { - VECTORIO_POLYGON_DEBUG("free(%d), ", sizeof(self->points_list)); - gc_free(self->points_list); - } - self->points_list = gc_alloc(2 * len * sizeof(uint16_t), false, false); - VECTORIO_POLYGON_DEBUG("alloc(%p, %d)", self->points_list, 2 * len * sizeof(uint16_t)); + self->points_list = gc_realloc(self->points_list, 2 * len * sizeof(uint16_t), true); + VECTORIO_POLYGON_DEBUG("realloc(%d) -> %p", self->points_list, 2 * len * sizeof(uint16_t)); } self->len = 2 * len; @@ -42,17 +39,10 @@ static void _clobber_points_list(vectorio_polygon_t *self, mp_obj_t points_tuple mp_arg_validate_length(tuple_len, 2, MP_QSTR_point); - mp_int_t x; - mp_int_t y; - if (!mp_obj_get_int_maybe(tuple_items[ 0 ], &x) - || !mp_obj_get_int_maybe(tuple_items[ 1 ], &y) - || x < SHRT_MIN || x > SHRT_MAX || y < SHRT_MIN || y > SHRT_MAX - ) { - gc_free(self->points_list); - self->points_list = NULL; - mp_raise_ValueError_varg(translate("unsupported %q type"), MP_QSTR_point); - self->len = 0; - } + mp_int_t x = mp_arg_validate_type_int(tuple_items[0], MP_QSTR_x); + mp_arg_validate_int_range(x, SHRT_MIN, SHRT_MAX, MP_QSTR_x); + mp_int_t y = mp_arg_validate_type_int(tuple_items[1], MP_QSTR_y); + mp_arg_validate_int_range(y, SHRT_MIN, SHRT_MAX, MP_QSTR_y); self->points_list[2 * i ] = (int16_t)x; self->points_list[2 * i + 1] = (int16_t)y; } diff --git a/shared-module/vectorio/VectorShape.c b/shared-module/vectorio/VectorShape.c index f72cd5cc97..d9c13f54cc 100644 --- a/shared-module/vectorio/VectorShape.c +++ b/shared-module/vectorio/VectorShape.c @@ -277,12 +277,8 @@ void common_hal_vectorio_vector_shape_set_location(vectorio_vector_shape_t *self mp_obj_tuple_get(xy, &tuple_len, &tuple_items); mp_arg_validate_length(tuple_len, 2, MP_QSTR_location); - mp_int_t x; - mp_int_t y; - if (!mp_obj_get_int_maybe(tuple_items[ 0 ], &x) - || !mp_obj_get_int_maybe(tuple_items[ 1 ], &y)) { - mp_raise_ValueError_varg(translate("unsupported %q type"), MP_QSTR_point); - } + mp_int_t x = mp_arg_validate_type_int(tuple_items[0], MP_QSTR_x); + mp_int_t y = mp_arg_validate_type_int(tuple_items[0], MP_QSTR_y); bool dirty = false; if (self->x != x) { check_bounds_and_set_x(self, x); From f7221d5895bfad2ea0d351c67f1d56c7406ba382 Mon Sep 17 00:00:00 2001 From: Jeff Epler Date: Thu, 23 Jun 2022 08:53:29 -0500 Subject: [PATCH 04/27] simplify logic in _clobber_points_list --- shared-module/vectorio/Polygon.c | 20 ++++++++++++-------- 1 file changed, 12 insertions(+), 8 deletions(-) diff --git a/shared-module/vectorio/Polygon.c b/shared-module/vectorio/Polygon.c index e24893af01..5d1e0d3e58 100644 --- a/shared-module/vectorio/Polygon.c +++ b/shared-module/vectorio/Polygon.c @@ -15,7 +15,7 @@ // Converts a list of points tuples to a flat list of ints for speedier internal use. // Also validates the points. If this fails due to invalid types or values, the -// content of the points is undefined. +// number of points is 0 and the points_list is NULL. static void _clobber_points_list(vectorio_polygon_t *self, mp_obj_t points_tuple_list) { size_t len = 0; mp_obj_t *items; @@ -26,11 +26,12 @@ static void _clobber_points_list(vectorio_polygon_t *self, mp_obj_t points_tuple mp_raise_TypeError(translate("Polygon needs at least 3 points")); } - if (self->len < 2 * len) { - self->points_list = gc_realloc(self->points_list, 2 * len * sizeof(uint16_t), true); - VECTORIO_POLYGON_DEBUG("realloc(%d) -> %p", self->points_list, 2 * len * sizeof(uint16_t)); - } - self->len = 2 * len; + int16_t *points_list = gc_realloc(self->points_list, 2 * len * sizeof(uint16_t), true); + VECTORIO_POLYGON_DEBUG("realloc(%p, %d) -> %p", self->points_list, 2 * len * sizeof(uint16_t), points_list); + + // In case the validation calls below fail, set these values temporarily + self->points_list = NULL; + self->len = 0; for (uint16_t i = 0; i < len; ++i) { size_t tuple_len = 0; @@ -43,9 +44,12 @@ static void _clobber_points_list(vectorio_polygon_t *self, mp_obj_t points_tuple mp_arg_validate_int_range(x, SHRT_MIN, SHRT_MAX, MP_QSTR_x); mp_int_t y = mp_arg_validate_type_int(tuple_items[1], MP_QSTR_y); mp_arg_validate_int_range(y, SHRT_MIN, SHRT_MAX, MP_QSTR_y); - self->points_list[2 * i ] = (int16_t)x; - self->points_list[2 * i + 1] = (int16_t)y; + points_list[2 * i ] = (int16_t)x; + points_list[2 * i + 1] = (int16_t)y; } + + self->points_list = points_list; + self->len = 2 * len; } From 18cb25e95c19c10fb368c353bda6ff345de69809 Mon Sep 17 00:00:00 2001 From: Jeff Epler Date: Thu, 23 Jun 2022 11:44:48 -0500 Subject: [PATCH 05/27] Re-use another message --- py/argcheck.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/py/argcheck.c b/py/argcheck.c index cabfaeeaae..c28c577088 100644 --- a/py/argcheck.c +++ b/py/argcheck.c @@ -189,7 +189,7 @@ mp_float_t mp_arg_validate_obj_float_non_negative(mp_obj_t float_in, mp_float_t ? default_for_null : mp_obj_get_float(float_in); if (f <= (mp_float_t)0.0) { - mp_raise_ValueError_varg(translate("%q must be >= 0"), arg_name); + mp_raise_ValueError_varg(translate("%q must be >= %d"), arg_name, 0); } return f; } From 8227903b617cd6aa38012b31803a1c4dfb280858 Mon Sep 17 00:00:00 2001 From: Jeff Epler Date: Thu, 23 Jun 2022 11:45:02 -0500 Subject: [PATCH 06/27] Use validation functions --- shared-bindings/audiobusio/PDMIn.c | 6 ++---- shared-bindings/vectorio/Circle.c | 4 +--- shared-bindings/vectorio/Rectangle.c | 8 ++------ 3 files changed, 5 insertions(+), 13 deletions(-) diff --git a/shared-bindings/audiobusio/PDMIn.c b/shared-bindings/audiobusio/PDMIn.c index 29752a442c..9df78ea449 100644 --- a/shared-bindings/audiobusio/PDMIn.c +++ b/shared-bindings/audiobusio/PDMIn.c @@ -188,10 +188,8 @@ STATIC MP_DEFINE_CONST_FUN_OBJ_VAR_BETWEEN(audiobusio_pdmin___exit___obj, 4, 4, STATIC mp_obj_t audiobusio_pdmin_obj_record(mp_obj_t self_obj, mp_obj_t destination, mp_obj_t destination_length) { audiobusio_pdmin_obj_t *self = MP_OBJ_TO_PTR(self_obj); check_for_deinit(self); - if (!mp_obj_is_small_int(destination_length) || MP_OBJ_SMALL_INT_VALUE(destination_length) < 0) { - mp_raise_TypeError(translate("destination_length must be an int >= 0")); - } - uint32_t length = MP_OBJ_SMALL_INT_VALUE(destination_length); + uint32_t length = mp_arg_validate_type_int(destination_length, MP_QSTR_length); + mp_arg_validate_length_min(length, 0, MP_QSTR_length); mp_buffer_info_t bufinfo; if (mp_obj_is_type(destination, &mp_type_fileio)) { diff --git a/shared-bindings/vectorio/Circle.c b/shared-bindings/vectorio/Circle.c index f955cd2afe..cce4f54e9d 100644 --- a/shared-bindings/vectorio/Circle.c +++ b/shared-bindings/vectorio/Circle.c @@ -34,9 +34,7 @@ static mp_obj_t vectorio_circle_make_new(const mp_obj_type_t *type, size_t n_arg mp_arg_parse_all_kw_array(n_args, n_kw, all_args, MP_ARRAY_SIZE(allowed_args), allowed_args, args); mp_int_t radius = args[ARG_radius].u_int; - if (radius < 1) { - mp_raise_ValueError_varg(translate("%q must be >= 1"), MP_QSTR_radius); - } + mp_arg_validate_int_min(radius, 1, MP_QSTR_radius); vectorio_circle_t *self = m_new_obj(vectorio_circle_t); self->base.type = &vectorio_circle_type; diff --git a/shared-bindings/vectorio/Rectangle.c b/shared-bindings/vectorio/Rectangle.c index 34b9e1eabe..13c68161b3 100644 --- a/shared-bindings/vectorio/Rectangle.c +++ b/shared-bindings/vectorio/Rectangle.c @@ -34,13 +34,9 @@ static mp_obj_t vectorio_rectangle_make_new(const mp_obj_type_t *type, size_t n_ mp_arg_parse_all_kw_array(n_args, n_kw, all_args, MP_ARRAY_SIZE(allowed_args), allowed_args, args); mp_int_t width = args[ARG_width].u_int; - if (width < 1) { - mp_raise_ValueError_varg(translate("%q must be >= 1"), MP_QSTR_width); - } + mp_arg_validate_int_min(width, 1, MP_QSTR_width); mp_int_t height = args[ARG_height].u_int; - if (height < 1) { - mp_raise_ValueError_varg(translate("%q must be >= 1"), MP_QSTR_height); - } + mp_arg_validate_int_min(height, 1, MP_QSTR_height); vectorio_rectangle_t *self = m_new_obj(vectorio_rectangle_t); self->base.type = &vectorio_rectangle_type; From 4f75d09e86d0876f8bba20bd06265359f06224f5 Mon Sep 17 00:00:00 2001 From: Jeff Epler Date: Thu, 22 Sep 2022 08:35:51 -0500 Subject: [PATCH 07/27] Get rid of an unneeded message --- shared-bindings/i2ctarget/I2CTarget.c | 5 +---- 1 file changed, 1 insertion(+), 4 deletions(-) diff --git a/shared-bindings/i2ctarget/I2CTarget.c b/shared-bindings/i2ctarget/I2CTarget.c index f094788140..81ddbe0ab8 100644 --- a/shared-bindings/i2ctarget/I2CTarget.c +++ b/shared-bindings/i2ctarget/I2CTarget.c @@ -85,10 +85,7 @@ STATIC mp_obj_t i2ctarget_i2c_target_make_new(const mp_obj_type_t *type, size_t uint8_t *addresses = NULL; unsigned int i = 0; while ((item = mp_iternext(iterable)) != MP_OBJ_STOP_ITERATION) { - mp_int_t value = mp_arg_validate_type_int(item, MP_QSTR_address); - if (value < 0x00 || value > 0x7f) { - mp_raise_ValueError(translate("address out of bounds")); - } + mp_uint_t value = mp_arg_validate_int_range(mp_obj_get_int(item), 0x00, 0x7f, MP_QSTR_address); addresses = m_renew(uint8_t, addresses, i, i + 1); addresses[i++] = value; } From a769beed3f2efe9fa9badf13194218334f849e48 Mon Sep 17 00:00:00 2001 From: Jeff Epler Date: Thu, 22 Sep 2022 16:23:38 -0500 Subject: [PATCH 08/27] Use new unique ID for this board --- .../espressif/boards/ai_thinker_esp32-c3s-2m/mpconfigboard.mk | 4 ++-- tools/ci_check_duplicate_usb_vid_pid.py | 1 - 2 files changed, 2 insertions(+), 3 deletions(-) diff --git a/ports/espressif/boards/ai_thinker_esp32-c3s-2m/mpconfigboard.mk b/ports/espressif/boards/ai_thinker_esp32-c3s-2m/mpconfigboard.mk index 125666b599..913f65f95c 100644 --- a/ports/espressif/boards/ai_thinker_esp32-c3s-2m/mpconfigboard.mk +++ b/ports/espressif/boards/ai_thinker_esp32-c3s-2m/mpconfigboard.mk @@ -1,5 +1,5 @@ -CIRCUITPY_CREATOR_ID = 0x70010001 -CIRCUITPY_CREATION_ID = 0x00100001 +CIRCUITPY_CREATOR_ID = 0x000C303B +CIRCUITPY_CREATION_ID = 0x00320001 IDF_TARGET = esp32c3 diff --git a/tools/ci_check_duplicate_usb_vid_pid.py b/tools/ci_check_duplicate_usb_vid_pid.py index f46295f240..87c68cfdc0 100644 --- a/tools/ci_check_duplicate_usb_vid_pid.py +++ b/tools/ci_check_duplicate_usb_vid_pid.py @@ -56,7 +56,6 @@ DEFAULT_CLUSTERLIST = { "espressif_esp32s3_devkitc_1_n8r8", ], "0x303A:0x7009": ["espressif_esp32s2_devkitc_1_n4", "espressif_esp32s2_devkitc_1_n4r2"], - "0x70010001:0x00100001": ["ai_thinker_esp32-c3s", "ai_thinker_esp32-c3s-2m"], } cli_parser = argparse.ArgumentParser( From 5bbbca4d44b7bcf1b7bbc1499f6b51e8e11b5dd1 Mon Sep 17 00:00:00 2001 From: Jeff Epler Date: Thu, 22 Sep 2022 17:03:05 -0500 Subject: [PATCH 09/27] lock and unlock i2c bus around any ops that might access it --- .../espressif/bindings/esp32_camera/Camera.c | 2 +- .../espressif/bindings/esp32_camera/Camera.h | 2 +- .../common-hal/esp32_camera/Camera.c | 32 +++++++++++++++++-- .../common-hal/esp32_camera/Camera.h | 2 ++ 4 files changed, 34 insertions(+), 4 deletions(-) diff --git a/ports/espressif/bindings/esp32_camera/Camera.c b/ports/espressif/bindings/esp32_camera/Camera.c index 4474f3024f..2f09970251 100644 --- a/ports/espressif/bindings/esp32_camera/Camera.c +++ b/ports/espressif/bindings/esp32_camera/Camera.c @@ -125,7 +125,7 @@ STATIC mp_obj_t esp32_camera_camera_make_new(const mp_obj_type_t *type, size_t n const mcu_pin_obj_t *pixel_clock_pin = validate_obj_is_free_pin(args[ARG_pixel_clock_pin].u_obj); const mcu_pin_obj_t *vsync_pin = validate_obj_is_free_pin(args[ARG_vsync_pin].u_obj); const mcu_pin_obj_t *href_pin = validate_obj_is_free_pin(args[ARG_href_pin].u_obj); - const busio_i2c_obj_t *i2c = MP_OBJ_TO_PTR(mp_arg_validate_type(args[ARG_i2c].u_obj, &busio_i2c_type, MP_QSTR_i2c)); + busio_i2c_obj_t *i2c = MP_OBJ_TO_PTR(mp_arg_validate_type(args[ARG_i2c].u_obj, &busio_i2c_type, MP_QSTR_i2c)); const mcu_pin_obj_t *external_clock_pin = validate_obj_is_free_pin(args[ARG_external_clock_pin].u_obj); const mcu_pin_obj_t *powerdown_pin = validate_obj_is_free_pin_or_none(args[ARG_powerdown_pin].u_obj); const mcu_pin_obj_t *reset_pin = validate_obj_is_free_pin_or_none(args[ARG_reset_pin].u_obj); diff --git a/ports/espressif/bindings/esp32_camera/Camera.h b/ports/espressif/bindings/esp32_camera/Camera.h index 146cd0da05..f190808531 100644 --- a/ports/espressif/bindings/esp32_camera/Camera.h +++ b/ports/espressif/bindings/esp32_camera/Camera.h @@ -45,7 +45,7 @@ extern void common_hal_esp32_camera_camera_construct( const mcu_pin_obj_t *href_pin, const mcu_pin_obj_t *powerdown_pin, const mcu_pin_obj_t *reset_pin, - const busio_i2c_obj_t *i2c, + busio_i2c_obj_t *i2c, mp_int_t external_clock_frequency, pixformat_t pixel_format, framesize_t frame_size, diff --git a/ports/espressif/common-hal/esp32_camera/Camera.c b/ports/espressif/common-hal/esp32_camera/Camera.c index 5ee112a911..65d2d0fbc6 100644 --- a/ports/espressif/common-hal/esp32_camera/Camera.c +++ b/ports/espressif/common-hal/esp32_camera/Camera.c @@ -24,12 +24,15 @@ * THE SOFTWARE. */ +#include "py/mperrno.h" #include "py/runtime.h" #include "bindings/esp32_camera/Camera.h" #include "bindings/espidf/__init__.h" #include "common-hal/esp32_camera/Camera.h" +#include "shared-bindings/busio/I2C.h" #include "shared-bindings/microcontroller/Pin.h" +#include "shared-bindings/util.h" #include "common-hal/microcontroller/Pin.h" #include "esp32-camera/driver/private_include/cam_hal.h" @@ -38,6 +41,19 @@ #error esp32_camera only works on boards configured with spiram, disable it in mpconfigboard.mk #endif +static void i2c_lock(esp32_camera_camera_obj_t *self) { + if (common_hal_busio_i2c_deinited(self->i2c)) { + raise_deinited_error(); + } + if (!common_hal_busio_i2c_try_lock(self->i2c)) { + mp_raise_OSError(MP_EWOULDBLOCK); + } +} + +static void i2c_unlock(esp32_camera_camera_obj_t *self) { + common_hal_busio_i2c_unlock(self->i2c); +} + static void maybe_claim_pin(const mcu_pin_obj_t *pin) { if (pin) { claim_pin(pin); @@ -53,7 +69,7 @@ void common_hal_esp32_camera_camera_construct( const mcu_pin_obj_t *href_pin, const mcu_pin_obj_t *powerdown_pin, const mcu_pin_obj_t *reset_pin, - const busio_i2c_obj_t *i2c, + busio_i2c_obj_t *i2c, mp_int_t external_clock_frequency, pixformat_t pixel_format, framesize_t frame_size, @@ -78,6 +94,8 @@ void common_hal_esp32_camera_camera_construct( common_hal_pwmio_pwmout_construct(&self->pwm, external_clock_pin, 1, external_clock_frequency, true); + self->i2c = i2c; + self->camera_config.pin_pwdn = common_hal_mcu_pin_number(powerdown_pin); self->camera_config.pin_reset = common_hal_mcu_pin_number(reset_pin); self->camera_config.pin_xclk = common_hal_mcu_pin_number(external_clock_pin); @@ -112,7 +130,11 @@ void common_hal_esp32_camera_camera_construct( self->camera_config.sccb_i2c_port = i2c->i2c_num; - CHECK_ESP_RESULT(esp_camera_init(&self->camera_config)); + i2c_lock(self); + esp_err_t result = esp_camera_init(&self->camera_config); + i2c_unlock(self); + + CHECK_ESP_RESULT(result); } extern void common_hal_esp32_camera_camera_deinit(esp32_camera_camera_obj_t *self) { @@ -165,7 +187,9 @@ camera_fb_t *common_hal_esp32_camera_camera_take(esp32_camera_camera_obj_t *self #define SENSOR_GET(type, name, status_field_name, setter_function_name) \ type common_hal_esp32_camera_camera_get_##name(esp32_camera_camera_obj_t * self) { \ + i2c_lock(self); \ sensor_t *sensor = esp_camera_sensor_get(); \ + i2c_unlock(self); \ if (!sensor->setter_function_name) { \ mp_raise_AttributeError(translate("no such attribute")); \ } \ @@ -174,7 +198,9 @@ camera_fb_t *common_hal_esp32_camera_camera_take(esp32_camera_camera_obj_t *self #define SENSOR_SET(type, name, setter_function_name) \ void common_hal_esp32_camera_camera_set_##name(esp32_camera_camera_obj_t * self, type value) { \ + i2c_lock(self); \ sensor_t *sensor = esp_camera_sensor_get(); \ + i2c_unlock(self); \ if (!sensor->setter_function_name) { \ mp_raise_AttributeError(translate("no such attribute")); \ } \ @@ -203,6 +229,7 @@ void common_hal_esp32_camera_camera_reconfigure(esp32_camera_camera_obj_t *self, frame_size = sensor_info->max_size; } + i2c_lock(self); cam_deinit(); self->camera_config.pixel_format = pixel_format; self->camera_config.frame_size = frame_size; @@ -212,6 +239,7 @@ void common_hal_esp32_camera_camera_reconfigure(esp32_camera_camera_obj_t *self, sensor->set_framesize(sensor, self->camera_config.frame_size); cam_init(&self->camera_config); cam_config(&self->camera_config, frame_size, sensor_info->pid); + i2c_unlock(self); cam_start(); } diff --git a/ports/espressif/common-hal/esp32_camera/Camera.h b/ports/espressif/common-hal/esp32_camera/Camera.h index 9c21f81b16..4f34fa54cd 100644 --- a/ports/espressif/common-hal/esp32_camera/Camera.h +++ b/ports/espressif/common-hal/esp32_camera/Camera.h @@ -29,10 +29,12 @@ #include "py/obj.h" #include "esp_camera.h" #include "shared-bindings/pwmio/PWMOut.h" +#include "common-hal/busio/I2C.h" typedef struct esp32_camera_camera_obj { mp_obj_base_t base; camera_config_t camera_config; camera_fb_t *buffer_to_return; pwmio_pwmout_obj_t pwm; + busio_i2c_obj_t *i2c; } esp32_camera_obj_t; From 52a2c5f6dcfb4a556211fe5777fad76277682576 Mon Sep 17 00:00:00 2001 From: Jeff Epler Date: Fri, 23 Sep 2022 08:27:05 -0500 Subject: [PATCH 10/27] Update ulab to 5.1.1 Closes: #6692 --- extmod/ulab | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/extmod/ulab b/extmod/ulab index 346c936e14..57de23c1fb 160000 --- a/extmod/ulab +++ b/extmod/ulab @@ -1 +1 @@ -Subproject commit 346c936e14c6ea3a8d3d65cb1fa46202dc92999d +Subproject commit 57de23c1fb434ba99aaafe1d00bd77d5cdf5d66b From f12136af7fd8fdc48c59276f8c7532634aba9066 Mon Sep 17 00:00:00 2001 From: Jeff Epler Date: Fri, 23 Sep 2022 08:54:00 -0500 Subject: [PATCH 11/27] esp32-camera: sync doc with code. Closes: #6836 --- ports/espressif/bindings/esp32_camera/Camera.c | 14 +++++++------- 1 file changed, 7 insertions(+), 7 deletions(-) diff --git a/ports/espressif/bindings/esp32_camera/Camera.c b/ports/espressif/bindings/esp32_camera/Camera.c index 2f09970251..1186afc90f 100644 --- a/ports/espressif/bindings/esp32_camera/Camera.c +++ b/ports/espressif/bindings/esp32_camera/Camera.c @@ -46,9 +46,9 @@ //| self, //| *, //| data_pins: List[microcontroller.Pin], -//| pixel_clock: microcontroller.Pin, -//| vsync: microcontroller.Pin, -//| href: microcontroller.Pin, +//| pixel_clock_pin: microcontroller.Pin, +//| vsync_pin: microcontroller.Pin, +//| href_pin: microcontroller.Pin, //| i2c: busio.I2C, //| external_clock_pin: microcontroller.Pin, //| external_clock_frequency: int, @@ -79,12 +79,12 @@ //| that case. //| //| :param data_pins: The 8 data data_pins used for image data transfer from the camera module, least significant bit first -//| :param pixel_clock: The pixel clock output from the camera module -//| :param vsync: The vertical sync pulse output from the camera module -//| :param href: The horizontal reference output from the camera module +//| :param pixel_clock_pin: The pixel clock output from the camera module +//| :param vsync_pin: The vertical sync pulse output from the camera module +//| :param href_pin: The horizontal reference output from the camera module //| :param i2c: The I2C bus connected to the camera module -//| :param external_clock_frequency: The frequency generated on the external clock pin //| :param external_clock_pin: The pin on which to generate the external clock +//| :param external_clock_frequency: The frequency generated on the external clock pin //| :param powerdown_pin: The powerdown input to the camera module //| :param reset_pin: The reset input to the camera module //| :param pixel_format: The pixel format of the captured image From 714da7bc283913d836ec6ec8a65c20540926fcff Mon Sep 17 00:00:00 2001 From: Alvaro Figueroa Date: Wed, 21 Sep 2022 17:56:56 +0000 Subject: [PATCH 12/27] Translated using Weblate (Spanish) Currently translated at 86.5% (868 of 1003 strings) Translation: CircuitPython/main Translate-URL: https://hosted.weblate.org/projects/circuitpython/main/es/ --- locale/es.po | 35 +++++++++++++++++++---------------- 1 file changed, 19 insertions(+), 16 deletions(-) diff --git a/locale/es.po b/locale/es.po index 3ef0d2f6e9..0d981d2d7c 100644 --- a/locale/es.po +++ b/locale/es.po @@ -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: 2021-08-23 14:19+0000\n" -"Last-Translator: Jeff Epler \n" +"PO-Revision-Date: 2022-09-23 17:20+0000\n" +"Last-Translator: Alvaro Figueroa \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.8.1-dev\n" +"X-Generator: Weblate 4.14.1\n" #: main.c msgid "" @@ -31,6 +31,8 @@ msgid "" "\n" "Code stopped by auto-reload. Reloading soon.\n" msgstr "" +"\n" +"Código detenido por la auto-recarga. Recargando pronto.\n" #: supervisor/shared/safe_mode.c msgid "" @@ -85,20 +87,21 @@ msgstr "" #: ports/raspberrypi/common-hal/analogio/AnalogOut.c #: ports/raspberrypi/common-hal/rtc/RTC.c ports/stm/common-hal/alarm/__init__.c #: ports/stm/common-hal/rtc/RTC.c +#, fuzzy msgid "%q" -msgstr "" +msgstr "%q" #: shared-bindings/microcontroller/Pin.c msgid "%q and %q contain duplicate pins" -msgstr "" +msgstr "%q y %q contienen pines duplicados" #: ports/atmel-samd/common-hal/audioio/AudioOut.c msgid "%q and %q must be different" -msgstr "" +msgstr "%q y %q deben ser diferentes" #: shared-bindings/microcontroller/Pin.c msgid "%q contains duplicate pins" -msgstr "" +msgstr "%q contiene pines duplicados" #: ports/atmel-samd/common-hal/sdioio/SDCard.c msgid "%q failure: %d" @@ -118,31 +121,31 @@ msgstr "%q indices deben ser enteros, no %s" #: shared-module/bitbangio/SPI.c msgid "%q init failed" -msgstr "" +msgstr "%q inicializado fallido" #: py/argcheck.c msgid "%q length must be %d" -msgstr "" +msgstr "%q tamaño debe ser %d" #: py/argcheck.c msgid "%q length must be %d-%d" -msgstr "" +msgstr "%q tamaño debe ser %d-%d" #: py/argcheck.c msgid "%q length must be <= %d" -msgstr "" +msgstr "%q tamaño debe ser <= %d" #: py/argcheck.c msgid "%q length must be >= %d" -msgstr "" +msgstr "%q tamaño debe ser >= %d" #: shared-bindings/busio/I2C.c msgid "%q length must be >= 1" -msgstr "" +msgstr "%q tamaño debe ser >= 1" #: py/argcheck.c msgid "%q must be %d" -msgstr "" +msgstr "%q debe ser %d" #: py/argcheck.c msgid "%q must be %d-%d" @@ -150,11 +153,11 @@ msgstr "%q debe ser %d-%d" #: shared-bindings/displayio/Display.c msgid "%q must be 1 when %q is True" -msgstr "" +msgstr "%q debe ser 1 cuando %q es True" #: py/argcheck.c shared-bindings/gifio/GifWriter.c msgid "%q must be <= %d" -msgstr "" +msgstr "%q debe ser <= %d" #: py/argcheck.c msgid "%q must be >= %d" From a7406ec0989d2dfc836718b6172b6a3cb57b27fa Mon Sep 17 00:00:00 2001 From: snkYmkrct Date: Fri, 23 Sep 2022 19:20:44 +0200 Subject: [PATCH 13/27] Support for opening a file by name in MP3Decoder --- locale/circuitpython.pot | 4 ++++ shared-bindings/audiomp3/MP3Decoder.c | 21 +++++++++++++++++++++ 2 files changed, 25 insertions(+) diff --git a/locale/circuitpython.pot b/locale/circuitpython.pot index 52f1bdb5ad..98fe415ce6 100644 --- a/locale/circuitpython.pot +++ b/locale/circuitpython.pot @@ -2942,6 +2942,10 @@ msgstr "" msgid "file must be a file opened in byte mode" msgstr "" +#: shared-bindings/audiomp3/MP3Decoder.c +msgid "file path must be provided as input" +msgstr "" + #: shared-bindings/traceback/__init__.c msgid "file write is not available" msgstr "" diff --git a/shared-bindings/audiomp3/MP3Decoder.c b/shared-bindings/audiomp3/MP3Decoder.c index f1b5a29cd5..5e2273add5 100644 --- a/shared-bindings/audiomp3/MP3Decoder.c +++ b/shared-bindings/audiomp3/MP3Decoder.c @@ -172,6 +172,26 @@ STATIC mp_obj_t audiomp3_mp3file_obj_set_file(mp_obj_t self_in, mp_obj_t file) { } MP_DEFINE_CONST_FUN_OBJ_2(audiomp3_mp3file_set_file_obj, audiomp3_mp3file_obj_set_file); +//| def open_file(self, str) -> None: +//| """Takes in the name of a mp3 file, opens it, and replaces the old playback file.""" +//| ... +//| +STATIC mp_obj_t audiomp3_mp3file_obj_open_file(mp_obj_t self_in, mp_obj_t path) { + audiomp3_mp3file_obj_t *self = MP_OBJ_TO_PTR(self_in); + mp_obj_t file; + check_for_deinit(self); + if (!mp_obj_is_str(path)) { + mp_raise_TypeError(translate("file path must be provided as input")); + } + file = mp_call_function_2(MP_OBJ_FROM_PTR(&mp_builtin_open_obj), path, MP_ROM_QSTR(MP_QSTR_rb)); + if (!mp_obj_is_type(file, &mp_type_fileio)) { + mp_raise_TypeError(translate("file must be a file opened in byte mode")); + } + common_hal_audiomp3_mp3file_set_file(self, file); + return mp_const_none; +} +MP_DEFINE_CONST_FUN_OBJ_2(audiomp3_mp3file_open_file_obj, audiomp3_mp3file_obj_open_file); + MP_PROPERTY_GETSET(audiomp3_mp3file_file_obj, (mp_obj_t)&audiomp3_mp3file_get_file_obj, (mp_obj_t)&audiomp3_mp3file_set_file_obj); @@ -256,6 +276,7 @@ MP_PROPERTY_GETTER(audiomp3_mp3file_samples_decoded_obj, STATIC const mp_rom_map_elem_t audiomp3_mp3file_locals_dict_table[] = { // Methods + { MP_ROM_QSTR(MP_QSTR_open_file), MP_ROM_PTR(&audiomp3_mp3file_open_file_obj) }, { MP_ROM_QSTR(MP_QSTR_deinit), MP_ROM_PTR(&audiomp3_mp3file_deinit_obj) }, { MP_ROM_QSTR(MP_QSTR___enter__), MP_ROM_PTR(&default___enter___obj) }, { MP_ROM_QSTR(MP_QSTR___exit__), MP_ROM_PTR(&audiomp3_mp3file___exit___obj) }, From c19bceaeaa6abbfaa438e1de2f34a593a96942a8 Mon Sep 17 00:00:00 2001 From: Bill Sideris Date: Thu, 22 Sep 2022 16:01:51 +0000 Subject: [PATCH 14/27] Translated using Weblate (Greek) Currently translated at 2.5% (26 of 1003 strings) Translation: CircuitPython/main Translate-URL: https://hosted.weblate.org/projects/circuitpython/main/el/ --- locale/el.po | 60 +++++++++++++++++++++++++++++----------------------- 1 file changed, 34 insertions(+), 26 deletions(-) diff --git a/locale/el.po b/locale/el.po index 05c36779f8..8205801d3a 100644 --- a/locale/el.po +++ b/locale/el.po @@ -8,19 +8,23 @@ msgstr "" "Project-Id-Version: PACKAGE VERSION\n" "Report-Msgid-Bugs-To: \n" "POT-Creation-Date: 2021-01-04 12:55-0600\n" -"PO-Revision-Date: YEAR-MO-DA HO:MI+ZONE\n" -"Last-Translator: Automatically generated\n" +"PO-Revision-Date: 2022-09-23 17:20+0000\n" +"Last-Translator: Bill Sideris \n" "Language-Team: none\n" "Language: el\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.14.1\n" #: main.c msgid "" "\n" "Code done running.\n" msgstr "" +"\n" +"Η εκτέλεση του κώδικα ολοκληρώθηκε.\n" #: main.c msgid "" @@ -34,14 +38,18 @@ msgid "" "Please file an issue with the contents of your CIRCUITPY drive at \n" "https://github.com/adafruit/circuitpython/issues\n" msgstr "" +"\n" +"Παρακαλώ δημιουγήστε ενα πρόβλημα με τα περιεχόμενα του CIRCUITPY δίσκου " +"στο\n" +"https://github.com/adafruit/circuitpython/issues\n" #: py/obj.c msgid " File \"%q\"" -msgstr "" +msgstr " Αρχείο \"%q\"" #: py/obj.c msgid " File \"%q\", line %d" -msgstr "" +msgstr " Αρχείο \"%q\", γραμμή %d" #: py/builtinhelp.c msgid " is of type %q\n" @@ -53,7 +61,7 @@ msgstr "" #: main.c msgid " output:\n" -msgstr "" +msgstr " έξοδος:\n" #: py/objstr.c #, c-format @@ -325,7 +333,7 @@ msgstr "" #: py/compile.c msgid "'await' outside function" -msgstr "" +msgstr "'await' εκτός συνάρτησης" #: py/compile.c msgid "'await', 'async for' or 'async with' outside async function" @@ -337,15 +345,15 @@ msgstr "" #: py/compile.c msgid "'continue' outside loop" -msgstr "" +msgstr "'continue' εκτός επανάληψης" #: py/objgenerator.c msgid "'coroutine' object is not an iterator" -msgstr "" +msgstr "'coroutine' αντικείμενο δεν μπορεί να χρησιμοποιηθεί σαν επαναλήπτης" #: py/compile.c msgid "'data' requires at least 2 arguments" -msgstr "" +msgstr "'data' απαιτεί τουλάχιστον 2 παραμέτρους" #: py/compile.c msgid "'data' requires integer arguments" @@ -373,15 +381,15 @@ msgstr "" #: py/obj.c msgid ", in %q\n" -msgstr "" +msgstr ", στο %q\n" #: py/objcomplex.c msgid "0.0 to a complex power" -msgstr "" +msgstr "0.0 σε μία σύνθετη δύναμη" #: py/modbuiltins.c msgid "3-arg pow() not supported" -msgstr "" +msgstr "pow() με 3 παραμέτρους δεν υποστηρίζεται" #: shared-module/msgpack/__init__.c msgid "64 bit types" @@ -391,66 +399,66 @@ msgstr "" #: ports/atmel-samd/common-hal/countio/Counter.c #: ports/atmel-samd/common-hal/rotaryio/IncrementalEncoder.c msgid "A hardware interrupt channel is already in use" -msgstr "" +msgstr "Ένα κανάλι interrupt υλικού είναι ήδη σε χρήση" #: ports/espressif/common-hal/analogio/AnalogIn.c msgid "ADC2 is being used by WiFi" -msgstr "" +msgstr "Το ADC2 χρησιμοποιείται απο το WIFI" #: shared-bindings/_bleio/Address.c shared-bindings/ipaddress/IPv4Address.c #, c-format msgid "Address must be %d bytes long" -msgstr "" +msgstr "Η διεύθυνση πρέπει να είναι %d bytes μεγάλη" #: ports/espressif/common-hal/canio/CAN.c msgid "All CAN peripherals are in use" -msgstr "" +msgstr "Όλα τα περιφεριακά CAN είναι σε χρήση" #: ports/espressif/common-hal/busio/I2C.c #: ports/espressif/common-hal/i2ctarget/I2CTarget.c #: ports/nrf/common-hal/busio/I2C.c msgid "All I2C peripherals are in use" -msgstr "" +msgstr "Όλα τα I2C περιφεριακά ειναι σε χρήση" #: ports/espressif/common-hal/countio/Counter.c #: ports/espressif/common-hal/frequencyio/FrequencyIn.c #: ports/espressif/common-hal/rotaryio/IncrementalEncoder.c msgid "All PCNT units in use" -msgstr "" +msgstr "Όλες οι μονάδες PCNT είναι σε χρήση" #: ports/atmel-samd/common-hal/canio/Listener.c #: ports/espressif/common-hal/canio/Listener.c #: ports/stm/common-hal/canio/Listener.c msgid "All RX FIFOs in use" -msgstr "" +msgstr "Όλα τα RX FIFOs είναι σε χρήση" #: ports/espressif/common-hal/busio/SPI.c ports/nrf/common-hal/busio/SPI.c msgid "All SPI peripherals are in use" -msgstr "" +msgstr "Όλα τα SPI περιφεριακά είναι σε χρήση" #: ports/espressif/common-hal/busio/UART.c ports/nrf/common-hal/busio/UART.c #: ports/raspberrypi/common-hal/busio/UART.c msgid "All UART peripherals are in use" -msgstr "" +msgstr "Όλα τα UART περιφεριακά ειναι σε χρήση" #: ports/nrf/common-hal/countio/Counter.c #: ports/nrf/common-hal/pulseio/PulseIn.c #: ports/nrf/common-hal/rotaryio/IncrementalEncoder.c #: shared-bindings/pwmio/PWMOut.c msgid "All channels in use" -msgstr "" +msgstr "Όλα τα κανάλια είναι σε χρήση" #: ports/atmel-samd/common-hal/audioio/AudioOut.c msgid "All event channels in use" -msgstr "" +msgstr "Όλα τα κανάλια γεγονότων είναι σε χρήση" #: ports/raspberrypi/common-hal/rp2pio/StateMachine.c msgid "All state machines in use" -msgstr "" +msgstr "Όλες οι μηχανές κατάστασης είναι σε χρήση" #: ports/atmel-samd/audio_dma.c msgid "All sync event channels in use" -msgstr "" +msgstr "Όλα τα κανάλια γεγονότων συγχρονισμού είναι σε χρήση" #: shared-bindings/pwmio/PWMOut.c msgid "All timers for this pin are in use" @@ -535,7 +543,7 @@ msgstr "" #: main.c msgid "Auto-reload is off.\n" -msgstr "" +msgstr "Η αυτόματη επαναφόρτωση είναι απενεργοποιημένη.\n" #: main.c msgid "" From 2dbcd760fc9e253d2f91904e2ff31d472f427697 Mon Sep 17 00:00:00 2001 From: Neradoc Date: Sun, 25 Sep 2022 04:53:54 +0200 Subject: [PATCH 15/27] usb_cdc.Serial.readinto has no nbytes parameter --- shared-bindings/usb_cdc/Serial.c | 7 ++++--- 1 file changed, 4 insertions(+), 3 deletions(-) diff --git a/shared-bindings/usb_cdc/Serial.c b/shared-bindings/usb_cdc/Serial.c index 8a74380be3..47e91b5721 100644 --- a/shared-bindings/usb_cdc/Serial.c +++ b/shared-bindings/usb_cdc/Serial.c @@ -54,11 +54,12 @@ //| ... //| //| def readinto(self, buf: WriteableBuffer) -> int: -//| """Read bytes into the ``buf``. If ``nbytes`` is specified then read at most -//| that many bytes, subject to `timeout`. Otherwise, read at most ``len(buf)`` bytes. +//| """Read bytes into the ``buf``. Read at most ``len(buf)`` bytes. If `timeout` +//| is > 0 or ``None``, keep waiting until the timeout expires or ``len(buf)`` +//| bytes are available. //| //| :return: number of bytes read and stored into ``buf`` -//| :rtype: bytes""" +//| :rtype: int""" //| ... //| //| def readline(self, size: int = -1) -> Optional[bytes]: From 5346b89b08400d84f895f723f23ea7fd98967cc6 Mon Sep 17 00:00:00 2001 From: Neradoc Date: Sun, 25 Sep 2022 07:18:18 +0200 Subject: [PATCH 16/27] don't use @property in docs, just document as a property --- ports/raspberrypi/bindings/rp2pio/StateMachine.c | 12 +++++------- shared-bindings/sdioio/SDCard.c | 14 +++++--------- 2 files changed, 10 insertions(+), 16 deletions(-) diff --git a/ports/raspberrypi/bindings/rp2pio/StateMachine.c b/ports/raspberrypi/bindings/rp2pio/StateMachine.c index be87a47ec5..97668bf303 100644 --- a/ports/raspberrypi/bindings/rp2pio/StateMachine.c +++ b/ports/raspberrypi/bindings/rp2pio/StateMachine.c @@ -521,9 +521,8 @@ STATIC mp_obj_t rp2pio_statemachine_obj_stop_background_write(mp_obj_t self_in) } MP_DEFINE_CONST_FUN_OBJ_1(rp2pio_statemachine_stop_background_write_obj, rp2pio_statemachine_obj_stop_background_write); -//| @property -//| def writing(self) -> bool: -//| """Returns True if a background write is in progress""" +//| writing: bool +//| """Returns True if a background write is in progress""" //| STATIC mp_obj_t rp2pio_statemachine_obj_get_writing(mp_obj_t self_in) { rp2pio_statemachine_obj_t *self = MP_OBJ_TO_PTR(self_in); @@ -539,11 +538,10 @@ const mp_obj_property_t rp2pio_statemachine_writing_obj = { }; -//| @property -//| def pending(self) -> int: -//| """Returns the number of pending buffers for background writing. +//| pending: int +//| """Returns the number of pending buffers for background writing. //| -//| If the number is 0, then a `StateMachine.background_write` call will not block.""" +//| If the number is 0, then a `StateMachine.background_write` call will not block.""" //| STATIC mp_obj_t rp2pio_statemachine_obj_get_pending(mp_obj_t self_in) { rp2pio_statemachine_obj_t *self = MP_OBJ_TO_PTR(self_in); diff --git a/shared-bindings/sdioio/SDCard.c b/shared-bindings/sdioio/SDCard.c index dbeb50ddf3..d3929c9372 100644 --- a/shared-bindings/sdioio/SDCard.c +++ b/shared-bindings/sdioio/SDCard.c @@ -201,11 +201,9 @@ STATIC mp_obj_t sdioio_sdcard_writeblocks(mp_obj_t self_in, mp_obj_t start_block MP_DEFINE_CONST_FUN_OBJ_3(sdioio_sdcard_writeblocks_obj, sdioio_sdcard_writeblocks); -//| @property -//| def frequency(self) -> int: -//| """The actual SDIO bus frequency. This may not match the frequency -//| requested due to internal limitations.""" -//| ... +//| frequency: int +//| """The actual SDIO bus frequency. This may not match the frequency +//| requested due to internal limitations.""" //| STATIC mp_obj_t sdioio_sdcard_obj_get_frequency(mp_obj_t self_in) { sdioio_sdcard_obj_t *self = MP_OBJ_TO_PTR(self_in); @@ -217,10 +215,8 @@ MP_DEFINE_CONST_FUN_OBJ_1(sdioio_sdcard_get_frequency_obj, sdioio_sdcard_obj_get MP_PROPERTY_GETTER(sdioio_sdcard_frequency_obj, (mp_obj_t)&sdioio_sdcard_get_frequency_obj); -//| @property -//| def width(self) -> int: -//| """The actual SDIO bus width, in bits""" -//| ... +//| width:int +//| """The actual SDIO bus width, in bits""" //| STATIC mp_obj_t sdioio_sdcard_obj_get_width(mp_obj_t self_in) { sdioio_sdcard_obj_t *self = MP_OBJ_TO_PTR(self_in); From ee6bd09438263a5e3e8ed2cb1326dfde1657f780 Mon Sep 17 00:00:00 2001 From: snkYmkrct Date: Sun, 25 Sep 2022 10:42:49 +0200 Subject: [PATCH 17/27] Rename method, and remove redundant checks --- locale/circuitpython.pot | 4 ---- shared-bindings/audiomp3/MP3Decoder.c | 19 +++++++------------ 2 files changed, 7 insertions(+), 16 deletions(-) diff --git a/locale/circuitpython.pot b/locale/circuitpython.pot index 98fe415ce6..52f1bdb5ad 100644 --- a/locale/circuitpython.pot +++ b/locale/circuitpython.pot @@ -2942,10 +2942,6 @@ msgstr "" msgid "file must be a file opened in byte mode" msgstr "" -#: shared-bindings/audiomp3/MP3Decoder.c -msgid "file path must be provided as input" -msgstr "" - #: shared-bindings/traceback/__init__.c msgid "file write is not available" msgstr "" diff --git a/shared-bindings/audiomp3/MP3Decoder.c b/shared-bindings/audiomp3/MP3Decoder.c index 5e2273add5..583cfbdc99 100644 --- a/shared-bindings/audiomp3/MP3Decoder.c +++ b/shared-bindings/audiomp3/MP3Decoder.c @@ -172,25 +172,20 @@ STATIC mp_obj_t audiomp3_mp3file_obj_set_file(mp_obj_t self_in, mp_obj_t file) { } MP_DEFINE_CONST_FUN_OBJ_2(audiomp3_mp3file_set_file_obj, audiomp3_mp3file_obj_set_file); -//| def open_file(self, str) -> None: +//| def open(self, str) -> None: //| """Takes in the name of a mp3 file, opens it, and replaces the old playback file.""" //| ... //| -STATIC mp_obj_t audiomp3_mp3file_obj_open_file(mp_obj_t self_in, mp_obj_t path) { +STATIC mp_obj_t audiomp3_mp3file_obj_open(mp_obj_t self_in, mp_obj_t path) { audiomp3_mp3file_obj_t *self = MP_OBJ_TO_PTR(self_in); - mp_obj_t file; check_for_deinit(self); - if (!mp_obj_is_str(path)) { - mp_raise_TypeError(translate("file path must be provided as input")); - } - file = mp_call_function_2(MP_OBJ_FROM_PTR(&mp_builtin_open_obj), path, MP_ROM_QSTR(MP_QSTR_rb)); - if (!mp_obj_is_type(file, &mp_type_fileio)) { - mp_raise_TypeError(translate("file must be a file opened in byte mode")); - } + + mp_obj_t file = mp_call_function_2(MP_OBJ_FROM_PTR(&mp_builtin_open_obj), path, MP_ROM_QSTR(MP_QSTR_rb)); + common_hal_audiomp3_mp3file_set_file(self, file); return mp_const_none; } -MP_DEFINE_CONST_FUN_OBJ_2(audiomp3_mp3file_open_file_obj, audiomp3_mp3file_obj_open_file); +MP_DEFINE_CONST_FUN_OBJ_2(audiomp3_mp3file_open_obj, audiomp3_mp3file_obj_open); MP_PROPERTY_GETSET(audiomp3_mp3file_file_obj, (mp_obj_t)&audiomp3_mp3file_get_file_obj, @@ -276,7 +271,7 @@ MP_PROPERTY_GETTER(audiomp3_mp3file_samples_decoded_obj, STATIC const mp_rom_map_elem_t audiomp3_mp3file_locals_dict_table[] = { // Methods - { MP_ROM_QSTR(MP_QSTR_open_file), MP_ROM_PTR(&audiomp3_mp3file_open_file_obj) }, + { MP_ROM_QSTR(MP_QSTR_open), MP_ROM_PTR(&audiomp3_mp3file_open_obj) }, { MP_ROM_QSTR(MP_QSTR_deinit), MP_ROM_PTR(&audiomp3_mp3file_deinit_obj) }, { MP_ROM_QSTR(MP_QSTR___enter__), MP_ROM_PTR(&default___enter___obj) }, { MP_ROM_QSTR(MP_QSTR___exit__), MP_ROM_PTR(&audiomp3_mp3file___exit___obj) }, From d7ea1c39c68fd934dc4226622f96708e0c4f0f34 Mon Sep 17 00:00:00 2001 From: snkYmkrct Date: Sun, 25 Sep 2022 13:34:50 +0200 Subject: [PATCH 18/27] Minor update to MP3Decoder documentation --- shared-bindings/audiomp3/MP3Decoder.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/shared-bindings/audiomp3/MP3Decoder.c b/shared-bindings/audiomp3/MP3Decoder.c index 583cfbdc99..5795fb8730 100644 --- a/shared-bindings/audiomp3/MP3Decoder.c +++ b/shared-bindings/audiomp3/MP3Decoder.c @@ -172,7 +172,7 @@ STATIC mp_obj_t audiomp3_mp3file_obj_set_file(mp_obj_t self_in, mp_obj_t file) { } MP_DEFINE_CONST_FUN_OBJ_2(audiomp3_mp3file_set_file_obj, audiomp3_mp3file_obj_set_file); -//| def open(self, str) -> None: +//| def open(self, filepath: str) -> None: //| """Takes in the name of a mp3 file, opens it, and replaces the old playback file.""" //| ... //| From e25c195b789c5273adf028980fc1d371557f5e8f Mon Sep 17 00:00:00 2001 From: Dan Halbert Date: Sun, 25 Sep 2022 09:12:23 -0400 Subject: [PATCH 19/27] fix broadcom UART ringbuf init --- ports/broadcom/common-hal/busio/UART.c | 1 - 1 file changed, 1 deletion(-) diff --git a/ports/broadcom/common-hal/busio/UART.c b/ports/broadcom/common-hal/busio/UART.c index 6d97b42c76..9f51f15acb 100644 --- a/ports/broadcom/common-hal/busio/UART.c +++ b/ports/broadcom/common-hal/busio/UART.c @@ -211,7 +211,6 @@ void common_hal_busio_uart_construct(busio_uart_obj_t *self, // Use the provided buffer when given. if (receiver_buffer != NULL) { ringbuf_init(&self->ringbuf, receiver_buffer, receiver_buffer_size); - self->ringbuf = (ringbuf_t) { receiver_buffer, receiver_buffer_size }; } else { // Initially allocate the UART's buffer in the long-lived part of the // heap. UARTs are generally long-lived objects, but the "make long- From 2c35e5e284c5bd2b180e787ec0adf4ff366accfd Mon Sep 17 00:00:00 2001 From: Neradoc Date: Sun, 25 Sep 2022 16:10:11 +0200 Subject: [PATCH 20/27] avoid problematic sphinx version number for rtd theme --- requirements-doc.txt | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/requirements-doc.txt b/requirements-doc.txt index 40ab2ad4ac..43e99fa32f 100644 --- a/requirements-doc.txt +++ b/requirements-doc.txt @@ -9,7 +9,7 @@ setuptools>=45 setuptools_scm # For sphinx -sphinx>=4.0.0 +sphinx!=5.2.0.post0 sphinx-autoapi sphinx-rtd-theme sphinxcontrib-svg2pdfconverter From 645cb6c2a591c49b9473b6fd182e5acd51b11a68 Mon Sep 17 00:00:00 2001 From: Jeff Epler Date: Sun, 25 Sep 2022 12:22:50 -0500 Subject: [PATCH 21/27] pin python version for doc building --- .github/workflows/build.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.github/workflows/build.yml b/.github/workflows/build.yml index 84224a1c1a..02985212f3 100644 --- a/.github/workflows/build.yml +++ b/.github/workflows/build.yml @@ -220,7 +220,7 @@ jobs: - name: Set up Python 3 uses: actions/setup-python@v2 with: - python-version: "3.x" + python-version: "3.10.6" - name: Install dependencies run: | sudo apt-get update From 77c1c695b03217418ba56ad1ad246b2841370bad Mon Sep 17 00:00:00 2001 From: Hosted Weblate Date: Sun, 25 Sep 2022 23:56:04 +0200 Subject: [PATCH 22/27] Update translation files Updated by "Update PO files to match POT (msgmerge)" hook in Weblate. Translation: CircuitPython/main Translate-URL: https://hosted.weblate.org/projects/circuitpython/main/ --- locale/ID.po | 27 ++++--------------------- locale/cs.po | 24 +--------------------- locale/de_DE.po | 39 +++++++++++++++--------------------- locale/el.po | 24 +--------------------- locale/en_GB.po | 39 +++++++++++++++--------------------- locale/es.po | 39 +++++++++++++++--------------------- locale/fil.po | 43 +++++++++++++++++----------------------- locale/fr.po | 39 +++++++++++++++--------------------- locale/hi.po | 24 +--------------------- locale/it_IT.po | 43 +++++++++++++++++----------------------- locale/ja.po | 33 ++++++++++-------------------- locale/ko.po | 24 +--------------------- locale/nl.po | 39 +++++++++++++++--------------------- locale/pl.po | 39 +++++++++++++++--------------------- locale/pt_BR.po | 39 +++++++++++++++--------------------- locale/ru.po | 24 +--------------------- locale/sv.po | 39 +++++++++++++++--------------------- locale/tr.po | 24 +--------------------- locale/zh_Latn_pinyin.po | 39 +++++++++++++++--------------------- 19 files changed, 200 insertions(+), 441 deletions(-) diff --git a/locale/ID.po b/locale/ID.po index d7044bf74e..5c7b21a0eb 100644 --- a/locale/ID.po +++ b/locale/ID.po @@ -2557,8 +2557,7 @@ msgstr "tidak dapat menetapkan ke ekspresi" msgid "can't cancel self" msgstr "" -#: py/obj.c py/objint.c shared-bindings/i2ctarget/I2CTarget.c -#: shared-module/adafruit_pixelbuf/PixelBuf.c +#: py/obj.c py/objint.c shared-module/adafruit_pixelbuf/PixelBuf.c msgid "can't convert %q to %q" msgstr "" @@ -2745,10 +2744,6 @@ msgstr "" msgid "color must be between 0x000000 and 0xffffff" msgstr "" -#: shared-bindings/displayio/ColorConverter.c -msgid "color should be an int" -msgstr "" - #: py/emitnative.c msgid "comparison of int and uint" msgstr "" @@ -2900,10 +2895,6 @@ msgstr "" msgid "end of format while looking for conversion specifier" msgstr "" -#: shared-bindings/displayio/Shape.c -msgid "end_x should be an int" -msgstr "" - #: shared-bindings/alarm/time/TimeAlarm.c msgid "epoch_time not supported on this board" msgstr "" @@ -3771,10 +3762,6 @@ msgstr "" msgid "palette must be 32 bytes long" msgstr "" -#: shared-bindings/displayio/Palette.c -msgid "palette_index should be an int" -msgstr "" - #: py/emitinlinextensa.c msgid "parameters must be registers in sequence a2 to a5" msgstr "" @@ -4012,10 +3999,6 @@ msgstr "" msgid "start/end indices" msgstr "" -#: shared-bindings/displayio/Shape.c -msgid "start_x should be an int" -msgstr "" - #: shared-bindings/random/__init__.c msgid "step must be non-zero" msgstr "" @@ -4230,7 +4213,6 @@ msgid "unreadable attribute" msgstr "" #: shared-bindings/displayio/TileGrid.c shared-bindings/vectorio/VectorShape.c -#: shared-module/vectorio/Polygon.c shared-module/vectorio/VectorShape.c msgid "unsupported %q type" msgstr "" @@ -4360,10 +4342,6 @@ msgstr "nilai x di luar batas" msgid "xTaskCreate failed" msgstr "xTaskCreate gagal" -#: shared-bindings/displayio/Shape.c -msgid "y should be an int" -msgstr "y harus menjadi int" - #: shared-module/displayio/Shape.c msgid "y value out of bounds" msgstr "Nilai y di luar batas" @@ -4384,6 +4362,9 @@ msgstr "zi harus berjenis float" msgid "zi must be of shape (n_section, 2)" msgstr "Zi harus berbentuk (n_section, 2)" +#~ msgid "y should be an int" +#~ msgstr "y harus menjadi int" + #~ msgid "%q must be a tuple of length 2" #~ msgstr "%q harus berupa tuple dengan panjang 2" diff --git a/locale/cs.po b/locale/cs.po index 27f426e658..ae9a8ed7b2 100644 --- a/locale/cs.po +++ b/locale/cs.po @@ -2544,8 +2544,7 @@ msgstr "" msgid "can't cancel self" msgstr "" -#: py/obj.c py/objint.c shared-bindings/i2ctarget/I2CTarget.c -#: shared-module/adafruit_pixelbuf/PixelBuf.c +#: py/obj.c py/objint.c shared-module/adafruit_pixelbuf/PixelBuf.c msgid "can't convert %q to %q" msgstr "" @@ -2732,10 +2731,6 @@ msgstr "" msgid "color must be between 0x000000 and 0xffffff" msgstr "" -#: shared-bindings/displayio/ColorConverter.c -msgid "color should be an int" -msgstr "" - #: py/emitnative.c msgid "comparison of int and uint" msgstr "" @@ -2887,10 +2882,6 @@ msgstr "" msgid "end of format while looking for conversion specifier" msgstr "" -#: shared-bindings/displayio/Shape.c -msgid "end_x should be an int" -msgstr "" - #: shared-bindings/alarm/time/TimeAlarm.c msgid "epoch_time not supported on this board" msgstr "" @@ -3757,10 +3748,6 @@ msgstr "" msgid "palette must be 32 bytes long" msgstr "" -#: shared-bindings/displayio/Palette.c -msgid "palette_index should be an int" -msgstr "" - #: py/emitinlinextensa.c msgid "parameters must be registers in sequence a2 to a5" msgstr "" @@ -3998,10 +3985,6 @@ msgstr "" msgid "start/end indices" msgstr "" -#: shared-bindings/displayio/Shape.c -msgid "start_x should be an int" -msgstr "" - #: shared-bindings/random/__init__.c msgid "step must be non-zero" msgstr "" @@ -4216,7 +4199,6 @@ msgid "unreadable attribute" msgstr "" #: shared-bindings/displayio/TileGrid.c shared-bindings/vectorio/VectorShape.c -#: shared-module/vectorio/Polygon.c shared-module/vectorio/VectorShape.c msgid "unsupported %q type" msgstr "" @@ -4346,10 +4328,6 @@ msgstr "" msgid "xTaskCreate failed" msgstr "" -#: shared-bindings/displayio/Shape.c -msgid "y should be an int" -msgstr "" - #: shared-module/displayio/Shape.c msgid "y value out of bounds" msgstr "" diff --git a/locale/de_DE.po b/locale/de_DE.po index 4e109a41cf..e173ee6c3c 100644 --- a/locale/de_DE.po +++ b/locale/de_DE.po @@ -2599,8 +2599,7 @@ msgstr "kann keinem Ausdruck zuweisen" msgid "can't cancel self" msgstr "kann self nicht abbrechen" -#: py/obj.c py/objint.c shared-bindings/i2ctarget/I2CTarget.c -#: shared-module/adafruit_pixelbuf/PixelBuf.c +#: py/obj.c py/objint.c shared-module/adafruit_pixelbuf/PixelBuf.c msgid "can't convert %q to %q" msgstr "kann %q nicht zu %q konvertieren" @@ -2795,10 +2794,6 @@ msgstr "" msgid "color must be between 0x000000 and 0xffffff" msgstr "Farbe muss zwischen 0x000000 und 0xffffff liegen" -#: shared-bindings/displayio/ColorConverter.c -msgid "color should be an int" -msgstr "Farbe sollte ein int sein" - #: py/emitnative.c msgid "comparison of int and uint" msgstr "Vergleich von int und uint" @@ -2952,10 +2947,6 @@ msgstr "leere Sequenz" msgid "end of format while looking for conversion specifier" msgstr "Ende des Formats wärend der Suche nach einem conversion specifier" -#: shared-bindings/displayio/Shape.c -msgid "end_x should be an int" -msgstr "end_x sollte ein int sein" - #: shared-bindings/alarm/time/TimeAlarm.c msgid "epoch_time not supported on this board" msgstr "epoch_time wird auf diesem Board nicht unterstützt" @@ -3835,10 +3826,6 @@ msgstr "pack erwartete %d Artikel zum Packen (erhalten %d)" msgid "palette must be 32 bytes long" msgstr "Die Palette muss 32 Byte lang sein" -#: shared-bindings/displayio/Palette.c -msgid "palette_index should be an int" -msgstr "palette_index sollte ein int sein" - #: py/emitinlinextensa.c msgid "parameters must be registers in sequence a2 to a5" msgstr "Die Parameter müssen Register der Reihenfolge a2 bis a5 sein" @@ -4076,10 +4063,6 @@ msgstr "source_bitmap muss value_count von 8 haben" msgid "start/end indices" msgstr "start/end Indizes" -#: shared-bindings/displayio/Shape.c -msgid "start_x should be an int" -msgstr "start_x sollte ein int sein" - #: shared-bindings/random/__init__.c msgid "step must be non-zero" msgstr "Schritt (step) darf nicht Null sein" @@ -4297,7 +4280,6 @@ msgid "unreadable attribute" msgstr "nicht lesbares Attribut" #: shared-bindings/displayio/TileGrid.c shared-bindings/vectorio/VectorShape.c -#: shared-module/vectorio/Polygon.c shared-module/vectorio/VectorShape.c msgid "unsupported %q type" msgstr "Nicht unterstützter %q-Typ" @@ -4427,10 +4409,6 @@ msgstr "x Wert außerhalb der Grenzen" msgid "xTaskCreate failed" msgstr "xTaskCreate fehlgeschlagen" -#: shared-bindings/displayio/Shape.c -msgid "y should be an int" -msgstr "y sollte ein int sein" - #: shared-module/displayio/Shape.c msgid "y value out of bounds" msgstr "y Wert außerhalb der Grenzen" @@ -4451,6 +4429,21 @@ msgstr "zi muss eine Gleitkommazahl sein" msgid "zi must be of shape (n_section, 2)" msgstr "zi muss die Form (n_section, 2) haben" +#~ msgid "color should be an int" +#~ msgstr "Farbe sollte ein int sein" + +#~ msgid "end_x should be an int" +#~ msgstr "end_x sollte ein int sein" + +#~ msgid "palette_index should be an int" +#~ msgstr "palette_index sollte ein int sein" + +#~ msgid "start_x should be an int" +#~ msgstr "start_x sollte ein int sein" + +#~ msgid "y should be an int" +#~ msgstr "y sollte ein int sein" + #~ msgid "" #~ "sample_source buffer must be a bytearray or array of type 'h', 'H', 'b' " #~ "or 'B'" diff --git a/locale/el.po b/locale/el.po index 8205801d3a..f996a90a23 100644 --- a/locale/el.po +++ b/locale/el.po @@ -2534,8 +2534,7 @@ msgstr "" msgid "can't cancel self" msgstr "" -#: py/obj.c py/objint.c shared-bindings/i2ctarget/I2CTarget.c -#: shared-module/adafruit_pixelbuf/PixelBuf.c +#: py/obj.c py/objint.c shared-module/adafruit_pixelbuf/PixelBuf.c msgid "can't convert %q to %q" msgstr "" @@ -2722,10 +2721,6 @@ msgstr "" msgid "color must be between 0x000000 and 0xffffff" msgstr "" -#: shared-bindings/displayio/ColorConverter.c -msgid "color should be an int" -msgstr "" - #: py/emitnative.c msgid "comparison of int and uint" msgstr "" @@ -2877,10 +2872,6 @@ msgstr "" msgid "end of format while looking for conversion specifier" msgstr "" -#: shared-bindings/displayio/Shape.c -msgid "end_x should be an int" -msgstr "" - #: shared-bindings/alarm/time/TimeAlarm.c msgid "epoch_time not supported on this board" msgstr "" @@ -3747,10 +3738,6 @@ msgstr "" msgid "palette must be 32 bytes long" msgstr "" -#: shared-bindings/displayio/Palette.c -msgid "palette_index should be an int" -msgstr "" - #: py/emitinlinextensa.c msgid "parameters must be registers in sequence a2 to a5" msgstr "" @@ -3988,10 +3975,6 @@ msgstr "" msgid "start/end indices" msgstr "" -#: shared-bindings/displayio/Shape.c -msgid "start_x should be an int" -msgstr "" - #: shared-bindings/random/__init__.c msgid "step must be non-zero" msgstr "" @@ -4206,7 +4189,6 @@ msgid "unreadable attribute" msgstr "" #: shared-bindings/displayio/TileGrid.c shared-bindings/vectorio/VectorShape.c -#: shared-module/vectorio/Polygon.c shared-module/vectorio/VectorShape.c msgid "unsupported %q type" msgstr "" @@ -4336,10 +4318,6 @@ msgstr "" msgid "xTaskCreate failed" msgstr "" -#: shared-bindings/displayio/Shape.c -msgid "y should be an int" -msgstr "" - #: shared-module/displayio/Shape.c msgid "y value out of bounds" msgstr "" diff --git a/locale/en_GB.po b/locale/en_GB.po index 92b83cd7aa..b525de6ff6 100644 --- a/locale/en_GB.po +++ b/locale/en_GB.po @@ -2560,8 +2560,7 @@ msgstr "Can't assign to expression" msgid "can't cancel self" msgstr "can't cancel self" -#: py/obj.c py/objint.c shared-bindings/i2ctarget/I2CTarget.c -#: shared-module/adafruit_pixelbuf/PixelBuf.c +#: py/obj.c py/objint.c shared-module/adafruit_pixelbuf/PixelBuf.c msgid "can't convert %q to %q" msgstr "Can't convert %q to %q" @@ -2750,10 +2749,6 @@ msgstr "colour buffer must be a bytearray or array of type 'b' or 'B'" msgid "color must be between 0x000000 and 0xffffff" msgstr "colour must be between 0x000000 and 0xffffff" -#: shared-bindings/displayio/ColorConverter.c -msgid "color should be an int" -msgstr "colour should be an int" - #: py/emitnative.c msgid "comparison of int and uint" msgstr "comparison of int and uint" @@ -2906,10 +2901,6 @@ msgstr "empty sequence" msgid "end of format while looking for conversion specifier" msgstr "end of format while looking for conversion specifier" -#: shared-bindings/displayio/Shape.c -msgid "end_x should be an int" -msgstr "end_x should be an int" - #: shared-bindings/alarm/time/TimeAlarm.c msgid "epoch_time not supported on this board" msgstr "epoch_time not supported on this board" @@ -3776,10 +3767,6 @@ msgstr "pack expected %d items for packing (got %d)" msgid "palette must be 32 bytes long" msgstr "palette must be 32 bytes long" -#: shared-bindings/displayio/Palette.c -msgid "palette_index should be an int" -msgstr "palette_index should be an int" - #: py/emitinlinextensa.c msgid "parameters must be registers in sequence a2 to a5" msgstr "parameters must be registers in sequence a2 to a5" @@ -4017,10 +4004,6 @@ msgstr "" msgid "start/end indices" msgstr "start/end indices" -#: shared-bindings/displayio/Shape.c -msgid "start_x should be an int" -msgstr "start_x should be an int" - #: shared-bindings/random/__init__.c msgid "step must be non-zero" msgstr "step must be non-zero" @@ -4235,7 +4218,6 @@ msgid "unreadable attribute" msgstr "unreadable attribute" #: shared-bindings/displayio/TileGrid.c shared-bindings/vectorio/VectorShape.c -#: shared-module/vectorio/Polygon.c shared-module/vectorio/VectorShape.c msgid "unsupported %q type" msgstr "unsupported %q type" @@ -4365,10 +4347,6 @@ msgstr "x value out of bounds" msgid "xTaskCreate failed" msgstr "xTaskCreate failed" -#: shared-bindings/displayio/Shape.c -msgid "y should be an int" -msgstr "y should be an int" - #: shared-module/displayio/Shape.c msgid "y value out of bounds" msgstr "y value out of bounds" @@ -4389,6 +4367,21 @@ msgstr "zi must be of float type" msgid "zi must be of shape (n_section, 2)" msgstr "zi must be of shape (n_section, 2)" +#~ msgid "color should be an int" +#~ msgstr "colour should be an int" + +#~ msgid "end_x should be an int" +#~ msgstr "end_x should be an int" + +#~ msgid "palette_index should be an int" +#~ msgstr "palette_index should be an int" + +#~ msgid "start_x should be an int" +#~ msgstr "start_x should be an int" + +#~ msgid "y should be an int" +#~ msgstr "y should be an int" + #~ msgid "" #~ "sample_source buffer must be a bytearray or array of type 'h', 'H', 'b' " #~ "or 'B'" diff --git a/locale/es.po b/locale/es.po index 0d981d2d7c..42ea8aecb9 100644 --- a/locale/es.po +++ b/locale/es.po @@ -2596,8 +2596,7 @@ msgstr "no se puede asignar a la expresión" msgid "can't cancel self" msgstr "no se puede cancelar a si mismo" -#: py/obj.c py/objint.c shared-bindings/i2ctarget/I2CTarget.c -#: shared-module/adafruit_pixelbuf/PixelBuf.c +#: py/obj.c py/objint.c shared-module/adafruit_pixelbuf/PixelBuf.c msgid "can't convert %q to %q" msgstr "no puede convertir %q a %q" @@ -2789,10 +2788,6 @@ msgstr "color buffer deberia ser un bytearray o array de tipo 'b' o 'B'" msgid "color must be between 0x000000 and 0xffffff" msgstr "color debe estar entre 0x000000 y 0xffffff" -#: shared-bindings/displayio/ColorConverter.c -msgid "color should be an int" -msgstr "color deberia ser un int" - #: py/emitnative.c msgid "comparison of int and uint" msgstr "comparación entre int y uint" @@ -2946,10 +2941,6 @@ msgstr "secuencia vacía" msgid "end of format while looking for conversion specifier" msgstr "el final del formato mientras se busca el especificador de conversión" -#: shared-bindings/displayio/Shape.c -msgid "end_x should be an int" -msgstr "end_x debe ser un int" - #: shared-bindings/alarm/time/TimeAlarm.c msgid "epoch_time not supported on this board" msgstr "epoch_time no esta soportado en esta tarjeta" @@ -3823,10 +3814,6 @@ msgstr "pack espera %d items para empaquetado (se recibió %d)" msgid "palette must be 32 bytes long" msgstr "palette debe ser 32 bytes de largo" -#: shared-bindings/displayio/Palette.c -msgid "palette_index should be an int" -msgstr "palette_index deberia ser un int" - #: py/emitinlinextensa.c msgid "parameters must be registers in sequence a2 to a5" msgstr "los parámetros deben ser registros en secuencia de a2 a a5" @@ -4064,10 +4051,6 @@ msgstr "" msgid "start/end indices" msgstr "índices inicio/final" -#: shared-bindings/displayio/Shape.c -msgid "start_x should be an int" -msgstr "start_x deberia ser un int" - #: shared-bindings/random/__init__.c msgid "step must be non-zero" msgstr "paso debe ser numero no cero" @@ -4283,7 +4266,6 @@ msgid "unreadable attribute" msgstr "atributo no legible" #: shared-bindings/displayio/TileGrid.c shared-bindings/vectorio/VectorShape.c -#: shared-module/vectorio/Polygon.c shared-module/vectorio/VectorShape.c msgid "unsupported %q type" msgstr "tipo de %q no soportado" @@ -4413,10 +4395,6 @@ msgstr "valor x fuera de límites" msgid "xTaskCreate failed" msgstr "fallo en xTaskCreate" -#: shared-bindings/displayio/Shape.c -msgid "y should be an int" -msgstr "y deberia ser un int" - #: shared-module/displayio/Shape.c msgid "y value out of bounds" msgstr "valor y fuera de límites" @@ -4437,6 +4415,21 @@ msgstr "zi debe ser de tipo flotante" msgid "zi must be of shape (n_section, 2)" msgstr "zi debe ser una forma (n_section,2)" +#~ msgid "color should be an int" +#~ msgstr "color deberia ser un int" + +#~ msgid "end_x should be an int" +#~ msgstr "end_x debe ser un int" + +#~ msgid "palette_index should be an int" +#~ msgstr "palette_index deberia ser un int" + +#~ msgid "start_x should be an int" +#~ msgstr "start_x deberia ser un int" + +#~ msgid "y should be an int" +#~ msgstr "y deberia ser un int" + #~ msgid "" #~ "sample_source buffer must be a bytearray or array of type 'h', 'H', 'b' " #~ "or 'B'" diff --git a/locale/fil.po b/locale/fil.po index 63f5990a0a..11fdd354d9 100644 --- a/locale/fil.po +++ b/locale/fil.po @@ -2548,8 +2548,7 @@ msgstr "hindi ma i-assign sa expression" msgid "can't cancel self" msgstr "" -#: py/obj.c py/objint.c shared-bindings/i2ctarget/I2CTarget.c -#: shared-module/adafruit_pixelbuf/PixelBuf.c +#: py/obj.c py/objint.c shared-module/adafruit_pixelbuf/PixelBuf.c msgid "can't convert %q to %q" msgstr "" @@ -2741,10 +2740,6 @@ msgstr "ang color buffer ay dapat bytearray o array na type ‘b’ or ‘B’" msgid "color must be between 0x000000 and 0xffffff" msgstr "color ay dapat mula sa 0x000000 hangang 0xffffff" -#: shared-bindings/displayio/ColorConverter.c -msgid "color should be an int" -msgstr "color ay dapat na int" - #: py/emitnative.c msgid "comparison of int and uint" msgstr "" @@ -2900,11 +2895,6 @@ msgstr "walang laman ang sequence" msgid "end of format while looking for conversion specifier" msgstr "sa huli ng format habang naghahanap sa conversion specifier" -#: shared-bindings/displayio/Shape.c -#, fuzzy -msgid "end_x should be an int" -msgstr "y ay dapat int" - #: shared-bindings/alarm/time/TimeAlarm.c msgid "epoch_time not supported on this board" msgstr "" @@ -3777,10 +3767,6 @@ msgstr "" msgid "palette must be 32 bytes long" msgstr "ang palette ay dapat 32 bytes ang haba" -#: shared-bindings/displayio/Palette.c -msgid "palette_index should be an int" -msgstr "palette_index ay dapat na int" - #: py/emitinlinextensa.c msgid "parameters must be registers in sequence a2 to a5" msgstr "ang mga parameter ay dapat na nagrerehistro sa sequence a2 hanggang a5" @@ -4019,11 +4005,6 @@ msgstr "" msgid "start/end indices" msgstr "start/end indeks" -#: shared-bindings/displayio/Shape.c -#, fuzzy -msgid "start_x should be an int" -msgstr "y ay dapat int" - #: shared-bindings/random/__init__.c msgid "step must be non-zero" msgstr "step ay dapat hindi zero" @@ -4238,7 +4219,6 @@ msgid "unreadable attribute" msgstr "hindi mabasa ang attribute" #: shared-bindings/displayio/TileGrid.c shared-bindings/vectorio/VectorShape.c -#: shared-module/vectorio/Polygon.c shared-module/vectorio/VectorShape.c msgid "unsupported %q type" msgstr "Hindi supportadong tipo ng %q" @@ -4369,10 +4349,6 @@ msgstr "wala sa sakop ang address" msgid "xTaskCreate failed" msgstr "" -#: shared-bindings/displayio/Shape.c -msgid "y should be an int" -msgstr "y ay dapat int" - #: shared-module/displayio/Shape.c #, fuzzy msgid "y value out of bounds" @@ -4394,6 +4370,23 @@ msgstr "" msgid "zi must be of shape (n_section, 2)" msgstr "" +#~ msgid "color should be an int" +#~ msgstr "color ay dapat na int" + +#, fuzzy +#~ msgid "end_x should be an int" +#~ msgstr "y ay dapat int" + +#~ msgid "palette_index should be an int" +#~ msgstr "palette_index ay dapat na int" + +#, fuzzy +#~ msgid "start_x should be an int" +#~ msgstr "y ay dapat int" + +#~ msgid "y should be an int" +#~ msgstr "y ay dapat int" + #~ msgid "" #~ "sample_source buffer must be a bytearray or array of type 'h', 'H', 'b' " #~ "or 'B'" diff --git a/locale/fr.po b/locale/fr.po index 9c7ce445ae..b3205f0ac5 100644 --- a/locale/fr.po +++ b/locale/fr.po @@ -2628,8 +2628,7 @@ msgstr "ne peut pas assigner à une expression" msgid "can't cancel self" msgstr "ne peut pas s'annuler soi-même" -#: py/obj.c py/objint.c shared-bindings/i2ctarget/I2CTarget.c -#: shared-module/adafruit_pixelbuf/PixelBuf.c +#: py/obj.c py/objint.c shared-module/adafruit_pixelbuf/PixelBuf.c msgid "can't convert %q to %q" msgstr "impossible de convertir %q en %q" @@ -2825,10 +2824,6 @@ msgstr "" msgid "color must be between 0x000000 and 0xffffff" msgstr "la couleur doit être entre 0x000000 et 0xffffff" -#: shared-bindings/displayio/ColorConverter.c -msgid "color should be an int" -msgstr "la couleur doit être un entier 'int'" - #: py/emitnative.c msgid "comparison of int and uint" msgstr "comparaison entre int et uint" @@ -2983,10 +2978,6 @@ msgstr "séquence vide" msgid "end of format while looking for conversion specifier" msgstr "fin de format en cherchant une spécification de conversion" -#: shared-bindings/displayio/Shape.c -msgid "end_x should be an int" -msgstr "end_x doit être un entier 'int'" - #: shared-bindings/alarm/time/TimeAlarm.c msgid "epoch_time not supported on this board" msgstr "epoch_time n'est pas supporté sur ce panneau" @@ -3864,10 +3855,6 @@ msgstr "pack attend %d element(s) (%d reçu)" msgid "palette must be 32 bytes long" msgstr "la palette doit être longue de 32 octets" -#: shared-bindings/displayio/Palette.c -msgid "palette_index should be an int" -msgstr "palette_index devrait être un entier 'int'" - #: py/emitinlinextensa.c msgid "parameters must be registers in sequence a2 to a5" msgstr "les paramètres doivent être des registres dans la séquence a2 à a5" @@ -4106,10 +4093,6 @@ msgstr "source_bitmap doit avoir une value_count de 8" msgid "start/end indices" msgstr "indices de début/fin" -#: shared-bindings/displayio/Shape.c -msgid "start_x should be an int" -msgstr "'start_x' doit être un entier 'int'" - #: shared-bindings/random/__init__.c msgid "step must be non-zero" msgstr "le pas 'step' doit être non nul" @@ -4325,7 +4308,6 @@ msgid "unreadable attribute" msgstr "attribut illisible" #: shared-bindings/displayio/TileGrid.c shared-bindings/vectorio/VectorShape.c -#: shared-module/vectorio/Polygon.c shared-module/vectorio/VectorShape.c msgid "unsupported %q type" msgstr "type %q non pris on charge" @@ -4455,10 +4437,6 @@ msgstr "valeur x hors limites" msgid "xTaskCreate failed" msgstr "Échec de xTaskCreate" -#: shared-bindings/displayio/Shape.c -msgid "y should be an int" -msgstr "'y' doit être un entier 'int'" - #: shared-module/displayio/Shape.c msgid "y value out of bounds" msgstr "valeur y hors limites" @@ -4479,6 +4457,21 @@ msgstr "zi doit être de type float" msgid "zi must be of shape (n_section, 2)" msgstr "zi doit être de forme (n_section, 2)" +#~ msgid "color should be an int" +#~ msgstr "la couleur doit être un entier 'int'" + +#~ msgid "end_x should be an int" +#~ msgstr "end_x doit être un entier 'int'" + +#~ msgid "palette_index should be an int" +#~ msgstr "palette_index devrait être un entier 'int'" + +#~ msgid "start_x should be an int" +#~ msgstr "'start_x' doit être un entier 'int'" + +#~ msgid "y should be an int" +#~ msgstr "'y' doit être un entier 'int'" + #~ msgid "" #~ "sample_source buffer must be a bytearray or array of type 'h', 'H', 'b' " #~ "or 'B'" diff --git a/locale/hi.po b/locale/hi.po index 65d430d860..c96d057c7b 100644 --- a/locale/hi.po +++ b/locale/hi.po @@ -2526,8 +2526,7 @@ msgstr "" msgid "can't cancel self" msgstr "" -#: py/obj.c py/objint.c shared-bindings/i2ctarget/I2CTarget.c -#: shared-module/adafruit_pixelbuf/PixelBuf.c +#: py/obj.c py/objint.c shared-module/adafruit_pixelbuf/PixelBuf.c msgid "can't convert %q to %q" msgstr "" @@ -2714,10 +2713,6 @@ msgstr "" msgid "color must be between 0x000000 and 0xffffff" msgstr "" -#: shared-bindings/displayio/ColorConverter.c -msgid "color should be an int" -msgstr "" - #: py/emitnative.c msgid "comparison of int and uint" msgstr "" @@ -2869,10 +2864,6 @@ msgstr "" msgid "end of format while looking for conversion specifier" msgstr "" -#: shared-bindings/displayio/Shape.c -msgid "end_x should be an int" -msgstr "" - #: shared-bindings/alarm/time/TimeAlarm.c msgid "epoch_time not supported on this board" msgstr "" @@ -3739,10 +3730,6 @@ msgstr "" msgid "palette must be 32 bytes long" msgstr "" -#: shared-bindings/displayio/Palette.c -msgid "palette_index should be an int" -msgstr "" - #: py/emitinlinextensa.c msgid "parameters must be registers in sequence a2 to a5" msgstr "" @@ -3980,10 +3967,6 @@ msgstr "" msgid "start/end indices" msgstr "" -#: shared-bindings/displayio/Shape.c -msgid "start_x should be an int" -msgstr "" - #: shared-bindings/random/__init__.c msgid "step must be non-zero" msgstr "" @@ -4198,7 +4181,6 @@ msgid "unreadable attribute" msgstr "" #: shared-bindings/displayio/TileGrid.c shared-bindings/vectorio/VectorShape.c -#: shared-module/vectorio/Polygon.c shared-module/vectorio/VectorShape.c msgid "unsupported %q type" msgstr "" @@ -4328,10 +4310,6 @@ msgstr "" msgid "xTaskCreate failed" msgstr "" -#: shared-bindings/displayio/Shape.c -msgid "y should be an int" -msgstr "" - #: shared-module/displayio/Shape.c msgid "y value out of bounds" msgstr "" diff --git a/locale/it_IT.po b/locale/it_IT.po index c2f0018256..c2be65716b 100644 --- a/locale/it_IT.po +++ b/locale/it_IT.po @@ -2560,8 +2560,7 @@ msgstr "impossibile assegnare all'espressione" msgid "can't cancel self" msgstr "" -#: py/obj.c py/objint.c shared-bindings/i2ctarget/I2CTarget.c -#: shared-module/adafruit_pixelbuf/PixelBuf.c +#: py/obj.c py/objint.c shared-module/adafruit_pixelbuf/PixelBuf.c msgid "can't convert %q to %q" msgstr "" @@ -2750,10 +2749,6 @@ msgstr "" msgid "color must be between 0x000000 and 0xffffff" msgstr "il colore deve essere compreso tra 0x000000 e 0xffffff" -#: shared-bindings/displayio/ColorConverter.c -msgid "color should be an int" -msgstr "il colore deve essere un int" - #: py/emitnative.c msgid "comparison of int and uint" msgstr "" @@ -2908,11 +2903,6 @@ msgstr "sequenza vuota" msgid "end of format while looking for conversion specifier" msgstr "" -#: shared-bindings/displayio/Shape.c -#, fuzzy -msgid "end_x should be an int" -msgstr "y dovrebbe essere un int" - #: shared-bindings/alarm/time/TimeAlarm.c msgid "epoch_time not supported on this board" msgstr "" @@ -3789,10 +3779,6 @@ msgstr "" msgid "palette must be 32 bytes long" msgstr "la palette deve essere lunga 32 byte" -#: shared-bindings/displayio/Palette.c -msgid "palette_index should be an int" -msgstr "palette_index deve essere un int" - #: py/emitinlinextensa.c msgid "parameters must be registers in sequence a2 to a5" msgstr "parametri devono essere i registri in sequenza da a2 a a5" @@ -4032,11 +4018,6 @@ msgstr "" msgid "start/end indices" msgstr "" -#: shared-bindings/displayio/Shape.c -#, fuzzy -msgid "start_x should be an int" -msgstr "y dovrebbe essere un int" - #: shared-bindings/random/__init__.c msgid "step must be non-zero" msgstr "step deve essere non zero" @@ -4251,7 +4232,6 @@ msgid "unreadable attribute" msgstr "attributo non leggibile" #: shared-bindings/displayio/TileGrid.c shared-bindings/vectorio/VectorShape.c -#: shared-module/vectorio/Polygon.c shared-module/vectorio/VectorShape.c msgid "unsupported %q type" msgstr "tipo di %q non supportato" @@ -4382,10 +4362,6 @@ msgstr "indirizzo fuori limite" msgid "xTaskCreate failed" msgstr "" -#: shared-bindings/displayio/Shape.c -msgid "y should be an int" -msgstr "y dovrebbe essere un int" - #: shared-module/displayio/Shape.c #, fuzzy msgid "y value out of bounds" @@ -4407,6 +4383,23 @@ msgstr "" msgid "zi must be of shape (n_section, 2)" msgstr "" +#~ msgid "color should be an int" +#~ msgstr "il colore deve essere un int" + +#, fuzzy +#~ msgid "end_x should be an int" +#~ msgstr "y dovrebbe essere un int" + +#~ msgid "palette_index should be an int" +#~ msgstr "palette_index deve essere un int" + +#, fuzzy +#~ msgid "start_x should be an int" +#~ msgstr "y dovrebbe essere un int" + +#~ msgid "y should be an int" +#~ msgstr "y dovrebbe essere un int" + #~ msgid "" #~ "sample_source buffer must be a bytearray or array of type 'h', 'H', 'b' " #~ "or 'B'" diff --git a/locale/ja.po b/locale/ja.po index 495c7ca978..d7ec845e23 100644 --- a/locale/ja.po +++ b/locale/ja.po @@ -2540,8 +2540,7 @@ msgstr "式には代入できません" msgid "can't cancel self" msgstr "" -#: py/obj.c py/objint.c shared-bindings/i2ctarget/I2CTarget.c -#: shared-module/adafruit_pixelbuf/PixelBuf.c +#: py/obj.c py/objint.c shared-module/adafruit_pixelbuf/PixelBuf.c msgid "can't convert %q to %q" msgstr "%qを%qに変換できません" @@ -2730,10 +2729,6 @@ msgstr "" msgid "color must be between 0x000000 and 0xffffff" msgstr "色は0x000000から0xffffffでなければなりません" -#: shared-bindings/displayio/ColorConverter.c -msgid "color should be an int" -msgstr "" - #: py/emitnative.c msgid "comparison of int and uint" msgstr "" @@ -2887,10 +2882,6 @@ msgstr "" msgid "end of format while looking for conversion specifier" msgstr "" -#: shared-bindings/displayio/Shape.c -msgid "end_x should be an int" -msgstr "end_xは整数でなければなりません" - #: shared-bindings/alarm/time/TimeAlarm.c msgid "epoch_time not supported on this board" msgstr "" @@ -3758,10 +3749,6 @@ msgstr "" msgid "palette must be 32 bytes long" msgstr "パレットの長さは32バイトでなければなりません" -#: shared-bindings/displayio/Palette.c -msgid "palette_index should be an int" -msgstr "palette_indexには整数が必要" - #: py/emitinlinextensa.c msgid "parameters must be registers in sequence a2 to a5" msgstr "" @@ -4001,10 +3988,6 @@ msgstr "" msgid "start/end indices" msgstr "" -#: shared-bindings/displayio/Shape.c -msgid "start_x should be an int" -msgstr "" - #: shared-bindings/random/__init__.c msgid "step must be non-zero" msgstr "stepは非ゼロ値でなければなりません" @@ -4219,7 +4202,6 @@ msgid "unreadable attribute" msgstr "読み込み不可能な属性" #: shared-bindings/displayio/TileGrid.c shared-bindings/vectorio/VectorShape.c -#: shared-module/vectorio/Polygon.c shared-module/vectorio/VectorShape.c msgid "unsupported %q type" msgstr "非対応の型 %q" @@ -4349,10 +4331,6 @@ msgstr "xが範囲外" msgid "xTaskCreate failed" msgstr "" -#: shared-bindings/displayio/Shape.c -msgid "y should be an int" -msgstr "yは整数でなければなりません" - #: shared-module/displayio/Shape.c msgid "y value out of bounds" msgstr "yが範囲外" @@ -4373,6 +4351,15 @@ msgstr "ziはfloat値でなければなりません" msgid "zi must be of shape (n_section, 2)" msgstr "" +#~ msgid "end_x should be an int" +#~ msgstr "end_xは整数でなければなりません" + +#~ msgid "palette_index should be an int" +#~ msgstr "palette_indexには整数が必要" + +#~ msgid "y should be an int" +#~ msgstr "yは整数でなければなりません" + #~ msgid "" #~ "sample_source buffer must be a bytearray or array of type 'h', 'H', 'b' " #~ "or 'B'" diff --git a/locale/ko.po b/locale/ko.po index aa3d738f01..669ae1a551 100644 --- a/locale/ko.po +++ b/locale/ko.po @@ -2530,8 +2530,7 @@ msgstr "" msgid "can't cancel self" msgstr "" -#: py/obj.c py/objint.c shared-bindings/i2ctarget/I2CTarget.c -#: shared-module/adafruit_pixelbuf/PixelBuf.c +#: py/obj.c py/objint.c shared-module/adafruit_pixelbuf/PixelBuf.c msgid "can't convert %q to %q" msgstr "" @@ -2718,10 +2717,6 @@ msgstr "" msgid "color must be between 0x000000 and 0xffffff" msgstr "" -#: shared-bindings/displayio/ColorConverter.c -msgid "color should be an int" -msgstr "" - #: py/emitnative.c msgid "comparison of int and uint" msgstr "" @@ -2873,10 +2868,6 @@ msgstr "" msgid "end of format while looking for conversion specifier" msgstr "" -#: shared-bindings/displayio/Shape.c -msgid "end_x should be an int" -msgstr "" - #: shared-bindings/alarm/time/TimeAlarm.c msgid "epoch_time not supported on this board" msgstr "" @@ -3743,10 +3734,6 @@ msgstr "" msgid "palette must be 32 bytes long" msgstr "" -#: shared-bindings/displayio/Palette.c -msgid "palette_index should be an int" -msgstr "" - #: py/emitinlinextensa.c msgid "parameters must be registers in sequence a2 to a5" msgstr "" @@ -3984,10 +3971,6 @@ msgstr "" msgid "start/end indices" msgstr "" -#: shared-bindings/displayio/Shape.c -msgid "start_x should be an int" -msgstr "" - #: shared-bindings/random/__init__.c msgid "step must be non-zero" msgstr "" @@ -4202,7 +4185,6 @@ msgid "unreadable attribute" msgstr "" #: shared-bindings/displayio/TileGrid.c shared-bindings/vectorio/VectorShape.c -#: shared-module/vectorio/Polygon.c shared-module/vectorio/VectorShape.c msgid "unsupported %q type" msgstr "" @@ -4332,10 +4314,6 @@ msgstr "" msgid "xTaskCreate failed" msgstr "" -#: shared-bindings/displayio/Shape.c -msgid "y should be an int" -msgstr "" - #: shared-module/displayio/Shape.c msgid "y value out of bounds" msgstr "" diff --git a/locale/nl.po b/locale/nl.po index 76577117fa..e888fc2d66 100644 --- a/locale/nl.po +++ b/locale/nl.po @@ -2557,8 +2557,7 @@ msgstr "kan niet toewijzen aan expressie" msgid "can't cancel self" msgstr "" -#: py/obj.c py/objint.c shared-bindings/i2ctarget/I2CTarget.c -#: shared-module/adafruit_pixelbuf/PixelBuf.c +#: py/obj.c py/objint.c shared-module/adafruit_pixelbuf/PixelBuf.c msgid "can't convert %q to %q" msgstr "kan %q niet naar %q converteren" @@ -2745,10 +2744,6 @@ msgstr "kleurbuffer moet een bytearray of array van type 'b' of 'B' zijn" msgid "color must be between 0x000000 and 0xffffff" msgstr "kleur moet tussen 0x000000 en 0xffffff liggen" -#: shared-bindings/displayio/ColorConverter.c -msgid "color should be an int" -msgstr "kleur moet een int zijn" - #: py/emitnative.c msgid "comparison of int and uint" msgstr "" @@ -2902,10 +2897,6 @@ msgstr "lege sequentie" msgid "end of format while looking for conversion specifier" msgstr "einde van format terwijl zoekend naar conversie-specifier" -#: shared-bindings/displayio/Shape.c -msgid "end_x should be an int" -msgstr "end_x moet een int zijn" - #: shared-bindings/alarm/time/TimeAlarm.c msgid "epoch_time not supported on this board" msgstr "epoch_time niet ondersteund op dit bord" @@ -3776,10 +3767,6 @@ msgstr "pack verwachtte %d elementen (ontving %d)" msgid "palette must be 32 bytes long" msgstr "palette moet 32 bytes lang zijn" -#: shared-bindings/displayio/Palette.c -msgid "palette_index should be an int" -msgstr "palette_index moet een int zijn" - #: py/emitinlinextensa.c msgid "parameters must be registers in sequence a2 to a5" msgstr "parameters moeten registers zijn in de volgorde a2 tot a5" @@ -4017,10 +4004,6 @@ msgstr "" msgid "start/end indices" msgstr "start/stop indices" -#: shared-bindings/displayio/Shape.c -msgid "start_x should be an int" -msgstr "start_x moet een int zijn" - #: shared-bindings/random/__init__.c msgid "step must be non-zero" msgstr "step mag geen nul zijn" @@ -4235,7 +4218,6 @@ msgid "unreadable attribute" msgstr "onleesbaar attribuut" #: shared-bindings/displayio/TileGrid.c shared-bindings/vectorio/VectorShape.c -#: shared-module/vectorio/Polygon.c shared-module/vectorio/VectorShape.c msgid "unsupported %q type" msgstr "niet ondersteund %q type" @@ -4365,10 +4347,6 @@ msgstr "x-waarde buiten bereik" msgid "xTaskCreate failed" msgstr "" -#: shared-bindings/displayio/Shape.c -msgid "y should be an int" -msgstr "y moet een int zijn" - #: shared-module/displayio/Shape.c msgid "y value out of bounds" msgstr "y-waarde buiten bereik" @@ -4389,6 +4367,21 @@ msgstr "zi moet van type float zijn" msgid "zi must be of shape (n_section, 2)" msgstr "zi moet vorm (n_section, 2) hebben" +#~ msgid "color should be an int" +#~ msgstr "kleur moet een int zijn" + +#~ msgid "end_x should be an int" +#~ msgstr "end_x moet een int zijn" + +#~ msgid "palette_index should be an int" +#~ msgstr "palette_index moet een int zijn" + +#~ msgid "start_x should be an int" +#~ msgstr "start_x moet een int zijn" + +#~ msgid "y should be an int" +#~ msgstr "y moet een int zijn" + #~ msgid "" #~ "sample_source buffer must be a bytearray or array of type 'h', 'H', 'b' " #~ "or 'B'" diff --git a/locale/pl.po b/locale/pl.po index bdda99d827..b01fd67829 100644 --- a/locale/pl.po +++ b/locale/pl.po @@ -2537,8 +2537,7 @@ msgstr "przypisanie do wyrażenia" msgid "can't cancel self" msgstr "" -#: py/obj.c py/objint.c shared-bindings/i2ctarget/I2CTarget.c -#: shared-module/adafruit_pixelbuf/PixelBuf.c +#: py/obj.c py/objint.c shared-module/adafruit_pixelbuf/PixelBuf.c msgid "can't convert %q to %q" msgstr "nie można dokonać konwersji %q na %q" @@ -2725,10 +2724,6 @@ msgstr "bufor kolorów musi być bytearray lub tablicą typu 'b' lub 'B'" msgid "color must be between 0x000000 and 0xffffff" msgstr "kolor musi być pomiędzy 0x000000 a 0xffffff" -#: shared-bindings/displayio/ColorConverter.c -msgid "color should be an int" -msgstr "kolor powinien być liczbą całkowitą" - #: py/emitnative.c msgid "comparison of int and uint" msgstr "" @@ -2881,10 +2876,6 @@ msgstr "pusta sekwencja" msgid "end of format while looking for conversion specifier" msgstr "koniec formatu przy szukaniu specyfikacji konwersji" -#: shared-bindings/displayio/Shape.c -msgid "end_x should be an int" -msgstr "end_x powinien być całkowity" - #: shared-bindings/alarm/time/TimeAlarm.c msgid "epoch_time not supported on this board" msgstr "" @@ -3751,10 +3742,6 @@ msgstr "" msgid "palette must be 32 bytes long" msgstr "paleta musi mieć 32 bajty długości" -#: shared-bindings/displayio/Palette.c -msgid "palette_index should be an int" -msgstr "palette_index powinien być całkowity" - #: py/emitinlinextensa.c msgid "parameters must be registers in sequence a2 to a5" msgstr "parametry muszą być rejestrami w kolejności a2 do a5" @@ -3993,10 +3980,6 @@ msgstr "" msgid "start/end indices" msgstr "początkowe/końcowe indeksy" -#: shared-bindings/displayio/Shape.c -msgid "start_x should be an int" -msgstr "start_x powinien być całkowity" - #: shared-bindings/random/__init__.c msgid "step must be non-zero" msgstr "step nie może być zerowe" @@ -4211,7 +4194,6 @@ msgid "unreadable attribute" msgstr "nieczytelny atrybut" #: shared-bindings/displayio/TileGrid.c shared-bindings/vectorio/VectorShape.c -#: shared-module/vectorio/Polygon.c shared-module/vectorio/VectorShape.c msgid "unsupported %q type" msgstr "zły typ %q" @@ -4341,10 +4323,6 @@ msgstr "x poza zakresem" msgid "xTaskCreate failed" msgstr "" -#: shared-bindings/displayio/Shape.c -msgid "y should be an int" -msgstr "y powinno być całkowite" - #: shared-module/displayio/Shape.c msgid "y value out of bounds" msgstr "y poza zakresem" @@ -4365,6 +4343,21 @@ msgstr "" msgid "zi must be of shape (n_section, 2)" msgstr "" +#~ msgid "color should be an int" +#~ msgstr "kolor powinien być liczbą całkowitą" + +#~ msgid "end_x should be an int" +#~ msgstr "end_x powinien być całkowity" + +#~ msgid "palette_index should be an int" +#~ msgstr "palette_index powinien być całkowity" + +#~ msgid "start_x should be an int" +#~ msgstr "start_x powinien być całkowity" + +#~ msgid "y should be an int" +#~ msgstr "y powinno być całkowite" + #~ msgid "" #~ "sample_source buffer must be a bytearray or array of type 'h', 'H', 'b' " #~ "or 'B'" diff --git a/locale/pt_BR.po b/locale/pt_BR.po index c78044a1bf..9d5a97b28b 100644 --- a/locale/pt_BR.po +++ b/locale/pt_BR.po @@ -2609,8 +2609,7 @@ msgstr "a expressão não pode ser atribuída" msgid "can't cancel self" msgstr "não é possível cancelar a si mesmo" -#: py/obj.c py/objint.c shared-bindings/i2ctarget/I2CTarget.c -#: shared-module/adafruit_pixelbuf/PixelBuf.c +#: py/obj.c py/objint.c shared-module/adafruit_pixelbuf/PixelBuf.c msgid "can't convert %q to %q" msgstr "não é possível converter %q para %q" @@ -2803,10 +2802,6 @@ msgstr "" msgid "color must be between 0x000000 and 0xffffff" msgstr "cor deve estar entre 0x000000 e 0xffffff" -#: shared-bindings/displayio/ColorConverter.c -msgid "color should be an int" -msgstr "cor deve ser um int" - #: py/emitnative.c msgid "comparison of int and uint" msgstr "comparação de int e uint" @@ -2961,10 +2956,6 @@ msgstr "seqüência vazia" msgid "end of format while looking for conversion specifier" msgstr "final de formato enquanto procura pelo especificador de conversão" -#: shared-bindings/displayio/Shape.c -msgid "end_x should be an int" -msgstr "end_x deve ser um int" - #: shared-bindings/alarm/time/TimeAlarm.c msgid "epoch_time not supported on this board" msgstr "O epoch_time não é compatível com esta placa" @@ -3844,10 +3835,6 @@ msgstr "o pacote previa %d itens para a empacotamento (obteve %d)" msgid "palette must be 32 bytes long" msgstr "a paleta deve ter 32 bytes de comprimento" -#: shared-bindings/displayio/Palette.c -msgid "palette_index should be an int" -msgstr "palette_index deve ser um int" - #: py/emitinlinextensa.c msgid "parameters must be registers in sequence a2 to a5" msgstr "os parâmetros devem ser registradores na sequência a2 até a5" @@ -4085,10 +4072,6 @@ msgstr "o source_bitmap deve ter o value_count de 8" msgid "start/end indices" msgstr "os índices de início/fim" -#: shared-bindings/displayio/Shape.c -msgid "start_x should be an int" -msgstr "start_x deve ser um int" - #: shared-bindings/random/__init__.c msgid "step must be non-zero" msgstr "o passo deve ser diferente de zero" @@ -4303,7 +4286,6 @@ msgid "unreadable attribute" msgstr "atributo ilegível" #: shared-bindings/displayio/TileGrid.c shared-bindings/vectorio/VectorShape.c -#: shared-module/vectorio/Polygon.c shared-module/vectorio/VectorShape.c msgid "unsupported %q type" msgstr "tipo %q não suportado" @@ -4433,10 +4415,6 @@ msgstr "o valor x está fora dos limites" msgid "xTaskCreate failed" msgstr "o xTaskCreate falhou" -#: shared-bindings/displayio/Shape.c -msgid "y should be an int" -msgstr "y deve ser um int" - #: shared-module/displayio/Shape.c msgid "y value out of bounds" msgstr "o valor y está fora dos limites" @@ -4457,6 +4435,21 @@ msgstr "zi deve ser de um tipo float" msgid "zi must be of shape (n_section, 2)" msgstr "zi deve estar na forma (n_section, 2)" +#~ msgid "color should be an int" +#~ msgstr "cor deve ser um int" + +#~ msgid "end_x should be an int" +#~ msgstr "end_x deve ser um int" + +#~ msgid "palette_index should be an int" +#~ msgstr "palette_index deve ser um int" + +#~ msgid "start_x should be an int" +#~ msgstr "start_x deve ser um int" + +#~ msgid "y should be an int" +#~ msgstr "y deve ser um int" + #~ msgid "" #~ "sample_source buffer must be a bytearray or array of type 'h', 'H', 'b' " #~ "or 'B'" diff --git a/locale/ru.po b/locale/ru.po index 7ee166c7ed..51480c87ed 100644 --- a/locale/ru.po +++ b/locale/ru.po @@ -2575,8 +2575,7 @@ msgstr "" msgid "can't cancel self" msgstr "" -#: py/obj.c py/objint.c shared-bindings/i2ctarget/I2CTarget.c -#: shared-module/adafruit_pixelbuf/PixelBuf.c +#: py/obj.c py/objint.c shared-module/adafruit_pixelbuf/PixelBuf.c msgid "can't convert %q to %q" msgstr "" @@ -2763,10 +2762,6 @@ msgstr "" msgid "color must be between 0x000000 and 0xffffff" msgstr "" -#: shared-bindings/displayio/ColorConverter.c -msgid "color should be an int" -msgstr "" - #: py/emitnative.c msgid "comparison of int and uint" msgstr "" @@ -2918,10 +2913,6 @@ msgstr "" msgid "end of format while looking for conversion specifier" msgstr "" -#: shared-bindings/displayio/Shape.c -msgid "end_x should be an int" -msgstr "" - #: shared-bindings/alarm/time/TimeAlarm.c msgid "epoch_time not supported on this board" msgstr "" @@ -3788,10 +3779,6 @@ msgstr "" msgid "palette must be 32 bytes long" msgstr "" -#: shared-bindings/displayio/Palette.c -msgid "palette_index should be an int" -msgstr "" - #: py/emitinlinextensa.c msgid "parameters must be registers in sequence a2 to a5" msgstr "" @@ -4029,10 +4016,6 @@ msgstr "" msgid "start/end indices" msgstr "" -#: shared-bindings/displayio/Shape.c -msgid "start_x should be an int" -msgstr "" - #: shared-bindings/random/__init__.c msgid "step must be non-zero" msgstr "" @@ -4247,7 +4230,6 @@ msgid "unreadable attribute" msgstr "" #: shared-bindings/displayio/TileGrid.c shared-bindings/vectorio/VectorShape.c -#: shared-module/vectorio/Polygon.c shared-module/vectorio/VectorShape.c msgid "unsupported %q type" msgstr "" @@ -4377,10 +4359,6 @@ msgstr "" msgid "xTaskCreate failed" msgstr "" -#: shared-bindings/displayio/Shape.c -msgid "y should be an int" -msgstr "" - #: shared-module/displayio/Shape.c msgid "y value out of bounds" msgstr "" diff --git a/locale/sv.po b/locale/sv.po index 03c918a6be..783229f591 100644 --- a/locale/sv.po +++ b/locale/sv.po @@ -2581,8 +2581,7 @@ msgstr "kan inte tilldela uttryck" msgid "can't cancel self" msgstr "kan inte avbryta sig själv" -#: py/obj.c py/objint.c shared-bindings/i2ctarget/I2CTarget.c -#: shared-module/adafruit_pixelbuf/PixelBuf.c +#: py/obj.c py/objint.c shared-module/adafruit_pixelbuf/PixelBuf.c msgid "can't convert %q to %q" msgstr "kan inte konvertera %q till %q" @@ -2771,10 +2770,6 @@ msgstr "färgbuffert måste vara en bytearray eller matris av typ 'b' eller 'B'" msgid "color must be between 0x000000 and 0xffffff" msgstr "färg måste vara mellan 0x000000 och 0xffffff" -#: shared-bindings/displayio/ColorConverter.c -msgid "color should be an int" -msgstr "color ska vara en int" - #: py/emitnative.c msgid "comparison of int and uint" msgstr "jämförelse av int och uint" @@ -2929,10 +2924,6 @@ msgstr "tom sekvens" msgid "end of format while looking for conversion specifier" msgstr "slut på format vid sökning efter konverteringsspecificerare" -#: shared-bindings/displayio/Shape.c -msgid "end_x should be an int" -msgstr "color ska vara en int" - #: shared-bindings/alarm/time/TimeAlarm.c msgid "epoch_time not supported on this board" msgstr "epoch_time stöds inte av detta kort" @@ -3804,10 +3795,6 @@ msgstr "pack förväntade %d stycken för packning (fick %d)" msgid "palette must be 32 bytes long" msgstr "palette måste vara 32 bytes lång" -#: shared-bindings/displayio/Palette.c -msgid "palette_index should be an int" -msgstr "palette_index ska vara en int" - #: py/emitinlinextensa.c msgid "parameters must be registers in sequence a2 to a5" msgstr "parametrarna måste registreras i följd a2-a5" @@ -4046,10 +4033,6 @@ msgstr "source_bitmap måste ha value_count av 8" msgid "start/end indices" msgstr "start-/slutindex" -#: shared-bindings/displayio/Shape.c -msgid "start_x should be an int" -msgstr "start_x ska vara en int" - #: shared-bindings/random/__init__.c msgid "step must be non-zero" msgstr "step måste vara icke-noll" @@ -4264,7 +4247,6 @@ msgid "unreadable attribute" msgstr "attribut kan inte läsas" #: shared-bindings/displayio/TileGrid.c shared-bindings/vectorio/VectorShape.c -#: shared-module/vectorio/Polygon.c shared-module/vectorio/VectorShape.c msgid "unsupported %q type" msgstr "typ %q stöds inte" @@ -4394,10 +4376,6 @@ msgstr "x-värde utanför intervall" msgid "xTaskCreate failed" msgstr "xTaskCreate misslyckades" -#: shared-bindings/displayio/Shape.c -msgid "y should be an int" -msgstr "y ska vara en int" - #: shared-module/displayio/Shape.c msgid "y value out of bounds" msgstr "y-värde utanför intervall" @@ -4418,6 +4396,21 @@ msgstr "zi måste vara av typ float" msgid "zi must be of shape (n_section, 2)" msgstr "zi måste vara i formen (n_section, 2)" +#~ msgid "color should be an int" +#~ msgstr "color ska vara en int" + +#~ msgid "end_x should be an int" +#~ msgstr "color ska vara en int" + +#~ msgid "palette_index should be an int" +#~ msgstr "palette_index ska vara en int" + +#~ msgid "start_x should be an int" +#~ msgstr "start_x ska vara en int" + +#~ msgid "y should be an int" +#~ msgstr "y ska vara en int" + #~ msgid "%q ``must`` be a bytearray or array of type 'h', 'H', 'b' or 'B'" #~ msgstr "" #~ "%q ``måste`` vara en bytearray eller matris av typen 'h', 'H', 'b' eller " diff --git a/locale/tr.po b/locale/tr.po index bd1c3e73eb..65cc6e85f6 100644 --- a/locale/tr.po +++ b/locale/tr.po @@ -2545,8 +2545,7 @@ msgstr "" msgid "can't cancel self" msgstr "" -#: py/obj.c py/objint.c shared-bindings/i2ctarget/I2CTarget.c -#: shared-module/adafruit_pixelbuf/PixelBuf.c +#: py/obj.c py/objint.c shared-module/adafruit_pixelbuf/PixelBuf.c msgid "can't convert %q to %q" msgstr "" @@ -2733,10 +2732,6 @@ msgstr "" msgid "color must be between 0x000000 and 0xffffff" msgstr "" -#: shared-bindings/displayio/ColorConverter.c -msgid "color should be an int" -msgstr "" - #: py/emitnative.c msgid "comparison of int and uint" msgstr "" @@ -2888,10 +2883,6 @@ msgstr "" msgid "end of format while looking for conversion specifier" msgstr "" -#: shared-bindings/displayio/Shape.c -msgid "end_x should be an int" -msgstr "" - #: shared-bindings/alarm/time/TimeAlarm.c msgid "epoch_time not supported on this board" msgstr "" @@ -3758,10 +3749,6 @@ msgstr "" msgid "palette must be 32 bytes long" msgstr "" -#: shared-bindings/displayio/Palette.c -msgid "palette_index should be an int" -msgstr "" - #: py/emitinlinextensa.c msgid "parameters must be registers in sequence a2 to a5" msgstr "" @@ -3999,10 +3986,6 @@ msgstr "" msgid "start/end indices" msgstr "" -#: shared-bindings/displayio/Shape.c -msgid "start_x should be an int" -msgstr "" - #: shared-bindings/random/__init__.c msgid "step must be non-zero" msgstr "" @@ -4217,7 +4200,6 @@ msgid "unreadable attribute" msgstr "" #: shared-bindings/displayio/TileGrid.c shared-bindings/vectorio/VectorShape.c -#: shared-module/vectorio/Polygon.c shared-module/vectorio/VectorShape.c msgid "unsupported %q type" msgstr "" @@ -4347,10 +4329,6 @@ msgstr "" msgid "xTaskCreate failed" msgstr "" -#: shared-bindings/displayio/Shape.c -msgid "y should be an int" -msgstr "" - #: shared-module/displayio/Shape.c msgid "y value out of bounds" msgstr "" diff --git a/locale/zh_Latn_pinyin.po b/locale/zh_Latn_pinyin.po index ddb1dbd821..3645f90d63 100644 --- a/locale/zh_Latn_pinyin.po +++ b/locale/zh_Latn_pinyin.po @@ -2584,8 +2584,7 @@ msgstr "bùnéng fēnpèi dào biǎodá shì" msgid "can't cancel self" msgstr "bù néng qǔ xiāo zì wǒ" -#: py/obj.c py/objint.c shared-bindings/i2ctarget/I2CTarget.c -#: shared-module/adafruit_pixelbuf/PixelBuf.c +#: py/obj.c py/objint.c shared-module/adafruit_pixelbuf/PixelBuf.c msgid "can't convert %q to %q" msgstr "Wúfǎ jiāng %q zhuǎnhuàn wèi %q" @@ -2776,10 +2775,6 @@ msgstr "" msgid "color must be between 0x000000 and 0xffffff" msgstr "yánsè bìxū jiè yú 0x000000 hé 0xffffff zhī jiān" -#: shared-bindings/displayio/ColorConverter.c -msgid "color should be an int" -msgstr "yánsè yīng wèi zhěngshù" - #: py/emitnative.c msgid "comparison of int and uint" msgstr "yīn tè hé wū yīn tè de bǐ jiào" @@ -2933,10 +2928,6 @@ msgstr "kōng xùliè" msgid "end of format while looking for conversion specifier" msgstr "xúnzhǎo zhuǎnhuàn biāozhù géshì de jiéshù" -#: shared-bindings/displayio/Shape.c -msgid "end_x should be an int" -msgstr "jiéwěi_x yīnggāi shì yīgè zhěngshù" - #: shared-bindings/alarm/time/TimeAlarm.c msgid "epoch_time not supported on this board" msgstr "epoch_time bǎn bù zhī chí cǐ bǎn běn" @@ -3804,10 +3795,6 @@ msgstr "bāo zhuāng yù qī de %d bāo zhuāng xiàng mù (dé dào %d)" msgid "palette must be 32 bytes long" msgstr "yánsè bìxū shì 32 gè zì jié" -#: shared-bindings/displayio/Palette.c -msgid "palette_index should be an int" -msgstr "yánsè suǒyǐn yīnggāi shì yīgè zhěngshù" - #: py/emitinlinextensa.c msgid "parameters must be registers in sequence a2 to a5" msgstr "cānshù bìxū shì xùliè a2 zhì a5 de dēngjì shù" @@ -4048,10 +4035,6 @@ msgstr "yuán wèi tú (source_bitmap) de zhí de shù mù (value_count) bì xū msgid "start/end indices" msgstr "kāishǐ/jiéshù zhǐshù" -#: shared-bindings/displayio/Shape.c -msgid "start_x should be an int" -msgstr "kāishǐ_x yīnggāi shì yīgè zhěngshù" - #: shared-bindings/random/__init__.c msgid "step must be non-zero" msgstr "bùzhòu bìxū shìfēi líng" @@ -4266,7 +4249,6 @@ msgid "unreadable attribute" msgstr "bùkě dú shǔxìng" #: shared-bindings/displayio/TileGrid.c shared-bindings/vectorio/VectorShape.c -#: shared-module/vectorio/Polygon.c shared-module/vectorio/VectorShape.c msgid "unsupported %q type" msgstr "bù zhīchí %q lèixíng" @@ -4396,10 +4378,6 @@ msgstr "x zhí chāochū biānjiè" msgid "xTaskCreate failed" msgstr "xTaskCreate shī bài" -#: shared-bindings/displayio/Shape.c -msgid "y should be an int" -msgstr "y yīnggāi shì yīgè zhěngshù" - #: shared-module/displayio/Shape.c msgid "y value out of bounds" msgstr "y zhí chāochū biānjiè" @@ -4420,6 +4398,21 @@ msgstr "zi bìxū wèi fú diǎn xíng" msgid "zi must be of shape (n_section, 2)" msgstr "zi bìxū jùyǒu xíngzhuàng (n_section,2)" +#~ msgid "color should be an int" +#~ msgstr "yánsè yīng wèi zhěngshù" + +#~ msgid "end_x should be an int" +#~ msgstr "jiéwěi_x yīnggāi shì yīgè zhěngshù" + +#~ msgid "palette_index should be an int" +#~ msgstr "yánsè suǒyǐn yīnggāi shì yīgè zhěngshù" + +#~ msgid "start_x should be an int" +#~ msgstr "kāishǐ_x yīnggāi shì yīgè zhěngshù" + +#~ msgid "y should be an int" +#~ msgstr "y yīnggāi shì yīgè zhěngshù" + #~ msgid "" #~ "sample_source buffer must be a bytearray or array of type 'h', 'H', 'b' " #~ "or 'B'" From 8754a6ec53a03b648dee608a5d2d936fcf515717 Mon Sep 17 00:00:00 2001 From: Florin Maticu Date: Sat, 19 Mar 2022 11:46:16 +0100 Subject: [PATCH 23/27] Add circuitpython support for STM Nucleo-F446RE. --- ports/stm/boards/STM32F446_fs.ld | 26 ++++ ports/stm/boards/nucleo_f446re/board.c | 40 ++++++ .../stm/boards/nucleo_f446re/mpconfigboard.h | 55 ++++++++ .../stm/boards/nucleo_f446re/mpconfigboard.mk | 35 +++++ ports/stm/boards/nucleo_f446re/pins.c | 78 +++++++++++ ports/stm/peripherals/periph.h | 7 + ports/stm/peripherals/pins.h | 3 + ports/stm/peripherals/stm32f4/clocks.c | 9 +- .../peripherals/stm32f4/stm32f446xx/clocks.h | 66 +++++++++ .../peripherals/stm32f4/stm32f446xx/gpio.c | 47 +++++++ .../peripherals/stm32f4/stm32f446xx/periph.c | 129 ++++++++++++++++++ .../peripherals/stm32f4/stm32f446xx/periph.h | 57 ++++++++ .../peripherals/stm32f4/stm32f446xx/pins.c | 88 ++++++++++++ .../peripherals/stm32f4/stm32f446xx/pins.h | 90 ++++++++++++ ports/stm/supervisor/internal_flash.h | 6 + 15 files changed, 733 insertions(+), 3 deletions(-) create mode 100644 ports/stm/boards/STM32F446_fs.ld create mode 100644 ports/stm/boards/nucleo_f446re/board.c create mode 100644 ports/stm/boards/nucleo_f446re/mpconfigboard.h create mode 100644 ports/stm/boards/nucleo_f446re/mpconfigboard.mk create mode 100644 ports/stm/boards/nucleo_f446re/pins.c create mode 100644 ports/stm/peripherals/stm32f4/stm32f446xx/clocks.h create mode 100644 ports/stm/peripherals/stm32f4/stm32f446xx/gpio.c create mode 100644 ports/stm/peripherals/stm32f4/stm32f446xx/periph.c create mode 100644 ports/stm/peripherals/stm32f4/stm32f446xx/periph.h create mode 100644 ports/stm/peripherals/stm32f4/stm32f446xx/pins.c create mode 100644 ports/stm/peripherals/stm32f4/stm32f446xx/pins.h diff --git a/ports/stm/boards/STM32F446_fs.ld b/ports/stm/boards/STM32F446_fs.ld new file mode 100644 index 0000000000..76735cbdc2 --- /dev/null +++ b/ports/stm/boards/STM32F446_fs.ld @@ -0,0 +1,26 @@ +/* + GNU linker script for STM32F446 with filesystem +*/ + +/* Specify the memory areas */ +MEMORY +{ + FLASH (rx) : ORIGIN = 0x08000000, LENGTH = 512K /* entire flash */ + FLASH_ISR (rx) : ORIGIN = 0x08000000, LENGTH = 16K /* sector 0 */ + FLASH_FS (rx) : ORIGIN = 0x08004000, LENGTH = 48K /* sectors 1,2,3 are 16K */ + FLASH_FIRMWARE (rx) : ORIGIN = 0x08010000, LENGTH = 448K /* sector 4 is 64K, sectors 5,6,7 are 128K */ + RAM (xrw) : ORIGIN = 0x20000000, LENGTH = 128K +} + +/* produce a link error if there is not this amount of RAM for these sections */ +_minimum_stack_size = 24K; +_minimum_heap_size = 16K; + +/* Define tho top end of the stack. The stack is full descending so begins just + above last byte of RAM. Note that EABI requires the stack to be 8-byte + aligned for a call. */ +_estack = ORIGIN(RAM) + LENGTH(RAM); + +/* RAM extents for the garbage collector */ +_ram_start = ORIGIN(RAM); +_ram_end = ORIGIN(RAM) + LENGTH(RAM); diff --git a/ports/stm/boards/nucleo_f446re/board.c b/ports/stm/boards/nucleo_f446re/board.c new file mode 100644 index 0000000000..31329a8d3b --- /dev/null +++ b/ports/stm/boards/nucleo_f446re/board.c @@ -0,0 +1,40 @@ +/* + * This file is part of the MicroPython project, http://micropython.org/ + * + * The MIT License (MIT) + * + * Copyright (c) 2022 flom84 for Adafruit Industries + * + * Permission is hereby granted, free of charge, to any person obtaining a copy + * of this software and associated documentation files (the "Software"), to deal + * in the Software without restriction, including without limitation the rights + * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell + * copies of the Software, and to permit persons to whom the Software is + * furnished to do so, subject to the following conditions: + * + * The above copyright notice and this permission notice shall be included in + * all copies or substantial portions of the Software. + * + * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR + * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, + * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE + * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER + * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, + * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN + * THE SOFTWARE. + */ + +#include "supervisor/board.h" + +void board_init(void) { +} + +bool board_requests_safe_mode(void) { + return false; +} + +void reset_board(void) { +} + +void board_deinit(void) { +} diff --git a/ports/stm/boards/nucleo_f446re/mpconfigboard.h b/ports/stm/boards/nucleo_f446re/mpconfigboard.h new file mode 100644 index 0000000000..eb67015c4e --- /dev/null +++ b/ports/stm/boards/nucleo_f446re/mpconfigboard.h @@ -0,0 +1,55 @@ +/* + * This file is part of the MicroPython project, http://micropython.org/ + * + * The MIT License (MIT) + * + * Copyright (c) 2022 flom84 for Adafruit Industries + * + * Permission is hereby granted, free of charge, to any person obtaining a copy + * of this software and associated documentation files (the "Software"), to deal + * in the Software without restriction, including without limitation the rights + * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell + * copies of the Software, and to permit persons to whom the Software is + * furnished to do so, subject to the following conditions: + * + * The above copyright notice and this permission notice shall be included in + * all copies or substantial portions of the Software. + * + * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR + * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, + * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE + * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER + * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, + * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN + * THE SOFTWARE. + */ + +// Micropython setup + +#define MICROPY_HW_BOARD_NAME "NUCLEO F446RE" +#define MICROPY_HW_MCU_NAME "STM32F446xx" + +#define FLASH_SIZE (0x80000u) // 512K +#define FLASH_PAGE_SIZE (0x4000u) // 16K + +#define HSE_VALUE ((uint32_t)8000000u) +#define BOARD_HSE_SOURCE (RCC_HSE_ON) +// The schematic has a 32k crystal that isn't fitted. Uncommented the line below if you add it. +// #define BOARD_HAS_LOW_SPEED_CRYSTAL (1) +// #define LSE_VALUE ((uint32_t)32000U) +#define BOARD_HAS_LOW_SPEED_CRYSTAL (0) + +// USART3 + USB FTDI +// #define CIRCUITPY_CONSOLE_UART_TX (&pin_PC10) +// #define CIRCUITPY_CONSOLE_UART_RX (&pin_PC11) + +// USART2 + ST link +// #define CIRCUITPY_CONSOLE_UART_TX (&pin_PA02) +// #define CIRCUITPY_CONSOLE_UART_RX (&pin_PA03) + +// Status LEDs +#define MICROPY_HW_LED_STATUS (&pin_PA05) + +#define MICROPY_FATFS_EXFAT 0 + +#define BOARD_NO_VBUS_SENSE (1) diff --git a/ports/stm/boards/nucleo_f446re/mpconfigboard.mk b/ports/stm/boards/nucleo_f446re/mpconfigboard.mk new file mode 100644 index 0000000000..3730729c95 --- /dev/null +++ b/ports/stm/boards/nucleo_f446re/mpconfigboard.mk @@ -0,0 +1,35 @@ +USB_VID = 0x239A +USB_PID = 0x809F +USB_PRODUCT = "NUCLEO-F446RE - CPy" +USB_MANUFACTURER = "STMicroelectronics" + +INTERNAL_FLASH_FILESYSTEM = 1 + +MCU_SERIES = F4 +MCU_VARIANT = STM32F446xx +MCU_PACKAGE = LQFP64 + +LD_COMMON = boards/common_default.ld +LD_FILE = boards/STM32F446_fs.ld + +# Too big for the flash +CIRCUITPY_AUDIOCORE = 0 +CIRCUITPY_AUDIOPWMIO = 0 +CIRCUITPY_BITMAPTOOLS = 0 +CIRCUITPY_BLEIO_HCI = 0 +CIRCUITPY_VECTORIO = 0 +CIRCUITPY_TOUCHIO = 0 +CIRCUITPY_RAINBOWIO = 0 +CIRCUITPY_USB_HID = 0 +CIRCUITPY_USB_MIDI = 0 +CIRCUITPY_JSON = 0 +# Requires neopixel_write or SPI (dotstar) +CIRCUITPY_PIXELBUF = 0 +# No requirements, but takes extra flash +CIRCUITPY_ULAB = 0 +CIRCUITPY_GAMEPADSHIFT = 0 +CIRCUITPY_BITBANGIO = 0 +CIRCUITPY_NEOPIXEL_WRITE = 0 +CIRCUITPY_SDCARDIO = 0 +CIRCUITPY_DISPLAYIO = 0 +CIRCUITPY_KEYPAD = 0 diff --git a/ports/stm/boards/nucleo_f446re/pins.c b/ports/stm/boards/nucleo_f446re/pins.c new file mode 100644 index 0000000000..ac5a457d07 --- /dev/null +++ b/ports/stm/boards/nucleo_f446re/pins.c @@ -0,0 +1,78 @@ +#include "shared-bindings/board/__init__.h" + +STATIC const mp_rom_map_elem_t board_module_globals_table[] = { + {MP_ROM_QSTR(MP_QSTR_ID), MP_ROM_PTR(&board_module_id_obj)}, + {MP_ROM_QSTR(MP_QSTR_D0), MP_ROM_PTR(&pin_PA03)}, + {MP_ROM_QSTR(MP_QSTR_D1), MP_ROM_PTR(&pin_PA02)}, + {MP_ROM_QSTR(MP_QSTR_D2), MP_ROM_PTR(&pin_PA10)}, + {MP_ROM_QSTR(MP_QSTR_D3), MP_ROM_PTR(&pin_PB03)}, + {MP_ROM_QSTR(MP_QSTR_D4), MP_ROM_PTR(&pin_PB05)}, + {MP_ROM_QSTR(MP_QSTR_D5), MP_ROM_PTR(&pin_PB04)}, + {MP_ROM_QSTR(MP_QSTR_D6), MP_ROM_PTR(&pin_PB10)}, + {MP_ROM_QSTR(MP_QSTR_D7), MP_ROM_PTR(&pin_PA08)}, + {MP_ROM_QSTR(MP_QSTR_D8), MP_ROM_PTR(&pin_PA09)}, + {MP_ROM_QSTR(MP_QSTR_D9), MP_ROM_PTR(&pin_PC07)}, + {MP_ROM_QSTR(MP_QSTR_D10), MP_ROM_PTR(&pin_PB06)}, + {MP_ROM_QSTR(MP_QSTR_D11), MP_ROM_PTR(&pin_PA07)}, + {MP_ROM_QSTR(MP_QSTR_D12), MP_ROM_PTR(&pin_PA06)}, + {MP_ROM_QSTR(MP_QSTR_D13), MP_ROM_PTR(&pin_PA05)}, + {MP_ROM_QSTR(MP_QSTR_D14), MP_ROM_PTR(&pin_PB09)}, + {MP_ROM_QSTR(MP_QSTR_D15), MP_ROM_PTR(&pin_PB08)}, + {MP_ROM_QSTR(MP_QSTR_A0), MP_ROM_PTR(&pin_PA00)}, + {MP_ROM_QSTR(MP_QSTR_A1), MP_ROM_PTR(&pin_PA01)}, + {MP_ROM_QSTR(MP_QSTR_A2), MP_ROM_PTR(&pin_PA04)}, + {MP_ROM_QSTR(MP_QSTR_A3), MP_ROM_PTR(&pin_PB00)}, + {MP_ROM_QSTR(MP_QSTR_A4), MP_ROM_PTR(&pin_PC01)}, + {MP_ROM_QSTR(MP_QSTR_A5), MP_ROM_PTR(&pin_PC00)}, + {MP_ROM_QSTR(MP_QSTR_PA0), MP_ROM_PTR(&pin_PA00)}, + {MP_ROM_QSTR(MP_QSTR_PA1), MP_ROM_PTR(&pin_PA01)}, + {MP_ROM_QSTR(MP_QSTR_PA2), MP_ROM_PTR(&pin_PA02)}, + {MP_ROM_QSTR(MP_QSTR_PA3), MP_ROM_PTR(&pin_PA03)}, + {MP_ROM_QSTR(MP_QSTR_PA4), MP_ROM_PTR(&pin_PA04)}, + {MP_ROM_QSTR(MP_QSTR_PA5), MP_ROM_PTR(&pin_PA05)}, + {MP_ROM_QSTR(MP_QSTR_PA6), MP_ROM_PTR(&pin_PA06)}, + {MP_ROM_QSTR(MP_QSTR_PA7), MP_ROM_PTR(&pin_PA07)}, + {MP_ROM_QSTR(MP_QSTR_PA8), MP_ROM_PTR(&pin_PA08)}, + {MP_ROM_QSTR(MP_QSTR_PA9), MP_ROM_PTR(&pin_PA09)}, + {MP_ROM_QSTR(MP_QSTR_PA10), MP_ROM_PTR(&pin_PA10)}, + {MP_ROM_QSTR(MP_QSTR_PA11), MP_ROM_PTR(&pin_PA11)}, + {MP_ROM_QSTR(MP_QSTR_PA12), MP_ROM_PTR(&pin_PA12)}, + {MP_ROM_QSTR(MP_QSTR_PA15), MP_ROM_PTR(&pin_PA15)}, + {MP_ROM_QSTR(MP_QSTR_PB0), MP_ROM_PTR(&pin_PB00)}, + {MP_ROM_QSTR(MP_QSTR_PB1), MP_ROM_PTR(&pin_PB01)}, + {MP_ROM_QSTR(MP_QSTR_PB2), MP_ROM_PTR(&pin_PB02)}, + {MP_ROM_QSTR(MP_QSTR_PB3), MP_ROM_PTR(&pin_PB03)}, + {MP_ROM_QSTR(MP_QSTR_PB4), MP_ROM_PTR(&pin_PB04)}, + {MP_ROM_QSTR(MP_QSTR_PB5), MP_ROM_PTR(&pin_PB05)}, + {MP_ROM_QSTR(MP_QSTR_PB6), MP_ROM_PTR(&pin_PB06)}, + {MP_ROM_QSTR(MP_QSTR_PB7), MP_ROM_PTR(&pin_PB07)}, + {MP_ROM_QSTR(MP_QSTR_PB8), MP_ROM_PTR(&pin_PB08)}, + {MP_ROM_QSTR(MP_QSTR_PB9), MP_ROM_PTR(&pin_PB09)}, + {MP_ROM_QSTR(MP_QSTR_PB10), MP_ROM_PTR(&pin_PB10)}, + {MP_ROM_QSTR(MP_QSTR_PB12), MP_ROM_PTR(&pin_PB12)}, + {MP_ROM_QSTR(MP_QSTR_PB13), MP_ROM_PTR(&pin_PB13)}, + {MP_ROM_QSTR(MP_QSTR_PB14), MP_ROM_PTR(&pin_PB14)}, + {MP_ROM_QSTR(MP_QSTR_PB15), MP_ROM_PTR(&pin_PB15)}, + {MP_ROM_QSTR(MP_QSTR_PC0), MP_ROM_PTR(&pin_PC00)}, + {MP_ROM_QSTR(MP_QSTR_PC1), MP_ROM_PTR(&pin_PC01)}, + {MP_ROM_QSTR(MP_QSTR_PC2), MP_ROM_PTR(&pin_PC02)}, + {MP_ROM_QSTR(MP_QSTR_PC3), MP_ROM_PTR(&pin_PC03)}, + {MP_ROM_QSTR(MP_QSTR_PC4), MP_ROM_PTR(&pin_PC04)}, + {MP_ROM_QSTR(MP_QSTR_PC5), MP_ROM_PTR(&pin_PC05)}, + {MP_ROM_QSTR(MP_QSTR_PC6), MP_ROM_PTR(&pin_PC06)}, + {MP_ROM_QSTR(MP_QSTR_PC7), MP_ROM_PTR(&pin_PC07)}, + {MP_ROM_QSTR(MP_QSTR_PC8), MP_ROM_PTR(&pin_PC08)}, + {MP_ROM_QSTR(MP_QSTR_PC9), MP_ROM_PTR(&pin_PC09)}, + {MP_ROM_QSTR(MP_QSTR_PC10), MP_ROM_PTR(&pin_PC10)}, + {MP_ROM_QSTR(MP_QSTR_PC11), MP_ROM_PTR(&pin_PC11)}, + {MP_ROM_QSTR(MP_QSTR_PC12), MP_ROM_PTR(&pin_PC12)}, + {MP_ROM_QSTR(MP_QSTR_PC13), MP_ROM_PTR(&pin_PC13)}, + {MP_ROM_QSTR(MP_QSTR_PC14), MP_ROM_PTR(&pin_PC14)}, + {MP_ROM_QSTR(MP_QSTR_PC15), MP_ROM_PTR(&pin_PC15)}, + {MP_ROM_QSTR(MP_QSTR_PD2), MP_ROM_PTR(&pin_PD02)}, + {MP_ROM_QSTR(MP_QSTR_PH0), MP_ROM_PTR(&pin_PH00)}, + {MP_ROM_QSTR(MP_QSTR_PH1), MP_ROM_PTR(&pin_PH01)}, + {MP_ROM_QSTR(MP_QSTR_LED), MP_ROM_PTR(&pin_PA05)}, + {MP_ROM_QSTR(MP_QSTR_SW), MP_ROM_PTR(&pin_PC13)}, +}; +MP_DEFINE_CONST_DICT(board_module_globals, board_module_globals_table); diff --git a/ports/stm/peripherals/periph.h b/ports/stm/peripherals/periph.h index caf4ca1324..1049aeb084 100644 --- a/ports/stm/peripherals/periph.h +++ b/ports/stm/peripherals/periph.h @@ -119,6 +119,13 @@ typedef struct { #include "stm32f4/stm32f407xx/periph.h" #endif +#ifdef STM32F446xx +#define HAS_DAC 0 +#define HAS_TRNG 0 +#define HAS_BASIC_TIM 0 +#include "stm32f4/stm32f446xx/periph.h" +#endif + // F7 Series #ifdef STM32F746xx diff --git a/ports/stm/peripherals/pins.h b/ports/stm/peripherals/pins.h index 37aa2d8feb..a53b05aa1d 100644 --- a/ports/stm/peripherals/pins.h +++ b/ports/stm/peripherals/pins.h @@ -97,6 +97,9 @@ extern const mp_obj_type_t mcu_pin_type; #ifdef STM32F407xx #include "stm32f4/stm32f407xx/pins.h" #endif +#ifdef STM32F446xx +#include "stm32f4/stm32f446xx/pins.h" +#endif // F7 Series #ifdef STM32F746xx diff --git a/ports/stm/peripherals/stm32f4/clocks.c b/ports/stm/peripherals/stm32f4/clocks.c index f3434a944b..a2f8344901 100644 --- a/ports/stm/peripherals/stm32f4/clocks.c +++ b/ports/stm/peripherals/stm32f4/clocks.c @@ -47,11 +47,14 @@ #ifdef STM32F407xx #include "stm32f4/stm32f407xx/clocks.h" #endif +#ifdef STM32F446xx +#include "stm32f4/stm32f446xx/clocks.h" +#endif void stm32_peripherals_clocks_init(void) { - RCC_ClkInitTypeDef RCC_ClkInitStruct; - RCC_OscInitTypeDef RCC_OscInitStruct; - RCC_PeriphCLKInitTypeDef PeriphClkInitStruct; + RCC_ClkInitTypeDef RCC_ClkInitStruct = {0}; + RCC_OscInitTypeDef RCC_OscInitStruct = {0}; + RCC_PeriphCLKInitTypeDef PeriphClkInitStruct = {0}; // Set voltage scaling in accordance with system clock speed __HAL_RCC_PWR_CLK_ENABLE(); diff --git a/ports/stm/peripherals/stm32f4/stm32f446xx/clocks.h b/ports/stm/peripherals/stm32f4/stm32f446xx/clocks.h new file mode 100644 index 0000000000..fc724fc056 --- /dev/null +++ b/ports/stm/peripherals/stm32f4/stm32f446xx/clocks.h @@ -0,0 +1,66 @@ +/* + * This file is part of the Micro Python project, http://micropython.org/ + * + * The MIT License (MIT) + * + * Copyright (c) 2022 flom84 for Adafruit Industries + * + * Permission is hereby granted, free of charge, to any person obtaining a copy + * of this software and associated documentation files (the "Software"), to deal + * in the Software without restriction, including without limitation the rights + * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell + * copies of the Software, and to permit persons to whom the Software is + * furnished to do so, subject to the following conditions: + * + * The above copyright notice and this permission notice shall be included in + * all copies or substantial portions of the Software. + * + * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR + * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, + * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE + * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER + * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, + * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN + * THE SOFTWARE. + */ + +#include "stm32f4xx_hal.h" + +// Chip: STM32F446xC/xV +// Line Type: Access Line +// Speed: 168MHz (max 180MHz) + +// Defaults: +#ifndef CPY_CLK_VSCALE +#define CPY_CLK_VSCALE (PWR_REGULATOR_VOLTAGE_SCALE1) +#endif +#ifndef CPY_CLK_PLLM +#define CPY_CLK_PLLM (8) +#endif +#ifndef CPY_CLK_PLLN +#define CPY_CLK_PLLN (336) +#endif +#ifndef CPY_CLK_PLLP +#define CPY_CLK_PLLP (RCC_PLLP_DIV2) +#endif +#ifndef CPY_CLK_PLLQ +#define CPY_CLK_PLLQ (7) +#endif +#ifndef CPY_CLK_AHBDIV +#define CPY_CLK_AHBDIV (RCC_SYSCLK_DIV1) +#endif +#ifndef CPY_CLK_APB1DIV +#define CPY_CLK_APB1DIV (RCC_HCLK_DIV4) +#endif +#ifndef CPY_CLK_APB2DIV +#define CPY_CLK_APB2DIV (RCC_HCLK_DIV2) +#endif +#ifndef CPY_CLK_FLASH_LATENCY +#define CPY_CLK_FLASH_LATENCY (FLASH_LATENCY_5) +#endif +#ifndef CPY_CLK_USB_USES_AUDIOPLL +#define CPY_CLK_USB_USES_AUDIOPLL (0) +#endif +#ifndef BOARD_HSE_SOURCE +#define BOARD_HSE_SOURCE (RCC_HSE_ON) +#endif diff --git a/ports/stm/peripherals/stm32f4/stm32f446xx/gpio.c b/ports/stm/peripherals/stm32f4/stm32f446xx/gpio.c new file mode 100644 index 0000000000..c31c785bf2 --- /dev/null +++ b/ports/stm/peripherals/stm32f4/stm32f446xx/gpio.c @@ -0,0 +1,47 @@ +/* + * This file is part of the Micro Python project, http://micropython.org/ + * + * The MIT License (MIT) + * + * Copyright (c) 2022 flom84 for Adafruit Industries + * + * Permission is hereby granted, free of charge, to any person obtaining a copy + * of this software and associated documentation files (the "Software"), to deal + * in the Software without restriction, including without limitation the rights + * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell + * copies of the Software, and to permit persons to whom the Software is + * furnished to do so, subject to the following conditions: + * + * The above copyright notice and this permission notice shall be included in + * all copies or substantial portions of the Software. + * + * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR + * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, + * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE + * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER + * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, + * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN + * THE SOFTWARE. + */ + +#include "peripherals/gpio.h" +#include "stm32f4xx_hal.h" +#include "common-hal/microcontroller/Pin.h" + +void stm32_peripherals_gpio_init(void) { + // * GPIO Ports Clock Enable */ + __HAL_RCC_GPIOC_CLK_ENABLE(); + __HAL_RCC_GPIOH_CLK_ENABLE(); + __HAL_RCC_GPIOA_CLK_ENABLE(); + __HAL_RCC_GPIOB_CLK_ENABLE(); + + // Never reset pins + never_reset_pin_number(2, 13); // PC13 anti tamp + never_reset_pin_number(2, 14); // PC14 OSC32_IN + never_reset_pin_number(2, 15); // PC15 OSC32_OUT + never_reset_pin_number(0, 13); // PA13 SWDIO + never_reset_pin_number(0, 14); // PA14 SWCLK +} + +void stm32f4_peripherals_status_led(uint8_t led, uint8_t state) { +} diff --git a/ports/stm/peripherals/stm32f4/stm32f446xx/periph.c b/ports/stm/peripherals/stm32f4/stm32f446xx/periph.c new file mode 100644 index 0000000000..666b2be2c2 --- /dev/null +++ b/ports/stm/peripherals/stm32f4/stm32f446xx/periph.c @@ -0,0 +1,129 @@ +/* + * This file is part of the MicroPython project, http://micropython.org/ + * + * The MIT License (MIT) + * + * Copyright (c) 2022 flom84 for Adafruit Industries + * + * Permission is hereby granted, free of charge, to any person obtaining a copy + * of this software and associated documentation files (the "Software"), to deal + * in the Software without restriction, including without limitation the rights + * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell + * copies of the Software, and to permit persons to whom the Software is + * furnished to do so, subject to the following conditions: + * + * The above copyright notice and this permission notice shall be included in + * all copies or substantial portions of the Software. + * + * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR + * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, + * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE + * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER + * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, + * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN + * THE SOFTWARE. + */ + +#include "py/obj.h" +#include "py/mphal.h" +#include "peripherals/pins.h" +#include "peripherals/periph.h" + +// I2C +I2C_TypeDef *mcu_i2c_banks[3] = {I2C1, I2C2, I2C3}; + +const mcu_periph_obj_t mcu_i2c_sda_list[3] = { + PERIPH(1, 4, &pin_PB07), + PERIPH(2, 4, &pin_PB03), + PERIPH(3, 4, &pin_PB04), +}; + +const mcu_periph_obj_t mcu_i2c_scl_list[3] = { + PERIPH(1, 4, &pin_PB06), + PERIPH(2, 4, &pin_PB10), + PERIPH(3, 4, &pin_PA08), +}; + +// SPI +SPI_TypeDef *mcu_spi_banks[3] = {SPI1, SPI2, SPI3}; + +const mcu_periph_obj_t mcu_spi_sck_list[3] = { + PERIPH(1, 5, &pin_PA05), + PERIPH(2, 5, &pin_PB13), + PERIPH(3, 6, &pin_PB03), +}; + +const mcu_periph_obj_t mcu_spi_mosi_list[3] = { + PERIPH(1, 5, &pin_PA07), + PERIPH(2, 5, &pin_PB15), + PERIPH(3, 6, &pin_PB05), + +}; + +const mcu_periph_obj_t mcu_spi_miso_list[3] = { + PERIPH(1, 5, &pin_PA06), + PERIPH(2, 5, &pin_PB14), + PERIPH(3, 6, &pin_PB04), +}; + +const mcu_periph_obj_t mcu_spi_nss_list[3] = { + PERIPH(1, 5, &pin_PA04), + PERIPH(2, 5, &pin_PB12), + PERIPH(3, 6, &pin_PA15), +}; + +USART_TypeDef *mcu_uart_banks[MAX_UART] = {USART1, USART2, USART3, NULL, NULL, NULL}; +bool mcu_uart_has_usart[MAX_UART] = {false, false, false, true, true, false}; + +const mcu_periph_obj_t mcu_uart_tx_list[3] = { + PERIPH(1, 7, &pin_PB06), + PERIPH(2, 7, &pin_PA02), + PERIPH(3, 7, &pin_PC10), + +}; + +const mcu_periph_obj_t mcu_uart_rx_list[3] = { + PERIPH(1, 7, &pin_PB07), + PERIPH(2, 7, &pin_PA03), + PERIPH(3, 7, &pin_PC11), +}; + +// Timers +TIM_TypeDef *mcu_tim_banks[14] = {TIM1, TIM2, TIM3, TIM4, TIM5, NULL, NULL, NULL, TIM9, TIM10, + TIM11, NULL, NULL, NULL}; + +const mcu_tim_pin_obj_t mcu_tim_pin_list[34] = { + TIM(2, 1, 1, &pin_PA00), + TIM(5, 2, 1, &pin_PA00), + TIM(2, 1, 2, &pin_PA01), + TIM(5, 2, 2, &pin_PA01), + TIM(2, 1, 3, &pin_PA02), + TIM(5, 2, 3, &pin_PA02), + TIM(2, 1, 4, &pin_PA03), + TIM(5, 2, 4, &pin_PA03), + TIM(9, 3, 1, &pin_PA02), + TIM(9, 3, 2, &pin_PA03), + TIM(3, 2, 1, &pin_PA06), + TIM(3, 2, 2, &pin_PA07), + TIM(1, 1, 1, &pin_PA08), + TIM(1, 1, 2, &pin_PA09), + TIM(1, 1, 3, &pin_PA10), + TIM(1, 1, 4, &pin_PA11), + TIM(2, 1, 1, &pin_PA15), + TIM(3, 2, 3, &pin_PB00), + TIM(3, 2, 4, &pin_PB01), + TIM(2, 1, 2, &pin_PB03), + TIM(3, 2, 1, &pin_PB04), + TIM(3, 2, 2, &pin_PB05), + TIM(4, 2, 1, &pin_PB06), + TIM(4, 2, 2, &pin_PB07), + TIM(4, 2, 3, &pin_PB08), + TIM(10, 2, 1, &pin_PB08), + TIM(4, 2, 4, &pin_PB09), + TIM(11, 2, 1, &pin_PB09), + TIM(2, 1, 3, &pin_PB10), + TIM(3, 2, 1, &pin_PC06), + TIM(3, 2, 2, &pin_PC07), + TIM(3, 2, 3, &pin_PC08), + TIM(3, 2, 4, &pin_PC09), +}; diff --git a/ports/stm/peripherals/stm32f4/stm32f446xx/periph.h b/ports/stm/peripherals/stm32f4/stm32f446xx/periph.h new file mode 100644 index 0000000000..31ee9be4d4 --- /dev/null +++ b/ports/stm/peripherals/stm32f4/stm32f446xx/periph.h @@ -0,0 +1,57 @@ +/* + * This file is part of the MicroPython project, http://micropython.org/ + * + * The MIT License (MIT) + * + * Copyright (c) 2022 flom84 for Adafruit Industries + * + * Permission is hereby granted, free of charge, to any person obtaining a copy + * of this software and associated documentation files (the "Software"), to deal + * in the Software without restriction, including without limitation the rights + * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell + * copies of the Software, and to permit persons to whom the Software is + * furnished to do so, subject to the following conditions: + * + * The above copyright notice and this permission notice shall be included in + * all copies or substantial portions of the Software. + * + * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR + * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, + * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE + * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER + * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, + * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN + * THE SOFTWARE. + */ + +#ifndef MICROPY_INCLUDED_STM32_PERIPHERALS_STM32F446RE_PERIPH_H +#define MICROPY_INCLUDED_STM32_PERIPHERALS_STM32F446RE_PERIPH_H + +// I2C +extern I2C_TypeDef *mcu_i2c_banks[3]; + +extern const mcu_periph_obj_t mcu_i2c_sda_list[3]; +extern const mcu_periph_obj_t mcu_i2c_scl_list[3]; + +// SPI +extern SPI_TypeDef *mcu_spi_banks[3]; + +extern const mcu_periph_obj_t mcu_spi_sck_list[3]; +extern const mcu_periph_obj_t mcu_spi_mosi_list[3]; +extern const mcu_periph_obj_t mcu_spi_miso_list[3]; +extern const mcu_periph_obj_t mcu_spi_nss_list[3]; + +// UART +extern USART_TypeDef *mcu_uart_banks[MAX_UART]; +extern bool mcu_uart_has_usart[MAX_UART]; + +extern const mcu_periph_obj_t mcu_uart_tx_list[3]; +extern const mcu_periph_obj_t mcu_uart_rx_list[3]; + +// Timers +#define TIM_BANK_ARRAY_LEN 14 +#define TIM_PIN_ARRAY_LEN 34 +extern TIM_TypeDef *mcu_tim_banks[TIM_BANK_ARRAY_LEN]; +extern const mcu_tim_pin_obj_t mcu_tim_pin_list[TIM_PIN_ARRAY_LEN]; + +#endif // MICROPY_INCLUDED_STM32_PERIPHERALS_STM32F446RE_PERIPH_H diff --git a/ports/stm/peripherals/stm32f4/stm32f446xx/pins.c b/ports/stm/peripherals/stm32f4/stm32f446xx/pins.c new file mode 100644 index 0000000000..23299cb6e8 --- /dev/null +++ b/ports/stm/peripherals/stm32f4/stm32f446xx/pins.c @@ -0,0 +1,88 @@ +/* + * This file is part of the MicroPython project, http://micropython.org/ + * + * The MIT License (MIT) + * + * Copyright (c) 2022 flom84 for Adafruit Industries + * + * Permission is hereby granted, free of charge, to any person obtaining a copy + * of this software and associated documentation files (the "Software"), to deal + * in the Software without restriction, including without limitation the rights + * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell + * copies of the Software, and to permit persons to whom the Software is + * furnished to do so, subject to the following conditions: + * + * The above copyright notice and this permission notice shall be included in + * all copies or substantial portions of the Software. + * + * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR + * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, + * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE + * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER + * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, + * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN + * THE SOFTWARE. + */ + +#include "py/obj.h" +#include "py/mphal.h" +#include "peripherals/pins.h" + +const mcu_pin_obj_t pin_PC13 = PIN(2, 13, NO_ADC); // anti-tamp +const mcu_pin_obj_t pin_PC14 = PIN(2, 14, NO_ADC); // OSC32_IN +const mcu_pin_obj_t pin_PC15 = PIN(2, 15, NO_ADC); // OSC32_OUT +const mcu_pin_obj_t pin_PC00 = PIN(2, 0, ADC_INPUT(ADC_1, 10)); +const mcu_pin_obj_t pin_PC01 = PIN(2, 1, ADC_INPUT(ADC_1, 11)); +const mcu_pin_obj_t pin_PC02 = PIN(2, 2, ADC_INPUT(ADC_1, 12)); +const mcu_pin_obj_t pin_PC03 = PIN(2, 3, ADC_INPUT(ADC_1, 13)); + +const mcu_pin_obj_t pin_PA00 = PIN(0, 0, ADC_INPUT(ADC_1, 0)); +const mcu_pin_obj_t pin_PA01 = PIN(0, 1, ADC_INPUT(ADC_1, 1)); +const mcu_pin_obj_t pin_PA02 = PIN(0, 2, ADC_INPUT(ADC_1, 2)); +const mcu_pin_obj_t pin_PA03 = PIN(0, 3, ADC_INPUT(ADC_1, 3)); +const mcu_pin_obj_t pin_PA04 = PIN(0, 4, ADC_INPUT(ADC_1, 4)); +const mcu_pin_obj_t pin_PA05 = PIN(0, 5, ADC_INPUT(ADC_1, 5)); +const mcu_pin_obj_t pin_PA06 = PIN(0, 6, ADC_INPUT(ADC_1, 6)); +const mcu_pin_obj_t pin_PA07 = PIN(0, 7, ADC_INPUT(ADC_1, 7)); + +const mcu_pin_obj_t pin_PC04 = PIN(2, 4, ADC_INPUT(ADC_1, 14)); +const mcu_pin_obj_t pin_PC05 = PIN(2, 5, ADC_INPUT(ADC_1, 15)); +const mcu_pin_obj_t pin_PB00 = PIN(1, 0, ADC_INPUT(ADC_1, 8)); +const mcu_pin_obj_t pin_PB01 = PIN(1, 1, ADC_INPUT(ADC_1, 9)); +const mcu_pin_obj_t pin_PB02 = PIN(1, 2, NO_ADC); + +const mcu_pin_obj_t pin_PB10 = PIN(1, 10, NO_ADC); +const mcu_pin_obj_t pin_PB12 = PIN(1, 12, NO_ADC); +const mcu_pin_obj_t pin_PB13 = PIN(1, 13, NO_ADC); +const mcu_pin_obj_t pin_PB14 = PIN(1, 14, NO_ADC); +const mcu_pin_obj_t pin_PB15 = PIN(1, 15, NO_ADC); + +const mcu_pin_obj_t pin_PC06 = PIN(2, 6, NO_ADC); +const mcu_pin_obj_t pin_PC07 = PIN(2, 7, NO_ADC); +const mcu_pin_obj_t pin_PC08 = PIN(2, 8, NO_ADC); +const mcu_pin_obj_t pin_PC09 = PIN(2, 9, NO_ADC); +const mcu_pin_obj_t pin_PA08 = PIN(0, 8, NO_ADC); +const mcu_pin_obj_t pin_PA09 = PIN(0, 9, NO_ADC); + +const mcu_pin_obj_t pin_PA10 = PIN(0, 10, NO_ADC); +const mcu_pin_obj_t pin_PA11 = PIN(0, 11, NO_ADC); +const mcu_pin_obj_t pin_PA12 = PIN(0, 12, NO_ADC); +const mcu_pin_obj_t pin_PA13 = PIN(0, 13, NO_ADC); // SWDIO +const mcu_pin_obj_t pin_PA14 = PIN(0, 14, NO_ADC); // SWCLK +const mcu_pin_obj_t pin_PA15 = PIN(0, 15, NO_ADC); // JTDI +const mcu_pin_obj_t pin_PC10 = PIN(2, 10, NO_ADC); +const mcu_pin_obj_t pin_PC11 = PIN(2, 11, NO_ADC); +const mcu_pin_obj_t pin_PC12 = PIN(2, 12, NO_ADC); + +const mcu_pin_obj_t pin_PB03 = PIN(1, 3, NO_ADC); +const mcu_pin_obj_t pin_PB04 = PIN(1, 4, NO_ADC); +const mcu_pin_obj_t pin_PB05 = PIN(1, 5, NO_ADC); +const mcu_pin_obj_t pin_PB06 = PIN(1, 6, NO_ADC); + +const mcu_pin_obj_t pin_PB07 = PIN(1, 7, NO_ADC); +const mcu_pin_obj_t pin_PB08 = PIN(1, 8, NO_ADC); +const mcu_pin_obj_t pin_PB09 = PIN(1, 9, NO_ADC); +const mcu_pin_obj_t pin_PD02 = PIN(5, 2, NO_ADC); + +const mcu_pin_obj_t pin_PH00 = PIN(7, 0, NO_ADC); +const mcu_pin_obj_t pin_PH01 = PIN(7, 1, NO_ADC); diff --git a/ports/stm/peripherals/stm32f4/stm32f446xx/pins.h b/ports/stm/peripherals/stm32f4/stm32f446xx/pins.h new file mode 100644 index 0000000000..629dda4623 --- /dev/null +++ b/ports/stm/peripherals/stm32f4/stm32f446xx/pins.h @@ -0,0 +1,90 @@ +/* + * This file is part of the MicroPython project, http://micropython.org/ + * + * The MIT License (MIT) + * + * Copyright (c) 2022 flom84 for Adafruit Industries + * + * Permission is hereby granted, free of charge, to any person obtaining a copy + * of this software and associated documentation files (the "Software"), to deal + * in the Software without restriction, including without limitation the rights + * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell + * copies of the Software, and to permit persons to whom the Software is + * furnished to do so, subject to the following conditions: + * + * The above copyright notice and this permission notice shall be included in + * all copies or substantial portions of the Software. + * + * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR + * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, + * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE + * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER + * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, + * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN + * THE SOFTWARE. + */ + +#ifndef MICROPY_INCLUDED_STM32_PERIPHERALS_STM32F446RE_PINS_H +#define MICROPY_INCLUDED_STM32_PERIPHERALS_STM32F446RE_PINS_H + +// Pins in datasheet order: DocID026289 Rev 7 page 38. LQFP64 only + +extern const mcu_pin_obj_t pin_PC13; +extern const mcu_pin_obj_t pin_PC14; +extern const mcu_pin_obj_t pin_PC15; +extern const mcu_pin_obj_t pin_PC00; +extern const mcu_pin_obj_t pin_PC01; +extern const mcu_pin_obj_t pin_PC02; +extern const mcu_pin_obj_t pin_PC03; + +extern const mcu_pin_obj_t pin_PA00; +extern const mcu_pin_obj_t pin_PA01; +extern const mcu_pin_obj_t pin_PA02; +extern const mcu_pin_obj_t pin_PA03; +extern const mcu_pin_obj_t pin_PA04; +extern const mcu_pin_obj_t pin_PA05; +extern const mcu_pin_obj_t pin_PA06; +extern const mcu_pin_obj_t pin_PA07; + +extern const mcu_pin_obj_t pin_PC04; +extern const mcu_pin_obj_t pin_PC05; +extern const mcu_pin_obj_t pin_PB00; +extern const mcu_pin_obj_t pin_PB01; +extern const mcu_pin_obj_t pin_PB02; + +extern const mcu_pin_obj_t pin_PB10; +extern const mcu_pin_obj_t pin_PB12; +extern const mcu_pin_obj_t pin_PB13; +extern const mcu_pin_obj_t pin_PB14; +extern const mcu_pin_obj_t pin_PB15; + +extern const mcu_pin_obj_t pin_PC06; +extern const mcu_pin_obj_t pin_PC07; +extern const mcu_pin_obj_t pin_PC08; +extern const mcu_pin_obj_t pin_PC09; +extern const mcu_pin_obj_t pin_PA08; +extern const mcu_pin_obj_t pin_PA09; + +extern const mcu_pin_obj_t pin_PA10; +extern const mcu_pin_obj_t pin_PA11; +extern const mcu_pin_obj_t pin_PA12; +extern const mcu_pin_obj_t pin_PA13; +extern const mcu_pin_obj_t pin_PA14; +extern const mcu_pin_obj_t pin_PA15; +extern const mcu_pin_obj_t pin_PC10; +extern const mcu_pin_obj_t pin_PC11; +extern const mcu_pin_obj_t pin_PC12; + +extern const mcu_pin_obj_t pin_PB03; +extern const mcu_pin_obj_t pin_PB04; +extern const mcu_pin_obj_t pin_PB05; +extern const mcu_pin_obj_t pin_PB06; + +extern const mcu_pin_obj_t pin_PB07; +extern const mcu_pin_obj_t pin_PB08; +extern const mcu_pin_obj_t pin_PB09; +extern const mcu_pin_obj_t pin_PD02; +extern const mcu_pin_obj_t pin_PH00; +extern const mcu_pin_obj_t pin_PH01; + +#endif // MICROPY_INCLUDED_STM32F4_PERIPHERALS_STM32F446RE_PINS_H diff --git a/ports/stm/supervisor/internal_flash.h b/ports/stm/supervisor/internal_flash.h index 98c55d30e8..809c263666 100644 --- a/ports/stm/supervisor/internal_flash.h +++ b/ports/stm/supervisor/internal_flash.h @@ -77,6 +77,12 @@ #define INTERNAL_FLASH_FILESYSTEM_START_ADDR 0x08004000 #endif +#ifdef STM32F446xx +#define STM32_FLASH_SIZE 0x80000 // 512KiB +#define INTERNAL_FLASH_FILESYSTEM_SIZE 0xC000 // 48KiB +#define INTERNAL_FLASH_FILESYSTEM_START_ADDR 0x08004000 +#endif + /* Note this applies to STM32F769xG only, STM32F746xE has 512KB */ #ifdef STM32F746xx #define STM32_FLASH_SIZE 0x100000 // 1MB From 2bd2406d134ecd06042bc542f1eb54dba71636fd Mon Sep 17 00:00:00 2001 From: flom84 Date: Mon, 26 Sep 2022 19:39:07 +0200 Subject: [PATCH 24/27] Update license info and remove redundant board functions. --- ports/stm/boards/nucleo_f446re/board.c | 15 ++------------- .../stm/peripherals/stm32f4/stm32f446xx/clocks.h | 2 +- ports/stm/peripherals/stm32f4/stm32f446xx/gpio.c | 2 +- .../stm/peripherals/stm32f4/stm32f446xx/periph.c | 2 +- .../stm/peripherals/stm32f4/stm32f446xx/periph.h | 2 +- ports/stm/peripherals/stm32f4/stm32f446xx/pins.c | 2 +- ports/stm/peripherals/stm32f4/stm32f446xx/pins.h | 2 +- 7 files changed, 8 insertions(+), 19 deletions(-) diff --git a/ports/stm/boards/nucleo_f446re/board.c b/ports/stm/boards/nucleo_f446re/board.c index 31329a8d3b..b75dda3061 100644 --- a/ports/stm/boards/nucleo_f446re/board.c +++ b/ports/stm/boards/nucleo_f446re/board.c @@ -3,7 +3,7 @@ * * The MIT License (MIT) * - * Copyright (c) 2022 flom84 for Adafruit Industries + * Copyright (c) 2022 flom84 * * Permission is hereby granted, free of charge, to any person obtaining a copy * of this software and associated documentation files (the "Software"), to deal @@ -26,15 +26,4 @@ #include "supervisor/board.h" -void board_init(void) { -} - -bool board_requests_safe_mode(void) { - return false; -} - -void reset_board(void) { -} - -void board_deinit(void) { -} +// Use the MP_WEAK supervisor/shared/board.c versions of routines not defined here. diff --git a/ports/stm/peripherals/stm32f4/stm32f446xx/clocks.h b/ports/stm/peripherals/stm32f4/stm32f446xx/clocks.h index fc724fc056..2cd4b59c75 100644 --- a/ports/stm/peripherals/stm32f4/stm32f446xx/clocks.h +++ b/ports/stm/peripherals/stm32f4/stm32f446xx/clocks.h @@ -3,7 +3,7 @@ * * The MIT License (MIT) * - * Copyright (c) 2022 flom84 for Adafruit Industries + * Copyright (c) 2022 flom84 * * Permission is hereby granted, free of charge, to any person obtaining a copy * of this software and associated documentation files (the "Software"), to deal diff --git a/ports/stm/peripherals/stm32f4/stm32f446xx/gpio.c b/ports/stm/peripherals/stm32f4/stm32f446xx/gpio.c index c31c785bf2..624eb319f4 100644 --- a/ports/stm/peripherals/stm32f4/stm32f446xx/gpio.c +++ b/ports/stm/peripherals/stm32f4/stm32f446xx/gpio.c @@ -3,7 +3,7 @@ * * The MIT License (MIT) * - * Copyright (c) 2022 flom84 for Adafruit Industries + * Copyright (c) 2022 flom84 * * Permission is hereby granted, free of charge, to any person obtaining a copy * of this software and associated documentation files (the "Software"), to deal diff --git a/ports/stm/peripherals/stm32f4/stm32f446xx/periph.c b/ports/stm/peripherals/stm32f4/stm32f446xx/periph.c index 666b2be2c2..5287a8bdf0 100644 --- a/ports/stm/peripherals/stm32f4/stm32f446xx/periph.c +++ b/ports/stm/peripherals/stm32f4/stm32f446xx/periph.c @@ -3,7 +3,7 @@ * * The MIT License (MIT) * - * Copyright (c) 2022 flom84 for Adafruit Industries + * Copyright (c) 2022 flom84 * * Permission is hereby granted, free of charge, to any person obtaining a copy * of this software and associated documentation files (the "Software"), to deal diff --git a/ports/stm/peripherals/stm32f4/stm32f446xx/periph.h b/ports/stm/peripherals/stm32f4/stm32f446xx/periph.h index 31ee9be4d4..d34be9d156 100644 --- a/ports/stm/peripherals/stm32f4/stm32f446xx/periph.h +++ b/ports/stm/peripherals/stm32f4/stm32f446xx/periph.h @@ -3,7 +3,7 @@ * * The MIT License (MIT) * - * Copyright (c) 2022 flom84 for Adafruit Industries + * Copyright (c) 2022 flom84 * * Permission is hereby granted, free of charge, to any person obtaining a copy * of this software and associated documentation files (the "Software"), to deal diff --git a/ports/stm/peripherals/stm32f4/stm32f446xx/pins.c b/ports/stm/peripherals/stm32f4/stm32f446xx/pins.c index 23299cb6e8..17176ea72f 100644 --- a/ports/stm/peripherals/stm32f4/stm32f446xx/pins.c +++ b/ports/stm/peripherals/stm32f4/stm32f446xx/pins.c @@ -3,7 +3,7 @@ * * The MIT License (MIT) * - * Copyright (c) 2022 flom84 for Adafruit Industries + * Copyright (c) 2022 flom84 * * Permission is hereby granted, free of charge, to any person obtaining a copy * of this software and associated documentation files (the "Software"), to deal diff --git a/ports/stm/peripherals/stm32f4/stm32f446xx/pins.h b/ports/stm/peripherals/stm32f4/stm32f446xx/pins.h index 629dda4623..c56412a258 100644 --- a/ports/stm/peripherals/stm32f4/stm32f446xx/pins.h +++ b/ports/stm/peripherals/stm32f4/stm32f446xx/pins.h @@ -3,7 +3,7 @@ * * The MIT License (MIT) * - * Copyright (c) 2022 flom84 for Adafruit Industries + * Copyright (c) 2022 flom84 * * Permission is hereby granted, free of charge, to any person obtaining a copy * of this software and associated documentation files (the "Software"), to deal From e626502fd2a0d77b4a5147477c05e6104d271bbd Mon Sep 17 00:00:00 2001 From: flom84 Date: Mon, 26 Sep 2022 19:45:33 +0200 Subject: [PATCH 25/27] Add USB VID and PID from STM. --- ports/stm/boards/nucleo_f446re/mpconfigboard.mk | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/ports/stm/boards/nucleo_f446re/mpconfigboard.mk b/ports/stm/boards/nucleo_f446re/mpconfigboard.mk index 3730729c95..0887578166 100644 --- a/ports/stm/boards/nucleo_f446re/mpconfigboard.mk +++ b/ports/stm/boards/nucleo_f446re/mpconfigboard.mk @@ -1,5 +1,5 @@ -USB_VID = 0x239A -USB_PID = 0x809F +USB_VID = 0x0483 +USB_PID = 0x572A USB_PRODUCT = "NUCLEO-F446RE - CPy" USB_MANUFACTURER = "STMicroelectronics" From 96a83ecbfe4752be13f40fae2b984e501adcb131 Mon Sep 17 00:00:00 2001 From: flom_84 <3575408+flom84@users.noreply.github.com> Date: Mon, 26 Sep 2022 19:58:33 +0200 Subject: [PATCH 26/27] Update mpconfigboard.h --- ports/stm/boards/nucleo_f446re/mpconfigboard.h | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/ports/stm/boards/nucleo_f446re/mpconfigboard.h b/ports/stm/boards/nucleo_f446re/mpconfigboard.h index eb67015c4e..f0155f4624 100644 --- a/ports/stm/boards/nucleo_f446re/mpconfigboard.h +++ b/ports/stm/boards/nucleo_f446re/mpconfigboard.h @@ -3,7 +3,7 @@ * * The MIT License (MIT) * - * Copyright (c) 2022 flom84 for Adafruit Industries + * Copyright (c) 2022 flom84 * * Permission is hereby granted, free of charge, to any person obtaining a copy * of this software and associated documentation files (the "Software"), to deal From 62aa7dfcdb955bffa6320b71e09a092afb3b70a9 Mon Sep 17 00:00:00 2001 From: Jeff Epler Date: Tue, 27 Sep 2022 08:20:44 -0500 Subject: [PATCH 27/27] Revert "pin python version for doc building" This reverts commit 645cb6c2a591c49b9473b6fd182e5acd51b11a68. --- .github/workflows/build.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.github/workflows/build.yml b/.github/workflows/build.yml index 02985212f3..84224a1c1a 100644 --- a/.github/workflows/build.yml +++ b/.github/workflows/build.yml @@ -220,7 +220,7 @@ jobs: - name: Set up Python 3 uses: actions/setup-python@v2 with: - python-version: "3.10.6" + python-version: "3.x" - name: Install dependencies run: | sudo apt-get update