Skip to content

HAL - creating new SPI/SPIslave invokes format() and freq() twice #935

Closed
@0xc0170

Description

@0xc0170

Format and frequency is set 2x when new SPI object is created.

From SPI ctor:

    spi_init(&_spi, mosi, miso, sclk, NC);
    spi_format(&_spi, _bits, _mode, 0);
    spi_frequency(&_spi, _hz);

And in the spi_init() for most targets:

    // set default format and frequency
    if (ssel == NC) {
        spi_format(obj, 8, 0, 0);  // 8 bits, mode 0, master
    } else {
        spi_format(obj, 8, 0, 1);  // 8 bits, mode 0, slave
    }
    spi_frequency(obj, 1000000);

This is a result of a PR #930 which was closed as ssel argument for SPI/SPISlave is not properly used. The main problem is to use ssel parameter in the HAL as slave/master selector.

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions