nxpUSBLib printer class

cancel
Showing results for 
Show  only  | Search instead for 
Did you mean: 

nxpUSBLib printer class

1,634 Views
lpcware
NXP Employee
NXP Employee
Content originally posted in LPCWare by elmira.n.f on Sat Jun 28 03:17:51 MST 2014
Hi
I downloaded the nxpUSBlib v0.98b for make  usb printer communication with lpc1754.
and print the ticket by micro (lpc1754 or 1768).

right now I don't know how to use this lib in my code, in keil.
any body can help me?
I really dizzy and need help.

best regards.
Labels (1)
0 Kudos
Reply
5 Replies

1,370 Views
lpcware
NXP Employee
NXP Employee
Content originally posted in LPCWare by elmira.n.f on Sun Jul 13 01:32:59 MST 2014

Quote:

Keil don't provide enough information to implement host for "USB Device Class" yet.
There is no working example for this option. It means, they haven't finished this option yet.


I know they haven't finish this option, I try to wrote it by changing the MSC and compatible it for printer class, by reading the printer class document on usb.org and find the information of my printer by USBLyzer.


Quote:

No one has misled you, except for your "sixth sense" ;-)
Isn't it the time when you should learn your "sixth sense" isn't reliable at all?


may be sixth sense is reliable but my think is fact, sixth sense means some thing not fact right now but you feel it. ;-)
because of my research and find some code and some way(!) I don't know which one is true! :~


Quote:

Huh?
I've given enough help. Did you try it?



Yes sure you helped me ,I know and again I'm saying you thank you so much. :)

I wrote two post but I don't know what happened for my second post(it hapend may be because of my internet!!!)

Certainly I try this solution but I gave some problem:
when I run this program on my board it doesn't work and print any paper, I see 2problem:

1- Some times in Host_EnumDev()  function, program still in loop:
while (!HOST_RhscIntr);
and it doesn't exit from this while.

2- if exit from this while and continues the program by placing break point I found that EDBulkOut->Control isn't initialize and this value still on 0x00000000

EDBulkOut->Control = 1                       |              /* USB address */
                           (2     << 7)                  |             /* Endpoint address */
                          (1                     << 11) |             /* direction */
                          (64 << 16);                               /* EP MaxPkt Size */


my main program:
int main()
{
     int32_t i , j;
    unsigned char b;
    int32_t  rc;
    uint32_t  numBlks, blkSize;
    uint8_t  inquiryResult[INQUIRY_LENGTH];

    LPC_RTC->CCR = 0x11;
    /* SystemClockUpdate() updates the SystemFrequency variable */
    SystemClockUpdate();

    Host_Init();               /* Initialize the lpc17xx host controller                                    */
    rc = Host_EnumDev();       /* Enumerate the device connected                                            */
    if (rc == OK)


      EDBulkOut->Control = 1                            |  /* USB address */
                          (2     << 7)  |  /* Endpoint address */
                          (1                     << 11) |  /* direction */
                          (64 << 16);   /* EP MaxPkt Size */
      // fill TDBuffer with print data, here

     TDBuffer[0] = 0x1B;   /*initialize printer*/
     TDBuffer[1] = 0x40;

     TDBuffer[2] = 0x1B;  /*bit image mode*/
     TDBuffer[3] = 0x2A;
     TDBuffer[4] = 33;
     TDBuffer[5] = 10;     
      for(j = 0; j < 5; j++)   /*my printer's data*/
      {
        TDBuffer[6 + (2*j)] = 0x11;
  TDBuffer[6 + (2*j) + 1] = 0x00;
       }
      TDBuffer[16] = 0x0D ;
      TDBuffer[17] = 0x0A ;
     
     // send TDBuffer to the printer
      rc = Host_ProcessTD(EDBulkOut, TD_OUT, TDBuffer, 18);
     
    }
   
}

What should I do?

Thank you
0 Kudos
Reply

1,370 Views
lpcware
NXP Employee
NXP Employee
Content originally posted in LPCWare by Tsuneo on Wed Jul 09 12:09:31 MST 2014

Quote:
for MSC I use this easily (for initialize MSD use finit(":U0") function), but for printer class I try 3part of this but it did not get any results!!!


Keil don't provide enough information to implement host for "USB Device Class" yet.
There is no working example for this option. It means, they haven't finished this option yet.


Quote:
I think I got confused and misled!


No one has misled you, except for your "sixth sense" ;-)
Isn't it the time when you should learn your "sixth sense" isn't reliable at all?


Quote:
I humbly still need your help.


Huh?
I've given enough help. Did you try it?

Tsuneo
0 Kudos
Reply

1,370 Views
lpcware
NXP Employee
NXP Employee
Content originally posted in LPCWare by elmira.n.f on Tue Jul 08 05:21:36 MST 2014
Thank you so much for replying,
but I can not implement the printer class yet!!!

Are you know, can I use the RL in keil for printer class?
I use this for mass storage usb and easily run it, but now I don't know how to use this,because in usb_config.c->configuration wizard->class configuration,contain 3 part:
1-MSC
2-HID
3-USB Device Class
for MSC I use this easily (for initialize MSD use finit(":U0") function), but for printer class I try 3part of this but it did not get any results!!!

I think I got confused and misled!

I humbly still need your help.
0 Kudos
Reply

1,370 Views
lpcware
NXP Employee
NXP Employee
Content originally posted in LPCWare by Tsuneo on Tue Jul 01 08:17:43 MST 2014

Quote:
when I was using printer class I gave some error in common.h and endianness.h


As the default setting (C90), Keil does’t recognize "inline". Enable C99 option.
- Options - C/C++ tab - C99 Mode check box.


With quick look in nxpUSBlib v0.98b, there is no example for USB printer host, though the library has printer host class.

As the USB printer class is simple, you don’t need so much hustle to implement such a complicated library. You may start with simple "USBHostLite" example in this code bundle.

MCB1700 Sample Code Bundle for LPC17xx Peripherals using Keil's MDK-ARM
http://www.lpcware.com/content/nxpfile/mcb1700-sample-code-bundle-lpc17xx-peripherals-using-keils-md...

Using "USBHostLite", the code is written as follows.
- Host_Init() initializes the host controller and variables
- Host_EnumDev() enumerates the target printer
- Host_ProcessTD() sends print data over the bulk OUT Endpoint (EP)
int main()
{
    int32_t  rc;

    /* SystemClockUpdate() updates the SystemFrequency variable */
    SystemClockUpdate();

    Host_Init();            /* Initialize the lpc17xx host controller */
    rc = Host_EnumDev();    /* Enumerate the device connected         */

    if (rc == OK) {
        // fill Endpoint Descriptor
        EDBulkOut->Control = 1                            |  /* USB address */
                            (BULK_OUT_EP_NUBER     << 7)  |  /* Endpoint address */
                            (1                     << 11) |  /* direction */
                            (BULK_OUT_EP_MAXPACKET << 16);   /* EP MaxPkt Size */

       // fill TDBuffer with print data, here
       // send TDBuffer to the printer
       rc = Host_ProcessTD(EDBulkOut, TD_OUT, TDBuffer, print_length);
    }
    while (1);
}


In this discussion on the Keil forum, you’ll get many suggestions to implement printer host.
http://www.keil.com/forum/57021/

Tsuneo
0 Kudos
Reply

1,370 Views
lpcware
NXP Employee
NXP Employee
Content originally posted in LPCWare by elmira.n.f on Sun Jun 29 06:01:27 MST 2014
when I was using printer class I gave some error in common.h and endianness.h and I don't have any idea for solve this problem
please help me.

.\libraries\LPCUSBLib\Drivers\USB\../../Common/Endianness.h(397): error:  #20: identifier "inline" is undefined
.\libraries\LPCUSBLib\Drivers\USB\../../Common/Endianness.h(397): error:  #101: "uint16_t" has already been declared in the current scope
.\libraries\LPCUSBLib\Drivers\USB\../../Common/Endianness.h(397): error:  #65: expected a ";"
.\libraries\LPCUSBLib\Drivers\USB\../../Common/Endianness.h(398): error:  #20: identifier "inline" is undefined
.\libraries\LPCUSBLib\Drivers\USB\../../Common/Endianness.h(398): error:  #65: expected a ";"
.\libraries\LPCUSBLib\Drivers\USB\../../Common/Endianness.h(426): warning:  #12-D: parsing restarts here after previous syntax error
.\libraries\LPCUSBLib\Drivers\USB\../../Common/Endianness.h(427): error:  #20: identifier "inline" is undefined
.\libraries\LPCUSBLib\Drivers\USB\../../Common/Endianness.h(427): error:  #101: "uint32_t" has already been declared in the current scope
.\libraries\LPCUSBLib\Drivers\USB\../../Common/Endianness.h(427): error:  #65: expected a ";"
.\libraries\LPCUSBLib\Drivers\USB\../../Common/Endianness.h(450): warning:  #12-D: parsing restarts here after previous syntax error
.\libraries\LPCUSBLib\Drivers\USB\../../Common/Endianness.h(451): error:  #169: expected a declaration
.\libraries\LPCUSBLib\Drivers\USB\../../Common/Endianness.h(461): warning:  #12-D: parsing restarts here after previous syntax error
.\libraries\LPCUSBLib\Drivers\USB\../../Common/Endianness.h(462): warning:  #260-D: explicit type is missing ("int" assumed)
.\libraries\LPCUSBLib\Drivers\USB\../../Common/Endianness.h(462): error:  #65: expected a ";"
.\libraries\LPCUSBLib\Drivers\USB\../../Common/Common.h(243): warning:  #12-D: parsing restarts here after previous syntax error
.\libraries\LPCUSBLib\Drivers\USB\../../Common/Common.h(244): error:  #757: variable "inline" is not a type name
.\libraries\LPCUSBLib\Drivers\USB\../../Common/Common.h(244): error:  #101: "uint8_t" has already been declared in the current scope
.\libraries\LPCUSBLib\Drivers\USB\../../Common/Common.h(244): error:  #65: expected a ";"
.\libraries\LPCUSBLib\Drivers\USB\../../Common/Common.h(260): warning:  #12-D: parsing restarts here after previous syntax error
.\libraries\LPCUSBLib\Drivers\USB\../../Common/Common.h(261): warning:  #260-D: explicit type is missing ("int" assumed)
.\libraries\LPCUSBLib\Drivers\USB\../../Common/Common.h(261): error:  #65: expected a ";"
.\libraries\LPCUSBLib\Drivers\USB\../../Common/Common.h(310): warning:  #12-D: parsing restarts here after previous syntax error
.\libraries\LPCUSBLib\Drivers\USB\../../Common/Common.h(311): error:  #757: variable "inline" is not a type name
.\libraries\LPCUSBLib\Drivers\USB\../../Common/Common.h(311): error:  #101: "uint_reg_t" has already been declared in the current scope
.\libraries\LPCUSBLib\Drivers\USB\../../Common/Common.h(311): error:  #65: expected a ";"
.\libraries\LPCUSBLib\Drivers\USB\../../Common/Common.h(338): warning:  #12-D: parsing restarts here after previous syntax error
.\libraries\LPCUSBLib\Drivers\USB\../../Common/Common.h(339): warning:  #260-D: explicit type is missing ("int" assumed)
.\libraries\LPCUSBLib\Drivers\USB\../../Common/Common.h(339): error:  #65: expected a ";"
.\libraries\LPCUSBLib\Drivers\USB\../../Common/Common.h(364): warning:  #12-D: parsing restarts here after previous syntax error
.\libraries\LPCUSBLib\Drivers\USB\../../Common/Common.h(365): warning:  #260-D: explicit type is missing ("int" assumed)
.\libraries\LPCUSBLib\Drivers\USB\../../Common/Common.h(365): error:  #65: expected a ";"
.\libraries\LPCUSBLib\Drivers\USB\../../Common/Common.h(387): warning:  #12-D: parsing restarts here after previous syntax error
.\libraries\LPCUSBLib\Drivers\USB\../../Common/Common.h(388): warning:  #260-D: explicit type is missing ("int" assumed)
.\libraries\LPCUSBLib\Drivers\USB\../../Common/Common.h(388): error:  #65: expected a ";"
.\libraries\LPCUSBLib\Drivers\USB\Core/LPC/../Events.h(92): warning:  #12-D: parsing restarts here after previous syntax error
.\libraries\LPCUSBLib\Drivers\USB\Core/LPC/../Events.h(105): error:  #757: variable "uint8_t" is not a type name
.\libraries\LPCUSBLib\Drivers\USB\Core/LPC/../Events.h(105): error:  #757: variable "uint8_t" is not a type name
error type>(120): error:  #757: variable "uint8_t" is not a type name
error type>(134): error:  #757: variable "uint8_t" is not a type name
error type>(152): error:  #757: variable "uint8_t" is not a type name
.\libraries\LPCUSBLib\Drivers\USB\Core/LPC/../Events.h(153): error:  #757: variable "uint8_t" is not a type name
.\libraries\LPCUSBLib\Drivers\USB\Core/LPC/../Events.h(154): error:  #757: variable "uint8_t" is not a type name
error type>(164): error:  #757: variable "uint8_t" is not a type name
error type>(181): error:  #757: variable "uint8_t" is not a type name
0 Kudos
Reply