Email: Password: Remember Me | Create Account (Free)

Back to Subject List

Old thread has been locked -- no new posts accepted in this thread
???
10/27/05 09:03
Read: times


 
#103017 - I2C-driver
Responding to: ???'s previous message
Hello all,
again i am sending some uncommented codes for I2C, the commenting work is in progress from my side. In the mean time great persons like ANDY can give some hints to me(sorry for taking the freedom).I am using SDCC(v2.3) configured with MED editor. This piece of code will be stored in the same folder of the main program as iic.c and will be included in the main.
If any of my technical wordings are wrong plz. correct me, since i am a hardware person doing with pure basics in software, i believe the comments of experienced people can help me to a great extend.
thanks
Jacob

Here it is:


#define set_clk() { SCL=1;SCL=1;SCL=1;SCL=1;SCL=1; }
#define clr_clk() { SCL=0;SCL=0;SCL=0;SCL=0;SCL=0; }
#define set_dat() { SDA=1;SDA=1;SDA=1;SDA=1;SDA=1; }
#define clr_dat() { SDA=0;SDA=0;SDA=0;SDA=0;SDA=0; }

#define start_iic() { clr_clk(); set_dat(); set_clk(); clr_dat(); }
#define stop_iic() { clr_clk(); clr_dat(); set_clk(); set_dat(); }
#define send_ack() { clr_clk(); clr_dat(); set_clk(); }
#define send_no_ack() { clr_clk(); set_dat(); set_clk(); }


unsigned char send_byte(unsigned char dat)
{
unsigned char re;
for(re=0;re<8;re++)
{
clr_clk();
SDA=(dat&0x80);
dat <<=1;
set_clk();
}
clr_clk();
SDA=1;
set_clk();
return SDA;
}

unsigned char receive_byte()
{
unsigned char re, dat=0;
for(re=0;re<8;re++)
{
clr_clk();
SDA=1;
dat <<=1;
set_clk();
dat|=SDA;
set_clk();
}
return dat;
}



List of 30 messages in thread
TopicAuthorDate
LCD drivers in C            01/01/70 00:00      
   beginners??            01/01/70 00:00      
   well intended, useless            01/01/70 00:00      
      freebie code            01/01/70 00:00      
   Reformatted your code.            01/01/70 00:00      
      you don't get it do you            01/01/70 00:00      
      Something positive??            01/01/70 00:00      
      Here it is            01/01/70 00:00      
         Text Processor            01/01/70 00:00      
            Syntax highlighter            01/01/70 00:00      
               Syntax Colouring            01/01/70 00:00      
                  The trick            01/01/70 00:00      
                     Colouring tips            01/01/70 00:00      
                     Specified by the poster            01/01/70 00:00      
         Andy's Code, colored !!            01/01/70 00:00      
   Atta Boy, Andy.            01/01/70 00:00      
      One thing to note            01/01/70 00:00      
         Thanks to ANDY            01/01/70 00:00      
         I2C-driver            01/01/70 00:00      
            SDCC 2.3 ?            01/01/70 00:00      
            Please do not            01/01/70 00:00      
   LCD code in C            01/01/70 00:00      
      Library Code            01/01/70 00:00      
         Useful or not.            01/01/70 00:00      
            as useful as the other 22.111 versions            01/01/70 00:00      
               Delay loop in C            01/01/70 00:00      
                  More on 'C' delay loops...            01/01/70 00:00      
                     Correct me if I am wrong            01/01/70 00:00      
                        Not wrong about busy polling            01/01/70 00:00      
            Ask yourself this            01/01/70 00:00      

Back to Subject List