
White Wizard SPI Chip Select test program. I changed chip select signal timing.
Revision 1:048ae028f72d, committed 2011-07-25
- Comitter:
- halfpitch
- Date:
- Mon Jul 25 10:01:36 2011 +0000
- Parent:
- 0:1d2148b42390
- Child:
- 2:5312f16c3ee8
- Commit message:
- Rev.A
Changed in this revision
main.cpp | Show annotated file Show diff for this revision Revisions of this file |
wwChipSelect.cpp | Show annotated file Show diff for this revision Revisions of this file |
--- a/main.cpp Mon Jul 25 10:00:33 2011 +0000 +++ b/main.cpp Mon Jul 25 10:01:36 2011 +0000 @@ -1,26 +1,26 @@ -#include "mbed.h" -#include "wwChipSelect.h" - -//Nest Egg Inc. -//http://nestegg.jp/ -//channel No must be A1 A2 A3 A4 -//#define ch_num 0x05 //channel No 0101, depend on your SPI module setting. -#define ch_num 0x0A //channel No 1010, depend on your SPI module setting. -#define reset_ch 0x00 //channel No 0000, for reset. - -DigitalOut myled(LED1); - -int main() { - - wwChipSelect wwcs(p8); - - while(1) { - wwcs.wwCSwrite(ch_num); - myled = 1; - wait(0.2); - - wwcs.wwCSwrite(reset_ch); - myled = 0; - wait(0.2); - } -} +#include "mbed.h" +#include "wwChipSelect.h" + +//Nest Egg Inc. +//http://nestegg.jp/ +//channel No must be A1 A2 A3 A4 +//#define ch_num 0x05 //channel No 0101, depend on your SPI module setting. +#define ch_num 0x0A //channel No 1010, depend on your SPI module setting. +#define reset_ch 0x00 //channel No 0000, for reset. + +DigitalOut myled(LED1); + +int main() { + + wwChipSelect wwcs(p8); + + while(1) { + wwcs.wwCSwrite(ch_num); + myled = 1; + wait(0.2); + + wwcs.wwCSwrite(reset_ch); + myled = 0; + wait(0.2); + } +}
--- a/wwChipSelect.cpp Mon Jul 25 10:00:33 2011 +0000 +++ b/wwChipSelect.cpp Mon Jul 25 10:01:36 2011 +0000 @@ -1,42 +1,42 @@ -//Nest Egg Inc. -//http://nestegg.jp/ -//White Wizard Board SPI Chip Select Code -//Auther : Yoshinari kou -//2010/10/03 - -#include "wwChipSelect.h" - -wwChipSelect :: wwChipSelect(PinName cs): - ChipSelect(cs){ - } - -void wwChipSelect :: wwCSwrite(int ch){ - //start - ChipSelect.write(1); - wait_us(20); - - ChipSelect.write(0); - - wait_us(26);//26 - -//A1 - ChipSelect.write(0x01 & ch); - wait_us(20);//46 - -//A2 - ChipSelect.write((0x02 & ch)>>1); - wait_us(20);//66 - -//A3 - ChipSelect.write((0x04 & ch)>>2); - wait_us(20);//86 - -//A4 - ChipSelect.write((0x08 & ch)>>3); - wait_us(20);//106 - - ChipSelect.write(1); - -} - - +//Nest Egg Inc. +//http://wizard.nestegg.jp/ +//White Wizard Board SPI Chip Select Code +//Auther : Yoshinari kou +//2010/10/03 + +#include "wwChipSelect.h" + +wwChipSelect :: wwChipSelect(PinName cs): + ChipSelect(cs){ + } + +void wwChipSelect :: wwCSwrite(int ch){ + //start + ChipSelect.write(1); + wait_us(20); + + ChipSelect.write(0); + + wait_us(26);//26 + +//A1 + ChipSelect.write(0x01 & ch); + wait_us(20);//46 + +//A2 + ChipSelect.write((0x02 & ch)>>1); + wait_us(20);//66 + +//A3 + ChipSelect.write((0x04 & ch)>>2); + wait_us(20);//86 + +//A4 + ChipSelect.write((0x08 & ch)>>3); + wait_us(20);//106 + + ChipSelect.write(1); + +} + +