Have a look here:
Should give you some ideas. Most ST’s operate the same way. More info here too: https://os.mbed.com/docs/mbed-os/v6.2/apis/power-management-sleep.html