Skip to content

SPI::transfer is defined in spi.h and spi.cpp #15160

@JojoS62

Description

@JojoS62

Description of defect

while examing problems with the current SPI implementation in #15115, I found that SPI::transfer is defined twice. Is this intended or is just not removed during compiling?

The transfer function is declared as template including code:

template<typename Type>
int transfer(const Type *tx_buffer, int tx_length, Type *rx_buffer, int rx_length, const event_callback_t &callback, int event = SPI_EVENT_COMPLETE)
{
if (spi_active(&_peripheral->spi)) {
return queue_transfer(tx_buffer, tx_length, rx_buffer, rx_length, sizeof(Type) * 8, callback, event);
}
start_transfer(tx_buffer, tx_length, rx_buffer, rx_length, sizeof(Type) * 8, callback, event);
return 0;
}

And also as code in :

int SPI::transfer(const void *tx_buffer, int tx_length, void *rx_buffer, int rx_length, unsigned char bit_width, const event_callback_t &callback, int event)
{
if (spi_active(&_peripheral->spi)) {
return queue_transfer(tx_buffer, tx_length, rx_buffer, rx_length, bit_width, callback, event);
}
start_transfer(tx_buffer, tx_length, rx_buffer, rx_length, bit_width, callback, event);
return 0;
}

I can remove the code from SPI.cpp and it still compiles fine because its created from the header.

Target(s) affected by this defect ?

Targets with ASYNC_SPI

Toolchain(s) (name and version) displaying this defect ?

gcc 10.2.1

What version of Mbed-os are you using (tag or sha) ?

mbed-os-6.15.0

What version(s) of tools are you using. List all that apply (E.g. mbed-cli)

mbed-tools 7.44.0

How is this defect reproduced ?

with code that uses SPI.transfer()

Metadata

Metadata

Assignees

No one assigned

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions