diff options
author | jaseg <git@jaseg.de> | 2020-11-27 18:43:00 +0100 |
---|---|---|
committer | jaseg <git@jaseg.de> | 2020-11-27 18:43:00 +0100 |
commit | 822c8a21d7fd834a75be20765be4b4f2e5133009 (patch) | |
tree | 7dea4cd057c4a2882bdd7707a15dfaa47c8fc4d6 /prototype/fw/src | |
parent | 6ebd1a667d6e58ca355387af24bbe2a5b00baa50 (diff) | |
download | ihsm-822c8a21d7fd834a75be20765be4b4f2e5133009.tar.gz ihsm-822c8a21d7fd834a75be20765be4b4f2e5133009.tar.bz2 ihsm-822c8a21d7fd834a75be20765be4b4f2e5133009.zip |
test code
Diffstat (limited to 'prototype/fw/src')
-rw-r--r-- | prototype/fw/src/main.c | 29 |
1 files changed, 18 insertions, 11 deletions
diff --git a/prototype/fw/src/main.c b/prototype/fw/src/main.c index 16e1b78..51e69e8 100644 --- a/prototype/fw/src/main.c +++ b/prototype/fw/src/main.c @@ -53,7 +53,7 @@ int main(void) { USART1->CR1 = USART_CR1_TE | USART_CR1_RE; USART1->BRR = (apb2_clock + baudrate/2) / baudrate; - USART1->CR2 |= USART_CR2_RXINV; + USART1->CR2 |= USART_CR2_RXINV; //| USART_CR2_TXINV; USART1->CR1 |= USART_CR1_UE; int req_seq = 0; @@ -70,25 +70,32 @@ int main(void) { unsigned int rx_crc_error = 0; USART1->TDR = 0; /* Kick off transmission */ + int i = 0; while (23) { - /* if (tx_st.remaining_bytes == 0) { - res_buf.req_seq = req_seq; - res_buf.res_seq = res_seq; - res_seq += 1; - packetize(&res_buf, &res_buf.trailer); - tx_st.tx_char = tx_buf; - tx_st.remaining_bytes = cobs_encode((uint8_t *)&res_buf, sizeof(res_buf), tx_buf, sizeof(tx_buf));; + if (i > 10000) { + res_buf.req_seq = req_seq; + res_buf.res_seq = res_seq; + res_seq += 1; + //packetize(&res_buf, &res_buf.trailer); + tx_st.tx_char = tx_buf; + //tx_st.remaining_bytes = cobs_encode((uint8_t *)&res_buf, sizeof(res_buf), tx_buf, sizeof(tx_buf));; + for (int k=0; k < 8; k++) + tx_buf[k] = 255-k; + for (int k=0; k < 8; k++) + tx_buf[8+k] = (k + 1) % 8; + tx_st.remaining_bytes = 16; + i = 0; + } else { + i++; + } } if (USART1->ISR & USART_ISR_TXE && tx_st.remaining_bytes > 0) { - for (int i=0; i<100; i++) - asm volatile ("nop"); USART1->TDR = *(tx_st.tx_char); tx_st.tx_char += 1; tx_st.remaining_bytes -= 1; } - */ if (USART1->ISR & USART_ISR_ORE) USART1->ICR = USART_ICR_ORECF; |