test aff8x8 avec 2*74HC595 (KRM2388AURPGB)

Dependencies:   mbed

Fork of DigitalIn_test by Junichi Katsu

Committer:
ER4
Date:
Mon Mar 09 17:13:23 2015 +0000
Revision:
3:555b0f6dd516
Parent:
2:a0e8e160bed1
affichage smiley

Who changed what in which revision?

UserRevisionLine numberNew contents of line
jksoft 0:592717f4890b 1 #include "mbed.h"
ER4 1:5a049a86616a 2
ER4 1:5a049a86616a 3 SPI spi(P0_9,P0_8,P0_7); // mosi, miso, sclk
ER4 1:5a049a86616a 4 DigitalOut cs(P0_6);
jksoft 0:592717f4890b 5
ER4 1:5a049a86616a 6 void ligne(char val){
ER4 1:5a049a86616a 7 cs = 0;
ER4 1:5a049a86616a 8 //spi.write(val);
ER4 1:5a049a86616a 9 spi.write(0xFF);
ER4 1:5a049a86616a 10 cs = 1;
ER4 1:5a049a86616a 11 }
ER4 1:5a049a86616a 12 //void colone(char val1){
ER4 1:5a049a86616a 13 // cs=0;
ER4 1:5a049a86616a 14 //spi.write(val1);
ER4 1:5a049a86616a 15 //cs=1;
ER4 1:5a049a86616a 16 //}
ER4 1:5a049a86616a 17
jksoft 0:592717f4890b 18
ER4 2:a0e8e160bed1 19 char Im [8][8] = { {0,0,0,0,0,0,0,0},
ER4 3:555b0f6dd516 20 {0,1,1,0,0,1,1,0},
ER4 3:555b0f6dd516 21 {0,1,1,0,0,1,1,0},
ER4 3:555b0f6dd516 22 {0,0,0,0,0,0,0,0},
ER4 2:a0e8e160bed1 23 {1,0,0,0,0,0,0,1},
ER4 2:a0e8e160bed1 24 {0,1,1,1,1,1,1,0},
ER4 2:a0e8e160bed1 25 {0,0,0,0,0,0,0,0},
ER4 2:a0e8e160bed1 26 {0,0,0,0,0,0,0,0}};
ER4 1:5a049a86616a 27
ER4 1:5a049a86616a 28
ER4 1:5a049a86616a 29
ER4 1:5a049a86616a 30 int main() {
ER4 1:5a049a86616a 31 int i=0,j=0;
ER4 1:5a049a86616a 32 // Chip must be deselected
ER4 1:5a049a86616a 33 cs = 1;
ER4 1:5a049a86616a 34
ER4 1:5a049a86616a 35 // Setup the spi for 8 bit data, high steady state clock,
ER4 1:5a049a86616a 36 // second edge capture, with a 1MHz clock rate
ER4 1:5a049a86616a 37 spi.format(8,3);
ER4 1:5a049a86616a 38 spi.frequency(1000000);
ER4 1:5a049a86616a 39 while(1){
ER4 3:555b0f6dd516 40
ER4 2:a0e8e160bed1 41 for(i=0;i<8;i++){
ER4 2:a0e8e160bed1 42 for (j=0;j<=7;j++){
ER4 1:5a049a86616a 43 //spi.write(colone[j]);
ER4 2:a0e8e160bed1 44 cs = 0;
ER4 2:a0e8e160bed1 45 if(Im[i][j]==1)
ER4 2:a0e8e160bed1 46 spi.write(~(1<<j));//allume pixel
ER4 2:a0e8e160bed1 47 else
ER4 2:a0e8e160bed1 48 spi.write(0xFF); //eteind pixel
ER4 2:a0e8e160bed1 49 spi.write(1<<i);//lignes
ER4 1:5a049a86616a 50 //spi.write(0xFF);
ER4 2:a0e8e160bed1 51 cs = 1;
ER4 2:a0e8e160bed1 52 }
ER4 2:a0e8e160bed1 53 }
ER4 2:a0e8e160bed1 54 wait(0.001);
ER4 2:a0e8e160bed1 55
jksoft 0:592717f4890b 56 }
ER4 2:a0e8e160bed1 57 }