[Tinyos-devel] I2C Driver for MSP430
Max CORTIANA
max.cortiana at st.com
Wed Sep 6 09:23:33 PDT 2006
There you find a snapshot of my code.
I still see that no HW interrupt ( != signal ) is received after last
STOP sent over I2C.
Today I've seen the same problem also with a read + read combination.
- Max
I2CAppC.nc
#include "I2C.h"
configuration I2CappC
{
}
implementation
{
components MainC, I2Capp, LedsC;//, Msp430I2CC;*/
/*components new TimerMilliC() as Timer0;
components new TimerMilliC() as Timer1;
components new TimerMilliC() as Timer2;
*/
I2Capp -> MainC.Boot;
components HplMsp430GeneralIOC;
I2Capp.HplMsp430GeneralIOADC -> HplMsp430GeneralIOC.ADC3/*ADC3*/;
I2Capp.HplMsp430GeneralIOInterrupt -> HplMsp430GeneralIOC.Port20/*ADC3*/;
I2Capp.Leds -> LedsC;
components new Msp430I2CC();
Msp430I2CC.Msp430I2CConfigure->I2Capp;
I2Capp.I2CBasicAddr->Msp430I2CC;
I2Capp.Resource -> Msp430I2CC;
// BlinkC.Leds -> LedsC;
}
--------------------------------------------------------
I2Capp.nc:
module I2Capp
{
provides interface Msp430I2CConfigure;
uses interface I2CPacket<TI2CBasicAddr> as I2CBasicAddr;
uses interface Boot;
uses interface HplMsp430GeneralIO as HplMsp430GeneralIOADC;
uses interface HplMsp430GeneralIO as HplMsp430GeneralIOInterrupt;
uses interface Leds;
uses interface Resource;
}
implementation
{
uint8_t buffer[10];
uint8_t write;
uint16_t threshold;
event void Boot.booted()
{
write = 3;
threshold = 0x10;
}
async command msp430_i2c_config_t* Msp430I2CConfigure.getConfig(){
return &msp430_i2c_default_config;
}
task void test(){
switch (write){
case 3:
buffer[0] = 0x28; //indirizzo del primo registro
buffer[0] |= 0x80;
write = 4;
call I2CBasicAddr.write(I2C_START|I2C_STOP, 0x1D, 1, buffer);
break;
case 4:
write = 3;
call I2CBasicAddr.read(I2C_START|I2C_STOP, 0x1D, 6, buffer);
break;
}
return;
}
async event void I2CBasicAddr.writeDone(error_t error, uint16_t addr,
uint8_t length, uint8_t* data){
post test();
return;
}
async event void I2CBasicAddr.readDone(error_t error, uint16_t addr,
uint8_t length, uint8_t* data){
post test();
return;
}
event void Resource.granted(){
post scrivi();
return;
}
}
--------------------------------------------------------
Jonathan Hui wrote:
> Can you send some sample code that reproduces the problem?
>
> Also, just to verify the I2C code you're using, what is the revision
> of the Msp430I2CP.nc printed in the @version tag?
>
> Thanks.
>
More information about the Tinyos-devel
mailing list