I need to compare what DMASetting I currently working with from the DMAChannel I have. Below is a simple example that does nothing but will give the error of: no match "operator =="
What I did was add Relation Operator Overloading to DMAChannel.h, but don't like my implementation. I was wondering if any the c++ gurus would have an idea how to do this correctly?
Added to DMAChannel.h:
If i just compare TCD structs for the DMAChannel and DMASetting they do not compare right, so I'm thinking that DMASetting doesn't inherent all the TCD parts so the compare "==" fails but if I just compare the Source Address "SADDR" or Destination Address "DADDR" it works which make sense. I guess I need to dig into what TCD parameters gets copied into DMASettings and what TCD parameters get copied into DMAChannel?
Code:
#include "DMAChannel.h"
DMAChannel DMA;
DMASetting ALT1;
DMASetting ALT2;
uint8_t inbuffer1;
uint8_t inbuffer2;
uint8_t outbuffer1;
uint8_t outbuffer2;
void setup() {
pinMode(LED_BUILTIN, OUTPUT);
while (!Serial);
delay(1000);
Serial.println("Start");
ALT1.source( inbuffer1 );
ALT2.source( inbuffer2 );
ALT1.destination( outbuffer1);
ALT2.destination( outbuffer2);
ALT1.interruptAtCompletion( );
ALT2.interruptAtCompletion( );
ALT1.replaceSettingsOnCompletion( ALT2 );
ALT2.replaceSettingsOnCompletion( ALT1 );
DMA = ALT1;
}
void loop() {
if (DMA == ALT1) Serial.println("True");[COLOR=#B22222]// errors here[/COLOR]
else Serial.println("False");
delay(1000);
}
What I did was add Relation Operator Overloading to DMAChannel.h, but don't like my implementation. I was wondering if any the c++ gurus would have an idea how to do this correctly?
Added to DMAChannel.h:
Code:
bool operator == (const DMASetting &rhs) const {
if (this->TCD->SADDR == rhs.TCD->SADDR) return true;
else return false;
}