you can del\velop codes with different header files example
for LCD routine develop lcd_init(), lcd_delay(), lcd_clear(), lcd_data
for i2c routine develop i2c_start(), I2c_write(), i2c_read(), i2c_ack(), i2c_stop() etc like this
---------- Post added at 09:46 ---------- Previous post was at 09:38 ----------
let say we want to make a header file for an lcd then
LCD.h file will have
#ifndef __LCD__ // it check that is this name of file exist or not if not exist
#define __LCD__ // then genrate a file else not generate
now in headerfile u can do a lot of things every type of definations lest say port and bit assignment for LCD
typedef unsigned char bit_8;
#define lcd_port P1
sbit rs=P3^5; // register select is port 3.5
sbit rw=P3^4; // read/write is port 3.4
sbit en=P3^3; // enable is port 3.3
sbit d7=P1^7;
Function Prototypes
void ini(void);
void command(bit_8);
void data_in(bit_8*);
void busy(void);
some macros
#define DISABLE_INT IE=0x0;
#define ENABLE_INT IE=0x81;
#endif
now u can create a c file coding that uses these definations let say that is lcd.c
So lcd.c will have
then that file contains functions body
for examole
#include "LCD.H"
/*--------------------------
*** initialising the LCD ***
--------------------------*/
void ini()
{
command(56);
command(12);
command(1);
command(6);
command(0x80);
}
/*----------------------------
*** checking the busy flag ***
----------------------------*/
void busy()
{
d7=1;
rs=0;
rw=1;
......
}
and other functions of your program