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

setDataMode inline and non-inline #36

Open
bkubicek opened this issue Oct 15, 2018 · 0 comments
Open

setDataMode inline and non-inline #36

bkubicek opened this issue Oct 15, 2018 · 0 comments

Comments

@bkubicek
Copy link

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

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant