Beispiel #1
0
uint8
cs84xx_read_gpio(ice1712 *ice, uint8 reg_addr, uint8 chip_select)
{
	uint8 tmp, data;

	tmp = read_gpio(ice);
	tmp |= ice->CommLines.cs_mask;
	tmp &= ~(chip_select);

	write_gpio(ice, tmp);
	snooze(GPIO_I2C_DELAY);

	write_gpio_byte(ice, (CS84xx_CHIP_ADDRESS & 0x7F) << 1,
                tmp); //For writing the MAP
	write_gpio_byte(ice, reg_addr & 0x7F, tmp); //Do not Increment

	tmp |= chip_select; //Deselect the chip
	write_gpio(ice, tmp);
	snooze(GPIO_I2C_DELAY);

	tmp &= ~(chip_select); //Reselect the chip
	write_gpio(ice, tmp);
	snooze(GPIO_I2C_DELAY);

	write_gpio_byte(ice, (CS84xx_CHIP_ADDRESS & 0x7F) << 1 | 1,
                tmp); //For writing the MAP
	data = read_gpio_byte(ice, tmp); //For reading

	tmp |= chip_select; //Deselect the chip
	write_gpio(ice, tmp);

	return data;
}
void* RecoveryUI::gpio_thread(void *cookie){
    int i=0;
    printf("gpio thread start!\n");
    for(;;){
        i = ~i;
        usleep(self->LED_FLICKER*1000);
        if(i){
            write_gpio("1");
        }else{
            write_gpio("0");
        }

    }
    return NULL;
}
Beispiel #3
0
static void write_gpios(void *arg, long period)
{
    gpio_t *s;

    s = arg;
    while ( s != NULL ) {
	write_gpio(s, period);
	s = s->next;
    }
}
Beispiel #4
0
void
cs84xx_write_gpio(ice1712 *ice, uint8 reg_addr, uint8 data, uint8 chip_select)
{
	uint8 tmp;

	tmp = read_gpio(ice);
	tmp |= ice->CommLines.cs_mask;
	tmp &= ~(chip_select);

	write_gpio(ice, tmp);
	snooze(GPIO_I2C_DELAY);

	write_gpio_byte(ice, (CS84xx_CHIP_ADDRESS & 0x7F) << 1, tmp);
	write_gpio_byte(ice, reg_addr & 0x7F, tmp); //Do not Increment
	write_gpio_byte(ice, data, tmp);

	tmp |= chip_select;
	write_gpio(ice, tmp);
	snooze(GPIO_I2C_DELAY);
}
Beispiel #5
0
void
ak45xx_write_gpio(ice1712 *ice, uint8 reg_addr, uint8 data, uint8 chip_select)
{
	uint8 tmp;

	tmp = read_gpio(ice);
	tmp |= ice->CommLines.cs_mask;
	tmp &= ~(chip_select);

	write_gpio(ice, tmp);
	snooze(GPIO_I2C_DELAY);

	write_gpio_byte(ice, ((AK45xx_CHIP_ADDRESS & 0x03) << 6) | 0x20
                    | (reg_addr & 0x1F), tmp);
	write_gpio_byte(ice, data, tmp);

	tmp |= chip_select;
	write_gpio(ice, tmp);
	snooze(GPIO_I2C_DELAY);
}
Beispiel #6
0
void
write_gpio_byte(ice1712 *ice, uint8 data, uint8 gpio_data)
{
	int i;

	for (i = 7; i >= 0; i--) {
		// drop clock and data bits
		gpio_data &= ~(ice->CommLines.clock | ice->CommLines.data_out);

		// set data bit if needed
		if (data & (1 << i))
			gpio_data |= ice->CommLines.data_out;

		write_gpio(ice, gpio_data);
		snooze(GPIO_I2C_DELAY);

		// raise clock
		gpio_data |= ice->CommLines.clock;
		write_gpio(ice, gpio_data);
		snooze(GPIO_I2C_DELAY);
	}
}
Beispiel #7
0
uint8
read_gpio_byte(ice1712 *ice, uint8 gpio_data)
{
	int i;
	uint8 data = 0;

	for (i = 7; i >= 0; i--) {
		// drop clock
		gpio_data &= ~(ice->CommLines.clock);
		write_gpio(ice, gpio_data);
		snooze(GPIO_I2C_DELAY);

		if (read_gpio(ice) &  ice->CommLines.data_in)
			data |= 1 << i;

		gpio_data |= ice->CommLines.clock;

		write_gpio(ice, gpio_data);
		snooze(GPIO_I2C_DELAY);
	}

	return data;
}
Beispiel #8
0
int *gpio_thread(void *ptr)
{
    init_gpio ();
    while (running)
    {
        //Read from the GPIO queue and send to the sound queue
        if (!queue_empty (&gpio_input_q))
            queue_add (&sfx_q, (queue_remove (&gpio_input_q)));

        //Write to the sound queue and send out to the WPC CPU
        if (!queue_empty (&gpio_output_q) && !output_waiting)
            write_gpio (queue_remove (&gpio_output_q));
    }
    digitalWrite (STATUS_LED, 0);
    if (verbose)
        fprintf (stdout, "GPIO thread stopped\n");
    return 0;
}
int write_register(char *flag, unsigned char mask)
{
	unsigned char val[2];

	if(read_gpio(val) < 0)
		return -1;

	if(strcmp("high", flag) == 0)
		val[0] |= mask;
	else if(strcmp("low", flag) == 0)
		val[0] &= ~mask;
	else
		return -1;

	if(write_gpio(val) < 0)
		return -1;

	return read_register(mask);
}
int main(int ac, char *av[])
{
	int ret=0;

	if(ac < 2 || ac > 4){
		usage(av[0]);
		return -1;
	}

	if(strncmp(QUIET, av[1], strlen(QUIET)) == 0)
		quiet = 1;

	if(strncmp(INIT, av[1], strlen(INIT)) == 0){
		if((ret = init_gpio(av[2])) == -1)
			return -1;
		if(!quiet)
			printf("%02x\n", ret);
	}
	else if(strncmp(READ, av[1], strlen(READ)) == 0){
		if((ret = read_gpio()) < 0)
			return -1;
		if(!quiet)
			printf("%02x\n", ret);
	}
	else if(strncmp(WRITE, av[1], strlen(WRITE)) == 0){
		if(write_gpio(av[2]) < 0)
			return -1;
		if((ret = read_gpio()) < 0)
			return -1;
		if(!quiet)
			printf("%02x\n", ret);
	}
	else{
		usage(av[0]);
		return -1;
	}

	return ret;
}
Beispiel #11
0
// schaltet eine LED an und alle anderen 7 aus
static void turn_on_led(uint8_t nrled)
{
    uint32_t led = 1u << (8+(nrled&0x7));
    write_gpio(GPIOE, led/*on*/, GPIO_PINS(15,8)&~led/*off*/);
}