#ifdef DEVBD2F_SM502 static volatile char *mmio = 0; #define GPIO_DIR_REG (volatile unsigned int *)(mmio + 0x1000c) #define GPIO_DATA_REG (volatile unsigned int *)(mmio + 0x10004) #define G_OUTPUT 1 #define G_INPUT 0 #define GPIO_SDA_DIR_SHIFT 15 #define GPIO_SCL_DIR_SHIFT 14 #define GPIO_SDA_DATA_SHIFT 15 #define GPIO_SCL_DATA_SHIFT 14 #elif defined(DEVBD2F_FIREWALL) #define GPIO_DIR_REG (volatile unsigned int *)(0xbfe00120) #define GPIO_DATA_REG (volatile unsigned int *)(0xbfe0011c) #define G_OUTPUT 0 #define G_INPUT 1 #define GPIO_SDA_DIR_SHIFT 2 #define GPIO_SCL_DIR_SHIFT 3 #define GPIO_SDA_DATA_SHIFT 2 #define GPIO_SCL_DATA_SHIFT 3 //extern int word_addr = 0; #endif static void i2c_sleep(int ntime) { int i,j=0; for(i=0; i<300*ntime; i++) { j=i; j+=i; } } void sda_dir(int ivalue) { int tmp; tmp = *GPIO_DIR_REG; if(ivalue == 1) *GPIO_DIR_REG = tmp|(0x1<=0;i--) { i2c_sleep(5); scl_bit(1); i2c_sleep(3); #ifdef DEVBD2F_SM502 tmp = ((*GPIO_DATA_REG)&(0x1<=0;i--) { and_char = value; and_char>>=i; and_char&=0x1; if(and_char) sda_bit(1); else sda_bit(0); i2c_sleep(1); scl_bit(1); i2c_sleep(5); scl_bit(0); i2c_sleep(1); } sda_bit(1); return 1; } unsigned char i2c_rec_s(unsigned char *addr,int addrlen,unsigned char reg,unsigned char* buf ,int count) { int i; int j; unsigned char value; //start signal for(i=0;i