C# 在Raspberry Pi上包含bcm2853库
我想在我的树莓上与C#开始SPI通信。 bcm2835库支持所需的命令,如:C# 在Raspberry Pi上包含bcm2853库,c#,dll,raspberry-pi,spi,C#,Dll,Raspberry Pi,Spi,我想在我的树莓上与C#开始SPI通信。 bcm2835库支持所需的命令,如: bcm2835\u spi\u begin() bcm2835\u spi\u end() 等等 在C语言中,你必须#包括,但在C语言中,你必须使用bcm2835不起作用 安装了RaspberryPidDotnet和bcm2835库 GPIO引脚可通过使用bcm2835库的GPIOMem命令进行控制 C#如何使用bcm2835的SPI命令?网络上的一切都是C或C++的。< /P>如何在Raspberry Pi上获得
bcm2835\u spi\u begin()
bcm2835\u spi\u end()
- 等等
#包括
,但在C语言中,你必须使用bcm2835代码>不起作用
安装了RaspberryPidDotnet和bcm2835库
GPIO引脚可通过使用bcm2835库的GPIOMem
命令进行控制
C#如何使用bcm2835的SPI命令?网络上的一切都是C或C++的。< /P>如何在Raspberry Pi上获得与C语言的SPI
以下是如何使其工作的完整教程:
sudo apt-get update
sudo apt-get install mono-complete
mkdir gpio_csharp
git clone git://github.com/cypherkey/RaspberryPi.Net.git
cd RaspberryPi.Net/RaspberryPiDotNet
xbuild RaspberryPiDotNet.csproj
cp bin/Debug/RaspberryPiDotNet.dll /home/pi/gpio_csharp/
wget http://www.airspayce.com/mikem/bcm2835/bcm2835-1.36.tar.gz
tar -zxf bcm2835-1.36.tar.gz
cd bcm2835-1.36
./configure
make
sudo make check
sudo make install
cd src
cc - shared bcm2835.o -o libbcm2835.so
cp libbcm2835.so /home/pi/gpio_csharp/
使用此命令,您可以删除创建的文件夹和文件,但不删除“gpio_csharp”:
(将其添加到程序的“类”空间中)
现在您可以使用以下命令来使用SPI。下面是例子
spi_begin();
spi_end();
spi_transfer();
spi_chipSelect();
spi_setClockDivider();
spi_setDataMode();
spi_setChipSelectPolarity();
示例:
//SPI Try
spi_setClockDivider(128);
spi_setDataMode(0);
spi_chipSelect(cs);
spi_setChipSelectPolarity(cs, false);
spi_begin();
spi_transfer(0xAA);
spi_end();
sudo apt-get update
sudo apt-get install mono-complete
mkdir gpio_csharp
git clone git://github.com/cypherkey/RaspberryPi.Net.git
cd RaspberryPi.Net/RaspberryPiDotNet
xbuild RaspberryPiDotNet.csproj
cp bin/Debug/RaspberryPiDotNet.dll /home/pi/gpio_csharp/
wget http://www.airspayce.com/mikem/bcm2835/bcm2835-1.36.tar.gz
tar -zxf bcm2835-1.36.tar.gz
cd bcm2835-1.36
./configure
make
sudo make check
sudo make install
cd src
cc - shared bcm2835.o -o libbcm2835.so
cp libbcm2835.so /home/pi/gpio_csharp/
使用此命令,您可以删除创建的文件夹和文件,但不删除“gpio_csharp”:
(将其添加到程序的“类”空间中)
现在您可以使用以下命令来使用SPI。下面是例子
spi_begin();
spi_end();
spi_transfer();
spi_chipSelect();
spi_setClockDivider();
spi_setDataMode();
spi_setChipSelectPolarity();
示例:
//SPI Try
spi_setClockDivider(128);
spi_setDataMode(0);
spi_chipSelect(cs);
spi_setChipSelectPolarity(cs, false);
spi_begin();
spi_transfer(0xAA);
spi_end();
非常感谢你的指导!编译libbcm2835时,我迷路了,因为我不知道cc-shared bcm2835.o-o libbcm2835.o你的代码是
cc-shared bcm2835.o-o libbcm2835.so
,不应该是cc-shared bcm2835.o-o libbcm2835.so
(前面没有空格shared
)?非常感谢你的教程!编译libbcm2835时,我丢失了,因为我不知道cc-shared bcm2835.o-o libbcm2835.o你的代码是cc-shared bcm2835.o-o libbcm2835.so
,它不应该是cc-shared bcm2835.o-o libbcm2835.so
(前面没有空格shared
)?