Ejemplo n.º 1
0
static void set_pni_config(void)
{  
	u8 i;
	for(i=0;i<2;i++)
	{
		spi_write8(CMM,pni[i].Mode,i);
		spi_write8(TMRC,pni[i].Update_Rate,i);
		spi_write16(CCX,pni[i].Gian[X_AXIS],i);
		spi_write16(CCY,pni[i].Gian[Y_AXIS],i);
		spi_write16(CCZ,pni[i].Gian[Z_AXIS],i); 
	}  
}  
Ejemplo n.º 2
0
static void bus_spi_write(uint8_t c)
{
    spi_write8(c);
    console_puts("WRITE: 0x");
    console_puthex8(c);
    console_newline();
}
Ejemplo n.º 3
0
static void bus_spi_read(void)
{
    uint8_t c;
    c = spi_write8(0xFF);
    console_puts("READ: 0x");
    console_puthex8(c);
    console_newline();
}
Ejemplo n.º 4
0
s32 _spi_write8(struct intf_hdl *pintfhdl, u32 addr, u8 val)
{
	s32 err;

_func_enter_;

	spi_write8(pintfhdl->padapter, addr, val, &err);

_func_exit_;

	return err;
}
Ejemplo n.º 5
0
static int s3c24xx_spi_txrx(struct spi_device *spi, struct spi_transfer *t)
{
	struct s3c24xx_spi *hw = to_hw(spi);
	int i=0;
	//static int flag=1;
	//unsigned char data1,data2;
	//char cmd[4]={0x38,0x80,0xab,0xcd};
	hw->tx = t->tx_buf;
	hw->rx = t->rx_buf;
	hw->len = t->len;
	hw->count = 0;

	//init_completion(&hw->done);

	//hw->fiq_inuse = 0;
	//if (s3c24xx_spi_usefiq(hw) && t->len >= 3)
	//	s3c24xx_spi_tryfiq(hw);
	//writeb(hw_txbyte(hw, 0), hw->regs + S3C2410_SPTDAT);

	//wait_for_completion(&hw->done);
	for (i = 0; i < t->len; i=i+1) 
	{
		spi_write8(hw,hw_txbyte(hw,i));
		if(hw->rx)
			hw->rx[i]=spi_read8(hw);
	//	udelay(2);
    }
	hw->count = hw->len;
	#if 0
	//for(i=0;i<hw->len;i++)
	//printk("%02x ",hw->tx[i]);
	//printk("==>\n");
	/* send the first byte */
	if(flag){
	for (i = 0; i < 4; i=i+2) 
	{
		spi_write8(hw,cmd[i]);
		spi_write8(hw,cmd[i+1]);
		udelay(2);
    }
	flag=0;
	
	//s3c24xx_spi_chipsel(spi,BITBANG_CS_INACTIVE);
		}
	else
		{
	//s3c24xx_spi_chipsel(spi,BITBANG_CS_INACTIVE);
	//udelay(500);
	//s3c24xx_spi_chipsel(spi,BITBANG_CS_ACTIVE);
	spi_write8(hw,0x38);
	spi_write8(hw,0x80);
	udelay(2);
	for(i=0;i<3;i++){
	spi_write8(hw,0xff);
	data1=spi_read8(hw);
	spi_write8(hw,0xff);
	data2=spi_read8(hw);
	udelay(2);
		}
	printk("1<== %02x\n",data1);	
	printk("2<== %02x\n",data2);	
	flag=1;
		}
		//udelay(2);
	
	//if ((hw->len % 4) != 0) {
	//	spi_write8(hw,0);
	//	spi_write8(hw,0);
	//	udelay(2);
	//}
	hw->count = hw->len;
	//writeb(hw_txbyte(hw, 0), hw->regs + S3C2410_SPTDAT);

	//wait_for_completion(&hw->done);
	#endif
	return hw->count;
}