summaryrefslogtreecommitdiff
path: root/gm_platform/fw/packet_interface.c
diff options
context:
space:
mode:
Diffstat (limited to 'gm_platform/fw/packet_interface.c')
-rw-r--r--gm_platform/fw/packet_interface.c46
1 files changed, 0 insertions, 46 deletions
diff --git a/gm_platform/fw/packet_interface.c b/gm_platform/fw/packet_interface.c
deleted file mode 100644
index 099993b..0000000
--- a/gm_platform/fw/packet_interface.c
+++ /dev/null
@@ -1,46 +0,0 @@
-
-#include "packet_interface.h"
-#include "cobs.h"
-
-void usart2_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");
- /* Clear interrupt flag */
- (void)USART2_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 */
-
- if (host_packet_length) {
- LOG_PRINTF("USART2 COBS buffer overrun\n");
- host_packet_length = -1;
- TRACING_CLEAR(TR_HOST_IF_USART_IRQ);
- return;
- }
-
- ssize_t rv = cobs_decode_incremental(&host_cobs_state, (char *)host_packet_buf, sizeof(host_packet_buf), data);
- if (rv == -2) {
- LOG_PRINTF("Host interface COBS packet too large\n");
- host_packet_length = -1;
- } else if (rv == -3) {
- LOG_PRINTF("Got double null byte from host\n");
- } else if (rv < 0) {
- LOG_PRINTF("Host interface COBS framing error\n");
- host_packet_length = -1;
- } else if (rv > 0) {
- host_packet_length = rv;
- } /* else just return and wait for next byte */
- TRACING_CLEAR(TR_HOST_IF_USART_IRQ);
-}
-
-void send_packet(struct dma_usart_file *f, const uint8_t *data, size_t len) {
- /* ignore return value as putf is blocking and always succeeds */
- (void)cobs_encode_incremental(f, putf, (char *)data, len);
- flush(f);
-}
-