Shield base pins reassignment - Netduino Go - Netduino Forums
   
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

Shield base pins reassignment


  • Please log in to reply
9 replies to this topic

#1 eplaksienko

eplaksienko

    Advanced Member

  • Members
  • PipPipPip
  • 112 posts

Posted 23 April 2013 - 03:47 PM

Question What happens if I open some D pin on shield base as output, then in some period of time reassign it as input?

 

Is it going to work? Does it require specific actions?

 

Thanks



#2 Chris Walker

Chris Walker

    Secret Labs Staff

  • Moderators
  • 7767 posts
  • LocationNew York, NY

Posted 23 April 2013 - 10:41 PM

Hi eplaksienko, Just dispose of the OutputPort when you don't need it anymore...and then you can open that pin as an InputPort, InterruptPort, etc. You can also use TristatePort...which lets you switch between input and output modes on the fly. Chris

#3 eplaksienko

eplaksienko

    Advanced Member

  • Members
  • PipPipPip
  • 112 posts

Posted 24 April 2013 - 01:50 PM

Thanks Chris

 

Actually, about disposal, what the quickest way to do it in NETMF? I am C++ person :D and C# and Java behavior make me always puzzled about it :D



#4 Chris Walker

Chris Walker

    Secret Labs Staff

  • Moderators
  • 7767 posts
  • LocationNew York, NY

Posted 24 April 2013 - 10:23 PM

Actually, about disposal, what the quickest way to do it in NETMF? I am C++ person :D and C# and Java behavior make me always puzzled about it :D

Here's an example...
// initialize the pin...OutputPort pinD1 = new OutputPort(Pins.GPIO_PIN_D1, false);// use the pin...pinD1.Write(true);// now dispose of the pin so that you can use it as an InputPort, etc.pinD1.Dipose();
That's pretty much it! Chris

#5 neslekkim

neslekkim

    Advanced Member

  • Members
  • PipPipPip
  • 350 posts
  • LocationOslo, Norway

Posted 24 April 2013 - 10:54 PM

No support for: using( OutputPort PinD1 =new.....) { pinD1.Write... } ??

--
Asbjørn


#6 Chris Walker

Chris Walker

    Secret Labs Staff

  • Moderators
  • 7767 posts
  • LocationNew York, NY

Posted 25 April 2013 - 01:01 AM

Hi neslekkim, You could also go that route if it works well in your code flow. Chris

#7 eplaksienko

eplaksienko

    Advanced Member

  • Members
  • PipPipPip
  • 112 posts

Posted 26 April 2013 - 02:18 PM

Chris, I get exception on dispose



#8 Chris Walker

Chris Walker

    Secret Labs Staff

  • Moderators
  • 7767 posts
  • LocationNew York, NY

Posted 26 April 2013 - 03:01 PM

Hi eplaksienko,

Chris, I get exception on dispose

Could you please share your code? What exception is being raised? Chris

#9 eplaksienko

eplaksienko

    Advanced Member

  • Members
  • PipPipPip
  • 112 posts

Posted 26 April 2013 - 03:36 PM

 Thread.Sleep(5000);

            ShieldBase sb = new ShieldBase((GoBus.GoSocket)4);
 
         
 
            OutputPort op1 = new OutputPort(sb.Pins.GPIO_PIN_D1, false);
            InputPort ip1 = new InputPort(sb.Pins.GPIO_PIN_D3, false, ResistorModes.Disabled);
            op1.Write(true);
            Thread.Sleep(5000);
            op1.Dispose();
            ip1.Dispose();
 
            OutputPort op2 = new OutputPort(sb.Pins.GPIO_PIN_D3, false);
            op2.Write(true);
            InputPort ip2 = new InputPort(sb.Pins.GPIO_PIN_D1, false, ResistorModes.Disabled);
            Thread.Sleep(5000);


#10 eplaksienko

eplaksienko

    Advanced Member

  • Members
  • PipPipPip
  • 112 posts

Posted 26 April 2013 - 03:37 PM

A first chance exception of type 'System.Exception' occurred in Microsoft.SPOT.Hardware.dll
An unhandled exception of type 'System.Exception' occurred in Microsoft.SPOT.Hardware.dll
 
on [color=rgb(40,40,40);font-family:helvetica, arial, sans-serif;]op1.Dispose();[/color]





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.