2424// #include "option_bits.h"
2525#include " mbed.h"
2626#include " target.h"
27- #include " QSPIFBlockDevice .h"
27+ #include " BlockDevice .h"
2828#include " FlashSimBlockDevice.h"
2929#include " flash_map_backend/secondary_bd.h"
3030#include " bootutil/bootutil.h"
4242/* Private macro ------------------------------------------------------------- */
4343/* Private variables --------------------------------------------------------- */
4444/* Private function prototypes ----------------------------------------------- */
45-
4645char BOOTLOADER_DESC_STR[48 ];
4746
4847
@@ -55,7 +54,7 @@ uint16_t Flash_If_DeInit(void);
5554uint16_t Flash_If_GetStatus (uint32_t Add, uint8_t Cmd, uint8_t * buffer);
5655
5756FlashIAP flash;
58- QSPIFBlockDevice qspi_flash (PD_11, PD_12, PF_7, PD_13, PF_10, PG_6, QSPIF_POLARITY_MODE_1, 40000000 );
57+ mbed::BlockDevice* qspi_flash = mbed::BlockDevice::get_default_instance( );
5958mbed::BlockDevice* dfu_secondary_bd = get_secondary_bd();
6059
6160const uint32_t QSPIFLASH_BASE_ADDRESS = 0x90000000 ;
@@ -80,7 +79,7 @@ bool Flash_If_Init_requested = false;
8079
8180void init_Memories () {
8281 flash.init ();
83- qspi_flash. init ();
82+ qspi_flash-> init ();
8483 dfu_secondary_bd->init ();
8584 snprintf (BOOTLOADER_DESC_STR, sizeof (BOOTLOADER_DESC_STR), " @MCUBoot version %d /0x00000000/0*4Kg" , BOOTLOADER_VERSION);
8685}
@@ -133,7 +132,7 @@ uint16_t Flash_If_Erase(uint32_t Add)
133132 return dfu_secondary_bd->erase (Add, dfu_secondary_bd->get_erase_size (Add));
134133 } else if (isExternalFlash (Add)) {
135134 Add -= QSPIFLASH_BASE_ADDRESS;
136- return qspi_flash. erase (Add, qspi_flash. get_erase_size (Add));
135+ return qspi_flash-> erase (Add, qspi_flash-> get_erase_size (Add));
137136 } else {
138137 return flash.erase (Add, flash.get_sector_size (Add));
139138 }
@@ -171,10 +170,10 @@ uint16_t Flash_If_Write(uint8_t * src, uint8_t * dest, uint32_t Len)
171170 return dfu_secondary_bd->program (src, (uint32_t )dest, Len);
172171 } else if (isExternalFlash ((uint32_t )dest)) {
173172 dest -= QSPIFLASH_BASE_ADDRESS;
174- if (Len < qspi_flash. get_erase_size (0 )) {
175- Len = qspi_flash. get_erase_size (0 );
173+ if (Len < qspi_flash-> get_erase_size (0 )) {
174+ Len = qspi_flash-> get_erase_size (0 );
176175 }
177- return qspi_flash. program (src, (uint32_t )dest, Len);
176+ return qspi_flash-> program (src, (uint32_t )dest, Len);
178177 } else {
179178 uint8_t * srcCopy = (uint8_t *)malloc (Len);
180179 memcpy (srcCopy, src, Len);
@@ -204,7 +203,7 @@ uint8_t *Flash_If_Read(uint8_t * src, uint8_t * dest, uint32_t Len)
204203 dfu_secondary_bd->read (dest, (uint32_t )src, Len);
205204 } else if (isExternalFlash ((uint32_t )src)) {
206205 src -= QSPIFLASH_BASE_ADDRESS;
207- qspi_flash. read (dest, (uint32_t )src, Len);
206+ qspi_flash-> read (dest, (uint32_t )src, Len);
208207 } else {
209208 for (i = 0 ; i < Len; i++)
210209 {
0 commit comments