/* Set the receive buffer size for a given USB endpoint. */
static uint16_t calc_ep_count_rx(uint16_t *size)
/* Set the receive buffer size for a given USB endpoint. */
static uint16_t calc_ep_count_rx(uint16_t *size)
{
	uint16_t size_value = *size, reg;
	if (size_value > 62) {
		uint16_t blocks_32byte = DIVIDE_AND_CEIL(size_value, 32) & 0x1F;
		size_value = blocks_32byte * 32;
		reg = USB_EP_COUNT_RX_BL_SIZE |
				USB_EP_COUNT_RX_NUM_BLOCK(blocks_32byte - 1);
	} else {
		uint16_t blocks_2byte = DIVIDE_AND_CEIL(size_value, 2) & 0x1F;
		size_value = blocks_2byte * 2;
		reg = USB_EP_COUNT_RX_NUM_BLOCK(blocks_2byte);
	}
	*size = size_value;
	return reg;
}