projects
/
fw
/
altos
/ blobdiff
commit
grep
author
committer
pickaxe
?
search:
re
summary
|
shortlog
|
log
|
commit
|
commitdiff
|
tree
raw
|
inline
| side by side
altos: Require SPI speed to be declared for cc1200
[fw/altos]
/
src
/
stm
/
ao_usb_stm.c
diff --git
a/src/stm/ao_usb_stm.c
b/src/stm/ao_usb_stm.c
index 11dde92eedf1d583df74c57252d3aa8e048dd1b9..9d72844e0c1a6710c06700f9725c13aae9d622a7 100644
(file)
--- a/
src/stm/ao_usb_stm.c
+++ b/
src/stm/ao_usb_stm.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
@@
-117,9
+118,8
@@
static uint8_t ao_usb_in_pending;
* but not pulled to the shadow buffer.
*/
static uint8_t ao_usb_out_avail;
* but not pulled to the shadow buffer.
*/
static uint8_t ao_usb_out_avail;
-
static uint8_t
ao_usb_running;
+
uint8_t
ao_usb_running;
static uint8_t ao_usb_configuration;
static uint8_t ao_usb_configuration;
-static uint8_t ueienx_0;
#define AO_USB_EP0_GOT_RESET 1
#define AO_USB_EP0_GOT_SETUP 2
#define AO_USB_EP0_GOT_RESET 1
#define AO_USB_EP0_GOT_SETUP 2
@@
-139,7
+139,7
@@
static inline uint32_t set_toggle(uint32_t current_value,
static inline uint32_t *ao_usb_packet_buffer_addr(uint16_t sram_addr)
{
static inline uint32_t *ao_usb_packet_buffer_addr(uint16_t sram_addr)
{
- return (uint32_t *) (
stm_usb_sram + 2 * sram_addr
);
+ return (uint32_t *) (
((void *) ((uint8_t *) stm_usb_sram + 2 * sram_addr))
);
}
static inline uint32_t ao_usb_epr_stat_rx(uint32_t epr) {
}
static inline uint32_t ao_usb_epr_stat_rx(uint32_t epr) {
@@
-174,7
+174,7
@@
static inline uint32_t ao_usb_epr_dtog_tx(uint32_t epr) {
* Set current device address and mark the
* interface as active
*/
* Set current device address and mark the
* interface as active
*/
-void
+
static
void
ao_usb_set_address(uint8_t address)
{
debug("ao_usb_set_address %02x\n", address);
ao_usb_set_address(uint8_t address)
{
debug("ao_usb_set_address %02x\n", address);
@@
-313,7
+313,6
@@
ao_usb_init_ep(uint8_t ep, uint32_t addr, uint32_t type, uint32_t stat_rx, uint3
static void
ao_usb_set_ep0(void)
{
static void
ao_usb_set_ep0(void)
{
- uint32_t epr;
int e;
ao_usb_sram_addr = 0;
int e;
ao_usb_sram_addr = 0;
@@
-351,13
+350,24
@@
ao_usb_set_ep0(void)
}
ao_usb_set_address(0);
}
ao_usb_set_address(0);
+
+ ao_usb_running = 0;
+
+ /* Reset our internal state
+ */
+
+ ao_usb_ep0_state = AO_USB_EP0_IDLE;
+
+ ao_usb_ep0_in_data = NULL;
+ ao_usb_ep0_in_len = 0;
+
+ ao_usb_ep0_out_data = 0;
+ ao_usb_ep0_out_len = 0;
}
static void
ao_usb_set_configuration(void)
{
}
static void
ao_usb_set_configuration(void)
{
- uint32_t epr;
-
debug ("ao_usb_set_configuration\n");
/* Set up the INT end point */
debug ("ao_usb_set_configuration\n");
/* Set up the INT end point */
@@
-397,7
+407,15
@@
ao_usb_set_configuration(void)
STM_USB_EPR_STAT_RX_DISABLED,
STM_USB_EPR_STAT_TX_NAK);
STM_USB_EPR_STAT_RX_DISABLED,
STM_USB_EPR_STAT_TX_NAK);
+ ao_usb_in_flushed = 0;
+ ao_usb_in_pending = 0;
+ ao_wakeup(&ao_usb_in_pending);
+
+ ao_usb_out_avail = 0;
+ ao_usb_configuration = 0;
+
ao_usb_running = 1;
ao_usb_running = 1;
+ ao_wakeup(&ao_usb_running);
}
static uint16_t control_count;
}
static uint16_t control_count;
@@
-572,7
+590,7
@@
ao_usb_ep0_out_set(uint8_t *data, uint8_t len)
}
static void
}
static void
-ao_usb_ep0_in_start(uint
8
_t max)
+ao_usb_ep0_in_start(uint
16
_t max)
{
/* Don't send more than asked for */
if (ao_usb_ep0_in_len > max)
{
/* Don't send more than asked for */
if (ao_usb_ep0_in_len > max)
@@
-585,7
+603,7
@@
static struct ao_usb_line_coding ao_usb_line_coding = {115200, 0, 0, 8};
/* Walk through the list of descriptors and find a match
*/
static void
/* Walk through the list of descriptors and find a match
*/
static void
-ao_usb_get_descriptor(uint16_t value)
+ao_usb_get_descriptor(uint16_t value
, uint16_t length
)
{
const uint8_t *descriptor;
uint8_t type = value >> 8;
{
const uint8_t *descriptor;
uint8_t type = value >> 8;
@@
-599,6
+617,8
@@
ao_usb_get_descriptor(uint16_t value)
len = descriptor[2];
else
len = descriptor[0];
len = descriptor[2];
else
len = descriptor[0];
+ if (len > length)
+ len = length;
ao_usb_ep0_in_set(descriptor, len);
break;
}
ao_usb_ep0_in_set(descriptor, len);
break;
}
@@
-643,7
+663,7
@@
ao_usb_ep0_setup(void)
break;
case AO_USB_REQ_GET_DESCRIPTOR:
debug ("get descriptor %d\n", ao_usb_setup.value);
break;
case AO_USB_REQ_GET_DESCRIPTOR:
debug ("get descriptor %d\n", ao_usb_setup.value);
- ao_usb_get_descriptor(ao_usb_setup.value);
+ ao_usb_get_descriptor(ao_usb_setup.value
, ao_usb_setup.length
);
break;
case AO_USB_REQ_GET_CONFIGURATION:
debug ("get configuration %d\n", ao_usb_configuration);
break;
case AO_USB_REQ_GET_CONFIGURATION:
debug ("get configuration %d\n", ao_usb_configuration);
@@
-731,6
+751,9
@@
ao_usb_ep0_handle(uint8_t receive)
if (receive & AO_USB_EP0_GOT_TX_ACK) {
debug ("\tgot tx ack\n");
if (receive & AO_USB_EP0_GOT_TX_ACK) {
debug ("\tgot tx ack\n");
+#if HAS_FLIGHT && AO_USB_FORCE_IDLE
+ ao_flight_force_idle = 1;
+#endif
/* Wait until the IN packet is received from addr 0
* before assigning our local address
*/
/* Wait until the IN packet is received from addr 0
* before assigning our local address
*/
@@
-965,7
+988,7
@@
ao_usb_disable(void)
stm_usb.cntr = (1 << STM_USB_CNTR_PDWN) | (1 << STM_USB_CNTR_FRES);
/* Disable the interface */
stm_usb.cntr = (1 << STM_USB_CNTR_PDWN) | (1 << STM_USB_CNTR_FRES);
/* Disable the interface */
- stm_rcc.apb1enr &
+
~(1 << STM_RCC_APB1ENR_USBEN);
+ stm_rcc.apb1enr &
=
~(1 << STM_RCC_APB1ENR_USBEN);
ao_arch_release_interrupts();
}
ao_arch_release_interrupts();
}