Skip to content

Commit

Permalink
drivers: spi: pin initialization + lock fixes
Browse files Browse the repository at this point in the history
  • Loading branch information
basilfx committed Feb 29, 2016
1 parent e85745f commit f472b5a
Showing 1 changed file with 8 additions and 5 deletions.
13 changes: 8 additions & 5 deletions cpu/efm32_common/periph/spi.c
Original file line number Diff line number Diff line change
Expand Up @@ -37,7 +37,7 @@
/* guard file in case no SPI device is defined */
#if SPI_NUMOF

static mutex_t spi_lock[I2C_NUMOF] = {
static mutex_t spi_lock[SPI_NUMOF] = {
#if SPI_0_EN
[SPI_0] = MUTEX_INIT,
#endif
Expand All @@ -57,9 +57,6 @@ int spi_init_master(spi_t dev, spi_conf_t conf, spi_speed_t speed)
CMU_ClockEnable(cmuClock_HFPER, true);
CMU_ClockEnable(spi_config[dev].cmu, true);

/* configure the pins */
spi_conf_pins(dev);

/* initialize and enable peripheral */
EFM32_CREATE_INIT(init, USART_InitSync_TypeDef, USART_INITSYNC_DEFAULT,
.conf.baudrate = (uint32_t) speed,
Expand All @@ -69,6 +66,9 @@ int spi_init_master(spi_t dev, spi_conf_t conf, spi_speed_t speed)

USART_InitSync(spi_config[dev].dev, &init.conf);

/* configure the pins */
spi_conf_pins(dev);

return 0;
}

Expand All @@ -83,7 +83,10 @@ int spi_conf_pins(spi_t dev)
/* configure the pins */
gpio_init(spi_config[dev].clk_pin, GPIO_OUT, 0);
gpio_init(spi_config[dev].mosi_pin, GPIO_OUT, 0);
gpio_init(spi_config[dev].miso_pin, GPIO_OUT, 0);
gpio_init(spi_config[dev].miso_pin, GPIO_IN_PD, 0);

gpio_set(spi_config[dev].clk_pin);
gpio_set(spi_config[dev].mosi_pin);

/* configure pin functions */
#ifdef _SILICON_LABS_32B_PLATFORM_1
Expand Down

0 comments on commit f472b5a

Please sign in to comment.