Search found 102 matches

by blargg
Tue Nov 26, 2013 9:15 am
Forum: V-USB
Topic: Using generic signal diodes instead of zeners
Replies: 3
Views: 3227

Using generic signal diodes instead of zeners

Using generic signal diodes instead of zeners I work on a tight budget and don't have 3.6V zener diodes (low-current or otherwise) and wanted to build the hardware side of V-USB myself (so far I've only programmed with V-USB on USBASP programmers by reprogramming them with my own programs). I decide...
by blargg
Mon Nov 25, 2013 11:20 pm
Forum: V-USB
Topic: How Do You Check CRC16 From Application?
Replies: 2
Views: 2500

Re: How Do You Check CRC16 From Application?

Or, if wasting a few cycles isn't a problem (and you know that len < 256-2), uchar usbFunctionWrite( uchar* data, uchar len ) { if ( usbCrc16( data, len + 2 ) != 0x4FFE ) { // CRC error } ... } This relies on the property that the checksum of some data with its usb CRC appended is 0x4FFE, which is j...
by blargg
Mon Nov 25, 2013 8:15 pm
Forum: V-USB
Topic: Entirely polled V-USB? [yes, it works!]
Replies: 18
Views: 10296

Re: Entirely polled V-USB? [yes, it works!]

Yes, you're way off This doesn't alter USB behavior, rather simply allows one to avoid using hardware interrupts on the AVR side. The main use is in a bootloader on an AVR without a separate vector table, where you want to preserve the user program's vectors and not hijack the INT0 handler (or rathe...
by blargg
Mon Nov 25, 2013 4:44 am
Forum: V-USB
Topic: Entirely polled V-USB? [yes, it works!]
Replies: 18
Views: 10296

Re: Entirely polled V-USB?

I solved the mystery, and now feel much more confident about polling. I now see it as a legitimate alternative to an interrupt where you know the timing of your code well and aren't doing much. It might help for really constrained systems. Here is what I found with a scope. First, I modified the cod...
by blargg
Sun Nov 24, 2013 12:06 am
Forum: V-USB
Topic: Entirely polled V-USB? [yes, it works!]
Replies: 18
Views: 10296

Re: Entirely polled V-USB?

OK, after thinking it was working, then that I was merely running the bootloader and being fooled, I'm sure it's working now. The critical change was a check for the interrupt in the small loop in usbPoll(). It's odd because that loop only checks a register, so the loop should only take a few micros...
by blargg
Sat Nov 23, 2013 9:45 pm
Forum: V-USB
Topic: Entirely polled V-USB? [yes, it works!]
Replies: 18
Views: 10296

Re: Entirely polled V-USB?

Yeah, I was going to just poll the port when I realized that the interrupt flag tells us whenever the interesting conditions occurred without having to dig around to see which edge it wants the interrupt on, etc. (and as you noted, past-tense as well; will have to try that as a diagnostic). I am als...
by blargg
Sat Nov 23, 2013 8:54 pm
Forum: V-USB
Topic: Entirely polled V-USB? [yes, it works!]
Replies: 18
Views: 10296

Re: Entirely polled V-USB?

The basic approach (with interrupts always disabled of course, and the interrupt handler modified to end in RET instead of RETI): for ( ;; ) { USB_INTR_PENDING = 1<<USB_INTR_PENDING_BIT; while ( !(USB_INTR_PENDING & (1<<USB_INTR_PENDING_BIT)) ) { } USB_INTR_PENDING = 1<<USB_INTR_PENDING_BIT; INT...
by blargg
Tue Nov 19, 2013 9:49 pm
Forum: V-USB
Topic: Entirely polled V-USB? [yes, it works!]
Replies: 18
Views: 10296

Entirely polled V-USB? [yes, it works!]

Any reasons an entirely polled V-USB wouldn't work? I gave it a try but got host errors (polling the interrupt flag between usbPoll() calls). Fundamentally, you've got the loop that calls usbPoll(), and periodic interrupts to run code that handles the timing-critical I/O. The I/O interrupts come at ...
by blargg
Sat Nov 16, 2013 4:27 am
Forum: V-USB
Topic: USBaspLoader 18-byte code reduction
Replies: 1
Views: 1703

USBaspLoader 18-byte code reduction

I shaved 18 bytes off USBaspLoader without removing functionality (at least for avr-gcc 4.5.3). This is small but given that out of the box it's around 2028 bytes, very close to the 2048 limit, this might be critical to someone. One change involved eliminating the wdt_reset() call, which seems fine ...
by blargg
Thu Nov 14, 2013 10:34 pm
Forum: V-USB
Topic: schar and uchar macros in usbdrv.h
Replies: 1
Views: 2203

schar and uchar macros in usbdrv.h

Perhaps a minor issue, but I'd rather mention it than keep quiet. I am thrilled with V-USB so small things like this stand out more. I am also aware that there's a feedback channel, but I'd rather discuss this with other users rather than merely have it be a request. The schar and uchar macros can c...
by blargg
Thu Nov 14, 2013 10:24 pm
Forum: V-USB
Topic: Char signedness bug in usbGenericSetInterrupt() [fixed]
Replies: 3
Views: 2558

Re: V-USB assumes that char is signed?!?

OK, so it does not assume that char is signed, and what I found today was a bug and happened to be fixed two days ago. Hah.
by blargg
Thu Nov 14, 2013 10:03 pm
Forum: V-USB
Topic: Char signedness bug in usbGenericSetInterrupt() [fixed]
Replies: 3
Views: 2558

Char signedness bug in usbGenericSetInterrupt() [fixed]

static void usbGenericSetInterrupt(uchar *data, uchar len, usbTxStatus_t *txStatus) { uchar *p; char i; [...] i = len; do{ /* if len == 0, we still copy 1 byte, but that's no problem */ *p++ = *data++; }while(--i > 0); /* loop control at the end is 2 bytes shorter than at beginning */ [...] It sure...