[gen3] hal: fixes early wakeup by RTC from STOP sleep mode #1803
For some reason when we are configuring the RTC before going into STOP sleep mode, the prescaler writes don't take effect. This can only happen if the RTC is not stopped, but it should have been stopped by that point.
This PR adds an ugly hack of looping and checking that the prescaler setting did take effect. We are also adding a similar hack to OpenThread alarm code just in case.
If anybody has better ideas on how to resolve this, I'll be more than willing to change this. I've tried various barriers (DMB, DSB and ISB) at multiple places but wasn't completely able to mitigate the issue. Perhaps a dummy prescaler read is what actually helps?
Steps to Test / Example App
See a test from #1789