void Init() { ConsoleInit_Serial(); Init_Serial(); Init_ADC(); Init_DigitalSensor(); WriteByte((char) 0xB7); ConsoleWrite("Starting Main.\r\n"); ConsoleWrite("Version 12.\r\n"); }
/** MMC Wait For Data start token 0xfe. * First any 0xFF's are read off the mmc. * The first non-ff octet is examined. If it's the 0xfe data start token, * everything is fine. If not, then some error has occurred. * Since we're in an embedded system, it's unclear what we should do then. * Current approach is to say all ok but make read block return 0xff's * by dropping the MMC card offline. Before that we read "lots" of * octets from the MMC to flush any pending data. Finally we return "ALL OK". * It's not disasterous at least as long as we don't WRITE to MMC. * 12/2005: Well, now we do write to mmc... */ unsigned char MmcWaitForData(){ unsigned char c; unsigned int i; i = 60000; //try max. 60000 bus cycles // Wait until something else than 0xff is read from the bus do { c=SPIGetChar(); --i; } while ((c == 0xff) && (i)); // Something was received from the bus? Might it actually be te // desired 0xFE data start token? if (c != 0xfe){ // No data start token, read fail. In an OS an error message would display. // Since we're in an embedded system, it's unclear what we should do now. // Current approach is to say all ok but make read block return 0xff's. // It's not disasterous at least as long as we don't WRITE to MMC. // Flush any data that might be pending from the MMC. #ifdef MMCLONGDEBUG { unsigned int i; ConsoleWrite("\r\nMMCWaitForData failed. \r\n"); ConsoleWrite("\r\nExpected 0xFE token, received: "); for (i=0;i<550;i++){ ConsolePutHex8(c); c=SPIGetChar(); } } #else Serial.print("\r\n NoData "); SPI8Clocks(200); /* Flush MMC by sending lots of FF's to it */ SPI8Clocks(200); SPI8Clocks(200); #endif DeselectMSD(); return 5; //Return error } return 0; }
void main() { FATFS fs; FIL file; InitMCU(); //VS_SinTest(0x74); VS_Init(); if(disk_initialize(0)) ConsoleWrite("Disk Initialization FAILED. :(\n"); else ConsoleWrite("Disk Initialization Complete.\n"); if(f_mount(0,&fs)) ConsoleWrite("Mount FieSystem Failed\n"); else ConsoleWrite("Mount FileSystem Success!\n"); ConsoleWrite("Scaning Music Files...\n\n"); if(scan_files("/",&(Player.TotalSongNum))) ConsoleWrite("Scan Files Failed\n"); else{ ConsoleWrite("\nScan Files Accomplished.\ntotal files: "); ConsolePutUInt (Player.TotalSongNum); ConsoleWrite ("\n\n");} if(scan_files_open (&file,"/",1)) // Start node to be scanned and opened ConsoleWrite("Open File Error\n"); //Playing mp3/track001.mp3 ... will apear in function Player.currFile = &file; Player.SongNum = 1; Player.Status = PS_PLAYING; Player.Mode = SM_SONG; Player.Volume = 170; Player.Bass = 7; Player.Treble = 0; VS_SetBassTreble(Player.Bass,Player.Treble); BufCnt = 0; // GenerateEvent(EV_BUFEMPTY); //Main loop while(1) { //Get system event Player.Event = GetEvent(); //Handle Events HandleEvent(); } }
void CeCosTestSerialFilter::Log(const char* pszFormat, ...) { va_list marker; va_start (marker, pszFormat); for(int nLength=100;nLength;) { char *buf=new char[1+nLength]; int n=vsnprintf(buf, nLength, pszFormat, marker ); if(-1==n){ nLength*=2; // NT behavior } else if (n<nLength){ if (m_bOptConsoleOutput) { ConsoleWrite(buf); } else { GDBWrite(buf); } nLength=0; // trigger exit from loop } else { nLength=n+1; // UNIX behavior generally, or NT behavior when buffer size exactly matches required length } delete [] buf; } va_end (marker); }
void Console::cmdConnect(const QString& args) { QString ret; if (args == "") { ret = "UASGE\nconnect <DeviceID>"; } if (this->isConnected) ret = "already connected"; else { extern MainWindow *mw; this->dev = mw->GetDeviceById(args); if (this->dev == NULL) ret = "unknown device"; else { connect(this, SIGNAL(onCommand(QString)), this->dev, SLOT(onExecuteCommand(QString))); connect(this->dev, SIGNAL(KeepCommandRequest()), this, SLOT(KeepCommandString())); connect(this->dev, SIGNAL(CommandReturn()), this, SLOT(CommandFinished())); connect(this->dev, SIGNAL(ConsoleWrite(QString)) , this, SLOT(ConsoleWriteRequest(QString))); connect(this->dev, SIGNAL(ConsoleWriteHTML(QString)), this, SLOT(ConsoleWriteRequestHTML(QString))); connect(this->dev, SIGNAL(ChangePrompt(QString)), this, SLOT(ChangePrompt(QString))); connect(this, SIGNAL(CommandInterrupted(QString)), this->dev, SLOT(onCommandInterrupt(QString))); connect(this->dev, SIGNAL(DisconnectConsole()), this, SLOT(cmdExit())); connect(this->dev, SIGNAL(destroyed()), this, SLOT(DeviceDeleted())); this->isConnected = true; ret = "connected to " + args; } } ConsoleWriteRequest(ret); CommandFinished(); }
LRESULT CALLBACK DocWin::CmdConsoleWrite( HWND hwnd, WPARAM wParam, LPARAM lParam ) { ConsoleWrite(m_pEdit, lParam); return 0; }
void Task2() { while(1) { if(!IsMultitasking()) { Halt("INTS DISABLED PRC2"); } ConsoleWrite("2"); _SimPrintString("2"); } }
LRESULT CALLBACK DocWin::CmdSplitConsoleWrite( HWND hwnd, WPARAM wParam, LPARAM lParam ) { CreateSplitConsole(SW_SHOW); ConsoleWrite(m_pConsole, lParam); return 0; }
int main() { Init_ADC(); ConsoleInit_Serial(); WriteByte((char) 0xB7); int i; while (1) { int frontleft = Get_ADC_Val("P15"); int backleft = Get_ADC_Val("P18"); ConsoleWrite((char)frontleft); ConsoleWrite((char)backleft); if (frontleft > (backleft + 200)) { Spin(-0.5f); } if (backleft > (frontleft + 200)) { Spin(0.5f); } Forward(0.1f); } }
int GetLine(char* String) { int i; char Character[2]; Character[1]='\0'; i=0; do { Character[0]=GetKeypress(); if(Character[0]!='\0') { ConsoleWrite(Character); String[i]=Character[0]; i++; } } while(Character[0]!='\n'); String[i]='\0'; return i; }
void Console::cmdExit() { disconnect(this, SIGNAL(onCommand(QString)), this->dev, SLOT(onExecuteCommand(QString))); disconnect(this->dev, SIGNAL(KeepCommandRequest()), this, SLOT(KeepCommandString())); disconnect(this->dev, SIGNAL(CommandReturn()), this, SLOT(CommandFinished())); disconnect(this->dev, SIGNAL(ConsoleWrite(QString)) , this, SLOT(ConsoleWriteRequest(QString))); disconnect(this->dev, SIGNAL(ConsoleWriteHTML(QString)), this, SLOT(ConsoleWriteRequestHTML(QString))); disconnect(this->dev, SIGNAL(ChangePrompt(QString)), this, SLOT(ChangePrompt(QString))); disconnect(this, SIGNAL(CommandInterrupted(QString)), this->dev, SLOT(onCommandInterrupt(QString))); disconnect(this->dev, SIGNAL(DisconnectConsole()), this, SLOT(cmdExit())); disconnect(this->dev, SIGNAL(destroyed()), this, SLOT(DeviceDeleted())); emit disconnectCommand(this); this->isConnected = false; ConsoleWriteRequest("connection closed with "+this->dev->GetDeviceID()); CommandFinished(); this->dev = NULL; }
void CeCosTestDownloadFilter::Trace(const char* pszFormat, ...) { va_list marker; va_start (marker, pszFormat); for(int nLength=100; nLength;) { char *buf=new char[1+nLength]; int n=vsnprintf(buf+4, nLength-4, pszFormat, marker ); if(-1==n) { nLength*=2; // NT behavior } else if (n<nLength) { memcpy(buf,"[d] ",4); ConsoleWrite(buf); nLength=0; // trigger exit from loop } else { nLength=n+1; // UNIX behavior generally, or NT behavior when buffer size exactly matches required length } delete [] buf; } va_end (marker); }
void main() { task* TI1; task* TI2; char* Data; char* Encoded; register unsigned int i; _asm; di ld sp,#0xffff ld a,#0x0 ld bc,#0x0 ld de,#0x0 ld hl,#0x0 ld ix,#0x0 ld iy,#0x0 _endasm; _SimWriteProtect((void*)0x0000, (void*)0x3fff); _SimPrintString("\n-------------------\n"); _SimPrintString("System reset\n"); _SimPrintString("-------------------\n"); IntsOff(); _SimPrintString("Interrupts disabled. Booting...\n"); TestMemory(); HardwareInit(); LocksInit(); SchedulingInit(); SupervisorMode(); TimeInit(); SystemInit(); MemoryInit(); //KeyboardInit(); //TapeInit(); ConsoleInit(); ConsoleWrite("LJL OS 0.1 FOR ZX SPECTRUM 48\n"); ConsoleWrite("\nCONSOLE OUTPUT\n\n"); /* TapeSave((void*)0x4000, (void*)0x5800); TapeLoad((void*)0x4000, (void*)0x5800); for(i=0; i<0x4000; i+=0x100) { ConsoleWrite("."); SaveBlock((void*)i); } Halt("Saved"); */ MainEntry=Task1; TI1=CreateTask(MainEntry, 100); MainEntry=Task2; TI2=CreateTask(MainEntry, 100); ConsoleWrite("TASKS CREATED\n"); SetScheduler(DefaultScheduler); ConsoleWrite("SCHEDULER SET\n"); Resume(); //ConsoleWrite("RESUMING\n"); //if(!IsMultitasking()) Halt("NOT MULTITASKING"); for(;;); Halt("SYSTEM SHUTDOWN"); }
void PrintNumber(unsigned int n) { char Temp[16]; WordToString(n, Temp); ConsoleWrite(Temp); }