enableInterrupts gives error on teensy 3.2
I'm newbe in programming i try to compile simple TeensyLoadcell by https://github.com/luni64/TeensyLoadcell
it keeps giving me an error can you please help?
void enableInterrupts(void (*isr)(void), uint8_t priority = 255);
^
C:\Program Files (x86)\Arduino\hardware\teensy\avr\libraries\ADC/ADC_Module.h:184:10: note: candidate expects 2 arguments, 0 provided
Error compiling for board Teensy 3.2 / 3.1.
`#include "ADC.h" #include "TeensyLoadcell.h" using namespace TeensyLoadcell;
ADC adc; Loadcell loadcell(adc.adc0);
void setup(){ loadcell.start(); }
void loop(){ Serial.println(loadcell.getValue()); delay(100); }`
`#include "TeensyLoadcell.h" #include "ADC.h"
#if ADC_USE_PGA == 0 #error "Board has no PGA" #endif
namespace TeensyLoadcell { static Loadcell *activeLCO[2]; // will point to current Loadcell objects, the pointers are required by the ISR to access the object
// ISR, Read values and calculate exponential average.
template
//----------------------------------------------------------------------------------
Loadcell::Loadcell(ADC_Module *adc, float tau, Gain gain, unsigned sampleFreq) { this->adc = adc; this->sampleFreq = sampleFreq;
pinP = adc->ADC_num == 0 ? A10 : A12;
pinN = adc->ADC_num == 0 ? A11 : A13;
pinMode(pinP, INPUT);
pinMode(pinN, INPUT);
adc->setAveraging(32);
adc->setResolution(13);
adc->setConversionSpeed(ADC_CONVERSION_SPEED::HIGH_SPEED);
adc->setSamplingSpeed(ADC_SAMPLING_SPEED::HIGH_SPEED);
adc->setReference(ADC_REFERENCE::REF_1V2);
adc->enablePGA(gain);
c0 = 0.0f;
c1 = 1.0f;
setTau(tau);
}
//-----------------------------------------------------------------
Loadcell::~Loadcell() { stop(); }
//-----------------------------------------------------------------
void Loadcell::start() {
// attach correct ISR depending on ADC module number
if (adc->ADC_num == 0)
{
activeLCO[0] = this;
attachInterruptVector(IRQ_ADC0, Loadcell_ISR<0>);
}
else
{
activeLCO[1] = this;
attachInterruptVector(IRQ_ADC1, Loadcell_ISR<1>);
}
average = 0.0f;
adc->stopPDB();
adc->startSingleDifferential(pinP, pinN);
adc->enableInterrupts();
adc->startPDB(sampleFreq);
}
//-----------------------------------------------------------------
void Loadcell::stop() { adc->stopPDB(); adc->disableInterrupts(); activeLCO[adc->ADC_num] = nullptr; }
//-----------------------------------------------------------------
void Loadcell::setTau(float tau) { if (tau <= 0.0f) { alpha = 1.0f; } else { alpha = 1 - expf(-1.0f / (tau * sampleFreq)); //https://en.wikipedia.org/wiki/Exponential_smoothing } }
//-----------------------------------------------------------------
void Loadcell::tare() { c0 = average; }
} // namespace TeensyLoadcell
#pragma once
#include "ADC.h"
namespace TeensyLoadcell { enum Gain : uint8_t { gain_1 = 1, gain_2 = 2, gain_4 = 4, gain_8 = 8, gain_16 = 16, gain_32 = 32, gain_64 = 64 };
class Loadcell { public: // Constructor, tau is the smoothing time constant in seconds. Loadcell(ADC_Module *adc, float tau = 1.0, Gain gain = gain_64, unsigned sampleFreq = 5000u); ~Loadcell();
/* Starts continous background conversion.*/
void start();
/*Stops background conversions*/
void stop();
/* Gets the averaged, calibrated value. Calibration coefficients can be set by setCalib(c0, c1) */
inline float getValue() { return (average - c0) * c1; }
// set the smoothing time constant in seconds. Values will be stable after about 5* tau.
void setTau(float tau);
// tares the load cell (sets c0 such that getValue() returns 0 )
void tare();
// calibration factors. getValue() returns "(average-c0) * c1"
float c0 = 0.0f, c1 = 1.0f;
// delete copy constructor
Loadcell(const Loadcell &) = delete;
protected: ADC_Module *adc; volatile float average = 0.0f; // current averaged measurement value uint8_t pinP, pinN; // used input pin pair
float alpha; // smoothing factor
unsigned sampleFreq; // used sample frequency for the PDB
template<unsigned n> friend void Loadcell_ISR(); // let the ADC ISR update the measurement value (average)
};
} // namespace TeensyLoadcell`
That library is using an old version of this library. Some function calls are different.for example adc->adc0->enableInterrupts(); has become now adc->enableInterrupts(adc0_isr);, so you need to pass the isr directly. You can try to fix it yourself or ask the owner of that lib.