Merge remote-tracking branch 'origin/main'
This commit is contained in:
commit
6c72ba8b00
@ -579,7 +579,7 @@ msgstr ""
|
||||
|
||||
#: shared-bindings/displayio/Display.c
|
||||
#: shared-bindings/framebufferio/FramebufferDisplay.c
|
||||
#: shared-bindings/is31fl3741/IS31FL3741.c
|
||||
#: shared-bindings/is31fl3741/FrameBuffer.c
|
||||
#: shared-bindings/rgbmatrix/RGBMatrix.c
|
||||
msgid "Brightness must be 0-1.0"
|
||||
msgstr ""
|
||||
@ -1129,6 +1129,13 @@ msgstr ""
|
||||
msgid "Group already used"
|
||||
msgstr ""
|
||||
|
||||
#: ports/atmel-samd/common-hal/busio/SPI.c ports/cxd56/common-hal/busio/SPI.c
|
||||
#: ports/espressif/common-hal/busio/SPI.c
|
||||
#: ports/mimxrt10xx/common-hal/busio/SPI.c ports/nrf/common-hal/busio/SPI.c
|
||||
#: ports/raspberrypi/common-hal/busio/SPI.c
|
||||
msgid "Half duplex SPI is not implemented"
|
||||
msgstr ""
|
||||
|
||||
#: ports/mimxrt10xx/common-hal/busio/SPI.c ports/stm/common-hal/busio/I2C.c
|
||||
#: ports/stm/common-hal/busio/SPI.c ports/stm/common-hal/canio/CAN.c
|
||||
#: ports/stm/common-hal/sdioio/SDCard.c
|
||||
@ -1480,7 +1487,7 @@ msgstr ""
|
||||
msgid "Key must be 16, 24, or 32 bytes long"
|
||||
msgstr ""
|
||||
|
||||
#: shared-module/is31fl3741/IS31FL3741.c
|
||||
#: shared-module/is31fl3741/FrameBuffer.c
|
||||
msgid "LED mappings must match display size"
|
||||
msgstr ""
|
||||
|
||||
@ -1508,7 +1515,7 @@ msgstr ""
|
||||
msgid "MOSI pin init failed."
|
||||
msgstr ""
|
||||
|
||||
#: shared-bindings/is31fl3741/__init__.c
|
||||
#: shared-bindings/is31fl3741/IS31FL3741.c
|
||||
msgid "Mapping must be a tuple"
|
||||
msgstr ""
|
||||
|
||||
@ -2121,7 +2128,7 @@ msgstr ""
|
||||
msgid "Sample rate too high. It must be less than %d"
|
||||
msgstr ""
|
||||
|
||||
#: shared-bindings/is31fl3741/IS31FL3741.c
|
||||
#: shared-bindings/is31fl3741/FrameBuffer.c
|
||||
msgid "Scale dimensions must divide by 3"
|
||||
msgstr ""
|
||||
|
||||
@ -4557,7 +4564,7 @@ msgstr ""
|
||||
msgid "width must be from 2 to 8 (inclusive), not %d"
|
||||
msgstr ""
|
||||
|
||||
#: shared-bindings/is31fl3741/IS31FL3741.c
|
||||
#: shared-bindings/is31fl3741/FrameBuffer.c
|
||||
#: shared-bindings/rgbmatrix/RGBMatrix.c
|
||||
msgid "width must be greater than zero"
|
||||
msgstr ""
|
||||
|
@ -9,5 +9,3 @@ CHIP_FAMILY = samd21
|
||||
INTERNAL_FLASH_FILESYSTEM = 1
|
||||
LONGINT_IMPL = NONE
|
||||
CIRCUITPY_FULL_BUILD = 0
|
||||
|
||||
CIRCUITPY_ONEWIREIO = 0
|
||||
|
@ -9,5 +9,3 @@ CHIP_FAMILY = samd21
|
||||
INTERNAL_FLASH_FILESYSTEM = 1
|
||||
LONGINT_IMPL = NONE
|
||||
CIRCUITPY_FULL_BUILD = 0
|
||||
|
||||
CIRCUITPY_ONEWIREIO = 0
|
||||
|
@ -10,4 +10,5 @@ INTERNAL_FLASH_FILESYSTEM = 1
|
||||
LONGINT_IMPL = NONE
|
||||
CIRCUITPY_FULL_BUILD = 0
|
||||
|
||||
CIRCUITPY_ONEWIREIO = 0
|
||||
# This board has many pins, and we have to remove something else to make room.
|
||||
CIRCUITPY_RAINBOWIO = 0
|
||||
|
@ -9,5 +9,3 @@ CHIP_FAMILY = samd21
|
||||
INTERNAL_FLASH_FILESYSTEM = 1
|
||||
LONGINT_IMPL = NONE
|
||||
CIRCUITPY_FULL_BUILD = 0
|
||||
|
||||
CIRCUITPY_ONEWIREIO = 0
|
||||
|
@ -15,7 +15,6 @@ LONGINT_IMPL = NONE
|
||||
CIRCUITPY_BUSDEVICE = 1
|
||||
CIRCUITPY_DISPLAYIO = 0
|
||||
CIRCUITPY_KEYPAD = 0
|
||||
CIRCUITPY_ONEWIREIO = 0
|
||||
|
||||
# Include these Python libraries in firmware.
|
||||
FROZEN_MPY_DIRS += $(TOP)/frozen/Adafruit_CircuitPython_CircuitPlayground
|
||||
|
@ -9,5 +9,3 @@ CHIP_FAMILY = samd21
|
||||
INTERNAL_FLASH_FILESYSTEM = 1
|
||||
LONGINT_IMPL = NONE
|
||||
CIRCUITPY_FULL_BUILD = 0
|
||||
|
||||
CIRCUITPY_ONEWIREIO = 0
|
||||
|
@ -9,5 +9,3 @@ CHIP_FAMILY = samd21
|
||||
INTERNAL_FLASH_FILESYSTEM = 1
|
||||
LONGINT_IMPL = NONE
|
||||
CIRCUITPY_FULL_BUILD = 0
|
||||
|
||||
CIRCUITPY_ONEWIREIO = 0
|
||||
|
@ -48,7 +48,7 @@ uint8_t display_init_sequence[] = {
|
||||
|
||||
void board_init(void) {
|
||||
busio_spi_obj_t *spi = &displays[0].fourwire_bus.inline_bus;
|
||||
common_hal_busio_spi_construct(spi, &pin_PA01, &pin_PA00, NULL);
|
||||
common_hal_busio_spi_construct(spi, &pin_PA01, &pin_PA00, NULL, false);
|
||||
common_hal_busio_spi_never_reset(spi);
|
||||
|
||||
displayio_fourwire_obj_t *bus = &displays[0].fourwire_bus;
|
||||
|
@ -49,7 +49,7 @@ uint8_t display_init_sequence[] = {
|
||||
|
||||
void board_init(void) {
|
||||
busio_spi_obj_t *spi = &displays[0].fourwire_bus.inline_bus;
|
||||
common_hal_busio_spi_construct(spi, &pin_PA13, &pin_PA12, NULL);
|
||||
common_hal_busio_spi_construct(spi, &pin_PA13, &pin_PA12, NULL, false);
|
||||
common_hal_busio_spi_never_reset(spi);
|
||||
|
||||
displayio_fourwire_obj_t *bus = &displays[0].fourwire_bus;
|
||||
|
@ -54,7 +54,7 @@ uint8_t stop_sequence[] = {
|
||||
|
||||
void board_init(void) {
|
||||
busio_spi_obj_t *spi = &displays[0].fourwire_bus.inline_bus;
|
||||
common_hal_busio_spi_construct(spi, &pin_PB13, &pin_PB15, NULL);
|
||||
common_hal_busio_spi_construct(spi, &pin_PB13, &pin_PB15, NULL, false);
|
||||
common_hal_busio_spi_never_reset(spi);
|
||||
|
||||
displayio_fourwire_obj_t *bus = &displays[0].fourwire_bus;
|
||||
|
@ -98,7 +98,7 @@ uint8_t display_init_sequence[] = {
|
||||
|
||||
void board_init(void) {
|
||||
busio_spi_obj_t *spi = &displays[0].fourwire_bus.inline_bus;
|
||||
common_hal_busio_spi_construct(spi, &pin_PA13, &pin_PA15, NULL);
|
||||
common_hal_busio_spi_construct(spi, &pin_PA13, &pin_PA15, NULL, false);
|
||||
common_hal_busio_spi_never_reset(spi);
|
||||
|
||||
displayio_fourwire_obj_t *bus = &displays[0].fourwire_bus;
|
||||
|
@ -71,7 +71,7 @@ uint8_t display_init_sequence[] = {
|
||||
|
||||
void board_init(void) {
|
||||
busio_spi_obj_t *spi = &displays[0].fourwire_bus.inline_bus;
|
||||
common_hal_busio_spi_construct(spi, &pin_PB13, &pin_PB15, NULL);
|
||||
common_hal_busio_spi_construct(spi, &pin_PB13, &pin_PB15, NULL, false);
|
||||
common_hal_busio_spi_never_reset(spi);
|
||||
|
||||
displayio_fourwire_obj_t *bus = &displays[0].fourwire_bus;
|
||||
|
@ -71,7 +71,7 @@ uint8_t display_init_sequence[] = {
|
||||
|
||||
void board_init(void) {
|
||||
busio_spi_obj_t *spi = &displays[0].fourwire_bus.inline_bus;
|
||||
common_hal_busio_spi_construct(spi, &pin_PB13, &pin_PB15, NULL);
|
||||
common_hal_busio_spi_construct(spi, &pin_PB13, &pin_PB15, NULL, false);
|
||||
common_hal_busio_spi_never_reset(spi);
|
||||
|
||||
displayio_fourwire_obj_t *bus = &displays[0].fourwire_bus;
|
||||
|
@ -66,7 +66,7 @@ uint8_t display_init_sequence[] = {
|
||||
|
||||
void board_init(void) {
|
||||
busio_spi_obj_t *spi = &displays[0].fourwire_bus.inline_bus;
|
||||
common_hal_busio_spi_construct(spi, &pin_PB20, &pin_PB19, NULL);
|
||||
common_hal_busio_spi_construct(spi, &pin_PB20, &pin_PB19, NULL, false);
|
||||
common_hal_busio_spi_never_reset(spi);
|
||||
|
||||
displayio_fourwire_obj_t *bus = &displays[0].fourwire_bus;
|
||||
|
@ -9,5 +9,3 @@ CHIP_FAMILY = samd21
|
||||
INTERNAL_FLASH_FILESYSTEM = 1
|
||||
LONGINT_IMPL = NONE
|
||||
CIRCUITPY_FULL_BUILD = 0
|
||||
|
||||
CIRCUITPY_ONEWIREIO = 0
|
||||
|
@ -11,6 +11,4 @@ LONGINT_IMPL = NONE
|
||||
CIRCUITPY_FULL_BUILD = 0
|
||||
|
||||
# There are many pin definitions on this board; it doesn't quite fit on very large translations.
|
||||
# Remove a couple of modules.
|
||||
CIRCUITPY_ONEWIREIO = 0
|
||||
CIRCUITPY_RAINBOWIO = 0
|
||||
|
@ -9,5 +9,3 @@ CHIP_FAMILY = samd21
|
||||
INTERNAL_FLASH_FILESYSTEM = 1
|
||||
LONGINT_IMPL = NONE
|
||||
CIRCUITPY_FULL_BUILD = 0
|
||||
|
||||
CIRCUITPY_ONEWIREIO = 0
|
||||
|
@ -12,7 +12,6 @@ EXTERNAL_FLASH_DEVICES = AT25SF161
|
||||
LONGINT_IMPL = MPZ
|
||||
|
||||
CIRCUITPY_KEYPAD = 0
|
||||
CIRCUITPY_ONEWIREIO = 0
|
||||
CIRCUITPY_USB_MIDI = 0
|
||||
|
||||
CIRCUITPY_BITBANG_APA102 = 1
|
||||
|
@ -44,7 +44,7 @@
|
||||
|
||||
void common_hal_busio_spi_construct(busio_spi_obj_t *self,
|
||||
const mcu_pin_obj_t *clock, const mcu_pin_obj_t *mosi,
|
||||
const mcu_pin_obj_t *miso) {
|
||||
const mcu_pin_obj_t *miso, bool half_duplex) {
|
||||
Sercom *sercom = NULL;
|
||||
uint8_t sercom_index;
|
||||
uint32_t clock_pinmux = 0;
|
||||
@ -57,6 +57,10 @@ void common_hal_busio_spi_construct(busio_spi_obj_t *self,
|
||||
uint8_t miso_pad = 0;
|
||||
uint8_t dopo = 255;
|
||||
|
||||
if (half_duplex) {
|
||||
mp_raise_NotImplementedError(translate("Half duplex SPI is not implemented"));
|
||||
}
|
||||
|
||||
// Ensure the object starts in its deinit state.
|
||||
self->clock_pin = NO_PIN;
|
||||
|
||||
|
@ -47,6 +47,14 @@ CIRCUITPY_TOUCHIO_USE_NATIVE ?= 1
|
||||
CIRCUITPY_ULAB = 0
|
||||
CIRCUITPY_VECTORIO = 0
|
||||
|
||||
# TODO: In CircuitPython 8.0, turn this back on, after `busio.OneWire` is removed.
|
||||
# We'd like a smoother transition, but we can't afford the space to have both
|
||||
# `busio.OneWire` and `onewireio.OneWire` present on these tiny builds.
|
||||
|
||||
ifeq ($(INTERNAL_FLASH_FILESYSTEM),1)
|
||||
CIRCUITPY_ONEWIREIO ?= 0
|
||||
endif
|
||||
|
||||
MICROPY_PY_ASYNC_AWAIT = 0
|
||||
|
||||
# We don't have room for the fonts for terminalio for ja and ko
|
||||
|
@ -77,11 +77,16 @@ void reset_spi(void) {
|
||||
|
||||
void common_hal_busio_spi_construct(busio_spi_obj_t *self,
|
||||
const mcu_pin_obj_t *clock, const mcu_pin_obj_t *mosi,
|
||||
const mcu_pin_obj_t *miso) {
|
||||
const mcu_pin_obj_t *miso, bool half_duplex) {
|
||||
size_t instance_index = NUM_SPI;
|
||||
BP_Function_Enum clock_alt = 0;
|
||||
BP_Function_Enum mosi_alt = 0;
|
||||
BP_Function_Enum miso_alt = 0;
|
||||
|
||||
if (half_duplex) {
|
||||
mp_raise_NotImplementedError(translate("Half duplex SPI is not implemented"));
|
||||
}
|
||||
|
||||
for (size_t i = 0; i < NUM_SPI; i++) {
|
||||
if (spi_in_use[i]) {
|
||||
continue;
|
||||
|
@ -35,9 +35,13 @@
|
||||
#include "shared-bindings/busio/SPI.h"
|
||||
|
||||
void common_hal_busio_spi_construct(busio_spi_obj_t *self, const mcu_pin_obj_t *clock,
|
||||
const mcu_pin_obj_t *mosi, const mcu_pin_obj_t *miso) {
|
||||
const mcu_pin_obj_t *mosi, const mcu_pin_obj_t *miso, bool half_duplex) {
|
||||
int port = -1;
|
||||
|
||||
if (half_duplex) {
|
||||
mp_raise_NotImplementedError(translate("Half duplex SPI is not implemented"));
|
||||
}
|
||||
|
||||
if (clock->number == PIN_SPI4_SCK &&
|
||||
(mosi == NULL || mosi->number == PIN_SPI4_MOSI) &&
|
||||
(miso == NULL || miso->number == PIN_SPI4_MISO)) {
|
||||
|
@ -57,7 +57,7 @@ void board_init(void) {
|
||||
#endif /* DEBUG */
|
||||
|
||||
busio_spi_obj_t *spi = &displays[0].fourwire_bus.inline_bus;
|
||||
common_hal_busio_spi_construct(spi, &pin_GPIO36, &pin_GPIO35, NULL);
|
||||
common_hal_busio_spi_construct(spi, &pin_GPIO36, &pin_GPIO35, NULL, false);
|
||||
common_hal_busio_spi_never_reset(spi);
|
||||
|
||||
displayio_fourwire_obj_t *bus = &displays[0].fourwire_bus;
|
||||
|
@ -117,7 +117,7 @@ void board_init(void) {
|
||||
#endif /* DEBUG */
|
||||
|
||||
busio_spi_obj_t *spi = &displays[0].fourwire_bus.inline_bus;
|
||||
common_hal_busio_spi_construct(spi, &pin_GPIO36, &pin_GPIO35, NULL);
|
||||
common_hal_busio_spi_construct(spi, &pin_GPIO36, &pin_GPIO35, NULL, false);
|
||||
common_hal_busio_spi_never_reset(spi);
|
||||
|
||||
displayio_fourwire_obj_t *bus = &displays[0].fourwire_bus;
|
||||
|
@ -45,7 +45,7 @@ uint8_t display_init_sequence[] = {
|
||||
|
||||
void board_init(void) {
|
||||
busio_spi_obj_t *spi = &displays[0].fourwire_bus.inline_bus;
|
||||
common_hal_busio_spi_construct(spi, &pin_GPIO7, &pin_GPIO6, NULL);
|
||||
common_hal_busio_spi_construct(spi, &pin_GPIO7, &pin_GPIO6, NULL, false);
|
||||
common_hal_busio_spi_never_reset(spi);
|
||||
|
||||
displayio_fourwire_obj_t *bus = &displays[0].fourwire_bus;
|
||||
|
@ -71,8 +71,8 @@ static void display_init(void) {
|
||||
spi,
|
||||
&pin_GPIO36, // CLK
|
||||
&pin_GPIO35, // MOSI
|
||||
NULL // MISO not connected
|
||||
);
|
||||
NULL, // MISO not connected
|
||||
false); // Not half-duplex
|
||||
|
||||
common_hal_busio_spi_never_reset(spi);
|
||||
|
||||
|
@ -153,8 +153,8 @@ void board_init(void) {
|
||||
spi,
|
||||
&pin_GPIO12, // CLK
|
||||
&pin_GPIO11, // MOSI
|
||||
NULL // MISO not connected
|
||||
);
|
||||
NULL, // MISO not connected
|
||||
false); // Not half-duplex
|
||||
|
||||
common_hal_busio_spi_never_reset(spi);
|
||||
|
||||
|
@ -73,7 +73,7 @@ static void set_spi_config(busio_spi_obj_t *self,
|
||||
|
||||
void common_hal_busio_spi_construct(busio_spi_obj_t *self,
|
||||
const mcu_pin_obj_t *clock, const mcu_pin_obj_t *mosi,
|
||||
const mcu_pin_obj_t *miso) {
|
||||
const mcu_pin_obj_t *miso, bool half_duplex) {
|
||||
|
||||
const spi_bus_config_t bus_config = {
|
||||
.mosi_io_num = mosi != NULL ? mosi->number : -1,
|
||||
@ -83,6 +83,10 @@ void common_hal_busio_spi_construct(busio_spi_obj_t *self,
|
||||
.quadhd_io_num = -1,
|
||||
};
|
||||
|
||||
if (half_duplex) {
|
||||
mp_raise_NotImplementedError(translate("Half duplex SPI is not implemented"));
|
||||
}
|
||||
|
||||
for (spi_host_device_t host_id = SPI2_HOST; host_id < SOC_SPI_PERIPH_NUM; host_id++) {
|
||||
if (spi_bus_is_free(host_id)) {
|
||||
self->host_id = host_id;
|
||||
|
@ -75,13 +75,17 @@ void spi_reset(void) {
|
||||
|
||||
void common_hal_busio_spi_construct(busio_spi_obj_t *self,
|
||||
const mcu_pin_obj_t *clock, const mcu_pin_obj_t *mosi,
|
||||
const mcu_pin_obj_t *miso) {
|
||||
const mcu_pin_obj_t *miso, bool half_duplex) {
|
||||
|
||||
const uint32_t sck_count = MP_ARRAY_SIZE(mcu_spi_sck_list);
|
||||
const uint32_t miso_count = MP_ARRAY_SIZE(mcu_spi_miso_list);
|
||||
const uint32_t mosi_count = MP_ARRAY_SIZE(mcu_spi_mosi_list);
|
||||
bool spi_taken = false;
|
||||
|
||||
if (half_duplex) {
|
||||
mp_raise_NotImplementedError(translate("Half duplex SPI is not implemented"));
|
||||
}
|
||||
|
||||
for (uint i = 0; i < sck_count; i++) {
|
||||
if (mcu_spi_sck_list[i].pin != clock) {
|
||||
continue;
|
||||
|
@ -48,7 +48,7 @@ uint8_t display_init_sequence[] = {
|
||||
|
||||
void board_init(void) {
|
||||
busio_spi_obj_t *spi = &displays[0].fourwire_bus.inline_bus;
|
||||
common_hal_busio_spi_construct(spi, &pin_P0_14, &pin_P0_15, NULL);
|
||||
common_hal_busio_spi_construct(spi, &pin_P0_14, &pin_P0_15, NULL, false);
|
||||
common_hal_busio_spi_never_reset(spi);
|
||||
|
||||
displayio_fourwire_obj_t *bus = &displays[0].fourwire_bus;
|
||||
|
@ -48,7 +48,7 @@ uint8_t display_init_sequence[] = {
|
||||
|
||||
void board_init(void) {
|
||||
busio_spi_obj_t *spi = &displays[0].fourwire_bus.inline_bus;
|
||||
common_hal_busio_spi_construct(spi, &pin_P0_07, &pin_P1_08, NULL); // SCK, MOSI, MISO
|
||||
common_hal_busio_spi_construct(spi, &pin_P0_07, &pin_P1_08, NULL, false); // SCK, MOSI, MISO, not half-duplex
|
||||
common_hal_busio_spi_never_reset(spi);
|
||||
|
||||
displayio_fourwire_obj_t *bus = &displays[0].fourwire_bus;
|
||||
|
@ -49,7 +49,7 @@ uint8_t display_init_sequence[] = {
|
||||
|
||||
void board_init(void) {
|
||||
busio_spi_obj_t *spi = &displays[0].fourwire_bus.inline_bus;
|
||||
common_hal_busio_spi_construct(spi, &pin_P0_11, &pin_P0_12, NULL);
|
||||
common_hal_busio_spi_construct(spi, &pin_P0_11, &pin_P0_12, NULL, false);
|
||||
common_hal_busio_spi_never_reset(spi);
|
||||
|
||||
displayio_fourwire_obj_t *bus = &displays[0].fourwire_bus;
|
||||
|
@ -48,7 +48,7 @@ uint8_t display_init_sequence[] = {
|
||||
|
||||
void board_init(void) {
|
||||
busio_spi_obj_t *spi = &displays[0].fourwire_bus.inline_bus;
|
||||
common_hal_busio_spi_construct(spi, &pin_P0_11, &pin_P0_12, NULL);
|
||||
common_hal_busio_spi_construct(spi, &pin_P0_11, &pin_P0_12, NULL, false);
|
||||
common_hal_busio_spi_never_reset(spi);
|
||||
|
||||
displayio_fourwire_obj_t *bus = &displays[0].fourwire_bus;
|
||||
|
@ -143,7 +143,12 @@ static nrf_spim_frequency_t baudrate_to_spim_frequency(const uint32_t baudrate)
|
||||
return 0;
|
||||
}
|
||||
|
||||
void common_hal_busio_spi_construct(busio_spi_obj_t *self, const mcu_pin_obj_t *clock, const mcu_pin_obj_t *mosi, const mcu_pin_obj_t *miso) {
|
||||
void common_hal_busio_spi_construct(busio_spi_obj_t *self, const mcu_pin_obj_t *clock, const mcu_pin_obj_t *mosi, const mcu_pin_obj_t *miso, bool half_duplex) {
|
||||
|
||||
if (half_duplex) {
|
||||
mp_raise_NotImplementedError(translate("Half duplex SPI is not implemented"));
|
||||
}
|
||||
|
||||
// Find a free instance, with most desirable (highest freq and not shared) allocated first.
|
||||
self->spim_peripheral = NULL;
|
||||
for (size_t i = 0; i < MP_ARRAY_SIZE(spim_peripherals); i++) {
|
||||
|
@ -60,7 +60,7 @@ uint8_t display_init_sequence[] = {
|
||||
|
||||
void board_init(void) {
|
||||
busio_spi_obj_t *spi = &displays[0].fourwire_bus.inline_bus;
|
||||
common_hal_busio_spi_construct(spi, &pin_GPIO26, &pin_GPIO27, NULL);
|
||||
common_hal_busio_spi_construct(spi, &pin_GPIO26, &pin_GPIO27, NULL, false);
|
||||
common_hal_busio_spi_never_reset(spi);
|
||||
|
||||
displayio_fourwire_obj_t *bus = &displays[0].fourwire_bus;
|
||||
|
@ -65,7 +65,7 @@ uint8_t display_init_sequence[] = {
|
||||
|
||||
void board_init(void) {
|
||||
busio_spi_obj_t *spi = &displays[0].fourwire_bus.inline_bus;
|
||||
common_hal_busio_spi_construct(spi, &pin_GPIO6, &pin_GPIO7, NULL);
|
||||
common_hal_busio_spi_construct(spi, &pin_GPIO6, &pin_GPIO7, NULL, false);
|
||||
common_hal_busio_spi_never_reset(spi);
|
||||
|
||||
displayio_fourwire_obj_t *bus = &displays[0].fourwire_bus;
|
||||
|
@ -54,8 +54,13 @@ void reset_spi(void) {
|
||||
|
||||
void common_hal_busio_spi_construct(busio_spi_obj_t *self,
|
||||
const mcu_pin_obj_t *clock, const mcu_pin_obj_t *mosi,
|
||||
const mcu_pin_obj_t *miso) {
|
||||
const mcu_pin_obj_t *miso, bool half_duplex) {
|
||||
size_t instance_index = NO_INSTANCE;
|
||||
|
||||
if (half_duplex) {
|
||||
mp_raise_NotImplementedError(translate("Half duplex SPI is not implemented"));
|
||||
}
|
||||
|
||||
if (clock->number % 4 == 2) {
|
||||
instance_index = (clock->number / 8) % 2;
|
||||
}
|
||||
|
@ -171,7 +171,7 @@ STATIC int check_pins(busio_spi_obj_t *self,
|
||||
|
||||
void common_hal_busio_spi_construct(busio_spi_obj_t *self,
|
||||
const mcu_pin_obj_t *sck, const mcu_pin_obj_t *mosi,
|
||||
const mcu_pin_obj_t *miso) {
|
||||
const mcu_pin_obj_t *miso, bool half_duplex) {
|
||||
|
||||
int periph_index = check_pins(self, sck, mosi, miso);
|
||||
SPI_TypeDef *SPIx = mcu_spi_banks[periph_index - 1];
|
||||
@ -209,7 +209,11 @@ void common_hal_busio_spi_construct(busio_spi_obj_t *self,
|
||||
self->handle.Instance = SPIx;
|
||||
self->handle.Init.Mode = SPI_MODE_MASTER;
|
||||
// Direction change only required for RX-only, see RefMan RM0090:884
|
||||
self->handle.Init.Direction = (self->mosi == NULL) ? SPI_DIRECTION_2LINES_RXONLY : SPI_DIRECTION_2LINES;
|
||||
if (half_duplex) {
|
||||
self->handle.Init.Direction = SPI_DIRECTION_1LINE;
|
||||
} else {
|
||||
self->handle.Init.Direction = (self->mosi == NULL) ? SPI_DIRECTION_2LINES_RXONLY : SPI_DIRECTION_2LINES;
|
||||
}
|
||||
self->handle.Init.DataSize = SPI_DATASIZE_8BIT;
|
||||
self->handle.Init.CLKPolarity = SPI_POLARITY_LOW;
|
||||
self->handle.Init.CLKPhase = SPI_PHASE_1EDGE;
|
||||
@ -224,6 +228,7 @@ void common_hal_busio_spi_construct(busio_spi_obj_t *self,
|
||||
}
|
||||
self->baudrate = (get_busclock(SPIx) / 16);
|
||||
self->prescaler = 16;
|
||||
self->half_duplex = half_duplex;
|
||||
self->polarity = 0;
|
||||
self->phase = 0;
|
||||
self->bits = 8;
|
||||
@ -340,11 +345,13 @@ bool common_hal_busio_spi_write(busio_spi_obj_t *self,
|
||||
|
||||
bool common_hal_busio_spi_read(busio_spi_obj_t *self,
|
||||
uint8_t *data, size_t len, uint8_t write_value) {
|
||||
if (self->miso == NULL) {
|
||||
if (self->miso == NULL && !self->half_duplex) {
|
||||
mp_raise_ValueError(translate("No MISO Pin"));
|
||||
} else if (self->half_duplex && self->mosi == NULL) {
|
||||
mp_raise_ValueError(translate("No MOSI Pin"));
|
||||
}
|
||||
HAL_StatusTypeDef result = HAL_OK;
|
||||
if (self->mosi == NULL) {
|
||||
if ((!self->half_duplex && self->mosi == NULL) || (self->half_duplex && self->mosi != NULL && self->miso == NULL)) {
|
||||
result = HAL_SPI_Receive(&self->handle, data, (uint16_t)len, HAL_MAX_DELAY);
|
||||
} else {
|
||||
memset(data, write_value, len);
|
||||
|
@ -44,6 +44,7 @@ typedef struct {
|
||||
const mcu_periph_obj_t *nss;
|
||||
uint32_t baudrate;
|
||||
uint16_t prescaler;
|
||||
bool half_duplex;
|
||||
uint8_t polarity;
|
||||
uint8_t phase;
|
||||
uint8_t bits;
|
||||
|
@ -74,7 +74,8 @@
|
||||
//|
|
||||
//| :param ~microcontroller.Pin clock: the pin to use for the clock.
|
||||
//| :param ~microcontroller.Pin MOSI: the Main Out Selected In pin.
|
||||
//| :param ~microcontroller.Pin MISO: the Main In Selected Out pin."""
|
||||
//| :param ~microcontroller.Pin MISO: the Main In Selected Out pin.
|
||||
//| :param bool half_duplex: True when MOSI is used for bidirectional data. False when SPI is full-duplex or simplex."""
|
||||
//| ...
|
||||
//|
|
||||
|
||||
@ -84,11 +85,12 @@ STATIC mp_obj_t busio_spi_make_new(const mp_obj_type_t *type, size_t n_args, siz
|
||||
#if CIRCUITPY_BUSIO_SPI
|
||||
busio_spi_obj_t *self = m_new_obj(busio_spi_obj_t);
|
||||
self->base.type = &busio_spi_type;
|
||||
enum { ARG_clock, ARG_MOSI, ARG_MISO };
|
||||
enum { ARG_clock, ARG_MOSI, ARG_MISO, ARG_half_duplex };
|
||||
static const mp_arg_t allowed_args[] = {
|
||||
{ MP_QSTR_clock, MP_ARG_REQUIRED | MP_ARG_OBJ },
|
||||
{ MP_QSTR_MOSI, MP_ARG_OBJ, {.u_obj = mp_const_none} },
|
||||
{ MP_QSTR_MISO, MP_ARG_OBJ, {.u_obj = mp_const_none} },
|
||||
{ MP_QSTR_half_duplex, MP_ARG_OBJ | MP_ARG_KW_ONLY, {.u_bool = false} },
|
||||
};
|
||||
mp_arg_val_t args[MP_ARRAY_SIZE(allowed_args)];
|
||||
mp_arg_parse_all_kw_array(n_args, n_kw, all_args, MP_ARRAY_SIZE(allowed_args), allowed_args, args);
|
||||
@ -101,7 +103,7 @@ STATIC mp_obj_t busio_spi_make_new(const mp_obj_type_t *type, size_t n_args, siz
|
||||
mp_raise_ValueError(translate("Must provide MISO or MOSI pin"));
|
||||
}
|
||||
|
||||
common_hal_busio_spi_construct(self, clock, mosi, miso);
|
||||
common_hal_busio_spi_construct(self, clock, mosi, miso, args[ARG_half_duplex].u_bool);
|
||||
return MP_OBJ_FROM_PTR(self);
|
||||
#else
|
||||
mp_raise_ValueError(translate("Invalid pins"));
|
||||
|
@ -38,7 +38,7 @@ extern const mp_obj_type_t busio_spi_type;
|
||||
// Construct an underlying SPI object.
|
||||
extern void common_hal_busio_spi_construct(busio_spi_obj_t *self,
|
||||
const mcu_pin_obj_t *clock, const mcu_pin_obj_t *mosi,
|
||||
const mcu_pin_obj_t *miso);
|
||||
const mcu_pin_obj_t *miso, bool half_duplex);
|
||||
|
||||
extern void common_hal_busio_spi_deinit(busio_spi_obj_t *self);
|
||||
extern bool common_hal_busio_spi_deinited(busio_spi_obj_t *self);
|
||||
|
@ -131,7 +131,7 @@ mp_obj_t common_hal_board_create_spi(const mp_int_t instance) {
|
||||
assert_pin_free(spi_pin[instance].mosi);
|
||||
assert_pin_free(spi_pin[instance].miso);
|
||||
|
||||
common_hal_busio_spi_construct(self, spi_pin[instance].clock, spi_pin[instance].mosi, spi_pin[instance].miso);
|
||||
common_hal_busio_spi_construct(self, spi_pin[instance].clock, spi_pin[instance].mosi, spi_pin[instance].miso, false);
|
||||
|
||||
spi_obj_created[instance] = true;
|
||||
return &spi_obj[instance];
|
||||
|
@ -149,7 +149,7 @@ void spi_flash_init(void) {
|
||||
common_hal_digitalio_digitalinout_never_reset(&cs_pin);
|
||||
|
||||
supervisor_flash_spi_bus.base.type = &busio_spi_type;
|
||||
common_hal_busio_spi_construct(&supervisor_flash_spi_bus, SPI_FLASH_SCK_PIN, SPI_FLASH_MOSI_PIN, SPI_FLASH_MISO_PIN);
|
||||
common_hal_busio_spi_construct(&supervisor_flash_spi_bus, SPI_FLASH_SCK_PIN, SPI_FLASH_MOSI_PIN, SPI_FLASH_MISO_PIN, false);
|
||||
common_hal_busio_spi_never_reset(&supervisor_flash_spi_bus);
|
||||
|
||||
return;
|
||||
|
@ -163,7 +163,8 @@ void status_led_init() {
|
||||
common_hal_busio_spi_construct(&status_apa102,
|
||||
MICROPY_HW_APA102_SCK,
|
||||
MICROPY_HW_APA102_MOSI,
|
||||
NULL);
|
||||
NULL,
|
||||
false);
|
||||
#endif
|
||||
#if CIRCUITPY_BITBANG_APA102
|
||||
shared_module_bitbangio_spi_try_lock(&status_apa102);
|
||||
|
Loading…
Reference in New Issue
Block a user