本帖最后由 litiejun 于 2013-9-22 10:27 编辑
这些天学习pcduino 终于有一点点收获了 驱动起来spi 正好有一个74hc595电路模块 就驱动起来
只是。。。。。。。不知道如何上传照片
程序#include <stdio.h> #include <string.h> #include <core.h> #include "SPI.h" int led_pin = 10; //#define EX_SPI_TEST int ReadSpiflashID(void) { 1 #include <stdio.h> 2 #include <string.h> 3 #include <core.h> 4 #include "SPI.h" 5 int led_pin = 10; 6 //#define EX_SPI_TEST 7 8 int ReadSpiflashID(void) { 9 pinMode(led_pin, OUTPUT); 10 digitalWrite(led_pin, LOW); 11 SPI.transfer (0x20,SPI_CONTINUE); 12 digitalWrite(led_pin, HIGH); 13 14 return 9; 15 } 16 17 void setup() { 18 pinMode(led_pin, OUTPUT); 19 SPI.begin(); 20 SPI.setDataMode(SPI_MODE3); 21 SPI.setBitOrder(MSBFIRST); 22 SPI.setClockDivider(SPI_CLOCK_DIV16); 23 24 } 25 void loop() { 26 //MSB first 27 printf("spi flash id = 0x%x\n", ReadSpiflashID()); 28 delay(2000); 29 }
|