This discussion has been locked.
You can no longer post new replies to this discussion. If you have a question you can start a new discussion

FLASH_Unlock() in mdk v5?

I need to use a library that relies on FLASH_Unlock and functions following it, however upon calling that function I get an error saying the function is invalid in C99. The library I use has an example file which is written in mdk v4 and works just fine. Is there a way I can use FLASH_Unlock() function?

Parents
  • I use eeprom emulation library for stm32f0xx.  ( https://www.st.com/content/st_com/en/products/embedded-software/mcu-mpu-embedded-software/stm32-embedded-software/stm32-standard-peripheral-library-expansion/stsw-stm32117.html )

    ../Src/main.c(69): warning:  #223-D: function "FLASH_Unlock" declared implicitly

    This is the main error I get, I also get multiple other errors which is because FLASH_Unlock doesnt work f.ex:

    ..\Src\eeprom.c(160): warning:  #223-D: function "FLASH_ErasePage" declared implicitly
              FlashStatus = FLASH_ErasePage(PAGE1_BASE_ADDRESS);
    ..\Src\eeprom.c(162): error:  #20: identifier "FLASH_COMPLETE" is undefined
              if (FlashStatus != FLASH_COMPLETE)
    ..\Src\eeprom.c(167): warning:  #223-D: function "FLASH_ProgramHalfWord" declared implicitly
              FlashStatus = FLASH_ProgramHalfWord(PAGE0_BASE_ADDRESS, VALID_PAGE);
    ..\Src\eeprom.c(179): error:  #20: identifier "FLASH_COMPLETE" is undefined
              if (FlashStatus != FLASH_COMPLETE)
    ..\Src\eeprom.c(192): error:  #20: identifier "FLASH_COMPLETE" is undefined
              if (FlashStatus != FLASH_COMPLETE)
    ..\Src\eeprom.c(200): warning:  #223-D: function "FLASH_ErasePage" declared implicitly
              FlashStatus = FLASH_ErasePage(PAGE1_BASE_ADDRESS);

Reply
  • I use eeprom emulation library for stm32f0xx.  ( https://www.st.com/content/st_com/en/products/embedded-software/mcu-mpu-embedded-software/stm32-embedded-software/stm32-standard-peripheral-library-expansion/stsw-stm32117.html )

    ../Src/main.c(69): warning:  #223-D: function "FLASH_Unlock" declared implicitly

    This is the main error I get, I also get multiple other errors which is because FLASH_Unlock doesnt work f.ex:

    ..\Src\eeprom.c(160): warning:  #223-D: function "FLASH_ErasePage" declared implicitly
              FlashStatus = FLASH_ErasePage(PAGE1_BASE_ADDRESS);
    ..\Src\eeprom.c(162): error:  #20: identifier "FLASH_COMPLETE" is undefined
              if (FlashStatus != FLASH_COMPLETE)
    ..\Src\eeprom.c(167): warning:  #223-D: function "FLASH_ProgramHalfWord" declared implicitly
              FlashStatus = FLASH_ProgramHalfWord(PAGE0_BASE_ADDRESS, VALID_PAGE);
    ..\Src\eeprom.c(179): error:  #20: identifier "FLASH_COMPLETE" is undefined
              if (FlashStatus != FLASH_COMPLETE)
    ..\Src\eeprom.c(192): error:  #20: identifier "FLASH_COMPLETE" is undefined
              if (FlashStatus != FLASH_COMPLETE)
    ..\Src\eeprom.c(200): warning:  #223-D: function "FLASH_ErasePage" declared implicitly
              FlashStatus = FLASH_ErasePage(PAGE1_BASE_ADDRESS);

Children
  • This is ST's code - nothing to do with ARM.

    The message does not say anything about the function being invalid in C99!

    "implicitly declared" means that you have failed to provide an explicit declaration - ie, either a prototype or definition of that function.

    With all those "undefined" errors, you have probably omitted to include a required header file.

    Or, perhaps, not correctly configured the project - so that the appropriate target-specific options are not defined.

    You need to go back to the ST documentation on how to properly set up a project using this library.

    ST should provide an example to get you started ...

  • Likely because you are not including one or more .H file.

    The settings for the Include Path pull from the wrong, or inappropriate place. ie not consistent with the .C file providing the functionality. The .C and .H need to be contemporaneous.

    The settings for the C/C++ command line don't define USE_STDPERIPH_DRIVER, etc