[Silicon Labs] Fix bug with SPI MISO and CS handling

pull/4477/head
Aksel Skauge Mellbye 2017-03-28 16:54:23 +01:00 committed by Russ Butler
parent 8d6bc1d47d
commit 9e999bd43b
1 changed files with 3 additions and 2 deletions

View File

@ -196,6 +196,7 @@ void spi_enable_pins(spi_t *obj, uint8_t enable, PinName mosi, PinName miso, Pin
/* Enabling pins and setting location */
#ifdef _USART_ROUTEPEN_RESETVALUE
uint32_t route = USART_ROUTEPEN_CLKPEN;
obj->spi.spi->ROUTELOC0 &= ~_USART_ROUTELOC0_CLKLOC_MASK;
obj->spi.spi->ROUTELOC0 |= pin_location(clk, PinMap_SPI_CLK)<<_USART_ROUTELOC0_CLKLOC_SHIFT;
if (mosi != NC) {
@ -206,12 +207,12 @@ void spi_enable_pins(spi_t *obj, uint8_t enable, PinName mosi, PinName miso, Pin
if (miso != NC) {
route |= USART_ROUTEPEN_RXPEN;
obj->spi.spi->ROUTELOC0 &= ~_USART_ROUTELOC0_RXLOC_MASK;
obj->spi.spi->ROUTELOC0 |= pin_location(miso, PinMap_SPI_MOSI)<<_USART_ROUTELOC0_RXLOC_SHIFT;
obj->spi.spi->ROUTELOC0 |= pin_location(miso, PinMap_SPI_MISO)<<_USART_ROUTELOC0_RXLOC_SHIFT;
}
if (!obj->spi.master) {
route |= USART_ROUTEPEN_CSPEN;
obj->spi.spi->ROUTELOC0 &= ~_USART_ROUTELOC0_CSLOC_MASK;
obj->spi.spi->ROUTELOC0 |= pin_location(cs, PinMap_SPI_MOSI)<<_USART_ROUTELOC0_CSLOC_SHIFT;
obj->spi.spi->ROUTELOC0 |= pin_location(cs, PinMap_SPI_CS)<<_USART_ROUTELOC0_CSLOC_SHIFT;
}
obj->spi.location = obj->spi.spi->ROUTELOC0;
obj->spi.route = route;