Disclaimer: Since it is beyond my comprehension that this error may have survived so long, I have thought that I may be wrong in my interpretations. I may be having some cognitive short here. Even built this case! If I am wrong nothing is better for XMOS, and I must just lip my wounds..
The headings of SPI modes show the two first wrongly. The correct is in green (and Mode 0 is SPI_MODE_0 etc.):
- “1.1.1 Mode 0 – CPOL: 0 CPHA 1” → Mode 1 in heading and figure description
- “1.1.2 Mode 1 – CPOL: 0 CPHA 0” → Mode 0 i in heading and figure description
Some examples from the code. The typedef in spi.h also has its comments wrong:
Code: Select all
/** This type indicates what mode an SPI component should use */
typedef enum spi_mode_t {
SPI_MODE_0, /**< SPI Mode 0 - Polarity = 0, Clock Edge = 1 CORRECT: Clock Edge = 0*/
SPI_MODE_1, /**< SPI Mode 1 - Polarity = 0, Clock Edge = 0 CORRECT: Clock Edge = 1*/
SPI_MODE_2, /**< SPI Mode 2 - Polarity = 1, Clock Edge = 0 */
SPI_MODE_3, /**< SPI Mode 3 - Polarity = 1, Clock Edge = 1 */
} spi_mode_t;
Code: Select all
static void get_mode_bits(spi_mode_t mode, unsigned &cpol, unsigned &cpha){
switch(mode){
case SPI_MODE_0:cpol = 0; cpha= 1; break;
case SPI_MODE_1:cpol = 0; cpha= 0; break;
case SPI_MODE_2:cpol = 1; cpha= 0; break;
case SPI_MODE_3:cpol = 1; cpha= 1; break;
}
}
[2] http://www.teigfam.net/oyvind/home/wp-c ... wapped.pdf,
as used in http://www.teigfam.net/oyvind/home/tech ... s/#lib_spi