Exemplo n.º 1
0
/* use gpio 19, 20, 21 */
static int led_init(void *unused)
{
	gpio_init();
	gpio_dir_af(19, 1, 0, 0);
	gpio_dir_af(20, 1, 0, 0);
	gpio_dir_af(21, 1, 0, 0);
	return 0;
}
Exemplo n.º 2
0
/* Public methods follow */
static int w1_gpio_reset(struct w1_bus *bus)
{
    int ret;

    gpio_dir_af(bus->detail, GPIO_DIR_IN, 0, GPIO_AF_GPIO);
    gpio_dir(bus->detail, GPIO_DIR_OUT, 0);
    udelay(480); /* low pulse */
    gpio_dir(bus->detail, GPIO_DIR_IN, 0);
    udelay(100);
    ret = !gpio_get(bus->detail); /* 0 == present */
    udelay(480);
    if (!gpio_get(bus->detail))
        return 0; /* stuck low: not present */
    return ret;
}
Exemplo n.º 3
0
/* Public methods follow */
static int w1_gpio_reset(struct w1_bus *bus)
{
	int ret;

	gpio_dir_af(bus->detail, 0, 0, 0); /* input, novalue, af = 0 */
	gpio_dir(bus->detail, 1, 0); /* low pulse */
	udelay(480);
	gpio_dir(bus->detail, 0, 0); /* input */
	udelay(100);
	ret = !gpio_get(bus->detail); /* 0 == present */
	udelay(480);
	if (!gpio_get(bus->detail))
		return 0; /* stuck low: not present */
	return ret;
}
Exemplo n.º 4
0
/* Handshake */
int spidy_main(void *unused)
{
	int found=0, i=0;

	/* Gpio initialization */
	gpio_init();

        /* MOD GPIO DIR AF */
	for (i=0; i<18; i++)
	        gpio_dir_af(used_gpio[i], 1, 0, 0);
	i=0;

	puts("Your friendly neighborhood Spider-Man\n");

	/* FIXME: spidy_reset(); */

	/* Handshake */
	while (!found) {
		putc(CHAR_MSTART);

		/* read from RBR start character */
		if ( getCommand() == CHAR_SSTART)
			found=1;
	}
	putc(CHAR_MREADY);

	/* Take at least 18 commands --> BLOCKING */
	while (i<18) {
		/* ready to get buffer */
		while (!getBuffer())
			;

		/* if a buffer has been caught send a ready */
		i += saveBuffer();
		putc(CHAR_MREADY);
	}

	frameIndex=0;
	portNow=0;
	portLast=-1;

	return 0;
}
Exemplo n.º 5
0
static int lcd_cmd(struct spi_dev *dev, int cmd)
{
	uint8_t buf[1] = {cmd};
	struct spi_obuf sob = {.len = 1, .buf = buf};
	int ret;

	gpio_set(GPIODC, 0);
	ret = spi_write(dev, SPI_F_DEFAULT, &sob);
	return ret;
}

static int lcd_data(struct spi_dev *dev, int cmd)
{
	uint8_t buf[1] = {cmd};
	struct spi_obuf sob = {.len = 1, .buf = buf};
	int ret;

	gpio_set(GPIODC, 1);
	ret = spi_write(dev, SPI_F_DEFAULT, &sob);
	return ret;
}

static int lcd_task_init(void *arg)
{
	struct spi_dev *dev = arg;

	printf("%s: %i\n", __func__, __LINE__);
	/* My board other devices on SPI: disable their CS */
	gpio_dir_af(GPIOCS_NO0, 1, 1, 0);
	gpio_set(GPIOCS_NO0, 1);
	gpio_dir_af(GPIOCS_NO1, 1, 1, 0);
	gpio_set(GPIOCS_NO1, 1);
	/* This is our gpio and the reset */
	gpio_dir_af(GPIOCS, 1, 1, 0);
	gpio_set(GPIOCS, 1);
	gpio_dir_af(13, 1, 1, 0);
	gpio_set(13, 1);

	/* d/c */
	gpio_dir_af(GPIODC, 1, 1, 0);
	gpio_set(GPIODC, 1);

	spi_create(&spi_dev);

	lcd_cmd(dev, 0x21);
	lcd_cmd(dev, 0x90);
	lcd_cmd(dev, 0x20);
	lcd_cmd(dev, 0x0c);

	return 0;
}

/* The task sends out one packet and reads pending ones */
static void *lcd_task_run(void *arg)
{
	struct spi_dev *dev = arg;
	static u8 inpacket[50];
	int i, j;

	printf("%s: %i\n", __func__, __LINE__);
	printf("cmd: %i\n", i);

	for (j = 0; j < 0x20; j++)
		i = lcd_data(dev, j);

	return dev;
}

static struct bathos_task __task t_lcd = {
	.name = "n5110", .period = HZ,
	.arg = &spi_dev,
	.init = lcd_task_init, .job = lcd_task_run,
	.release = 15
};