Revised by I. Cserny

Dependents:   Lab04_Check_StandBy_os2 Lab04_wakeup_STM32

Embed: (wiki syntax)

« Back to documentation index

Show/hide line numbers WakeUp_STM32.h Source File

WakeUp_STM32.h

00001 /*
00002 
00003     Original idea & program
00004     https://os.mbed.com/users/Sissors/code/WakeUp/
00005         by Erik
00006  */
00007 
00008 /*
00009  *  Modified only for STM CPU
00010  *      by Kenji Arai / JH1PJL
00011  *
00012  *  http://www7b.biglobe.ne.jp/~kenjia/
00013  *  http://mbed.org/users/kenjiArai/
00014  *      Created:    September  21st, 2017
00015  *      Revised:    March      12th, 2020
00016  */
00017 /*
00018  *  Modified for correcting few typos
00019  *  by Istvan Cserny on Nov 11, 2021.
00020  *  last revised: Nov 12, 2021.
00021  */
00022  
00023 #include "mbed.h"
00024 
00025 /**
00026  * Class to make wake up a STM CPU from deepsleep using a low-power timer. 
00027  *
00028  * @code
00029  * 
00030  * #include "mbed.h"
00031  * #include "WakeUp_STM32.h"
00032  * 
00033  * DigitalOut myled(LED1);
00034  * 
00035  * int main() {
00036  *     uint32_t loop_count = 1;
00037  *     wait(1);
00038  *     while(true) {
00039  *         myled = !myled;
00040  *         if (++loop_count > 4) {
00041  *             WakeUp::standby_then_reset(30000);  // 30sec
00042  *             while(true) {;} // never executing this line
00043  *         }
00044  *     }
00045  * }
00046  * @endcode
00047  */
00048 class WakeUp
00049 {
00050 public:
00051     /**
00052     * Enter Standby mode then Reset
00053     * @param ms required time in milliseconds
00054     */
00055     static void standby_then_reset(uint32_t ms);
00056 
00057 private:
00058     static Callback<void()> callback;
00059     static void irq_handler(void);
00060     static void set_ms(uint32_t ms);
00061     static float cycles_per_ms;
00062 };