On 25.08.14 17:23, Matthew Schinkel wrote:
> I'll try to let the max7219 libraries use either the master_spi_hw or
the master_spi_sw library.
It sounds like you are trying to put the SPI definitions/include in your
library, but I think it should go in your sample files.Think of SPI
like Serial, where we define speed, pins, etc in our sample. The code I
gave you is to put in your sample, and can be easily switched out
between software/hardware by the user.
Indeed I specify the SPI stuff in the max721 libraries.
In my view a library should hide the use of an included library to the
user (as good as possible). It is the responsibility of the 'high' level
library to use the 'low' level library the right way for its specific
purpose.
It is a bit theoretical but assume that the max7219 library would be
refactored and would replace the SPI library by another library. When
the SPI stuff would be in the user program all programs using the
max7219 library would have to be changed.
With the device files it is our goal to limit the device dependency as
much as possible so that it is easy to switch from one to another PIC.
Similarly the use of a library should be as independent from included
libraries as much as possible.
I think me and Seb had decided on the current implementation. Again,
look at serial, which has similar inconsistencies. These are fixed with
alias.
alias spi_master is spi_master_sw
or
alias spi_master is spi_master_hw
Aha, good idea (why didn't I think of that myself ;-)
As for the init procedure, they could be renamed, what do you suggest?
spi_sw_init() and spi_hw_init()? Using different procedure names gives
the possibility of using both libs at the same time. For example, if two
chips use different SPI modes and speed is a concern. Of course the mode
can be changed in the middle of a sample, hence the constant in SD_CARD
lib and others. There are if defined statements in libs for this. You
might want to look at sd_card lib/sample. Init is called in the samples.
I'll have a look. Maybe it changes my view!
Regards, Rob.
--
R. Hamerling, Netherlands --- http://www.robh.nl
--
You received this message because you are subscribed to the Google Groups
"jallib" group.
To unsubscribe from this group and stop receiving emails from it, send an email
to [email protected].
To post to this group, send email to [email protected].
Visit this group at http://groups.google.com/group/jallib.
For more options, visit https://groups.google.com/d/optout.