// Execute the command in the command buffer void shell_cmd_execute(void) { unsigned char i = 0, para_cnt = 0, err = 0; while ((para_cnt < SHELL_PARA_CNT_MAX) && (shell_para_ptr[para_cnt]) && (*shell_para_ptr[para_cnt])) { para_cnt++; } // Move old saved commands to higher array indices for (i = SHELL_MAX_LASTCOMMANDS - 1; i > 0; --i) { strcpy((char*)shell_lastcmd[i], (char*)shell_lastcmd[i - 1]); } // Save current command strcpy((char*)shell_lastcmd[0], (char*)shell_buf); for (i = 0; i < para_cnt; i++) { strcat((char*)shell_lastcmd[0], " "); strcat((char*)shell_lastcmd[0], shell_para_ptr[i]); } shell_lastcmd_ptr = 0; while (0 != (shell_cmd_set[i].name)) { if (!strcmp((char*) shell_buf, shell_cmd_set[i].name)) { dbgu_print_ascii("\r\n"); err = shell_cmd_set[i].do_cmd(shell_para_ptr, para_cnt); if (err != 0) { dbgu_print_ascii("\r\n"); dbgu_printf("Error %d!\r\n", err); } shell_flush_buf(); shell_cmd_prompt(); return; } i++; } dbgu_printf("\r\nUnknown Command\r\n"); shell_flush_buf(); shell_cmd_prompt(); }
// help command implementation int shell_cmd_help(char * args[], char num_args) { int i = 0; dbgu_printf("\r\nCOMMAND SHELL HELP\n\n\rCommand list\r\n"); while (shell_cmd_set[i].name) { dbgu_printf(shell_cmd_set[i].name); dbgu_printf("\t"); dbgu_printf(shell_cmd_set[i].help); dbgu_print_ascii("\r\n"); i++; } return 0; }
/****************************************************************************** Send string trough dbgu port. Parameters: none Returns: none ******************************************************************************/ void HAL_SendDbguMessage(const char *buffer) { dbgu_print_ascii(buffer); }
// print the command shell prompt void shell_cmd_prompt() { dbgu_print_ascii("\r\n"); dbgu_printf(SHELL_PROMPT); }
/*----------------------------------------------------------------------------- * Function Name : dabt_handler * Object : Data Abort Handler *-----------------------------------------------------------------------------*/ void dabt_handler(void) { dbgu_print_ascii("-F- Data abort at "); dbgu_print_hex8(AT91C_BASE_MC->MC_AASR); dbgu_print_ascii("\n\r"); }
/*----------------------------------------------------------------------------- * Function Name : pabt_handler * Object : Prefetch Abort Handler *-----------------------------------------------------------------------------*/ void pabt_handler(void) { dbgu_print_ascii("-F- Prefetch abort at "); dbgu_print_hex8(AT91C_BASE_MC->MC_AASR); dbgu_print_ascii("\n\r"); }