树莓派使用16位SPI模式及静态库编译连接
本文地址:http://tongxinmao.com/Article/Detail/id/35
int wiringPiSPISetupMode (int channel, int speed, int mode) { int fd ; mode &= 3 ; // Mode is 0, 1, 2 or 3 channel &= 1 ; // Channel is 0 or 1 if ((fd = open (channel == 0 ? spiDev0 : spiDev1, O_RDWR)) < 0) return wiringPiFailure (WPI_ALMOST, "Unable to open SPI device: %s\n", strerror (errno)) ; spiSpeeds [channel] = speed ; spiFds [channel] = fd ; // Set SPI parameters. if (ioctl (fd, SPI_IOC_WR_MODE, &mode) < 0) return wiringPiFailure (WPI_ALMOST, "SPI Mode Change failure: %s\n", strerror (errno)) ; if (ioctl (fd, SPI_IOC_WR_BITS_PER_WORD, &spiBPW) < 0) return wiringPiFailure (WPI_ALMOST, "SPI BPW Change failure: %s\n", strerror (errno)) ; if (ioctl (fd, SPI_IOC_WR_MAX_SPEED_HZ, &speed) < 0) return wiringPiFailure (WPI_ALMOST, "SPI Speed Change failure: %s\n", strerror (errno)) ; return fd ; }
https://github.com/WiringPi/WiringPi/blob/master/wiringPi/wiringPiSPI.c
How to install wiringPi ======================= The easiest way is to use the supplied 'build' script: ./build that should do a complete install or upgrade of wiringPi for you. That will install a dynamic library. cd wiringPi make static sudo make install-static To un-install wiringPi: ./build uninstall 静态库的连接用法的确是 gcc -L libpath -llibname
上一篇:树莓派 SPI Interface编程
下一篇:流媒体(电视)测试地址