White Wizard SPI Chip Select test program. I changed chip select signal timing.

Dependencies:   mbed

Committer:
halfpitch
Date:
Thu Sep 01 10:05:25 2011 +0000
Revision:
2:5312f16c3ee8
Parent:
1:048ae028f72d
Rev.B

Who changed what in which revision?

UserRevisionLine numberNew contents of line
halfpitch 1:048ae028f72d 1 //Nest Egg Inc.
halfpitch 2:5312f16c3ee8 2 //http://nestegg.jp/
halfpitch 1:048ae028f72d 3 //White Wizard Board SPI Chip Select Code
halfpitch 1:048ae028f72d 4 //Auther : Yoshinari kou
halfpitch 1:048ae028f72d 5 //2010/10/03
halfpitch 1:048ae028f72d 6
halfpitch 1:048ae028f72d 7 #include "wwChipSelect.h"
halfpitch 2:5312f16c3ee8 8 //#define NORMAL //if you want to use normal chipselect, you should enable this code.
halfpitch 1:048ae028f72d 9
halfpitch 1:048ae028f72d 10 wwChipSelect :: wwChipSelect(PinName cs):
halfpitch 1:048ae028f72d 11 ChipSelect(cs){
halfpitch 1:048ae028f72d 12 }
halfpitch 1:048ae028f72d 13
halfpitch 2:5312f16c3ee8 14 void wwChipSelect :: wwCSwrite(int ch){
halfpitch 2:5312f16c3ee8 15
halfpitch 2:5312f16c3ee8 16 #ifdef NORMAL
halfpitch 2:5312f16c3ee8 17 if(ch == 0){//reset code
halfpitch 2:5312f16c3ee8 18 ChipSelect.write(1);
halfpitch 2:5312f16c3ee8 19 }else{
halfpitch 2:5312f16c3ee8 20 ChipSelect.write(0);
halfpitch 2:5312f16c3ee8 21 }
halfpitch 2:5312f16c3ee8 22
halfpitch 2:5312f16c3ee8 23 #else
halfpitch 1:048ae028f72d 24 //start
halfpitch 1:048ae028f72d 25 ChipSelect.write(1);
halfpitch 2:5312f16c3ee8 26 wait_us(30);
halfpitch 1:048ae028f72d 27
halfpitch 1:048ae028f72d 28 ChipSelect.write(0);
halfpitch 1:048ae028f72d 29
halfpitch 1:048ae028f72d 30 wait_us(26);//26
halfpitch 1:048ae028f72d 31
halfpitch 1:048ae028f72d 32 //A1
halfpitch 1:048ae028f72d 33 ChipSelect.write(0x01 & ch);
halfpitch 1:048ae028f72d 34 wait_us(20);//46
halfpitch 1:048ae028f72d 35
halfpitch 1:048ae028f72d 36 //A2
halfpitch 1:048ae028f72d 37 ChipSelect.write((0x02 & ch)>>1);
halfpitch 1:048ae028f72d 38 wait_us(20);//66
halfpitch 1:048ae028f72d 39
halfpitch 1:048ae028f72d 40 //A3
halfpitch 1:048ae028f72d 41 ChipSelect.write((0x04 & ch)>>2);
halfpitch 1:048ae028f72d 42 wait_us(20);//86
halfpitch 1:048ae028f72d 43
halfpitch 1:048ae028f72d 44 //A4
halfpitch 1:048ae028f72d 45 ChipSelect.write((0x08 & ch)>>3);
halfpitch 1:048ae028f72d 46 wait_us(20);//106
halfpitch 1:048ae028f72d 47
halfpitch 1:048ae028f72d 48 ChipSelect.write(1);
halfpitch 2:5312f16c3ee8 49
halfpitch 2:5312f16c3ee8 50 wait_us(30);
halfpitch 2:5312f16c3ee8 51
halfpitch 2:5312f16c3ee8 52 #endif
halfpitch 1:048ae028f72d 53 }
halfpitch 1:048ae028f72d 54