Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fix SPI polarity/phase and chip select #222

Merged
merged 1 commit into from
Mar 9, 2020
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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