Hey Seb, let's get back to work. William and others, I welcome your
input as well. I was wondering if we could change the name of
spi_master_common to spi_common. SPI slave requires some of the same
constants as master:
const SPI_MODE_00 = 0
const SPI_MODE_01 = 1
const SPI_MODE_10 = 2
const SPI_MODE_11 = 3
Rate constants are not used, but the compiler will ignore them. I
would just like to use the same named constants for mode. I don't
think there's any need for additional "common" libs. Do you agree?
As for SPI master libs, please let me know if you think it is a good
idea to split the set mode proc into 4. This should save some cycles
in sd_card lib.
procedure spi_master_hw_set_mode_00() is
pragma inline
SSPCON_CKP = 0
SSPSTAT_CKE = 1
end procedure
This changes our aliases in the sample. Instead of:
alias spi_master_set_mode is spi_master_hw_set_mode
We will need a line for each used mode used as follows, unless we add
a optional user constant to enable aliases. Is it worth it?
alias spi_master_set_mode_00 is spi_master_hw_set_mode_00
alias spi_master_set_mode_01 is spi_master_hw_set_mode_01
alias spi_master_set_mode_10 is spi_master_hw_set_mode_10
alias spi_master_set_mode_11 is spi_master_hw_set_mode_11
As I mentioned, the compiler could take care of it for us when inline.
We have to ask Kyle. See below:
procedure spi_master_hw_set_mode(byte in spi_mode) is
pragma inline
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
end procedure
spi_master_hw_set_mode(SPI_MODE_00)
That should have compiled the same as this, since the input to the
inline procedure was constant, and therefore if statements would get
removed.
SSPCON_CKP = 0
SSPSTAT_CKE = 1
Of course you will review "author" in spi_master_hw.jal. I suggest you
follow what you did in spi_master_hw2.jal unless William speaks up and
wishes to keep the current header format.
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.