/* vsync() * no parameters * * wait for the vertical sync to start */ void vsync(void) { // wait until any previous retrace has ended while (inpb(0x3DA) & (1<<3)); // wait until a new retrace has just begun while (!(inpb(0x3DA) & (1<<3))); }
void PDMA_Callback_1(void) { extern volatile int32_t IntCnt; int32_t i ; printf("\tTransfer Done %02d!\t",++IntCnt); for(i=0;i<UART_TEST_LENGTH;i++) printf(" 0x%2x(%c),",inpb(((uint32_t)DestArray+i)),inpb(((uint32_t)DestArray+i))); // printf("\n"); if(IntCnt<10) { PDMA0->CSR|= PDMA_CSR_TRIG_EN_Msk; } else { IsTestOver = TRUE; } }
int FloppyController:: result(void) { for (int i = 0; i < sizeof(status); ++i) { u8 msr; do { msr = inpb(base + MSR); if ((msr & 0xc0) == 0x80) { statusLength = i; return statusLength; } } while ((msr & 0xc0) != 0xc0); status[i] = inpb(base + FIFO); } statusLength = sizeof(status); return statusLength; }
void PDMA_Callback_1(void) { int32_t i ; printf("\tTransfer Done %d!\t",++IntCnt); /* Show UART Rx data */ for(i=0;i<UART_TEST_LENGTH;i++) printf(" 0x%x(%c),",inpb(((uint32_t)DestArray+i)),inpb(((uint32_t)DestArray+i))); printf("\n"); /* Use PDMA to do UART Rx test 10 times */ if(IntCnt<10) { /* Trigger PDMA */ PDMA0->CSR |= PDMA_CSR_TRIG_EN_Msk; } else { /* Test is over */ IsTestOver = TRUE; } }
void rtc_init () { register u08_t r ; i386_pushfl () ; i386_cli () ; outpb (0x70,0x8B) ; r = inpb (0x71) ; outpb (0x70,0x8B) ; outpb (0x71,0x40|r) ; rtc_timestamp = 0LL ; i386_popfl () ; }
trap_retval ReqRead_io( void ) { read_io_req *acc; void *ret; trap_elen len; /* Perform I/O on the target machine on behalf of the debugger. * Since there are no kernel APIs in Linux to do this, we just * enable IOPL and use regular I/O. We will bail if we can't get * IOPL=3, so the debugger trap file will need to be run as root * before it can be used for I/O access. */ acc = GetInPtr( 0 ); ret = GetOutPtr( 0 ); #ifdef __WATCOMC__ if( iopl( 3 ) == 0 ) { len = acc->len; switch( len ) { case 1: *((unsigned_8*)ret) = inpb( acc->IO_offset ); break; case 2: *((unsigned_16*)ret) = inpw( acc->IO_offset ); break; case 4: *((unsigned_32*)ret) = inpd( acc->IO_offset ); break; } } else { len = 0; } #else len = 0; #endif return( len ); }
void FloppyController:: issue(FloppyDrive* drive, u8 cmd, void* param) { done = false; commandLength = 0; switch (cmd) { case SENSE: command[commandLength++] = cmd; done = true; break; case RECALIBRATE: command[commandLength++] = cmd; command[commandLength++] = drive->drive; break; case SEEK: command[commandLength++] = cmd; command[commandLength++] = (drive->head << 2) | drive->drive; command[commandLength++] = drive->cylinder; break; case READ: case WRITE: command[commandLength++] = cmd; command[commandLength++] = (drive->head << 2) | drive->drive; command[commandLength++] = drive->cylinder; command[commandLength++] = drive->head; command[commandLength++] = drive->record; command[commandLength++] = drive->recordLength; command[commandLength++] = drive->eot; command[commandLength++] = drive->gpl; command[commandLength++] = 0xFF; break; case FORMAT: command[commandLength++] = cmd; command[commandLength++] = (drive->head << 2) | drive->drive; command[commandLength++] = drive->recordLength; command[commandLength++] = drive->eot; command[commandLength++] = drive->fgpl; command[commandLength++] = 0x00; break; default: esReport("FloppyController: unsupported command %0x2\n", cmd); break; } current = drive; statusLength = 0; for (int i = 0; i < commandLength; i++) { u8 msr; do { msr = inpb(base + MSR); } while (!(msr & 0x80)); if (msr & 0x40) { result(); done = true; break; } outpb(base + FIFO, command[i]); } while (!done) { monitor->wait(); } }
void play_from_file(INT choose,INT ch) { INT hFile; INT nReadBytes; INT nTime0; INT nErr; INT8 bAsciiFileName [20]; INT8 bUnicodeFileName [40]; INT ntemp,nVol=20 ; INT nSPToggle=0; INT nHPToggle=0; _uPcmQHead = _uPcmQTail = 0; strcpy(bAsciiFileName , "c:\\record.pcm"); fsAsciiToUnicode(bAsciiFileName, bUnicodeFileName, TRUE); hFile = fsOpenFile(bUnicodeFileName, NULL, OP_READ); if (hFile < 0) { printf("Can't open playback file0x%x!\n",hFile); //return; } #if defined (TEST_WM8978) /* for eCos version audio lib*/ #if 0 if (choose==32000)//8.192Mhz { outpw(REG_APLLCON, 0x6529); outpw(REG_CLKDIV0, (inpw(REG_CLKDIV0) & 0xFF0FFFFF) | 0x500000); } else if (choose%8000==0 || choose%12000==0){//12.288Mhz outpw(REG_APLLCON, 0x6529); outpw(REG_CLKDIV0, (inpw(REG_CLKDIV0) & 0xFF0FFFFF) | 0x300000); } else if (choose%11025==0){//11.289Mhz outpw(REG_APLLCON, 0x652f); outpw(REG_CLKDIV0, (inpw(REG_CLKDIV0) & 0xFF0FFFFF) | 0x400000); } #else if (choose%8000==0 || choose%12000==0){//24.576Mhz outpw(REG_APLLCON, 0x6529); outpw(REG_CLKDIV0, (inpw(REG_CLKDIV0) & 0xFF0FFFFF) | 0x100000); } else if (choose%11025==0){//22.579Mhz outpw(REG_APLLCON, 0x642d); outpw(REG_CLKDIV0, (inpw(REG_CLKDIV0) & 0xFF0FFFFF) | 0x200000); } #endif #endif /* read PCM data to PCM buffer */ printf("Read %d KB to PCM data buffer...\n", PCM_QUEUE_LEN/1024); nErr = fsReadFile(hFile, _pucPcmQueue, 256*1024, &nReadBytes); if (nErr<0) printf("err num=%d\n",nErr); //memset(_pucPcmQueue,0,PCM_QUEUE_LEN); printf("OK\n"); audioStartPlay(play_callback, choose, ch); //tiaic31StartPlay(play_callback, choose, channels,format); audioSetPlayVolume(nVol,nVol); ntemp = nTime0 = sysGetTicks(TIMER1); while (1) { if (sysGetTicks(TIMER1) - nTime0 >= 100) { nTime0 = sysGetTicks(TIMER1); printf("H=%d, T=%d\n", _uPcmQHead/1024, _uPcmQTail/1024); } if ((_uPcmQTail > _uPcmQHead) || ((_uPcmQTail < _uPcmQHead) && (_uPcmQHead - _uPcmQTail > 64*1024))) { fsReadFile(hFile, &_pucPcmQueue[_uPcmQTail], 64*1024, &nReadBytes); if (nReadBytes > 0) _uPcmQTail = (_uPcmQTail + nReadBytes) % PCM_QUEUE_LEN; if (sysGetTicks(TIMER1) - ntemp >=1000) break; } if (inpb(REG_COM_LSR) & 0x01) /* check key press */ { CHAR cmd = inpb(REG_COM_RX); if (cmd=='1') { if (--nVol<=0) nVol=0; audioSetPlayVolume(nVol,nVol); printf("vol=%d\n",nVol); }else if (cmd=='2') { if (++nVol>=31) nVol=31; audioSetPlayVolume(nVol,nVol); printf("vol=%d\n",nVol); }else if (cmd=='3') { if (nSPToggle) { audioSelectOutputPath(OUT_PATH_SP,TRUE); nSPToggle = 0; }else { audioSelectOutputPath(OUT_PATH_SP,FALSE); nSPToggle = 1; } } else if (cmd=='4') { if (nHPToggle) { audioSelectOutputPath(OUT_PATH_HP,TRUE); nHPToggle = 0; }else { audioSelectOutputPath(OUT_PATH_HP,FALSE); nHPToggle = 1; } } } } fsCloseFile(hFile); audioStopPlay(); }
void audio_loopback_demo(INT choose,INT ch,INT format) { INT nTime0,nTime1,nVol=20; _uPcmQHead = _uPcmQTail = 0; #if defined( TEST_I2S ) || defined(TEST_UDA1345TS) if (choose%11025==0){ /* 16.934Mhz */ outpw(REG_APLLCON, 0x642D); outpw(REG_CLKDIV0, (inpw(REG_CLKDIV0) & 0xFF0FFFFF) | 0x300000); } else{ /* 12.288Mhz */ outpw(REG_APLLCON, 0x6529); outpw(REG_CLKDIV0, (inpw(REG_CLKDIV0) & 0xFF0FFFFF) | 0x300000); } #endif #if defined (TEST_WM8978) #if 0 if (choose==32000)//8.192Mhz { outpw(REG_APLLCON, 0x6529); outpw(REG_CLKDIV0, (inpw(REG_CLKDIV0) & 0xFF0FFFFF) | 0x500000); } else if (choose%8000==0 || choose%12000==0){//12.288Mhz outpw(REG_APLLCON, 0x6529); outpw(REG_CLKDIV0, (inpw(REG_CLKDIV0) & 0xFF0FFFFF) | 0x300000); } else if (choose%11025==0){//11.289Mhz outpw(REG_APLLCON, 0x652f); outpw(REG_CLKDIV0, (inpw(REG_CLKDIV0) & 0xFF0FFFFF) | 0x400000); } #else if (choose%8000==0 || choose%12000==0){//24.576Mhz outpw(REG_APLLCON, 0x6529); outpw(REG_CLKDIV0, (inpw(REG_CLKDIV0) & 0xFF0FFFFF) | 0x100000); } else if (choose%11025==0){//22.579Mhz outpw(REG_APLLCON, 0x642d); outpw(REG_CLKDIV0, (inpw(REG_CLKDIV0) & 0xFF0FFFFF) | 0x200000); } #endif #endif #if 1 while(1){ _uPcmQTail = _uPcmQHead = 0; printf("Start record...\n"); audioStartRecord(record_callback, choose, ch); audioSetRecordVolume(nVol,nVol); nTime1 = nTime0 = sysGetTicks(TIMER1); while (_uPcmQTail < PCM_QUEUE_LEN - 4096) { if (inpb(REG_COM_LSR) & 0x01) /* check key press */ { CHAR cmd = inpb(REG_COM_RX); if (cmd=='1') { if (--nVol<=0) nVol=0; audioSetRecordVolume(nVol,nVol); printf("vol=%d\n",nVol); }else if (cmd=='2') { if (++nVol>=31) nVol=31; audioSetRecordVolume(nVol,nVol); printf("vol=%d\n",nVol); } } if (sysGetTicks(TIMER1) - nTime0 >= 100) { nTime0 = sysGetTicks(TIMER1); printf("H=%d, T=%d\n", _uPcmQHead/1024, _uPcmQTail/1024); } } audioStopRecord(); printf("Start play...\n"); audioStartPlay(play_callback, choose, ch); audioSetPlayVolume(30,30); nTime1 = nTime0 = sysGetTicks(TIMER1); while (_uPcmQHead < PCM_QUEUE_LEN - 4096 ) { if (sysGetTicks(TIMER1) - nTime0 >= 100) { nTime0 = sysGetTicks(TIMER1); printf("H=%d, T=%d\n", _uPcmQHead/1024, _uPcmQTail/1024); } } audioStopPlay(); _uPcmQTail = _uPcmQHead = 0; } #endif #if 1 audioStartRecord(record_callback, choose, ch); audioSetRecordVolume(31,31); while (_uPcmQTail- _uPcmQHead <= 1024); audioStartPlay(play_callback, choose, ch); audioSetPlayVolume(20,20); //while(audioWriteData(50,0x1)!=0); //while(audioWriteData(51,0x1)!=0); while(1){ if (sysGetTicks(TIMER1) - nTime0 >= 100) { nTime0 = sysGetTicks(TIMER1); printf("H=%d, T=%d\n", _uPcmQHead/1024, _uPcmQTail/1024); } } #endif }
void rtc_isr () { outpb (0x70,0x0C) ; inpb (0x71) ; ++rtc_timestamp ; }