In principle, it is possible to switch from an STM32L1xx to an STM32F401 if the general conditions are right and the peripherals are available. USB is also used in your main.c, for which you should check the clock settings in the F401. However, it will probably not be possible to switch without debugging.
But if you also use EEPROM in the L1xx, which is not visible in main.c, then it becomes a little more difficult because the F401 does not contain a native EEPROM and can only emulate it.
Regards /Peter
In order to give better visibility on the answered topics, please click on Accept as Solution on the reply which solved your issue or answered your question.
It always depends on the user's experience whether something is easy, difficult or complex. Generating the main program from an IOC and thus the complex process of configuring the peripherals is done with just a few clicks, the actual work of writing the actual program comes afterwards.
Good luck! /Peter
In order to give better visibility on the answered topics, please click on Accept as Solution on the reply which solved your issue or answered your question.