|
@@ -1,6 +1,7 @@
|
|
|
|
|
|
|
|
#include "luat_base.h"
|
|
#include "luat_base.h"
|
|
|
#include "luat_uart.h"
|
|
#include "luat_uart.h"
|
|
|
|
|
+#include "luat_shell.h"
|
|
|
#include "freertos/FreeRTOS.h"
|
|
#include "freertos/FreeRTOS.h"
|
|
|
#include "freertos/task.h"
|
|
#include "freertos/task.h"
|
|
|
#include "freertos/queue.h"
|
|
#include "freertos/queue.h"
|
|
@@ -9,6 +10,10 @@
|
|
|
#include "luat_log.h"
|
|
#include "luat_log.h"
|
|
|
#define LUAT_LOG_TAG "uart"
|
|
#define LUAT_LOG_TAG "uart"
|
|
|
|
|
|
|
|
|
|
+#ifdef LUAT_USE_SHELL
|
|
|
|
|
+static uint8_t shell_state = 0;
|
|
|
|
|
+static char shell_buffer[1024] = {0};
|
|
|
|
|
+#endif
|
|
|
typedef struct ifd_uart_port{
|
|
typedef struct ifd_uart_port{
|
|
|
TaskHandle_t xHandle;
|
|
TaskHandle_t xHandle;
|
|
|
QueueHandle_t xQueue;
|
|
QueueHandle_t xQueue;
|
|
@@ -37,6 +42,15 @@ static void uart0_irq_task(void *arg){
|
|
|
msg.arg2 = 1;
|
|
msg.arg2 = 1;
|
|
|
luat_msgbus_put(&msg, 0);
|
|
luat_msgbus_put(&msg, 0);
|
|
|
}
|
|
}
|
|
|
|
|
+#ifdef LUAT_USE_SHELL
|
|
|
|
|
+ if (shell_state==2){
|
|
|
|
|
+ int len = luat_uart_read(0, shell_buffer, 1024);
|
|
|
|
|
+ if (len < 1)
|
|
|
|
|
+ continue;
|
|
|
|
|
+ shell_buffer[len] = 0x00;
|
|
|
|
|
+ luat_shell_push(shell_buffer, len);
|
|
|
|
|
+ }
|
|
|
|
|
+#endif
|
|
|
xQueueReset(uart_port[0].xQueue);
|
|
xQueueReset(uart_port[0].xQueue);
|
|
|
}
|
|
}
|
|
|
}
|
|
}
|
|
@@ -101,12 +115,20 @@ int luat_uart_setup(luat_uart_t *uart){
|
|
|
uart_config.source_clk = UART_SCLK_XTAL;
|
|
uart_config.source_clk = UART_SCLK_XTAL;
|
|
|
switch (id){
|
|
switch (id){
|
|
|
case 0:
|
|
case 0:
|
|
|
|
|
+#ifdef LUAT_USE_SHELL
|
|
|
|
|
+ shell_state++;
|
|
|
|
|
+ if (shell_state==1){
|
|
|
|
|
+ shell_state = 0;
|
|
|
|
|
+ }else if(shell_state==3){
|
|
|
|
|
+ shell_state = 0;
|
|
|
|
|
+ }
|
|
|
|
|
+#endif
|
|
|
if (uart_port[id].xHandle==NULL){
|
|
if (uart_port[id].xHandle==NULL){
|
|
|
uart_driver_install(0, uart->bufsz * 2, uart->bufsz * 2, 20, &(uart_port[0].xQueue), 0);
|
|
uart_driver_install(0, uart->bufsz * 2, uart->bufsz * 2, 20, &(uart_port[0].xQueue), 0);
|
|
|
uart_set_pin(0, UART_PIN_NO_CHANGE, UART_PIN_NO_CHANGE, UART_PIN_NO_CHANGE, UART_PIN_NO_CHANGE);
|
|
uart_set_pin(0, UART_PIN_NO_CHANGE, UART_PIN_NO_CHANGE, UART_PIN_NO_CHANGE, UART_PIN_NO_CHANGE);
|
|
|
uart_param_config(id, &uart_config);
|
|
uart_param_config(id, &uart_config);
|
|
|
uart_pattern_queue_reset(id, 20);
|
|
uart_pattern_queue_reset(id, 20);
|
|
|
- uart_port[id].xHandle = xTaskCreate(uart0_irq_task, "uart0_irq_task", 2048, NULL, 10, NULL);
|
|
|
|
|
|
|
+ xTaskCreate(uart0_irq_task, "uart0_irq_task", 2048, NULL, 10, &uart_port[id].xHandle);
|
|
|
}
|
|
}
|
|
|
break;
|
|
break;
|
|
|
case 1:
|
|
case 1:
|
|
@@ -115,7 +137,7 @@ int luat_uart_setup(luat_uart_t *uart){
|
|
|
uart_set_pin(1, 18, 19, UART_PIN_NO_CHANGE, UART_PIN_NO_CHANGE);
|
|
uart_set_pin(1, 18, 19, UART_PIN_NO_CHANGE, UART_PIN_NO_CHANGE);
|
|
|
uart_param_config(id, &uart_config);
|
|
uart_param_config(id, &uart_config);
|
|
|
uart_pattern_queue_reset(id, 20);
|
|
uart_pattern_queue_reset(id, 20);
|
|
|
- uart_port[id].xHandle = xTaskCreate(uart1_irq_task, "uart1_irq_task", 2048, NULL, 10, NULL);
|
|
|
|
|
|
|
+ xTaskCreate(uart1_irq_task, "uart1_irq_task", 2048, NULL, 10, &uart_port[id].xHandle);
|
|
|
}
|
|
}
|
|
|
break;
|
|
break;
|
|
|
default:
|
|
default:
|
|
@@ -161,3 +183,23 @@ int luat_setup_cb(int uartid, int received, int sent){
|
|
|
}
|
|
}
|
|
|
return 0;
|
|
return 0;
|
|
|
}
|
|
}
|
|
|
|
|
+
|
|
|
|
|
+#ifdef LUAT_USE_SHELL
|
|
|
|
|
+void luat_shell_poweron(int _drv) {
|
|
|
|
|
+ uart_set_baudrate(0, 921600);
|
|
|
|
|
+ shell_state = 1;
|
|
|
|
|
+ luat_uart_t shell_uart = {
|
|
|
|
|
+ .id = _drv,
|
|
|
|
|
+ .baud_rate=921600,
|
|
|
|
|
+ .baud_rate=8,
|
|
|
|
|
+ .parity=LUAT_PARITY_NONE,
|
|
|
|
|
+ .bit_order=LUAT_BIT_ORDER_LSB,
|
|
|
|
|
+ .bufsz=1024,
|
|
|
|
|
+ .pin485=0xffffffff,
|
|
|
|
|
+ };
|
|
|
|
|
+ luat_uart_setup(&shell_uart);
|
|
|
|
|
+}
|
|
|
|
|
+#endif
|
|
|
|
|
+
|
|
|
|
|
+
|
|
|
|
|
+
|