Netduino home hardware projects downloads community

Jump to content


The Netduino forums have been replaced by new forums at community.wildernesslabs.co. This site has been preserved for archival purposes only and the ability to make new accounts or posts has been turned off.
Photo

I2C Driver Improvement


  • Please log in to reply
5 replies to this topic

#1 CW2

CW2

    Advanced Member

  • Members
  • PipPipPip
  • 1592 posts
  • LocationCzech Republic

Posted 16 September 2010 - 09:30 PM

This is a follow-up to missing start bit in I2C communication post. I have been able to successfully get the temperature reading from Melexis MLX90614 IR Thermometer by hardcoding the internal address in the firmware, namely MasterXAction_Start function method:


// DeviceCode\Targets\Native\AT91\DeviceCode\AT91_I2C\AT91__I2C.cpp, line 123
if (g_AT91_I2C_Driver.m_currentXActionUnit->IsReadXActionUnit())
{
  address |=  AT91_I2C::TWI_MMR_MREAD_R ;

  // Experimental: Master Read with hardcoded IADR -> repeated start bit
  address |= AT91_I2C::TWI_MMR_IADRSZ_1;  // Size = 1
  I2C.TWI_IADR = 0x7;                     // Melexis RAM Tobj1 Address
}
Although this fits my particular needs, it obviously cannot be used as a general solution. After a bit of further investigation, it seems to be possible to modify the I2CDevice::Execute() method (in spot_hardware_native_Microsoft_SPOT_Hardware_I2CDevice.cpp) to examine the list of transactions and replace Write+Read sequences with a Read transaction that takes the buffer from preceding Write transaction and sets it as internal address (up to three bytes supported). The internal address can be stored in new attributes of I2C_HAL_XACTION structure and the value can be set to TWI registers in AT91_I2C_Driver::MasterXAction_Start.

Note: I focused on the native layer, because most of the managed classes are sealed and modification would result in a need to rebuild and distribute the whole SDK (managed dlls) along with the firmware.

If anyone is interested in doing this (perhaps in a completely different/much better way), I will be glad to provide more detailed information and I can test the code - unfortunately, I cannot do it by myself right now, because I am busy finishing OneWire support.

#2 phantomtypist

phantomtypist

    Advanced Member

  • Members
  • PipPipPip
  • 142 posts
  • LocationNew York, NY

Posted 12 October 2010 - 05:35 AM

Any updates on the progress of implementing a fix for this problem?

#3 CW2

CW2

    Advanced Member

  • Members
  • PipPipPip
  • 1592 posts
  • LocationCzech Republic

Posted 08 November 2010 - 08:36 PM

Any updates on the progress of implementing a fix for this problem?

I have just published I2CDevice extension (firmware and managed dll) that supports Repeated Start condition.

#4 Chris Walker

Chris Walker

    Secret Labs Staff

  • Moderators
  • 7767 posts
  • LocationNew York, NY

Posted 28 December 2010 - 01:59 AM

Update: based on CW2's contribution, this feature has been incorporated into the v4.1.1 alpha 4 firmware, which will be posted by 12/31/2010.

#5 madartsoft

madartsoft

    Member

  • Members
  • PipPip
  • 19 posts

Posted 08 January 2011 - 10:54 AM

Hi, When the new firmware with mentioned I2CDevice support will be available?

#6 Fred

Fred

    Advanced Member

  • Members
  • PipPipPip
  • 302 posts
  • LocationUK

Posted 08 January 2011 - 01:36 PM

Already available (and updated to alpha 5) here.




0 user(s) are reading this topic

0 members, 0 guests, 0 anonymous users

home    hardware    projects    downloads    community    where to buy    contact Copyright © 2016 Wilderness Labs Inc.  |  Legal   |   CC BY-SA
This webpage is licensed under a Creative Commons Attribution-ShareAlike License.