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   17830 use strict;
  31         66  
  31         736  
3 31     31   130 use warnings;
  31         49  
  31         1165  
4             our $VERSION = '0.32';
5             $VERSION = eval $VERSION;
6 31     31   141 use Carp;
  31         61  
  31         1191  
7 31     31   145 use POSIX ();
  31         58  
  31         358  
8 31     31   108 use Moo::Role;
  31         45  
  31         144  
9              
10             sub sleep {
11 2     2 0 15 my $self = shift;
12 2 50       112 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         4 foreach (keys %{$self->chip_config->{on_off}}) {
  2         11  
18 14 100       60 $self->chip_config->{on_off}->{$_} = 1 if $_ =~ /PWRTE|WDT/;
19             }
20             }
21             # best to clear the WDT before sleep always
22 2         75 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__