Finally, I was able to get an answer. I will put the code at the end for those who need it
OSPI_RegularCmdTypeDef sCommand={0};
OSPI_MemoryMappedTypeDef sMemMappedCfg={0};
/* Enable Memory-Mapped mode-------------------------------------------------- */
/* Common Commands*/
sCommand.OperationType = HAL_OSPI_OPTYPE_READ_CFG; /* Read Configuration (Memory-Mapped Mode) */
sCommand.FlashId = HAL_OSPI_FLASH_ID_1; /* Set The OCTO SPI Flash ID */
sCommand.InstructionDtrMode = HAL_OSPI_INSTRUCTION_DTR_DISABLE; /* Disable Instruction DDR/DTR Mode */
sCommand.AddressDtrMode = HAL_OSPI_ADDRESS_DTR_DISABLE; /* Disable Address DDR/DTR Mode */
sCommand.DataDtrMode = HAL_OSPI_DATA_DTR_DISABLE; /* Disable Data DDR/DTR Mode */
sCommand.DQSMode = HAL_OSPI_DQS_DISABLE; /* Disable Data Strobe */
sCommand.SIOOMode = HAL_OSPI_SIOO_INST_EVERY_CMD; /* SIOO Mode: Send instruction on every transaction */
sCommand.AlternateBytesMode = HAL_OSPI_ALTERNATE_BYTES_NONE; /* Disable Alternate Bytes Mode */
sCommand.AlternateBytes = HAL_OSPI_ALTERNATE_BYTES_NONE; /* Alternate Bytes = 0 */
sCommand.AlternateBytesSize = HAL_OSPI_ALTERNATE_BYTES_NONE; /* Alternate Bytes Size = 0 */
sCommand.AlternateBytesDtrMode = HAL_OSPI_ALTERNATE_BYTES_DTR_DISABLE; /* Disable Alternate Bytes DDR/DTR Mode */
sCommand.InstructionMode = HAL_OSPI_INSTRUCTION_1_LINE; /* Instruction on a single line */
sCommand.InstructionSize = HAL_OSPI_INSTRUCTION_8_BITS; /* 8-bit Instruction */
sCommand.AddressSize = HAL_OSPI_ADDRESS_32_BITS; /* 24-bit Address */
/* Instruction */
sCommand.Instruction = 0xEC; /* What We Do? */
/* Address */
sCommand.AddressMode = HAL_OSPI_ADDRESS_4_LINES; /* Define Address Lines: Address On Four Lines */
sCommand.Address = 0; /* Byte Address */
/* Data */
sCommand.DataMode = HAL_OSPI_DATA_4_LINES; /* Define Data Lines: Data On Four Lines */
sCommand.DummyCycles = 6; /* Bytes Send With No Data */
sCommand.NbData = 0; /* Bytes Send With Data */
HAL_OSPI_Command(&hospi1, &sCommand, HAL_OSPI_TIMEOUT_DEFAULT_VALUE);
/* Initialize the program command */
/* Common Commands*/
sCommand.OperationType = HAL_OSPI_OPTYPE_WRITE_CFG; /* Write Configuration (Memory-Mapped Mode)) */
sCommand.FlashId = HAL_OSPI_FLASH_ID_1; /* Set The OCTO SPI Flash ID */
sCommand.InstructionDtrMode = HAL_OSPI_INSTRUCTION_DTR_DISABLE; /* Disable Instruction DDR/DTR Mode */
sCommand.AddressDtrMode = HAL_OSPI_ADDRESS_DTR_DISABLE; /* Disable Address DDR/DTR Mode */
sCommand.DataDtrMode = HAL_OSPI_DATA_DTR_DISABLE; /* Disable Data DDR/DTR Mode */
sCommand.DQSMode = HAL_OSPI_DQS_DISABLE; /* Disable Data Strobe */
sCommand.SIOOMode = HAL_OSPI_SIOO_INST_EVERY_CMD; /* SIOO Mode: Send instruction on every transaction */
sCommand.AlternateBytesMode = HAL_OSPI_ALTERNATE_BYTES_NONE; /* Disable Alternate Bytes Mode */
sCommand.AlternateBytes = HAL_OSPI_ALTERNATE_BYTES_NONE; /* Alternate Bytes = 0 */
sCommand.AlternateBytesSize = HAL_OSPI_ALTERNATE_BYTES_NONE; /* Alternate Bytes Size = 0 */
sCommand.AlternateBytesDtrMode = HAL_OSPI_ALTERNATE_BYTES_DTR_DISABLE; /* Disable Alternate Bytes DDR/DTR Mode */
sCommand.InstructionMode = HAL_OSPI_INSTRUCTION_1_LINE; /* Instruction on a single line */
sCommand.InstructionSize = HAL_OSPI_INSTRUCTION_8_BITS; /* 8-bit Instruction */
sCommand.AddressSize = HAL_OSPI_ADDRESS_32_BITS; /* 24-bit Address */
/* Instruction */
sCommand.Instruction = 0xEC; /* What We Do? */
/* Address */
sCommand.AddressMode = HAL_OSPI_ADDRESS_1_LINE; /* Define Address Lines: Address On a Single Line */
sCommand.Address = 0; /* Byte Address */
/* Data */
sCommand.DataMode = HAL_OSPI_DATA_4_LINES; /* Define Data Lines: Data On Four Lines */
sCommand.DummyCycles = 6; /* Bytes Send With No Data */
sCommand.NbData = 0; /* Bytes Send With Data */
HAL_OSPI_Command(&hospi1, &sCommand, HAL_OSPI_TIMEOUT_DEFAULT_VALUE);
/* Initialize Memory Mapped Command */
sMemMappedCfg.TimeOutActivation = HAL_OSPI_TIMEOUT_COUNTER_DISABLE; /* Timeout counter disabled, nCS remains active */
HAL_OSPI_MemoryMapped(&hospi1, &sMemMappedCfg);