SPI配置为主

时间:2018-02-03 07:02:16

标签: stm32 spi keil nucleo

我需要在Nucleo STM32F103RB中将SPI_1配置为主设备。这是我到目前为止所做的(Keil uvision 4)。

// Configuring GPIOs


// SPI_SCK
GPIOA_CRL |= 0x00A00000; //Alternate function push-pull

// SPI_MOSI
GPIOA_CRL |= 0xA0000000; //Alternate function push-pull

// SPI_MISO
GPIOA_CRL |= 0x04000000; //Input floating

但是我需要为多个奴隶设置nSS。我怎么做?我应该使用哪个GPIO引脚将nSS引脚连接到多个从器件。

我还可以附加多少个最大奴隶?

1 个答案:

答案 0 :(得分:2)

You can use any GPIO. Just configure them as outputs and manually set their state to choose the slave. There is no other way for the multiple CS lines.