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

C# equivalent for Wire.endTransmission(false) ?


  • Please log in to reply
4 replies to this topic

#1 Frode

Frode

    Advanced Member

  • Members
  • PipPipPip
  • 202 posts
  • LocationNorway

Posted 26 September 2013 - 07:49 PM

Hi,

I'm trying to write a driver for the MPL3115A2 Altimeter, but have some trouble with the I2C communication. I've got several other I2C devices working fine, so I think there is a particularity with this device I'm having trouble with.

 

The Arduino example code says this, at the bottom of the page:

 

byte [color=rgb(153,0,0);font-weight:bold;]IIC_Read[/color](byte regAddr)
{
[color=rgb(153,153,136);font-style:italic;]// This function reads one byte over IIC[/color]
Wire.beginTransmission(MPL3115A2_ADDRESS);
Wire.write(regAddr); [color=rgb(153,153,136);font-style:italic;]// Address of CTRL_REG1[/color]
Wire.endTransmission([color=rgb(0,134,179);]false[/color]); [color=rgb(153,153,136);font-style:italic;]// Send data to I2C dev with option for a repeated start. THIS IS NECESSARY and not supported before Arduino V1.0.1![/color]
Wire.requestFrom(MPL3115A2_ADDRESS, [color=rgb(0,153,153);]1[/color]); [color=rgb(153,153,136);font-style:italic;]// Request the data...[/color]
return Wire.read();
}

 

I have a feeling my problem occurs because I cannot find a C#-equivalent for endTransmission(false);

Does anyone have an idea on how I can accomplish the same with C#?

 

Here is the code I use. It uses the I2C helperclass found in this thread.

 

            byte[] readBuffer = new byte[1];
            bus.ReadRegister(config, (byte)Registers.CTRL_REG1, readBuffer, Timeout);
 
Whatever I do I only get 0-values back from the device.


#2 TinkeringTurtle

TinkeringTurtle

    Advanced Member

  • Members
  • PipPipPip
  • 55 posts

Posted 26 September 2013 - 08:06 PM

The endTransmission() parameter is setting the internal address feature (repeated start bit). Have you checked this out yet?



#3 Frode

Frode

    Advanced Member

  • Members
  • PipPipPip
  • 202 posts
  • LocationNorway

Posted 26 September 2013 - 08:14 PM

Thanks, I agree, that seems to be valid for my case. I'll try to figure it out from Chris's example.



#4 scardinale

scardinale

    Member

  • Members
  • PipPip
  • 27 posts
  • LocationNew York, USA

Posted 25 April 2014 - 02:00 PM

Did you ever get this working, I am having the same problem. Would you mind sharing your code?



#5 Frode

Frode

    Advanced Member

  • Members
  • PipPipPip
  • 202 posts
  • LocationNorway

Posted 26 April 2014 - 06:37 PM

No, unfortunatly not. I think I stopped working on it after posting in this thread:

http://forums.netdui...ort/#entry56305




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.