FastArduino v1.10
C++ library to build fast but small Arduino/AVR projects
Loading...
Searching...
No Matches
power.h
Go to the documentation of this file.
1// Copyright 2016-2023 Jean-Francois Poilpret
2//
3// Licensed under the Apache License, Version 2.0 (the "License");
4// you may not use this file except in compliance with the License.
5// You may obtain a copy of the License at
6//
7// http://www.apache.org/licenses/LICENSE-2.0
8//
9// Unless required by applicable law or agreed to in writing, software
10// distributed under the License is distributed on an "AS IS" BASIS,
11// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
12// See the License for the specific language governing permissions and
13// limitations under the License.
14
16
21#ifndef POWER_HH
22#define POWER_HH
23
24#include "boards/board.h"
25
29namespace power
30{
32 extern void sleep(uint8_t mode);
34
39 class Power
40 {
41 public:
43 Power() = delete;
45
54 {
55 default_mode_ = mode;
56 }
57
69 static void sleep()
70 {
71 sleep(default_mode_);
72 }
73
84 static void sleep(board::SleepMode mode)
85 {
86 ::power::sleep((uint8_t) mode);
87 }
88
89 private:
90 static board::SleepMode default_mode_;
91 };
92}
93
94#endif /* POWER_HH */
This class contains the API for handling power sleep modes.
Definition: power.h:40
static void set_default_mode(board::SleepMode mode)
Set the default sleep mode, that will be used by next calls to Power::sleep() and time::yield().
Definition: power.h:53
static void sleep()
Enter power sleep mode as defined by Power::set_default_mode().
Definition: power.h:69
static void sleep(board::SleepMode mode)
Enter a specific power sleep mode.
Definition: power.h:84
SleepMode
Defines all available sleep modes for target MCU.
Definition: empty.h:119
Defines simple API to handle AVR power sleep modes.
Definition: power.h:30