Example #1
0
int gpio_decode_number(unsigned gpio_list[], int count)
{
	int result = 0;
	int multiplier = 1;
	int gpio, i, value;
	enum mvl3 mvl3;

	for (i = 0; i < count; i++) {
		gpio = gpio_list[i];

		mvl3 = gpio_read_mvl3(gpio);
		if (mvl3 == LOGIC_1)
			value = 2;
		else if (mvl3 == LOGIC_0)
			value = 1;
		else if (mvl3 == LOGIC_Z)
			value = 0;
		else
			return -1;

		result += value * multiplier;
		multiplier *= 3;
	}

	return result;
}
Example #2
0
static int board_get_config(void)
{
	int i;
	int id0, id1;
	enum board_config config = DAISY_CONFIG_UNKNOWN;

	id0 = gpio_read_mvl3(BOARD_ID0_GPIO);
	id1 = gpio_read_mvl3(BOARD_ID1_GPIO);
	if (id0 < 0 || id1 < 0)
		return -1;

	for (i = 0; i < ARRAY_SIZE(id_map); i++) {
		if (id0 == id_map[i].id0 && id1 == id_map[i].id1) {
			config = id_map[i].config;
			break;
		}
	}

	return config;
}