Skip to content

Commit

Permalink
Add missing configuration for CS in SPI configuration (#1632)
Browse files Browse the repository at this point in the history
  • Loading branch information
networkfusion authored May 14, 2020
1 parent 12d7f2a commit 3b5919d
Show file tree
Hide file tree
Showing 3 changed files with 17 additions and 8 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -291,10 +291,10 @@
* SPI driver system settings.
*/
#define STM32_SPI_USE_SPI1 FALSE
#define STM32_SPI_USE_SPI2 TRUE
#define STM32_SPI_USE_SPI2 FALSE
#define STM32_SPI_USE_SPI3 FALSE
#define STM32_SPI_USE_SPI4 FALSE
#define STM32_SPI_USE_SPI5 FALSE
#define STM32_SPI_USE_SPI5 TRUE
#define STM32_SPI_USE_SPI6 FALSE
#define STM32_SPI_SPI1_RX_DMA_STREAM STM32_DMA_STREAM_ID(2, 0)
#define STM32_SPI_SPI1_TX_DMA_STREAM STM32_DMA_STREAM_ID(2, 3)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -6,13 +6,13 @@
#include "win_dev_spi_native_target.h"

//////////
// SPI2 //
// SPI5 //
//////////

// pin configuration for SPI2
// port for SCK pin is: LINE_ARD_D13
// port for MISO pin is: LINE_ARD_D12
// port for MOSI pin is: LINE_ARD_D11
// pin configuration for SPI5
// port for SCK pin is: PF7 (D6)
// port for MISO pin is: PF8 (A4)
// port for MOSI pin is: PF9 (A5)

// GPIO alternate pin function is 5 (see alternate function mapping table in device datasheet)
SPI_CONFIG_PINS(2, GPIOA, 12, GPIOB, 14, GPIOB, 15, 5)
SPI_CONFIG_PINS(5, GPIOF, 7, GPIOF, 8, GPIOF, 9, 5)
Original file line number Diff line number Diff line change
Expand Up @@ -297,7 +297,16 @@ void GetSPIConfig(int busIndex, CLR_RT_HeapBlock* config, SPIConfig* llConfig, b
#if (SPI_SUPPORTS_CIRCULAR == TRUE)
llConfig->circular = SPI_USE_CIRCULAR;
#endif

llConfig->end_cb = SpiCallback;

// make sure the CS pin is properly configured as GPIO, output & pushpull
palSetPadMode( GPIO_PORT(csPin), csPin % 16, (PAL_STM32_OSPEED_HIGHEST | PAL_MODE_OUTPUT_PUSHPULL) );

// being SPI CS active low, default it to high
palSetPad(GPIO_PORT(csPin), csPin % 16);

// set port&pad for CS pin
llConfig->ssport = GPIO_PORT(csPin);
llConfig->sspad = csPin % 16;
}
Expand Down

0 comments on commit 3b5919d

Please sign in to comment.