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.
main.cpp
00001 #include "mbed.h" 00002 00003 Serial pc(USBTX, USBRX); 00004 00005 Ticker event_timer; 00006 00007 #define ARY_SIZE 1000 00008 00009 SPISlave spi_slave(p5,p6,p7,p8); 00010 // p5 mosi 00011 // p6 nc 00012 // p7 sclk 00013 // p8 hs 00014 00015 //DigitalIn sclk(p7); 00016 //DigitalIn data(p5); 00017 //DigitalIn hs(p8); 00018 00019 int event_timer_time=0; 00020 00021 void event_timer_progress() 00022 { 00023 event_timer_time++; 00024 } 00025 00026 int reverse_byte(int byte) 00027 { 00028 return ((byte&0x80)>>7)|((byte&0x40)>>5) | ((byte&0x20)>>3) | ((byte&0x10)>>1) | ((byte&0x08)<<1) | ((byte&0x04)<<3) | ((byte&0x02)<<5) | ((byte&0x01)<<7); 00029 } 00030 00031 00032 int main() 00033 { 00034 int com_seq=0; 00035 int com_ary[ARY_SIZE]; 00036 int time_ary[ARY_SIZE]; 00037 00038 // 100us ticker 00039 event_timer.attach(&event_timer_progress, 0.0001); 00040 00041 spi_slave.format(8, 3); 00042 00043 pc.baud(115200); 00044 pc.printf("Nikon lens serial interface sniffer.\n"); 00045 while(com_seq<ARY_SIZE) 00046 { 00047 if(spi_slave.receive()) 00048 { 00049 com_ary[com_seq]=spi_slave.read(); 00050 time_ary[com_seq]= event_timer_time; 00051 com_seq++; 00052 } 00053 } 00054 00055 for(int l=0;l<ARY_SIZE;l++) 00056 { 00057 int rv_dat=reverse_byte(com_ary[l]); 00058 if(rv_dat>=0x20 && rv_dat<=0x7e) 00059 pc.printf("%08.01fms %02X '%c'\n",time_ary[l]/10.0,rv_dat,rv_dat); 00060 else 00061 pc.printf("%08.01fms %02X '-'\n",time_ary[l]/10.0,rv_dat); 00062 } 00063 }
Generated on Sun Jul 17 2022 22:20:41 by
1.7.2