stm32: Enable SPI support on stm32g0

Signed-off-by: Alan.Ma from BigTreeTech <tech@biqu3d.com>
Signed-off-by: Kevin O'Connor <kevin@koconnor.net>
This commit is contained in:
Kevin O'Connor 2021-12-19 13:18:44 -05:00
parent 1c24317380
commit c89a01c83b
2 changed files with 8 additions and 4 deletions

View File

@ -8,7 +8,7 @@ config STM32_SELECT
select HAVE_GPIO
select HAVE_GPIO_ADC
select HAVE_GPIO_I2C if !(MACH_STM32F031 || MACH_STM32H7)
select HAVE_GPIO_SPI if !(MACH_STM32F031 || MACH_STM32G0)
select HAVE_GPIO_SPI if !MACH_STM32F031
select HAVE_GPIO_HARD_PWM if MACH_STM32F1 || MACH_STM32F4 || MACH_STM32H7
select HAVE_GPIO_BITBANGING if !MACH_STM32F031
select HAVE_STRICT_TIMING

View File

@ -21,7 +21,7 @@ DECL_ENUMERATION("spi_bus", "spi1", 1);
DECL_CONSTANT_STR("BUS_PINS_spi1", "PA6,PA7,PA5");
DECL_ENUMERATION("spi_bus", "spi1a", 2);
DECL_CONSTANT_STR("BUS_PINS_spi1a", "PB4,PB5,PB3");
#if CONFIG_MACH_STM32F0 || CONFIG_MACH_STM32F2 || CONFIG_MACH_STM32F4
#if !CONFIG_MACH_STM32F1
DECL_ENUMERATION("spi_bus", "spi2a", 3);
DECL_CONSTANT_STR("BUS_PINS_spi2a", "PC2,PC3,PB10");
#endif
@ -41,7 +41,11 @@ DECL_CONSTANT_STR("BUS_PINS_spi1a", "PB4,PB5,PB3");
#endif
#endif
#define SPI_FUNCTION GPIO_FUNCTION(CONFIG_MACH_STM32F0 ? 0 : 5)
#if CONFIG_MACH_STM32F0 || CONFIG_MACH_STM32G0
#define SPI_FUNCTION GPIO_FUNCTION(0)
#else
#define SPI_FUNCTION GPIO_FUNCTION(5)
#endif
static const struct spi_info spi_bus[] = {
{ SPI2, GPIO('B', 14), GPIO('B', 15), GPIO('B', 13), SPI_FUNCTION },
@ -76,7 +80,7 @@ spi_setup(uint32_t bus, uint8_t mode, uint32_t rate)
gpio_peripheral(spi_bus[bus].sck_pin, spi_bus[bus].function, 0);
// Configure CR2 on stm32f0
#if CONFIG_MACH_STM32F0
#if CONFIG_MACH_STM32F0 || CONFIG_MACH_STM32G0
spi->CR2 = SPI_CR2_FRXTH | (7 << SPI_CR2_DS_Pos);
#endif
}