fork download
  1. #include <stdio.h>
  2. #define u8 unsigned char
  3.  
  4. #define PFC_ADDR 0xB0
  5. #define EE_ADDR 0x10
  6.  
  7. u8 PFC_value[2];
  8.  
  9. //=================================================================================================
  10. // Funciton : LDByteReadI2C()
  11. //
  12. // input parameter:Control Byte, Address, *Data, Length.
  13. //
  14. // output parameter:NONE
  15. //
  16. // Description :Performs a low density read of Length bytes and stores in *Data array starting at Address.
  17. //=================================================================================================
  18. void LDByteReadI2C(unsigned char ControlByte, unsigned char Address, unsigned char *Data, unsigned char Length)
  19. {
  20. IdleI2C(); //wait for bus Idle
  21. StartI2C(); //Generate Start Condition
  22. WriteI2C(ControlByte); //Write Control Byte
  23. IdleI2C(); //wait for bus Idle
  24. WriteI2C(Address); //Write start address
  25. IdleI2C(); //wait for bus Idle
  26.  
  27. RestartI2C(); //Generate restart condition
  28. WriteI2C(ControlByte | 0x01); //Write control byte for read
  29. IdleI2C(); //wait for bus Idle
  30.  
  31. getsI2C(Data, Length); //read Length number of bytes
  32. NotAckI2C(); //Send Not Ack
  33. StopI2C(); //Generate Stop
  34. Delay_mS(5);
  35. }
  36. void main(void) {
  37.  
  38. LDByteReadI2C(EE_ADDR,0x0001,&PFC_value,2);
  39. // your code goes here
  40. return 0;
  41. }
  42.  
Compilation error #stdin compilation error #stdout 0s 0KB
stdin
Standard input is empty
compilation info
prog.c: In function ‘LDByteReadI2C’:
prog.c:20:2: warning: implicit declaration of function ‘IdleI2C’ [-Wimplicit-function-declaration]
  IdleI2C();     //wait for bus Idle
  ^
prog.c:21:2: warning: implicit declaration of function ‘StartI2C’ [-Wimplicit-function-declaration]
  StartI2C();     //Generate Start Condition
  ^
prog.c:22:2: warning: implicit declaration of function ‘WriteI2C’ [-Wimplicit-function-declaration]
  WriteI2C(ControlByte);  //Write Control Byte
  ^
prog.c:27:2: warning: implicit declaration of function ‘RestartI2C’ [-Wimplicit-function-declaration]
  RestartI2C();    //Generate restart condition
  ^
prog.c:31:2: warning: implicit declaration of function ‘getsI2C’ [-Wimplicit-function-declaration]
  getsI2C(Data, Length);  //read Length number of bytes
  ^
prog.c:32:2: warning: implicit declaration of function ‘NotAckI2C’ [-Wimplicit-function-declaration]
  NotAckI2C();    //Send Not Ack
  ^
prog.c:33:2: warning: implicit declaration of function ‘StopI2C’ [-Wimplicit-function-declaration]
  StopI2C();     //Generate Stop
  ^
prog.c:34:2: warning: implicit declaration of function ‘Delay_mS’ [-Wimplicit-function-declaration]
  Delay_mS(5);
  ^
prog.c: At top level:
prog.c:36:6: warning: return type of ‘main’ is not ‘int’ [-Wmain]
 void main(void) {
      ^
prog.c: In function ‘main’:
prog.c:38:7: warning: passing argument 3 of ‘LDByteReadI2C’ from incompatible pointer type [enabled by default]
       LDByteReadI2C(EE_ADDR,0x0001,&PFC_value,2);
       ^
prog.c:18:6: note: expected ‘unsigned char *’ but argument is of type ‘unsigned char (*)[2]’
 void LDByteReadI2C(unsigned char ControlByte, unsigned char Address, unsigned char *Data, unsigned char Length)
      ^
prog.c:40:2: warning: ‘return’ with a value, in function returning void [enabled by default]
  return 0;
  ^
/home/cpvsdi/cceDH6Lg.o: In function `LDByteReadI2C':
prog.c:(.text+0x18): undefined reference to `IdleI2C'
prog.c:(.text+0x1d): undefined reference to `StartI2C'
prog.c:(.text+0x2e): undefined reference to `WriteI2C'
prog.c:(.text+0x33): undefined reference to `IdleI2C'
prog.c:(.text+0x40): undefined reference to `WriteI2C'
prog.c:(.text+0x45): undefined reference to `IdleI2C'
prog.c:(.text+0x4a): undefined reference to `RestartI2C'
prog.c:(.text+0x52): undefined reference to `WriteI2C'
prog.c:(.text+0x57): undefined reference to `IdleI2C'
prog.c:(.text+0x68): undefined reference to `getsI2C'
prog.c:(.text+0x6d): undefined reference to `NotAckI2C'
prog.c:(.text+0x72): undefined reference to `StopI2C'
prog.c:(.text+0x86): undefined reference to `Delay_mS'
collect2: error: ld returned 1 exit status
stdout
Standard output is empty