diff --git a/firmware/shared/spi.c b/firmware/shared/spi.c index ca39c0b..e2dc977 100644 --- a/firmware/shared/spi.c +++ b/firmware/shared/spi.c @@ -45,9 +45,18 @@ void spi_init(){ 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(); if(d>7){ - #warning "spi baudrate too slow, cannot be set" + // warning was (hopefully) output previously by cpp d=7; }