File tree Expand file tree Collapse file tree 1 file changed +11
-4
lines changed Expand file tree Collapse file tree 1 file changed +11
-4
lines changed Original file line number Diff line number Diff line change @@ -581,16 +581,23 @@ int can_device_calc_bittiming(uint32_t clock, const struct can_bittiming_const *
581581 timing -> phase_seg1 = tseg1 - timing -> prop_seg ;
582582 timing -> phase_seg2 = tseg2 ;
583583
584- if (!timing -> sjw || !timing_const -> sjw_max ) {
584+ if (!timing -> sjw && !timing_const -> sjw_max ) {
585+ /* fallback if sjw is unset and no device max value is known */
585586 timing -> sjw = SJW ;
586587 }
587588 else {
589+ if (!timing -> sjw ) {
590+ /* SJW shall not be bigger than phase segmet 2*/
591+ timing -> sjw = timing -> phase_seg2 ;
592+ }
593+ if (timing -> sjw > timing -> phase_seg1 ) {
594+ /* SJW shall not be bigger than phase segmet 1*/
595+ timing -> sjw = timing -> phase_seg1 ;
596+ }
588597 if (timing -> sjw > timing_const -> sjw_max ) {
598+ /* SJW shall not be bigger than its max value*/
589599 timing -> sjw = timing_const -> sjw_max ;
590600 }
591- if (timing -> sjw > tseg2 ) {
592- timing -> sjw = tseg2 ;
593- }
594601 }
595602
596603 timing -> brp = best_brp ;
You can’t perform that action at this time.
0 commit comments