//****************************************************************************** //****************************************************************************** // Main //****************************************************************************** //****************************************************************************** int main (void) { BYTE i; DWORD temp; int value; value = SYSTEMConfigWaitStatesAndPB( GetSystemClock() ); mJTAGPortEnable(DEBUG_JTAGPORT_OFF); // Enable the cache for the best performance CheKseg0CacheOn(); value = OSCCON; while (!(value & 0x00000020)) { value = OSCCON; // Wait for PLL lock to stabilize } InitKeyboardDriver(); INTEnableSystemMultiVectoredInt(); // Init status LED mPORTCSetBits(BIT_0); mPORTCSetPinsDigitalOut(BIT_0); //DBINIT(); // Initialize USB layers USBInitialize(0); while (1) { USBTasks(); App_Detect_Device(); switch (App_State_Keyboard) { case DEVICE_NOT_CONNECTED: mPORTCSetBits(BIT_0); USBTasks(); if (DisplayDeatachOnce == FALSE) { DBPRINTF("Device Detached\n"); DisplayDeatachOnce = TRUE; } if (USBHostHID_ApiDeviceDetect()) /* True if report descriptor is parsed with no error */ { DBPRINTF("Device Attached\n"); App_State_Keyboard = DEVICE_CONNECTED; DisplayConnectOnce = FALSE; } break; case DEVICE_CONNECTED: mPORTCClearBits(BIT_0); App_State_Keyboard = READY_TO_TX_RX_REPORT; if (DisplayConnectOnce == FALSE) { DisplayConnectOnce = TRUE; DisplayDeatachOnce = FALSE; } InitializeTimer(); // start 10ms timer to schedule input reports break; case READY_TO_TX_RX_REPORT: if (!USBHostHID_ApiDeviceDetect()) { App_State_Keyboard = DEVICE_NOT_CONNECTED; // DisplayOnce = FALSE; } break; case GET_INPUT_REPORT: if (USBHostHID_ApiGetReport(Appl_raw_report_buffer.Report_ID, Appl_ModifierKeysDetails.interfaceNum, Appl_raw_report_buffer.ReportSize, Appl_raw_report_buffer.ReportData)) { /* Host may be busy/error -- keep trying */ } else { App_State_Keyboard = INPUT_REPORT_PENDING; } USBTasks(); break; case INPUT_REPORT_PENDING: if (USBHostHID_ApiTransferIsComplete(&ErrorDriver, &NumOfBytesRcvd)) { if (ErrorDriver || (NumOfBytesRcvd != Appl_raw_report_buffer.ReportSize )) { ErrorCounter++ ; if (MAX_ERROR_COUNTER <= ErrorDriver) App_State_Keyboard = ERROR_REPORTED; else App_State_Keyboard = READY_TO_TX_RX_REPORT; } else { ErrorCounter = 0; ReportBufferUpdated = TRUE; App_State_Keyboard = READY_TO_TX_RX_REPORT; if (DisplayConnectOnce == TRUE) { for (i = 0; i < Appl_raw_report_buffer.ReportSize; i++) { if (Appl_raw_report_buffer.ReportData[i] != 0) { //LCDClear(); //LCDL1Home(); DisplayConnectOnce = FALSE; } } } App_ProcessInputReport(); App_PrepareOutputReport(); } } break; case SEND_OUTPUT_REPORT: /* Will be done while implementing Keyboard */ if (USBHostHID_ApiSendReport(Appl_LED_Indicator.reportID, Appl_LED_Indicator.interfaceNum, Appl_LED_Indicator.reportLength, (BYTE*) & Appl_led_report_buffer)) { /* Host may be busy/error -- keep trying */ } else { App_State_Keyboard = OUTPUT_REPORT_PENDING; } USBTasks(); break; case OUTPUT_REPORT_PENDING: if (USBHostHID_ApiTransferIsComplete(&ErrorDriver, &NumOfBytesRcvd)) { if (ErrorDriver) { ErrorCounter++ ; if (MAX_ERROR_COUNTER <= ErrorDriver) App_State_Keyboard = ERROR_REPORTED; // App_State_Keyboard = READY_TO_TX_RX_REPORT; } else { ErrorCounter = 0; App_State_Keyboard = READY_TO_TX_RX_REPORT; } } break; case ERROR_REPORTED: break; default: break; } } }
BOOL InitializeSystem ( void ) { #if defined( __PIC24FJ256GB110__ ) // Configure U2RX - put on pin 49 (RP10) RPINR19bits.U2RXR = 10; // Configure U2TX - put on pin 50 (RP17) RPOR8bits.RP17R = 5; OSCCON = 0x3302; // Enable secondary oscillator CLKDIV = 0x0000; // Set PLL prescaler (1:1) TRISA = 0x0000; TRISD = 0x00C0; #elif defined( __PIC24FJ256GB106__ ) // Configure U2RX - put on pin 17 (RP8) RPINR19bits.U2RXR = 8; // Configure U2TX - put on pin 16 (RP7) RPOR3bits.RP7R = 5; // OSCCON = 0x3302; // Enable secondary oscillator CLKDIV = 0x0000; // Set PLL prescaler (1:1) #elif defined(__PIC24FJ64GB004__) //On the PIC24FJ64GB004 Family of USB microcontrollers, the PLL will not power up and be enabled //by default, even if a PLL enabled oscillator configuration is selected (such as HS+PLL). //This allows the device to power up at a lower initial operating frequency, which can be //advantageous when powered from a source which is not gauranteed to be adequate for 32MHz //operation. On these devices, user firmware needs to manually set the CLKDIV<PLLEN> bit to //power up the PLL. { unsigned int pll_startup_counter = 600; CLKDIVbits.PLLEN = 1; while(pll_startup_counter--); } #elif defined(__PIC24FJ64GB002__) //On the PIC24FJ64GB004 Family of USB microcontrollers, the PLL will not power up and be enabled //by default, even if a PLL enabled oscillator configuration is selected (such as HS+PLL). //This allows the device to power up at a lower initial operating frequency, which can be //advantageous when powered from a source which is not gauranteed to be adequate for 32MHz //operation. On these devices, user firmware needs to manually set the CLKDIV<PLLEN> bit to //power up the PLL. { unsigned int pll_startup_counter = 600; CLKDIVbits.PLLEN = 1; while(pll_startup_counter--); } AD1PCFG = 0xffff; CLKDIV = 0x0000; // Set PLL prescaler (1:1) // Configure U2RX - put on pin 17 (RP8) RPINR19bits.U2RXR = 8; // Configure U2TX - put on pin 16 (RP7) RPOR3bits.RP7R = 5; #elif defined(__PIC32MX__) { int value; value = SYSTEMConfigWaitStatesAndPB( GetSystemClock() ); // Enable the cache for the best performance CheKseg0CacheOn(); INTEnableSystemMultiVectoredInt(); value = OSCCON; while (!(value & 0x00000020)) { value = OSCCON; // Wait for PLL lock to stabilize } } #endif // Init UART UART2Init(); return TRUE; } // InitializeSystem
int main(void) { int value; int junk; millisec = 0; value = SYSTEMConfigWaitStatesAndPB( GetSystemClock() ); // Enable the cache for the best performance CheKseg0CacheOn(); //Setupt input for inteface button JF8 (RA01) (0x02) TRISASET = 0x02; //RED LED - JF9 (RA04) (0x10) TRISACLR = 0x10; ODCACLR = 0x10; LATASET = 0x10; //Green LED -JF7 (RE9) (0x200) TRISECLR = 0x200; ODCECLR = 0x200; LATESET = 0x200; //Setupt Input for DataFlag Button - JF10 - RA5 0x20 TRISASET = 0x20; //Setup Output for Clutch Hold (Launch) JE1 RD14 0x4000 //This function is active low, driving the FET on the PDU TRISDCLR = 0x4000; ODCDCLR = 0x4000; LATDSET = 0x4000; //Default state is high (off) CAN1Init();//CAN1 ACCL 500kbs CAN2Init();//Motec 1mbs DelayInit(); initUART2(); // GPS UART prevButton1 = 0; prevButton2 = 0; millisec = 0; // Configure Timer 2 to request a real-time interrupt once per millisecond. // The period of Timer 2 is (16 * 5000)/(80 MHz) = 1 ms. OpenTimer2(T2_ON | T2_IDLE_CON | T2_SOURCE_INT | T2_PS_1_16 | T2_GATE_OFF, 5000); // Configure the CPU to respond to Timer 2's interrupt requests. INTEnableSystemMultiVectoredInt(); INTSetVectorPriority(INT_TIMER_2_VECTOR, INT_PRIORITY_LEVEL_2); INTClearFlag(INT_T2); INTEnable(INT_T2, INT_ENABLED); //UART GPS Interrupts INTSetVectorPriority(INT_UART_2_VECTOR ,INT_PRIORITY_LEVEL_1); //Make sure UART interrupt is top priority INTClearFlag(INT_U2RX); INTEnable(INT_U2RX, INT_ENABLED); value = OSCCON; while (!(value & 0x00000020)) { value = OSCCON; // Wait for PLL lock to stabilize } deviceAttached = FALSE; //Initialize the stack USBInitialize(0); shouldLog = FALSE; shouldStop = FALSE; //count = 0; angularRateInfoRec = FALSE; accelerationSensorRec = FALSE; HRaccelerationSensorRec = FALSE; //init tim er 3 to convert adc at 100hz OpenTimer3(T3_ON|T3_PS_1_256|T3_SOURCE_INT, 1562); //initialize i2c for the psoc initI2CPSoC(); state = wait; logNum = 0; initI2CEEPROM(); short addy = 0x0000; BYTE num = 0x00; logNum = readEEPROM(addy); if(logNum >= 0xEF) //Address stored in EEPROM if greater than 0xEF reset to zero, limited to a single byte with current code configuration { writeEEPROM(addy, 0x00); } char GroupString[550];//Group Names (Line1) char UnitString[550];//Units (line2) char ParamString[650];//Paramater Names (line3) sprintf(GroupString,"Time,Accelerometer,Accelerometer,Accelerometer,Accelerometer,Accelerometer,Accelerometer,Accelerometer,Accelerometer,Accelerometer,Engine,Engine,Engine,Engine,Engine,Engine,Engine,Engine,Engine,Engine,Drivetrain,Drivetrain,Electrical,Drivetrain,Drivetrain,Drivetrain,Drivetrain,Engine,Engine,Engine,Engine,Electrical,Electrical,Electrical,Electrical,Electrical,Electrical,Suspension,Suspension,Suspension,Suspension,Suspension,Drivetrain,Driver\n"); sprintf(UnitString,"ms,deg/s,deg/s,deg/s,m/s^2,m/s^2,m/s^2,m/s^2,m/s^2,m/s^2,rpm,%,kpa,degF,degF,lambda,psi,degF,na,na,psi,psi,V,mph,mph,mph,mph,s,gal,degF,degBTDC,mV,mV,mV,mV,mV,mV,mV,mV,mV,mV,mV,mV,\n"); sprintf(ParamString, "Millisec,pitch(deg/sec),roll(deg/sec),yaw(deg/sec),lat(m/s^2),long(m/s^2),vert(m/s^2),latHR(m/s^2),longHR(m/s^2),vertHR(m/s^2),rpm,tps(percent),MAP(kpa),AT(degF),ect(degF),lambda,fuel pres,egt(degF),launch,neutral,brake pres,brake pres filtered,BattVolt(V),ld speed(mph), lg speed(mph),rd speed(mph),rg speed(mph),run time(s),fuel used,Oil Temp (deg F), Ignition Adv (degBTDC),Overall Consumption(mV),Overall Production(mV),Fuel Pump(mV),Fuel Injector(mV),Ignition(mV),Vref(mV),Back Left(mV),Back Right(mV),Front Left(mV),Front Right(mV),Steering Angle(mV),Brake Temp(mV),Data Flag,GPRMC,Time,Valid,Lat,N/S,Long,E/W,Speed,Course,Date,Variation,E/W\n"); LATACLR = 0x10; //Turn on Red LED // LATECLR = 0x200; UARTSendString(UART2,PMTK_HOT_RESTART); int i = 0; while(!UARTTransmissionHasCompleted(UART2)){ i++; } while(1) { GPSDataRead(); GPSSentenceParse(); ClutchHold(); //This function handles the venting direction of the clutch actuator DataFlagFunc(); //This function handles the updates of the data flag variable //USB stack process function USBTasks(); switch(state){ case wait: USBTasks(); millisec = 0; if(CheckLogStateChange() == 1){ //start the transition from wait to log state = startLog; } break; case startLog: //if thumbdrive is plugged in if(USBHostMSDSCSIMediaDetect()) { deviceAttached = TRUE; //now a device is attached //See if the device is attached and in the right format if(FSInit()) { //Opening a file in mode "w" will create the file if it doesn't // exist. If the file does exist it will delete the old file // and create a new one that is blank. logNum = readEEPROM(addy); sprintf(nameString, "test%d.csv", logNum); myFile = FSfopen(nameString,"w"); FSfwrite(GroupString,1,strlen(GroupString),myFile); FSfwrite(UnitString,1,strlen(UnitString),myFile); FSfwrite(ParamString,1, strlen(ParamString),myFile); millisec = 0; //LATDSET = 0x4000; //Send sync pulse (aeroprobe) // while(millisec < 1000){} //Wait 1s then move to log, the aeroprobe ADC waits 1s. state = log; LATECLR = 0x200; //Turn on Green LATASET = 0x10; //Turn off Red } } break; case log: //This uses MOTEC as the master timer. Data is only written to the USB after all the motec Data is received if(motec0Read && motec1Read && motec2Read && motec3Read && motec4Read && motec5Read){ WriteToUSB(); } else{}//Wait for motec data to write the next row if(CheckLogStateChange() == 2){ //Start the transition from log to wait state = stopLog; } if(millisec > 2000){ LATDCLR = 0x4000; //After 2 seconds pass no need to keep output high } //Add a function to check for a flag button and set a variable break; case stopLog: //Always make sure to close the file so that the data gets written to the drive. FSfwrite("endFile", 1, 7, myFile); FSfclose(myFile); state = wait; logNum++; writeEEPROM(addy, logNum); LATACLR = 0x10; //Turn on Red LATESET = 0x200; //Turn off Green break; default: state = wait; break; } //CAN Handlers CANRxMessageBuffer* CAN1RxMessage = CAN1RxMsgProcess(); if(CAN1RxMessage){ WriteAccelData(CAN1RxMessage); //Accel is on CAN 1 } CANRxMessageBuffer* CAN2RxMessage = CAN2RxMsgProcess(); if(CAN2RxMessage){ writeCan2Msg(CAN2RxMessage); //Motec is on CAN 2 } } return 0; }
int main (void) { #if defined (__C30__) || defined __XC16__ #if defined( __PIC24FJ256GB110__ ) || defined(__PIC24FJ256GB210__) // Configure U2RX - put on pin 49 (RP10) RPINR19bits.U2RXR = 10; // Configure U2TX - put on pin 50 (RP17) RPOR8bits.RP17R = 5; // Configure SPI2 Data In - put on pin 11 (RP26) RPINR22bits.SDI2R = 26; // Configure SPI2 Clock Out - put on pin 10 (RP21) RPOR10bits.RP21R = 11; // Configure SPI2 Data Out - put on pin 12 (RP19) RPOR9bits.RP19R = 10; OSCCON = 0x3302; // Enable secondary oscillator CLKDIV = 0x0000; // Set PLL prescaler (1:1) #elif defined(__PIC24FJ64GB004__) //On the PIC24FJ64GB004 Family of USB microcontrollers, the PLL will not power up and be enabled //by default, even if a PLL enabled oscillator configuration is selected (such as HS+PLL). //This allows the device to power up at a lower initial operating frequency, which can be //advantageous when powered from a source which is not gauranteed to be adequate for 32MHz //operation. On these devices, user firmware needs to manually set the CLKDIV<PLLEN> bit to //power up the PLL. { unsigned int pll_startup_counter = 600; CLKDIVbits.PLLEN = 1; while(pll_startup_counter--); } //Device switches over automatically to PLL output after PLL is locked and ready. #elif defined(__PIC24FJ256DA210__) //TX RF3 RP16 //RX RD0 RP11 // Configure U2RX - put on RP11 RPINR19bits.U2RXR = 11; // Configure U2TX - put on RP16 RPOR8bits.RP16R = 5; #endif #elif defined(__PIC32MX__) { int value; value = SYSTEMConfigWaitStatesAndPB( GetSystemClock() ); // Enable the cache for the best performance CheKseg0CacheOn(); INTEnableSystemMultiVectoredInt(); value = OSCCON; while (!(value & 0x00000020)) { value = OSCCON; // Wait for PLL lock to stabilize } } AD1PCFG = 0xFFFF; // Set analog pins to digital. TRISF = 0x00; #else #error Cannot initialize. #endif UART2Init(); UART2PrintString( "\r\n\r\nUSB Embedded Host Simple Full Sheet Printer Demo\r\n" ); // Initialize USB Embedded Host USBInitialize(0); // Turn on the A/D converter to monitor Vbus. InitializeVbusMonitor(); while(1) { MonitorVBUS(); USBTasks(); if (status.printerAttached) { if(status.printerStatusDone == 0) { if(status.printerStatusSent == 0) { if(USBHostPrinterGetStatus( printerInfo.deviceAddress, &status.printer ) == USB_SUCCESS) { status.printerStatusSent = 1; } } } else { if(status.printer != 0x18) { //if there was an error in the printer status then setup to // check the status again status.printerStatusSent = 0; status.printerStatusDone = 0; } else { if (!status.pagePrinted) { status.pagePrinted = 1; UART2PrintString( "Printing to full sheet printer...\r\n" ); // Initialize USBHostPrinterCommandWithReadyWait( &returnCode, printerInfo.deviceAddress, USB_PRINTER_JOB_START, USB_NULL, 0, 0 ); if (!printerInfo.support.supportFlags.supportsVectorGraphics) { // In the demo's initial configuration, this section executes for the HP Deskjet 460. UART2PrintString( "Vector graphics are not supported.\r\n" ); imageInfo.resolution = 75; imageInfo.scale = 1.0; imageInfo.positionX = (PRINTER_PAGE_PORTRAIT_WIDTH - 0x120)/2; imageInfo.positionY = 100; #if defined( __C30__ ) || defined __XC16__ PrintImageFullSheet( (BYTE __prog__ *)(logoMCHP.address), &imageInfo ); #elif defined( __PIC32MX__ ) PrintImageFullSheet( (const BYTE *)(logoMCHP.address), &imageInfo ); #endif USBHostPrinterCommandWithReadyWait( &returnCode, printerInfo.deviceAddress, USB_PRINTER_FONT_NAME, USB_NULL, USB_PRINTER_FONT_COURIER, 0 ); USBHostPrinterCommandWithReadyWait( &returnCode, printerInfo.deviceAddress, USB_PRINTER_FONT_SIZE, USB_NULL, (DWORD)24, 0 ); USBHostPrinterCommandWithReadyWait( &returnCode, printerInfo.deviceAddress, USB_PRINTER_FONT_BOLD, USB_NULL, 0, 0 ); WriteLine( 200, 325, &(businessCard[0][0]) ); USBHostPrinterCommandWithReadyWait( &returnCode, printerInfo.deviceAddress, USB_PRINTER_FONT_MEDIUM, USB_NULL, 0, 0 ); USBHostPrinterCommandWithReadyWait( &returnCode, printerInfo.deviceAddress, USB_PRINTER_FONT_SIZE, USB_NULL, (DWORD)20, 0 ); WriteLine( 200, 350, &(businessCard[1][0]) ); WriteLine( 200, 375, &(businessCard[2][0]) ); WriteLine( 200, 400, &(businessCard[3][0]) ); WriteLine( 200, 425, &(businessCard[4][0]) ); WriteLine( 200, 450, &(businessCard[5][0]) ); WriteLine( 200, 475, &(businessCard[6][0]) ); WriteLine( 200, 500, &(businessCard[7][0]) ); USBHostPrinterCommandWithReadyWait( &returnCode, printerInfo.deviceAddress, USB_PRINTER_FONT_NAME, USB_NULL, USB_PRINTER_FONT_TIMES_NEW_ROMAN, 0 ); USBHostPrinterCommandWithReadyWait( &returnCode, printerInfo.deviceAddress, USB_PRINTER_FONT_SIZE, USB_NULL, (DWORD)18, 0 ); USBHostPrinterCommandWithReadyWait( &returnCode, printerInfo.deviceAddress, USB_PRINTER_FONT_BOLD, USB_NULL, 0, 0 ); WriteLine( 50, PRINTER_PAGE_PORTRAIT_HEIGHT - 145, &(adddressMicrochip[0][0]) ); USBHostPrinterCommandWithReadyWait( &returnCode, printerInfo.deviceAddress, USB_PRINTER_FONT_MEDIUM, USB_NULL, 0, 0 ); WriteLine( 50, PRINTER_PAGE_PORTRAIT_HEIGHT - 120, &(adddressMicrochip[1][0]) ); WriteLine( 50, PRINTER_PAGE_PORTRAIT_HEIGHT - 95, &(adddressMicrochip[2][0]) ); WriteLine( 50, PRINTER_PAGE_PORTRAIT_HEIGHT - 70, &(adddressMicrochip[3][0]) ); } else { // In the demo's initial configuration, this section executes for the Lexmark E250dn. USBHostPrinterCommandWithReadyWait( &returnCode, printerInfo.deviceAddress, USB_PRINTER_ORIENTATION_LANDSCAPE, USB_NULL, 0, 0 ); USBHostPrinterCommandWithReadyWait( &returnCode, printerInfo.deviceAddress, USB_PRINTER_GRAPHICS_LINE_WIDTH, USB_NULL, PRINTER_LINE_WIDTH_THICK, 0 ); params.sBevel.xL = 50; // X-axis position of the left side of the bevel. params.sBevel.yT = 50; // Y-axis position of the top of the bevel. params.sBevel.xR = PRINTER_PAGE_LANDSCAPE_WIDTH - 50; // X-axis position of the right side of the bevel. params.sBevel.yB = PRINTER_PAGE_LANDSCAPE_HEIGHT - 50; // Y-axis position of the bottom of the bevel. params.sBevel.r = 20; // The radius of the cicle that defines the rounded corner USBHostPrinterCommandWithReadyWait( &returnCode, printerInfo.deviceAddress, USB_PRINTER_GRAPHICS_BEVEL, USB_DATA_POINTER_RAM(¶ms), sizeof(params.sBevel), 0 ); imageInfo.resolution = 75; imageInfo.scale = 1.0; imageInfo.positionX = 100; imageInfo.positionY = 100; #if defined( __C30__ ) || defined __XC16__ PrintImageFullSheet( (BYTE __prog__ *)(logoMCHP.address), &imageInfo ); #elif defined( __PIC32MX__ ) PrintImageFullSheet( (const BYTE *)(logoMCHP.address), &imageInfo ); #endif USBHostPrinterCommandWithReadyWait( &returnCode, printerInfo.deviceAddress, USB_PRINTER_FONT_NAME, USB_NULL, USB_PRINTER_FONT_HELVETICA, 0 ); USBHostPrinterCommandWithReadyWait( &returnCode, printerInfo.deviceAddress, USB_PRINTER_FONT_SIZE, USB_NULL, (DWORD)18, 0 ); USBHostPrinterCommandWithReadyWait( &returnCode, printerInfo.deviceAddress, USB_PRINTER_FONT_BOLD, USB_NULL, 0, 0 ); WriteLine( 100, PRINTER_PAGE_LANDSCAPE_HEIGHT - 145, &(adddressMicrochip[0][0]) ); USBHostPrinterCommandWithReadyWait( &returnCode, printerInfo.deviceAddress, USB_PRINTER_FONT_MEDIUM, USB_NULL, 0, 0 ); WriteLine( 100, PRINTER_PAGE_LANDSCAPE_HEIGHT - 120, &(adddressMicrochip[1][0]) ); WriteLine( 100, PRINTER_PAGE_LANDSCAPE_HEIGHT - 95, &(adddressMicrochip[2][0]) ); WriteLine( 100, PRINTER_PAGE_LANDSCAPE_HEIGHT - 70, &(adddressMicrochip[3][0]) ); USBHostPrinterCommandWithReadyWait( &returnCode, printerInfo.deviceAddress, USB_PRINTER_FONT_NAME, USB_NULL, USB_PRINTER_FONT_AVANT_GARDE, 0 ); USBHostPrinterCommandWithReadyWait( &returnCode, printerInfo.deviceAddress, USB_PRINTER_FONT_SIZE, USB_NULL, (DWORD)24, 0 ); USBHostPrinterCommandWithReadyWait( &returnCode, printerInfo.deviceAddress, USB_PRINTER_FONT_BOLD, USB_NULL, 0, 0 ); WriteLine( 450, 125, &(businessCard[0][0]) ); USBHostPrinterCommandWithReadyWait( &returnCode, printerInfo.deviceAddress, USB_PRINTER_FONT_MEDIUM, USB_NULL, 0, 0 ); USBHostPrinterCommandWithReadyWait( &returnCode, printerInfo.deviceAddress, USB_PRINTER_FONT_SIZE, USB_NULL, (DWORD)20, 0 ); WriteLine( 450, 150, &(businessCard[1][0]) ); WriteLine( 450, 175, &(businessCard[2][0]) ); WriteLine( 450, 200, &(businessCard[3][0]) ); WriteLine( 450, 225, &(businessCard[4][0]) ); WriteLine( 450, 250, &(businessCard[5][0]) ); WriteLine( 450, 275, &(businessCard[6][0]) ); WriteLine( 450, 300, &(businessCard[7][0]) ); USBHostPrinterCommandWithReadyWait( &returnCode, printerInfo.deviceAddress, USB_PRINTER_FONT_NAME, USB_NULL, USB_PRINTER_FONT_PALATINO, 0 ); USBHostPrinterCommandWithReadyWait( &returnCode, printerInfo.deviceAddress, USB_PRINTER_FONT_SIZE, USB_NULL, (DWORD)16, 0 ); USBHostPrinterCommandWithReadyWait( &returnCode, printerInfo.deviceAddress, USB_PRINTER_FONT_ITALIC, USB_NULL, 0, 0 ); USBHostPrinterCommandWithReadyWait( &returnCode, printerInfo.deviceAddress, USB_PRINTER_GRAPHICS_LINE_WIDTH, USB_NULL, PRINTER_LINE_WIDTH_NORMAL, 0 ); USBHostPrinterCommandWithReadyWait( &returnCode, printerInfo.deviceAddress, USB_PRINTER_GRAPHICS_LINE_TYPE, USB_NULL, PRINTER_LINE_TYPE_DASHED, 0 ); WriteLine( 120, 310, &(notes[0][0]) ); params.sLine.x1 = 170; params.sLine.y1 = 290; params.sLine.x2 = 220; params.sLine.y2 = 260; USBHostPrinterCommandWithReadyWait( &returnCode, printerInfo.deviceAddress, USB_PRINTER_GRAPHICS_LINE, USB_DATA_POINTER_RAM(¶ms), sizeof(params.sLine), 0 ); WriteLine( 216, 396, &(notes[1][0]) ); params.sLine.x1 = 266; params.sLine.y1 = 400; params.sLine.x2 = 216; params.sLine.y2 = 445; USBHostPrinterCommandWithReadyWait( &returnCode, printerInfo.deviceAddress, USB_PRINTER_GRAPHICS_LINE, USB_DATA_POINTER_RAM(¶ms), sizeof(params.sLine), 0 ); WriteLine( 440, 330, &(notes[2][0]) ); params.sLine.x1 = 490; params.sLine.y1 = 310; params.sLine.x2 = 515; params.sLine.y2 = 280; USBHostPrinterCommandWithReadyWait( &returnCode, printerInfo.deviceAddress, USB_PRINTER_GRAPHICS_LINE, USB_DATA_POINTER_RAM(¶ms), sizeof(params.sLine), 0 ); WriteLine( 450, 410, &(notes[3][0]) ); params.sLine.x1 = 550; params.sLine.y1 = 415; params.sLine.x2 = 590; params.sLine.y2 = 430; USBHostPrinterCommandWithReadyWait( &returnCode, printerInfo.deviceAddress, USB_PRINTER_GRAPHICS_LINE, USB_DATA_POINTER_RAM(¶ms), sizeof(params.sLine), 0 ); params.sLine.x1 = 500; params.sLine.y1 = 415; params.sLine.x2 = 500; params.sLine.y2 = 540; USBHostPrinterCommandWithReadyWait( &returnCode, printerInfo.deviceAddress, USB_PRINTER_GRAPHICS_LINE, USB_DATA_POINTER_RAM(¶ms), sizeof(params.sLine), 0 ); #define TAO_UNIT 4 #define TAO_XL (PRINTER_PAGE_LANDSCAPE_WIDTH - 200) #define TAO_YT (PRINTER_PAGE_LANDSCAPE_HEIGHT - 200) #define TAO_XC (TAO_XL + TAU_UNIT * 12) #define TAO_YC (TAO_YL + TAU_UNIT * 12) USBHostPrinterCommandWithReadyWait( &returnCode, printerInfo.deviceAddress, USB_PRINTER_GRAPHICS_LINE_WIDTH, USB_NULL, PRINTER_LINE_WIDTH_NORMAL, 0 ); USBHostPrinterCommandWithReadyWait( &returnCode, printerInfo.deviceAddress, USB_PRINTER_GRAPHICS_LINE_TYPE, USB_NULL, PRINTER_LINE_TYPE_SOLID, 0 ); params.sArc.xL = TAO_XL; params.sArc.yT = TAO_YT; params.sArc.xR = TAO_XL + TAO_UNIT * 24; params.sArc.yB = TAO_YT + TAO_UNIT * 24; params.sArc.r1 = 0; params.sArc.r2 = TAO_UNIT * 12; params.sArc.octant = 0xF0; USBHostPrinterCommandWithReadyWait( &returnCode, printerInfo.deviceAddress, USB_PRINTER_GRAPHICS_ARC, USB_DATA_POINTER_RAM(¶ms), sizeof(params.sArc), 0 ); params.sCircle.x = TAO_XL + TAO_UNIT * 12; params.sCircle.y = TAO_YT + TAO_UNIT * 18; params.sCircle.r = TAO_UNIT * 6; USBHostPrinterCommandWithReadyWait( &returnCode, printerInfo.deviceAddress, USB_PRINTER_GRAPHICS_CIRCLE_FILLED, USB_DATA_POINTER_RAM(¶ms), sizeof(params.sCircle), 0 ); USBHostPrinterCommandWithReadyWait( &returnCode, printerInfo.deviceAddress, USB_PRINTER_GRAPHICS_COLOR, USB_NULL, PRINTER_COLOR_WHITE, 0 ); params.sCircle.x = TAO_XL + TAO_UNIT * 12; params.sCircle.y = TAO_YT + TAO_UNIT * 6; params.sCircle.r = TAO_UNIT * 6; USBHostPrinterCommandWithReadyWait( &returnCode, printerInfo.deviceAddress, USB_PRINTER_GRAPHICS_CIRCLE_FILLED, USB_DATA_POINTER_RAM(¶ms), sizeof(params.sCircle), 0 ); params.sCircle.x = TAO_XL + TAO_UNIT * 12; params.sCircle.y = TAO_YT + TAO_UNIT * 18; params.sCircle.r = TAO_UNIT; USBHostPrinterCommandWithReadyWait( &returnCode, printerInfo.deviceAddress, USB_PRINTER_GRAPHICS_CIRCLE_FILLED, USB_DATA_POINTER_RAM(¶ms), sizeof(params.sCircle), 0 ); USBHostPrinterCommandWithReadyWait( &returnCode, printerInfo.deviceAddress, USB_PRINTER_GRAPHICS_COLOR, USB_NULL, PRINTER_COLOR_BLACK, 0 ); params.sCircle.x = TAO_XL + TAO_UNIT * 12; params.sCircle.y = TAO_YT + TAO_UNIT * 6; params.sCircle.r = TAO_UNIT; USBHostPrinterCommandWithReadyWait( &returnCode, printerInfo.deviceAddress, USB_PRINTER_GRAPHICS_CIRCLE_FILLED, USB_DATA_POINTER_RAM(¶ms), sizeof(params.sCircle), 0 ); params.sCircle.x = TAO_XL + TAO_UNIT * 12; params.sCircle.y = TAO_YT + TAO_UNIT * 12; params.sCircle.r = TAO_UNIT * 12; USBHostPrinterCommandWithReadyWait( &returnCode, printerInfo.deviceAddress, USB_PRINTER_GRAPHICS_CIRCLE, USB_DATA_POINTER_RAM(¶ms), sizeof(params.sCircle), 0 ); } // Terminate UART2PrintString( "Demo complete.\r\n" ); USBHostPrinterCommandWithReadyWait( &returnCode, printerInfo.deviceAddress, USB_PRINTER_JOB_STOP, USB_NULL, 0, 0 ); } } } } } }