add half_duplex to spi constructs in other ports but raise not implemented errors

This commit is contained in:
Scott Gauche 2022-02-08 22:25:23 -05:00
parent 3b418dbddc
commit 89ad767b8f
8 changed files with 50 additions and 12 deletions

View File

@ -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 ""

View File

@ -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 == true) {
mp_raise_NotImplementedError(translate("Half duplex SPI is not implemented"));
}
// Ensure the object starts in its deinit state.
self->clock_pin = NO_PIN;

View File

@ -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 == true) {
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;

View File

@ -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 == true) {
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)) {

View File

@ -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 == true) {
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;

View File

@ -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 == true) {
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;

View File

@ -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 == true) {
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++) {

View File

@ -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 == true) {
mp_raise_NotImplementedError(translate("Half duplex SPI is not implemented"));
}
if (clock->number % 4 == 2) {
instance_index = (clock->number / 8) % 2;
}