altos/flash-loader: On STM, don't include ao_usb_disable
[fw/altos] / src / stm / ao_usb_stm.c
index 33e0617c8c4faa44cda6f73387b46aabe773546e..b06814d23184fcf992b7df4fc880fd598986c31c 100644 (file)
@@ -446,15 +446,11 @@ ao_usb_write_short(uint16_t data, uint32_t *base, uint16_t offset)
 }
 
 static void
-ao_usb_write(const uint8_t *src, uint32_t *base, uint16_t offset, uint16_t bytes)
+ao_usb_write(const uint8_t *src, uint32_t *base, uint16_t bytes)
 {
+       uint16_t offset = 0;
        if (!bytes)
                return;
-       if (offset & 1) {
-               debug_data (" %02x", src[0]);
-               ao_usb_write_byte(*src++, base, offset++);
-               bytes--;
-       }
        while (bytes >= 2) {
                debug_data (" %02x %02x", src[0], src[1]);
                ao_usb_write_short((src[1] << 8) | src[0], base, offset);
@@ -531,7 +527,7 @@ ao_usb_ep0_flush(void)
        ao_usb_ep0_in_len -= this_len;
 
        debug_data ("Flush EP0 len %d:", this_len);
-       ao_usb_write(ao_usb_ep0_in_data, ao_usb_ep0_tx_buffer, 0, this_len);
+       ao_usb_write(ao_usb_ep0_in_data, ao_usb_ep0_tx_buffer, this_len);
        debug_data ("\n");
        ao_usb_ep0_in_data += this_len;
 
@@ -598,7 +594,7 @@ ao_usb_ep0_in_start(uint16_t max)
        ao_usb_ep0_flush();
 }
 
-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
  */
@@ -850,7 +846,7 @@ _ao_usb_in_send(void)
        ao_usb_in_pending = 1;
        if (ao_usb_tx_count != AO_USB_IN_SIZE)
                ao_usb_in_flushed = 1;
-       ao_usb_write(ao_usb_tx_buffer, ao_usb_in_tx_buffer, 0, ao_usb_tx_count);
+       ao_usb_write(ao_usb_tx_buffer, ao_usb_in_tx_buffer, ao_usb_tx_count);
        ao_usb_bdt[AO_USB_IN_EPR].single.count_tx = ao_usb_tx_count;
        ao_usb_tx_count = 0;
        _ao_usb_set_stat_tx(AO_USB_IN_EPR, STM_USB_EPR_STAT_TX_VALID);
@@ -974,6 +970,11 @@ ao_usb_getchar(void)
        return c;
 }
 
+#ifndef HAS_USB_DISABLE
+#define HAS_USB_DISABLE 1
+#endif
+
+#if HAS_USB_DISABLE
 void
 ao_usb_disable(void)
 {
@@ -991,6 +992,7 @@ ao_usb_disable(void)
        stm_rcc.apb1enr &= ~(1 << STM_RCC_APB1ENR_USBEN);
        ao_arch_release_interrupts();
 }
+#endif
 
 void
 ao_usb_enable(void)