This is the code used on my video series "Hybrid Supercapacitor Car Battery" for my own hardware monitoring system. THe videos can be found on madelectronengineering.com

Dependencies:   BurstSPI Fonts INA219 mbed LPC1114_WakeInterruptIn

Fork of SharpMemoryLCD by Paul Staron

Embed: (wiki syntax)

« Back to documentation index

WakeUp Class Reference

WakeUp Class Reference

Class to make wake up a microcontroller from deepsleep using a low-power timer. More...

#include <WakeUp.h>

Static Public Member Functions

static void set (uint32_t s)
 Set the timeout.
static void set_ms (uint32_t ms)
 Set the timeout.
static void attach (Callback< void()> function)
 Attach a function to be called after timeout.
static void calibrate (void)
 Calibrate the timer.
static void standby_then_reset (uint32_t ms)
 Enter Standby mode then Reset (available only for confirmed Nucleo boards)

Detailed Description

Class to make wake up a microcontroller from deepsleep using a low-power timer.

 // Depending on the LED connections either the LED is off the 2 seconds
 // the target spends in deepsleep(), and on for the other second. Or it is inverted 
 
 #include "mbed.h"
 #include "WakeUp.h"
 
 DigitalOut myled(LED1);
 
 int main() {
     wait(5);

     //The low-power oscillator can be quite inaccurate on some targets
     //this function calibrates it against the main clock
     WakeUp::calibrate();
    
     while(1) {
         //Set LED to zero
         myled = 0;
         
         //Set wakeup time for 2 seconds
         WakeUp::set_ms(2000);
         
         //Enter deepsleep, the program won't go beyond this point until it is woken up
         deepsleep();
         
         //Set LED for 1 second to one
         myled = 1;
         wait(1);
     }
 }

Definition at line 39 of file WakeUp.h.


Member Function Documentation

static void attach ( Callback< void()>  function ) [static]

Attach a function to be called after timeout.

This is optional, if you just want to wake up you do not need to attach a function.

Important: Many targets will run the wake-up routine at reduced clock speed, afterwards clock speed is restored. This means that clock speed dependent functions, such as printf might end up distorted.

 // Attaching regular function
 WakeUp::attach(&yourFunc);
 // Attaching member function inside another library    
 WakeUp::attach(callback(this, &YourLib::yourLibFunction));    

It uses the new Callback system to attach functions.

Parameters:
*functionfunction to call

Definition at line 80 of file WakeUp.h.

void calibrate ( void   ) [static]

Calibrate the timer.

Some of the low-power timers have very bad accuracy. This function calibrates it against the main timer.

Warning: Blocks for 100ms!

Definition at line 96 of file WakeUp_Freescale.cpp.

static void set ( uint32_t  s ) [static]

Set the timeout.

Parameters:
srequired time in seconds

Definition at line 47 of file WakeUp.h.

void set_ms ( uint32_t  ms ) [static]

Set the timeout.

Parameters:
msrequired time in milliseconds

Definition at line 21 of file WakeUp_Freescale.cpp.

void standby_then_reset ( uint32_t  ms ) [static]

Enter Standby mode then Reset (available only for confirmed Nucleo boards)

Parameters:
msrequired time in milliseconds

Definition at line 150 of file WakeUp_STM32_others.cpp.