X-Git-Url: https://git.gag.com/?a=blobdiff_plain;f=src%2Fstm%2Fao_usb_stm.c;h=4f37a7d9e7af5256a7ce4b89ecb8a2ec65ca7249;hb=6d47dd1d9104745cf68bef23b066c5033ca30a84;hp=223fdeaa4620c9eea4d5802dd6966a2f0ae0e9e2;hpb=e9f6fca7cfe796cbd86ae9d8f1ebe31bba7251db;p=fw%2Faltos diff --git a/src/stm/ao_usb_stm.c b/src/stm/ao_usb_stm.c index 223fdeaa..4f37a7d9 100644 --- a/src/stm/ao_usb_stm.c +++ b/src/stm/ao_usb_stm.c @@ -792,10 +792,10 @@ static void ao_usb_in_send(void) { debug ("send %d\n", ao_usb_tx_count); + ao_usb_in_pending = 1; ao_usb_write(ao_usb_tx_buffer, ao_usb_in_tx_buffer, 0, ao_usb_tx_count); ao_usb_bdt[AO_USB_IN_EPR].single.count_tx = ao_usb_tx_count; ao_usb_set_stat_tx(AO_USB_IN_EPR, STM_USB_EPR_STAT_TX_VALID); - ao_usb_in_pending = 1; ao_usb_tx_count = 0; } @@ -848,12 +848,12 @@ ao_usb_putchar(char c) __critical __reentrant ao_usb_in_wait(); + ao_usb_in_flushed = 0; ao_usb_tx_buffer[ao_usb_tx_count++] = (uint8_t) c; /* Send the packet when full */ if (ao_usb_tx_count == AO_USB_IN_SIZE) ao_usb_in_send(); - ao_usb_in_flushed = 0; } static void @@ -937,7 +937,7 @@ ao_usb_disable(void) void ao_usb_enable(void) { - uint16_t tick; + int t; /* Enable SYSCFG */ stm_rcc.apb2enr |= (1 << STM_RCC_APB2ENR_SYSCFGEN); @@ -985,6 +985,8 @@ ao_usb_enable(void) (0 << STM_USB_CNTR_PDWN) | (0 << STM_USB_CNTR_FRES)); + for (t = 0; t < 1000; t++) + ao_arch_nop(); /* Enable USB pull-up */ stm_syscfg.pmc |= (1 << STM_SYSCFG_PMC_USB_PU); } @@ -1005,6 +1007,7 @@ ao_usb_echo(void) } #endif +#if USB_DEBUG static void ao_usb_irq(void) { @@ -1016,6 +1019,7 @@ __code struct ao_cmds ao_usb_cmds[] = { { ao_usb_irq, "I\0Show USB interrupt counts" }, { 0, NULL } }; +#endif void ao_usb_init(void) @@ -1027,7 +1031,9 @@ ao_usb_init(void) #if USB_ECHO ao_add_task(&ao_usb_echo_task, ao_usb_echo, "usb echo"); #endif +#if USB_DEBUG ao_cmd_register(&ao_usb_cmds[0]); +#endif #if !USB_ECHO ao_add_stdio(ao_usb_pollchar, ao_usb_putchar, ao_usb_flush); #endif