summaryrefslogtreecommitdiff
path: root/fw/src/packet_interface.c
diff options
context:
space:
mode:
Diffstat (limited to 'fw/src/packet_interface.c')
-rw-r--r--fw/src/packet_interface.c40
1 files changed, 20 insertions, 20 deletions
diff --git a/fw/src/packet_interface.c b/fw/src/packet_interface.c
index 98a1ef2..c6c54cb 100644
--- a/fw/src/packet_interface.c
+++ b/fw/src/packet_interface.c
@@ -12,54 +12,54 @@
volatile struct {
struct dma_buf dma;
uint8_t data[256];
-} usart2_buf = { .dma = { .len = sizeof(usart2_buf.data) } };
+} uart4_buf = { .dma = { .len = sizeof(uart4_buf.data) } };
-struct dma_usart_file usart2_out_s = {
- .usart = USART2,
+struct dma_usart_file uart4_out_s = {
+ .usart = UART4,
.baudrate = 115200,
.dma = DMA1,
- .stream = 6,
+ .stream = 4,
.channel = 4,
- .irqn = NVIC_DMA_IRQ(1, 6),
- .buf = &usart2_buf.dma
+ .irqn = NVIC_DMA_IRQ(1, 4),
+ .buf = &uart4_buf.dma
};
-struct dma_usart_file *usart2_out = &usart2_out_s;
+struct dma_usart_file *uart4_out = &uart4_out_s;
-void dma1_stream6_isr(void) {
+void dma1_stream4_isr(void) {
TRACING_SET(TR_HOST_IF_DMA_IRQ);
static unsigned int fifo_errors = 0; /* debug */
- if (dma_get_interrupt_flag(usart2_out->dma, usart2_out->stream, DMA_FEIF)) {
+ if (dma_get_interrupt_flag(uart4_out->dma, uart4_out->stream, DMA_FEIF)) {
/* Ignore FIFO errors as they're 100% non-critical for UART applications */
- dma_clear_interrupt_flags(usart2_out->dma, usart2_out->stream, DMA_FEIF);
+ dma_clear_interrupt_flags(uart4_out->dma, uart4_out->stream, DMA_FEIF);
fifo_errors++;
TRACING_CLEAR(TR_HOST_IF_DMA_IRQ);
return;
}
/* Transfer complete interrupt */
- dma_clear_interrupt_flags(usart2_out->dma, usart2_out->stream, DMA_TCIF);
+ dma_clear_interrupt_flags(uart4_out->dma, uart4_out->stream, DMA_TCIF);
- if (usart2_out->buf->wr_pos != usart2_out->buf->xfr_end) /* buffer not empty */
- schedule_dma(usart2_out);
+ if (uart4_out->buf->wr_pos != uart4_out->buf->xfr_end) /* buffer not empty */
+ schedule_dma(uart4_out);
TRACING_CLEAR(TR_HOST_IF_DMA_IRQ);
}
-void usart2_isr(void) {
+void uart4_isr(void) {
TRACING_SET(TR_HOST_IF_USART_IRQ);
static struct cobs_decode_state host_cobs_state = {0};
- if (USART2_SR & USART_SR_ORE) { /* Overrun handling */
- LOG_PRINTF("USART2 data register overrun\n");
+ if (UART4_SR & USART_SR_ORE) { /* Overrun handling */
+ LOG_PRINTF("UART4 data register overrun\n");
/* Clear interrupt flag */
- (void)USART2_DR; /* FIXME make sure this read is not optimized out */
+ (void)UART4_DR; /* FIXME make sure this read is not optimized out */
host_packet_length = -1;
TRACING_CLEAR(TR_HOST_IF_USART_IRQ);
return;
}
- uint8_t data = USART2_DR; /* This automatically acknowledges the IRQ */
+ uint8_t data = UART4_DR; /* This automatically acknowledges the IRQ */
if (host_packet_length) {
- LOG_PRINTF("USART2 COBS buffer overrun\n");
+ LOG_PRINTF("UART4 COBS buffer overrun\n");
host_packet_length = -1;
TRACING_CLEAR(TR_HOST_IF_USART_IRQ);
return;
@@ -78,7 +78,7 @@ void usart2_isr(void) {
} else if (rv == -3) {
/* invalid empty frame */
LOG_PRINTF("Got double null byte from host\n");
- host_packet_length = -1;
+ /* FIXME DEBUG host_packet_length = -1; */
} else if (rv == -4) {
/* frame too large */
LOG_PRINTF("Got too large frame from host\n");