STM32F405 code compatibility with STM32F407
The STM32F407 is a strict superset of the STM32F405. (Indeed, they share a single datasheet.) As long as you're working with the same package and flash size, code that runs on the '405 will work identically on the '407.