Dear Arduino Community,
I would kindly like to ask for your help on this conundrum that I face. My sketch used to work perfectly on a previous version of IDE, but after upgrading it to IDE 1.6.5-r5-windows, my sketch does not even compile.
The problem seems to be with a function that returns a structure. Once I comment this out it works fine.
Please see below the problematic function:
typedef struct{
uint16_t bin0;
uint16_t bin1;
uint16_t bin2;
uint16_t bin3;
uint16_t bin4;
uint16_t bin5;
uint16_t bin6;
uint16_t bin7;
uint16_t bin8;
uint16_t bin9;
uint16_t bin10;
uint16_t bin11;
uint16_t bin12;
uint16_t bin13;
uint16_t bin14;
uint16_t bin15;
// Mass Time-of-Flight
float bin1MToF;
float bin3MToF;
float bin5MToF;
float bin7MToF;
// Sample Flow Rate
float sfr;
// Either the Temperature or Pressure
unsigned long temp_pressure;
// Sampling Period
float period;
// Checksum
unsigned int checksum;
float pm1;
float pm25;
float pm10;
}HistogramData;
HistogramData hist;
void setup() {
// put your setup code here, to run once:
}
void loop() {
// put your main code here, to run repeatedly:
hist= read_histogram();
}
HistogramData read_histogram()
{
// Read the Histogram Data and reset the histogram, return the struct
// $ alpha.read_histogram()
HistogramData data;
byte vals[62];
// Read the data and clear the local memory
digitalWrite(SS, LOW); // Pull the SS Low
SPI.transfer(0x30); // Transfer the command byte
digitalWrite(SS, HIGH);
delay(12); // Delay for 12 ms
// Send commands and build array of data
digitalWrite(SS, LOW);
for (int i = 0; i < 62; i++){
vals[i] = SPI.transfer(0x30);
delayMicroseconds(4);
}
digitalWrite(SS, HIGH); // Pull the SS High
data.period = _calculate_float(vals[44], vals[45], vals[46], vals[47]);
data.sfr = _calculate_float(vals[36], vals[37], vals[38], vals[39]);
// Calculate all of the values!
data.bin0 = _16bit_int(vals[0], vals[1]);
data.bin1 = _16bit_int(vals[2], vals[3]);
data.bin2 = _16bit_int(vals[4], vals[5]);
data.bin3 = _16bit_int(vals[6], vals[7]);
data.bin4 = _16bit_int(vals[8], vals[9]);
data.bin5 = _16bit_int(vals[10], vals[11]);
data.bin6 = _16bit_int(vals[12], vals[13]);
data.bin7 = _16bit_int(vals[14], vals[15]);
data.bin8 = _16bit_int(vals[16], vals[17]);
data.bin9 = _16bit_int(vals[18], vals[19]);
data.bin10 = _16bit_int(vals[20], vals[21]);
data.bin11 = _16bit_int(vals[22], vals[23]);
data.bin12 = _16bit_int(vals[24], vals[25]);
data.bin13 = _16bit_int(vals[26], vals[27]);
data.bin14 = _16bit_int(vals[28], vals[29]);
data.bin15 = _16bit_int(vals[30], vals[31]);
return data;
}
The problem arises when I define this function. Do you have any idea what could be the source of this problem??
Please also find attached the complete code.
Looking forward for your insight!
Thank you,
Panayiota.