• Home
  • pcDuino
  • WiKi
  • Store
  • Distributors
  • Home
  • pcDuino
  • WiKi
  • Store
  • Distributors
HomepcDuinoArduino-ish ProgramSPIDriver 74hc595 by SPI on pcDuino
Previous Next

Driver 74hc595 by SPI on pcDuino

Posted by: Alvin Jin , March 15, 2014

Learning pcDuino for some days and had some gains. Just can driver SPI and have 74hc595 circuit module. 

Driver it up

Code:

#include <stdio.h>
#include <string.h>
#include <core.h>
#include "SPI.h"
int led_pin = 10;
//#define EX_SPI_TEST

int ReadSpiflashID(void) {
#include <stdio.h>
       #include <string.h>
       #include <core.h>
       #include "SPI.h"
       int led_pin = 10;
       //#define EX_SPI_TEST
      
       int ReadSpiflashID(void) {
               pinMode(led_pin, OUTPUT);
              digitalWrite(led_pin, LOW);
             SPI.transfer (0x20,SPI_CONTINUE);
              digitalWrite(led_pin, HIGH);
     
          return 9;
      }
     
      void setup() {
              pinMode(led_pin, OUTPUT);
          SPI.begin();
          SPI.setDataMode(SPI_MODE3);
          SPI.setBitOrder(MSBFIRST);
          SPI.setClockDivider(SPI_CLOCK_DIV16);
     
      }
      void loop() {
          //MSB first
          printf("spi flash id = 0x%x\n", ReadSpiflashID());
          delay(2000);
      }

Tags: SPI

Share!
Tweet

Alvin Jin

About the author

Leave a Reply Cancel reply

You must be logged in to post a comment.

Category

  • Home
  • pcDuino
  • WiKi
  • Store
  • Distributors