I will most likely make the above change you requested. Hopefully all
SPI libs can have the same standards.

William, do you agree that if you are always using the same mode/
speed, the mode/speed variables should indeed be constant? Although
API would be affected, I wish for you to think about what is best in
the long run.

As previously mentioned, the init procedure currently takes "byte in
mode", "byte in rate" (these variables take up space), but it could
be:

-- in sample
const byte SPI_SET_RATE = SPI_RATE_FOSC_4
const byte SPI_SET_MODE = SPI_MODE_11
spi_init()

-- in lib
procedure spi_init() is
   pragma inline

   SSPCON = 0
   SSPSTAT_SMP = 0

   if spi_mode == SPI_MODE_00 then
      SSPCON_CKP = 0
      SSPSTAT_CKE = 1
   elsif spi_mode == SPI_MODE_01 then
      SSPCON_CKP = 0
      SSPSTAT_CKE = 0
   elsif spi_mode == SPI_MODE_10 then
      SSPCON_CKP = 1
      SSPSTAT_CKE = 1
   else
      SSPCON_CKP = 1
      SSPSTAT_CKE = 0
   end if

   SSPCON_SSPM = SPI_SET_RATE

   SSPCON_SSPEN = 1
end procedure


The constants will remove the "if" statements during compile.

Seb, I would like your opinion as well but I don't want to enforce it
unless we all agree.

Matt.

-- 
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