#include #include #include #include #include #include #include #include #include #include #include "defines.h" size_t size_dsp=S_DSP; // <-- unsigned long addr_dsp=A_DSP; // <-- caddr_t ptr_dsp; // <-- unsigned short *wp_dsp; // <-- extern int fd; //a16d16 mem space void hapd_begin() { if((ptr_dsp = mmap(0,size_dsp,PROT_WRITE|PROT_READ,MAP_SHARED,fd,addr_dsp)) == (caddr_t)-1){ perror("mmap_dsp"); exit(1); } wp_dsp = (unsigned short*) ptr_dsp; // DSP8230 initialization printf( "DSP module ID: 0x%04x\n", *(wp_dsp) ); // for debug (can be removed) *(wp_dsp + 0x5) = 0x5; // software reset DSP8230 *(wp_dsp + 0x1) = 0x0808; // DATA1 = input to DSP8230 (read) *(wp_dsp + 0x2) = 0x0909; // DATA2 = output to DSP8230 (write) *(wp_dsp + 0xe) = 0x20; // write CLEAR to Meisei-board WWHILE; } void hapd_event() { int i; unsigned int dsp_stat1, dsp_stat2; unsigned int dsp_buf[19]; /* HAPD data 4bit X 18ch X 4chip = 288bit one access = 16 bit (4bit X 4ch) --> need to read 18 times */ dsp_stat1 = ((*(wp_dsp + 0x4))>>12)&0x3; // DSP_8230 status for( i=0; i<18; i++ ) { dsp_buf[i] = *(wp_dsp + 0xd); // read 16 bit data (same address) } dsp_stat2 = ((*(wp_dsp + 0x4))>>12)&0x3; // DSP_8230 status dsp_buf[19] = (dsp_stat1<<2) | dsp_stat2; *(wp_dsp + 0xe) = 0x20; // write CLEAR to Meisei-board /* please add dsp_buf to *buf */ /* we don't need to do the following here. for( i=0; i<16; i++ ) { for( j=0; j<3; j++ ) { buf[4*i+j] = (dsp_buf[i]>>(4*j)) & 0xf; } } */ } void hapd_resume(mode) { *(wp_dsp + 0xe) = 0x20; // write CLEAR to Meisei-board }