LCOV - code coverage report
Current view: top level - util/timing_util.c (source / functions) Coverage Total Hit
Test: coverage-filtered.info Lines: 100.0 % 32 32
Test Date: 2026-04-29 08:47:32 Functions: 100.0 % 1 1
Branches: 100.0 % 6 6
MC/DC: 100.0 % 2 2

             Branch data      MC/DC data    Line data    Source code
       1                 :              :             : #include <stdint.h>
       2                 :              :             : 
       3                 :              :             : #include "common.h"
       4                 :              :             : 
       5                 :              :             : #include "can.h"
       6                 :              :             : #include "timing_util.h"
       7                 :              :             : 
       8                 :              :             : #if (CANLIB_BIT_TIME_US != 4)
       9                 :              :             : #warning "the bit time that can.h is expecting is not what timing_util is expecting"
      10                 :              :             : #endif
      11                 :              :             : 
      12                 :              :           5 : w_status_t can_generate_timing_params(uint32_t system_freq, can_timing_t *timing) {
      13         [ +  + ]:      [ T  F ]:           5 :         w_assert(timing);
      14                 :              :             : 
      15                 :              :             :         // this function is designed to create a bit time of 4 microseconds
      16   [ +  +  +  + ]:              :           4 :         switch (system_freq) {
      17                 :              :           1 :                 case 48000000:
      18                 :              :           1 :                         timing->brp = 7;
      19                 :              :           1 :                         timing->sjw = 3;
      20                 :              :           1 :                         timing->btlmode = 1;
      21                 :              :           1 :                         timing->sam = 0;
      22                 :              :           1 :                         timing->seg1ph = 4;
      23                 :              :           1 :                         timing->prseg = 0;
      24                 :              :           1 :                         timing->seg2ph = 4;
      25                 :              :           1 :                         return W_SUCCESS;
      26                 :              :           1 :                 case 12000000:
      27                 :              :           1 :                         timing->brp = 1;
      28                 :              :           1 :                         timing->sjw = 3;
      29                 :              :           1 :                         timing->btlmode = 1;
      30                 :              :           1 :                         timing->sam = 0;
      31                 :              :           1 :                         timing->seg1ph = 4;
      32                 :              :           1 :                         timing->prseg = 0;
      33                 :              :           1 :                         timing->seg2ph = 4;
      34                 :              :           1 :                         return W_SUCCESS;
      35                 :              :           1 :                 case 6000000:
      36                 :              :           1 :                         timing->brp = 0;
      37                 :              :           1 :                         timing->sjw = 3;
      38                 :              :           1 :                         timing->btlmode = 1;
      39                 :              :           1 :                         timing->sam = 0;
      40                 :              :           1 :                         timing->seg1ph = 4;
      41                 :              :           1 :                         timing->prseg = 0;
      42                 :              :           1 :                         timing->seg2ph = 4;
      43                 :              :           1 :                         return W_SUCCESS;
      44                 :              :           1 :                 default:
      45                 :              :             :                         // unhandled can frequency, just abort
      46                 :              :           1 :                         return W_INVALID_PARAM;
      47                 :              :             :         }
      48                 :              :             : }
        

Generated by: LCOV version 2.0-1