Skip to content
This repository has been archived by the owner on Aug 27, 2023. It is now read-only.

Commit

Permalink
I2C: initial support.
Browse files Browse the repository at this point in the history
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 :-)
  • Loading branch information
RaD authored and Traumflug committed Apr 20, 2016
1 parent 537b93a commit 619560c
Show file tree
Hide file tree
Showing 5 changed files with 725 additions and 6 deletions.
20 changes: 14 additions & 6 deletions cpu-avr.c
Expand Up @@ -18,16 +18,24 @@
*/
void cpu_init() {
#ifdef PRR
#if defined SPI
PRR = MASK(PRTWI) | MASK(PRADC);
#if defined I2C && defined SPI
PRR = MASK(PRADC);
#elif defined SPI
PRR = MASK(PRADC) | MASK(PRTWI);
#elif defined I2C
PRR = MASK(PRADC) | MASK(PRSPI);
#else
PRR = MASK(PRTWI) | MASK(PRADC) | MASK(PRSPI);
PRR = MASK(PRADC) | MASK(PRTWI) | MASK(PRSPI);
#endif
#elif defined PRR0
#if defined SPI
PRR0 = MASK(PRTWI) | MASK(PRADC);
#if defined I2C && defined SPI
PRR0 = MASK(PRADC);
#elif defined SPI
PRR0 = MASK(PRADC) | MASK(PRTWI);
#elif defined I2C
PRR0 = MASK(PRADC) | MASK(PRSPI);
#else
PRR0 = MASK(PRTWI) | MASK(PRADC) | MASK(PRSPI);
PRR0 = MASK(PRADC) | MASK(PRTWI) | MASK(PRSPI);
#endif
#if defined(PRUSART3)
// Don't use USART2 or USART3. Leave USART1 for GEN3 and derivatives.
Expand Down

0 comments on commit 619560c

Please sign in to comment.