diff options
author | Keith Packard <keithp@keithp.com> | 2012-11-30 16:01:07 -0800 |
---|---|---|
committer | Keith Packard <keithp@keithp.com> | 2012-11-30 16:01:07 -0800 |
commit | 0b65402361f36a0c722977bcb63edb26fda0db28 (patch) | |
tree | 435d23c147829f11aac67fd6c30c74dd96f76e8e /src/cc1111/ao_usb.c | |
parent | 0fa9ce23dd63846337872d6d666a469512614d07 (diff) |
altos: Make stdio 8-bit clean by making pollchar return int
We were stealing one value (0xff) in the return value from pollchar to
indicate 'not ready yet'. Instead of doing that, use the integer value
-1 and have pollchar return an int instead of a char. That
necessitated cleaning a few other bits to make sure that 0xff wouldn't
get promoted to -1 on accident.
Signed-off-by: Keith Packard <keithp@keithp.com>
Diffstat (limited to 'src/cc1111/ao_usb.c')
-rw-r--r-- | src/cc1111/ao_usb.c | 12 |
1 files changed, 6 insertions, 6 deletions
diff --git a/src/cc1111/ao_usb.c b/src/cc1111/ao_usb.c index ce26e808..81e9074e 100644 --- a/src/cc1111/ao_usb.c +++ b/src/cc1111/ao_usb.c @@ -382,19 +382,19 @@ ao_usb_putchar(char c) __critical __reentrant ao_usb_in_send(); } -char +int ao_usb_pollchar(void) __critical { - char c; + uint8_t c; if (ao_usb_out_bytes == 0) { USBINDEX = AO_USB_OUT_EP; if ((USBCSOL & USBCSOL_OUTPKT_RDY) == 0) - return AO_READ_AGAIN; + return -1; ao_usb_out_bytes = (USBCNTH << 8) | USBCNTL; if (ao_usb_out_bytes == 0) { USBINDEX = AO_USB_OUT_EP; USBCSOL &= ~USBCSOL_OUTPKT_RDY; - return AO_READ_AGAIN; + return -1; } } --ao_usb_out_bytes; @@ -409,9 +409,9 @@ ao_usb_pollchar(void) __critical char ao_usb_getchar(void) __critical { - char c; + int c; - while ((c = ao_usb_pollchar()) == AO_READ_AGAIN) + while ((c = ao_usb_pollchar()) == -1) ao_sleep(&ao_stdin_ready); return c; } |