projects
/
fw
/
altos
/ blobdiff
commit
grep
author
committer
pickaxe
?
search:
re
summary
|
shortlog
|
log
|
commit
|
commitdiff
|
tree
raw
|
inline
| side by side
builds, loads, runs, not very useful yet
[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 4e9d1f145cd98001e4378d3f8ea12050fc034e91..33e0617c8c4faa44cda6f73387b46aabe773546e 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
@@
-138,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) {
@@
-173,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);
@@
-349,6
+350,19
@@
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
}
static void
@@
-393,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;
@@
-581,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;
@@
-595,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;
}
@@
-639,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);
@@
-991,7
+1015,7
@@
ao_usb_enable(void)
ao_arch_block_interrupts();
/* Route interrupts */
ao_arch_block_interrupts();
/* Route interrupts */
- stm_nvic_set_priority(STM_ISR_USB_LP_POS,
3
);
+ stm_nvic_set_priority(STM_ISR_USB_LP_POS,
AO_STM_NVIC_LOW_PRIORITY
);
stm_nvic_set_enable(STM_ISR_USB_LP_POS);
ao_usb_configuration = 0;
stm_nvic_set_enable(STM_ISR_USB_LP_POS);
ao_usb_configuration = 0;
@@
-1085,7
+1109,7
@@
struct ao_usb_dbg {
int line;
char *msg;
uint32_t value;
int line;
char *msg;
uint32_t value;
- uint32_t pri
mask
;
+ uint32_t pri
val
;
#if TX_DBG
uint16_t in_count;
uint32_t in_epr;
#if TX_DBG
uint16_t in_count;
uint32_t in_epr;
@@
-1101,19
+1125,23
@@
struct ao_usb_dbg {
#endif
};
#endif
};
-#define NUM_USB_DBG 1
28
+#define NUM_USB_DBG 1
6
-static struct ao_usb_dbg dbg[
128
];
+static struct ao_usb_dbg dbg[
NUM_USB_DBG
];
static int dbg_i;
static void _dbg(int line, char *msg, uint32_t value)
{
static int dbg_i;
static void _dbg(int line, char *msg, uint32_t value)
{
- uint32_t pri
mask
;
+ uint32_t pri
val
;
dbg[dbg_i].line = line;
dbg[dbg_i].msg = msg;
dbg[dbg_i].value = value;
dbg[dbg_i].line = line;
dbg[dbg_i].msg = msg;
dbg[dbg_i].value = value;
- asm("mrs %0,primask" : "=&r" (primask));
- dbg[dbg_i].primask = primask;
+#if AO_NONMASK_INTERRUPT
+ asm("mrs %0,basepri" : "=&r" (prival));
+#else
+ asm("mrs %0,primask" : "=&r" (prival));
+#endif
+ dbg[dbg_i].prival = prival;
#if TX_DBG
dbg[dbg_i].in_count = in_count;
dbg[dbg_i].in_epr = stm_usb.epr[AO_USB_IN_EPR];
#if TX_DBG
dbg[dbg_i].in_count = in_count;
dbg[dbg_i].in_epr = stm_usb.epr[AO_USB_IN_EPR];