projects
/
fw
/
altos
/ blobdiff
commit
grep
author
committer
pickaxe
?
search:
re
summary
|
shortlog
|
log
|
commit
|
commitdiff
|
tree
raw
|
inline
| side by side
altos/stm: Make flash loader work with either 8MHz or 16MHz xtal
[fw/altos]
/
src
/
avr
/
ao_usb_avr.c
diff --git
a/src/avr/ao_usb_avr.c
b/src/avr/ao_usb_avr.c
index 2ef546c98dc2d4d1f462bb2c042c9c9885a8df85..41d3c1becbf44fbb3f47480d172ae770a528c869 100644
(file)
--- a/
src/avr/ao_usb_avr.c
+++ b/
src/avr/ao_usb_avr.c
@@
-3,7
+3,8
@@
*
* This program is free software; you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
*
* This program is free software; you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
- * the Free Software Foundation; version 2 of the License.
+ * the Free Software Foundation; either version 2 of the License, or
+ * (at your option) any later version.
*
* This program is distributed in the hope that it will be useful, but
* WITHOUT ANY WARRANTY; without even the implied warranty of
*
* This program is distributed in the hope that it will be useful, but
* WITHOUT ANY WARRANTY; without even the implied warranty of
@@
-46,7
+47,7
@@
static __xdata uint8_t ao_usb_ep0_out_len;
static __xdata uint8_t *__xdata ao_usb_ep0_out_data;
static __xdata uint8_t ao_usb_in_flushed;
static __xdata uint8_t *__xdata ao_usb_ep0_out_data;
static __xdata uint8_t ao_usb_in_flushed;
-
static __xdata uint8_t
ao_usb_running;
+
__xdata uint8_t
ao_usb_running;
static __xdata uint8_t ao_usb_configuration;
static __xdata uint8_t ueienx_0;
static __xdata uint8_t ao_usb_configuration;
static __xdata uint8_t ueienx_0;
@@
-135,7
+136,7
@@
ISR(USB_GEN_vect)
}
}
-
__xdata static
struct ao_usb_line_coding ao_usb_line_coding = {115200, 0, 0, 8};
+struct ao_usb_line_coding ao_usb_line_coding = {115200, 0, 0, 8};
/* Walk through the list of descriptors and find a match
*/
/* Walk through the list of descriptors and find a match
*/
@@
-411,7
+412,7
@@
ao_usb_ep0(void)
/* Wait for a free IN buffer */
static void
/* Wait for a free IN buffer */
static void
-ao_usb_in_wait(void)
+
_
ao_usb_in_wait(void)
{
for (;;) {
/* Check if the current buffer is writable */
{
for (;;) {
/* Check if the current buffer is writable */
@@
-419,7
+420,6
@@
ao_usb_in_wait(void)
if (UEINTX & (1 << RWAL))
break;
if (UEINTX & (1 << RWAL))
break;
- cli();
/* Wait for an IN buffer to be ready */
for (;;) {
UENUM = AO_USB_IN_EP;
/* Wait for an IN buffer to be ready */
for (;;) {
UENUM = AO_USB_IN_EP;
@@
-430,24
+430,24
@@
ao_usb_in_wait(void)
}
/* Ack the interrupt */
UEINTX &= ~(1 << TXINI);
}
/* Ack the interrupt */
UEINTX &= ~(1 << TXINI);
- sei();
}
}
/* Queue the current IN buffer for transmission */
static void
}
}
/* Queue the current IN buffer for transmission */
static void
-ao_usb_in_send(void)
+
_
ao_usb_in_send(void)
{
UENUM = AO_USB_IN_EP;
UEINTX &= ~(1 << FIFOCON);
}
void
{
UENUM = AO_USB_IN_EP;
UEINTX &= ~(1 << FIFOCON);
}
void
-ao_usb_flush(void)
__critical
+ao_usb_flush(void)
{
if (!ao_usb_running)
return;
{
if (!ao_usb_running)
return;
+ ao_arch_block_interrupts();
/* Anytime we've sent a character since
* the last time we flushed, we'll need
* to send a packet -- the only other time
/* Anytime we've sent a character since
* the last time we flushed, we'll need
* to send a packet -- the only other time
@@
-457,18
+457,20
@@
ao_usb_flush(void) __critical
*/
if (!ao_usb_in_flushed) {
ao_usb_in_flushed = 1;
*/
if (!ao_usb_in_flushed) {
ao_usb_in_flushed = 1;
- ao_usb_in_wait();
- ao_usb_in_send();
+
_
ao_usb_in_wait();
+
_
ao_usb_in_send();
}
}
+ ao_arch_release_interrupts();
}
void
}
void
-ao_usb_putchar(char c)
__critical __reentrant
+ao_usb_putchar(char c)
{
if (!ao_usb_running)
return;
{
if (!ao_usb_running)
return;
- ao_usb_in_wait();
+ ao_arch_block_interrupts();
+ _ao_usb_in_wait();
/* Queue a byte */
UENUM = AO_USB_IN_EP;
/* Queue a byte */
UENUM = AO_USB_IN_EP;
@@
-476,11
+478,12
@@
ao_usb_putchar(char c) __critical __reentrant
/* Send the packet when full */
if ((UEINTX & (1 << RWAL)) == 0)
/* Send the packet when full */
if ((UEINTX & (1 << RWAL)) == 0)
- ao_usb_in_send();
+
_
ao_usb_in_send();
ao_usb_in_flushed = 0;
ao_usb_in_flushed = 0;
+ ao_arch_release_interrupts();
}
}
-
static
int
+int
_ao_usb_pollchar(void)
{
uint8_t c;
_ao_usb_pollchar(void)
{
uint8_t c;
@@
-517,25
+520,15
@@
_ao_usb_pollchar(void)
return c;
}
return c;
}
-int
-ao_usb_pollchar(void)
-{
- int c;
- cli();
- c = _ao_usb_pollchar();
- sei();
- return c;
-}
-
char
char
-ao_usb_getchar(void)
__critical
+ao_usb_getchar(void)
{
int c;
{
int c;
-
cli
();
+
ao_arch_block_interrupts
();
while ((c = _ao_usb_pollchar()) == AO_READ_AGAIN)
ao_sleep(&ao_stdin_ready);
while ((c = _ao_usb_pollchar()) == AO_READ_AGAIN)
ao_sleep(&ao_stdin_ready);
-
sei
();
+
ao_arch_release_interrupts
();
return c;
}
return c;
}
@@
-668,5
+661,5
@@
ao_usb_init(void)
#if USB_DEBUG
ao_add_task(&ao_usb_echo_task, ao_usb_echo, "usb echo");
#endif
#if USB_DEBUG
ao_add_task(&ao_usb_echo_task, ao_usb_echo, "usb echo");
#endif
- ao_add_stdio(ao_usb_pollchar, ao_usb_putchar, ao_usb_flush);
+ ao_add_stdio(
_
ao_usb_pollchar, ao_usb_putchar, ao_usb_flush);
}
}