|
@@ -69,7 +69,7 @@ static void shark_uart_rx(shark_uart_t *uart){
|
|
|
while(1) {
|
|
while(1) {
|
|
|
u8 data;
|
|
u8 data;
|
|
|
update_dma_w_pos(uart);
|
|
update_dma_w_pos(uart);
|
|
|
- if (circle_get_one_data(&uart->rx_queue, (char *)&data) != 1) {
|
|
|
|
|
|
|
+ if (circle_get_one_data(&uart->rx_queue, &data) != 1) {
|
|
|
if (!new_prococol){//通过老协议发送过来的,需要回复一个信息,告知使用新协议,霍尔移除,通信超时需要reset new_protocol
|
|
if (!new_prococol){//通过老协议发送过来的,需要回复一个信息,告知使用新协议,霍尔移除,通信超时需要reset new_protocol
|
|
|
if (shark_get_mseconds() - _rx_time >= 30) {
|
|
if (shark_get_mseconds() - _rx_time >= 30) {
|
|
|
_rx_time = 0xFFFFFFFFFFFFL;
|
|
_rx_time = 0xFFFFFFFFFFFFL;
|
|
@@ -239,7 +239,8 @@ void shark_uart_deinit(uart_enum_t uart_no){
|
|
|
UART0_IR_EN(0);
|
|
UART0_IR_EN(0);
|
|
|
}else {
|
|
}else {
|
|
|
UART1_IR_EN(0);
|
|
UART1_IR_EN(0);
|
|
|
- }
|
|
|
|
|
|
|
+ }
|
|
|
|
|
+ new_prococol = false;
|
|
|
}
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
@@ -251,7 +252,7 @@ void shark_uart_init(uart_enum_t uart_no)
|
|
|
uart->tx_length = 0;
|
|
uart->tx_length = 0;
|
|
|
uart->uart_com = (uart_no == SHARK_UART0)?SHARK_UART0_com:SHARK_UART1_com;
|
|
uart->uart_com = (uart_no == SHARK_UART0)?SHARK_UART0_com:SHARK_UART1_com;
|
|
|
|
|
|
|
|
- circle_buffer_init(&uart->rx_queue, (char *)shark_uart_rx_cache, SHARK_UART_TX_MEM_SIZE);
|
|
|
|
|
|
|
+ circle_buffer_init(&uart->rx_queue, shark_uart_rx_cache, SHARK_UART_TX_MEM_SIZE);
|
|
|
byte_queue_init(&uart->tx_queue,tx_cache_addr(uart_no), SHARK_UART_TX_MEM_SIZE);
|
|
byte_queue_init(&uart->tx_queue,tx_cache_addr(uart_no), SHARK_UART_TX_MEM_SIZE);
|
|
|
|
|
|
|
|
uart->rx_dma_ch = (uart_no == SHARK_UART0)?SHARK_UART0_rx_dma_ch:SHARK_UART1_rx_dma_ch;
|
|
uart->rx_dma_ch = (uart_no == SHARK_UART0)?SHARK_UART0_rx_dma_ch:SHARK_UART1_rx_dma_ch;
|
|
@@ -359,7 +360,7 @@ static void shark_uart_tx_end(shark_uart_t *uart)
|
|
|
shark_uart_write_byte(uart, CH_END);
|
|
shark_uart_write_byte(uart, CH_END);
|
|
|
}
|
|
}
|
|
|
|
|
|
|
|
-void shark_uart_write_frame(uart_enum_t uart_no, char *bytes, int len){
|
|
|
|
|
|
|
+void shark_uart_write_frame(uart_enum_t uart_no, uint8_t *bytes, int len){
|
|
|
shark_uart_t *uart = _shark_uart + uart_no;
|
|
shark_uart_t *uart = _shark_uart + uart_no;
|
|
|
shark_uart_tx_start(uart);
|
|
shark_uart_tx_start(uart);
|
|
|
shark_uart_tx_continue(uart, bytes, len);
|
|
shark_uart_tx_continue(uart, bytes, len);
|