Lines Matching refs:timing

75 static void assert_bitrate_correct(const struct device *dev, struct can_timing *timing,  in assert_bitrate_correct()  argument
78 const uint32_t ts = 1 + timing->prop_seg + timing->phase_seg1 + timing->phase_seg2; in assert_bitrate_correct()
83 zassert_not_equal(timing->prescaler, 0, "prescaler is zero"); in assert_bitrate_correct()
88 bitrate_calc = core_clock / timing->prescaler / ts; in assert_bitrate_correct()
101 static void assert_timing_within_bounds(struct can_timing *timing, in assert_timing_within_bounds() argument
105 zassert_true(timing->sjw <= max->sjw, "sjw exceeds max"); in assert_timing_within_bounds()
106 zassert_true(timing->prop_seg <= max->prop_seg, "prop_seg exceeds max"); in assert_timing_within_bounds()
107 zassert_true(timing->phase_seg1 <= max->phase_seg1, "phase_seg1 exceeds max"); in assert_timing_within_bounds()
108 zassert_true(timing->phase_seg2 <= max->phase_seg2, "phase_seg2 exceeds max"); in assert_timing_within_bounds()
109 zassert_true(timing->prescaler <= max->prescaler, "prescaler exceeds max"); in assert_timing_within_bounds()
111 zassert_true(timing->sjw >= min->sjw, "sjw lower than min"); in assert_timing_within_bounds()
112 zassert_true(timing->prop_seg >= min->prop_seg, "prop_seg lower than min"); in assert_timing_within_bounds()
113 zassert_true(timing->phase_seg1 >= min->phase_seg1, "phase_seg1 lower than min"); in assert_timing_within_bounds()
114 zassert_true(timing->phase_seg2 >= min->phase_seg2, "phase_seg2 lower than min"); in assert_timing_within_bounds()
115 zassert_true(timing->prescaler >= min->prescaler, "prescaler lower than min"); in assert_timing_within_bounds()
128 static void assert_sp_within_margin(struct can_timing *timing, uint16_t sp, uint16_t sp_margin) in assert_sp_within_margin() argument
130 const uint32_t ts = 1 + timing->prop_seg + timing->phase_seg1 + timing->phase_seg2; in assert_sp_within_margin()
131 const uint16_t sp_calc = ((1 + timing->prop_seg + timing->phase_seg1) * 1000) / ts; in assert_sp_within_margin()
153 struct can_timing timing = { 0 }; in test_timing_values() local
164 sp_err = can_calc_timing_data(dev, &timing, test->bitrate, test->sp); in test_timing_values()
171 sp_err = can_calc_timing(dev, &timing, test->bitrate, test->sp); in test_timing_values()
183 timing.sjw, timing.prop_seg, timing.phase_seg1, timing.phase_seg2, in test_timing_values()
184 timing.prescaler); in test_timing_values()
186 assert_bitrate_correct(dev, &timing, test->bitrate); in test_timing_values()
187 assert_timing_within_bounds(&timing, min, max); in test_timing_values()
188 assert_sp_within_margin(&timing, test->sp, SAMPLE_POINT_MARGIN); in test_timing_values()
191 err = can_set_timing_data(dev, &timing); in test_timing_values()
193 err = can_set_timing(dev, &timing); in test_timing_values()