projects
/
fw
/
altos
/ blobdiff
commit
grep
author
committer
pickaxe
?
search:
re
summary
|
shortlog
|
log
|
commit
|
commitdiff
|
tree
raw
|
inline
| side by side
altos: Force telemetry rate to 38400 when ao_force_freq is set
[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 0de501ab5cfac7a05adcf8498e965021add0faf4..b06814d23184fcf992b7df4fc880fd598986c31c 100644
(file)
--- a/
src/stm/ao_usb_stm.c
+++ b/
src/stm/ao_usb_stm.c
@@
-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);
@@
-446,15
+446,11
@@
ao_usb_write_short(uint16_t data, uint32_t *base, uint16_t offset)
}
static void
}
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 (!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);
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_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;
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();
}
ao_usb_ep0_flush();
}
-st
atic st
ruct 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
*/
/* 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_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);
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;
}
return c;
}
+#ifndef HAS_USB_DISABLE
+#define HAS_USB_DISABLE 1
+#endif
+
+#if HAS_USB_DISABLE
void
ao_usb_disable(void)
{
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();
}
stm_rcc.apb1enr &= ~(1 << STM_RCC_APB1ENR_USBEN);
ao_arch_release_interrupts();
}
+#endif
void
ao_usb_enable(void)
void
ao_usb_enable(void)
@@
-1015,7
+1017,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;
@@
-1109,7
+1111,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;
@@
-1125,19
+1127,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];