From: Harding, T. <tha...@ba...> - 2002-04-25 18:58:00
|
I have a function that needs to access the upper byte of an address. I am working on writing an interface to a i2c serial eeprom, and I would like to pass in an address to make the function more user friendly. Anyway here is the code I have and the errors I get: unsigned char eeprom_read(char *readAddr) { unsigned char retVal; unsigned char firstByte; unsigned char secondByte; // Calculate first and second bytes. firstByte = (unsigned char)((0xA0) | ((readAddr >> 7) & 0x0E)); secondByte = (unsigned char)readAddr; ... [root@localhost final]# sdcc i2c.c i2c.c(52):warning *** 'auto' variable 'retVal' may be used before initialization at i2c.c(52) i2c.c(52):warning *** in function i2c_send_byte unreferenced function argument : 'sendByte' i2c.c(68):warning *** 'auto' variable 'retVal' may be used before initialization at i2c.c(68) i2c.c(77):error *** invalid operand for shift operator i2c.c(77):warning *** left & right types are _generic * char ,char i2c.c(88):error *** code not generated for 'eeprom_read' due to previous errors If anyone knows how to get access to just the second byte of this generic pointer please let me know. I have thought about using the registers that the compiler uses to pass the argument, but I don't know how reliable that would be. Any help or ideas would be great. Tyson Harding |