yoshinari kou / Mbed 2 deprecated WW_SD_send_IRVer2

Dependencies:   mbed

Embed: (wiki syntax)

« Back to documentation index

Show/hide line numbers wwChipSelect.cpp Source File

wwChipSelect.cpp

00001 //Nest Egg Inc.
00002 //http://nestegg.jp/
00003 //White Wizard Board SPI Chip Select Code
00004 //Auther : Yoshinari kou
00005 //2010/10/03
00006 
00007 #include "wwChipSelect.h"
00008 //#define NORMAL    //if you want to use normal chipselect, you should enable this code.
00009 
00010 wwChipSelect :: wwChipSelect(PinName cs):
00011  ChipSelect(cs){
00012  }
00013  
00014 void wwChipSelect :: wwCSwrite(int ch){
00015 
00016 #ifdef NORMAL
00017     if(ch == 0){//reset code
00018         ChipSelect.write(1);
00019     }else{
00020         ChipSelect.write(0);
00021     }
00022     
00023 #else
00024     //start
00025     ChipSelect.write(1);   
00026     wait_us(30); 
00027     
00028     ChipSelect.write(0);
00029         
00030     wait_us(26);//26
00031     
00032 //A1
00033     ChipSelect.write(0x01 & ch);    
00034     wait_us(20);//46  
00035     
00036 //A2    
00037     ChipSelect.write((0x02 & ch)>>1);
00038     wait_us(20);//66  
00039     
00040 //A3    
00041     ChipSelect.write((0x04 & ch)>>2);
00042     wait_us(20);//86 
00043     
00044 //A4    
00045     ChipSelect.write((0x08 & ch)>>3);
00046     wait_us(20);//106
00047     
00048     ChipSelect.write(1);
00049     
00050     wait_us(30);
00051 #endif
00052 }
00053