David_
Advanced Member level 2
Hello.
I do not know much about C/C++ but I am trying to make classes for my data converters that I use with my arduino Due, and why not then put each class in a library.
I want to ask about the following:
Is it any meaning in doing almost nothing in the constructor and then initialize everything in a begin function?
Is there a reason to not put everything that is in MAX5216::begin() into MAX5216::MAX5216(int CSpin)?
Regards
- - - Updated - - -
I am aware of the things I need to do in order to use the SPI library inside my own library.
I do not know much about C/C++ but I am trying to make classes for my data converters that I use with my arduino Due, and why not then put each class in a library.
I want to ask about the following:
Code:
MAX5216::MAX5216(int CSpin)
{
_CSpin = CSpin;
}
void MAX5216::begin()
{
// MAX5216 DAC Setup
// MSB first, shifts data on SCKs falling edge, clock idle Low, SCK freq « 50MHz.
SPI.begin(_CSpin);
SPI.setBitOrder(_CSpin, MSBFIRST);
SPI.setDataMode(_CSpin, SPI_MODE1);
SPI.setClockDivider(_CSpin, 2);
}
Is it any meaning in doing almost nothing in the constructor and then initialize everything in a begin function?
Is there a reason to not put everything that is in MAX5216::begin() into MAX5216::MAX5216(int CSpin)?
Regards
- - - Updated - - -
I am aware of the things I need to do in order to use the SPI library inside my own library.