mirror of
https://github.com/RIOT-OS/RIOT.git
synced 2025-01-18 12:52:44 +01:00
Merge pull request #14107 from jue89/fix/sam0_spi_muxing
cpu/sam0_common/spi: move clk pin muxing into spi_acquire / spi_release
This commit is contained in:
commit
f86934a497
@ -94,7 +94,7 @@ void spi_init_pins(spi_t bus)
|
|||||||
gpio_init(spi_config[bus].clk_pin, GPIO_OUT);
|
gpio_init(spi_config[bus].clk_pin, GPIO_OUT);
|
||||||
gpio_init_mux(spi_config[bus].miso_pin, spi_config[bus].miso_mux);
|
gpio_init_mux(spi_config[bus].miso_pin, spi_config[bus].miso_mux);
|
||||||
gpio_init_mux(spi_config[bus].mosi_pin, spi_config[bus].mosi_mux);
|
gpio_init_mux(spi_config[bus].mosi_pin, spi_config[bus].mosi_mux);
|
||||||
gpio_init_mux(spi_config[bus].clk_pin, spi_config[bus].clk_mux);
|
/* clk_pin will be muxed during acquire / release */
|
||||||
}
|
}
|
||||||
|
|
||||||
int spi_acquire(spi_t bus, spi_cs_t cs, spi_mode_t mode, spi_clk_t clk)
|
int spi_acquire(spi_t bus, spi_cs_t cs, spi_mode_t mode, spi_clk_t clk)
|
||||||
@ -141,11 +141,18 @@ int spi_acquire(spi_t bus, spi_cs_t cs, spi_mode_t mode, spi_clk_t clk)
|
|||||||
dev(bus)->CTRLA.reg |= SERCOM_SPI_CTRLA_ENABLE;
|
dev(bus)->CTRLA.reg |= SERCOM_SPI_CTRLA_ENABLE;
|
||||||
while (dev(bus)->SYNCBUSY.reg & SERCOM_SPI_SYNCBUSY_ENABLE) {}
|
while (dev(bus)->SYNCBUSY.reg & SERCOM_SPI_SYNCBUSY_ENABLE) {}
|
||||||
|
|
||||||
|
/* mux clk_pin to SPI peripheral */
|
||||||
|
gpio_init_mux(spi_config[bus].clk_pin, spi_config[bus].clk_mux);
|
||||||
|
|
||||||
return SPI_OK;
|
return SPI_OK;
|
||||||
}
|
}
|
||||||
|
|
||||||
void spi_release(spi_t bus)
|
void spi_release(spi_t bus)
|
||||||
{
|
{
|
||||||
|
/* Demux clk_pin back to GPIO_OUT function. Otherwise it will get HIGH-Z
|
||||||
|
* and lead to unexpected current draw by SPI salves. */
|
||||||
|
gpio_disable_mux(spi_config[bus].clk_pin);
|
||||||
|
|
||||||
/* disable the device */
|
/* disable the device */
|
||||||
dev(bus)->CTRLA.reg &= ~(SERCOM_SPI_CTRLA_ENABLE);
|
dev(bus)->CTRLA.reg &= ~(SERCOM_SPI_CTRLA_ENABLE);
|
||||||
while (dev(bus)->SYNCBUSY.reg & SERCOM_SPI_SYNCBUSY_ENABLE) {}
|
while (dev(bus)->SYNCBUSY.reg & SERCOM_SPI_SYNCBUSY_ENABLE) {}
|
||||||
|
Loading…
Reference in New Issue
Block a user