Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

SPI Frequency change limits not reflected on Espressif port #7593

Closed
gamblor21 opened this issue Feb 16, 2023 · 0 comments · Fixed by #7963
Closed

SPI Frequency change limits not reflected on Espressif port #7593

gamblor21 opened this issue Feb 16, 2023 · 0 comments · Fixed by #7963
Assignees
Labels
bug busio espressif applies to multiple Espressif chips
Milestone

Comments

@gamblor21
Copy link
Member

CircuitPython version

Adafruit CircuitPython 8.0.0-beta.6

Code/REPL

import displayio
import board
import busio

displayio.release_displays()

FREQ = 80_000_000
spi = board.SPI()
spi.try_lock()
spi.configure(baudrate=FREQ)
spi.unlock()

Behavior

The frequency returned will always be what the baudrate parameter was, even if the bus could not be set to that frequency.

Description

spi.frequency always returns the value it was set to, even if that value was not achieved.

From set_spi_config in /ports/espressif/common-hal/busio/SPI.c

...
    esp_err_t result = spi_bus_add_device(self->host_id, &device_config, &spi_handle[self->host_id]);
    if (result != ESP_OK) {
        mp_raise_RuntimeError(translate("SPI configuration failed"));
    }
    self->baudrate = baudrate;
...

Instead of setting the baudrate calling spi_device_get_actual_freq function could be used to calculate the actual frequency the bus was set to.

Additional information

No response

@gamblor21 gamblor21 added bug espressif applies to multiple Espressif chips busio labels Feb 16, 2023
@dhalbert dhalbert added this to the 8.1.0 milestone Feb 16, 2023
@dhalbert dhalbert self-assigned this Apr 14, 2023
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug busio espressif applies to multiple Espressif chips
Projects
None yet
Development

Successfully merging a pull request may close this issue.

2 participants