s3c2440 usb-host驱动HP彩色打印机程序片断:
U8 PCL_RESET_CMD[] ={0x1b,'%','-','1','2','3','4','5','X',0};
U8 PCL_END_CMD[] ={0x1b,'E',0};
U8 PCL_PageSize_cmd[]={0x1b,'&','l','0','O',0};
U8 PCL_PrtDir_cmd[] ={0x1b,'&','l','2','6','A',0};
U8 prt_content_buf[]="HP Printer test!!!";
void USB_PCL_Command(U8 *str)
{
U8 pcl_head[]={0x1b,0};
usb_host_SendString(pcl_head);
usb_host_SendString(str);
}
/****************************************************************************
* 功 能:USB打印机打印文字起始位置(units:PCL) 用于精确定位
*---------------------------------------------------------------------------*
* 入口参数:x1:起始点横坐标;y1:起始点纵坐标
* 出口参数:nil
****************************************************************************/
void USB_Text_Posn(U8 x1,U8 y1)
{
U8 psn_buf[13]={0x1B,'&','a',0xff,0xff,'C',0x1B,'&','a',0xff,0xff,'R',0};
//PCL Command "Esc&a#C"
psn_buf[3]=x1/10+0x30; //水平位置
psn_buf[4]=x1%10+0x30;
//PCL Command "Esc&a#R"
psn_buf[9]=y1/10+0x30; //垂直位置
psn_buf[10]=y1%10+0x30;
usb_host_SendString(psn_buf); //发送12个数据
}
/****************************************************************************
* 功 能:USB打印机打印字符串
*---------------------------------------------------------------------------*
* 入口参数:str:字符串指针
* 出口参数:nil
****************************************************************************/
void USB_PCL_String(U8 *str)
{
usb_host_SendString(str);
}
void USB_Printer_Test(void)
{
int i;
usb_host_SendString(PCL_RESET_CMD);
usb_host_SendString(PCL_END_CMD);
usb_host_SendString(PCL_PageSize_cmd); //A4
usb_host_SendString(PCL_PrtDir_cmd); //Page Orientation:Portrait
USB_PCL_Command("(s1P"); //Font:To specify proportional spacing
USB_PCL_Command("(s22V"); //Font Height:22
USB_PCL_Command("(s3B"); //Font:Bold
USB_Text_Posn(25,5);
USB_PCL_String("HP Photosmart D5368 Print Test");
USB_PCL_Command("(s0P"); //Font:To specify fixed spacing
USB_PCL_Command("(s12V"); //Font Height:12
USB_PCL_Command("(s0B"); //Font:Medium
USB_Text_Posn(10,7);
for(i=0;i<8;i++)
USB_PCL_String("----------");
USB_Text_Posn(10,15);
for(i=0x30;i<0x3A;i++) //0~9
usb_host_SendByte(i);
USB_Text_Posn(10,16);
for(i=0x61;i<0x7B;i++) //a~z
usb_host_SendByte(i);
USB_Text_Posn(10,17);
for(i=0x41;i<0x5B;i++) //A~Z
usb_host_SendByte(i);
USB_Text_Posn(10,18);
USB_PCL_String("S3C2440 USB HOST PRINTER TEST END !!!");
usb_host_SendString(PCL_RESET_CMD);
usb_host_SendString(PCL_END_CMD);
}
void About_USB_Print(void)
{
int i;
usb_host_SendString(PCL_RESET_CMD);
usb_host_SendString(PCL_END_CMD);
usb_host_SendString(PCL_PageSize_cmd); //A4
usb_host_SendString(PCL_PrtDir_cmd); //Page Orientation:Portrait
USB_PCL_Command("(s1P"); //Font:To specify proportional spacing
USB_PCL_Command("(s22V"); //Font Secondary Height:22
USB_PCL_Command("(s3B"); //Font:Bold
USB_Text_Posn(50,5);
USB_PCL_String("AutoDist About");
USB_PCL_Command("(s0P"); //Font:To specify fixed spacing
USB_PCL_Command("(s12V"); //Font Height:12
USB_PCL_Command("(s0B"); //Font:Medium
USB_Text_Posn(10,7);
for(i=0;i<6;i++)
USB_PCL_String("----------");
USB_PCL_Command("(s1P"); //Font:To specify proportional spacing
USB_PCL_Command("(s14V"); //Font Height:14
USB_PCL_Command("(s3B"); //Font:Bold
USB_Text_Posn(10,13);
USB_PCL_String("About Dialog");
USB_PCL_Command("(s0P"); //Font:To specify fixed spacing
USB_PCL_Command("(s12V"); //Font Height:12
USB_PCL_Command("(s0B"); //Font:Medium
USB_Text_Posn(33,13);
USB_PCL_String("Firmware Revison: V1.0");
USB_Text_Posn(60,13);
USB_PCL_String("Boot: V3.0");
USB_Text_Posn(10,17);
USB_PCL_String("CPU Board : Core-S3C2440A ");
USB_Text_Posn(55,17);
USB_PCL_String("rev.: B1");
USB_Text_Posn(10,19);
USB_PCL_String("Manufacturer name: Embedded_Systerm");
USB_Text_Posn(55,19);
USB_PCL_String("date: 25 JUL 2009");
USB_Text_Posn(10,21);
USB_PCL_String("Test bench ID : NONE");
USB_Text_Posn(55,21);
USB_PCL_String("Test revision number: 0");
USB_Text_Posn(10,25);
USB_PCL_String("Master Control Board : MB_R091158");
USB_Text_Posn(10,28);
USB_PCL_String("Temperature Control Board: TB_R0911585");
USB_Text_Posn(10,31);
USB_PCL_String("Heating Control Board : HB_R0911643");
usb_host_SendString(PCL_RESET_CMD);
usb_host_SendString(PCL_END_CMD);
} |