projects
/
bertos.git
/ blobdiff
commit
grep
author
committer
pickaxe
?
search:
re
summary
|
shortlog
|
log
|
commit
|
commitdiff
|
tree
raw
|
inline
| side by side
Add i2c definition for lm3s cpu.
[bertos.git]
/
bertos
/
cpu
/
avr
/
drv
/
i2c_avr.c
diff --git
a/bertos/cpu/avr/drv/i2c_avr.c
b/bertos/cpu/avr/drv/i2c_avr.c
index 335d8330f4635722b42547b162d4f5f3d44652f8..a10c450dbb87bdae3eca0598c658beee4cc9c501 100644
(file)
--- a/
bertos/cpu/avr/drv/i2c_avr.c
+++ b/
bertos/cpu/avr/drv/i2c_avr.c
@@
-32,13
+32,11
@@
*
* \brief Driver for the AVR ATMega TWI (implementation)
*
*
* \brief Driver for the AVR ATMega TWI (implementation)
*
- * \version $Id$
- *
* \author Stefano Fedrigo <aleph@develer.com>
* \author Bernie Innocenti <bernie@codewiz.org>
*/
* \author Stefano Fedrigo <aleph@develer.com>
* \author Bernie Innocenti <bernie@codewiz.org>
*/
-#include
"hw/hw_cpu.h" /* CLOCK
_FREQ */
+#include
<hw/hw_cpufreq.h> /* CPU
_FREQ */
#include "cfg/cfg_i2c.h"
#include "cfg/cfg_i2c.h"
@@
-67,7
+65,7
@@
*
* \return true on success, false otherwise.
*/
*
* \return true on success, false otherwise.
*/
-static bool i2c_start(void)
+static bool i2c_
builtin_
start(void)
{
TWCR = BV(TWINT) | BV(TWSTA) | BV(TWEN);
WAIT_TWI_READY;
{
TWCR = BV(TWINT) | BV(TWSTA) | BV(TWEN);
WAIT_TWI_READY;
@@
-87,7
+85,7
@@
static bool i2c_start(void)
*
* \return true on success, false otherwise.
*/
*
* \return true on success, false otherwise.
*/
-bool i2c_start_w(uint8_t id)
+bool i2c_
builtin_
start_w(uint8_t id)
{
/*
* Loop on the select write sequence: when the eeprom is busy
{
/*
* Loop on the select write sequence: when the eeprom is busy
@@
-96,7
+94,7
@@
bool i2c_start_w(uint8_t id)
* keep trying until the eeprom responds with an ACK.
*/
ticks_t start = timer_clock();
* keep trying until the eeprom responds with an ACK.
*/
ticks_t start = timer_clock();
- while (i2c_start())
+ while (i2c_
builtin_
start())
{
TWDR = id & ~I2C_READBIT;
TWCR = BV(TWINT) | BV(TWEN);
{
TWDR = id & ~I2C_READBIT;
TWCR = BV(TWINT) | BV(TWEN);
@@
-127,9
+125,9
@@
bool i2c_start_w(uint8_t id)
*
* \return true on success, false otherwise.
*/
*
* \return true on success, false otherwise.
*/
-bool i2c_start_r(uint8_t id)
+bool i2c_
builtin_
start_r(uint8_t id)
{
{
- if (i2c_start())
+ if (i2c_
builtin_
start())
{
TWDR = id | I2C_READBIT;
TWCR = BV(TWINT) | BV(TWEN);
{
TWDR = id | I2C_READBIT;
TWCR = BV(TWINT) | BV(TWEN);
@@
-148,7
+146,7
@@
bool i2c_start_r(uint8_t id)
/**
* Send STOP condition.
*/
/**
* Send STOP condition.
*/
-void i2c_stop(void)
+void i2c_
builtin_
stop(void)
{
TWCR = BV(TWINT) | BV(TWEN) | BV(TWSTO);
}
{
TWCR = BV(TWINT) | BV(TWEN) | BV(TWSTO);
}
@@
-160,7
+158,7
@@
void i2c_stop(void)
*
* \return true on success, false on error.
*/
*
* \return true on success, false on error.
*/
-bool i2c_put(const uint8_t data)
+bool i2c_
builtin_
put(const uint8_t data)
{
TWDR = data;
TWCR = BV(TWINT) | BV(TWEN);
{
TWDR = data;
TWCR = BV(TWINT) | BV(TWEN);
@@
-181,7
+179,7
@@
bool i2c_put(const uint8_t data)
*
* \return the byte read if ok, EOF on errors.
*/
*
* \return the byte read if ok, EOF on errors.
*/
-int i2c_get(bool ack)
+int i2c_
builtin_
get(bool ack)
{
TWCR = BV(TWINT) | BV(TWEN) | (ack ? BV(TWEA) : 0);
WAIT_TWI_READY;
{
TWCR = BV(TWINT) | BV(TWEN) | (ack ? BV(TWEA) : 0);
WAIT_TWI_READY;
@@
-212,7
+210,7
@@
MOD_DEFINE(i2c);
/**
* Initialize TWI module.
*/
/**
* Initialize TWI module.
*/
-void i2c_init(void)
+void i2c_
builtin_
init(void)
{
ATOMIC(
/*
{
ATOMIC(
/*
@@
-237,7
+235,7
@@
void i2c_init(void)
/*
* Set speed:
/*
* Set speed:
- * F = C
LOCK
_FREQ / (16 + 2*TWBR * 4^TWPS)
+ * F = C
PU
_FREQ / (16 + 2*TWBR * 4^TWPS)
*/
#ifndef CONFIG_I2C_FREQ
#warning Using default value of 300000L for CONFIG_I2C_FREQ
*/
#ifndef CONFIG_I2C_FREQ
#warning Using default value of 300000L for CONFIG_I2C_FREQ
@@
-245,7
+243,7
@@
void i2c_init(void)
#endif
#define TWI_PRESC 1 /* 4 ^ TWPS */
#endif
#define TWI_PRESC 1 /* 4 ^ TWPS */
- TWBR = (C
LOCK
_FREQ / (2 * CONFIG_I2C_FREQ * TWI_PRESC)) - (8 / TWI_PRESC);
+ TWBR = (C
PU
_FREQ / (2 * CONFIG_I2C_FREQ * TWI_PRESC)) - (8 / TWI_PRESC);
TWSR = 0;
TWCR = BV(TWEN);
);
TWSR = 0;
TWCR = BV(TWEN);
);