> -----Original Message----- > From: Peter Tiang [SMTP:petertiang@PD.JARING.MY] > Sent: Wednesday, April 11, 2001 10:52 AM > To: PICLIST@MITVMA.MIT.EDU > Subject: Re: [OT]: Coding style > > Err... how come your I2CStart() and I2CStop() routine > needs to generate a status ? > > Unless you are doing multi-master I2C and need to > monitor for bus collision.... > > ... otherwise, isn't it too much to return a status > for the (transmit only) I2C start and stop condition ? > > Regards, > Peter Tiang > All the functions call the functions bool SetSDA(bool state) which not only sets the bus line to the required state, it also polls the read back line until either the bus line has reached the required state, or it has timed out. This could be due to hung slave, faulty hardware etc. If I performed a start condition and both lines were stuck low for instance, the function would be aborted imediately rather than chugging away through the rest of the code trying to send or receive data. My goal is to make the drivers (which are compiled as a Win32 DLL) as robust as possible, with decent error reporting. The driver operates perfectly, but as this driver is likely to be shipped along with some hardware to customers, I want to make the code as maintainable as possible. If this was a quick one-off for myself, or for in house use I wouldn't give this a second thought, but I feel compelled to make the best job of this that I can. Regards Mike -- http://www.piclist.com hint: PICList Posts must start with ONE topic: [PIC]:,[SX]:,[AVR]: ->uP ONLY! [EE]:,[OT]: ->Other [BUY]:,[AD]: ->Ads