/* Assert that a sample point is within a specified margin. 
Assert that values of a CAN timing struct results in a specified sample point within a given margin. */
static void assert_sp_within_margin(struct can_timing *timing, uint16_t sp, uint16_t sp_margin)
/* Assert that a sample point is within a specified margin. 
Assert that values of a CAN timing struct results in a specified sample point within a given margin. */
static void assert_sp_within_margin(struct can_timing *timing, uint16_t sp, uint16_t sp_margin)
{
	const uint32_t ts = 1 + timing->prop_seg + timing->phase_seg1 + timing->phase_seg2;
	const uint16_t sp_calc = ((1 + timing->prop_seg + timing->phase_seg1) * 1000) / ts;
	zassert_within(sp, sp_calc, sp_margin,
		       "sample point %d not within calculated sample point %d +/- %d",
		       sp, sp_calc, sp_margin);
}