<util/atomic.h> not found on Due

I'm using the RotorHazard (GitHub - RotorHazard/RotorHazard: FPV race timing and event management) arduino code. The code was written for NANO boards and it compiles for this board. However, I own a DUE board and there is an error:

fatal error: util/atomic.h: No such file or directory

What would I have to change in the files for the code to work for the DUE board? I'm assuming some pin numbers should be enough? Thanks in advance.

Welcome to the forum

Your topic title is misleading. I assume that you meant to refer to the Due rather than the Nano. Please change the topic title

Wrong assumption.

Classic Nano boards are AVR based boards, not SAM boards; the include is part of avr-libc and does not exist for SAM based boards like the Due.

A bit of googling might give you some insight and possibly a solution (e.g. util/atomic.h on a ARM - #7 by westfw).

You are right. I had to change some functions to some ARM equivalents.
I changed the atomic blocks to __disable_irq(); and __enable_irq();
I also had to change some EEPROM read/write functions - luckily I found a library for that.
There is still one error but if not for this error it compiles. Then I believe changing the pin numbers should hopefully make it work.

void i2cInitialize(bool delayFlag)
{
    setModuleLed(true);
#if !STM32_MODE_FLAG
    Wire.end();  // release I2C pins (SDA & SCL), in case they are "stuck"
#endif
    if (delayFlag)   // do delay if called via comms monitor
        delay(250);  //  to help bus reset and show longer LED flash
    setModuleLed(false);

    Wire.begin(i2cAddress);  // I2C address setup
    Wire.onReceive(i2cReceive);   // Trigger 'i2cReceive' function on incoming data
    Wire.onRequest(i2cTransmit);  // Trigger 'i2cTransmit' function for outgoing data, on master request

#if !STM32_MODE_FLAG
    TWAR = (i2cAddress << 1) | 1;  // enable broadcasts to be received
#endif
}

The TWAR line throws an error. Am I right in assuming that for Due the Wire.begin() function already takes care of that?

I do not know enough (basically nothing) about the Due.

The general way I2C communication works on the Arduino is that you pass the address of the peripheral in Wire.beginTransmission(address) or in Wire.requestFrom(address, numBytes).

This topic was automatically closed 180 days after the last reply. New replies are no longer allowed.