diff --git a/ports/stm32f4/peripherals/stm32f4/stm32f405xx/periph.c b/ports/stm32f4/peripherals/stm32f4/stm32f405xx/periph.c index f2ace8204f..7b0a54e55e 100644 --- a/ports/stm32f4/peripherals/stm32f4/stm32f405xx/periph.c +++ b/ports/stm32f4/peripherals/stm32f4/stm32f405xx/periph.c @@ -46,4 +46,43 @@ const mcu_i2c_scl_obj_t mcu_i2c_scl_list[4] = { I2C_SCL(2, 4, &pin_PB10), I2C_SCL(3, 4, &pin_PA08) }; -//SPI, UART, Etc + +SPI_TypeDef * mcu_spi_banks[3] = {SPI1, SPI2, SPI3}; + +const mcu_spi_sck_obj_t mcu_spi_sck_list[7] = { + SPI(1, 5, &pin_PA05), + SPI(1, 5, &pin_PB03), + SPI(2, 5, &pin_PB10), + SPI(2, 5, &pin_PB13), + SPI(2, 5, &pin_PC07), + SPI(3, 6, &pin_PB03), + SPI(3, 6, &pin_PC10), +}; + +const mcu_spi_mosi_obj_t mcu_spi_mosi_list[6] = { + SPI(1, 5, &pin_PA07), + SPI(1, 5, &pin_PB05), + SPI(2, 5, &pin_PB15), + SPI(2, 5, &pin_PC03), + SPI(3, 6, &pin_PB05), + SPI(3, 6, &pin_PC12), +}; + +const mcu_spi_miso_obj_t mcu_spi_miso_list[6] = { + SPI(1, 5, &pin_PA06), + SPI(1, 5, &pin_PB04), + SPI(2, 5, &pin_PB14), + SPI(2, 5, &pin_PC02), + SPI(3, 6, &pin_PB04), + SPI(3, 6, &pin_PC11), +}; + +const mcu_spi_nss_obj_t mcu_spi_nss_list[6] = { + SPI(1, 5, &pin_PA04), + SPI(1, 5, &pin_PA15), + SPI(2, 5, &pin_PB09), + SPI(2, 5, &pin_PB12), + SPI(3, 6, &pin_PA04), + SPI(3, 6, &pin_PA15), +}; +//UART, Etc diff --git a/ports/stm32f4/peripherals/stm32f4/stm32f405xx/periph.h b/ports/stm32f4/peripherals/stm32f4/stm32f405xx/periph.h index 41b797e5f2..cb9b33f6eb 100644 --- a/ports/stm32f4/peripherals/stm32f4/stm32f405xx/periph.h +++ b/ports/stm32f4/peripherals/stm32f4/stm32f405xx/periph.h @@ -24,8 +24,8 @@ * THE SOFTWARE. */ -#ifndef MICROPY_INCLUDED_STM32F4_PERIPHERALS_STM32F411VE_PERIPH_H -#define MICROPY_INCLUDED_STM32F4_PERIPHERALS_STM32F411VE_PERIPH_H +#ifndef MICROPY_INCLUDED_STM32F4_PERIPHERALS_STM32F405XX_PERIPH_H +#define MICROPY_INCLUDED_STM32F4_PERIPHERALS_STM32F405XX_PERIPH_H //I2C extern I2C_TypeDef * mcu_i2c_banks[3]; @@ -33,5 +33,13 @@ extern I2C_TypeDef * mcu_i2c_banks[3]; extern const mcu_i2c_sda_obj_t mcu_i2c_sda_list[4]; extern const mcu_i2c_scl_obj_t mcu_i2c_scl_list[4]; +//SPI +extern SPI_TypeDef * mcu_spi_banks[3]; -#endif // MICROPY_INCLUDED_STM32F4_PERIPHERALS_STM32F411VE_PERIPH_H \ No newline at end of file +extern const mcu_spi_sck_obj_t mcu_spi_sck_list[7]; +extern const mcu_spi_mosi_obj_t mcu_spi_mosi_list[6]; +extern const mcu_spi_miso_obj_t mcu_spi_miso_list[6]; +extern const mcu_spi_nss_obj_t mcu_spi_nss_list[6]; + + +#endif // MICROPY_INCLUDED_STM32F4_PERIPHERALS_STM32F405XX_PERIPH_H \ No newline at end of file diff --git a/ports/stm32f4/peripherals/stm32f4/stm32f411xe/periph.c b/ports/stm32f4/peripherals/stm32f4/stm32f411xe/periph.c index 645e937170..f0966f785f 100644 --- a/ports/stm32f4/peripherals/stm32f4/stm32f411xe/periph.c +++ b/ports/stm32f4/peripherals/stm32f4/stm32f411xe/periph.c @@ -49,4 +49,74 @@ const mcu_i2c_scl_obj_t mcu_i2c_scl_list[4] = { I2C_SCL(2, 4, &pin_PB10), I2C_SCL(3, 4, &pin_PA08) }; -//SPI, UART, Etc + +// SPI + +SPI_TypeDef * mcu_spi_banks[5] = {SPI1, SPI2, SPI3, SPI4, SPI5}; + +const mcu_spi_sck_obj_t mcu_spi_sck_list[15] = { + SPI(1, 5, &pin_PA05), + SPI(1, 5, &pin_PB03), + SPI(2, 5, &pin_PB10), + SPI(2, 5, &pin_PB13), + SPI(2, 5, &pin_PC07), + SPI(2, 5, &pin_PD03), + SPI(3, 6, &pin_PB03), + SPI(3, 7, &pin_PB12), + SPI(3, 6, &pin_PC10), + SPI(4, 6, &pin_PB13), + SPI(4, 5, &pin_PE02), + SPI(4, 5, &pin_PE12), + SPI(5, 6, &pin_PB00), + SPI(5, 6, &pin_PE02), + SPI(5, 6, &pin_PE12) +}; + +const mcu_spi_mosi_obj_t mcu_spi_mosi_list[14] = { + SPI(1, 5, &pin_PA07), + SPI(1, 5, &pin_PB05), + SPI(2, 5, &pin_PB15), + SPI(2, 5, &pin_PC03), + SPI(3, 6, &pin_PB05), + SPI(3, 6, &pin_PC12), + SPI(3, 5, &pin_PD06), + SPI(4, 5, &pin_PA01), + SPI(4, 5, &pin_PE06), + SPI(4, 5, &pin_PE14), + SPI(5, 6, &pin_PA10), + SPI(5, 6, &pin_PB08), + SPI(5, 6, &pin_PE06), + SPI(5, 6, &pin_PE14) +}; + +const mcu_spi_miso_obj_t mcu_spi_miso_list[12] = { + SPI(1, 5, &pin_PA06), + SPI(1, 5, &pin_PB04), + SPI(2, 5, &pin_PB14), + SPI(2, 5, &pin_PC02), + SPI(3, 6, &pin_PB04), + SPI(3, 6, &pin_PC11), + SPI(4, 6, &pin_PA11), + SPI(4, 5, &pin_PE05), + SPI(4, 5, &pin_PE13), + SPI(5, 6, &pin_PA12), + SPI(5, 6, &pin_PE05), + SPI(5, 6, &pin_PE13) +}; + +const mcu_spi_nss_obj_t mcu_spi_nss_list[12] = { + SPI(1, 5, &pin_PA04), + SPI(1, 5, &pin_PA15), + SPI(2, 5, &pin_PB09), + SPI(2, 5, &pin_PB12), + SPI(3, 6, &pin_PA04), + SPI(3, 6, &pin_PA15), + SPI(4, 6, &pin_PB12), + SPI(4, 5, &pin_PE04), + SPI(4, 5, &pin_PE11), + SPI(5, 6, &pin_PB01), + SPI(5, 6, &pin_PE04), + SPI(5, 6, &pin_PE11) +}; + +//UART, Etc diff --git a/ports/stm32f4/peripherals/stm32f4/stm32f411xe/periph.h b/ports/stm32f4/peripherals/stm32f4/stm32f411xe/periph.h index 13236468d1..08efa14ca5 100644 --- a/ports/stm32f4/peripherals/stm32f4/stm32f411xe/periph.h +++ b/ports/stm32f4/peripherals/stm32f4/stm32f411xe/periph.h @@ -33,4 +33,12 @@ extern I2C_TypeDef * mcu_i2c_banks[3]; extern const mcu_i2c_sda_obj_t mcu_i2c_sda_list[7]; extern const mcu_i2c_scl_obj_t mcu_i2c_scl_list[4]; +//SPI +extern SPI_TypeDef * mcu_spi_banks[5]; + +extern const mcu_spi_sck_obj_t mcu_spi_sck_list[15]; +extern const mcu_spi_mosi_obj_t mcu_spi_mosi_list[14]; +extern const mcu_spi_miso_obj_t mcu_spi_miso_list[12]; +extern const mcu_spi_nss_obj_t mcu_spi_nss_list[12]; + #endif // MICROPY_INCLUDED_STM32F4_PERIPHERALS_STM32F411VE_PERIPH_H \ No newline at end of file diff --git a/ports/stm32f4/peripherals/stm32f4/stm32f412zx/periph.c b/ports/stm32f4/peripherals/stm32f4/stm32f412zx/periph.c index 7df876931a..1f51b5b8df 100644 --- a/ports/stm32f4/peripherals/stm32f4/stm32f412zx/periph.c +++ b/ports/stm32f4/peripherals/stm32f4/stm32f412zx/periph.c @@ -55,7 +55,7 @@ const mcu_i2c_scl_obj_t mcu_i2c_scl_list[4] = { SPI_TypeDef * mcu_spi_banks[5] = {SPI1, SPI2, SPI3, SPI4, SPI5}; -const mcu_spi_sck_obj_t mcu_spi_sck_list[16] = { +const mcu_spi_sck_obj_t mcu_spi_sck_list[15] = { SPI(1, 5, &pin_PA05), SPI(1, 5, &pin_PB03), SPI(2, 5, &pin_PB10), diff --git a/ports/stm32f4/peripherals/stm32f4/stm32f412zx/periph.h b/ports/stm32f4/peripherals/stm32f4/stm32f412zx/periph.h index 188afcfd2e..d12bbba93e 100644 --- a/ports/stm32f4/peripherals/stm32f4/stm32f412zx/periph.h +++ b/ports/stm32f4/peripherals/stm32f4/stm32f412zx/periph.h @@ -37,7 +37,7 @@ extern const mcu_i2c_scl_obj_t mcu_i2c_scl_list[4]; //SPI extern SPI_TypeDef * mcu_spi_banks[5]; -extern const mcu_spi_sck_obj_t mcu_spi_sck_list[16]; +extern const mcu_spi_sck_obj_t mcu_spi_sck_list[15]; extern const mcu_spi_mosi_obj_t mcu_spi_mosi_list[14]; extern const mcu_spi_miso_obj_t mcu_spi_miso_list[12]; extern const mcu_spi_nss_obj_t mcu_spi_nss_list[12];