fix: 🐛 APP运行正常配合USB CDC和letter shell
This commit is contained in:
parent
cbaaace76b
commit
604d356a99
@ -28,24 +28,46 @@
|
|||||||
#include "esp_chip_info.h"
|
#include "esp_chip_info.h"
|
||||||
#include "sdkconfig.h"
|
#include "sdkconfig.h"
|
||||||
#include <inttypes.h>
|
#include <inttypes.h>
|
||||||
|
#include <stdio.h>
|
||||||
|
|
||||||
#include "main_common.h"
|
#include "main_common.h"
|
||||||
|
#include "shell_port.h"
|
||||||
|
|
||||||
/* define --------------------------------------------------------------------*/
|
/* define --------------------------------------------------------------------*/
|
||||||
/* typedef -------------------------------------------------------------------*/
|
/* typedef -------------------------------------------------------------------*/
|
||||||
/* variables -----------------------------------------------------------------*/
|
/* variables -----------------------------------------------------------------*/
|
||||||
|
|
||||||
|
static uint8_t print_en = 0;
|
||||||
|
|
||||||
/* Private function(only *.c) -----------------------------------------------*/
|
/* Private function(only *.c) -----------------------------------------------*/
|
||||||
|
|
||||||
|
uint8_t _set_print_en(int argc, char **argv)
|
||||||
|
{
|
||||||
|
if (argc < 2) {
|
||||||
|
cdc_printf("too few argv\r\n");
|
||||||
|
}
|
||||||
|
int en_v = atoi(argv[1]);
|
||||||
|
print_en = en_v;
|
||||||
|
return 0;
|
||||||
|
}
|
||||||
/* Exported functions --------------------------------------------------------*/
|
/* Exported functions --------------------------------------------------------*/
|
||||||
|
|
||||||
uint8_t imp_main_app_task()
|
uint8_t imp_main_app_task()
|
||||||
{
|
{
|
||||||
int i = 0;
|
int i = 0;
|
||||||
while (1) {
|
while (1) {
|
||||||
cdc_printf("hello %d\r\n", i++);
|
if (print_en) {
|
||||||
|
cdc_printf("hello %d\r\n", i++);
|
||||||
|
}
|
||||||
|
|
||||||
vTaskDelay(1000 / portTICK_PERIOD_MS);
|
vTaskDelay(1000 / portTICK_PERIOD_MS);
|
||||||
}
|
}
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
SHELL_EXPORT_CMD(SHELL_CMD_PERMISSION(0) | SHELL_CMD_TYPE(SHELL_TYPE_CMD_MAIN),
|
||||||
|
main_pe, _set_print_en, set print value);
|
||||||
|
|
||||||
/*
|
/*
|
||||||
* EOF
|
* EOF
|
||||||
*/
|
*/
|
||||||
22
main/main.c
22
main/main.c
@ -46,14 +46,14 @@ void app_main(void)
|
|||||||
esp_chip_info_t chip_info;
|
esp_chip_info_t chip_info;
|
||||||
uint32_t flash_size;
|
uint32_t flash_size;
|
||||||
esp_chip_info(&chip_info);
|
esp_chip_info(&chip_info);
|
||||||
printf("This is %s chip with %d CPU core(s), %s%s%s%s, ", CONFIG_IDF_TARGET,
|
// printf("This is %s chip with %d CPU core(s), %s%s%s%s, ", CONFIG_IDF_TARGET,
|
||||||
chip_info.cores,
|
// chip_info.cores,
|
||||||
(chip_info.features & CHIP_FEATURE_WIFI_BGN) ? "WiFi/" : "",
|
// (chip_info.features & CHIP_FEATURE_WIFI_BGN) ? "WiFi/" : "",
|
||||||
(chip_info.features & CHIP_FEATURE_BT) ? "BT" : "",
|
// (chip_info.features & CHIP_FEATURE_BT) ? "BT" : "",
|
||||||
(chip_info.features & CHIP_FEATURE_BLE) ? "BLE" : "",
|
// (chip_info.features & CHIP_FEATURE_BLE) ? "BLE" : "",
|
||||||
(chip_info.features & CHIP_FEATURE_IEEE802154)
|
// (chip_info.features & CHIP_FEATURE_IEEE802154)
|
||||||
? ", 802.15.4 (Zigbee/Thread)"
|
// ? ", 802.15.4 (Zigbee/Thread)"
|
||||||
: "");
|
// : "");
|
||||||
|
|
||||||
unsigned major_rev = chip_info.revision / 100;
|
unsigned major_rev = chip_info.revision / 100;
|
||||||
unsigned minor_rev = chip_info.revision % 100;
|
unsigned minor_rev = chip_info.revision % 100;
|
||||||
@ -75,7 +75,11 @@ void app_main(void)
|
|||||||
// vTaskDelay(1000 / portTICK_PERIOD_MS);
|
// vTaskDelay(1000 / portTICK_PERIOD_MS);
|
||||||
// }
|
// }
|
||||||
cdc_printf("start run app:\r\n");
|
cdc_printf("start run app:\r\n");
|
||||||
imp_main_app_task();
|
xTaskCreate(imp_main_app_task, "main", 2048, NULL, 10, NULL);
|
||||||
|
while(1) {
|
||||||
|
// cdc_printf("start run app:\r\n");
|
||||||
|
vTaskDelay(1000 / portTICK_PERIOD_MS);
|
||||||
|
}
|
||||||
|
|
||||||
printf("Restarting now.\n");
|
printf("Restarting now.\n");
|
||||||
fflush(stdout);
|
fflush(stdout);
|
||||||
|
|||||||
@ -177,7 +177,7 @@
|
|||||||
* @brief shell默认用户密码
|
* @brief shell默认用户密码
|
||||||
* 若默认用户不需要密码,设为""
|
* 若默认用户不需要密码,设为""
|
||||||
*/
|
*/
|
||||||
#define SHELL_DEFAULT_USER_PASSWORD "passwd"
|
#define SHELL_DEFAULT_USER_PASSWORD ""
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @brief shell自动锁定超时
|
* @brief shell自动锁定超时
|
||||||
|
|||||||
@ -51,6 +51,7 @@ unsigned short userShellWrite(char *data, unsigned short len)
|
|||||||
signed char userShellRead(char *data, unsigned short len)
|
signed char userShellRead(char *data, unsigned short len)
|
||||||
{
|
{
|
||||||
// return uart_read_bytes(SHELL_UART, (uint8_t *)data, len, portMAX_DELAY);
|
// return uart_read_bytes(SHELL_UART, (uint8_t *)data, len, portMAX_DELAY);
|
||||||
|
vTaskDelay(10);
|
||||||
signed char ret = 0;
|
signed char ret = 0;
|
||||||
ret = cdc_usb_read_bytes(data, len);
|
ret = cdc_usb_read_bytes(data, len);
|
||||||
// cdc_printf("read need : %d, get %d\r\n", len, ret);
|
// cdc_printf("read need : %d, get %d\r\n", len, ret);
|
||||||
@ -64,18 +65,18 @@ signed char userShellRead(char *data, unsigned short len)
|
|||||||
*/
|
*/
|
||||||
void userShellInit(void)
|
void userShellInit(void)
|
||||||
{
|
{
|
||||||
uart_config_t uartConfig = {
|
// uart_config_t uartConfig = {
|
||||||
.baud_rate = 115200,
|
// .baud_rate = 115200,
|
||||||
.data_bits = UART_DATA_8_BITS,
|
// .data_bits = UART_DATA_8_BITS,
|
||||||
.parity = UART_PARITY_DISABLE,
|
// .parity = UART_PARITY_DISABLE,
|
||||||
.stop_bits = UART_STOP_BITS_1,
|
// .stop_bits = UART_STOP_BITS_1,
|
||||||
.flow_ctrl = UART_HW_FLOWCTRL_DISABLE
|
// .flow_ctrl = UART_HW_FLOWCTRL_DISABLE
|
||||||
};
|
// };
|
||||||
uart_param_config(SHELL_UART, &uartConfig);
|
// uart_param_config(SHELL_UART, &uartConfig);
|
||||||
uart_driver_install(SHELL_UART, 256 * 2, 0, 0, NULL, 0);
|
// uart_driver_install(SHELL_UART, 256 * 2, 0, 0, NULL, 0);
|
||||||
shell.write = userShellWrite;
|
shell.write = userShellWrite;
|
||||||
shell.read = userShellRead;
|
shell.read = userShellRead;
|
||||||
shellInit(&shell, shellBuffer, 512);
|
shellInit(&shell, shellBuffer, 512);
|
||||||
|
|
||||||
xTaskCreate(shellTask, "shell", 2048, &shell, 10, NULL);
|
xTaskCreate(shellTask, "shell", 2048, &shell, 8, NULL);
|
||||||
}
|
}
|
||||||
|
|||||||
@ -135,7 +135,7 @@ void usbd_cdc_acm_out(uint8_t ep)
|
|||||||
|
|
||||||
void usbd_cdc_acm_in(uint8_t ep)
|
void usbd_cdc_acm_in(uint8_t ep)
|
||||||
{
|
{
|
||||||
USB_LOG_RAW("in\r\n");
|
// USB_LOG_RAW("in\r\n");
|
||||||
}
|
}
|
||||||
|
|
||||||
/*!< endpoint call back */
|
/*!< endpoint call back */
|
||||||
|
|||||||
597
sdkconfig.old
597
sdkconfig.old
File diff suppressed because it is too large
Load Diff
Loading…
Reference in New Issue
Block a user