3 Replies Latest reply on Dec 18, 2017 11:51 PM by bob.marlowe

    Build error: 'i2c_sendbyte': requires ANSI-style prototype

    jaseelaka945_2746661

      Hello everyone,

                            iam new to psoc and iam facing error :  Build error: 'i2c_sendbyte': requires ANSI-style prototype

         

       

      THIS IS THE CODE

      #include<project.h>

      #include"i2c.h"

       

       

       

       

       

       

       

       

      uint8 i2c_Send(uint8 Address,uint8 *Data,uint8 Num)

      {

       

       

       

      i2c_start();

       

       

      //-- Send Addresss

      i2c_sendbyte(Address & 0xFE);   //-- Lowest bit = 0 => WRITE    //error line

      if(!i2cgetack())

      {

        i2cstop();

        return(0);

      }

       

       

      while(Num--)

      {

       

        i2c_sendbyte(*Data);

        if(!i2cgetack())

        {

         i2cstop();

         return(0);

        }

        Data++;

      }

      i2cstop();

      return(1);

      }

       

       

      uint8 i2c_Read(uint8 Address,uint8 *Data, char Num)

      {

      i2c_start();

       

       

      //-- Send Address

      i2csendbyte(Address | 0x01);   //-- Lowest bit = 1 => READ

       

       

      if(!i2c_getack())

      {

        i2cstop();

        return(0);

      }

       

       

      while(Num--)

      {

        *Data=i2c_getbyte();

        Data++;

       

       

        if(Num > 0)

        {

         i2c_sendack();

        }

      }

      i2c_stop();

      return(1);

       

       

      }

       

       

       

       

      uint8 i2c_getbyte(void)

      {

      char count,Byte=0;

      int delay;

       

      SCL_Write(0);

      SDA_SetDriveMode(SDA_DM_OD_LO);

       

       

      for(delay=0;delay<I2CCLOCKLOW;delay++);

      //i2cdelay(I2CCLOCKLOW);         //-- Minimum Clock Low Time

       

       

      for(count=8;count>0;count--)   //-- Read 8 bits of data

      {

        Byte=Byte <<1;

        SDA_SetDriveMode(SDA_DM_DIG_HIZ);

        if(i2creadbit())

        {

         Byte +=1;

        }

      }

      return(Byte);

      }

       

       

       

       

      char i2c_readbit(void)

      {

      char Data=0;

      int delay;

       

      //i2cdelay(I2CDATASETTLE);       //-- Minimum Clock Low Time

        for(delay=0;delay<I2CDATASETTLE;delay++);

       

       

      SCL_Write(1);

      //i2cdelay(I2CHALFCLOCK);        //-- 1/2 Minimum Clock High Time

        for(delay=0;delay<I2CHALFCLOCK;delay++);

       

      if(SDA_Read() !=0 ) Data=1;           //-- READ in the data bit

      //i2cdelay(I2CHALFCLOCK);        //-- 1/2 Minimum Clock High Time

        for(delay=0;delay<I2CHALFCLOCK;delay++);

       

      SCL_Write(0);

      //i2cdelay(I2CCLOCKLOW);         //-- Minimum Clock Low Time

        for(delay=0;delay<I2CCLOCKLOW;delay++);

       

      return(Data);

      }

       

       

      void i2c_sendack(void)

      {

        int delay;

       

      //--- Send Ack to slave except for last time ---

        SDA_SetDriveMode(SDA_DM_OD_LO);

      //i2cdelay(I2CDATASETTLE);      //-- Give it time to settle

        for(delay=0;delay<I2CDATASETTLE;delay++);

       

      i2cclock();                   //-- Pulse the clock

      SDA_SetDriveMode(SDA_DM_DIG_HIZ);

      //i2cdelay(I2CDATASETTLE);      //-- Gap between next byte

        for(delay=0;delay<I2CDATASETTLE;delay++);

       

      }

      //************** END OF i2csendack

       

       

       

       

       

       

      void i2c_stop(void)

      {

        int delay;

       

        //-- Generate Stop Condition --

      SDA_SetDriveMode(SDA_DM_OD_LO);

      SCL_Write(1);

      //i2cdelay(I2CSTOPDELAY);

        for(delay=0;delay<I2CSTOPDELAY;delay++);

       

      SDA_SetDriveMode(SDA_DM_DIG_HIZ);

       

       

      }

       

       

       

       

      void i2c_start(void)

      {

      int delay;

      //data goes low with clock high - start condition

      SDA_SetDriveMode(SDA_DM_OD_LO);

      //i2cdelay(I2CCLOCKLOW);         //-- Minimum Clock Low Time

        for(delay=0;delay<I2CCLOCKLOW;delay++);

       

      }

       

       

      /*void i2c_delay(int delay)

      {

      int i;

      for(i = 0;i < delay;i++);

       

       

      }*/

       

       

       

       

      void i2c_sendbyte(uint8 Byte)

      {

      char count;

      int delay;

       

      SCL_Write(0);

       

      //i2cdelay(I2CCLOCKLOW);         //-- Minimum Clock Low Time

         for(delay=0;delay<I2CCLOCKLOW;delay++);

       

       

       

       

       

       

       

       

      for(count=8;count>0;count--)   //-- Send 8 bits of data

      {

        if( (Byte & 0x80)== 0)        //-- Get the Bit

        {

      SDA_SetDriveMode(SDA_DM_OD_LO);

                        //-- Ensure Port pin is low

        }

        else

        {

      SDA_SetDriveMode(SDA_DM_DIG_HIZ);

                   //-- Release pin if bit = 1

        }

        Byte=Byte<<1;                 //-- Shift next bit into position

        i2cclock();                   //-- Pulse the clock

      /*

        //for(delay=0;delay<I2CDATASETTLE;delay++);

        SCL_Write(1);

      // for(delay=0;delay<I2CCLOCKHIGH;delay++);

        SCL_Write(0);

        //for(delay=0;delay<I2CCLOCKLOW;delay++);

        */

      }

      //SDA_TRIS=I2CHIGH;              //-- Release data pin for ACK

      SDA_SetDriveMode(SDA_DM_DIG_HIZ);

       

      }

       

       

       

       

      void i2c_clock(void)

      {

      //int delay;

       

      //i2cdelay(I2CDATASETTLE);       //-- Minimum Clock Low Time

      // for(delay=0;delay<I2CDATASETTLE;delay++);

       

      SCL_Write(1);

      //i2cdelay(I2CCLOCKHIGH);        //-- Minimum Clock High Time

      // for(delay=0;delay<I2CCLOCKHIGH;delay++);

       

      SCL_Write(0);

      //i2cdelay(I2CCLOCKLOW);         //-- Minimum Clock Low Time

      //  for(delay=0;delay<I2CCLOCKLOW;delay++);

       

      }

       

       

       

       

       

       

      char i2c_getack(void)

      {

        int i,j;

        int dat;

        int delay;

       

       

      SCL_Write(0);

      //i2cdelay(I2CCLOCKLOW);         //-- Minimum Clock Low Time

        for(delay=0;delay<I2CCLOCKLOW;delay++);

       

      SCL_Write(1);

       

      //i2cdelay(I2CHALFCLOCK);          //-- wait for 1/2 the clock pulse

      //i2cdelay(22);          //-- wait for 1/2 the clock pulse

       

       

      for(i = 0;i < 2000;i++)

      {

      for(j = 0; j<10;j++);

      dat = SDA_Read();

      if(!dat)

      break;

      }

       

       

       

      //if(SDA_Read())                          //-- sample the ACK signal

      if(dat)                          //-- sample the ACK signal

      {/

        return(0);                      //-- No ACK so return BAD

      }

      //i2cdelay(I2CHALFCLOCK);          //-- Else wait for rest of clock

         for(delay=0;delay<I2CHALFCLOCK;delay++);

       

       

      SCL_Write(0);                 //-- Finish the clock pulse

      //i2cdelay(I2CCLOCKLOW);           //-- Minimum Clock Low Time

      //i2cdelay(I2CCLOCKLOW);           //-- Minimum Clock Low Time

         for(delay=0;delay<I2CCLOCKLOW;delay++);

        for(delay=0;delay<I2CCLOCKLOW;delay++);

       

       

      return(1);

      }

       

       

       

       

       

       

      /* [] END OF FILE */

      please help me