> When the SPI stuff would be in the user program all programs using the > max7219 library would have to be changed.
Are there currently a lot of things using the max7219 lib? If not, I don't see why things would have to be changed. Here's my use for this... lets look at 18f4620_mp3_decoder_vs1053b_sd_card.jal - vs1053b uses fat32, - fat32 uses sd card - sd card uses SPI. - output is serial_hw Currently, you could use the same main sample code for different possibilities. - use a hard disk instead of sd card - use fat32_small instead of fat32 - use spi_sw instead of spi_hw - use serial_sw instead of serial_hw. - Also, I would have liked to have fat32 easily swapped with Minix. - If there were other mp3 decoders, maybe they could be swapped as well. All with no change to the main sample code. Another added benefit for me is sample generation, since each bit can be changed without affecting the main sample code. Matt. > Date: Mon, 25 Aug 2014 21:28:41 +0200 > From: [email protected] > To: [email protected] > Subject: Re: [jallib] r3570 committed - Added forgotten max7219_common library > > > > 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 a topic in the Google > Groups "jallib" group. > To unsubscribe from this topic, visit > https://groups.google.com/d/topic/jallib/8YKBol8LKJI/unsubscribe. > To unsubscribe from this group and all its topics, 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. -- 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.
