yoshinari kou
/
WW_SPI_Uni_TEST_Ver2
White Wizard Board SPI module chip select TEST program
main.cpp@0:747306a9d2ad, 2011-08-26 (annotated)
- Committer:
- halfpitch
- Date:
- Fri Aug 26 15:34:03 2011 +0000
- Revision:
- 0:747306a9d2ad
RevA
Who changed what in which revision?
User | Revision | Line number | New contents of line |
---|---|---|---|
halfpitch | 0:747306a9d2ad | 1 | #include "mbed.h" |
halfpitch | 0:747306a9d2ad | 2 | #include "wwChipSelect.h" |
halfpitch | 0:747306a9d2ad | 3 | |
halfpitch | 0:747306a9d2ad | 4 | //Nest Egg Inc. |
halfpitch | 0:747306a9d2ad | 5 | //http://wizard.nestegg.jp/ |
halfpitch | 0:747306a9d2ad | 6 | //channel No must be A1 A2 A3 A4 |
halfpitch | 0:747306a9d2ad | 7 | |
halfpitch | 0:747306a9d2ad | 8 | //#define ch_num 0x05 //channel No 0101, depend on your SPI module setting. |
halfpitch | 0:747306a9d2ad | 9 | //#define ch_num1 0x08 //channel No 1000, depend on your SPI module setting. |
halfpitch | 0:747306a9d2ad | 10 | |
halfpitch | 0:747306a9d2ad | 11 | DigitalOut myled1(LED1); |
halfpitch | 0:747306a9d2ad | 12 | DigitalOut myled2(LED2); |
halfpitch | 0:747306a9d2ad | 13 | DigitalOut myled3(LED3); |
halfpitch | 0:747306a9d2ad | 14 | DigitalOut myled4(LED4); |
halfpitch | 0:747306a9d2ad | 15 | |
halfpitch | 0:747306a9d2ad | 16 | void LEDbit(int ch){ |
halfpitch | 0:747306a9d2ad | 17 | |
halfpitch | 0:747306a9d2ad | 18 | //A1 |
halfpitch | 0:747306a9d2ad | 19 | myled1 = (0x01 & ch); |
halfpitch | 0:747306a9d2ad | 20 | |
halfpitch | 0:747306a9d2ad | 21 | //A2 |
halfpitch | 0:747306a9d2ad | 22 | myled2 =((0x02 & ch)>>1); |
halfpitch | 0:747306a9d2ad | 23 | |
halfpitch | 0:747306a9d2ad | 24 | //A3 |
halfpitch | 0:747306a9d2ad | 25 | myled3 =((0x04 & ch)>>2); |
halfpitch | 0:747306a9d2ad | 26 | |
halfpitch | 0:747306a9d2ad | 27 | //A4 |
halfpitch | 0:747306a9d2ad | 28 | myled4 =((0x08 & ch)>>3); |
halfpitch | 0:747306a9d2ad | 29 | |
halfpitch | 0:747306a9d2ad | 30 | } |
halfpitch | 0:747306a9d2ad | 31 | |
halfpitch | 0:747306a9d2ad | 32 | int main() { |
halfpitch | 0:747306a9d2ad | 33 | |
halfpitch | 0:747306a9d2ad | 34 | wwChipSelect wwcs(p8); |
halfpitch | 0:747306a9d2ad | 35 | int ch_num=1; |
halfpitch | 0:747306a9d2ad | 36 | |
halfpitch | 0:747306a9d2ad | 37 | while(1) { |
halfpitch | 0:747306a9d2ad | 38 | for(ch_num=0;ch_num<16;ch_num++){ |
halfpitch | 0:747306a9d2ad | 39 | //myled1 =! myled1; |
halfpitch | 0:747306a9d2ad | 40 | LEDbit(ch_num); |
halfpitch | 0:747306a9d2ad | 41 | wwcs.wwCSwrite(ch_num); |
halfpitch | 0:747306a9d2ad | 42 | printf("ch No.%d\n",ch_num); |
halfpitch | 0:747306a9d2ad | 43 | wait(0.7); |
halfpitch | 0:747306a9d2ad | 44 | } |
halfpitch | 0:747306a9d2ad | 45 | } |
halfpitch | 0:747306a9d2ad | 46 | } |
halfpitch | 0:747306a9d2ad | 47 |