Skip to content

Commit

Permalink
Merge pull request #222 from sifive/fix-spi-phase-pol-cs
Browse files Browse the repository at this point in the history
Fix SPI polarity/phase and chip select
  • Loading branch information
nategraff-sifive authored Mar 9, 2020
2 parents 1504333 + 518bfc5 commit d30ec29
Showing 1 changed file with 5 additions and 5 deletions.
10 changes: 5 additions & 5 deletions src/drivers/sifive_spi0.c
Original file line number Diff line number Diff line change
Expand Up @@ -82,19 +82,19 @@ static int configure_spi(struct __metal_driver_sifive_spi0 *spi,
/* Set Polarity */
if (config->polarity) {
METAL_SPI_REGW(METAL_SIFIVE_SPI0_SCKMODE) |=
(1 << METAL_SPI_SCKMODE_PHA_SHIFT);
(1 << METAL_SPI_SCKMODE_POL_SHIFT);
} else {
METAL_SPI_REGW(METAL_SIFIVE_SPI0_SCKMODE) &=
~(1 << METAL_SPI_SCKMODE_PHA_SHIFT);
~(1 << METAL_SPI_SCKMODE_POL_SHIFT);
}

/* Set Phase */
if (config->phase) {
METAL_SPI_REGW(METAL_SIFIVE_SPI0_SCKMODE) |=
(1 << METAL_SPI_SCKMODE_POL_SHIFT);
(1 << METAL_SPI_SCKMODE_PHA_SHIFT);
} else {
METAL_SPI_REGW(METAL_SIFIVE_SPI0_SCKMODE) &=
~(1 << METAL_SPI_SCKMODE_POL_SHIFT);
~(1 << METAL_SPI_SCKMODE_PHA_SHIFT);
}

/* Set Endianness */
Expand Down Expand Up @@ -123,7 +123,7 @@ static int configure_spi(struct __metal_driver_sifive_spi0 *spi,
}

/* Set CS line */
METAL_SPI_REGW(METAL_SIFIVE_SPI0_CSID) = 1 << (config->csid);
METAL_SPI_REGW(METAL_SIFIVE_SPI0_CSID) = config->csid;

/* Toggle off memory-mapped SPI flash mode, toggle on programmable IO mode
* It seems that with this line uncommented, the debugger cannot have access
Expand Down

0 comments on commit d30ec29

Please sign in to comment.