7,166
edits
Line 452: | Line 452: | ||
avr/sleep.h のコメント読む... | avr/sleep.h のコメント読む... | ||
<syntaxhighlight lang="c" enclose="div"> | <syntaxhighlight lang="c" enclose="div"> | ||
#include <avr/sleep.h> | #include <avr/sleep.h> | ||
... | ... | ||
set_sleep_mode(<mode>); | set_sleep_mode(<mode>); | ||
sleep_mode(); | sleep_mode(); | ||
</syntaxhighlight> | </syntaxhighlight> | ||
<syntaxhighlight lang="c" enclose="div"> | <syntaxhighlight lang="c" enclose="div"> | ||
#include <avr/interrupt.h> | #include <avr/interrupt.h> | ||
#include <avr/sleep.h> | #include <avr/sleep.h> | ||
... | ... | ||
set_sleep_mode(<mode>); | set_sleep_mode(<mode>); | ||
cli(); | cli(); | ||
if (some_condition) | if (some_condition) | ||
{ | { | ||
sleep_enable(); | sleep_enable(); | ||
sei(); | sei(); | ||
sleep_cpu(); | sleep_cpu(); | ||
sleep_disable(); | sleep_disable(); | ||
} | } | ||
sei(); | sei(); | ||
</syntaxhighlight> | </syntaxhighlight> | ||
<syntaxhighlight lang="c" enclose="div"> | <syntaxhighlight lang="c" enclose="div"> | ||
#include <avr/interrupt.h> | #include <avr/interrupt.h> | ||
#include <avr/sleep.h> | #include <avr/sleep.h> | ||
... | ... | ||
set_sleep_mode(<mode>); | set_sleep_mode(<mode>); | ||
cli(); | cli(); | ||
if (some_condition) | if (some_condition) | ||
{ | { | ||
sleep_enable(); | sleep_enable(); | ||
sleep_bod_disable(); | sleep_bod_disable(); | ||
sei(); | sei(); | ||
sleep_cpu(); | sleep_cpu(); | ||
sleep_disable(); | sleep_disable(); | ||
} | } | ||
sei(); | sei(); | ||
</syntaxhighlight> | </syntaxhighlight> | ||