I love seeking (and finding) answers. A little google searching later:
The __IO is just a macro defined in the STM32 Firmware libraries. Just right-click on it and select “Go to definition” under Ride7 and you will see that it just defines the variable as “volatile”.
The Delay() function from our examples is not properly calibrated. Its goal is only to wait for a given period of time, hence it just loops doing nothing a given number of times. You will have to manually calibrate it if you need some specific precision. However, the calibration will change if you recompile the application with a different optimization level, so you should not consider our Delay() function as accurate.
If precise delays are required, you should consider taking advantage of the the STM32 timers.
So then what’s volatile good for you ask? 1st and more importantly 2nd answer here:
Another use for volatile is signal handlers. If you have code like this:
quit = 0;
/* very small loop which is completely visible to the compiler */
The compiler is allowed to notice the loop body does not touch the quit variable and convert the loop to a while (true) loop. Even if the quit variable is set on the signal handler for SIGINT and SIGTERM; the compiler has no way to know that.
However, if the quit variable is declared volatile, the compiler is forced to load it every time, because it can be modified elsewhere. This is exactly what you want in this situation.
And that’s exactly what we want in our situation