projects
/
fw
/
altos
/ blobdiff
commit
grep
author
committer
pickaxe
?
search:
re
summary
|
shortlog
|
log
|
commit
|
commitdiff
|
tree
raw
|
inline
| side by side
altos/telebt-v3.0: Flip CTS/RTS pins for BT module
[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 74bdea23ef8d5eb630dde4c59d390eaf276672ec..cb0455c2d1ac6886bad4846c8d0184ed2efeaf00 100644
(file)
--- a/
src/avr/ao_usb_avr.c
+++ b/
src/avr/ao_usb_avr.c
@@
-46,7
+46,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;
@@
-303,9
+303,6
@@
ao_usb_ep0_setup(void)
}
break;
case AO_USB_RECIP_INTERFACE:
}
break;
case AO_USB_RECIP_INTERFACE:
-#ifndef AVR
- #pragma disable_warning 110
-#endif
debug ("Interface setup packet\n");
switch(ao_usb_setup.request) {
case AO_USB_REQ_GET_STATUS:
debug ("Interface setup packet\n");
switch(ao_usb_setup.request) {
case AO_USB_REQ_GET_STATUS:
@@
-333,17
+330,17
@@
ao_usb_ep0_setup(void)
case AO_USB_TYPE_CLASS:
debug ("Class setup packet\n");
switch (ao_usb_setup.request) {
case AO_USB_TYPE_CLASS:
debug ("Class setup packet\n");
switch (ao_usb_setup.request) {
- case SET_LINE_CODING:
+ case
AO_USB_
SET_LINE_CODING:
debug ("set line coding\n");
ao_usb_ep0_out_len = 7;
ao_usb_ep0_out_data = (__xdata uint8_t *) &ao_usb_line_coding;
break;
debug ("set line coding\n");
ao_usb_ep0_out_len = 7;
ao_usb_ep0_out_data = (__xdata uint8_t *) &ao_usb_line_coding;
break;
- case GET_LINE_CODING:
+ case
AO_USB_
GET_LINE_CODING:
debug ("get line coding\n");
ao_usb_ep0_in_len = 7;
ao_usb_ep0_in_data = (uint8_t *) &ao_usb_line_coding;
break;
debug ("get line coding\n");
ao_usb_ep0_in_len = 7;
ao_usb_ep0_in_data = (uint8_t *) &ao_usb_line_coding;
break;
- case SET_CONTROL_LINE_STATE:
+ case
AO_USB_
SET_CONTROL_LINE_STATE:
break;
}
break;
break;
}
break;
@@
-414,7
+411,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 */
@@
-422,7
+419,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;
@@
-433,24
+429,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
@@
-460,18
+456,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;
@@
-479,14
+477,15
@@
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 char
+int
_ao_usb_pollchar(void)
{
_ao_usb_pollchar(void)
{
-
char
c;
+
uint8_t
c;
uint8_t intx;
if (!ao_usb_running)
uint8_t intx;
if (!ao_usb_running)
@@
-521,24
+520,14
@@
_ao_usb_pollchar(void)
}
char
}
char
-ao_usb_
poll
char(void)
+ao_usb_
get
char(void)
{
{
- char c;
- cli();
- c = _ao_usb_pollchar();
- sei();
- return c;
-}
+ int c;
-char
-ao_usb_getchar(void) __critical
-{
- char 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;
}
@@
-661,18
+650,6
@@
ao_usb_echo(void)
}
#endif
}
#endif
-static void
-ao_usb_irq(void)
-{
- printf ("control: %d out: %d in: %d\n",
- control_count, out_count, in_count);
-}
-
-__code struct ao_cmds ao_usb_cmds[] = {
- { ao_usb_irq, "i\0Show USB interrupt counts" },
- { 0, NULL }
-};
-
void
ao_usb_init(void)
{
void
ao_usb_init(void)
{
@@
-683,6
+660,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_cmd_register(&ao_usb_cmds[0]);
- ao_add_stdio(ao_usb_pollchar, ao_usb_putchar, ao_usb_flush);
+ ao_add_stdio(_ao_usb_pollchar, ao_usb_putchar, ao_usb_flush);
}
}