Skip to content

setDataMode inline and non-inline #36

Description

@bkubicek

Hi,
in the header file line 290 there is:
inline static void setDataMode(uint8_t dataMode) {
SPCR = (SPCR & ~SPI_MODE_MASK) | dataMode;
}
however the same function is also used in the cpp file, without the core SPCR activity:

void SPIClass::setDataMode(uint8_t dataMode)
{
hardware().clock_gate_register |= hardware().clock_gate_mask;
//uint32_t ctar = port().CTAR0;

// TODO: implement with native code
//SPCR = (SPCR & ~SPI_MODE_MASK) | dataMode;

}

I find it quite strange, that there is both an inline and a non-inline function with the same name.
At least on my system windows 10, Arduino 1.8.1 teensyduino 1.4.1 calling setDataMode had no effect at all. I assume without proof it was calling the non-inline version which does not set SPCR.

My proposal would be to remove the non-inline version, and maybe add the hardware().clock_gate line to the inline version if necessary, or make it non-inline.

My personal workaround was to use the transactions stuff, but really without any complaints to the maintainer, it cost me two days to find the reason why my pcb worked with an old arduino version, and failed with a newer one. Thanks to logic tester i finally found that the data mode was set, but the statement had no effect. I know how crappy the job of maintaining something like this is, all the work that went in so far is highly appreciated.

thanks a lot & very nice greetings,
Bernhard Kubicek

Activity

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions