WIZnet2012

Netduino: 用Ethernet Shield读/写SD卡

0
阅读(2327)

在成功的运行一个程序后,写一个文件到SD卡中,然后就可以读取内容了。我已经决定总结所有需要的步骤为了使用“带Ethernet Shield和SD卡”的Netduino。

首先,你需要更新固件(我使用的是v4.1.1.0 Beta,可以在这里找到)。关于固件升级的详细说明可在相同的地址找到。

接下来,你需要焊接ICSP引脚在你的Netduino板子上并用跳线连接D4和D10,如下图所示。

 

在增加了ICSP接头和跳线,硬件已经就绪,你可以写一个程序来使用SD卡的读卡器。以下是我用来测试的例程,运行顺畅。

using System;
using System.Threading;
using Microsoft.SPOT;
using Microsoft.SPOT.Hardware;
using SecretLabs.NETMF.Hardware;
using SecretLabs.NETMF.Hardware.Netduino;
using SecretLabs.NETMF.IO;
using System.IO;

namespace NetduinoSD
{
public class Program
{
public static void Main()
{
StorageDevice.MountSD(“SD”, SPI.SPI_module.SPI1, Pins.GPIO_PIN_D10);
using (var filestream = new FileStream(@”SD\dontpanic.txt”, FileMode.Create))
{
StreamWriter streamWriter = new StreamWriter(filestream);
streamWriter.WriteLine(“This is a test of the SD card support on the netduino…This is only a test…”);
streamWriter.Close();
}

using (var filestream = new FileStream(@”SD\dontpanic.txt”, FileMode.Open))
{
StreamReader reader = new StreamReader(filestream);
Debug.Print(reader.ReadToEnd());
reader.Close();
}

StorageDevice.Unmount(“SD”);

}

}
}

完整的Visual Studio 解决方案可在这里找到。

翻译自:http://mypetprojects.blogspot.com/2011/10/netduino-using-ethernet-shield-to.html

感谢关注!

与我们更多联系:

WIZnet邮箱:wiznetbj@wiznet.co.kr

WIZnet主页:http://www.wiznet.co.kr

WIZnet企业微博http://e.weibo.com/wiznet2012