I am tring to create a class that setsup the ADC, A Timer and so...
I am tring to create also a class that for example turns a LED on, or off using methods.
The problem is that it does not compile for the arduino.
It says that there is a problem with the method like ADC, when I am tring to use it.
I have tried to include different headers but it didnt work.
please help.
For example: Header file
class SetupClass
{
public:
SetupClass();
~SetupClass();
int Calculate_Register_Value(int Desired_Freq);
void ADC_Timer();
void ADC();
void DAC(int Resolution);
void Serial_Timer();
private:
};
Then let look at the CPP
void SetupClass::ADC()
{
PMC->PMC_PCER1 |= PMC_PCER1_PID37; // ADC power on
ADC->ADC_CR = ADC_CR_SWRST; // Reset ADC
NVIC_EnableIRQ(ADC_IRQn); // enable ADC interrupt vector
ADC->ADC_IDR = 0xFFFFFFFF; // Disables all interrupts
ADC->ADC_IER = 0x80; // Enable End-Of-Conversion interrupt on Channel 7 -> A0
ADC->ADC_CHDR = 0xFFFFFFFF; // Disables all channels
ADC->ADC_CHER = 0x80; // Enable channel 7
ADC->ADC_MR = ADC->ADC_MR & 0xFFFFFFF0; // Disable Trigers | 4 lowesr bits of ADC_MR
ADC->ADC_MR = ADC->ADC_MR | 0x2; // TRGEN on => External trigger
ADC->ADC_MR = ADC->ADC_MR | 0x1; // TIOA Output of the Timer Counter Channel 0
ADC->ADC_MR = ADC->ADC_MR & 0xFFFFFFEF; // 12-bit resolution
}
Then in the Arduino IDE:
SetupClass Setup;
void setup()
{
Setup.ADC(); // Here is a problem and I dont know why.
}
I have tried to include many files like:
#include "Arduino.h"
#include "wiring_analog.h"
#include "wiring_digital.h"
#include "ControlClass.h"
#include "pmc.h"
#include "component_adc.h"
#include "tc.h"
#include "wiring_constants.h"
#include "dac.h"
#include "pins_arduino.h"