分享一下我自己自定义的shell 指令:
/*
argc是参数的数目
argv存储每个参数的起始地址和内容
*/
void shell_reboot_cmd(char argc, char *argv)
{
if (0 == strcmp("reboot", &argv[argv[0]]))
{
shell_printf("MCU Reboot now!!\r\n");
MCU_SW_reset();
}
}
/**
* @brief iap command
*/
void shell_update_cmd(char argc, char *argv)
{
if (0 == strcmp("update", &argv[argv[0]]))
{
shell_printf("MCU Ready to OTA!!\r\n");
UsrCMD.lte_update_cmd = true;
}
}
void shell_erase_cmd(char argc, char *argv)
{
if (0 == strcmp("erase", &argv[argv[0]]))
{
if (argc > 1)
{
if (0 == strcmp("disk0", &argv[argv[1]]))
{
shell_printf("Erase (Inner Flash) Fatfs...\r\n");
//f_mount(NULL, "0:", 0);
BSP_fmc_erase_bank1(); // whole bank1
}
if (0 == strcmp("disk1", &argv[argv[1]]))
{
shell_printf("Erase (SPI Flash) Fatfs...\r\n");
//f_mount(NULL, "1:", 0);
spi_flash_bulk_erase(); // whole chip
}
}
}
}
void shell_list_files_cmd(char argc, char *argv)
{
if (0 == strcmp("list", &argv[argv[0]]))
{
shell_printf(">List all files in disk1...\r\n");
UsrCMD.list_file = true;
}
}
void shell_cat_file_cmd(char argc, char *argv)
{
if (0 == strcmp("cat", &argv[argv[0]]))
{
if (argc > 1)
{
strcpy(UsrCMD.file_name, &argv[argv[1]]);
shell_printf(">File : %s\r\n",UsrCMD.file_name);
UsrCMD.cat_file = true;
}
}
}
void shell_date_cmd(char argc, char *argv)
{
if (0 == strcmp("date", &argv[argv[0]]))
{
EasyTime_Get_LocalTime_to_console(MyTime.TimeZone);
}
}
|