⭐ 欢迎来到虫虫下载站! | 📦 资源下载 📁 资源专辑 ℹ️ 关于我们
⭐ 虫虫下载站

📄 phonerec.c

📁 基于AVR制作的电话语音录制系统
💻 C
📖 第 1 页 / 共 5 页
字号:
            if (mmc_read_cluster) {                stop_playback();                current_playback_call=mmc_index.last_call;                if (current_playback_call>0) current_playback_call--;            } else {#endif // HAVE_MMC                monitor_mode++; if (monitor_mode==3) monitor_mode=0;#ifdef HAVE_MMC                //dtmf_string[2]=monitor_mode+'0';                mmc_read_cluster=mmc_write_cluster=0;                //dtmf_string[0]=dtmf_string[1]=' ';                mmc_read_buf_state=0;                mmc_read_state=0;                mmc_write_buf_state=0;                mmc_write_state=0;                audio_status=0;                spi_finish();                mmc_init_state=6;                kbd_last_key=0;            }#endif // HAVE_MMC        }         else if (kbd_last_key=='U') {            wavp=wavp0=wav880; wav_rep=wav_rep0=64; wav_cnt=10; wav_mask=1;            kbd_last_key=0;        }#ifdef DO_HEXDUMP        else if (kbd_last_key=='D') {            hexdump_count=16;            kbd_last_key=0;        } else if (kbd_last_key=='U') {            hexdump_ptr=(unsigned char *)&buffer_a;            kbd_last_key=0;        }#endif // DO_HEXDUMP#ifdef HAVE_MMC#ifdef DEBUG_RECORDING_TEST        else if (kbd_last_key=='L') {            start_playback(1,32);            kbd_last_key=0;        } else if (kbd_last_key=='R') {            start_recording(1);            kbd_last_key=0;        }#else        else if (kbd_last_key=='L') {            unsigned short start_cluster;            if (current_playback_call>mmc_index.first_call)                current_playback_call--;            //dtmf_string[0]=current_playback_call+'0';            start_cluster=mmc_index.start[current_playback_call];            if (start_cluster>0) {                unsigned short end_cluster;                if (current_playback_call==mmc_index.last_call) {                    end_cluster=mmc_index.last_cluster;                } else {                    end_cluster=mmc_index.start[current_playback_call+1];                }                start_playback(start_cluster,end_cluster);                //dtmf_string[1]=current_playback_call+'0';            }            kbd_last_key=0;        } else if (kbd_last_key=='R') {            unsigned short start_cluster;            if (current_playback_call<mmc_index.last_call)                current_playback_call++;            //dtmf_string[0]=current_playback_call+'0';            start_cluster=mmc_index.start[current_playback_call];            if (start_cluster>0) {                unsigned short end_cluster;                if (current_playback_call==mmc_index.last_call) {                    end_cluster=mmc_index.last_cluster;                } else {                    end_cluster=mmc_index.start[current_playback_call+1];                }                start_playback(start_cluster,end_cluster);                //dtmf_string[1]=current_playback_call+'0';            }            kbd_last_key=0;        }#endif // DEBUG_RECORDING_TEST#endif // HAVE_MMC    } // if (count>45...)    #ifdef HAVE_MMC        if (mmc_write_buf_state) {        if (mmc_write_buf_state>1 && mmc_write_buf_state<10) {            mmc_write_buf_state++;        } else if (mmc_write_buf_state==10) {            mmc_write_buf_state++;            unsigned long mmc_address=(unsigned long)mmc_write_cluster;            mmc_address<<=MMC_CLUSTER_BITSHIFT;            mmc_address+=mmc_write_cluster_sector;            mmc_address<<=MMC_BLOCK_SIZE_BITSHIFT;            mmc_command(MMC_WRITE_BLOCK,mmc_address);            spi_autofinish=FALSE;            mmc_ptr=(unsigned char *)io_buf;            mmc_write_state=1;            mmc_retry=0;        }    } else if (mmc_read_buf_state) {        if (mmc_read_buf_state>1 && mmc_read_buf_state<10) {            mmc_read_buf_state++;        } else if (mmc_read_buf_state==10) {            mmc_read_buf_state++;            unsigned long mmc_address=(unsigned long)mmc_read_cluster;            mmc_address<<=MMC_CLUSTER_BITSHIFT;            mmc_address+=mmc_read_cluster_sector;            mmc_address<<=MMC_BLOCK_SIZE_BITSHIFT;            mmc_command(MMC_READ_SINGLE_BLOCK,mmc_address);            spi_autofinish=FALSE;            mmc_ptr=(unsigned char *)io_buf;            mmc_read_state=1;            mmc_retry=0;            //dtmf_string[6]='?';        }    }         if (mmc_read_state) {        //dtmf_string[0]=mmc_read_state+'0';        if (mmc_read_state==1) {            if (spi_has_reply) {                if (spi_reply) {                    // Failure!                    //dtmf_string[2]='!';                    //mmc_psn[0]=spi_reply;                    mmc_retry++;                    if (mmc_retry==8) {                        //dtmf_string[2]=' ';                        //dtmf_string[1]='X';                        mmc_read_state=0;                        spi_finish();                        if (mmc_read_index_state)                            mmc_read_index_state=1;                        else if (mmc_read_buf_state==11)                            mmc_read_buf_state=10;                    } else spi_get_next();                } else {                    mmc_read_state++;                    spi_get_next();                    mmc_retry=0;                }            }         } else if (mmc_read_state==2) {            if (spi_has_reply) {                if (spi_reply==MMC_STARTBLOCK_READ) {                    mmc_ptr_count=MMC_BLOCK_SIZE;                    mmc_read_state++;                    //mmc_psn[3]=spi_reply;                    spi_get_next();                } else {                    mmc_retry++;                    if (mmc_retry==8) {                        //dtmf_string[2]='#';                        //dtmf_string[1]=' ';                        //mmc_psn[0]=spi_reply;                        mmc_read_state=0;                        spi_finish();                        if (mmc_read_index_state)                            mmc_read_index_state=1;                        else if (mmc_read_buf_state==11)                            mmc_read_buf_state=10;                    } else spi_get_next();                }            }        } else if (mmc_read_state==3) {            if (mmc_ptr_count) {                //dtmf_string[3]='-';                if (spi_has_reply) {                    //dtmf_string[4]='+';                    *mmc_ptr++=spi_reply;                    mmc_ptr_count--;                    spi_get_next();                }            } else {                //dtmf_string[3]='O';                mmc_read_state++;                //spi_finish();            }        } else if (mmc_read_state==4) {           spi_get_next();           mmc_read_state++;        } else if (mmc_read_state==5) {            mmc_read_state=0;            spi_finish();            //dtmf_string[8]=mmc_read_buf_state+'@';            if (!has_index) {                has_index=1;                mmc_read_index_state=0;            } else if (mmc_read_buf_state) {                set_dcnt((mmc_read_cluster<<4)|mmc_read_cluster_sector);                mmc_read_cluster_sector++;                mmc_read_cluster_sector&=MMC_CLUSTER_SIZE_MASK;                mmc_read_buf_state=0;                if (!mmc_read_cluster_sector) {                    mmc_read_cluster++;                    if (mmc_read_cluster==mmc_read_stop_at) {                        audio_status |= AS_PLAYBACK_SHUTTING_DOWN;                    }                }                 if (audio_status & AS_PLAYBACK_SHUTTING_DOWN) {                    mmc_read_cluster=0;                     //dtmf_string[5]='!';                    audio_status &= ~(                        AS_PLAYBACK_SHUTTING_DOWN |                        AS_PLAYBACK_IN_PROGRESS                    );                } else {                    audio_status |=  AS_PLAYBACK_IN_PROGRESS;                }            }        }    } else if (mmc_write_state) {        //dtmf_string[3]=mmc_write_state+'@';        if (mmc_write_state==1) {            if (spi_has_reply) {                if (spi_reply) {                    // Failure!                    mmc_retry++;                    //dtmf_string[4]='X';                    if (mmc_retry==20) {                        mmc_write_state=0;                        spi_finish();                        if (mmc_write_index_state)                             mmc_write_index_state=1;                        else if (mmc_write_buf_state==11)                            mmc_write_buf_state=10;                    } else spi_get_next();                } else {                    mmc_retry=0;                    mmc_write_state++;                    spi_get_next();                }            }         } else if (mmc_write_state==2) {            mmc_write_state++;            SPDR=MMC_STARTBLOCK_WRITE;            mmc_ptr_count=MMC_BLOCK_SIZE;        } else if (mmc_write_state==3) {            if (mmc_ptr_count) {                //dtmf_string[10]='+';                SPDR=*mmc_ptr++;                mmc_ptr_count--;            } else {                mmc_write_state++;                spi_buf_putc(0xFF); // First byte of the dummy 16-bit CRC                spi_start_xmit();                spi_autofinish=FALSE;               }         } if (mmc_write_state==4) {            if (spi_has_reply) {                if ( (spi_reply & MMC_DR_MASK) != MMC_DR_ACCEPT) {                    //mmc_psn[1]=spi_reply;                    //dtmf_string[4]='F';                    mmc_retry++;                    if (mmc_retry==20) {                        mmc_write_state=0;                        spi_finish();                        if (mmc_write_index_state)                             mmc_write_index_state=1;                        else if (mmc_write_buf_state==11)                            mmc_write_buf_state=10;                    } else spi_get_next();                } else {                    mmc_write_state++;                    spi_get_next();                }            }        } if (mmc_write_state==5) {            if (spi_has_reply) {                if (spi_reply) {                    //dtmf_string[4]='S';                    mmc_ptr=0;                    mmc_write_state=0;                    spi_finish();                    if (mmc_write_index_state) {                        has_index=4;                        mmc_write_index_state=0;                    } else if (mmc_write_buf_state) {                        set_dcnt((mmc_write_cluster<<4)|mmc_write_cluster_sector);                        mmc_write_cluster_sector++;                        mmc_write_cluster_sector&=MMC_CLUSTER_SIZE_MASK;                        if (!mmc_write_cluster_sector) {                            mmc_write_cluster++;                            // If we're at the card's last cluster, wrap                            // around. This essentially treats the card as                            // an infinite tape.                            if (mmc_write_cluster==mmc_last_cluster)                                mmc_write_cluster=1;                            if (audio_status & AS_RECORDING_SHUTTING_DOWN) {                                mmc_index.last_cluster=mmc_write_cluster;                                mmc_write_cluster=0;                                audio_status &= ~(                                    AS_RECORDING_IN_PROGRESS |                                    AS_RECORDING_SHUTTING_DOWN                                );                                // As we're finish recording, we arrange for                                // the index to be saved. But can't do that                                // when performing playback, so in this case                                // we arrange for it to be saved later#ifdef ALLOW_SIMULTANEOUS_RECORD_AND_PLAYBACK                                if (!mmc_read_cluster)                                     mmc_write_index_state=1;                                else                                    has_index |= DEFERRED_INDEX_WRITE;#endif // ALLOW_SIMULTANEOUS_RECORD_AND_PLAYBACK                                                    }                        }                        mmc_write_buf_state=0;#ifdef ALLOW_SIMULTANEOUS_RECORD_AND_PLAYBACK                        if (mmc_read_cluster) {                            mmc_read_buf_state=10;                        }#endif // ALLOW_SIMULTANEOUS_RECORD_AND_PLAYBACK                                            }                } else spi_get_next();            }        }    }    if (has_index==2) {        mmc_index.start[has_index_count++]=0;        if (has_index_count==MAXCALLS) {            has_index=3;            // Arrange for the index to be saved            mmc_write_index_state=1;        }    }    if (count==39) {        if (has_index==1) {            if (mmc_index.magic1==MAGIC1 && mmc_index.magic2==MAGIC2 &&                mmc_index.mmc_psn[0]==mmc_psn[0] &&                mmc_index.mmc_psn[1]==mmc_psn[1] &&                mmc_index.mmc_psn[2]==mmc_psn[2] &&                mmc_index.mmc_psn[3]==mmc_psn[3]) {                    has_index=3;                    //dtmf_string[7]='R';                    current_playback_call=mmc_index.last_call;                    if (current_playback_call>0) current_playback_call--;            } else {                mmc_index.magic1=MAGIC1;                mmc_index.magic2=MAGIC2;                mmc_index.mmc_psn[0]=mmc_psn[0];                mmc_index.mmc_psn[1]=mmc_psn[1];                mmc_index.mmc_psn[2]=mmc_psn[2];                mmc_index.mmc_psn[3]=mmc_psn[3];                mmc_index.first_cluster=1;                mmc_index.last_cluster=1;                mmc_index.first_call=0;                mmc_index.last_call=0;                mmc_index.free=mmc_last_cluster-2;                has_index++;                has_index_count=0;                //dtmf_string[1]='I';            }        }     } else #endif // HAVE_MMC    #ifdef HAVE_LCD    if (count==40) {#ifdef HAVE_MMC#ifdef SHOW_DEBUG_COUNT        unsigned short x=dcnt;        unsigned char c;        c=(x&15)+'0'; if (c>'9') c+=7;        dtmf_string[15]=c; x>>=4;        c=(x&15)+'0'; if (c>'9') c+=7;        dtmf_string[14]=c; x>>=4;        c=(x&15)+'0'; if (c>'9') c+=7;        dtmf_string[13]=c; x>>=4;        c=(x&15)+'0'; if (c>'9') c+=7;        dtmf_string[12]=c;#endif // SHOW_DEBUG_COUNT#endif // HAVE_MMC        msg_index=0;        if (call_status==CallIncoming) {            main_msg=(prog_char *)ring_number_msg;             l1=1; lcd_gotoxy(0,0);        } else if (call_status==CallIdle) {            if (last_reported_hook==Disconnected) {                main_msg=(prog_char *)disconn_msg; l1=1;            } else {                main_msg=(prog_char *)on

⌨️ 快捷键说明

复制代码 Ctrl + C
搜索代码 Ctrl + F
全屏模式 F11
切换主题 Ctrl + Shift + D
显示快捷键 ?
增大字号 Ctrl + =
减小字号 Ctrl + -