/* This function is used to calculate the minimum necessary DLC code for a number of bytes. */
enum can_ctrl_dlc can_ctrl_size_to_dlc(uint8_t size)
/* This function is used to calculate the minimum necessary DLC code for a number of bytes. */
enum can_ctrl_dlc can_ctrl_size_to_dlc(uint8_t size)
{
	if(size > 64)
		return CAN_DLC_TOO_SMALL;
	if((size > 8) && (size <= 12))
		return CAN_DLC_12;
	if((size > 12) && (size <= 16))
		return CAN_DLC_16;
	if((size > 16) && (size <= 20))
		return CAN_DLC_20;
	if((size > 20) && (size <= 24))
		return CAN_DLC_24;
	if((size > 24) && (size <= 32))
		return CAN_DLC_32;
	if((size > 32) && (size <= 48))
		return CAN_DLC_48;
	if((size > 48) && (size <= 64))
		return CAN_DLC_64;
	return size;
}