CCS C Software and Maintenance Offers
FAQFAQ   FAQForum Help   FAQOfficial CCS Support   SearchSearch  RegisterRegister 

ProfileProfile   Log in to check your private messagesLog in to check your private messages   Log inLog in 

CCS does not monitor this forum on a regular basis.

Please do not post bug reports on this forum. Send them to CCS Technical Support

USB HID send first data

 
Post new topic   Reply to topic    CCS Forum Index -> General CCS C Discussion
View previous topic :: View next topic  
Author Message
SuperDave



Joined: 22 May 2008
Posts: 63
Location: Madison, TN

View user's profile Send private message Visit poster's website

USB HID send first data
PostPosted: Wed Jun 19, 2013 1:23 pm     Reply with quote

Delphi on the PC, CCS C compiler for 18LF13K50
Enumeration works fine. Trying to write some data to endpoint 0

Delphi
Code:
MyDevice.WriteFile(SendUSB, 5, Written)  // actual data 0,1,2,3,4
returns true (ie. success, 0 is endpoint zero, next four bytes are simple data, written changes from 0 before to 5 after)


CCS C - 18LF13K50 running and enumerated
Code:
void main()  {
  enable_interrupts(INT_USB);  //not sure needed
  enable_interrupts(global); 
  usb_init();   
  testdelay := 1;   //to see scope change on C1
  while (1) {
    output_toggle(Pin_C1);
    delay_ms(testdelay);
    if (usb_kbhit(0)) {  //should be true if endpoint 0 has data
   testdelay = 2;
    }      
  }  //end while (1)      
}  //end main   

TestDelay does not change from 1mS to 2mS. ie. usb_kbhit(0) is not triggering. Any idea why?

Configuration
Code:

#ifndef USB_CONFIG_HID_TX_SIZE
   //valid range is 0-255
   #define USB_CONFIG_HID_TX_SIZE   4  //   
#endif

#ifndef USB_CONFIG_HID_RX_SIZE
   //valid range is 0-255
   #define USB_CONFIG_HID_RX_SIZE   4     //   
#endif
asmboy



Joined: 20 Nov 2007
Posts: 2128
Location: albany ny

View user's profile Send private message AIM Address

PostPosted: Wed Jun 19, 2013 3:54 pm     Reply with quote

Quote:

Enumeration works fine.

on WHAT OS and version might that be ??

also -you post so little code, ( and no includes - etc etc )
- that I don't see how anyone will be able to help you solve this.
Ttelmah



Joined: 11 Mar 2010
Posts: 19504

View user's profile Send private message

PostPosted: Thu Jun 20, 2013 12:37 am     Reply with quote

USB endpoint 0, is reserved in USB for device control transfers.
Can't have less than 8 bytes. Normally controls things like DTR etc..
Your normal transfers cannot use this endpoint.

Best Wishes
SuperDave



Joined: 22 May 2008
Posts: 63
Location: Madison, TN

View user's profile Send private message Visit poster's website

PostPosted: Thu Jun 20, 2013 5:12 am     Reply with quote

Thank you. Your statement "Can't have less than 8 bytes." is at odds with the configure comment "//valid range is 0-255" Is endpoint 0 restricted to 8 bytes?
Ttelmah



Joined: 11 Mar 2010
Posts: 19504

View user's profile Send private message

PostPosted: Thu Jun 20, 2013 7:26 am     Reply with quote

Yes.
It is in the USB spec.

The very first packet sent to any USB device, is a 'setup' packet on endpoint 0, and is 8 bytes in size. This happens as the first part of enumeration. EP0, is reserved for command packets.

Best Wishes
Display posts from previous:   
Post new topic   Reply to topic    CCS Forum Index -> General CCS C Discussion All times are GMT - 6 Hours
Page 1 of 1

 
Jump to:  
You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum
You cannot vote in polls in this forum


Powered by phpBB © 2001, 2005 phpBB Group