Line | Branch | Exec | Source |
---|---|---|---|
1 | #include <stdio.h> | ||
2 | #include <errno.h> | ||
3 | |||
4 | #include <powertask/energy.h> | ||
5 | |||
6 | /* ------------------------------------------------------------------------------------------------------------------ */ | ||
7 | /* Private API */ | ||
8 | /* ------------------------------------------------------------------------------------------------------------------ */ | ||
9 | |||
10 | /* ------------------------------------------------------------------------------------------------------------------ */ | ||
11 | /* Public API */ | ||
12 | /* ------------------------------------------------------------------------------------------------------------------ */ | ||
13 | |||
14 | 5 | int powertask_get_available_energy(powertask_energy_source_t *energy_source){ | |
15 | int voltage_mV, capacitance_uF; | ||
16 | |||
17 |
2/2✓ Branch 0 taken 1 times.
✓ Branch 1 taken 4 times.
|
5 | if(energy_source == NULL){ |
18 | 1 | return -EINVAL; | |
19 | } | ||
20 | |||
21 |
4/4✓ Branch 0 taken 2 times.
✓ Branch 1 taken 2 times.
✓ Branch 2 taken 1 times.
✓ Branch 3 taken 1 times.
|
4 | if(energy_source->capacitance == 0 || energy_source->get_voltage == NULL){ |
22 | 3 | return -EINVAL; | |
23 | } | ||
24 | |||
25 | 1 | voltage_mV = energy_source->get_voltage(); | |
26 | 1 | capacitance_uF = energy_source->capacitance; | |
27 | |||
28 | 1 | return capacitance_uF * voltage_mV * voltage_mV * (1/2000000); | |
29 | } | ||
30 |