Skip to content
GitLab
Explore
Sign in
Register
Primary navigation
Search or go to…
Project
Miosix Kernel
Manage
Activity
Members
Labels
Plan
Issues
Issue boards
Milestones
Wiki
Code
Merge requests
Repository
Branches
Commits
Tags
Repository graph
Compare revisions
Snippets
Build
Pipelines
Jobs
Pipeline schedules
Artifacts
Deploy
Releases
Container registry
Model registry
Operate
Environments
Monitor
Incidents
Analyze
Value stream analytics
Contributor analytics
CI/CD analytics
Repository analytics
Model experiments
Help
Help
Support
GitLab documentation
Compare GitLab plans
Community forum
Contribute to GitLab
Provide feedback
Keyboard shortcuts
?
Snippets
Groups
Projects
Show more breadcrumbs
Avionics
Software Development
Miosix Kernel
Commits
7d8a2963
Commit
7d8a2963
authored
4 years ago
by
Federico
Browse files
Options
Downloads
Patches
Plain Diff
Added deep sleep example
parent
f4ec05d0
Branches
Branches containing commit
No related tags found
2 merge requests
!40
Update to Miosix 2.7
,
!17
Draft: Improved miosix build system and fixed cmake scripts
Changes
1
Show whitespace changes
Inline
Side-by-side
Showing
1 changed file
miosix/_examples/deep_sleep/main-test.cpp
+69
-0
69 additions, 0 deletions
miosix/_examples/deep_sleep/main-test.cpp
with
69 additions
and
0 deletions
miosix/_examples/deep_sleep/main-test.cpp
0 → 100644
+
69
−
0
View file @
7d8a2963
/***************************************************************************
* Copyright (C) 2019 by Marsella Daniele *
* *
* This program is free software; you can redistribute it and/or modify *
* it under the terms of the GNU General Public License as published by *
* the Free Software Foundation; either version 2 of the License, or *
* (at your option) any later version. *
* *
* This program is distributed in the hope that it will be useful, *
* but WITHOUT ANY WARRANTY; without even the implied warranty of *
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the *
* GNU General Public License for more details. *
* *
* As a special exception, if other files instantiate templates or use *
* macros or inline functions from this file, or you compile this file *
* and link it with other works to produce a work based on this file, *
* this file does not by itself cause the resulting work to be covered *
* by the GNU General Public License. However the source code for this *
* file must still be made available in accordance with the GNU General *
* Public License. This exception does not invalidate any other reasons *
* why a work based on this file might be covered by the GNU General *
* Public License. *
* *
* You should have received a copy of the GNU General Public License *
* along with this program; if not, see <http://www.gnu.org/licenses/> *
***************************************************************************/
#include
<cstdio>
#include
"miosix.h"
#include
"interfaces/cstimer.h"
using
namespace
std
;
using
namespace
miosix
;
int
main
()
{
ContextSwitchTimer
&
cstimer
=
ContextSwitchTimer
::
instance
();
long
long
int
timeBefore
,
timeAfter
;
using
sleepLed
=
Gpio
<
GPIOD_BASE
,
13
>
;
// orange
using
deepSleepLed
=
Gpio
<
GPIOD_BASE
,
15
>
;
// blue
sleepLed
::
mode
(
Mode
::
OUTPUT
);
deepSleepLed
::
mode
(
Mode
::
OUTPUT
);
int
i
=
1
;
for
(;;)
{
printf
(
"Going into deep sleep
\n
"
);
fflush
(
stdout
);
delayMs
(
500
);
deepSleepLed
::
high
();
timeBefore
=
cstimer
.
getCurrentTime
();
Thread
::
sleep
(
i
*
1000
);
timeAfter
=
cstimer
.
getCurrentTime
();
deepSleepLed
::
low
();
printf
(
"Elapsed time: %lld
\n
"
,
timeAfter
-
timeBefore
);
{
DeepSleepLock
dl
;
printf
(
"Going into normal sleep
\n
"
);
fflush
(
stdout
);
delayMs
(
500
);
sleepLed
::
high
();
timeBefore
=
cstimer
.
getCurrentTime
();
Thread
::
sleep
(
i
*
1000
);
timeAfter
=
cstimer
.
getCurrentTime
();
sleepLed
::
low
();
printf
(
"Elapsed time: %lld
\n
"
,
timeAfter
-
timeBefore
);
}
i
++
;
}
}
This diff is collapsed.
Click to expand it.
Preview
0%
Loading
Try again
or
attach a new file
.
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Save comment
Cancel
Please
register
or
sign in
to comment