Refactor to use new protocol module and sipo.
[bertos.git] / bertos / cpu / arm / drv / twi_at91.c
index 6256558bf90e9dd0c3278951e9f58308e30f4e6c..ad95f50cb80f6155ee3c34b0c194dc68fb380742 100644 (file)
  *
  * \brief Driver for the AT91 ARM TWI (implementation)
  *
- * \version $Id$
  *
  * \author Francesco Sacchi <batt@develer.com>
  */
 
 #include "twi_at91.h"
 
-#include <cfg/cfg_twi.h>
+#include "cfg/cfg_i2c.h"
 #include <cfg/compiler.h>
 #include <cfg/debug.h>
 #include <cfg/macros.h>
@@ -181,7 +180,7 @@ bool twi_read(uint8_t id, twi_iaddr_t byte1, twi_iaddr_t byte2, twi_iaddr_t byte
        /*
         * Start reception.
         * Kludge: if we want to receive only 1 byte, the stop but *must* be set here
-        * (thanks to crappy twi implementation again).
+        * (thanks to crappy twi implementation again).
         */
        if (size == 1)
        {
@@ -250,11 +249,11 @@ void twi_init(void)
        /*
         * Compute twi clock.
         * CLDIV = ((Tlow * 2^CKDIV) -3) * Tmck
-        * CHDIV = ((THigh * 2^CKDIV) -3) * Tmck
-        * Only CLDIV is computed since CLDIV = CHDIV (50% duty cycle)
+        * CHDIV = ((THigh * 2^CKDIV) -3) * Tmck
+        * Only CLDIV is computed since CLDIV = CHDIV (50% duty cycle)
         */
-       uint16_t cldiv, ckdiv = 0;
-       while ((cldiv = ((CLOCK_FREQ / (2 * CONFIG_TWI_FREQ)) - 3) / (1 << ckdiv)) > 255)
+       uint16_t cldiv, ckdiv = 0;
+       while ((cldiv = ((CPU_FREQ / (2 * CONFIG_I2C_FREQ)) - 3) / (1 << ckdiv)) > 255)
                ckdiv++;
 
        /* Atmel errata states that ckdiv *must* be less than 5 for unknown reason */
@@ -265,3 +264,4 @@ void twi_init(void)
 
        MOD_INIT(twi);
 }
+