Commit Graph

5 Commits

Author SHA1 Message Date
Markus Hitter 8e8946dd37 I2C: remove parameter 'address' from i2c_write().
As we usually talk to one device only, there's not much point in
carrying around the address all the time. Surprise, this saves
only 16 bytes binary size despite of heavy usage.
2016-04-20 21:15:11 +02:00
Markus Hitter aab447567c I2C: rewrite demo to use program memory.
Advantages are apparent: much less RAM usage.

$ avr-size -C --mcu=atmega1284p build/teacup.elf
AVR Memory Usage
----------------
Device: atmega1284p

Program:   23750 bytes (18.1% Full)
(.text + .data + .bootloader)

Data:       2053 bytes (12.5% Full)
(.data + .bss + .noinit)

EEPROM:       32 bytes (0.8% Full)
(.eeprom)

$ avr-size -C --mcu=atmega1284p build/teacup.elf
AVR Memory Usage
----------------
Device: atmega1284p

Program:   23720 bytes (18.1% Full)
(.text + .data + .bootloader)

Data:       1543 bytes (9.4% Full)
(.data + .bss + .noinit)

EEPROM:       32 bytes (0.8% Full)
(.eeprom)

A note about size reports: what 'make size' currently reports is
a bit misleading, because it doesn't count the .data section as
Flash usage. However, this section is actually written there as
it's the section which initialises RAM.
2016-04-20 21:15:11 +02:00
Markus Hitter 2298973343 I2C: distinguish between individual transmissions.
So far calling code had to wait long enough between individual
transmissions to make sure they end up in distinc ones. Now
calling code can stuff as fast as it wants, i2c_write() takes
care of the distinction.
2016-04-20 21:15:11 +02:00
Markus Hitter d088930664 I2C: use ringbuffer for data buffering.
This removes the need to write in full blocks, so data can be
sent from loops and/or program memory.

This capability allows to clear the screen without too much
effort, see i2c_test.c.

Still two weaknesses left:

 - Transmission end is currently detected by ringbuffer becoming
   empty, so delays are needed to make sure a transmission is
   completed before the next one is sent to the buffer.

 - Error handling is still only half existent. Any error on the
   bus will stop I2C entirely. A recovery strategy is required.

Sizes show, taking into account the additional screen clearing
code, no significant change:

    FLASH  : 23216 bytes
    RAM    :  2052 bytes
    EEPROM :    32 bytes
2016-04-20 21:15:11 +02:00
Ruslan Popov 619560c112 I2C: initial support.
This commit squashes in some fixes found after debugging on the
topic branch. Test code by Traumflug, collected from Ruslan's
code on the topic branch.

Before, same as now without I2C:

    FLASH  : 22408 bytes
    RAM    :  1393 bytes
    EEPROM :    32 bytes

Now with I2C:

    FLASH  : 23224 bytes
    RAM    :  2057 bytes
    EEPROM :    32 bytes

This totals to some 800 bytes with a whole lot of test code, so
implementation is pretty small :-)
2016-04-20 21:15:11 +02:00