File Coverage

blib/lib/VIC/PIC/Functions/Power.pm
Criterion Covered Total %
statement 22 24 91.6
branch 4 6 66.6
condition n/a
subroutine 6 6 100.0
pod 0 1 0.0
total 32 37 86.4


line stmt bran cond sub pod time code
1             package VIC::PIC::Functions::Power;
2 31     31   15296 use strict;
  31         45  
  31         726  
3 31     31   116 use warnings;
  31         36  
  31         1252  
4             our $VERSION = '0.31';
5             $VERSION = eval $VERSION;
6 31     31   117 use Carp;
  31         37  
  31         1456  
7 31     31   123 use POSIX ();
  31         38  
  31         408  
8 31     31   88 use Moo::Role;
  31         37  
  31         153  
9              
10             sub sleep {
11 2     2 0 13 my $self = shift;
12 2 50       5 unless ($self->doesrole('Power')) {
13 0         0 carp $self->type . " does not support sleep\n";
14 0         0 return;
15             }
16 2 50       13 if (defined $self->chip_config->{on_off}) {
17 2         11 foreach (keys %{$self->chip_config->{on_off}}) {
  2         10  
18 14 100       39 $self->chip_config->{on_off}->{$_} = 1 if $_ =~ /PWRTE|WDT/;
19             }
20             }
21             # best to clear the WDT before sleep always
22 2         5 return << "...";
23             \tclrwdt ;; ensure WDT is cleared
24             \tsleep
25             \tnop ;; in case the user is using interrupts to wake up
26             ...
27             }
28              
29             1;
30             __END__