make it work with radar
This commit is contained in:
parent
71e91979e8
commit
bea5523e02
26
src/main.c
26
src/main.c
|
|
@ -130,7 +130,8 @@ void send_some_command(void) {
|
||||||
tx_buffer[0] = 'C';
|
tx_buffer[0] = 'C';
|
||||||
tx_buffer[1] = 'M';
|
tx_buffer[1] = 'M';
|
||||||
tx_buffer[2] = 'D';
|
tx_buffer[2] = 'D';
|
||||||
start_cmd(3);
|
tx_buffer[3] = '\n';
|
||||||
|
start_cmd(4);
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
|
@ -248,7 +249,7 @@ void tick_250ms(void) {
|
||||||
*/
|
*/
|
||||||
int is_rx_finished(void) {
|
int is_rx_finished(void) {
|
||||||
// head + len + cmd + ver + tail
|
// head + len + cmd + ver + tail
|
||||||
if (rx_pos < 6 || (rx_buffer[0] != RANGE[0] && rx_pos < 4 + 2 + 2 + 2 + 4)) {
|
if (rx_pos < 6) {
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
// Check head, tail and just in case - length
|
// Check head, tail and just in case - length
|
||||||
|
|
@ -260,16 +261,7 @@ int is_rx_finished(void) {
|
||||||
rx_buffer[4] == RANGE[4] &&
|
rx_buffer[4] == RANGE[4] &&
|
||||||
rx_buffer[5] == RANGE[5] &&
|
rx_buffer[5] == RANGE[5] &&
|
||||||
(rx_buffer[rx_pos - 1] == '\r' ||
|
(rx_buffer[rx_pos - 1] == '\r' ||
|
||||||
rx_buffer[rx_pos - 1] == '\n')) ||
|
rx_buffer[rx_pos - 1] == '\n'));
|
||||||
(rx_buffer[0] == 0xFD &&
|
|
||||||
rx_buffer[1] == 0xFC &&
|
|
||||||
rx_buffer[2] == 0xFB &&
|
|
||||||
rx_buffer[3] == 0xFA &&
|
|
||||||
rx_buffer[rx_pos - 1] == 0x01 &&
|
|
||||||
rx_buffer[rx_pos - 2] == 0x02 &&
|
|
||||||
rx_buffer[rx_pos - 3] == 0x03 &&
|
|
||||||
rx_buffer[rx_pos - 4] == 0x04 &&
|
|
||||||
(rx_buffer[4] | (rx_buffer[5] << 8)) == rx_pos - 12);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
|
@ -310,14 +302,14 @@ interrupt(IRQ_UART1_RX_F, uart_recv) {
|
||||||
if ((s & UART_RX_NOT_EMPTY) == 0) {
|
if ((s & UART_RX_NOT_EMPTY) == 0) {
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
if (rx_pos <= 4) {
|
||||||
if (rx_pos < 4) {
|
if (RANGE[rx_pos] == c) {
|
||||||
if (rx_pos == 0xFD - c || RANGE[rx_pos] == c) {
|
|
||||||
rx_buffer[rx_pos] = c;
|
rx_buffer[rx_pos] = c;
|
||||||
} else {
|
} else {
|
||||||
// Something wrong - reset
|
// Something wrong - reset
|
||||||
rx_pos = 0;
|
rx_pos = 0;
|
||||||
memset(rx_buffer, 0, BUFFER_LEN);
|
memset(rx_buffer, 0, BUFFER_LEN);
|
||||||
|
return;
|
||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
rx_buffer[rx_pos] = c;
|
rx_buffer[rx_pos] = c;
|
||||||
|
|
@ -414,8 +406,8 @@ void main(void) {
|
||||||
UART1.CR3 &= ~(UART_CR3_STOP1 | UART_CR3_STOP2);
|
UART1.CR3 &= ~(UART_CR3_STOP1 | UART_CR3_STOP2);
|
||||||
// UART1.BRR2 = 0x0B; // 0x03; // 0x11;
|
// UART1.BRR2 = 0x0B; // 0x03; // 0x11;
|
||||||
// UART1.BRR1 = 0x08; // 0x68; // 0x06;
|
// UART1.BRR1 = 0x08; // 0x68; // 0x06;
|
||||||
UART1.BRR2 = 0x03;
|
UART1.BRR2 = 0x0B;
|
||||||
UART1.BRR1 = 0x68;
|
UART1.BRR1 = 0x08;
|
||||||
UART1.CR2 = UART_CR2_TEN | UART_CR2_REN | UART_CR2_RXNE_IVT | UART_CR2_SBK;
|
UART1.CR2 = UART_CR2_TEN | UART_CR2_REN | UART_CR2_RXNE_IVT | UART_CR2_SBK;
|
||||||
CLK.Peripheral1.Serial1 = 1;
|
CLK.Peripheral1.Serial1 = 1;
|
||||||
|
|
||||||
|
|
|
||||||
Loading…
Reference in New Issue