本文整理汇总了C#中SPI.Write方法的典型用法代码示例。如果您正苦于以下问题:C# SPI.Write方法的具体用法?C# SPI.Write怎么用?C# SPI.Write使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类SPI
的用法示例。
在下文中一共展示了SPI.Write方法的1个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。
示例1: LedStripLPD8806
/// <summary>
/// c'tor
/// </summary>
/// <param name="socket">the Gadgeteer socket that the strip is on</param>
/// <param name="numLeds">the number of LEDs in the strip</param>
public LedStripLPD8806(GT.Socket socket, int numLeds)
{
var spiConfig = new SPI.Configuration(Cpu.Pin.GPIO_NONE,
false, // chip select active state
0, // chip select setup time
0, // chip select hold time
false, // clock idle state
true, // clock edge (true = rising)
2000, // 2mhz
SPI.SPI_module.SPI1
);
// the protocol seems to be that we need to write 1 + (1 per 64 LEDs) bytes
// at the end of each update (I've only tested this on a 32-LED strip)
int latchBytes = ((numLeds + 63) / 64) * 3;
mLedByteCount = numLeds * 3;
mData = new byte[mLedByteCount + latchBytes];
mNumLeds = numLeds;
// mLedStrip = new SPI(socket, spiConfig, SPI.Sharing.Exclusive, null);
mLedStrip = new SPI(spiConfig);
// start with all the LEDs off
for (int i = 0; i < mLedByteCount; i++)
{
mData[i] = MASK;
}
// give the strip an inital poke of the latch bytes (no idea
// why this is needed)
mLedStrip.Write(new byte[latchBytes]);
// push the initial values (all off) to the strip
SendUpdate();
}