Hi Matt,

2011/3/27 mattschinkel <[email protected]>

> Someday we all need to decide on either using the same library twice,
> or create a 2nd library. A preprocessor doesn't seem like the right
> solution. Again, pointers would be nice.
>

Pointers won't help here, except if you want to use both MSSP at the same
time. I don't think it's even doable, IIRC when there are two MSSP modules,
one can be used for I²C, the other for SPI, but not both for I²C/SPI. This
makes sense anyway since both those protocols are addressable (sort of for
SPI, using chip select).

The question is still available for serial_hardware, when you have 2 EUART
and would use both modules...


>
> Maybe you can ask William if you can add a optional constant for
> choosing what SPI port to use (after you test with ENC28J60 of
> course).


If MSSP related variables weren't aliases of MSSP1 in device files, we would
have default MSSP1 to MSSP within SPI lib. In this case user could have the
choice to define his own MSSP aliases (pointing to the second module) before
including spi lib. For now, we can change MSSP variable names used in SPI
lib, and default to MSSP1:

-- spi_master_hw_.jal
-- for SSPBUF
if !defined(_SSPBUF) then
   alias _SSPBUF is SSP1BUF -- explicitely select MSSP1, with "1", even if
an alias exists, if better readable
end if
etc...

spi_master_hw.jal should now uses _SSPBUF insteand of variable SSPBUF

-- user code
alias _SSPBUF is SSP2BUF
etc...
include spi_master_hw

Unfortunately we can't put these aliases within a procedure, because we
can't declare global aliases from within a procedure's body. But we can add
(yet another) constant, within another library (not spi_master_hw, as MSSP2
could be used elsewhere, like slave ??)

if defined(SPI_USE_MSSP2) then
   alias _SSPBUF is SSP2BUF
   etc...
end if

I'll modify spi_master_hw.jal to check if it works with MSSP2, manually
modifying variables to point to this module. If so, we'll see how we can
deal with this.

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