In the latest update of tinyos 2.x, it seems Atm128I2C.h is in two places:
/opt/tinyos-2.x/tos/chips/atm128/
and
/opt/tinyos-2.x/tos/chips/atm128/I2C
They have different contents, and Atm128_TWBR_t is defined multiple times,
causing compiler errors.
I copied the contents of the smaller file to the larger, yielding:
#ifndef _H_Atm128I2C_h
#define _H_Atm128I2C_h
//====================== I2C Bus ==================================
/* SCL freq = CPU freq / (16 + 2(TWBR) * pow(4, TWPR)) */
enum {
ATM128_I2C_RATE_DIVIDE_16 = 0,
ATM128_I2C_RATE_DIVIDE_24 = 1,
ATM128_I2C_RATE_DIVIDE_80 = 2,
}
typedef uint8_t Atm128_TWBR_t; //!< Two Wire Bit Rate Register
/* I2C Control Register */
typedef struct
{
uint8_t twie : 1; //!< Two Wire Interrupt Enable
uint8_t rsvd : 1; //!< Reserved
uint8_t twen : 1; //!< Two Wire Enable Bit
uint8_t twwc : 1; //!< Two Wire Write Collision Flag
uint8_t twsto : 1; //!< Two Wire Stop Condition Bit
uint8_t twsta : 1; //!< Two Wire Start Condition Bit
uint8_t twea : 1; //!< Two Wire Enable Acknowledge Bit
uint8_t twint : 1; //!< Two Wire Interrupt Flag
} Atm128I2CControl_t;
typedef Atm128I2CControl_t Atm128_TWCR_t; //!< Two Wire Control Register
/* SCL freq = CPU freq / (16 + 2(TWBR) * pow(4, TWPR)) */
enum {
ATM128_I2C_PRESCALE_1 = 0,
ATM128_I2C_PRESCALE_4 = 1,
ATM128_I2C_PRESCALE_16 = 2,
ATM128_I2C_PRESCALE_64 = 3,
};
enum {
ATM128_I2C_STATUS_START = 1,
};
/* I2C Status Register */
typedef struct
{
uint8_t twps : 2; //!< Two Wire Prescaler Bits
uint8_t rsvd : 1; //!< Reserved
uint8_t tws : 5; //!< Two Wire Status
} Atm128I2CStatus_t;
typedef Atm128I2CStatus_t Atm128_TWCR_t; //!< Two Wire Status Register
typedef uint8_t Atm128_TWDR_t; //!< Two Wire Data Register
typedef uint8_t Atm128_TWAR_t; //!< Two Wire Slave Address Register
#define ATM128_I2C_SLA_WRITE 0x00
#define ATM128_I2C_SLA_READ 0x01
#define UQ_ATM128_I2CMASTER "Atm128I2CMasterC.I2CPacket"
enum {
ATM128_I2C_BUSERROR = 0x00,
ATM128_I2C_START = 0x08,
ATM128_I2C_RSTART = 0x10,
ATM128_I2C_MW_SLA_ACK = 0x18,
ATM128_I2C_MW_SLA_NACK = 0x20,
ATM128_I2C_MW_DATA_ACK = 0x28,
ATM128_I2C_MW_DATA_NACK = 0x30,
ATM128_I2C_M_ARB_LOST = 0x38,
ATM128_I2C_MR_SLA_ACK = 0x40,
ATM128_I2C_MR_SLA_NACK = 0x48,
ATM128_I2C_MR_DATA_ACK = 0x50,
ATM128_I2C_MR_DATA_NACK = 0x58
};
#endif //_H_Atm128I2C_h
Does anyone know which Atm128_TWBR_t line to keep? And exactly what this
file should really look like?
Here's my component/config file (nothing too spectacular):
#include "I2CMasterWrite.h"
#include "I2C.h"
#include "Atm128I2C.h"
configuration I2CMasterWriteC {
}
implementation {
components MainC;
components I2CMasterWriteM as App;
components LedsC;
components new TimerMilliC() as Timer0;
components new Atm128I2CMasterC() as I2CMaster ;
App.Boot -> MainC.Boot;
App.Leds -> LedsC;
App.Timer0 -> Timer0;
App.I2CBasicAddr-> I2CMaster.I2CPacket;
App.I2CResource -> I2CMaster.Resource;
}
Regards,
Kurt
_______________________________________________
Tinyos-help mailing list
[email protected]
https://mail.millennium.berkeley.edu/cgi-bin/mailman/listinfo/tinyos-help