X-Git-Url: https://codewiz.org/gitweb?a=blobdiff_plain;ds=sidebyside;f=drv%2Ftwi.c;h=0d03950f95fe22d74e5763be804c0f0abd448ff5;hb=27fef4ed34eb237817defa14242e726ccad70948;hp=f2c73f94d760ea05e767bf1d014c33311fb71fd0;hpb=0c154bc0927a32f77467f32aac3cc3507baa97ca;p=bertos.git diff --git a/drv/twi.c b/drv/twi.c old mode 100755 new mode 100644 index f2c73f94..0d03950f --- a/drv/twi.c +++ b/drv/twi.c @@ -1,8 +1,33 @@ -/*! +/** * \file * * * \brief Driver for the AVR ATMega TWI (implementation) @@ -15,6 +40,12 @@ /*#* *#* $Log$ + *#* Revision 1.8 2007/06/07 14:35:12 batt + *#* Merge from project_ks. + *#* + *#* Revision 1.7 2006/07/19 12:56:26 bernie + *#* Convert to new Doxygen style. + *#* *#* Revision 1.6 2006/03/20 17:49:50 bernie *#* Make the TWI driver more generic to work with devices other than EEPROMS. *#* @@ -38,9 +69,9 @@ #include "twi.h" #include -#include +#include #include // BV() -#include +#include /* CLOCK_FREQ */ #include #include @@ -52,7 +83,7 @@ #define READ_BIT BV(0) -/*! +/** * Send START condition on the bus. * * \return true on success, false otherwise. @@ -70,7 +101,7 @@ static bool twi_start(void) } -/*! +/** * Send START condition and select slave for write. * \c id is the device id comprehensive of address left shifted by 1. * The LSB of \c id is ignored and reset to 0 for write operation. @@ -104,7 +135,7 @@ bool twi_start_w(uint8_t id) } -/*! +/** * Send START condition and select slave for read. * \c id is the device id comprehensive of address left shifted by 1. * The LSB of \c id is ignored and set to 1 for read operation. @@ -129,7 +160,7 @@ bool twi_start_r(uint8_t id) } -/*! +/** * Send STOP condition. */ void twi_stop(void) @@ -138,7 +169,7 @@ void twi_stop(void) } -/*! +/** * Put a single byte in master transmitter mode * to the selected slave device through the TWI bus. * @@ -158,7 +189,7 @@ bool twi_put(const uint8_t data) } -/*! +/** * Send a sequence of bytes in master transmitter mode * to the selected slave device through the TWI bus. * @@ -177,7 +208,7 @@ bool twi_send(const void *_buf, size_t count) } -/*! +/** * Receive a sequence of one or more bytes from the * selected slave device in master receive mode through * the TWI bus. @@ -222,7 +253,7 @@ bool twi_recv(void *_buf, size_t count) } -/*! +/** * Initialize TWI module. */ void twi_init(void) @@ -235,12 +266,12 @@ void twi_init(void) * probably due to some unwanted interaction between the * port pin and the TWI lines. */ -#if defined(__AVR_ATmega64__) +#if CPU_AVR_ATMEGA64 || CPU_AVR_ATMEGA128 || CPU_AVR_ATMEGA1281 PORTD |= BV(PD0) | BV(PD1); - DDRD |= BV(PD0) | BV(PD1); -#elif defined(__AVR_ATmega8__) + DDRD |= BV(PD0) | BV(PD1); +#elif CPU_AVR_ATMEGA8 PORTC |= BV(PC4) | BV(PC5); - DDRC |= BV(PC4) | BV(PC5); + DDRC |= BV(PC4) | BV(PC5); #else #error Unsupported architecture #endif