PDA

View Full Version : USB Endpoints



Squibcakes
- 7th February 2007, 07:57
Does anybody understand what end points are?

eg
USBIn endpoint,buffer,countvar, label
USBOut endpoint,buffer,count, label


Trying to get my head around this and not gettin very far :(

Squib

vacpress
- 7th February 2007, 08:32
The USB 2.0 specification from usb.org discuses endpoints.

mvs_sarma
- 7th February 2007, 10:52
Does anybody understand what end points are?

eg
USBIn endpoint,buffer,countvar, label
USBOut endpoint,buffer,count, label


Trying to get my head around this and not gettin very far :(

Squib

please try this

http://www.symbian.com/developer/techlib/v70sdocs/doc_source/reference/cpp/USBClient/SupportedTypeDirConstants.html

Bruce
- 7th February 2007, 22:59
Endpoints are just blocks of RAM on the device that are used for inbound
and outbound data exchange between the device & USB host.

Squibcakes
- 8th February 2007, 09:56
Still not getting it.

I guess what i am trying to ask is how do I know what value to set as an endpoint number? ie 0 1 2 or 3?

Squib

Bruce
- 8th February 2007, 15:32
With PBP, you have a boat-load of USB assembly language 'framework' files
that get included at compile time. One of these is the 'descriptor' file. This
one includes your endpoint initialization/setup info - along with tons of other
information.

; HID
; Endpoints Allocation
#define HID_INTF_ID 0x00
#define HID_UEP UEP1
#define HID_BD_OUT ep1Bo
#define HID_INT_OUT_EP_SIZE 8
#define HID_BD_IN ep1Bi
#define HID_INT_IN_EP_SIZE 8
#define HID_NUM_OF_DSC 1

If your 'Endpoints Allocation' section looks similar to the one above, then you
would issue USBIn 1, USBBuffer, blah, blah to use endpoint 1.

USBOut would also use endpoint 1.

PBP's USBIn & USBOut commands are pretty generic, and don't really do much
except call the .asm USB framework routines, and pass data. The real meat
of what's going on is handled by the assembler USB framework files.

It's a great deal to learn if you want to get 'really' familiar with USB - for sure.
The Microchip C18 'C' USB framework files are easier to understand than the
.asm files MeLabs ported over from C18. If you're not familiar with assembler,
you might find those easier to decipher.

Squibcakes
- 9th February 2007, 23:37
Thanks Bruce,

I'm away from my pic for a while but will look into it somemorewhen I get back....

Cheers
Squib

nimonia
- 9th April 2007, 11:52
this is just wat i understand about endpoints... wish to share.. i've been working on a usb keyboard from my previous company therefore kinda know a little bout how endpoint works... basicly endpoint 1 is used for setup and cofig and also for mass storage if i am not wrong... the rest is up to you to use and whether u have define its endpoint descriptor... for example u might have a keyboard with a bootloader probably for the display on the keyboard i.e. an lcd... u can use endpoint 2 for ur keyboard and proly endpoint 3 for communicating with the pc just for the bootloader or the lcd display for example.. its more like a databus but with different address for specific thigns.. checkout the HID usage tables from usb.org for more information on descriptor files and such... and if u have a usb hub build in to the keyboard then u can proly also have endpoint 4 for ur mouse for example..

regards..

dan

Squibcakes
- 10th May 2007, 01:35
Thanks nimonia,

Yeah I just use EP 1 for my usb programs and it seems to always work. There is a lot of stuff out there on USB, but most of it's jargon and doesn't explain it easily.

I too have been messing with a HID keyboard interface and almost have it working. ;)

I can mimic the Num lock, scroll lock, and caps lock leds on my test PCB when they're pressed on the main PC keyboard.

I can send the special keys (shift, control, GUI)

I can and send regular key chars but... I have a problem with the chars repeating. So if I press the key "J" for instances it keeps on sending, my program seems to be stuck in the DoUSBout out loop. I've tried sending a $00 code as a keystop but this doesn't work.

Have you run into this problem at all? Anyone else?
Cheers
Squib

----

OK I sussed this one out hrs after posting... ;) always the way!

nimonia
- 11th May 2007, 04:10
yeap.. happen to me the first time.. u said u send $00 keystop u mean as the USBout buffer right.. tht should do the trick.. but if it doesnt then proly it could be the simple things like maybe u were sending a variable out and u didnt clear the variable to $00... always clear after sending them once.. wat i do is clear before sending and after sending.. just a suggestion if it still repeating then proly its just a small routine mistake somewhere..

one mroe thing the scan key routine i did would check for special modifier keys first.. keep it in a variable then check for normal keys and add them to the variable.. then only u send it out..

Squibcakes
- 11th May 2007, 05:01
Hi,

Yep, thats exactly what I've been doing too. ;) It's great when the penny finally drops with this USB stuff!

Cheers
Squib

Kamikaze47
- 26th June 2007, 16:22
Thanks nimonia,

Yeah I just use EP 1 for my usb programs and it seems to always work. There is a lot of stuff out there on USB, but most of it's jargon and doesn't explain it easily.

I too have been messing with a HID keyboard interface and almost have it working. ;)

I can mimic the Num lock, scroll lock, and caps lock leds on my test PCB when they're pressed on the main PC keyboard.

I can send the special keys (shift, control, GUI)

I can and send regular key chars but... I have a problem with the chars repeating. So if I press the key "J" for instances it keeps on sending, my program seems to be stuck in the DoUSBout out loop. I've tried sending a $00 code as a keystop but this doesn't work.

Have you run into this problem at all? Anyone else?
Cheers
Squib

----

OK I sussed this one out hrs after posting... ;) always the way!

Squibcakes, could you post your code for using USBIN to receive the PC's packets with the keyboard LED status?

I'm also making a USB keyboard, and I've got the PIC->PC communication working perfectly, but struggling with the PC->PIC communication.

Thanks

sirnoname
- 27th June 2007, 18:45
look, here is a interrupt handler of keyboard LED on 16C745 / 765

' Define interrupt handler
DEFINE INTHAND usbint
' Assembly language interrupt handler
asm
; W, STATUS and PCLATH registers already saved, save FSR
usbint movf FSR, W
movwf fsave
; Check interrupt source and vector there
movlw high ServiceUSBInt
movwf PCLATH
btfsc PIR1, USBIF
call ServiceUSBInt
btfsc PIR2, USBIF
call ServiceUSBInt
; Restore saved registers
banksel UIR
movf 0xC8,w
clrf STATUS
movwf kbdLED
movf fsave, W
movwf FSR
movf psave, W
movwf PCLATH
swapf ssave, W
movwf STATUS
swapf wsave, F
swapf wsave, W

retfie ; Return from interrupt
endasm

before the kbdLED should be defined in Picbasic static (important !):
kbdLED VAR BYTE bank0 system

on 18F Chips the code have to be placed in the USB interrupt routine.
LEDs are using the EP0 control transfere.
To get pc->pic communication use a component device with a HID + Keyboard interface.