When using the Microsoft.SPOT.Hardware.CPu.Pin for a general class does it cast appropriately using ((CPu.Pin)Pins.whatever) from the each of the Netduino.Pins classes? I am having some trouble determining a very general exception when doing so.
Casting Pins Exception
Started by Bendage, Apr 12 2012 06:34 PM
4 replies to this topic
#1
Posted 12 April 2012 - 06:34 PM
#2
Posted 12 April 2012 - 07:51 PM
Hi,
the "SecretLabs.NETMF.Hardware.Netduino.Pins" are in fact only constants with "Microsoft.SPOT.Hardware.Cpu.Pin" definitions inside. They exist only for one purpose: to give them a cool name like "Pins.GPIO_PIN_D7" instead of "Pin.GPIO_Pin3". Both names decribe the digital port 7. Only "...D7" is easier to remember than "3".
There is no cast involved and each parameter in a method signature has to use "Microsoft.SPOT.Hardware.Cpu.Pin".
If you use your VisualStudios IntelliSense feature on a Netduin pin definition (hover over it with your mouse) you see the Microsoft pin definition in the popup text.
Regards
Guido
#3
Posted 12 April 2012 - 09:48 PM
Thanks for the reply. I think the error is coming from when I take an output port and set it to new using another pin. Do I have to dispose the current port or disable interrupt or what because its not letting me.
#4
Posted 13 April 2012 - 12:11 AM
Hi Bendage,
Chris
Yes, when you are done using an OutputPort/InputPort/etc., please dispose of it.Thanks for the reply. I think the error is coming from when I take an output port and set it to new using another pin. Do I have to dispose the current port or disable interrupt or what because its not letting me.
Chris
#5
Posted 18 April 2012 - 12:23 PM
All the ports inherit from the Port class, which implements IDisposable. This means that you can stick the port in a using block, e.g.:
Dave
P.S. Are Ports 'cheap' things to create? How wary should one be one rapidly creating and destroying ports? If output and interrupt were needed?
using (OutputPort outputPort = new OutputPort(pin, false)) { //Do Stuff }
Dave
P.S. Are Ports 'cheap' things to create? How wary should one be one rapidly creating and destroying ports? If output and interrupt were needed?
Edited by BanksySan, 18 April 2012 - 12:36 PM.
0 user(s) are reading this topic
0 members, 0 guests, 0 anonymous users