Skip to content

SPI byte order looks suspicious #1858

Closed
@Cross22

Description

@Cross22

Comparing SPI.setBitOrder() and transfer16() they seem to be contradicting each other. Based on the espressif docs I think the transfer16() implementation is wrong.

void SPIClass::setBitOrder(uint8_t bitOrder) {
if(bitOrder == MSBFIRST) {
SPI1C &= ~(SPICWBO | SPICRBO);
} else {
SPI1C |= (SPICWBO | SPICRBO);
}
}

uint16_t SPIClass::transfer16(uint16_t data) {
....
if((SPI1C & (SPICWBO | SPICRBO))) {
//MSBFIRST
out.msb = transfer(in.msb);
out.lsb = transfer(in.lsb);
} else {
//LSBFIRST
out.lsb = transfer(in.lsb);
out.msb = transfer(in.msb);
}
....
}

Metadata

Metadata

Assignees

No one assigned

    Type

    No type

    Projects

    No projects

    Milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions