static void __inline__ sccb_start(void) { CFG_WRITE(SIO_D); Low(SIO_D); WAIT_STABLE(); }
static void __inline__ sccb_stop(void) { Low(SIO_C); WAIT_STABLE(); CFG_WRITE(SIO_D); Low(SIO_D); WAIT_CYCLE(); High(SIO_C); WAIT_STABLE(); High(SIO_D); WAIT_CYCLE(); CFG_READ(SIO_D); }
int sccb_init(void) { CFG_WRITE(SIO_C); CFG_WRITE(SIO_D); High(SIO_C); High(SIO_D); WAIT_STABLE(); return 0; }
static void __inline__ sccb_write_byte(u8 data) { int i; CFG_WRITE(SIO_D); WAIT_STABLE(); /* write 8-bits octet. */ for (i=0;i<8;i++) { Low(SIO_C); WAIT_STABLE(); if (data & 0x80) { High(SIO_D); } else { Low(SIO_D); } data = data<<1; WAIT_CYCLE(); High(SIO_C); WAIT_CYCLE(); } /* write byte done, wait the Don't care bit now. */ { Low(SIO_C); High(SIO_D); CFG_READ(SIO_D); WAIT_CYCLE(); High(SIO_C); WAIT_CYCLE(); } }
static u8 __inline__ sccb_read_byte(void) { int i; u8 data; CFG_READ(SIO_D); WAIT_STABLE(); Low(SIO_C); WAIT_CYCLE(); data = 0; for (i=0;i<8;i++) { High(SIO_C); WAIT_STABLE(); data = data<<1; data |= State(SIO_D)?1:0; WAIT_CYCLE(); Low(SIO_C); WAIT_CYCLE(); } /* read byte down, write the NA bit now.*/ { CFG_WRITE(SIO_D); High(SIO_D); WAIT_CYCLE(); High(SIO_C); WAIT_CYCLE(); } return data; }
static u8 __inline__ sccb_read_byte(void) { int i; u8 data; CFG_READ(SIO_D); WAIT_STABLE(); Low(SIO_C); WAIT_CYCLE(); data = 0; for (i=7;i>=0;i--) { //High(SIO_C); //WAIT_STABLE(); data |= State(SIO_D)<<i; WAIT_CYCLE(); //Low(SIO_C); //WAIT_CYCLE(); } /* read byte down, write the NA bit now.*/ { CFG_WRITE(SIO_D); High(SIO_D); WAIT_CYCLE(); High(SIO_C); WAIT_CYCLE(); } printk("(%d)",data & 0xFF); return (data); }