Important changes to repositories hosted on mbed.com
Mbed hosted mercurial repositories are deprecated and are due to be permanently deleted in July 2026.
To keep a copy of this software download the repository Zip archive or clone locally using Mercurial.
It is also possible to export all your personal repositories from the account settings page.
b.h
00001 SPI deviceM(PB_15, PB_14, PB_13); 00002 DigitalOut ssel (PB_12); 00003 float Vel=0.8; 00004 00005 void sendSPI(uint8_t d1, uint8_t d2) 00006 { 00007 deviceM.unlock(); 00008 ssel=0; 00009 deviceM.write(d1); 00010 deviceM.write(d2); 00011 ssel=1; 00012 deviceM.lock(); 00013 } 00014 00015 void printMatrix(uint8_t* vC, uint8_t col) 00016 { 00017 int i; 00018 int j=1; 00019 int h=1; 00020 for(i=1;i<=8;i++){ 00021 if(*(vC+1)==0b00000000 && *(vC)==0b00000000){ 00022 sendSPI(i,*(vC+2)>>col-1); 00023 if(i>0){ 00024 sendSPI(i-1,0); 00025 } 00026 wait(Vel); 00027 } 00028 else 00029 { 00030 if(i>1){ 00031 j=i-2; 00032 h=i-3; 00033 if(*(vC)==0b00000000){ 00034 j=i-1; 00035 h=i; 00036 } 00037 sendSPI(i,*(vC)>>col-1); 00038 sendSPI(j,*(vC+1)>>col-1); 00039 sendSPI(h,*(vC+2)>>col-1); 00040 if(i>2){ 00041 sendSPI(i-3,0); 00042 } 00043 wait(Vel); 00044 } 00045 } 00046 } 00047 } 00048 00049 void giro(uint8_t *f,uint8_t col,uint8_t gi) 00050 { 00051 uint8_t a[3]={0,0,0}; 00052 int i; 00053 int j; 00054 switch(gi){ 00055 case 0: 00056 printMatrix(f,col); 00057 break; 00058 case 1: 00059 for(j=0;j<3;j++){ 00060 for(i=0;i<3;i++){ 00061 a[i]=((((*(f+j))<<2-i)&0b10000000)>>j)+a[i]; 00062 } 00063 } 00064 printMatrix(a,col); 00065 break; 00066 case 2: 00067 for(j=0;j<3;j++){ 00068 for(i=0;i<3;i++){ 00069 a[i]=((((*(f+(2-i)))>>2-j)&0b00100000)<<j)+a[i]; 00070 } 00071 } 00072 printMatrix(a,col); 00073 break; 00074 case 3: 00075 for(j=0;j<3;j++){ 00076 for(i=0;i<3;i++){ 00077 a[i]=((((*(f+j))>>2-i)&(0b00100000))<<j)+a[i]; 00078 } 00079 } 00080 printMatrix(a,col); 00081 break; 00082 default: 00083 break; 00084 } 00085 }
Generated on Tue Jul 26 2022 16:33:14 by
1.7.2