コード例 #1
0
ファイル: lcd.c プロジェクト: plumbum/easyface
static void lcdPrepareWrite(void)
{
    CMD_WRITE();
    PIN_OUT(LCD_D0);
    PIN_OUT(LCD_D1);
    PIN_OUT(LCD_D2);
    PIN_OUT(LCD_D3);
    PIN_OUT(LCD_D4);
    PIN_OUT(LCD_D5);
    PIN_OUT(LCD_D6);
    PIN_OUT(LCD_D7);
}
コード例 #2
0
static int __write_reg(struct tps6524x *hw, int reg, int val)
{
	int error = 0;
	u16 cmd = CMD_WRITE(reg), out = val;
	u8 status;
	struct spi_message m;
	struct spi_transfer t[3];

	spi_message_init(&m);
	memset(t, 0, sizeof(t));

	t[0].tx_buf = &cmd;
	t[0].len = 2;
	t[0].bits_per_word = 12;
	spi_message_add_tail(&t[0], &m);

	t[1].tx_buf = &out;
	t[1].len = 2;
	t[1].bits_per_word = 16;
	spi_message_add_tail(&t[1], &m);

	t[2].rx_buf = &status;
	t[2].len = 1;
	t[2].bits_per_word = 4;
	spi_message_add_tail(&t[2], &m);

	error = spi_sync(hw->spi, &m);
	if (error < 0)
		return error;

	dev_dbg(hw->dev, "wrote reg %d, data %x, status %x\n",
		reg, out, status);

	if (!(status & STAT_CLK) || !(status & STAT_WRITE))
		return -EIO;

	if (status & (STAT_INVALID | STAT_WP))
		return -EINVAL;

	return error;
}