Frequency divider bug

This commit is contained in:
UncleRus 2016-03-05 03:07:57 +05:00
parent bd40f75d37
commit 0e3f3bb2ca

View file

@ -107,7 +107,7 @@ void spi_set_frequency_div(uint8_t bus, uint32_t divider)
{ {
uint32_t predivider = divider & 0xffff; uint32_t predivider = divider & 0xffff;
uint32_t count = divider >> 16; uint32_t count = divider >> 16;
if (count > 1 && divider > 1) if (count > 1 || divider > 1)
{ {
predivider = predivider > SPI_CLOCK_DIV_PRE_M + 1 ? SPI_CLOCK_DIV_PRE_M + 1 : predivider; predivider = predivider > SPI_CLOCK_DIV_PRE_M + 1 ? SPI_CLOCK_DIV_PRE_M + 1 : predivider;
count = count > SPI_CLOCK_COUNT_NUM_M + 1 ? SPI_CLOCK_COUNT_NUM_M + 1 : count; count = count > SPI_CLOCK_COUNT_NUM_M + 1 ? SPI_CLOCK_COUNT_NUM_M + 1 : count;