Hi Matt,

2011/5/8 mattschinkel <[email protected]>
>
> One case for example: if you wish to store web pages on a sd card +
> use enc28j60 for networking. sd card is spi mode 11, enc28j60 is spi
> mode 00
>

OK, I understand different devices may need different modes, but one device
will use one, and only one mode. As in SD card. For this reason, a library
using SPI lib should use set_mode_00, _01, _10, or _11, that is, one of the
four inlined procedure.

This means the other procedure, set_mode(mode) -- taking mode as parameter
--, won't be used elsewhere than from spi_init() procedure, called once.
>From this perspective, it should remain inlined... yet seperated just in
case :)


>
> Any single device will only need one SPI mode. The above need for
> changing SPI modes is real for me, and therefore I cannot use Williams
> MAC eeprom ee_25aa02e48.jal library with sd card + enc28j60 unless I
> manually set mode in my sample every time I wish to read or write to
> 25aa02e48. This should be taken care of in the library, not the
> sample.
>

OK


>
> So, for me, spi_master_hw_set_mode() should not be inline unless the
> compiler can take care of the if statements through the constant
> input.
>

Well, if you're calling set_mode(mode), with always the same mode, and use
-const-detect, then you should have the same result as when using
set_mode_XX().

As you're using two different modes, I don't know if the compiler is able to
keep these 2 modes in "if" cases, and optimize away the unused two others.

That said, according to what William and you are saying, using set_mode_XX()
in libs should be enough, so no need to use set_mode(mode). Right ?


>
> Personally, I think all devices libraries that use SPI should contain
> the following:
>
>   -- put spi into mode 11 for device
>   if SD_ALWAYS_SET_SPI_MODE == TRUE then
>       spi_master_set_mode(SPI_MODE_11)
>    end if
>

this one is potentially much more resource consuming (memory + stack)
than...


>
> OR
>
>   -- put spi into mode 11 for device
>   if SD_ALWAYS_SET_SPI_MODE == TRUE then
>       spi_master_set_mode_11()
>    end if
>
>
... this one.



Cheers,
Seb

-- 
You received this message because you are subscribed to the Google Groups 
"jallib" group.
To post to this group, send email to [email protected].
To unsubscribe from this group, send email to 
[email protected].
For more options, visit this group at 
http://groups.google.com/group/jallib?hl=en.

Reply via email to