Reading and Writing Bytes to Pins
#1
Posted 23 August 2010 - 01:24 AM
#2
Posted 23 August 2010 - 02:15 AM
#3
Posted 23 August 2010 - 03:00 AM
Can the Microsoft.SPOT.Hardware.SPI class be used for this somehow? it needs a configuration which needs a CPU pin, is there a map between the CPU pins and the netduino hardware pins?
The "Pins." enumeration contains the pin definitions for the Netduino pins. It's in the SecretLabs.NETMF.Hardware.Netduino namespace (which is included in Netduino applications by default).
Chris
#4
Posted 23 August 2010 - 03:25 AM
#5
Posted 23 August 2010 - 03:34 AM
#6
Posted 23 August 2010 - 05:08 AM
Yes, absolutely...the "Pins." enumeration returns a Cpu.Pin. You can use them anywhere that a Cpu.Pin is required in the .NET MF or SecretLabs namespaces.
As to whether or not the SPI class is the answer to what you're trying to accomplish...can you give us an example of what you're trying to do?
The SerialPort class will write serial data over D0/D1 or D2/D3. The SPI class will write SPI data over D11-D13. The I2C class will write I2C data over pins A4/A5. If those are what you need, then it's built in. If you're looking for something different, then we can make recommendations as to what to do (and whether to do it in managed C# or native code).
We'll be releasing drivers for a number of shields alongside the v4.1.1 release in September. In the meantime...
Here is an example of using SPI from a community member's code:
http://forums.netdui...ch__1#entry1055
Chris
got it, yes, that's what i want to do. last question, i don't see anything to configure typical serial setup stuff such as baud rate, parity bit, etc. is there a way to do that?
#7
Posted 23 August 2010 - 05:26 AM
got it, yes, that's what i want to do. last question, i don't see anything to configure typical serial setup stuff such as baud rate, parity bit, etc. is there a way to do that?
For serial baud rate, parity, etc. you can either use the System.IO.SerialPort constructor or set the properties of System.IO.SerialPort manually.
You'll also need to add a reference to the Microsoft.SPOT.Hardware.SerialPort.dll assembly to your project to use the serial port feature...
Chris
#8
Posted 23 August 2010 - 05:44 AM
#9
Posted 23 August 2010 - 05:56 AM
but serial port doesn't work for pins. i'm trying to get serial functionality on the digital input pins. for instance, i have a gps module that dumps raw data on a particular pin. i'd like to create a serial listener that listens on that pin at a certain baud rate, parity, etc.
You should hook the GPS module up to the RX line of serial port #1 (RX = pin D0) or serial port #2 (RX = pin D2). Schematics are here. Then use an instance of the System.IO.SerialPort class to read your GPS data. Some of our users have already built a GPS Parser if you'd like to use that as well.
The Atmel MCU natively provides SerialPort on certain pins--but if you're looking for custom serial support on digital pins other than those that the Atmel MCU provides then you'll need a native C++ driver and bit-banged communication.
Chris
#10
Posted 23 August 2010 - 06:30 AM
#11
Posted 23 August 2010 - 11:40 AM
ok. so this chip has 2 uarts, right? so i get two "true" serial interfaces (d0 rx, d1 tx, and d2 rx, d3, tx), that's what you're saying, correct? now, if i create a System.IO.SerialPort object, what is the named instance of those two serial interfaces, com1 and com2?
now, on serial communication across other pins, true serial communications have been limited (traditionally) by the number of uarts on the chip, however, with modern chips, such as this, that's not really an issue with a proper message pump and, in this case (with .net), threading. i don't believe i need a native c++ driver. correct me if i'm wrong. (even if you do correct me, i'm going to try and prove that it's possible - i've been able to get it to work with a number of less powerful chips. ). hhahaha
what i am hoping, however, is that i can wrangle an SPI to do this for me. we'll see.
as far as the GPS parser, i'm going to go with this one: http://code.google.com/p/gpstalk/ - it's open source (i wrote it), and it appears much more feature rich than the other examples here i've seen. and.. it's being used in swedish missile guidance systems. hhahhahahah
Yes, D0/D1 are COM1 and D2/D3 are COM2.
0 user(s) are reading this topic
0 members, 0 guests, 0 anonymous users