Here is a simple echo demo using the JTR-Honken open source USB stack. It has been tested on the IR Toy (18F2550) and the Bus Pirate v4 (24FJ256GB106).
A lot of things are still a bit messy, especially the USB read buffer ported from the IR Toy, but it works! I hope by releasing this simple package we can get some other developers involved.
The key to a new port:
*Change hardware define in HardwareProfile.h, add a LED pin for your hardware
*Add setup code for your hardware in void SetupBoard(void) in main.c
*Add basic USB info for your hardware in cdc_config.h (copy an old one and modify if needed)
*Add your config words to configWords.h
If you try it please contribute any additional PIC support.
New vb:
*Double buffer output demo
*Interrupts (pic24F) demo
New vc:
*include fixes
*service loop fixes
Problems:
*on PIC 24F it will not work the first time (device error). Hit reset and it connects. This is consistent.
*on PIC 24F with interrupts enabled it will be device error about 2 out of 10 resets
Fİrst I tried to compile it, the compiler gave all sorts of weird warnings. Especially about some comments (/* stuff, I really didn't care at that time), but my computer didn't recognize the device when I plug it in.
Then I used the supplied hex file with my BPv4, my computer (Vista) does not recognize the device when it is directly connected.
However, when I pressed "normal" button while plugging in. It recognized, installed drivers and assigned a COM port automatically.
Connected with PuTTY at baud rate 115200, echo is good, no glitches. Pressing "enter" puts the cursor at the beginning of the line.
Yay!!! :)
I get the comments warnings too.
Strange about the button thing, hum...
For me it is unrecognized when first plugged in. Pressing reset gets it to connect.
Hum, maybe a delay is needed?
Oh yeah, sorry about that. I did the reset cycle with "normal" button pressed. This time I really plugged in while pressing "normal", nothing happened. Then I pressed reset and it worked.
There should be a solution. I'll start looking around. Will you be at IRC by any chance?
Yeah, noticed that too. Quick plug and unplug will make it work too. I'm not worried because I can keep developing the Bus Pirate firmware because I only use ICD2 to reset and it works every time :)
Yeah, I'll jump in IRC.
Also - I noticed it doesn't do it on the 18F version.
Also - no amount of delay anywhere in the setup fixes it...
[quote author="ian"]I get the comments warnings too.
Strange about the button thing, hum...
For me it is unrecognized when first plugged in. Pressing reset gets it to connect.
Hum, maybe a delay is needed?[/quote]
Isn't the brown-out protection and power on reset settings (config word) messing with you? A delay would temporary fix this.
Saw your update so i guess this isnt the issue :)
how about a delay after initing the usbhardware? perhaps the bus needs some time to stabilize.
There's an updated package attached above.
[quote author="ian"]There's an updated package attached above.[/quote]
hex file in the vb package works on my Vista PC with BPv4.
vc uploaded with include fixes.
Coming soon. A whole new, documented, CDC stack with easy to use API.
inByte = getc_cdc();
putc_cdc(inByte);
With automatic double buffering, ZLP handling and timeout flush (adjustable in milliseconds increments), doesn't get much simpler than this. The new API also hides the low level CDC handling so that if/when hardware ping-pong is added (required for the PIC32 port) this will be invisible to the user app. It also runs equally well with interrupt mode or polled mode.
Very cool. I'm going to talk about [s:]your[/s:] JTR and Honken's work on the stack, as well as the Microchip editorial at the Open Hardware Summit this Thursday.
I think JTR deserves to be mentioned as well. He has found and corrected a lot of bugs while I have almost dropped the ball lately due to lack of time.
Sorry about that, I edited it to remove any confusion.