#if 0 int PASCAL WinMain(HINSTANCE /*hInstance*/,HINSTANCE /*hPrevInstance*/,LPSTR /*lpszCmdLine*/,int /*nCmdShow*/) { CommControl commControl; DeviceControlBlock deviceControlBlock; CommStatus commStatus; BYTE charByte; String strString; BYTE ioBuffer[256]; DWORD eventMask; commControl.open(CommControl::PortCOM1); if(!commControl.isOkay())return FALSE; commControl.getDeviceControlBlock(deviceControlBlock); deviceControlBlock.parity(DeviceControlBlock::ParityNone); deviceControlBlock.baudRate(1200); deviceControlBlock.dataBits(8); deviceControlBlock.stopBits(0); if(!commControl.setDeviceControlBlock(deviceControlBlock))::OutputDebugString("Set operation failed\n"); ::OutputDebugString("waiting for break signal...\n"); commControl.setEventMask(CommControl::EventBreak); commControl.waitEvent(); ::OutputDebugString("break received, loading code...\n"); for(int index=0;index<256;index++)ioBuffer[index]=index; charByte=0xFF; commControl.write(&charByte,sizeof(charByte)); commControl.write(ioBuffer,sizeof(ioBuffer)); ::memset(ioBuffer,0,sizeof(ioBuffer)); ::OutputDebugString("receiving echo\n"); while(TRUE) { commControl.clearError(commStatus); if(commStatus.bytesInReceiveQueue()) { commControl.read(ioBuffer,sizeof(ioBuffer)); for(index=0;index+8 #include #include #include #include #include #include #include void main(int argc,char **argv) { CommControl commControl; CommStatus commStatus; DeviceControlBlock deviceControlBlock; DeviceControlBlock sanityBlock; BYTE ioBuffer[256]; commControl.open(CommControl::PortCOM1); if(!commControl.isOkay())return; commControl.getDeviceControlBlock(deviceControlBlock); deviceControlBlock.parity(DeviceControlBlock::ParityNone); // deviceControlBlock.dataBits(8); // deviceControlBlock.stopBits(1); // deviceControlBlock.baudRate(1200); if(!commControl.setDeviceControlBlock(deviceControlBlock)) { String strCode; DWORD errorCode(::GetLastError()); ::sprintf(strCode,"0x%08lx %d\n",errorCode,errorCode); ::OutputDebugString(strCode); } String strRcv; commControl.writeLine("ATE1"); commControl.readLine(strRcv); ::OutputDebugString(strRcv); commControl.writeLine("ATDT 9,1,5162620924"); // commControl.readLine(strRcv); ::OutputDebugString(strRcv); commControl.clearError(commStatus); if(commStatus.bytesInReceiveQueue()) { commControl.readLine(strRcv); ::OutputDebugString(strRcv); } commControl.close(); } #endif #include String strPathFileName("c:\\work\\as68hc11\\code2.asm"); String strLine; FileIO outFile; outFile.open(strPathFileName); //,FileIO::GenericRead,FileIO::FileShareRead); if(!outFile.isOkay())return FALSE; while(outFile.readLine(strLine)); outFile.close(); outFile.open(strPathFileName,FileIO::GenericRead,FileIO::FileShareRead); if(!outFile.isOkay())return FALSE; while(outFile.readLine(strLine)); return FALSE; void MainFrame::createToolBar(void) { Block addBitmaps; mToolBar.create(*this,ToolBarID); addBitmaps.insert(&AddBitmap(0,HINST_COMMCTRL)); if(!mToolBar.addBitmaps(addBitmaps))return; mToolBar.addButton(ToolBarButton(STD_FILENEW,MenuFileNew,ToolBarButton::StateEnabled,ToolBarButton::StyleButton)); mToolBar.addButton(ToolBarButton(STD_FILEOPEN,MenuFileOpen,ToolBarButton::StateEnabled,ToolBarButton::StyleButton)); mToolBar.addButton(ToolBarButton(STD_FILESAVE,MenuFileSave,ToolBarButton::StateEnabled,ToolBarButton::StyleButton)); mToolBar.addButton(ToolBarButton(STD_CUT,112,ToolBarButton::StateEnabled,ToolBarButton::StyleButton)); mToolBar.addButton(ToolBarButton(STD_COPY,110,ToolBarButton::StateEnabled,ToolBarButton::StyleButton)); mToolBar.addButton(ToolBarButton(STD_PASTE,111,ToolBarButton::StateEnabled,ToolBarButton::StyleButton)); // mToolBar.addButton(ToolBarButton(STD_PRINT,RiskMenuPrint,ToolBarButton::StateEnabled,ToolBarButton::StyleButton)); // mToolBar.addButton(ToolBarButton(STD_PRINTPRE,RiskMenuPageSetup,ToolBarButton::StateEnabled,ToolBarButton::StyleButton)); mToolBar.addButton(ToolBarButton(STD_FIND,122,ToolBarButton::StateEnabled,ToolBarButton::StyleButton)); mToolBar.show(SW_SHOW); // mToolBar.addButton(ToolBarButton(STD_HELP,RiskMenuHelpContents,ToolBarButton::StateEnabled,ToolBarButton::StyleButton)); // mToolBar.addButton(ToolBarButton(STD_DELETE,114,ToolBarButton::StateEnabled,ToolBarButton::StyleButton)); // mToolBar.addButton(ToolBarButton(STD_PROPERTIES,117,ToolBarButton::StateEnabled,ToolBarButton::StyleButton)); // mToolBar.addButton(ToolBarButton(STD_REDOW,119,ToolBarButton::StateEnabled,ToolBarButton::StyleButton)); // mToolBar.addButton(ToolBarButton(STD_REPLACE,121,ToolBarButton::StateEnabled,ToolBarButton::StyleButton)); // mToolBar.addButton(ToolBarButton(STD_UNDO,123,ToolBarButton::StateEnabled,ToolBarButton::StyleButton)); } // mToolBar.show(SW_SHOW); // mToolBar.addButton(ToolBarButton(STD_PRINT,RiskMenuPrint,ToolBarButton::StateEnabled,ToolBarButton::StyleButton)); // mToolBar.addButton(ToolBarButton(STD_PRINTPRE,RiskMenuPageSetup,ToolBarButton::StateEnabled,ToolBarButton::StyleButton)); // mToolBar.addButton(ToolBarButton(STD_HELP,RiskMenuHelpContents,ToolBarButton::StateEnabled,ToolBarButton::StyleButton)); // mToolBar.addButton(ToolBarButton(STD_DELETE,114,ToolBarButton::StateEnabled,ToolBarButton::StyleButton)); // mToolBar.addButton(ToolBarButton(STD_PROPERTIES,117,ToolBarButton::StateEnabled,ToolBarButton::StyleButton)); // mToolBar.addButton(ToolBarButton(STD_REDOW,119,ToolBarButton::StateEnabled,ToolBarButton::StyleButton)); // mToolBar.addButton(ToolBarButton(STD_REPLACE,121,ToolBarButton::StateEnabled,ToolBarButton::StyleButton)); // mToolBar.addButton(ToolBarButton(STD_UNDO,123,ToolBarButton::StateEnabled,ToolBarButton::StyleButton)); // commControl.read(&address,sizeof(address)); // ::sprintf(strString,"%lx",int(address)); // ::sprintf(strString,"%d%d%d%d%d%d%d%d", // int((address&128?1:0)),int((address&64?1:0)),int((address&32?1:0)),int((address&16?1:0)), // int((address&8?1:0)),int((address&4?1:0)),int((address&2?1:0)),int((address&1?1:0))); // ::MessageBox(::GetFocus(),(LPSTR)strString,"VALUE",MB_OK); // commControl.write(&charByte,sizeof(charByte)); // WORD address; // typedef void (PASCAL * DEBUGPROC)(CommControl &commControl); // Library procLib("procLib.dll"); // if(!procLib.isOkay())return FALSE; // if(!procLib.procIn("_procDebug@4"))return FALSE; // ((DEBUGPROC)procLib.procAddress("_procDebug@4"))(commControl); //c ((COMPROC)procLib.procAddress("_procDebug@4"))(commControl); /// ::memset(rcvBuffer,0,sizeof(rcvBuffer)); // WORD address; // String strString; // WORD count(0); // while(TRUE) // { // commControl.read(&address,sizeof(address)); // ::sprintf(strString,"%d) %08lx\n",++count,int(address)); // ::OutputDebugString(strString); // commControl.write(&charByte,sizeof(charByte)); // } // commControl.read(rcvBuffer,1); // commControl.read(rcvBuffer+1, // commControl.read(rcvBuffer+2,1); // commControl.read(rcvBuffer+3,1); // commControl.setEventMask(CommControl::EventBreak); // if(!commControl.waitEvent()){mStatusBar->setText("timeout waiting for break.");return FALSE;} // else mStatusBar->setText("received break"); // commControl.write(&charByte,sizeof(charByte)); // ::memset(rcvBuffer,0,sizeof(rcvBuffer)); // charByte=0; // commControl.read(&charByte,1); // commControl.read(&charByte,1); // ldd SWIHANDLER ; get address of SWIHANDLER to register D // bsr WRITEWORD ; send it out to SCI // bsr WAITCHAR ; wait for a character // ldd [SWI] ; load contents of SWI vector ? // bsr WRITEWORD ; send it out to SCI // bsr WAITCHAR ; wait for a character // ldd SWIHANDLER ; load address of SWIHANDLER to register D // std [SWI] ; store SWIHANDLER at swi vector ? // ldd [SWI] ; load contents of SWIHANDLER // bsr WRITEWORD ; send it out to SCI // bsr WAITCHAR ; wait for a character ; ********************************************************************************* ; ; ldd REGS ; load REGS into D ; std [MEMLOC] ; store D into MEMLOC ;CONTINUE equ * ; sync address ; ldd [MEMLOC] ; load D with value at MEMLOC ; xgdx ; exchange D with X ; ldab ix,00h ; load B with byte at address of X plus 00h ; bsr WRITECHAR ; write the contents of B to SCI ; ldd [MEMLOC] ; reload the value at MEMLOC ; addd 0001h ; increment value ; cpd CONFIG ; compare register D with CONFIG ; bgt END ; if D is greater than CONFIG we're all done ; std [MEMLOC] ; store value back into MEMLOC ; jmp CONTINUE ; keep going ;END equ * ; std [EEPROM] ; ldd [EEPROM] ; bsr WRITEWORD ; bsr WAITCHAR ; ldab EVENTCHAR ; bsr WRITECHAR ; ldab [PPROG] ; bsr WRITECHAR ; bsr WAITCHAR ; ldab EVENTCHAR ; bsr WRITECHAR ; ldab [BPROT] ; bsr WRITECHAR ; bsr WAITCHAR ; ldab 00h ; stab [BPROT] ; ldab EVENTCHAR ; bsr WRITECHAR ; ldab [BPROT] ; bsr WRITECHAR ; bsr WAITCHAR ; ldab 11h ; stab [EEPROM] ; ldab EVENTCHAR ; bsr WRITECHAR ; ldab [EEPROM] ; bsr WRITECHAR ; bsr WAITCHAR ; ldab EVENTEND ; bsr WRITECHAR ; ldab EVENTWORD ; bsr WRITECHAR ; ldd 5555h ; std [EEPROM] ; ldd [EEPROM] ; bsr WRITEWORD ; bsr READCHAR ; ldab EVENTEND ; bsr WRITECHAR ; ldd [msg] ; this seems to generate a compile error ; bsr WRITEENDEVENT ; write end event character to the SCI #define STRING_REGISTERPORTA 700 #define STRING_REGISTERCONFIG 763 mOwnerDrawList->insertString("PORTA"); mOwnerDrawList->insertString("RESERVED"); mOwnerDrawList->insertString("PIOC"); mOwnerDrawList->insertString("PORTC"); mOwnerDrawList->insertString("PORTB"); mOwnerDrawList->insertString("PORTCL"); mOwnerDrawList->insertString("RESERVED"); mOwnerDrawList->insertString("DDRC"); mOwnerDrawList->insertString("PORTD"); mOwnerDrawList->insertString("DDRD"); mOwnerDrawList->insertString("PORTE"); mOwnerDrawList->insertString("CFORC"); mOwnerDrawList->insertString("OC1M"); mOwnerDrawList->insertString("OC1D"); mOwnerDrawList->insertString("TCNT(Hi)"); mOwnerDrawList->insertString("TCNT(Lo)"); mOwnerDrawList->insertString("TIC1(Hi)"); mOwnerDrawList->insertString("TIC1(Lo)"); mOwnerDrawList->insertString("TIC2(Hi)"); mOwnerDrawList->insertString("TIC2(Lo)"); mOwnerDrawList->insertString("TIC3(Hi)"); mOwnerDrawList->insertString("TIC3(Lo)"); mOwnerDrawList->insertString("TOC1(Hi)"); mOwnerDrawList->insertString("TOC1(Lo)"); mOwnerDrawList->insertString("TOC2(Hi)"); mOwnerDrawList->insertString("TOC2(Lo)"); mOwnerDrawList->insertString("TOC3(Hi)"); mOwnerDrawList->insertString("TOC3(Lo)"); mOwnerDrawList->insertString("TOC4(Hi)"); mOwnerDrawList->insertString("TOC4(Lo)"); mOwnerDrawList->insertString("TI405(Hi)"); mOwnerDrawList->insertString("TI405(Lo)"); mOwnerDrawList->insertString("TCTL1"); mOwnerDrawList->insertString("TCTL2"); mOwnerDrawList->insertString("TMSK1"); mOwnerDrawList->insertString("TFLG1"); mOwnerDrawList->insertString("TMSK2"); mOwnerDrawList->insertString("TFLG2"); mOwnerDrawList->insertString("PACTL"); mOwnerDrawList->insertString("PACNT"); mOwnerDrawList->insertString("SPCR"); mOwnerDrawList->insertString("SPSR"); mOwnerDrawList->insertString("SPDR"); mOwnerDrawList->insertString("BAUD"); mOwnerDrawList->insertString("SCCR1"); mOwnerDrawList->insertString("SCCR2"); mOwnerDrawList->insertString("SCSR"); mOwnerDrawList->insertString("SCDR"); mOwnerDrawList->insertString("ADCTL"); mOwnerDrawList->insertString("ADR1"); mOwnerDrawList->insertString("ADR2"); mOwnerDrawList->insertString("ADR3"); mOwnerDrawList->insertString("ADR4"); mOwnerDrawList->insertString("BPROT"); mOwnerDrawList->insertString("EPROG"); mOwnerDrawList->insertString("RESERVED"); mOwnerDrawList->insertString("RESERVED"); mOwnerDrawList->insertString("OPTION"); mOwnerDrawList->insertString("COPRST"); mOwnerDrawList->insertString("PPROG"); mOwnerDrawList->insertString("HPRIO"); mOwnerDrawList->insertString("INIT"); mOwnerDrawList->insertString("TEST1"); mOwnerDrawList->insertString("CONFIG"); #if 0 #include BOOL MainFrame::codeLoad(const String &strPathBinary) { FileHandle inFile; BYTE sndBuffer[256]; BYTE rcvBuffer[256]; BYTE *ptrByte; BYTE charByte(0xFF); WORD codeLength(0); DeviceControlBlock deviceControlBlock; CommControl commControl; CommStatus commStatus; if(!inFile.open(strPathBinary)){mStatusBar->setText("Error opening file.");return FALSE;} if(!commControl.open(CommControl::Port(0))){mStatusBar->setText("Error opening port.");return FALSE;} commControl.getDeviceControlBlock(deviceControlBlock); deviceControlBlock.baudRate(1200); deviceControlBlock.parity(DeviceControlBlock::Parity(0)); deviceControlBlock.dataBits(8); deviceControlBlock.stopBits(0); if(!commControl.setDeviceControlBlock(deviceControlBlock))mStatusBar->setText("Failed to apply settings."); mStatusBar->setText("waiting for break signal...."); commControl.setEventMask(CommControl::EventBreak); if(!commControl.waitEvent()){mStatusBar->setText("timeout waiting for break.");return FALSE;} mStatusBar->setText("break received, loading code..."); ::memset(sndBuffer,1,sizeof(sndBuffer)); ::memset(rcvBuffer,0,sizeof(rcvBuffer)); ptrByte=sndBuffer; while(inFile.read(*ptrByte)){codeLength++;ptrByte++;} commControl.write(&charByte,sizeof(charByte)); commControl.read(&charByte,sizeof(charByte)); commControl.write(sndBuffer,sizeof(sndBuffer)); if(!commControl.read(rcvBuffer,sizeof(sndBuffer))){mStatusBar->setText("Failed to verify write.");return FALSE;} if(!::memcmp(rcvBuffer,sndBuffer,codeLength))mStatusBar->setText("Code has been loaded onto device."); else {mStatusBar->setText("Failed to verify write.");return FALSE;} // event types // 0x00 - character // 0x01 - WORD // 0x02 - DWORD // 0x03 - varchar : [WORD:count,countcharacters] // 0xFF - end BYTE event; // 0x00=char, 0x01=WORD, 0x02=varchar BYTE ack(0x00); char charData; WORD wordData; DWORD dwordData; int index; BOOL reading(TRUE); String strString; int map(0x1000); enum Event{EventSingleByte=0x00,EventDoubleByte=0x01,EventQuadByte=0x02,EventVarByte=0x03, EventRegs=0x04,EventEnd=0xFF}; while(reading) { commControl.read(&event,sizeof(event)); switch(Event(event)) { case EventSingleByte : commControl.read(&charData,sizeof(charData)); commControl.write(&ack,sizeof(ack)); ::sprintf(strString,"(%d%d%d%d%d%d%d%d) %lx\n", int((charData&128?1:0)),int((charData&64?1:0)),int((charData&32?1:0)),int((charData&16?1:0)), int((charData&8?1:0)),int((charData&4?1:0)),int((charData&2?1:0)),int((charData&1?1:0)), int(charData)); ::OutputDebugString(strString); ::MessageBox(::GetFocus(),(LPSTR)strString,"M68HC11",MB_OK); break; case EventDoubleByte : commControl.read(&wordData,sizeof(wordData)); commControl.write(&ack,sizeof(ack)); ::sprintf(strString,"%lx\n",int(wordData)); ::OutputDebugString(strString); ::MessageBox(::GetFocus(),(LPSTR)strString,"M68HC11",MB_OK); break; case EventQuadByte : commControl.read(&dwordData,sizeof(dwordData)); commControl.write(&ack,sizeof(ack)); ::sprintf(strString,"%lx\n",int(dwordData)); ::OutputDebugString(strString); ::MessageBox(::GetFocus(),(LPSTR)strString,"M68HC11",MB_OK); break; case EventVarByte : commControl.read(&wordData,sizeof(wordData)); for(index=0;indexsetText("No response to initial command.");return;} commControl.write(sndBuffer,sizeof(sndBuffer)); // if(!commControl.read(rcvBuffer,sizeof(sndBuffer))){mStatusBar->setText("no data was received from device.");return;} // if(!::memcmp(rcvBuffer,sndBuffer,sizeof(sndBuffer)))mStatusBar->setText("The device is present and working properly."); // else mStatusBar->setText("Failed to verify write."); #if 0 #include int PASCAL WinMain(HINSTANCE /*hInstance*/,HINSTANCE /*hPrevInstance*/,LPSTR /*lpszCmdLine*/,int /*nCmdShow*/) { CommControl commControl; CommStatus commStatus; DeviceControlBlock deviceControlBlock; BYTE charByte(0xFF); commControl.open(CommControl::PortCOM1); if(!commControl.isOkay())return FALSE; if(!commControl.setDeviceControlBlock("baud=1200 data=8 stop=1 parity=N"))::OutputDebugString("Set operation failed\n"); String strString; charByte='a'; while(TRUE) { commControl.write(&charByte,sizeof(charByte)); // commControl.waitForData(); commControl.read(&charByte,sizeof(charByte)); ::sprintf(strString,"%02x\n",(int)charByte); ::OutputDebugString(strString); charByte++; // commControl.clearError(commStatus); // if(commStatus.bytesInReceiveQueue()) // { // commControl.read(&charByte,sizeof(charByte)); // ::sprintf(strString,"%02x\n",(int)charByte); // ::OutputDebugString(strString); // break; // } ::Sleep(250); } /* ::OutputDebugString("waiting for break signal...\n"); commControl.setEventMask(CommControl::EventBreak); // EventBreak if(!commControl.waitEvent())::OutputDebugString("timeout waiting for break.\n"); else ::OutputDebugString("break received, loading code...\n"); BYTE ioBuffer[256]; for(int index=0;index<256;index++)ioBuffer[index]=index; charByte=0xFF; commControl.write(&charByte,sizeof(charByte)); // commControl.clearError(commStatus); // if(commStatus.bytesInReceiveQueue())commControl.read(ioBuffer,commStatus.bytesInReceiveQueue()); commControl.write(ioBuffer,sizeof(ioBuffer)); ::memset(ioBuffer,0,sizeof(ioBuffer)); String strString; ::OutputDebugString("receiving echo\n"); while(TRUE) { commControl.clearError(commStatus); if(commStatus.bytesInReceiveQueue()) { commControl.read(ioBuffer,sizeof(ioBuffer)); for(index=0;index+8