eriksl / usitwislave

Software TWI/I2C implementation for ATtiny devices using USI.
Other
45 stars 14 forks source link

Using usitwislave on ATmega328 (arduino uno) #3

Open maali-mnasri opened 10 years ago

maali-mnasri commented 10 years ago

Hi, I wonder if this library "usitwislave" can be used on ATmega328p (arduino uno) or at least is there a chance to make it run on ATmega if I adapt the registers to my device ?

eriksl commented 10 years ago

I wonder if this library "usitwislave" can be used on ATmega328p (arduino uno) or at least is there a chance to make it run on ATmega if I adapt the registers to my device ?

You don't need this library on an ATmega328p, this microcontroller has a "complete" hardware supported twi/i2c, it's no "USI" implementation. You can find USI mainly on "ATtiny" devices.

maali-mnasri commented 10 years ago

For a special case I need to use a software I2C (slave) library and not the I2C hardware module of the ATmega. USI is not implemented on ATmega328p but isn't it similar to USART ? Don't you think it (usiTwiSlave) may function on ATmega if I change the register names to the USART registers? Thank you.

eriksl commented 10 years ago

On 24-04-14 00:27, ilaam wrote:

For a special case I need to use an I2C slave software library and not the I2C hardware module of the ATmega. USI is not implemented on ATmega328p but isn't it similar to USART ? Don't you think it may function on ATmega if I change the register names to the USART registers? Thank you.

I see your point but the library is really tailored for USI, including timings. I guess you'll have to search e.g. for i2c using bitbanging (which I am sure do exist). I know the USART on the ATmega328p can be used as secondary SPI device, but that's really something different. It's a nice challenge ;-)

I guess you need the TWI pins for something else ;-)

maali-mnasri commented 10 years ago

Yes exactly TWI pins are already used. Thank you for your reply :+1: Now that you told me it's challenging to try to adapt usiTwiSlave to USART, I'll try again to find some bitbanging i2c lib because I already searched and all I could find were i2c master libraries not slave ones .