Skip to content

Commit

Permalink
added ospi support to WeAct Studio H723VG_LCD board
Browse files Browse the repository at this point in the history
  • Loading branch information
bshewan committed Aug 15, 2024
1 parent e5fff60 commit 9f4749f
Show file tree
Hide file tree
Showing 8 changed files with 236 additions and 103 deletions.
1 change: 1 addition & 0 deletions ports/stm/Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -134,6 +134,7 @@ SRC_STM32 = $(addprefix $(HAL_DIR)/Src/stm32$(MCU_SERIES_LOWER)xx_,\
hal_gpio.c \
hal_i2c.c \
hal_i2c_ex.c \
hal_ospi.c \
hal_pcd.c \
hal_pcd_ex.c \
hal_pwr.c \
Expand Down
48 changes: 48 additions & 0 deletions ports/stm/boards/weact-h723vg-lcd/board.c
Original file line number Diff line number Diff line change
Expand Up @@ -10,4 +10,52 @@
// Use the MP_WEAK supervisor/shared/board.c versions of routines not defined here.

void board_init(void) {

}

void external_flash_setup(void) {

/**OCTOSPI1 GPIO Configuration
PE2 ------> OCTOSPIM_P1_IO2
PB2 ------> OCTOSPIM_P1_CLK
PD11 ------> OCTOSPIM_P1_IO0
PD12 ------> OCTOSPIM_P1_IO1
PD13 ------> OCTOSPIM_P1_IO3
PB6 ------> OCTOSPIM_P1_NCS
*/

GPIO_InitTypeDef GPIO_InitStruct = {0};

GPIO_InitStruct.Pin = GPIO_PIN_2;
GPIO_InitStruct.Mode = GPIO_MODE_AF_PP;
GPIO_InitStruct.Pull = GPIO_NOPULL;
GPIO_InitStruct.Speed = GPIO_SPEED_FREQ_VERY_HIGH;
GPIO_InitStruct.Alternate = GPIO_AF9_OCTOSPIM_P1;
HAL_GPIO_Init(GPIOE, &GPIO_InitStruct);

GPIO_InitStruct.Pin = GPIO_PIN_2;
GPIO_InitStruct.Mode = GPIO_MODE_AF_PP;
GPIO_InitStruct.Pull = GPIO_NOPULL;
GPIO_InitStruct.Speed = GPIO_SPEED_FREQ_VERY_HIGH;
GPIO_InitStruct.Alternate = GPIO_AF9_OCTOSPIM_P1;
HAL_GPIO_Init(GPIOB, &GPIO_InitStruct);

GPIO_InitStruct.Pin = GPIO_PIN_11 | GPIO_PIN_12 | GPIO_PIN_13;
GPIO_InitStruct.Mode = GPIO_MODE_AF_PP;
GPIO_InitStruct.Pull = GPIO_NOPULL;
GPIO_InitStruct.Speed = GPIO_SPEED_FREQ_VERY_HIGH;
GPIO_InitStruct.Alternate = GPIO_AF9_OCTOSPIM_P1;
HAL_GPIO_Init(GPIOD, &GPIO_InitStruct);

GPIO_InitStruct.Pin = GPIO_PIN_6;
GPIO_InitStruct.Mode = GPIO_MODE_AF_PP;
GPIO_InitStruct.Pull = GPIO_NOPULL;
GPIO_InitStruct.Speed = GPIO_SPEED_FREQ_VERY_HIGH;
GPIO_InitStruct.Alternate = GPIO_AF10_OCTOSPIM_P1;
HAL_GPIO_Init(GPIOB, &GPIO_InitStruct);

/* OCTOSPI1 interrupt Init */
HAL_NVIC_SetPriority(OCTOSPI1_IRQn, 0, 0);
HAL_NVIC_EnableIRQ(OCTOSPI1_IRQn);

}
9 changes: 9 additions & 0 deletions ports/stm/boards/weact-h723vg-lcd/mpconfigboard.h
Original file line number Diff line number Diff line change
Expand Up @@ -38,6 +38,15 @@
#define SPI_FLASH_SCK_PIN (&pin_PB03)
#define SPI_FLASH_CS_PIN (&pin_PD06)

#if QSPI_FLASH_FILESYSTEM
#define MICROPY_QSPI_DATA0 (&pin_PD11)
#define MICROPY_QSPI_DATA1 (&pin_PD12)
#define MICROPY_QSPI_DATA2 (&pin_PE02)
#define MICROPY_QSPI_DATA3 (&pin_PD13)
#define MICROPY_QSPI_SCK (&pin_PB02)
#define MICROPY_QSPI_CS (&pin_PB06)
#endif

// usb?
#define IGNORE_PIN_PA11 1
#define IGNORE_PIN_PA12 1
Expand Down
4 changes: 2 additions & 2 deletions ports/stm/boards/weact-h723vg-lcd/mpconfigboard.mk
Original file line number Diff line number Diff line change
Expand Up @@ -4,8 +4,8 @@ USB_PRODUCT = "H723VG LCD"
USB_MANUFACTURER = "WeAct Studio"

INTERNAL_FLASH_FILESYSTEM = 0
# QSPI_FLASH_FILESYSTEM = 1
SPI_FLASH_FILESYSTEM = 1
QSPI_FLASH_FILESYSTEM = 1
# SPI_FLASH_FILESYSTEM = 1

MCU_SERIES = H7
MCU_VARIANT = STM32H723xx
Expand Down
2 changes: 1 addition & 1 deletion ports/stm/hal_conf/stm32_hal_conf.h
Original file line number Diff line number Diff line change
Expand Up @@ -49,7 +49,7 @@
// #define HAL_NAND_MODULE_ENABLED
// #define HAL_NOR_MODULE_ENABLED
// #define HAL_OPAMP_MODULE_ENABLED
// #define HAL_OSPI_MODULE_ENABLED
#define HAL_OSPI_MODULE_ENABLED
// #define HAL_OTFDEC_MODULE_ENABLED
// #define HAL_PCCARD_MODULE_ENABLED
#define HAL_PCD_MODULE_ENABLED
Expand Down
15 changes: 14 additions & 1 deletion ports/stm/peripherals/stm32h7/clocks.c
Original file line number Diff line number Diff line change
Expand Up @@ -79,7 +79,7 @@ void stm32_peripherals_clocks_init(void) {
// Set up non-bus peripherals
// TODO: I2S settings go here
PeriphClkInitStruct.PeriphClockSelection = RCC_PERIPHCLK_RTC | RCC_PERIPHCLK_USART3
| RCC_PERIPHCLK_USB;
| RCC_PERIPHCLK_USB | RCC_PERIPHCLK_OSPI;
#if (BOARD_HAS_LOW_SPEED_CRYSTAL)
PeriphClkInitStruct.RTCClockSelection = RCC_RTCCLKSOURCE_LSE;
#else
Expand All @@ -91,8 +91,21 @@ void stm32_peripherals_clocks_init(void) {
#else
PeriphClkInitStruct.UsbClockSelection = RCC_USBCLKSOURCE_PLL;
#endif
PeriphClkInitStruct.PLL2.PLL2M = 2;
PeriphClkInitStruct.PLL2.PLL2N = 20;
PeriphClkInitStruct.PLL2.PLL2P = 2;
PeriphClkInitStruct.PLL2.PLL2Q = 2;
PeriphClkInitStruct.PLL2.PLL2R = 2;
PeriphClkInitStruct.PLL2.PLL2RGE = RCC_PLL2VCIRANGE_3;
PeriphClkInitStruct.PLL2.PLL2VCOSEL = RCC_PLL2VCOWIDE;
PeriphClkInitStruct.PLL2.PLL2FRACN = 0;
PeriphClkInitStruct.OspiClockSelection = RCC_OSPICLKSOURCE_PLL2;
HAL_RCCEx_PeriphCLKConfig(&PeriphClkInitStruct);

/* OCTOSPI1 clock enable */
__HAL_RCC_OCTOSPIM_CLK_ENABLE();
__HAL_RCC_OSPI1_CLK_ENABLE();

// Enable USB Voltage detector
HAL_PWREx_EnableUSBVoltageDetector();
}
8 changes: 8 additions & 0 deletions ports/stm/peripherals/stm32h7/stm32h723xx/gpio.c
Original file line number Diff line number Diff line change
Expand Up @@ -23,4 +23,12 @@ void stm32_peripherals_gpio_init(void) {
never_reset_pin_number(2, 15); // PC15 OSC32_OUT
never_reset_pin_number(0, 13); // PA13 SWDIO
never_reset_pin_number(0, 14); // PA14 SWCLK

never_reset_pin_number(1, 6); // PB6 OSPI NCS
never_reset_pin_number(1, 2); // PB2 OSPI CLK
never_reset_pin_number(3, 11); // PD11 OSPI IO0
never_reset_pin_number(3, 12); // PD12 OSPI IO1
never_reset_pin_number(4, 2); // PE2 OSPI IO2
never_reset_pin_number(3, 13); // PD13 OSPI IO3

}
Loading

0 comments on commit 9f4749f

Please sign in to comment.