Skip to content

Commit 0cd2c97

Browse files
committed
tiam1808/drivers/spi: Round *up* divisor for clock prescaler
This ensures that the specified frequency is never exceeced.
1 parent 56aea2a commit 0cd2c97

File tree

1 file changed

+1
-1
lines changed
  • lib/tiam1808/drivers

1 file changed

+1
-1
lines changed

lib/tiam1808/drivers/spi.c

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -59,7 +59,7 @@ void SPIClkConfigure(unsigned int baseAdd, unsigned int moduleClk,
5959
{
6060
unsigned int prescale;
6161

62-
prescale = (moduleClk/spiClk) - 1;
62+
prescale = ((moduleClk + spiClk - 1)/spiClk) - 1;
6363

6464
HWREG(baseAdd + SPI_SPIFMT(dataFormat)) = \
6565
(SPI_SPIFMT_PRESCALE & (prescale << SPI_SPIFMT_PRESCALE_SHIFT));

0 commit comments

Comments
 (0)