|
|
|
@ -45,9 +45,18 @@ void spi_init(){
|
|
|
|
return d-1; // the -1 because minimum divisor is /2
|
|
|
|
return d-1; // the -1 because minimum divisor is /2
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
/* do pseudo-calculation in preprocessor, to get warnings
|
|
|
|
|
|
|
|
* we right-shift 8 times; if result >0, d will be >7
|
|
|
|
|
|
|
|
* so output warning in that case
|
|
|
|
|
|
|
|
*/
|
|
|
|
|
|
|
|
#define D_VAL (F_CPU / SPI_BAUDRATE)
|
|
|
|
|
|
|
|
#if ((D_VAL >> 8) > 0 )
|
|
|
|
|
|
|
|
#warning "spi baudrate too slow, cannot be set"
|
|
|
|
|
|
|
|
#endif
|
|
|
|
|
|
|
|
|
|
|
|
d = spi_clock_divisor();
|
|
|
|
d = spi_clock_divisor();
|
|
|
|
if(d>7){
|
|
|
|
if(d>7){
|
|
|
|
#warning "spi baudrate too slow, cannot be set"
|
|
|
|
// warning was (hopefully) output previously by cpp
|
|
|
|
d=7;
|
|
|
|
d=7;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|